blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
132
path
stringlengths
2
382
src_encoding
stringclasses
34 values
length_bytes
int64
9
3.8M
score
float64
1.5
4.94
int_score
int64
2
5
detected_licenses
listlengths
0
142
license_type
stringclasses
2 values
text
stringlengths
9
3.8M
download_success
bool
1 class
febc9e4f864f513e44c98c2d3640062422b1f160
Java
ichoukou/uhome
/uhomeBase/src/main/java/com/ytoxl/module/uhome/uhomebase/mapper/UserCouponMapper.java
UTF-8
2,375
1.9375
2
[]
no_license
package com.ytoxl.module.uhome.uhomebase.mapper; import java.util.List; import java.util.Map; import org.apache.ibatis.annotations.Param; import org.springframework.dao.DataAccessException; import com.ytoxl.module.core.common.persistence.BaseSqlMapper; import com.ytoxl.module.uhome.uhomebase.dataobject.UserCoupon; public interface UserCouponMapper<T extends UserCoupon> extends BaseSqlMapper<T> { /** * 分页查询用户优惠券信息 * @param couponStatus 优惠券状态 * @return * @throws DataAccessException */ public List<UserCoupon> searchUserCouponsByStatus(Map<String, Object> map) throws DataAccessException; public Integer searchUserCouponsByStatusCount(Map<String, Object> map) throws DataAccessException; /** * 根据优惠券号查询用户优惠券信息 * @param couponNo 优惠券号 * @return * @throws DataAccessException */ public UserCoupon getUserCouponByCouponNo(String couponNo) throws DataAccessException; /** * * @param couponNo * @return * @throws DataAccessException */ public UserCoupon getUserCouponById(Integer userCouponId) throws DataAccessException; /** * 根据用户id查询用户可用优惠券 * @param userId * @return 用户可用优惠券 * @throws DataAccessException */ public List<UserCoupon> searchValidCoupons(Integer userId) throws DataAccessException; /** * 修改用户优惠券状态 * userCoupon * @throws DataAccessException */ public void updateCouponStatus(UserCoupon userCoupon)throws DataAccessException; /** * 修改已激活但未使用的优惠券状态为已删除 * @param eventId * @throws DataAccessException */ public void updateCouponStatus2Deleted(Integer eventId) throws DataAccessException; public Integer checkUserActiveCode(UserCoupon userCoupon) throws DataAccessException; /** * 根据用户id,couponConfigIds获得用户优惠劵 * @param userid * @param couponConfigs * @return * @throws DataAccessException */ public List<UserCoupon> getUserCouponByCouponConfigAndUserId(@Param("userId")Integer userId,@Param("list")List<Integer> couponConfigs) throws DataAccessException; /** * 根据用户id获得能全场使用的优惠劵 * @param userId * @return * @throws DataAccessException */ public List<UserCoupon> getUserCouponByUserIdWithAll(Integer userId) throws DataAccessException; }
true
7fff64823c974e07457dcfa63b9f1b3f2f4165ae
Java
TGNThump/core
/src/main/java/uk/me/pilgrim/dev/core/commands/annotations/Alias.java
UTF-8
643
2.453125
2
[]
no_license
package uk.me.pilgrim.dev.core.commands.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotates a {@link Command} or {@link Flag} Parameter to provide it with an alias. * @author Benjamin Pilgrim &lt;ben@pilgrim.me.uk&gt; */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.PARAMETER}) @Repeatable(Aliases.class) public @interface Alias { /** * The alias attached to the method or parameter. * @return The name of the alias. */ String value(); }
true
963a188cb8a7b1f58ad95a43deed6d6f007d0f0b
Java
Pashkar80/AutomationFinalTask
/src/main/java/by/htp/finalproject/controler/MainControler.java
UTF-8
395
2.109375
2
[]
no_license
package by.htp.finalproject.controler; import java.sql.SQLException; import by.htp.finalprojectlibrary.dao.BookDAO; import by.htp.finalprojectlibrary.dao.DAO; import by.htp.finalprojectlibrary.ntety.Book; public class MainControler { public static void main(String[] args) throws SQLException { DAO dao = new BookDAO(); Book book = dao.getAll("book"); System.out.println(book); } }
true
9a354c77d055eb8f3e6098e63c38bef7e53615a5
Java
soyoung1016/JAVA
/day1119/HomeWork_1119.java
UHC
4,506
3.921875
4
[]
no_license
package day1119; /** * *1. ð Է¹޾ Ʒ ϼ. * : ð ִ 2ð 60 Ѵ ٸ "Ÿ" 60 ϶ "ܰŸ" ϼ. 2. ̸, ܰ Ÿ Է¹޾ Ʒ ϼ. ",ö,ý," Ѵ. 1200, ö 1250, ýÿ 3800 Դϴ. 10Ű ⺻, 5Ű ʰ 100 մϴ. : xxx xx̸ Ÿ xx Ű Դϴ. ̿ xx̰, պ̿ xx̸, Ѵ 20ϱ : xxxx Դϴ. * @author owner */ public class HomeWork_1119 { public static final int BUS_PRICE=1200; public static final int SUB_PRICE=1250; public static final int TAXI_PRICE=3800; public static void main(String[] args) { //1 int commute = Integer.parseInt(args[0]); if (0<commute&commute<=60) { System.out.println("ܰŸ Դϴ."); } else if (60<commute&commute<=120) { System.out.println("Ÿ Դϴ."); } else { System.out.println("ִ ð ʰϿϴ."); }//end else //1 //2 /* * 2. ̸, ܰ Ÿ Է¹޾ Ʒ ϼ. ",ö,ý," Ѵ. 1200, ö 1250, ýÿ 3800 Դϴ. 10Ű ⺻, 5Ű ʰ 100 մϴ. : xxx xx̸ Ÿ xx Ű Դϴ. ̿ xx̰, պ̿ xx̸, Ѵ 20ϱ : xxxx Դϴ. */ int distance = Integer.parseInt(args[3]); int price = (int)(distance-10)/5; System.out.print(args[1]+" "); if (args[2].equals("")) { if(distance<=10) { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+BUS_PRICE+" ̰, պ ̿ "+BUS_PRICE*2+"̸, Ѵ 20 : "+BUS_PRICE*2*20+" Դϴ."); } else { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+(BUS_PRICE+(price*100))+" ̰, պ ̿ "+((BUS_PRICE+(price*100))*2)+ "̸, Ѵ 20 : "+((BUS_PRICE+(price*100))*2*20)+" Դϴ."); } } else if (args[2].equals("ö")) { if(distance<=10) { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+SUB_PRICE+" ̰, պ ̿ "+SUB_PRICE*2+"̸, Ѵ 20 : "+SUB_PRICE*2*20+" Դϴ."); } else { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+(SUB_PRICE+(price*100))+" ̰, պ ̿ "+((SUB_PRICE+(price*100))*2)+ "̸, Ѵ 20 : "+((SUB_PRICE+(price*100))*2*20)+" Դϴ."); } } else if (args[2].equals("ý")) { if(distance<=10) { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+TAXI_PRICE+" ̰, պ ̿ "+TAXI_PRICE*2+"̸, Ѵ 20 : "+TAXI_PRICE*2*20+" Դϴ."); } else { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); System.out.println(" ̿ "+(TAXI_PRICE+(price*100))+" ̰, պ ̿ "+((TAXI_PRICE+(price*100))*2)+ "̸, Ѵ 20 : "+((TAXI_PRICE+(price*100))*2*20)+" Դϴ."); } } else if (args[2].equals("")) { System.out.println(args[2]+"̸ Ÿ "+args[3]+"Ű Դϴ."); } else { System.out.println("߸ Դϴ."); } }//main }//class
true
41f41d124a9857e7213ee34c4d5b755a9e676694
Java
Gabrielsouza1945/CURSO-FACULDADE-JAVA
/ByteBank-Conta-Herdado/src/padrao/TesteSaca.java
UTF-8
638
2.625
3
[]
no_license
package padrao; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author rafae */ public class TesteSaca { public static void main(String[] args) { Conta c = new ContaCorrente(0454,123243); try{ c.deposita(500); c.saca(5050); } catch(SaldoInsuficienteException ex){ ex.printStackTrace(); } System.out.println(c.getSaldo()); } }
true
f2d8ffe33d6a2646ca2d9ddcd431d0c4a8cbd0c8
Java
xinput123/xinput
/java/juc/src/main/java/com/xinput/entity/ProductItem.java
UTF-8
772
2.40625
2
[]
no_license
package com.xinput.entity; import lombok.Getter; import lombok.Setter; /** * 商品 */ @Getter @Setter public class ProductItem { private Long id; private String name; private Double price; private String desc; private int sleep; public ProductItem(Long id, String name, Double price, String desc, int sleep) { this.id = id; this.name = name; this.price = price; this.desc = desc; this.sleep = sleep; } @Override public String toString() { return "ProductItem{" + "id=" + id + ", name='" + name + '\'' + ", price=" + price + ", desc='" + desc + '\'' + ", sleep=" + sleep + '}'; } }
true
d2c2410368ba362e7ea96766bc8a98b1ba162454
Java
wapjia43106140/KMIP-2.0-Implementation
/webapp/backend/src/main/java/com/ibm/controllers/TestController.java
UTF-8
9,677
2.421875
2
[]
no_license
package com.ibm.controllers; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import com.ibm.model.Key; import com.ibm.model.KeyPair; import com.ibm.model.User; import com.ibm.algorithms.aes; import com.ibm.algorithms.rsa; import ClientInterfaces.Connection; import ClientInterfaces.MainApplication; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @CrossOrigin(origins = "http://localhost:4200") @RestController public class TestController { private List<User> employees = createList(); MainApplication mainObject = new MainApplication(); public void getConnection() throws IOException { mainObject.setKeyStore("keystorePath", "keystoreType", "keystorePassword"); Connection connection = mainObject.getConnection("IP", Port); } @RequestMapping(value = "/users", method = RequestMethod.GET, produces = "application/json") public List<User> firstPage() { return employees; } @PostMapping(path = { "/createkey" }) public Key create(@RequestBody Key key) throws Exception { System.out.println(key.getTypeOfKey()+" "+key.getAlgorithm()+" "+key.getKeySize()+" "+key.getUniqueIdentifier()); //pass these parameters to the create key function //add unique identifier to the object //return the same object //key.setUniqueIdentifier("ThisIsUniqueIdentifier"); getConnection(); List<String> uuid = mainObject.createKey(key.getAlgorithm(), key.getKeySize(), key.getTypeOfKey()); key.setUniqueIdentifier(uuid.get(0)); //System.out.println(key.getTypeOfKey()+" "+key.getAlgorithm()+" "+key.getKeySize()+" "+key.getUniqueIdentifier()); System.out.println(uuid); return key; } @PostMapping(path = { "/createkeypair" }) public KeyPair createKeyPair(@RequestBody KeyPair keyPair) throws Exception { System.out.println(keyPair.getTypeOfKey()+" "+keyPair.getAlgorithm()+" "+keyPair.getKeySize()+" "+keyPair.getPrivateKeyUniqueIdentifier()+" "+keyPair.getPublicKeyUniqueIdentifier()+" "+keyPair.getPrivateKeyNameValue()+" "+keyPair.getPublicKeyNameValue()); //pass these parameters to the create key function //add unique identifier to the object //return the same object //keyPair.setPrivateKeyUniqueIdentifier("ThisIsPrivateKeyUniqueIdentifier"); //keyPair.setPublicKeyUniqueIdentifier("ThisIsPublicKeyUniqueIdentifier"); getConnection(); List<String> uuid = mainObject.createKeyPair(keyPair.getAlgorithm(), keyPair.getKeySize(), keyPair.getTypeOfKey(), keyPair.getPrivateKeyNameValue(), keyPair.getPublicKeyNameValue()); keyPair.setPrivateKeyUniqueIdentifier(uuid.get(0)); keyPair.setPublicKeyUniqueIdentifier(uuid.get(1)); //System.out.println(keyPair.getTypeOfKey()+" "+keyPair.getAlgorithm()+" "+keyPair.getKeySize()+" "+keyPair.getPrivateKeyUniqueIdentifier()+" "+keyPair.getPublicKeyUniqueIdentifier()+" "+keyPair.getPrivateKeyNameValue()+" "+keyPair.getPublicKeyNameValue()); System.out.println(uuid); return keyPair; } @PostMapping(path = { "/getkey" }) public List<String> get(@RequestBody Key key) throws Exception { //get key by passing uniqueIdentifier System.out.println(key.getUniqueIdentifier()); /*List<String> keyBlock = new ArrayList<String>(); keyBlock.add("ThisIsKey"); keyBlock.add("ThisIsKeyMaterial"); keyBlock.add("ThisIsKeyFormatType"); keyBlock.add("ThisIsObjectType");*/ getConnection(); List<String> keyBlock = mainObject.getKey(key.getUniqueIdentifier()); System.out.println(keyBlock); //keyBlock.add(0, "Key Unique Identifier : "+keyBlock.get(0)); //keyBlock.add(1, "Key Format Type : "+keyBlock.get(1)); //keyBlock.add(2, "Key Material : "+keyBlock.get(2)); //keyBlock.add(3, "Object Type : "+keyBlock.get(3)); return keyBlock; } @PostMapping(path = { "/destroykey" }) public List<String> destroy(@RequestBody Key key) throws Exception { //get result status by passing unique identifier System.out.println(key.getUniqueIdentifier()); //String ResultStatus = "ThisIsResultStatus"; getConnection(); List<String> ResultStatus = mainObject.destroyKey(key.getUniqueIdentifier()); System.out.println(ResultStatus); return ResultStatus; } @PostMapping(path = { "/locatekey" }) public List<String> locate(@RequestParam("ObjectType") String ObjectType) throws Exception { //get result status by passing unique identifier System.out.println(ObjectType); //List<String> UniqueIdentifiers = new ArrayList<String>(); //UniqueIdentifiers.add("UUID1"); //UniqueIdentifiers.add("UUID2"); getConnection(); List<String> UniqueIdentifiers = mainObject.locateKey(ObjectType); System.out.println(UniqueIdentifiers); return UniqueIdentifiers; } @PostMapping(path = { "/encrypt" }) public String encrypt(@RequestParam("plaintextFile") MultipartFile file, @RequestParam("uniqueIdentifier") String uniqueIdentifier) throws Exception { //String plaintext = file.getBytes().toString(); //System.out.println(plaintext); //System.out.println(uniqueIdentifier); //convert multipart to file and read content String fileName = "D:/"+"encrypted-"+file.getOriginalFilename(); File ciphertext = new File(fileName); file.transferTo(ciphertext); BufferedReader bufferedReader = new BufferedReader(new FileReader(ciphertext)); String fileContent=""; String i; while ((i = bufferedReader.readLine()) != null){ fileContent+=i; } System.out.println(fileContent); //consider value of key for now //String secretKey = "30820122300D06092A864886F70D01010105000382010F003082010A02820101008F2613A05EE5132FBE1B28447FAE2B37D6B7C3D75CB4CEF67E229FE9C4D019D998E30F44AD4F767E477BEB632AEB38A5EC9D5897327FABD81E8B45F35536D399635C12F95008C5996B393533B471D432742E75C4F58B8F3398B8FF4CD0752CD368F410EA41EB435BD9ADA7E4825EA25FF31BCFCE12B4C07D0306B86C52721328F804A0C548A39972F346C1A4DDEA3B760C74FD510F0F92275384B92EFF3D5846352C74CA644EC30194353D18853BE7B2BC49FA957E29C2B84CC32E4048BDFDD99C7F4A2A6E5AD8D02D8F1BA4909419ACC9DEDDE84B5B4B49AD575815E2F1A186FCAC9E3FD3BCB5825AD4796FACA97A42B8D61101C6DA4F9C6375C5C3FA6C599D0203010001"; String SymmetricKeyObjectType = "SymmetricKey"; String PublicKeyObjectType = "PublicKey"; //String ObjectType = "PublicKey"; String encryptedText = ""; getConnection(); List<String> keyBlock = mainObject.getKey(uniqueIdentifier); String secretKey = keyBlock.get(2); String ObjectType = keyBlock.get(3); if(ObjectType.equals(SymmetricKeyObjectType)) { aes aesAlgo = new aes(); encryptedText = aesAlgo.encrypt(fileContent, secretKey); System.out.println(encryptedText); return encryptedText; } else if(ObjectType.equals(PublicKeyObjectType)) { rsa rsaAlgo = new rsa(); encryptedText = rsaAlgo.encrypt(fileContent, secretKey); System.out.println(encryptedText); } //WRITE TO FILE NOT WORKING //FileWriter fileWriter = new FileWriter(ciphertext); //fileWriter.write(encryptedText); //BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); //bufferedWriter.write(encryptedText); return encryptedText; } @PostMapping(path = { "/decrypt" }) public String decrypt(@RequestParam("ciphertextFile") MultipartFile file, @RequestParam("uniqueIdentifier") String uniqueIdentifier) throws Exception { //String plaintext = file.getBytes().toString(); //System.out.println(plaintext); //System.out.println(uniqueIdentifier); //convert multipart to file and read content String fileName = "D:/"+"decrypted-"+file.getOriginalFilename(); File plaintext = new File(fileName); file.transferTo(plaintext); BufferedReader bufferedReader = new BufferedReader(new FileReader(plaintext)); String fileContent=""; String i; while ((i = bufferedReader.readLine()) != null){ fileContent+=i; } System.out.println(fileContent); //consider value of key for now //String secretKey = "308204BC020100300D06092A864886F70D0101010500048204A6308204A202010002820101008F2613A05EE5132FBE1B28447FAE2B37D6B7C3D75CB4CEF67E229FE9C4D019D998E30F44AD4F767E477BEB632AEB38A5EC9D5897327FABD81E8B45F35536D399635C12F95008C5996B393533B471D432742E75C4F58B8F3398B8FF4CD0752CD368F410EA41EB435BD9ADA7E4825EA25FF31BCFCE12B4C07D0306B86C52721328F804A0C548A39972F346C1A4DDEA3B760C74FD510F0F92275384B92EFF3D5846352C74CA644EC30194353D18853BE7B2BC49FA957E29C2B84CC32E4048BDFDD99C7F4A2A6E5AD8D02D8F1BA4909419ACC9DEDDE84B5B4B49AD575815E2F1A186FCAC9E3FD3BCB5825AD4796FACA97A42B8D61101C6DA4F9C6375C5C3FA6C599D02030100010282010031E6B624CBAFD3766B3110628097F89CE88EFB08525AFD62D429C1D13E38C52A23AFD39CBF45DA2ABF44A593D65C554D1224EFC31569884038B59856F137C19FD11141D403606B71C5FD155CC6E47F726F29DB082408D88CC60A8785018E3768234821B567F15973E57831F4E8B590A91E186DE28A86D42B4028D19581501EF93CB4FEFC669C2CF0366C1EC600582CCDA8BDBD522DA9721B1E974986BDCE1D477BA39CBF742DD9F34ED7426C8E81469C985F1F02945DCEC9132146567F09720AF48973B38D14067FA10E1BB80D13053CA4420EC34C617D91F368F060898AAA2E548CCFA8A07806E2F4DB8335D2FB32BCF73BC9E7E841D6321F75E33A5594AF8902818100D8566B2C9D90F13F008825BF49329553FF77D49BB1C3E89EFA7CDD9EAF03E2FE3A24226ADF7A15CE93FCC6533D1F5E7675A8940C991A92AC75A8219AE8A002232E633BA8317DE3DC141D80D1666E9C7089FA8307428D6A9B533566E0F449B8D83DD752DF4F554833D12BD71E13DBE7C47235508CCC41076DDC48D5084E239E8302818100A9649D85C7C65A57D017F2ABA8980964924BBB2471C2CD2321D9B656BF488D0A907A8BC16BFC1E4B4ECF2F87429F67430E2E371DD8422320AEF0FD7436802D031D226573AF2F9CF31E4997B53CB68D37D71CF41C18C63C7009E9F64CC74434B0768015F4A6E8D5BB0DE67CC9B1E44CD0DC47969E81282583334A9511E6B2AD5F02818020B5A84CBDA22DA7BDF7D7E53D3705B7069862B00BC7B843595249DBF5505C20DE3F9A689853883A8CCB9A5CF98FE5A37994BC95CF0C6282EAE339F98714B25E09647D9FA7A40630BF65DA954EAC88C0C74BF645C1BD4A1224199DED8362262DA3E40BA6B2030E00AFAEB63ED8F7D5EA30EE78B86125AFEEDF70AFAD2ACB5DEB0281805DEE2A1F45F12AA5A901AE921B91FB1B66B851D4DAB44FB65C8DF23B5624AFF91CB6A78AA10B93ECE48DA4E8573C37318ACA7BCBB3E0B0C3EDDE3A5D57DF69966170725B5CD8852A972FEDCD1516916656857AA39DE5471C459313FDED3D580E4617AE95147CE60FAC9C93B3F04E0D7E7FB7BEC0B414040125CF04AC8185B0F70281806CB961439C636501EBE761E6620ED3B4EBE497C969A7056D371BC08BB83463395561933206B593644BC7B19130469C80F021380EB54439E8EA025DD33A793D62F17E29A83A848B6AF8085B613D7219BC4E1E0945E996247FA42F452DB39B97F273CD5183E128260E3654DB8ECC261106A881CCC06E8626B9EE87B5AADAFD84AC"; String SymmetricKeyObjectType = "SymmetricKey"; String PrivateKeyObjectType = "PrivateKey"; //String ObjectType = "PrivateKey"; String decryptedText = ""; getConnection(); List<String> keyBlock = mainObject.getKey(uniqueIdentifier); String secretKey = keyBlock.get(2); String ObjectType = keyBlock.get(3); if(ObjectType.equals(SymmetricKeyObjectType)) { aes aesAlgo = new aes(); decryptedText = aesAlgo.decrypt(fileContent, secretKey); System.out.println(decryptedText); } else if (ObjectType.equals(PrivateKeyObjectType)) { rsa rsaAlgo = new rsa(); decryptedText = rsaAlgo.decrypt(fileContent, secretKey); System.out.println(decryptedText); } //WRITE TO FILE NOT WORKING //FileWriter fileWriter = new FileWriter(ciphertext); //fileWriter.write(encryptedText); //BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); //bufferedWriter.write(encryptedText); return decryptedText; } private static List<User> createList() { List<User> tempUsers = new ArrayList<User>(); User user1 = new User(); user1.setUserName("user1"); user1.setPassword("password1"); User user2 = new User(); user2.setUserName("user2"); user2.setPassword("password2"); tempUsers.add(user1); tempUsers.add(user2); //System.out.println(tempEmployees); return tempUsers; } }
true
357b388901ba37aaf35bdc1929e5bcadd5fa1539
Java
aiq7520/gupao-2019-resources
/code/design-pattern/delegation-pattern/src/main/java/org/gege/design/delegation/web/Handler.java
UTF-8
93
1.664063
2
[]
no_license
package org.gege.design.delegation.web; public interface Handler { void controller(); }
true
aee3165f144a72940bbafe0ebaf5adda8339fe93
Java
yangjin1234/iMusicProject
/iMusicProject/src/main/java/com/teach/mapper/VideoMapper.java
UTF-8
364
1.875
2
[]
no_license
package com.teach.mapper; import com.teach.entity.Video; public interface VideoMapper { int deleteByPrimaryKey(String videoId); int insert(Video record); int insertSelective(Video record); Video selectByPrimaryKey(String videoId); int updateByPrimaryKeySelective(Video record); int updateByPrimaryKey(Video record); }
true
a3f133d50e3428106883f25f51a6436703e7c01b
Java
aidenyan/inside
/inside-service/src/main/java/com/jimmy/service/sys/impl/SysConfigServiceImpl.java
UTF-8
1,686
2.1875
2
[]
no_license
package com.jimmy.service.sys.impl; import com.jimmy.common.utils.BeanUtils; import com.jimmy.dao.sys.entity.SysConfig; import com.jimmy.dao.sys.mapper.SysConfigMapper; import com.jimmy.dto.SysConfigDTO; import com.jimmy.service.sys.SysConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.List; /** * Created by Administrator on 2019/5/27/027. */ @Service @Transactional(readOnly = true) public class SysConfigServiceImpl implements SysConfigService { @Autowired private SysConfigMapper sysConfigMapper; @Override public SysConfigDTO find() { List<SysConfig> sysConfigList = sysConfigMapper.list(); if (CollectionUtils.isEmpty(sysConfigList)) { return new SysConfigDTO(); } SysConfigDTO sysConfigDTO = new SysConfigDTO(); sysConfigList.forEach(sysConfig -> { BeanUtils.setFieldValue(sysConfigDTO, sysConfig.getKey(), sysConfig.getValue()); }); return sysConfigDTO; } @Override @Transactional(rollbackFor = Exception.class) public void save(SysConfigDTO sysConfigDTO) { List<SysConfig> sysConfigList = sysConfigMapper.list(); if (CollectionUtils.isEmpty(sysConfigList)) { return; } sysConfigList.forEach(sysConfig -> { Object value = BeanUtils.getFieldValue(sysConfigDTO, sysConfig.getKey()); sysConfig.setValue((String) value); sysConfigMapper.update(sysConfig); }); } }
true
524f1cb51b3e94c792e75b8b993ff105af0289f9
Java
loong0306/SEEGEM
/src/main/source/me/dragon/model/Constants.java
UTF-8
662
1.851563
2
[]
no_license
package me.dragon.model; /** * Created by dragon on 12/12/2017. */ public class Constants { public static final String IMAGE_BMP = "image/bmp"; public static final String IMAGE_JPEG = "image/jpeg"; public static final String IMAGE_GIF = "image/gif"; public static final String TEXT_HTML = "text/html"; public static final String APPLICATION_VSD = "application/vnd.visio"; public static final String TEXT_PLAIN = "text/plain"; public static final String APPLICATION_PPT = "application/vnd.ms-powerpoint"; public static final String APPLICATION_DOC = "application/msword"; public static final String TEXT_XML = "text/xml"; }
true
4605a971a847756cea2fc9bbd25bfa6d5815c5a2
Java
10020210/myproject
/src/main/java/com/pass/model/domain/EngineCost.java
UTF-8
2,193
2.28125
2
[]
no_license
package com.pass.model.domain; import java.util.Date; import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; @Entity @Table(name="engine_cost" ,catalog="mysql" ) public class EngineCost implements java.io.Serializable { private EngineCostId id; private Float costValue; private Date lastUpdate; private String comment; public EngineCost() { } public EngineCost(EngineCostId id, Date lastUpdate) { this.id = id; this.lastUpdate = lastUpdate; } public EngineCost(EngineCostId id, Float costValue, Date lastUpdate, String comment) { this.id = id; this.costValue = costValue; this.lastUpdate = lastUpdate; this.comment = comment; } @EmbeddedId @AttributeOverrides( { @AttributeOverride(name="costName", column=@Column(name="cost_name", nullable=false, length=64) ), @AttributeOverride(name="engineName", column=@Column(name="engine_name", nullable=false, length=64) ), @AttributeOverride(name="deviceType", column=@Column(name="device_type", nullable=false) ) } ) public EngineCostId getId() { return this.id; } public void setId(EngineCostId id) { this.id = id; } @Column(name="cost_value", precision=12, scale=0) public Float getCostValue() { return this.costValue; } public void setCostValue(Float costValue) { this.costValue = costValue; } @Temporal(TemporalType.TIMESTAMP) @Column(name="last_update", nullable=false, length=19) public Date getLastUpdate() { return this.lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } @Column(name="comment", length=1024) public String getComment() { return this.comment; } public void setComment(String comment) { this.comment = comment; } }
true
59fac3c7d936efda8ee2c58213ef5cff707cd9d9
Java
Varno/CadastrePortal
/src/main/java/bs/cadastre/dashboard/DashboardUIProvider.java
UTF-8
326
1.898438
2
[]
no_license
package bs.cadastre.dashboard; import com.vaadin.server.UIClassSelectionEvent; import com.vaadin.server.UIProvider; import com.vaadin.ui.UI; public class DashboardUIProvider extends UIProvider { @Override public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { return DashboardUI.class; } }
true
4290623c3a65088100163a913b01a5c5e08a1ccd
Java
GEM-training/support-server
/src/main/java/com/gem/support/service/dto/CompanyFeedbackDTO.java
UTF-8
1,068
2.15625
2
[]
no_license
package com.gem.support.service.dto; /** * Created by VanHop on 3/8/2016. */ public class CompanyFeedbackDTO { private String uuid; private String companyName; private long numOfTicket; public CompanyFeedbackDTO() { } public CompanyFeedbackDTO(String companyName, long numOfTicket) { this.companyName = companyName; this.numOfTicket = numOfTicket; } public CompanyFeedbackDTO(String uuid, String companyName, long numOfTicket) { this.uuid = uuid; this.companyName = companyName; this.numOfTicket = numOfTicket; } public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } public String getCompanyName() { return companyName; } public void setCompanyName(String companyName) { this.companyName = companyName; } public long getNumOfTicket() { return numOfTicket; } public void setNumOfTicket(long numOfTicket) { this.numOfTicket = numOfTicket; } }
true
f7f414fa7972008f087351a153a0d487a0e80122
Java
Enitsed/Java-Spring-Web-Server
/src/main/java/kr/co/crewmate/core/util/NumberUtil.java
UTF-8
1,188
3.5625
4
[]
no_license
package kr.co.crewmate.core.util; /** * 문자열 관련 유틸 모음 * @author crewmate * */ public class NumberUtil { /** * 해당 값들이 모두 0인지를 체크함. * - 0인 항목의 index값을 반환함. * - 모두 0이 아닌경우 -1값을 리턴시킴. * @param val : 체크할 값들... * @return */ public static int isZero(int ... val){ for(int i=0 ; i < val.length ; i++){ if(val[i] == 0){ return i; } } return -1; } /** * 해당 값들이 모두 숫자인지 체크 * @param val * @return */ public static boolean isNumeric(String ... val){ for(int i=0; i < val.length ; i++) { if(!val[i].matches("[0-9]+")) { return false;} } return true; } /** * 해당값들이 모두 0이거나 작은지 검증함. * @param val * @return */ public static int isZeroMinus(int ... val) { for(int i=0 ; i < val.length ; i++){ if(val[i] <= 0){ return i; } } return -1; } /** * 해당값들이 모두 0보다 작은지 검증함. * @param val * @return */ public static int isMinus(int ... val) { for(int i=0 ; i < val.length ; i++){ if(val[i] < 0){ return i; } } return -1; } }
true
2158a645c1b8400982f5bfb93d9f34577755a9a4
Java
manuelsaravia/SiscolWeb
/src/java/negocio/Negocio.java
UTF-8
804
2.109375
2
[]
no_license
/* * 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 negocio; import controller.Controlador; import dto.Persona; import util.ServicioEmail; /** * * @author msaravia */ public class Negocio { public Negocio(){} public String leerDatosPersona(Persona p){ Controlador c=new Controlador(); return c.insertar(p); } public void enviar(){ ServicioEmail se = new ServicioEmail("manuel@institutoreinounido.edu.co", "Jasonsaravia94"); //ServicioEmail se = new ServicioEmail("manuel.saravia.bulla@gmail.com", "jasonsaraviab"); se.enviarEmail("natalia.andrea.tovar@gmail.com", "hola", "hola"); se.enviarEmail("manuel.saravia.bulla@gmail.com", "hola", "hola"); } }
true
3ec894db98a86168cf4b59fa87599def188ebc81
Java
franslundberg/binson-java
/src-test/org/binson/BytesTest.java
UTF-8
1,201
2.796875
3
[ "MIT" ]
permissive
package org.binson; import static org.junit.Assert.*; import java.util.Arrays; import org.junit.Test; /** * Tests storing a bytes (byte[]) in a Binson object. * * @author Frans Lundberg */ public class BytesTest { private Binson obj = new Binson().put("a", new byte[1]); @Test public void testGet() { byte[] bytes = obj.getBytes("a"); assertTrue(Arrays.equals(new byte[1], bytes)); } @Test public void testHas() { assertTrue(obj.hasBytes("a")); assertFalse(obj.hasString("a")); assertFalse(obj.hasBytes("aaa")); } @Test(expected=BinsonFormatException.class) public void testGetNonExistant() { obj.getBytes("b"); } @Test public void test128() { byte[] arr1 = new byte[128]; arr1[5] = 123; Binson b = new Binson().put("bytes", arr1); byte[] serialized = b.toBytes(); byte[] arr2 = Binson.fromBytes(serialized).getBytes("bytes"); assertArrayEquals(arr1, arr2); } @Test(expected=IllegalArgumentException.class) public void testPutNull() { byte[] value = null; new Binson().put("bytes", (byte[]) value); } }
true
e1e02fcde6cb3250862b6ba99e092c5b27a5fe07
Java
xl9605/ICT-TianYan_AndroidCDS
/OtherTools/HistoryBackup/two/20180812_LpmsBs/app/src/main/java/ict/ac/humanmotion/uapplication/lpmsbs/model/User.java
UTF-8
1,309
2.390625
2
[]
no_license
package ict.ac.humanmotion.uapplication.lpmsbs.model; /** * Created by Administrator on 2018/8/12 0012. */ public class User { private String Adress; private Integer ID; private String Password; private String Phone; private String Realname; private Integer Type; private String Username; public String getAdress() { return Adress; } public void setAdress(String adress) { Adress = adress; } public Integer getID() { return ID; } public void setID(Integer ID) { this.ID = ID; } public String getPassword() { return Password; } public void setPassword(String password) { Password = password; } public String getPhone() { return Phone; } public void setPhone(String phone) { Phone = phone; } public String getRealname() { return Realname; } public void setRealname(String realname) { Realname = realname; } public Integer getType() { return Type; } public void setType(Integer type) { Type = type; } public String getUsername() { return Username; } public void setUsername(String username) { Username = username; } }
true
ec1eb8af57c2064d3c51ffdba1185a3150b3da64
Java
ljolliet/MixBay
/src/MixBay/app/src/main/java/fr/pdp/mixbay/presentation/SettingsActivity.java
UTF-8
6,067
2.15625
2
[]
no_license
/** * Application MixBay * * @authors E. Bah, N. Deguillaume, L. Jolliet, J. Loison, P. Vigneau * @version 1.0 * Génération de playlistes musicales pour un groupe d'utilisateurs * PdP 2019-2020 Université de Bordeaux */ package fr.pdp.mixbay.presentation; import java.util.Objects; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListView; import android.widget.PopupMenu; import android.widget.TextView; import android.widget.Toolbar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import fr.pdp.mixbay.R; import fr.pdp.mixbay.business.algorithms.Fairness; import fr.pdp.mixbay.business.algorithms.LeastMisery; import fr.pdp.mixbay.business.algorithms.MostPleasure; import fr.pdp.mixbay.business.algorithms.RandomAlgo; import fr.pdp.mixbay.business.models.AlgoI; import fr.pdp.mixbay.business.models.User; import fr.pdp.mixbay.business.services.Services; import fr.pdp.mixbay.business.utils.UserSettingsAdapter; public class SettingsActivity extends AppCompatActivity { private final int MUTE_POSITION = 0; private final int DELETE_POSITION = 1; private ListView userListView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = findViewById(R.id.settingsToolbar); userListView = findViewById(R.id.userListView); setActionBar(toolbar); Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayShowHomeEnabled(true); // Set onClick event on toolbar toolbar.setNavigationOnClickListener(view -> finish()); // Add Users to ListView this.loadUserList(); // Detect onClick on User userListView.setOnItemClickListener(this::onClickUser); // Init algorithm View initAlgorithmDisplay(); } private void initAlgorithmDisplay() { TextView algorithmTextView = findViewById(R.id.chosenAlgorithmTextView); algorithmTextView.setText(Services.getAlgorithmName(this)); } private void loadUserList() { UserSettingsAdapter adapter = new UserSettingsAdapter(this, Services.getUsers()); userListView.setAdapter(adapter); } private void onClickUser(AdapterView<?> adapterView, View view, int i, long l) { ImageView moreImageView = view.findViewById(R.id.userSettingsMore); PopupMenu popup = new PopupMenu(this, moreImageView); popup.getMenuInflater().inflate(R.menu.popup_user_settings_menu, popup.getMenu()); // Get User User user = (User) adapterView.getItemAtPosition(i); // Change title of menu if (user.isMute()) popup.getMenu().getItem(MUTE_POSITION).setTitle(R.string.unmute); if (Services.isCurrentUser(user)) popup.getMenu().getItem(DELETE_POSITION).setVisible(false); // Detect popup click event popup.setOnMenuItemClickListener(item -> { switch (item.getItemId()) { case R.id.mute: toggleMuteUser(user, view); break; case R.id.delete: removeUser(user); break; default: Log.d("SettingsActivity", "Default: " + item.getItemId()); break; } return true; }); popup.show(); } private void toggleMuteUser(User user, View view) { TextView displayName = view.findViewById(R.id.userDisplayName); if (user.isMute()) { user.unmute(); displayName.setTextColor(getResources().getColor(R.color.white, getTheme())); } else { user.mute(); displayName.setTextColor(getResources() .getColor(R.color.colorDisabled, getTheme())); } } private void removeUser(User user) { // Create a confirm popup AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogStyle); builder.setTitle(getString(R.string.remove_user_alert_title, user.username)); builder.setMessage(R.string.remove_user_message); // OK button builder.setPositiveButton(R.string.OK, (dialog, which) -> { // If OK, remove the user Services.removeUser(user); // Reload userList loadUserList(); }); // Cancel button builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.cancel()); builder.show(); } public void onClickDisconnect(View view){ Services.disconnectSession(); Intent i = new Intent(this, LoginActivity.class); startActivity(i); onStop(); } public void onClickSelectAlgorithm(View view) { AlertDialog.Builder builder = new AlertDialog .Builder(this, R.style.AlertDialogStyle); builder.setTitle(R.string.choose_algo_alert_title); builder.setItems(R.array.algorithms, (dialogInterface, i) -> { AlgoI algorithm; switch (i) { case 1: algorithm = new Fairness(); break; case 2: algorithm = new MostPleasure(); break; case 3: algorithm = new RandomAlgo(); break; default: algorithm = new LeastMisery(); break; } Services.setAlgorithm(algorithm); // Update View initAlgorithmDisplay(); }); builder.show(); } }
true
bd7185f8c21d03567caab2c0c22adb11f38ed42f
Java
moraispgsi/3linha
/Milestone2/Entrega/Milestone2/src/pt/ips/pa/fase1/tads/implementations/ConjuntoAleatorioEstatico.java
UTF-8
1,040
3.203125
3
[ "MIT" ]
permissive
/* * 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 pt.ips.pa.fase1.tads.implementations; import pt.ips.pa.fase1.tads.interfaces.ConjuntoAleatorio; import java.util.Random; /** * Implementação estática do @link ConjuntoAleatorio * * @see ConjuntoAleatorio * @author Ricardo José Horta Morais * * @param <E> tipo de elementos */ public class ConjuntoAleatorioEstatico<E> implements ConjuntoAleatorio<E> { private final E[] elementos; private static final Random aleatorio = new Random(); /** * Constroi um conjunto aleatório com todos os elementos recebidos * * @param elementos elementos que serão guardados como possibilidades */ public ConjuntoAleatorioEstatico(E... elementos) { this.elementos = elementos; } @Override public E peek() { int indice = aleatorio.nextInt(elementos.length); return elementos[indice]; } }
true
42957080bd2ebc8d2889ba50e91c1291f05750e3
Java
pablocastillo123/Proyecto-1-OOP-Consola-
/src/com/pdcg/consolaexplorador/Unix.java
UTF-8
2,891
3.15625
3
[]
no_license
package com.pdcg.consolaexplorador; import java.io.File; import java.util.Scanner; public class Unix { private String opc,texto; private String iruta,ruta1,p,delruta,mkdruta; private boolean win = true; Scanner entrada = new Scanner(System.in); ManejadorDirectorio md = new ManejadorDirectorio(); String c ="C:\\Users\\pablo\\desktop\\prueba"; String cw = "C:\\Windows"; Windows wm = new Windows(); public void umenu() { File vaio = new File(""); ruta1=vaio.getAbsolutePath(); while(win){ p=""; for(int i=0;i<ruta1.length();i++) { char b[]; b = new char[ruta1.length()]; if(ruta1.charAt(i)=='\\') { b[i]='/'; } else { b[i]=ruta1.charAt(i); } p=p+b[i]; } File ruta2 = new File(ruta1); p=p.toUpperCase().replaceAll("C:/users".toUpperCase(), "~"); System.out.print("\n"+p+" $"); opc = entrada.next(); if(opc.equalsIgnoreCase("cd")) { ruta1=wm.desDirectorio(ruta1,ruta2,entrada.next()); } else if(opc.equalsIgnoreCase("prub")) {ruta1=c;} else if(opc.equalsIgnoreCase("mkdir")) { iruta = entrada.next(); if(ruta1.equalsIgnoreCase(cw)) { System.out.println("No puede Acceder a esta ruta");} else { mkdruta=ruta1+"\\"+iruta; md.crearDirectorio(mkdruta,iruta,ruta1); System.out.print("\n"); } } else if(opc.equalsIgnoreCase("is")) { md.leerDirectorioRuta(ruta1); System.out.print("\n"); } else if(opc.equalsIgnoreCase("echo")) { iruta = entrada.next(); if(ruta1.equalsIgnoreCase(cw)) { System.out.println("No puede Acceder a esta ruta");} else { texto = entrada.nextLine(); md.echo(iruta,texto,ruta1); System.out.print("\n"); } } else if(opc.equalsIgnoreCase("rm")) { iruta=entrada.next(); if(ruta1.equalsIgnoreCase(cw)) { System.out.println("No puede Acceder a esta ruta");} else { delruta=ruta1+"\\"+iruta; md.deleteArchivo(delruta); System.out.print("\n"); } } else if(opc.equalsIgnoreCase("exit")) { win=false; } else if (opc.equalsIgnoreCase("cp")) { if(ruta1.equalsIgnoreCase(cw)) { System.out.println("No puede Acceder a esta ruta");} else { String oruta = entrada.next(); String druta = entrada.next(); md.copiarDir(oruta,druta,ruta1); System.out.print("\n"); } } else if(opc.equalsIgnoreCase("mv")) { if(ruta1.equalsIgnoreCase(cw)) { System.out.println("No puede Acceder a esta ruta");} else { String oruta = entrada.next(); String druta = entrada.next(); md.moverArchivo(oruta,druta,ruta1); System.out.print("\n"); } } else System.out.println("("+opc+") No se reconoce como comando interno o externo \n"); } } }
true
4b7d8c826049c107b746d49ba240343261474dc5
Java
romero-tsi-2008/projeto-webservice-2011-1
/ProjetoEjbServerWS/ejbModule/interfacesRemotas/IdiomaRemote.java
UTF-8
244
1.710938
2
[]
no_license
package interfacesRemotas; import java.util.List; import javax.ejb.Remote; import entityBeans.Idioma; @Remote public interface IdiomaRemote { public boolean cadastrar(Idioma idioma); public List<Idioma> autocompletar(Object sugestao); }
true
f55cb6b1a5ea4f27f29ae861ca62c3278f50a898
Java
shunkakinoki/Insight
/backend/shared/rest-api/src/main/java/com/rebrowse/shared/rest/mappers/ApiExceptionMapper.java
UTF-8
657
2.078125
2
[]
no_license
package com.rebrowse.shared.rest.mappers; import com.rebrowse.api.RebrowseApiError; import com.rebrowse.exception.ApiException; import com.rebrowse.shared.rest.response.Boom; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; @Provider public class ApiExceptionMapper implements ExceptionMapper<ApiException> { @Override public Response toResponse(ApiException apiException) { RebrowseApiError<?> apiError = apiException.getApiError(); return Boom.status(apiError.getStatusCode()) .message(apiError.getMessage()) .errors(apiError.getErrors()) .response(); } }
true
1bf1a27fffdb8465315045f2b17fa2778b73a7c8
Java
hanhanhanxu/homefurn
/src/main/java/hx/insist/service/CommentServiceImpl.java
UTF-8
844
2.140625
2
[]
no_license
package hx.insist.service; import hx.insist.mapper.CommentMapper; import hx.insist.pojo.Comment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.UUID; @Service public class CommentServiceImpl implements CommentService { @Autowired private CommentMapper commentMapper; @Override public void addComment(Comment comment) { comment.setCid(UUID.randomUUID().toString());//设置ID comment.setCtime(new Date());//补充时间 commentMapper.insert(comment); } @Override public List findAllByFid(String fid) { List<Comment> list = commentMapper.selectByFid(fid); if(list.isEmpty()) return null; else return list; } }
true
f867d46d58e4b2dfa1f8153a650d42d5bdaf2eb9
Java
HodAlpert/LocalApplication
/src/main/java/com/Local_aplication/Run.java
UTF-8
4,178
2.53125
3
[]
no_license
package com.Local_aplication; import com.Local_aplication.common.common; import com.Local_aplication.common.init; import com.Local_aplication.managers.EC2Manager; import com.Local_aplication.managers.HTMLManager; import com.Local_aplication.managers.S3Manager; import com.Local_aplication.managers.SQSManager; import com.amazonaws.services.sqs.model.Message; import java.util.UUID; import java.util.logging.Logger; public class Run { private EC2Manager ec2 = new EC2Manager(); private S3Manager s3 = new S3Manager(); private SQSManager sqs = new SQSManager(); private boolean should_terminate = false; private String input_file; private String output_file; private int number_of_instances_per_lines = 10; private String client_id = String.valueOf(UUID.randomUUID()); private Logger logger = init.logger; Run() { init.main(); } public void main(String[] args) { initialize_arguments(args); logger.info(String.format("uploading file: %s", input_file)); String key = s3.upload_object(input_file); logger.info("sending message to manager"); sqs.send_message(common.manager_queue_url, common.generate_new_task_message(client_id, key, number_of_instances_per_lines), client_id, common.manager_main_thread_consumer); logger.info("waiting for manager to finish"); Message message = wait_for_message_from_manager(); logger.info("got response from manager"); handle_message_from_manager(message); send_termination_message_if_needed(); } /** * checks if 'terminate' command was given, if it was- send terminate sqs message to manager */ private void send_termination_message_if_needed() { if (should_terminate) { logger.info("sending termination message"); sqs.send_message(common.manager_queue_url, String.format("%s\t%s", common.terminate_task, client_id) , client_id, common.manager_main_thread_consumer); } } /** * download the file in message body from s3 and deletes the message * * @param message to handle */ private void handle_message_from_manager(Message message) { String S3_key = message.getBody().split("\t")[2]; logger.info("downloading file from s3"); s3.download_file_as_text(S3_key, S3_key); logger.info("downloaded output.txt from manager"); sqs.delete_message(common.clients_queue_url, message); new HTMLManager(S3_key, output_file).build_html_file(); } /** * @return Message returned from manager if type and client id are matching */ private Message wait_for_message_from_manager() { Message message = null; while (message == null) { message = sqs.recieve_message(common.clients_queue_url, client_id, common.client_consumer); if (message != null) { String[] parsed_body = message.getBody().split("\t"); String type = parsed_body[0]; String tmp_client_id = parsed_body[1]; if (!type.equals(common.done_task) || !client_id.equals(tmp_client_id)) message = null; } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } return message; } /** * parses and store input_file, number_of_instances_per_lines and terminate * * @param args list of command line arguments */ private void initialize_arguments(String[] args) { power_up_manager_if_needed(); input_file = args[0]; output_file = args[1]; number_of_instances_per_lines = Integer.parseInt(args[2]); if (args.length == 4 && args[3].equals("terminate")) should_terminate = true; } /** * if manager is not in state running- start the manager. */ private void power_up_manager_if_needed() { if (!ec2.is_manager_up()) { ec2.power_up_manager(); } } }
true
b53fb228dfb60490c343b98320492c560e9af339
Java
summerlove66/web-projects
/springboot-jwt-demo/src/main/java/com/park/controller/HelloController.java
UTF-8
413
2.03125
2
[]
no_license
package com.park.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @RequestMapping("/hi") private String sayHi() { return "Hi SpringBoot"; } @RequestMapping(value = "/{.*}") private String sayHello() { return "Hello SpringBoot"; } }
true
a74de628fd03cb8c3ec10dcee16cb649609d4864
Java
Wuerike/java-devdojo
/src/br/ind/lhf/javacore/G_associacao/classes/Pessoa.java
UTF-8
146
1.515625
2
[]
no_license
package br.ind.lhf.javacore.G_associacao.classes; public class Pessoa { private Depertamento depertamento; private Endereco endereco; }
true
08e742006e463561374bb5814514fad08315cf35
Java
sindhubaskar/canvasprojects.github.io
/DVDLibrary/src/main/java/DVD/ui/UserIOImpl.java
UTF-8
5,299
3.203125
3
[]
no_license
/* * 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 DVD.ui; import java.util.Scanner; /** * * @author sindhu */ public class UserIOImpl implements UserIO{ Scanner reader = new Scanner( System.in ); @Override public void print(String message) { System.out.println(message); } @Override public double readDouble(String prompt) { double toReturn = Double.NaN; System.out.println( prompt ); boolean validInput = false; while( !validInput ) { try { String toCheck = reader.nextLine(); toReturn = Double.parseDouble( toCheck ); validInput = true; } catch(NumberFormatException e) { System.out.println("Please enter a valid number."); } } return toReturn; } @Override public double readDouble(String prompt, double min, double max) { double toReturn = Double.NaN; boolean isValid = false; while( !isValid ) { toReturn = readDouble( prompt ); if( toReturn < min || toReturn > max) { System.out.println( "Please enter a number between " + min + " and " + max + "."); } else { isValid = true; } } return toReturn; } @Override public float readFloat(String prompt) { float toReturn=Float.NaN; System.out.println(prompt); boolean validInput=false; while(!validInput) { try { String toCheck=reader.nextLine(); toReturn=Float.parseFloat(toCheck); validInput=true; } catch(NumberFormatException e) { System.out.println("Please enter a valid number."); } } return toReturn; } @Override public float readFloat(String prompt, float min, float max) { float toReturn=Float.NaN; boolean isValid=false; while(!isValid) { toReturn=readFloat(prompt); if(toReturn<min||toReturn>max) { System.out.println("Please enter a number between "+min+ " and "+max+" . "); } else { isValid=true; } } return toReturn; } @Override public int readInt(String prompt) { int toReturn=Integer.MIN_VALUE; System.out.println(prompt); boolean isValid=false; while(!isValid) { try { String toCheck=reader.nextLine(); toReturn=Integer.parseInt(toCheck); isValid=true; } catch(NumberFormatException e) { System.out.println("please enter a valid number"); } } return toReturn; } @Override public int readInt(String prompt, int min, int max) { int toReturn=Integer.MIN_VALUE; boolean isValid=false; while(!isValid) { toReturn=readInt(prompt); if(toReturn<min||toReturn>max) { System.out.println("please enter a number between "+min+ " and "+max+" . "); } else { isValid=true; } } return toReturn; } @Override public long readLong(String prompt) { long toReturn=Long.MIN_VALUE; System.out.println(prompt); boolean isValid=false; while(!isValid) { try { String toCheck=reader.nextLine(); toReturn=Long.parseLong(prompt); isValid=true; } catch(NumberFormatException e) { System.out.println("please enter a valid number"); } } return toReturn; } @Override public long readLong(String prompt, long min, long max) { Long toReturn=Long.MIN_VALUE; boolean isValid=false; while(!isValid) { toReturn=readLong(prompt); if(toReturn<min||toReturn>max) { System.out.println("please enter a number between "+min+ " and "+max+" . "); }else { isValid=true; } } return toReturn; } @Override public String readString(String prompt) { System.out.println(prompt); String toReturn=reader.nextLine(); return toReturn; } }
true
a704fa0b8f6139bbe758c9fbb943c530d0efdfa8
Java
Moonvid/SpringProject_SNS
/SpringProject_SNS_Friends/src/main/java/com/team/springsns/dao/FriendsDaoInterface.java
UTF-8
523
1.984375
2
[]
no_license
package com.team.springsns.dao; import java.util.List; import com.team.springsns.model.FriendRequestInfo; import com.team.springsns.model.MemberInfo; public interface FriendsDaoInterface { // 친구 목록 가져오는 메서드 public List getFriendsList(); // 친구 페이지를 보여주는 메서드 public MemberInfo getFriendPage(int userNo); // 친구 요청 시 친구 요청 리스트에 추가(등록)하는 메서드 public int setFriendRequest(FriendRequestInfo requestInfo); }
true
4fa5db31ebc56fabd34089615c0e0b0f0835e98e
Java
foodcart/coursework1
/Project/foodCart/core/Item_JUnit.java
UTF-8
563
2.875
3
[ "MIT" ]
permissive
package core; import java.util.HashMap; import java.util.Map; import static org.junit.Assert.*; import org.junit.Test; class Item_JUnit { Item testItem = new Item("AB25", "Beverage", "Coca-Cola", 2.0); @Test void testGetId() { assertEquals("AB25", testItem.getId()); } @Test void testGetCategory() { assertEquals("Beverage", testItem.getCategory()); } @Test void testGetDescription() { assertEquals("Coca-Cola", testItem.getDescription()); } @Test void testGetCost() { assertEquals(2.0, testItem.getCost()); } }
true
a4f56b6c697a257b9369edbcc3dfc26033ca9b4a
Java
Andreas237/AndroidPolicyAutomation
/ExtractedJars/RT_News_com.rt.mobile.english/javafiles/android/support/v4/widget/FocusStrategy.java
UTF-8
43,373
2.078125
2
[ "MIT" ]
permissive
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) annotate safe package android.support.v4.widget; import android.graphics.Rect; import java.util.*; class FocusStrategy { public static interface BoundsAdapter { public abstract void obtainBounds(Object obj, Rect rect); } public static interface CollectionAdapter { public abstract Object get(Object obj, int i); public abstract int size(Object obj); } private static class SequentialComparator implements Comparator { public int compare(Object obj, Object obj1) { Rect rect = mTemp1; // 0 0:aload_0 // 1 1:getfield #28 <Field Rect mTemp1> // 2 4:astore 6 Rect rect1 = mTemp2; // 3 6:aload_0 // 4 7:getfield #30 <Field Rect mTemp2> // 5 10:astore 7 mAdapter.obtainBounds(obj, rect); // 6 12:aload_0 // 7 13:getfield #34 <Field FocusStrategy$BoundsAdapter mAdapter> // 8 16:aload_1 // 9 17:aload 6 // 10 19:invokeinterface #45 <Method void FocusStrategy$BoundsAdapter.obtainBounds(Object, Rect)> mAdapter.obtainBounds(obj1, rect1); // 11 24:aload_0 // 12 25:getfield #34 <Field FocusStrategy$BoundsAdapter mAdapter> // 13 28:aload_2 // 14 29:aload 7 // 15 31:invokeinterface #45 <Method void FocusStrategy$BoundsAdapter.obtainBounds(Object, Rect)> int i = rect.top; // 16 36:aload 6 // 17 38:getfield #49 <Field int Rect.top> // 18 41:istore 4 int j = rect1.top; // 19 43:aload 7 // 20 45:getfield #49 <Field int Rect.top> // 21 48:istore 5 byte byte0 = -1; // 22 50:iconst_m1 // 23 51:istore_3 if(i < j) //* 24 52:iload 4 //* 25 54:iload 5 //* 26 56:icmpge 61 return -1; // 27 59:iconst_m1 // 28 60:ireturn if(rect.top > rect1.top) //* 29 61:aload 6 //* 30 63:getfield #49 <Field int Rect.top> //* 31 66:aload 7 //* 32 68:getfield #49 <Field int Rect.top> //* 33 71:icmple 76 return 1; // 34 74:iconst_1 // 35 75:ireturn if(rect.left < rect1.left) //* 36 76:aload 6 //* 37 78:getfield #52 <Field int Rect.left> //* 38 81:aload 7 //* 39 83:getfield #52 <Field int Rect.left> //* 40 86:icmpge 100 { if(mIsLayoutRtl) //* 41 89:aload_0 //* 42 90:getfield #32 <Field boolean mIsLayoutRtl> //* 43 93:ifeq 98 byte0 = 1; // 44 96:iconst_1 // 45 97:istore_3 return ((int) (byte0)); // 46 98:iload_3 // 47 99:ireturn } if(rect.left > rect1.left) //* 48 100:aload 6 //* 49 102:getfield #52 <Field int Rect.left> //* 50 105:aload 7 //* 51 107:getfield #52 <Field int Rect.left> //* 52 110:icmple 124 return !mIsLayoutRtl ? 1 : -1; // 53 113:aload_0 // 54 114:getfield #32 <Field boolean mIsLayoutRtl> // 55 117:ifeq 122 // 56 120:iconst_m1 // 57 121:ireturn // 58 122:iconst_1 // 59 123:ireturn if(rect.bottom < rect1.bottom) //* 60 124:aload 6 //* 61 126:getfield #55 <Field int Rect.bottom> //* 62 129:aload 7 //* 63 131:getfield #55 <Field int Rect.bottom> //* 64 134:icmpge 139 return -1; // 65 137:iconst_m1 // 66 138:ireturn if(rect.bottom > rect1.bottom) //* 67 139:aload 6 //* 68 141:getfield #55 <Field int Rect.bottom> //* 69 144:aload 7 //* 70 146:getfield #55 <Field int Rect.bottom> //* 71 149:icmple 154 return 1; // 72 152:iconst_1 // 73 153:ireturn if(rect.right < rect1.right) //* 74 154:aload 6 //* 75 156:getfield #58 <Field int Rect.right> //* 76 159:aload 7 //* 77 161:getfield #58 <Field int Rect.right> //* 78 164:icmpge 178 { if(mIsLayoutRtl) //* 79 167:aload_0 //* 80 168:getfield #32 <Field boolean mIsLayoutRtl> //* 81 171:ifeq 176 byte0 = 1; // 82 174:iconst_1 // 83 175:istore_3 return ((int) (byte0)); // 84 176:iload_3 // 85 177:ireturn } if(rect.right > rect1.right) //* 86 178:aload 6 //* 87 180:getfield #58 <Field int Rect.right> //* 88 183:aload 7 //* 89 185:getfield #58 <Field int Rect.right> //* 90 188:icmple 202 return !mIsLayoutRtl ? 1 : -1; // 91 191:aload_0 // 92 192:getfield #32 <Field boolean mIsLayoutRtl> // 93 195:ifeq 200 // 94 198:iconst_m1 // 95 199:ireturn // 96 200:iconst_1 // 97 201:ireturn else return 0; // 98 202:iconst_0 // 99 203:ireturn } private final BoundsAdapter mAdapter; private final boolean mIsLayoutRtl; private final Rect mTemp1 = new Rect(); private final Rect mTemp2 = new Rect(); SequentialComparator(boolean flag, BoundsAdapter boundsadapter) { // 0 0:aload_0 // 1 1:invokespecial #23 <Method void Object()> // 2 4:aload_0 // 3 5:new #25 <Class Rect> // 4 8:dup // 5 9:invokespecial #26 <Method void Rect()> // 6 12:putfield #28 <Field Rect mTemp1> // 7 15:aload_0 // 8 16:new #25 <Class Rect> // 9 19:dup // 10 20:invokespecial #26 <Method void Rect()> // 11 23:putfield #30 <Field Rect mTemp2> mIsLayoutRtl = flag; // 12 26:aload_0 // 13 27:iload_1 // 14 28:putfield #32 <Field boolean mIsLayoutRtl> mAdapter = boundsadapter; // 15 31:aload_0 // 16 32:aload_2 // 17 33:putfield #34 <Field FocusStrategy$BoundsAdapter mAdapter> // 18 36:return } } FocusStrategy() { // 0 0:aload_0 // 1 1:invokespecial #17 <Method void Object()> // 2 4:return } private static boolean beamBeats(int i, Rect rect, Rect rect1, Rect rect2) { boolean flag = beamsOverlap(i, rect, rect1); // 0 0:iload_0 // 1 1:aload_1 // 2 2:aload_2 // 3 3:invokestatic #25 <Method boolean beamsOverlap(int, Rect, Rect)> // 4 6:istore 4 if(!beamsOverlap(i, rect, rect2)) //* 5 8:iload_0 //* 6 9:aload_1 //* 7 10:aload_3 //* 8 11:invokestatic #25 <Method boolean beamsOverlap(int, Rect, Rect)> //* 9 14:ifne 70 { if(!flag) //* 10 17:iload 4 //* 11 19:ifne 24 return false; // 12 22:iconst_0 // 13 23:ireturn if(!isToDirectionOf(i, rect, rect2)) //* 14 24:iload_0 //* 15 25:aload_1 //* 16 26:aload_3 //* 17 27:invokestatic #28 <Method boolean isToDirectionOf(int, Rect, Rect)> //* 18 30:ifne 35 return true; // 19 33:iconst_1 // 20 34:ireturn if(i != 17) //* 21 35:iload_0 //* 22 36:bipush 17 //* 23 38:icmpeq 68 { if(i == 66) //* 24 41:iload_0 //* 25 42:bipush 66 //* 26 44:icmpne 49 return true; // 27 47:iconst_1 // 28 48:ireturn return majorAxisDistance(i, rect, rect1) < majorAxisDistanceToFarEdge(i, rect, rect2); // 29 49:iload_0 // 30 50:aload_1 // 31 51:aload_2 // 32 52:invokestatic #32 <Method int majorAxisDistance(int, Rect, Rect)> // 33 55:iload_0 // 34 56:aload_1 // 35 57:aload_3 // 36 58:invokestatic #35 <Method int majorAxisDistanceToFarEdge(int, Rect, Rect)> // 37 61:icmpge 66 // 38 64:iconst_1 // 39 65:ireturn // 40 66:iconst_0 // 41 67:ireturn } else { return true; // 42 68:iconst_1 // 43 69:ireturn } } else { return false; // 44 70:iconst_0 // 45 71:ireturn } } private static boolean beamsOverlap(int i, Rect rect, Rect rect1) { boolean flag3; label0: { flag3 = false; // 0 0:iconst_0 // 1 1:istore 5 boolean flag2 = false; // 2 3:iconst_0 // 3 4:istore 4 if(i == 17) break label0; // 4 6:iload_0 // 5 7:bipush 17 // 6 9:icmpeq 73 if(i != 33) //* 7 12:iload_0 //* 8 13:bipush 33 //* 9 15:icmpeq 41 { if(i == 66) break label0; // 10 18:iload_0 // 11 19:bipush 66 // 12 21:icmpeq 73 if(i != 130) //* 13 24:iload_0 //* 14 25:sipush 130 //* 15 28:icmpeq 41 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 16 31:new #38 <Class IllegalArgumentException> // 17 34:dup // 18 35:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 19 37:invokespecial #43 <Method void IllegalArgumentException(String)> // 20 40:athrow } boolean flag = flag2; // 21 41:iload 4 // 22 43:istore_3 if(rect1.right >= rect.left) //* 23 44:aload_2 //* 24 45:getfield #49 <Field int Rect.right> //* 25 48:aload_1 //* 26 49:getfield #52 <Field int Rect.left> //* 27 52:icmplt 71 { flag = flag2; // 28 55:iload 4 // 29 57:istore_3 if(rect1.left <= rect.right) //* 30 58:aload_2 //* 31 59:getfield #52 <Field int Rect.left> //* 32 62:aload_1 //* 33 63:getfield #49 <Field int Rect.right> //* 34 66:icmpgt 71 flag = true; // 35 69:iconst_1 // 36 70:istore_3 } return flag; // 37 71:iload_3 // 38 72:ireturn } boolean flag1 = flag3; // 39 73:iload 5 // 40 75:istore_3 if(rect1.bottom >= rect.top) //* 41 76:aload_2 //* 42 77:getfield #55 <Field int Rect.bottom> //* 43 80:aload_1 //* 44 81:getfield #58 <Field int Rect.top> //* 45 84:icmplt 103 { flag1 = flag3; // 46 87:iload 5 // 47 89:istore_3 if(rect1.top <= rect.bottom) //* 48 90:aload_2 //* 49 91:getfield #58 <Field int Rect.top> //* 50 94:aload_1 //* 51 95:getfield #55 <Field int Rect.bottom> //* 52 98:icmpgt 103 flag1 = true; // 53 101:iconst_1 // 54 102:istore_3 } return flag1; // 55 103:iload_3 // 56 104:ireturn } public static Object findNextFocusInAbsoluteDirection(Object obj, CollectionAdapter collectionadapter, BoundsAdapter boundsadapter, Object obj1, Rect rect, int i) { Rect rect1 = new Rect(rect); // 0 0:new #45 <Class Rect> // 1 3:dup // 2 4:aload 4 // 3 6:invokespecial #64 <Method void Rect(Rect)> // 4 9:astore 10 int j = 0; // 5 11:iconst_0 // 6 12:istore 6 if(i != 17) //* 7 14:iload 5 //* 8 16:bipush 17 //* 9 18:icmpeq 103 { if(i != 33) //* 10 21:iload 5 //* 11 23:bipush 33 //* 12 25:icmpeq 87 { if(i != 66) //* 13 28:iload 5 //* 14 30:bipush 66 //* 15 32:icmpeq 70 { if(i != 130) //* 16 35:iload 5 //* 17 37:sipush 130 //* 18 40:icmpeq 53 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 19 43:new #38 <Class IllegalArgumentException> // 20 46:dup // 21 47:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 22 49:invokespecial #43 <Method void IllegalArgumentException(String)> // 23 52:athrow rect1.offset(0, -(rect.height() + 1)); // 24 53:aload 10 // 25 55:iconst_0 // 26 56:aload 4 // 27 58:invokevirtual #68 <Method int Rect.height()> // 28 61:iconst_1 // 29 62:iadd // 30 63:ineg // 31 64:invokevirtual #72 <Method void Rect.offset(int, int)> } else //* 32 67:goto 116 { rect1.offset(-(rect.width() + 1), 0); // 33 70:aload 10 // 34 72:aload 4 // 35 74:invokevirtual #75 <Method int Rect.width()> // 36 77:iconst_1 // 37 78:iadd // 38 79:ineg // 39 80:iconst_0 // 40 81:invokevirtual #72 <Method void Rect.offset(int, int)> } } else //* 41 84:goto 116 { rect1.offset(0, rect.height() + 1); // 42 87:aload 10 // 43 89:iconst_0 // 44 90:aload 4 // 45 92:invokevirtual #68 <Method int Rect.height()> // 46 95:iconst_1 // 47 96:iadd // 48 97:invokevirtual #72 <Method void Rect.offset(int, int)> } } else //* 49 100:goto 116 { rect1.offset(rect.width() + 1, 0); // 50 103:aload 10 // 51 105:aload 4 // 52 107:invokevirtual #75 <Method int Rect.width()> // 53 110:iconst_1 // 54 111:iadd // 55 112:iconst_0 // 56 113:invokevirtual #72 <Method void Rect.offset(int, int)> } Object obj2 = null; // 57 116:aconst_null // 58 117:astore 8 int k = collectionadapter.size(obj); // 59 119:aload_1 // 60 120:aload_0 // 61 121:invokeinterface #79 <Method int FocusStrategy$CollectionAdapter.size(Object)> // 62 126:istore 7 Rect rect2 = new Rect(); // 63 128:new #45 <Class Rect> // 64 131:dup // 65 132:invokespecial #80 <Method void Rect()> // 66 135:astore 11 for(; j < k; j++) //* 67 137:iload 6 //* 68 139:iload 7 //* 69 141:icmpge 208 { Object obj3 = collectionadapter.get(obj, j); // 70 144:aload_1 // 71 145:aload_0 // 72 146:iload 6 // 73 148:invokeinterface #84 <Method Object FocusStrategy$CollectionAdapter.get(Object, int)> // 74 153:astore 9 if(obj3 == obj1) //* 75 155:aload 9 //* 76 157:aload_3 //* 77 158:if_acmpne 164 continue; // 78 161:goto 199 boundsadapter.obtainBounds(obj3, rect2); // 79 164:aload_2 // 80 165:aload 9 // 81 167:aload 11 // 82 169:invokeinterface #88 <Method void FocusStrategy$BoundsAdapter.obtainBounds(Object, Rect)> if(isBetterCandidate(i, rect, rect2, rect1)) //* 83 174:iload 5 //* 84 176:aload 4 //* 85 178:aload 11 //* 86 180:aload 10 //* 87 182:invokestatic #91 <Method boolean isBetterCandidate(int, Rect, Rect, Rect)> //* 88 185:ifeq 199 { rect1.set(rect2); // 89 188:aload 10 // 90 190:aload 11 // 91 192:invokevirtual #94 <Method void Rect.set(Rect)> obj2 = obj3; // 92 195:aload 9 // 93 197:astore 8 } } // 94 199:iload 6 // 95 201:iconst_1 // 96 202:iadd // 97 203:istore 6 //* 98 205:goto 137 return obj2; // 99 208:aload 8 // 100 210:areturn } public static Object findNextFocusInRelativeDirection(Object obj, CollectionAdapter collectionadapter, BoundsAdapter boundsadapter, Object obj1, int i, boolean flag, boolean flag1) { int k = collectionadapter.size(obj); // 0 0:aload_1 // 1 1:aload_0 // 2 2:invokeinterface #79 <Method int FocusStrategy$CollectionAdapter.size(Object)> // 3 7:istore 8 ArrayList arraylist = new ArrayList(k); // 4 9:new #100 <Class ArrayList> // 5 12:dup // 6 13:iload 8 // 7 15:invokespecial #103 <Method void ArrayList(int)> // 8 18:astore 9 for(int j = 0; j < k; j++) //* 9 20:iconst_0 //* 10 21:istore 7 //* 11 23:iload 7 //* 12 25:iload 8 //* 13 27:icmpge 54 arraylist.add(collectionadapter.get(obj, j)); // 14 30:aload 9 // 15 32:aload_1 // 16 33:aload_0 // 17 34:iload 7 // 18 36:invokeinterface #84 <Method Object FocusStrategy$CollectionAdapter.get(Object, int)> // 19 41:invokevirtual #107 <Method boolean ArrayList.add(Object)> // 20 44:pop // 21 45:iload 7 // 22 47:iconst_1 // 23 48:iadd // 24 49:istore 7 //* 25 51:goto 23 Collections.sort(((java.util.List) (arraylist)), ((Comparator) (new SequentialComparator(flag, boundsadapter)))); // 26 54:aload 9 // 27 56:new #12 <Class FocusStrategy$SequentialComparator> // 28 59:dup // 29 60:iload 5 // 30 62:aload_2 // 31 63:invokespecial #110 <Method void FocusStrategy$SequentialComparator(boolean, FocusStrategy$BoundsAdapter)> // 32 66:invokestatic #116 <Method void Collections.sort(java.util.List, Comparator)> switch(i) //* 33 69:iload 4 { //* 34 71:tableswitch 1 2: default 92 // 1 111 // 2 102 default: throw new IllegalArgumentException("direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD}."); // 35 92:new #38 <Class IllegalArgumentException> // 36 95:dup // 37 96:ldc1 #118 <String "direction must be one of {FOCUS_FORWARD, FOCUS_BACKWARD}."> // 38 98:invokespecial #43 <Method void IllegalArgumentException(String)> // 39 101:athrow case 2: // '\002' return getNextFocusable(obj1, arraylist, flag1); // 40 102:aload_3 // 41 103:aload 9 // 42 105:iload 6 // 43 107:invokestatic #122 <Method Object getNextFocusable(Object, ArrayList, boolean)> // 44 110:areturn case 1: // '\001' return getPreviousFocusable(obj1, arraylist, flag1); // 45 111:aload_3 // 46 112:aload 9 // 47 114:iload 6 // 48 116:invokestatic #125 <Method Object getPreviousFocusable(Object, ArrayList, boolean)> // 49 119:areturn } } private static Object getNextFocusable(Object obj, ArrayList arraylist, boolean flag) { int j = arraylist.size(); // 0 0:aload_1 // 1 1:invokevirtual #128 <Method int ArrayList.size()> // 2 4:istore 4 int i; if(obj == null) //* 3 6:aload_0 //* 4 7:ifnonnull 15 i = -1; // 5 10:iconst_m1 // 6 11:istore_3 else //* 7 12:goto 21 i = arraylist.lastIndexOf(obj); // 8 15:aload_1 // 9 16:aload_0 // 10 17:invokevirtual #131 <Method int ArrayList.lastIndexOf(Object)> // 11 20:istore_3 i++; // 12 21:iload_3 // 13 22:iconst_1 // 14 23:iadd // 15 24:istore_3 if(i < j) //* 16 25:iload_3 //* 17 26:iload 4 //* 18 28:icmpge 37 return arraylist.get(i); // 19 31:aload_1 // 20 32:iload_3 // 21 33:invokevirtual #134 <Method Object ArrayList.get(int)> // 22 36:areturn if(flag && j > 0) //* 23 37:iload_2 //* 24 38:ifeq 52 //* 25 41:iload 4 //* 26 43:ifle 52 return arraylist.get(0); // 27 46:aload_1 // 28 47:iconst_0 // 29 48:invokevirtual #134 <Method Object ArrayList.get(int)> // 30 51:areturn else return ((Object) (null)); // 31 52:aconst_null // 32 53:areturn } private static Object getPreviousFocusable(Object obj, ArrayList arraylist, boolean flag) { int j = arraylist.size(); // 0 0:aload_1 // 1 1:invokevirtual #128 <Method int ArrayList.size()> // 2 4:istore 4 int i; if(obj == null) //* 3 6:aload_0 //* 4 7:ifnonnull 16 i = j; // 5 10:iload 4 // 6 12:istore_3 else //* 7 13:goto 22 i = arraylist.indexOf(obj); // 8 16:aload_1 // 9 17:aload_0 // 10 18:invokevirtual #138 <Method int ArrayList.indexOf(Object)> // 11 21:istore_3 i--; // 12 22:iload_3 // 13 23:iconst_1 // 14 24:isub // 15 25:istore_3 if(i >= 0) //* 16 26:iload_3 //* 17 27:iflt 36 return arraylist.get(i); // 18 30:aload_1 // 19 31:iload_3 // 20 32:invokevirtual #134 <Method Object ArrayList.get(int)> // 21 35:areturn if(flag && j > 0) //* 22 36:iload_2 //* 23 37:ifeq 54 //* 24 40:iload 4 //* 25 42:ifle 54 return arraylist.get(j - 1); // 26 45:aload_1 // 27 46:iload 4 // 28 48:iconst_1 // 29 49:isub // 30 50:invokevirtual #134 <Method Object ArrayList.get(int)> // 31 53:areturn else return ((Object) (null)); // 32 54:aconst_null // 33 55:areturn } private static int getWeightedDistanceFor(int i, int j) { return 13 * i * i + j * j; // 0 0:bipush 13 // 1 2:iload_0 // 2 3:imul // 3 4:iload_0 // 4 5:imul // 5 6:iload_1 // 6 7:iload_1 // 7 8:imul // 8 9:iadd // 9 10:ireturn } private static boolean isBetterCandidate(int i, Rect rect, Rect rect1, Rect rect2) { boolean flag1 = isCandidate(rect, rect1, i); // 0 0:aload_1 // 1 1:aload_2 // 2 2:iload_0 // 3 3:invokestatic #144 <Method boolean isCandidate(Rect, Rect, int)> // 4 6:istore 5 boolean flag = false; // 5 8:iconst_0 // 6 9:istore 4 if(!flag1) //* 7 11:iload 5 //* 8 13:ifne 18 return false; // 9 16:iconst_0 // 10 17:ireturn if(!isCandidate(rect, rect2, i)) //* 11 18:aload_1 //* 12 19:aload_3 //* 13 20:iload_0 //* 14 21:invokestatic #144 <Method boolean isCandidate(Rect, Rect, int)> //* 15 24:ifne 29 return true; // 16 27:iconst_1 // 17 28:ireturn if(beamBeats(i, rect, rect1, rect2)) //* 18 29:iload_0 //* 19 30:aload_1 //* 20 31:aload_2 //* 21 32:aload_3 //* 22 33:invokestatic #146 <Method boolean beamBeats(int, Rect, Rect, Rect)> //* 23 36:ifeq 41 return true; // 24 39:iconst_1 // 25 40:ireturn if(beamBeats(i, rect, rect2, rect1)) //* 26 41:iload_0 //* 27 42:aload_1 //* 28 43:aload_3 //* 29 44:aload_2 //* 30 45:invokestatic #146 <Method boolean beamBeats(int, Rect, Rect, Rect)> //* 31 48:ifeq 53 return false; // 32 51:iconst_0 // 33 52:ireturn if(getWeightedDistanceFor(majorAxisDistance(i, rect, rect1), minorAxisDistance(i, rect, rect1)) < getWeightedDistanceFor(majorAxisDistance(i, rect, rect2), minorAxisDistance(i, rect, rect2))) //* 34 53:iload_0 //* 35 54:aload_1 //* 36 55:aload_2 //* 37 56:invokestatic #32 <Method int majorAxisDistance(int, Rect, Rect)> //* 38 59:iload_0 //* 39 60:aload_1 //* 40 61:aload_2 //* 41 62:invokestatic #149 <Method int minorAxisDistance(int, Rect, Rect)> //* 42 65:invokestatic #151 <Method int getWeightedDistanceFor(int, int)> //* 43 68:iload_0 //* 44 69:aload_1 //* 45 70:aload_3 //* 46 71:invokestatic #32 <Method int majorAxisDistance(int, Rect, Rect)> //* 47 74:iload_0 //* 48 75:aload_1 //* 49 76:aload_3 //* 50 77:invokestatic #149 <Method int minorAxisDistance(int, Rect, Rect)> //* 51 80:invokestatic #151 <Method int getWeightedDistanceFor(int, int)> //* 52 83:icmpge 89 flag = true; // 53 86:iconst_1 // 54 87:istore 4 return flag; // 55 89:iload 4 // 56 91:ireturn } private static boolean isCandidate(Rect rect, Rect rect1, int i) { boolean flag7; label0: { boolean flag6; label1: { boolean flag5; label2: { boolean flag; label3: { flag5 = false; // 0 0:iconst_0 // 1 1:istore 5 flag6 = false; // 2 3:iconst_0 // 3 4:istore 6 flag7 = false; // 4 6:iconst_0 // 5 7:istore 7 boolean flag4 = false; // 6 9:iconst_0 // 7 10:istore 4 if(i == 17) break label0; // 8 12:iload_2 // 9 13:bipush 17 // 10 15:icmpeq 176 if(i == 33) break label1; // 11 18:iload_2 // 12 19:bipush 33 // 13 21:icmpeq 133 if(i == 66) break label2; // 14 24:iload_2 // 15 25:bipush 66 // 16 27:icmpeq 90 if(i != 130) //* 17 30:iload_2 //* 18 31:sipush 130 //* 19 34:icmpeq 47 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 20 37:new #38 <Class IllegalArgumentException> // 21 40:dup // 22 41:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 23 43:invokespecial #43 <Method void IllegalArgumentException(String)> // 24 46:athrow if(rect.top >= rect1.top) //* 25 47:aload_0 //* 26 48:getfield #58 <Field int Rect.top> //* 27 51:aload_1 //* 28 52:getfield #58 <Field int Rect.top> //* 29 55:icmplt 72 { flag = flag4; // 30 58:iload 4 // 31 60:istore_3 if(rect.bottom > rect1.top) break label3; // 32 61:aload_0 // 33 62:getfield #55 <Field int Rect.bottom> // 34 65:aload_1 // 35 66:getfield #58 <Field int Rect.top> // 36 69:icmpgt 88 } flag = flag4; // 37 72:iload 4 // 38 74:istore_3 if(rect.bottom < rect1.bottom) //* 39 75:aload_0 //* 40 76:getfield #55 <Field int Rect.bottom> //* 41 79:aload_1 //* 42 80:getfield #55 <Field int Rect.bottom> //* 43 83:icmpge 88 flag = true; // 44 86:iconst_1 // 45 87:istore_3 } return flag; // 46 88:iload_3 // 47 89:ireturn } boolean flag1; label4: { if(rect.left >= rect1.left) //* 48 90:aload_0 //* 49 91:getfield #52 <Field int Rect.left> //* 50 94:aload_1 //* 51 95:getfield #52 <Field int Rect.left> //* 52 98:icmplt 115 { flag1 = flag5; // 53 101:iload 5 // 54 103:istore_3 if(rect.right > rect1.left) break label4; // 55 104:aload_0 // 56 105:getfield #49 <Field int Rect.right> // 57 108:aload_1 // 58 109:getfield #52 <Field int Rect.left> // 59 112:icmpgt 131 } flag1 = flag5; // 60 115:iload 5 // 61 117:istore_3 if(rect.right < rect1.right) //* 62 118:aload_0 //* 63 119:getfield #49 <Field int Rect.right> //* 64 122:aload_1 //* 65 123:getfield #49 <Field int Rect.right> //* 66 126:icmpge 131 flag1 = true; // 67 129:iconst_1 // 68 130:istore_3 } return flag1; // 69 131:iload_3 // 70 132:ireturn } boolean flag2; label5: { if(rect.bottom <= rect1.bottom) //* 71 133:aload_0 //* 72 134:getfield #55 <Field int Rect.bottom> //* 73 137:aload_1 //* 74 138:getfield #55 <Field int Rect.bottom> //* 75 141:icmpgt 158 { flag2 = flag6; // 76 144:iload 6 // 77 146:istore_3 if(rect.top < rect1.bottom) break label5; // 78 147:aload_0 // 79 148:getfield #58 <Field int Rect.top> // 80 151:aload_1 // 81 152:getfield #55 <Field int Rect.bottom> // 82 155:icmplt 174 } flag2 = flag6; // 83 158:iload 6 // 84 160:istore_3 if(rect.top > rect1.top) //* 85 161:aload_0 //* 86 162:getfield #58 <Field int Rect.top> //* 87 165:aload_1 //* 88 166:getfield #58 <Field int Rect.top> //* 89 169:icmple 174 flag2 = true; // 90 172:iconst_1 // 91 173:istore_3 } return flag2; // 92 174:iload_3 // 93 175:ireturn } boolean flag3; label6: { if(rect.right <= rect1.right) //* 94 176:aload_0 //* 95 177:getfield #49 <Field int Rect.right> //* 96 180:aload_1 //* 97 181:getfield #49 <Field int Rect.right> //* 98 184:icmpgt 201 { flag3 = flag7; // 99 187:iload 7 // 100 189:istore_3 if(rect.left < rect1.right) break label6; // 101 190:aload_0 // 102 191:getfield #52 <Field int Rect.left> // 103 194:aload_1 // 104 195:getfield #49 <Field int Rect.right> // 105 198:icmplt 217 } flag3 = flag7; // 106 201:iload 7 // 107 203:istore_3 if(rect.left > rect1.left) //* 108 204:aload_0 //* 109 205:getfield #52 <Field int Rect.left> //* 110 208:aload_1 //* 111 209:getfield #52 <Field int Rect.left> //* 112 212:icmple 217 flag3 = true; // 113 215:iconst_1 // 114 216:istore_3 } return flag3; // 115 217:iload_3 // 116 218:ireturn } private static boolean isToDirectionOf(int i, Rect rect, Rect rect1) { boolean flag1 = false; // 0 0:iconst_0 // 1 1:istore 4 boolean flag2 = false; // 2 3:iconst_0 // 3 4:istore 5 boolean flag3 = false; // 4 6:iconst_0 // 5 7:istore 6 boolean flag = false; // 6 9:iconst_0 // 7 10:istore_3 if(i != 17) //* 8 11:iload_0 //* 9 12:bipush 17 //* 10 14:icmpeq 97 { if(i != 33) //* 11 17:iload_0 //* 12 18:bipush 33 //* 13 20:icmpeq 79 { if(i != 66) //* 14 23:iload_0 //* 15 24:bipush 66 //* 16 26:icmpeq 61 { if(i != 130) //* 17 29:iload_0 //* 18 30:sipush 130 //* 19 33:icmpeq 46 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 20 36:new #38 <Class IllegalArgumentException> // 21 39:dup // 22 40:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 23 42:invokespecial #43 <Method void IllegalArgumentException(String)> // 24 45:athrow if(rect.bottom <= rect1.top) //* 25 46:aload_1 //* 26 47:getfield #55 <Field int Rect.bottom> //* 27 50:aload_2 //* 28 51:getfield #58 <Field int Rect.top> //* 29 54:icmpgt 59 flag = true; // 30 57:iconst_1 // 31 58:istore_3 return flag; // 32 59:iload_3 // 33 60:ireturn } flag = flag1; // 34 61:iload 4 // 35 63:istore_3 if(rect.right <= rect1.left) //* 36 64:aload_1 //* 37 65:getfield #49 <Field int Rect.right> //* 38 68:aload_2 //* 39 69:getfield #52 <Field int Rect.left> //* 40 72:icmpgt 77 flag = true; // 41 75:iconst_1 // 42 76:istore_3 return flag; // 43 77:iload_3 // 44 78:ireturn } flag = flag2; // 45 79:iload 5 // 46 81:istore_3 if(rect.top >= rect1.bottom) //* 47 82:aload_1 //* 48 83:getfield #58 <Field int Rect.top> //* 49 86:aload_2 //* 50 87:getfield #55 <Field int Rect.bottom> //* 51 90:icmplt 95 flag = true; // 52 93:iconst_1 // 53 94:istore_3 return flag; // 54 95:iload_3 // 55 96:ireturn } flag = flag3; // 56 97:iload 6 // 57 99:istore_3 if(rect.left >= rect1.right) //* 58 100:aload_1 //* 59 101:getfield #52 <Field int Rect.left> //* 60 104:aload_2 //* 61 105:getfield #49 <Field int Rect.right> //* 62 108:icmplt 113 flag = true; // 63 111:iconst_1 // 64 112:istore_3 return flag; // 65 113:iload_3 // 66 114:ireturn } private static int majorAxisDistance(int i, Rect rect, Rect rect1) { return Math.max(0, majorAxisDistanceRaw(i, rect, rect1)); // 0 0:iconst_0 // 1 1:iload_0 // 2 2:aload_1 // 3 3:aload_2 // 4 4:invokestatic #154 <Method int majorAxisDistanceRaw(int, Rect, Rect)> // 5 7:invokestatic #159 <Method int Math.max(int, int)> // 6 10:ireturn } private static int majorAxisDistanceRaw(int i, Rect rect, Rect rect1) { if(i != 17) //* 0 0:iload_0 //* 1 1:bipush 17 //* 2 3:icmpeq 65 { if(i != 33) //* 3 6:iload_0 //* 4 7:bipush 33 //* 5 9:icmpeq 55 { if(i != 66) //* 6 12:iload_0 //* 7 13:bipush 66 //* 8 15:icmpeq 45 { if(i != 130) //* 9 18:iload_0 //* 10 19:sipush 130 //* 11 22:icmpeq 35 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 12 25:new #38 <Class IllegalArgumentException> // 13 28:dup // 14 29:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 15 31:invokespecial #43 <Method void IllegalArgumentException(String)> // 16 34:athrow else return rect1.top - rect.bottom; // 17 35:aload_2 // 18 36:getfield #58 <Field int Rect.top> // 19 39:aload_1 // 20 40:getfield #55 <Field int Rect.bottom> // 21 43:isub // 22 44:ireturn } else { return rect1.left - rect.right; // 23 45:aload_2 // 24 46:getfield #52 <Field int Rect.left> // 25 49:aload_1 // 26 50:getfield #49 <Field int Rect.right> // 27 53:isub // 28 54:ireturn } } else { return rect.top - rect1.bottom; // 29 55:aload_1 // 30 56:getfield #58 <Field int Rect.top> // 31 59:aload_2 // 32 60:getfield #55 <Field int Rect.bottom> // 33 63:isub // 34 64:ireturn } } else { return rect.left - rect1.right; // 35 65:aload_1 // 36 66:getfield #52 <Field int Rect.left> // 37 69:aload_2 // 38 70:getfield #49 <Field int Rect.right> // 39 73:isub // 40 74:ireturn } } private static int majorAxisDistanceToFarEdge(int i, Rect rect, Rect rect1) { return Math.max(1, majorAxisDistanceToFarEdgeRaw(i, rect, rect1)); // 0 0:iconst_1 // 1 1:iload_0 // 2 2:aload_1 // 3 3:aload_2 // 4 4:invokestatic #162 <Method int majorAxisDistanceToFarEdgeRaw(int, Rect, Rect)> // 5 7:invokestatic #159 <Method int Math.max(int, int)> // 6 10:ireturn } private static int majorAxisDistanceToFarEdgeRaw(int i, Rect rect, Rect rect1) { if(i != 17) //* 0 0:iload_0 //* 1 1:bipush 17 //* 2 3:icmpeq 65 { if(i != 33) //* 3 6:iload_0 //* 4 7:bipush 33 //* 5 9:icmpeq 55 { if(i != 66) //* 6 12:iload_0 //* 7 13:bipush 66 //* 8 15:icmpeq 45 { if(i != 130) //* 9 18:iload_0 //* 10 19:sipush 130 //* 11 22:icmpeq 35 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 12 25:new #38 <Class IllegalArgumentException> // 13 28:dup // 14 29:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 15 31:invokespecial #43 <Method void IllegalArgumentException(String)> // 16 34:athrow else return rect1.bottom - rect.bottom; // 17 35:aload_2 // 18 36:getfield #55 <Field int Rect.bottom> // 19 39:aload_1 // 20 40:getfield #55 <Field int Rect.bottom> // 21 43:isub // 22 44:ireturn } else { return rect1.right - rect.right; // 23 45:aload_2 // 24 46:getfield #49 <Field int Rect.right> // 25 49:aload_1 // 26 50:getfield #49 <Field int Rect.right> // 27 53:isub // 28 54:ireturn } } else { return rect.top - rect1.top; // 29 55:aload_1 // 30 56:getfield #58 <Field int Rect.top> // 31 59:aload_2 // 32 60:getfield #58 <Field int Rect.top> // 33 63:isub // 34 64:ireturn } } else { return rect.left - rect1.left; // 35 65:aload_1 // 36 66:getfield #52 <Field int Rect.left> // 37 69:aload_2 // 38 70:getfield #52 <Field int Rect.left> // 39 73:isub // 40 74:ireturn } } private static int minorAxisDistance(int i, Rect rect, Rect rect1) { label0: { if(i == 17) break label0; // 0 0:iload_0 // 1 1:bipush 17 // 2 3:icmpeq 62 if(i != 33) //* 3 6:iload_0 //* 4 7:bipush 33 //* 5 9:icmpeq 35 { if(i == 66) break label0; // 6 12:iload_0 // 7 13:bipush 66 // 8 15:icmpeq 62 if(i != 130) //* 9 18:iload_0 //* 10 19:sipush 130 //* 11 22:icmpeq 35 throw new IllegalArgumentException("direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."); // 12 25:new #38 <Class IllegalArgumentException> // 13 28:dup // 14 29:ldc1 #40 <String "direction must be one of {FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}."> // 15 31:invokespecial #43 <Method void IllegalArgumentException(String)> // 16 34:athrow } return Math.abs((rect.left + rect.width() / 2) - (rect1.left + rect1.width() / 2)); // 17 35:aload_1 // 18 36:getfield #52 <Field int Rect.left> // 19 39:aload_1 // 20 40:invokevirtual #75 <Method int Rect.width()> // 21 43:iconst_2 // 22 44:idiv // 23 45:iadd // 24 46:aload_2 // 25 47:getfield #52 <Field int Rect.left> // 26 50:aload_2 // 27 51:invokevirtual #75 <Method int Rect.width()> // 28 54:iconst_2 // 29 55:idiv // 30 56:iadd // 31 57:isub // 32 58:invokestatic #166 <Method int Math.abs(int)> // 33 61:ireturn } return Math.abs((rect.top + rect.height() / 2) - (rect1.top + rect1.height() / 2)); // 34 62:aload_1 // 35 63:getfield #58 <Field int Rect.top> // 36 66:aload_1 // 37 67:invokevirtual #68 <Method int Rect.height()> // 38 70:iconst_2 // 39 71:idiv // 40 72:iadd // 41 73:aload_2 // 42 74:getfield #58 <Field int Rect.top> // 43 77:aload_2 // 44 78:invokevirtual #68 <Method int Rect.height()> // 45 81:iconst_2 // 46 82:idiv // 47 83:iadd // 48 84:isub // 49 85:invokestatic #166 <Method int Math.abs(int)> // 50 88:ireturn } }
true
299418d1f5469e2111bb8a151d99fcb94880a0e7
Java
ffsales/comercio
/src/main/java/com/br/viavarejo/comercio/resource/ProdutoResource.java
UTF-8
1,456
2.171875
2
[]
no_license
package com.br.viavarejo.comercio.resource; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.br.viavarejo.comercio.model.Produto; import com.br.viavarejo.comercio.repository.ProdutoRepository; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @CrossOrigin @RestController @RequestMapping("/produtos") @Api(value = "Produto") public class ProdutoResource { @Autowired private ProdutoRepository produtoRepository; @ApiOperation(value = "Lista de produtos") @RequestMapping(value = "/produto", method = RequestMethod.GET) public ResponseEntity<List<Produto>> getProdutos() { List<Produto> produtos = produtoRepository.findAll(); return ResponseEntity.status(HttpStatus.OK).body(produtos); } @ApiOperation(value = "Inclusão de produto") @RequestMapping(value = "/produto", method = RequestMethod.POST) public ResponseEntity<Void> postProduto(@RequestBody Produto produto) { produtoRepository.save(produto); return ResponseEntity.noContent().build(); } }
true
eaf15bf70ef05c0b64b6a585bfff8bc96f92160f
Java
munsif3/csrf-protection-synchronizer-token
/src/main/java/com/munsif/ssd/csrfsynchronizer/CsrfsynchronizerApplication.java
UTF-8
510
1.773438
2
[]
no_license
package com.munsif.ssd.csrfsynchronizer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import com.munsif.ssd.csrfsynchronizer.model.CredentialStore; @SpringBootApplication public class CsrfsynchronizerApplication { public static void main(String[] args) { SpringApplication.run(CsrfsynchronizerApplication.class, args); // Initial seeding of the credentials store HashMap new CredentialStore().seedCredentialStore(); } }
true
82a5db4f2a0dc0b850ac54eec659e16a9d02395c
Java
mallocation/obdme
/web_app/obdmeweb/app/controllers/Security.java
UTF-8
557
2.234375
2
[]
no_license
package controllers; import play.Logger; import models.obdmedb.User; import models.*; public class Security extends Secure.Security { static boolean authentify(String username, String password) { boolean validated = User.isValidCredentialsClearText(username, password); Logger.info("User Activity: " + username + " requesting authentication. User validated: " + validated + "."); return validated; } static void onAuthenticated() { Application.index(); } static void onDisconnected() { Application.index(); } }
true
2fa99a20964c38e4f572c41af581de6dc27dc329
Java
sunbeibei111466/baiduren
/app/src/main/java/com/yl/baiduren/entity/result/Open_Member_Result.java
UTF-8
6,882
2.3125
2
[]
no_license
package com.yl.baiduren.entity.result; import java.util.List; /** * Created by sunbeibei on 2017/12/28. */ public class Open_Member_Result { private String nickName;//昵称 private Long vipTime;//vip截止时间 private String userImage;//用户图片 private boolean isSolveMan;//是否解债人 private boolean isVip;//是否vip private boolean isFull;//用户资料是否齐全 false:不全; true:全 private Long toVipTimeAfterPay;//支付多少分钟之后开通vip private String personVipExplain;//个人vip开通说明 private String mechanisVipExplain;//企业vip开通说名 //个人vip private List<PersonVipListBean> personVipList; //企业vip(6个账号,买一带五) private List<MechanisSixtListBean> mechanisSixtList; //企业vip(11个账号,买一带10) private List<MechanisElevenListBean> mechanisElevenList; public String getNickName() { return nickName; } public void setNickName(String nickName) { this.nickName = nickName; } public Long getVipTime() { return vipTime; } public void setVipTime(Long vipTime) { this.vipTime = vipTime; } public String getUserImage() { return userImage; } public void setUserImage(String userImage) { this.userImage = userImage; } public boolean isIsSolveMan() { return isSolveMan; } public void setIsSolveMan(boolean isSolveMan) { this.isSolveMan = isSolveMan; } public boolean isIsVip() { return isVip; } public void setIsVip(boolean isVip) { this.isVip = isVip; } public boolean isIsFull() { return isFull; } public void setIsFull(boolean isFull) { this.isFull = isFull; } public Long getToVipTimeAfterPay() { return toVipTimeAfterPay; } public void setToVipTimeAfterPay(Long toVipTimeAfterPay) { this.toVipTimeAfterPay = toVipTimeAfterPay; } public String getPersonVipExplain() { return personVipExplain; } public void setPersonVipExplain(String personVipExplain) { this.personVipExplain = personVipExplain; } public String getMechanisVipExplain() { return mechanisVipExplain; } public void setMechanisVipExplain(String mechanisVipExplain) { this.mechanisVipExplain = mechanisVipExplain; } public List<PersonVipListBean> getPersonVipList() { return personVipList; } public void setPersonVipList(List<PersonVipListBean> personVipList) { this.personVipList = personVipList; } public List<MechanisSixtListBean> getMechanisSixtList() { return mechanisSixtList; } public void setMechanisSixtList(List<MechanisSixtListBean> mechanisSixtList) { this.mechanisSixtList = mechanisSixtList; } public List<MechanisElevenListBean> getMechanisElevenList() { return mechanisElevenList; } public void setMechanisElevenList(List<MechanisElevenListBean> mechanisElevenList) { this.mechanisElevenList = mechanisElevenList; } public static class PersonVipListBean { /** * id : 1 * priceStr : 30 * originalPriceStr : 50 * information : /月 */ private Long id; private String priceStr; private String originalPriceStr; private String information; private int month; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPriceStr() { return priceStr; } public void setPriceStr(String priceStr) { this.priceStr = priceStr; } public String getOriginalPriceStr() { return originalPriceStr; } public void setOriginalPriceStr(String originalPriceStr) { this.originalPriceStr = originalPriceStr; } public String getInformation() { return information; } public void setInformation(String information) { this.information = information; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } } public static class MechanisSixtListBean { /** * id : 19 * priceStr : 168 * originalPriceStr : 280 * information : /月 */ private Long id; private String priceStr; private String originalPriceStr; private String information; private int month; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPriceStr() { return priceStr; } public void setPriceStr(String priceStr) { this.priceStr = priceStr; } public String getOriginalPriceStr() { return originalPriceStr; } public void setOriginalPriceStr(String originalPriceStr) { this.originalPriceStr = originalPriceStr; } public String getInformation() { return information; } public void setInformation(String information) { this.information = information; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } } public static class MechanisElevenListBean { /** * id : 23 * priceStr : 300 * originalPriceStr : 500 * information : /月 */ private Long id; private String priceStr; private String originalPriceStr; private String information; private int month; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPriceStr() { return priceStr; } public void setPriceStr(String priceStr) { this.priceStr = priceStr; } public String getOriginalPriceStr() { return originalPriceStr; } public void setOriginalPriceStr(String originalPriceStr) { this.originalPriceStr = originalPriceStr; } public String getInformation() { return information; } public void setInformation(String information) { this.information = information; } public int getMonth() { return month; } public void setMonth(int month) { this.month = month; } } }
true
ebb59fdfe650e304d0448e29c6f10c82a4627faf
Java
Maram-93/letshelpeachother
/CodeSource/helpus/src/main/java/com/derbala/helpus/dao/IProposeServiceCustomerDao.java
UTF-8
466
1.6875
2
[]
no_license
package com.derbala.helpus.dao; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.derbala.helpus.Entities.ProposeServiceCustomer; @Repository public interface IProposeServiceCustomerDao extends JpaRepository <ProposeServiceCustomer, Integer> { public List<ProposeServiceCustomer> findAll(); //public List <ProposeServiceCustomer> findByCategoryIgnoreCase(); }
true
f18a52869729fd4f7c92f47152c5ba6eeaa8001a
Java
yearsyan/Harmony-OS-Java-class-library
/src/main/java/ohos/com/sun/org/apache/xerces/internal/util/XMLChar.java
UTF-8
51,403
1.523438
2
[]
no_license
package ohos.com.sun.org.apache.xerces.internal.util; import java.util.Arrays; import ohos.agp.render.opengl.EGL; import ohos.agp.render.opengl.GLES1X; import ohos.agp.render.opengl.GLES20; import ohos.bluetooth.BluetoothDeviceClass; import ohos.devtools.JLogConstants; import ohos.global.icu.impl.Normalizer2Impl; import ohos.global.icu.impl.UCharacterProperty; import ohos.global.icu.text.Bidi; import ohos.global.icu.text.UTF16; import ohos.media.camera.params.adapter.camera2ex.CameraMetadataEx; import ohos.media.player.Player; import ohos.miscservices.download.DownloadSession; import ohos.telephony.TelephonyUtils; import ohos.utils.system.safwk.java.SystemAbilityDefinition; public class XMLChar { private static final byte[] CHARS = new byte[65536]; public static final int MASK_CONTENT = 32; public static final int MASK_NAME = 8; public static final int MASK_NAME_START = 4; public static final int MASK_NCNAME = 128; public static final int MASK_NCNAME_START = 64; public static final int MASK_PUBID = 16; public static final int MASK_SPACE = 2; public static final int MASK_VALID = 1; public static char highSurrogate(int i) { return (char) (((i - 65536) >> 10) + 55296); } public static boolean isHighSurrogate(int i) { return 55296 <= i && i <= 56319; } public static boolean isLowSurrogate(int i) { return 56320 <= i && i <= 57343; } public static boolean isMarkup(int i) { return i == 60 || i == 38 || i == 37; } public static boolean isSupplemental(int i) { return i >= 65536 && i <= 1114111; } public static char lowSurrogate(int i) { return (char) (((i - 65536) & UCharacterProperty.MAX_SCRIPT) + UTF16.TRAIL_SURROGATE_MIN_VALUE); } public static int supplemental(char c, char c2) { return ((c - 55296) * 1024) + (c2 - UTF16.TRAIL_SURROGATE_MIN_VALUE) + 65536; } static { byte[] bArr = CHARS; bArr[9] = 35; bArr[10] = 19; bArr[13] = 19; bArr[32] = 51; bArr[33] = 49; bArr[34] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr, 35, 38, (byte) 49); byte[] bArr2 = CHARS; bArr2[38] = 1; Arrays.fill(bArr2, 39, 45, (byte) 49); Arrays.fill(CHARS, 45, 47, (byte) -71); byte[] bArr3 = CHARS; bArr3[47] = 49; Arrays.fill(bArr3, 48, 58, (byte) -71); byte[] bArr4 = CHARS; bArr4[58] = 61; bArr4[59] = 49; bArr4[60] = 1; bArr4[61] = 49; bArr4[62] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr4, 63, 65, (byte) 49); Arrays.fill(CHARS, 65, 91, (byte) -3); Arrays.fill(CHARS, 91, 93, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr5 = CHARS; bArr5[93] = 1; bArr5[94] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr5[95] = -3; bArr5[96] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr5, 97, 123, (byte) -3); Arrays.fill(CHARS, 123, 183, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr6 = CHARS; bArr6[183] = -87; Arrays.fill(bArr6, 184, 192, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 192, 215, (byte) -19); byte[] bArr7 = CHARS; bArr7[215] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr7, 216, 247, (byte) -19); byte[] bArr8 = CHARS; bArr8[247] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr8, 248, 306, (byte) -19); Arrays.fill(CHARS, 306, 308, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 308, (int) JLogConstants.JLID_CAMERAALGO_ALGOEXT1_END, (byte) -19); Arrays.fill(CHARS, (int) JLogConstants.JLID_CAMERAALGO_ALGOEXT1_END, (int) JLogConstants.JLID_CAMERAALGO_ALGOEXT2_END, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) JLogConstants.JLID_CAMERAALGO_ALGOEXT2_END, (int) JLogConstants.JLID_CAMERA3_HAL_CAF_END, (byte) -19); byte[] bArr9 = CHARS; bArr9[329] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr9, (int) JLogConstants.JLID_CAMERAAPP_SURFACE_AVALIABLE, 383, (byte) -19); byte[] bArr10 = CHARS; bArr10[383] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr10, 384, (int) JLogConstants.JLID_REMOTE_DMS_CONTINUATION_OLD, (byte) -19); Arrays.fill(CHARS, (int) JLogConstants.JLID_REMOTE_DMS_CONTINUATION_OLD, (int) JLogConstants.JLID_CAMERA_COLD_START_BEGIN, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) JLogConstants.JLID_CAMERA_COLD_START_BEGIN, 497, (byte) -19); Arrays.fill(CHARS, 497, 500, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 500, (int) DownloadSession.ERROR_DEVICE_NOT_FOUND, (byte) -19); Arrays.fill(CHARS, (int) DownloadSession.ERROR_DEVICE_NOT_FOUND, (int) DownloadSession.ERROR_CANNOT_RESUME, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) DownloadSession.ERROR_CANNOT_RESUME, 536, (byte) -19); Arrays.fill(CHARS, 536, 592, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 592, 681, (byte) -19); Arrays.fill(CHARS, 681, 699, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 699, 706, (byte) -19); Arrays.fill(CHARS, 706, 720, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 720, 722, (byte) -87); Arrays.fill(CHARS, 722, 768, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 768, 838, (byte) -87); Arrays.fill(CHARS, 838, 864, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 864, 866, (byte) -87); Arrays.fill(CHARS, 866, (int) Player.PLAYER_INFO_SUBTITLE_TIMED_OUT, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr11 = CHARS; bArr11[902] = -19; bArr11[903] = -87; Arrays.fill(bArr11, 904, 907, (byte) -19); byte[] bArr12 = CHARS; bArr12[907] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr12[908] = -19; bArr12[909] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr12, 910, 930, (byte) -19); byte[] bArr13 = CHARS; bArr13[930] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr13, 931, 975, (byte) -19); byte[] bArr14 = CHARS; bArr14[975] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr14, 976, 983, (byte) -19); Arrays.fill(CHARS, 983, 986, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr15 = CHARS; bArr15[986] = -19; bArr15[987] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr15[988] = -19; bArr15[989] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr15[990] = -19; bArr15[991] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr15[992] = -19; bArr15[993] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr15, 994, 1012, (byte) -19); Arrays.fill(CHARS, 1012, 1025, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1025, 1037, (byte) -19); byte[] bArr16 = CHARS; bArr16[1037] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr16, 1038, 1104, (byte) -19); byte[] bArr17 = CHARS; bArr17[1104] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr17, 1105, (int) SystemAbilityDefinition.IPC_MSG_SERVER, (byte) -19); byte[] bArr18 = CHARS; bArr18[1117] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr18, (int) SystemAbilityDefinition.IPC_TEST_SERVICE, 1154, (byte) -19); byte[] bArr19 = CHARS; bArr19[1154] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr19, 1155, 1159, (byte) -87); Arrays.fill(CHARS, 1159, 1168, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1168, 1221, (byte) -19); Arrays.fill(CHARS, 1221, 1223, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1223, 1225, (byte) -19); Arrays.fill(CHARS, 1225, 1227, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1227, 1229, (byte) -19); Arrays.fill(CHARS, 1229, 1232, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1232, 1260, (byte) -19); Arrays.fill(CHARS, 1260, 1262, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1262, 1270, (byte) -19); Arrays.fill(CHARS, 1270, 1272, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1272, 1274, (byte) -19); Arrays.fill(CHARS, 1274, 1329, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1329, 1367, (byte) -19); Arrays.fill(CHARS, 1367, 1369, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr20 = CHARS; bArr20[1369] = -19; Arrays.fill(bArr20, 1370, 1377, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1377, 1415, (byte) -19); Arrays.fill(CHARS, 1415, 1425, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1425, 1442, (byte) -87); byte[] bArr21 = CHARS; bArr21[1442] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr21, 1443, 1466, (byte) -87); byte[] bArr22 = CHARS; bArr22[1466] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr22, 1467, 1470, (byte) -87); byte[] bArr23 = CHARS; bArr23[1470] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr23[1471] = -87; bArr23[1472] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr23, 1473, 1475, (byte) -87); byte[] bArr24 = CHARS; bArr24[1475] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr24[1476] = -87; Arrays.fill(bArr24, 1477, 1488, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1488, 1515, (byte) -19); Arrays.fill(CHARS, 1515, 1520, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1520, 1523, (byte) -19); Arrays.fill(CHARS, 1523, 1569, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1569, 1595, (byte) -19); Arrays.fill(CHARS, 1595, 1600, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr25 = CHARS; bArr25[1600] = -87; Arrays.fill(bArr25, 1601, 1611, (byte) -19); Arrays.fill(CHARS, 1611, 1619, (byte) -87); Arrays.fill(CHARS, 1619, 1632, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1632, 1642, (byte) -87); Arrays.fill(CHARS, 1642, 1648, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr26 = CHARS; bArr26[1648] = -87; Arrays.fill(bArr26, 1649, 1720, (byte) -19); Arrays.fill(CHARS, 1720, 1722, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1722, 1727, (byte) -19); byte[] bArr27 = CHARS; bArr27[1727] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr27, 1728, 1743, (byte) -19); byte[] bArr28 = CHARS; bArr28[1743] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr28, 1744, 1748, (byte) -19); byte[] bArr29 = CHARS; bArr29[1748] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr29[1749] = -19; Arrays.fill(bArr29, 1750, 1765, (byte) -87); Arrays.fill(CHARS, 1765, 1767, (byte) -19); Arrays.fill(CHARS, 1767, 1769, (byte) -87); byte[] bArr30 = CHARS; bArr30[1769] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr30, 1770, 1774, (byte) -87); Arrays.fill(CHARS, 1774, 1776, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 1776, 1786, (byte) -87); Arrays.fill(CHARS, 1786, 2305, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2305, (int) BluetoothDeviceClass.MajorMinorClass.HEALTH_BLOOD_PRESSURE_MONITOR, (byte) -87); byte[] bArr31 = CHARS; bArr31[2308] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr31, 2309, 2362, (byte) -19); Arrays.fill(CHARS, 2362, (int) BluetoothDeviceClass.MajorMinorClass.HEALTH_PERSONAL_MOBILITY_DEVICE, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr32 = CHARS; bArr32[2364] = -87; bArr32[2365] = -19; Arrays.fill(bArr32, 2366, 2382, (byte) -87); Arrays.fill(CHARS, 2382, 2385, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2385, 2389, (byte) -87); Arrays.fill(CHARS, 2389, 2392, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2392, 2402, (byte) -19); Arrays.fill(CHARS, 2402, 2404, (byte) -87); Arrays.fill(CHARS, 2404, 2406, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2406, 2416, (byte) -87); Arrays.fill(CHARS, 2416, 2433, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2433, 2436, (byte) -87); byte[] bArr33 = CHARS; bArr33[2436] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr33, 2437, 2445, (byte) -19); Arrays.fill(CHARS, 2445, 2447, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2447, 2449, (byte) -19); Arrays.fill(CHARS, 2449, 2451, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2451, 2473, (byte) -19); byte[] bArr34 = CHARS; bArr34[2473] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr34, 2474, 2481, (byte) -19); byte[] bArr35 = CHARS; bArr35[2481] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr35[2482] = -19; Arrays.fill(bArr35, 2483, 2486, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2486, 2490, (byte) -19); Arrays.fill(CHARS, 2490, 2492, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr36 = CHARS; bArr36[2492] = -87; bArr36[2493] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr36, 2494, 2501, (byte) -87); Arrays.fill(CHARS, 2501, 2503, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2503, 2505, (byte) -87); Arrays.fill(CHARS, 2505, 2507, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2507, 2510, (byte) -87); Arrays.fill(CHARS, 2510, 2519, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr37 = CHARS; bArr37[2519] = -87; Arrays.fill(bArr37, 2520, 2524, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2524, 2526, (byte) -19); byte[] bArr38 = CHARS; bArr38[2526] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr38, 2527, 2530, (byte) -19); Arrays.fill(CHARS, 2530, 2532, (byte) -87); Arrays.fill(CHARS, 2532, 2534, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2534, 2544, (byte) -87); Arrays.fill(CHARS, 2544, 2546, (byte) -19); Arrays.fill(CHARS, 2546, 2562, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr39 = CHARS; bArr39[2562] = -87; Arrays.fill(bArr39, 2563, 2565, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2565, 2571, (byte) -19); Arrays.fill(CHARS, 2571, 2575, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2575, 2577, (byte) -19); Arrays.fill(CHARS, 2577, 2579, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2579, 2601, (byte) -19); byte[] bArr40 = CHARS; bArr40[2601] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr40, 2602, 2609, (byte) -19); byte[] bArr41 = CHARS; bArr41[2609] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr41, 2610, 2612, (byte) -19); byte[] bArr42 = CHARS; bArr42[2612] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr42, 2613, 2615, (byte) -19); byte[] bArr43 = CHARS; bArr43[2615] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr43, 2616, 2618, (byte) -19); Arrays.fill(CHARS, 2618, 2620, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr44 = CHARS; bArr44[2620] = -87; bArr44[2621] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr44, 2622, 2627, (byte) -87); Arrays.fill(CHARS, 2627, 2631, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2631, 2633, (byte) -87); Arrays.fill(CHARS, 2633, 2635, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2635, 2638, (byte) -87); Arrays.fill(CHARS, 2638, 2649, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2649, 2653, (byte) -19); byte[] bArr45 = CHARS; bArr45[2653] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr45[2654] = -19; Arrays.fill(bArr45, 2655, 2662, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2662, 2674, (byte) -87); Arrays.fill(CHARS, 2674, 2677, (byte) -19); Arrays.fill(CHARS, 2677, 2689, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2689, 2692, (byte) -87); byte[] bArr46 = CHARS; bArr46[2692] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr46, 2693, (int) SystemAbilityDefinition.SUBSYS_KERNEL_SYS_ABILITY_ID_BEGIN, (byte) -19); byte[] bArr47 = CHARS; bArr47[2700] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr47[2701] = -19; bArr47[2702] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr47, 2703, 2706, (byte) -19); byte[] bArr48 = CHARS; bArr48[2706] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr48, 2707, 2729, (byte) -19); byte[] bArr49 = CHARS; bArr49[2729] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr49, 2730, 2737, (byte) -19); byte[] bArr50 = CHARS; bArr50[2737] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr50, 2738, 2740, (byte) -19); byte[] bArr51 = CHARS; bArr51[2740] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr51, 2741, 2746, (byte) -19); Arrays.fill(CHARS, 2746, 2748, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr52 = CHARS; bArr52[2748] = -87; bArr52[2749] = -19; Arrays.fill(bArr52, 2750, 2758, (byte) -87); byte[] bArr53 = CHARS; bArr53[2758] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr53, 2759, 2762, (byte) -87); byte[] bArr54 = CHARS; bArr54[2762] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr54, 2763, 2766, (byte) -87); Arrays.fill(CHARS, 2766, 2784, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr55 = CHARS; bArr55[2784] = -19; Arrays.fill(bArr55, 2785, 2790, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2790, (int) SystemAbilityDefinition.SUBSYS_LOCATION_SYS_ABILITY_ID_BEGIN, (byte) -87); Arrays.fill(CHARS, (int) SystemAbilityDefinition.SUBSYS_LOCATION_SYS_ABILITY_ID_BEGIN, 2817, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2817, 2820, (byte) -87); byte[] bArr56 = CHARS; bArr56[2820] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr56, 2821, 2829, (byte) -19); Arrays.fill(CHARS, 2829, 2831, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2831, 2833, (byte) -19); Arrays.fill(CHARS, 2833, 2835, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2835, 2857, (byte) -19); byte[] bArr57 = CHARS; bArr57[2857] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr57, 2858, 2865, (byte) -19); byte[] bArr58 = CHARS; bArr58[2865] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr58, 2866, 2868, (byte) -19); Arrays.fill(CHARS, 2868, 2870, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2870, 2874, (byte) -19); Arrays.fill(CHARS, 2874, 2876, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr59 = CHARS; bArr59[2876] = -87; bArr59[2877] = -19; Arrays.fill(bArr59, 2878, 2884, (byte) -87); Arrays.fill(CHARS, 2884, 2887, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2887, 2889, (byte) -87); Arrays.fill(CHARS, 2889, 2891, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2891, 2894, (byte) -87); Arrays.fill(CHARS, 2894, 2902, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2902, 2904, (byte) -87); Arrays.fill(CHARS, 2904, 2908, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2908, 2910, (byte) -19); byte[] bArr60 = CHARS; bArr60[2910] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr60, 2911, (int) GLES1X.GL_FOG_DENSITY, (byte) -19); Arrays.fill(CHARS, (int) GLES1X.GL_FOG_DENSITY, (int) GLES1X.GL_FOG_COLOR, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) GLES1X.GL_FOG_COLOR, 2928, (byte) -87); Arrays.fill(CHARS, 2928, 2946, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2946, 2948, (byte) -87); byte[] bArr61 = CHARS; bArr61[2948] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr61, 2949, 2955, (byte) -19); Arrays.fill(CHARS, 2955, 2958, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2958, 2961, (byte) -19); byte[] bArr62 = CHARS; bArr62[2961] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr62, 2962, 2966, (byte) -19); Arrays.fill(CHARS, 2966, 2969, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2969, 2971, (byte) -19); byte[] bArr63 = CHARS; bArr63[2971] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr63[2972] = -19; bArr63[2973] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr63, 2974, 2976, (byte) -19); Arrays.fill(CHARS, 2976, 2979, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2979, 2981, (byte) -19); Arrays.fill(CHARS, 2981, 2984, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2984, 2987, (byte) -19); Arrays.fill(CHARS, 2987, 2990, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 2990, 2998, (byte) -19); byte[] bArr64 = CHARS; bArr64[2998] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr64, 2999, 3002, (byte) -19); Arrays.fill(CHARS, 3002, (int) TelephonyUtils.MSG_IS_IMS_SMS_SUPPORT, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) TelephonyUtils.MSG_IS_IMS_SMS_SUPPORT, 3011, (byte) -87); Arrays.fill(CHARS, 3011, 3014, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3014, 3017, (byte) -87); byte[] bArr65 = CHARS; bArr65[3017] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr65, 3018, 3022, (byte) -87); Arrays.fill(CHARS, 3022, 3031, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr66 = CHARS; bArr66[3031] = -87; Arrays.fill(bArr66, 3032, 3047, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3047, 3056, (byte) -87); Arrays.fill(CHARS, 3056, 3073, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3073, 3076, (byte) -87); byte[] bArr67 = CHARS; bArr67[3076] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr67, 3077, 3085, (byte) -19); byte[] bArr68 = CHARS; bArr68[3085] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr68, 3086, 3089, (byte) -19); byte[] bArr69 = CHARS; bArr69[3089] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr69, 3090, 3113, (byte) -19); byte[] bArr70 = CHARS; bArr70[3113] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr70, 3114, 3124, (byte) -19); byte[] bArr71 = CHARS; bArr71[3124] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr71, 3125, 3130, (byte) -19); Arrays.fill(CHARS, 3130, 3134, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3134, 3141, (byte) -87); byte[] bArr72 = CHARS; bArr72[3141] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr72, 3142, 3145, (byte) -87); byte[] bArr73 = CHARS; bArr73[3145] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr73, 3146, 3150, (byte) -87); Arrays.fill(CHARS, 3150, 3157, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3157, 3159, (byte) -87); Arrays.fill(CHARS, 3159, 3168, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3168, 3170, (byte) -19); Arrays.fill(CHARS, 3170, 3174, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3174, 3184, (byte) -87); Arrays.fill(CHARS, 3184, (int) SystemAbilityDefinition.COMMON_EVENT_SERVICE_ABILITY_ID, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) SystemAbilityDefinition.COMMON_EVENT_SERVICE_ABILITY_ID, 3204, (byte) -87); byte[] bArr74 = CHARS; bArr74[3204] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr74, 3205, 3213, (byte) -19); byte[] bArr75 = CHARS; bArr75[3213] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr75, 3214, 3217, (byte) -19); byte[] bArr76 = CHARS; bArr76[3217] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr76, 3218, 3241, (byte) -19); byte[] bArr77 = CHARS; bArr77[3241] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr77, 3242, 3252, (byte) -19); byte[] bArr78 = CHARS; bArr78[3252] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr78, 3253, 3258, (byte) -19); Arrays.fill(CHARS, 3258, 3262, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3262, 3269, (byte) -87); byte[] bArr79 = CHARS; bArr79[3269] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr79, 3270, 3273, (byte) -87); byte[] bArr80 = CHARS; bArr80[3273] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr80, 3274, 3278, (byte) -87); Arrays.fill(CHARS, 3278, 3285, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3285, 3287, (byte) -87); Arrays.fill(CHARS, 3287, 3294, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr81 = CHARS; bArr81[3294] = -19; bArr81[3295] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr81, 3296, 3298, (byte) -19); Arrays.fill(CHARS, 3298, (int) SystemAbilityDefinition.POWER_MANAGER_BATT_SERVICE_ID, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) SystemAbilityDefinition.POWER_MANAGER_BATT_SERVICE_ID, 3312, (byte) -87); Arrays.fill(CHARS, 3312, 3330, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3330, 3332, (byte) -87); byte[] bArr82 = CHARS; bArr82[3332] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr82, 3333, 3341, (byte) -19); byte[] bArr83 = CHARS; bArr83[3341] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr83, 3342, 3345, (byte) -19); byte[] bArr84 = CHARS; bArr84[3345] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr84, 3346, 3369, (byte) -19); byte[] bArr85 = CHARS; bArr85[3369] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr85, 3370, 3386, (byte) -19); Arrays.fill(CHARS, 3386, 3390, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3390, 3396, (byte) -87); Arrays.fill(CHARS, 3396, 3398, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3398, 3401, (byte) -87); byte[] bArr86 = CHARS; bArr86[3401] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr86, 3402, 3406, (byte) -87); Arrays.fill(CHARS, 3406, 3415, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr87 = CHARS; bArr87[3415] = -87; Arrays.fill(bArr87, 3416, 3424, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3424, 3426, (byte) -19); Arrays.fill(CHARS, 3426, 3430, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3430, 3440, (byte) -87); Arrays.fill(CHARS, 3440, 3585, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3585, 3631, (byte) -19); byte[] bArr88 = CHARS; bArr88[3631] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr88[3632] = -19; bArr88[3633] = -87; Arrays.fill(bArr88, 3634, 3636, (byte) -19); Arrays.fill(CHARS, 3636, 3643, (byte) -87); Arrays.fill(CHARS, 3643, 3648, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3648, 3654, (byte) -19); Arrays.fill(CHARS, 3654, 3663, (byte) -87); byte[] bArr89 = CHARS; bArr89[3663] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr89, 3664, 3674, (byte) -87); Arrays.fill(CHARS, 3674, 3713, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3713, 3715, (byte) -19); byte[] bArr90 = CHARS; bArr90[3715] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr90[3716] = -19; Arrays.fill(bArr90, 3717, 3719, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3719, 3721, (byte) -19); byte[] bArr91 = CHARS; bArr91[3721] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr91[3722] = -19; Arrays.fill(bArr91, 3723, 3725, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr92 = CHARS; bArr92[3725] = -19; Arrays.fill(bArr92, 3726, 3732, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3732, 3736, (byte) -19); byte[] bArr93 = CHARS; bArr93[3736] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr93, 3737, 3744, (byte) -19); byte[] bArr94 = CHARS; bArr94[3744] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr94, 3745, 3748, (byte) -19); byte[] bArr95 = CHARS; bArr95[3748] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr95[3749] = -19; bArr95[3750] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr95[3751] = -19; Arrays.fill(bArr95, 3752, 3754, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3754, 3756, (byte) -19); byte[] bArr96 = CHARS; bArr96[3756] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr96, 3757, 3759, (byte) -19); byte[] bArr97 = CHARS; bArr97[3759] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr97[3760] = -19; bArr97[3761] = -87; Arrays.fill(bArr97, 3762, 3764, (byte) -19); Arrays.fill(CHARS, 3764, 3770, (byte) -87); byte[] bArr98 = CHARS; bArr98[3770] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr98, 3771, 3773, (byte) -87); byte[] bArr99 = CHARS; bArr99[3773] = -19; Arrays.fill(bArr99, 3774, 3776, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3776, 3781, (byte) -19); byte[] bArr100 = CHARS; bArr100[3781] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr100[3782] = -87; bArr100[3783] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr100, 3784, 3790, (byte) -87); Arrays.fill(CHARS, 3790, 3792, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3792, 3802, (byte) -87); Arrays.fill(CHARS, 3802, 3864, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3864, 3866, (byte) -87); Arrays.fill(CHARS, 3866, 3872, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3872, 3882, (byte) -87); Arrays.fill(CHARS, 3882, 3893, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr101 = CHARS; bArr101[3893] = -87; bArr101[3894] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr101[3895] = -87; bArr101[3896] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr101[3897] = -87; Arrays.fill(bArr101, 3898, 3902, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3902, 3904, (byte) -87); Arrays.fill(CHARS, 3904, 3912, (byte) -19); byte[] bArr102 = CHARS; bArr102[3912] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr102, 3913, 3946, (byte) -19); Arrays.fill(CHARS, 3946, 3953, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3953, 3973, (byte) -87); byte[] bArr103 = CHARS; bArr103[3973] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr103, 3974, 3980, (byte) -87); Arrays.fill(CHARS, 3980, 3984, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 3984, 3990, (byte) -87); byte[] bArr104 = CHARS; bArr104[3990] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr104[3991] = -87; bArr104[3992] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr104, 3993, 4014, (byte) -87); Arrays.fill(CHARS, 4014, 4017, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4017, 4024, (byte) -87); byte[] bArr105 = CHARS; bArr105[4024] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr105[4025] = -87; Arrays.fill(bArr105, 4026, 4256, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4256, 4294, (byte) -19); Arrays.fill(CHARS, 4294, 4304, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4304, 4343, (byte) -19); Arrays.fill(CHARS, 4343, (int) Normalizer2Impl.Hangul.JAMO_L_BASE, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr106 = CHARS; bArr106[4352] = -19; bArr106[4353] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr106, 4354, 4356, (byte) -19); byte[] bArr107 = CHARS; bArr107[4356] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr107, 4357, 4360, (byte) -19); byte[] bArr108 = CHARS; bArr108[4360] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr108[4361] = -19; bArr108[4362] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr108, 4363, 4365, (byte) -19); byte[] bArr109 = CHARS; bArr109[4365] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr109, 4366, (int) Normalizer2Impl.Hangul.JAMO_L_LIMIT, (byte) -19); Arrays.fill(CHARS, (int) Normalizer2Impl.Hangul.JAMO_L_LIMIT, 4412, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr110 = CHARS; bArr110[4412] = -19; bArr110[4413] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr110[4414] = -19; bArr110[4415] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr110[4416] = -19; Arrays.fill(bArr110, 4417, 4428, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr111 = CHARS; bArr111[4428] = -19; bArr111[4429] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr111[4430] = -19; bArr111[4431] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr111[4432] = -19; Arrays.fill(bArr111, 4433, 4436, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4436, 4438, (byte) -19); Arrays.fill(CHARS, 4438, 4441, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr112 = CHARS; bArr112[4441] = -19; Arrays.fill(bArr112, 4442, 4447, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4447, 4450, (byte) -19); byte[] bArr113 = CHARS; bArr113[4450] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr113[4451] = -19; bArr113[4452] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr113[4453] = -19; bArr113[4454] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr113[4455] = -19; bArr113[4456] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr113[4457] = -19; Arrays.fill(bArr113, 4458, 4461, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4461, 4463, (byte) -19); Arrays.fill(CHARS, 4463, 4466, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4466, 4468, (byte) -19); byte[] bArr114 = CHARS; bArr114[4468] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr114[4469] = -19; Arrays.fill(bArr114, (int) Normalizer2Impl.Hangul.JAMO_V_LIMIT, 4510, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr115 = CHARS; bArr115[4510] = -19; Arrays.fill(bArr115, 4511, 4520, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr116 = CHARS; bArr116[4520] = -19; Arrays.fill(bArr116, 4521, 4523, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr117 = CHARS; bArr117[4523] = -19; Arrays.fill(bArr117, 4524, 4526, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4526, 4528, (byte) -19); Arrays.fill(CHARS, 4528, 4535, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 4535, 4537, (byte) -19); byte[] bArr118 = CHARS; bArr118[4537] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr118[4538] = -19; bArr118[4539] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr118, 4540, 4547, (byte) -19); Arrays.fill(CHARS, 4547, 4587, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr119 = CHARS; bArr119[4587] = -19; Arrays.fill(bArr119, 4588, 4592, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr120 = CHARS; bArr120[4592] = -19; Arrays.fill(bArr120, 4593, 4601, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr121 = CHARS; bArr121[4601] = -19; Arrays.fill(bArr121, 4602, (int) GLES20.GL_KEEP, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) GLES20.GL_KEEP, 7836, (byte) -19); Arrays.fill(CHARS, 7836, 7840, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 7840, 7930, (byte) -19); Arrays.fill(CHARS, 7930, 7936, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 7936, 7958, (byte) -19); Arrays.fill(CHARS, 7958, 7960, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 7960, 7966, (byte) -19); Arrays.fill(CHARS, 7966, 7968, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 7968, 8006, (byte) -19); Arrays.fill(CHARS, 8006, 8008, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8008, 8014, (byte) -19); Arrays.fill(CHARS, 8014, 8016, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8016, 8024, (byte) -19); byte[] bArr122 = CHARS; bArr122[8024] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr122[8025] = -19; bArr122[8026] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr122[8027] = -19; bArr122[8028] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr122[8029] = -19; bArr122[8030] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr122, 8031, 8062, (byte) -19); Arrays.fill(CHARS, 8062, 8064, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8064, 8117, (byte) -19); byte[] bArr123 = CHARS; bArr123[8117] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr123, 8118, 8125, (byte) -19); byte[] bArr124 = CHARS; bArr124[8125] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr124[8126] = -19; Arrays.fill(bArr124, 8127, 8130, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8130, 8133, (byte) -19); byte[] bArr125 = CHARS; bArr125[8133] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr125, 8134, 8141, (byte) -19); Arrays.fill(CHARS, 8141, 8144, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8144, 8148, (byte) -19); Arrays.fill(CHARS, 8148, 8150, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8150, 8156, (byte) -19); Arrays.fill(CHARS, 8156, 8160, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8160, 8173, (byte) -19); Arrays.fill(CHARS, 8173, 8178, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8178, 8181, (byte) -19); byte[] bArr126 = CHARS; bArr126[8181] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr126, 8182, 8189, (byte) -19); Arrays.fill(CHARS, 8189, 8400, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8400, 8413, (byte) -87); Arrays.fill(CHARS, 8413, 8417, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr127 = CHARS; bArr127[8417] = -87; Arrays.fill(bArr127, 8418, 8486, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr128 = CHARS; bArr128[8486] = -19; Arrays.fill(bArr128, 8487, 8490, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8490, 8492, (byte) -19); Arrays.fill(CHARS, 8492, 8494, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr129 = CHARS; bArr129[8494] = -19; Arrays.fill(bArr129, 8495, 8576, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 8576, 8579, (byte) -19); Arrays.fill(CHARS, 8579, 12293, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); byte[] bArr130 = CHARS; bArr130[12293] = -87; bArr130[12294] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; bArr130[12295] = -19; Arrays.fill(bArr130, 12296, (int) EGL.EGL_ALPHA_SIZE, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) EGL.EGL_ALPHA_SIZE, 12330, (byte) -19); Arrays.fill(CHARS, 12330, 12336, (byte) -87); byte[] bArr131 = CHARS; bArr131[12336] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr131, 12337, 12342, (byte) -87); Arrays.fill(CHARS, 12342, 12353, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 12353, 12437, (byte) -19); Arrays.fill(CHARS, 12437, 12441, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 12441, 12443, (byte) -87); Arrays.fill(CHARS, 12443, 12445, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 12445, 12447, (byte) -87); Arrays.fill(CHARS, 12447, 12449, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 12449, 12539, (byte) -19); byte[] bArr132 = CHARS; bArr132[12539] = CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART; Arrays.fill(bArr132, 12540, 12543, (byte) -87); Arrays.fill(CHARS, 12543, 12549, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 12549, 12589, (byte) -19); Arrays.fill(CHARS, 12589, 19968, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 19968, 40870, (byte) -19); Arrays.fill(CHARS, 40870, (int) Normalizer2Impl.Hangul.HANGUL_BASE, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, (int) Normalizer2Impl.Hangul.HANGUL_BASE, (int) Normalizer2Impl.Hangul.HANGUL_LIMIT, (byte) -19); Arrays.fill(CHARS, (int) Normalizer2Impl.Hangul.HANGUL_LIMIT, 55296, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); Arrays.fill(CHARS, 57344, 65534, (byte) CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_SMART); } public static boolean isValid(int i) { if (i >= 65536 || (CHARS[i] & 1) == 0) { return 65536 <= i && i <= 1114111; } return true; } public static boolean isInvalid(int i) { return !isValid(i); } public static boolean isContent(int i) { return (i < 65536 && (CHARS[i] & CameraMetadataEx.HUAWEI_EXT_SCENE_MODE_BASE) != 0) || (65536 <= i && i <= 1114111); } public static boolean isSpace(int i) { return i <= 32 && (CHARS[i] & 2) != 0; } public static boolean isNameStart(int i) { return i < 65536 && (CHARS[i] & 4) != 0; } public static boolean isName(int i) { return i < 65536 && (CHARS[i] & 8) != 0; } public static boolean isNCNameStart(int i) { return i < 65536 && (CHARS[i] & 64) != 0; } public static boolean isNCName(int i) { return i < 65536 && (CHARS[i] & Bidi.LEVEL_OVERRIDE) != 0; } public static boolean isPubid(int i) { return i < 65536 && (CHARS[i] & 16) != 0; } public static boolean isValidName(String str) { int length = str.length(); if (length == 0 || !isNameStart(str.charAt(0))) { return false; } for (int i = 1; i < length; i++) { if (!isName(str.charAt(i))) { return false; } } return true; } public static boolean isValidNCName(String str) { int length = str.length(); if (length == 0 || !isNCNameStart(str.charAt(0))) { return false; } for (int i = 1; i < length; i++) { if (!isNCName(str.charAt(i))) { return false; } } return true; } public static boolean isValidNmtoken(String str) { int length = str.length(); if (length == 0) { return false; } for (int i = 0; i < length; i++) { if (!isName(str.charAt(i))) { return false; } } return true; } public static boolean isValidIANAEncoding(String str) { int length; char charAt; if (str == null || (length = str.length()) <= 0 || (((charAt = str.charAt(0)) < 'A' || charAt > 'Z') && (charAt < 'a' || charAt > 'z'))) { return false; } for (int i = 1; i < length; i++) { char charAt2 = str.charAt(i); if ((charAt2 < 'A' || charAt2 > 'Z') && ((charAt2 < 'a' || charAt2 > 'z') && !((charAt2 >= '0' && charAt2 <= '9') || charAt2 == '.' || charAt2 == '_' || charAt2 == '-'))) { return false; } } return true; } public static boolean isValidJavaEncoding(String str) { int length; if (str == null || (length = str.length()) <= 0) { return false; } for (int i = 1; i < length; i++) { char charAt = str.charAt(i); if ((charAt < 'A' || charAt > 'Z') && ((charAt < 'a' || charAt > 'z') && !((charAt >= '0' && charAt <= '9') || charAt == '.' || charAt == '_' || charAt == '-'))) { return false; } } return true; } public static String trim(String str) { int length = str.length() - 1; int i = 0; while (i <= length && isSpace(str.charAt(i))) { i++; } int i2 = length; while (i2 >= i && isSpace(str.charAt(i2))) { i2--; } if (i == 0 && i2 == length) { return str; } if (i > length) { return ""; } return str.substring(i, i2 + 1); } }
true
71ab83dde82d850f402fc7f202e8877e61c750c3
Java
dolphinxx/android_smart_update_demo
/smart_update/src/com/example/smartupdate/upgrade/UpgradeManager.java
UTF-8
8,110
2.015625
2
[]
no_license
package com.example.smartupdate.upgrade; import ie.wombat.jbdiff.JBPatch; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Collections; import java.util.Locale; import org.json.JSONObject; import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; import android.os.Environment; import android.util.Log; import android.widget.Toast; import com.example.smartupdate.BaseActivity; import com.example.smartupdate.MyApplication; import com.example.smartupdate.R; import com.example.smartupdate.http.HttpRequest; import com.example.smartupdate.http.JsonResponseHandler; public class UpgradeManager { private static final String TAG = UpgradeManager.class.getName(); private static final String VERSION_URL = "http://192.168.1.104/upgrade"; private Context context; private PackageManager packageManager; private String VERSION; private boolean checking; private boolean auto; private boolean downloading; private File apkFile; UpgradeInfo upgradeInfo; private JsonResponseHandler checkUpgradeResonseHandler; private HttpRequest checkUpgradeRequest; private ApkDownloadHandler apkDownloadHandler; private ApkDownloadTask task; private static UpgradeManager instance; private UpgradeManager() { context = MyApplication.getInstance(); packageManager = context.getPackageManager(); checkUpgradeResonseHandler = new JsonResponseHandler() { @Override public void onRequestSuccess(Object data, Object extra) { final JSONObject json = (JSONObject) data; if (json.optBoolean("upgrade")) { upgradeInfo = new UpgradeInfo(); upgradeInfo.version = json.optString("version"); upgradeInfo.url = json.optString("url"); upgradeInfo.patch = json.optBoolean("patch"); upgradeInfo.sha1 = json.optString("sha1").getBytes(); upgradeInfo.size = json.optInt("size"); if(upgradeInfo.patch){ upgradeInfo.patch_sha1 = json.optString("patch_sha1").getBytes(); upgradeInfo.patched_file = Environment.getExternalStorageDirectory() + "/download/" + context.getPackageName() + "." + upgradeInfo.version + ".apk"; } AlertDialog dialog = new AlertDialog.Builder( BaseActivity.getCurrentActivity()).setCancelable(false) .setTitle("Prompt") .setMessage( "new version of " + upgradeInfo.version + " is available, do you want to update to the newest version?") .setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which) { upgrade(); dialog.dismiss(); } }) .setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.show(); } else { if (!auto) { Toast.makeText(BaseActivity.getCurrentActivity(), "You are already at the newest version!", Toast.LENGTH_LONG).show(); } } } @Override public void onComplete(int statusCode) { if (!auto) { dismissLoadingDialog(); } } @Override public void onError(int errorCode, String errorMessage, Object extra) { Toast.makeText( context, "Checking upgrade failed, please try it later! " + errorMessage, Toast.LENGTH_LONG).show(); } }; } public static UpgradeManager getInstance() { if (null == instance) { instance = new UpgradeManager(); } return instance; } public String getVersion() { if (null == VERSION) { try { PackageInfo pInfo = packageManager.getPackageInfo( context.getPackageName(), 0); VERSION = pInfo.versionName; } catch (NameNotFoundException e) { Log.e(TAG, "error getting version info", e); } } return VERSION; } public void checkVersion(boolean auto) { this.auto = auto; if (checking) { return; } if (null != checkUpgradeRequest) { checkUpgradeRequest.cancel(); checkUpgradeRequest = null; } checkUpgradeRequest = new HttpRequest(); checkUpgradeRequest.setListener(checkUpgradeResonseHandler); checkUpgradeRequest.sendRequest(VERSION_URL, Collections.singletonMap("version", getVersion()), true); if (!auto) { showLoadingDialog(); } } public String getApk() { return context.getApplicationInfo().publicSourceDir; } private ProgressDialog mProgressDialog; private void showLoadingDialog() { if (mProgressDialog == null) { mProgressDialog = new ProgressDialog( BaseActivity.getCurrentActivity()); mProgressDialog.setMessage(context .getString(R.string.progress_loading)); mProgressDialog.setCanceledOnTouchOutside(false); mProgressDialog.setCancelable(true); } mProgressDialog.show(); } private void dismissLoadingDialog() { if (mProgressDialog != null && mProgressDialog.isShowing()) { mProgressDialog.dismiss(); mProgressDialog = null; } } private void upgrade() { download(); } private void download(){ String formedUrl = upgradeInfo.url.toLowerCase(Locale.getDefault()); if (formedUrl.endsWith(".apk") || formedUrl.endsWith(".patch")) { apkDownloadHandler = new ApkDownloadHandler(context); startDownloadApkFileTask(apkDownloadHandler); } else { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.parse(upgradeInfo.url); intent.setData(uri); BaseActivity.getCurrentActivity().startActivity(intent); } } private void startDownloadApkFileTask(final ApkDownloadHandler handler) { task = new ApkDownloadTask(upgradeInfo, new ApkDownloadListener() { @Override public void onStart(String url) { downloading = true; handler.obtainMessage(ApkDownloadHandler.START, url).sendToTarget(); } @Override public void onSuccess(File apkFile) { UpgradeManager.this.apkFile = apkFile; handler.obtainMessage(ApkDownloadHandler.SUCCESS).sendToTarget(); clear(); } @Override public void onProgress(int downloadSize, int totalSize) { handler.obtainMessage(ApkDownloadHandler.PROGRESS, downloadSize, totalSize).sendToTarget(); } @Override public void onError() { handler.obtainMessage(ApkDownloadHandler.ERROR).sendToTarget(); clear(); } @Override public void onCancel() { handler.obtainMessage(ApkDownloadHandler.CANCEL).sendToTarget(); clear(); } }); new Thread(task).start(); } public void install(){ if(apkDownloadHandler != null){ apkDownloadHandler.cancelNotification(); } if(!upgradeInfo.patch || (upgradeInfo.patch && patch())){ _install(); } } private boolean patch(){ File old = new File(getApk()); File newFile = new File(upgradeInfo.patched_file); FileOutputStream fos = null; try { fos = new FileOutputStream(newFile); JBPatch.bspatch(old, fos, apkFile); } catch (IOException e) { e.printStackTrace(); } finally{ if(null != fos){ try { fos.close(); } catch (IOException e) { } } } if(!newFile.exists()){ Toast.makeText(context, "patching failed!", Toast.LENGTH_LONG).show(); return false; }else{ apkFile = newFile; return true; } } private void _install(){ Intent installIntent = new Intent(Intent.ACTION_VIEW) .setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); BaseActivity.getCurrentActivity().startActivity(installIntent); } private void clear(){ task = null; downloading = false; } public boolean isDownloading(){ return downloading; } public void cancel(){ if(task != null){ task.cancel(); } if(apkDownloadHandler != null){ apkDownloadHandler.cancelNotification(); } } }
true
3aaa1eb41713a448be27ebf747ee8c973dd29877
Java
koek67/receipt-ocr
/ocr-core/src/main/java/org/korosoft/javaocr/core/ImgUtil.java
UTF-8
2,576
3.234375
3
[]
no_license
package org.korosoft.javaocr.core; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; /** * Utility class fot basic {@link MutableImage} manipulations. * * @author Dmitry Korotkov * @since 1.0 */ public final class ImgUtil { /** * Loads mutable image from stream supported by {@link ImageIO#read(javax.imageio.stream.ImageInputStream)} method. * * @param stream Input stream. * @return read {@link MutableImage} * @throws IOException When UO exception occurs */ public static MutableImage readMutableImageFromSupportedStream(InputStream stream) throws IOException { final BufferedImage bufferedImage = ImageIO.read(stream); final int w = bufferedImage.getWidth(); final int h = bufferedImage.getHeight(); final byte[] pixels = new byte[w * h]; int p = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int rgb = bufferedImage.getRGB(x, y); int c1 = rgb & 0xff; int c2 = (rgb >> 8) & 0xff; int c3 = (rgb >> 16) & 0xff; int grayscale = (c1 + c2 + c3) / 3; if (grayscale > 255) { grayscale = 255; } pixels[p++] = (byte) grayscale; } } return new MutableImage(pixels, 0, 0, w, h); } /** * Converts image to printable text. Handy for debugging. * * @param image Image to convert. * @return ASCII image representation. */ public static String imageToText(MutableImage image) { StringBuilder builder = new StringBuilder((image.width + 1) * image.height); char pseudo[] = "█▓▒░▪◦·".toCharArray(); int p = image.firstPixel; for (int y = 0; y < image.height; y++) { for (int x = 0; x < image.width; x++) { int i = ((int) image.pixels[p] & 255) / (255 / pseudo.length); if (i < 0) { i = 0; } if (i >= pseudo.length) { i = pseudo.length - 1; } builder.append(pseudo[i]); p++; } builder.append("\n"); p += image.lineSpan; } return builder.toString(); } /** * Private constructor prevents instantiation */ private ImgUtil() { } }
true
105be280665bfeaa3ddbb6b07b51d014f45b43d4
Java
Mounnjide/Irecrutements
/Irecrutements/src/main/java/com/irecrutements/spring/dao/VilleDaoJdbc.java
UTF-8
4,154
2.515625
3
[]
no_license
package com.irecrutements.spring.dao; import java.util.List; import org.hibernate.Session; import org.hibernate.Transaction; import org.springframework.stereotype.Component; import com.irecrutements.spring.models.Remarque; import com.irecrutements.spring.models.Ville; import com.irecrutements.spring.utils.HibernateUtil; @Component public class VilleDaoJdbc implements VilleDao{ public VilleDaoJdbc() { } public int insert(Ville c) { Session session = null; Transaction tx = null; int id = -1; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); id = (Integer) session.save(c); session.flush(); tx.commit(); } catch (Exception e) { System.out.println(e.getMessage()); if (tx != null) tx.rollback(); return id; } finally { session.close(); } return id; } public int update(Ville c) { Session session = null; Transaction tx = null; int id = -1; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); session.update(c); session.flush(); tx.commit(); } catch (Exception e) { System.out.println(e.getMessage()); if (tx != null) tx.rollback(); return id; } finally { session.close(); } return 0; } public int delete(Ville c) { Session session = null; Transaction tx = null; int id = -1; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); session.delete(c); session.flush(); tx.commit(); } catch (Exception e) { System.out.println(e.getMessage()); if (tx != null) tx.rollback(); return id; } finally { session.close(); } return 0; } public List<Ville> selectAll() { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return session.createQuery("from Ville").list(); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } public Ville selectById(int id) { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return (Ville) session.get(Ville.class, id); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } public List<Ville> selectByNomVille(String nomVille) { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return session .createQuery( "from Ville where nomVille like :nomVille") .setParameter("nomVille", "%" + nomVille + "%").list(); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } @Override public Ville selectByNomVilleExact(String nomVille) { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return (Ville)session .createQuery( "from Ville where nomVille = :nomVille") .setParameter("nomVille", nomVille ).list().get(0); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } public List<Ville> selectByPaysVille(String paysVille) { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return session .createQuery( "from Ville where paysVille like :paysVille") .setParameter("paysVille", "%" + paysVille + "%").list(); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } public List<Ville> selectByNomPays(String nomVille, String paysVille) { Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); return session .createQuery( "from Ville where nomVille like :nomVille and paysVille like :paysVille") .setParameter("nomVille", "%" + nomVille + "%") .setParameter("paysVille", "%" + paysVille + "%").list(); } catch (Exception e) { System.out.println(e.getMessage()); return null; } finally { session.close(); } } }
true
fe7301a70d17584a2e6a5e39faa97d1c229c38c5
Java
krishnachandranes/devapi
/src/main/java/com/wncdevapi/devapi/service/CountyService.java
UTF-8
289
1.703125
2
[]
no_license
package com.wncdevapi.devapi.service; import java.util.List; import org.springframework.http.ResponseEntity; import com.wncdevapi.devapi.entity.County; public interface CountyService { County findById(Long id); County save(County county); List<County> findAll(); }
true
7c5fc1adc3cfdee090e3110a84b7ef250eb05044
Java
hnhy2001/office
/src/main/java/com/example/office/repository/UserRepository.java
UTF-8
465
1.96875
2
[]
no_license
package com.example.office.repository; import com.example.office.model.UserEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.List; public interface UserRepository extends JpaRepository<UserEntity,Integer> { @Override List<UserEntity> findAll(); UserEntity findAllByAcountAndPassword(String acount, String pass); UserEntity findAllByAcount(String acount); }
true
b6ec20cd04f80709ce4866ea1a808ef290cabd8d
Java
ashyonline/bluetoothtest
/app/src/main/java/com/codingbad/com/bluetoothtest/AppModule.java
UTF-8
1,090
2.109375
2
[]
no_license
package com.codingbad.com.bluetoothtest; import android.content.Context; import com.codingbad.com.bluetoothtest.mvp.MainContract; import com.codingbad.com.bluetoothtest.mvp.presenter.MainPresenter; import com.google.inject.AbstractModule; import com.google.inject.Provider; /** * Created by Ayelen Chavez on 07.03.16. * <p> * Module used for Guice configuration to inject objects * <p> * Mostly boilerplate code. */ public class AppModule extends AbstractModule { @Override protected void configure() { bind(Context.class).toProvider(new Provider<Context>() { @Override public Context get() { return BluetoothTestApplication.getContext(); } }); bind(BluetoothTestApplication.class).toProvider(new Provider<BluetoothTestApplication>() { @Override public BluetoothTestApplication get() { return (BluetoothTestApplication) BluetoothTestApplication.getAppContext(); } }); bind(MainContract.Presenter.class).to(MainPresenter.class); } }
true
9e0356b2b49bc81e90e6d38e3529e820b84f9597
Java
ksksks2222/pl-workspace
/dzpw/dzpw-dealer-client/src/main/java/hg/dzpw/dealer/client/api/v1/response/PayToTicketOrderResponse.java
UTF-8
901
2.046875
2
[]
no_license
package hg.dzpw.dealer.client.api.v1.response; import hg.dzpw.dealer.client.common.ApiResponse; /** * @类功能说明:确认支付结果 * @类修改者: * @修改日期:2014-11-26上午11:17:17 * @修改说明: * @公司名称:浙江汇购科技有限公司 * @作者:zhurz * @创建时间:2014-11-26上午11:17:17 */ @SuppressWarnings("serial") public class PayToTicketOrderResponse extends ApiResponse { /** 订单不存在 */ public final static String RESULT_ORDER_NOT_EXISTS = "-1"; /** 支付失败 */ public final static String RESULT_PAY_ERROR = "-2"; /** 余额不足 */ public final static String RESULT_MONEY_NOT_ENOUGH = "-3"; /** 不能为已经关闭的订单付款 */ public final static String RESULT_ORDER_CLOSED = "-4"; /** 不能为已经付款的订单付款 */ public final static String RESULT_ORDER_PAID = "-5"; }
true
70fc218ca53db2cd8ff867b6640b316c90d0b662
Java
Pbergkvist/Timeline
/src/beans/BackingBean.java
UTF-8
3,238
2.171875
2
[]
no_license
package beans; import javax.ejb.EJB; import javax.enterprise.context.SessionScoped; import javax.inject.Named; import java.io.Serializable; import java.util.List; @Named @SessionScoped public class BackingBean implements Serializable { @EJB private QueryBean theQuery; private List<EventEntity> event; private String userName; private String password; private LoginEntity resultLE; private boolean visible; // Event private int year; private String headline; private String description; private int newYear; public int getNewYear() { return newYear; } public void setNewYear(int newYear) { this.newYear = newYear; } // update meny private List<EventEntity> theYears; public List<EventEntity> getTheYears() { return theQuery.getListOfYears(); } public void setTheYears(List<EventEntity> theYears) { this.theYears = theYears; } private int selectedyear; public int getSelectedyear() { return selectedyear; } public void setSelectedyear(int selectedyear) { this.selectedyear = selectedyear; } public void addEvent() { theQuery.addEvent(year, headline, description); visible = false; } public void deleteEvent() { theQuery.deleteEvent(selectedyear); visible = false; } public void updateEvent() { theQuery.updateEvent(selectedyear, newYear, headline, description); } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public String getHeadline() { return headline; } public void setHeadline(String headline) { this.headline = headline; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } // public void show(){ visible=true; } public void hide(){ visible=false; } public boolean isVisible() { return visible; } public void setVisible(boolean visible) { this.visible = visible; } public LoginEntity getResultLE() { return resultLE; } public void setResultLE(LoginEntity resultLE) { this.resultLE = resultLE; } public String searchUser() { resultLE = theQuery.getUsers(userName, password); if (resultLE != null) { return "admin"; } else { return "error"; } } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public QueryBean getTheQuery() { return theQuery; } public void setTheQuery(QueryBean theQuery) { this.theQuery = theQuery; } public List<EventEntity> getEvent() { return theQuery.getListOfEvents(); } public void setEvent(List<EventEntity> event) { this.event = event; } }
true
302485757dafde165f74dc135e083cc3655f41b1
Java
inter6/smtp-sender
/src/main/java/com/inter6/mail/gui/component/DatePanel.java
UTF-8
1,588
2.734375
3
[ "Apache-2.0" ]
permissive
package com.inter6.mail.gui.component; import com.inter6.mail.model.component.DateData; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; public class DatePanel extends JPanel { private static final long serialVersionUID = 4260562530907366011L; private final JCheckBox useCheckBox = new JCheckBox(); private final JTextField textField = new JTextField(20); private final JCheckBox nowCheckBox = new JCheckBox("Now"); public DatePanel(String label, int columns, boolean isUse, boolean isNow) { super(new FlowLayout(FlowLayout.LEFT)); this.useCheckBox.setSelected(isUse); this.useCheckBox.setText(label); this.add(this.useCheckBox); this.textField.setEnabled(!isNow); this.textField.setColumns(columns); this.add(this.textField); this.nowCheckBox.setSelected(isNow); this.nowCheckBox.addActionListener(this.createNowEvent()); this.add(this.nowCheckBox); } private ActionListener createNowEvent() { return event -> DatePanel.this.textField.setEnabled(!DatePanel.this.nowCheckBox.isSelected()); } public DateData getDateData() { DateData dateData = new DateData(); dateData.setUse(this.useCheckBox.isSelected()); dateData.setText(this.textField.getText()); dateData.setNow(this.nowCheckBox.isSelected()); return dateData; } public void setDateData(DateData dateData) { if (dateData == null) { return; } this.useCheckBox.setSelected(dateData.isUse()); this.textField.setText(dateData.getText()); this.textField.setEnabled(!dateData.isNow()); this.nowCheckBox.setSelected(dateData.isNow()); } }
true
834c4d978ba2ace4f68fc4d958e141b4f16cd1f0
Java
Hy-Lm/good_garden_java
/service/service_img/src/main/java/com/yiyuan/imgservice/controller/CarimgController.java
UTF-8
934
1.765625
2
[]
no_license
package com.yiyuan.imgservice.controller; import com.yiyuan.imgservice.entity.Carimg; import com.yiyuan.imgservice.service.CarimgService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * <p> * 前端控制器 * </p> * * @author testjava * @since 2021-08-31 */ @RestController @CrossOrigin //解决跨域 @RequestMapping("/imgservice/carimg") public class CarimgController { //注入 @Autowired private CarimgService carimgService; //查询全部 @GetMapping("findImg") public List<Carimg> findImg(){ System.out.println("11111111111111"); return carimgService.list(null); } // }
true
bfd2fd1665383698e016e96552ba99ebd84804d9
Java
LakeShire/Discounts
/app/src/main/java/com/github/lakeshire/discounts/fragment/RegisterFragment.java
UTF-8
3,492
2.265625
2
[]
no_license
package com.github.lakeshire.discounts.fragment; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import com.alibaba.fastjson.JSON; import com.github.lakeshire.discounts.R; import com.github.lakeshire.discounts.manager.UserManager; import com.github.lakeshire.discounts.model.User; import com.github.lakeshire.lemon.fragment.base.DBaseFragment; import com.github.lakeshire.lemon.util.HttpUtil; import java.io.IOException; public class RegisterFragment extends DBaseFragment { private EditText mEtName; private EditText mEtPassword; private Button mBtnRegister; private EditText mEtEmail; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public int getLayoutId() { return R.layout.fragment_login; } @Override protected void initUI() { setTitle("注册"); mEtName = (EditText) find(R.id.et_name); mEtPassword = (EditText) find(R.id.et_password); mEtEmail = (EditText) find(R.id.et_email); mBtnRegister = (Button) find(R.id.btn_register); mBtnRegister.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = mEtName.getText().toString(); String password = mEtPassword.getText().toString(); final User user = new User(name, password); try { HttpUtil.getInstance().post("http://lakeshire.top/users/add", JSON.toJSONString(user), new HttpUtil.Callback() { @Override public void onFail(String error) { if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getActivity(), "注册失败", Toast.LENGTH_SHORT).show(); } }); } } @Override public void onSuccess(final String response) { if (getActivity() != null) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (response.equals("Error")) { Toast.makeText(getActivity(), "注册失败", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), "注册成功", Toast.LENGTH_SHORT).show(); UserManager.setUser(user); endFragment(); } } }); } } }, 0); } catch (IOException e) { e.printStackTrace(); } } }); } @Override public void loadData() { super.loadData(); } }
true
990b3a4c1a22e519721c3ba0f9ccb8d3ba9522df
Java
Song-1/sync-tool
/songFile/src/cn/com/musicone/www/counts/service/CountQueryService.java
UTF-8
736
1.84375
2
[]
no_license
/** * */ package cn.com.musicone.www.counts.service; import java.util.List; import cn.com.musicone.www.counts.model.CountModel; import cn.com.musicone.www.counts.model.SearchReqLogModel; /** * @author Administrator * */ public interface CountQueryService { public List<CountModel> querySingerCountsByDate(SearchReqLogModel qbo)throws Exception; public void addSingerCountLog(List<CountModel> datas)throws Exception; public void addAlbumCountLog(List<CountModel> datas)throws Exception; public void addSongCountLog(List<CountModel> datas)throws Exception; public void addAlbumsCountLog(CountModel data) throws Exception; public CountModel countAlbumCollect(SearchReqLogModel qbo) throws Exception; }
true
7df438175afac3fc4e2c4a888112b8e68f9df117
Java
swara12262/DSAGeeksForGeeks
/Dynamic Programming/CoinChange.java
UTF-8
786
2.90625
3
[]
no_license
import java.util.*; public class CoinChangeProblem { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] a=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } int sum=sc.nextInt(); int[][] dp=new int[sum+1][n+1]; for(int i=0;i<=n;i++) dp[0][i] = 1; for(int i=1;i<=sum;i++) dp[i][0]=0; for(int i=1;i<=sum;i++) { for(int j=1;j<=n;j++) { dp[i][j]=dp[i][j-1]; if(i>=a[j-1]) { dp[i][j] +=dp[i-a[j-1]][j]; } } } System.out.println(dp[sum][n]+""); } }
true
724e0b0e34a6948fa488b229d9ec3783b954a1b5
Java
hfqin/Algorithms_lab_pj
/Algorithms_Project2/src/ZobristTable.java
UTF-8
543
3.203125
3
[]
no_license
/* * Zobrist表,player表示是哪方玩家,table[i][j]表示棋子i在j位置时的键值,用RC4 * 算法生成,保证其随机性 */ public class ZobristTable { Zobrist player; Zobrist[][] table = new Zobrist[14][100]; public ZobristTable() { RC4password rc4password = new RC4password(); rc4password.initial(); player = new Zobrist(); player.initial(rc4password); for (int i=0;i<14;i++) { for (int j=0;j<100;j++) { table[i][j] = new Zobrist(); table[i][j].initial(rc4password); } } } }
true
538f09da4622c11a9543e389003de5ea566ea665
Java
ruusey/JRelay
/JRelay/app/com/packets/server/ShowEffectPacket.java
UTF-8
1,000
2.421875
2
[]
no_license
package com.packets.server; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import com.data.shared.Location; import com.models.Packet; public class ShowEffectPacket extends Packet { public int effectType; public int targetObjectId; public Location pos1 = new Location(); public Location pos2 = new Location(); public int color; public float duration; @Override public void parseFromInput(DataInput in) throws IOException { this.effectType = in.readUnsignedByte(); this.targetObjectId = in.readInt(); this.pos1.parseFromInput(in); this.pos2.parseFromInput(in); this.color = in.readInt(); this.duration=in.readFloat(); } @Override public void writeToOutput(DataOutput out) throws IOException { out.writeByte(this.effectType); out.writeInt(this.targetObjectId); this.pos1.writeToOutput(out); this.pos2.writeToOutput(out); out.writeInt(this.color); out.writeFloat(this.duration); } }
true
3b0387c791fe41ab20f4f7bac3745817654154c4
Java
balaramhub1/RestAssured_proj2
/src/test/java/localAPI_test/LocalAPI_PATCH_Test01.java
UTF-8
846
2.171875
2
[]
no_license
package localAPI_test; import org.testng.annotations.Test; import io.restassured.http.ContentType; import static io.restassured.RestAssured.*; import static io.restassured.matcher.RestAssuredMatchers.*; import static org.hamcrest.Matchers.*; import org.json.simple.JSONObject; public class LocalAPI_PATCH_Test01 { @Test(description="PATCH request to upate a user information based on id") public void Test_01_PATCH() { baseURI="http://localhost:3000"; // Change information for user with id 102 String endPoint="/users/102"; JSONObject jsonReq=new JSONObject(); jsonReq.put("lastName", "Manu"); given(). header("Content-Type", "application/json"). contentType(ContentType.JSON). accept(ContentType.JSON). body(jsonReq). when(). patch(endPoint). then(). statusCode(200). log().all(); } }
true
78af44adda05226efd96d195bbcd0f1e0ffde6bb
Java
wenbin8/PractiseCode
/src/com/wenbin/base/genrice/my/GenericInterface.java
UTF-8
141
2.09375
2
[]
no_license
package com.wenbin.base.genrice.my; /** * Created by wenbin on 2017/12/30. */ public interface GenericInterface<T, E> { T get(E e); }
true
14acc25cb57fa31a818d9d17d5cc80dfad0a0039
Java
matthew-serretta/Sheep-and-Wolves
/src/RabbitAdapter.java
UTF-8
1,216
2.734375
3
[]
no_license
import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.imageio.ImageIO; import bos.NoMove; import bos.RelativeMove; // the rabbit character serves no purpose in game, it is only used to display the adapter design patter and use of threads // adapter work is done in the RabbitMovementThread class // the rabbit class is intentionally poorly designed to make movements take longer, resulting in poor response time and therefore the need for threads public class RabbitAdapter extends Character { // due to the time it takes to determine the rabbit's next move, we store them // here in advance public List<RelativeMove> nextMoves = new ArrayList<RelativeMove>(); public RabbitAdapter(Cell location) { super(location, new StandStill()); try { display = Optional.of(ImageIO.read(new File("rabbit.png"))); } catch (Exception e) { display = Optional.empty(); } } // if available, return the next move the rabbit should make @Override public RelativeMove aiMove() { if (nextMoves.size() < 1) return new NoMove(Grid.getGrid(), this); else { RelativeMove move = nextMoves.get(0); nextMoves.remove(0); return move; } } }
true
94ff9c98ebb95a93dbac28c79a1019b46310e46f
Java
zhaoqin1234/javaEE
/src/main/java/com/hrxt/controller/OilJCJHController.java
UTF-8
27,395
1.9375
2
[]
no_license
package com.hrxt.controller; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFCellStyle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import com.alibaba.fastjson.JSON; import com.hrxt.pojo.Csjh; import com.hrxt.pojo.MonthPZ; import com.hrxt.pojo.OilJCJH; import com.hrxt.pojo.Page; import com.hrxt.service.OilJCJHService; import com.hrxt.utils.ExcelUtil; import com.hrxt.utils.JSONutils; /** * 油井检测计划 controller * @author ZhaoQin * */ @Controller @RequestMapping("/oiljcjh") public class OilJCJHController { @Autowired private OilJCJHService oilJCJHService; @RequestMapping("/insert") @ResponseBody public String insetOilJCJH(OilJCJH oilJCJH){ Map<String,Object> map = this.oilJCJHService.insertOrUpdate(oilJCJH); return JSON.toJSONString(map); } @RequestMapping("/insertList") @ResponseBody public String insetOilJCJHList( OilJCJH oilJCJH){ List<OilJCJH> list11 = new ArrayList<OilJCJH>(); list11.add(oilJCJH); List<String> list = oilJCJHService.batchInsertOrUpdate(list11); return JSONutils.Object2String(list); } @RequestMapping("/delOneOilJCJH") @ResponseBody public String delOneOilJCJH(String seq){ Map<String,Object> map = this.oilJCJHService.delOneOilJCJH(seq); return JSON.toJSONString(map); } @RequestMapping("/delOilJCJHList") @ResponseBody public String delOilJCJHList(String seqlist){ Map<String,Object> map = this.oilJCJHService.delListOilJCJH(seqlist); return JSON.toJSONString(map); } @RequestMapping("/getOilJCJHList") @ResponseBody public String getOilJCJHList(OilJCJH oilJCJH,Page<List<OilJCJH>> page){ return JSONutils.Object2String(oilJCJHService.getOilJCJHList(oilJCJH, page)); } /** * 记录审核 方法 * @param seqlist * @return */ @RequestMapping("/auditOilJCJH") @ResponseBody public String auditOilJCJH(String seqlist){ return oilJCJHService.auditOneOilJCJH(seqlist); } @RequestMapping("/unAuditOilJCJH") @ResponseBody public String unAuditOilJCJH(String seqlist){ return oilJCJHService.unAuditOneOilJCJH(seqlist); } /** * 【提交】 方法 * @param seqlist * @return */ @RequestMapping("/submitOilJCJH") @ResponseBody public String submitMonthPZ(String seqlist){ return oilJCJHService.submitOilJCJH(seqlist); } @RequestMapping("/unSubmitOilJCJH") @ResponseBody public String unSubmitOilJCJH(String seqlist){ return oilJCJHService.unSubmitOilJCJH(seqlist); } /** * 批量上传数据 * @param fileMult * @param fileName * @return */ @RequestMapping("/excelUpdateOilJCJH") @ResponseBody public String updateOilJCJHList(MultipartFile fileMult,String fileName){ List<Map<String, Object>> list = null; if(fileMult==null) { //System.out.println("没有数据流"); return "没有数据流"; } try { String name = fileMult.getOriginalFilename(); InputStream is = fileMult.getInputStream(); //System.out.println(name+is); String [] fileds = {"site_name","yc_name","well_name","cs_type_name", "stime","well_section","thickness","plies_num","cs_purpose", "cs_claim","last_success_date","recently_fail_date", "recently_revise_mesg","level_demand","tc_date","fk_cd_date", "wcd_mesg","success_date","fail_mesg"}; if(is != null) { //sheet0 第一行 iostream 传入文件名 读取字段名字 list = ExcelUtil.getDataListByexcel(0, 1, is, name, fileds); } } catch (Exception e) { e.printStackTrace(); } for (int i = 0; i < list.size(); i++) { Map<String, Object> map = list.get(i); OilJCJH oilJCJH = new OilJCJH(); oilJCJH.setSite_name((String)map.get("site_name")); oilJCJH.setYc_name((String)map.get("yc_name")); oilJCJH.setWell_name((String)map.get("well_name")); oilJCJH.setCs_type_name((String)map.get("cs_type_name")); oilJCJH.setStime(map.get("stime")!=null&&!"".equals(map.get("stime"))?((String)map.get("stime")).substring(0, 7):""); oilJCJH.setWell_section((String)map.get("well_section")); oilJCJH.setThickness(map.get("thickness")!=null&&!"".equals(map.get("thickness"))?Double.parseDouble((String)map.get("thickness")):0); oilJCJH.setPlies_num(map.get("plies_num")!=null&&!"".equals(map.get("plies_num"))?Integer.parseInt((String)map.get("plies_num")):0); oilJCJH.setCs_purpose((String)map.get("cs_purpose")); oilJCJH.setCs_claim((String)map.get("cs_claim")); oilJCJH.setLast_success_date((String)map.get("last_success_date")); oilJCJH.setRecently_fail_date((String)map.get("recently_fail_date")); oilJCJH.setRecently_revise_mesg((String)map.get("recently_revise_mesg")); oilJCJH.setLevel_demand((String)map.get("level_demand")); DateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); String date=fmt.format(new Date()); oilJCJH.setTc_date((String)map.get("tc_date")!=null&&(String)map.get("tc_date")!=""?(String)map.get("tc_date"):date); oilJCJH.setFk_cd_date((String)map.get("fk_cd_date")); oilJCJH.setWcd_mesg((String)map.get("wcd_mesg")); oilJCJH.setSuccess_date((String)map.get("success_date")); oilJCJH.setFail_mesg((String)map.get("fail_mesg")); this.oilJCJHService.insertOrUpdate(oilJCJH); } return ""; } /** * 下载导入模板 措施计划, */ @RequestMapping("/dwnloadOilJCJHTmp") public void dwnloadTmpMB(OilJCJH oilJCJH,HttpServletResponse response,String fileName){ //获取措施计划数据 List<OilJCJH> datalist = this.oilJCJHService.getOilJCJHExcelMoBan(oilJCJH); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("信息表"); if(fileName == null) { fileName = "措施计划";//设置要导出的文件的名字 } //新增数据行,并且设置单元格数据 int rowNum = 1; String[] headers = { "工区", "油藏", "井号", "测试类型","措施月份(yyyy-mm)","生产井段(m)","厚度(m)","层数(t)","测试目的","测试要求", "上次测成时间","(最近一次)未测成时间","(最近一次)整改情况","需求程度","提出日期(默认当前)","出单日期","未出单原因","测成日期","未测成原因"}; sheet.setColumnWidth(0, 35*150); sheet.setColumnWidth(1, 35*150); sheet.setColumnWidth(2, 35*150); sheet.setColumnWidth(3, 35*150); sheet.setColumnWidth(4, 35*150); sheet.setColumnWidth(5, 35*150); sheet.setColumnWidth(6, 35*150); sheet.setColumnWidth(7, 35*150); sheet.setColumnWidth(8, 35*150); sheet.setColumnWidth(9, 35*150); sheet.setColumnWidth(10, 35*150); sheet.setColumnWidth(11, 35*150); sheet.setColumnWidth(12, 35*150); sheet.setColumnWidth(13, 35*150); sheet.setColumnWidth(14, 35*150); sheet.setColumnWidth(15, 35*150); sheet.setColumnWidth(16, 35*150); sheet.setColumnWidth(17, 35*150); sheet.setColumnWidth(18, 35*150); //headers表示excel表中第一行的表头 HSSFRow row = sheet.createRow(0); //在excel表中添加表头 for(int i=0;i<headers.length;i++){ HSSFCell cell = row.createCell(i); HSSFRichTextString text = new HSSFRichTextString(headers[i]); cell.setCellValue(text); } //在表中存放查询到的数据放入对应的列 for (OilJCJH csjhTmp : datalist) { HSSFRow row1 = sheet.createRow(rowNum); row1.createCell(0).setCellValue(csjhTmp.getSite_name()); row1.createCell(1).setCellValue(csjhTmp.getYc_name()); row1.createCell(2).setCellValue(csjhTmp.getWell_name()); /* row1.createCell(5).setCellValue(csjhTmp.getWell_section()); //井段 row1.createCell(6).setCellValue(csjhTmp.getThickness()); //厚度 row1.createCell(7).setCellValue(csjhTmp.getPlies_num()); //层数 */ rowNum++; } response.setContentType("application/octet-stream"); String newFileName = ""; try { newFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } response.setHeader("Content-disposition", "attachment;filename=" + newFileName+ ".xls"); try { response.flushBuffer(); workbook.write(response.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } } /** * 监测计划报表查询 油水井都包含了 * 根据类型查询 */ @RequestMapping("getOilJCJHBBByType") @ResponseBody public List<OilJCJH> getOilJCJHBBByType(String site_id ,String date){ List<OilJCJH> datalist = this.oilJCJHService.getOilJCJHReport(site_id, date); int sumWell=0; for (OilJCJH oilJCJH : datalist) { if(oilJCJH.getCs_type_name().equals("小计")){ String wellNum = oilJCJH.getWell_name(); if(wellNum!=null&&!"".equals(wellNum)){ sumWell +=Integer.parseInt(wellNum); oilJCJH.setWell_name(wellNum+"口"); } } } OilJCJH oilJCJH2=new OilJCJH(); oilJCJH2.setCs_type_name("总计"); oilJCJH2.setWell_name(sumWell+"口"); datalist.add(oilJCJH2); return datalist; } /** * 检测计划 报表下载 * site_id: 工区id,逗号分隔 * date:时间 yyyy-mm * @throws IOException * @throws ParseException */ @RequestMapping("/dwnloadOilJCJHReport") public void dwnloadOilJcjhReport(String site_id,String siteNames, String date ,HttpServletResponse response,String fileName) throws IOException, ParseException{ if(siteNames==null||"".equals(siteNames)||"undefined".equals(siteNames)){ siteNames="饶阳工区,河间工区,三厂合作,留北工区,宁北工区,留西工区,肃宁工区,武强工区"; } SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM"); SimpleDateFormat fmt2=new SimpleDateFormat("yyyy年MM月"); Date parse = fmt.parse(date); String date2 = fmt2.format(parse); String sheetName = "测试计划井号"; String[] title1 = { "项目", "测试内容", "井号", "生产井段(m)", "厚度(m)", "层数","测试","","上次测成时间","最近一次","","需求程度","提出日期","生产反馈意见","",""}; String[] title2 = { "","","","","","","目的", "要求(层内打点位置等)","", "未测成时间", "整改情况", "","","出单日期", "未出单原因","测成日期及未测成原因"}; HSSFWorkbook wb = null; // 第一步,创建一个HSSFWorkbook,对应一个Excel文件 if (wb == null) { wb = new HSSFWorkbook(); } // 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet HSSFSheet sheet = wb.createSheet(sheetName); sheet.setColumnWidth((short) 0, 2500); sheet.setColumnWidth((short) 1, 2500); sheet.setColumnWidth((short) 2, 5000); sheet.setColumnWidth((short) 3, 5000); sheet.setColumnWidth((short) 4, 2500); sheet.setColumnWidth((short) 5, 2500); sheet.setColumnWidth((short) 6, 15000); sheet.setColumnWidth((short) 7, 8000); sheet.setColumnWidth((short) 8, 7000); sheet.setColumnWidth((short) 9, 5000); sheet.setColumnWidth((short) 10, 5000); sheet.setColumnWidth((short) 11, 3000); sheet.setColumnWidth((short) 12, 3000); sheet.setColumnWidth((short) 13, 3000); sheet.setColumnWidth((short) 14, 3000); sheet.setColumnWidth((short) 15, 8000); //表头样式 1 开始 HSSFFont titleFont = wb.createFont(); titleFont.setFontName("微软雅黑"); titleFont.setFontHeightInPoints((short) 16);// 字号 titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗 // 第四步,创建单元格,并设置值表头 设置表头居中 HSSFCellStyle style = wb.createCellStyle(); // 表格内容样式 style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 垂直 style.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框 style.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框 style.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框 style.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框 style.setWrapText(true); // 设置换行 style.setFont(titleFont); //表头样式2 开始 HSSFFont titleFont2 = wb.createFont(); titleFont2.setFontName("宋体"); titleFont2.setFontHeightInPoints((short) 11);// 字号 titleFont2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗 HSSFCellStyle style2 = wb.createCellStyle(); // 表格内容样式 style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style2.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 垂直 style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框 style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框 style2.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框 style2.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框 style2.setWrapText(true); // 设置换行 style2.setFont(titleFont2); //内容样式3开始 HSSFFont font= wb.createFont(); font.setFontName("宋体"); font.setFontHeightInPoints((short) 11);// 字号 //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗 HSSFCellStyle style3 = wb.createCellStyle(); // 表格内容样式 style3.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style3.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 垂直 style3.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框 style3.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框 style3.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框 style3.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框 style3.setWrapText(true); // 设置换行 style3.setFont(font); // 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制 HSSFRow row = sheet.createRow(0); row.setHeight((short) 800); HSSFCell createCell = row.createCell(0); createCell.setCellValue(siteNames+date2+"测试计划井号"); createCell.setCellStyle(style); sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 2, 2)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 3, 3)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 4, 4)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 5, 5)); sheet.addMergedRegion(new CellRangeAddress(1, 1, 6, 7)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 8, 8)); sheet.addMergedRegion(new CellRangeAddress(1, 1, 9, 10)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 11, 11)); sheet.addMergedRegion(new CellRangeAddress(1, 2, 12, 12)); sheet.addMergedRegion(new CellRangeAddress(1, 1, 13, 15)); sheet.addMergedRegion(new CellRangeAddress(0,0, 0, 15)); HSSFRow row1 = sheet.createRow(1); HSSFRow row2 = sheet.createRow(2); // 声明列对象 HSSFCell cell = null; // 创建标题 for (int i = 0; i < title1.length; i++) { cell = row1.createCell(i); cell.setCellValue(title1[i]); cell.setCellStyle(style2); } for (int i = 0; i < title2.length; i++) { cell = row2.createCell(i); cell.setCellValue(title2[i]); cell.setCellStyle(style2); } //获取措施计划数据 List<OilJCJH> datalist = this.oilJCJHService.getOilJCJHReport(site_id, date); int sumWell=0; for (OilJCJH oilJCJH : datalist) { if(oilJCJH.getCs_type_name().equals("小计")){ String wellNum = oilJCJH.getWell_name(); if(wellNum!=null&&!"".equals(wellNum)){ sumWell +=Integer.parseInt(wellNum); oilJCJH.setWell_name(wellNum+"口"); } } } OilJCJH oilJCJH2=new OilJCJH(); oilJCJH2.setCs_type_name("总计"); oilJCJH2.setWell_name(sumWell+"口"); datalist.add(oilJCJH2); String xm = ""; String testType=""; int stratRowNum = 3; int stratRowNumType = 3; int endNum=0; int endNumType=0; // 创建内容 for (int i = 0; i < datalist.size(); i++) { //动态合并内容相同的行 if(i==0){ xm = datalist.get(i).getXm(); testType = datalist.get(i).getCs_type_name(); } //动态合并内容相同的行 if(!xm.equals(datalist.get(i).getXm())){ if(stratRowNum<endNum){ sheet.addMergedRegion(new CellRangeAddress(stratRowNum,endNum,0, 0)); } xm = datalist.get(i).getXm();; stratRowNum=i+3; }else if(xm.equals(datalist.get(i).getXm())){ endNum=i+3; if(xm.equals(datalist.get(i).getXm())&&i==datalist.size()-1){ sheet.addMergedRegion(new CellRangeAddress(stratRowNum,endNum,0, 0)); } } if(!testType.equals(datalist.get(i).getCs_type_name())){ if(stratRowNumType<endNumType){ sheet.addMergedRegion(new CellRangeAddress(stratRowNumType,endNumType,1, 1)); } testType = datalist.get(i).getCs_type_name(); stratRowNumType=i+3; }else if(testType.equals(datalist.get(i).getCs_type_name())){ endNumType=i+3; if(testType.equals(datalist.get(i).getCs_type_name())&&i==datalist.size()-1){ sheet.addMergedRegion(new CellRangeAddress(stratRowNumType,endNumType,1, 1)); } } row = sheet.createRow(i + 3); HSSFCell createCell0 = row.createCell(0); HSSFCell createCell1 = row.createCell(1); HSSFCell createCell2 = row.createCell(2); HSSFCell createCell3 = row.createCell(3); HSSFCell createCell4 = row.createCell(4); HSSFCell createCell5 = row.createCell(5); HSSFCell createCell6 = row.createCell(6); HSSFCell createCell7 = row.createCell(7); HSSFCell createCell8 = row.createCell(8); HSSFCell createCell9 = row.createCell(9); HSSFCell createCell10 = row.createCell(10); HSSFCell createCell11= row.createCell(11); HSSFCell createCell12= row.createCell(12); HSSFCell createCell13 = row.createCell(13); HSSFCell createCell14= row.createCell(14); HSSFCell createCell15= row.createCell(15); createCell0.setCellValue(datalist.get(i).getXm()); createCell1.setCellValue(datalist.get(i).getCs_type_name()); createCell2.setCellValue(datalist.get(i).getWell_name()); createCell3.setCellValue(datalist.get(i).getWell_section()); createCell4.setCellValue(datalist.get(i).getThickness() == null?"":datalist.get(i).getThickness()+""); createCell5.setCellValue(datalist.get(i).getPlies_num() == null?"":datalist.get(i).getPlies_num()+""); createCell6.setCellValue(datalist.get(i).getCs_purpose()); createCell7.setCellValue(datalist.get(i).getCs_claim()); createCell8.setCellValue(datalist.get(i).getLast_success_date()); createCell9.setCellValue(datalist.get(i).getRecently_fail_date()); createCell10.setCellValue(datalist.get(i).getRecently_revise_mesg()); createCell11.setCellValue(datalist.get(i).getLevel_demand()==null?"":datalist.get(i).getLevel_demand()+""); createCell12.setCellValue(datalist.get(i).getTc_date()); createCell13.setCellValue(datalist.get(i).getFk_cd_date()); createCell14.setCellValue(datalist.get(i).getWcd_mesg()); createCell15.setCellValue(datalist.get(i).getSjyy()); createCell0.setCellStyle(style3); createCell1.setCellStyle(style3); createCell2.setCellStyle(style3); createCell3.setCellStyle(style3); createCell4.setCellStyle(style3); createCell5.setCellStyle(style3); createCell6.setCellStyle(style3); createCell7.setCellStyle(style3); createCell8.setCellStyle(style3); createCell9.setCellStyle(style3); createCell10.setCellStyle(style3); createCell11.setCellStyle(style3); createCell12.setCellStyle(style3); createCell13.setCellStyle(style3); createCell14.setCellStyle(style3); createCell15.setCellStyle(style3); } OutputStream output = response.getOutputStream(); response.reset(); response.setHeader("Content-disposition","attachment; filename=ceshijihua.xls"); response.setContentType("application/msexcel"); wb.write(output); output.flush(); output.close(); } /** * 导出数据 * @param oilJCJH * @param page * @param response * @param fileName */ @RequestMapping("/dwnloadQueryData") public void dwnloadQueryData(OilJCJH oilJCJH,Page<List<OilJCJH>> page,HttpServletResponse response,String fileName){ //获取配注的计划信息 Map<String,Object> map = this.oilJCJHService.getOilJCJHList(oilJCJH, page); List<OilJCJH> datalist = (List<OilJCJH>)map.get("data"); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("信息表"); if(fileName == null) { fileName = "油井监测计划数据导出" ;//设置要导出的文件的名字 } //新增数据行,并且设置单元格数据 int rowNum = 1; String[] headers = { "工区", "油藏", "井名", "测试内容","测试类型","措施计划月份","生产井段(m)","厚度(m)","层数(t)","测试目的","测试要求","上次测成时间", "(最近一次)未测成时间","(最近一次整改情况","需求程度","提出日期","出单日期","未出单原因","测成日期","未测成原因","提交状态","审核状态"}; //设置列宽 sheet.setColumnWidth(0, 35*150); sheet.setColumnWidth(1, 35*150); sheet.setColumnWidth(2, 35*150); sheet.setColumnWidth(3, 35*150); sheet.setColumnWidth(4, 35*150); sheet.setColumnWidth(5, 35*150); sheet.setColumnWidth(6, 35*150); sheet.setColumnWidth(7, 35*150); sheet.setColumnWidth(8, 35*150); sheet.setColumnWidth(9, 35*150); sheet.setColumnWidth(10, 35*150); sheet.setColumnWidth(11, 35*150); sheet.setColumnWidth(12, 35*150); sheet.setColumnWidth(13, 35*150); sheet.setColumnWidth(14, 35*150); sheet.setColumnWidth(15, 35*150); sheet.setColumnWidth(16, 35*150); sheet.setColumnWidth(17, 35*150); sheet.setColumnWidth(18, 35*150); sheet.setColumnWidth(19, 35*150); sheet.setColumnWidth(20, 35*150); sheet.setColumnWidth(21, 35*150); //headers表示excel表中第一行的表头 //表头样式2 开始 HSSFFont titleFont2 = workbook.createFont(); titleFont2.setFontName("宋体"); titleFont2.setFontHeightInPoints((short) 11);// 字号 titleFont2.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗 HSSFCellStyle style2 = workbook.createCellStyle(); // 表格内容样式 style2.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style2.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 垂直 style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框 style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框 style2.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框 style2.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框 style2.setWrapText(true); // 设置换行 style2.setFont(titleFont2); //内容样式3开始 HSSFFont font= workbook.createFont(); font.setFontName("宋体"); font.setFontHeightInPoints((short) 11);// 字号 //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);// 加粗 HSSFCellStyle style3 = workbook.createCellStyle(); // 表格内容样式 style3.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式 style3.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 垂直 style3.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框 style3.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框 style3.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框 style3.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框 style3.setWrapText(true); // 设置换行 style3.setFont(font); HSSFRow row = sheet.createRow(0); //在excel表中添加表头 for(int i=0;i<headers.length;i++){ HSSFCell cell = row.createCell(i); cell.setCellStyle(style2); HSSFRichTextString text = new HSSFRichTextString(headers[i]); cell.setCellValue(text); } //在表中存放查询到的数据放入对应的列 for (OilJCJH welltmp : datalist) { HSSFRow row1 = sheet.createRow(rowNum); row1.createCell(0).setCellValue(welltmp.getSite_name()); row1.createCell(1).setCellValue(welltmp.getYc_name()); row1.createCell(2).setCellValue(welltmp.getWell_name()); row1.createCell(3).setCellValue(welltmp.getCs_explaim()); row1.createCell(4).setCellValue(welltmp.getCs_type_name()); row1.createCell(5).setCellValue(welltmp.getStime()); row1.createCell(6).setCellValue(welltmp.getWell_section()); row1.createCell(7).setCellValue(welltmp.getThickness()); row1.createCell(8).setCellValue(welltmp.getPlies_num()==null?"":welltmp.getPlies_num()+""); row1.createCell(9).setCellValue(welltmp.getCs_purpose()); row1.createCell(10).setCellValue(welltmp.getCs_claim()); row1.createCell(11).setCellValue(welltmp.getLast_success_date()); row1.createCell(12).setCellValue(welltmp.getRecently_fail_date()); row1.createCell(13).setCellValue(welltmp.getRecently_revise_mesg()); row1.createCell(14).setCellValue(welltmp.getLevel_demand()==null?"":welltmp.getLevel_demand()+""); row1.createCell(15).setCellValue(welltmp.getTc_date()); row1.createCell(16).setCellValue(welltmp.getFk_cd_date()); row1.createCell(17).setCellValue(welltmp.getWcd_mesg()); row1.createCell(18).setCellValue(welltmp.getSuccess_date()); row1.createCell(19).setCellValue(welltmp.getFail_mesg()); row1.createCell(20).setCellValue(welltmp.getTj_status()); row1.createCell(21).setCellValue(welltmp.getSh_status()); rowNum++; } String newFileName = ""; try { newFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } response.setContentType("application/octet-stream"); response.setHeader("Content-disposition", "attachment;filename=" + newFileName+ ".xls"); try { response.flushBuffer(); workbook.write(response.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } } }
true
ba1ad090ace30e226c707b429638e8b1ca5a5700
Java
marcbriand/revsim
/Revsim/src/revsim/mvc/view/PatternNode.java
UTF-8
3,319
2.796875
3
[]
no_license
package revsim.mvc.view; import java.util.ArrayList; import java.util.List; import revsim.config.objects.revsim.TransformDestOption; import revsim.config.objects.revsim.TransformObject; import revsim.config.objects.revsim.TransformSourceOption; import revsim.modeltools.objects.AbstractBlip; public class PatternNode { private PatternNode parent = null; private final List<PatternNode> children = new ArrayList<PatternNode>(); private final List<AbstractBlip> blips = new ArrayList<AbstractBlip>(); public List<AbstractBlip> getLocalBlips () { return blips; } public List<AbstractBlip> gather (int depth) { List<AbstractBlip> ret = new ArrayList<AbstractBlip>(); for (AbstractBlip blip : blips) { ret.add((AbstractBlip)blip.clone()); } if (depth > 0) { for (PatternNode pn : children) { ret.addAll(pn.gather(depth-1)); } } return ret; } public List<AbstractBlip> gatherFromSubnode (List<Integer> path, int depth) throws NodeException { if (path.isEmpty()) { return gather(depth); } int child = path.get(0); if (child >= children.size()) throw NodeException.make(child, children.size()); PatternNode childNode = children.get(child); path.remove(0); return childNode.gatherFromSubnode(path, depth); } public void addNode (PatternNode node) { node.parent = this; children.add(node); } public void mergeNode (PatternNode node) { blips.addAll(node.blips); } public PatternNode getParent() { return parent; } public int getNumChildren () { return children.size(); } public PatternNode getChild (int i) { return children.get(i); } public void addBlip (AbstractBlip b) { blips.add(b); } public static void apply (PatternNode root, NodeOp op) { op.apply(root); for (int i = 0; i < root.getNumChildren(); i++) { PatternNode child = root.getChild(i); apply(child, op); } } private static void applyTransform (TransformObject tx, PatternNode tree) throws NodeException { List<Integer> path = tx.getSrcPath(); PatternNode cursor = tree; for (Integer i : path) { if (i >= cursor.getNumChildren()) { throw new NodeException("No child at index " + Integer.toString(i)); } cursor = cursor.getChild(i); } List<AbstractBlip> blips = cursor.gather(tx.getSrcDepth()); if (tx.getSrcOption() == TransformSourceOption.Remove) { cursor.blips.clear(); } List<List<AbstractBlip>> txFormed = tx.getOperation().transform(blips); List<Integer> destPath = tx.getDestPath(); cursor = tree; for (Integer i : destPath) { while(i >= cursor.getNumChildren()) { cursor.addNode(new PatternNode()); } cursor = cursor.getChild(i); } if (tx.getDestOption() == TransformDestOption.Add) { for (List<AbstractBlip> list : txFormed) { PatternNode node = new PatternNode(); node.blips.addAll(list); cursor.addNode(node); } } else { for (List<AbstractBlip> list : txFormed) { cursor.blips.addAll(list); } } System.out.println(TransformUtil.showTree(tree, 0, 0)); } public static void applyTransforms (List<TransformObject> transforms, PatternNode tree) throws NodeException { System.out.println(TransformUtil.showTree(tree, 0, 0)); int count = 1; for (TransformObject tO : transforms) { applyTransform(tO, tree); count++; } } }
true
441a952039a7f2ab5bb2e531fec2a8dfa8bbf147
Java
alyyasser19/Milestone2
/src/tests/tests.java
UTF-8
1,558
2.71875
3
[]
no_license
package tests; import java.io.IOException; import engine.Game; import exceptions.FullFieldException; import exceptions.FullHandException; import exceptions.HeroPowerAlreadyUsedException; import exceptions.NotEnoughManaException; import exceptions.NotYourTurnException; import model.cards.Rarity; import model.cards.minions.Minion; import model.heroes.Hero; import model.heroes.Mage; import model.heroes.Paladin; import model.heroes.Priest; import engine.Game; import model.cards.spells.AOESpell; import model.cards.spells.FieldSpell; import model.cards.spells.Flamestrike; import model.cards.spells.Spell; public class tests { public static void main(String[] args) throws IOException, CloneNotSupportedException, FullHandException, NotYourTurnException, NotEnoughManaException, HeroPowerAlreadyUsedException, FullFieldException { Hero a= new Paladin(); Hero b= new Mage(); Priest c= new Priest(); a.getField().add(new Minion("Chromaggus", 1, Rarity.BASIC, 1, 11, false, false, false)); b.getField().add(new Minion("Kalycgos", 1, Rarity.BASIC, 1, 11, false, false, false)); c.getField().add(new Minion("Prophet Velen", 1, Rarity.BASIC, 1, 11, false, false, false)); b.getHand().add(new Flamestrike()); Game start= new Game(a, c); //b.setTotalManaCrystals(5); //b.setCurrentManaCrystals(5); //b.castSpell((AOESpell)b.getHand().get(0), a.getField()); //System.out.println(a.getHand()); c.setCurrentHP(10); c.setTotalManaCrystals(2); c.setCurrentManaCrystals(2); c.useHeroPower(c); System.out.println(c.getCurrentHP()); } }
true
49d1fdc7e46a86cdb1b638b5252b26bc98adec07
Java
xinsec/AnewB
/src/java/test/thread/SyncDemo3.java
UTF-8
953
3.90625
4
[]
no_license
package test.thread; class MyThread9 implements Runnable { private int ticket = 100; public void run() { sale(); } /** * 同步方法 * */ public synchronized void sale() { while (ticket > 0) { /*try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); }*/ System.out.println(Thread.currentThread().getName() + "卖票,剩余票数: ticket = " + --ticket); } } } /** * 这个例子在这里并不合适,因为同步方法的原因导致整个卖票过程都在一个线程里执行了,因此在这里多线程的作用并没有体现出来 * @author woshizbh * */ public class SyncDemo3 { public static void main(String[] args) { MyThread9 mThread9 = new MyThread9(); Thread t1 = new Thread(mThread9, "售票员A"); Thread t2 = new Thread(mThread9, "售票员B"); Thread t3 = new Thread(mThread9, "售票员C"); t1.start(); t2.start(); t3.start(); } }
true
4ac028ce806407eb023adf613960f3f5b2967bbf
Java
javator2/PROBLEMS_PS
/src/test/java/com/sda/problems/ProblemsTest.java
UTF-8
5,201
3.421875
3
[]
no_license
package com.sda.problems; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; import static java.util.Arrays.asList; import static java.util.stream.Collectors.toList; import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.*; import static org.hamcrest.MatcherAssert.*; class ProblemsTest { @Test public void shouldFindLastElementFromAListOfAlphabets() throws Exception { assertThat(Problems.last(asList("a", "b", "c", "d")), is(equalTo("d"))); } @Test public void shouldFindSecondLastElementFromAList() throws Exception { List<Integer> numbers = asList(1, 2, 11, 4, 5, 8, 10, 6); assertThat(Problems.secondLast(numbers), is(equalTo(10))); } @Test public void listOfEmptyListShouldBe0() throws Exception { int length = Problems.length(Collections.emptyList()); assertThat(length, is(equalTo(0))); } @Test public void shouldFindListOfNonEmptyList() throws Exception { assertThat(Problems.length(Arrays.asList(1, 2, 3, 4, 5)), is(equalTo(5))); } @Test public void shouldReverseAList() throws Exception { List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5); assertThat(Problems.reverse(numbers), is(equalTo(Arrays.asList(5, 4, 3, 2, 1)))); } @Test public void shouldDuplicateElementsInAList() throws Exception { List<String> duplicates = Problems.duplicate(Arrays.asList("a", "b", "c", "d")); assertThat(duplicates, hasSize(8)); assertThat(duplicates, contains("a", "a", "b", "b", "c", "c", "d", "d")); } @Test public void shouldReturnAListOfThreeRandomSelectedElements() throws Exception { List<String> result = Problems.randomSelect(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"), 3); System.out.println(result); assertThat(result, hasSize(3)); } @Test public void shouldGiveAllPrimeNumbersBetween2And10() throws Exception { List<Integer> primeNumbers = Problems.primeNumbers(IntStream.rangeClosed(2, 10)); assertThat(primeNumbers, hasSize(4)); assertThat(primeNumbers, hasItems(2, 3, 5, 7)); } @Test public void shouldGiveAllPrimeNumbersBetween7And31() throws Exception { List<Integer> primeNumbers = Problems.primeNumbers(IntStream.rangeClosed(7, 31)); assertThat(primeNumbers, hasSize(8)); assertThat(primeNumbers, hasItems(7, 11, 13, 17, 19, 23, 29, 31)); } @Test public void shouldRotateAListByThreeElementsWhenNIs3() throws Exception { List<String> rotated = Problems.rotate(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"), 3); assertThat(rotated, equalTo(Arrays.asList("d", "e", "f", "g", "h", "a", "b", "c"))); } @Test public void shouldReturnSameListWhenNIs0() throws Exception { List<String> rotated = Problems.rotate(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"), 0); assertThat(rotated, equalTo(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"))); } @Test public void shouldRotateWhenNIsNegative() throws Exception { List<String> rotated = Problems.rotate(Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h"), -2); assertThat(rotated, equalTo(Arrays.asList("g", "h", "a", "b", "c", "d", "e", "f"))); } @Test public void shouldRemoveKthElementFromList() throws Exception { Object[] result = Problems.removeAt(Arrays.asList("a", "b", "c", "d"), 2); assertThat(result[0], equalTo(Arrays.asList("a", "c", "d"))); assertThat(result[1], equalTo("b")); } @Test public void shouldInsertElementAtSecondPosition() throws Exception { List<String> input = Stream.of("a", "b", "c", "d").collect(toList()); List<String> result = Problems.insertAt(input, 2, "alfa"); assertThat(result, hasSize(5)); assertThat(result, contains("a", "alfa", "b", "c", "d")); } @Test public void shouldInsertElementAtFirstPosition() throws Exception { List<String> input = Stream.of("a", "b", "c", "d").collect(toList()); List<String> result = Problems.insertAt(input, 1, "alfa"); assertThat(result, hasSize(5)); assertThat(result, contains("alfa", "a", "b", "c", "d")); } @Test public void shouldInsertElementAtEnd() throws Exception { List<String> input = Stream.of("a", "b", "c", "d").collect(toList()); List<String> result = Problems.insertAt(input, 5, "alfa"); assertThat(result, hasSize(5)); assertThat(result, contains("a", "b", "c", "d", "alfa")); } @Test public void shouldGenerateRandomPermutationOfElementsOfAList() throws Exception { List<String> permutation = Problems.randomPermutation(Stream.of("a", "b", "c", "d", "e", "f").collect(toList())); assertThat(permutation, hasSize(6)); assertThat(permutation, containsInAnyOrder("a", "b", "c", "d", "e", "f")); System.out.println(permutation); // np. [a, e, f, c, b, d] } }
true
ed2e79e2e2883734ea53a3a334cac711b984732d
Java
katarina-show/Design-pattern
/src/main/java/com/sjw/design/pattern/structural/bridge/shape/Test.java
UTF-8
1,229
3.90625
4
[]
no_license
package com.sjw.design.pattern.structural.bridge.shape; /** * @Author: Irelia * @Date: 2018/12/12 20:50 * @Description: 典型桥接模式案例:给图形上色 * 新增图形或者颜色,都无需改动已有的类,符合开闭原则 * 针对接口编程 符合 依赖倒置原则 * 每个类只有1个职责 符合 单一职责原则 * 持有别的类的引用,而不是继承,符合 合成/复用原则 * 不算Test共计8个类 * * 同样的如果使用继承,在Circle下有RedCircle、BlueCircle、YellowCircle,Rectangle和Square也是同理,共计13个类 * * 新增1个图形 * 使用桥接:8+1=9个类 * 使用继承:13+4=17个类 * 新增1个颜色 * 使用桥接:8+1=9个类 * 使用继承:13+3=16个类 * 同时新增1个图形和1个颜色 * 使用桥接:8+2=10个类 * 使用继承:13+3+4=20个类 * * 桥接模式减少类个数,易于拓展 **/ public class Test { public static void main(String[] args) { Shape circle = new Circle(new Red()); circle.paintColor(); Shape rectangle = new Rectangle(new Blue()); rectangle.paintColor(); Shape square = new Square(new Yellow()); square.paintColor(); } }
true
1908292d2ec05fbf1d96e045581dcf10e0320875
Java
Diegoavilap/TaximetroVirtual
/TaximetroVirtual/src/main/java/com/ceiba/adn/taximetrovirtual/aplicacion/dto/DetalleCarreraDTO.java
UTF-8
886
2.3125
2
[]
no_license
package com.ceiba.adn.taximetrovirtual.aplicacion.dto; import java.math.BigDecimal; import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; public class DetalleCarreraDTO { private Long id; private Long carreraId; private LocalDateTime fechaFin; private BigDecimal costo; @JsonCreator public DetalleCarreraDTO(@JsonProperty("id") Long id, @JsonProperty("carreraId") Long carreraId, @JsonProperty("fechaFin") LocalDateTime fechaFin, @JsonProperty("costo") BigDecimal costo) { this.id = id; this.carreraId = carreraId; this.fechaFin = fechaFin; this.costo = costo; } public Long getCarreraId() { return carreraId; } public LocalDateTime getFechaFin() { return fechaFin; } public Long getId() { return id; } public BigDecimal getCosto() { return costo; } }
true
3750ef78e2f8ccd3d8861dc9ec21c1283bbbe214
Java
museong-park/petdoc.v2
/app/src/main/java/com/compet/petdoc/fragment/MainFragment.java
UTF-8
18,567
1.742188
2
[]
no_license
package com.compet.petdoc.fragment; import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.content.res.Resources; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.compet.petdoc.R; import com.compet.petdoc.adapter.HospitalAdapter; import com.compet.petdoc.data.HospitalItem; import com.compet.petdoc.data.RegionItem; import com.compet.petdoc.manager.NetworkManager; import com.compet.petdoc.manager.NetworkRequest; import com.compet.petdoc.request.HospitalListRequest; import com.compet.petdoc.util.Constants; import com.compet.petdoc.util.HospitalURL; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationServices; import com.google.android.gms.maps.model.LatLng; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import static android.Manifest.permission.ACCESS_COARSE_LOCATION; public class MainFragment extends BaseFragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, AbsListView.OnScrollListener { private static final String TAG = MainFragment.class.getSimpleName(); private final static int PLAY_SERVICES_RESOLUTION_REQUEST = 1000; private static final int RC_PERMISSION = 1000; private TextView locationView; private Context mContext; // Google client to interact with Google API private GoogleApiClient mGoogleApiClient; private Location mLastLocation; private LatLng userPosition; private HospitalAdapter mAdapter; private View footerView; private boolean mLockListView; private boolean mListAdd; private int startIndex = 1; private int endIndex = 10; private RegionItem regionItem; private HospitalItem hospitalItem; private String url; private List<RegionItem> regionList; private HospitalListRequest request; public MainFragment() { // Required empty public constructor } public static MainFragment newInstance(RegionItem regionItem) { MainFragment fragment = new MainFragment(); Bundle args = new Bundle(); args.putSerializable(Constants.REGION, regionItem); fragment.setArguments(args); return fragment; } public static MainFragment newInstance() { MainFragment fragment = new MainFragment(); Bundle args = new Bundle(); fragment.setArguments(args); return fragment; } @Override public void onAttach(Context context) { super.onAttach(context); mContext = context; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "MainFragment onCreate() 실행"); if (getArguments() != null) { regionItem = (RegionItem)getArguments().getSerializable(Constants.REGION); } checkPermission(mContext); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_main, container, false); Log.d(TAG, "MainFragment OnCreateView() 실행"); startIndex = 1; endIndex = 10; setHasOptionsMenu(true); initToolBar(getString(R.string.app_name), view, mContext); mListAdd = true; locationView = (TextView)view.findViewById(R.id.text_location); LinearLayout layoutLocation = (LinearLayout)view.findViewById(R.id.layout_location); layoutLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFragmentManager().beginTransaction() .addToBackStack(null) .replace(R.id.container, SearchFragment.newInstance()) .commit(); } }); Button mapButton = (Button)view.findViewById(R.id.btn_map); mapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFragmentManager().beginTransaction() .replace(R.id.container, MapDocFragment.getListItem(mAdapter.getListItem())) .addToBackStack(null) .commit(); } }); if (checkPlayServices()) { // Building the GoogleApi client buildGoogleApiClient(); } mGoogleApiClient.connect(); regionList = new ArrayList<>(); mAdapter = new HospitalAdapter(getContext()); ListView listView = (ListView)view.findViewById(R.id.listView); footerView = LayoutInflater.from(getContext()).inflate(R.layout.view_footer, null); footerView.setVisibility(View.GONE); listView.addFooterView(footerView); listView.setOnScrollListener(this); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { getFragmentManager().beginTransaction() .replace(R.id.container, DetailFragment.newInstance(mAdapter.getItem(position))) .addToBackStack(null) .commit(); } }); listView.setAdapter(mAdapter); if (regionItem == null) { setRegionData(); } else { initData(); locationView.setText(regionItem.getName()); } return view; } @Override public void onStart() { super.onStart(); mGoogleApiClient.connect(); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.bookmark_menu, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_search: getFragmentManager().beginTransaction() .replace(R.id.container, BookmarkFragment.newInstance()) .addToBackStack(null) .commit(); break; } return super.onOptionsItemSelected(item); } @Override public void onStop() { super.onStop(); if (mGoogleApiClient.isConnected()) { mGoogleApiClient.disconnect(); } } protected synchronized void buildGoogleApiClient() { mGoogleApiClient = new GoogleApiClient.Builder(mContext).addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build(); } private boolean checkPlayServices() { GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance(); int result = googleAPI.isGooglePlayServicesAvailable(mContext); if (result != ConnectionResult.SUCCESS) { if (googleAPI.isUserResolvableError(result)) { googleAPI.getErrorDialog(getActivity(), result, PLAY_SERVICES_RESOLUTION_REQUEST).show(); } return false; } return true; } @Override public void onResume() { super.onResume(); Log.d(TAG, "MainFragment OnResume() 실행"); mAdapter.clear(); startIndex = 1; endIndex = 10; } private void setRegionData() { Resources res = getResources(); String[] arrString = res.getStringArray(R.array.seoul_region); for (int i = 0; i < arrString.length; i++) { RegionItem regionItem = new RegionItem(); regionItem.setName(arrString[i]); regionItem.setUrl(HospitalURL.URL[i]); regionList.add(regionItem); } } private void initData() { url = regionItem.getUrl(); footerView.setVisibility(View.VISIBLE); mLockListView = true; request = new HospitalListRequest(getContext(), url, Constants.GET, String.valueOf(startIndex), String.valueOf(endIndex)); NetworkManager.getInstance().getNetworkData(request, new NetworkManager.OnResultListener() { @Override public void onSuccess(NetworkRequest request, Object result) { if (result != null) { mAdapter.addAll((List<HospitalItem>)result); mLockListView = false; footerView.setVisibility(View.GONE); mListAdd = false; startIndex = endIndex + 1; endIndex = endIndex + 10; } } @Override public void onFail(NetworkRequest request, int errorCode, String errorMessage) { mLockListView = false; mListAdd = false; footerView.setVisibility(View.GONE); Toast.makeText(getContext(), "서버 오류 입니다. 다음에 다시 시도해주세요.", Toast.LENGTH_LONG); } }); } private void addData() { url = regionItem.getUrl(); footerView.setVisibility(View.VISIBLE); mLockListView = true; HospitalListRequest request = new HospitalListRequest(getContext(), url, Constants.GET, String.valueOf(startIndex), String.valueOf(endIndex)); NetworkManager.getInstance().getNetworkData(request, new NetworkManager.OnResultListener() { @Override public void onSuccess(NetworkRequest request, Object result) { if (result != null) { mAdapter.addItem((List<HospitalItem>)result); mLockListView = false; startIndex = endIndex + 1; endIndex = endIndex + 10; } else { footerView.setVisibility(View.GONE); } } @Override public void onFail(NetworkRequest request, int errorCode, String errorMessage) { Toast.makeText(getContext(), "서버 오류 입니다. 다음에 다시 시도해주세요.", Toast.LENGTH_LONG); startIndex = 1; endIndex = 10; mLockListView = true; footerView.setVisibility(View.GONE); } }); } private void getUserLocation() { if (ContextCompat.checkSelfPermission(mContext, ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); } if (mLastLocation != null) { Log.d(TAG, "latitude : " + mLastLocation.getLatitude() + " " + "longitude : " + mLastLocation.getLongitude()); String address = changeAddress(mLastLocation.getLatitude(), mLastLocation.getLongitude()); String[] addressLine = address.split(" "); StringBuilder stringBuilder = new StringBuilder(); regionItem = searchRegion(addressLine); stringBuilder.append(addressLine[2]).append(" ").append(addressLine[3]); locationView.setText(stringBuilder.toString()); if (regionItem != null) { initData(); } else { } } else { } } private RegionItem searchRegion(String[] addressLine) { for (int i = 0; i < regionList.size(); i++) { if (regionList.get(i).getName().equals(addressLine[2])) { regionItem = regionList.get(i); return regionItem; } else { // getFragmentManager().beginTransaction() // .replace(R.id.container, SearchFragment.newInstance()) // .commit(); } } return null; } private String changeAddress(double latitude, double longitude) { StringBuffer bf = new StringBuffer(); Geocoder geocoder = new Geocoder(mContext, Locale.KOREA); List<Address> address; try { if (geocoder != null) { // 세번째 인수는 최대결과값인데 하나만 리턴받도록 설정했다 address = geocoder.getFromLocation(latitude, longitude, 1); // 설정한 데이터로 주소가 리턴된 데이터가 있으면 if (address != null && address.size() > 0) { // 주소 bf.append(address.get(0).getAddressLine(0)); } } } catch (IOException e) { Toast.makeText(mContext, "주소취득 실패", Toast.LENGTH_LONG).show(); e.printStackTrace(); } return bf.toString(); } public void checkPermission(final Context context) { List<String> permissions = new ArrayList<>(); if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE); } if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { permissions.add(Manifest.permission.ACCESS_COARSE_LOCATION); } if (permissions.size() > 0) { boolean isShowUI = false; for (String perm : permissions) { if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), perm)) { isShowUI = true; break; } } final String[] perms = permissions.toArray(new String[permissions.size()]); if (isShowUI) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getContext()); builder.setTitle("Permission"); builder.setMessage("Permission"); builder.setCancelable(false); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ActivityCompat.requestPermissions((Activity)context, perms, RC_PERMISSION); } }); builder.create().show(); return; } requestPermissions(perms, RC_PERMISSION); } } @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == RC_PERMISSION) { if (permissions != null) { boolean granted = true; for (int i = 0; i < permissions.length; i++) { if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { granted = false; } } if (!granted) { Toast.makeText(getContext(), "permission not granted", Toast.LENGTH_SHORT).show(); } } } } @Override public void onConnected(@Nullable Bundle bundle) { if (mAdapter.isEmpty() && locationView.getText().toString().equals("위치")) { getUserLocation(); } } @Override public void onConnectionSuspended(int i) { mGoogleApiClient.connect(); } @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int count = totalItemCount - visibleItemCount; if (firstVisibleItem >= count && totalItemCount != 0 && !mLockListView && !mListAdd) { addData(); } } @Override public void onPause() { super.onPause(); } }
true
fa6f96fbf10ebac9c7d2a99d5f0a64ba0b918a99
Java
pushker-git/LeetCodeTopInterviewQuestions
/kickstart/BikeTour.java
UTF-8
2,078
3.78125
4
[]
no_license
Li has planned a bike tour through the mountains of Switzerland. His tour consists of N checkpoints, numbered from 1 to N in the order he will visit them. The i-th checkpoint has a height of Hi. A checkpoint is a peak if: It is not the 1st checkpoint or the N-th checkpoint, and The height of the checkpoint is strictly greater than the checkpoint immediately before it and the checkpoint immediately after it. Please help Li find out the number of peaks. Input The first line of the input gives the number of test cases, T. T test cases follow. Each test case begins with a line containing the integer N. The second line contains N integers. The i-th integer is Hi. Output For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of peaks in Li's bike tour. Limits Time limit: 10 seconds per test set. Memory limit: 1GB. 1 ≤ T ≤ 100. 1 ≤ Hi ≤ 100. Test set 1 3 ≤ N ≤ 5. Test set 2 3 ≤ N ≤ 100. Sample Input Output 4 3 10 20 14 4 7 7 7 7 5 10 90 20 90 10 3 10 3 10 Case #1: 1 Case #2: 0 Case #3: 2 Case #4: 0 In sample case #1, the 2nd checkpoint is a peak. In sample case #2, there are no peaks. In sample case #3, the 2nd and 4th checkpoint are peaks. In sample case #4, there are no peaks. import java.util.*; public class Solution { public static int numberOfPeaks(int [] mountain) { int length = mountain.length; int peaks = 0; for (int i=1; i<length - 1; i++) { if (mountain[i-1] < mountain[i] && mountain[i] > mountain[i+1]) peaks ++; } return peaks; } public static void main(String [] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt(); for (int t = 1; t <= test; t++) { int n = sc.nextInt(); int [] mountain = new int [n]; for (int i=0; i<n; i++) mountain[i] = sc.nextInt(); System.out.println("Case #" + t + ": " + numberOfPeaks(mountain)); } } }
true
ea94df62c037be26970c375a52ac5860dd345309
Java
Hyo-gyeong/JavaStudy
/Practice22.java
UHC
575
3.515625
4
[]
no_license
import java.util.Scanner; public class Practice22 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(" Էϼ: "); int n1 = sc.nextInt(); System.out.print(" Էϼ: "); int n2 = sc.nextInt(); int total1 = sum(n1, n2); System.out.println(n1 + "+" + n2 + "="+ total1); int total2 = sum(n2, n1); System.out.println(n2 + "+" + n1 + "="+ total2); sc.close(); } public static int sum(int x, int y) { int sum = x + y; return sum; } }
true
e5261a1d2e6846004ef4f5feb76c3ef5e47c37bc
Java
mengyan520/java-
/基础学习1-19/07-if语句.java
UTF-8
206
2.734375
3
[]
no_license
public class IFDemo{ public static void main(String[] args) { if (4>2) { System.out.println("4>2"); }else if (5>4) { System.out.println("5>4"); }else { System.out.println("哈哈"); } } }
true
6eaf39c10525396724e8e48e33b5b6c811013b8f
Java
andrewjjenkins/roboDTN
/roboDTN/src/net/robodtn/Malformity.java
UTF-8
1,421
2.046875
2
[ "Apache-2.0" ]
permissive
/******************************************************************************* * Copyright 2011 Andrew Jenkins * * 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 net.robodtn; public enum Malformity { UNSPECIFIED, /* Exception creator didn't specify */ OTHER, /* Creator was too lazy to define a new exception */ DICTTOOSHORT, /* Dictionary was shorter than it could possibly be. */ EIDREFNOTINDICT, /* The EID reference was outside the dictionary bounds. */ INVALIDVERSION, /* The version wasn't 0x06 (RFC5050) */ NOLASTBLOCK, /* There wasn't a block with the "last block" flag set. */ TOOMANYPAYLOADS, /* There was more than one block with the payload type 0x00. */ TOOSHORT, /* The bundle wasn't as long as it was supposed to be. */ TOOBIG /* The bundle was bigger than this implementation supports. */ }
true
11c98bcd2d68a1e5d292f06193d7d2dedcd18663
Java
DanielCYLim/lumify
/tools/import/src/main/java/io/lumify/tools/Import.java
UTF-8
3,226
2.265625
2
[ "Apache-2.0" ]
permissive
package io.lumify.tools; import com.google.inject.Inject; import io.lumify.core.cmdline.CommandLineBase; import io.lumify.core.ingest.FileImport; import io.lumify.core.model.workspace.Workspace; import io.lumify.core.model.workspace.WorkspaceRepository; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import java.io.File; public class Import extends CommandLineBase { private static final String CMD_OPT_DATADIR = "datadir"; private static final String CMD_OPT_QUEUE_DUPLICATES = "queuedups"; private static final String CMD_OPT_VISIBILITY_SOURCE = "visibilitysource"; private static final String CMD_OPT_WORKSPACE_ID = "workspaceid"; private FileImport fileImport; private WorkspaceRepository workspaceRepository; public static void main(String[] args) throws Exception { int res = new Import().run(args); if (res != 0) { System.exit(res); } } @Override protected Options getOptions() { Options opts = super.getOptions(); opts.addOption( OptionBuilder .withLongOpt(CMD_OPT_DATADIR) .withDescription("Location of the data directory") .hasArg() .isRequired() .create() ); opts.addOption( OptionBuilder .withLongOpt(CMD_OPT_QUEUE_DUPLICATES) .withDescription("Specify if you would like to queue duplicate files") .create() ); opts.addOption( OptionBuilder .withLongOpt(CMD_OPT_VISIBILITY_SOURCE) .withDescription("The visibility source data.") .hasArg() .create() ); opts.addOption( OptionBuilder .withLongOpt(CMD_OPT_WORKSPACE_ID) .withDescription("The workspace id to import the files into.") .hasArg() .create() ); return opts; } @Override protected int run(CommandLine cmd) throws Exception { File dataDir = new File(cmd.getOptionValue(CMD_OPT_DATADIR)); boolean queueDuplicates = cmd.hasOption(CMD_OPT_QUEUE_DUPLICATES); String visibilitySource = cmd.getOptionValue(CMD_OPT_VISIBILITY_SOURCE, ""); String workspaceId = cmd.getOptionValue(CMD_OPT_WORKSPACE_ID, null); Workspace workspace; if (workspaceId == null) { workspace = null; } else { workspace = workspaceRepository.findById(workspaceId, getUser()); } fileImport.importDirectory(dataDir, queueDuplicates, visibilitySource, workspace, getUser(), getAuthorizations()); return 0; } @Inject public void setFileImport(FileImport fileImport) { this.fileImport = fileImport; } @Inject public void setWorkspaceRepository(WorkspaceRepository workspaceRepository) { this.workspaceRepository = workspaceRepository; } }
true
37b50a934f9c066205e01bc375c72f9c021a8a93
Java
ka3stam/bookstore
/build/generated-sources/ap-source-output/models/Category_.java
UTF-8
594
1.898438
2
[]
no_license
package models; import javax.annotation.Generated; import javax.persistence.metamodel.CollectionAttribute; import javax.persistence.metamodel.SingularAttribute; import javax.persistence.metamodel.StaticMetamodel; import models.Book; @Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2018-12-09T10:16:44") @StaticMetamodel(Category.class) public class Category_ { public static volatile SingularAttribute<Category, Integer> id; public static volatile SingularAttribute<Category, String> title; public static volatile CollectionAttribute<Category, Book> bookCollection; }
true
3e2b860bdf8fdef8864da0f577a529f1b5baed04
Java
liviaguimaraes92/tuma19java
/Java/AULA/src/Java1exercicio3.java
ISO-8859-1
691
3.46875
3
[]
no_license
import java.util.Scanner; public class Java1exercicio3 { public static void main(String[] args) { Scanner leia = new Scanner (System.in); int idade; System.out.println("Qual a sua idade?"); idade = leia.nextInt(); if (idade < 10 || idade > 25) { System.out.println("Voc no pertence a nenhuma categoria programada."); } else if (idade >= 10 && idade < 15){ System.out.println("Voc pertence a categoria infantil."); } else if (idade >= 15 && idade < 18) { System.out.println("Voc pertence a categoria juvenil."); } else if (idade >= 18 && idade < 26) { System.out.println("Voc pertence a categoria adulta."); } } }
true
7cc1ff65cebc4e7a52aa61b6012a3930e2142fd9
Java
ShriLingam23/dms
/app/src/main/java/com/mad/dms/MainActivity.java
UTF-8
977
2.125
2
[]
no_license
package com.mad.dms; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.mad.dms.R; import com.mad.dms.order.OrderMain; import com.mad.dms.product.ProductMain; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void setOnClick(View view) { int id = view.getId(); Class menu; switch (id) { case R.id.main_view_orders: menu = OrderMain.class; break; case R.id.main_view_products: menu = ProductMain.class; break; default: menu = ProductMain.class; } Intent intent = new Intent(MainActivity.this, menu); startActivity(intent); } }
true
ae9690afc4ca9d1cc486b4d3c03ff11883284a8e
Java
Team5519/Stronghold2016
/src/org/usfirst/frc/team5519/helpers/ArcadeDrive.java
UTF-8
6,559
2.671875
3
[]
no_license
package org.usfirst.frc.team5519.helpers; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.RobotDrive; import edu.wpi.first.wpilibj.SpeedController; import edu.wpi.first.wpilibj.Talon; public class ArcadeDrive { // fields and global variables // joystick related private final Joystick stick; // robot drive private final RobotDrive drive; // speed controllers related private final SpeedController SFL; // front left private final SpeedController SFR; // front right private final SpeedController SRL; // rear left private final SpeedController SRR; // rear right // default constants private static final int DF_JOYSTICK_PORT = 0; private static final int DF_SFL_CHANNEL = 0; private static final int DF_SFR_CHANNEL = 1; private static final int DF_SRL_CHANNEL = 2; private static final int DF_SRR_CHANNEL = 3; private final static int STOP_SPEED = 0; private final static int MAX_SPEED = 1; private final static int MIN_SPEED = -1; // others private boolean isInverted; // constructors public ArcadeDrive() { // create Talon Speed Controllers with LF = 0, RF = 1, LR = 2 and RR = 3 // use the joystick plugged in port 0 this(null, null, null, null, null, DF_JOYSTICK_PORT, DF_SFL_CHANNEL, DF_SFR_CHANNEL, DF_SRL_CHANNEL, DF_SRR_CHANNEL); } // only joystick provided public ArcadeDrive(Joystick stick) { // create Talon Speed Controllers with LF = 0, RF = 1, LR = 2 and RR = 3 // use the joystick provided this(stick, null, null, null, null, DF_JOYSTICK_PORT, DF_SFL_CHANNEL, DF_SFR_CHANNEL, DF_SRL_CHANNEL, DF_SRR_CHANNEL); } // provide joystick port public ArcadeDrive(int joystickPort) { // create Talon Speed Controllers with LF = 0, RF = 1, LR = 2 and RR = 3 // use the joystick port provided this(null, null, null, null, null, joystickPort, DF_SFL_CHANNEL, DF_SFR_CHANNEL, DF_SRL_CHANNEL, DF_SRR_CHANNEL); } // provide speed controllers' channels public ArcadeDrive(final int frontLeftMotor, final int frontRightMotor, final int rearLeftMotor, final int rearRightMotor) { // create default joystick // use the channels to make speed controllers this(null, null, null, null, null, DF_JOYSTICK_PORT, frontLeftMotor, frontRightMotor, rearLeftMotor, rearRightMotor); } // provide speed controllers public ArcadeDrive(final SpeedController frontLeftMotor, final SpeedController frontRightMotor, final SpeedController rearLeftMotor, final SpeedController rearRightMotor) { // create default joystick // use speed controllers this(null, frontLeftMotor, frontRightMotor, rearLeftMotor, rearRightMotor, DF_JOYSTICK_PORT, DF_SFL_CHANNEL, DF_SFR_CHANNEL, DF_SRL_CHANNEL, DF_SRR_CHANNEL); } // provide Joystick and speed controllers public ArcadeDrive(final Joystick joystick, final SpeedController frontLeftMotor, final SpeedController frontRightMotor, final SpeedController rearLeftMotor, final SpeedController rearRightMotor) { // create default joystick // use speed controllers this(joystick, frontLeftMotor, frontRightMotor, rearLeftMotor, rearRightMotor, DF_JOYSTICK_PORT, DF_SFL_CHANNEL, DF_SFR_CHANNEL, DF_SRL_CHANNEL, DF_SRR_CHANNEL); } // provide all ports public ArcadeDrive(int joystickPort, int frontLeftMotor, int frontRightMotor, int rearLeftMotor, int rearRightMotor) { // call the main constructor this(null, null,null, null, null, joystickPort, frontLeftMotor, frontRightMotor, rearLeftMotor, rearRightMotor); } // main constructor private ArcadeDrive(Joystick joystick, SpeedController sfl, SpeedController sfr, SpeedController srl, SpeedController srr, int joystickPort, int fl_cont, int fr_cont, int rl_cont, int rr_cont) { // if joystick is null, create joystick if (joystick == null) this.stick = new Joystick(joystickPort); else this.stick = joystick; // check if front left speed controller is null // if it is create a Talon Speed Controller at the provided port if (sfl == null) this.SFL = new Talon(fl_cont); else this.SFL = sfl; // check if front right speed controller is null // if it is create a Talon Speed Controller at the provided port if (sfr == null) this.SFR = new Talon(fr_cont); else this.SFR = sfr; // check if rear left speed controller is null // if it is create a Talon Speed Controller at the provided port if (srl == null) this.SRL = new Talon(rl_cont); else this.SRL = srl; // check if rear right speed controller is null // if it is create a Talon Speed Controller at the provided port if (srr == null) this.SRR = new Talon(rr_cont); else this.SRR = srr; // create RobotDrive to be used drive = new RobotDrive(SFL, SRL, SFR, SRR); isInverted = false; } // joystick object and channels public ArcadeDrive(Joystick driver, int frontLeftMotor, int frontRightMotor, int rearLeftMotor, int rearRightMotor) { this(driver, null, null, null, null, DF_JOYSTICK_PORT, frontLeftMotor, frontRightMotor, rearLeftMotor, rearRightMotor); } // set isInverted true or false public void setInverted(boolean isInverted) { this.isInverted = isInverted; } // specify forward speed and turn speed public void drive(double forwardSpeed, double turnSpeed) { if (isInverted) { forwardSpeed *= -1; turnSpeed *= -1; } drive.arcadeDrive(forwardSpeed, turnSpeed); } // stop the robot public void stop() { this.drive(STOP_SPEED, STOP_SPEED); } // no parameter public void drive() { this.drive(stick.getX(), stick.getY()); } // specify the percentage the robot will run public void drive(double percent) { if (percent < 0.0 || percent > 1.0) return; // drive based on that percentage this.drive(stick.getX() * percent, stick.getY() * percent); } // robot moves forward based on the percentage public void goForward(double percent) { if (percent < 0.00 || percent > 1.0) return; this.drive(MAX_SPEED * percent, STOP_SPEED); } // robot moves backwards based on the percentage public void goBackwards(double percent) { if (percent < 0.00 || percent > 1.0) return; this.drive(MIN_SPEED * percent, STOP_SPEED); } // robot turns right based on the percentage public void goRight(double percent) { if (percent < 0.00 || percent > 1.0) return; this.drive(STOP_SPEED, MIN_SPEED * percent); } // robot turns left based on the percentage public void goLeft(double percent) { if (percent < 0.00 || percent > 1.0) return; this.drive(STOP_SPEED, MAX_SPEED * percent); } }
true
9b85ef0cb11f9a56df36a6199ce1c075a05abbe6
Java
anisacozzy/gemfire-fe
/gemfire-examples/gemfire-fraud/gemfire-fraud-server/src/main/java/io/pivotal/bds/gemfire/fraud/server/dao/AccountBalanceDAO.java
UTF-8
446
1.726563
2
[ "Apache-2.0" ]
permissive
package io.pivotal.bds.gemfire.fraud.server.dao; import org.apache.geode.cache.Region; import io.pivotal.bds.gemfire.dao.DefaultDAO; import io.pivotal.bds.gemfire.fraud.common.data.AccountBalance; import io.pivotal.bds.gemfire.fraud.common.key.AccountKey; public class AccountBalanceDAO extends DefaultDAO<AccountKey, AccountBalance> { public AccountBalanceDAO(Region<AccountKey, AccountBalance> region) { super(region); } }
true
681fe55bbe2215fc3e77a984d110c82ad6a7c5e6
Java
sweti640/day1CollectionExamples
/CollectionExamples/src/question_16.java
UTF-8
2,242
3.359375
3
[]
no_license
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; public class question_16 { /*Consider an ArrayList<Test>and test has {tid,sid,int marks[]} .Create a Set<Student> * Student{sid,totalmarks} from the list and sort the set in descending order of totalmarks */ public static void main(String[] args) { ArrayList<Test> test=new ArrayList<Test>(); int mark1[]= {10,20,30}; int mark2[]= {40,50,60}; int mark3[]= {15,5,5}; int mark4[]= {70,80,90}; Test t1=new Test(1, 1, mark1); Test t2=new Test(2, 2, mark2); Test t3=new Test(3, 3, mark3); Test t4=new Test(4, 4, mark4); test.add(t1); test.add(t2); test.add(t3); test.add(t4); Set<StudentDamy> student=new HashSet(); Iterator<Test> stutest=test.iterator(); while(stutest.hasNext()) { Test data=stutest.next(); int id=data.stu_id; int sum=0; int total[]=data.marks; for(int i=0;i<total.length;i++) { sum=sum+total[i]; } student.add(new StudentDamy(id,sum)); } //System.out.println(student); TreeSet<StudentDamy> tree=new TreeSet<StudentDamy>(student); System.out.println(tree); } } class Test { int test_id; int stu_id; int marks[]; public Test( int test_id, int stu_id, int[] marks) { this.test_id = test_id; this.stu_id = stu_id; this.marks = marks; } @Override public String toString() { return "Test [test_id=" + test_id + ", stu_id=" + stu_id + ", marks=" + Arrays.toString(marks) + "]"; } } class StudentDamy implements Comparable<StudentDamy> { int student_id; int total; public StudentDamy(int id,int t) { this.student_id=id; this.total=t; } public StudentDamy(int sid) { this.student_id=sid; } @Override public String toString() { return "StudentDamy [student_id=" + student_id + ", total=" + total + "]"; } @Override public int compareTo(StudentDamy o) { if(this.total<o.total) return 1; if(this.total>o.total) return -1; else return 0; } }
true
0a4af6d0441e92dc7d775f4c85f7f03e6c9eb517
Java
SekthDroid/EspressoSamples
/app/src/androidTest/java/com/sekthdroid/espressosample/TestUtils.java
UTF-8
955
2.21875
2
[ "Apache-2.0" ]
permissive
package com.sekthdroid.espressosample; import android.app.Activity; import android.support.test.runner.lifecycle.ActivityLifecycleMonitorRegistry; import java.util.Collection; import static android.support.test.InstrumentationRegistry.getInstrumentation; import static android.support.test.runner.lifecycle.Stage.RESUMED; /** * Created by SekthDroid on 12/1/17. */ public class TestUtils { public static Activity getActivityInstance() { final Activity[] currentActivity = {null}; getInstrumentation().runOnMainSync(new Runnable() { public void run() { Collection resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(RESUMED); if (resumedActivities.iterator().hasNext()) { currentActivity[0] = (Activity) resumedActivities.iterator().next(); } } }); return currentActivity[0]; } }
true
8125ea85e2a96d434787810fa72f78ba5639b7d8
Java
GypsyBud/pegasus_spyware
/pegasus-spyware-decompiled/sample4/recompiled_java/sources/QQPIM/CheckClientInfo.java
UTF-8
5,069
1.984375
2
[ "MIT" ]
permissive
package QQPIM; import com.qq.taf.jce.JceDisplayer; import com.qq.taf.jce.JceInputStream; import com.qq.taf.jce.JceOutputStream; import com.qq.taf.jce.JceStruct; import com.qq.taf.jce.JceUtil; import com.tencent.tmsecure.module.wupsession.WupConfig; public final class CheckClientInfo extends JceStruct implements Cloneable { static final /* synthetic */ boolean a = (!CheckClientInfo.class.desiredAssertionStatus()); public int connectType; public int engineVersion; public String guid; public String imei; public String imsi; public boolean isRoot; public CheckClientInfo() { this.engineVersion = 0; this.guid = ""; this.imei = ""; this.imsi = ""; this.connectType = 0; this.isRoot = false; this.engineVersion = this.engineVersion; this.guid = this.guid; this.imei = this.imei; this.imsi = this.imsi; this.connectType = this.connectType; this.isRoot = this.isRoot; } public CheckClientInfo(int i, String str, String str2, String str3, int i2, boolean z) { this.engineVersion = 0; this.guid = ""; this.imei = ""; this.imsi = ""; this.connectType = 0; this.isRoot = false; this.engineVersion = i; this.guid = str; this.imei = str2; this.imsi = str3; this.connectType = i2; this.isRoot = z; } public final String className() { return "QQPIM.CheckClientInfo"; } @Override // java.lang.Object public final Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { if (a) { return null; } throw new AssertionError(); } } @Override // com.qq.taf.jce.JceStruct public final void display(StringBuilder sb, int i) { JceDisplayer jceDisplayer = new JceDisplayer(sb, i); jceDisplayer.display(this.engineVersion, "engineVersion"); jceDisplayer.display(this.guid, WupConfig.KEY_GUID); jceDisplayer.display(this.imei, "imei"); jceDisplayer.display(this.imsi, "imsi"); jceDisplayer.display(this.connectType, "connectType"); jceDisplayer.display(this.isRoot, "isRoot"); } public final boolean equals(Object obj) { if (obj == null) { return false; } CheckClientInfo checkClientInfo = (CheckClientInfo) obj; return JceUtil.equals(this.engineVersion, checkClientInfo.engineVersion) && JceUtil.equals(this.guid, checkClientInfo.guid) && JceUtil.equals(this.imei, checkClientInfo.imei) && JceUtil.equals(this.imsi, checkClientInfo.imsi) && JceUtil.equals(this.connectType, checkClientInfo.connectType) && JceUtil.equals(this.isRoot, checkClientInfo.isRoot); } public final String fullClassName() { return "QQPIM.CheckClientInfo"; } public final int getConnectType() { return this.connectType; } public final int getEngineVersion() { return this.engineVersion; } public final String getGuid() { return this.guid; } public final String getImei() { return this.imei; } public final String getImsi() { return this.imsi; } public final boolean getIsRoot() { return this.isRoot; } public final int hashCode() { try { throw new Exception("Need define key first!"); } catch (Exception e) { e.printStackTrace(); return 0; } } @Override // com.qq.taf.jce.JceStruct public final void readFrom(JceInputStream jceInputStream) { this.engineVersion = jceInputStream.read(this.engineVersion, 0, true); this.guid = jceInputStream.readString(1, true); this.imei = jceInputStream.readString(2, false); this.imsi = jceInputStream.readString(3, false); this.connectType = jceInputStream.read(this.connectType, 4, false); this.isRoot = jceInputStream.read(this.isRoot, 5, false); } public final void setConnectType(int i) { this.connectType = i; } public final void setEngineVersion(int i) { this.engineVersion = i; } public final void setGuid(String str) { this.guid = str; } public final void setImei(String str) { this.imei = str; } public final void setImsi(String str) { this.imsi = str; } public final void setIsRoot(boolean z) { this.isRoot = z; } @Override // com.qq.taf.jce.JceStruct public final void writeTo(JceOutputStream jceOutputStream) { jceOutputStream.write(this.engineVersion, 0); jceOutputStream.write(this.guid, 1); if (this.imei != null) { jceOutputStream.write(this.imei, 2); } if (this.imsi != null) { jceOutputStream.write(this.imsi, 3); } jceOutputStream.write(this.connectType, 4); jceOutputStream.write(this.isRoot, 5); } }
true
92ec0117cba321d04a1c9500226595caf62b2c1c
Java
subhashreddy22/car-pooling-surcharge-calculator-service
/src/main/java/com/car/pooling/surcharge/controller/SurchargeController.java
UTF-8
4,288
2.71875
3
[]
no_license
package com.car.pooling.surcharge.controller; import java.text.DecimalFormat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import com.car.pooling.surcharge.config.ApplicationProperties; import com.car.pooling.surcharge.controller.model.CarPriceDetails; import com.car.pooling.surcharge.controller.model.PriceDetails; /** * The Class SurchargeController. */ @RestController public class SurchargeController { /** * The properties. * This autowires the properties from application.yml to this class. * */ @Autowired private ApplicationProperties properties; /** * The rest template. * * This is the library provided by Spring Boot * to communicate with other rest services. */ @Autowired private RestTemplate restTemplate; /** * The car details url. * @Value is used to fetch the details from application.yml * The url for fetching the car price details will be injected in to the field */ @Value("${car.details.url}") private String carDetailsUrl; /** * Gets the price details. * Receives noOfDays and FIN as input * Returns the Price Details like basePrice, surchargePrice, totalPrice * * This a GET method with URI /car/pooling/surcharge * Please refer README.md for further info * * @param noOfDays the no of days * @param FIN the fin * @return the price details */ @GetMapping(value = "/car/pooling/surcharge", produces = MediaType.APPLICATION_JSON_VALUE) public PriceDetails getPriceDetails(@RequestParam int noOfDays, @RequestParam String FIN) { // create a httpEntity which is required for REST communication HttpEntity<String> httpEntity = new HttpEntity<>(null); // REST communication with another service using restTemplate // and fetching the required car data based on FIN ResponseEntity<CarPriceDetails> carEntity = restTemplate.exchange(carDetailsUrl, HttpMethod.GET, httpEntity, CarPriceDetails.class, FIN); // getting CarpriceDetails from the response entity retrieved above CarPriceDetails carPriceDetails = carEntity.getBody(); // calling the getSurcharge method to get the surcharge percentage with the above retrieved price details int surcharge = this.getSurcharge(carPriceDetails.getEnginePower(), carPriceDetails.getLocation()); // fetching basePrice per day double basePrice = carPriceDetails.getBasePrice(); // calculating surcharge per day double surchargePerDay = (surcharge * basePrice) / 100; // calculating totalPrice double totalPrice = noOfDays * (basePrice + surchargePerDay); // creating a decimalFormat object to format prices with 2 decimal points precision DecimalFormat numberFormat = new DecimalFormat("#.00"); // constructs a PriceDetails object and return as output return new PriceDetails(basePrice, Double.parseDouble(numberFormat.format(surchargePerDay)), Double.parseDouble(numberFormat.format(totalPrice))); } /** * Gets the surcharge percentage. * * Method to get the surcharge percentage based on the enginePower and location * * @param enginePower the engine power * @param location the location * @return the surcharge */ private int getSurcharge(short enginePower, String location) { if (enginePower <= 140) { return properties.getLessThan140Map().get(location); } else if (enginePower > 140 && enginePower <= 200) { return properties.getLessThan200Map().get(location); } else if (enginePower > 200 && enginePower <= 320) { return properties.getLessThan320Map().get(location); } else if (enginePower > 320 && enginePower <= 400) { return properties.getLessThan400Map().get(location); } else { return properties.getGreaterThan400Map().get(location); } } }
true
175c55e3474241e27120bf2d3f5213892ca56a34
Java
WDayan/Prog1Prova2
/Writter.java
UTF-8
148
2
2
[]
no_license
class Writter{ private Elemento [] v; public void setElemento(Elemento e){ } public Elemento getElemento(){ return this.v[1]; } }
true
4b70e58adb2cfc2b12499f7b578c387dcbc15821
Java
muyaaho/eclipse
/Practice_Chap08(변수와 메서드)/src/example05/FactorialEx.java
UHC
634
3.984375
4
[]
no_license
package example05; public class FactorialEx { public static void main(String[] args) { System.out.println("5! = " + factorial(5L)); // Ʈ Լ ǰ 丮 ÿ // factorial() Լ ǰ println()Լ } public static long factorial(long n) { long result = 0L; // n 1 , ȣ . f(1) = 1 if (n==1) result = 1; else { System.out.println("result: "+result+"n: "+n); result = n * factorial(n-1); // ȣ ̷° } return result; } }
true
0ca602c99fb0403f66ad0c84429fa41901ae8977
Java
amagana10/Week3WeekendHW
/app/src/main/java/com/example/navtest/Frag3FindUpdateOrDeleteEmployee.java
UTF-8
6,078
2.203125
2
[]
no_license
package com.example.navtest; import android.content.Context; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; /** * A simple {@link Fragment} subclass. * Activities that contain this fragment must implement the * {@link OnFragment3InteractionListener} interface * to handle interaction events. * Use the {@link Frag3FindUpdateOrDeleteEmployee#newInstance} factory method to * create an instance of this fragment. */ public class Frag3FindUpdateOrDeleteEmployee extends Fragment implements View.OnClickListener{ EditText etSearchID; EditText etEditName; EditText etEditBday; EditText etEditWage; EditText etEditHireDate; EditText etEditImage; Button btnSearch; Button btnEdit; Button btnDelete; Employee loadedEmployee; boolean isEmployeeloaded =false; private OnFragment3InteractionListener mListener; public Frag3FindUpdateOrDeleteEmployee() { // Required empty public constructor } // TODO: Rename and change types and number of parameters public static Frag3FindUpdateOrDeleteEmployee newInstance() { Frag3FindUpdateOrDeleteEmployee fragment = new Frag3FindUpdateOrDeleteEmployee(); Bundle args = new Bundle(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_frag3_find_update_or_delete_employee, container, false); } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); etSearchID = view.findViewById(R.id.etEditEmpID); etEditName = view.findViewById(R.id.etEditEmpName); etEditBday = view.findViewById(R.id.etEditEmpBday); etEditWage = view.findViewById(R.id.etEditEmpWage); etEditHireDate = view.findViewById(R.id.etEditEmpHireDate); etEditImage = view.findViewById(R.id.etEditEmpImage); btnSearch = view.findViewById(R.id.btnSearchEmployee); btnEdit = view.findViewById(R.id.btnEditEmployee); btnDelete = view.findViewById(R.id.btnDeleteEmployee); btnSearch.setOnClickListener(this); btnEdit.setOnClickListener(this); btnDelete.setOnClickListener(this); } // TODO: Rename method, update argument and hook method into UI event public void onButtonPressed(Uri uri) { } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnFragment3InteractionListener) { mListener = (OnFragment3InteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnFragment1InteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } @Override public void onClick(View v) { EmployeeDBHelper employeeDBHelper= new EmployeeDBHelper(getContext()); switch (v.getId()){ case R.id.btnSearchEmployee: if (etSearchID.getText()!= null){ int id = Integer.parseInt(etSearchID.getText().toString()); loadedEmployee = employeeDBHelper.getEmployeeByID(id); etEditName.setText(loadedEmployee.getName()); etEditBday.setText(loadedEmployee.getBirthday()); etEditWage.setText(loadedEmployee.getWage()); etEditHireDate.setText(loadedEmployee.getHiredate()); etEditImage.setText(loadedEmployee.getImage()); isEmployeeloaded = true; } break; case R.id.btnEditEmployee: if (mListener != null && isEmployeeloaded) { if (etSearchID.getText()!= null) { loadedEmployee.setName(etEditName.getText().toString()); loadedEmployee.setBirthday(etEditBday.getText().toString()); loadedEmployee.setWage(etEditWage.getText().toString()); loadedEmployee.setHiredate(etEditHireDate.getText().toString()); loadedEmployee.setImage(etEditImage.getText().toString()); mListener.onFragment3InteractionEdit(loadedEmployee); } } break; case R.id.btnDeleteEmployee: if (mListener != null && isEmployeeloaded) { if (etSearchID.getText()!= null) { mListener.onFragment3InteractionDelete(loadedEmployee); } } break; } } /** * This interface must be implemented by activities that contain this * fragment to allow an interaction in this fragment to be communicated * to the activity and potentially other fragments contained in that * activity. * <p> * See the Android Training lesson <a href= * "http://developer.android.com/training/basics/fragments/communicating.html" * >Communicating with Other Fragments</a> for more information. */ public interface OnFragment3InteractionListener { // TODO: Update argument type and name void onFragment3InteractionEdit(Employee employee); void onFragment3InteractionDelete(Employee employee); } }
true
d2dfe6d334a5877a9b7f2e87031b46c70884247e
Java
TeacherGaming/qcraft-mod
/src/main/java/dan200/qcraft/shared/QCraftCommand.java
UTF-8
3,962
2.109375
2
[ "Apache-2.0" ]
permissive
/* Copyright 2014 Google Inc. All rights reserved. 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 dan200.qcraft.shared; import dan200.QCraft; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import java.util.ArrayList; import java.util.List; public class QCraftCommand implements ICommand { private String m_name; private List m_aliases; public QCraftCommand() { m_name = "qcraft"; m_aliases = new ArrayList( 1 ); m_aliases.add( m_name ); } @Override public String getCommandName() { return m_name; } @Override public String getCommandUsage( ICommandSender icommandsender ) { return "/" + m_name + " verify [playername]"; } @Override public List getCommandAliases() { return m_aliases; } @Override public void processCommand( ICommandSender icommandsender, String[] astring ) { if( !(icommandsender instanceof EntityPlayer) ) { return; } EntityPlayer player = (EntityPlayer)icommandsender; String verb = (astring.length >= 1) ? astring[0] : null; if( verb != null && verb.equals( "verify" ) ) { // verify EntityPlayer targetPlayer; if( astring.length >= 2 ) { String targetPlayerName = astring[1]; targetPlayer = MinecraftServer.getServer().getConfigurationManager().func_152612_a( targetPlayerName ); } else { targetPlayer = player; } if( targetPlayer == null ) { sendChat( icommandsender, "There is no such player" ); } else if( QCraft.canPlayerVerifyPortalServers( player ) ) { QCraft.verifyUnverifiedLuggage( player, targetPlayer ); } else if( QCraft.canAnybodyVerifyPortalServers() ) { sendChat( icommandsender, "You must be an admin to verify this server link." ); } else { sendChat( icommandsender, "This server does not allow incoming inter-server portals." ); } } else { // Unknown sendUsage( icommandsender ); } } private void sendUsage( ICommandSender icommandsender ) { sendChat( icommandsender, "Usage: " + getCommandUsage( icommandsender ) ); } private void sendChat( ICommandSender icommandsender, String text ) { icommandsender.addChatMessage( new ChatComponentText( text ) ); } @Override public boolean canCommandSenderUseCommand( ICommandSender icommandsender ) { return (icommandsender instanceof EntityPlayer); } @Override public List addTabCompletionOptions( ICommandSender icommandsender, String[] astring ) { return null; } @Override public boolean isUsernameIndex( String[] astring, int i ) { return false; } @Override public int compareTo( Object o ) { if( o instanceof ICommand ) { return ((ICommand)o).getCommandName().compareTo( getCommandName() ); } return 0; } }
true
0217ba626d19d32f2546b463ec76710ea25bf0da
Java
williamjava/java_practise
/practise/src/main/java/com/gui/practise/base/RecursionTest.java
UTF-8
1,335
4.15625
4
[]
no_license
package com.gui.practise.base; /** * 递归算法 */ public class RecursionTest { public static void main(String[] args) { System.out.println("1-100之间的数字之和为:" + sum(100)); System.out.println("斐波那契数列中第20个数是多少:" + fun(20)); System.out.println("10阶乘是多少:" + multipy(10)); } /** * 1-100之间的数字之和 * @param num * @return */ private static Integer sum(int num){ if (num == 1) { return 1; } else { return num * multipy(num - 1); } } /** * 斐波那契数列(获取第20个数) * 斐波那契数列数列从第3项开始,每一项都等于前两项之和。 * 例子:数列 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368........ * @return */ private static Integer fun(Integer n){ if (n == 1 || n == 2) { return 1; } else { return fun(n - 1) + fun(n-2); } } /** * 10阶乘 * @param num * @return */ private static Integer multipy(int num) { if (num == 1) { return num; } else { return num * multipy(num - 1); } } }
true
6c1583f66d4602f205060dcbe1303566842d861c
Java
EugenePetrik/java_selenium_pom
/src/test/java/horizontalslidertests/HorizontalSliderTests.java
UTF-8
897
2.859375
3
[]
no_license
package horizontalslidertests; import base.TestUtilities; import org.testng.annotations.Test; import pages.HorizontalSliderPage; import pages.WelcomePage; import static org.testng.Assert.assertTrue; public class HorizontalSliderTests extends TestUtilities { @Test public void sliderTest() { // Open main page WelcomePage welcomePage = new WelcomePage(driver, log); welcomePage.openPage(); // Click on Horizontal Slider link HorizontalSliderPage horizontalSliderPage = welcomePage.clickHorizontalSliderLink(); // Slider value String value = "3.5"; // Set slider value horizontalSliderPage.setSliderTo(value); // Verify slider value String sliderValue = horizontalSliderPage.getSliderValue(); assertTrue(sliderValue.equals(value), "Range is not correct. It is: " + sliderValue); } }
true
c3bd49be64dadccfb6030fdd7329e19898bdc628
Java
snis-aa/SNBHISv4
/app/src/main/java/com/hospital/snbhis/Doctor.java
UTF-8
2,313
2.0625
2
[]
no_license
package com.hospital.snbhis; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RatingBar; import android.widget.TextView; public class Doctor extends Activity { DoctorClass drclass; TextView textDrName,textDrDegree,textDrExp,textDrFee,textDrDesc,textDrSpeciality; // RatingBar ratingBar1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_doctor); textDrName = (TextView) findViewById(R.id.textDrName); textDrDegree = (TextView) findViewById(R.id.textDrDegree); textDrExp = (TextView) findViewById(R.id.textDrExp); textDrFee = (TextView) findViewById(R.id.textDrFee); textDrDesc = (TextView) findViewById(R.id.textDrDesc); textDrSpeciality = (TextView) findViewById(R.id.textDrSpeciality); // ratingBar1 = (RatingBar) findViewById(R.id.ratingBar1); for(DoctorClass dc:Data.ListDoctor) { if(dc.getiddr()==Data.Iddoctor) { drclass=dc; break; } } textDrName.setText(drclass.getnamedr()); textDrDegree.setText(drclass.getdrdegree()); textDrExp.setText(drclass.getdrexp()); textDrFee.setText(Double.toString(drclass.getfee())); textDrDesc.setText(drclass.getdescription()); textDrSpeciality.setText(drclass.getspeciality()); Button Button1 = (Button) findViewById(R.id.btnappo); Button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), Appointments.class); startActivity(intent); } }); Button Button2 = (Button) findViewById(R.id.btnratedr); Button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), DoctorRate.class); startActivity(intent); } }); } }
true
5dec3b7b6cf0df48b97a3033a5b0d195c8c32a56
Java
sumanth-31/KryTez-Share-Windows
/src/main/java/krytez/KrytezShare.java
UTF-8
41,472
2.109375
2
[]
no_license
package krytez; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.plaf.ButtonUI; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.awt.Color; import java.awt.Component; import java.awt.GridLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Image; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.NoRouteToHostException; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class KrytezShare extends JFrame implements ActionListener { JButton senditb, receiveitb; GridBagConstraints gbc; JLabel layout1; String fname1, fname; public class Server1 { ServerSocket socket; InetAddress inet; long data = 0; int ind = 0; GridBagLayout layout; GridBagConstraints gbc; JLabel uid, pass, panel; Socket servs; File[] files1; ArrayList<File> files; Dimension d; JFileChooser jf; LookAndFeel def; long startt, endt, totalt, maintrans = 0; float rate; double time, datad; boolean startflag = true; boolean errflag = false; JProgressBar cpb; Server1() { remove(layout1); setExtendedState(JFrame.MAXIMIZED_BOTH); files = new ArrayList<>(); String path = System.getProperty("user.dir"); path += "\\backtry6.jpg"; ImageIcon iimg = new ImageIcon(path); try { def = UIManager.getLookAndFeel(); } catch (Exception e) { } /* * Image img = iimg.getImage(); setBounds(0, 0, d.height, d.width); Image * finalimg = img.getScaledInstance(d.height, d.width, Image.SCALE_SMOOTH); iimg * = new ImageIcon(finalimg); */ panel = new JLabel(iimg, JLabel.CENTER); try { inet = InetAddress.getLocalHost(); } catch (Exception e) { JOptionPane.showMessageDialog(KrytezShare.this, "Error occurred while collecting ip address!", "ERROR!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); add(layout1); return; } String ipadd; ipadd = inet.getHostAddress(); if (ipadd.equals("127.0.0.1")) { JOptionPane.showMessageDialog(KrytezShare.this, "Connect to the network and try again !", "WARNING!", JOptionPane.WARNING_MESSAGE); add(layout1); return; } uid = new JLabel("User Id: " + ipadd); pass = new JLabel("Password: "); layout = new GridBagLayout(); gbc = new GridBagConstraints(); panel.setLayout(layout); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; gbc.ipady = 20; gbc.ipadx = 10; gbc.gridwidth = 1; panel.add(uid, gbc); gbc.gridx = 0; gbc.gridy = 1; panel.add(pass, gbc); uid.setFont(font); uid.setForeground(Color.DARK_GRAY); pass.setForeground(Color.DARK_GRAY); pass.setFont(font); add(panel); setVisible(true); d = getSize(); files = new ArrayList<>(); if (select() == 1) { if (startServer() == 1) { } else return; } else return; } Font font = new Font("courier", Font.PLAIN, 24); int generatePort() { Random random = new Random(); int portno = random.nextInt(64511) + 1024; return portno; } void setUI(Component comp) { comp.setBackground(Color.BLACK); comp.setForeground(Color.DARK_GRAY); comp.setFont(font); } // Server connected int portno; int startServer() { try { portno = generatePort(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); cpb = new JProgressBar(); cpb.setIndeterminate(true); cpb.setStringPainted(true); cpb.setString("Waiting for receiver"); cpb.setVisible(true); } catch (Exception e) { } gbc.gridx = 0; gbc.gridy = 2; panel.add(cpb, gbc); revalidate(); repaint(); SwingWorker sw = new SwingWorker<String, String>() { protected String doInBackground() { try { socket = new ServerSocket(portno); SwingUtilities.invokeAndWait(new Runnable() { public void run() { pass.setText("Password: " + portno); JOptionPane.showMessageDialog(getParent(), "Server Started!", "Server Status Report", JOptionPane.INFORMATION_MESSAGE); } }); servs = socket.accept(); send(); } catch (IOException e2) { JOptionPane.showMessageDialog(getParent(), "Error occured.Retrying!", "ERROR!", JOptionPane.ERROR_MESSAGE); if (startServer() == 1) { errflag = false; return "noerr"; } else { errflag = true; return "err"; } } catch (Exception e) { JOptionPane.showMessageDialog(getParent(), "Error occured while connecting to port", "ERROR!", JOptionPane.ERROR_MESSAGE); errflag = true; return "err"; } return "noerr"; } public void done() { try { UIManager.setLookAndFeel(def); } catch (Exception e) { } /* * remove(panel); add(layout1); revalidate(); repaint(); */ } }; sw.execute(); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(KrytezShare.this, "Enter a number", "ERROR!", JOptionPane.ERROR_MESSAGE); } catch (Exception e3) { JOptionPane.showMessageDialog(KrytezShare.this, "Error occured while starting server", "ERROR!", JOptionPane.ERROR_MESSAGE); } if (errflag) { return 0; } else return 1; } int select() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } int j = ind; JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); chooser.showOpenDialog(null); files1 = chooser.getSelectedFiles(); for (File fl : files1) { files.add(fl); ind++; } try { UIManager.setLookAndFeel(def); } catch (Exception e) { } if (ind > 0) { for (; j < ind; j++) { File f = files.get(j); if (f.isDirectory()) { calc(f); } else data += (long) (f.length()); } KrytezShare.this.revalidate(); KrytezShare.this.repaint(); if (JOptionPane.showOptionDialog(getParent(), "Do you want to select more files or do you want to send?", "Confirmation!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Select More files", "Send" }, null) == JOptionPane.YES_OPTION) { select(); return 1; } else { return 1; } } else { JOptionPane.showMessageDialog(getParent(), "You need to select at least one file to send.", "ERROR!", JOptionPane.ERROR_MESSAGE); remove(panel); add(layout1); revalidate(); repaint(); return 0; } } public void calc(File df) { for (File dfa : df.listFiles()) { if (dfa.isDirectory()) { calc(dfa); } else this.data += dfa.length(); } } JProgressBar pb; void send() { try { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); pb = new JProgressBar(0, (int) ((double) data / 1000000)); pb.setStringPainted(true); pb.setString("Transferring files..."); pb.setVisible(true); } catch (Exception e) { } panel.remove(cpb); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 5; gbc.ipadx = 40; panel.add(pb, gbc); revalidate(); repaint(); SwingWorker sw = new SwingWorker<String, String>() { protected String doInBackground() { try { datad = data / 1000000.0; data /= 1000000; int trans = 0; String fullname = "file"; BufferedOutputStream bo = new BufferedOutputStream(servs.getOutputStream()); PrintWriter pw = new PrintWriter(bo, true); BufferedReader br = new BufferedReader(new InputStreamReader(servs.getInputStream())); for (File f : files) { if (f.isDirectory()) { dirTrav(f); continue; } fullname = f.getName(); pw.println(f.length() + " " + fullname); br.readLine(); if (startflag) { pw.println(datad); startflag = false; startt = System.nanoTime(); } bo.flush(); FileInputStream fin = new FileInputStream(f); byte[] buff = new byte[32768]; int length; // publish(fullname, String.valueOf(trans)); br.readLine(); while ((length = fin.read(buff)) != -1) { bo.write(buff, 0, length); bo.flush(); trans += length; if (trans >= 1048576) { maintrans += 1; trans = 0; publish(fullname, String.valueOf(maintrans)); } } bo.flush(); br.readLine(); fin.close(); } if (files.size() > 0) publish("Finished", String.valueOf(data)); pw.println("Finished"); bo.flush(); bo.close(); servs.close(); socket.close(); endt = System.nanoTime(); totalt = endt - startt; time = totalt / 1000000000.0; rate = (float) (datad / time); time = time * 10; time = Math.floor(time) / 10; if (time >= 1) JOptionPane.showMessageDialog(getParent(), "Transfer successful!\nAverage transfer speed: " + rate + "MBps", "INFORMATION!", JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(getParent(), "Transfer successful!", "INFORMATION!", JOptionPane.INFORMATION_MESSAGE); startflag = true; try { UIManager.setLookAndFeel(def); } catch (Exception e) { } } catch (SocketException e) { JOptionPane.showMessageDialog(getParent(), "Error occured while transferring.\nCheck for connection or storage permission or connection.", "ERROR!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog(getParent(), "Error occured!Contact KryTez team for support.", "ERROR!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } return null; } @Override public void process(List<String> f) { pb.setString("Transferring file: " + f.get(0) + " " + f.get(1) + "MB/" + data); pb.setValue(Integer.parseInt(f.get(1))); } protected void done() { try { servs.close(); socket.close(); } catch (Exception e) { } panel.remove(pb); setSize(d); files.clear(); data = 0; ind = 0; pb.setString("Transferring files..."); remove(panel); add(layout1); revalidate(); repaint(); } }; sw.execute(); } catch (Exception e) { JOptionPane.showMessageDialog(KrytezShare.this, "Error occured!Contact KryTez team for support.\nConatct info at KryTezTechnologies.netlify.com", "ERROR!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } public void dirTrav(File df) { try { DataOutputStream bo = new DataOutputStream(servs.getOutputStream()); PrintWriter pw = new PrintWriter(bo, true); BufferedReader br = new BufferedReader(new InputStreamReader(servs.getInputStream())); pw.println("Dir"); pw.flush(); br.readLine(); fname1 = df.getName(); pw.println(fname1); pw.flush(); br.readLine(); for (File doc : df.listFiles()) { if (doc.isDirectory()) { dirTrav(doc); } else { FileInputStream is = new FileInputStream(doc); fname1 = doc.getName(); pw.println(doc.length() + " " + fname1); br.readLine(); if (startflag) { pw.println(datad); startflag = false; startt = System.nanoTime(); } int len; long trans = 0; byte buff[] = new byte[32768]; br.readLine(); while ((len = is.read(buff)) != -1) { bo.write(buff, 0, len); bo.flush(); trans += len; if (trans >= 1048576) { maintrans += 1; SwingUtilities.invokeAndWait(new Runnable() { public void run() { pb.setString( "Transferring file: " + fname1 + " " + maintrans + "MB/" + data + "MB"); pb.setValue((int) maintrans); } }); trans = 0; } } bo.flush(); br.readLine(); is.close(); } } pw.println("Dirend"); pw.flush(); br.readLine(); bo.flush(); return; } catch (Exception e) { e.printStackTrace(); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(KrytezShare.this, "Error Occured!", "ERROR!", JOptionPane.ERROR_MESSAGE); } }); } catch (Exception ex) { ex.printStackTrace(); } } } } class Client1 implements ActionListener { JTextField ip, port; String totaldata; float rate; int data; JButton conn, back; JLabel panel; JProgressBar pb; GridBagConstraints gbc; Font font; Dimension dim; long trans; Socket socket; Client1() { remove(layout1); InetAddress inet; try { inet = InetAddress.getLocalHost(); } catch (Exception e) { JOptionPane.showMessageDialog(KrytezShare.this, "Error occurred while collecting ip address!", "ERROR!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); add(layout1); return; } String ipadd; ipadd = inet.getHostAddress(); if (ipadd.equals("127.0.0.1")) { JOptionPane.showMessageDialog(KrytezShare.this, "Connect to the network and restart app!", "WARNING!", JOptionPane.WARNING_MESSAGE); add(layout1); return; } String path = System.getProperty("user.dir"); path += "\\backtry6.jpg"; ImageIcon iimg = new ImageIcon(path); panel = new JLabel(iimg, JLabel.CENTER); ip = new JTextField("Enter username of sender"); port = new JTextField("Enter password of sender"); conn = new JButton("Connect"); conn.addActionListener(this); pb = new JProgressBar(); pb.setIndeterminate(true); pb.setStringPainted(true); back = new JButton("Back"); pb.setString("Waiting for files..."); font = new Font("courier", Font.PLAIN, 18); ip.setFont(font); port.setFont(font); conn.setFont(font); conn.setForeground(Color.DARK_GRAY); panel.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; gbc.ipadx = 40; gbc.ipady = 30; gbc.insets = new Insets(10, 0, 0, 0); gbc.gridwidth = 4; panel.add(ip, gbc); gbc.gridx = 0; gbc.gridy = 2; panel.add(port, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.insets = new Insets(10, 0, 0, 0); panel.add(conn, gbc); gbc.gridy = 5; panel.add(back, gbc); back.setContentAreaFilled(false); back.setOpaque(false); back.setFont(font); back.addActionListener(this); back.setForeground(Color.DARK_GRAY); conn.setContentAreaFilled(false); conn.setOpaque(false); add(panel); setVisible(true); setExtendedState(JFrame.MAXIMIZED_BOTH); dim = getSize(); } SwingWorker sw; String ipadd, file; int portno; boolean finflag = false; boolean start = true; long starttime, endtime, totaltime; BufferedInputStream is; FileOutputStream fos; long maintrans = 0; double datad; void reset() { gbc.gridx = 0; gbc.gridy = 0; gbc.ipadx = 40; gbc.ipady = 30; gbc.insets = new Insets(10, 0, 0, 0); gbc.gridwidth = 4; panel.add(ip, gbc); gbc.gridx = 0; gbc.gridy = 2; panel.add(port, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.insets = new Insets(10, 0, 0, 0); panel.add(conn, gbc); gbc.gridy = 5; panel.add(back, gbc); remove(panel); add(layout1); revalidate(); repaint(); } public void initUI() { reset(); revalidate(); repaint(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == conn) { try { ipadd = ip.getText(); portno = Integer.parseInt(port.getText()); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(getParent(), "Enter a proper User Id and password!", "ERROR!", JOptionPane.ERROR_MESSAGE); initUI(); } panel.remove(ip); panel.remove(port); panel.remove(conn); panel.remove(back); gbc.gridy = 0; gbc.gridwidth = 8; gbc.ipadx = 120; panel.add(pb, gbc); gbc.gridy = 1; panel.add(back, gbc); revalidate(); repaint(); sw = new SwingWorker<String, String>() { @Override protected String doInBackground() throws Exception { BufferedReader br; BufferedOutputStream bo; PrintWriter pw; trans = 0; maintrans = 0; try { socket = new Socket(ipadd, portno); br = new BufferedReader(new InputStreamReader(socket.getInputStream())); bo = new BufferedOutputStream(socket.getOutputStream()); pw = new PrintWriter(bo, true); while (true) { file = br.readLine(); String path = System.getProperty("user.dir"); File dir = new File(path + "\\Received Files"); if (dir.exists()) ; else if (dir.mkdir()) ; else { JOptionPane.showMessageDialog(KrytezShare.this, "Can't create folder to save files.Try running in administrator mode", "ERROR!", JOptionPane.ERROR_MESSAGE); reset(); socket.close(); return "err"; } if (file.equals("Finished")) { br.close(); socket.close(); finflag = true; break; } else if (file.equals("Dir")) { pw.println("done"); file = br.readLine(); pw.println("Done"); pw.flush(); dirTrav(path + "\\Received Files", file); continue; } String filedata[] = file.split(" "); long filelen = Long.parseLong(filedata[0]); file = file.substring(filedata[0].length()); long transferred = 0; File f = new File(dir + "\\" + file); byte[] buff = new byte[32768]; int len; int i = 0; pw.println("done"); pw.flush(); while (f.exists()) { f = new File(dir + "\\" + "(" + i + ")" + file); i++; } pw.println("done"); pw.flush(); if (start) { totaldata = br.readLine(); datad = Double.parseDouble(totaldata); data = (int) datad; starttime = System.nanoTime(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { pb.setIndeterminate(false); pb.setMaximum((int) data); pb.setMinimum(0); } }); start = false; } is = new BufferedInputStream(socket.getInputStream()); fos = new FileOutputStream(f); publish(file); if (filelen == 0) { fos.flush(); fos.close(); pw.println("received"); pw.flush(); continue; } while ((len = is.read(buff)) != -1) { fos.write(buff, 0, len); trans += len; if (trans >= 1048576) { maintrans += 1; trans = 0; publish(file); } transferred += len; if (transferred == filelen) break; } fos.flush(); fos.close(); pw.println("received"); pw.flush(); } } catch (UnknownHostException e) { JOptionPane.showMessageDialog(getParent(), "Enter a proper User Id and password!", "ERROR!", JOptionPane.ERROR_MESSAGE); initUI(); } catch (NoRouteToHostException e) { JOptionPane.showMessageDialog(getParent(), "Enter a proper User Id and password!", "ERROR!", JOptionPane.ERROR_MESSAGE); initUI(); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(getParent(), "Error occured!Try checking connection!", "ERROR!", JOptionPane.ERROR_MESSAGE); initUI(); } endtime = System.nanoTime(); start = true; totaltime = endtime - starttime; return null; } public void process(List<String> f) { pb.setString("Transferring: " + f.get(0) + " " + maintrans + "MB/" + (int) data + "MB"); pb.setValue((int) (maintrans)); } public void done() { initUI(); if (finflag) { finflag = false; double time = totaltime / 1000000000.0; time = time * 10; time = Math.floor(time) / 10; rate = (float) (datad / time); if (totaltime >= 1) JOptionPane.showMessageDialog(getParent(), "Transfer successful!\nAverage transfer speed: " + rate + "MBps\nFiles will be saved in " + System.getProperty("user.dir") + "\\Received Files", "INFORMATION!", JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog( getParent(), "Transfer successful!\nFiles will be saved in " + System.getProperty("user.dir") + "\\Received Files", "INFORMATION!", JOptionPane.INFORMATION_MESSAGE); } try { is.close(); fos.close(); socket.close(); } catch (Exception e) { // nothin } reset(); revalidate(); repaint(); } }; sw.execute(); } else if (e.getSource() == back) { try { is.close(); fos.close(); socket.close(); } catch (Exception e1) { // nothin } reset(); } } public void dirTrav(String path, String file) { File f = new File(path, file); int index = 0; while (f.exists()) { f = new File(path, "(" + index + ")" + file); index++; } if (!f.mkdir()) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(KrytezShare.this, "Error Occured!\nCould not create folder.\nIf the app is installed in system drive, kindly run as administrator.", "ERROR!", JOptionPane.ERROR_MESSAGE); } }); } catch (Exception ex) { ex.printStackTrace(); } } try { DataOutputStream bo = null; while (true) { try { bo = new DataOutputStream(socket.getOutputStream()); } catch (Exception ex1) { // System.out.println(886); } PrintWriter pw = new PrintWriter(bo, true); BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); BufferedInputStream is = new BufferedInputStream(socket.getInputStream()); if ((fname = br.readLine()).equals("Dirend")) { // System.out.println(fname); pw.println("done"); pw.flush(); break; } // System.out.println(fname); if (fname.equals("Dir")) { pw.println("done"); pw.flush(); file = br.readLine(); pw.println("Done"); pw.flush(); dirTrav(f.getPath(), file); continue; } String filedata[] = fname.split(" "); long filelen = Long.parseLong(filedata[0]); fname = fname.substring(filedata[0].length()); long transferred = 0; // System.out.println(fname + " length is " + filelen); pw.println("Done"); pw.flush(); File f1 = new File(f, fname); // System.out.println(896); if (start) { totaldata = br.readLine(); datad = Double.parseDouble(totaldata); data = (int) datad; starttime = System.nanoTime(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { pb.setIndeterminate(false); pb.setMaximum((int) data); pb.setMinimum(0); } }); start = false; } // System.out.println(911); int len; byte[] buff = new byte[32768]; FileOutputStream fos = new FileOutputStream(f1); pw.println("done"); pw.flush(); long transd = 0; // System.out.println(917); if (filelen == 0) { fos.flush(); fos.close(); pw.println("received"); pw.flush(); continue; } while ((len = is.read(buff)) != -1) { fos.write(buff, 0, len); fos.flush(); transd += len; if (transd >= 1048576) { maintrans += 1; SwingUtilities.invokeAndWait(new Runnable() { public void run() { pb.setString("Transferring file: " + fname + " " + maintrans + "MB/" + data + "MB"); pb.setValue((int) maintrans); } }); transd = 0; } transferred += len; if (transferred == filelen) break; } fos.flush(); fos.close(); pw.println("received"); pw.flush(); } } catch (Exception e) { e.printStackTrace(); // System.out.println(952); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(KrytezShare.this, "Error Occured!", "ERROR!", JOptionPane.ERROR_MESSAGE); } }); } catch (Exception ex) { ex.printStackTrace(); } } } } KrytezShare() { setTitle("KryTez Share"); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JOptionPane.showMessageDialog(this, "If the app is installed in System drive(C:),\nplease run in administrator mode to share files.\nWithout admin permission,app can't write to c drive."); Font font = new Font("courier", Font.PLAIN, 24); senditb = new JButton("Send"); senditb.addActionListener(this); senditb.setForeground(Color.DARK_GRAY); senditb.setFont(font); receiveitb = new JButton("Receive"); receiveitb.addActionListener(this); receiveitb.setFont(font); receiveitb.setForeground(Color.DARK_GRAY); String path = System.getProperty("user.dir"); path += "\\Background_2.jpg"; ImageIcon icon = new ImageIcon(path); layout1 = new JLabel(icon, JLabel.CENTER); layout1.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; gbc.ipadx = 10; gbc.ipady = 20; layout1.add(senditb, gbc); gbc.gridy = 1; Insets inset = new Insets(20, 0, 0, 0); gbc.insets = inset; layout1.add(receiveitb, gbc); senditb.setContentAreaFilled(false); senditb.setOpaque(false); receiveitb.setContentAreaFilled(false); receiveitb.setOpaque(false); add(layout1); setVisible(true); setExtendedState(JFrame.MAXIMIZED_BOTH); } public void actionPerformed(ActionEvent e) { if (e.getSource() == senditb) { Server1 server = new Server1(); } else { Client1 client = new Client1(); } } }
true
06e2b31e3e16df0edc0022412a4db39f42cf2ab6
Java
wjohnson000/wlj-place-test
/src/main/java/std/wlj/pom/PomFile.java
UTF-8
603
1.820313
2
[]
no_license
package std.wlj.pom; import java.util.*; public class PomFile { // Basic properties ... String groupId; String artifactId; String version; String name; String directory; // Parent, children Dependency parent; PomFile parentPom; List<PomFile> children = new ArrayList<>(); // Details Map<String,String> properties = new TreeMap<>(); Set<String> propertyUsage = new TreeSet<>(); List<Dependency> managedDependencies = new ArrayList<>(); List<Dependency> dependencies = new ArrayList<>(); List<Plugin> managedPlugins = new ArrayList<>(); List<Plugin> plugins = new ArrayList<>(); }
true
cf939a95399d20d4ee767d3c2fc1747e64612ca3
Java
Dominika-L/Homework
/lesson7/ElectricCar.java
UTF-8
220
2.546875
3
[]
no_license
package homeworks.lesson7; public class ElectricCar extends Car implements Chargable { public ElectricCar(String manufacturer, String model, String type) { super(manufacturer, model, type); } }
true
89e22f9d7602f59dedebc2ebcd5fb94ea5db05c3
Java
android-misc-examples/PermissionManagementExample
/app/src/main/java/it/pgp/permissionmanagementexample/MainActivity.java
UTF-8
2,557
2.625
3
[]
no_license
package it.pgp.permissionmanagementexample; import android.Manifest; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Environment; import android.support.v4.app.ActivityCompat; import android.os.Bundle; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import java.io.File; public class MainActivity extends Activity { public void requestDangerousPermissions() { ActivityCompat.requestPermissions( this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0x11111); } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == 0x11111) { if (grantResults.length == 0) { // request cancelled Toast.makeText(this, "Permissions denied", Toast.LENGTH_SHORT).show(); finishAffinity(); return; } for (int grantResult : grantResults) { if (grantResult != PackageManager.PERMISSION_GRANTED) { Toast.makeText(this, "Permissions denied", Toast.LENGTH_SHORT).show(); finishAffinity(); return; } } Toast.makeText(this, "Permissions granted", Toast.LENGTH_SHORT).show(); Intent i = new Intent(this,MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(i); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView t = findViewById(R.id.textView); Button b = findViewById(R.id.button); b.setOnClickListener(v-> requestDangerousPermissions()); try { File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()); StringBuilder ss = new StringBuilder(); for (File ff : f.listFiles()) { ss.append(ff.getAbsolutePath()); ss.append("\n"); } t.setText(ss.toString()); } catch (Exception e) { e.printStackTrace(); t.setText("Cannot list dir content, please enable write storage permissions"); } } }
true
a37761ef94c197aa55d51c1234570e7217087039
Java
gatherdata/gather-commons
/org.gatherdata.commons.db.db4o/src/main/java/org/gatherdata/commons/db/db4o/model/DescribedEntityDb4o.java
UTF-8
1,453
2.078125
2
[]
no_license
/** * The contents of this file are subject to the AED Public Use License Agreement, Version 1.0 (the "License"); * use in any manner is strictly prohibited except in compliance with the terms of the License. * The License is available at http://gatherdata.org/license. * * Copyright (c) AED. All Rights Reserved */ package org.gatherdata.commons.db.db4o.model; import java.net.URI; import org.gatherdata.commons.model.DescribedEntity; import org.gatherdata.commons.model.UniqueEntity; import org.gatherdata.commons.net.CbidFactory; import org.joda.time.DateTime; public class DescribedEntityDb4o extends UniqueEntityDb4o implements DescribedEntity { protected String description; protected String name; public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public DescribedEntityDb4o copy(DescribedEntity template) { if (template != null) { super.copy(template); setDescription(template.getDescription()); setName(template.getName()); } return this; } public URI selfIdentify() { return CbidFactory.createCbid(getDateCreated() + name + description + Integer.toHexString(hashCode())); } }
true
2436a37aaa8789c1c4ffa25d955ad6c2af9f4820
Java
nacos-group/nacos-examples
/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/impl/UserServiceImpl.java
UTF-8
1,950
2.203125
2
[ "Apache-2.0" ]
permissive
package com.alibaba.nacos.example.spring.cloud.service.impl; import com.alibaba.nacos.example.spring.cloud.dao.UserRepository; import com.alibaba.nacos.example.spring.cloud.model.User; import com.alibaba.nacos.example.spring.cloud.service.UserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; /** * @author hexu.hxy * @date 2019/1/7 */ @Service @RefreshScope public class UserServiceImpl implements UserService { private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class); private final UserRepository userRepository; private final RedisTemplate redisTemplate; @Value("${app.user.cache}") private boolean cache; @Autowired public UserServiceImpl(UserRepository userRepository, RedisTemplate redisTemplate) { this.userRepository = userRepository; this.redisTemplate = redisTemplate; } @Override public User findById(Long id) { LOGGER.info("cache: {}", cache); if (cache) { Object obj = redisTemplate.opsForValue().get(key(id)); if (obj != null) { LOGGER.info("get user from cache, id: {}", id); return (User)obj; } } User user = userRepository.findById(id).orElse(null); if (user != null) { if (cache) { LOGGER.info("set cache for user, id: {}", id); redisTemplate.opsForValue().set(key(id), user); } } return user; } private String key(Long id) { return String.format("nacos-spring-cloud-config-multi-data-ids-example:user:%d", id); } }
true
4ce465bad6ebf77ac8ff079a162898653e04090f
Java
open-keychain/bouncycastle
/core/src/main/java/org/bouncycastle/asn1/ASN1BitString.java
UTF-8
7,825
2.875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
package org.bouncycastle.asn1; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import org.bouncycastle.util.Arrays; import org.bouncycastle.util.io.Streams; /** * Base class for BIT STRING objects */ public abstract class ASN1BitString extends ASN1Primitive implements ASN1String { private static final char[] table = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; protected final byte[] data; protected final int padBits; /** * @param bitString an int containing the BIT STRING * @return the correct number of pad bits for a bit string defined in * a 32 bit constant */ static protected int getPadBits( int bitString) { int val = 0; for (int i = 3; i >= 0; i--) { // // this may look a little odd, but if it isn't done like this pre jdk1.2 // JVM's break! // if (i != 0) { if ((bitString >> (i * 8)) != 0) { val = (bitString >> (i * 8)) & 0xFF; break; } } else { if (bitString != 0) { val = bitString & 0xFF; break; } } } if (val == 0) { return 0; } int bits = 1; while (((val <<= 1) & 0xFF) != 0) { bits++; } return 8 - bits; } /** * @param bitString an int containing the BIT STRING * @return the correct number of bytes for a bit string defined in * a 32 bit constant */ static protected byte[] getBytes(int bitString) { if (bitString == 0) { return new byte[0]; } int bytes = 4; for (int i = 3; i >= 1; i--) { if ((bitString & (0xFF << (i * 8))) != 0) { break; } bytes--; } byte[] result = new byte[bytes]; for (int i = 0; i < bytes; i++) { result[i] = (byte) ((bitString >> (i * 8)) & 0xFF); } return result; } protected ASN1BitString(byte data, int padBits) { if (padBits > 7 || padBits < 0) { throw new IllegalArgumentException("pad bits cannot be greater than 7 or less than 0"); } this.data = new byte[]{ data }; this.padBits = padBits; } /** * Base constructor. * * @param data the octets making up the bit string. * @param padBits the number of extra bits at the end of the string. */ public ASN1BitString( byte[] data, int padBits) { if (data == null) { throw new NullPointerException("'data' cannot be null"); } if (data.length == 0 && padBits != 0) { throw new IllegalArgumentException("zero length data with non-zero pad bits"); } if (padBits > 7 || padBits < 0) { throw new IllegalArgumentException("pad bits cannot be greater than 7 or less than 0"); } this.data = Arrays.clone(data); this.padBits = padBits; } /** * Return a String representation of this BIT STRING * * @return a String representation. */ public String getString() { StringBuffer buf = new StringBuffer("#"); byte[] string; try { string = getEncoded(); } catch (IOException e) { throw new ASN1ParsingException("Internal error encoding BitString: " + e.getMessage(), e); } for (int i = 0; i != string.length; i++) { buf.append(table[(string[i] >>> 4) & 0xf]); buf.append(table[string[i] & 0xf]); } return buf.toString(); } /** * @return the value of the bit string as an int (truncating if necessary) */ public int intValue() { int value = 0; int end = Math.min(4, data.length - 1); for (int i = 0; i < end; ++i) { value |= (data[i] & 0xFF) << (8 * i); } if (0 <= end && end < 4) { byte der = (byte)(data[end] & (0xFF << padBits)); value |= (der & 0xFF) << (8 * end); } return value; } /** * Return the octets contained in this BIT STRING, checking that this BIT STRING really * does represent an octet aligned string. Only use this method when the standard you are * following dictates that the BIT STRING will be octet aligned. * * @return a copy of the octet aligned data. */ public byte[] getOctets() { if (padBits != 0) { throw new IllegalStateException("attempt to get non-octet aligned data from BIT STRING"); } return Arrays.clone(data); } public byte[] getBytes() { if (0 == data.length) { return data; } byte[] rv = Arrays.clone(data); // DER requires pad bits be zero rv[data.length - 1] &= (0xFF << padBits); return rv; } public int getPadBits() { return padBits; } public String toString() { return getString(); } public int hashCode() { int end = data.length; if (--end < 0) { return 1; } byte der = (byte)(data[end] & (0xFF << padBits)); int hc = Arrays.hashCode(data, 0, end); hc *= 257; hc ^= der; return hc ^ padBits; } boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof ASN1BitString)) { return false; } ASN1BitString other = (ASN1BitString)o; if (padBits != other.padBits) { return false; } byte[] a = data, b = other.data; int end = a.length; if (end != b.length) { return false; } if (--end < 0) { return true; } for (int i = 0; i < end; ++i) { if (a[i] != b[i]) { return false; } } byte derA = (byte)(a[end] & (0xFF << padBits)); byte derB = (byte)(b[end] & (0xFF << padBits)); return derA == derB; } static ASN1BitString fromInputStream(int length, InputStream stream) throws IOException { if (length < 1) { throw new IllegalArgumentException("truncated BIT STRING detected"); } int padBits = stream.read(); byte[] data = new byte[length - 1]; if (data.length != 0) { if (Streams.readFully(stream, data) != data.length) { throw new EOFException("EOF encountered in middle of BIT STRING"); } if (padBits > 0 && padBits < 8) { if (data[data.length - 1] != (byte)(data[data.length - 1] & (0xFF << padBits))) { return new DLBitString(data, padBits); } } } return new DERBitString(data, padBits); } public ASN1Primitive getLoadedObject() { return this.toASN1Primitive(); } ASN1Primitive toDERObject() { return new DERBitString(data, padBits); } ASN1Primitive toDLObject() { return new DLBitString(data, padBits); } abstract void encode(ASN1OutputStream out, boolean withTag) throws IOException; }
true
fdedb37d68f751753eae0608d0b48d5887c0cd13
Java
zhangliang0115/jboot
/src/test/java/io/jboot/test/validate/ValidateController.java
UTF-8
838
1.890625
2
[ "Apache-2.0" ]
permissive
package io.jboot.test.validate; import com.jfinal.core.Controller; import io.jboot.web.controller.annotation.RequestMapping; import io.jboot.web.validate.EmptyValidate; import io.jboot.web.validate.Form; import io.jboot.web.validate.UrlParaValidate; import io.jboot.web.validate.ValidateRenderType; @RequestMapping("/validate") public class ValidateController extends Controller { public void index(){ renderText("index"); } @UrlParaValidate public void test1(){ renderText("test1"); } @UrlParaValidate(renderType = ValidateRenderType.TEXT,message = "test2 was verification failed") public void test2(){ renderText("test2"); } @EmptyValidate(value = @Form(name = "form"),renderType = ValidateRenderType.JSON) public void test3(){ renderText("test3"); } }
true
586f2559951b5b116cfd3e98dff154e7798aa4aa
Java
itskshitizsh/Bhukhad-Customer-Side
/app/src/main/java/com/itskshitizsh/bhukhad/Purchased.java
UTF-8
693
2.609375
3
[]
no_license
package com.itskshitizsh.bhukhad; public class Purchased { Item item; int quantity; double total_price; int canteen_id; public Item getItem() { return item; } public Purchased(Item item, int quantity) { this.item = item; this.quantity = quantity; this.canteen_id = item.getCanteen_id(); } public int getQuantity() { return quantity; } public int getCanteen_id() { return canteen_id; } public double getTotal_price() { total_price=quantity*(item.getPrice()); return total_price; } public void setQuantity(int quantity) { this.quantity = quantity; } }
true
3fc1c0133ccdf811ccd216553cfe4f84baf2f8e5
Java
nikskonda/library-back-end
/repository/src/main/java/by/bntu/fitr/repository/user/order/OrderDetailRepository.java
UTF-8
392
1.804688
2
[]
no_license
package by.bntu.fitr.repository.user.order; import by.bntu.fitr.model.user.order.OrderDetail; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Set; @Repository public interface OrderDetailRepository extends JpaRepository<OrderDetail, Long> { Set<OrderDetail> findOrderDetailsByOrderId(Long orderId); }
true
a560a2f372e44f537d0b20643a012405fd59a8f1
Java
sslavik/acdat
/Actividad32/src/actividad32/Actividad32.java
UTF-8
1,583
3.09375
3
[]
no_license
/* * 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 actividad32; import java.sql.*; /** *El código postal (columna CP) está definido con tipo CHAR(5) en la tabla CLIENTES, pero es siem- pre un número entero. ¿Se podría utilizar getInt() en lugar de getString() para recuperar su valor? Cambia el programa y verifica tu hipótesis, o justifica los resultados si no son los que esperabas. * * @author Vyacheslav Shylyayev */ public class Actividad32 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here try (Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/ad?useSSL=false", "ad", "123"); Statement s = c.createStatement(); ResultSet rs = s.executeQuery("SELECT * FROM CLIENTES")){ System.out.println("Conexión realizada"); int i = 0; while (rs.next()) { System.err.println("_________ CLIENTE "+ i++ + "_________"); System.out.println("DNI : " + rs.getString("DNI")); System.out.println("APELLIDOS : " + rs.getString("APELLIDOS")); System.out.println("CP : " + rs.getInt("CP")); // EN CASO DE QUE DEVUELVA NULL SERÁ 0 } } catch (Exception e){ System.err.println(e.getMessage()); } } }
true
4761f51fc3b6aff1d4db01db5b20b8a12fff32cb
Java
masudgit/Spring-Boot
/product-manager/src/main/java/com/ikbal/springboot/web/repository/ProductRepository.java
UTF-8
233
1.71875
2
[]
no_license
package com.ikbal.springboot.web.repository; import org.springframework.data.jpa.repository.JpaRepository; import com.ikbal.springboot.web.model.Product; public interface ProductRepository extends JpaRepository<Product, Long> { }
true
7f0a7ed0a040ba7f3db378d4a1bd13bd0e27325e
Java
stillsw/playzone
/other fun stuff by programming language/java/rebound puck game/gameplay/OnlyTargetScores.java
UTF-8
106,712
2.84375
3
[]
no_license
package firstReboundGame.gameplay; import firstReboundGame.*; import java.awt.Color; import java.util.*; /* * This game expects just one Target .... but could be more * Rules for this ScoringManager * Puck goes into goal * [easy = no score, medium/hard = penalty] * Puck leaves playing area without a goal happening * [easy/medium = no score, hard = penalty] * Target leaves playing area * [easy = no score, medium/hard = penalty] * Target goes into goal and Puck penalties, before or after goal (depending on level Puck may just no score for goal or leaving playing area) * [score for target, debit score for puck] * Target goes into goal * [easy = scores] * [medium = scores only if target has bounced first, note: score multiplies by number of bounces] * [hard = scores only if puck has bounced first, note: score multiplies by number of bounces] */ public class OnlyTargetScores extends ScoringManager { private HashMap<TargetDisk, Integer> bounces = new HashMap<TargetDisk, Integer>(); private boolean puckHasHitTarget = false; private Puck thePuck; private boolean puckPenaltyPending = false; protected OnlyTargetScores(int gameStyle, PlayManager playManager, ColorArrangement animatedTextColours) { super(gameStyle, playManager, animatedTextColours); } private void incrementBounce(TargetDisk piece) { Integer bounce = bounces.get(piece); if (bounce == null) { bounce = new Integer(1); bounces.put(piece, bounce); } else { bounces.put(piece, new Integer(bounce.intValue() + 1)); } } @Override public void registerBounce(TargetDisk piece, StrikeableGamePiece offPiece) { if (this.puckHasHitTarget) { // for target count from the first hit from puck till goes into goal // try only counting bounces from non goal pieces... otherwise tiny bounces into a goal will count if (!(piece instanceof Puck)) { if (!(StrikeableGamePiece.getTopPart(offPiece) instanceof GatedGoal)) this.incrementBounce(piece); } } else { // only the puck should be moving at this point // count the bounces for the puck from strike until it hits the target if (piece instanceof Puck && offPiece instanceof TargetDisk && (!(offPiece instanceof WallEndDiskArc) && !(offPiece instanceof GoalPost))) { // only want to register hitting the actual target // unfortunately other types are also TargetDisks this.puckHasHitTarget = true; this.thePuck = (Puck)piece; } else { this.incrementBounce(piece); } } } @Override public boolean registerGoal(TargetDisk piece) { // what scored a goal, puck or target? if (piece instanceof Puck) { if (this.difficulty != ScoringManager.GAME_DIFFICULTY_EASY) this.registerPenalty(piece); this.registerStoppedMoving(piece); return false; } else { // Target goes into goal // [easy = scores] // [medium = scores only if target has bounced first, note: score multiplies by number of bounces] // [hard = scores only if puck AND target have bounced first, note: score multiplies by number of bounces] if (this.difficulty == ScoringManager.GAME_DIFFICULTY_EASY) this.otherPlayScores++; else { Integer bounce = this.bounces.get(piece); int numTargetBounces = (bounce == null ? 0 : bounce.intValue()); if (this.difficulty == ScoringManager.GAME_DIFFICULTY_MEDIUM) { this.otherPlayScores += numTargetBounces; } else { // difficult bounce = this.bounces.get(this.thePuck); int numPuckBounces = (bounce == null ? 0 : bounce.intValue()); if (numPuckBounces > 0) { this.otherPlayScores += numTargetBounces + numPuckBounces; // only for hard level, if the puck left the play area there could be a penalty, unless a goal is scored if (this.puckPenaltyPending) this.puckPenaltyPending = false; } } } this.registerStoppedMoving(piece); return true; } } @Override public void registerLeavePlayArea(TargetDisk piece) { // what left the playing area, puck or target? if (piece instanceof Puck) { if (this.difficulty == ScoringManager.GAME_DIFFICULTY_HARD) if (playManager.allPiecesStopped()) { if (this.otherPlayScores == 0) // target has not scored a goal this.registerPenalty(piece); } else this.puckPenaltyPending = true; } else { if (this.difficulty != ScoringManager.GAME_DIFFICULTY_EASY) this.registerPenalty(piece); } this.registerStoppedMoving(piece); } @Override protected void registerPenalty(TargetDisk piece) { if (piece instanceof Puck) this.puckPlayPenalties++; else this.otherPlayPenalties++; } @Override public void registerStrike(boolean fromStartPosn) { if (this.inAPlay) // nothing happened to stop the last play, like puck leaving playing area or going into a goal this.finishAPlay(); this.startAPlay(); } @Override public void registerStoppedMoving(TargetDisk piece) { // when all pieces are stopped can finish the play if (playManager.allPiecesStopped()) this.finishAPlay(); } @Override public void startAPlay() { super.startAPlay(); this.puckPenaltyPending = this.puckHasHitTarget = false; } @Override protected int calcPlayScore() { // play has finished, tot up the play scores into the game scores if (this.puckPenaltyPending) { this.puckPenalties++; this.puckPenaltyPending = false; } int playScores = this.puckPlayScores + this.otherPlayScores - this.puckPlayPenalties - this.otherPlayPenalties; // test streaks if (playScores > 0 && this.otherPlayScores > 0) { // a win: scored a goal and penalties don't eliminate it this.streakWins++; this.streakLosses = 0; } else { // failed to score this.streakWins = 0; this.streakLosses++; } // playScores > 0 and actually scored a goal may trigger multiples if (this.streakWins > 0) playScores *= this.streakWins; // maintain a breakdown for stats (if wanted) this.puckScores += this.puckPlayScores; this.puckPenalties += this.puckPlayPenalties; this.otherScores += this.otherPlayScores; this.otherPenalties += this.otherPlayPenalties; // less than 0 is a 0 score return (playScores < 0 ? 0 : playScores * ScoringManager.GAME_SCORE_MULTIPLIER); } @Override protected int calcGameScore() { // int gameScores = this.puckScores + this.otherScores - this.puckPenalties - this.otherPenalties; // return (gameScores < 0 ? 0 : gameScores * ScoringManager.GAME_SCORE_MULTIPLIER); return this.overAllScore; } @Override public void resetPlayScores() { super.resetPlayScores(); this.bounces.clear(); } protected static void testRules() { // System.out.println("OnlyTargetScores.testRules: starting tests, create test objects"); // create a puck and and 2 targets, a wall piece and an end wall piece Location2D zeroLoc = new Location2D(0,0); LineVector2D aLine = new LineVector2D(zeroLoc, new Vector2D(1, 0)); Puck testPuck = new Puck(null, null, zeroLoc, 10, ColorArrangement.NULL_COLOURS); TargetDisk testTarget1 = new TargetDisk(null, null, zeroLoc, 10, ColorArrangement.NULL_COLOURS); TargetDisk testTarget2 = new TargetDisk(null, null, zeroLoc, 10, ColorArrangement.NULL_COLOURS); WallPiece wallPiece = new WallPiece(aLine, WallPiece.WALL_LINE_DIRECTION_LEFT_TO_RIGHT, WallFactory.WALL_N, new Vector2D(0,1), WallPiece.WALL_END_TYPE_CORNER_JOIN, WallPiece.WALL_END_TYPE_CORNER_JOIN, 0, 10, false, ColorArrangement.NULL_COLOURS); WallEndDiskArc wallEnd = new WallEndDiskArc(zeroLoc, 10, WallFactory.WALL_N, true, false, ColorArrangement.NULL_COLOURS); wallEnd.setPartOf(wallPiece); LinearObstacle lineObstacle = new LinearObstacle(aLine, false, ColorArrangement.NULL_COLOURS, true); GatedGoal goal = new GatedGoal(zeroLoc, 5, GatedGoal.GATED_GOAL_NORTH, 30, 30, 0, false, Goal.GOAL_SHAPE_RECTANGULAR, false, ColorArrangement.NULL_COLOURS); LinearObstacle linePartOfGoal = new LinearObstacle(aLine, false, ColorArrangement.NULL_COLOURS, true); linePartOfGoal.setPartOf(goal); PlayManager playManager = new PlayManager(PlayManager.SCHEME_REPLAY_WHEN_ALL_PIECES_STOP); playManager.registerPieces(new MoveableGamePiece[] {testPuck, testTarget1, testTarget2}); ScoringManager scoringManager = ScoringManager.getInstance(ScoringManager.GAME_STYLE_TARGET_SCORES_PUCK_PENALISES, playManager, null); Striker striker = new Striker(testPuck); // striker.setStrengthBar(strikerStrengthBar); // striker.setAngleIndicator(strikerAngleIndicator); testPuck.setStriker(striker); // Puck goes into goal // [easy = no score, medium/hard = penalty] // Puck leaves playing area without a goal happening // [easy/medium = no score, hard = penalty] // Target leaves playing area // [easy = no score, medium/hard = penalty] // Target goes into goal and Puck penalties, before or after goal (depending on level Puck may just no score for goal or leaving playing area) // [score for target, debit score for puck] // Target goes into goal // [easy = scores] // [medium = scores only if target has bounced first, note: score multiplies by number of bounces] // [hard = scores only if puck has bounced first, note: score multiplies by number of bounces] scoringManager.startGame(); System.out.println("OnlyTargetScores.testRules: starting easy tests, number of lives="+scoringManager.numberOfLives); // simulate game play is a bit challenging because each time have to tell game play manager a piece has stopped moving, and also // have to start a piece each time too int gameTick = 100; ReboundGamePanel.gameTick = 1000; // easy tests scoringManager.setDifficulty(ScoringManager.GAME_DIFFICULTY_EASY); { int testNum = 1; int scoreTotal = 0; { //1 int expectedResult = 0; System.out.println(""+(testNum++)+". puck straight into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//1a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } { //2 int expectedResult = 0; System.out.println(""+(testNum++)+". puck goes out of play... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//2a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } { //3 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//3a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } {//4 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes out of play... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//4a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } {//5 int expectedResult = 100; System.out.println(""+(testNum++)+". puck hits target then target scores and then puck goes into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//5a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } {//6 int expectedResult = 200; // double for streak of 2 System.out.println(""+(testNum++)+". puck hits target then target scores and then puck goes out of play... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//6a System.out.println("\t Sub test multiples numLives should still be default now="+scoringManager.numberOfLives+" streakWins="+scoringManager.streakWins+" streakLosses="+scoringManager.streakLosses); } } {//7 int expectedResult = 1300; // triple score for streak of 3 + extra life bonus System.out.println(""+(testNum++)+". puck hits target then target scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//7a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//8 int expectedResult = 400; // 4x System.out.println(""+(testNum++)+". puck hits target then target bounces off wall and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//9 int expectedResult = 500; // 5x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall and then a wall end and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//9a System.out.println("\t Sub test multiples 3 in a row should not generate extra life yet, numLives now="+scoringManager.numberOfLives); } } {//10 int expectedResult = 1600; // 6x + extra life bonus System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//10a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//11 int expectedResult = 700; //7x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//12 int expectedResult = 800; // 8x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores and puck goes into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//13 int expectedResult = 1900; // 9x + extra life bonus System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes into goal before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//10a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//14 int expectedResult = 1000; // 10x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//15 int expectedResult = 1100; // 11x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//16 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes into goal before target leaves ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//17 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//18 int expectedResult = 100; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//19 int expectedResult = 200; // 2x System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores and puck penalties (with goal) ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//20 int expectedResult = 1300; // 3x + extra life bonus System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then penalties then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//20a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//21 int expectedResult = 400; // 4x System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then leaves playing area after the target scores: then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//22 int expectedResult = 500; // 5x System.out.println(""+(testNum++)+". puck hits target then target scores and then puck stops moving... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerStoppedMoving(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//23 int expectedResult = 1600; // 6x + extra life bonus System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece, part of goal, goal and then hits target and then leaves playing area after the target scores: then target bounces off same pieces too and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); scoringManager.registerBounce(testPuck, linePartOfGoal); scoringManager.registerBounce(testPuck, goal); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, lineObstacle); scoringManager.registerBounce(testTarget1, linePartOfGoal); scoringManager.registerBounce(testTarget1, goal); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//23a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } System.out.println("End of easy tests for 1 target scoreTotal="+scoreTotal+" game total="+scoringManager.finishGame()); } // > 1 target // Puck goes into goal // [easy = no score, medium/hard = penalty] // Puck leaves playing area without a goal happening // [easy/medium = no score, hard = penalty] // Target leaves playing area // [easy = no score, medium/hard = penalty] // Target goes into goal and Puck penalties, before or after goal (depending on level Puck may just no score for goal or leaving playing area) // [score for target, debit score for puck] // Target goes into goal // [easy = scores] // [medium = scores only if target has bounced first, note: score multiplies by number of bounces] // [hard = scores only if puck has bounced first, note: score multiplies by number of bounces] scoringManager.startGame(); // medium tests System.out.println("OnlyTargetScores.testRules: starting medium tests (same as easy, with differing results)"); scoringManager.setDifficulty(ScoringManager.GAME_DIFFICULTY_MEDIUM); { int testNum = 1; int scoreTotal = 0; {//1 int expectedResult = 0; System.out.println(""+(testNum++)+". puck straight into goal... expected results (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//2 int expectedResult = 0; System.out.println(""+(testNum++)+". puck goes out of play... expected result (+0 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//3 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes into goal... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//4 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes out of play... expected result (+0 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//4a System.out.println("\t Sub test no lives change yet numLives now="+scoringManager.numberOfLives+" streakLosses="+scoringManager.streakLosses); } } {//5 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores and then puck goes into goal... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//5a System.out.println("\t Sub test multiples 5 in a row should generate lose life numLives now="+scoringManager.numberOfLives+" streakLosses="+scoringManager.streakLosses); } } {//6 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores without a bounce and then puck goes out of play... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//7 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores without a bounce ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//8 int expectedResult = 100; System.out.println(""+(testNum++)+". puck hits target then target bounces off wall and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//9 int expectedResult = 400; // 2x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall and then a wall end and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//10 int expectedResult = 3900; // 3x + extra life bonus System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//10a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//11 int expectedResult = 1600; // 4x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//12 int expectedResult = 1500; // 5x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores and puck goes into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//13 int expectedResult = 4800; // 6x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes into goal before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//13a System.out.println("\t Sub test multiples 3 in a row should generate extra life numLives now="+scoringManager.numberOfLives); } } {//14 int expectedResult = 2800; // 7x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//15 int expectedResult = 3200; // 8x System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//16 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes into goal before target leaves ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//17 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//18 int expectedResult = 0; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//19 int expectedResult = 0; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores and puck penalties (with goal) ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//20 int expectedResult = 300; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then penalties (in goal) then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//21 int expectedResult = 800; // 2x System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then leaves playing area after the target scores: then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//22 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores and then puck stops moving... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerStoppedMoving(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//23 int expectedResult = 300; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece, part of goal, goal and then hits target and then leaves playing area after the target scores: then target bounces off same pieces too and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); scoringManager.registerBounce(testPuck, linePartOfGoal); scoringManager.registerBounce(testPuck, goal); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, lineObstacle); scoringManager.registerBounce(testTarget1, linePartOfGoal); scoringManager.registerBounce(testTarget1, goal); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//24 int expectedResult = 0; // no multiple because target fails to score System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece, part of goal, goal and then hits target and then leaves playing area as does target ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); scoringManager.registerBounce(testPuck, linePartOfGoal); scoringManager.registerBounce(testPuck, goal); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, lineObstacle); scoringManager.registerBounce(testTarget1, linePartOfGoal); scoringManager.registerBounce(testTarget1, goal); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } System.out.println("End of medium tests for 1 target scoreTotal="+scoreTotal+" game total="+scoringManager.finishGame()); } // > 1 target // Puck goes into goal // [easy = no score, medium/hard = penalty] // Puck leaves playing area without a goal happening // [easy/medium = no score, hard = penalty] // Target leaves playing area // [easy = no score, medium/hard = penalty] // Target goes into goal and Puck penalties, before or after goal (depending on level Puck may just no score for goal or leaving playing area) // [score for target, debit score for puck] // Target goes into goal // [easy = scores] // [medium = scores only if target has bounced first, note: score multiplies by number of bounces] // [hard = scores only if puck has bounced first, note: score multiplies by number of bounces] scoringManager.startGame(); // difficult tests // difficult tests System.out.println("OnlyTargetScores.testRules: starting hard tests (same as medium, with differing results)"); scoringManager.setDifficulty(ScoringManager.GAME_DIFFICULTY_HARD); { int testNum = 1; int scoreTotal = 0; {//1 int expectedResult = 0; System.out.println(""+(testNum++)+". puck straight into goal... expected results (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//2 int expectedResult = 0; System.out.println(""+(testNum++)+". puck goes out of play... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//3 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes into goal... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//4 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then goes out of play... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//5 // 5x int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores and then puck goes into goal... expected result (+1 to penalties) score="+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//5a System.out.println("\t Sub test multiples 5 in a row should generate lose life numLives now="+scoringManager.numberOfLives); } } {//6 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores without a bounce and then puck goes out of play... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//7 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores without a bounce ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//8 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off wall and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//9 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall and then a wall end and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//10 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//10a System.out.println("\t Sub test multiples 5 in a row should generate lose life numLives now="+scoringManager.numberOfLives); } {//11 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//12 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores and puck goes into goal... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//13 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes into goal before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//14 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//15 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then scores but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//15a System.out.println("\t Sub test multiples 5 in a row should generate lose life and end of game! numLives now="+scoringManager.numberOfLives); } } {//16 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes into goal before target leaves ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); {//16a System.out.println("\t Sub test new game should have started numLives="+scoringManager.numberOfLives); } } {//17 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target bounces off a wall, a wall end, puck again, wall again and then leaves play area but puck goes out of play before target does ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerLeavePlayArea(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//18 int expectedResult = 300; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores without a bounce ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//19 int expectedResult = 400; // 2x System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and target scores and puck penalties (with goal) ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//20 int expectedResult = 6800; // 3x + extra life bonus System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then penalties (in goal) then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerGoal(testPuck); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//21 int expectedResult = 2800; // 4x System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece and then hits target and then leaves playing area after the target scores: then target bounces off pieces as earlier and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, testPuck); scoringManager.registerBounce(testTarget1, wallPiece); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//22 int expectedResult = 0; System.out.println(""+(testNum++)+". puck hits target then target scores and then puck stops moving... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerStoppedMoving(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } {//23 int expectedResult = 800; System.out.println(""+(testNum++)+". puck bounces off wall, wall end, another piece, part of goal, goal and then hits target and then leaves playing area after the target scores: then target bounces off same pieces too and then scores ... expected result "+expectedResult); testPuck.resetToStart(); testTarget1.resetToStart(); testTarget2.resetToStart(); testPuck.setMoving(true); scoringManager.registerStrike(true); // puck hits.. this should initialise a play scoringManager.registerBounce(testPuck, wallPiece); scoringManager.registerBounce(testPuck, wallEnd); scoringManager.registerBounce(testPuck, lineObstacle); scoringManager.registerBounce(testPuck, linePartOfGoal); scoringManager.registerBounce(testPuck, goal); testTarget1.setMoving(true); scoringManager.registerBounce(testPuck, testTarget1); scoringManager.registerBounce(testTarget1, wallPiece); scoringManager.registerBounce(testTarget1, wallEnd); scoringManager.registerBounce(testTarget1, lineObstacle); scoringManager.registerBounce(testTarget1, linePartOfGoal); scoringManager.registerBounce(testTarget1, goal); playManager.waitToRestart(testTarget1, gameTick); scoringManager.registerGoal(testTarget1); playManager.waitToRestart(testPuck, gameTick); scoringManager.registerLeavePlayArea(testPuck); System.out.println("\t result="+scoringManager.finishAPlay()+" test "+(scoringManager.scoreForLastPlay == expectedResult ? "success" : "FAILED!")); scoreTotal += scoringManager.scoreForLastPlay; System.out.println("\t game scores : \n\t\t puck="+scoringManager.puckScores+"\n\t\t other="+scoringManager.otherScores+"\n\t\t penalty puck="+scoringManager.puckPenalties+"\n\t\t penalty other="+scoringManager.otherPenalties); } System.out.println("End of hard tests for 1 target scoreTotal="+scoreTotal+" game total="+scoringManager.finishGame()); } // > 1 target System.out.println("OnlyTargetScores.testRules: tests finished"); } } // end of class
true
787bd83553a599fb0f71adc85808ffd40696c460
Java
tttangjie/JavaWorkbench
/Users/Administrator/workspace/Student/src/com/ymy/controller/InformationSearchController.java
UTF-8
965
1.921875
2
[]
no_license
package com.ymy.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.ymy.pojo.Course; import com.ymy.pojo.School; import com.ymy.pojo.Student; import com.ymy.service.InformationSearchService; @Controller @RequestMapping("/Information") public class InformationSearchController { @Autowired InformationSearchService informservice; @RequestMapping("/selectStudent.do") @ResponseBody public List<Student> selectStudent() { return informservice.studentList(); } @RequestMapping("/selectCourse.do") @ResponseBody public List<Course> selectCourse() { return informservice.courseList(); } @RequestMapping("/selectSchool.do") @ResponseBody public List<School> selectSchool() { return informservice.schoolList(); } }
true
095c6748e7740423c04f98b56966f5cefcc48f52
Java
pks1986/InterViewConcept
/OOPS/src/InstanceInitBlock.java
UTF-8
493
3.609375
4
[]
no_license
public class InstanceInitBlock { int number; int i; { System.out.println("First Instance Initializer block"); while(i < 5){ System.out.println(i); i++; } number = 10; } { System.out.println("Second Instance Initializer block"); } void display(){ System.out.println(number); } public static void main(String[] args) { // TODO Auto-generated method stub InstanceInitBlock ob = new InstanceInitBlock(); new InstanceInitBlock().display(); ob.display(); } }
true
70b10dd8f63641fc79518f4d37f6f9df3854448c
Java
NEUDitao/SoftwareDevF19-PreCodeSwap
/Tsuro/Common/src/com/tsuro/utils/RenderUtils.java
UTF-8
513
2.609375
3
[]
no_license
package com.tsuro.utils; import java.awt.GridBagConstraints; import lombok.experimental.UtilityClass; /** * Utilities for rendering. */ @UtilityClass public class RenderUtils { /** * Creates a GridBagConstraints with gridx and gridy of x and y. */ public static GridBagConstraints createDefaultGBC(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; return c; } }
true