blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
6c824af2bd23f55c2e4ba6f3dc343b45eadbe03c
fe42e7923075495577ac26b70f7b5b82662cf5c4
/accela/demo/src/main/java/com/accela/demo/service/PersonServiceImpl.java
7f5f8787c216299ca2a8c922dfc466c8d1de5ffa
[]
no_license
CloudNine86/accelaAssessment
68d51d6903bbc138abb9798b7168add56f424a70
f4d0897a62508846dcaa0495ad09ed40a1a682a8
refs/heads/main
2023-02-12T12:09:10.208989
2021-01-13T01:16:22
2021-01-13T01:16:22
329,151,910
0
0
null
null
null
null
UTF-8
Java
false
false
2,158
java
package com.accela.demo.service; import com.accela.demo.entity.Address; import com.accela.demo.entity.Person; import com.accela.demo.repository.PersonRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; @Service public class PersonServiceImpl implements PersonService { @Autowired AddressService addressService; public final PersonRepository personRepository; public PersonServiceImpl(PersonRepository personRepository) { this.personRepository = personRepository; } @Override public List<Person> listPersons() { List<Person> personSet = new ArrayList<>(); personRepository.findAll().iterator().forEachRemaining(personSet::add); return personSet; } @Override public Long countPersons() { return personRepository.count(); } @Override public Person addPerson(String firstName, String lastName) { Person person = new Person(); person.setFirstName(firstName); person.setLastName(lastName); Person savedPerson = personRepository.save(person); return savedPerson; } @Override public Person editPerson(Long id, String firstName, String lastName) { Person person; try { person = personRepository.findById(id).get(); } catch (NoSuchElementException ex) { return null; } person.setFirstName(firstName); person.setLastName(lastName); return personRepository.save(person); } @Override public void deletePerson(Long id) { personRepository.deleteById(id); } @Override public Person addAddress(Long personId, String street, String city, String state, String postalCode) throws NoSuchElementException { Person person = personRepository.findById(personId).get(); Address address = addressService.addAddress(street, city, state, postalCode); person.setAddress(address); return personRepository.save(person); } }
79e99f88b86b93832e87ab5bc4d17328dd7de83d
6111b9f7aa6f3bcbf296b174beea521f5f0d53af
/src/com/Project/testProject/Item.java
ead64e62fd54cb442f136aa74c8eeb3bc58ae438
[]
no_license
ashishgenext/MyGame
54883f3fdd1522278e8cdde248643a4d682163f7
f79e9906c38826bbf4160173f0227681fc099afb
refs/heads/master
2020-12-24T16:08:12.091917
2015-04-21T12:53:20
2015-04-21T12:53:20
33,073,168
0
0
null
null
null
null
UTF-8
Java
false
false
248
java
package com.Project.testProject; import android.graphics.Bitmap; public class Item { int ImageId; public Item(int ImageId) { super(); this.ImageId = ImageId ; } public int getBitmapImageId(){ return this.ImageId ; } }
4e6af57d612a292f7327827bc08f6b54b0bde312
5df875abfd7a1e0d90b2ad44699e823a9f3d793b
/CS331/hw5/part2/Driver.java
8b60929a83e500af6054c4be3547ad9fd148e9e9
[]
no_license
Snepsts/classwork
199824d977882541c8daed11d00e63a4b6c0c6f1
8e18a69acda43f08a0f901b3d28e93ab1b7c9477
refs/heads/master
2021-09-09T13:52:46.943126
2018-03-16T18:32:47
2018-03-16T18:32:47
107,140,595
0
0
null
null
null
null
UTF-8
Java
false
false
2,305
java
import java.util.Scanner; public class Driver { public static void main(String[] args) { Scanner s = new Scanner(System.in); //default constructors CreditCardPayment ccp = new CreditCardPayment(); CashPayment cp = new CashPayment(); //test accessors for creditcard System.out.println("Name: " + ccp.getName()); System.out.println("Card Number: " + Long.toString(ccp.getNumber())); System.out.println("Expiration Date: " + Integer.toString(ccp.getMonth()) + "/" + Integer.toString(ccp.getYear())); System.out.println("Payment amount: " + Double.toString(ccp.getPayment())); //test mutator for payment System.out.print("Please enter the amount you'd like to pay: "); ccp.setPayment(s.nextDouble()); System.out.print("Please enter the amount you'd like to pay (in cash): "); cp.setPayment(s.nextDouble()); //test accessor for payment System.out.println("The amount you entered was: " + cp.getPayment()); //test paymentDetails cp.paymentDetails(); System.out.print("Please enter the amount you'd like to pay (in cash): "); CashPayment cp2 = new CashPayment(s.nextDouble()); //test explicit cp2.paymentDetails(); //test mutators for creditcard System.out.print("Please enter the expiration month: "); ccp.setMonth(s.nextInt()); System.out.print("Please enter the expiration year: "); ccp.setYear(s.nextInt()); System.out.print("Please enter the card holder's name: "); s.nextLine(); //consume current \n ccp.setName(s.nextLine()); System.out.print("Please enter the card number: "); ccp.setNumber(s.nextLong()); //test paymentDetails, getNumberFormat and getExpire ccp.paymentDetails(); int month, year; long number; double payment; System.out.print("Please enter the payment amount: "); payment = s.nextDouble(); System.out.print("Please enter the card number: "); number = s.nextLong(); System.out.print("Please enter the expiration month: "); month = s.nextInt(); System.out.print("Please enter the expiration year: "); year = s.nextInt(); System.out.print("Please enter the cardholder name: "); s.nextLine(); //consume current \n String name = s.nextLine(); CreditCardPayment ccp2 = new CreditCardPayment(month, year, name, number); ccp2.setPayment(payment); ccp2.paymentDetails(); } }
42d5d1559eeb43b8c77d9aeeb0f7a719e137facf
3096be674e7782de3f0e3525baaade7027283b4d
/WCcomposite.java
ac6a2dbc16c2e037037fde9468ac85778d0710b4
[]
no_license
ZeinaKittaneh/SOEN341-ProjectA
22804793367916bc40986f86e976b46808b85354
1c58d3a04e246cef091f51808a17369d427c43d3
refs/heads/master
2023-01-02T06:46:37.729290
2020-10-12T20:30:15
2020-10-12T20:30:15
303,504,611
0
0
null
null
null
null
UTF-8
Java
false
false
1,392
java
import java.io.IOException; //This class is used for executing the counting process for the wc counter public class WCcomposite extends Counter{ int totalLines = 0, totalWords = 0, totalChars = 0; //used to save results of different counting processes boolean inWord = false; public void countingAll(String [] args, Administrator admin, CounterFactory cf) throws IOException { for(int j = 0; j < args.length; j++) { ICounter [] counters = cf.createCounter(args[j]); // create counters for each file counters[0].readFile(args[j]); // Execute the word,line,character count. int c; int nChars = 0, nLines = 0, nWords = 0; inWord = false; while((c = srcStream.read()) != EOF ) { nChars = counters[0].process(c, nChars); nWords = counters[1].process(c, nWords, inWord); inWord = WordCounter.inWord; nLines = counters[2].process(c, nLines); } // Close and flush the opened file. closeSrcStream(srcStream); // Print the result of the source file. System.out.println(srcFilename + " : " + nLines +" lines, " + nWords + " words, " + nChars + " chars\n"); totalLines += nLines; totalWords += nWords; totalChars += nChars; } // Print the total if more than one source file. if (args.length > 1) { System.out.println("**Total:" + totalLines + " lines, " + totalWords + " words, " + totalChars + " chars\n"); } } }
2acbfac90e074419eee0b1cc9d365e09ad9ad230
4d5efe7b0788c29f0b11bf06e6b1e3f26ad9f7ee
/testing-java-junit5/src/main/java/diegogarciaviana/unit5/fauxspring/Model.java
2ab6542e2f28a1f5e9cdbfc816acec6bda7b7f6f
[ "Apache-2.0" ]
permissive
DGV1995/Testing-Spring-Boot
ecedafcf54aee4d0b7797be6679320268dfd305f
86f6a9a18585ffcff7d266eff79b50bf6c76a67a
refs/heads/master
2020-06-06T10:08:31.234686
2019-07-11T09:26:21
2019-07-11T09:26:21
192,709,826
0
0
null
null
null
null
UTF-8
Java
false
false
151
java
package diegogarciaviana.unit5.fauxspring; public interface Model { void addAttribute(String key, Object o); void addAttribute(Object o); }
406e6e296d1c71f4bb65c9a2ee57a90c1db3c05f
cb422b1b77c3c24d4d35c1ca5caf92805392817f
/ormfinal2/src/main/java/com/nikhil/truyum/service/UserService.java
c9b4b7c53641a86194ac623be1d0dbdf25a7f213
[]
no_license
Nikhi69/alldemo
b0845abda14a6892d6b45d3043bb67424afb7d06
f0a16eedc0e20a095a0a72475bf079124be00551
refs/heads/main
2023-04-02T23:15:39.966785
2021-03-26T04:02:53
2021-03-26T04:02:53
351,297,323
0
0
null
null
null
null
UTF-8
Java
false
false
559
java
package com.nikhil.truyum.service; import javax.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.nikhil.truyum.entity.User; import com.nikhil.truyum.repository.UserRepository; @Service public class UserService { @Autowired UserRepository userRepository; @Transactional public User get(int id) { return userRepository.findById(id).get(); } @Transactional public void save(User user) { userRepository.save(user); } }
e93cefff1eeda02a726295781533fdba0a42796e
b5ff720cdc1868ddb36b2a780ebe348de26af623
/src/z3/Z3Function.java
525ebfc23b7cd9bad5134fcd11375d30d6b9a194
[]
no_license
terry2012/horndroid
981e805a2b4f7f993388c6d95d4fc45e2167f954
6785c2c2cf401d9a64368dc0e56526b6f5cffe33
refs/heads/master
2021-01-24T20:03:15.117374
2016-03-29T14:24:25
2016-03-29T14:24:25
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,379
java
package z3; import com.microsoft.z3.*; /** * Created by rtongchenchitt on 10/15/2015. */ public class Z3Function { // Function private final FuncDecl h, hi, i, s; public Z3Function(Context ctx, int bvSize) throws Z3Exception { // out.println("(declare-rel H (bv64 bv64 bv64 bv64 Bool Bool) interval_relation bound_relation)"); // out.println("(declare-rel HI (bv64 bv64 bv64 Bool Bool) interval_relation bound_relation)"); // out.println("(declare-rel I (bv64 bv64 bv64 Bool Bool) interval_relation bound_relation)"); // out.println("(declare-rel S (Int Int bv64 Bool Bool) interval_relation bound_relation)"); BitVecSort bv64 = ctx.mkBitVecSort(bvSize); BoolSort bool = ctx.mkBoolSort(); IntSort integer = ctx.mkIntSort(); this.h = ctx.mkFuncDecl("H", new Sort[]{bv64, bv64, bv64, bv64, bool, bool}, bool); this.hi = ctx.mkFuncDecl("HI", new Sort[]{bv64, bv64, bv64, bool, bool}, bool); this.i = ctx.mkFuncDecl("I", new Sort[]{bv64, bv64, bv64, bool, bool}, bool); this.s = ctx.mkFuncDecl("S", new Sort[]{integer, integer, bv64, bool, bool}, bool); } public FuncDecl getH() { return h; } public FuncDecl getHi() { return hi; } public FuncDecl getI() { return i; } public FuncDecl getS() { return s; } }
0370ffc0084cf7933978cc3927884a3c26a82a10
c37cc036ea35489c574f0815e3735815a5daeca8
/WEB-INF/src/net/joycool/wap/action/job/fish/PullEventBean.java
4ac1abdd466163a25c26997a2c2c0e5204d4c853
[]
no_license
liuyang0923/joycool
ac032b616d65ecc54fae8c08ae8e6f3e9ce139d3
e7fcd943d536efe34f2c77b91dddf20844e7cab9
refs/heads/master
2020-06-12T17:14:31.104162
2016-12-09T07:15:40
2016-12-09T07:15:40
75,793,605
0
0
null
null
null
null
UTF-8
Java
false
false
1,572
java
package net.joycool.wap.action.job.fish; /** * @author bomb * */ public class PullEventBean { int id; int areaId; // 出现区域 String desc; // 自己看的描述 String log; // 给别人看的描述 int money; // 乐币奖励 int exp; // 经验奖励 String image; /** * @return Returns the image. */ public String getImage() { return image; } /** * @param image The image to set. */ public void setImage(String image) { this.image = image; } /** * @return Returns the areaId. */ public int getAreaId() { return areaId; } /** * @param areaId The areaId to set. */ public void setAreaId(int areaId) { this.areaId = areaId; } /** * @return Returns the desc. */ public String getDesc() { return desc; } /** * @param desc The desc to set. */ public void setDesc(String desc) { this.desc = desc; } /** * @return Returns the exp. */ public int getExp() { return exp; } /** * @param exp The exp to set. */ public void setExp(int exp) { this.exp = exp; } /** * @return Returns the id. */ public int getId() { return id; } /** * @param id The id to set. */ public void setId(int id) { this.id = id; } /** * @return Returns the log. */ public String getLog() { return log; } /** * @param log The log to set. */ public void setLog(String log) { this.log = log; } /** * @return Returns the point. */ public int getMoney() { return money; } /** * @param point The point to set. */ public void setMoney(int money) { this.money = money; } }
ef42ed31bea60a75d403851ea29d5f4fb6779cca
e2f8b46b4f004aa14f43f73dcfad9977b0a7a274
/lesson3/src/main/java/lesson3/Client.java
26fe0a5b55a121feb110a72984510938fe222147
[]
no_license
AntJava/SpringOne
da1fb23eff4543015256b846ef9393d7e0979c68
1828696a7ee4f0f53c9544f0db70c75fe54a47ec
refs/heads/master
2023-01-18T23:34:55.179254
2020-11-17T15:07:04
2020-11-17T15:07:04
307,719,890
0
0
null
2020-11-19T15:43:16
2020-10-27T14:05:57
Java
UTF-8
Java
false
false
765
java
package lesson3; import javax.persistence.*; import java.util.List; @Entity @Table(name = "client") public class Client { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "client") private String client; @OneToMany(mappedBy = "client") private List<Sell> sells; public Client() { } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getClient() { return client; } public void setClient(String client) { this.client = client; } public List<Sell> getSells() { return sells; } public void setSells(List<Sell> sells) { this.sells = sells; } }
ea934e24bf63d94a4c7e2df5c0d8d09caa5ea24d
a4ffdcfe848272d9381a4e33b8142c9c3fa33b5b
/src/main/java/cashpiles/model/RoutineCategory.java
dc7103f0a8359f4a9d11758d46acce96d4c6eec6
[]
no_license
upstreammuse/cashpiles
bffdb3223f7345632563cd21d444aa2750ed3e83
43c094ad4a7dbc68ad2f38d94fc6bce1f9018a5d
refs/heads/master
2023-04-13T07:33:43.782032
2022-12-17T22:53:00
2022-12-17T22:53:00
59,172,268
0
0
null
null
null
null
UTF-8
Java
false
false
4,727
java
package cashpiles.model; import java.time.Period; import java.util.ArrayList; import java.util.List; import cashpiles.currency.Amount; import cashpiles.ledger.CategoryTransactionEntry; import cashpiles.ledger.RoutineBudgetEntry; import cashpiles.time.DateRange; //this is an immutable data class /** * We don't yet have a well defined method for routine to work, so here's what * we'll go with for now. First, the category will allocate (during the next * period generation) enough to equal the last 12 months of flow as applied to * the duration of the current period. Then, if the balance of the category is * below a 6 month average (based on the last 12 months), it will allocate an * additional amount to bring it up to the 6 month threshold. This is to * accomplish a few things: * * 1. Make sure we allocate based on a rolling average of past performance * * 2. Make sure we always have enough to cover the next 6 months of average * spending * * There are issues with this, because the point of covering the next 6 months * is to cover "cost of living" in the absence of additional income during that * time. However, the program doesn't fill up routine categories based on income * events, so there's no way to tie the routine allocation to getting money. It * may be that we need to connect routine allocation to an income event, but * that gets awkward because we only want to do the allocation for the first * income event in a budget period, assuming that income is sufficient to fund * the routine categories. * * Another possible approach is to only fund routine categories for "now", i.e. * the current budget period, based on average past performance, but don't try * to also allocate the 6 month lookahead. Instead, the program could keep a * global sum of what the total 6 month (or some other duration) lookahead is, * and show that to the user. That would allow a new user to start with a small * lookahead as low as 0 days, and encourage the user to increase the lookahead * amount until it's at least 180 days or so. * * However, all routine categories would then fall under a single lookahead * number, making it difficult to understand which categories are contributing * the most to the lookahead amount. It is almost certain that users will have * multiple "tiers" of routine expenses, and would be willing and able to cut * off some of those expenses during an actual loss of income. */ class RoutineCategory extends Category { private List<CategoryTransactionEntry> oldTransactions = new ArrayList<>(); RoutineCategory(RoutineBudgetEntry entry) { super(entry.owner()); } @Override public RoutineCategory clone() { var retval = (RoutineCategory) super.clone(); retval.oldTransactions = new ArrayList<>(oldTransactions); return retval; } @Override RoutineCategory next(DateRange dates) { var retval = (RoutineCategory) super.next(dates); // keep any old transactions that are within a year of the new period start date var oldTransactions = new ArrayList<CategoryTransactionEntry>(); for (var xact : transactions) { if (xact.date().plus(Period.ofYears(1)).compareTo(dates.startDate()) >= 0) { oldTransactions.add(xact); } } for (var xact : this.oldTransactions) { if (xact.date().plus(Period.ofYears(1)).compareTo(dates.startDate()) >= 0) { oldTransactions.add(xact); } } retval.oldTransactions = oldTransactions; // get the total of the old transactions var yearTotal = new Amount(); for (var xact : retval.oldTransactions) { yearTotal = yearTotal.add(xact.amount()); } // distribute the yearly total over a single day to determine the daily average var dayAverage = yearTotal.distributeAndAdd( new DateRange(dates.startDate().minus(Period.ofYears(1)), dates.startDate()), new DateRange(dates.startDate(), dates.startDate())); // allocate based on the new period duration // FIXME make sure other category allocations don't add to existing allocation, // since it doesn't get reset during a clone of a category retval.allocation = dayAverage.times(dates.numberOfDays()).negate(); // If the balance is below the 6 month average, pull it up to be at least the 6 // month average. This lets the balance get larger than the 6 month average, for // routine expenses that happen less frequently (like annual bills), but ensures // that at least the next 6 months are covered. var sixMonthTotal = dayAverage.times(180); var shortfall = retval.balance().add(sixMonthTotal); if (shortfall.isNegative()) { retval.allocation = retval.allocation.add(shortfall.negate()); } return retval; } @Override public String type() { return "Routine"; } }
58def00f12b276a5387d76c2f56cd36a5c804b9c
07abfb3dd9c4b2ef9fa973f3e4175901ffa4c82c
/TaxiSystem/src/ui/MainStart.java
a38d4ded7285d5060749f79e3ae7baf72a9118c2
[]
no_license
shraddhakannav/MSProject
60d80e561cbe5c48eda1875fcf6222747120d6a6
fd3c613212463e2aeb1106aa8c60031c7c30bc89
refs/heads/master
2021-01-18T18:31:55.856685
2015-08-08T11:08:54
2015-08-08T11:08:54
39,932,926
0
3
null
null
null
null
UTF-8
Java
false
false
374
java
package ui; import java.io.BufferedReader; import java.io.InputStreamReader; public class MainStart { static BufferedReader br = null; public static void main(String[] args) { MainMenu mainMenu = new MainMenu(); } public static BufferedReader getReader() { if (br == null) { br = new BufferedReader(new InputStreamReader(System.in)); } return br; } }
99a6b92d67668a3739f4cddf2d99fc8bd7f29915
de4259b6760d5462602eab48d6696876b728e24e
/taotao-portal/src/test/java/com/taotao/freemarker/FreeMarkerTest.java
045fc9ba649374740aa4f2f8f8a41a79fc07d005
[]
no_license
LylYorick/taotao
15fbf71a0ab28b9d85ea3839d4c663085ee75259
d63c08ca3817be8dae5c97608b1af1f6938ce244
refs/heads/master
2021-09-15T02:14:14.600215
2018-05-24T07:17:24
2018-05-24T07:17:24
103,926,679
0
0
null
null
null
null
UTF-8
Java
false
false
2,934
java
package com.taotao.freemarker; import java.io.File; import java.io.FileWriter; import java.io.Writer; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Test; import freemarker.template.Configuration; import freemarker.template.Template; public class FreeMarkerTest { public class Person{ private int id; private String name; private String address; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public Person(int id, String name, String address) { super(); this.id = id; this.name = name; this.address = address; } } @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testFreeMarker() throws Exception{ // 第一步:把freemarker的jar包添加到工程中 // 第二步:freemarker的运行不依赖web容器,可以在java工程中运行。创建一个测试方法进行测试。 // 第三步:创建一个Configuration对象 Configuration config = new Configuration(Configuration.getVersion()); // 第四步:告诉config对象模板文件存放的路径。 config.setDirectoryForTemplateLoading(new File("E:\\learningsoft\\eclipseWorkspaces\\personalWorkspace\\taotao\\taotao-portal\\src\\main\\webapp\\WEB-INF\\ftl")); // 第五步:设置config的默认字符集。一般是utf-8 config.setDefaultEncoding("utf-8"); // 第六步:从config对象中获得模板对象。需要制定一个模板文件的名字。 Template template = config.getTemplate("second.ftl"); // 第七步:创建模板需要的数据集。可以是一个map对象也可以是一个pojo,把模板需要的数据都放入数据集。 Map map = new HashMap<String,Object>(); map.put("hello", "hello freemarker"); // map.put("title", "题目"); List list = new ArrayList<Person>(); list.add(new Person(1, "张三", "深圳")); list.add(new Person(2, "张2", "深圳")); list.add(new Person(3, "张3", "深圳")); list.add(new Person(4, "张4", "深圳")); list.add(new Person(5, "张5", "深圳")); map.put("persons", list); map.put("student", new Person(1, "张三", "深圳")); map.put("currentDate", new Date()); // 第八步:创建一个Writer对象,指定生成的文件保存的路径及文件名。 Writer out = new FileWriter(new File("D:\\test\\hello.html")); // 第九步:调用模板对象的process方法生成静态文件。需要两个参数数据集和writer对象。 template.process(map, out); // 第十步:关闭writer对象。 out.flush(); out.close(); } }
1ce6f5c10552012f18a5cf818246e4dfd7725004
bbef8d4d03e3c22ca234db458ceb23f29b270329
/A1/txjg1/src/main/java/javabean/FuWuYuan.java
0b08a55df0dbb902ba6231d7484e7a3a22b452b4
[]
no_license
Acescen/RJTXJG_A
e32e472232ce05f683afa8b105cb87e9e0164860
e153fea7ea9f026e60aed311459efce9b659212c
refs/heads/master
2022-06-26T21:16:19.967473
2019-12-28T03:35:42
2019-12-28T03:36:26
230,236,272
0
0
null
2022-06-21T02:31:39
2019-12-26T09:35:31
Java
UTF-8
Java
false
false
933
java
package javabean; import org.apache.commons.lang3.StringUtils; /** * @Author: jurui * @Email: [email protected] * @ProjectName: txjg1 * @Package: javabean * @Description: * @Date: Created in 15:03 2019-12-27 */ public class FuWuYuan { public static String msg; public static int count = 0; public String chaoqiezi() { System.out.println("count="+count); if ((StringUtils.isBlank(msg)||"服务员正在服务".equals(msg)) && count < 3) { msg = "服务员正在服务"; count++; } else { Chushi chushi = new Chushi(); Chaoqiezi chaoqiezi = chushi.cookEggplant(); if (chaoqiezi != null) { msg = "上了 " + (++count-3) + " 道炒茄子菜品"; } else { msg = "不好意思,炒茄子卖完了!"; } } System.out.println(msg); return msg; } }
6a1c75a1e60404646779dbbc2a73bc8b3a48a3e5
34ce6176d3c0e071558d7c8e749959ae4e4be453
/HelpDesk/.svn/pristine/43/43e507ac817abe17205590b86fd8e95eec4f6916.svn-base
8a504b7c9f2a2dfa182099fbda9b9154c1a473a1
[]
no_license
yeshwanth-Konakanchi/ProjectBoot
f467911815c437311ee1c2156467e9c155479c5c
c28e0d986820ed2438ff1f05477e6e86babfa3ff
refs/heads/master
2020-03-08T04:42:12.781257
2018-04-03T15:46:13
2018-04-03T15:46:13
127,929,403
0
0
null
null
null
null
UTF-8
Java
false
false
2,534
package com.crmindz.helpdesk.jUnitTests; import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import com.crmindz.helpdesk.DAO.HelpDeskDAO; import com.crmindz.helpdesk.entity.User; import com.crmindz.helpdesk.service.RegistrationService; import junit.framework.Assert; /** * @author Yeshwanth Konakanchi * * RegistrationServiceTest class implements the methods to perform unit * tests on RegistrationService Class */ @RunWith(MockitoJUnitRunner.class) public class RegistrationServiceTest { @InjectMocks private RegistrationService registrationService; @Mock private HelpDeskDAO helpDeskDao; /** * registerUserTest method tests the registerTest method unit in the * RegistrationService class * */ @Test public void registerUserTest() { String result = "registration success"; when(helpDeskDao.registerUser(Mockito.any(User.class))).thenReturn(result); User user = new User(); user.setFirstName("linga"); user.setEmailId("[email protected]"); Assert.assertEquals("registration success", registrationService.registerUser(user)); } /** * getStatesInfoTest method tests the getStatesInfo method unit in the * RegistrationService class * */ @Test public void getStatesInfoTest() { List<Map<String, String>> statesInfo = new ArrayList<Map<String, String>>(); Map<String, String> stateAndValue = new HashMap<String, String>(); stateAndValue.put("ColName", "Missouri"); stateAndValue.put("colValue", "MO"); statesInfo.add(stateAndValue); when(helpDeskDao.getStatesInfo()).thenReturn(statesInfo); Assert.assertEquals(statesInfo, registrationService.getStatesInfo()); } /** * getUserTypeInfoTest method tests the getUserTypeInfo method in unit in * the RegistrationService class * */ @Test public void getUserTypeInfoTest() { List<Map<String, String>> userTypeInfo = new ArrayList<Map<String, String>>(); Map<String, String> userTypeAndValue = new HashMap<String, String>(); userTypeAndValue.put("ColName", "student"); userTypeAndValue.put("ColValue", "S"); userTypeInfo.add(userTypeAndValue); when(helpDeskDao.getUserTypeInfo()).thenReturn(userTypeInfo); Assert.assertEquals(userTypeInfo, registrationService.getUserTypeInfo()); } }
4969fa6edf3316781d41639e5c2301c4dab49056
165893beb548c15053621423a657682c98684587
/b2c-rest/src/main/java/com/pursuit/rest/service/impl/ItemDescServiceImpl.java
9f6a5993046e71427af8dc6d18c74837ef929db6
[]
no_license
lza1997/b2c-1
00031e92586cfc4495fa3eb247fe91422c3ac812
eaa309faaaf6a615909efc6cc6899f19b2f89ed4
refs/heads/master
2021-01-12T15:09:17.220915
2016-10-20T11:58:13
2016-10-20T11:58:13
71,715,760
1
0
null
2016-10-23T16:41:56
2016-10-23T16:41:56
null
UTF-8
Java
false
false
2,173
java
package com.pursuit.rest.service.impl; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.pursuit.common.util.JsonUtils; import com.pursuit.mapper.TbItemDescMapper; import com.pursuit.pojo.TbItemDesc; import com.pursuit.pojo.TbItemDescExample; import com.pursuit.pojo.TbItemDescExample.Criteria; import com.pursuit.rest.component.JedisClient; import com.pursuit.rest.service.ItemDescService; @Service public class ItemDescServiceImpl implements ItemDescService { Logger logger = Logger.getLogger(ItemDescServiceImpl.class); @Value("${REDIS_CONTENT}") private String REDIS_CONTENT; @Value("${REST_ITEM_DESC}") private String REST_ITEM_DESC; @Value("${ITEM_EXPIRE_SECOND}") private Integer ITEM_EXPIRE_SECOND; @Autowired private JedisClient jedisClient; @Autowired private TbItemDescMapper itemDescMapper; @Override public TbItemDesc getItemDescById(Long itemId) { try { String json = jedisClient.get(REDIS_CONTENT+":"+REST_ITEM_DESC+":"+itemId); if(StringUtils.isNotBlank(json)){ return JsonUtils.jsonToPojo(json, TbItemDesc.class); } } catch (Exception e) { logger.error("读取缓存信息出错,请检测缓存配置 itemId:"+itemId); e.printStackTrace(); } TbItemDescExample example = new TbItemDescExample(); Criteria criteria = example.createCriteria(); criteria.andItemIdEqualTo(itemId); List<TbItemDesc> list = itemDescMapper.selectByExampleWithBLOBs(example); if(null!=list&&list.size()>0){ try { jedisClient.set(REDIS_CONTENT+":"+REST_ITEM_DESC+":"+itemId, JsonUtils.objectToJson(list.get(0))); //设置key的过期时间 jedisClient.expire(REDIS_CONTENT+":"+REST_ITEM_DESC+":"+itemId, ITEM_EXPIRE_SECOND); } catch (Exception e) { logger.error("存储缓存信息出错,请检测缓存配置 itemId:"+itemId); e.printStackTrace(); } return list.get(0); } return null; } }
9240408e26ab15f81e30988dd3b7e983b4e8d2f6
704507754a9e7f300dfab163e97cd976b677661b
/src/javax/naming/SizeLimitExceededException.java
f0f734228819551db4a21f863007ddef2e9c82aa
[]
no_license
ossaw/jdk
60e7ca5e9f64541d07933af25c332e806e914d2a
b9d61d6ade341b4340afb535b499c09a8be0cfc8
refs/heads/master
2020-03-27T02:23:14.010857
2019-08-07T06:32:34
2019-08-07T06:32:34
145,785,700
0
0
null
null
null
null
UTF-8
Java
false
false
1,385
java
/* * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.naming; import javax.naming.Name; /** * This exception is thrown when a method produces a result that exceeds a * size-related limit. This can happen, for example, if the result contains more * objects than the user requested, or when the size of the result exceeds some * implementation-specific limit. * <p> * Synchronization and serialization issues that apply to NamingException apply * directly here. * * @author Rosanna Lee * @author Scott Seligman * @since 1.3 */ public class SizeLimitExceededException extends LimitExceededException { /** * Constructs a new instance of SizeLimitExceededException. All fields * default to null. */ public SizeLimitExceededException() { super(); } /** * Constructs a new instance of SizeLimitExceededException using an * explanation. All other fields default to null. * * @param explanation * Possibly null detail about this exception. */ public SizeLimitExceededException(String explanation) { super(explanation); } /** * Use serialVersionUID from JNDI 1.1.1 for interoperability */ private static final long serialVersionUID = 7129289564879168579L; }
3a641b7b32410d80e49828cf2d3291bffb011b37
0d193d52daf66b433eabecd7d790c558fd62d650
/net.sourceforge.flora.eclipse.console/src/net/sourceforge/flora/eclipse/console/ConsoleColorManager.java
7bbba86ace14a898e7b1efea202d0b2f3b6dadd5
[]
no_license
vital-ai/flora2-visualizer
2a8029366c7897519d5e5a63a27d4354176b6111
902b86f296766ed77a0a8ede589a5721a943d56b
refs/heads/main
2023-07-25T22:11:15.157536
2021-09-09T15:50:20
2021-09-09T15:50:20
404,365,163
0
0
null
null
null
null
UTF-8
Java
false
false
1,982
java
/* File: FloraColorManager.java ** ** Author(s): Daniel Winkler ** Contact: [email protected] ** ** Copyright (C) 2007 Digital Enterprise Research Insitute (DERI) Innsbruck ** ** FLORA-2 Visualizer is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public License ** as published by the Free Software Foundation; either version 2 ** of the License, or (at your option) any later version. ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU Lesser General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA. */ package net.sourceforge.flora.eclipse.console; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; /** * @author Daniel Winkler * * A manager for colors needed for syntax highlighting */ public class ConsoleColorManager { protected static Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10); /** * disposes all colors * * @see Color#dispose() */ public void dispose() { Iterator<Color> e = fColorTable.values().iterator(); while (e.hasNext()) (e.next()).dispose(); } /** * Returns a {@link Color} for a {@link RGB} value * * @param rgb the <code>RGB</code> value * @return the color for the specified <code>RGB</code> value */ public static Color getColor(RGB rgb) { Color color = (Color) fColorTable.get(rgb); if (color == null) { color = new Color(Display.getCurrent(), rgb); fColorTable.put(rgb, color); } return color; } }
ba91e4394e25c1e7d7d2a6b2fc1d2a139e09c23c
970d2df7bffc00bd4b5aeab247b430cd03b7541c
/adk/src/main/java/com/kescoode/adk/net/volley/toolbox/RequestFuture.java
7adf0d75e9000512f9d62021a719cca5e0ad382e
[]
no_license
kesco/xmail
4754e30294c485f8cc4944b94381babee99fa109
260239e262f61b5079456df40437120a75958561
refs/heads/master
2020-05-30T16:52:22.635430
2015-04-23T09:11:22
2015-04-23T09:11:22
42,143,833
2
0
null
null
null
null
UTF-8
Java
false
false
4,119
java
/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.kescoode.adk.net.volley.toolbox; import com.kescoode.adk.net.volley.Request; import com.kescoode.adk.net.volley.Response; import com.kescoode.adk.net.volley.VolleyError; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /** * A Future that represents a Volley request. * * Used by providing as your response and error listeners. For example: * <pre> * RequestFuture&lt;JSONObject&gt; future = RequestFuture.newFuture(); * MyRequest request = new MyRequest(URL, future, future); * * // If you want to be able to cancel the request: * future.setRequest(requestQueue.add(request)); * * // Otherwise: * requestQueue.add(request); * * try { * JSONObject response = future.get(); * // do something with response * } catch (InterruptedException e) { * // handle the error * } catch (ExecutionException e) { * // handle the error * } * </pre> * * @param <T> The type of parsed response this future expects. */ public class RequestFuture<T> implements Future<T>, Response.Listener<T>, Response.ErrorListener { private Request<?> mRequest; private boolean mResultReceived = false; private T mResult; private VolleyError mException; public static <E> RequestFuture<E> newFuture() { return new RequestFuture<E>(); } private RequestFuture() {} public void setRequest(Request<?> request) { mRequest = request; } @Override public synchronized boolean cancel(boolean mayInterruptIfRunning) { if (mRequest == null) { return false; } if (!isDone()) { mRequest.cancel(); return true; } else { return false; } } @Override public T get() throws InterruptedException, ExecutionException { try { return doGet(null); } catch (TimeoutException e) { throw new AssertionError(e); } } @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return doGet(TimeUnit.MILLISECONDS.convert(timeout, unit)); } private synchronized T doGet(Long timeoutMs) throws InterruptedException, ExecutionException, TimeoutException { if (mException != null) { throw new ExecutionException(mException); } if (mResultReceived) { return mResult; } if (timeoutMs == null) { wait(0); } else if (timeoutMs > 0) { wait(timeoutMs); } if (mException != null) { throw new ExecutionException(mException); } if (!mResultReceived) { throw new TimeoutException(); } return mResult; } @Override public boolean isCancelled() { if (mRequest == null) { return false; } return mRequest.isCanceled(); } @Override public synchronized boolean isDone() { return mResultReceived || mException != null || isCancelled(); } @Override public synchronized void onResponse(T response) { mResultReceived = true; mResult = response; notifyAll(); } @Override public synchronized void onErrorResponse(VolleyError error) { mException = error; notifyAll(); } }
553e77464256d3c5b04bfe39b94c0419dbed9151
5a5f0f473a3994380b8f03a5500934990154ef0c
/ProvEnkel/src/provenkel/ProvEnkel.java
131432506789767817541acebaf944b62b9017cc
[]
no_license
rappos/Gymnasiet-Programmering-1
89b4af1b78a4749ad3ec7fb8c5ae3b6dc757abae
0ae705dab78775b319dd75eb5fb3f4455a2cb76e
refs/heads/master
2023-05-30T20:17:12.639608
2023-04-28T12:06:23
2023-04-28T12:06:23
232,209,584
0
0
null
null
null
null
UTF-8
Java
false
false
1,055
java
package provenkel; import java.util.Scanner; public class ProvEnkel { //Program som kollar längden på en input av lösenord, och godkänner om längre än 6 tecken public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Vi ska undersöka om ditt lösenord är godkänt."); System.out.print("Skriv ditt lösenord: "); String lösen = input.next(); //lösenordet i variabeln lösen int längd = lösen.length(); //dess längd i variabeln längd //Detta sker om längden är mindre än 6 if (längd < 6) { System.out.println("Ditt lösenord var bara " + längd + " tecken långt."); System.out.println("Inte godkänt!"); } //Annars sker detta else { System.out.println("Ditt lösenord var " + längd + " tecken långt och är därför godkänt."); System.out.println("Grattis!"); } System.out.println("Programmet avslutas här"); } }
397c41dcb41dc65f4f4215f382d6ad1cb2d38b9b
4cf28de03d844aa2d84a8e8cec103ba2312ea353
/src/com/xjt/crazypic/edit/filters/ColorSpaceMatrix.java
1363c509c79ffa883f8e0932daa66a40c85c723a
[ "Apache-2.0" ]
permissive
jituo666/CrazyPic
873b7b3f67b678cee69d19f096030eb61572df72
706e9f92430af1e72a7fca3bf39bd8dbcf0c30a5
refs/heads/master
2021-01-06T20:38:01.951788
2014-10-14T01:51:59
2014-10-14T01:51:59
24,831,462
0
2
null
null
null
null
UTF-8
Java
false
false
5,415
java
package com.xjt.crazypic.edit.filters; import java.util.Arrays; public class ColorSpaceMatrix { private final float[] mMatrix = new float[16]; private static final float RLUM = 0.3086f; private static final float GLUM = 0.6094f; private static final float BLUM = 0.0820f; public ColorSpaceMatrix() { identity(); } /** * Copy constructor * * @param matrix */ public ColorSpaceMatrix(ColorSpaceMatrix matrix) { System.arraycopy(matrix.mMatrix, 0, mMatrix, 0, matrix.mMatrix.length); } /** * get the matrix * * @return the internal matrix */ public float[] getMatrix() { return mMatrix; } /** * set matrix to identity */ public void identity() { Arrays.fill(mMatrix, 0); mMatrix[0] = mMatrix[5] = mMatrix[10] = mMatrix[15] = 1; } public void convertToLuminance() { mMatrix[0] = mMatrix[1] = mMatrix[2] = 0.3086f; mMatrix[4] = mMatrix[5] = mMatrix[6] = 0.6094f; mMatrix[8] = mMatrix[9] = mMatrix[10] = 0.0820f; } private void multiply(float[] a) { int x, y; float[] temp = new float[16]; for (y = 0; y < 4; y++) { int y4 = y * 4; for (x = 0; x < 4; x++) { temp[y4 + x] = mMatrix[y4 + 0] * a[x] + mMatrix[y4 + 1] * a[4 + x] + mMatrix[y4 + 2] * a[8 + x] + mMatrix[y4 + 3] * a[12 + x]; } } for (int i = 0; i < 16; i++) mMatrix[i] = temp[i]; } private void xRotateMatrix(float rs, float rc) { ColorSpaceMatrix c = new ColorSpaceMatrix(); float[] tmp = c.mMatrix; tmp[5] = rc; tmp[6] = rs; tmp[9] = -rs; tmp[10] = rc; multiply(tmp); } private void yRotateMatrix(float rs, float rc) { ColorSpaceMatrix c = new ColorSpaceMatrix(); float[] tmp = c.mMatrix; tmp[0] = rc; tmp[2] = -rs; tmp[8] = rs; tmp[10] = rc; multiply(tmp); } private void zRotateMatrix(float rs, float rc) { ColorSpaceMatrix c = new ColorSpaceMatrix(); float[] tmp = c.mMatrix; tmp[0] = rc; tmp[1] = rs; tmp[4] = -rs; tmp[5] = rc; multiply(tmp); } private void zShearMatrix(float dx, float dy) { ColorSpaceMatrix c = new ColorSpaceMatrix(); float[] tmp = c.mMatrix; tmp[2] = dx; tmp[6] = dy; multiply(tmp); } /** * sets the transform to a shift in Hue * * @param rot rotation in degrees */ public void setHue(float rot) { float mag = (float) Math.sqrt(2.0); float xrs = 1 / mag; float xrc = 1 / mag; xRotateMatrix(xrs, xrc); mag = (float) Math.sqrt(3.0); float yrs = -1 / mag; float yrc = (float) Math.sqrt(2.0) / mag; yRotateMatrix(yrs, yrc); float lx = getRedf(RLUM, GLUM, BLUM); float ly = getGreenf(RLUM, GLUM, BLUM); float lz = getBluef(RLUM, GLUM, BLUM); float zsx = lx / lz; float zsy = ly / lz; zShearMatrix(zsx, zsy); float zrs = (float) Math.sin(rot * Math.PI / 180.0); float zrc = (float) Math.cos(rot * Math.PI / 180.0); zRotateMatrix(zrs, zrc); zShearMatrix(-zsx, -zsy); yRotateMatrix(-yrs, yrc); xRotateMatrix(-xrs, xrc); } /** * set it to a saturation matrix * * @param s */ public void changeSaturation(float s) { mMatrix[0] = (1 - s) * RLUM + s; mMatrix[1] = (1 - s) * RLUM; mMatrix[2] = (1 - s) * RLUM; mMatrix[4] = (1 - s) * GLUM; mMatrix[5] = (1 - s) * GLUM + s; mMatrix[6] = (1 - s) * GLUM; mMatrix[8] = (1 - s) * BLUM; mMatrix[9] = (1 - s) * BLUM; mMatrix[10] = (1 - s) * BLUM + s; } /** * Transform RGB value * * @param r red pixel value * @param g green pixel value * @param b blue pixel value * @return computed red pixel value */ public float getRed(int r, int g, int b) { return r * mMatrix[0] + g * mMatrix[4] + b * mMatrix[8] + mMatrix[12]; } /** * Transform RGB value * * @param r red pixel value * @param g green pixel value * @param b blue pixel value * @return computed green pixel value */ public float getGreen(int r, int g, int b) { return r * mMatrix[1] + g * mMatrix[5] + b * mMatrix[9] + mMatrix[13]; } /** * Transform RGB value * * @param r red pixel value * @param g green pixel value * @param b blue pixel value * @return computed blue pixel value */ public float getBlue(int r, int g, int b) { return r * mMatrix[2] + g * mMatrix[6] + b * mMatrix[10] + mMatrix[14]; } private float getRedf(float r, float g, float b) { return r * mMatrix[0] + g * mMatrix[4] + b * mMatrix[8] + mMatrix[12]; } private float getGreenf(float r, float g, float b) { return r * mMatrix[1] + g * mMatrix[5] + b * mMatrix[9] + mMatrix[13]; } private float getBluef(float r, float g, float b) { return r * mMatrix[2] + g * mMatrix[6] + b * mMatrix[10] + mMatrix[14]; } }
a5efbeb8f0f31ac12f42d693ce4e8d5ae666ccba
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/14/14_f341874f8b86b2ebce062826f2b995e26a0ef2ff/Command/14_f341874f8b86b2ebce062826f2b995e26a0ef2ff_Command_s.java
20b2cb9fa4ccd8f7bd7c3edc09dc73da0d7b720d
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
462
java
package rescuecore2.messages; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import rescuecore2.worldmodel.EntityID; /** A sub-interface of Message that tags messages that are interpreted as agent commands. */ public interface Command { /** Get the id of the agent-controlled entity that has issued this command. @return The id of the agent. */ public EntityID getAgentID(); }
6d4bd8b09d93f63b0a7ee5dde092a69fba4124c7
b160428cea4348a59ac77b22fd5d31f3f66697f1
/src/main/java/hiber/service/UserServiceImp.java
7e69726383109442464c3ec3984a93587ac70bbd
[]
no_license
SyrnoLinanalin/spring_hibernate
e16d9c3e84e8891def26e644dffe9554bf78fd33
f1b44eccf9f78af93abeddc12b87e3f0cb083e84
refs/heads/master
2023-04-21T22:49:52.525216
2021-05-04T13:33:29
2021-05-04T13:33:29
362,899,439
0
0
null
null
null
null
UTF-8
Java
false
false
804
java
package hiber.service; import hiber.dao.UserDao; import hiber.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class UserServiceImp implements UserService { private final UserDao userDao; public UserServiceImp(@Autowired UserDao userDao) { this.userDao = userDao; } @Transactional @Override public void add(User user) { userDao.add(user); } @Transactional(readOnly = true) @Override public List<User> listUsers() { return userDao.listUsers(); } @Override public List<User> findCar(String model, int series) { return userDao.findCar(model, series); } }
5028fa23f79da4f82d17f90d5e6048b260659dda
c1258abaa7d60bc06899e64c897146db34a34cdb
/src/main/java/org/jetlinks/core/metadata/types/IntType.java
babc47a345b29ee0781ccaf44bd124397b93ee68
[]
no_license
ydhqfly/jetlinks-core
9e88f63e3d8547cc6302de9b7c71b8c54759eaef
61a567c302647138a579a49243f55bdeef2671d2
refs/heads/master
2020-09-21T12:45:36.613946
2019-11-20T07:30:38
2019-11-20T07:30:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
535
java
package org.jetlinks.core.metadata.types; import lombok.Getter; import lombok.Setter; import java.util.Map; @Getter @Setter public class IntType extends NumberType<Integer> { public static final String ID = "int"; private Map<String, Object> expands; @Override public String getId() { return ID; } @Override public String getName() { return "整型"; } @Override public Integer convert(Object value) { return super.convertNumber(value, Number::intValue); } }
58b70dd3089ce98dc55a042e907d72cba64f7237
9e67004a4d33d35d14b61e66a9a9703f9af50760
/mbox/src/bvv/util/mailLog/Postfix_qmgr.java
3de62d06371512910fb8042b95b68d705a951d67
[]
no_license
begun74/mbox
f639e0f14c7524189747b33f45ad56f0223d4d9f
89f3f9c5a2243b4abccfc774955579204731dbf8
refs/heads/master
2020-05-20T00:17:15.333719
2015-06-23T07:02:50
2015-06-23T07:02:50
35,890,195
0
0
null
null
null
null
UTF-8
Java
false
false
1,574
java
package bvv.util.mailLog; import java.util.regex.Matcher; import java.util.regex.Pattern; import bvv.util.mailLog.view.Postfix; import bvv.util.mailLog.view.Qmgr; import bvv.util.mailLog.view.SmtpD; public class Postfix_qmgr implements PatternImpl { private String pattern; //default Pattern regexp = Pattern.compile("([A-za-z]{3}[\\s]{1,2}[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2}).+ (postfix/qmgr\\[[0-9]+\\]): ([A-Z0-9]{7,11}):{1} from=<(.+)>, size=(.+), nrcpt=(.+)$"); //Pattern regexp = Pattern.compile("([A-za-z]{3}[\\s]{1,2}[0-9]{1,2} [0-9]{2}:[0-9]{2}:[0-9]{2}).+ (postfix/qmgr\\[[0-9]+\\]): ([A-Z0-9]{7,11}):{1} removed"); private Matcher matcher; public Postfix_qmgr() { } @Override public Postfix findPattern(String line) { Qmgr Qmgr = null; matcher = regexp.matcher(line); //the input while(matcher.find()) { //System.out.println(line); Qmgr = new Qmgr(); Qmgr.setData(DataParser.dataParser(matcher.group(1))); Qmgr.setProcName(matcher.group(2)); Qmgr.setN(matcher.group(3)); switch(matcher.groupCount()) { case 4: Qmgr.setFrom(matcher.group(4)); break; case 6: Qmgr.setFrom(matcher.group(4)); Qmgr.setSize(matcher.group(5)); break; } } return Qmgr; } @Override public void setPattern(String pattern) { // TODO Auto-generated method stub this.pattern = pattern; this.regexp = Pattern.compile(pattern); } }
2a2139cb6f5e7f77e82c7a3e18a363995a87dcbb
62086a5702431bcfcb4c1edba9d6e174eaf70272
/src/main/java/com/attendee/attendee/service/AttendeeRecapService.java
48b4adf92c40f623032c776d566498e7f585ef71
[]
no_license
christbiz86/project-attendees
ed6dc27991efe23753c95089a701be5cc038247b
80543d5a02bb02ef3b5a3de180ff8b65af507d77
refs/heads/master
2020-06-28T09:01:06.482949
2019-10-08T07:17:27
2019-10-08T07:17:27
200,193,454
0
0
null
2019-08-26T04:13:56
2019-08-02T08:06:54
Java
UTF-8
Java
false
false
2,012
java
package com.attendee.attendee.service; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.attendee.attendee.dao.AttendeeRecapDao; import com.attendee.attendee.model.AttendeeRecap; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; @Service public class AttendeeRecapService { @Autowired private AttendeeRecapDao attendeeRecapDao; @Autowired private CloudService cloudService; @Transactional public List<AttendeeRecap> getAll(String company, Date startDate, Date endDate) { List<AttendeeRecap> list = attendeeRecapDao.getAllRecap(company, startDate, endDate); return list; } @Transactional public byte[] generateReport(String company, Date startDate, Date endDate) throws Exception { // Compile the Jasper report from .jrxml to .japser JasperReport jasperReport = JasperCompileManager.compileReport(cloudService.loadReport("AttRecapRpt")); // Get your data source JRBeanCollectionDataSource jrBeanCollectionDataSource = new JRBeanCollectionDataSource(attendeeRecapDao.getAllRecap(company, startDate, endDate)); // Add parameters Map<String, Object> parameters = new HashMap<>(); parameters.put("company", company); parameters.put("startDate", startDate); parameters.put("endDate", endDate); // Fill the report JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrBeanCollectionDataSource); // Export the report to a PDF file byte[] pdf = JasperExportManager.exportReportToPdf(jasperPrint); return pdf; } }
6253b5812d850cb128eb8a46546c52efb4919b9d
d38978522614c8389812301530f7d9a291a7b16e
/src/InC/Vue/Map/Grille/Entitemap/EntiteMap.java
1d7e6beffc19e20fce8db48e4bb0d1f7ed7d4b53
[]
no_license
Chnapy/Timeflies_horscombat
d87aa68f7163730a2d129557fea1cdc5d798a32d
2b0889a769c186deb3087671e8210521bfdbe42e
refs/heads/master
2021-01-17T10:19:25.943855
2016-06-30T16:35:04
2016-06-30T16:35:04
59,307,795
0
0
null
null
null
null
UTF-8
Java
false
false
480
java
/* * * * */ package InC.Vue.Map.Grille.Entitemap; import InC.Vue.Map.Grille.AbstractMap; /** * EntiteMap.java * */ public class EntiteMap extends AbstractMap<EntiteSprite> { public EntiteMap() { setId("entitemap"); } @Override public void ajoutNode(EntiteSprite es, int x, int y) { double w = es.getImage().getWidth(); double h = es.getImage().getHeight(); placerNode(es, x, y, (TILE_WIDTH - w) / 2, -h + TILE_HEIGHT / 2); getChildren().add(es); } }
[ "Richard@PCportable-Richard" ]
Richard@PCportable-Richard
d708dc95f95e9ae7cbd7814040353ed13732b931
1f9bb807e4f478bf8f00a5cc085762e0869275a8
/MyJfinal/src/main/java/com/yzp/jfinaltest/common/routes/FrontRoutes.java
cc523e265f31c4ec84c0d86c80a392be9f448d16
[]
no_license
uaucome/jfinal
0353bf15452052de0cc7f10d38a64439b9d763b2
6a04a960a1a3d5cd986d8208d75022a27c47280a
refs/heads/master
2022-06-30T17:16:20.457277
2019-07-08T01:59:01
2019-07-08T01:59:01
195,325,342
2
0
null
2022-06-21T01:24:18
2019-07-05T02:24:50
Java
UTF-8
Java
false
false
266
java
package com.yzp.jfinaltest.common.routes; import com.jfinal.config.Routes; /** * Description: 前端路由 * * @author yzp * * @date 2019年7月5日 */ public class FrontRoutes extends Routes { @Override public void config() { } }
[ "yuzhiping@LAPTOP-KOPDN6M9" ]
yuzhiping@LAPTOP-KOPDN6M9
d42df8e45f38ecfe54c40c13be9be11df6b636a1
a82e89ad619bbf0346b369242e34dc61e95970d9
/suncertify/code/src/suncertify/nw/ServerService.java
f0e4d4aabb8ea34729df9e4936d5e4bdff07a00b
[]
no_license
mjilugu/OCJD
49d6bdd7f0ca991451ac007812cf68b7acd01b7e
a4bbbf45cb6b44a26cf9426b0ea5d2a9bd76bb29
refs/heads/master
2021-01-17T14:49:56.393072
2016-06-13T13:09:17
2016-06-13T13:09:17
16,104,675
0
0
null
null
null
null
UTF-8
Java
false
false
582
java
package suncertify.nw; import java.net.Socket; /** * This class provides a common interface for various * entities on the network server. Each entity on the server * performs a service on a request from a client represented by * a network socket. * @author Moses L. Jilugu. * @version March 13, 2013. */ public interface ServerService { /** * This method will define action that an entity on the network server * performs on a socket connection. * @param socket socket connection to be serviced. */ public void service(Socket socket) throws Exception; }
fdaecf594d1bcbfedf6907e5eaf60d603eb54d22
6d79986329a62ef17ded91809d35aca6475dbda7
/src/mit/core/protocol/core/methods/response/MitGetBlockTransactionCountByNumber.java
7190240f3395be9fa21da90c9ebb9ec4aa3efba2
[]
no_license
timenewbank/java-mitWeb3
33c8bdc2e3c7fd43bcb0d358447d730153c1fa1f
0f86d27e0d471a0e4bb99a03b278b88dccb4a9f8
refs/heads/master
2020-04-09T07:51:16.265805
2018-12-04T06:58:49
2018-12-04T06:58:49
160,173,137
0
2
null
null
null
null
UTF-8
Java
false
false
378
java
package mit.core.protocol.core.methods.response; import java.math.BigInteger; import mit.core.protocol.core.Response; import mit.utils.Numeric; /** * eth_getBlockTransactionCountByNumber. */ public class MitGetBlockTransactionCountByNumber extends Response<String> { public BigInteger getTransactionCount() { return Numeric.decodeQuantity(getResult()); } }
55a65967f41b11fdd6c7e93924d01cfbda584586
48ca0949bd95fdc25975140565df6d1a0471ba60
/answers/day1/JSM-ITP-day1/src/nl/rug/jsm/introduction_to_programming/day1/Main.java
b3192814ba94ba23f19b12b179097c5f38540937
[]
no_license
Neleor/JSM-ITP
22ab658d0e8a09e7495135f6d7e52ea9f300eb70
888302b4be860cd84712791d2f4a3497f64079e1
refs/heads/master
2020-08-16T14:28:46.765989
2019-12-05T19:58:07
2019-12-05T19:58:07
215,512,365
0
0
null
2019-12-05T19:58:09
2019-10-16T09:44:26
Java
UTF-8
Java
false
false
1,789
java
// this is an assignment for the JSM introduction to programming course // the assignment here is as follows: // // Make a simple program that asks the name of the user, then greet the user. // // Ask the body temperature of the user and tell if he/she has a fever. package nl.rug.jsm.introduction_to_programming.day1; import java.util.Scanner; /** * this is a class description, here we tell people what our class does * @author OelenR * */ public class Main { /** * this is a method description, here we tell people what our method does * @param args here we describe what this parameters does or why its required */ public static void main(String[] args) { // create the Object Scanner scanner = new Scanner(System.in); // tell the user what we are going to ask them System.out.println("what is your name?"); // get the name the user entered String text = scanner.nextLine(); // greet the user System.out.println("hello "+text); // again, tell the user what we are going to ask them System.out.println("what is your body temperature in Celcius?"); // get the number the user entered double number = scanner.nextDouble(); // check the number the user entered and tell if he/she has a fever (operators?) if(number > 37.0) { //bigger than 37 System.out.println("you have a fever"); } else if(number <= 37.0 && number>35.0) { //equal or smaller than 37 and more than 35 System.out.println("you do not have a fever"); } else if(number <= 35.0) { //equal or smaller than 35 System.out.println("you do not have a fever, but you're pretty cold"); } else { // all the conditions are already captured by the other if/elseifs, so the program should never end up here System.out.println("what are you doing here?"); } } }
c37982dbfd92f7a12d564f0edc39c9ec09fc95dd
d294108ce74ca357df5fd8f282888f7c17e2ed9f
/large-project5/src/main/java/demo/large_project3/Pojo217.java
1e0aa7af065dbced492f0a86309c3c0346f7dd28
[]
no_license
wmedvede/test-files5
f0d9fdeed8840659313d37a71563c92896275117
32733be4d769530b40d6e43f81dd670449bdc030
refs/heads/master
2021-03-22T02:13:05.431054
2017-12-20T16:28:21
2017-12-20T16:28:21
114,897,714
0
0
null
null
null
null
UTF-8
Java
false
false
5,205
java
/* * Copyright ${year} Red Hat, Inc. and/or its affiliates. * * 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 demo.large_project3; /** * This class was automatically generated by the data modeler tool. */ public class Pojo217 implements java.io.Serializable { static final long serialVersionUID = 1L; private java.math.BigDecimal field1; private java.math.BigDecimal field2; private java.math.BigDecimal field3; private java.math.BigDecimal field4; private java.math.BigDecimal field5; private java.math.BigDecimal field6; private java.math.BigDecimal field7; private java.math.BigDecimal field8; private java.math.BigDecimal field9; private java.math.BigDecimal field10; private java.math.BigDecimal field11; private java.math.BigDecimal field12; private java.math.BigDecimal field13; private java.math.BigDecimal field14; private java.math.BigDecimal field15; private java.math.BigDecimal field16; private java.math.BigDecimal field17; private java.math.BigDecimal field18; private java.math.BigDecimal field19; private java.math.BigDecimal field20; public java.math.BigDecimal getField1() { return this.field1; } public void setField1(java.math.BigDecimal field1) { this.field1 = field1; } public java.math.BigDecimal getField2() { return this.field2; } public void setField2(java.math.BigDecimal field2) { this.field2 = field2; } public java.math.BigDecimal getField3() { return this.field3; } public void setField3(java.math.BigDecimal field3) { this.field3 = field3; } public java.math.BigDecimal getField4() { return this.field4; } public void setField4(java.math.BigDecimal field4) { this.field4 = field4; } public java.math.BigDecimal getField5() { return this.field5; } public void setField5(java.math.BigDecimal field5) { this.field5 = field5; } public java.math.BigDecimal getField6() { return this.field6; } public void setField6(java.math.BigDecimal field6) { this.field6 = field6; } public java.math.BigDecimal getField7() { return this.field7; } public void setField7(java.math.BigDecimal field7) { this.field7 = field7; } public java.math.BigDecimal getField8() { return this.field8; } public void setField8(java.math.BigDecimal field8) { this.field8 = field8; } public java.math.BigDecimal getField9() { return this.field9; } public void setField9(java.math.BigDecimal field9) { this.field9 = field9; } public java.math.BigDecimal getField10() { return this.field10; } public void setField10(java.math.BigDecimal field10) { this.field10 = field10; } public java.math.BigDecimal getField11() { return this.field11; } public void setField11(java.math.BigDecimal field11) { this.field11 = field11; } public java.math.BigDecimal getField12() { return this.field12; } public void setField12(java.math.BigDecimal field12) { this.field12 = field12; } public java.math.BigDecimal getField13() { return this.field13; } public void setField13(java.math.BigDecimal field13) { this.field13 = field13; } public java.math.BigDecimal getField14() { return this.field14; } public void setField14(java.math.BigDecimal field14) { this.field14 = field14; } public java.math.BigDecimal getField15() { return this.field15; } public void setField15(java.math.BigDecimal field15) { this.field15 = field15; } public java.math.BigDecimal getField16() { return this.field16; } public void setField16(java.math.BigDecimal field16) { this.field16 = field16; } public java.math.BigDecimal getField17() { return this.field17; } public void setField17(java.math.BigDecimal field17) { this.field17 = field17; } public java.math.BigDecimal getField18() { return this.field18; } public void setField18(java.math.BigDecimal field18) { this.field18 = field18; } public java.math.BigDecimal getField19() { return this.field19; } public void setField19(java.math.BigDecimal field19) { this.field19 = field19; } public java.math.BigDecimal getField20() { return this.field20; } public void setField20(java.math.BigDecimal field20) { this.field20 = field20; } public Pojo217() { } }
8208a3b85b1cce6271a99cc529b27821f0452e51
085a4d2e59899d40f206d09681a24356657e4f37
/BeeTriathlon/src/dbc/DBConnectionMgr.java
76a8db1bde96f119cb3a49b88d99977b632b36c2
[]
no_license
quickbonak/BPDUO
234a0654a272e9e5605c283473ed62856f4f293d
cc8d98171e6552541647328b8b9b6586d8a66207
refs/heads/master
2022-12-11T07:34:00.052473
2019-11-21T06:23:26
2019-11-21T06:23:26
222,656,378
1
0
null
2019-11-19T09:58:16
2019-11-19T09:19:24
HTML
UTF-8
Java
false
false
9,344
java
package dbc; /** * Copyright(c) 2001 iSavvix Corporation (http://www.isavvix.com/) * * All rights reserved * * Permission to use, copy, modify and distribute this material for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of iSavvix Corporation not be used in * advertising or publicity pertaining to this material without the * specific, prior written permission of an authorized representative of * iSavvix Corporation. * * ISAVVIX CORPORATION MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, * EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST * INFRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL ISAVVIX CORPORATION OR * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELATING * TO THE SOFTWARE. * */ import java.sql.*; import java.util.Properties; import java.util.Vector; /** * Manages a java.sql.Connection pool. * * @author Anil Hemrajani */ public class DBConnectionMgr { private Vector connections = new Vector(10); private String _driver = "org.gjt.mm.mysql.Driver", _url = "jdbc:mysql://localhost:3306/game?useUnicode=true&characterEncoding=UTF-8", _user = "root", _password = "123321"; private boolean _traceOn = false; private boolean initialized = false; private int _openConnections = 50; private static DBConnectionMgr instance = null; public DBConnectionMgr() { } /** Use this method to set the maximum number of open connections before unused connections are closed. */ public static DBConnectionMgr getInstance() { if (instance == null) { synchronized (DBConnectionMgr.class) { if (instance == null) { instance = new DBConnectionMgr(); } } } return instance; } public void setOpenConnectionCount(int count) { _openConnections = count; } public void setEnableTrace(boolean enable) { _traceOn = enable; } /** Returns a Vector of java.sql.Connection objects */ public Vector getConnectionList() { return connections; } /** Opens specified "count" of connections and adds them to the existing pool */ public synchronized void setInitOpenConnections(int count) throws SQLException { Connection c = null; ConnectionObject co = null; for (int i = 0; i < count; i++) { c = createConnection(); co = new ConnectionObject(c, false); connections.addElement(co); trace("ConnectionPoolManager: Adding new DB connection to pool (" + connections.size() + ")"); } } /** Returns a count of open connections */ public int getConnectionCount() { return connections.size(); } /** Returns an unused existing or new connection. */ public synchronized Connection getConnection() throws Exception { if (!initialized) { Class c = Class.forName(_driver); DriverManager.registerDriver((Driver) c.newInstance()); initialized = true; } Connection c = null; ConnectionObject co = null; boolean badConnection = false; for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); // If connection is not in use, test to ensure it's still valid! if (!co.inUse) { try { badConnection = co.connection.isClosed(); if (!badConnection) badConnection = (co.connection.getWarnings() != null); } catch (Exception e) { badConnection = true; e.printStackTrace(); } // Connection is bad, remove from pool if (badConnection) { connections.removeElementAt(i); trace("ConnectionPoolManager: Remove disconnected DB connection #" + i); continue; } c = co.connection; co.inUse = true; trace("ConnectionPoolManager: Using existing DB connection #" + (i + 1)); break; } } if (c == null) { c = createConnection(); co = new ConnectionObject(c, true); connections.addElement(co); trace("ConnectionPoolManager: Creating new DB connection #" + connections.size()); } return c; } /** Marks a flag in the ConnectionObject to indicate this connection is no longer in use */ public synchronized void freeConnection(Connection c) { if (c == null) return; ConnectionObject co = null; for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); if (c == co.connection) { co.inUse = false; break; } } for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); if ((i + 1) > _openConnections && !co.inUse) removeConnection(co.connection); } } public void freeConnection(Connection c, PreparedStatement p, ResultSet r) { try { if (r != null) r.close(); if (p != null) p.close(); freeConnection(c); } catch (SQLException e) { e.printStackTrace(); } } public void freeConnection(Connection c, Statement s, ResultSet r) { try { if (r != null) r.close(); if (s != null) s.close(); freeConnection(c); } catch (SQLException e) { e.printStackTrace(); } } public void freeConnection(Connection c, PreparedStatement p) { try { if (p != null) p.close(); freeConnection(c); } catch (SQLException e) { e.printStackTrace(); } } public void freeConnection(Connection c, Statement s) { try { if (s != null) s.close(); freeConnection(c); } catch (SQLException e) { e.printStackTrace(); } } /** Marks a flag in the ConnectionObject to indicate this connection is no longer in use */ public synchronized void removeConnection(Connection c) { if (c == null) return; ConnectionObject co = null; for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); if (c == co.connection) { try { c.close(); connections.removeElementAt(i); trace("Removed " + c.toString()); } catch (Exception e) { e.printStackTrace(); } break; } } } private Connection createConnection() throws SQLException { Connection con = null; try { if (_user == null) _user = ""; if (_password == null) _password = ""; Properties props = new Properties(); props.put("user", _user); props.put("password", _password); con = DriverManager.getConnection(_url, props); } catch (Throwable t) { throw new SQLException(t.getMessage()); } return con; } /** Closes all connections and clears out the connection pool */ public void releaseFreeConnections() { trace("ConnectionPoolManager.releaseFreeConnections()"); Connection c = null; ConnectionObject co = null; for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); if (!co.inUse) removeConnection(co.connection); } } /** Closes all connections and clears out the connection pool */ public void finalize() { trace("ConnectionPoolManager.finalize()"); Connection c = null; ConnectionObject co = null; for (int i = 0; i < connections.size(); i++) { co = (ConnectionObject) connections.elementAt(i); try { co.connection.close(); } catch (Exception e) { e.printStackTrace(); } co = null; } connections.removeAllElements(); } private void trace(String s) { if (_traceOn) System.err.println(s); } } class ConnectionObject { public java.sql.Connection connection = null; public boolean inUse = false; public ConnectionObject(Connection c, boolean useFlag) { connection = c; inUse = useFlag; } }
98e0a43bb2539140b7bcd25ab21913062a777bfb
05a5383020235a099343eb8d5fb5cd6e581ea147
/2.JavaCore/src/com/javarush/task/task19/task1904/Solution.java
a20eb3e1dd2248c58c77f55c47156642486e420a
[]
no_license
Andrey221285/javarush
10db804265e06775d63345239003c98d558523b8
79f91c4828fb687e1cb7192b80e6b14faec02c46
refs/heads/master
2021-04-23T22:43:41.943203
2020-11-19T16:44:40
2020-11-19T16:44:40
132,452,080
0
0
null
null
null
null
UTF-8
Java
false
false
1,545
java
package com.javarush.task.task19.task1904; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; import java.util.Scanner; /* И еще один адаптер */ public class Solution { public static void main(String[] args) throws Exception { String name = "Иванов Иван Иванович 31 12 1950"; PersonScannerAdapter adapter = new PersonScannerAdapter(new Scanner(name)); System.out.println(adapter.read()); } public static class PersonScannerAdapter implements PersonScanner { private final Scanner fileScanner; PersonScannerAdapter(Scanner fileScanner) { this.fileScanner = fileScanner; } @Override public Person read() throws IOException { Person p = null; if (this.fileScanner.hasNext()) { String s = this.fileScanner.nextLine(); String[] bufer = s.split(" "); int year = Integer.parseInt(bufer[5]); int month =Integer.parseInt(bufer[4])-1; int day = Integer.parseInt(bufer[3]); GregorianCalendar calendar = new GregorianCalendar(year, month, day); Date date = calendar.getTime(); p = new Person(bufer[1], bufer[2], bufer[0],date); } return p; } @Override public void close() throws IOException { this.fileScanner.close(); } } }
ab977e5536da73cdbe4cf51f128887f9e044966d
9077e0fddc4c49014928879954128bbf3d9ebae5
/resourcesharing/src/main/java/com/dbteam6/resourcesharing/controller/ItemController.java
dd512c0b686367736c74283c025dfc95c8114178
[]
no_license
JungDayoon/DBproject_team6
c91e17e5f01f3eb51fd9e1b3f27440feded3957e
55b060611dc02509f18acc60adb1a5f7bea386eb
refs/heads/master
2023-04-06T07:19:31.314379
2019-12-19T04:57:10
2019-12-19T04:57:10
222,119,434
0
0
null
2023-03-23T20:39:19
2019-11-16T15:31:55
Java
UTF-8
Java
false
false
2,455
java
package com.dbteam6.resourcesharing.controller; import com.dbteam6.resourcesharing.model.dao.DeptDao; import com.dbteam6.resourcesharing.model.dao.ItemDao; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.sql.SQLException; @Controller public class ItemController { ItemDao iDao = ItemDao.getInstance(); /*GET*/ @ResponseBody @GetMapping("/items") public JSONArray getItems() throws SQLException { System.out.println("@ REQUEST : GET ALL ITEMS"); return iDao.getAllItems(); } @ResponseBody @GetMapping("/items/{uuid}/{iid}") public JSONObject getOnesItemById(@PathVariable("uuid") int uuid, @PathVariable("iid") int iid) throws SQLException { System.out.println("@ GET : GET BORROWED ITEM BY ID"); JSONArray items = iDao.getOnesItemById(uuid, iid); if (items.size() == 0){ return null; } else{ return (JSONObject) items.get(0); } } @ResponseBody @GetMapping("/items/of/{category_name}") public JSONArray getItemsOfCategory(@PathVariable("category_name") String cname) throws SQLException { System.out.println("@ GET : GET ITEM OBY CATEGORY NAME"); return iDao.getItemsOfCategory(cname); } @ResponseBody @GetMapping("/items/from/{dept_name}") public JSONArray getItemsOfDept(@PathVariable("dept_name") String dname) throws SQLException { return iDao.getItemsOfDept(dname); } @ResponseBody @PostMapping("/items/add/{iname}/{dname}/{cname}/{count}") public boolean addItem(@PathVariable("iname") String iname, @PathVariable("dname") String dname, @PathVariable("cname") String cname, @PathVariable("count") int count) throws SQLException { System.out.println("@ POST : ADD ITEM"); return iDao.addItem(iname, dname, cname, count); } @ResponseBody @PutMapping("/items/update/{iid}/{newCount}") public boolean updateItem(@PathVariable("iid") int iid, @PathVariable("newCount") int newCount) throws SQLException { return iDao.updateItem(iid, newCount); } @ResponseBody @DeleteMapping("/items/return/{iid}/of/{uuid}") public boolean returnItem(@PathVariable("iid") int iid, @PathVariable("uuid") int uuid) throws SQLException { return iDao.returnItem(uuid, iid); } }
73daa21c3470a9ac2d16f5d12032ea2131152f9d
94b97f7af619896c438bd0aa15e82b0c37f9de75
/app/src/main/java/com/app/foody/Controller/BinhLuanController.java
2914e1cd51ebc7e7c6a605c98a79ac2e248fb158
[]
no_license
hieugiddy/Foody
6bfaa363c28c50b66242de8438e3670a10f750e9
a9746ff0a055537c90105734300dffd44ab35bda
refs/heads/master
2023-02-05T16:23:47.650623
2020-12-22T16:49:14
2020-12-22T16:49:14
305,984,466
0
0
null
2020-12-22T13:02:35
2020-10-21T10:12:43
Java
UTF-8
Java
false
false
457
java
package com.app.foody.Controller; import com.app.foody.Model.BinhLuanModel; import java.util.List; public class BinhLuanController { BinhLuanModel binhLuanModel; public BinhLuanController(){ binhLuanModel=new BinhLuanModel(); } public void ThemBinhluan(String maQuanAn, BinhLuanModel binhLuanModel, List<String> listHinh){ binhLuanModel.ThemBinhluan(maQuanAn,binhLuanModel,listHinh); } }
dc20f2fdfaf2b0884071e75d6dff94fada1f050a
8875274be5820b81262e98fe5c9dc3e7ed4493ee
/echoproject/src/main/java/net/xdclass/echo/InboundHandler1.java
01f58608ad5e3ffb555381732625bb5460d5ec3d
[]
no_license
cowboybusy/netty-project
f757bd05b345db3b047c6efb3503d2739eac5309
31e9c21db9c1a33edd5c53853d31a668d21fe0be
refs/heads/master
2020-04-20T01:34:06.435173
2019-01-31T15:37:33
2019-01-31T15:37:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,094
java
package net.xdclass.echo; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.handler.codec.FixedLengthFrameDecoder; import io.netty.util.CharsetUtil; public class InboundHandler1 extends ChannelInboundHandlerAdapter { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { ByteBuf data = (ByteBuf) msg; System.out.println("InboundHandler1 channelRead 服务端收到数据:" + data.toString(CharsetUtil.UTF_8)); // 执行下一个InboundHandler ctx.fireChannelRead(Unpooled.copiedBuffer("InboundHandler1 "+data.toString(CharsetUtil.UTF_8), CharsetUtil.UTF_8)); } @Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { ctx.flush(); } @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { cause.printStackTrace(); ctx.close(); } }
c3d49f59fb48227ba13002e4569c902504f5fa43
d75ae724b161656a72892727bdfbcdaadf47f536
/src/main/java/com/bootdo/system/shiro/UserRealm.java
a87c4fa319102e879de65273fe483be4f08b6fd1
[]
no_license
xuxiaonian/bootdo
f20a8370b231c271b2bc598c73ceb3c240d25fa0
880198da4c0b87323b5fa9f8216caeb5db0a49bd
refs/heads/master
2021-01-25T14:10:54.754587
2018-03-14T10:37:35
2018-03-14T10:37:35
123,664,755
0
0
null
null
null
null
UTF-8
Java
false
false
2,322
java
package com.bootdo.system.shiro; import java.util.HashMap; import java.util.Map; import java.util.Set; import com.bootdo.common.utils.StringTools; import com.bootdo.system.service.UserService; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.LockedAccountException; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.UnknownAccountException; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import org.springframework.beans.factory.annotation.Autowired; import com.bootdo.common.utils.ShiroUtils; import com.bootdo.system.domain.SysUserDO; import com.bootdo.system.service.MenuService; public class UserRealm extends AuthorizingRealm { @Autowired UserService userService; @Autowired MenuService menuService; @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) { Long userId = ShiroUtils.getUserId(); Set<String> perms = menuService.listPerms(userId); SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); info.setStringPermissions(perms); return info; } @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { String username = (String) token.getPrincipal(); Map<String, Object> map = new HashMap<>(); map.put("username", username); String password = new String((char[]) token.getCredentials()); // 查询用户信息 SysUserDO user = userService.list(username).get(0); if (user == null) { throw new UnknownAccountException("账号不正确"); } String pass= StringTools.MD5EncodeToHex(password); // 密码错误 if (!pass.equals(user.getPassword())) { throw new IncorrectCredentialsException("密码不正确"); } // 账号锁定 if (user.getStatus() == 0) { throw new LockedAccountException("账号已被锁定,请联系管理员"); } SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName()); return info; } }
3a23dac8bb287afb6030846177ac04fee8c6cc93
50328dd3507960e2135694bb32e9a6f38d888b3c
/app/src/main/java/com/example/multipleactivitiesfun/SecondActivity.java
f2ac6c26a6e357e615a06fef37de25f0ee4d4f89
[]
no_license
abrodhead352/MultipleActivitiesFun
19196a07fca6abf309ba52ca575af67b100e5c3c
4151bbecccc844946521c4d46ef4fe9f44ba97b5
refs/heads/master
2020-08-15T14:34:36.575678
2019-10-17T16:59:07
2019-10-17T16:59:07
215,357,750
1
0
null
null
null
null
UTF-8
Java
false
false
1,539
java
package com.example.multipleactivitiesfun; import androidx.appcompat.app.AppCompatActivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.Toast; public class SecondActivity extends AppCompatActivity { static final String TAG = "SecondActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); Intent intent = getIntent(); if(intent != null) { //returns null if it doesn't find the username key String username = intent.getStringExtra("username"); //returns default value if it doesn't find "pin" int pin = intent.getIntExtra("pin", 0); Toast.makeText(this, username+ " " + pin,Toast.LENGTH_LONG).show(); } //call SecondActivity.this.finish(); Button backButton = (Button) findViewById(R.id.backButton); backButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "onClick: "); //3. send a result back to main activity Intent intent = new Intent(); intent.putExtra("result", "successful"); setResult(Activity.RESULT_OK, intent); SecondActivity.this.finish(); } }); } }
9220e7492ad46f5949a70cac27ff89f62abf9b89
122287275ec1666cc27a6b6d06bab4f8b1c4ff33
/用到的工具jar包/jars/evosuite-tests/org/apache/bcel/generic/IAND_ESTest.java
4c2fa41b001364f909e2106cc441e32af365c5e2
[]
no_license
NJUCWL/symbolic_tools
f036691918b147019c99584efb4dcbe1228ae6c0
669f549b0a97045de4cd95b1df43de93b1462e45
refs/heads/main
2023-05-09T12:00:57.836897
2021-06-01T13:34:40
2021-06-01T13:34:40
370,017,201
2
0
null
null
null
null
UTF-8
Java
false
false
2,650
java
/* * This file was automatically generated by EvoSuite * Tue Mar 16 14:57:13 GMT 2021 */ package org.apache.bcel.generic; import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.runtime.EvoAssertions.*; import org.apache.bcel.generic.IAND; import org.apache.bcel.verifier.structurals.ExecutionVisitor; import org.apache.bcel.verifier.structurals.Frame; import org.apache.bcel.verifier.structurals.InstConstraintVisitor; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true) public class IAND_ESTest extends IAND_ESTest_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { IAND iAND0 = new IAND(); InstConstraintVisitor instConstraintVisitor0 = new InstConstraintVisitor(); Frame frame0 = new Frame(1, (-1)); instConstraintVisitor0.setFrame(frame0); // Undeclared exception! try { iAND0.accept(instConstraintVisitor0); fail("Expecting exception: RuntimeException"); } catch(RuntimeException e) { // // Instruction IAND constraint violated: Cannot consume 2 stack slots: only 0 slot(s) left on stack! // Stack: // Slots used: 0 MaxStack: -1. // verifyException("org.apache.bcel.verifier.structurals.InstConstraintVisitor", e); } } @Test(timeout = 4000) public void test1() throws Throwable { IAND iAND0 = new IAND(); iAND0.setOpcode((short)3720); InstConstraintVisitor instConstraintVisitor0 = new InstConstraintVisitor(); // Undeclared exception! try { iAND0.accept(instConstraintVisitor0); fail("Expecting exception: ArrayIndexOutOfBoundsException"); } catch(ArrayIndexOutOfBoundsException e) { // // 3720 // verifyException("org.apache.bcel.Const", e); } } @Test(timeout = 4000) public void test2() throws Throwable { IAND iAND0 = new IAND(); ExecutionVisitor executionVisitor0 = new ExecutionVisitor(); // Undeclared exception! try { iAND0.accept(executionVisitor0); fail("Expecting exception: NullPointerException"); } catch(NullPointerException e) { // // no message in exception (getMessage() returned null) // verifyException("org.apache.bcel.verifier.structurals.ExecutionVisitor", e); } } }
f6168949d716bf49a23d1c31e33e2cbe0f7caf51
11f74fc42576807b3e76c45669838fe7b4bf310b
/src/me/RabidCrab/ExplodingSheep/Events/ExplodingSheepCommandExecutor.java
55281b977a3b486868fa5a094d30b7803b8f3557
[]
no_license
RabidCrab/Exploding-Sheep
0cc4998b842bcc2ae8b16f41bfdace1b685086fe
3965701a893200aa26282ee4825d951fdc086910
refs/heads/master
2016-09-16T10:02:28.059252
2016-04-10T02:08:56
2016-04-10T02:08:56
2,267,234
0
0
null
null
null
null
UTF-8
Java
false
false
3,724
java
package me.RabidCrab.ExplodingSheep.Events; import java.util.List; import me.RabidCrab.ExplodingSheep.ExplodingSheep; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; /** * Upon a player command, figure out what they want * @author RabidCrab */ public class ExplodingSheepCommandExecutor implements CommandExecutor { public static ExplodingSheep plugin; public static List<LivingEntity> entities; public ExplodingSheepCommandExecutor(ExplodingSheep instance) { plugin = instance; } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(label.equalsIgnoreCase("esheep") && sender != null && args != null) { // Get the player, we'll need it Player player = (Player)sender; // All of the commands have to do with settings. Make sure the user has the correct settings // before even displaying the help text if (!player.hasPermission("explodingsheep.modifysettings") && !player.isOp()) { player.sendMessage("You do not have permission to modify settings!"); return true; } if (args.length < 1) { displayGeneralHelp(player); return true; } if (args[0].equalsIgnoreCase("enable")) { ExplodingSheep.configuration.setExplodingSheepEnabled(true); player.sendMessage("Exploding sheep enabled."); return true; } if (args[0].equalsIgnoreCase("disable")) { ExplodingSheep.configuration.setExplodingSheepEnabled(false); player.sendMessage("Exploding sheep disabled."); return true; } if (args[0].equalsIgnoreCase("leap") && args.length == 2) { if (args[1].equalsIgnoreCase("enable")) { ExplodingSheep.configuration.setSheepLeap(true); player.sendMessage("Exploding sheep leap enabled."); } else { ExplodingSheep.configuration.setSheepLeap(false); player.sendMessage("Exploding sheep leap disabled."); } return true; } if (args[0].equalsIgnoreCase("radius") && args.length == 2) { ExplodingSheep.configuration.setExplosionRadius(Integer.parseInt(args[1])); player.sendMessage("Exploding sheep radius set to " + args[1].toString() + "."); return true; } if (args[0].equalsIgnoreCase("explodechance") && args.length == 2) { int percentage = Integer.parseInt(args[1]); if (percentage < 1 || percentage > 100) { player.sendMessage("The value must be between 1 and 100!"); return true; } ExplodingSheep.configuration.setExplosionRadius(percentage); player.sendMessage("Exploding sheep radius set to " + args[1].toString() + "."); return true; } } return false; } /** * Display the general help to a specific player */ private void displayGeneralHelp(Player player) { List<String> helpList = ExplodingSheep.configuration.getGeneralCommandsHelp(); if (helpList == null) { player.sendMessage(ExplodingSheep.configuration.getGeneralHelpNotFound()); return; } if (helpList.size() > 0) for (String helpText : ExplodingSheep.configuration.getGeneralCommandsHelp()) player.sendMessage(helpText); else player.sendMessage(ExplodingSheep.configuration.getGeneralHelpNotFound()); } }
3f642633484fe6b56e79d82c84cd29f1f310a5b6
99c8e4f287d0350b6dc50bc503fa630979272633
/src/main/java/no/kristiania/devopsexam/CartService.java
195d0ac54d4a95f842ead2d4f6d0b64de0d27b58
[]
no_license
glennbech/devops-exam
b4d6ea0f37e886c11f7b61bce1c1aa50f1a63db6
67b3e99e07b389aacde547e511074581af102a55
refs/heads/main
2023-01-14T13:34:45.228042
2023-01-02T19:43:59
2023-01-02T19:43:59
584,135,957
0
0
null
2023-01-02T19:56:04
2023-01-01T14:28:45
Java
UTF-8
Java
false
false
341
java
package no.kristiania.devopsexam; import io.micrometer.core.annotation.Timed; import org.springframework.stereotype.Component; import java.util.List; @Component public interface CartService { Cart getCart(String id); Cart update(Cart cart); String checkout(Cart cart); List<String> getAllCarts(); float total(); }
a6aa680db4d62689cc5d3084da10df5a59648247
d7fa9067f240c5da423980f32fb649a5ee8c03db
/jrap-eureka/src/test/java/com/jrapcloud/eureka/JrapEurekaApplicationTests.java
1c758c482d5f9198de622ce06f4006a96d39518e
[ "Apache-2.0" ]
permissive
IvanStephenYuan/jrapcloud
6eb71684908be8d36cf1ecae94b8888be709f91b
56231e7b2f525a7846bc53bd00935bdb67f93c1c
refs/heads/master
2022-12-22T20:31:14.342227
2020-04-16T23:55:36
2020-04-16T23:55:36
234,579,310
0
0
Apache-2.0
2022-12-15T23:34:25
2020-01-17T15:40:51
Java
UTF-8
Java
false
false
225
java
package com.jrapcloud.eureka; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class JrapEurekaApplicationTests { @Test void contextLoads() { } }
d4facada233a6ce8a3d2f918b5496eae9dd03327
e7b03b975e9a8e2d19929fc45668d080a6566d81
/7.设计模式/DesignPatternsDemo/Demo2/src/main/java/com/sun/demo2/factoryMethod/BMW523.java
6b00c8720e5753f31ee3b9720f133e74ceada014
[]
no_license
langsun/learn_new
9b81d2d8307cd2ffbc05b99a533d633a24723a80
b584ae350a8a64b0f2201d95f55c5a447a844085
refs/heads/main
2023-03-06T15:13:01.314769
2021-02-21T16:05:05
2021-02-21T16:05:05
340,648,512
0
0
null
null
null
null
UTF-8
Java
false
false
192
java
package com.sun.demo2.factoryMethod; /** * @author sky * @date 2019/11/24 */ public class BMW523 extends BMW { public BMW523() { System.out.println("制造-->BMW523"); } }
77848b04fa9c90c8a4f75af0615cd7c4fafbf035
76c4c7325e4f8c274a78ec2b7377cd9e11e07263
/ch05/Comparison.java
b85eaff7b36e43bc35cd932a7530e64a8dd9ab58
[ "MIT" ]
permissive
raedaniel36/ThinkJavaCode
6454317b4d0e4ee41345680127e0a2938f587c7b
8c207fea6e049e1381fbe073dc3f96a6e358d907
refs/heads/master
2020-03-11T06:15:36.374025
2018-04-20T02:01:46
2018-04-20T02:01:46
117,287,852
0
0
null
2018-01-12T21:04:55
2018-01-12T21:04:54
null
UTF-8
Java
false
false
620
java
// Exercise 5-ES-1 // Exercise 1 public class Comparison { public static void main(String[] args) { String txt = "Fantastic"; String lang = "Java"; boolean state = (txt == lang); System.out.println("String Equality Test: " + state); state = (txt != lang); System.out.println("String Inequality Test: " + state); System.out.println(); int dozen = 12; int score = 10; state = (dozen > score); System.out.println("Greater Than Test: " + state); state = (dozen < score); System.out.println("Less Than Test: " + state); } }
8b3aefc5df3be9f97c2f43db46bc1724e75857e0
d9cd41884c9a61e32b01f7bc576f058495f7defe
/database/src/main/java/by/itacademy/model/Gender.java
da71a4d99740e166f4680dfecc533808655db3d2
[]
no_license
lkghost7/debit3
342eac7be3a3ee5ad9cd1537aa5e92e2135e58a7
de9aaaec3035700c10056118cc2c5b0ff4e4c286
refs/heads/master
2020-04-05T09:29:02.601543
2018-11-18T17:12:37
2018-11-18T17:12:37
156,759,229
0
0
null
2018-11-18T17:15:55
2018-11-08T19:37:53
Java
UTF-8
Java
false
false
79
java
package by.itacademy.model; public enum Gender { MALE, FEMALE, INDEFINED }
78092837b8b2eab776be2090eb2d74ddcf07bf2d
3db66fd312ba97b3a33acb9d639d8d6fbdd8df4d
/eo-parser/src/test/java/org/eolang/parser/XMIRTest.java
2cfedfe3b609a0c969d38c2557157b2cb3e37577
[ "MIT" ]
permissive
alex-semenyuk/eo
6c0ba7eb8c5f5514b4a635ed82b4fe9666afa096
0e58e2932cb9a7061a9d366346471e67e2da8428
refs/heads/master
2022-08-26T12:49:00.920369
2022-08-11T16:33:37
2022-08-11T16:33:37
75,278,677
2
0
null
2016-12-01T09:52:16
2016-12-01T09:52:16
null
UTF-8
Java
false
false
4,284
java
/* * The MIT License (MIT) * * Copyright (c) 2016-2022 Yegor Bugayenko * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package org.eolang.parser; import com.jcabi.log.Logger; import com.jcabi.xml.ClasspathSources; import com.jcabi.xml.XML; import com.jcabi.xml.XMLDocument; import com.jcabi.xml.XSL; import com.jcabi.xml.XSLDocument; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Collection; import org.cactoos.io.InputOf; import org.cactoos.io.OutputTo; import org.cactoos.io.ResourceOf; import org.cactoos.iterable.Mapped; import org.cactoos.list.ListOf; import org.cactoos.text.TextOf; import org.cactoos.text.UncheckedText; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; /** * Test case for {@link XMIR}. * * @since 0.5 * @checkstyle AbbreviationAsWordInNameCheck (500 lines) */ public final class XMIRTest { @ParameterizedTest @MethodSource("samples") public void printsToEO(final String sample) throws Exception { final String src = new TextOf( new ResourceOf(sample) ).asString(); Logger.debug(this, "Original EOLANG:%n%s", src); final XML first = XMIRTest.clean(XMIRTest.parse(src)); Logger.debug(this, "First:%n%s", first); final String eolang = new XMIR(first).toEO(); Logger.debug(this, "EOLANG:%n%s", eolang); final XML second = XMIRTest.clean(XMIRTest.parse(eolang)); Logger.debug(this, "Second:%n%s", second); MatcherAssert.assertThat( first.toString(), Matchers.equalTo(second.toString()) ); } /** * Parse EO code to XMIR. * @param source The source * @return XMIR * @throws IOException If fails */ private static XML parse(final String source) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final Syntax syntax = new Syntax( "test", new InputOf(source), new OutputTo(baos) ); syntax.parse(); final XSL wrap = new XSLDocument( XMIRTest.class.getResourceAsStream("wrap-method-calls.xsl") ).with(new ClasspathSources()); return wrap.transform(new XMLDocument(baos.toByteArray())); } /** * Take the clean version of XML, without the noise. * @param xmir The original * @return Clean one */ private static XML clean(final XML xmir) { return new XSLDocument( XMIRTest.class.getResourceAsStream("strip-xmir.xsl") ).with(new ClasspathSources()).transform(xmir); } @SuppressWarnings("PMD.UnusedPrivateMethod") private static Collection<String> samples() { final String dir = "org/eolang/parser/xmir-samples/"; return new ListOf<>( new Mapped<>( file -> String.format("%s%s", dir, file), new ListOf<>( new UncheckedText( new TextOf( new ResourceOf(dir) ) ).asString().split("\n") ) ) ); } }
30402bf59345c8342d6303095685739f9dc32e1e
a0fe95bb0d40cb1fec8f0a20c928fb296e2de886
/MPT_3_Sample/src/com/cg/service/RechargeServiceImpl.java
6686b69df5063b7fefdcb83898119a52d308f143
[]
no_license
niraj3124/MPT_3
6b88301ce07f8ec6d4ae6716c0ff73c7c5340fde
41743dc18725642a7618e19f1f0202c149764ccd
refs/heads/master
2020-04-01T04:20:05.630642
2018-10-13T10:05:19
2018-10-13T10:05:19
152,858,918
0
0
null
null
null
null
UTF-8
Java
false
false
582
java
package com.cg.service; import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.cg.bean.Recharge; import com.cg.dao.IRechargeDao; @Service public class RechargeServiceImpl implements IRechargeService{ @Autowired IRechargeDao rdao; @Override public int addRechargeDetails(Recharge rech) { int b=rdao.addRechargeDetails(rech); return b; } @Override public ArrayList<Recharge> getAllRechargeInfo() { return rdao.getAllRechargeInfo(); } }
071e1e89cbee7c48ba982a27a0056d19cecc5bcd
491d68d006314de605de28a3be398d3bef20b8c3
/src/main/java/x3d/fields/MFFloat.java
190757e63d4b757d0f07cda9d74ac1309fc4d9d8
[ "Apache-2.0" ]
permissive
VT-Visionarium/osnap
c0afeace5c07686d2897f874da92c2bf782fd512
3055447ef2017b0184282ed5d6fb1e71a0d372f1
refs/heads/master
2021-01-15T15:51:26.043422
2019-01-11T02:05:19
2019-01-11T02:05:19
25,793,629
1
0
null
null
null
null
UTF-8
Java
false
false
1,918
java
/* * To change this template, choose Tools | Templates and open the template in * the editor. */ package x3d.fields; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; import java.util.StringTokenizer; import java.util.ArrayList; /** * * @author peter */ @XmlAccessorType(XmlAccessType.NONE) @XmlType(name = "MFFloat") @XmlRootElement(name = "MFFloat") public class MFFloat extends X3DArrayField<SFFloat> { public MFFloat() { super(); } public MFFloat(Float... values) { super(); for (Float value : values) { this.add(value); } } public MFFloat(SFFloat... values) { super(); for (SFFloat value : values) { this.add(value); } } public void add(Float value) { this.getValue().add(new SFFloat(value)); } @Override @XmlValue public String getStringValue() { return this.toString(); } @Override public void setStringValue(String value) { ArrayList<String> tokenList = this.getListFromString(value); for (String token : tokenList) { StringTokenizer tokenizer = new StringTokenizer(token, " ", false); while (tokenizer.hasMoreTokens()) { try { String firstToken = tokenizer.nextToken(); Float firstValue = Float.parseFloat(firstToken); SFFloat sfFloat = new SFFloat(); sfFloat.setValue(firstValue); this.add(sfFloat); } catch (Exception ex) { throw new IllegalArgumentException(ex.getMessage()); } } } } }
e09909ae8f046d76c534ffe5ade67d5728b4db36
0e325187e4fffbb97ebcab6c3b383a0b85c0d130
/assignment2_part1/src/Business/Patient.java
d7f4f9930ae4cdf5bb9c722aed0ebda6e1415819
[]
no_license
rohit-khokle/khokle_rohit_001029550
56f4b1f88df35653c85d79b159c9d9272e7135ea
aacb9ab08b28802869297f1427e4a3575847ebc5
refs/heads/master
2022-04-21T07:05:03.087785
2020-04-20T20:15:47
2020-04-25T20:15:47
233,949,232
0
0
null
null
null
null
UTF-8
Java
false
false
3,995
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Business; /** * * @author Rohit */ public class Patient { String name; int age; float height; VitalSigns vitalSigns; public Patient(String name, int age, float height, VitalSigns vitalSigns) { this.name = name; this.age = age; this.height = height; this.vitalSigns = vitalSigns; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(short age) { this.age = age; } public float getHeight() { return height; } public void setHeight(float height) { this.height = height; } public VitalSigns getVitalSigns() { return vitalSigns; } public void setVitalSigns(VitalSigns vitalSigns) { this.vitalSigns = vitalSigns; } public boolean isPatientNormal() { int age = this.age; VitalSigns vitals = this.vitalSigns; double heartRt = vitals.getHeartRt(); double resRt = vitals.getRespiratoryRt(); double bp = vitals.getSysBP(); double wt = vitals.getWght(); double wtp = vitals.getWghtP(); // converting age to months // age = age*12; // New Born if(age < 1 ){ if((resRt >= 30 && resRt <= 50) && ( heartRt >= 120 && heartRt <= 160) && ( bp >= 50 && bp<= 70) && (wt >= 2 && wt <= 3) && (wtp >= 4.5 && wtp <= 7)){ return true; } } // Infant (1-12 months) if(age >= 1 && age < 12){ if((resRt >= 20 && resRt <= 30 ) && ( heartRt >= 80 && heartRt <= 140) && ( bp >= 70 && bp<= 100) && (wt >= 4 && wt <= 10) && (wtp >= 9 && wtp <= 22)){ return true; } } // Toodler (1-3 years) if(age >= 12 && age < 36){ if((resRt >= 20 && resRt <= 30 ) && ( heartRt >= 80 && heartRt <= 130 ) && ( bp >= 80 && bp<= 110 ) && (wt >= 10 && wt <= 14 ) && (wtp >= 22 && wtp <= 31)){ return true; } } // Preschooler (3-5 years) if(age >= 36 && age <= 60){ if((resRt >= 20 && resRt <= 30 ) && ( heartRt >= 80 && heartRt <= 120 ) && ( bp >= 80 && bp<= 110) && (wt >= 14 && wt <= 18) && (wtp >= 31 && wtp <= 40)){ return true; } } // School age (6-12) if(age >= 72 && age <= 144){ if((resRt >= 20 && resRt <= 30) && ( heartRt >= 70 && heartRt <= 110) && ( bp >= 80 && bp<= 120) && (wt >= 20 && wt <= 42) && (wtp >= 40 && wtp <= 93)){ return true; } } // Adolescent (13+) if(age >= 156){ if((resRt >= 12 && resRt <= 20) && ( heartRt >= 55 && heartRt <= 105 ) && ( bp >= 110 && bp<= 120) && (wt > 50) && (wtp > 110)){ return true; } } return false; } @Override public String toString() { return "Patient{" + "name=" + name + ", age=" + age/12 + ", height=" + height + ", vitalSigns=" + vitalSigns + '}'; } }
1944ab5251fb91279debbae7a66c9ea0694be46f
86314d9fcf2f05ee0f35cd2666264fd4e377954b
/Core/src/com/core/reflective/ObjectAnalyzerTest.java
51e107ce76da937297731ee6d856acd7c883c524
[]
no_license
ToWorkit/Java
60f387c74163ea262a6309dad842d63b1dbcfa21
2a6dae98f5c87a96d9767c30f214b7b75d704167
refs/heads/master
2021-04-06T08:51:32.908245
2018-09-27T02:14:52
2018-09-27T02:14:52
124,810,589
1
0
null
null
null
null
UTF-8
Java
false
false
314
java
package com.core.reflective; import java.util.ArrayList; public class ObjectAnalyzerTest { public static void main(String[] args) { ArrayList<Integer> squares = new ArrayList<>(); for (int i = 1; i <= 5; i++) { squares.add(i * i); } // System.out.println(new ObjectAnalyzer().toString(squares)); } }
6418eb2f2b29d2a45d7978a9bc052e5f2ebbbe54
135551bcd51b0a6f1594bc01b1489b1b54ea474d
/src/java/com/myapifilms/data/ObjectFactory.java
852cba925e9e7c142ce30be73d8d9bba820a9202
[]
no_license
tjulinfan-zz/MovieSearchWebservice
d70827849ca5a7646fe853df9033f0f37397d55f
a119b22524fa1a4c624dbe691d73a3e2943e93a0
refs/heads/master
2021-05-26T22:51:30.615498
2014-04-09T16:08:58
2014-04-09T16:08:58
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,375
java
// // ���ļ����� JavaTM Architecture for XML Binding (JAXB) ����ʵ�� v2.2.5-2 ��ɵ� // ����� <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // �����±���Դģʽʱ, �Դ��ļ��������޸Ķ�����ʧ�� // ���ʱ��: 2014.04.07 ʱ�� 08:11:04 PM CST // package com.myapifilms.data; import javax.xml.bind.annotation.XmlRegistry; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the com.myapifilms.data package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. * */ @XmlRegistry public class ObjectFactory { /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.myapifilms.data * */ public ObjectFactory() { } /** * Create an instance of {@link MAFMovie } * */ public MAFMovie createMovie() { return new MAFMovie(); } /** * Create an instance of {@link Movie.Countries } * */ public MAFMovie.Countries createMovieCountries() { return new MAFMovie.Countries(); } /** * Create an instance of {@link Movie.Directors } * */ public MAFMovie.Directors createMovieDirectors() { return new MAFMovie.Directors(); } /** * Create an instance of {@link Movie.Genres } * */ public MAFMovie.Genres createMovieGenres() { return new MAFMovie.Genres(); } /** * Create an instance of {@link Movie.Languages } * */ public MAFMovie.Languages createMovieLanguages() { return new MAFMovie.Languages(); } /** * Create an instance of {@link Movie.Writers } * */ public MAFMovie.Writers createMovieWriters() { return new MAFMovie.Writers(); } }
ea3ef45c232c725223adddaa4f0907499bbbcfd1
7efbda1bff2d304f9f86259ece5127dc9ee69111
/BIServer/src/main/java/com/jaspersoft/jasperserver/war/dto/ReportUnitWrapper.java
3e8c42325f160c2c93f2fb9b189d8e95ede5f442
[]
no_license
kalyansvm/biproject
8f1bafd57b4cb8affa443a394dee2e774b9a9992
482b461f3b05b33b9a468526c5a59ed98dd4551c
refs/heads/master
2021-01-10T09:34:25.669950
2009-05-13T01:50:17
2009-05-13T01:50:17
50,026,186
0
0
null
null
null
null
UTF-8
Java
false
false
6,178
java
/* * Copyright (C) 2005 - 2007 JasperSoft Corporation. All rights reserved. * http://www.jaspersoft.com. * * Unless you have purchased a commercial license agreement from JasperSoft, * the following license terms apply: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed WITHOUT ANY WARRANTY; and without the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt * or write to: * * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, * Boston, MA USA 02111-1307 */ package com.jaspersoft.jasperserver.war.dto; import java.util.List; import com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit; public class ReportUnitWrapper extends BaseDTO { private List existingResources; // List of resource names already present in the chosen folder private ReportUnit reportUnit; private List suggestedResources; private List suggestedControls; private List reusableJrxmls; private String source; private byte[] jrxmlData; private String jrxmlUri; private String oldJrxmlUri;//TODO remove? private String originalJrxmlUri;//TODO remove? private String validationMessage; private boolean jrxmlChanged; private boolean jrxmlLocated; private boolean result; private boolean named; private boolean datasourceIdentified; private List reports; private boolean hasNonSuggestedResources; private boolean hasSuggestedResources; private boolean hasNonSuggestedControls; private boolean hasSuggestedControls; private String inputControlSource; private String inputControlPath; private List inputControlList; public boolean isHasNonSuggestedResources() { return hasNonSuggestedResources; } public void setHasNonSuggestedResources(boolean hasNonSuggestedResources) { this.hasNonSuggestedResources = hasNonSuggestedResources; } public boolean isHasSuggestedResources() { return hasSuggestedResources; } public void setHasSuggestedResources(boolean hasSuggestedResources) { this.hasSuggestedResources = hasSuggestedResources; } public boolean isDatasourceIdentified() { return datasourceIdentified; } public void setDatasourceIdentified(boolean datasourceIdentified) { this.datasourceIdentified = datasourceIdentified; } public boolean isNamed() { return named; } public void setNamed(boolean named) { this.named = named; } public boolean isJrxmlChanged() { return jrxmlChanged; } public void setJrxmlChanged(boolean jrxmlChanged) { this.jrxmlChanged = jrxmlChanged; setJrxmlLocated(true); } public String getSource() { return source; } public void setSource(String source) { this.source = source; } public List getReusableJrxmls() { return reusableJrxmls; } public void setReusableJrxmls(List reusableJrxmls) { this.reusableJrxmls = reusableJrxmls; } public ReportUnit getReportUnit() { return reportUnit; } public void setReportUnit(ReportUnit reportUnit) { this.reportUnit = reportUnit; } public String getOldJrxmlUri() { return oldJrxmlUri; } public void setOldJrxmlUri(String oldJrxmlUri) { this.oldJrxmlUri = oldJrxmlUri; } public String getOriginalJrxmlUri() { return originalJrxmlUri; } public void setOriginalJrxmlUri(String originalJrxmlUri) { this.originalJrxmlUri = originalJrxmlUri; } public boolean isJrxmlLocated() { return jrxmlLocated; } public void setJrxmlLocated(boolean jrxmlLocated) { this.jrxmlLocated = jrxmlLocated; } public byte[] getJrxmlData() { return jrxmlData; } public void setJrxmlData(byte[] jrxmlData) { this.jrxmlData = jrxmlData; } public String getJrxmlUri() { return jrxmlUri; } public void setJrxmlUri(String jrxmlUri) { this.jrxmlUri = jrxmlUri; } public List getSuggestedControls() { return suggestedControls; } public void setSuggestedControls(List controlWrappers) { this.suggestedControls = controlWrappers; } public List getSuggestedResources() { return suggestedResources; } public void setSuggestedResources(List resourceWrappers) { this.suggestedResources = resourceWrappers; } public boolean isHasNonSuggestedControls() { return hasNonSuggestedControls; } public void setHasNonSuggestedControls(boolean hasNonSuggestedControls) { this.hasNonSuggestedControls = hasNonSuggestedControls; } public boolean isHasSuggestedControls() { return hasSuggestedControls; } public void setHasSuggestedControls(boolean hasSuggestedControls) { this.hasSuggestedControls = hasSuggestedControls; } public boolean getResult() { return result; } public void setResult(boolean result) { this.result = result; } public List getReports() { return reports; } public void setReports(List reports) { this.reports = reports; } public String getValidationMessage() { return validationMessage; } public void setValidationMessage(String validationMessage) { this.validationMessage = validationMessage; } public List getExistingResources() { return existingResources; } public void setExistingResources(List existingResources) { this.existingResources = existingResources; } public List getInputControlList() { return inputControlList; } public void setInputControlList(List inputControlList) { this.inputControlList = inputControlList; } public String getInputControlPath() { return inputControlPath; } public void setInputControlPath(String inputControlPath) { this.inputControlPath = inputControlPath; } public String getInputControlSource() { return inputControlSource; } public void setInputControlSource(String inputControlSource) { this.inputControlSource = inputControlSource; } }
17c22f712a15c3cb5398cdce54db04232d302dd8
e265c21fbfed72d49b247c9b3a8e27744698e7eb
/src/main/java/vorobss/blpractice/dao/countrie/CountrieDaoImpl.java
9f89e44283f634571c5352a842a8551330c68dbd
[]
no_license
VorobSS/BL_Practice
ffedd19edb080bf60d2003a1b223e3110299138b
0d43a6e107a7df03aa4b674b3c5fb379bf709a69
refs/heads/master
2020-04-08T04:10:48.706576
2018-12-28T11:13:36
2018-12-28T11:13:36
159,006,247
0
0
null
null
null
null
UTF-8
Java
false
false
1,774
java
package vorobss.blpractice.dao.countrie; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import vorobss.blpractice.model.Countrie; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import java.util.List; /** * {@inheritDoc} */ @Repository public class CountrieDaoImpl implements CountrieDao { private final EntityManager em; @Autowired public CountrieDaoImpl(EntityManager em) { this.em = em; } /** * {@inheritDoc} */ @Override public List<Countrie> all() { TypedQuery<Countrie> query = em.createQuery("SELECT p FROM Countrie p", Countrie.class); return query.getResultList(); } /** * {@inheritDoc} */ @Override public Countrie loadById(Long id) { return em.find(Countrie.class, id); } /** * {@inheritDoc} */ @Override public void save(Countrie countrie) { em.persist(countrie); } private CriteriaQuery<Countrie> buildCriteria(String name, String fullName, int inn, int kpp ) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Countrie> criteria = builder.createQuery(Countrie.class); Root<Countrie> countrie = criteria.from(Countrie.class); criteria.where(builder.equal(countrie.get("name"), name)); criteria.where(builder.equal(countrie.get("fullName"), fullName)); criteria.where(builder.equal(countrie.get("inn"), inn)); criteria.where(builder.equal(countrie.get("kpp"), kpp)); return criteria; } }
d389b99ed9ab1dd301c522d2c2c8474edb66bc1a
b784f8cfef0da32aa6bfa6facd2aec35e16a1c32
/src/test/java/com/ning/http/client/ws/grizzly/GrizzlyProxyTunnellingTest.java
a7c7f13bbcb6bbdfa52aff6c0e46d16ed8fe4fca
[ "Apache-2.0" ]
permissive
eclipse-ee4j/grizzly-ahc
2aa4c47a3aef8cdf97fa4ff04a16208369752b69
d29c1758de779ec56bdc51978b87ffbf17853ee9
refs/heads/master
2023-07-31T23:23:27.231555
2022-01-04T21:39:14
2022-01-04T21:39:14
144,562,012
8
5
Apache-2.0
2022-12-03T00:15:02
2018-08-13T10:05:00
Java
UTF-8
Java
false
false
1,287
java
/* * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014 AsyncHttpClient Project. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. * * Unless required by applicable law or agreed to in writing, * software distributed under the Apache License Version 2.0 is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. */ package com.ning.http.client.ws.grizzly; import org.testng.annotations.Test; import com.ning.http.client.AsyncHttpClient; import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.async.ProviderUtil; import com.ning.http.client.ws.ProxyTunnellingTest; @Test public class GrizzlyProxyTunnellingTest extends ProxyTunnellingTest { @Override public AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) { return ProviderUtil.grizzlyProvider(config); } }
455ae299e655f71566bfe0ee0905634092b30d03
1fcc8ce882447b97c0b9411db44cbf4fc27346d6
/app/sample/Placement.java
bda2d1574adf9747f18be40c1bd8167f3aed24d9
[]
no_license
Paul-Tra/PLONG-SQL-Dependencies
cb37b0e999baad2ef9aba46f975cd9764ab784b2
7ae2683a638750ca9255826bf6e4d182b8d9c59a
refs/heads/master
2022-11-12T23:20:12.435058
2020-06-01T18:11:35
2020-06-01T18:11:35
274,882,837
1
0
null
null
null
null
UTF-8
Java
false
false
10,138
java
package sample; import java.util.ArrayList; import java.util.HashMap; import java.util.Random; public class Placement { /** * internal node class */ private class Node{ protected double x ; protected double y ; protected double dx ; protected double dy ; public Node() { } /** * affects random values to x and y * @param width bound for x * @param height bound for y */ public void randPos(double width, double height) { this.x = new Random().nextDouble() * width; this.y = new Random().nextDouble() * height; } public void setPos(double x, double y) { this.x = x; this.y = y; } public void setDisp(double dx, double dy) { this.dx = dx; this.dy = dy; } /** * adds values to dx and dy attributes * @param dx * @param dy */ public void addDisp(double dx, double dy) { this.dx += dx; this.dy += dy; } } /** * internal edge class */ private class Edge{ private Node u; private Node v; public Edge(Node depart, Node arrivee) { this.u = depart; this.v = arrivee; } } int iterations; boolean optimum = false; int nb_node; ArrayList<Node> nodes = new ArrayList<>(); ArrayList<Edge> edges = new ArrayList<>(); HashMap<Integer,String> map = new HashMap<>(); double width; double heigth; private final int NB_ITERATONS = 1000; private static final double IDEAL_COEFFICIENT = 4.6; private double temperature; // is the maximum amount of movement allowed for a node public Placement(ArrayList<Transaction> transactions, ArrayList<Relation> relations, double width, double height) { this.nb_node = transactions.size(); this.width = width; this.heigth = height; fillAttributes(transactions, relations); fruchtermanReingold(); } /** * applies Fruchterman-Reingold force-directed layout algorithm * @see */ public void fruchtermanReingold(){ temperature = width / 10; double cooling = temperature / (NB_ITERATONS + 1); double area = width * heigth; double k = Math.sqrt(area / nb_node)*IDEAL_COEFFICIENT; while (iterations < NB_ITERATONS) { manageFRPlacement(cooling, k); } } /** * applies a loop turn of Fruchterman-Reingold algorithm * * @param cooling value to subtract to the temperature at each loop turn * @param k ideal size of edge */ private void manageFRPlacement(double cooling, double k) { for (Node node : nodes) { node.setDisp(0, 0); for (Node node1 : nodes) { if (!node.equals(node1)) { double dx = node.x - node1.x; double dy = node.y - node1.y; double delta = Math.sqrt((dx * dx) + (dy * dy)); if (delta != 0) { double d = repulsiveForce(delta, k) / delta; node.addDisp(dx * d, dy * d); } } } } // calculate attractive forces (only between neighbors) for (Edge e : edges) { double dx = e.v.x - e.u.x; double dy = e.v.y - e.u.y; double delta = Math.sqrt(dx * dx + dy * dy); if (delta != 0) { double d = attractiveForce(delta, k) / delta; double ddx = dx * d; double ddy = dy * d; e.v.addDisp(-ddx, -ddy); e.u.addDisp(+ddx, +ddy); } } optimum = true; for (Node v : nodes) { double dx = v.dx; double dy = v.dy; double delta = Math.sqrt((dx * dx) + (dy * dy)); if (delta != 0) { double d = Math.min(delta, temperature) / delta; double x = v.x + dx * d; double y = v.y + dy * d; x = Math.min(width, Math.max(0, x)) - width / 2; y = Math.min(heigth, Math.max(0, y)) - heigth / 2; v.setPos(Math.min(Math.sqrt((width * width / 4) - (y * y)), Math.max(-Math.sqrt((width * width / 4) - (y * y)), x)) + (width / 2), Math.min(Math.sqrt(Math.abs((heigth * heigth / 4) - (x * x))), Math.max(-Math.sqrt(Math.abs((heigth * heigth / 4) - (x * x))), y))+ (heigth / 2)); } } temperature -= cooling; iterations++; } /** * applies repulsion force from d and k * @param d * @param k * @return the corresponding value from parameters with repulsive force applying */ private double repulsiveForce(double d, double k) { return (k * k) / d; } /** * applies attraction force from d and k * @param d * @param k * @return the corresponding value from parameters with attractive force applying */ private double attractiveForce(double d, double k) { return (d * d) / k; } /** * places the transactions at the same positions as the corresponding nodes * * @param transactions list of transaction that we want to place */ public void placementTransaction(ArrayList<Transaction> transactions) { if (transactions.size() != nodes.size()) { System.out.println("there is an issue with th transactions list"); return; } for (int i = 0; i < nodes.size(); i++) { transactions.get(i).getRectangle().setLayoutX((int) nodes.get(i).x); transactions.get(i).getRectangle().setLayoutY((int) nodes.get(i).y); } } /** * looks after the filling of the different structures * * @param transactions * @param relations */ private void fillAttributes(ArrayList<Transaction> transactions, ArrayList<Relation> relations){ initNodes(); fillMap(transactions); initEdges(relations); } /** * fill the map with transaction's id as content from transaction's list * * @param transactions transaction's list */ private void fillMap(ArrayList<Transaction> transactions) { // begin at 1 and not 0 to have a default bad value as 0 for test for (int i = 1; i < transactions.size()+1; i++) { map.put(i, transactions.get(i-1).getId()); } } /** * Initialize and put nodes in the node list with random coordinates */ private void initNodes() { for (int i = 0; i < nb_node ; i++) { Node n = new Node(); n.randPos(width, heigth); nodes.add(n); } } /** * Initialize the edges corresponding to the relations * * @param relations relations that we to initialize under edge's shape */ private void initEdges(ArrayList<Relation> relations){ for (int i = 0; i < relations.size(); i++) { int u = getMapIntFromString(relations.get(i).getSource().getId()); int v = getMapIntFromString(relations.get(i).getTarget().getId()); Edge e = new Edge(nodes.get(u), nodes.get(v)); edges.add(e); } } /** * find a key in by the content in the map * * @param s content that we want to match in the map to find its key * @return the key of the content representing by s */ private int getMapIntFromString(String s) { for (int i = 1; i < map.size() ; i++) { if (map.get(i).equals(s)) { return i; } } return 0; // default bad value } } /* // calculate repulsive forces (from every vertex to every other) for (Vertex v : graph.vertexSet()) { // reset displacement vector for new calculation v.getDisp().set(0, 0); for (Vertex u : graph.vertexSet()) { if (!v.equals(u)) { // normalized difference position vector of v and u Vector2d deltaPos = new Vector2d(); deltaPos.sub(v.getPos(), u.getPos()); double length = deltaPos.length(); deltaPos.normalize(); // displacement depending on repulsive force deltaPos.scale(this.forceRepulsive(length, k)); v.getDisp().add(deltaPos); } } } // calculate attractive forces (only between neighbors) for (Edge e : graph.edgeSet()) { // normalized difference position vector of v and u Vector2d deltaPos = new Vector2d(); deltaPos.sub(e.getV().getPos(), e.getU().getPos()); double length = deltaPos.length(); deltaPos.normalize(); // displacements depending on attractive force deltaPos.scale(this.forceAttractive(length, k)); e.getV().getDisp().sub(deltaPos); e.getU().getDisp().add(deltaPos); } // assume equilibrium equilibriumReached = true; for (Vertex v : graph.vertexSet()) { Vector2d disp = new Vector2d(v.getDisp()); double length = disp.length(); // no equilibrium if one vertex has too high net force if (length > criterion) { equilibriumReached = false; } // System.out.print((int)length + "; "); // limit maximum displacement by temperature t disp.normalize(); disp.scale(Math.min(length, t)); v.getPos().add(disp); // prevent being displaced outside the frame v.getPos().x = Math.min(frameWidth, Math.max(0.0, v.getPos().x)); v.getPos().y = Math.min(frameHeight, Math.max(0.0, v.getPos().y)); } // System.out.println(); // reduce the temperature as the layout approaches a better // configuration but always let vertices move at least 1px t = Math.max(t * (1 - coolingRate), 1); // System.out.println("t: " + (float) t); try { Thread.sleep(delay); } catch (InterruptedException e1) { e1.printStackTrace(); } iteration++; } */
52b68d9574111516f96a1fbe00325a341755db88
bf5d71b032cf2a0f68dc7c3fab7fa9ae4e061d7c
/app/src/main/java/com/jaden/htlabel/view/HtModel4.java
12030ac265fdf733a622971ee12d22001274adde
[]
no_license
jadennn/HtLabel
d82552b093040d0852176febe85a7d8c59e1d2c3
7e6b15ce79fc36a629f747f7f03c1cefb969c8a0
refs/heads/master
2020-04-12T03:01:41.106251
2018-12-25T14:32:27
2018-12-25T14:32:27
162,261,398
0
1
null
null
null
null
UTF-8
Java
false
false
1,591
java
package com.jaden.htlabel.view; import android.graphics.Color; import android.graphics.RectF; import android.view.MotionEvent; import com.jaden.htlabel.bean.Label; import com.jaden.htlabel.bean.Model; import com.jaden.htlabel.interfaces.HtModel; import com.jaden.htlabel.utils.DateUtil; import com.jaden.htlabel.utils.DensityUtil; import com.jaden.htlabel.utils.LabelUtil; /** * Created Date: 2018/12/14 * Description: */ public class HtModel4 extends HtModel{ @Override public Label createLabel(MotionEvent event) { Label label = new Label(); label.setBackgroundColor(Color.parseColor("#49b7c8")); label.setSpaceX(DensityUtil.dp2px(3)); label.setSpaceY(DensityUtil.dp2px(3)); label.setTextColor(Color.parseColor("#ffffff")); label.setTextSize((int) DensityUtil.dp2px(14)); label.setText(""); label.setDate(DateUtil.getFormatDate()); label.setDateSize((int) DensityUtil.dp2px(8)); label.setDateColor(Color.parseColor("#ffffff")); label.setX(event.getX() - LabelUtil.measureLabelDateW(label) / 2); //绘制中间的位置为触摸的位置 label.setY(event.getY()); return label; } @Override public Model createModel(RectF rectF) { this.rectF.set(rectF); Model model = new Model(); model.setRectF(rectF); model.setBgColor(Color.parseColor("#49b7c8")); model.setTextColor(Color.parseColor("#ffffff")); model.setTextSize((int) DensityUtil.dp2px(14)); model.setText("胡兔"); return model; } }
b992f31ef7bfbe70d8e04ea0c7625f5d4cd421ac
2959f38e5804947d52e14cf0a6e0b4aa8d2da4f2
/app/src/main/java/it/liehr/mls_app/ActivityLearn.java
e9cd64f48e4e61eb34fdc8d9ec6b463d9c7c14cd
[ "MIT" ]
permissive
adibaba/MLS_Lernanwendung
50ac872b8f3354a6acdc980ea479f32fb18bde1b
dcafd50b8eab5c44c205d7cb41e0a6beb0d8942b
refs/heads/master
2021-01-19T22:15:20.750741
2017-04-19T08:42:01
2017-04-19T08:42:01
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,858
java
package it.liehr.mls_app; import android.app.Activity; import android.content.Intent; import android.database.SQLException; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; import java.util.List; import Components.Assessment; import Components.DragAssessment; import Components.HotspotAssessment; import Components.MultipleChoiceAssessment; import Components.SingleChoiceAssessment; import Components.TableAssessment; import Comprehensive.DatabaseHelper; import Comprehensive.UsersAssessmentResponse; public class ActivityLearn extends AppCompatActivity { // region object variables public List<Assessment> assessments = new ArrayList<Assessment>(); String[] assessmentIds; private int currentAssessmentIndex = 0; public static int assessmentsToProcess = 0; // endregion // region object methods public void loadAssessments() { // load from database DatabaseHelper helper = new DatabaseHelper(this); // iterate through ids for(String id:this.assessmentIds) { try { // get assessment type String assessmentIdentifier = helper.getAssessmentIdentifierById(Long.valueOf(id)); // id long aId = Long.valueOf(id); // distinguish between types switch (assessmentIdentifier) { case "choice": { SingleChoiceAssessment singleChoiceAssessment = helper.getSingleChoiceAssessment(aId); singleChoiceAssessment.setContext(this); this.assessments.add(singleChoiceAssessment); break; } case "choiceMultiple": { MultipleChoiceAssessment multipleChoiceAssessment = helper.getMultipleChoiceAssessment(aId); multipleChoiceAssessment.setContext(this); this.assessments.add(multipleChoiceAssessment); break; } case "positionObjects": { HotspotAssessment hotspotAssessment = helper.getHotspotAssessment(aId); hotspotAssessment.setContext(this); this.assessments.add(hotspotAssessment); break; } case "table": { TableAssessment tableAssessment = helper.getTableAssessment(aId); tableAssessment.setContext(this); this.assessments.add(tableAssessment); break; } case "dragndropTable": { DragAssessment dragAssessment = helper.getDragAssessment(aId); dragAssessment.setContext(this); this.assessments.add(dragAssessment); break; } } } catch (SQLException se) { Log.e("Error", "SQL Error in Activity Learn: " + se.getMessage()); Log.e("Error", "SQL Error in Activity Learn: (File / Class / Method / Linenumber): " + se.getStackTrace()[0].getFileName() + " / " + se.getStackTrace()[0].getClassName() + " / " + se.getStackTrace()[0].getMethodName() + " / " + se.getStackTrace()[0].getLineNumber()); } catch (Exception e) { Log.e("Error", "Error in Activity Learn: " + e.getMessage()); Log.e("Error", "Error in Activity Learn: (File / Class / Method / Linenumber): " + e.getStackTrace()[0].getFileName() + " / " + e.getStackTrace()[0].getClassName() + " / " + e.getStackTrace()[0].getMethodName() + " / " + e.getStackTrace()[0].getLineNumber()); } } } // endregion // region button onclick methods public void btnPrevAssessmentOnClick(View view) { // check next index position if (this.currentAssessmentIndex - 1 >= 0) { // on next prev position is an assessment if(this.currentAssessmentIndex - 1 == 0) { // next assessment will be the first view.setEnabled(false); } this.currentAssessmentIndex -= 1; this.findViewById(R.id.btnNextAssessment).setEnabled(true); this.displayAssessment(this.currentAssessmentIndex); //this.assessments.get(this.currentAssessmentIndex).setHowSolved(UsersAssessmentResponse.Wrong); ((LinearLayout) this.findViewById(R.id.layoutAssessmentHandling)).removeAllViews(); } else { // already reached end } // check index == 0 if (this.currentAssessmentIndex == 0) { Button prevButton = (Button) this.findViewById(R.id.btnPrevAssessment); prevButton.setEnabled(false); } } public void btnNextAssessmentOnClick(View view) { // check next index position if(this.currentAssessmentIndex + 1 <= this.assessments.size()-1) { // on next position is an assessment if(this.currentAssessmentIndex + 1 == this.assessments.size()-1) { // next position is last assessment view.setEnabled(false); } this.currentAssessmentIndex += 1; this.findViewById(R.id.btnPrevAssessment).setEnabled(true); this.displayAssessment(this.currentAssessmentIndex); //this.assessments.get(this.currentAssessmentIndex).setHowSolved(UsersAssessmentResponse.Wrong); ((LinearLayout) this.findViewById(R.id.layoutAssessmentHandling)).removeAllViews(); } else { // already reached end } // check prev index position if(this.currentAssessmentIndex + 1 >= 1) { Button prevButton = (Button) this.findViewById(R.id.btnPrevAssessment); prevButton.setEnabled(true); } // check index == 0 if(this.currentAssessmentIndex == 0) { Button prevButton = (Button) this.findViewById(R.id.btnPrevAssessment); prevButton.setEnabled(false); } } // endregion private void displayAssessment(int index) { // check if index is in range if(!(currentAssessmentIndex >= 0 && currentAssessmentIndex <= assessments.size()-1)) { // not in range currentAssessmentIndex = 0; } // index dot GradientDrawable dotBackground = new GradientDrawable(); dotBackground.setShape(GradientDrawable.RECTANGLE); dotBackground.setStroke(1, Color.rgb(0, 0, 0)); dotBackground.setColor(Color.rgb(255, 255, 255)); GradientDrawable dotCurrentBackground = new GradientDrawable(); dotCurrentBackground.setShape(GradientDrawable.RECTANGLE); dotCurrentBackground.setStroke(1, Color.rgb(0, 0, 0)); dotCurrentBackground.setColor(Color.rgb(89, 166, 238)); LinearLayout linearLayoutAssessmentIndex = (LinearLayout) findViewById(R.id.linearLayoutAssessmentIndex); for(int i=0;i < linearLayoutAssessmentIndex.getChildCount();i++) { if(i == currentAssessmentIndex) { TextView tv = (TextView) linearLayoutAssessmentIndex.getChildAt(i); tv.setBackground(dotCurrentBackground); } else { TextView tv = (TextView) linearLayoutAssessmentIndex.getChildAt(i); tv.setBackground(dotBackground); } } String assessmentType = this.assessments.get(index).getIdentifier(); LinearLayout targetLinearLayout = (LinearLayout) findViewById(R.id.linearLayoutAssessmentContent); switch (assessmentType) { case "choice": ((SingleChoiceAssessment) this.assessments.get(index)).displayAssessment(this, targetLinearLayout); break; case "choiceMultiple": ((MultipleChoiceAssessment) this.assessments.get(index)).displayAssessment(this, targetLinearLayout); break; case "positionObjects": ((HotspotAssessment) this.assessments.get(index)).displayAssessment(this, targetLinearLayout); break; case "table": ((TableAssessment) this.assessments.get(index)).displayAssessment(this, targetLinearLayout); break; case "dragndropTable": ((DragAssessment) this.assessments.get(index)).displayAssessment(this, targetLinearLayout); break; } } private void showAssessmentIndex() { // clear views ((LinearLayout) findViewById(R.id.linearLayoutAssessmentIndex)).removeAllViews(); if(this.assessments.size() >= 1) { // dot background GradientDrawable dotBackground = new GradientDrawable(); dotBackground.setShape(GradientDrawable.RECTANGLE); dotBackground.setStroke(1, Color.rgb(0, 0, 0)); dotBackground.setColor(Color.rgb(255, 255, 255)); // dot layout params LinearLayout.LayoutParams dotParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); dotParams.width = 50; dotParams.height = 50; dotParams.setMargins(10, 20, 10, 10); // show dots for(int i=0;i < this.assessments.size();i++) { TextView dotTextView = new TextView(this); dotTextView.setBackground(dotBackground); dotTextView.setLayoutParams(dotParams); ((LinearLayout) findViewById(R.id.linearLayoutAssessmentIndex)).addView(dotTextView); } } } // region override methods @Override protected void onStart() { super.onStart(); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_learn); // get assessment ids Intent intent = getIntent(); String ids = intent.getStringExtra("assessment_ids"); // seperate ids this.assessmentIds = ids.split(";"); // load assessments this.loadAssessments(); // assessments existing? if(this.assessments.size() > 1) { findViewById(R.id.btnNextAssessment).setEnabled(true); } // asssessment dots this.showAssessmentIndex(); // show first assessment this.displayAssessment(0); // show start info summary ActivityLearn.assessmentsToProcess = this.assessments.size(); } @Override protected void onResume() { super.onResume(); } // region menu (dot points) @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_learn_assessments, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menuItemSelection: this.finish(); return true; case R.id.menuItemExitApplication: this.finishAffinity(); return true; case R.id.menuItemMainMenu: this.finish(); return true; default: return super.onOptionsItemSelected(item); } } // endregion // endregion }
16f3d143d11e7f7972ea0edc3c45530844a8794f
f4dea340b7c6799ed4b627e9f162344291eea9d7
/app/src/main/java/com/xw/compoint/gallery/GalleryActivity.java
f5690f1ccf5c4d7de658f91c0e8e887d41e20601
[]
no_license
dzs-yaodi/ComPoint
acb7df6d909ac13e5ddf4475045ffb1db8c47439
4af22f32e740845202c71dda8cb932111b70995f
refs/heads/master
2023-07-19T06:40:52.930690
2021-08-30T10:20:47
2021-08-30T10:20:47
400,094,278
0
0
null
null
null
null
UTF-8
Java
false
false
699
java
package com.xw.compoint.gallery; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import com.xw.compoint.R; import com.xw.customrecycler.gallery.RecyclerGallery; public class GalleryActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); RecyclerGallery recyclerGallery = findViewById(R.id.recycler_gallery); GalleryAdapter galleryAdapter = new GalleryAdapter(); recyclerGallery.setAdapter(galleryAdapter); galleryAdapter.setOnItemlickListener(recyclerGallery::scrollToPosition); } }
ca7b4726f9507b77f982f70a9c0a460186fd4402
e23f76c17e34cc534359cbc6a1b5b6e854e23636
/service/service-edu/src/test/java/com/atguigu/guli/service/edu/CountCodeTest.java
e3be0b21ee6e698eea5243771e3995d28eb1690b
[]
no_license
zsf3424/guli
276932f2dad89e3c99a1d9c7133962de5a89aebd
8c5a8c405004242b354dce4d66e19800b22756cc
refs/heads/master
2022-07-17T07:27:43.715946
2019-12-10T11:49:37
2019-12-10T11:49:37
223,130,894
0
0
null
2022-06-17T02:41:39
2019-11-21T08:57:41
Java
UTF-8
Java
false
false
2,327
java
package com.atguigu.guli.service.edu; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; /** * @author zsf * @create 2019-12-05 10:19 */ public class CountCodeTest { public static void main(String[] args) { //指定统计路径 String path = "E:/Workspace";//路径需同步修改 System.out.println(path + "路径下.java文件的行数为" + getFile(path)); } public static long getFile(String path) { // 1.创建File对象,表示传入的路径的抽象形式 File file = new File(path); // 2.获取该路径下的所有子文件和子文件夹 File[] files = file.listFiles(); // 定义一个变量,用来统计行数 long lineCount = 0; // 3.遍历所有子文件和子文件夹的数组 for (File file1 : files) { // 4.判断是否是文件,并且后缀是以.java结尾,如果是,直接打印输出 if (file1.isFile() && file1.getName().endsWith(".java")) { // 统计每一个.java文件的行数 来到了这里,说明拿到了一个.java文件 BufferedReader br = null; try { // 创建字符缓冲输入流对象,封装数据源文件路径 br = new BufferedReader(new FileReader(file1)); // 循环读取文件行数据 String line; while ((line = br.readLine()) != null) { // 每读取一行就计数+1 lineCount++; } } catch (Exception e) { System.out.println("出现了异常...."); } finally { // 关闭流,释放资源 if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } } // 5.判断是否是文件夹,如果是,就递归 if (file1.isDirectory()) { lineCount += getFile(file1.getAbsolutePath()); } } return lineCount; } }
59d4dd6b5cf840cedfb88050291a7edbaf6b969b
41b0d6a4299e6aed2f5b0ea2bb857e798e8575c6
/src/main/java/leetcode/Problem102.java
0415e0b973845a1427aa6f744abff310d1027a0e
[]
no_license
tpardabe/algo
3c9c6436303f23f846af60b03fb26e65f3ed2e97
ea5ed852053ed7fd641d9f3aa08fa80b810836a2
refs/heads/master
2022-11-21T02:06:11.085179
2020-07-28T17:13:41
2020-07-28T17:13:41
112,421,451
0
0
null
null
null
null
UTF-8
Java
false
false
1,452
java
package leetcode; import sun.reflect.generics.tree.Tree; import java.util.ArrayList; import java.util.List; public class Problem102 { public static void main(String[] args) { Problem102 problem101 = new Problem102(); problem101.solve(); } public void solve(){ TreeNode p = new TreeNode(3); p.left = new TreeNode(9); TreeNode p_right = new TreeNode(20); p_right.left = new TreeNode(15); p_right.right = new TreeNode (7); p.right = p_right; List<List<Integer>> list = levelOrder(p); for(List i: list) { for(int j = 0; j < i.size(); j++) { System.out.print(i.get(j) + " "); } System.out.println(); } } public List<List<Integer>> levelOrder(TreeNode root) { List<List<Integer>> list = new ArrayList<>(); getLevel(root, list, 0); return list; } private void getLevel(TreeNode node, List<List<Integer>> list, int level) { if(node == null) return; if(list.size() <= level) list.add(level, new ArrayList<>()); list.get(level).add(node.val); getLevel(node.left, list, level + 1); getLevel(node.right, list, level + 1); } public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } }
534c3673e5a12cefa78bc43efce0a68b6388bf17
9acf7a492b08e0c6a8589c2c4ecbb97629f951c4
/app/src/main/java/com/business/app/club/ClubDao.java
fa5bcdb4909656562c008bc169dc9060b61f82dd
[]
no_license
sengeiou/Fitmix
b1b8322f46b54015410310917911b177a076846d
cf987d9dbb142aae9087b79b5299f4b38533dd4a
refs/heads/master
2020-07-02T19:36:18.578482
2019-08-06T05:31:34
2019-08-06T05:31:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,997
java
package com.business.app.club; import com.business.core.entity.club.Club; import com.business.core.mongo.BaseMongoDaoSupport; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Repository; import java.util.Collection; import java.util.List; /** * Created by sin on 2015/11/23. */ @Repository public class ClubDao extends BaseMongoDaoSupport { /** * 添加 俱乐部 * @param club 俱乐部对象 */ public void insertClub(Club club) { insertToMongo(club); } /** * 查询 俱乐部 信息 * @param ids 俱乐部编号 * @param fields 列 * @return 俱乐部信息 */ public List<Club> findClubByIds(Collection<Long> ids, String...fields) { Query query = new Query(Criteria.where("id").in(ids).and("status").is(Club.STATUS_NORMAL)); includeFields(query, fields); return getRoutingMongoOps().find(query, Club.class); } /** * 查询 俱乐部 * @param id 编号 * @param fields 列 * @return 俱乐部信息 */ public Club findClubById(Long id, String...fields) { return findEntityById(Club.class, id, fields); } /** * 查询俱乐部 信息 * @param id 俱乐部编号 * @param uid 用户编号 * @param fields 列 * @return 俱乐部信息 */ public Club findClubByIdAndUid(Long id, Integer uid, String...fields) { Query query = new Query(Criteria.where("id").is(id).and("uid").is(uid)); includeFields(query, fields); return getRoutingMongoOps().findOne(query, Club.class); } /** * 查询 用户 加入了那些俱乐部 * @param uid 用户编号 * @param fields 列 * @return 俱乐部信息 */ public List<Club> findClubByUid(Integer uid, String...fields) { Query query = new Query(Criteria.where("uid").is(uid).and("status").is(Club.STATUS_NORMAL)); includeFields(query, fields); return getRoutingMongoOps().find(query, Club.class); } /** * 查询 用户 加入了那些俱乐部 * @param uidCollections 用户编号 * @param fields 列 * @return 俱乐部信息 */ public List<Club> findClubByUid(Collection<Integer> uidCollections, String...fields) { Query query = new Query(Criteria.where("uid").in(uidCollections).and("status").is(Club.STATUS_NORMAL)); includeFields(query, fields); return getRoutingMongoOps().find(query, Club.class); } /** * 查询 俱乐部 * <p> * 根据 名称确定, 但要根据 uid (用户编号)来确定 * </p> * @param uid 用户编号 * @param name 名称 * @param fields 列 * @return 俱乐部信息 */ public Club findClubByUidName(Integer uid, String name, String...fields) { Query query = new Query(Criteria.where("uid").is(uid).and("name").is(name)); includeFields(query, fields); return getRoutingMongoOps().findOne(query, Club.class); } /** * 查询 并更新 * @param id 俱乐部编号 * @param update 更新信息 * @return 新的信息 */ public Club findAndModifyNew(Long id, Update update) { Query query = new Query(Criteria.where("id").is(id)); return getRoutingMongoOps().findAndModify(query, update, FIND_AND_MODIFY_OPTIONS_RETURN_NEW, Club.class); } public void updateClubById(Long clubId, Update update) { Query query = new Query(Criteria.where("id").is(clubId)); getRoutingMongoOps().updateFirst(query, update, Club.class); } public void updateClubByIdAndUid(Long clubId, Integer uid, Update update) { Query query = new Query(Criteria.where("id").is(clubId).and("uid").is(uid)); getRoutingMongoOps().updateFirst(query, update, Club.class); } }
8799b55c60522dc3112a6f944a168f65d7ed394a
3d0089e9082cb06b198fe655a675bcbf53055bf0
/src/test/java/org/xson/core/vo/PersonStatus.java
880a3911222252058f256eb45f9beb19422faed5
[ "Apache-2.0" ]
permissive
nearniu/xson
82ee73d82cc44025100793724144d97d7a6a3514
ce1e197ec4ef9be448ed6ca96513e886151f83a9
refs/heads/master
2021-06-19T11:44:52.034821
2017-07-27T15:58:57
2017-07-27T16:05:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
653
java
/** * Project: dubbo.test * * File Created at 2010-11-19 * $Id: PersonStatus.java 67600 2010-11-30 06:01:31Z tony.chenl $ * * Copyright 2008 Alibaba.com Croporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Alibaba Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Alibaba.com. */ package org.xson.core.vo; /** * TODO Comment of PersonStatus * * @author tony.chenl */ public enum PersonStatus { ENABLED, DISABLED }
[ "gaop@DESKTOP-27V29OR" ]
gaop@DESKTOP-27V29OR
80dfafff3162f000b1d809cbf221bc1c5eac2e5b
35029f02d7573415d6fc558cfeeb19c7bfa1e3cc
/gs-accessing-data-jpa-complete/src/main/java/hello/service/CustomerService1406.java
2bcbfbac98899a066c9d484f1fb084a80a0616f7
[]
no_license
MirekSz/spring-boot-slow-startup
e06fe9d4f3831ee1e79cf3735f6ceb8c50340cbe
3b1e9e4ebd4a95218b142b7eb397d0eaa309e771
refs/heads/master
2021-06-25T22:50:21.329236
2017-02-19T19:08:24
2017-02-19T19:08:24
59,591,530
0
2
null
null
null
null
UTF-8
Java
false
false
119
java
package hello.service; import org.springframework.stereotype.Service; @Service public class CustomerService1406 { }
[ "miro1994" ]
miro1994
460f3e057961e87c29ff9ab3e4be8b32447c2fa3
93065cd976bcf2733d0309ccb70f474265731c54
/newretail-manager/.svn/pristine/d4/d4969b712afb31e9a16afd77c1b7274abd24fe8d.svn-base
87eb4b2a7d08a12725922b7091dadbdcb20b43e0
[]
no_license
ojama/NewRetail
690b18551d844717f07a5d9a3e93bb5b7cae7a1f
3c11496fe609160b94e99e49326bf8e12bfd927c
refs/heads/master
2021-04-26T23:11:21.364996
2018-02-09T07:59:06
2018-02-09T07:59:06
null
0
0
null
null
null
null
UTF-8
Java
false
false
811
package com.newretail.mapper.custom; import java.util.List; import java.util.Map; import org.apache.ibatis.annotations.Param; import com.newretail.common.utils.JqGridResult; import com.newretail.pojo.DeliverInfoTable; import com.newretail.pojo.custom.DeliverInfoAddTable; public interface DeliverModelMapper { //测试 public List<Map<String,Object>> test(Map<String,Object> param); /** * 点击配送情况,查询当日订单(按时间倒序排列) */ List<Map<String,String>> getAllDeliverListToday(@Param(value="queryTime")String toDay); /** * 商家按配送状态+时间查询 */ List<Map<String,Object>> getDeliverListByStatus(Map<String,Object> param); /** * 管理员按照条件查询 */ List<Map<String,Object>> getDeliverListByCondition(Map<String,Object> param); }
3feb3b7163c8246deb95f54797064786f4474b95
5a82f3535d559adffe8149103ef1c7cd2848d086
/src/main/java/com/tongu/search/service/impl/IncomeServiceImpl.java
3e3cd34b905a2971ad16a47dbc77cc647d0d7868
[ "MIT" ]
permissive
wjf8882300/password
b85fcbb107f77ee2a4bd5164dc405bfaf1d12048
da74b7c1105f0ae1887743c77b601008d0439a96
refs/heads/main
2023-05-18T12:03:53.750828
2021-06-08T05:41:24
2021-06-08T05:41:24
374,875,841
0
0
null
null
null
null
UTF-8
Java
false
false
2,274
java
package com.tongu.search.service.impl; import com.tongu.search.model.bo.IncomeBO; import com.tongu.search.model.entity.Income; import com.tongu.search.repository.IncomeRepository; import com.tongu.search.service.IncomeService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.util.ArrayList; import java.util.List; @Service public class IncomeServiceImpl extends BaseServiceImpl<IncomeRepository, Income, String> implements IncomeService { @Autowired @PersistenceContext private EntityManager entityManager; @Override public List<Income> query(IncomeBO incomeBO) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<Income> query = builder.createQuery(Income.class); Root<Income> root = query.from(Income.class); // query.multiselect(root.get("id"), root.get("incomeType"), root.get("incomeDate"), root.get("amount"), root.get("remark")); List<Predicate> predicateList = new ArrayList<Predicate>(); predicateList.add(builder.equal(root.get("userId"), incomeBO.getUserId())); if(!StringUtils.isEmpty(incomeBO.getIncomeType())) { predicateList.add(builder.equal(root.get("incomeType"), incomeBO.getIncomeType())); } if(incomeBO.getStartDate() != null) { predicateList.add(builder.greaterThanOrEqualTo(root.get("incomeDate"), incomeBO.getStartDate())); } if(incomeBO.getEndDate() != null) { predicateList.add(builder.lessThan(root.get("incomeDate"), incomeBO.getEndDate())); } Predicate[] predicates = new Predicate[predicateList.size()]; predicates = predicateList.toArray(predicates); query.where(predicates); query.orderBy(builder.desc(root.get("incomeDate"))); List<Income> list = entityManager.createQuery(query).getResultList(); return list; } }
8728681175a9ec9ddf49ba87851b11308f39708a
5949e59dddb9c8bfefa30de8fc2106f4657989db
/Clear_algorithms/ClearAlgorithms_TaskFromStepicAttemptN2.java
3a0d102604a115255b138ea5bc81efa609e911d5
[]
no_license
SergeiShumilin/Java_adventures
c07d58500fb8123d01ed4d02db7d26eb08dc5f53
c8a03f5b3244b0ad16e6839bc7d3554321b0cc37
refs/heads/master
2020-03-26T15:00:50.432882
2018-08-16T17:09:59
2018-08-16T17:09:59
145,017,729
0
0
null
null
null
null
UTF-8
Java
false
false
1,280
java
package ClearAlgorithms; import java.util.Scanner; /** * Created by Sergey on 07.03.2018. */ public class TaskFromStepicAttemptN2 { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int N; N = scanner.nextInt(); System.out.println("N создано" + N); int[] a = new int[N]; int[] b = new int[N]; for (int i = 0; i < N; i++) { a[i] = scanner.nextInt(); } System.out.println("Массив а создан"); for (int i = 0; i < N; i++) { b[i] = scanner.nextInt(); } System.out.println("Массив b создан"); maxPair(a,b); } static void maxPair(int[] a, int[] b){ if (a.length==0 || b.length == 0){return;} Pair pair = new Pair(0,0,0); for (int i = b.length-1; i >= maxElement(a) ; i--) { if (a[maxElement(a)]+b[i]>pair.sum){pair.sum = a[maxElement(a)]+b[i];} } System.out.println(pair); } static int maxElement(int[] a){ int MAX = 0; for (int i = 1; i < a.length; i++) { if (a[i]>MAX){MAX = i;} } return MAX; } static class Pair { int i; int j; int sum; public Pair() { } public Pair(int i, int j, int sum) { this.i = i; this.j = j; this.sum = sum; } @Override public String toString() { return i + " " + j; } } }
17dc344958fb8cb06618a736d7b63ca91ac8499e
0f1f7332b8b06d3c9f61870eb2caed00aa529aaa
/ebean/tags/ebean-2.7.4/src/main/java/com/avaje/ebeaninternal/server/deploy/meta/DeployBeanPropertyAssocMany.java
e6acd53ed2d4c44a8504aa97c6379d557ecee1be
[]
no_license
rbygrave/sourceforge-ebean
7e52e3ef439ed64eaf5ce48e0311e2625f7ee5ed
694274581a188be664614135baa3e4697d52d6fb
refs/heads/master
2020-06-19T10:29:37.011676
2019-12-17T22:09:29
2019-12-17T22:09:29
196,677,514
1
0
null
2019-12-17T22:07:13
2019-07-13T04:21:16
Java
UTF-8
Java
false
false
5,246
java
/** * Copyright (C) 2006 Robin Bygrave * * This file is part of Ebean. * * Ebean is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * Ebean is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Ebean; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.avaje.ebeaninternal.server.deploy.meta; import com.avaje.ebean.bean.BeanCollection.ModifyListenMode; import com.avaje.ebeaninternal.server.deploy.ManyType; import com.avaje.ebeaninternal.server.deploy.TableJoin; /** * Property mapped to a List Set or Map. */ public class DeployBeanPropertyAssocMany<T> extends DeployBeanPropertyAssoc<T> { ModifyListenMode modifyListenMode = ModifyListenMode.NONE; /** * Flag to indicate manyToMany relationship. */ boolean manyToMany; /** * Flag to indicate this is a unidirectional relationship. */ boolean unidirectional; /** * Join for manyToMany intersection table. */ DeployTableJoin intersectionJoin; /** * For ManyToMany this is the Inverse join used to build reference queries. */ DeployTableJoin inverseJoin; String fetchOrderBy; String mapKey; /** * The type of the many, set, list or map. */ ManyType manyType; /** * Create this property. */ public DeployBeanPropertyAssocMany(DeployBeanDescriptor<?> desc, Class<T> targetType, ManyType manyType) { super(desc, targetType); this.manyType = manyType; } /** * When generics is not used for manyType you can specify via annotations. * <p> * Really only expect this for Scala due to a Scala compiler bug at the moment. * Otherwise I'd probably not bother support this. * </p> */ @SuppressWarnings("unchecked") public void setTargetType(Class<?> cls){ this.targetType = (Class<T>)cls; } /** * Return the many type. */ public ManyType getManyType() { return manyType; } /** * Return true if this is many to many. */ public boolean isManyToMany() { return manyToMany; } /** * Set to true if this is a many to many. */ public void setManyToMany(boolean isManyToMany) { this.manyToMany = isManyToMany; } /** * Return the mode for listening to changes to the List Set or Map. */ public ModifyListenMode getModifyListenMode() { return modifyListenMode; } /** * Set the mode for listening to changes to the List Set or Map. */ public void setModifyListenMode(ModifyListenMode modifyListenMode) { this.modifyListenMode = modifyListenMode; } /** * Return true if this is a unidirectional relationship. */ public boolean isUnidirectional() { return unidirectional; } /** * Set to true if this is a unidirectional relationship. */ public void setUnidirectional(boolean unidirectional) { this.unidirectional = unidirectional; } /** * Create the immutable version of the intersection join. */ public TableJoin createIntersectionTableJoin() { if (intersectionJoin != null){ return new TableJoin(intersectionJoin, null); } else { return null; } } /** * Create the immutable version of the inverse join. */ public TableJoin createInverseTableJoin() { if (inverseJoin != null){ return new TableJoin(inverseJoin, null); } else { return null; } } /** * ManyToMany only, join from local table to intersection table. */ public DeployTableJoin getIntersectionJoin() { return intersectionJoin; } public DeployTableJoin getInverseJoin() { return inverseJoin; } /** * ManyToMany only, join from local table to intersection table. */ public void setIntersectionJoin(DeployTableJoin intersectionJoin) { this.intersectionJoin = intersectionJoin; } /** * ManyToMany only, join from foreign table to intersection table. */ public void setInverseJoin(DeployTableJoin inverseJoin) { this.inverseJoin = inverseJoin; } /** * Return the order by clause used to order the fetching of the data for * this list, set or map. */ public String getFetchOrderBy() { return fetchOrderBy; } /** * Return the default mapKey when returning a Map. */ public String getMapKey() { return mapKey; } /** * Set the default mapKey to use when returning a Map. */ public void setMapKey(String mapKey) { if (mapKey != null && mapKey.length() > 0) { this.mapKey = mapKey; } } /** * Set the order by clause used to order the fetching or the data for this * list, set or map. */ public void setFetchOrderBy(String orderBy) { if (orderBy != null && orderBy.length() > 0) { fetchOrderBy = orderBy; } } }
5948ab5c30557a03ef52a4cc5f16609f2b764baa
84748726e8933a5df24e9f31b02ea03f04f83efb
/src/main/java/org/protege/owl/server/connect/ConfigurableCompression.java
e4fedb02c1ddf5043a71918557a57db4397173a7
[]
no_license
protegeproject/protege-server
3d80addd03572900c630c327c72d1323d7f4b8dc
a667f46f34aa8130a0a9e4d269a44707a80e43b9
refs/heads/master
2022-10-10T14:35:50.187464
2016-09-08T18:37:14
2016-09-08T18:37:14
12,231,287
24
8
null
2022-08-09T03:25:09
2013-08-20T00:59:14
Java
UTF-8
Java
false
false
139
java
package org.protege.owl.server.connect; public interface ConfigurableCompression { void setCompressionLimit(int compressionLimit); }
1ce265dba512184e6559620243424a0f587292be
72f0fd8eb0158e6d2d32a8e7aa4f3de290229972
/app-service/user/user-impl/src/main/java/com/easy/user/model/mysql/dao/defined/UserDefinedMapper.java
7166b9b9956d1afa65bd2b3d419ccd110c15095c
[]
no_license
sunnyeasy/servicebase
c924f99a1e07fa9f684cc9931c594ac4b771edf2
242d186a8ce364c754a48f9f981bd72aa4d23b8b
refs/heads/master
2022-07-01T23:47:33.452969
2020-12-04T00:50:40
2020-12-04T00:50:40
228,140,056
0
1
null
2022-06-17T02:51:05
2019-12-15T06:38:19
Java
UTF-8
Java
false
false
170
java
package com.easy.user.model.mysql.dao.defined; import com.easy.user.model.mysql.po.User; public interface UserDefinedMapper { User selectByMobile(String mobile); }
ada48a75938ddb02556907ddd963556c38a167f5
cfc692f308148017d3ec5b555d2c78cd4755d080
/src/main/java/com/diwayou/nlp/DemoNormalization.java
a0942090918c5c590d5e05a0d9bba4dcfc2faf83
[]
no_license
P79N6A/acm
be34c5676233b1fa45c68bb26df93be6cbee0368
400423dee951ae4dc5123499ad595b3ccd7bb749
refs/heads/master
2020-05-17T23:55:43.483758
2019-04-29T10:02:56
2019-04-29T10:02:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,168
java
/* * <summary></summary> * <author>hankcs</author> * <email>[email protected]</email> * <create-date>2015/5/18 16:08</create-date> * * <copyright file="DemoNormalization.java"> * Copyright (c) 2003-2015, hankcs. All Right Reserved, http://www.hankcs.com/ * </copyright> */ package com.diwayou.nlp; import com.hankcs.hanlp.HanLP; import com.hankcs.hanlp.dictionary.CustomDictionary; /** * 演示正规化字符配置项的效果(繁体->简体,全角->半角,大写->小写)。 * 该配置项位于hanlp.properties中,通过Normalization=true来开启 * 切换配置后必须删除CustomDictionary.txt.bin缓存,否则只影响动态插入的新词。 * * @author hankcs */ public class DemoNormalization { public static void main(String[] args) { HanLP.Config.Normalization = true; CustomDictionary.insert("爱听4G", "nz 1000"); System.out.println(HanLP.segment("爱听4g")); System.out.println(HanLP.segment("爱听4G")); System.out.println(HanLP.segment("爱听4G")); System.out.println(HanLP.segment("爱听4G")); System.out.println(HanLP.segment("愛聽4G")); } }
92534126128b2c7b64443119def9bdc5639b59ee
8a75b55c3c25ff1e7f94dc5bd22c92539eedb702
/src/laiClass/class_03_queue_stack_linkedList/findMinStack2.java
3fe7f7977e27d8e53bf0f272366c42514d2a455c
[]
no_license
Cookies-Yan/Algorithm_LeetCode
dcd7f07d7463612a13ad30864ce68905d91eb1f1
cf42ff3972613694edfb6a7beb8337a1925ccb31
refs/heads/master
2022-12-16T19:09:01.018292
2020-09-10T21:19:09
2020-09-10T21:19:09
294,524,593
0
0
null
null
null
null
UTF-8
Java
false
false
2,052
java
package laiClass.class_03_queue_stack_linkedList; import javafx.util.Pair; import java.util.Stack; /** * 变形2 * How to implement the min{} function when using stack with time Complexity O(1) * 直接用stack存pair节省空间 */ public class findMinStack2 { /** initialize your data structure here. */ Stack<Integer> stack1; Stack<Pair> stack2; public findMinStack2() { stack1 = new Stack<>(); stack2 = new Stack<>(); } public void push(int x) { stack1.push(x); if (stack2.isEmpty()) { stack2.push(new Pair<>(x, stack1.size())); } else { if (x < (int)stack2.peek().getKey()) { stack2.push(new Pair<>(x, stack1.size())); } } } public void pop() { if (stack1.isEmpty()) { return; } else if (stack1.size() == (int)stack2.peek().getValue()){ stack1.pop(); stack2.pop(); } else { stack1.pop(); } } public int top() { if (stack1.isEmpty()) { return -1; } return stack1.peek(); } public int getMin() { if (stack1.isEmpty()) { return -1; } else{ return (int)stack2.peek().getKey(); } } public static void main(String[] args) { findMinStack2 a = new findMinStack2(); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-1); a.push(-3); a.push(0); a.push(0); a.push(-3); a.pop(); System.out.println(a.getMin()); a.pop(); System.out.println(a.getMin()); a.pop(); System.out.println(a.getMin()); a.pop(); System.out.println(a.getMin()); a.pop(); System.out.println(a.getMin()); a.pop(); System.out.println(a.getMin()); } }
f07ab1773446e78fee659c017a2969a2a0e5d18e
cb2e0b45e47ebeb518f1c8d7d12dfa0680aed01c
/openbanking-api-soap-transform/src/main/gen/com/laegler/openbanking/soap/model/ApplicationFrequency13.java
ad95dfb27c556ecd0bff9adf7ce4cb630fa6185b
[ "MIT" ]
permissive
thlaegler/openbanking
4909cc9e580210267874c231a79979c7c6ec64d8
924a29ac8c0638622fba7a5674c21c803d6dc5a9
refs/heads/develop
2022-12-23T15:50:28.827916
2019-10-30T09:11:26
2019-10-31T05:43:04
213,506,933
1
0
MIT
2022-11-16T11:55:44
2019-10-07T23:39:49
HTML
UTF-8
Java
false
false
3,382
java
package com.laegler.openbanking.soap.model; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for ApplicationFrequency13. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="ApplicationFrequency13"&gt; * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string"&gt; * &lt;enumeration value="AccountClosing"/&gt; * &lt;enumeration value="AccountOpening"/&gt; * &lt;enumeration value="AcademicTerm"/&gt; * &lt;enumeration value="ChargingPeriod"/&gt; * &lt;enumeration value="Daily"/&gt; * &lt;enumeration value="PerItem"/&gt; * &lt;enumeration value="Monthly"/&gt; * &lt;enumeration value="OnAccountAnniversary"/&gt; * &lt;enumeration value="Other"/&gt; * &lt;enumeration value="PerHour"/&gt; * &lt;enumeration value="PerOccurrence"/&gt; * &lt;enumeration value="PerSheet"/&gt; * &lt;enumeration value="PerTransaction"/&gt; * &lt;enumeration value="PerTransactionAmount"/&gt; * &lt;enumeration value="PerTransactionPercentage"/&gt; * &lt;enumeration value="Quarterly"/&gt; * &lt;enumeration value="SixMonthly"/&gt; * &lt;enumeration value="StatementMonthly"/&gt; * &lt;enumeration value="Weekly"/&gt; * &lt;enumeration value="Yearly"/&gt; * &lt;/restriction&gt; * &lt;/simpleType&gt; * </pre> * */ @XmlType(name = "ApplicationFrequency13") @XmlEnum public enum ApplicationFrequency13 { @XmlEnumValue("AccountClosing") ACCOUNT_CLOSING("AccountClosing"), @XmlEnumValue("AccountOpening") ACCOUNT_OPENING("AccountOpening"), @XmlEnumValue("AcademicTerm") ACADEMIC_TERM("AcademicTerm"), @XmlEnumValue("ChargingPeriod") CHARGING_PERIOD("ChargingPeriod"), @XmlEnumValue("Daily") DAILY("Daily"), @XmlEnumValue("PerItem") PER_ITEM("PerItem"), @XmlEnumValue("Monthly") MONTHLY("Monthly"), @XmlEnumValue("OnAccountAnniversary") ON_ACCOUNT_ANNIVERSARY("OnAccountAnniversary"), @XmlEnumValue("Other") OTHER("Other"), @XmlEnumValue("PerHour") PER_HOUR("PerHour"), @XmlEnumValue("PerOccurrence") PER_OCCURRENCE("PerOccurrence"), @XmlEnumValue("PerSheet") PER_SHEET("PerSheet"), @XmlEnumValue("PerTransaction") PER_TRANSACTION("PerTransaction"), @XmlEnumValue("PerTransactionAmount") PER_TRANSACTION_AMOUNT("PerTransactionAmount"), @XmlEnumValue("PerTransactionPercentage") PER_TRANSACTION_PERCENTAGE("PerTransactionPercentage"), @XmlEnumValue("Quarterly") QUARTERLY("Quarterly"), @XmlEnumValue("SixMonthly") SIX_MONTHLY("SixMonthly"), @XmlEnumValue("StatementMonthly") STATEMENT_MONTHLY("StatementMonthly"), @XmlEnumValue("Weekly") WEEKLY("Weekly"), @XmlEnumValue("Yearly") YEARLY("Yearly"); private final String value; ApplicationFrequency13(String v) { value = v; } public String value() { return value; } public static ApplicationFrequency13 fromValue(String v) { for (ApplicationFrequency13 c: ApplicationFrequency13 .values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } }
77e007a49850f851f1d5cfb623bd4ed860829fab
421f0a75a6b62c5af62f89595be61f406328113b
/generated_tests/no_seeding/107_weka-weka.filters.unsupervised.attribute.FirstOrder-1.0-4/weka/filters/unsupervised/attribute/FirstOrder_ESTest.java
14a83d6514aa6fa21f4159ec675708af0d32101a
[]
no_license
tigerqiu712/evosuite-model-seeding-empirical-evaluation
c78c4b775e5c074aaa5e6ca56bc394ec03c2c7c6
11a920b8213d9855082d3946233731c843baf7bc
refs/heads/master
2020-12-23T21:04:12.152289
2019-10-30T08:02:29
2019-10-30T08:02:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
661
java
/* * This file was automatically generated by EvoSuite * Mon Oct 28 17:51:50 GMT 2019 */ package weka.filters.unsupervised.attribute; import org.junit.Test; import static org.junit.Assert.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true) public class FirstOrder_ESTest extends FirstOrder_ESTest_scaffolding { @Test public void notGeneratedAnyTest() { // EvoSuite did not generate any tests } }
194e4c80fda57df1b3e35c4170df099ad189c8e4
526997758b12f1ad7114bf6187019989aa21c4f1
/dolphin-core/src/main/java/fr/bmqt/dolphin/network/packets/play/server/SKeepAlivePacket.java
b6801da592347d9fdce3a9812eb17eb351d2a44e
[ "MIT" ]
permissive
baptmqt/dolphin
b77b03441d62ed9b344cdc5f066fecced8d30b5d
a2421650bf2acfa43f0d9a93bc8f606682a170d8
refs/heads/main
2023-02-03T13:58:13.591711
2020-12-19T20:30:48
2020-12-19T20:30:48
312,092,176
2
0
null
null
null
null
UTF-8
Java
false
false
2,085
java
/* * MIT License * * Copyright (c) 2020. Baptiste MAQUET * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package fr.bmqt.dolphin.network.packets.play.server; import fr.bmqt.dolphin.network.packets.Packet; import fr.bmqt.dolphin.network.packets.PacketBuffer; import fr.bmqt.dolphin.network.packets.play.INetHandlerPlayClient; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import java.io.IOException; /** * @author Baptiste MAQUET on 11/11/2020 * @project dolphin-parent */ @Getter @NoArgsConstructor @AllArgsConstructor public class SKeepAlivePacket implements Packet<INetHandlerPlayClient> { protected int id; @Override public void readPacketData(PacketBuffer buf) throws IOException { id = buf.readVarIntFromBuffer(); } @Override public void writePacketData(PacketBuffer buf) throws IOException { buf.writeVarIntToBuffer(id); } @Override public void processPacket(INetHandlerPlayClient handler) { handler.handleKeepAlive(this); } }
ea78e4df4d1c72cc87d8af4f2a55dd4fdc6fb505
90dcf908ce9e5733d205cf6dcd44271c96408632
/app/src/main/java/ntt/bps/namberwan/adminkonsultasistatistik/chat/MessageModel.java
7882a02636691f223045f982580e0b7490c482d2
[]
no_license
ZipoNamberwan/AdminKonsultasiStatistik
57919e96ca0d9ab9f990c8de7175cadfc23cef6a
0e3283d0a6bd3e8688efd7740da9c0316c1b92b9
refs/heads/master
2020-04-20T17:56:35.871299
2019-02-12T00:55:53
2019-02-12T00:55:53
169,003,950
0
0
null
null
null
null
UTF-8
Java
false
false
836
java
package ntt.bps.namberwan.adminkonsultasistatistik.chat; public class MessageModel { private String sender; private String receiver; private String message; private long createdAt; public MessageModel(){ } public String getSender() { return sender; } public void setSender(String sender) { this.sender = sender; } public String getReceiver() { return receiver; } public void setReceiver(String receiver) { this.receiver = receiver; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public long getCreatedAt() { return createdAt; } public void setCreatedAt(long createdAt) { this.createdAt = createdAt; } }
1a9568f98f2ff7448ad0cd2b18c29f8872500053
2aa644ff7368684f278c14cf072230b76452c17e
/src/main/java/mja/designpattern/creational/Singleton/MainApp.java
a5bed38f04f15eac369e2a9202b65a163a01ff4f
[]
no_license
jeins/design-pattern
e22366f3d5d27fe3af70cf9d11681f9e111be979
cf7ad034567d484b69d0028be37a7907ecd63638
refs/heads/master
2020-09-09T09:59:26.382837
2019-11-15T10:24:39
2019-11-15T10:24:39
221,417,372
0
0
null
null
null
null
UTF-8
Java
false
false
465
java
package mja.designpattern.creational.Singleton; /** * Singleton * Ensure a class only has one instance, and provide a global point of access to it. */ public class MainApp { public static void main(String[] args) { OrderService orderService = new OrderService(); orderService.getOrderById(10); orderService.getOrders(); PaymentService paymentService = new PaymentService(); paymentService.getPaymentById(1); } }
5c875afaf0908db82188222969f0c1e4365b9f6a
e28ca94227ed7dd6b905878233aec7cce98a99df
/Combination-Sum-III/src/Solution.java
249feccd24e913adb788f14e0d2aa7905518c876
[]
no_license
xiao-peng1006/Coding-Chanllenge
a0f80b70439902da98191d91f2d2b023070c3dde
419ddfa497b744da4c985407c601f44ac149a03d
refs/heads/master
2020-04-27T09:59:47.396322
2019-12-16T19:02:05
2019-12-16T19:02:05
174,236,289
0
0
null
null
null
null
UTF-8
Java
false
false
874
java
import java.util.ArrayList; import java.util.Collections; import java.util.List; class Solution { /** * Leetcode 216. Combination Sum III * @param k * @param n * @return */ int sum = 0; public List<List<Integer>> combinationSum3(int k, int n) { List<List<Integer>> res = new ArrayList<>(); if (n <= 0) return res; helper(k, n, 1, new ArrayList<>(), res); return res; } private void helper(int k, int n, int start, List<Integer> temp, List<List<Integer>> list) { if (temp.size() == k && sum == n) { list.add(new ArrayList<>(temp)); return; } for (int i = start; i <= 9; i++) { temp.add(i); sum += i; helper(k, n, i+1, temp, list); temp.remove(temp.size()-1); sum -= i; } } }
da7b80d8d92362b56b51d411235cd2d9c49de3a9
08e8177f8a9f96461aca9d99d053b5c9c5277555
/src/main/chris/businesscards/util/Utils.java
319aebfc0c1b5023ab3f83b14aafba7990f2342f
[]
no_license
csteppp/asymproj
45b2f9dbecf4f0ed223a4fc3bf4a41ac19c1ef71
60d46612288b45d29968a4bba6ac074eb0c67b6f
refs/heads/master
2021-09-07T12:50:09.532385
2018-02-23T05:50:20
2018-02-23T05:50:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
835
java
package chris.businesscards.util; /** * Contains static utility methods for equals and hashCode * @author Chris * */ public class Utils { /** * Does smart comparisons. Handles nulls. Assumes the object * has an intelligent equals method implemented * @param a * @param b * @return true if they are equal, false otherwise */ public static boolean equal(Object a, Object b) { if(a == b) return true; if(a == null || b == null) return false; return a.equals(b); } /** * Return a number that can be used to generate a reasonable hash code. Not perfect. * @param o may be null * @return a number that can be used to generate a reasonable hash code */ public static int hashCodePrime(Object o) { if(o == null) return 37; return 37 * o.hashCode(); } }
4a55d018e9b9e1253427859bcc844e89400859cd
da8fac5eaf6c40e593768fff9ab9f9a9567a2808
/tlatools/org.lamport.tlatools/test/tlc2/tool/suite/Test21.java
344b694f43559ef73e07d2658023ee448be1392d
[ "MIT" ]
permissive
tlaplus/tlaplus
dd02971ea1fface9a4e6642d0b433291ad462db4
baf6f1b4000ba72cd4ac2704d07c60ea2ae8343b
refs/heads/master
2023-09-03T17:39:23.238115
2023-08-28T00:28:30
2023-08-28T02:46:40
50,906,927
2,214
203
MIT
2023-09-05T21:38:47
2016-02-02T08:48:27
Java
UTF-8
Java
false
false
1,660
java
/******************************************************************************* * Copyright (c) 2016 Microsoft Research. All rights reserved. * * The MIT License (MIT) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Contributors: * Markus Alexander Kuppe - initial API and implementation ******************************************************************************/ package tlc2.tool.suite; public class Test21 extends SuiteTestCase { public Test21() { super("8", "2", "0", "1", "line 59, col 16 to line 59, col 21 of module test21: 0\n" + "line 60, col 16 to line 60, col 19 of module test21: 0\n"); } }
7398c7f3a935e9ca3f7879fb68efa0667d8e6d26
fd0006f4de27cf9fdfb02aaed44b5604b6032c97
/CrawlSpellSuccessCalc/src/crawlspellsuccesscalc/XPOptimizer.java
8a5884203709d99fe313ddcc0b2ff78ceadd9bfb
[]
no_license
Dawiar/DCSS-spell-success-calculator
d3dc8a6ccd686ba31a91101c3de7a15f87bcfa62
cc4b1f73ea6512638be4a6df5851327fec38b537
refs/heads/master
2020-11-24T06:23:41.184225
2019-12-14T11:03:27
2019-12-14T11:03:27
228,007,005
0
0
null
null
null
null
UTF-8
Java
false
false
14,396
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package crawlspellsuccesscalc; import static java.lang.Double.max; import static java.lang.Double.min; import static java.lang.Math.abs; import static java.lang.Math.floor; import static java.lang.Math.round; /** * * @author Игорь */ public class XPOptimizer { private CrawlCalculator calc; private int neededMiscast; private int skillAptitudes[]; private int spellcastingApt; private int armorApt; private int shieldsApt; private int xpAptitude; private int xl; public int getXl() { return xl; } public int getNextxl() { return nextxl; } private int nextxl; private long xpPool; private double baseSkills[]; private final int skill_exp[] = { 0, 50, 150, 300, 500, 750, // 0-5 1050, 1400, 1800, 2250, 2800, // 6-10 3450, 4200, 5050, 6000, 7050, // 11-15 8200, 9450, 10800, 12300, 13950, // 16-20 15750, 17700, 19800, 22050, 24450, // 21-25 27000, 29750 }; private final int xl_exp[]= { 0, 10, 30, 70, 140, //1-5 270, 520, 1010, 1980, 3910, //6-10 7760, 15450, 26895, 45585, 72745, //11-15 108375, 152475, 205045, 266085, 335595, //16-20 413575, 500025, 594945, 698335, 810195, //21-25 930525, 1059325 }; private boolean calculated; public XPOptimizer(CrawlCalculator calc, int neededMiscast, int[] skillAptitudes, int spellcastingApt, int armorApt, int shieldsApt) { this.calc = calc; this.neededMiscast = neededMiscast; this.skillAptitudes = skillAptitudes; this.spellcastingApt = spellcastingApt; this.armorApt = armorApt; this.shieldsApt = shieldsApt; baseSkills=new double[skillAptitudes.length+3]; for(int i=0; i<skillAptitudes.length+3; i++) baseSkills[i]=calc.getSkillByType(i); } public XPOptimizer(CrawlCalculator calc, int neededMiscast, int[] skillAptitudes, int spellcastingApt, int armorApt, int shieldsApt, int xl, int nextxl, int xpAptitude) { this.calc = calc; this.neededMiscast = neededMiscast; this.skillAptitudes = skillAptitudes; this.spellcastingApt = spellcastingApt; this.armorApt = armorApt; this.shieldsApt = shieldsApt; this.xpAptitude = xpAptitude; this.xl = xl; this.nextxl=nextxl; baseSkills=new double[skillAptitudes.length+3]; for(int i=0; i<skillAptitudes.length+3; i++) baseSkills[i]=calc.getSkillByType(i); this.xpPool=0; int i; for(i=0; i<xl; i++) { xpPool+=AptModif(xl_exp[i], xpAptitude); } xpPool+=AptModif(xl_exp[i], xpAptitude)*(((double)nextxl) / 100.0); } public CrawlCalculator GetCalc() { return calc; } /*public static void main(String[] args) { double spellcasting = 5; //this.nskill = nskill; //this.magic_skills = magic_skills; int nmagicSkills=2; double[] magicSkills=new double[nmagicSkills]; magicSkills[0]=10; if(nmagicSkills>1) magicSkills[1]=10; if(nmagicSkills>2) magicSkills[2]=10; double shields = 10; //this.shieldtype = ShieldsSpinner; double armor = 10; int encumbrance = 7; //this.size = size; int Str = (Integer)8; int Int = (Integer)20; int spellLvl = 5; int vehumet=CrawlCalculator.NOVEHUMET; int wizardry=CrawlCalculator.NOWIZARDRY; int wildmagic=CrawlCalculator.NOWILDMAGIC; int subduedmagic=CrawlCalculator.NOSUBDUEDMAGIC; boolean hat=false; int shieldtype=CrawlCalculator.SHIELD; int size=CrawlCalculator.NORMALSPECIES; CrawlCalculator calc=new CrawlCalculator(spellcasting,nmagicSkills,magicSkills,vehumet,wizardry,wildmagic,subduedmagic,hat,shields,shieldtype,armor,encumbrance,size,Str,Int,spellLvl); double res=calc.calculateMiscast(); System.out.println((new XPOptimizer(calc,10,new int[2],0,0,0)).OptimizeXP()); System.out.println(res); }*/ public boolean OptimizeXP() { if(calc==null) return false; if(skillAptitudes.length!=calc.getMagic_skills().length) return false; int i; //first, check if it's possible double magic_skills[]=calc.getMagic_skills().clone(); for(i=0; i<magic_skills.length; i++) magic_skills[i]=27; if(calc.calculateMiscast(27, magic_skills.length, magic_skills, 27, 27)>neededMiscast) return false; while(calc.calculateMiscast()-neededMiscast>0.01) { int skillToLearn=selectOptimalSkill(); //int base=((int)floor(calc.getSkillByType(skillToLearn)+0.01)); // while(((int)floor(calc.getSkillByType(skillToLearn)+0.01))==base && abs(calc.calculateMiscast()-neededMiscast)>0.01) int apt= skillToLearn==CrawlCalculator.SHIELDS ? shieldsApt : (skillToLearn==CrawlCalculator.ARMOR ? armorApt : (skillToLearn==CrawlCalculator.SPC ? spellcastingApt : skillAptitudes[skillToLearn-3])); calc.changeSkill(0.1, skillToLearn); xpPool+=AptModif(skill_exp[(int)floor(calc.getSkillByType(skillToLearn))+1]*0.1, apt); } //уменьшаем скилы настолько, насколько возможно //плохой способ, да // for(i=0; i<2+skillAptitudes.length; i++) // { // while(neededMiscast-calc.calculateMiscast()>0.01) // calc.changeSkill(-0.1, i); // calc.changeSkill(0.1, i); // } //попробуем еще раз int xp,maxxp,maxj; maxj=-1; maxxp=Integer.MIN_VALUE; for(int j=0; j<3+skillAptitudes.length; j++) { CrawlCalculator copy=new CrawlCalculator(calc); for(i=0; i<3+skillAptitudes.length; i++) { int i1=(i+j)%(3+skillAptitudes.length); boolean changed=false; while(neededMiscast-copy.calculateMiscast()>-0.01 && copy.getSkillByType(i1)>=(baseSkills[i1]-0.0001) && copy.getSkillByType(i1)>=0.0001) { copy.changeSkill(-0.1, i1); changed=true; } if(changed) copy.changeSkill(0.1, i1); } xp=0; int apt= j==CrawlCalculator.SHIELDS ? shieldsApt : (j==CrawlCalculator.ARMOR ? armorApt : (j==CrawlCalculator.SPC ? spellcastingApt : skillAptitudes[j-3])); for(int sk=0; sk<3+skillAptitudes.length; sk++) { for(double lvl=copy.getSkillByType(sk); lvl<calc.getSkillByType(sk); lvl+=0.1) xp+=AptModif(skill_exp[(int)floor(lvl)+1]*0.1, apt); } if(xp>maxxp) { maxxp=xp; maxj=j; } } for(i=0; i<3+skillAptitudes.length; i++) { int i1=(i+maxj)%(3+skillAptitudes.length); int apt= i1==CrawlCalculator.SHIELDS ? shieldsApt : (i1==CrawlCalculator.ARMOR ? armorApt : (i1==CrawlCalculator.SPC ? spellcastingApt : skillAptitudes[i1-3])); boolean changed=false; while(neededMiscast-calc.calculateMiscast()>-0.01 && calc.getSkillByType(i1)>=(baseSkills[i1]-0.0001) && calc.getSkillByType(i1)>=0.0001) { xpPool-=AptModif(skill_exp[(int)floor(calc.getSkillByType(i1))+1]*0.1, apt); calc.changeSkill(-0.1, i1); changed=true; } if(changed) { xpPool+=AptModif(skill_exp[(int)floor(calc.getSkillByType(i1)-0.1)+1]*0.1, apt); calc.changeSkill(0.1, i1); } } if(xl!=-1 && nextxl!=-1) { xpPool-=xpPool<(AptModif(xl_exp[xl], xpAptitude)*((1.0-(double)nextxl) / 100.0)) ? xpPool : (AptModif(xl_exp[xl], xpAptitude)*((1.0-(double)nextxl) / 100.0)); while(xpPool>0) { xl++; xpPool-=AptModif(xl_exp[xl], xpAptitude); } if(xl==27) nextxl=0; else nextxl=(int)(100-(-100)*((double)xpPool)/((double)xl_exp[xl])); } //пробуем простой перебор /*double all=(270-10*calc.getSpellcasting())*(270-10*calc.getArmor())*(270-10*calc.getShields()); for(i=0;i<magic_skills.length;i++) all*=(270-10*calc.getMagic_skills()[i]); System.out.println(all); double progress=0; double olddif=-1; int n=calc.getNskill(); for(int spc=(int)calc.getSpellcasting()*10; spc<=270; spc++) { for(int shld=(int)calc.getShields()*10; shld<=270; shld++) { for(int armr=(int)calc.getArmor()*10; armr<=270; armr++) { for(int sk1=(int)calc.getMagic_skills()[0]*10; sk1<=270; sk1++) { for(int sk2=(int)(n>=2 ? calc.getMagic_skills()[1]*10 : 270); sk2<=270; sk2++) { for(int sk3=(int)(n>=3 ? calc.getMagic_skills()[2]*10 : 270); sk3<=270; sk3++) { double arr[]={sk1/10.0,sk2/10.0,sk3/10.0}; //if(calc.calculateMiscast(spc/10.0, n, arr, armr/10.0, shld/10.0)<=neededMiscast) calc.calculateMiscast(spc/10.0, n, arr, armr/10.0, shld/10.0); progress++; if(progress/all-olddif>0.1) { System.out.println(progress/all); olddif=progress/all; } } } } } } }*/ //простой перебор не работает //совсем. return true; } private double AptModif(double exp, double apt) { //return exp*Math.pow(2.0, (-1)*apt/4); return exp*(1 / Math.exp(Math.log(2) * apt / 4)); } private double GetEfficiency_rec(int skillType, int apt, CrawlCalculator calc, int depth) { double newLvl; double prev_chance; double deltaSkill; double NextLevelCost; double chance; double eff; CrawlCalculator copy=new CrawlCalculator(calc); newLvl=min(round(copy.getSkillByType(skillType)+(depth-1)+0.51),27); prev_chance=copy.GetSpellFailure(); deltaSkill=newLvl-copy.getSkillByType(skillType); NextLevelCost=0; for(int j=0; j<depth && (int)floor(copy.getSkillByType(skillType))+j<=27; j++) NextLevelCost+=AptModif(skill_exp[(int)floor(copy.getSkillByType(skillType))+j+1]*min(deltaSkill-(depth-1)+j,1), apt); copy.changeSkill(deltaSkill, skillType); boolean canIncrease=newLvl+0.001<27; chance=copy.GetSpellFailure(); eff=((prev_chance-chance)/NextLevelCost)/(deltaSkill*10.0); if(eff==0 && canIncrease) return GetEfficiency_rec(skillType,apt,calc,depth+1); return eff; } private double GetEfficiency(int skillType, int apt, CrawlCalculator calc) { //copy=new CrawlCalculator(calc); return GetEfficiency_rec(skillType,apt,calc,1); } private int selectOptimalSkill_rec(int depth) { double maxEff=Double.MIN_VALUE; int effSkill=-1; CrawlCalculator copy; double eff; //shields if(calc.getShields()+0.01<27) { eff=GetEfficiency(CrawlCalculator.SHIELDS,shieldsApt,calc); if(eff>maxEff) { maxEff=eff; effSkill=CrawlCalculator.SHIELDS; } } //armor if(calc.getArmor()+0.01<27) { eff=GetEfficiency(CrawlCalculator.ARMOR,armorApt,calc); if(eff>maxEff) { maxEff=eff; effSkill=CrawlCalculator.ARMOR; } } //spc if(calc.getSpellcasting()+0.01<27) { eff=GetEfficiency(CrawlCalculator.SPC,spellcastingApt,calc); if(eff>maxEff) { maxEff=eff; effSkill=CrawlCalculator.SPC; } } for(int i=0; i<skillAptitudes.length; i++) { if(calc.getMagic_skills()[i]+0.01<27) { eff=GetEfficiency(CrawlCalculator.MAG1+i,skillAptitudes[i],calc); if(eff>maxEff) { maxEff=eff; effSkill=CrawlCalculator.MAG1+i; } } } //if(effSkill==-1) // effSkill=selectOptimalSkill_rec(depth+1); return effSkill; } private int selectOptimalSkill() { return selectOptimalSkill_rec(1); } }
0a98fa3eaa71d076376258e64022f1878b74981d
735e009d30cfdbb0b8d1c93b5169e3db795c78f2
/Magna/app/src/main/java/com/example/apple/magna/questions.java
a4d38c8538a128d2d1cca62426b5317e7fe6a48e
[]
no_license
RishikeshYadav95/magna
87a7b0b93392d837fb961a5aa3170ae084eb1a73
a843603668c05bd712f0cb4a547c032720fac85e
refs/heads/master
2022-12-24T07:38:10.742206
2020-09-25T21:28:03
2020-09-25T21:28:03
298,680,390
0
0
null
null
null
null
UTF-8
Java
false
false
628
java
package com.example.apple.magna; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.view.ViewPager; /** * Created by APPLE on 25/03/16. */ public class questions extends FragmentActivity { ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.questions); viewPager = (ViewPager)findViewById(R.id.viewpager); SwipeAdapter swipeAdapter = new SwipeAdapter(getSupportFragmentManager()); viewPager.setAdapter(swipeAdapter); } }
bc4a399b0a2d9a8569d48cd402d165f20a1d53e2
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/14/14_6966c60a47d88f7253fcf20d7a6ffc591b35b624/CallNotifier/14_6966c60a47d88f7253fcf20d7a6ffc591b35b624_CallNotifier_t.java
7a4fb031b6ec334432d11ea960d533e5aae995ed
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
95,965
java
/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.phone; import com.android.internal.telephony.Call; import com.android.internal.telephony.CallerInfo; import com.android.internal.telephony.CallerInfoAsyncQuery; import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; import com.android.internal.telephony.cdma.SignalToneUtil; import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaDisplayInfoRec; import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaSignalInfoRec; import com.android.internal.telephony.Connection; import com.android.internal.telephony.Phone; import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.CallManager; import android.app.ActivityManagerNative; import android.content.Context; import android.media.AudioManager; import android.media.ToneGenerator; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemProperties; import android.os.Vibrator; import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.Settings; import android.telephony.PhoneNumberUtils; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.EventLog; import android.util.Log; import android.preference.PreferenceManager; import android.hardware.SensorManager; import android.hardware.SensorEventListener; import android.hardware.SensorEvent; import android.hardware.Sensor; /** * Phone app module that listens for phone state changes and various other * events from the telephony layer, and triggers any resulting UI behavior * (like starting the Ringer and Incoming Call UI, playing in-call tones, * updating notifications, writing call log entries, etc.) */ public class CallNotifier extends Handler implements CallerInfoAsyncQuery.OnQueryCompleteListener { private static final String LOG_TAG = "CallNotifier"; private static final boolean DBG = (PhoneApp.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1); private static final boolean VDBG = (PhoneApp.DBG_LEVEL >= 2); // Maximum time we allow the CallerInfo query to run, // before giving up and falling back to the default ringtone. private static final int RINGTONE_QUERY_WAIT_TIME = SystemProperties.getInt("ro.ringtone_query_wait_time", 500); // msec // Timers related to CDMA Call Waiting // 1) For displaying Caller Info // 2) For disabling "Add Call" menu option once User selects Ignore or CW Timeout occures private static final int CALLWAITING_CALLERINFO_DISPLAY_TIME = 20000; // msec private static final int CALLWAITING_ADDCALL_DISABLE_TIME = 30000; // msec // Time to display the DisplayInfo Record sent by CDMA network private static final int DISPLAYINFO_NOTIFICATION_TIME = 2000; // msec // Boolean to keep track of whether or not a CDMA Call Waiting call timed out. // // This is CDMA-specific, because with CDMA we *don't* get explicit // notification from the telephony layer that a call-waiting call has // stopped ringing. Instead, when a call-waiting call first comes in we // start a 20-second timer (see CALLWAITING_CALLERINFO_DISPLAY_DONE), and // if the timer expires we clean up the call and treat it as a missed call. // // If this field is true, that means that the current Call Waiting call // "timed out" and should be logged in Call Log as a missed call. If it's // false when we reach onCdmaCallWaitingReject(), we can assume the user // explicitly rejected this call-waiting call. // // This field is reset to false any time a call-waiting call first comes // in, and after cleaning up a missed call-waiting call. It's only ever // set to true when the CALLWAITING_CALLERINFO_DISPLAY_DONE timer fires. // // TODO: do we really need a member variable for this? Don't we always // know at the moment we call onCdmaCallWaitingReject() whether this is an // explicit rejection or not? // (Specifically: when we call onCdmaCallWaitingReject() from // PhoneUtils.hangupRingingCall() that means the user deliberately rejected // the call, and if we call onCdmaCallWaitingReject() because of a // CALLWAITING_CALLERINFO_DISPLAY_DONE event that means that it timed // out...) private boolean mCallWaitingTimeOut = false; // values used to track the query state private static final int CALLERINFO_QUERY_READY = 0; private static final int CALLERINFO_QUERYING = -1; // the state of the CallerInfo Query. private int mCallerInfoQueryState; // object used to synchronize access to mCallerInfoQueryState private Object mCallerInfoQueryStateGuard = new Object(); // Event used to indicate a query timeout. private static final int RINGER_CUSTOM_RINGTONE_QUERY_TIMEOUT = 100; // Events from the Phone object: private static final int PHONE_STATE_CHANGED = 1; private static final int PHONE_NEW_RINGING_CONNECTION = 2; private static final int PHONE_DISCONNECT = 3; private static final int PHONE_UNKNOWN_CONNECTION_APPEARED = 4; private static final int PHONE_INCOMING_RING = 5; private static final int PHONE_STATE_DISPLAYINFO = 6; private static final int PHONE_STATE_SIGNALINFO = 7; private static final int PHONE_CDMA_CALL_WAITING = 8; private static final int PHONE_ENHANCED_VP_ON = 9; private static final int PHONE_ENHANCED_VP_OFF = 10; private static final int PHONE_RINGBACK_TONE = 11; private static final int PHONE_RESEND_MUTE = 12; // Events generated internally: private static final int PHONE_MWI_CHANGED = 21; private static final int PHONE_BATTERY_LOW = 22; private static final int CALLWAITING_CALLERINFO_DISPLAY_DONE = 23; private static final int CALLWAITING_ADDCALL_DISABLE_TIMEOUT = 24; private static final int DISPLAYINFO_NOTIFICATION_DONE = 25; private static final int EVENT_OTA_PROVISION_CHANGE = 26; private static final int CDMA_CALL_WAITING_REJECT = 27; // Emergency call related defines: private static final int EMERGENCY_TONE_OFF = 0; private static final int EMERGENCY_TONE_ALERT = 1; private static final int EMERGENCY_TONE_VIBRATE = 2; private PhoneApp mApplication; private CallManager mCM; private Ringer mRinger; private BluetoothHandsfree mBluetoothHandsfree; private CallLogAsync mCallLog; private boolean mSilentRingerRequested; private boolean mHasRingingCall; // ToneGenerator instance for playing SignalInfo tones private ToneGenerator mSignalInfoToneGenerator; // The tone volume relative to other sounds in the stream SignalInfo private static final int TONE_RELATIVE_VOLUME_SIGNALINFO = 80; private Call.State mPreviousCdmaCallState; private boolean mCdmaVoicePrivacyState = false; private boolean mIsCdmaRedialCall = false; // Emergency call tone and vibrate: private int mIsEmergencyToneOn; private int mCurrentEmergencyToneState = EMERGENCY_TONE_OFF; private EmergencyTonePlayerVibrator mEmergencyTonePlayerVibrator; // Ringback tone player private InCallTonePlayer mInCallRingbackTonePlayer; // Call waiting tone player private InCallTonePlayer mCallWaitingTonePlayer; // Cached AudioManager private AudioManager mAudioManager; private PowerManager mPowerManager; // add by cytown private CallFeaturesSetting mSettings; private static final String BLACKLIST = "blacklist"; public CallNotifier(PhoneApp app, Phone phone, Ringer ringer, BluetoothHandsfree btMgr, CallLogAsync callLog) { mSettings = CallFeaturesSetting.getInstance(PreferenceManager.getDefaultSharedPreferences(app)); //mSensorManager = (SensorManager) app.getSystemService(Context.SENSOR_SERVICE); mApplication = app; mCM = app.mCM; mCallLog = callLog; mAudioManager = (AudioManager) mApplication.getSystemService(Context.AUDIO_SERVICE); mPowerManager = (PowerManager) mApplication.getSystemService(Context.POWER_SERVICE); registerForNotifications(); // Instantiate the ToneGenerator for SignalInfo and CallWaiting // TODO: We probably don't need the mSignalInfoToneGenerator instance // around forever. Need to change it so as to create a ToneGenerator instance only // when a tone is being played and releases it after its done playing. try { mSignalInfoToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, TONE_RELATIVE_VOLUME_SIGNALINFO); } catch (RuntimeException e) { Log.w(LOG_TAG, "CallNotifier: Exception caught while creating " + "mSignalInfoToneGenerator: " + e); mSignalInfoToneGenerator = null; } mRinger = ringer; mBluetoothHandsfree = btMgr; TelephonyManager telephonyManager = (TelephonyManager)app.getSystemService( Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR); } @Override public void handleMessage(Message msg) { switch (msg.what) { case PHONE_NEW_RINGING_CONNECTION: if (DBG) log("RINGING... (new)"); onNewRingingConnection((AsyncResult) msg.obj); mSilentRingerRequested = false; break; case PHONE_INCOMING_RING: // repeat the ring when requested by the RIL, and when the user has NOT // specifically requested silence. if (msg.obj != null && ((AsyncResult) msg.obj).result != null) { PhoneBase pb = (PhoneBase)((AsyncResult)msg.obj).result; if ((pb.getState() == Phone.State.RINGING) && mHasRingingCall && (mSilentRingerRequested == false)) { if (DBG) log("RINGING... (PHONE_INCOMING_RING event)"); mRinger.ring(); } else { if (DBG) log("RING before NEW_RING, skipping"); } } break; case PHONE_STATE_CHANGED: onPhoneStateChanged((AsyncResult) msg.obj); break; case PHONE_DISCONNECT: if (DBG) log("DISCONNECT"); onDisconnect((AsyncResult) msg.obj); break; case PHONE_UNKNOWN_CONNECTION_APPEARED: onUnknownConnectionAppeared((AsyncResult) msg.obj); break; case RINGER_CUSTOM_RINGTONE_QUERY_TIMEOUT: // CallerInfo query is taking too long! But we can't wait // any more, so start ringing NOW even if it means we won't // use the correct custom ringtone. Log.w(LOG_TAG, "CallerInfo query took too long; manually starting ringer"); // In this case we call onCustomRingQueryComplete(), just // like if the query had completed normally. (But we're // going to get the default ringtone, since we never got // the chance to call Ringer.setCustomRingtoneUri()). onCustomRingQueryComplete(); break; case PHONE_MWI_CHANGED: onMwiChanged(mApplication.phone.getMessageWaitingIndicator()); break; case PHONE_BATTERY_LOW: onBatteryLow(); break; case PHONE_CDMA_CALL_WAITING: if (DBG) log("Received PHONE_CDMA_CALL_WAITING event"); onCdmaCallWaiting((AsyncResult) msg.obj); break; case CDMA_CALL_WAITING_REJECT: Log.i(LOG_TAG, "Received CDMA_CALL_WAITING_REJECT event"); onCdmaCallWaitingReject(); break; case CALLWAITING_CALLERINFO_DISPLAY_DONE: Log.i(LOG_TAG, "Received CALLWAITING_CALLERINFO_DISPLAY_DONE event"); mCallWaitingTimeOut = true; onCdmaCallWaitingReject(); break; case CALLWAITING_ADDCALL_DISABLE_TIMEOUT: if (DBG) log("Received CALLWAITING_ADDCALL_DISABLE_TIMEOUT event ..."); // Set the mAddCallMenuStateAfterCW state to true mApplication.cdmaPhoneCallState.setAddCallMenuStateAfterCallWaiting(true); mApplication.updateInCallScreenTouchUi(); break; case PHONE_STATE_DISPLAYINFO: if (DBG) log("Received PHONE_STATE_DISPLAYINFO event"); onDisplayInfo((AsyncResult) msg.obj); break; case PHONE_STATE_SIGNALINFO: if (DBG) log("Received PHONE_STATE_SIGNALINFO event"); onSignalInfo((AsyncResult) msg.obj); break; case DISPLAYINFO_NOTIFICATION_DONE: if (DBG) log("Received Display Info notification done event ..."); CdmaDisplayInfo.dismissDisplayInfoRecord(); break; case EVENT_OTA_PROVISION_CHANGE: mApplication.handleOtaEvents(msg); break; case PHONE_ENHANCED_VP_ON: if (DBG) log("PHONE_ENHANCED_VP_ON..."); if (!mCdmaVoicePrivacyState) { int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY; new InCallTonePlayer(toneToPlay).start(); mCdmaVoicePrivacyState = true; // Update the VP icon: if (DBG) log("- updating notification for VP state..."); NotificationMgr.getDefault().updateInCallNotification(); } break; case PHONE_ENHANCED_VP_OFF: if (DBG) log("PHONE_ENHANCED_VP_OFF..."); if (mCdmaVoicePrivacyState) { int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY; new InCallTonePlayer(toneToPlay).start(); mCdmaVoicePrivacyState = false; // Update the VP icon: if (DBG) log("- updating notification for VP state..."); NotificationMgr.getDefault().updateInCallNotification(); } break; case PHONE_RINGBACK_TONE: onRingbackTone((AsyncResult) msg.obj); break; case PHONE_RESEND_MUTE: onResendMute(); break; default: // super.handleMessage(msg); } } PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onMessageWaitingIndicatorChanged(boolean mwi) { onMwiChanged(mwi); } @Override public void onCallForwardingIndicatorChanged(boolean cfi) { onCfiChanged(cfi); } }; private void onNewRingingConnection(AsyncResult r) { Connection c = (Connection) r.result; if (DBG) log("onNewRingingConnection(): " + c); Call ringing = c.getCall(); Phone phone = ringing.getPhone(); // Incoming calls are totally ignored if the device isn't provisioned yet boolean provisioned = Settings.Secure.getInt(mApplication.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0; if (!provisioned && !PhoneUtils.isPhoneInEcm(phone)) { Log.i(LOG_TAG, "CallNotifier: rejecting incoming call: not provisioned / ECM"); // Send the caller straight to voicemail, just like // "rejecting" an incoming call. PhoneUtils.hangupRingingCall(ringing); return; } String number = c!=null?c.getAddress():"0000"; if (android.text.TextUtils.isEmpty(number)) number = "0000"; if (DBG) log("incoming number is: " + number); if (c != null && mSettings.isBlackList(number)) { try { c.setUserData(BLACKLIST); c.hangup(); if (DBG) Log.i(LOG_TAG, "Reject the incoming call in BL:" + number); } catch (Exception e) {} // ignore return; } // Incoming calls are totally ignored if OTA call is active if (TelephonyCapabilities.supportsOtasp(phone)) { boolean activateState = (mApplication.cdmaOtaScreenState.otaScreenState == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_ACTIVATION); boolean dialogState = (mApplication.cdmaOtaScreenState.otaScreenState == OtaUtils.CdmaOtaScreenState.OtaScreenState.OTA_STATUS_SUCCESS_FAILURE_DLG); boolean spcState = mApplication.cdmaOtaProvisionData.inOtaSpcState; if (spcState) { Log.i(LOG_TAG, "CallNotifier: rejecting incoming call: OTA call is active"); PhoneUtils.hangupRingingCall(ringing); return; } else if (activateState || dialogState) { if (dialogState) mApplication.dismissOtaDialogs(); mApplication.clearOtaState(); mApplication.clearInCallScreenMode(); } } if (c == null) { Log.w(LOG_TAG, "CallNotifier.onNewRingingConnection(): null connection!"); // Should never happen, but if it does just bail out and do nothing. return; } if (!c.isRinging()) { Log.i(LOG_TAG, "CallNotifier.onNewRingingConnection(): connection not ringing!"); // This is a very strange case: an incoming call that stopped // ringing almost instantly after the onNewRingingConnection() // event. There's nothing we can do here, so just bail out // without doing anything. (But presumably we'll log it in // the call log when the disconnect event comes in...) return; } // Stop any signalInfo tone being played on receiving a Call if (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { stopSignalInfoTone(); } Call.State state = c.getState(); // State will be either INCOMING or WAITING. if (VDBG) log("- connection is ringing! state = " + state); // if (DBG) PhoneUtils.dumpCallState(); // No need to do any service state checks here (like for // "emergency mode"), since in those states the SIM won't let // us get incoming connections in the first place. // TODO: Consider sending out a serialized broadcast Intent here // (maybe "ACTION_NEW_INCOMING_CALL"), *before* starting the // ringer and going to the in-call UI. The intent should contain // the caller-id info for the current connection, and say whether // it would be a "call waiting" call or a regular ringing call. // If anybody consumed the broadcast, we'd bail out without // ringing or bringing up the in-call UI. // // This would give 3rd party apps a chance to listen for (and // intercept) new ringing connections. An app could reject the // incoming call by consuming the broadcast and doing nothing, or // it could "pick up" the call (without any action by the user!) // by firing off an ACTION_ANSWER intent. // // We'd need to protect this with a new "intercept incoming calls" // system permission. // Obtain a partial wake lock to make sure the CPU doesn't go to // sleep before we finish bringing up the InCallScreen. // (This will be upgraded soon to a full wake lock; see // showIncomingCall().) if (VDBG) log("Holding wake lock on new incoming connection."); mApplication.requestWakeState(PhoneApp.WakeState.PARTIAL); // - don't ring for call waiting connections // - do this before showing the incoming call panel if (PhoneUtils.isRealIncomingCall(state)) { startIncomingCallQuery(c); //startSensor(); } else { if (mSettings.mVibCallWaiting) { mApplication.vibrate(200,300,500); } if (VDBG) log("- starting call waiting tone..."); if (mCallWaitingTonePlayer == null) { mCallWaitingTonePlayer = new InCallTonePlayer(InCallTonePlayer.TONE_CALL_WAITING); mCallWaitingTonePlayer.start(); } // in this case, just fall through like before, and call // showIncomingCall(). if (DBG) log("- showing incoming call (this is a WAITING call)..."); showIncomingCall(); } // Note we *don't* post a status bar notification here, since // we're not necessarily ready to actually show the incoming call // to the user. (For calls in the INCOMING state, at least, we // still need to run a caller-id query, and we may not even ring // at all if the "send directly to voicemail" flag is set.) // // Instead, we update the notification (and potentially launch the // InCallScreen) from the showIncomingCall() method, which runs // when the caller-id query completes or times out. if (VDBG) log("- onNewRingingConnection() done."); } /** * Helper method to manage the start of incoming call queries */ private void startIncomingCallQuery(Connection c) { // TODO: cache the custom ringer object so that subsequent // calls will not need to do this query work. We can keep // the MRU ringtones in memory. We'll still need to hit // the database to get the callerinfo to act as a key, // but at least we can save the time required for the // Media player setup. The only issue with this is that // we may need to keep an eye on the resources the Media // player uses to keep these ringtones around. // make sure we're in a state where we can be ready to // query a ringtone uri. boolean shouldStartQuery = false; synchronized (mCallerInfoQueryStateGuard) { if (mCallerInfoQueryState == CALLERINFO_QUERY_READY) { mCallerInfoQueryState = CALLERINFO_QUERYING; shouldStartQuery = true; } } if (shouldStartQuery) { // create a custom ringer using the default ringer first mRinger.setCustomRingtoneUri(Settings.System.DEFAULT_RINGTONE_URI); // query the callerinfo to try to get the ringer. PhoneUtils.CallerInfoToken cit = PhoneUtils.startGetCallerInfo( mApplication, c, this, this); // if this has already been queried then just ring, otherwise // we wait for the alloted time before ringing. if (cit.isFinal) { if (VDBG) log("- CallerInfo already up to date, using available data"); onQueryComplete(0, this, cit.currentInfo); } else { if (VDBG) log("- Starting query, posting timeout message."); sendEmptyMessageDelayed(RINGER_CUSTOM_RINGTONE_QUERY_TIMEOUT, RINGTONE_QUERY_WAIT_TIME); } // The call to showIncomingCall() will happen after the // queries are complete (or time out). } else { // This should never happen; its the case where an incoming call // arrives at the same time that the query is still being run, // and before the timeout window has closed. EventLog.writeEvent(EventLogTags.PHONE_UI_MULTIPLE_QUERY); // In this case, just log the request and ring. if (VDBG) log("RINGING... (request to ring arrived while query is running)"); mRinger.ring(); mHasRingingCall = true; // in this case, just fall through like before, and call // showIncomingCall(). if (DBG) log("- showing incoming call (couldn't start query)..."); showIncomingCall(); } } /** * Performs the final steps of the onNewRingingConnection sequence: * starts the ringer, and brings up the "incoming call" UI. * * Normally, this is called when the CallerInfo query completes (see * onQueryComplete()). In this case, onQueryComplete() has already * configured the Ringer object to use the custom ringtone (if there * is one) for this caller. So we just tell the Ringer to start, and * proceed to the InCallScreen. * * But this method can *also* be called if the * RINGTONE_QUERY_WAIT_TIME timeout expires, which means that the * CallerInfo query is taking too long. In that case, we log a * warning but otherwise we behave the same as in the normal case. * (We still tell the Ringer to start, but it's going to use the * default ringtone.) */ private void onCustomRingQueryComplete() { boolean isQueryExecutionTimeExpired = false; synchronized (mCallerInfoQueryStateGuard) { if (mCallerInfoQueryState == CALLERINFO_QUERYING) { mCallerInfoQueryState = CALLERINFO_QUERY_READY; isQueryExecutionTimeExpired = true; } } if (isQueryExecutionTimeExpired) { // There may be a problem with the query here, since the // default ringtone is playing instead of the custom one. Log.w(LOG_TAG, "CallerInfo query took too long; falling back to default ringtone"); EventLog.writeEvent(EventLogTags.PHONE_UI_RINGER_QUERY_ELAPSED); } // Make sure we still have an incoming call! // // (It's possible for the incoming call to have been disconnected // while we were running the query. In that case we better not // start the ringer here, since there won't be any future // DISCONNECT event to stop it!) // // Note we don't have to worry about the incoming call going away // *after* this check but before we call mRinger.ring() below, // since in that case we *will* still get a DISCONNECT message sent // to our handler. (And we will correctly stop the ringer when we // process that event.) if (mCM.getState() != Phone.State.RINGING) { Log.i(LOG_TAG, "onCustomRingQueryComplete: No incoming call! Bailing out..."); // Don't start the ringer *or* bring up the "incoming call" UI. // Just bail out. return; } // Ring, either with the queried ringtone or default one. if (VDBG) log("RINGING... (onCustomRingQueryComplete)"); mRinger.ring(); mHasRingingCall = true; // ...and display the incoming call to the user: if (DBG) log("- showing incoming call (custom ring query complete)..."); showIncomingCall(); } private void onUnknownConnectionAppeared(AsyncResult r) { Phone.State state = mCM.getState(); if (state == Phone.State.OFFHOOK) { // basically do onPhoneStateChanged + display the incoming call UI onPhoneStateChanged(r); if (DBG) log("- showing incoming call (unknown connection appeared)..."); showIncomingCall(); } } /** * Informs the user about a new incoming call. * * In most cases this means "bring up the full-screen incoming call * UI". However, if an immersive activity is running, the system * NotificationManager will instead pop up a small notification window * on top of the activity. * * Watch out: be sure to call this method only once per incoming call, * or otherwise we may end up launching the InCallScreen multiple * times (which can lead to slow responsiveness and/or visible * glitches.) * * Note this method handles only the onscreen UI for incoming calls; * the ringer and/or vibrator are started separately (see the various * calls to Ringer.ring() in this class.) * * @see NotificationMgr.updateInCallNotification() */ private void showIncomingCall() { if (DBG) log("showIncomingCall()..."); // Before bringing up the "incoming call" UI, force any system // dialogs (like "recent tasks" or the power dialog) to close first. try { ActivityManagerNative.getDefault().closeSystemDialogs("call"); } catch (RemoteException e) { } // Go directly to the in-call screen. // (No need to do anything special if we're already on the in-call // screen; it'll notice the phone state change and update itself.) // But first, grab a full wake lock. We do this here, before we // even fire off the InCallScreen intent, to make sure the // ActivityManager doesn't try to pause the InCallScreen as soon // as it comes up. (See bug 1648751.) // // And since the InCallScreen isn't visible yet (we haven't even // fired off the intent yet), we DON'T want the screen to actually // come on right now. So *before* acquiring the wake lock we need // to call preventScreenOn(), which tells the PowerManager that // the screen should stay off even if someone's holding a full // wake lock. (This prevents any flicker during the "incoming // call" sequence. The corresponding preventScreenOn(false) call // will come from the InCallScreen when it's finally ready to be // displayed.) // // TODO: this is all a temporary workaround. The real fix is to add // an Activity attribute saying "this Activity wants to wake up the // phone when it's displayed"; that way the ActivityManager could // manage the wake locks *and* arrange for the screen to come on at // the exact moment that the InCallScreen is ready to be displayed. // (See bug 1648751.) // // TODO: also, we should probably *not* do any of this if the // screen is already on(!) // let the NotificationMgr know the original state of screen NotificationMgr.getDefault().setScreenStateAtIncomingCall(mPowerManager.isScreenOn()); mApplication.preventScreenOn(true); mApplication.requestWakeState(PhoneApp.WakeState.FULL); // Post the "incoming call" notification. This will usually take // us straight to the incoming call screen (thanks to the // notification's "fullScreenIntent" field), but if an immersive // activity is running it'll just appear as a notification. if (DBG) log("- updating notification from showIncomingCall()..."); NotificationMgr.getDefault().updateInCallNotification(); } /** * Updates the phone UI in response to phone state changes. * * Watch out: certain state changes are actually handled by their own * specific methods: * - see onNewRingingConnection() for new incoming calls * - see onDisconnect() for calls being hung up or disconnected */ private void onPhoneStateChanged(AsyncResult r) { Phone.State state = mCM.getState(); if (VDBG) log("onPhoneStateChanged: state = " + state); // Turn status bar notifications on or off depending upon the state // of the phone. Notification Alerts (audible or vibrating) should // be on if and only if the phone is IDLE. NotificationMgr.getDefault().getStatusBarMgr() .enableNotificationAlerts(state == Phone.State.IDLE); Phone fgPhone = mCM.getFgPhone(); if (fgPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { if ((fgPhone.getForegroundCall().getState() == Call.State.ACTIVE) && ((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING))) { if (mIsCdmaRedialCall) { int toneToPlay = InCallTonePlayer.TONE_REDIAL; new InCallTonePlayer(toneToPlay).start(); } // Stop any signal info tone when call moves to ACTIVE state stopSignalInfoTone(); } mPreviousCdmaCallState = fgPhone.getForegroundCall().getState(); } // Have the PhoneApp recompute its mShowBluetoothIndication // flag based on the (new) telephony state. // There's no need to force a UI update since we update the // in-call notification ourselves (below), and the InCallScreen // listens for phone state changes itself. mApplication.updateBluetoothIndication(false); // Update the proximity sensor mode (on devices that have a // proximity sensor). mApplication.updatePhoneState(state); if (state == Phone.State.OFFHOOK) { // stop call waiting tone if needed when answering if (mCallWaitingTonePlayer != null) { mCallWaitingTonePlayer.stopTone(); mCallWaitingTonePlayer = null; } if (VDBG) log("onPhoneStateChanged: OFF HOOK"); Call call = PhoneUtils.getCurrentCall(fgPhone); Connection c = PhoneUtils.getConnection(fgPhone, call); if (VDBG) PhoneUtils.dumpCallState(fgPhone); Call.State cstate = call.getState(); if (cstate == Call.State.ACTIVE && !c.isIncoming()) { long callDurationMsec = c.getDurationMillis(); if (VDBG) Log.i(LOG_TAG, "duration is " + callDurationMsec); if (mSettings.mVibOutgoing && callDurationMsec < 200) { mApplication.vibrate(100,0,0); } if (mSettings.mVib45) { callDurationMsec = callDurationMsec % 60000; mApplication.startVib45(callDurationMsec); } } // make sure audio is in in-call mode now PhoneUtils.setAudioMode(mCM); // if the call screen is showing, let it handle the event, // otherwise handle it here. if (!mApplication.isShowingCallScreen()) { mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT); mApplication.requestWakeState(PhoneApp.WakeState.SLEEP); } // Since we're now in-call, the Ringer should definitely *not* // be ringing any more. (This is just a sanity-check; we // already stopped the ringer explicitly back in // PhoneUtils.answerCall(), before the call to phone.acceptCall().) // TODO: Confirm that this call really *is* unnecessary, and if so, // remove it! if (DBG) log("stopRing()... (OFFHOOK state)"); mRinger.stopRing(); mHasRingingCall = false; // put a icon in the status bar if (DBG) log("- updating notification for phone state change..."); NotificationMgr.getDefault().updateInCallNotification(); } if (fgPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { Connection c = fgPhone.getForegroundCall().getLatestConnection(); if ((c != null) && (PhoneNumberUtils.isEmergencyNumber(c.getAddress()))) { if (VDBG) log("onPhoneStateChanged: it is an emergency call."); Call.State callState = fgPhone.getForegroundCall().getState(); if (mEmergencyTonePlayerVibrator == null) { mEmergencyTonePlayerVibrator = new EmergencyTonePlayerVibrator(); } if (callState == Call.State.DIALING || callState == Call.State.ALERTING) { mIsEmergencyToneOn = Settings.System.getInt( mApplication.getContentResolver(), Settings.System.EMERGENCY_TONE, EMERGENCY_TONE_OFF); if (mIsEmergencyToneOn != EMERGENCY_TONE_OFF && mCurrentEmergencyToneState == EMERGENCY_TONE_OFF) { if (mEmergencyTonePlayerVibrator != null) { mEmergencyTonePlayerVibrator.start(); } } } else if (callState == Call.State.ACTIVE) { if (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF) { if (mEmergencyTonePlayerVibrator != null) { mEmergencyTonePlayerVibrator.stop(); } } } } } if ((fgPhone.getPhoneType() == Phone.PHONE_TYPE_GSM) || (fgPhone.getPhoneType() == Phone.PHONE_TYPE_SIP)) { Call.State callState = mCM.getActiveFgCallState(); if (!callState.isDialing()) { // If call get activated or disconnected before the ringback // tone stops, we have to stop it to prevent disturbing. if (mInCallRingbackTonePlayer != null) { mInCallRingbackTonePlayer.stopTone(); mInCallRingbackTonePlayer = null; } } } } void updateCallNotifierRegistrationsAfterRadioTechnologyChange() { if (DBG) Log.d(LOG_TAG, "updateCallNotifierRegistrationsAfterRadioTechnologyChange..."); // Unregister all events from the old obsolete phone mCM.unregisterForNewRingingConnection(this); mCM.unregisterForPreciseCallStateChanged(this); mCM.unregisterForDisconnect(this); mCM.unregisterForUnknownConnection(this); mCM.unregisterForIncomingRing(this); mCM.unregisterForCallWaiting(this); mCM.unregisterForDisplayInfo(this); mCM.unregisterForSignalInfo(this); mCM.unregisterForCdmaOtaStatusChange(this); mCM.unregisterForRingbackTone(this); mCM.unregisterForResendIncallMute(this); // Release the ToneGenerator used for playing SignalInfo and CallWaiting if (mSignalInfoToneGenerator != null) { mSignalInfoToneGenerator.release(); } // Clear ringback tone player mInCallRingbackTonePlayer = null; // Clear call waiting tone player mCallWaitingTonePlayer = null; mCM.unregisterForInCallVoicePrivacyOn(this); mCM.unregisterForInCallVoicePrivacyOff(this); // Register all events new to the new active phone registerForNotifications(); } private void registerForNotifications() { mCM.registerForNewRingingConnection(this, PHONE_NEW_RINGING_CONNECTION, null); mCM.registerForPreciseCallStateChanged(this, PHONE_STATE_CHANGED, null); mCM.registerForDisconnect(this, PHONE_DISCONNECT, null); mCM.registerForUnknownConnection(this, PHONE_UNKNOWN_CONNECTION_APPEARED, null); mCM.registerForIncomingRing(this, PHONE_INCOMING_RING, null); mCM.registerForCdmaOtaStatusChange(this, EVENT_OTA_PROVISION_CHANGE, null); mCM.registerForCallWaiting(this, PHONE_CDMA_CALL_WAITING, null); mCM.registerForDisplayInfo(this, PHONE_STATE_DISPLAYINFO, null); mCM.registerForSignalInfo(this, PHONE_STATE_SIGNALINFO, null); mCM.registerForInCallVoicePrivacyOn(this, PHONE_ENHANCED_VP_ON, null); mCM.registerForInCallVoicePrivacyOff(this, PHONE_ENHANCED_VP_OFF, null); mCM.registerForRingbackTone(this, PHONE_RINGBACK_TONE, null); mCM.registerForResendIncallMute(this, PHONE_RESEND_MUTE, null); } /** * Implemented for CallerInfoAsyncQuery.OnQueryCompleteListener interface. * refreshes the CallCard data when it called. If called with this * class itself, it is assumed that we have been waiting for the ringtone * and direct to voicemail settings to update. */ public void onQueryComplete(int token, Object cookie, CallerInfo ci) { if (cookie instanceof Long) { if (VDBG) log("CallerInfo query complete, posting missed call notification"); NotificationMgr.getDefault().notifyMissedCall(ci.name, ci.phoneNumber, ci.phoneLabel, ((Long) cookie).longValue()); } else if (cookie instanceof CallNotifier) { if (VDBG) log("CallerInfo query complete (for CallNotifier), " + "updating state for incoming call.."); // get rid of the timeout messages removeMessages(RINGER_CUSTOM_RINGTONE_QUERY_TIMEOUT); boolean isQueryExecutionTimeOK = false; synchronized (mCallerInfoQueryStateGuard) { if (mCallerInfoQueryState == CALLERINFO_QUERYING) { mCallerInfoQueryState = CALLERINFO_QUERY_READY; isQueryExecutionTimeOK = true; } } //if we're in the right state if (isQueryExecutionTimeOK) { // send directly to voicemail. if (ci.shouldSendToVoicemail) { if (DBG) log("send to voicemail flag detected. hanging up."); PhoneUtils.hangupRingingCall(mCM.getFirstActiveRingingCall()); return; } // set the ringtone uri to prepare for the ring. if (ci.contactRingtoneUri != null) { if (DBG) log("custom ringtone found, setting up ringer."); Ringer r = ((CallNotifier) cookie).mRinger; r.setCustomRingtoneUri(ci.contactRingtoneUri); } // ring, and other post-ring actions. onCustomRingQueryComplete(); } } } private void onDisconnect(AsyncResult r) { if (VDBG) log("onDisconnect()... CallManager state: " + mCM.getState()); Connection c = (Connection) r.result; if (DBG && c != null) { log("- onDisconnect: cause = " + c.getDisconnectCause() + ", incoming = " + c.isIncoming() + ", date = " + c.getCreateTime()); } mCdmaVoicePrivacyState = false; int autoretrySetting = 0; if ((c != null) && (c.getCall().getPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA)) { autoretrySetting = android.provider.Settings.System.getInt(mApplication. getContentResolver(),android.provider.Settings.System.CALL_AUTO_RETRY, 0); } if ((c != null) && (c.getCall().getPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA)) { // Stop any signalInfo tone being played when a call gets ended stopSignalInfoTone(); // Resetting the CdmaPhoneCallState members mApplication.cdmaPhoneCallState.resetCdmaPhoneCallState(); // Remove Call waiting timers removeMessages(CALLWAITING_CALLERINFO_DISPLAY_DONE); removeMessages(CALLWAITING_ADDCALL_DISABLE_TIMEOUT); } if (c != null) { Object o = c.getUserData(); if (BLACKLIST.equals(o)) { if (VDBG) Log.i(LOG_TAG, "in blacklist so skip calllog"); return; } if (c.getDurationMillis() > 0 && mSettings.mVibHangup) { mApplication.vibrate(50, 100, 50); } if (!c.isIncoming()) { mApplication.stopVib45(); } } // Stop the ringer if it was ringing (for an incoming call that // either disconnected by itself, or was rejected by the user.) // // TODO: We technically *shouldn't* stop the ringer if the // foreground or background call disconnects while an incoming call // is still ringing, but that's a really rare corner case. // It's safest to just unconditionally stop the ringer here. // CDMA: For Call collision cases i.e. when the user makes an out going call // and at the same time receives an Incoming Call, the Incoming Call is given // higher preference. At this time framework sends a disconnect for the Out going // call connection hence we should *not* be stopping the ringer being played for // the Incoming Call Call ringingCall = mCM.getFirstActiveRingingCall(); if (ringingCall.getPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA) { if (PhoneUtils.isRealIncomingCall(ringingCall.getState())) { // Also we need to take off the "In Call" icon from the Notification // area as the Out going Call never got connected if (DBG) log("cancelCallInProgressNotification()... (onDisconnect)"); NotificationMgr.getDefault().cancelCallInProgressNotification(); } else { if (DBG) log("stopRing()... (onDisconnect)"); mRinger.stopRing(); mHasRingingCall = false; } } else { // GSM if (DBG) log("stopRing()... (onDisconnect)"); mRinger.stopRing(); mHasRingingCall = false; } // stop call waiting tone if needed when disconnecting if (mCallWaitingTonePlayer != null) { mCallWaitingTonePlayer.stopTone(); mCallWaitingTonePlayer = null; } // Check for the various tones we might need to play (thru the // earpiece) after a call disconnects. int toneToPlay = InCallTonePlayer.TONE_NONE; // The "Busy" or "Congestion" tone is the highest priority: if (c != null) { Connection.DisconnectCause cause = c.getDisconnectCause(); if (cause == Connection.DisconnectCause.BUSY) { if (DBG) log("- need to play BUSY tone!"); toneToPlay = InCallTonePlayer.TONE_BUSY; } else if (cause == Connection.DisconnectCause.CONGESTION) { if (DBG) log("- need to play CONGESTION tone!"); toneToPlay = InCallTonePlayer.TONE_CONGESTION; } else if (((cause == Connection.DisconnectCause.NORMAL) || (cause == Connection.DisconnectCause.LOCAL)) && (mApplication.isOtaCallInActiveState())) { if (DBG) log("- need to play OTA_CALL_END tone!"); toneToPlay = InCallTonePlayer.TONE_OTA_CALL_END; } else if (cause == Connection.DisconnectCause.CDMA_REORDER) { if (DBG) log("- need to play CDMA_REORDER tone!"); toneToPlay = InCallTonePlayer.TONE_REORDER; } else if (cause == Connection.DisconnectCause.CDMA_INTERCEPT) { if (DBG) log("- need to play CDMA_INTERCEPT tone!"); toneToPlay = InCallTonePlayer.TONE_INTERCEPT; } else if (cause == Connection.DisconnectCause.CDMA_DROP) { if (DBG) log("- need to play CDMA_DROP tone!"); toneToPlay = InCallTonePlayer.TONE_CDMA_DROP; } else if (cause == Connection.DisconnectCause.OUT_OF_SERVICE) { if (DBG) log("- need to play OUT OF SERVICE tone!"); toneToPlay = InCallTonePlayer.TONE_OUT_OF_SERVICE; } else if (cause == Connection.DisconnectCause.UNOBTAINABLE_NUMBER) { if (DBG) log("- need to play TONE_UNOBTAINABLE_NUMBER tone!"); toneToPlay = InCallTonePlayer.TONE_UNOBTAINABLE_NUMBER; } else if (cause == Connection.DisconnectCause.ERROR_UNSPECIFIED) { if (DBG) log("- DisconnectCause is ERROR_UNSPECIFIED: play TONE_CALL_ENDED!"); toneToPlay = InCallTonePlayer.TONE_CALL_ENDED; } } // If we don't need to play BUSY or CONGESTION, then play the // "call ended" tone if this was a "regular disconnect" (i.e. a // normal call where one end or the other hung up) *and* this // disconnect event caused the phone to become idle. (In other // words, we *don't* play the sound if one call hangs up but // there's still an active call on the other line.) // TODO: We may eventually want to disable this via a preference. if ((toneToPlay == InCallTonePlayer.TONE_NONE) && (mCM.getState() == Phone.State.IDLE) && (c != null)) { Connection.DisconnectCause cause = c.getDisconnectCause(); if ((cause == Connection.DisconnectCause.NORMAL) // remote hangup || (cause == Connection.DisconnectCause.LOCAL)) { // local hangup if (VDBG) log("- need to play CALL_ENDED tone!"); toneToPlay = InCallTonePlayer.TONE_CALL_ENDED; mIsCdmaRedialCall = false; } } if (mCM.getState() == Phone.State.IDLE) { // Don't reset the audio mode or bluetooth/speakerphone state // if we still need to let the user hear a tone through the earpiece. if (toneToPlay == InCallTonePlayer.TONE_NONE) { resetAudioStateAfterDisconnect(); } NotificationMgr.getDefault().cancelCallInProgressNotification(); // If the InCallScreen is *not* in the foreground, forcibly // dismiss it to make sure it won't still be in the activity // history. (But if it *is* in the foreground, don't mess // with it; it needs to be visible, displaying the "Call // ended" state.) if (!mApplication.isShowingCallScreen()) { if (VDBG) log("onDisconnect: force InCallScreen to finish()"); mApplication.dismissCallScreen(); } else { if (VDBG) log("onDisconnect: In call screen. Set short timeout."); mApplication.clearUserActivityTimeout(); } } if (c != null) { final String number = c.getAddress(); final long date = c.getCreateTime(); final long duration = c.getDurationMillis(); final Connection.DisconnectCause cause = c.getDisconnectCause(); final Phone phone = c.getCall().getPhone(); // Set the "type" to be displayed in the call log (see constants in CallLog.Calls) final int callLogType; if (c.isIncoming()) { callLogType = (cause == Connection.DisconnectCause.INCOMING_MISSED ? Calls.MISSED_TYPE : Calls.INCOMING_TYPE); } else { callLogType = Calls.OUTGOING_TYPE; } if (VDBG) log("- callLogType: " + callLogType + ", UserData: " + c.getUserData()); { final CallerInfo ci = getCallerInfoFromConnection(c); // May be null. final String logNumber = getLogNumber(c, ci); if (DBG) log("- onDisconnect(): logNumber set to: " + /*logNumber*/ "xxxxxxx"); // TODO: In getLogNumber we use the presentation from // the connection for the CNAP. Should we use the one // below instead? (comes from caller info) // For international calls, 011 needs to be logged as + final int presentation = getPresentation(c, ci); if (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) { if ((PhoneNumberUtils.isEmergencyNumber(number)) && (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF)) { if (mEmergencyTonePlayerVibrator != null) { mEmergencyTonePlayerVibrator.stop(); } } } // To prevent accidental redial of emergency numbers // (carrier requirement) the quickest solution is to // not log the emergency number. We gate on CDMA // (ugly) when we actually mean carrier X. // TODO: Clean this up and come up with a unified strategy. final boolean shouldNotlogEmergencyNumber = (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA); // Don't call isOtaSpNumber on GSM phones. final boolean isOtaNumber = (phone.getPhoneType() == Phone.PHONE_TYPE_CDMA) && phone.isOtaSpNumber(number); final boolean isEmergencyNumber = PhoneNumberUtils.isEmergencyNumber(number); // Don't put OTA or CDMA Emergency calls into call log if (!(isOtaNumber || isEmergencyNumber && shouldNotlogEmergencyNumber)) { CallLogAsync.AddCallArgs args = new CallLogAsync.AddCallArgs( mApplication, ci, logNumber, presentation, callLogType, date, duration); mCallLog.addCall(args); } } if (callLogType == Calls.MISSED_TYPE) { // Show the "Missed call" notification. // (Note we *don't* do this if this was an incoming call that // the user deliberately rejected.) showMissedCallNotification(c, date); } // Possibly play a "post-disconnect tone" thru the earpiece. // We do this here, rather than from the InCallScreen // activity, since we need to do this even if you're not in // the Phone UI at the moment the connection ends. if (toneToPlay != InCallTonePlayer.TONE_NONE) { if (VDBG) log("- starting post-disconnect tone (" + toneToPlay + ")..."); new InCallTonePlayer(toneToPlay).start(); // TODO: alternatively, we could start an InCallTonePlayer // here with an "unlimited" tone length, // and manually stop it later when this connection truly goes // away. (The real connection over the network was closed as soon // as we got the BUSY message. But our telephony layer keeps the // connection open for a few extra seconds so we can show the // "busy" indication to the user. We could stop the busy tone // when *that* connection's "disconnect" event comes in.) } if (mCM.getState() == Phone.State.IDLE) { // Release screen wake locks if the in-call screen is not // showing. Otherwise, let the in-call screen handle this because // it needs to show the call ended screen for a couple of // seconds. if (!mApplication.isShowingCallScreen()) { if (VDBG) log("- NOT showing in-call screen; releasing wake locks!"); mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT); mApplication.requestWakeState(PhoneApp.WakeState.SLEEP); } else { if (VDBG) log("- still showing in-call screen; not releasing wake locks."); } } else { if (VDBG) log("- phone still in use; not releasing wake locks."); } if (((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING)) && (!PhoneNumberUtils.isEmergencyNumber(number)) && (cause != Connection.DisconnectCause.INCOMING_MISSED ) && (cause != Connection.DisconnectCause.NORMAL) && (cause != Connection.DisconnectCause.LOCAL) && (cause != Connection.DisconnectCause.INCOMING_REJECTED)) { if (!mIsCdmaRedialCall) { if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) { // TODO: (Moto): The contact reference data may need to be stored and use // here when redialing a call. For now, pass in NULL as the URI parameter. PhoneUtils.placeCall(phone, number, null); mIsCdmaRedialCall = true; } else { mIsCdmaRedialCall = false; } } else { mIsCdmaRedialCall = false; } } } } /** * Resets the audio mode and speaker state when a call ends. */ private void resetAudioStateAfterDisconnect() { if (VDBG) log("resetAudioStateAfterDisconnect()..."); if (mBluetoothHandsfree != null) { mBluetoothHandsfree.audioOff(); } // call turnOnSpeaker() with state=false and store=true even if speaker // is already off to reset user requested speaker state. PhoneUtils.turnOnSpeaker(mApplication, false, true); PhoneUtils.setAudioMode(mCM); } private void onMwiChanged(boolean visible) { if (VDBG) log("onMwiChanged(): " + visible); NotificationMgr.getDefault().updateMwi(visible); } /** * Posts a delayed PHONE_MWI_CHANGED event, to schedule a "retry" for a * failed NotificationMgr.updateMwi() call. */ /* package */ void sendMwiChangedDelayed(long delayMillis) { Message message = Message.obtain(this, PHONE_MWI_CHANGED); sendMessageDelayed(message, delayMillis); } private void onCfiChanged(boolean visible) { if (VDBG) log("onCfiChanged(): " + visible); NotificationMgr.getDefault().updateCfi(visible); } /* private SensorManager mSensorManager; private boolean mSensorRunning = false; private TurnListener mTurnListener = new TurnListener(); class TurnListener implements SensorEventListener { int count = 0; public void onSensorChanged(SensorEvent event) { if (++count < 5) { // omit the first 5 times return; } float[] values = event.values; // Log.i("==="," @ " + values[1] + " : " + values[2]); if (count <= 7) { // test 5 to 7 times if (Math.abs(values[1]) > 15 || Math.abs(values[2]) > 20) { // Log.i("===","force stop sensor! @ " + values[1] + " : " + values[2]); stopSensor(); } } else { if (Math.abs(values[1]) > 165 && Math.abs(values[2]) < 20) { if (DBG) log("turn over!"); silenceRinger(); } } } public void onAccuracyChanged(Sensor sensor, int accuracy) {} }; void stopSensor() { if (mSensorRunning) { if (DBG) log("stop sensor!"); mTurnListener.count = 0; mSensorManager.unregisterListener(mTurnListener); mSensorRunning = false; } } void startSensor() { if (mSettings.mTurnSilence && !mSensorRunning) { if (DBG) log("startSensor()..."); mSensorManager.registerListener(mTurnListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); mSensorRunning = true; } } */ /** * Indicates whether or not this ringer is ringing. */ boolean isRinging() { return mRinger.isRinging(); } /** * Stops the current ring, and tells the notifier that future * ring requests should be ignored. */ void silenceRinger() { mSilentRingerRequested = true; if (DBG) log("stopRing()... (silenceRinger)"); // Log.i("===","silence sensor!"); //stopSensor(); mRinger.stopRing(); } /** * Posts a PHONE_BATTERY_LOW event, causing us to play a warning * tone if the user is in-call. */ /* package */ void sendBatteryLow() { Message message = Message.obtain(this, PHONE_BATTERY_LOW); sendMessage(message); } private void onBatteryLow() { if (DBG) log("onBatteryLow()..."); // A "low battery" warning tone is now played by // StatusBarPolicy.updateBattery(). } /** * Helper class to play tones through the earpiece (or speaker / BT) * during a call, using the ToneGenerator. * * To use, just instantiate a new InCallTonePlayer * (passing in the TONE_* constant for the tone you want) * and start() it. * * When we're done playing the tone, if the phone is idle at that * point, we'll reset the audio routing and speaker state. * (That means that for tones that get played *after* a call * disconnects, like "busy" or "congestion" or "call ended", you * should NOT call resetAudioStateAfterDisconnect() yourself. * Instead, just start the InCallTonePlayer, which will automatically * defer the resetAudioStateAfterDisconnect() call until the tone * finishes playing.) */ private class InCallTonePlayer extends Thread { private int mToneId; private int mState; // The possible tones we can play. public static final int TONE_NONE = 0; public static final int TONE_CALL_WAITING = 1; public static final int TONE_BUSY = 2; public static final int TONE_CONGESTION = 3; public static final int TONE_BATTERY_LOW = 4; public static final int TONE_CALL_ENDED = 5; public static final int TONE_VOICE_PRIVACY = 6; public static final int TONE_REORDER = 7; public static final int TONE_INTERCEPT = 8; public static final int TONE_CDMA_DROP = 9; public static final int TONE_OUT_OF_SERVICE = 10; public static final int TONE_REDIAL = 11; public static final int TONE_OTA_CALL_END = 12; public static final int TONE_RING_BACK = 13; public static final int TONE_UNOBTAINABLE_NUMBER = 14; // The tone volume relative to other sounds in the stream private static final int TONE_RELATIVE_VOLUME_HIPRI = 80; private static final int TONE_RELATIVE_VOLUME_LOPRI = 50; // Buffer time (in msec) to add on to tone timeout value. // Needed mainly when the timeout value for a tone is the // exact duration of the tone itself. private static final int TONE_TIMEOUT_BUFFER = 20; // The tone state private static final int TONE_OFF = 0; private static final int TONE_ON = 1; private static final int TONE_STOPPED = 2; InCallTonePlayer(int toneId) { super(); mToneId = toneId; mState = TONE_OFF; } @Override public void run() { if (VDBG) log("InCallTonePlayer.run(toneId = " + mToneId + ")..."); int toneType = 0; // passed to ToneGenerator.startTone() int toneVolume; // passed to the ToneGenerator constructor int toneLengthMillis; int phoneType = mCM.getFgPhone().getPhoneType(); switch (mToneId) { case TONE_CALL_WAITING: toneType = ToneGenerator.TONE_SUP_CALL_WAITING; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; // Call waiting tone is stopped by stopTone() method toneLengthMillis = Integer.MAX_VALUE - TONE_TIMEOUT_BUFFER; break; case TONE_BUSY: if (phoneType == Phone.PHONE_TYPE_CDMA) { toneType = ToneGenerator.TONE_CDMA_NETWORK_BUSY_ONE_SHOT; toneVolume = TONE_RELATIVE_VOLUME_LOPRI; toneLengthMillis = 1000; } else if ((phoneType == Phone.PHONE_TYPE_GSM) || (phoneType == Phone.PHONE_TYPE_SIP)) { toneType = ToneGenerator.TONE_SUP_BUSY; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 4000; } else { throw new IllegalStateException("Unexpected phone type: " + phoneType); } break; case TONE_CONGESTION: toneType = ToneGenerator.TONE_SUP_CONGESTION; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 4000; break; case TONE_BATTERY_LOW: // For now, use ToneGenerator.TONE_PROP_ACK (two quick // beeps). TODO: is there some other ToneGenerator // tone that would be more appropriate here? Or // should we consider adding a new custom tone? toneType = ToneGenerator.TONE_PROP_ACK; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 1000; break; case TONE_CALL_ENDED: toneType = ToneGenerator.TONE_PROP_PROMPT; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 200; break; case TONE_OTA_CALL_END: if (mApplication.cdmaOtaConfigData.otaPlaySuccessFailureTone == OtaUtils.OTA_PLAY_SUCCESS_FAILURE_TONE_ON) { toneType = ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 750; } else { toneType = ToneGenerator.TONE_PROP_PROMPT; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 200; } break; case TONE_VOICE_PRIVACY: toneType = ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 5000; break; case TONE_REORDER: toneType = ToneGenerator.TONE_CDMA_ABBR_REORDER; toneVolume = TONE_RELATIVE_VOLUME_LOPRI; toneLengthMillis = 4000; break; case TONE_INTERCEPT: toneType = ToneGenerator.TONE_CDMA_ABBR_INTERCEPT; toneVolume = TONE_RELATIVE_VOLUME_LOPRI; toneLengthMillis = 500; break; case TONE_CDMA_DROP: case TONE_OUT_OF_SERVICE: toneType = ToneGenerator.TONE_CDMA_CALLDROP_LITE; toneVolume = TONE_RELATIVE_VOLUME_LOPRI; toneLengthMillis = 375; break; case TONE_REDIAL: toneType = ToneGenerator.TONE_CDMA_ALERT_AUTOREDIAL_LITE; toneVolume = TONE_RELATIVE_VOLUME_LOPRI; toneLengthMillis = 5000; break; case TONE_RING_BACK: toneType = ToneGenerator.TONE_SUP_RINGTONE; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; // Call ring back tone is stopped by stopTone() method toneLengthMillis = Integer.MAX_VALUE - TONE_TIMEOUT_BUFFER; break; case TONE_UNOBTAINABLE_NUMBER: toneType = ToneGenerator.TONE_SUP_ERROR; toneVolume = TONE_RELATIVE_VOLUME_HIPRI; toneLengthMillis = 4000; break; default: throw new IllegalArgumentException("Bad toneId: " + mToneId); } // If the mToneGenerator creation fails, just continue without it. It is // a local audio signal, and is not as important. ToneGenerator toneGenerator; try { int stream; if (mBluetoothHandsfree != null) { stream = mBluetoothHandsfree.isAudioOn() ? AudioManager.STREAM_BLUETOOTH_SCO: AudioManager.STREAM_VOICE_CALL; } else { stream = AudioManager.STREAM_VOICE_CALL; } toneGenerator = new ToneGenerator(stream, toneVolume); // if (DBG) log("- created toneGenerator: " + toneGenerator); } catch (RuntimeException e) { Log.w(LOG_TAG, "InCallTonePlayer: Exception caught while creating ToneGenerator: " + e); toneGenerator = null; } // Using the ToneGenerator (with the CALL_WAITING / BUSY / // CONGESTION tones at least), the ToneGenerator itself knows // the right pattern of tones to play; we do NOT need to // manually start/stop each individual tone, or manually // insert the correct delay between tones. (We just start it // and let it run for however long we want the tone pattern to // continue.) // // TODO: When we stop the ToneGenerator in the middle of a // "tone pattern", it sounds bad if we cut if off while the // tone is actually playing. Consider adding API to the // ToneGenerator to say "stop at the next silent part of the // pattern", or simply "play the pattern N times and then // stop." boolean needToStopTone = true; boolean okToPlayTone = false; if (toneGenerator != null) { int ringerMode = mAudioManager.getRingerMode(); if (phoneType == Phone.PHONE_TYPE_CDMA) { if (toneType == ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD) { if ((ringerMode != AudioManager.RINGER_MODE_SILENT) && (ringerMode != AudioManager.RINGER_MODE_VIBRATE)) { if (DBG) log("- InCallTonePlayer: start playing call tone=" + toneType); okToPlayTone = true; needToStopTone = false; } } else if ((toneType == ToneGenerator.TONE_CDMA_NETWORK_BUSY_ONE_SHOT) || (toneType == ToneGenerator.TONE_CDMA_ABBR_REORDER) || (toneType == ToneGenerator.TONE_CDMA_ABBR_INTERCEPT) || (toneType == ToneGenerator.TONE_CDMA_CALLDROP_LITE)) { if (ringerMode != AudioManager.RINGER_MODE_SILENT) { if (DBG) log("InCallTonePlayer:playing call fail tone:" + toneType); okToPlayTone = true; needToStopTone = false; } } else if ((toneType == ToneGenerator.TONE_CDMA_ALERT_AUTOREDIAL_LITE) || (toneType == ToneGenerator.TONE_CDMA_ALERT_NETWORK_LITE)) { if ((ringerMode != AudioManager.RINGER_MODE_SILENT) && (ringerMode != AudioManager.RINGER_MODE_VIBRATE)) { if (DBG) log("InCallTonePlayer:playing tone for toneType=" + toneType); okToPlayTone = true; needToStopTone = false; } } else { // For the rest of the tones, always OK to play. okToPlayTone = true; } } else { // Not "CDMA" okToPlayTone = true; } synchronized (this) { if (okToPlayTone && mState != TONE_STOPPED) { mState = TONE_ON; toneGenerator.startTone(toneType); try { wait(toneLengthMillis + TONE_TIMEOUT_BUFFER); } catch (InterruptedException e) { Log.w(LOG_TAG, "InCallTonePlayer stopped: " + e); } if (needToStopTone) { toneGenerator.stopTone(); } } // if (DBG) log("- InCallTonePlayer: done playing."); toneGenerator.release(); mState = TONE_OFF; } } // Finally, do the same cleanup we otherwise would have done // in onDisconnect(). // // (But watch out: do NOT do this if the phone is in use, // since some of our tones get played *during* a call (like // CALL_WAITING and BATTERY_LOW) and we definitely *don't* // want to reset the audio mode / speaker / bluetooth after // playing those! // This call is really here for use with tones that get played // *after* a call disconnects, like "busy" or "congestion" or // "call ended", where the phone has already become idle but // we need to defer the resetAudioStateAfterDisconnect() call // till the tone finishes playing.) if (mCM.getState() == Phone.State.IDLE) { resetAudioStateAfterDisconnect(); } } public void stopTone() { synchronized (this) { if (mState == TONE_ON) { notify(); } mState = TONE_STOPPED; } } } /** * Displays a notification when the phone receives a DisplayInfo record. */ private void onDisplayInfo(AsyncResult r) { // Extract the DisplayInfo String from the message CdmaDisplayInfoRec displayInfoRec = (CdmaDisplayInfoRec)(r.result); if (displayInfoRec != null) { String displayInfo = displayInfoRec.alpha; if (DBG) log("onDisplayInfo: displayInfo=" + displayInfo); CdmaDisplayInfo.displayInfoRecord(mApplication, displayInfo); // start a 2 second timer sendEmptyMessageDelayed(DISPLAYINFO_NOTIFICATION_DONE, DISPLAYINFO_NOTIFICATION_TIME); } } /** * Helper class to play SignalInfo tones using the ToneGenerator. * * To use, just instantiate a new SignalInfoTonePlayer * (passing in the ToneID constant for the tone you want) * and start() it. */ private class SignalInfoTonePlayer extends Thread { private int mToneId; SignalInfoTonePlayer(int toneId) { super(); mToneId = toneId; } @Override public void run() { if (DBG) log("SignalInfoTonePlayer.run(toneId = " + mToneId + ")..."); if (mSignalInfoToneGenerator != null) { //First stop any ongoing SignalInfo tone mSignalInfoToneGenerator.stopTone(); //Start playing the new tone if its a valid tone mSignalInfoToneGenerator.startTone(mToneId); } } } /** * Plays a tone when the phone receives a SignalInfo record. */ private void onSignalInfo(AsyncResult r) { if (PhoneUtils.isRealIncomingCall(mCM.getFirstActiveRingingCall().getState())) { // Do not start any new SignalInfo tone when Call state is INCOMING // and stop any previous SignalInfo tone which is being played stopSignalInfoTone(); } else { // Extract the SignalInfo String from the message CdmaSignalInfoRec signalInfoRec = (CdmaSignalInfoRec)(r.result); // Only proceed if a Signal info is present. if (signalInfoRec != null) { boolean isPresent = signalInfoRec.isPresent; if (DBG) log("onSignalInfo: isPresent=" + isPresent); if (isPresent) {// if tone is valid int uSignalType = signalInfoRec.signalType; int uAlertPitch = signalInfoRec.alertPitch; int uSignal = signalInfoRec.signal; if (DBG) log("onSignalInfo: uSignalType=" + uSignalType + ", uAlertPitch=" + uAlertPitch + ", uSignal=" + uSignal); //Map the Signal to a ToneGenerator ToneID only if Signal info is present int toneID = SignalToneUtil.getAudioToneFromSignalInfo (uSignalType, uAlertPitch, uSignal); //Create the SignalInfo tone player and pass the ToneID new SignalInfoTonePlayer(toneID).start(); } } } } /** * Stops a SignalInfo tone in the following condition * 1 - On receiving a New Ringing Call * 2 - On disconnecting a call * 3 - On answering a Call Waiting Call */ /* package */ void stopSignalInfoTone() { if (DBG) log("stopSignalInfoTone: Stopping SignalInfo tone player"); new SignalInfoTonePlayer(ToneGenerator.TONE_CDMA_SIGNAL_OFF).start(); } /** * Plays a Call waiting tone if it is present in the second incoming call. */ private void onCdmaCallWaiting(AsyncResult r) { // Remove any previous Call waiting timers in the queue removeMessages(CALLWAITING_CALLERINFO_DISPLAY_DONE); removeMessages(CALLWAITING_ADDCALL_DISABLE_TIMEOUT); // Set the Phone Call State to SINGLE_ACTIVE as there is only one connection // else we would not have received Call waiting mApplication.cdmaPhoneCallState.setCurrentCallState( CdmaPhoneCallState.PhoneCallState.SINGLE_ACTIVE); // Display the incoming call to the user if the InCallScreen isn't // already in the foreground. if (!mApplication.isShowingCallScreen()) { if (DBG) log("- showing incoming call (CDMA call waiting)..."); showIncomingCall(); } // Start timer for CW display mCallWaitingTimeOut = false; sendEmptyMessageDelayed(CALLWAITING_CALLERINFO_DISPLAY_DONE, CALLWAITING_CALLERINFO_DISPLAY_TIME); // Set the mAddCallMenuStateAfterCW state to false mApplication.cdmaPhoneCallState.setAddCallMenuStateAfterCallWaiting(false); // Start the timer for disabling "Add Call" menu option sendEmptyMessageDelayed(CALLWAITING_ADDCALL_DISABLE_TIMEOUT, CALLWAITING_ADDCALL_DISABLE_TIME); // Extract the Call waiting information CdmaCallWaitingNotification infoCW = (CdmaCallWaitingNotification) r.result; int isPresent = infoCW.isPresent; if (DBG) log("onCdmaCallWaiting: isPresent=" + isPresent); if (isPresent == 1 ) {//'1' if tone is valid int uSignalType = infoCW.signalType; int uAlertPitch = infoCW.alertPitch; int uSignal = infoCW.signal; if (DBG) log("onCdmaCallWaiting: uSignalType=" + uSignalType + ", uAlertPitch=" + uAlertPitch + ", uSignal=" + uSignal); //Map the Signal to a ToneGenerator ToneID only if Signal info is present int toneID = SignalToneUtil.getAudioToneFromSignalInfo(uSignalType, uAlertPitch, uSignal); //Create the SignalInfo tone player and pass the ToneID new SignalInfoTonePlayer(toneID).start(); } } /** * Posts a event causing us to clean up after rejecting (or timing-out) a * CDMA call-waiting call. * * This method is safe to call from any thread. * @see onCdmaCallWaitingReject() */ /* package */ void sendCdmaCallWaitingReject() { sendEmptyMessage(CDMA_CALL_WAITING_REJECT); } /** * Performs Call logging based on Timeout or Ignore Call Waiting Call for CDMA, * and finally calls Hangup on the Call Waiting connection. * * This method should be called only from the UI thread. * @see sendCdmaCallWaitingReject() */ private void onCdmaCallWaitingReject() { final Call ringingCall = mCM.getFirstActiveRingingCall(); // Call waiting timeout scenario if (ringingCall.getState() == Call.State.WAITING) { // Code for perform Call logging and missed call notification Connection c = ringingCall.getLatestConnection(); if (c != null) { String number = c.getAddress(); int presentation = c.getNumberPresentation(); final long date = c.getCreateTime(); final long duration = c.getDurationMillis(); final int callLogType = mCallWaitingTimeOut ? Calls.MISSED_TYPE : Calls.INCOMING_TYPE; // get the callerinfo object and then log the call with it. Object o = c.getUserData(); final CallerInfo ci; if ((o == null) || (o instanceof CallerInfo)) { ci = (CallerInfo) o; } else { ci = ((PhoneUtils.CallerInfoToken) o).currentInfo; } // Do final CNAP modifications of logNumber prior to logging [mimicking // onDisconnect()] final String logNumber = PhoneUtils.modifyForSpecialCnapCases( mApplication, ci, number, presentation); final int newPresentation = (ci != null) ? ci.numberPresentation : presentation; if (DBG) log("- onCdmaCallWaitingReject(): logNumber set to: " + logNumber + ", newPresentation value is: " + newPresentation); CallLogAsync.AddCallArgs args = new CallLogAsync.AddCallArgs( mApplication, ci, logNumber, presentation, callLogType, date, duration); mCallLog.addCall(args); if (callLogType == Calls.MISSED_TYPE) { // Add missed call notification showMissedCallNotification(c, date); } else { // Remove Call waiting 20 second display timer in the queue removeMessages(CALLWAITING_CALLERINFO_DISPLAY_DONE); } // Hangup the RingingCall connection for CW PhoneUtils.hangup(c); } //Reset the mCallWaitingTimeOut boolean mCallWaitingTimeOut = false; } } /** * Return the private variable mPreviousCdmaCallState. */ /* package */ Call.State getPreviousCdmaCallState() { return mPreviousCdmaCallState; } /** * Return the private variable mCdmaVoicePrivacyState. */ /* package */ boolean getCdmaVoicePrivacyState() { return mCdmaVoicePrivacyState; } /** * Return the private variable mIsCdmaRedialCall. */ /* package */ boolean getIsCdmaRedialCall() { return mIsCdmaRedialCall; } /** * Helper function used to show a missed call notification. */ private void showMissedCallNotification(Connection c, final long date) { PhoneUtils.CallerInfoToken info = PhoneUtils.startGetCallerInfo(mApplication, c, this, Long.valueOf(date)); if (info != null) { // at this point, we've requested to start a query, but it makes no // sense to log this missed call until the query comes back. if (VDBG) log("showMissedCallNotification: Querying for CallerInfo on missed call..."); if (info.isFinal) { // it seems that the query we have actually is up to date. // send the notification then. CallerInfo ci = info.currentInfo; // Check number presentation value; if we have a non-allowed presentation, // then display an appropriate presentation string instead as the missed // call. String name = ci.name; String number = ci.phoneNumber; if (ci.numberPresentation == Connection.PRESENTATION_RESTRICTED) { name = mApplication.getString(R.string.private_num); } else if (ci.numberPresentation != Connection.PRESENTATION_ALLOWED) { name = mApplication.getString(R.string.unknown); } else { number = PhoneUtils.modifyForSpecialCnapCases(mApplication, ci, number, ci.numberPresentation); } NotificationMgr.getDefault().notifyMissedCall(name, number, ci.phoneLabel, date); } } else { // getCallerInfo() can return null in rare cases, like if we weren't // able to get a valid phone number out of the specified Connection. Log.w(LOG_TAG, "showMissedCallNotification: got null CallerInfo for Connection " + c); } } /** * Inner class to handle emergency call tone and vibrator */ private class EmergencyTonePlayerVibrator { private final int EMG_VIBRATE_LENGTH = 1000; // ms. private final int EMG_VIBRATE_PAUSE = 1000; // ms. private final long[] mVibratePattern = new long[] { EMG_VIBRATE_LENGTH, EMG_VIBRATE_PAUSE }; private ToneGenerator mToneGenerator; private Vibrator mEmgVibrator; /** * constructor */ public EmergencyTonePlayerVibrator() { } /** * Start the emergency tone or vibrator. */ private void start() { if (VDBG) log("call startEmergencyToneOrVibrate."); int ringerMode = mAudioManager.getRingerMode(); if ((mIsEmergencyToneOn == EMERGENCY_TONE_ALERT) && (ringerMode == AudioManager.RINGER_MODE_NORMAL)) { if (VDBG) log("Play Emergency Tone."); mToneGenerator = new ToneGenerator (AudioManager.STREAM_VOICE_CALL, InCallTonePlayer.TONE_RELATIVE_VOLUME_HIPRI); if (mToneGenerator != null) { mToneGenerator.startTone(ToneGenerator.TONE_CDMA_EMERGENCY_RINGBACK); mCurrentEmergencyToneState = EMERGENCY_TONE_ALERT; } } else if (mIsEmergencyToneOn == EMERGENCY_TONE_VIBRATE) { if (VDBG) log("Play Emergency Vibrate."); mEmgVibrator = new Vibrator(); if (mEmgVibrator != null) { mEmgVibrator.vibrate(mVibratePattern, 0); mCurrentEmergencyToneState = EMERGENCY_TONE_VIBRATE; } } } /** * If the emergency tone is active, stop the tone or vibrator accordingly. */ private void stop() { if (VDBG) log("call stopEmergencyToneOrVibrate."); if ((mCurrentEmergencyToneState == EMERGENCY_TONE_ALERT) && (mToneGenerator != null)) { mToneGenerator.stopTone(); mToneGenerator.release(); } else if ((mCurrentEmergencyToneState == EMERGENCY_TONE_VIBRATE) && (mEmgVibrator != null)) { mEmgVibrator.cancel(); } mCurrentEmergencyToneState = EMERGENCY_TONE_OFF; } } private void onRingbackTone(AsyncResult r) { boolean playTone = (Boolean)(r.result); if (playTone == true) { // Only play when foreground call is in DIALING or ALERTING. // to prevent a late coming playtone after ALERTING. // Don't play ringback tone if it is in play, otherwise it will cut // the current tone and replay it if (mCM.getActiveFgCallState().isDialing() && mInCallRingbackTonePlayer == null) { mInCallRingbackTonePlayer = new InCallTonePlayer(InCallTonePlayer.TONE_RING_BACK); mInCallRingbackTonePlayer.start(); } } else { if (mInCallRingbackTonePlayer != null) { mInCallRingbackTonePlayer.stopTone(); mInCallRingbackTonePlayer = null; } } } /** * Toggle mute and unmute requests while keeping the same mute state */ private void onResendMute() { boolean muteState = PhoneUtils.getMute(); PhoneUtils.setMute(!muteState); PhoneUtils.setMute(muteState); } /** * Retrieve the phone number from the caller info or the connection. * * For incoming call the number is in the Connection object. For * outgoing call we use the CallerInfo phoneNumber field if * present. All the processing should have been done already (CDMA vs GSM numbers). * * If CallerInfo is missing the phone number, get it from the connection. * Apply the Call Name Presentation (CNAP) transform in the connection on the number. * * @param conn The phone connection. * @param info The CallerInfo. Maybe null. * @return the phone number. */ private String getLogNumber(Connection conn, CallerInfo callerInfo) { String number = null; if (conn.isIncoming()) { number = conn.getAddress(); } else { // For emergency and voicemail calls, // CallerInfo.phoneNumber does *not* contain a valid phone // number. Instead it contains an I18N'd string such as // "Emergency Number" or "Voice Mail" so we get the number // from the connection. if (null == callerInfo || TextUtils.isEmpty(callerInfo.phoneNumber) || callerInfo.isEmergencyNumber() || callerInfo.isVoiceMailNumber()) { if (conn.getCall().getPhone().getPhoneType() == Phone.PHONE_TYPE_CDMA) { // In cdma getAddress() is not always equals to getOrigDialString(). number = conn.getOrigDialString(); } else { number = conn.getAddress(); } } else { number = callerInfo.phoneNumber; } } if (null == number) { return null; } else { int presentation = conn.getNumberPresentation(); // Do final CNAP modifications. number = PhoneUtils.modifyForSpecialCnapCases(mApplication, callerInfo, number, presentation); if (!PhoneNumberUtils.isUriNumber(number)) { number = PhoneNumberUtils.stripSeparators(number); } if (VDBG) log("getLogNumber: " + number); return number; } } /** * Get the caller info. * * @param conn The phone connection. * @return The CallerInfo associated with the connection. Maybe null. */ private CallerInfo getCallerInfoFromConnection(Connection conn) { CallerInfo ci = null; Object o = conn.getUserData(); if ((o == null) || (o instanceof CallerInfo)) { ci = (CallerInfo) o; } else { ci = ((PhoneUtils.CallerInfoToken) o).currentInfo; } return ci; } /** * Get the presentation from the callerinfo if not null otherwise, * get it from the connection. * * @param conn The phone connection. * @param info The CallerInfo. Maybe null. * @return The presentation to use in the logs. */ private int getPresentation(Connection conn, CallerInfo callerInfo) { int presentation; if (null == callerInfo) { presentation = conn.getNumberPresentation(); } else { presentation = callerInfo.numberPresentation; if (DBG) log("- getPresentation(): ignoring connection's presentation: " + conn.getNumberPresentation()); } if (DBG) log("- getPresentation: presentation: " + presentation); return presentation; } private void log(String msg) { Log.d(LOG_TAG, msg); } }
49a97b747dca8ac83524002e461a9797ed4f9bdf
2f28118a9981454700b1e5e3a9c96cc52e6d40ae
/xrecyclerview/src/main/java/com/example/xrecyclerview/XRecyclerView.java
2fa81760375712349186b1565a86db4f048cfdf3
[]
no_license
lxf111/ZhuDuoDuo
bd64cebd764e0d1001a4fc3dafae678b4545f42e
c7e1065cc63baa5d724eb98a870ff5c95150f3b8
refs/heads/master
2020-03-18T21:54:12.764736
2018-08-01T10:07:06
2018-08-01T10:11:36
135,311,796
0
0
null
null
null
null
UTF-8
Java
false
false
15,190
java
package com.example.xrecyclerview; import android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.StaggeredGridLayoutManager; import android.util.AttributeSet; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; /** * Created by jingbin on 2016/1/28. */ public class XRecyclerView extends RecyclerView { private LoadingListener mLoadingListener; private WrapAdapter mWrapAdapter; private SparseArray<View> mHeaderViews = new SparseArray<>(); private SparseArray<View> mFootViews = new SparseArray<>(); private boolean pullRefreshEnabled = true; private boolean loadingMoreEnabled = true; private YunRefreshHeader mRefreshHeader; private boolean isLoadingData; public int previousTotal; public boolean isnomore; private float mLastY = -1; private static final float DRAG_RATE = 1.75f; // 是否是额外添加FooterView private boolean isOther = false; public XRecyclerView(Context context) { this(context, null); } public XRecyclerView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public XRecyclerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context); } private void init(Context context) { if (pullRefreshEnabled) { YunRefreshHeader refreshHeader = new YunRefreshHeader(context); mHeaderViews.put(0, refreshHeader); mRefreshHeader = refreshHeader; } LoadingMoreFooter footView = new LoadingMoreFooter(context); addFootView(footView, false); mFootViews.get(0).setVisibility(GONE); reset(); } /** * 改为公有。供外添加view使用,使用标识 * 注意:使用后不能使用 上拉刷新,否则添加无效 * 使用时 isOther 传入 true,然后调用 noMoreLoading即可。 */ public void addFootView(final View view, boolean isOther) { mFootViews.clear(); mFootViews.put(0, view); this.isOther = isOther; } public void clearFootView() { mFootViews.clear(); } /** * 相当于加一个空白头布局: * 只有一个目的:为了滚动条显示在最顶端 * 因为默认加了刷新头布局,不处理滚动条会下移。 * 和 setPullRefreshEnabled(false) 一块儿使用 * 使用下拉头时,此方法不应被使用! */ public void clearHeader() { mHeaderViews.clear(); final float scale = getContext().getResources().getDisplayMetrics().density; int height = (int) (1.0f * scale + 0.5f); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height); View view = new View(getContext()); view.setLayoutParams(params); mHeaderViews.put(0, view); } public void addHeaderView(View view) { if (pullRefreshEnabled && !(mHeaderViews.get(0) instanceof YunRefreshHeader)) { YunRefreshHeader refreshHeader = new YunRefreshHeader(getContext()); mHeaderViews.put(0, refreshHeader); mRefreshHeader = refreshHeader; } mHeaderViews.put(mHeaderViews.size(), view); } public void loadMoreComplete() { isLoadingData = false; View footView = mFootViews.get(0); if (previousTotal <= getLayoutManager().getItemCount()) { if (footView instanceof LoadingMoreFooter) { ((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_COMPLETE); } else { footView.setVisibility(View.GONE); } } else { if (footView instanceof LoadingMoreFooter) { ((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_NOMORE); } else { footView.setVisibility(View.GONE); } isnomore = true; } previousTotal = getLayoutManager().getItemCount(); } public void noMoreLoading() { isLoadingData = false; final View footView = mFootViews.get(0); isnomore = true; if (footView instanceof LoadingMoreFooter) { ((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_NOMORE); } else { if (footView != null) { footView.setVisibility(View.GONE); } } // 额外添加的footView if (isOther) { footView.setVisibility(View.VISIBLE); } } public void showFootView() { final View footView = mFootViews.get(0); if (footView != null) { footView.setVisibility(View.VISIBLE); } } public void refreshComplete() { // mRefreshHeader.refreshComplate(); if (isLoadingData) { loadMoreComplete(); } else { mRefreshHeader.refreshComplate(); } } @Override public void setAdapter(Adapter adapter) { mWrapAdapter = new WrapAdapter(mHeaderViews, mFootViews, adapter); super.setAdapter(mWrapAdapter); adapter.registerAdapterDataObserver(mDataObserver); } @Override public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); if (state == RecyclerView.SCROLL_STATE_IDLE && mLoadingListener != null && !isLoadingData && loadingMoreEnabled) { LayoutManager layoutManager = getLayoutManager(); int lastVisibleItemPosition; if (layoutManager instanceof GridLayoutManager) { lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition(); } else if (layoutManager instanceof StaggeredGridLayoutManager) { int[] into = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()]; ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(into); lastVisibleItemPosition = findMax(into); } else { lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition(); } if (layoutManager.getChildCount() > 0 && lastVisibleItemPosition >= layoutManager.getItemCount() - 1 && layoutManager.getItemCount() > layoutManager.getChildCount() && !isnomore && mRefreshHeader.getState() < YunRefreshHeader.STATE_REFRESHING) { View footView = mFootViews.get(0); isLoadingData = true; if (footView instanceof LoadingMoreFooter) { ((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_LOADING); } else { footView.setVisibility(View.VISIBLE); } if (isNetWorkConnected(getContext())) { mLoadingListener.onLoadMore(); } else { postDelayed(new Runnable() { @Override public void run() { mLoadingListener.onLoadMore(); } }, 1000); } } } } @Override public boolean onTouchEvent(MotionEvent ev) { if (mLastY == -1) { mLastY = ev.getRawY(); } switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mLastY = ev.getRawY(); break; case MotionEvent.ACTION_MOVE: final float deltaY = ev.getRawY() - mLastY; mLastY = ev.getRawY(); if (isOnTop() && pullRefreshEnabled) { mRefreshHeader.onMove(deltaY / DRAG_RATE); if (mRefreshHeader.getVisiableHeight() > 0 && mRefreshHeader.getState() < YunRefreshHeader.STATE_REFRESHING) { return false; } } break; default: mLastY = -1; // reset if (isOnTop() && pullRefreshEnabled) { if (mRefreshHeader.releaseAction()) { if (mLoadingListener != null) { mLoadingListener.onRefresh(); isnomore = false; previousTotal = 0; final View footView = mFootViews.get(0); if (footView instanceof LoadingMoreFooter) { if (footView.getVisibility() != View.GONE) { footView.setVisibility(View.GONE); } } } } } break; } return super.onTouchEvent(ev); } private int findMax(int[] lastPositions) { int max = lastPositions[0]; for (int value : lastPositions) { if (value > max) { max = value; } } return max; } private int findMin(int[] firstPositions) { int min = firstPositions[0]; for (int value : firstPositions) { if (value < min) { min = value; } } return min; } public boolean isOnTop() { if (mHeaderViews == null || mHeaderViews.size() == 0) { return false; } View view = mHeaderViews.get(0); if (view.getParent() != null) { return true; } else { return false; } } private final RecyclerView.AdapterDataObserver mDataObserver = new RecyclerView.AdapterDataObserver() { @Override public void onChanged() { mWrapAdapter.notifyDataSetChanged(); } @Override public void onItemRangeInserted(int positionStart, int itemCount) { mWrapAdapter.notifyItemRangeInserted(positionStart, itemCount); } @Override public void onItemRangeChanged(int positionStart, int itemCount) { mWrapAdapter.notifyItemRangeChanged(positionStart, itemCount); } @Override public void onItemRangeChanged(int positionStart, int itemCount, Object payload) { mWrapAdapter.notifyItemRangeChanged(positionStart, itemCount, payload); } @Override public void onItemRangeRemoved(int positionStart, int itemCount) { mWrapAdapter.notifyItemRangeRemoved(positionStart, itemCount); } @Override public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) { mWrapAdapter.notifyItemMoved(fromPosition, toPosition); } }; public void setLoadingListener(LoadingListener listener) { mLoadingListener = listener; } public void setPullRefreshEnabled(boolean pullRefreshEnabled) { this.pullRefreshEnabled = pullRefreshEnabled; } public void setLoadingMoreEnabled(boolean loadingMoreEnabled) { this.loadingMoreEnabled = loadingMoreEnabled; if (!loadingMoreEnabled) { if (mFootViews != null) { mFootViews.remove(0); } } else { if (mFootViews != null) { LoadingMoreFooter footView = new LoadingMoreFooter(getContext()); addFootView(footView, false); } } } public void setLoadMoreGone() { if (mFootViews == null) { return; } View footView = mFootViews.get(0); if (footView != null && footView instanceof LoadingMoreFooter) { mFootViews.remove(0); } } public interface LoadingListener { void onRefresh(); void onLoadMore(); } /** * 检测网络是否可用 * * @param context * @return */ public static boolean isNetWorkConnected(Context context) { if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable(); } } return false; } /** * headerview 增高 */ public void Increase() { mRefreshHeader.displayView(); } public void reset() { isnomore = false; final View footView = mFootViews.get(0); if (footView instanceof LoadingMoreFooter) { ((LoadingMoreFooter) footView).reSet(); } } public void setErr(Context context) { clearHeader(); View view = View.inflate(context, R.layout.header_null, null); TextView tv = (TextView) view.findViewById(R.id.tv); tv.setText("网络错误"); view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) this.getLayoutParams(); //取控件textView当前的布局参数 linearParams.height = 20;// 控件的高强制设成20 linearParams.height = LinearLayout.LayoutParams.MATCH_PARENT;// this.setLayoutParams(linearParams); addHeaderView(view); setPullRefreshEnabled(false); setLoadingMoreEnabled(false); } public void setErr2(Context context) { clearHeader(); View view = View.inflate(context, R.layout.header_null, null); TextView tv = (TextView) view.findViewById(R.id.tv); tv.setText("网络错误"); view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); addHeaderView(view); setPullRefreshEnabled(false); setLoadingMoreEnabled(false); } public void setNullData(Context context) { clearHeader(); View view = View.inflate(context, R.layout.header_null, null); TextView tv = (TextView) view.findViewById(R.id.tv); tv.setText("暂无数据"); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ViewGroup.LayoutParams linearParams = this.getLayoutParams(); //取控件textView当前的布局参数 linearParams.height = 20;// 控件的高强制设成20 linearParams.height = LinearLayout.LayoutParams.MATCH_PARENT;// this.setLayoutParams(linearParams); addHeaderView(view); setPullRefreshEnabled(false); setLoadingMoreEnabled(false); } }
04a8e15c6b07de052207b3525852f323282adb4f
d6f32b5ce6033aa257f5c50a24aa42c4f2d8101f
/src/com/company/structural/facade/library/MP4.java
4e350ee20ff11a0abe1444d6581cb2b397dbc198
[]
no_license
useer1337/patterns_exam
1cbabb05b039791084a8c846ee3c115b7d0e84e8
e5092da52d287a2bedff4d86de19876a4f1e2c99
refs/heads/main
2023-03-19T16:39:24.332000
2021-03-12T07:16:25
2021-03-12T07:19:11
329,922,802
0
0
null
null
null
null
UTF-8
Java
false
false
261
java
package com.company.structural.facade.library; public class MP4 { public void convert(String name) { System.out.println("Видео c названием \"" + name + " \" было с конвертированно в MP4 формат"); } }
8aa62fef4d1517304025115df26edcf98a9a3fba
2eee39dfb5c05f37daa97f49a41424c6f23ea8ed
/app/src/main/java/cz/weissar/horolezeckypruvodce/dijkstra/Road.java
869c867f0f2b4bc76ae29fc5b3e5128716132073
[]
no_license
thenracker/horolezeckypruvodce
5874bc6df7e8a2541c88cf9367687f64aa364828
ccd8bc3047830bea9a7e5189b48d5d4fcfaf2f17
refs/heads/master
2021-01-20T00:00:57.703804
2017-04-22T12:10:59
2017-04-22T12:10:59
89,066,807
0
0
null
null
null
null
UTF-8
Java
false
false
2,029
java
package cz.weissar.horolezeckypruvodce.dijkstra; import com.google.android.gms.maps.model.LatLng; import java.util.ArrayList; import cz.weissar.horolezeckypruvodce.data.Placemark; /** * Created by petrw on 07.12.2015. */ public class Road { private LatLng startPoint, endPoint; private double totalLength; private Placemark odkazNaPlacemark; private CrossRoad[] crossRoads; //velikost array by měla být dvě public Road(LatLng startPoint, LatLng endPoint, double totalLength, Placemark odkazNaPlacemark){ crossRoads = new CrossRoad[2]; this.startPoint = startPoint; this.endPoint = endPoint; this.totalLength = totalLength; this.odkazNaPlacemark = odkazNaPlacemark; } //FUNKCE VRAŤ KŽIŽOVATKU Z DRUHÉ STRANY CESTY (ano určitě tam je) public CrossRoad getNextCrossroad(CrossRoad prvni){ //vrátí druhý konec cesty (když zadáme první) if(crossRoads[0] != prvni) return crossRoads[0]; else return crossRoads[1]; } //PŘIDAT KŘIŽOVATKU public void addCrossroad(CrossRoad c){ if(crossRoads[0] == null)crossRoads[0] = c; else crossRoads[1] = c; } public LatLng getStartPoint() { return startPoint; } public void setStartPoint(LatLng startPoint) { this.startPoint = startPoint; } public LatLng getEndPoint() { return endPoint; } public void setEndPoint(LatLng endPoint) { this.endPoint = endPoint; } public double getTotalLength() { return totalLength; } public ArrayList<LatLng> getCoordinates(){ //odkaz nesmí být prázdný return odkazNaPlacemark.getCoordinates(); } public void setTotalLength(double totalLength) { this.totalLength = totalLength; } public Placemark getOdkazNaPlacemark() { return odkazNaPlacemark; } public void setOdkazNaPlacemark(Placemark odkazNaPlacemark) { this.odkazNaPlacemark = odkazNaPlacemark; } }
70046186867163ba5448965149fe552bd58b63d2
e8aa9f1045bab77373a6b2ec1df0af2ae13d7641
/javers-core/src/main/java/org/javers/repository/jql/ValueObjectIdDTO.java
f64d57abb45d106c8769ca6d90c73cb7638044a9
[ "Apache-2.0" ]
permissive
ianagius/javers
3f9909d4dec997ae4678eea09eaeadf7539aa2d5
53815352f30e09bb1864ba0c958f4074f6ca8935
refs/heads/master
2021-01-21T06:05:53.401423
2016-10-25T17:08:32
2016-10-25T17:08:32
68,282,201
1
0
null
2016-09-15T09:36:54
2016-09-15T09:36:53
null
UTF-8
Java
false
false
970
java
package org.javers.repository.jql; import org.javers.common.validation.Validate; import static org.javers.repository.jql.InstanceIdDTO.instanceId; /** * @author bartosz walacik */ public final class ValueObjectIdDTO extends GlobalIdDTO { private final InstanceIdDTO ownerIdDTO; private final String path; ValueObjectIdDTO(Class ownerClass, Object ownerLocalId, String path) { Validate.argumentsAreNotNull(ownerClass, ownerLocalId, path); ownerIdDTO = instanceId(ownerLocalId, ownerClass); this.path = path; } public static ValueObjectIdDTO valueObjectId(Object ownerLocalId, Class ownerClass, String fragment){ return new ValueObjectIdDTO(ownerClass, ownerLocalId, fragment); } @Override public String value() { return ownerIdDTO.value()+"#"+ path; } public InstanceIdDTO getOwnerIdDTO() { return ownerIdDTO; } public String getPath() { return path; } }
69fd52646c2bcf858da7394689e7bd4fe2d72063
fc8600b897bf112160a8ce0b161f20e85dc94610
/src/com/nico/dao/TesKurir.java
91d5d0a44d136cb4a49dee1edb9ce1e82900175b
[]
no_license
nicoreinaldi/Courier
939cb748cea73fa3f04f9f48442962bf87439c38
6c0ecfd5275b0e218278605a7e0bab6fa1572876
refs/heads/master
2021-08-23T19:55:04.883529
2017-12-06T09:19:22
2017-12-06T09:19:22
113,022,698
0
0
null
null
null
null
UTF-8
Java
false
false
455
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.nico.dao; /** * * @author user */ public class TesKurir { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } }
7bafbe8fd82db3eec9f7c7afaf123ab7079cce09
b76430327ee920461af8fb2d0a001efb04d5ecf4
/app/src/main/java/com/ming/slove/mvnew/tab2/IMFragment.java
8afe8bb7d9e2b357b494c0b392bf034a60eae825
[]
no_license
HggMing/SloveMvnew
71f5a8ea40bd8733909cac99098e491e293d05c6
6a1308b83727422612be3ea6aad47d81fcccfa5e
refs/heads/master
2021-06-16T16:57:13.406509
2017-05-10T03:52:23
2017-05-10T03:52:23
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,246
java
package com.ming.slove.mvnew.tab2; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import com.bilibili.magicasakura.utils.ThemeUtils; import com.bilibili.magicasakura.widgets.TintToolbar; import com.flyco.tablayout.listener.OnTabSelectListener; import com.ming.slove.mvnew.R; import com.ming.slove.mvnew.model.database.MyDB; import com.ming.slove.mvnew.model.database.NewFriendModel; import com.ming.slove.mvnew.model.event.ChangeThemeColorEvent; import com.ming.slove.mvnew.model.event.NewFriendEvent; import com.ming.slove.mvnew.tab2.friendlist.FriendListFragment; import com.ming.slove.mvnew.tab2.message.MessageFragment; import com.ming.slove.mvnew.ui.main.MyViewPager; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import java.util.List; import butterknife.Bind; import butterknife.ButterKnife; /** * Created by MingN on 2017/3/27. */ public class IMFragment extends Fragment { @Bind(R.id.tab_layout) MySegmentTabLayout tabLayout; @Bind(R.id.toolbar) TintToolbar mToolBar; @Bind(R.id.view_pager) MyViewPager viewPager; @Bind(R.id.contentFrame) FrameLayout contentFrame; String[] mTitles = {"消息", "老乡"}; private ArrayList<Fragment> mFragments = new ArrayList<>(); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_im, container, false); ButterKnife.bind(this, view); setHasOptionsMenu(true); EventBus.getDefault().register(this); return view; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mToolBar.setTitle(""); int themeColor = ThemeUtils.getColorById(getContext().getApplicationContext(), R.color.theme_color_primary); tabLayout.setBackgroundColor(themeColor); tabLayout.setTextSelectColor(themeColor); mFragments.add(new MessageFragment()); mFragments.add(new FriendListFragment()); // configTab(); tabLayout.setTabData(mTitles, this, R.id.contentFrame, mFragments); } //更换主题后手动刷新上方tab的颜色 @Subscribe(threadMode = ThreadMode.MAIN) public void changeThemeColor(ChangeThemeColorEvent event) { int themeColor = ThemeUtils.getColorById(getContext().getApplicationContext(), R.color.theme_color_primary); tabLayout.setBackgroundColor(themeColor); tabLayout.setTextSelectColor(themeColor); } /** * 接收到新的朋友请求消息,更新顶部tab“老乡”处消息徽章计数 * * @param event 3 */ @Subscribe(threadMode = ThreadMode.MAIN) public void showCount2(NewFriendEvent event) { List<NewFriendModel> nFriends = MyDB.getQueryAll(NewFriendModel.class); int count = 0; for (NewFriendModel nFriend : nFriends) { count += nFriend.getCount(); } if (count > 0) { tabLayout.showMsg(1, count); } else { tabLayout.hideMsg(1); } } @Override public void onDestroyView() { super.onDestroyView(); EventBus.getDefault().unregister(this); ButterKnife.unbind(this); } private void configTab() { viewPager.setAdapter(new MyPagerAdapter(getChildFragmentManager())); tabLayout.setTabData(mTitles); tabLayout.setOnTabSelectListener(new OnTabSelectListener() { @Override public void onTabSelect(int position) { viewPager.setCurrentItem(position); } @Override public void onTabReselect(int position) { } }); viewPager.setSlipping(false); viewPager.setCurrentItem(0); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { tabLayout.setCurrentTab(position); } @Override public void onPageScrollStateChanged(int state) { } }); } private class MyPagerAdapter extends FragmentPagerAdapter { MyPagerAdapter(FragmentManager fm) { super(fm); } @Override public int getCount() { return mFragments.size(); } @Override public CharSequence getPageTitle(int position) { return mTitles[position]; } @Override public Fragment getItem(int position) { return mFragments.get(position); } } }
00e209cee130a326006eae925d595e1cb8325049
69b7aecfbc4363e44ec6000c50414498e8b4911b
/libraries/android/detection/src/main/java/com/bosch/pai/bearing/sensordatastore/sensorobservation/rawobs/Constants.java
25d637afa92b47db5447445ec37687066f5fcf7f
[]
no_license
devsops/Poc_jenkins
6dcb1caef22bad324f76fe18300eb39a52228c36
8823bb2628bf4cedb826736dea6fa1820367e336
refs/heads/master
2020-06-02T15:57:32.999734
2019-06-10T18:00:28
2019-06-10T18:00:28
191,218,436
0
0
null
null
null
null
UTF-8
Java
false
false
1,458
java
package com.bosch.pai.bearing.sensordatastore.sensorobservation.rawobs; /** * The type Constants. */ public class Constants { /** * The constant GEOFENCE_RADIUS_IN_METERS. */ public static final int GEOFENCE_RADIUS_IN_METERS = 1500; // 1.5 kms /** * The constant GEOFENCE_EXPIRATION_IN_HOURS. */ // Used to set an expiration time for a geofence. After this amount of time Location Services // stops tracking the geofence. public static final long GEOFENCE_EXPIRATION_IN_HOURS = 12; /** * The constant GEOFENCE_EXPIRATION_IN_MILLISECONDS. */ // For this sample, geofences expire after twelve hours. public static final long GEOFENCE_EXPIRATION_IN_MILLISECONDS = GEOFENCE_EXPIRATION_IN_HOURS * 60 * 60 * 1000; /** * The constant GEO_FENCE_LOITERING_DELAY. */ public static final int GEO_FENCE_LOITERING_DELAY = 30000; // 0.5 minute /** * The constant START_SCAN. */ public static final int START_SCAN = 6; /** * The constant RESPONSE_RECEIVED. */ public static final int RESPONSE_RECEIVED = 7; /** * The constant SCAN_INTERVAL_WIFI. */ public static final long SCAN_INTERVAL_WIFI = 2000; /** * The constant SCAN_INTERVAL_BLE. */ public static final long SCAN_INTERVAL_BLE = 3000; /** * The constant SCAN_INTERVAL_GPS. */ public static final long SCAN_INTERVAL_GPS = 10; }
d328e5c18d8c1242bac9f3529aee49bc6d061c4c
c96b0be86c08f639d388498851384706a3c87815
/KCX-Mapping-Convert/src/com/kewill/kcx/component/mapping/countries/de/ics20/msg/MsgEntrySummaryDeclarationAcknowledgment.java
23357b18c7066752c60ba08d15b273c79d072253
[]
no_license
joelsousa/KCX-Mapping-Convert
cf1b4b785af839f6f369bcdf539bd023d4478f72
9da4b25db31f5b1dfbefd279eb76c555f3977c0e
refs/heads/master
2020-06-07T12:06:43.517765
2014-10-03T14:14:51
2014-10-03T14:14:51
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,359
java
package com.kewill.kcx.component.mapping.countries.de.ics20.msg; import java.util.ArrayList; import java.util.List; import java.util.Vector; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamException; import org.xml.sax.Attributes; import com.kewill.kcx.component.mapping.countries.common.Party; import com.kewill.kcx.component.mapping.countries.common.TIN; import com.kewill.kcx.component.mapping.countries.de.aes.msg.KCXMessage; import com.kewill.kcx.component.mapping.countries.de.ics20.msg.common.GoodsItemShort; import com.kewill.kcx.component.mapping.countries.de.ics.msg.common.IcsDocument; import com.kewill.kcx.component.mapping.countries.de.ics.msg.common.TransportMeans; import com.kewill.kcx.component.mapping.util.EFormat; import com.kewill.kcx.component.mapping.util.Utils; /** * Module : ICS20<br> * Created : 19.10.2012<br> * Description : Contains Message Structure with fields used in ICSMsgEntrySummaryDeclarationAcknowledgment. * : (IE328). * * @author krzoska * @version 2.0.00 */ public class MsgEntrySummaryDeclarationAcknowledgment extends KCXMessage { private String msgName = "ICSEntrySummaryDeclarationAcknowledgment"; private String msgType; private String referenceNumber; private String mrn; private TransportMeans meansOfTransportBorder; private String shipmentNumber; private String conveyanceReference; private String registrationDateAndTime; //private String amendmentDateAndTime; private Party personLodgingSuma; private TIN personLodgingSumaTIN; private Party representative; private TIN representativeTIN; private Party carrier; private TIN carrierTIN; private String customsOfficeOfLodgment; private String customsOfficeFirstEntry; private String declaredDateOfArrival; private IcsDocument document; private List<GoodsItemShort> goodsItemList = new ArrayList<GoodsItemShort>(); private EFormat declaredDateOfArrivalFormat; private EFormat registrationDateAndTimeFormat; public MsgEntrySummaryDeclarationAcknowledgment() { super(); } public MsgEntrySummaryDeclarationAcknowledgment(XMLEventReader parser) throws XMLStreamException { super(parser); } public MsgEntrySummaryDeclarationAcknowledgment(XMLEventReader parser, String type) throws XMLStreamException { super(parser); msgType = type; } private enum EEntrySummaryDeclarationAcknowledgment { //KIDS: UIDS (ICSAcceptance): ReferenceNumber, LocalReferenceNumber, MRN, //same MeansOfTransportBorder, TransportAtBorder, ShipmentNumber, CommercialReferenceNumber, ConveyanceReference, ConveyanceNumber, RegistrationDateAndTime, //same //AmendmentDateAndTime, //same PersonLodgingSumaTIN, PersonLodgingSumDec, PersonLodgingSumaAddress, RepresentativeTIN, Representative, RepresentativeAddress, CarrierTIN, EntryCarrier, Carrier, CarrierAddress, CustomsOfficeOfLodgement, OfficeOfLodgement, CustomsOfficeFirstEntry, OfficeOfFirstEntry, ExpectedDateOfArrival, DeclaredDateOfArrival, ExpectedArrivalDateAndTime, Document, GoodsItem; //same } public void startElement(Enum tag, String value, Attributes attr) { if (value == null) { switch ((EEntrySummaryDeclarationAcknowledgment) tag) { case MeansOfTransportBorder: case TransportAtBorder: meansOfTransportBorder = new TransportMeans(getScanner(), msgType); meansOfTransportBorder.parse(tag.name()); break; case PersonLodgingSumaTIN: personLodgingSumaTIN = new TIN(getScanner()); personLodgingSumaTIN.parse(tag.name()); break; case PersonLodgingSumaAddress: case PersonLodgingSumDec: personLodgingSuma = new Party(getScanner()); personLodgingSuma.parse(tag.name()); break; case RepresentativeTIN: representativeTIN = new TIN(getScanner()); representativeTIN.parse(tag.name()); break; case RepresentativeAddress: case Representative: representative = new Party(getScanner()); representative.parse(tag.name()); break; case CarrierTIN: carrierTIN = new TIN(getScanner()); carrierTIN.parse(tag.name()); break; case CarrierAddress: case EntryCarrier: case Carrier: carrier = new Party(getScanner()); carrier.parse(tag.name()); break; case GoodsItem: GoodsItemShort wrkGoodsItem = new GoodsItemShort(getScanner(), msgName, msgType); wrkGoodsItem.parse(tag.name()); addGoodsItemList(wrkGoodsItem); break; case Document: document = new IcsDocument(getScanner()); document.parse(tag.name()); break; default: return; } } else { switch ((EEntrySummaryDeclarationAcknowledgment) tag) { case ReferenceNumber: case LocalReferenceNumber: setReferenceNumber(value); break; case ShipmentNumber: case CommercialReferenceNumber: setShipmentNumber(value); break; case MRN: setMrn(value); break; case ConveyanceReference: case ConveyanceNumber: setConveyanceReference(value); break; case RegistrationDateAndTime: setRegistrationDateAndTime(value); if (msgType.equals("KIDS")) { setRegistrationDateAndTimeFormat(Utils.getKidsDateAndTimeFormat(value)); } else if (msgType.equals("UIDS")) { setRegistrationDateAndTimeFormat(Utils.getUidsDateAndTimeFormat(value)); } else { setRegistrationDateAndTimeFormat(null); } break; //case AmendmentDateAndTime: // setAmendmentDateAndTime(value); // break; case CustomsOfficeOfLodgement: case OfficeOfLodgement: setCustomsOfficeOfLodgment(value); break; case CustomsOfficeFirstEntry: case OfficeOfFirstEntry: setCustomsOfficeFirstEntry(value); break; case DeclaredDateOfArrival: case ExpectedDateOfArrival: case ExpectedArrivalDateAndTime: setDeclaredDateOfArrival(value); if (tag == EEntrySummaryDeclarationAcknowledgment.DeclaredDateOfArrival) { setDeclaredDateOfArrivalFormat(Utils.getKidsDateAndTimeFormat(value)); } else { setRegistrationDateAndTimeFormat(Utils.getUidsDateAndTimeFormat(value)); } break; default: break; } } } public void stoppElement(Enum tag) { } public Enum translate(String token) { try { return EEntrySummaryDeclarationAcknowledgment.valueOf(token); } catch (IllegalArgumentException e) { return null; } } public String getMsgName() { return this.msgName; } /* public void setMsgName(String argument) { this.msgName = argument; } */ public String getMsgType() { return this.msgType; } public void setMsgType(String argument) { this.msgType = argument; } public String getReferenceNumber() { return this.referenceNumber; } public void setReferenceNumber(String argument) { this.referenceNumber = argument; } public TransportMeans getMeansOfTransportBorder() { return meansOfTransportBorder; } public void setMeansOfTransportBorder(TransportMeans meansOfTransportBorder) { if (meansOfTransportBorder == null) { return; } this.meansOfTransportBorder = meansOfTransportBorder; } public Party getCarrier() { if (carrierTIN != null) { if (carrier == null) { carrier = new Party(); } carrier.setPartyTIN(carrierTIN); } return this.carrier; } public void setCarrier(Party carrier) { this.carrier = carrier; } public Party getPersonLodgingSuma() { if (personLodgingSumaTIN != null) { if (personLodgingSuma == null) { personLodgingSuma = new Party(); } personLodgingSuma.setPartyTIN(personLodgingSumaTIN); } return this.personLodgingSuma; } public void setPersonLodgingSuma(Party party) { this.personLodgingSuma = party; } public Party getRepresentative() { if (representativeTIN != null) { if (representative == null) { representative = new Party(); } representative.setPartyTIN(representativeTIN); } return this.representative; } public void setRepresentative(Party argument) { this.representative = argument; } public String getShipmentNumber() { return shipmentNumber; } public void setShipmentNumber(String shipmentNumber) { this.shipmentNumber = shipmentNumber; } public String getMrn() { return mrn; } public void setMrn(String mrn) { this.mrn = mrn; } public String getConveyanceReference() { return conveyanceReference; } public void setConveyanceReference(String conveyanceReference) { this.conveyanceReference = conveyanceReference; } public String getRegistrationDateAndTime() { return registrationDateAndTime; } public void setRegistrationDateAndTime(String registrationDateAndTime) { this.registrationDateAndTime = registrationDateAndTime; } /* public String getAmendmentDateAndTime() { return amendmentDateAndTime; } public void setAmendmentDateAndTime(String amendmentDateAndTime) { this.amendmentDateAndTime = amendmentDateAndTime; } */ public String getCustomsOfficeOfLodgment() { return customsOfficeOfLodgment; } public void setCustomsOfficeOfLodgment(String customsOfficeOfLodgment) { this.customsOfficeOfLodgment = customsOfficeOfLodgment; } public String getCustomsOfficeFirstEntry() { return customsOfficeFirstEntry; } public void setCustomsOfficeFirstEntry(String customsOfficeFirstEntry) { this.customsOfficeFirstEntry = customsOfficeFirstEntry; } public String getDeclaredDateOfArrival() { return declaredDateOfArrival; } public void setDeclaredDateOfArrival(String expectedDateOfArrival) { this.declaredDateOfArrival = expectedDateOfArrival; } public IcsDocument getDocument() { return document; } public void setDocument(IcsDocument argument) { this.document = argument; } public void setGoodsItemList(List<GoodsItemShort> goodsItemList) { this.goodsItemList = goodsItemList; } public List<GoodsItemShort> getGoodsItemList() { return goodsItemList; } public void addGoodsItemList(GoodsItemShort argument) { if (this.goodsItemList == null) { this.goodsItemList = new Vector<GoodsItemShort>(); } this.goodsItemList.add(argument); } public EFormat getDeclaredDateOfArrivalFormat() { return declaredDateOfArrivalFormat; } public void setDeclaredDateOfArrivalFormat(EFormat declaredDateOfArrivalFormat) { this.declaredDateOfArrivalFormat = declaredDateOfArrivalFormat; } public EFormat getRegistrationDateAndTimeFormat() { return registrationDateAndTimeFormat; } public void setRegistrationDateAndTimeFormat(EFormat eFormat) { this.registrationDateAndTimeFormat = eFormat; } }
31dcf516153ebf2ecf0959d27a4f801e6972cb4a
00c284f44c1734b034f18ab4e397202cdfe67965
/java_basics/23062014/src/pkg23062014/Atleti.java
5bf3b71c4dcbdfa8aad6c11a931adb2ed1abe180
[]
no_license
kaisersource/Prog
6ae752c818fe4847055023362290f9c43d7212f4
7f89c108d4003b5e09f2bd9c70a55e2d260e6a03
refs/heads/master
2021-09-02T00:13:49.515212
2017-12-29T10:33:58
2017-12-29T10:33:58
62,514,668
0
0
null
null
null
null
UTF-8
Java
false
false
402
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package pkg23062014; public abstract class Atleti { String nome; int km; public Atleti(String nome, int km){ this.nome=nome; this.km=km; } abstract double premio(); }
ee1de6b1fe42b4f023552bddcde07e34f1e76755
5dd092442f022addfd1989c592bb65864e45cf3b
/src/com/example/mobilesafe/SetUp3Activity.java
de8f02a2a3ab718ec624a1753e251bdef5013b7e
[]
no_license
xuegz/MobileSafe
faa63211003c6aefab703d7246cecc99cea3a25b
b6cfddfe7960874a79b2d12373a2988701fd5e41
refs/heads/master
2021-01-10T01:20:36.087747
2016-04-06T02:41:11
2016-04-06T02:41:11
55,400,963
1
0
null
null
null
null
UTF-8
Java
false
false
4,397
java
package com.example.mobilesafe; import com.example.utils.ShowToastUtil; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.text.TextUtils; import android.view.View; import android.widget.EditText; /* * 手机防盗设置界面3 */ public class SetUp3Activity extends SetUpActivity { private EditText et_phone; private SharedPreferences sp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_set_up3); et_phone=(EditText) findViewById(R.id.et_phone); sp=getSharedPreferences("info", MODE_PRIVATE); String telphone=sp.getString("phone", null); if (telphone!=null){ et_phone.setText(telphone); } } /* * 选择联系人 */ public void choosePhone(View v){ Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, 1); } @SuppressWarnings("deprecation") protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case 1: if (resultCode == RESULT_OK) { Uri contactData = data.getData(); Cursor cursor = managedQuery(contactData, null, null, null,null); cursor.moveToFirst(); String num = this.getContactPhone(cursor); et_phone.setText(num); } break; default: break; } } private String getContactPhone(Cursor cursor) { int phoneColumn = cursor .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); int phoneNum = cursor.getInt(phoneColumn); String result = ""; if (phoneNum > 0) { // 获得联系人的ID号 int idColumn = cursor.getColumnIndex(ContactsContract.Contacts._ID); String contactId = cursor.getString(idColumn); // 获得联系人电话的cursor Cursor phone = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + contactId, null, null); if (phone.moveToFirst()) { for (; !phone.isAfterLast(); phone.moveToNext()) { int index = phone .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); int typeindex = phone .getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE); int phone_type = phone.getInt(typeindex); String phoneNumber = phone.getString(index); result = phoneNumber; // switch (phone_type) {//此处请看下方注释 // case 2: // result = phoneNumber; // break; // // default: // break; // } } if (!phone.isClosed()) { phone.close(); } } } return result; } public void next(View v){ String num=et_phone.getText().toString(); sp.edit().putString("phone", num).commit(); toNext(); } public void back(View v){ toBack(); } @Override public void toNext() { if (TextUtils.isEmpty(et_phone.getText().toString().trim())){ ShowToastUtil.showToast(this, "安全号码不能为空"); return; } startActivity(new Intent(this, SetUp4Activity.class)); finish(); overridePendingTransition(R.anim.activity_next_in, R.anim.activity_next_out); } @Override public void toBack() { startActivity(new Intent(this, SetUp2Activity.class)); finish(); overridePendingTransition(R.anim.activity_back_in, R.anim.activity_back_out); } }
1a12b66e7b88f06e6d80c28ed542985c76359545
221d7402e7501a62135d40ccca0e69cdd628c3bb
/stock-parent/stock-model/src/main/java/com/came/stock/model/domain/ClaveArmonizada.java
ecf7e74d4f3852bd8cb16d467f7359cd4be29cf9
[]
no_license
ca4los-palalia/c4m3-570ck
5a8910e0bea3246fd6883c73d57f7f74d375f2ad
8bac5f54f1bb737cf5b5d58e9e06883cc1ca8bda
refs/heads/master
2022-12-25T15:17:02.511566
2019-07-29T14:00:12
2019-07-29T14:00:12
199,079,071
0
0
null
2022-12-09T22:51:35
2019-07-26T20:56:42
Java
UTF-8
Java
false
false
3,038
java
package com.came.stock.model.domain; import java.io.Serializable; import java.util.Calendar; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table public class ClaveArmonizada implements Serializable { private static final long serialVersionUID = -8758393432856527807L; private Long idClaveArmonizada; private String clasificacionId; private String clasificacionNombre; private Integer grupo; private Integer subGrupo; private Integer clase; private String subclase; private String tipoDeBien; private String clave; private String descripcion; private Calendar fechaActualizacion; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column public Long getIdClaveArmonizada() { return this.idClaveArmonizada; } public void setIdClaveArmonizada(Long idClaveArmonizada) { this.idClaveArmonizada = idClaveArmonizada; } @Column public String getClasificacionId() { return this.clasificacionId; } public void setClasificacionId(String clasificacionId) { this.clasificacionId = clasificacionId; } @Column public String getClasificacionNombre() { return this.clasificacionNombre; } public void setClasificacionNombre(String clasificacionNombre) { this.clasificacionNombre = clasificacionNombre; } @Column public Integer getGrupo() { return this.grupo; } public void setGrupo(Integer grupo) { this.grupo = grupo; } @Column public Integer getSubGrupo() { return this.subGrupo; } public void setSubGrupo(Integer subGrupo) { this.subGrupo = subGrupo; } @Column public Integer getClase() { return this.clase; } public void setClase(Integer clase) { this.clase = clase; } @Column public String getSubclase() { return this.subclase; } public void setSubclase(String subclase) { this.subclase = subclase; } @Column public String getTipoDeBien() { return this.tipoDeBien; } public void setTipoDeBien(String tipoDeBien) { this.tipoDeBien = tipoDeBien; } @Column public String getClave() { this.clave = (String.valueOf(this.grupo) + String.valueOf(this.subGrupo) + String.valueOf(this.clase)); if ((this.subclase != null) && (this.tipoDeBien != null)) { this.clave = (this.clave + this.subclase + this.tipoDeBien); } this.clave = (this.clave + " " + this.descripcion); return this.clave; } public void setClave(String clave) { this.clave = clave; } @Column public String getDescripcion() { return this.descripcion; } public void setDescripcion(String descripcion) { this.descripcion = descripcion; } @Column public Calendar getFechaActualizacion() { return this.fechaActualizacion; } public void setFechaActualizacion(Calendar fechaActualizacion) { this.fechaActualizacion = fechaActualizacion; } }
[ "Carlos [email protected]" ]
d7323537dde79dc482726a697efa9bd71f5e104e
586d331d6db72cc9edc84cf89bf3e154d3615d8d
/75-Sort-Colors/solution.java
eab0d6d029059fad3818428275811c100c6a4bcb
[]
no_license
whzhyh/leetcode
984368dfde045543ebba4274c6281c47dc49b322
6d1c67270fcfbba02e89387d306e4f605f056677
refs/heads/master
2020-04-06T07:06:50.131699
2016-09-06T01:11:56
2016-09-06T01:11:56
60,932,935
0
0
null
null
null
null
UTF-8
Java
false
false
1,065
java
public class Solution { public void sortColors(int[] nums) { if(nums == null || nums.length == 0) return; int left = 0, right = nums.length - 1; for(int i = 0; i < nums.length; i++) { while(nums[i] == 2 && i < right) { swap(nums, i, right--); } while(nums[i] == 0 && i > left) { swap(nums, i, left++); } } } public void swap(int[] nums, int i, int j) { int tmp = nums[i]; nums[i] = nums[j]; nums[j] = tmp; } // Counting Sort public void sortColors2(int[] nums) { if(nums == null || nums.length == 0) return; int[] counter = new int[3]; for(int n : nums) { counter[n]++; } int idx = 0; for(int i = 0; i < nums.length;) { while(counter[idx] != 0) { nums[i++] = idx; counter[idx]--; } idx++; } } }
224d41e55642fffcdd2e0ad69a1c81c247596184
4807315480333baf316e48eaa4080ee9938672be
/game-cardgame-core/src/main/java/evanq/game/common/specification/AndSpecification.java
c564f3315334e6ebc2a7e814b496d31b8cd8cfec
[ "MIT" ]
permissive
lanen/mint4j
fb4491ea51b739687df75d05e2797cf25f26b476
da73df5fcc30b636e49f29c6ff911a5851908738
refs/heads/master
2021-01-10T19:17:21.852151
2014-04-10T09:17:23
2014-04-10T09:17:23
14,675,613
1
0
null
null
null
null
UTF-8
Java
false
false
724
java
package evanq.game.common.specification; /** * AND specification, used to create a new specifcation that is the AND of two other specifications. */ public class AndSpecification<T> extends AbstractSpecification<T> { private Specification<T> spec1; private Specification<T> spec2; /** * Create a new AND specification based on two other spec. * * @param spec1 Specification one. * @param spec2 Specification two. */ public AndSpecification(final Specification<T> spec1, final Specification<T> spec2) { this.spec1 = spec1; this.spec2 = spec2; } /** * {@inheritDoc} */ public boolean isSatisfiedBy(final T t) { return spec1.isSatisfiedBy(t) && spec2.isSatisfiedBy(t); } }
5458e9fcf90d43157e272bd8e65956b78f32cfff
e6036790640b9a9572f2af711c4d743e2a4d1764
/source/mil/af/eglin/ccf/rt/fx/control/ChoiceBox.java
883b5466ed7cc6a80683793fd13439767369fe35
[ "Apache-2.0" ]
permissive
kwkin/rt-fx
a132cb17e05efd58f1777b21608885bf31a263fe
c89886404e19514c72fd54a90bf2f8ac7d516c0a
refs/heads/master
2023-02-19T23:25:55.979535
2020-06-19T14:41:55
2020-06-19T14:41:55
258,559,388
4
2
Apache-2.0
2020-05-07T19:51:52
2020-04-24T16:02:42
Java
UTF-8
Java
false
false
1,810
java
package mil.af.eglin.ccf.rt.fx.control; import com.sun.javafx.css.StyleManager; import javafx.collections.ObservableList; import mil.af.eglin.ccf.rt.fx.control.style.Accent; import mil.af.eglin.ccf.rt.util.ResourceLoader; public class ChoiceBox<T> extends javafx.scene.control.ChoiceBox<T> implements RtStyleableComponent { protected Accent accent = Accent.PRIMARY_MID; private static final String USER_AGENT_STYLESHEET = "combo-box.css"; private static final String CSS_CLASS = "rt-choice-box"; public ChoiceBox() { super(); initialize(); } public ChoiceBox(Accent accent) { super(); this.accent = accent; initialize(); } public ChoiceBox(ObservableList<T> items) { super(items); initialize(); } public ChoiceBox(ObservableList<T> items, Accent accent) { super(items); this.accent = accent; initialize(); } /** * {@inheritDoc} */ @Override public Accent getAccent() { return this.accent; } /** * {@inheritDoc} */ @Override public String getRtStyleCssName() { return CSS_CLASS; } /** * {@inheritDoc} */ @Override public String getUserAgentStylesheet() { return null; } private void initialize() { getStyleClass().add(CSS_CLASS); getStyleClass().add(this.accent.getCssName()); } /** * Loads the user agent stylesheet specific to this component */ public static void loadStyleSheet() { StyleManager.getInstance().addUserAgentStylesheet(ResourceLoader.loadComponent(USER_AGENT_STYLESHEET)); } static { ChoiceBox.loadStyleSheet(); } }
a2e30de2767580cf0ed197a205b7c6a0a075da45
d3710297bceb117445e1228ace4732572ab18efb
/android/app/src/main/java/com/newapp/MainApplication.java
5189854822ed733505d579e44a419cb8b3c76fba
[]
no_license
Nirajpaul2/Movies-App
b28fb512f575e33209e0f3bae3cfef89ee12a021
00235574af15288b1adaa98d7624b1b6b321b82c
refs/heads/master
2023-02-16T13:43:42.550701
2020-02-27T11:43:39
2020-02-27T11:43:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,752
java
package com.newapp; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.th3rdwave.safeareacontext.SafeAreaContextPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; import co.apptailor.googlesignin.RNGoogleSigninPackage; import com.facebook.react.modules.i18nmanager.I18nUtil; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); new RNGoogleSigninPackage(); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this); // Remove this line if you don't want Flipper enabled I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance(); sharedI18nUtilInstance.forceRTL(this,true); sharedI18nUtilInstance.allowRTL(this, true); } /** * Loads Flipper in React Native templates. * * @param context */ private static void initializeFlipper(Context context) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
c91a47a8e5b5c11d6b187f48920f4c0676470eff
833af4b04505f03553eedd0796898fe3825f2852
/NhryService/src/main/java/com/nhry/webService/client/masterData/functions/ZTMM00037.java
e9531ff71249ae8c79c2905e31e1f651a5dbb62d
[]
no_license
gongnol/nhry-platform
a9613a34d91db950cd958ae7d3ba923ecf22dc71
204bdbc94bc187e0aecd87dcd5fba0e5e04130c3
refs/heads/master
2021-01-21T16:15:29.538474
2017-08-05T07:19:47
2017-08-05T07:19:47
95,402,706
1
2
null
null
null
null
UTF-8
Java
false
false
59,931
java
/** * ZTMM00037.java * * This file was auto-generated from WSDL * by the Apache Axis2 version: 1.7.3 Built on : May 30, 2016 (04:09:26 BST) */ package com.nhry.webService.client.masterData.functions; /** * ZTMM00037 bean class */ @SuppressWarnings({"unchecked", "unused" }) public class ZTMM00037 implements org.apache.axis2.databinding.ADBBean { /* This type was generated from the piece of schema that had name = ZTMM00037 Namespace URI = urn:sap-com:document:sap:rfc:functions Namespace Prefix = ns1 */ /** * field for MANDT */ protected com.nhry.webService.client.masterData.functions.MANDT_type3 localMANDT; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localMANDTTracker = false; /** * field for MATNR */ protected com.nhry.webService.client.masterData.functions.MATNR_type9 localMATNR; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localMATNRTracker = false; /** * field for PRDL1 */ protected com.nhry.webService.client.masterData.functions.PRDL1_type1 localPRDL1; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPRDL1Tracker = false; /** * field for PRDL2 */ protected com.nhry.webService.client.masterData.functions.PRDL2_type1 localPRDL2; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPRDL2Tracker = false; /** * field for BRAND */ protected com.nhry.webService.client.masterData.functions.BRAND_type1 localBRAND; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localBRANDTracker = false; /** * field for BRANF */ protected com.nhry.webService.client.masterData.functions.BRANF_type1 localBRANF; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localBRANFTracker = false; /** * field for FRMAT */ protected com.nhry.webService.client.masterData.functions.FRMAT_type1 localFRMAT; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localFRMATTracker = false; /** * field for COUNF */ protected com.nhry.webService.client.masterData.functions.COUNF_type1 localCOUNF; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localCOUNFTracker = false; /** * field for MEINS */ protected com.nhry.webService.client.masterData.functions.MEINS_type5 localMEINS; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localMEINSTracker = false; /** * field for PACK1 */ protected com.nhry.webService.client.masterData.functions.PACK1_type1 localPACK1; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPACK1Tracker = false; /** * field for PACK2 */ protected com.nhry.webService.client.masterData.functions.PACK2_type1 localPACK2; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPACK2Tracker = false; /** * field for CLASF */ protected com.nhry.webService.client.masterData.functions.CLASF_type1 localCLASF; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localCLASFTracker = false; /** * field for STUDF */ protected com.nhry.webService.client.masterData.functions.STUDF_type1 localSTUDF; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localSTUDFTracker = false; /** * field for PRDLD */ protected com.nhry.webService.client.masterData.functions.PRDLD_type1 localPRDLD; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPRDLDTracker = false; /** * field for PRDLT */ protected com.nhry.webService.client.masterData.functions.PRDLT_type1 localPRDLT; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPRDLTTracker = false; /** * field for BRANT */ protected com.nhry.webService.client.masterData.functions.BRANT_type1 localBRANT; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localBRANTTracker = false; /** * field for BRANS */ protected com.nhry.webService.client.masterData.functions.BRANS_type1 localBRANS; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localBRANSTracker = false; /** * field for PACKD */ protected com.nhry.webService.client.masterData.functions.PACKD_type1 localPACKD; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPACKDTracker = false; /** * field for PACKT */ protected com.nhry.webService.client.masterData.functions.PACKT_type1 localPACKT; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localPACKTTracker = false; /** * field for CLAST */ protected com.nhry.webService.client.masterData.functions.CLAST_type1 localCLAST; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localCLASTTracker = false; /** * field for USADD */ protected com.nhry.webService.client.masterData.functions.USADD_type1 localUSADD; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localUSADDTracker = false; /** * field for FRMAD */ protected com.nhry.webService.client.masterData.functions.FRMAD_type1 localFRMAD; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localFRMADTracker = false; /** * field for MSEHL */ protected com.nhry.webService.client.masterData.functions.MSEHL_type1 localMSEHL; /* This tracker boolean wil be used to detect whether the user called the set method * for this attribute. It will be used to determine whether to include this field * in the serialized XML */ protected boolean localMSEHLTracker = false; public boolean isMANDTSpecified() { return localMANDTTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.MANDT_type3 */ public com.nhry.webService.client.masterData.functions.MANDT_type3 getMANDT() { return localMANDT; } /** * Auto generated setter method * @param param MANDT */ public void setMANDT( com.nhry.webService.client.masterData.functions.MANDT_type3 param) { localMANDTTracker = param != null; this.localMANDT = param; } public boolean isMATNRSpecified() { return localMATNRTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.MATNR_type9 */ public com.nhry.webService.client.masterData.functions.MATNR_type9 getMATNR() { return localMATNR; } /** * Auto generated setter method * @param param MATNR */ public void setMATNR( com.nhry.webService.client.masterData.functions.MATNR_type9 param) { localMATNRTracker = param != null; this.localMATNR = param; } public boolean isPRDL1Specified() { return localPRDL1Tracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PRDL1_type1 */ public com.nhry.webService.client.masterData.functions.PRDL1_type1 getPRDL1() { return localPRDL1; } /** * Auto generated setter method * @param param PRDL1 */ public void setPRDL1( com.nhry.webService.client.masterData.functions.PRDL1_type1 param) { localPRDL1Tracker = param != null; this.localPRDL1 = param; } public boolean isPRDL2Specified() { return localPRDL2Tracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PRDL2_type1 */ public com.nhry.webService.client.masterData.functions.PRDL2_type1 getPRDL2() { return localPRDL2; } /** * Auto generated setter method * @param param PRDL2 */ public void setPRDL2( com.nhry.webService.client.masterData.functions.PRDL2_type1 param) { localPRDL2Tracker = param != null; this.localPRDL2 = param; } public boolean isBRANDSpecified() { return localBRANDTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.BRAND_type1 */ public com.nhry.webService.client.masterData.functions.BRAND_type1 getBRAND() { return localBRAND; } /** * Auto generated setter method * @param param BRAND */ public void setBRAND( com.nhry.webService.client.masterData.functions.BRAND_type1 param) { localBRANDTracker = param != null; this.localBRAND = param; } public boolean isBRANFSpecified() { return localBRANFTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.BRANF_type1 */ public com.nhry.webService.client.masterData.functions.BRANF_type1 getBRANF() { return localBRANF; } /** * Auto generated setter method * @param param BRANF */ public void setBRANF( com.nhry.webService.client.masterData.functions.BRANF_type1 param) { localBRANFTracker = param != null; this.localBRANF = param; } public boolean isFRMATSpecified() { return localFRMATTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.FRMAT_type1 */ public com.nhry.webService.client.masterData.functions.FRMAT_type1 getFRMAT() { return localFRMAT; } /** * Auto generated setter method * @param param FRMAT */ public void setFRMAT( com.nhry.webService.client.masterData.functions.FRMAT_type1 param) { localFRMATTracker = param != null; this.localFRMAT = param; } public boolean isCOUNFSpecified() { return localCOUNFTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.COUNF_type1 */ public com.nhry.webService.client.masterData.functions.COUNF_type1 getCOUNF() { return localCOUNF; } /** * Auto generated setter method * @param param COUNF */ public void setCOUNF( com.nhry.webService.client.masterData.functions.COUNF_type1 param) { localCOUNFTracker = param != null; this.localCOUNF = param; } public boolean isMEINSSpecified() { return localMEINSTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.MEINS_type5 */ public com.nhry.webService.client.masterData.functions.MEINS_type5 getMEINS() { return localMEINS; } /** * Auto generated setter method * @param param MEINS */ public void setMEINS( com.nhry.webService.client.masterData.functions.MEINS_type5 param) { localMEINSTracker = param != null; this.localMEINS = param; } public boolean isPACK1Specified() { return localPACK1Tracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PACK1_type1 */ public com.nhry.webService.client.masterData.functions.PACK1_type1 getPACK1() { return localPACK1; } /** * Auto generated setter method * @param param PACK1 */ public void setPACK1( com.nhry.webService.client.masterData.functions.PACK1_type1 param) { localPACK1Tracker = param != null; this.localPACK1 = param; } public boolean isPACK2Specified() { return localPACK2Tracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PACK2_type1 */ public com.nhry.webService.client.masterData.functions.PACK2_type1 getPACK2() { return localPACK2; } /** * Auto generated setter method * @param param PACK2 */ public void setPACK2( com.nhry.webService.client.masterData.functions.PACK2_type1 param) { localPACK2Tracker = param != null; this.localPACK2 = param; } public boolean isCLASFSpecified() { return localCLASFTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.CLASF_type1 */ public com.nhry.webService.client.masterData.functions.CLASF_type1 getCLASF() { return localCLASF; } /** * Auto generated setter method * @param param CLASF */ public void setCLASF( com.nhry.webService.client.masterData.functions.CLASF_type1 param) { localCLASFTracker = param != null; this.localCLASF = param; } public boolean isSTUDFSpecified() { return localSTUDFTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.STUDF_type1 */ public com.nhry.webService.client.masterData.functions.STUDF_type1 getSTUDF() { return localSTUDF; } /** * Auto generated setter method * @param param STUDF */ public void setSTUDF( com.nhry.webService.client.masterData.functions.STUDF_type1 param) { localSTUDFTracker = param != null; this.localSTUDF = param; } public boolean isPRDLDSpecified() { return localPRDLDTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PRDLD_type1 */ public com.nhry.webService.client.masterData.functions.PRDLD_type1 getPRDLD() { return localPRDLD; } /** * Auto generated setter method * @param param PRDLD */ public void setPRDLD( com.nhry.webService.client.masterData.functions.PRDLD_type1 param) { localPRDLDTracker = param != null; this.localPRDLD = param; } public boolean isPRDLTSpecified() { return localPRDLTTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PRDLT_type1 */ public com.nhry.webService.client.masterData.functions.PRDLT_type1 getPRDLT() { return localPRDLT; } /** * Auto generated setter method * @param param PRDLT */ public void setPRDLT( com.nhry.webService.client.masterData.functions.PRDLT_type1 param) { localPRDLTTracker = param != null; this.localPRDLT = param; } public boolean isBRANTSpecified() { return localBRANTTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.BRANT_type1 */ public com.nhry.webService.client.masterData.functions.BRANT_type1 getBRANT() { return localBRANT; } /** * Auto generated setter method * @param param BRANT */ public void setBRANT( com.nhry.webService.client.masterData.functions.BRANT_type1 param) { localBRANTTracker = param != null; this.localBRANT = param; } public boolean isBRANSSpecified() { return localBRANSTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.BRANS_type1 */ public com.nhry.webService.client.masterData.functions.BRANS_type1 getBRANS() { return localBRANS; } /** * Auto generated setter method * @param param BRANS */ public void setBRANS( com.nhry.webService.client.masterData.functions.BRANS_type1 param) { localBRANSTracker = param != null; this.localBRANS = param; } public boolean isPACKDSpecified() { return localPACKDTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PACKD_type1 */ public com.nhry.webService.client.masterData.functions.PACKD_type1 getPACKD() { return localPACKD; } /** * Auto generated setter method * @param param PACKD */ public void setPACKD( com.nhry.webService.client.masterData.functions.PACKD_type1 param) { localPACKDTracker = param != null; this.localPACKD = param; } public boolean isPACKTSpecified() { return localPACKTTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.PACKT_type1 */ public com.nhry.webService.client.masterData.functions.PACKT_type1 getPACKT() { return localPACKT; } /** * Auto generated setter method * @param param PACKT */ public void setPACKT( com.nhry.webService.client.masterData.functions.PACKT_type1 param) { localPACKTTracker = param != null; this.localPACKT = param; } public boolean isCLASTSpecified() { return localCLASTTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.CLAST_type1 */ public com.nhry.webService.client.masterData.functions.CLAST_type1 getCLAST() { return localCLAST; } /** * Auto generated setter method * @param param CLAST */ public void setCLAST( com.nhry.webService.client.masterData.functions.CLAST_type1 param) { localCLASTTracker = param != null; this.localCLAST = param; } public boolean isUSADDSpecified() { return localUSADDTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.USADD_type1 */ public com.nhry.webService.client.masterData.functions.USADD_type1 getUSADD() { return localUSADD; } /** * Auto generated setter method * @param param USADD */ public void setUSADD( com.nhry.webService.client.masterData.functions.USADD_type1 param) { localUSADDTracker = param != null; this.localUSADD = param; } public boolean isFRMADSpecified() { return localFRMADTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.FRMAD_type1 */ public com.nhry.webService.client.masterData.functions.FRMAD_type1 getFRMAD() { return localFRMAD; } /** * Auto generated setter method * @param param FRMAD */ public void setFRMAD( com.nhry.webService.client.masterData.functions.FRMAD_type1 param) { localFRMADTracker = param != null; this.localFRMAD = param; } public boolean isMSEHLSpecified() { return localMSEHLTracker; } /** * Auto generated getter method * @return com.nhry.webService.client.masterData.functions.MSEHL_type1 */ public com.nhry.webService.client.masterData.functions.MSEHL_type1 getMSEHL() { return localMSEHL; } /** * Auto generated setter method * @param param MSEHL */ public void setMSEHL( com.nhry.webService.client.masterData.functions.MSEHL_type1 param) { localMSEHLTracker = param != null; this.localMSEHL = param; } /** * * @param parentQName * @param factory * @return org.apache.axiom.om.OMElement */ public org.apache.axiom.om.OMElement getOMElement( final javax.xml.namespace.QName parentQName, final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException { return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource( this, parentQName)); } public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { serialize(parentQName, xmlWriter, false); } public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "urn:sap-com:document:sap:rfc:functions"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":ZTMM00037", xmlWriter); } else { writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "ZTMM00037", xmlWriter); } } if (localMANDTTracker) { if (localMANDT == null) { throw new org.apache.axis2.databinding.ADBException( "MANDT cannot be null!!"); } localMANDT.serialize(new javax.xml.namespace.QName("", "MANDT"), xmlWriter); } if (localMATNRTracker) { if (localMATNR == null) { throw new org.apache.axis2.databinding.ADBException( "MATNR cannot be null!!"); } localMATNR.serialize(new javax.xml.namespace.QName("", "MATNR"), xmlWriter); } if (localPRDL1Tracker) { if (localPRDL1 == null) { throw new org.apache.axis2.databinding.ADBException( "PRDL1 cannot be null!!"); } localPRDL1.serialize(new javax.xml.namespace.QName("", "PRDL1"), xmlWriter); } if (localPRDL2Tracker) { if (localPRDL2 == null) { throw new org.apache.axis2.databinding.ADBException( "PRDL2 cannot be null!!"); } localPRDL2.serialize(new javax.xml.namespace.QName("", "PRDL2"), xmlWriter); } if (localBRANDTracker) { if (localBRAND == null) { throw new org.apache.axis2.databinding.ADBException( "BRAND cannot be null!!"); } localBRAND.serialize(new javax.xml.namespace.QName("", "BRAND"), xmlWriter); } if (localBRANFTracker) { if (localBRANF == null) { throw new org.apache.axis2.databinding.ADBException( "BRANF cannot be null!!"); } localBRANF.serialize(new javax.xml.namespace.QName("", "BRANF"), xmlWriter); } if (localFRMATTracker) { if (localFRMAT == null) { throw new org.apache.axis2.databinding.ADBException( "FRMAT cannot be null!!"); } localFRMAT.serialize(new javax.xml.namespace.QName("", "FRMAT"), xmlWriter); } if (localCOUNFTracker) { if (localCOUNF == null) { throw new org.apache.axis2.databinding.ADBException( "COUNF cannot be null!!"); } localCOUNF.serialize(new javax.xml.namespace.QName("", "COUNF"), xmlWriter); } if (localMEINSTracker) { if (localMEINS == null) { throw new org.apache.axis2.databinding.ADBException( "MEINS cannot be null!!"); } localMEINS.serialize(new javax.xml.namespace.QName("", "MEINS"), xmlWriter); } if (localPACK1Tracker) { if (localPACK1 == null) { throw new org.apache.axis2.databinding.ADBException( "PACK1 cannot be null!!"); } localPACK1.serialize(new javax.xml.namespace.QName("", "PACK1"), xmlWriter); } if (localPACK2Tracker) { if (localPACK2 == null) { throw new org.apache.axis2.databinding.ADBException( "PACK2 cannot be null!!"); } localPACK2.serialize(new javax.xml.namespace.QName("", "PACK2"), xmlWriter); } if (localCLASFTracker) { if (localCLASF == null) { throw new org.apache.axis2.databinding.ADBException( "CLASF cannot be null!!"); } localCLASF.serialize(new javax.xml.namespace.QName("", "CLASF"), xmlWriter); } if (localSTUDFTracker) { if (localSTUDF == null) { throw new org.apache.axis2.databinding.ADBException( "STUDF cannot be null!!"); } localSTUDF.serialize(new javax.xml.namespace.QName("", "STUDF"), xmlWriter); } if (localPRDLDTracker) { if (localPRDLD == null) { throw new org.apache.axis2.databinding.ADBException( "PRDLD cannot be null!!"); } localPRDLD.serialize(new javax.xml.namespace.QName("", "PRDLD"), xmlWriter); } if (localPRDLTTracker) { if (localPRDLT == null) { throw new org.apache.axis2.databinding.ADBException( "PRDLT cannot be null!!"); } localPRDLT.serialize(new javax.xml.namespace.QName("", "PRDLT"), xmlWriter); } if (localBRANTTracker) { if (localBRANT == null) { throw new org.apache.axis2.databinding.ADBException( "BRANT cannot be null!!"); } localBRANT.serialize(new javax.xml.namespace.QName("", "BRANT"), xmlWriter); } if (localBRANSTracker) { if (localBRANS == null) { throw new org.apache.axis2.databinding.ADBException( "BRANS cannot be null!!"); } localBRANS.serialize(new javax.xml.namespace.QName("", "BRANS"), xmlWriter); } if (localPACKDTracker) { if (localPACKD == null) { throw new org.apache.axis2.databinding.ADBException( "PACKD cannot be null!!"); } localPACKD.serialize(new javax.xml.namespace.QName("", "PACKD"), xmlWriter); } if (localPACKTTracker) { if (localPACKT == null) { throw new org.apache.axis2.databinding.ADBException( "PACKT cannot be null!!"); } localPACKT.serialize(new javax.xml.namespace.QName("", "PACKT"), xmlWriter); } if (localCLASTTracker) { if (localCLAST == null) { throw new org.apache.axis2.databinding.ADBException( "CLAST cannot be null!!"); } localCLAST.serialize(new javax.xml.namespace.QName("", "CLAST"), xmlWriter); } if (localUSADDTracker) { if (localUSADD == null) { throw new org.apache.axis2.databinding.ADBException( "USADD cannot be null!!"); } localUSADD.serialize(new javax.xml.namespace.QName("", "USADD"), xmlWriter); } if (localFRMADTracker) { if (localFRMAD == null) { throw new org.apache.axis2.databinding.ADBException( "FRMAD cannot be null!!"); } localFRMAD.serialize(new javax.xml.namespace.QName("", "FRMAD"), xmlWriter); } if (localMSEHLTracker) { if (localMSEHL == null) { throw new org.apache.axis2.databinding.ADBException( "MSEHL cannot be null!!"); } localMSEHL.serialize(new javax.xml.namespace.QName("", "MSEHL"), xmlWriter); } xmlWriter.writeEndElement(); } private static java.lang.String generatePrefix(java.lang.String namespace) { if (namespace.equals("urn:sap-com:document:sap:rfc:functions")) { return "ns1"; } return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); } /** * Utility method to write an element start tag. */ private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); if (writerPrefix != null) { xmlWriter.writeStartElement(writerPrefix, localPart, namespace); } else { if (namespace.length() == 0) { prefix = ""; } else if (prefix == null) { prefix = generatePrefix(namespace); } xmlWriter.writeStartElement(prefix, localPart, namespace); xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } } /** * Util method to write an attribute with the ns prefix */ private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName, java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); if (writerPrefix != null) { xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue); } else { xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); xmlWriter.writeAttribute(prefix, namespace, attName, attValue); } } /** * Util method to write an attribute without the ns prefix */ private void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { if (namespace.equals("")) { xmlWriter.writeAttribute(attName, attValue); } else { xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue); } } /** * Util method to write an attribute without the ns prefix */ private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String attributeNamespace = qname.getNamespaceURI(); java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); if (attributePrefix == null) { attributePrefix = registerPrefix(xmlWriter, attributeNamespace); } java.lang.String attributeValue; if (attributePrefix.trim().length() > 0) { attributeValue = attributePrefix + ":" + qname.getLocalPart(); } else { attributeValue = qname.getLocalPart(); } if (namespace.equals("")) { xmlWriter.writeAttribute(attName, attributeValue); } else { registerPrefix(xmlWriter, namespace); xmlWriter.writeAttribute(attributePrefix, namespace, attName, attributeValue); } } /** * method to handle Qnames */ private void writeQName(javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String namespaceURI = qname.getNamespaceURI(); if (namespaceURI != null) { java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); if (prefix == null) { prefix = generatePrefix(namespaceURI); xmlWriter.writeNamespace(prefix, namespaceURI); xmlWriter.setPrefix(prefix, namespaceURI); } if (prefix.trim().length() > 0) { xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qname)); } else { // i.e this is the default namespace xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qname)); } } else { xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qname)); } } private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { if (qnames != null) { // we have to store this data until last moment since it is not possible to write any // namespace data after writing the charactor data java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); java.lang.String namespaceURI = null; java.lang.String prefix = null; for (int i = 0; i < qnames.length; i++) { if (i > 0) { stringToWrite.append(" "); } namespaceURI = qnames[i].getNamespaceURI(); if (namespaceURI != null) { prefix = xmlWriter.getPrefix(namespaceURI); if ((prefix == null) || (prefix.length() == 0)) { prefix = generatePrefix(namespaceURI); xmlWriter.writeNamespace(prefix, namespaceURI); xmlWriter.setPrefix(prefix, namespaceURI); } if (prefix.trim().length() > 0) { stringToWrite.append(prefix).append(":") .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qnames[i])); } else { stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qnames[i])); } } else { stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString( qnames[i])); } } xmlWriter.writeCharacters(stringToWrite.toString()); } } /** * Register a namespace prefix */ private java.lang.String registerPrefix( javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { java.lang.String prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = generatePrefix(namespace); javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); while (true) { java.lang.String uri = nsContext.getNamespaceURI(prefix); if ((uri == null) || (uri.length() == 0)) { break; } prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); } xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } return prefix; } /** * Factory class that keeps the parse method */ public static class Factory { private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(Factory.class); /** * static method to create the object * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element * Postcondition: If this object is an element, the reader is positioned at its end element * If this object is a complex type, the reader is positioned at the end element of its outer element */ public static ZTMM00037 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { ZTMM00037 object = new ZTMM00037(); int event; javax.xml.namespace.QName currentQName = null; java.lang.String nillableValue = null; java.lang.String prefix = ""; java.lang.String namespaceuri = ""; try { while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); currentQName = reader.getName(); if (reader.getAttributeValue( "http://www.w3.org/2001/XMLSchema-instance", "type") != null) { java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); if (fullTypeName != null) { java.lang.String nsPrefix = null; if (fullTypeName.indexOf(":") > -1) { nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); } nsPrefix = (nsPrefix == null) ? "" : nsPrefix; java.lang.String type = fullTypeName.substring(fullTypeName.indexOf( ":") + 1); if (!"ZTMM00037".equals(type)) { //find namespace for the prefix java.lang.String nsUri = reader.getNamespaceContext() .getNamespaceURI(nsPrefix); return (ZTMM00037) com.nhry.webService.client.masterData.functions.ExtensionMapper.getTypeObject(nsUri, type, reader); } } } // Note all attributes that were handled. Used to differ normal attributes // from anyAttributes. java.util.Vector handledAttributes = new java.util.Vector(); reader.next(); while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "MANDT").equals( reader.getName())) || new javax.xml.namespace.QName("", "MANDT").equals( reader.getName())) { object.setMANDT(com.nhry.webService.client.masterData.functions.MANDT_type3.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "MATNR").equals( reader.getName())) || new javax.xml.namespace.QName("", "MATNR").equals( reader.getName())) { object.setMATNR(com.nhry.webService.client.masterData.functions.MATNR_type9.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PRDL1").equals( reader.getName())) || new javax.xml.namespace.QName("", "PRDL1").equals( reader.getName())) { object.setPRDL1(com.nhry.webService.client.masterData.functions.PRDL1_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PRDL2").equals( reader.getName())) || new javax.xml.namespace.QName("", "PRDL2").equals( reader.getName())) { object.setPRDL2(com.nhry.webService.client.masterData.functions.PRDL2_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "BRAND").equals( reader.getName())) || new javax.xml.namespace.QName("", "BRAND").equals( reader.getName())) { object.setBRAND(com.nhry.webService.client.masterData.functions.BRAND_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "BRANF").equals( reader.getName())) || new javax.xml.namespace.QName("", "BRANF").equals( reader.getName())) { object.setBRANF(com.nhry.webService.client.masterData.functions.BRANF_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "FRMAT").equals( reader.getName())) || new javax.xml.namespace.QName("", "FRMAT").equals( reader.getName())) { object.setFRMAT(com.nhry.webService.client.masterData.functions.FRMAT_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "COUNF").equals( reader.getName())) || new javax.xml.namespace.QName("", "COUNF").equals( reader.getName())) { object.setCOUNF(com.nhry.webService.client.masterData.functions.COUNF_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "MEINS").equals( reader.getName())) || new javax.xml.namespace.QName("", "MEINS").equals( reader.getName())) { object.setMEINS(com.nhry.webService.client.masterData.functions.MEINS_type5.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PACK1").equals( reader.getName())) || new javax.xml.namespace.QName("", "PACK1").equals( reader.getName())) { object.setPACK1(com.nhry.webService.client.masterData.functions.PACK1_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PACK2").equals( reader.getName())) || new javax.xml.namespace.QName("", "PACK2").equals( reader.getName())) { object.setPACK2(com.nhry.webService.client.masterData.functions.PACK2_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "CLASF").equals( reader.getName())) || new javax.xml.namespace.QName("", "CLASF").equals( reader.getName())) { object.setCLASF(com.nhry.webService.client.masterData.functions.CLASF_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "STUDF").equals( reader.getName())) || new javax.xml.namespace.QName("", "STUDF").equals( reader.getName())) { object.setSTUDF(com.nhry.webService.client.masterData.functions.STUDF_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PRDLD").equals( reader.getName())) || new javax.xml.namespace.QName("", "PRDLD").equals( reader.getName())) { object.setPRDLD(com.nhry.webService.client.masterData.functions.PRDLD_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PRDLT").equals( reader.getName())) || new javax.xml.namespace.QName("", "PRDLT").equals( reader.getName())) { object.setPRDLT(com.nhry.webService.client.masterData.functions.PRDLT_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "BRANT").equals( reader.getName())) || new javax.xml.namespace.QName("", "BRANT").equals( reader.getName())) { object.setBRANT(com.nhry.webService.client.masterData.functions.BRANT_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "BRANS").equals( reader.getName())) || new javax.xml.namespace.QName("", "BRANS").equals( reader.getName())) { object.setBRANS(com.nhry.webService.client.masterData.functions.BRANS_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PACKD").equals( reader.getName())) || new javax.xml.namespace.QName("", "PACKD").equals( reader.getName())) { object.setPACKD(com.nhry.webService.client.masterData.functions.PACKD_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "PACKT").equals( reader.getName())) || new javax.xml.namespace.QName("", "PACKT").equals( reader.getName())) { object.setPACKT(com.nhry.webService.client.masterData.functions.PACKT_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "CLAST").equals( reader.getName())) || new javax.xml.namespace.QName("", "CLAST").equals( reader.getName())) { object.setCLAST(com.nhry.webService.client.masterData.functions.CLAST_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "USADD").equals( reader.getName())) || new javax.xml.namespace.QName("", "USADD").equals( reader.getName())) { object.setUSADD(com.nhry.webService.client.masterData.functions.USADD_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "FRMAD").equals( reader.getName())) || new javax.xml.namespace.QName("", "FRMAD").equals( reader.getName())) { object.setFRMAD(com.nhry.webService.client.masterData.functions.FRMAD_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if ((reader.isStartElement() && new javax.xml.namespace.QName("", "MSEHL").equals( reader.getName())) || new javax.xml.namespace.QName("", "MSEHL").equals( reader.getName())) { object.setMSEHL(com.nhry.webService.client.masterData.functions.MSEHL_type1.Factory.parse( reader)); reader.next(); } // End of if for expected property start element else { } while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if (reader.isStartElement()) { // 2 - A start element we are not expecting indicates a trailing invalid property throw new org.apache.axis2.databinding.ADBException( "Unexpected subelement " + reader.getName()); } } catch (javax.xml.stream.XMLStreamException e) { throw new java.lang.Exception(e); } return object; } } //end of factory class }
dae0c725c254c9c57c56dd3053cd3f717356d15c
76c53c289e3379e4e9c67bfa208fb1eda115d460
/app1/src/com/tfs/operator/util/OperatorUtil.java
68e9b6066a0487faadc689e3dfdda7f08388dc93
[]
no_license
ayazpasha2434/poc
d99a2154c66c3c0469dcd787c0d7afbb9ece820c
bfafd4f81696153310b07a111c092919476a8e3e
refs/heads/master
2021-01-20T03:34:06.739932
2012-12-12T09:11:03
2012-12-12T09:11:03
null
0
0
null
null
null
null
UTF-8
Java
false
false
416
java
/** * */ package com.tfs.operator.util; import com.tfs.common.Util; import com.tfs.operator.rest.Operator; import com.tfs.operator.service.OperatorService; /** * @author ayaz * */ public class OperatorUtil { public static Operator get(long id) { OperatorService operatorService = (OperatorService) Util.getObject("operatorService"); return new Operator(operatorService.getOperatorDetails(id)); } }
91d4e2125bb616fe85d94a481665a9ee14d3949a
132538db8ca5eefe5b7bb7e8a37b6c9d1fe8f1af
/javaWork/onLineChess/com/resources/ResourceFinder.java
85a2d0ba8b418496e91e66dbe399526a2e79030c
[]
no_license
KiranPaladugu/javawork_old
0dd6832107f58b36f528dbace166d3e352082fd1
707f195149c7295c8efe7b8c98f218f0aaf5be88
refs/heads/master
2021-04-05T08:34:39.273050
2016-08-03T22:24:43
2016-08-03T22:26:21
61,388,772
0
0
null
null
null
null
UTF-8
Java
false
false
675
java
package com.resources; import java.io.File; import java.io.InputStream; import java.net.URL; import com.logService.Logger; public class ResourceFinder { public static URL getResource(){ return ResourceFinder.getResource(); } public static URL getResource(String name){ try{ return ResourceFinder.class.getResource(name); }catch (Exception e){ Logger.log("Unable to Load resource:"+name); return null; } } public static File getResourceFile(String name){ return new File(ResourceFinder.class.getResource(name).getFile()); } public static InputStream getResouceAsAStream(String name){ return ResourceFinder.class.getResourceAsStream(name); } }