blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2 values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82 values | src_encoding stringclasses 28 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 5.41M | extension stringclasses 11 values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dfbad0659f9ea44385bc06bb70cec2a836a32867 | 987427d05466ccc096a3be8a23e950aa88c81e28 | /JavaStudy/OOP-Blackjack/src/main/CardDeck.java | d56ff7eb85b34717545fc2eb8b2c69533728e1d3 | [] | no_license | bkdoo/TIL | 800d67061921a6bacdea29b6fba9c220974068b9 | 14eef91e76d36f91ea38dd8d587b88c48e100f9d | refs/heads/master | 2020-04-07T11:41:19.739021 | 2019-02-26T09:16:52 | 2019-02-26T09:16:52 | 158,336,634 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,039 | java | package main;
import java.util.LinkedList;
import java.util.List;
public class CardDeck {
private List<Card> cards;
private static final String[] PATTERNS = { "spade", "diamond", "heart", "club" };
private static int CARD_COUNT = 13;
public CardDeck() {
cards = this.generateCards();
}
public Card getCard() {
return null;
}
public Card draw() {
Card selectedCard = getRandomCard();
cards.remove(selectedCard);
return selectedCard;
}
private List<Card> generateCards() {
List<Card> cards = new LinkedList<>();
for (String pattern : PATTERNS) {
for (int i = 1; i <= CARD_COUNT; i++) {
Card card = new Card(pattern, i);
cards.add(card);
}
}
return cards;
}
private Card getRandomCard() {
int size = cards.size();
int select = (int) (Math.random() * size);
return cards.get(select);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Card card : cards) {
sb.append(card.toString());
sb.append("\n");
}
return sb.toString();
}
}
| [
"kyeongdoos@gmail.com"
] | kyeongdoos@gmail.com |
3dbdd9667fc0e90cb063c7758149b869659e3357 | e0f949ff949121ab6402b0525ce785611fac699e | /app/src/main/java/com/example/signature/ECDSA/Point.java | d3d344d05f004badb883fb7397857fa7c28372c0 | [] | no_license | ngmduc2012/Signature-ECDSA-Andorid | fee70bb277b7275d59641e2573ea8d9900ef36ce | 6174fb5b7b6504412fe71e8bd27c0b3d9c95598b | refs/heads/master | 2023-04-05T09:23:33.269257 | 2021-04-12T03:13:22 | 2021-04-12T03:13:22 | 298,802,637 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 536 | java | package com.example.signature.ECDSA;
import java.math.BigInteger;
public class Point {
public BigInteger x;
public BigInteger y;
public BigInteger z;
/**
* @param x
* @param y
*/
public Point(BigInteger x, BigInteger y) {
this.x = x;
this.y = y;
this.z = BigInteger.ZERO;
}
/**
* @param x
* @param y
* @param z
*/
public Point(BigInteger x, BigInteger y, BigInteger z) {
this.x = x;
this.y = y;
this.z = z;
}
}
| [
"ngmduc2012@users.noreply.github.com"
] | ngmduc2012@users.noreply.github.com |
98c40b25cfcab5b3550bc39cb06cf79fd871b679 | 1ceb7af51e54d8aff5814b6a7f4c3e7917f543cf | /hwplib-master/hwplib-master/src/kr/dogfoot/hwplib/object/bodytext/control/sectiondefine/PageBorderFill.java | ee0e3e26d180d1ea204be2b9bc2c618c02d0fdf1 | [
"Apache-2.0"
] | permissive | seunghakbae/maeil-economy-test-practice-program-java-hwplib | 83ea1e425382d000f26e57a8a6068c39705b2b81 | fe1fbb769c0b7c29b295bf6e986fe65e86db960b | refs/heads/master | 2022-04-24T18:59:51.920428 | 2020-04-25T23:45:20 | 2020-04-25T23:45:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,858 | java | package kr.dogfoot.hwplib.object.bodytext.control.sectiondefine;
/**
* 쪽 테두리/배경 정보에 대한 레코드
*
* @author neolord
*/
public class PageBorderFill {
/**
* 속성
*/
private PageBorderFillProperty property;
/**
* 테두리/배경 위치 왼쪽 간격
*/
private int leftGap;
/**
* 테두리/배경 위치 오른쪽 간격
*/
private int rightGap;
/**
* 테두리/배경 위치 위쪽 간격
*/
private int topGap;
/**
* 테두리/배경 위치 아래쪽 간격
*/
private int bottomGap;
/**
* 참조된 테두리/배경의 id
*/
private int borderFillId;
/**
* 생성자
*/
public PageBorderFill() {
property = new PageBorderFillProperty();
}
/**
* 속성 객체를 반환한다.
*
* @return 속성 객체
*/
public PageBorderFillProperty getProperty() {
return property;
}
/**
* 테두리/배경 위치 왼쪽 간격을 반환한다.
*
* @return 테두리/배경 위치 왼쪽 간격
*/
public int getLeftGap() {
return leftGap;
}
/**
* 테두리/배경 위치 왼쪽 간격을 설정한다.
*
* @param leftGap
* 테두리/배경 위치 왼쪽 간격
*/
public void setLeftGap(int leftGap) {
this.leftGap = leftGap;
}
/**
* 테두리/배경 위치 오른쪽 간격을 반환한다.
*
* @return 테두리/배경 위치 오른쪽 간격
*/
public int getRightGap() {
return rightGap;
}
/**
* 테두리/배경 위치 오른쪽 간격을 설정한다.
*
* @param rightGap
* 테두리/배경 위치 오른쪽 간격
*/
public void setRightGap(int rightGap) {
this.rightGap = rightGap;
}
/**
* 테두리/배경 위치 위쪽 간격을 반환한다.
*
* @return 테두리/배경 위치 위쪽 간격
*/
public int getTopGap() {
return topGap;
}
/**
* 테두리/배경 위치 위쪽 간격을 설정한다.
*
* @param topGap
* 테두리/배경 위치 위쪽 간격
*/
public void setTopGap(int topGap) {
this.topGap = topGap;
}
/**
* 테두리/배경 위치 아래쪽 간격을 반환한다.
*
* @return 테두리/배경 위치 아래쪽 간격
*/
public int getBottomGap() {
return bottomGap;
}
/**
* 테두리/배경 위치 아래쪽 간격을 설정한다.
*
* @param bottomGap
* 테두리/배경 위치 아래쪽 간격
*/
public void setBottomGap(int bottomGap) {
this.bottomGap = bottomGap;
}
/**
* 참조된 테두리/배경의 id를 반환한다.
*
* @return 참조된 테두리/배경의 id
*/
public int getBorderFillId() {
return borderFillId;
}
/**
* 참조된 테두리/배경의 id를 설정한다.
*
* @param borderFillId
* 참조된 테두리/배경의 id
*/
public void setBorderFillId(int borderFillId) {
this.borderFillId = borderFillId;
}
}
| [
"onelife0717@gmail.com"
] | onelife0717@gmail.com |
f65794abc3fc23748ef670606c278a7cb27b3dfa | 84a5f35c6931aac307e66acb191d9e6ba923781f | /app/src/main/java/com/finappl/models/CalendarSummary.java | a3f67a1426878a269a46b6dac0efb66e8bdd7588 | [] | no_license | AjitKamath/neutron | 6d07bd3916a48de1c0a374092298c41c62690eca | f16d40160661ca814fa9374c405bb6a52d6844eb | refs/heads/master | 2020-12-13T22:44:25.110726 | 2017-06-24T06:57:26 | 2017-06-24T06:57:26 | 28,878,055 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 784 | java | package com.finappl.models;
import android.widget.Adapter;
import com.finappl.adapters.CalendarSummaryTransactionsListViewAdapter;
/**
* Created by ajit on 9/2/17.
*/
public class CalendarSummary {
private String heading;
private Double amount;
private Object listViewAdapter;
public String getHeading() {
return heading;
}
public void setHeading(String heading) {
this.heading = heading;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public Object getListViewAdapter() {
return listViewAdapter;
}
public void setListViewAdapter(Object listViewAdapter) {
this.listViewAdapter = listViewAdapter;
}
}
| [
"ajitkamathk@gmail.com"
] | ajitkamathk@gmail.com |
c378fc2d4791b8a8d43fc90211132b208363bfb1 | d5c3bcdc86d8802527ce7b1f3671d3ec5893e0ca | /IF01-10118029-latihanMVC/src/edu/aziskomara/latihanmvc/model/PelangganModel.java | 148d81d3cd2be11541af03ceee4112f4909faf0b | [] | no_license | Aziskomara/IF01-10118029-latihanMVC | b139b3313486fc55e9797233a72e342c4369b2ad | 04d98b1f983b6768de225e294b482ed550488561 | refs/heads/master | 2020-12-06T06:48:41.518006 | 2020-01-07T17:23:09 | 2020-01-07T17:23:09 | 232,377,544 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,794 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.aziskomara.latihanmvc.model;
import edu.aziskomara.latihanmvc.event.PelangganListener;
import javax.swing.JOptionPane;
/**
*
* @author Azis Komara
* NIM : 10118029
* Nama : Azis Komara
* Kelas : IF-1
*/
public class PelangganModel {
private String nama;
private String email;
private String notelepon;
private PelangganListener pelangganListeber;
public PelangganListener getPelangganListeber() {
return pelangganListeber;
}
public void setPelangganListeber(PelangganListener pelangganListeber) {
this.pelangganListeber = pelangganListeber;
}
public String getNama() {
return nama;
}
public void setNama(String nama) {
this.nama = nama;
fireOnChange();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
fireOnChange();
}
public String getNotelepon() {
return notelepon;
}
public void setNotelepon(String notelepon) {
this.notelepon = notelepon;
fireOnChange();
}
protected void fireOnChange(){
if (pelangganListeber!=null) {
pelangganListeber.onChange(this);
}
}
public void resetForm(){
setNama("");
setEmail("");
setNotelepon("");
}
public void simpanForm(){
JOptionPane.showMessageDialog(null, "Berhasil Disimpan");
resetForm();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
c890e1b5d2cce82c86456ce74b02c73504ca1de5 | bf29eabd2e9fe845889826ab7205dab7a603f865 | /src/main/java/com/example/auctionapp/controller/AddressController.java | a27d8ef509d89d6d45c84ef9e3ba60b6e6501d73 | [] | no_license | lejlakasum/AuctionApp | c54ddd89aa4fef6ba81ce6ffe7d2337129aae285 | 368a323b84ec8ea71104cc3225920754039bf560 | refs/heads/master | 2023-02-02T22:11:18.525699 | 2020-12-14T13:49:48 | 2020-12-14T13:49:48 | 295,234,007 | 0 | 2 | null | 2020-12-14T13:49:49 | 2020-09-13T20:41:31 | Java | UTF-8 | Java | false | false | 2,113 | java | package com.example.auctionapp.controller;
import com.example.auctionapp.dto.UserDtos.AddressDto;
import com.example.auctionapp.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/user/address")
public class AddressController implements IBaseController<AddressDto> {
private final AddressService addressService;
@Autowired
public AddressController(AddressService addressService) {
this.addressService = addressService;
}
@GetMapping()
public ResponseEntity<List<AddressDto>> getAll() {
return new ResponseEntity<>(addressService.getAll(), HttpStatus.OK);
}
@GetMapping("/{id}")
public ResponseEntity<AddressDto> getById(@PathVariable Long id) {
return new ResponseEntity<>(addressService.getById(id), HttpStatus.OK);
}
@PostMapping()
@Valid
public ResponseEntity<AddressDto> add(@Valid @RequestBody AddressDto resource) {
return new ResponseEntity<>(addressService.add(resource), HttpStatus.CREATED);
}
@PutMapping()
@Valid
public ResponseEntity<AddressDto> update(@Valid @RequestBody AddressDto resource) {
return new ResponseEntity<>(addressService.update(resource), HttpStatus.OK);
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteById(@PathVariable Long id) {
addressService.deleteById(id);
return ResponseEntity.noContent().build();
}
}
| [
"lkasum1@etf.unsa.ba"
] | lkasum1@etf.unsa.ba |
6fb62909d98582d285a71bbc3d95926acfb363c8 | 15c80525595fab0a70464e983baa84a85be744d3 | /project_drive/src/main/java/com/lieyan/Service/CoachServicempl.java | e4f760fdfd834400c3e31c71236eba9f61e28450 | [] | no_license | Fourous/lieyan | bc5ce881d599e5e4c903762ff6789914d873a26f | d11bb4efecfa4b5595d42fd0b44abcf35ee69260 | refs/heads/master | 2021-10-21T16:19:42.289496 | 2019-03-05T05:20:15 | 2019-03-05T05:20:15 | 165,776,468 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,891 | java | package com.lieyan.Service;
import com.lieyan.Entity.Coach;
import com.lieyan.mapper.CoachMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CoachServicempl implements CoachService{
@Autowired
private CoachMapper coachMapper;
public List<Coach> coachall (){
return coachMapper.coachall();
}
public Coach coachone(Integer tid)
{
return coachMapper.coachquerybyid(tid);
}
public boolean coachlike(Integer tid) {
Coach coach=coachMapper.coachquerybyid(tid);
int like=coach.getLike();
like+=1;
System.out.println(like);
int num=coachMapper.coachlike(tid,like);
if(num>0){
return true;
}else {
return false;
}
}
public boolean coachunlike(Integer tid){
Coach coach=coachMapper.coachquerybyid(tid);
int unlike=coach.getUnlike();
unlike+=1;
System.out.println(unlike);
int num=coachMapper.coachunlike(tid,unlike);
if(num>0){
return true;
}else {
return false;
}
}
public boolean coachlikere(Integer tid){
Coach coach=coachMapper.coachquerybyid(tid);
int like=coach.getLike();
like-=1;
int num=coachMapper.coachlikere(tid,like);
if(num>0){
return true;
}else {
return false;
}
}
public boolean coachunlikere(Integer tid){
Coach coach=coachMapper.coachquerybyid(tid);
int unlike=coach.getUnlike();
unlike-=1;
int num=coachMapper.coachunlikere(tid,unlike);
if(num>0){
return true;
}else {
return false;
}
}
}
| [
"fourousky@gmail.com"
] | fourousky@gmail.com |
a791d804fcfa1a2a6b03f428365daf8841c99868 | adbbf286f4d038385e4fa10eea11f4f8217af7df | /app/src/main/java/com/hyht/amap_historical_building/callback/SingleButtonCallBackShowOverlayOnMap.java | ad278f2d37eaec56d8aa2b288934ede17c456b5e | [] | no_license | robotautomatic/amap_historical_building | 66b2cd55a2d827ea2e18dd30a076caa9a3989e7c | a219ecca44d693c528d1283676472e323ce32b34 | refs/heads/master | 2023-03-08T22:06:44.095143 | 2021-03-08T02:14:23 | 2021-03-08T02:14:23 | 296,574,756 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,403 | java | package com.hyht.amap_historical_building.callback;
import android.content.Context;
import androidx.annotation.NonNull;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.hyht.amap_historical_building.entity.PolygonBasic;
import com.hyht.amap_historical_building.entity.TBasic;
import com.hyht.amap_historical_building.listener.OnInFoWindowClickListenerShowDetail;
import com.hyht.amap_historical_building.utils.EntityToOverlay;
import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction;
import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog;
import com.xuexiang.xui.widget.toast.XToast;
import java.util.List;
/**
* 将建筑图片从地图上显示并跳转至
*/
public class SingleButtonCallBackShowOverlayOnMap implements MaterialDialog.SingleButtonCallback {
private AMap aMap;
private TBasic tBasic;
Context context;
public SingleButtonCallBackShowOverlayOnMap(AMap aMap, TBasic tBasic, Context context) {
this.aMap = aMap;
this.tBasic = tBasic;
this.context = context;
}
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
String positionCoordinates = tBasic.getPositionCoordinates();
if (positionCoordinates == null || positionCoordinates.isEmpty() || positionCoordinates.length() <20){
XToast.normal(context,"没有坐标数据").show();
}else {
List<Marker> markers = aMap.getMapScreenMarkers();
Marker marker = new EntityToOverlay(aMap, tBasic,context).transform();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(marker.getPosition());
aMap.animateCamera(cameraUpdate);
aMap.setOnInfoWindowClickListener(new OnInFoWindowClickListenerShowDetail(context, aMap));
marker.showInfoWindow();
for (Marker marker1 : markers) {
if (marker.getPosition().equals(marker1.getPosition())){
if (marker1.getObject() instanceof PolygonBasic){
((PolygonBasic) marker1.getObject()).getPolygon().remove();
}
marker1.destroy();
}
}
}
}
}
| [
"xcx0424@163.com"
] | xcx0424@163.com |
61decd9ae06f3ab0d46509a0726b96a21ed7a9a7 | ef77cc0ab610a2690cfbd881d653c4e026770aa8 | /test/courbes/TestCalcul.java | 7d53ae85a1cd847f99d1631a11124918064e37af | [] | no_license | JorisSittler/Graphiqueur2 | 8c15ee34b0f7be50a88c640ac42c4ef593763cb5 | f922a31d5b25eadd7bcaf36ad52b1a5c7b13b1a4 | refs/heads/master | 2022-08-16T11:31:41.444227 | 2022-07-29T17:18:19 | 2022-07-29T17:18:19 | 171,561,806 | 2 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 3,347 | java | package courbes;
import static org.junit.Assert.assertEquals;
import graphique.donnees.Course;
import marche.calcul.CalculTempsTrajet;
import marche.donnees.courbes.Performance;
import marche.donnees.courbes.PerformanceCalculee;
import marche.donnees.polygone.PolygoneVitesse;
import marche.donnees.polygone.SegmentPolygone;
import org.junit.Before;
import org.junit.Test;
public class TestCalcul {
Performance perf;
@Before
public void init() {
perf = new PerformanceCalculee(10, 0.5, 1);
}
@Test
public void test200Cst() {
SegmentPolygone el = new SegmentPolygone(0, 10, 200);
double t = CalculTempsTrajet.calculerTempsSegment(perf, 200, el, 200);
// vérifie qu'on obtient bien 3 minutes pour 10 km à 200
assertEquals(180, t, 0);
}
@Test
public void test200TropCourt() {
SegmentPolygone el = new SegmentPolygone(0, 10, 200);
double t = CalculTempsTrajet.calculerTempsSegment(perf, 0, el, 0);
// vérifie qu'on obtient bien 3 minutes pour 10 km à 200
assertEquals(180, t, 0);
}
@Test
public void test200Arret() {
SegmentPolygone el = new SegmentPolygone(0, 100, 200);
double t = CalculTempsTrajet.calculerTempsSegment(perf, 0, el, 0);
// vérifie qu'on obtient bien 30 minutes pour 100 km à 200
assertEquals(1800, t, 0);
}
@Test
public void testArret() {
SegmentPolygone el = new SegmentPolygone(0, 2, 0);
double t = CalculTempsTrajet.calculerTempsSegment(perf, 200, el, 200);
// vérifie qu'on obtient bien 120 secondes pour un arrêt de 2 minutes
assertEquals(120, t, 0);
}
@Test
public void testCourbe200Cst() {
// enchaînement de 2 éléments à 200
SegmentPolygone el = new SegmentPolygone(0, 150, 200);
SegmentPolygone el2 = new SegmentPolygone(150, 250, 200);
PolygoneVitesse pol = new PolygoneVitesse();
pol.getCourbe().add(el);
pol.getCourbe().add(el2);
Course c = CalculTempsTrajet.calculerTempsPolygone(perf, pol);
// vérifie qu'on obtient bien 2h pour 400 km à 200
System.out.println(c);
}
@Test
public void testCourbe200CstArret() {
// enchaînement de 2 éléments à 200 avec un arrêt entre
SegmentPolygone el = new SegmentPolygone(0, 150, 200);
SegmentPolygone ar = new SegmentPolygone(150, 5, 0);
SegmentPolygone el2 = new SegmentPolygone(150, 250, 200);
PolygoneVitesse pol = new PolygoneVitesse();
pol.getCourbe().add(el);
pol.getCourbe().add(ar);
pol.getCourbe().add(el2);
Course c = CalculTempsTrajet.calculerTempsPolygone(perf, pol);
// vérifie qu'on obtient bien 2h05 pour 40 km à 200 + 5 minutes
// d'arrêt
System.out.println(c);
}
@Test
public void testCourbe200Arrets() {
// enchaînement de 2 éléments à 200 avec un arrêt entre
SegmentPolygone el = new SegmentPolygone(0, 150, 160);
SegmentPolygone ar = new SegmentPolygone(150, 5, 0);
SegmentPolygone el2 = new SegmentPolygone(150, 10, 200);
SegmentPolygone ar2 = new SegmentPolygone(160, 2, 0);
SegmentPolygone el3 = new SegmentPolygone(160, 250, 200);
PolygoneVitesse pol = new PolygoneVitesse();
pol.getCourbe().add(el);
pol.getCourbe().add(ar);
pol.getCourbe().add(el2);
pol.getCourbe().add(ar2);
pol.getCourbe().add(el3);
Course c = CalculTempsTrajet.calculerTempsPolygone(perf, pol);
// vérifie qu'on obtient bien 2h05 pour 40 km à 200 + 5 minutes
// d'arrêt
System.out.println(c);
}
}
| [
"JorisSittler@users.noreply.github.com"
] | JorisSittler@users.noreply.github.com |
2d812c61df414f8734b3ffa1aa5184f0b221c1df | 0e5231726f376dd043e180751d0a50d0f280b5e4 | /app/src/main/java/com/example/enigmav1/ui/home/HomeViewModel.java | 352e7bdf8d712fe6493ff44ac8248f3e17f9b4a3 | [] | no_license | DarkDriverHD/EnigmaV2 | 068b8938ef494db4f69f0f27d1dd4769c7359f12 | ad9095d18690c9dfa6b5eb324bf41e8655b0acb8 | refs/heads/master | 2020-09-14T20:19:30.884761 | 2019-11-21T18:57:20 | 2019-11-21T18:57:20 | 223,243,372 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 443 | java | package com.example.enigmav1.ui.home;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel {
private MutableLiveData<String> mText;
public HomeViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is home fragment");
}
public LiveData<String> getText() {
return mText;
}
} | [
"DarkDriverHD@web.de"
] | DarkDriverHD@web.de |
01df692017b0fa67103c80b44b84a8eeb45ea856 | 81c48b8f7a6d39ec37214f122a2eb1333a69da0e | /src/main/java/com/huivip/steel/dao/RoleDao.java | ab275c8b8e2a0954dc89e16383946d0c5d986731 | [] | no_license | laihui0207/steel | bce5814ab827940b92d758b86a0332b663023174 | 4ed85dd1101e48368c0cf6d1406beadf6a0a1568 | refs/heads/master | 2016-09-06T00:00:00.031369 | 2015-06-12T16:29:10 | 2015-06-12T16:29:10 | 37,024,308 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 573 | java | package com.huivip.steel.dao;
import com.huivip.steel.model.Role;
/**
* Role Data Access Object (DAO) interface.
*
* @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
*/
public interface RoleDao extends GenericDao<Role, Long> {
/**
* Gets role information based on rolename
* @param rolename the rolename
* @return populated role object
*/
Role getRoleByName(String rolename);
/**
* Removes a role from the database by name
* @param rolename the role's rolename
*/
void removeRole(String rolename);
}
| [
"laihui0207gm@gmail.com"
] | laihui0207gm@gmail.com |
4c0d4b92caaa68efb3d108a6204540a76ba3aa78 | f84fa8aa61d21b09da3f2e83cc2203b69116c047 | /src/java/fr/paris/lutece/plugins/ocra2ia/util/OcrResultUtils.java | 5df2d53cec90cd3ac982806146bed470f3b45a90 | [] | no_license | lutece-secteur-public/ocr-plugin-a2ia | 16e7f1650ca411f847b6ed593e75f3e2480fb486 | 32ac23a5d5b4574c6206a0a095b07ca4ad782f92 | refs/heads/master | 2020-05-14T15:55:43.144434 | 2019-08-29T12:32:10 | 2019-08-29T12:32:10 | 181,863,248 | 0 | 1 | null | 2019-08-01T08:51:35 | 2019-04-17T09:49:53 | null | UTF-8 | Java | false | false | 16,280 | java | /*
* Copyright (c) 2002-2019, Mairie de Paris
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice
* and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice
* and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* License 1.0
*/
package fr.paris.lutece.plugins.ocra2ia.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import fr.paris.lutece.plugins.ocra2ia.business.A2iaOutput;
import fr.paris.lutece.portal.service.util.AppPropertiesService;
/**
*
* Utility class to get Ocr results
*
*/
public final class OcrResultUtils
{
/**
* Default private constructor. Do not call
*/
private OcrResultUtils( )
{
throw new AssertionError( );
}
/**
* Get Ocr results in map.
*
* @param strDocumentType
* Document type
*
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @return Map result of OCR
*/
public static Map<String, String> getOcrResults( String strDocumentType, Dispatch dispatchA2iaObject, Variant variantResultOcrId )
{
if ( strDocumentType.equalsIgnoreCase( AppPropertiesService.getProperty( OcrConstants.PROPERTY_A2IA_DOCUMENT_RIB ) ) )
{
return getRIBResult( dispatchA2iaObject, variantResultOcrId );
}
else
if ( strDocumentType.equalsIgnoreCase( AppPropertiesService.getProperty( OcrConstants.PROPERTY_A2IA_DOCUMENT_TAX ) ) )
{
return getTaxAssessmentResult( dispatchA2iaObject, variantResultOcrId );
}
else
if ( strDocumentType.equalsIgnoreCase( AppPropertiesService.getProperty( OcrConstants.PROPERTY_A2IA_DOCUMENT_IDENTITY ) ) )
{
return getIdentityResult( dispatchA2iaObject, variantResultOcrId );
}
return null;
}
/**
* Get Ocr results for Rib document.
*
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @return Map result of OCR
*/
private static Map<String, String> getRIBResult( Dispatch dispatchA2iaObject, Variant variantResultOcrId )
{
Map<String, String> mapOcrRibResult = new HashMap<>( );
List<A2iaOutput> listA2iaOutputRib = new ArrayList<>( );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT ), OcrConstants.OUTPUT_ZONE_RIB,
Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_CODE_BANQUE ),
OcrConstants.OUTPUT_ZONE_RIB_CODE_BANQUE, Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_CODE_GUICHET ),
OcrConstants.OUTPUT_ZONE_RIB_CODE_GUICHET, Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_N_COMPTE ),
OcrConstants.OUTPUT_ZONE_RIB_N_COMPTE, Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_CLE ), OcrConstants.OUTPUT_ZONE_RIB_CLE,
Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_IBAN ), OcrConstants.OUTPUT_ZONE_RIB_IBAN,
Variant.VariantString ) );
listA2iaOutputRib.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_BIC ), OcrConstants.OUTPUT_ZONE_RIB_BIC,
Variant.VariantString ) );
listA2iaOutputRib.forEach( a2iaOutput -> {
getA2iaOutputResult( a2iaOutput, dispatchA2iaObject, variantResultOcrId, mapOcrRibResult );
} );
// get Address info
A2iaOutput a2iaOutputAddress = new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_RIB_RESULT_ADDRESS ),
OcrConstants.OUTPUT_ZONE_RIB_ADDRESS, Variant.VariantInt );
getA2iaOutputResultMultiLines( a2iaOutputAddress, dispatchA2iaObject, variantResultOcrId, mapOcrRibResult );
return mapOcrRibResult;
}
/**
* Get Ocr results for Tax assessment.
*
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @return Map result of OCR
*/
private static Map<String, String> getTaxAssessmentResult( Dispatch dispatchA2iaObject, Variant variantResultOcrId )
{
Map<String, String> mapOcrTaxResult = new HashMap<>( );
// get Address info
A2iaOutput a2iaOutputAddress = new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_TAX_ASSESSMENT_RESULT_ADDRESS ),
OcrConstants.OUTPUT_ZONE_TAX_ASSESSMENT_ADDRESS, Variant.VariantInt );
getA2iaOutputResultMultiLines( a2iaOutputAddress, dispatchA2iaObject, variantResultOcrId, mapOcrTaxResult );
// get established date
A2iaOutput a2iaOutputDate = new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_TAX_ASSESSMENT_RESULT_DATE ),
OcrConstants.OUTPUT_ZONE_TAX_ASSESSMENT_ESTABLISHED_DATE, Variant.VariantString );
getA2iaOutputResultDate( a2iaOutputDate, dispatchA2iaObject, variantResultOcrId, mapOcrTaxResult );
// get Tax Amount
A2iaOutput a2iaOutputTaxAmonut = new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_TAX_ASSESSMENT_RESULT_TAX_AMOUNT ),
OcrConstants.OUTPUT_ZONE_TAX_ASSESSMENT_TAX_AMOUNT, Variant.VariantFloat );
getA2iaOutputResult( a2iaOutputTaxAmonut, dispatchA2iaObject, variantResultOcrId, mapOcrTaxResult );
return mapOcrTaxResult;
}
/**
* Get Ocr results for identity card document.
*
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @return Map result of OCR
*/
private static Map<String, String> getIdentityResult( Dispatch dispatchA2iaObject, Variant variantResultOcrId )
{
Map<String, String> mapOcrIdentityResult = new HashMap<>( );
List<A2iaOutput> listA2iaOutputIdentity = new ArrayList<>( );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_FIRST_NAME ),
OcrConstants.OUTPUT_ZONE_IDENTITY_FIRST_NAME, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_LAST_NAME ),
OcrConstants.OUTPUT_ZONE_IDENTITY_LAST_NAME, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_BIRTH_PLACE ),
OcrConstants.OUTPUT_ZONE_IDENTITY_BIRTH_PLACE, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_GENDER ),
OcrConstants.OUTPUT_ZONE_IDENTITY_GENDER, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_NATIONALITY ),
OcrConstants.OUTPUT_ZONE_IDENTITY_NATIONALITY, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_ID_NUMBER ),
OcrConstants.OUTPUT_ZONE_IDENTITY_ID_NUMBER, Variant.VariantInt ) );
listA2iaOutputIdentity.forEach( a2iaOutput -> {
getA2iaOutputResult( a2iaOutput, dispatchA2iaObject, variantResultOcrId, mapOcrIdentityResult );
} );
listA2iaOutputIdentity.clear( );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_BIRTH_DATE ),
OcrConstants.OUTPUT_ZONE_IDENTITY_BIRTH_DATE, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_EXPIRATION_DATE ),
OcrConstants.OUTPUT_ZONE_IDENTITY_EXPIRATION_DATE, Variant.VariantString ) );
listA2iaOutputIdentity.add( new A2iaOutput( AppPropertiesService.getProperty( OcrConstants.PROPERTY_IDENTITY_ISSUE_DATE ),
OcrConstants.OUTPUT_ZONE_IDENTITY_ISSUE_DATE, Variant.VariantString ) );
listA2iaOutputIdentity.forEach( a2iaOutputDate -> {
getA2iaOutputResultDate( a2iaOutputDate, dispatchA2iaObject, variantResultOcrId, mapOcrIdentityResult );
} );
return mapOcrIdentityResult;
}
/**
* Call a2ia to get property value.
*
* @param a2iaOutput
* a2iaOutput object
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @param mapResult
* map result of OCR
*/
private static void getA2iaOutputResult( A2iaOutput a2iaOutput, Dispatch dispatchA2iaObject, Variant variantResultOcrId, Map<String, String> mapResult )
{
Variant variantResult = Dispatch
.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ), a2iaOutput.getOutputZoneName( ) );
if ( variantResult != null )
{
mapResult.put( a2iaOutput.getKey( ), variantResult.changeType( a2iaOutput.getOutputZoneType( ) ).toString( ) );
}
}
/**
* Call a2ia to get property value for a multi lines output result.
*
* @param a2iaOutputMultiLines
* a2iaOutput object
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @param mapResult
* map result of OCR
*/
private static void getA2iaOutputResultMultiLines( A2iaOutput a2iaOutputMultiLines, Dispatch dispatchA2iaObject, Variant variantResultOcrId,
Map<String, String> mapResult )
{
Variant variantLines = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputMultiLines.getOutputZoneName( ) );
if ( ( ( variantLines != null ) && !variantLines.isNull( ) ) && ( variantLines.getInt( ) > 0 ) )
{
StringBuilder sbAdresse = new StringBuilder( );
for ( int i = 1; i <= variantLines.getInt( ); i++ )
{
Variant variantLine = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputMultiLines.getOutputZoneName( ) + "[" + i + "].wreco" );
if ( variantLine != null )
{
sbAdresse.append( variantLine.toString( ) ).append( " " );
Variant variantType = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputMultiLines.getOutputZoneName( ) + "[" + i + "].type" );
if ( OcrConstants.OUTPUT_ZONE_ADDRESS_NAME.equalsIgnoreCase( variantType.toString( ) ) )
{
mapResult.put( AppPropertiesService.getProperty( OcrConstants.PROPERTY_ADDRESS_NAME ), variantLine.toString( ) );
}
else
if ( OcrConstants.OUTPUT_ZONE_ADDRESS_DESTINATION.equalsIgnoreCase( variantType.toString( ) ) )
{
mapResult.put( AppPropertiesService.getProperty( OcrConstants.PROPERTY_ADDRESS_DESTINATION ), variantLine.toString( ) );
}
else
if ( OcrConstants.OUTPUT_ZONE_ADDRESS_PHONE_NUMBER.equalsIgnoreCase( variantType.toString( ) ) )
{
mapResult.put( AppPropertiesService.getProperty( OcrConstants.PROPERTY_ADDRESS_PHONE ), variantLine.toString( ) );
}
else
if ( OcrConstants.OUTPUT_ZONE_ADDRESS_CITY_ZIP.equalsIgnoreCase( variantType.toString( ) ) )
{
mapResult.put( AppPropertiesService.getProperty( OcrConstants.PROPERTY_ADDRESS_CITYZIP ), variantLine.toString( ) );
}
}
}
mapResult.put( a2iaOutputMultiLines.getKey( ), sbAdresse.toString( ) );
}
}
/**
* Call a2ia to get property value for an output type date.
*
* @param a2iaOutputDate
* a2iaOutput object
* @param dispatchA2iaObject
* A2ia Jacob wrapper
* @param variantResultOcrId
* id result Ocr A2ia
* @param mapResult
* map result of OCR
*/
private static void getA2iaOutputResultDate( A2iaOutput a2iaOutputDate, Dispatch dispatchA2iaObject, Variant variantResultOcrId,
Map<String, String> mapResult )
{
String strDayOfDate = ".day";
String strMonthOfDate = ".month";
String strYearOfDate = ".year";
String strDateSeparator = "/";
Variant variantDay = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputDate.getOutputZoneName( ) + strDayOfDate );
Variant variantMonth = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputDate.getOutputZoneName( ) + strMonthOfDate );
Variant variantYear = Dispatch.call( dispatchA2iaObject, OcrConstants.GET_PROPERTY_A2IA, variantResultOcrId.getInt( ),
a2iaOutputDate.getOutputZoneName( ) + strYearOfDate );
if ( ( variantDay != null ) && ( variantMonth != null ) && ( variantYear != null ) )
{
StringBuilder sbAddressResult = new StringBuilder( );
sbAddressResult.append( variantDay.changeType( Variant.VariantInt ).toString( ) ).append( strDateSeparator );
sbAddressResult.append( variantMonth.changeType( Variant.VariantInt ).toString( ) ).append( strDateSeparator );
sbAddressResult.append( variantYear.changeType( Variant.VariantInt ).toString( ) );
mapResult.put( a2iaOutputDate.getKey( ), sbAddressResult.toString( ) );
}
}
}
| [
"rafik.yahiaoui@paris.fr"
] | rafik.yahiaoui@paris.fr |
75ad7955cbc3479e45e910fa9ba85d21bdbf2c90 | 523e455fb882be9394130c4e8ba19955c4c4b3d6 | /eu/luscau/extras/CheckUnbreaking.java | 6ee43408420c32a3e3a3b867cdad32adb780ef33 | [] | no_license | Luscau/lcPickBreakBedRock | 6091873c52e68c963aeba9a85508d3b8d356c0eb | e69d33b6eb1892ad92807689617c49922e2db3db | refs/heads/master | 2021-01-20T07:15:34.632206 | 2017-08-27T16:18:08 | 2017-08-27T16:18:08 | 101,527,836 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,286 | java | package eu.luscau.extras;
import org.bukkit.inventory.ItemStack;
public class CheckUnbreaking {
public static void checkUnbreakingLevelSlow(int unb, ItemStack i) {
if (unb == 0) {
i.setDurability((short) (i.getDurability() + 7));
}
if (unb == 1) {
i.setDurability((short) (i.getDurability() + 6));
}
if (unb == 2) {
i.setDurability((short) (i.getDurability() + 5));
}
if (unb == 3) {
i.setDurability((short) (i.getDurability() + 4));
}
}
public static void checkUnbreakingLevelFast(int unb, ItemStack i) {
if (unb == 0) {
i.setDurability((short) (i.getDurability() + 15));
}
if (unb == 1) {
i.setDurability((short) (i.getDurability() + 13));
}
if (unb == 2) {
i.setDurability((short) (i.getDurability() + 12));
}
if (unb == 3) {
i.setDurability((short) (i.getDurability() + 10));
}
}
public static void checkUnbreakingLevelVeryFast(int unb, ItemStack i) {
if (unb == 0) {
i.setDurability((short) (i.getDurability() + 30));
}
if (unb == 1) {
i.setDurability((short) (i.getDurability() + 27));
}
if (unb == 2) {
i.setDurability((short) (i.getDurability() + 25));
}
if (unb == 3) {
i.setDurability((short) (i.getDurability() + 20));
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
bcf5d08b463ed2409d1f730caba70fe7604275e4 | 28a32c8fd9ac29fffdd87c7fe606733c94ac14a8 | /src/main/java/com/huawei/cloudsop/us/queryengine/Application.java | 16d59f7e7cd331bbf27dcc4ccc11dbe0fead4057 | [] | no_license | valtroffuture/queryengine | f6fde847cb7fb2ba93ebe3c18fabd278c9724c47 | 5af20c14e700a39bdf9dd922321c1b2c960736c3 | refs/heads/master | 2020-05-20T07:49:32.371657 | 2019-05-07T19:13:07 | 2019-05-07T19:13:07 | 185,461,062 | 0 | 0 | null | 2019-05-07T18:55:41 | 2019-05-07T18:55:41 | null | UTF-8 | Java | false | false | 326 | java | package com.huawei.cloudsop.us.queryengine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
} | [
"z00759325@china.huawei.com"
] | z00759325@china.huawei.com |
7b954ee818ad20ebd3fb85489a83b24af3515aeb | 20e6aa01bfe4a04632431a8fb2b6d31c2eea83fb | /app/src/main/java/com/test/markdemo/utils/RandomUtil.java | 47f8ca00ec6b4b326903b85b741e68f604c3a10f | [] | no_license | yuhuangyu/DemoCode | 33c8d35fab8af280f7ac95fd170a45870d3876ae | 799c9222d502632100d31eff215ceee06146fbfa | refs/heads/master | 2020-03-21T07:30:59.044709 | 2019-01-31T08:40:07 | 2019-01-31T08:40:17 | 138,284,513 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,765 | java | package com.test.markdemo.utils;
import java.util.Arrays;
import java.util.Random;
/*
*
* 随机获取工具类
* */
public class RandomUtil
{
private static Random _rand;
static
{
_rand = new Random(System.nanoTime());
}
public static boolean randBool()
{
return _rand.nextBoolean();
}
public static int randInt(int min, int max)
{
return _rand.nextInt(max - min + 1) + min;
}
public static String randWord(int min, int max)
{
Random random = _rand;
int len = random.nextInt(max - min + 1) + min;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < len; i++)
{
if (random.nextBoolean())
buffer.append((char) (random.nextInt('z' - 'a') + 'a'));
else buffer.append((char) (random.nextInt('Z' - 'A') + 'A'));
}
return buffer.toString();
}
public static String randWordNember(int min, int max)
{
Random random = _rand;
int len = random.nextInt(max - min) + min;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < len; i++)
{
int v = random.nextInt(3);
if (v == 0)
buffer.append((char) (random.nextInt('z' - 'a') + 'a'));
else if (v == 1)
buffer.append((char) (random.nextInt('Z' - 'A') + 'A'));
else buffer.append((char) (random.nextInt('9' - '0') + '0'));
}
return buffer.toString();
}
public static String randNember(int min, int max)
{
Random random = _rand;
int len = random.nextInt(max - min) + min;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < len; i++)
{
buffer.append((char) (random.nextInt('9' - '0') + '0'));
}
return buffer.toString();
}
// !小写字母 @大写字母 #数字
public static String rand(String pattern)
{
Random random = _rand;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < pattern.length(); i++)
{
if (pattern.charAt(i) == '!')
buffer.append((char) (random.nextInt('z' - 'a') + 'a'));
else if (pattern.charAt(i) == '@')
buffer.append((char) (random.nextInt('Z' - 'A') + 'A'));
else if (pattern.charAt(i) == '#')
buffer.append((char) (random.nextInt('9' - '0') + '0'));
else buffer.append(pattern.charAt(i));
}
return buffer.toString();
}
public static <T> T rand(T... array)
{
int index = _rand.nextInt(array.length);
if (array.length == 0)
return null;
else return array[index];
}
static <T> RandomArray<T> getArray(int def, T[] array)
{
return new RandomArray<T>(def, array);
}
static <T> RandomArray<T> getArray(T[] array)
{
return new RandomArray<T>(1, array);
}
static class RandomArray<T>
{
T[] _array;
int[] _powers;
int[] _updates;
int _def = 1;
int _max;
public RandomArray(int def, T[] array)
{
_array = array;
_def = def;
_powers = new int[array.length];
_updates = new int[array.length + 1];
Arrays.fill(_powers, def);
}
public void setPower(int index, int power)
{
_powers[index] = power;
}
public void update()
{
_updates[0] = 0;
for (int i = 0; i < _powers.length; i++)
{
_updates[i + 1] = _updates[i] + _powers[i];
}
_max = _updates[_updates.length - 1];
}
public T get()
{
int r = _rand.nextInt(_max);
return _array[seach(r)];
}
int seach(int r)
{
int end = _updates.length - 2;
int start = 0;
int index = (end + start) / 2;
while (true)
{
if (_updates[index] <= r && _updates[index + 1] > r)
{
return index;
}
else if (_updates[index] > r)
{
end = index - 1;
}
else if (_updates[index + 1] <= r)
{
start = index + 1;
}
index = (end + start) / 2;
}
}
}
}
| [
"fujian.yu@joyreach.com"
] | fujian.yu@joyreach.com |
7b6b71086c6d06ec21e867aa30157b372c02f438 | d29084e77834c47f1d02249261e8514513df0cd7 | /android/app/src/main/java/com/testprojectsecondtry/MainActivity.java | 5803e6f72b513f8432e289aa1bcb490ebeeb9a20 | [] | no_license | CheenaT/React-Native-WebRTC-App | a92330b7966b87893f7d1037cf67e528673f0e68 | 67a76745630daa6d3e5447243736ad17a042e8e1 | refs/heads/master | 2023-01-10T16:35:51.863602 | 2019-09-10T17:52:17 | 2019-09-10T17:52:17 | 191,544,038 | 3 | 2 | null | 2023-01-04T00:37:38 | 2019-06-12T09:50:17 | JavaScript | UTF-8 | Java | false | false | 385 | java | package com.testprojectsecondtry;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "testProjectSecondTry";
}
}
| [
"mac@Macs-MacBook-Air.local"
] | mac@Macs-MacBook-Air.local |
8af60af9387906c61263304a1fe58ae9acda3a93 | 0429ec7192a11756b3f6b74cb49dc1ba7c548f60 | /src/main/java/com/linkage/module/itms/report/dao/BandwidthDeviceReportDAO.java | 163334a661bd9112d1e14ac17f0f38eb9674e5df | [] | no_license | lichao20000/WEB | 5c7730779280822619782825aae58506e8ba5237 | 5d2964387d66b9a00a54b90c09332e2792af6dae | refs/heads/master | 2023-06-26T16:43:02.294375 | 2021-07-29T08:04:46 | 2021-07-29T08:04:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,048 | java |
package com.linkage.module.itms.report.dao;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.linkage.commons.db.DBUtil;
import com.linkage.commons.util.StringUtil;
import com.linkage.litms.common.util.StringUtils;
import com.linkage.module.gwms.Global;
import com.linkage.module.gwms.dao.SuperDAO;
import com.linkage.module.gwms.dao.tabquery.CityDAO;
import com.linkage.module.itms.report.act.BandwidthDeviceReportACT;
@SuppressWarnings({"rawtypes", "unchecked"})
public class BandwidthDeviceReportDAO extends SuperDAO {
// 日志记录
private static Logger logger = LoggerFactory.getLogger(BandwidthDeviceReportDAO.class);
public List<Map> getDeviceInfo(int curPage_splitPage, int num_splitPage,
String cityId, String bandwidth, String isSpeedUp) {
StringBuffer sql = getsql(cityId, bandwidth, isSpeedUp, "1");
logger.warn("带宽设备查询sql:{}",sql.toString());
List<Map> list = querySP(sql.toString(), (curPage_splitPage - 1) * num_splitPage + 1,
num_splitPage);
if(null == list || list.isEmpty()){
return new ArrayList<Map>();
}
for (Map map : list) {
map.put("vendorName", BandwidthDeviceReportACT.getVendor(StringUtil.getStringValue(map.get("vendor_id"))));
map.put("deviceModel", BandwidthDeviceReportACT.getModel(StringUtil.getStringValue(map.get("device_model_id"))));
map.put("cityName", CityDAO.getCityName(StringUtil.getStringValue(map.get("city_id"))));
if (StringUtil.IsEmpty(cityId) || "-1".equals(cityId)) {
cityId = Global.G_City_Pcity_Map.get(map.get("city_id"));
}
map.put("parentCityName", CityDAO.getCityName(cityId));
String _isSpeedUp = StringUtil.getStringValue(map, "gigabit_port", "0");
map.put("isSpeedUp", "1".equals(_isSpeedUp) ? "是" : "否");
}
return list;
}
private StringBuffer getsql(String cityId, String bandwidth, String isSpeedUp, String type) {
StringBuffer sql = new StringBuffer();
if ("1".equals(type)) {
sql.append("select a.city_id, b.username as loid , a.device_name, c.username, a.vendor_id, ");
sql.append("a.device_model_id, d.down_bandwidth, e.gigabit_port from ");
}
else {
if(DBUtil.GetDB()==3){
//TODO wait
sql.append("select count(*) from ");
}else{
sql.append("select count(1) from ");
}
}
sql.append("tab_gw_device a,tab_hgwcustomer b,hgwcust_serv_info c,tab_net_serv_param d,tab_device_version_attribute e ");
sql.append("where a.device_id = b.device_id and b.user_id = c.user_id ");
sql.append("and b.user_id = d.user_id and a.devicetype_id = e.devicetype_id ");
sql.append("and c.serv_type_id = 10 ");
if(!StringUtil.IsEmpty(cityId) && !"-1".equals(cityId)){
// 带上子属地及其本身
ArrayList<String> cityIdList = CityDAO.getAllNextCityIdsByCityPid(cityId);
if(null == cityIdList || cityIdList.isEmpty()){
sql.append(" and a.city_id = " + cityId);
}else{
sql.append(" and a.city_id in (")
.append(StringUtils.weave(cityIdList)).append(")");
cityIdList = null;
}
}
if ("1".equals(bandwidth)) {
sql.append(" and replace(d.down_bandwidth,'M') > 0 and replace(d.down_bandwidth,'M') <= 100");
}
else if ("2".equals(bandwidth)) {
sql.append(" and replace(d.down_bandwidth,'M') > 100 and replace(d.down_bandwidth,'M') <= 200");
}
else if ("3".equals(bandwidth)) {
sql.append(" and replace(d.down_bandwidth,'M') > 200");
}
sql.append(" and d.down_bandwidth is not null");
if ("1".equals(isSpeedUp)) {
sql.append(" and e.gigabit_port = 1");
}
else if ("2".equals(isSpeedUp)) {
sql.append(" and e.gigabit_port != 1");
}
return sql;
}
public int getDeviceInfoCount(int num_splitPage, String cityId, String bandwidth, String isSpeedUp) {
StringBuffer sql = getsql(cityId, bandwidth, isSpeedUp, "");
int total = jt.queryForInt(sql.toString());
int maxPage = 1;
if (total % num_splitPage == 0) {
maxPage = total / num_splitPage;
}
else {
maxPage = total / num_splitPage + 1;
}
return maxPage;
}
public List<Map> getAllDeviceInfo(String cityId, String bandwidth, String isSpeedUp) {
StringBuffer sql = getsql(cityId, bandwidth, isSpeedUp, "1");
List<Map> list = jt.queryForList(sql.toString());
if(null == list || list.isEmpty()){
return new ArrayList<Map>();
}
for (Map map : list) {
map.put("vendorName", BandwidthDeviceReportACT.getVendor(StringUtil.getStringValue(map.get("vendor_id"))));
map.put("deviceModel", BandwidthDeviceReportACT.getModel(StringUtil.getStringValue(map.get("device_model_id"))));
map.put("cityName", CityDAO.getCityName(StringUtil.getStringValue(map.get("city_id"))));
if (StringUtil.IsEmpty(cityId) || "-1".equals(cityId)) {
cityId = Global.G_City_Pcity_Map.get(map.get("city_id"));
}
map.put("parentCityName", CityDAO.getCityName(cityId));
String _isSpeedUp = StringUtil.getStringValue(map, "gigabit_port", "0");
map.put("isSpeedUp", "1".equals(_isSpeedUp) ? "是" : "否");
}
return list;
}
}
| [
"di4zhibiao.126.com"
] | di4zhibiao.126.com |
06dfddfdcd6d07ae1bbfbd8d2f86710716f5babb | 1abfb18cde2ba84a7b32df43be20ebb12c208072 | /Minesweeper/src/SaveGame.java | 3440b8335d087cad3c65dbf3434228db7eac7aad | [] | no_license | adamak1990/Minesweeper | d4d17f69bf9e468251436bb368b11ecdcd0dc655 | 48783f570738518f3581c2f386f85ccae656c049 | refs/heads/master | 2016-09-15T01:49:41.925282 | 2016-02-18T19:14:29 | 2016-02-18T19:14:29 | 51,688,045 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 424 | java | import java.io.Serializable;
public class SaveGame implements Serializable{
String highscore;
int width, height, mines, minesAtStart, left, pixels;
double loadedTime;
public SaveGame(String hscore, int w, int h, int m, int mAtStart, int l, int p, double lt) {
highscore = hscore;
width = w;
height = h;
mines = m;
minesAtStart = mAtStart;
left = l;
pixels = p;
loadedTime = lt;
}
}
| [
"adamak1990@gmail.com"
] | adamak1990@gmail.com |
3d3385e439f4ad4037bb6b5657a9fb5c94a79413 | aa993cc5a7dab7251fd7f6c7c709dfa82e7fed35 | /core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java | 20894bd9e294b28c716cb5021c6f1523a9810644 | [
"Apache-2.0"
] | permissive | cherish6092/elasticsearch-5.4.0 | 7102eb48dd254e52a149687b596dc39305b76218 | 8b611b0271ee98308c710a5dce11c408fab4fa3a | refs/heads/master | 2022-12-14T18:46:12.588517 | 2020-08-13T04:07:48 | 2020-08-13T04:07:48 | 263,504,074 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,989 | java | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.action.support.broadcast.node;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlock;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.ShardsIterator;
import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.transport.CapturingTransport;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportResponseOptions;
import org.elasticsearch.transport.TransportService;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static org.elasticsearch.test.ClusterServiceUtils.createClusterService;
import static org.elasticsearch.test.ClusterServiceUtils.setState;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.object.HasToString.hasToString;
public class TransportBroadcastByNodeActionTests extends ESTestCase {
private static final String TEST_INDEX = "test-index";
private static final String TEST_CLUSTER = "test-cluster";
private static ThreadPool THREAD_POOL;
private ClusterService clusterService;
private CapturingTransport transport;
private TestTransportBroadcastByNodeAction action;
public static class Request extends BroadcastRequest<Request> {
public Request() {
}
public Request(String[] indices) {
super(indices);
}
}
public static class Response extends BroadcastResponse {
public Response() {
}
public Response(int totalShards, int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
super(totalShards, successfulShards, failedShards, shardFailures);
}
}
class TestTransportBroadcastByNodeAction extends TransportBroadcastByNodeAction<Request, Response, TransportBroadcastByNodeAction.EmptyResult> {
private final Map<ShardRouting, Object> shards = new HashMap<>();
TestTransportBroadcastByNodeAction(Settings settings, TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request, String executor) {
super(settings, "indices:admin/test", THREAD_POOL, TransportBroadcastByNodeActionTests.this.clusterService, transportService, actionFilters, indexNameExpressionResolver, request, executor);
}
@Override
protected EmptyResult readShardResult(StreamInput in) throws IOException {
return EmptyResult.readEmptyResultFrom(in);
}
@Override
protected Response newResponse(Request request, int totalShards, int successfulShards, int failedShards, List<EmptyResult> emptyResults, List<ShardOperationFailedException> shardFailures, ClusterState clusterState) {
return new Response(totalShards, successfulShards, failedShards, shardFailures);
}
@Override
protected Request readRequestFrom(StreamInput in) throws IOException {
final Request request = new Request();
request.readFrom(in);
return request;
}
@Override
protected EmptyResult shardOperation(Request request, ShardRouting shardRouting) {
if (rarely()) {
shards.put(shardRouting, Boolean.TRUE);
return EmptyResult.INSTANCE;
} else {
ElasticsearchException e = new ElasticsearchException("operation failed");
shards.put(shardRouting, e);
throw e;
}
}
@Override
protected ShardsIterator shards(ClusterState clusterState, Request request, String[] concreteIndices) {
return clusterState.routingTable().allShards(new String[]{TEST_INDEX});
}
@Override
protected ClusterBlockException checkGlobalBlock(ClusterState state, Request request) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}
@Override
protected ClusterBlockException checkRequestBlock(ClusterState state, Request request, String[] concreteIndices) {
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, concreteIndices);
}
public Map<ShardRouting, Object> getResults() {
return shards;
}
}
class MyResolver extends IndexNameExpressionResolver {
MyResolver() {
super(Settings.EMPTY);
}
@Override
public String[] concreteIndexNames(ClusterState state, IndicesRequest request) {
return request.indices();
}
}
@BeforeClass
public static void startThreadPool() {
THREAD_POOL = new TestThreadPool(TransportBroadcastByNodeActionTests.class.getSimpleName());
}
@Before
public void setUp() throws Exception {
super.setUp();
transport = new CapturingTransport();
clusterService = createClusterService(THREAD_POOL);
final TransportService transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL,
TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
transportService.start();
transportService.acceptIncomingRequests();
setClusterState(clusterService, TEST_INDEX);
action = new TestTransportBroadcastByNodeAction(
Settings.EMPTY,
transportService,
new ActionFilters(new HashSet<>()),
new MyResolver(),
Request::new,
ThreadPool.Names.SAME
);
}
@After
public void tearDown() throws Exception {
super.tearDown();
clusterService.close();
}
void setClusterState(ClusterService clusterService, String index) {
int numberOfNodes = randomIntBetween(3, 5);
DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder();
IndexRoutingTable.Builder indexRoutingTable = IndexRoutingTable.builder(new Index(index, "_na_"));
int shardIndex = -1;
int totalIndexShards = 0;
for (int i = 0; i < numberOfNodes; i++) {
final DiscoveryNode node = newNode(i);
discoBuilder = discoBuilder.add(node);
int numberOfShards = randomIntBetween(1, 10);
totalIndexShards += numberOfShards;
for (int j = 0; j < numberOfShards; j++) {
final ShardId shardId = new ShardId(index, "_na_", ++shardIndex);
ShardRouting shard = TestShardRouting.newShardRouting(index, shardId.getId(), node.getId(), true, ShardRoutingState.STARTED);
IndexShardRoutingTable.Builder indexShard = new IndexShardRoutingTable.Builder(shardId);
indexShard.addShard(shard);
indexRoutingTable.addIndexShard(indexShard.build());
}
}
discoBuilder.localNodeId(newNode(0).getId());
discoBuilder.masterNodeId(newNode(numberOfNodes - 1).getId());
ClusterState.Builder stateBuilder = ClusterState.builder(new ClusterName(TEST_CLUSTER));
stateBuilder.nodes(discoBuilder);
final IndexMetaData.Builder indexMetaData = IndexMetaData.builder(index)
.settings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT))
.numberOfReplicas(0)
.numberOfShards(totalIndexShards);
stateBuilder.metaData(MetaData.builder().put(indexMetaData));
stateBuilder.routingTable(RoutingTable.builder().add(indexRoutingTable.build()).build());
ClusterState clusterState = stateBuilder.build();
setState(clusterService, clusterState);
}
static DiscoveryNode newNode(int nodeId) {
return new DiscoveryNode("node_" + nodeId, LocalTransportAddress.buildUnique(), emptyMap(), emptySet(), Version.CURRENT);
}
@AfterClass
public static void destroyThreadPool() {
ThreadPool.terminate(THREAD_POOL, 30, TimeUnit.SECONDS);
// since static must set to null to be eligible for collection
THREAD_POOL = null;
}
public void testGlobalBlock() {
Request request = new Request(new String[]{TEST_INDEX});
PlainActionFuture<Response> listener = new PlainActionFuture<>();
ClusterBlocks.Builder block = ClusterBlocks.builder()
.addGlobalBlock(new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
try {
action.new AsyncAction(null, request, listener).start();
fail("expected ClusterBlockException");
} catch (ClusterBlockException expected) {
assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
}
}
public void testRequestBlock() {
Request request = new Request(new String[]{TEST_INDEX});
PlainActionFuture<Response> listener = new PlainActionFuture<>();
ClusterBlocks.Builder block = ClusterBlocks.builder()
.addIndexBlock(TEST_INDEX, new ClusterBlock(1, "test-block", false, true, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL));
setState(clusterService, ClusterState.builder(clusterService.state()).blocks(block));
try {
action.new AsyncAction(null, request, listener).start();
fail("expected ClusterBlockException");
} catch (ClusterBlockException expected) {
assertEquals("blocked by: [SERVICE_UNAVAILABLE/1/test-block];", expected.getMessage());
}
}
public void testOneRequestIsSentToEachNodeHoldingAShard() {
Request request = new Request(new String[]{TEST_INDEX});
PlainActionFuture<Response> listener = new PlainActionFuture<>();
action.new AsyncAction(null, request, listener).start();
Map<String, List<CapturingTransport.CapturedRequest>> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear();
ShardsIterator shardIt = clusterService.state().routingTable().allShards(new String[]{TEST_INDEX});
Set<String> set = new HashSet<>();
for (ShardRouting shard : shardIt) {
set.add(shard.currentNodeId());
}
// check a request was sent to the right number of nodes
assertEquals(set.size(), capturedRequests.size());
// check requests were sent to the right nodes
assertEquals(set, capturedRequests.keySet());
for (Map.Entry<String, List<CapturingTransport.CapturedRequest>> entry : capturedRequests.entrySet()) {
// check one request was sent to each node
assertEquals(1, entry.getValue().size());
}
}
// simulate the master being removed from the cluster but before a new master is elected
// as such, the shards assigned to the master will still show up in the cluster state as assigned to a node but
// that node will not be in the local cluster state on any node that has detected the master as failing
// in this case, such a shard should be treated as unassigned
public void testRequestsAreNotSentToFailedMaster() {
Request request = new Request(new String[]{TEST_INDEX});
PlainActionFuture<Response> listener = new PlainActionFuture<>();
DiscoveryNode masterNode = clusterService.state().nodes().getMasterNode();
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
builder.remove(masterNode.getId());
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder));
action.new AsyncAction(null, request, listener).start();
Map<String, List<CapturingTransport.CapturedRequest>> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear();
// the master should not be in the list of nodes that requests were sent to
ShardsIterator shardIt = clusterService.state().routingTable().allShards(new String[]{TEST_INDEX});
Set<String> set = new HashSet<>();
for (ShardRouting shard : shardIt) {
if (!shard.currentNodeId().equals(masterNode.getId())) {
set.add(shard.currentNodeId());
}
}
// check a request was sent to the right number of nodes
assertEquals(set.size(), capturedRequests.size());
// check requests were sent to the right nodes
assertEquals(set, capturedRequests.keySet());
for (Map.Entry<String, List<CapturingTransport.CapturedRequest>> entry : capturedRequests.entrySet()) {
// check one request was sent to each non-master node
assertEquals(1, entry.getValue().size());
}
}
public void testOperationExecution() throws Exception {
ShardsIterator shardIt = clusterService.state().routingTable().allShards(new String[]{TEST_INDEX});
Set<ShardRouting> shards = new HashSet<>();
String nodeId = shardIt.iterator().next().currentNodeId();
for (ShardRouting shard : shardIt) {
if (nodeId.equals(shard.currentNodeId())) {
shards.add(shard);
}
}
final TransportBroadcastByNodeAction.BroadcastByNodeTransportRequestHandler handler =
action.new BroadcastByNodeTransportRequestHandler();
TestTransportChannel channel = new TestTransportChannel();
handler.messageReceived(action.new NodeRequest(nodeId, new Request(), new ArrayList<>(shards)), channel);
// check the operation was executed only on the expected shards
assertEquals(shards, action.getResults().keySet());
TransportResponse response = channel.getCapturedResponse();
assertTrue(response instanceof TransportBroadcastByNodeAction.NodeResponse);
TransportBroadcastByNodeAction.NodeResponse nodeResponse = (TransportBroadcastByNodeAction.NodeResponse) response;
// check the operation was executed on the correct node
assertEquals("node id", nodeId, nodeResponse.getNodeId());
int successfulShards = 0;
int failedShards = 0;
for (Object result : action.getResults().values()) {
if (!(result instanceof ElasticsearchException)) {
successfulShards++;
} else {
failedShards++;
}
}
// check the operation results
assertEquals("successful shards", successfulShards, nodeResponse.getSuccessfulShards());
assertEquals("total shards", action.getResults().size(), nodeResponse.getTotalShards());
assertEquals("failed shards", failedShards, nodeResponse.getExceptions().size());
List<BroadcastShardOperationFailedException> exceptions = nodeResponse.getExceptions();
for (BroadcastShardOperationFailedException exception : exceptions) {
assertThat(exception.getMessage(), is("operation indices:admin/test failed"));
assertThat(exception, hasToString(containsString("operation failed")));
}
}
public void testResultAggregation() throws ExecutionException, InterruptedException {
Request request = new Request(new String[]{TEST_INDEX});
PlainActionFuture<Response> listener = new PlainActionFuture<>();
// simulate removing the master
final boolean simulateFailedMasterNode = rarely();
DiscoveryNode failedMasterNode = null;
if (simulateFailedMasterNode) {
failedMasterNode = clusterService.state().nodes().getMasterNode();
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
builder.remove(failedMasterNode.getId());
builder.masterNodeId(null);
setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder));
}
action.new AsyncAction(null, request, listener).start();
Map<String, List<CapturingTransport.CapturedRequest>> capturedRequests = transport.getCapturedRequestsByTargetNodeAndClear();
ShardsIterator shardIt = clusterService.state().getRoutingTable().allShards(new String[]{TEST_INDEX});
Map<String, List<ShardRouting>> map = new HashMap<>();
for (ShardRouting shard : shardIt) {
if (!map.containsKey(shard.currentNodeId())) {
map.put(shard.currentNodeId(), new ArrayList<>());
}
map.get(shard.currentNodeId()).add(shard);
}
int totalShards = 0;
int totalSuccessfulShards = 0;
int totalFailedShards = 0;
for (Map.Entry<String, List<CapturingTransport.CapturedRequest>> entry : capturedRequests.entrySet()) {
List<BroadcastShardOperationFailedException> exceptions = new ArrayList<>();
long requestId = entry.getValue().get(0).requestId;
if (rarely()) {
// simulate node failure
totalShards += map.get(entry.getKey()).size();
totalFailedShards += map.get(entry.getKey()).size();
transport.handleRemoteError(requestId, new Exception());
} else {
List<ShardRouting> shards = map.get(entry.getKey());
List<TransportBroadcastByNodeAction.EmptyResult> shardResults = new ArrayList<>();
for (ShardRouting shard : shards) {
totalShards++;
if (rarely()) {
// simulate operation failure
totalFailedShards++;
exceptions.add(new BroadcastShardOperationFailedException(shard.shardId(), "operation indices:admin/test failed"));
} else {
shardResults.add(TransportBroadcastByNodeAction.EmptyResult.INSTANCE);
}
}
totalSuccessfulShards += shardResults.size();
TransportBroadcastByNodeAction.NodeResponse nodeResponse = action.new NodeResponse(entry.getKey(), shards.size(), shardResults, exceptions);
transport.handleResponse(requestId, nodeResponse);
}
}
if (simulateFailedMasterNode) {
totalShards += map.get(failedMasterNode.getId()).size();
}
Response response = listener.get();
assertEquals("total shards", totalShards, response.getTotalShards());
assertEquals("successful shards", totalSuccessfulShards, response.getSuccessfulShards());
assertEquals("failed shards", totalFailedShards, response.getFailedShards());
assertEquals("accumulated exceptions", totalFailedShards, response.getShardFailures().length);
}
public class TestTransportChannel implements TransportChannel {
private TransportResponse capturedResponse;
public TransportResponse getCapturedResponse() {
return capturedResponse;
}
@Override
public String action() {
return null;
}
@Override
public String getProfileName() {
return "";
}
@Override
public void sendResponse(TransportResponse response) throws IOException {
capturedResponse = response;
}
@Override
public void sendResponse(TransportResponse response, TransportResponseOptions options) throws IOException {
}
@Override
public void sendResponse(Exception exception) throws IOException {
}
@Override
public long getRequestId() {
return 0;
}
@Override
public String getChannelType() {
return "test";
}
}
}
| [
"muzan@ibantang.com"
] | muzan@ibantang.com |
4642fe153eba02d7d0cddd1d0267d46e372cbf0a | 1860f32932c4e5198d8e89f9568c371a72775a3b | /OOP_Advanced_Exam_9_January/SomeExam/src/main/java/panzer/models/vehicles/Vanguard.java | 30641e0b71eb0de91d1b0383a32843b6c2142894 | [] | no_license | tsmarkov/Java-Fundamentals | 75099aceaed54dd9edf31f83522a1dac8420e2f0 | fbbc8df04c85cad7a54b1611f33a6abcd7a7df8c | refs/heads/master | 2020-03-06T20:22:56.443176 | 2018-03-27T22:20:13 | 2018-03-27T22:20:13 | 127,051,589 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,147 | java | package panzer.models.vehicles;
import panzer.contracts.Assembler;
import panzer.contracts.Part;
import java.math.BigDecimal;
import java.util.List;
public class Vanguard extends BaseVehicle {
public Vanguard(String model, double weight, BigDecimal price, long attack, long defense, long hitPoints, Assembler assembler) {
super(model, weight, price, attack, defense, hitPoints, assembler);
}
@Override
protected void setHitPoints(long hitPoints) {
super.setHitPoints(hitPoints + ((hitPoints * 75) / 100));
}
@Override
protected void setWeight(double weight) {
super.setWeight(weight + ((weight * 100) / 100));
}
@Override
protected void setAttack(long attack) {
super.setAttack(attack - ((attack * 25) / 100));
}
@Override
protected void setDefense(long defense) {
super.setDefense(defense + ((defense * 50) / 100));
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(String.format("Vanguard - %s", this.getModel())).append(System.lineSeparator());
sb.append(String.format("Total Weight: %.3f", this.getTotalWeight())).append(System.lineSeparator());
sb.append(String.format("Total Price: %.3f", this.getTotalPrice())).append(System.lineSeparator());
sb.append(String.format("Attack: %d", this.getTotalAttack())).append(System.lineSeparator());
sb.append(String.format("Defense: %d", this.getTotalDefense())).append(System.lineSeparator());
sb.append(String.format("HitPoints: %d", this.getTotalHitPoints())).append(System.lineSeparator());
sb.append("Parts: ");
List<Part> parts = (List<Part>) this.getParts();
if (parts.isEmpty()) {
sb.append("None");
} else {
int i = 0;
for (Part s : parts) {
if (i != 0) {
sb.append(String.format(", %s", s.getModel()));
} else {
sb.append(s.getModel());
}
i++;
}
}
return sb.toString();
}
}
| [
"markovcvetomir@gmail.com"
] | markovcvetomir@gmail.com |
7bd8d74ad30b709a6c4fd3d574611864fd649f01 | 2abbe81a8a6c8b897dfe38628416e209b4e0a137 | /src/main/java/com/example/demo/service/OpencourService.java | a2978e4616d16741756852d421ba26280bf6688f | [] | no_license | 2416941966/ziyuan | b531e6841d1954bc3e6ef7722d4f0c695b707af5 | 90759e6a32d3fd7a91f4b17e937c0f1274257d26 | refs/heads/master | 2023-06-07T05:39:51.399501 | 2019-11-15T08:51:54 | 2019-11-15T08:51:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 263 | java | package com.example.demo.service;
public interface OpencourService {
void addppt(String cid,String ppt);
void addcourse(String cid,String cname,String label,String processchart,String outline,String exinstruct);
void addtc(String tid,String cid);
}
| [
"2320165467@qq.com"
] | 2320165467@qq.com |
454a81857ce530c29ea8fc33cfec99ed63a499ae | d83be7f38b4defb108b48725cd5d8eebd2c47c10 | /HIA/src/vo/CommentPageInfo.java | 24ef8958e75ce8f4267c307799dd37fcf42941a6 | [] | no_license | amayun707/HIA_TEAM | e322bea92f710ab0b574405ac6e51120f122fa66 | 1c311254738eea03168e57f5b784bf2548ff6617 | refs/heads/master | 2020-08-30T14:28:22.830020 | 2019-12-20T05:07:33 | 2019-12-20T05:07:33 | 218,408,675 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,541 | java | package vo;
public class CommentPageInfo {
// 페이징 처리 관련 정보를 저장하는 클래스
private int commentPage;
private int commentMaxPage;
private int commentStartPage;
private int commentEndPage;
private int commentListCount;
public CommentPageInfo() {}
public CommentPageInfo(int commentPage, int commentMaxPage, int commentStartPage, int commentEndPage,
int commentListCount) {
super();
this.commentPage = commentPage;
this.commentMaxPage = commentMaxPage;
this.commentStartPage = commentStartPage;
this.commentEndPage = commentEndPage;
this.commentListCount = commentListCount;
}
public int getCommentPage() {
return commentPage;
}
public void setCommentPage(int commentPage) {
this.commentPage = commentPage;
}
public int getCommentMaxPage() {
return commentMaxPage;
}
public void setCommentMaxPage(int commentMaxPage) {
this.commentMaxPage = commentMaxPage;
}
public int getCommentStartPage() {
return commentStartPage;
}
public void setCommentStartPage(int commentStartPage) {
this.commentStartPage = commentStartPage;
}
public int getCommentEndPage() {
return commentEndPage;
}
public void setCommentEndPage(int commentEndPage) {
this.commentEndPage = commentEndPage;
}
public int getCommentListCount() {
return commentListCount;
}
public void setCommentListCount(int commentListCount) {
this.commentListCount = commentListCount;
}
}
| [
"ITWILL@DESKTOP-BFHD141"
] | ITWILL@DESKTOP-BFHD141 |
7eeed04766cf6d512cffe6b88eeba3457fc60793 | 7098f2d71cb0699a46a11c2db96e76285d35727c | /dss-src/apps/dss/core/dss-service/src/main/java/eu/europa/ec/markt/dss/validation/https/OptimistX509HostnameVerifier.java | 83459decff51bcf0555643c5e26e5014c499fe89 | [] | no_license | p4535992/sd-dss-3.0.3 | 4344521a309efaacd1798ed4bd7e7ef37a69f874 | b2fa77670267732daca5d86a5e46a9f71bd16247 | refs/heads/master | 2021-08-30T11:07:59.383832 | 2017-12-17T15:07:14 | 2017-12-17T15:07:14 | 112,770,373 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,758 | java | /*
* DSS - Digital Signature Services
*
* Copyright (C) 2011 European Commission, Directorate-General Internal Market and Services (DG MARKT), B-1049 Bruxelles/Brussel
*
* Developed by: 2011 ARHS Developments S.A. (rue Nicolas Bové 2B, L-1253 Luxembourg) http://www.arhs-developments.com
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* "DSS - Digital Signature Services" is free software: you can redistribute it and/or modify it under the terms of
* the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* DSS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* "DSS - Digital Signature Services". If not, see <http://www.gnu.org/licenses/>.
*/
package eu.europa.ec.markt.dss.validation.https;
import java.io.IOException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.apache.http.conn.ssl.X509HostnameVerifier;
/**
*
* A X509HostnameVerifier for allow all hostnames.
*
* <p>
* DISCLAIMER: Project owner DG-MARKT.
*
* @version $Revision: 1016 $ - $Date: 2011-06-17 15:30:45 +0200 (Fri, 17 Jun 2011) $
* @author <a href="mailto:dgmarkt.Project-DSS@arhs-developments.com">ARHS Developments</a>
*/
public class OptimistX509HostnameVerifier implements X509HostnameVerifier {
/*
* (non-Javadoc)
*
* @see javax.net.ssl.HostnameVerifier#verify(java.lang.String, javax.net.ssl.SSLSession)
*/
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
/*
* (non-Javadoc)
*
* @see org.apache.http.conn.ssl.X509HostnameVerifier#verify(java.lang.String, javax.net.ssl.SSLSocket)
*/
@Override
public void verify(String host, SSLSocket ssl) throws IOException {
}
/*
* (non-Javadoc)
*
* @see org.apache.http.conn.ssl.X509HostnameVerifier#verify(java.lang.String, java.lang.String[],
* java.lang.String[])
*/
@Override
public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException {
}
/*
* (non-Javadoc)
*
* @see org.apache.http.conn.ssl.X509HostnameVerifier#verify(java.lang.String, java.security.cert.X509Certificate)
*/
@Override
public void verify(String host, X509Certificate cert) throws SSLException {
}
}
| [
"tentimarco0@gmail.com"
] | tentimarco0@gmail.com |
06bd7733113b8e06f763c0e842c881fd028eae3b | d5bd2f103f241fb1c371855e88ec8cbb41583f2d | /src/main/java/org/mudebug/prapr/core/mutationtest/engine/mutators/util/Commons.java | 4eadd17b0c32f7419bccad8827628c7aa34cfff4 | [
"Apache-2.0"
] | permissive | monperrus/prapr-sc | 38f03d2f1fb1e6c8045600fab5fa5faa8dca3843 | 9cf616099e7bb64621bfd6422c17d7bb497dd654 | refs/heads/master | 2020-11-25T19:59:20.444725 | 2019-12-17T17:30:09 | 2019-12-17T17:30:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,388 | java | package org.mudebug.prapr.core.mutationtest.engine.mutators.util;
/*
* #%L
* prapr-plugin
* %%
* Copyright (C) 2018 - 2019 University of Texas at Dallas
* %%
* 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.
* #L%
*/
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.classinfo.ClassName;
import org.pitest.mutationtest.engine.gregor.MethodInfo;
import org.pitest.reloc.asm.ClassReader;
import org.pitest.reloc.asm.ClassVisitor;
import org.pitest.reloc.asm.MethodVisitor;
import org.pitest.reloc.asm.Opcodes;
import org.pitest.reloc.asm.Type;
import org.pitest.reloc.asm.commons.LocalVariablesSorter;
/**
* A set of utility methods useful for mutating JVM byetcode.
*
* @author Ali Ghanbari (ali.ghanbari@utdallas.edu)
* @since 1.0.0
*/
public final class Commons {
private Commons() {
}
public static MethodVisitor dummyMethodVisitor(final MethodVisitor mv) {
return new MethodVisitor(Opcodes.ASM6, mv) {
/* do nothing */
};
}
public static LocalVarInfo pickLocalVariable(final List<LocalVarInfo> visibleLocals,
final String desc,
final int skip,
final int index) {
int count = skip;
for (final LocalVarInfo lvi : visibleLocals) {
if (lvi.typeDescriptor.equals(desc)) {
if (index == count) {
return lvi;
}
count++;
}
}
return null;
}
public static FieldInfo pickField(final Map<String, List<FieldInfo>> fieldsInfo,
final String desc,
final int skip,
final int index,
final boolean accessedInStaticMeth) {
final List<FieldInfo> fil = fieldsInfo.get(desc);
int count = skip;
if (fil != null) {
if (accessedInStaticMeth) {
for (final FieldInfo fi : fil) {
if (fi.isStatic) {
if (count == index) {
return fi;
}
count++;
}
}
} else {
for (final FieldInfo fi : fil) {
if (count == index) {
return fi;
}
count++;
}
}
}
return null;
}
public static int[] createTempLocals(final LocalVariablesSorter lvs, final Type... types) {
final int[] tempLocals = new int[types.length];
for (int i = 0; i < types.length; i++) {
tempLocals[i] = lvs.newLocal(types[i]);
}
return tempLocals;
}
public static void storeValues(final MethodVisitor mv, final Type[] args, final int[] tempLocals) {
for (int i = tempLocals.length - 1; i >= 0; i--) {
final int tempLocal = tempLocals[i];
switch (args[i].getSort()) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
mv.visitVarInsn(Opcodes.ASTORE, tempLocal);
break;
case Type.FLOAT:
mv.visitVarInsn(Opcodes.FSTORE, tempLocal);
break;
case Type.LONG:
mv.visitVarInsn(Opcodes.LSTORE, tempLocal);
break;
case Type.DOUBLE:
mv.visitVarInsn(Opcodes.DSTORE, tempLocal);
break;
case Type.BYTE:
case Type.BOOLEAN:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
mv.visitVarInsn(Opcodes.ISTORE, tempLocal);
break;
default:
throw new RuntimeException();
}
}
}
public static void restoreValues(final MethodVisitor mv, final int[] tempLocals, final Type[] args) {
for (int i = 0; i < args.length; i++) {
final int tempLocal = tempLocals[i];
switch (args[i].getSort()) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
mv.visitVarInsn(Opcodes.ALOAD, tempLocal);
break;
case Type.FLOAT:
mv.visitVarInsn(Opcodes.FLOAD, tempLocal);
break;
case Type.LONG:
mv.visitVarInsn(Opcodes.LLOAD, tempLocal);
break;
case Type.DOUBLE:
mv.visitVarInsn(Opcodes.DLOAD, tempLocal);
break;
case Type.BYTE:
case Type.BOOLEAN:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
mv.visitVarInsn(Opcodes.ILOAD, tempLocal);
break;
default:
throw new RuntimeException();
}
}
}
public static void injectFieldValue(final MethodVisitor mv,
final int baseIndex,
final FieldInfo fi,
final Type expectedType) {
final String desc = expectedType.getDescriptor();
final String ownerInternalName = fi.owningClassName.asInternalName();
final String name = fi.name;
if (fi.isStatic) {
mv.visitFieldInsn(Opcodes.GETSTATIC, ownerInternalName, name, desc);
} else {
mv.visitVarInsn(Opcodes.ALOAD, baseIndex);
mv.visitFieldInsn(Opcodes.GETFIELD, ownerInternalName, name, desc);
}
}
public static void injectLocalValue(final MethodVisitor mv,
final int local,
final Type expectedType) {
switch (expectedType.getSort()) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
mv.visitVarInsn(Opcodes.ALOAD, local);
break;
case Type.FLOAT:
mv.visitVarInsn(Opcodes.FLOAD, local);
break;
case Type.LONG:
mv.visitVarInsn(Opcodes.LLOAD, local);
break;
case Type.DOUBLE:
mv.visitVarInsn(Opcodes.DLOAD, local);
break;
case Type.BYTE:
case Type.BOOLEAN:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
mv.visitVarInsn(Opcodes.ILOAD, local);
break;
default:
throw new RuntimeException();
}
}
public static void injectDefaultValue(final MethodVisitor mv,
final Type expectedType) {
switch (expectedType.getSort()) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
mv.visitInsn(Opcodes.ACONST_NULL);
break;
case Type.FLOAT:
mv.visitInsn(Opcodes.FCONST_0);
break;
case Type.LONG:
mv.visitInsn(Opcodes.LCONST_0);
break;
case Type.DOUBLE:
mv.visitInsn(Opcodes.DCONST_0);
break;
case Type.BYTE:
case Type.BOOLEAN:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
mv.visitInsn(Opcodes.ICONST_0);
break;
default:
throw new RuntimeException();
}
}
public static void injectReturnStmt(final MethodVisitor mv,
final Type returnType,
final LocalVarInfo lvi,
final FieldInfo fi) {
final int mutatedMethodReturnSort = returnType.getSort();
if (mutatedMethodReturnSort == Type.VOID) {
mv.visitInsn(Opcodes.RETURN);
} else {
if (lvi == null && fi == null) {
injectDefaultValue(mv, returnType);
} else if (fi == null) {
injectLocalValue(mv, lvi.index, returnType);
} else {
injectFieldValue(mv, 0, fi, returnType);
}
switch (mutatedMethodReturnSort) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
mv.visitInsn(Opcodes.ARETURN);
break;
case Type.FLOAT:
mv.visitInsn(Opcodes.FRETURN);
break;
case Type.LONG:
mv.visitInsn(Opcodes.LRETURN);
break;
case Type.DOUBLE:
mv.visitInsn(Opcodes.DRETURN);
break;
case Type.BYTE:
case Type.BOOLEAN:
case Type.CHAR:
case Type.SHORT:
case Type.INT:
mv.visitInsn(Opcodes.IRETURN);
break;
default:
throw new RuntimeException();
}
}
}
public static String defValString(final Type type) {
switch (type.getSort()) {
case Type.OBJECT:
case Type.METHOD:
case Type.ARRAY:
return "null";
case Type.FLOAT:
return "0.F";
case Type.LONG:
return "0L";
case Type.DOUBLE:
return "0.D";
case Type.BYTE:
return "0";
case Type.BOOLEAN:
return "false";
case Type.CHAR:
return "'\\0'";
case Type.SHORT:
return "0";
case Type.INT:
return "0";
default:
throw new RuntimeException();
}
}
public static boolean isVirtualCall(int opcode) {
switch (opcode) {
case Opcodes.INVOKEINTERFACE:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKEVIRTUAL:
return true;
}
return false;
}
public static boolean isStaticCall(int opcode) {
return opcode == Opcodes.INVOKESTATIC;
}
private static class SimpleClassVisitor extends ClassVisitor {
private String superName;
public SimpleClassVisitor() {
super(Opcodes.ASM6);
}
@Override
public void visit(int version,
int access,
String name,
String signature,
String superName,
String[] interfaces) {
this.superName = superName;
super.visit(version, access, name, signature, superName, interfaces);
}
public String getSuperName() {
return superName;
}
}
public static String getSupertype(final ClassByteArraySource cache,
final String typeInternalName) {
final byte[] bytes = cache.getBytes(typeInternalName).value();
final SimpleClassVisitor cv = new SimpleClassVisitor();
final ClassReader cr = new ClassReader(bytes);
cr.accept(cv, ClassReader.EXPAND_FRAMES);
return cv.getSuperName();
}
/**
*
* @param methodInfo
* @return
* @since 2.0.3
*/
public static ClassName getOwningClassName(final MethodInfo methodInfo) {
final String methodName = methodInfo.getDescription();
final int indexOfColon = methodName.indexOf(':');
return ClassName.fromString(methodName.substring(0, indexOfColon));
}
/**
*
* @param methodInfo
* @return
* @since 2.0.3
*/
public static int getMethodAccess(final MethodInfo methodInfo) {
try {
final Field accessField = MethodInfo.class.getDeclaredField("access");
accessField.setAccessible(true);
return accessField.getInt(methodInfo);
} catch (Exception e) {
e.printStackTrace();
}
throw new IllegalStateException();
}
} | [
"ali.ghanbari@utdallas.edu"
] | ali.ghanbari@utdallas.edu |
95babe0fc68cb8dcb996217c931873d0e147d8e8 | 6cd44c24432165400a71faafe2ebac6855729104 | /projects/TipOfTheDay/trunk/TipOfTheDayWeb/src/main/java/com/googlecode/gradlesamples/tipoftheday/servlets/TipOfTheDayJSONServlet.java | fda4ab3de9ac5d8809b5f3433417484ee6299c2f | [] | no_license | lio972/gradle-samples | 9d5a8366fbc81ea257ad08e24beb7a5b9b4d9b2a | 78a1d4da0d5c977b6b032c8a67e300a0fe83bc65 | refs/heads/master | 2020-05-24T14:45:37.045402 | 2009-05-23T00:34:40 | 2009-05-23T00:34:40 | 34,383,532 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,829 | java | package com.googlecode.gradlesamples.tipoftheday.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.googlecode.gradlesamples.tipoftheday.ejb.TipOfTheDayBeanLocal;
import com.googlecode.gradlesamples.tipoftheday.ejb.TipOfTheDayVO;
/**
* Servlet implementation class TipOfTheDayJSONServlet
*/
public class TipOfTheDayJSONServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(TipOfTheDayJSONServlet.class);
/**
* @see HttpServlet#HttpServlet()
*/
public TipOfTheDayJSONServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter writer = response.getWriter();
TipOfTheDayBeanLocal bean = null;
try {
InitialContext ctx = new InitialContext();
bean = (TipOfTheDayBeanLocal) ctx
.lookup("java:comp/env/ejb/TipOfTheDay");
} catch (NamingException e) {
logger.error(e.getMessage(), e);
throw new ServletException(e);
}
if (bean != null) {
TipOfTheDayVO tip = bean.nextTip();
JSONObject object = (JSONObject) JSONSerializer.toJSON(tip);
writer.println(object.toString());
}
}
}
| [
"dizzydevvy@f8746bb8-46cf-11de-aeda-3f4d37dfb5fa"
] | dizzydevvy@f8746bb8-46cf-11de-aeda-3f4d37dfb5fa |
8a97ffec7a205260ceec07ab4a6df89cf4bcb4ca | c221cd01ec47d16a9f188ee722548aa8cc499927 | /presto-main/src/main/java/com/facebook/presto/metadata/BoundVariables.java | 8e9267fdca145d6dd72eb72d83e257e0b2ee4052 | [
"Apache-2.0"
] | permissive | lacbs/presto | 10d843ac1b778912025ef977a62c8fd7fc342be3 | b907d7cdbc445dbd4dc97789af8d8beb22ae2535 | refs/heads/master | 2020-12-24T21:55:06.601414 | 2016-04-29T16:33:10 | 2016-04-29T21:44:43 | 52,392,846 | 0 | 0 | null | 2016-02-23T21:27:02 | 2016-02-23T21:27:02 | null | UTF-8 | Java | false | false | 3,510 | java | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.metadata;
import com.facebook.presto.spi.type.Type;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Objects;
import java.util.OptionalLong;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Collections.unmodifiableMap;
import static java.util.Objects.requireNonNull;
public class BoundVariables
{
private final Map<String, Type> typeVariables;
private final Map<String, OptionalLong> longVariables;
public BoundVariables(Map<String, Type> typeVariables,
Map<String, OptionalLong> longVariables)
{
requireNonNull(typeVariables, "typeVariableBindings is null");
requireNonNull(longVariables, "longVariableBindings is null");
this.typeVariables = ImmutableMap.copyOf(typeVariables);
this.longVariables = ImmutableMap.copyOf(longVariables);
}
public Type getTypeVariable(String variableName)
{
return getValue(typeVariables, variableName);
}
public boolean containsTypeVariable(String variableName)
{
return containsValue(typeVariables, variableName);
}
public Map<String, Type> getTypeVariables()
{
return unmodifiableMap(typeVariables);
}
public OptionalLong getLongVariable(String variableName)
{
return getValue(longVariables, variableName);
}
public boolean containsLongVariable(String variableName)
{
return containsValue(longVariables, variableName);
}
public Map<String, OptionalLong> getLongVariables()
{
return unmodifiableMap(longVariables);
}
private <T> T getValue(Map<String, T> map, String variableName)
{
checkState(variableName != null, "variableName is null");
T value = map.get(variableName);
checkState(value != null, "value for variable '%s' is null", variableName);
return value;
}
private boolean containsValue(Map<String, ?> map, String variableName)
{
checkState(variableName != null, "variableName is null");
return map.containsKey(variableName);
}
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BoundVariables that = (BoundVariables) o;
return Objects.equals(typeVariables, that.typeVariables) &&
Objects.equals(longVariables, that.longVariables);
}
@Override
public int hashCode()
{
return Objects.hash(typeVariables, longVariables);
}
@Override
public String toString()
{
return toStringHelper(this)
.add("typeVariables", typeVariables)
.add("longVariables", longVariables)
.toString();
}
}
| [
"mtraverso@gmail.com"
] | mtraverso@gmail.com |
d67c772101ecb8924439343417afdbfeb0277a63 | 196cb24d4ec66df267fc27eed5163965cf9b04bf | /android/src/com/ia/smsservice/LoginActivity.java | cc024ac38a5b88d0e71241d6a98dd9283a88e7dc | [] | no_license | ibrahimAltinoluk/sms_service | 44e76a668d5f490dd8e9757858cc2b7fa33b074d | c2a9d34466e9859ada4cf0ecf10f07fca1d0ab41 | refs/heads/master | 2021-01-17T17:07:56.352186 | 2014-08-13T14:24:54 | 2014-08-13T14:24:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,074 | java | package com.ia.smsservice;
import java.util.Arrays;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import com.facebook.AccessToken;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
public class LoginActivity extends FragmentActivity {
Context context;
Utils utils;
Activity activity;
Button fb_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
context = activity = this;
utils = new Utils(activity);
fb_login = (Button) findViewById(R.id.btn_login);
fb_login.setVisibility(View.INVISIBLE);
fb_login.setOnClickListener(logintrigger);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
ifSessionActiveThenContinueIt();
}
public void ifSessionActiveThenContinueIt() {
Session session = new Session(context);
AccessToken at;
at = AccessToken.createFromExistingAccessToken(utils.LoadToken(), null, null, null, null);
if (!utils.LoadToken().equals("")) {
utils.open_progress();
Session.openActiveSessionWithAccessToken(context, at, session_call_back);
} else {
fb_login.setVisibility(View.VISIBLE);
}
}
View.OnClickListener logintrigger = new View.OnClickListener() {
@Override
public void onClick(View v) {
Session session = new Session(context);
Session.OpenRequest request = new Session.OpenRequest(activity).setPermissions(Arrays.asList(utils.USER_EMAIL, utils.USER_INFO));
request.setCallback(session_call_back);
Session.setActiveSession(session);
session.openForRead(request);
}
};
Session.StatusCallback session_call_back = new Session.StatusCallback() {
@Override
public void call(final Session session, SessionState state, Exception exception) {
Session.setActiveSession(session);
if (session.isOpened()) {
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(final GraphUser user, final Response response) {
if (user != null) {
startActivity(new Intent(context, MainActivity.class));
Log.w("bilgiler", user.getInnerJSONObject().toString());
utils.SaveToken(session.getAccessToken()).SaveData(utils.USER_NAME, user.getFirstName()).SaveData(utils.USER_FULL_NAME, user.getFirstName() + " " + user.getLastName())
.register_on_web(user, true);
finish();
}
}
});
}
utils.close_progress();
}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
| [
"ibrahim.altinoluk@gmail.com"
] | ibrahim.altinoluk@gmail.com |
b2dca02b30c5c7cb4492c50f1867011a160aa488 | 2933f7a780a385c0b3fa7e51862b305fd3407e83 | /Cuenta.java | 276e37c7afeb0322c076471a84eca2acf508f1ca | [] | no_license | CIS032/examen-002-b-frankoMendoza | 872489ec255d0f3d2e7960770c48f98ce3ddf0b7 | c3a0a1b458636867cd8fffde37673f889becedc5 | refs/heads/master | 2021-05-03T05:17:56.664740 | 2018-02-07T20:15:14 | 2018-02-07T20:15:14 | 120,635,903 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,148 | java | package examen2;
import java.util.Objects;
public abstract class Cuenta {
private String cliente;
private String tipoCliente;
private double balance;
private double tasaInteres;
public Cuenta() {
}
public Cuenta(String cliente) {
this.cliente = cliente;
}
public Cuenta(String cliente, String tipoCliente, double balance, double tasaInteres) {
this.cliente = cliente;
this.tipoCliente = tipoCliente;
this.balance = balance;
this.tasaInteres = tasaInteres;
}
public String getCliente() {
return cliente;
}
public void setCliente(String cliente) {
this.cliente = cliente;
}
public String getTipoCliente() {
return tipoCliente;
}
public void setTipoCliente(String tipoCliente) {
this.tipoCliente = tipoCliente;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getTasaInteres() {
return tasaInteres;
}
public void setTasaInteres(double tasaInteres) {
this.tasaInteres = tasaInteres;
}
public abstract double calcularInteres(int meses);
public abstract double depositar(double monto);
@Override
public String toString() {
return "cliente=" + cliente + ", tipoCliente=" + tipoCliente + ", balance=" + balance + ", tasaInteres=" + tasaInteres ;
}
@Override
public int hashCode() {
int hash = 7;
hash = 37 * hash + Objects.hashCode(this.cliente);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Cuenta other = (Cuenta) obj;
if (!Objects.equals(this.cliente, other.cliente)) {
return false;
}
return true;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
9ba08c8349590d8a4ea220edfffe02e7fc5baf64 | 331b8b4ee03a7aea17c7fb433e7379993b17ec4d | /java/src/Test.java | 98e824466213567422eee7c1c096434eee76b479 | [] | no_license | macoto35/Algorithmic_Design_and_Techniques | 0e8e234a9cea08f08459b36479161fff6089c787 | 2531316cd82a90636a0d0562bcb048d2b2f66b5f | refs/heads/master | 2020-03-08T20:00:38.380562 | 2018-11-30T03:48:34 | 2018-11-30T03:48:34 | 128,370,896 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,074 | java | import java.util.*;
public class Test {
/*private static long calc_fib(int n) {
long[] arr = new long[n + 1];
arr[0] = 0;
if (n > 0) {
arr[1] = 1;
}
for(int i = 2 ; i < n + 1 ; i++) {
arr[i] = arr[i - 1] + arr[i - 2];
}
return arr[n];
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
System.out.println(calc_fib(n));
in.close();
}*/
public static void main(String[] args) {
GenericSub<Integer> gs = new GenericSub<Integer>();
gs.setParam1(10);
gs.setParam2(20);
System.out.println(gs.printParamNum(gs.getParam1(), gs.getParam2()));
/*GenericSub<String> gs2 = new GenericSub<String>();
gs2.setParam1("potato");
gs2.setParam2("sweet potato");
System.out.println(gs.printParamNum(gs2.getParam1(), gs2.getParam2()));*/
String a = "aa";
String b = "aa";
System.out.println(a == b);
System.out.println(a.equals(b));
String c = new String("java");
String d = new String("java");
System.out.println(c == d);
System.out.println(c.equals(d));
String e = "help";
String f = new String("help");
System.out.println(e == f);
System.out.println(e.equals(f));
}
static class GenericSub<T extends Number> {
private T num1;
private T num2;
public T getParam1() { return num1; }
public T getParam2() { return num2;}
public void setParam1(T num1) { this.num1 = num1; }
public void setParam2(T num2) { this.num2 = num2; }
public <T> StringBuffer printParamNum(T param1, T param2) {
StringBuffer sb = new StringBuffer();
sb.append("first argument: ");
sb.append(param1);
sb.append(", second argument: ");
sb.append(param2);
return sb;
}
public Double addParam(T param1, T param2) {
Double d1 = param1.doubleValue();
Double d2 = param2.doubleValue();
return d1 + d2;
}
}
}
| [
"sohee.um@mercer.com"
] | sohee.um@mercer.com |
4830e869593e0a1937708a2a4bf6d10de6d33f20 | 324d9a54b41e842426ed346219ba86e754fb94c2 | /app/src/main/java/cat/jorda/xavier/lespellicules/util/HttpRequestAsync.java | f615d4d76c3967610c2eff81bc97fcfe15b6538c | [] | no_license | XavierJordaMurria/Les-Pel-l-cules | 8084f4f14c87361c1aa1b672aded61094ee2edca | 3992ec3fd1fad0fc9d2d09738b9b122b133e1915 | refs/heads/master | 2020-06-09T12:48:13.496829 | 2017-02-12T11:41:29 | 2017-02-12T11:41:29 | 76,037,785 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,092 | java |
/**
* Created by xj on 08/12/2016.
*/
package cat.jorda.xavier.lespellicules.util;
import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import cat.jorda.xavier.lespellicules.MainApplication;
import cat.jorda.xavier.lespellicules.moviedetails.MovieInfo;
import cat.jorda.xavier.lespellicules.reviews.ReviewsInfo;
import cat.jorda.xavier.lespellicules.trailers.TrailersInfo;
public class HttpRequestAsync extends AsyncTask<String, Void, String>
{
private final static String TAG = "HttpRequestAsync";
private final WeakReference<IHttpRequestCallback> onTaskDoneListener;
private String urlStr = "";
private String fullURL = "";
private int pageNum = 1;
private String mMovieId = "";
private Constants.TMDB_REQUESTS mSpecificAPI;
private List<MovieInfo> tmpMovies = new ArrayList<>();
private List<TrailersInfo> trailersInfoList = new ArrayList<>();
private List<ReviewsInfo> reviewsInfoList = new ArrayList<>();
public HttpRequestAsync(Constants.TMDB_REQUESTS specificAPI, IHttpRequestCallback onTaskDoneListener)
{
/**
* TMDB_BASE_URL = https://api.themoviedb.org/3/movie/
* specificAPI = now_playing
* ?api_key=your_key
* &language=en-US&page=1
*
* https://api.themoviedb.org/3/movie/now_playing?api_key=your_key&language=en-US&page=1
* https://api.themoviedb.org/3/movie/157336/videos?api_key=your_key&language=en-US&page=1
*/
mSpecificAPI = specificAPI;
this.urlStr = Constants.TMDB_BASE_URL+mSpecificAPI.toString()+"?api_key="+Constants.TMDB_KEY+"&language=en-US";
this.onTaskDoneListener = new WeakReference<>(onTaskDoneListener);
}
/**
* Add a movie Id if you would like to do an specific request.
* @param movieId Movie that we want to get the information from.
* @return
*/
public HttpRequestAsync setSpecificMovieId(int movieId)
{
this.mMovieId = Integer.toString(movieId);
this.urlStr = Constants.TMDB_BASE_URL+mMovieId+"/"+mSpecificAPI+"?api_key="+Constants.TMDB_KEY+"&language=en-US";
return this;
}
/**
* Add a page parameter to the HtppRequestAsync obj.
* @param page number to get from the API
* @return object containing the new page information.
*/
public HttpRequestAsync setPage(int page)
{
this.pageNum = page;
return this;
}
/**
* This method will increase by one the page num reques and trigger an asyncTask to the
* REST API defined in the constructor.
*/
public void getNewPage()
{
this.pageNum = this.pageNum + 1;
this.fullURL = this.urlStr + "&page="+pageNum;
this.execute();
}
/**
* ex:API request for:
* NowPlaying movies:
* https://api.themoviedb.org/3/movie/now_playing?api_key=your_key&language=en-US&page=1
* Popular:
* https://api.themoviedb.org/3/movie/popular?api_key=your_key&language=en-US&page=1
* TopRated:
* https://api.themoviedb.org/3/movie/top_rated?api_key=your_key&language=en-US&page=1
**/
@Override
protected String doInBackground(String... params)
{
try
{
this.fullURL = this.urlStr + "&page="+pageNum;
URL mUrl = new URL(fullURL);
HttpURLConnection httpConnection = (HttpURLConnection) mUrl.openConnection();
httpConnection.setRequestMethod("GET");
httpConnection.setRequestProperty("Content-length", "0");
httpConnection.setUseCaches(false);
httpConnection.setAllowUserInteraction(false);
httpConnection.setConnectTimeout(100000);
httpConnection.setReadTimeout(100000);
Log.d(TAG, "Doing async request to:" +httpConnection.getURL().toString());
httpConnection.connect();
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK)
{
Log.d(TAG, "responseCode HTTP_OK");
BufferedReader br = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
{
sb.append(line + "\n");
}
br.close();
String jsonString = sb.toString();
JSONObject jObject = new JSONObject(jsonString);
JSONArray jArray = jObject.getJSONArray("results");
if(mSpecificAPI == Constants.TMDB_REQUESTS.REVIEWS_URL)
parseReview(jArray);
else if (mSpecificAPI == Constants.TMDB_REQUESTS.TRAILERS_URL)
parseTrailers(jArray);
else
addResult2MoviesSArray(jArray);
return jsonString;
}
else
{
Log.e(TAG, "Something went wrong, response code " + responseCode);
}
}
catch (IOException e)
{
e.printStackTrace();
}
catch (Exception ex)
{
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s)
{
super.onPostExecute(s);
if (onTaskDoneListener.get() == null)
{
Log.e(TAG, "TaskDoneListener is null");
return;
}
if (s != null)
{
if(mSpecificAPI == Constants.TMDB_REQUESTS.REVIEWS_URL)
onTaskDoneListener.get().onReviewsDone(reviewsInfoList);
else if (mSpecificAPI == Constants.TMDB_REQUESTS.TRAILERS_URL)
onTaskDoneListener.get().onTrailersDone(trailersInfoList);
else
{
MainApplication.getInstance().mMoviesSArray = new ArrayList<>(tmpMovies);
onTaskDoneListener.get().onTaskDone(s);
}
}
else
onTaskDoneListener.get().onError();
}
private void parseReview(JSONArray jsonArray)
{
int restLength = jsonArray.length();
for (int i=0; i < restLength; i++)
{
try
{
JSONObject oneObject = jsonArray.getJSONObject(i);
String id = oneObject.getString(Constants.KEY_ID);
String author = oneObject.getString(Constants.KEY_AUTHOR);
String content = oneObject.getString(Constants.KEY_CONTENT);
String url = oneObject.getString(Constants.KEY_URL);
reviewsInfoList.add(new ReviewsInfo(id, author, content, url));
}
catch (JSONException e)
{
Log.e(TAG, "Something went wrong parsing the Reviews json result array");
}
}
}
private void parseTrailers(JSONArray jsonArray)
{
int restLength = jsonArray.length();
for (int i=0; i < restLength; i++)
{
try
{
JSONObject oneObject = jsonArray.getJSONObject(i);
String id = oneObject.getString(Constants.KEY_ID);
String key = oneObject.getString(Constants.KEY_KEY);
String name = oneObject.getString(Constants.KEY_NAME);
String site = oneObject.getString(Constants.KEY_SITE);
String type = oneObject.getString(Constants.KEY_TYPE);
trailersInfoList.add(new TrailersInfo(id, key, name, site, type));
}
catch (JSONException e)
{
Log.e(TAG, "Something went wrong parsing the trailers json result array");
}
}
}
private void addResult2MoviesSArray(JSONArray jArray)
{
int restLength = jArray.length();
for (int i=0; i < restLength; i++)
{
try
{
JSONObject oneObject = jArray.getJSONObject(i);
int id = oneObject.getInt(Constants.KEY_ID);
// Retrieve number array from JSON object.
JSONArray array = oneObject.optJSONArray(Constants.KEY_GENERES);
// Deal with the case of a non-array value.
if (array == null) { /*...*/ }
// Create an int array to accomodate the numbers.
int[] genArr = new int[array.length()];
// Extract numbers from JSON array.
for (int j = 0; j < array.length(); ++j)
{
genArr[j] = array.optInt(j);
}
MovieInfo movie = new MovieInfo(id,
oneObject.getString(Constants.KEY_TITLE),
oneObject.getString(Constants.KEY_ORG_TITLE),
oneObject.getString(Constants.KEY_ORG_LNG),
oneObject.getString(Constants.KEY_POSTER),
oneObject.getString(Constants.KEY_BACKDROP),
oneObject.getInt(Constants.KEY_POPULARITY),
oneObject.getInt(Constants.KEY_VOTE_CNT),
oneObject.getDouble(Constants.KEY_VOTE_AVG),
oneObject.getBoolean(Constants.KEY_ADULT),
oneObject.getString(Constants.KEY_OVERVIEW),
oneObject.getString(Constants.KEY_REL_DATE),
genArr);
tmpMovies.add(movie);
}
catch (JSONException e)
{
Log.e(TAG, "Something went wrong parsing the result array");
}
}
}
}
| [
"xavier.jorda@intrasonics.com"
] | xavier.jorda@intrasonics.com |
5ec9fcf00ad2a76c14262fa8587bc476d4969282 | d0fa2faf7c50f9a4d4e6bd0ec83280a662d804c2 | /17.Generics.L28/src/typeinfo/pets/Dog.java | 71bcc9eecc97e060c036bd007073e923968094d7 | [] | no_license | Neo975/LabsCollection | ef2bf2a13026e78988e1295041168283366385fd | 4117f86fe033a733ed6326bbf5eaa07f956d7e4c | refs/heads/master | 2021-01-10T14:59:56.205112 | 2016-04-04T12:51:29 | 2016-04-04T12:51:29 | 50,587,346 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 175 | java | package typeinfo.pets;
/**
* Created by Mike on 27.03.2016.
*/
public class Dog extends Pet {
public Dog(String name) { super(name); }
public Dog() { super(); };
}
| [
"neo975@gmail.com"
] | neo975@gmail.com |
131aa41f410a4efd8aa0ab182b9c47d31230b4bc | 147351c47e625260bf1156fbfcfab748587b7c6d | /src/main/java/com/example/demo/mapper/MessageMapper.java | 0fe4cb195eb27181e9755201e3eebc36119c9803 | [] | no_license | Park1122/Hello-Mapstruct | 21455d92b3e632d52e6bfa05870a5d3a06055a52 | 45c8b41f5d710ad1c180aa65f9b4f17ec7aca229 | refs/heads/master | 2023-07-28T01:38:20.920559 | 2021-09-08T06:12:31 | 2021-09-08T06:12:31 | 404,209,774 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | package com.example.demo.mapper;
import java.util.Collection;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import com.example.demo.dto.MessageResult;
import com.example.demo.entity.Message;
@Mapper
public interface MessageMapper {
MessageMapper INSTANCE = Mappers.getMapper(MessageMapper.class);
MessageResult toMessageResult(Message message, String sender, int senderReplyCode, Collection<Exception> exceptions);
}
| [
"cco2416@gmail.com"
] | cco2416@gmail.com |
fba3120ecf52bb9350adf9983ee0745189ea57e3 | ed0261afd3d7af2a2c7c226c1ea8577ce5ff5c58 | /src/day26/ToCharArrayPracticeWithArrayClassMethods.java | 875c1c01713a647e56b070011d0d4fbabb50cdde | [] | no_license | Mukaddes06/JavaPractice2020 | c7be9367af64178767a886d4f4ff3854c73cbd5f | fd92e845e6cc95764117ab74ae44c0899583c372 | refs/heads/master | 2020-12-03T22:26:47.732829 | 2020-02-29T18:01:58 | 2020-02-29T18:01:58 | 231,504,657 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 586 | java | package day26;
import java.util.Arrays;
public class ToCharArrayPracticeWithArrayClassMethods {
public static void main(String[] args) {
// 2 additional String String methods related to array
// toCharArray(), another is split(bySomething)
String survey = "Complete B15 Online 1 month Survey";
char[] surveyChars = survey.toCharArray();
System.out.println("BEFORE surveyChars : " + Arrays.toString(surveyChars));
Arrays.sort(surveyChars);
System.out.println("AFTER surveyChars : " + Arrays.toString(surveyChars));
}
}
| [
"mukaddes_06_@hotmail.com"
] | mukaddes_06_@hotmail.com |
6ce528bed6ab7bb3852d8dbdf53c7e7eeece915d | 1b37735941eae1b813130793b2d383bb45f6af7c | /app/src/test/java/com/yuqianhao/bluetoothservice/ExampleUnitTest.java | 9c25fbd8675cad344a0eaee6a5a02f388df1f950 | [] | no_license | YuQianhao/BluetoothService | 4d765f93536abc382be8b3aff38d5abb6e0a5d4b | 7d12922089f27daf481bf86bf37563a2dcb4672a | refs/heads/master | 2022-01-14T19:45:40.798911 | 2022-01-07T08:51:07 | 2022-01-07T08:51:07 | 181,314,984 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | package com.yuqianhao.bluetoothservice;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"yqh916640168****"
] | yqh916640168**** |
bcd35a9a60fa44335c08e38366908be2779cb86e | 6df2b5c952ae5b474b5210f7b45395a851a4c6f1 | /Mytest1/app/src/androidTest/java/com/example/mytest1/ExampleInstrumentedTest.java | 4c82472d0eb32c7812129b6bea0fb6babbf77e47 | [] | no_license | dddong1234/android-exercise | 3695d3836fc1304af3550757be6e5235f7646b02 | de4497eac4cd851a9a1e13b97704fe9643ef245a | refs/heads/master | 2023-08-19T01:04:55.743169 | 2021-10-06T18:31:34 | 2021-10-06T18:31:34 | 389,577,283 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 752 | java | package com.example.mytest1;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.mytest1", appContext.getPackageName());
}
} | [
"sdh080200@gmail.com"
] | sdh080200@gmail.com |
065eab2b7780a22420e979fb136e04c3b1ab4027 | bad049513ea2fc7c8210bf5fc2af0bdd276e3d75 | /src/main/java/util/ToFloatFunction.java | 91ece99cc13965a0b6a17a3e1d53ba554a6e74cd | [] | no_license | icarocd/BoTG | bd5375c59336672b6509ec0ade8836b0286f0ed0 | 905b9cd9b3bf992e13675d36741e8a45bef30775 | refs/heads/master | 2022-02-09T12:00:06.283859 | 2020-03-15T16:59:04 | 2020-03-15T16:59:04 | 247,332,354 | 0 | 0 | null | 2022-02-01T01:01:18 | 2020-03-14T18:34:03 | Java | UTF-8 | Java | false | false | 667 | java | package util;
import java.util.function.Function;
/**
* Represents a function that produces a float-valued result. This is the
* {@code float}-producing primitive specialization for {@link Function}.
*
* <p>This is a <a href="package-summary.html">functional interface</a>
* whose functional method is {@link #applyAsFloat(Object)}.
*
* @param <T> the type of the input to the function
*
* @see Function
*/
@FunctionalInterface
public interface ToFloatFunction<T> {
/**
* Applies this function to the given argument.
*
* @param value the function argument
* @return the function result
*/
float applyAsFloat(T value);
}
| [
"icarocd@gmail.com"
] | icarocd@gmail.com |
6fbe79e97229e1a3eafeeab35015aa4a1145b05a | c2882688b3d1bb00785e745cce06063e5663afc7 | /pdf/pdfprinter/src/main/java/org/bndly/pdf/visualobject/Text.java | c68105c1cd118d45f9d00ee4c1a2fd04288d250a | [
"Apache-2.0"
] | permissive | bndly/bndly-commons | e04be01aabcb9e5ff6d15287a3cfa354054a26fe | 6734e6a98f7e253ed225a4f2cce47572c5a969cb | refs/heads/master | 2023-04-03T04:20:47.954354 | 2023-03-17T13:49:57 | 2023-03-17T13:49:57 | 275,222,708 | 1 | 2 | Apache-2.0 | 2023-01-02T21:59:50 | 2020-06-26T18:31:34 | Java | UTF-8 | Java | false | false | 1,794 | java | package org.bndly.pdf.visualobject;
/*-
* #%L
* PDF Document Printer
* %%
* Copyright (C) 2013 - 2020 Cybercon GmbH
* %%
* 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.
* #L%
*/
import org.bndly.common.lang.StringUtil;
import org.bndly.pdf.PrintingContext;
import org.bndly.pdf.PrintingObject;
import org.bndly.pdf.style.Style;
import org.bndly.pdf.style.StyleAttributes;
public class Text extends VisualObject {
private String value;
public Text(PrintingContext context, PrintingObject owner) {
super(context, owner);
}
@Override
public Double getWidth() {
return getContext().getTextSizeStrategy().calculateWidthForText(this);
}
@Override
public Double getHeight() {
return getContext().getTextSizeStrategy().calculateHeightForText(this);
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
protected String asString() {
return super.asString() + " : " + value;
}
/**
* convenience method
* @return
*/
public Double getFontSize() {
Style style = getCalculatedStyle();
return style.get(StyleAttributes.FONT_SIZE);
}
@Override
public Text copyTo(VisualObject owner) {
Text copy = getContext().createText(owner);
copy.value = value;
return copy;
}
}
| [
"mika.goeckel@cybercon.de"
] | mika.goeckel@cybercon.de |
2621d4b6248078bf751f506cb49edc6a31fa9637 | b96c955073bd2f236069ea94cfefdf346f2d7423 | /Project1/src/db/Token.java | 8412386f6d5626077842b8ba2ee98d4df62c3b0c | [] | no_license | yeongjinc/SNUCSE2015F_DB | 74c27db9f7f1717c1c9d6d226429fb0fd6a251b7 | e32bba94d74f91853f59da120b3e241b6e81a004 | refs/heads/master | 2021-01-10T01:12:39.256065 | 2015-12-09T09:42:56 | 2015-12-09T09:42:56 | 45,456,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,068 | java | /* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package db;
/**
* Describes the input token stream.
*/
public class Token implements java.io.Serializable {
/**
* The version identifier for this Serializable class.
* Increment only if the <i>serialized</i> form of the
* class changes.
*/
private static final long serialVersionUID = 1L;
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/** The line number of the first character of this Token. */
public int beginLine;
/** The column number of the first character of this Token. */
public int beginColumn;
/** The line number of the last character of this Token. */
public int endLine;
/** The column number of the last character of this Token. */
public int endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* An optional attribute value of the Token.
* Tokens which are not used as syntactic sugar will often contain
* meaningful values that will be used later on by the compiler or
* interpreter. This attribute value is often different from the image.
* Any subclass of Token that actually wants to return a non-null value can
* override this method as appropriate.
*/
public Object getValue() {
return null;
}
/**
* No-argument constructor
*/
public Token() {}
/**
* Constructs a new token for the specified Image.
*/
public Token(int kind)
{
this(kind, null);
}
/**
* Constructs a new token for the specified Image and Kind.
*/
public Token(int kind, String image)
{
this.kind = kind;
this.image = image;
}
/**
* Returns the image.
*/
public String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simply add something like :
*
* case MyParserConstants.ID : return new IDToken(ofKind, image);
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use sit in your lexical actions.
*/
public static Token newToken(int ofKind, String image)
{
switch(ofKind)
{
default : return new Token(ofKind, image);
}
}
public static Token newToken(int ofKind)
{
return newToken(ofKind, null);
}
}
/* JavaCC - OriginalChecksum=131cfe9e2213bf797d11adef9dd20a57 (do not edit this line) */
| [
"yeongjinc@gmail.com"
] | yeongjinc@gmail.com |
6ea12595a7d6a205bae8042bec9f237c989983fe | 6c5ae01fc059921a60c32566da7911ec07194bd6 | /src/main/java/com/example/GeoKidsBackend/repository/UserRepository.java | b73fcc15d4c1160ee90b79474c0aef79237686e9 | [] | no_license | EduardoGit-1/GeoKids-Backend | 5a92766c1173a52a037e554be646aa1c1a459ed0 | 7f498ceebf5883836b6e724293789170d1b6e42a | refs/heads/master | 2023-05-08T10:44:24.941255 | 2021-05-24T16:40:03 | 2021-05-24T16:40:03 | 349,164,140 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.example.GeoKidsBackend.repository;
import java.util.Optional;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.example.GeoKidsBackend.model.User;
public interface UserRepository extends MongoRepository<User, String> {
Optional<User> findByEmail(String email);
Boolean existsByEmail(String email);
} | [
"eduardogomes9995@gmail.com"
] | eduardogomes9995@gmail.com |
a367038ff61f4cf7083a61385881ffbac8635016 | ae5eb1a38b4d22c82dfd67c86db73592094edc4b | /project444/src/test/java/org/gradle/test/performance/largejavamultiproject/project444/p2224/Test44488.java | a67148401827eb210ec08edc856cf84e140d7b57 | [] | no_license | big-guy/largeJavaMultiProject | 405cc7f55301e1fd87cee5878a165ec5d4a071aa | 1cd6a3f9c59e9b13dffa35ad27d911114f253c33 | refs/heads/main | 2023-03-17T10:59:53.226128 | 2021-03-04T01:01:39 | 2021-03-04T01:01:39 | 344,307,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,113 | java | package org.gradle.test.performance.largejavamultiproject.project444.p2224;
import org.junit.Test;
import static org.junit.Assert.*;
public class Test44488 {
Production44488 objectUnderTest = new Production44488();
@Test
public void testProperty0() {
String value = "value";
objectUnderTest.setProperty0(value);
assertEquals(value, objectUnderTest.getProperty0());
}
@Test
public void testProperty1() {
String value = "value";
objectUnderTest.setProperty1(value);
assertEquals(value, objectUnderTest.getProperty1());
}
@Test
public void testProperty2() {
String value = "value";
objectUnderTest.setProperty2(value);
assertEquals(value, objectUnderTest.getProperty2());
}
@Test
public void testProperty3() {
String value = "value";
objectUnderTest.setProperty3(value);
assertEquals(value, objectUnderTest.getProperty3());
}
@Test
public void testProperty4() {
String value = "value";
objectUnderTest.setProperty4(value);
assertEquals(value, objectUnderTest.getProperty4());
}
@Test
public void testProperty5() {
String value = "value";
objectUnderTest.setProperty5(value);
assertEquals(value, objectUnderTest.getProperty5());
}
@Test
public void testProperty6() {
String value = "value";
objectUnderTest.setProperty6(value);
assertEquals(value, objectUnderTest.getProperty6());
}
@Test
public void testProperty7() {
String value = "value";
objectUnderTest.setProperty7(value);
assertEquals(value, objectUnderTest.getProperty7());
}
@Test
public void testProperty8() {
String value = "value";
objectUnderTest.setProperty8(value);
assertEquals(value, objectUnderTest.getProperty8());
}
@Test
public void testProperty9() {
String value = "value";
objectUnderTest.setProperty9(value);
assertEquals(value, objectUnderTest.getProperty9());
}
} | [
"sterling.greene@gmail.com"
] | sterling.greene@gmail.com |
d7e28b8595447f89c61cd01c1871d4c4c0447699 | 340244f649995da96ea7b079c78a31b6302c4504 | /trunk/org.openebiz.core/src/org/openebiz/core/common/cbc/MarkAttentionIndicatorType.java | 9b0821121c44105726f1bd54e4edfbf7683c8ba1 | [] | no_license | BackupTheBerlios/openebiz-svn | 6be3506ba0f5068a69459e6f093917699af50708 | f83946dab9371d17ffbc0ec43fe157e4544d97fe | refs/heads/master | 2020-04-18T01:46:26.607391 | 2009-03-08T17:23:20 | 2009-03-08T17:23:20 | 40,749,474 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,772 | java | /*******************************************************************************
* Open E-Biz - Darrell Kundel
*
* Contributors:
* Darrell Kundel - initial API and implementation
*******************************************************************************/
package org.openebiz.core.common.cbc;
import java.io.Serializable;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Mark Attention Indicator Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.openebiz.core.common.cbc.MarkAttentionIndicatorType#isValue <em>Value</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class MarkAttentionIndicatorType implements Serializable {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = "Open E-Biz - Darrell Kundel"; //$NON-NLS-1$
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static final long serialVersionUID = 1L;
/**
* The default value of the '{@link #isValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isValue()
* @generated
* @ordered
*/
protected static final boolean VALUE_EDEFAULT = false;
/**
* The cached value of the '{@link #isValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isValue()
* @generated
* @ordered
*/
protected boolean value = VALUE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MarkAttentionIndicatorType() {
super();
}
/**
* Returns the value of the '<em><b>Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* Returning the '<em>Value</em>' attribute
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Value</em>' attribute.
* @see #setValue(boolean)
* @generated
*/
public boolean isValue() {
return value;
}
/**
* Sets the value of the '{@link org.openebiz.core.common.cbc.MarkAttentionIndicatorType#isValue <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Value</em>' attribute.
* @see #isValue()
* @generated
*/
public void setValue(boolean newValue) {
value = newValue;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
StringBuffer result = new StringBuffer(super.toString());
result.append(" (value: "); //$NON-NLS-1$
result.append(value);
result.append(')');
return result.toString();
}
} // MarkAttentionIndicatorType | [
"wukunlun@3b9d58ea-9e0c-0410-94fd-f833e57fda8f"
] | wukunlun@3b9d58ea-9e0c-0410-94fd-f833e57fda8f |
6e9b8769fb42a9227aa5047503a0937043ccf1f3 | 11f6f1c5d6bd174225c01f0bfcb10e73013838f8 | /SProject/src/de/glurak/data/Announcement.java | 2b47f942f9562d510b3a8f0869a609b10649326e | [] | no_license | zian92/Glurak | a433757e24f934d64f2a52808af4b79bf425f37f | 420ecc280fe886ddd6df0312f4e5fa3a58076fc4 | refs/heads/master | 2022-09-02T04:01:06.678130 | 2022-08-21T22:02:55 | 2022-08-21T22:02:55 | 16,947,656 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,602 | java | package de.glurak.data;
import de.glurak.data.User.ArtistProfile;
import de.glurak.data.User.Profile;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* Klasse um Ankündigungen zu machen
* @author Entscheider
*/
@Entity
public class Announcement implements Serializable{
@Id
@GeneratedValue
private long id;
private Timestamp time;
private String title;
private String content;
@ManyToOne
private Profile belongsTo;
public Timestamp getTime() {
return time;
}
public void setTime(Timestamp time) {
this.time = time;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Profile getBelongsTo() {
return belongsTo;
}
/**
* Setzt das Profil zu dem diese Ankündigung gehört.
* @param belongsTo ein Profil, null falls kein Profil zugeordnet
*/
public void setBelongsTo(Profile belongsTo) {
if (this.belongsTo==belongsTo) return;
Profile oldProfile = this.belongsTo;
this.belongsTo = belongsTo;
if (oldProfile!=null)
oldProfile.removeAnnouncement(this);
belongsTo.addAnnouncement(this);
}
public long getId(){
return this.id;
}
}
| [
"noone@nowhere.org"
] | noone@nowhere.org |
5a3d7af5c48e53273c726d08ae3379b8e851a792 | 4da27d29cbe5edee39ca9b9dfeff2d0023585c6f | /src/wipeout_INCOMPLETE.java | ae4b51f45bc161c8ac61e32c4fb9441ec2abfec1 | [] | no_license | jmwurst/UCF_Online2017_Live | 9f392df545541bd45b2b6b70f1fba68628760dcf | 5929039f6f9b3e492516624cc99011597a7abaca | refs/heads/master | 2020-03-29T17:37:16.536388 | 2018-09-24T22:06:42 | 2018-09-24T22:06:42 | 150,173,556 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,918 | java | import java.util.*;
public class wipeout_INCOMPLETE //Time Limit Exceeded - djikstra???
{
static int time;
static int platformGoal;
static ArrayList<Obstacle>[] platforms;
public static class Obstacle
{
public int from, to, stamina, time;
public Obstacle(int f, int t, int s, int ti)
{
from = f;
to = t;
stamina = s;
time = ti;
}
}
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int cases = in.nextInt();
for (int d = 1; d <= cases; d++)
{
int numPlatforms = in.nextInt();
int numObstacles = in.nextInt();
int initStamina = in.nextInt();
platformGoal = numPlatforms - 1;
platforms = new ArrayList[numPlatforms];
for (int i = 0; i < numPlatforms; i++)
platforms[i] = new ArrayList<Obstacle>();
for (int i = 0; i < numObstacles; i++)
{
int from = in.nextInt() - 1;
int to = in.nextInt() - 1;
int stamcost = in.nextInt();
int timecost = in.nextInt();
platforms[from].add(new Obstacle(from, to, stamcost, timecost));
}
boolean[] visited = new boolean[numPlatforms];
Arrays.fill(visited, false);
visited[0] = true;
time = -1;
wipo(initStamina, 0, 0, visited);
if (time == -1)
System.out.printf("Episode #%d: Wipeout!%n", d);
else
System.out.printf("Episode #%d: %d%n", d, time);
}
}
static void wipo(int staminaRemaining, int curPlatform, int curTime, boolean[] visited)
{
if (curPlatform == platformGoal || staminaRemaining < 0)
{
if (staminaRemaining >= 0)
{
if (time == -1)
time = curTime;
else
time = Math.min(time, curTime);
}
return;
}
for (int i = 0; i < platforms[curPlatform].size(); i++)
{
Obstacle ob = platforms[curPlatform].get(i);
if (!visited[ob.to])
{
visited[ob.to] = true;
wipo(staminaRemaining - ob.stamina, ob.to, curTime + ob.time, visited);
visited[ob.to] = false;
}
}
}
} | [
"jmwurst@me.com"
] | jmwurst@me.com |
e00eb63ada65df00b0ad16e51e99e2e938b2768c | f675d96714a999682f1883af2c4b18f8f41f0733 | /sns-hibernate-entity/src/main/java/com/sky/sns/hibernate/entity/Notice.java | 86758206180f0b79ac0e256476f1f6e853ff1900 | [] | no_license | ejunjsh/sns | 3d9382e4c7eea75bfd4990282b09fc566be9cc4e | a18c4640ca46ce8cce72ba52ed051115f7e4165e | refs/heads/master | 2020-03-28T23:57:29.270146 | 2014-02-23T12:19:20 | 2014-02-23T12:19:20 | 107,090,063 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,113 | java | package com.sky.sns.hibernate.entity;
import java.util.Date;
import javax.persistence.*;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Table(name="Notice")
public class Notice {
@GenericGenerator(name = "generator", strategy = "native")
@Id
@GeneratedValue(generator = "generator")
@Column(name = "id", unique = true, nullable = false)
private long id;
@Column(name = "createdDate")
private Date createdDate;
@Column(name = "title")
private String title;
@Column(name = "content",length=java.lang.Integer.MAX_VALUE)
private String content;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId")
private User user;
@Column(name = "noticeType")
private int noticeType;
@Column(name = "refId")
private long refId;
@Column(name = "isRead")
private int isRead;
@Column(name = "updatedDate")
private Date updatedDate;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public int getNoticeType() {
return noticeType;
}
public void setNoticeType(int noticeType) {
this.noticeType = noticeType;
}
public long getRefId() {
return refId;
}
public void setRefId(long refId) {
this.refId = refId;
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
public int getIsRead() {
return isRead;
}
public void setIsRead(int isRead) {
this.isRead = isRead;
}
}
| [
"shaojunjie@shaojunjie-Rev-1-0"
] | shaojunjie@shaojunjie-Rev-1-0 |
88c5d0dd375b9e7f33955c81fdc012d737787004 | 4866616ec8b054beec5bf8a8fc5805931ef13616 | /src/chap15/textbook/s150301/Member.java | 54869fa8f5bd2b5597369135dd6bacaaed380284 | [] | no_license | bomiyu/java20200929 | 95a0906b9c61db2c68fe4f41fd84f435098cd198 | 82fce2f065f6bdf30b9cd3104eeabbb359f5e235 | refs/heads/master | 2023-01-24T05:26:18.254775 | 2020-12-07T08:54:02 | 2020-12-07T08:54:02 | 299,485,604 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 536 | java | package chap15.textbook.s150301;
import chap15.textbook.s150401.Student;
public class Member {
public String name;
public int age;
public Member(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof Student) {
Student student = (Student) obj;
return (sno==student.sno) && (name.equals(student.name));
}else {
return false;
}
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return name.hashCode()+age;
}
}
| [
"bom7768@gmail.com"
] | bom7768@gmail.com |
2fbd1f0093f8def0cf7eaf6a75cd12a8dde60c0a | cb03a4dea36c63c67b2b140ac80d43758b79ee9a | /bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java | 27153d075622e9c6146429b2a1cbe54ac807131c | [] | no_license | Riolu/TradingMarket-JY | f6c15aa193cdfde2cce45d08f8979ac542c77448 | bdbc057231870598da51aac94f7be1b1223f973f | refs/heads/master | 2021-01-19T08:35:00.965363 | 2017-05-23T03:49:04 | 2017-05-23T03:49:04 | 87,649,388 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 59,201 | java | package com.roughike.bottombar;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.MenuRes;
import android.support.annotation.StyleRes;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.roughike.bottombar.scrollsweetness.BottomNavigationBehavior;
import java.util.HashMap;
/*
* BottomBar library for Android
* Copyright (c) 2016 Iiro Krankka (http://github.com/roughike).
*
* 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.
*/
public class BottomBar extends FrameLayout implements View.OnClickListener, View.OnLongClickListener {
private static final long ANIMATION_DURATION = 150;
private static final String STATE_CURRENT_SELECTED_TAB = "STATE_CURRENT_SELECTED_TAB";
private static final String STATE_BADGE_STATES_BUNDLE = "STATE_BADGE_STATES_BUNDLE";
private static final String TAG_BOTTOM_BAR_VIEW_INACTIVE = "BOTTOM_BAR_VIEW_INACTIVE";
private static final String TAG_BOTTOM_BAR_VIEW_ACTIVE = "BOTTOM_BAR_VIEW_ACTIVE";
private static final String TAG_BADGE = "BOTTOMBAR_BADGE_";
private Context mContext;
private boolean mIsComingFromRestoredState;
private boolean mIgnoreTabletLayout;
private boolean mIsTabletMode;
private boolean mIsShy;
private boolean mShyHeightAlreadyCalculated;
private boolean mUseExtraOffset;
private ViewGroup mUserContentContainer;
private ViewGroup mOuterContainer;
private ViewGroup mItemContainer;
private View mBackgroundView;
private View mBackgroundOverlay;
private View mShadowView;
private View mTabletRightBorder;
private View mPendingUserContentView;
private int mPrimaryColor;
private int mInActiveColor;
private int mDarkBackgroundColor;
private int mWhiteColor;
private int mScreenWidth;
private int mTwoDp;
private int mTenDp;
private int mMaxFixedItemWidth;
private int mMaxInActiveShiftingItemWidth;
private int mInActiveShiftingItemWidth;
private int mActiveShiftingItemWidth;
private Object mListener;
private Object mMenuListener;
private int mCurrentTabPosition;
private boolean mIsShiftingMode;
private Object mFragmentManager;
private int mFragmentContainer;
private BottomBarItemBase[] mItems;
private HashMap<Integer, Integer> mColorMap;
private HashMap<Integer, Object> mBadgeMap;
private HashMap<Integer, Boolean> mBadgeStateMap;
private int mCurrentBackgroundColor;
private int mDefaultBackgroundColor;
private boolean mIsDarkTheme;
private boolean mIgnoreNightMode;
private boolean mIgnoreShiftingResize;
private int mCustomActiveTabColor;
private boolean mDrawBehindNavBar = true;
private boolean mUseTopOffset = true;
private boolean mUseOnlyStatusBarOffset;
private int mPendingTextAppearance = -1;
private Typeface mPendingTypeface;
// For fragment state restoration
private boolean mShouldUpdateFragmentInitially;
private int mMaxFixedTabCount = 3;
/**
* Bind the BottomBar to your Activity, and inflate your layout here.
* <p/>
* Remember to also call {@link #onRestoreInstanceState(Bundle)} inside
* of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
*
* @param activity an Activity to attach to.
* @param savedInstanceState a Bundle for restoring the state on configuration change.
* @return a BottomBar at the bottom of the screen.
*/
public static BottomBar attach(Activity activity, Bundle savedInstanceState) {
BottomBar bottomBar = new BottomBar(activity);
bottomBar.onRestoreInstanceState(savedInstanceState);
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
View oldLayout = contentView.getChildAt(0);
contentView.removeView(oldLayout);
bottomBar.setPendingUserContentView(oldLayout);
contentView.addView(bottomBar, 0);
return bottomBar;
}
private void setPendingUserContentView(View oldLayout) {
mPendingUserContentView = oldLayout;
}
/**
* Bind the BottomBar to the specified View's parent, and inflate
* your layout there. Useful when the BottomBar overlaps some content
* that shouldn't be overlapped.
* <p/>
* Remember to also call {@link #onRestoreInstanceState(Bundle)} inside
* of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
*
* @param view a View, which parent we're going to attach to.
* @param savedInstanceState a Bundle for restoring the state on configuration change.
* @return a BottomBar at the bottom of the screen.
*/
public static BottomBar attach(View view, Bundle savedInstanceState) {
BottomBar bottomBar = new BottomBar(view.getContext());
bottomBar.onRestoreInstanceState(savedInstanceState);
ViewGroup contentView = (ViewGroup) view.getParent();
if (contentView != null) {
View oldLayout = contentView.getChildAt(0);
contentView.removeView(oldLayout);
bottomBar.setPendingUserContentView(oldLayout);
contentView.addView(bottomBar, 0);
} else {
bottomBar.setPendingUserContentView(view);
}
return bottomBar;
}
/**
* Deprecated. Breaks support for tablets.
* Use {@link #attachShy(CoordinatorLayout, View, Bundle)} instead.
*/
@Deprecated
public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle savedInstanceState) {
return attachShy(coordinatorLayout, null, savedInstanceState);
}
/**
* Adds the BottomBar inside of your CoordinatorLayout and shows / hides
* it according to scroll state changes.
* <p/>
* Remember to also call {@link #onRestoreInstanceState(Bundle)} inside
* of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
*
* @param coordinatorLayout a CoordinatorLayout for the BottomBar to add itself into
* @param userContentView the view (usually a NestedScrollView) that has your scrolling content.
* Needed for tablet support.
* @param savedInstanceState a Bundle for restoring the state on configuration change.
* @return a BottomBar at the bottom of the screen.
*/
public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, View userContentView, Bundle savedInstanceState) {
final BottomBar bottomBar = new BottomBar(coordinatorLayout.getContext());
bottomBar.onRestoreInstanceState(savedInstanceState);
bottomBar.toughChildHood(ViewCompat.getFitsSystemWindows(coordinatorLayout));
if (userContentView != null && coordinatorLayout.getContext()
.getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode)) {
bottomBar.setPendingUserContentView(userContentView);
}
coordinatorLayout.addView(bottomBar);
return bottomBar;
}
/**
* Set tabs and fragments for this BottomBar. When setting more than 3 items,
* only the icons will show by default, but the selected item
* will have the text visible.
*
* @param fragmentManager a FragmentManager for managing the Fragments.
* @param containerResource id for the layout to inflate Fragments to.
* @param fragmentItems an array of {@link BottomBarFragment} objects.
*/
public void setFragmentItems(android.app.FragmentManager fragmentManager, @IdRes int containerResource,
BottomBarFragment... fragmentItems) {
if (fragmentItems.length > 0) {
int index = 0;
for (BottomBarFragment fragmentItem : fragmentItems) {
if (fragmentItem.getFragment() == null
&& fragmentItem.getSupportFragment() != null) {
throw new IllegalArgumentException("Conflict: cannot use android.app.FragmentManager " +
"to handle a android.support.v4.app.Fragment object at position " + index +
". If you want BottomBar to handle support Fragments, use getSupportFragment" +
"Manager() instead of getFragmentManager().");
}
index++;
}
}
clearItems();
mFragmentManager = fragmentManager;
mFragmentContainer = containerResource;
mItems = fragmentItems;
updateItems(mItems);
}
/**
* Deprecated.
* <p/>
* Use either {@link #setItems(BottomBarTab...)} or
* {@link #setItemsFromMenu(int, OnMenuTabClickListener)} and add a listener using
* {@link #setOnTabClickListener(OnTabClickListener)} to handle tab changes by yourself.
* <p/>
* Set tabs and fragments for this BottomBar. When setting more than 3 items,
* only the icons will show by default, but the selected item
* will have the text visible.
*
* @param fragmentManager a FragmentManager for managing the Fragments.
* @param containerResource id for the layout to inflate Fragments to.
* @param fragmentItems an array of {@link BottomBarFragment} objects.
*/
@Deprecated
public void setFragmentItems(android.support.v4.app.FragmentManager fragmentManager, @IdRes int containerResource,
BottomBarFragment... fragmentItems) {
if (fragmentItems.length > 0) {
int index = 0;
for (BottomBarFragment fragmentItem : fragmentItems) {
if (fragmentItem.getSupportFragment() == null
&& fragmentItem.getFragment() != null) {
throw new IllegalArgumentException("Conflict: cannot use android.support.v4.app.FragmentManager " +
"to handle a android.app.Fragment object at position " + index +
". If you want BottomBar to handle normal Fragments, use getFragment" +
"Manager() instead of getSupportFragmentManager().");
}
index++;
}
}
clearItems();
mFragmentManager = fragmentManager;
mFragmentContainer = containerResource;
mItems = fragmentItems;
updateItems(mItems);
}
/**
* Set tabs for this BottomBar. When setting more than 3 items,
* only the icons will show by default, but the selected item
* will have the text visible.
*
* @param bottomBarTabs an array of {@link BottomBarTab} objects.
*/
public void setItems(BottomBarTab... bottomBarTabs) {
clearItems();
mItems = bottomBarTabs;
updateItems(mItems);
}
/**
* Deprecated. Use {@link #setItemsFromMenu(int, OnMenuTabClickListener)} instead.
*/
@Deprecated
public void setItemsFromMenu(@MenuRes int menuRes, OnMenuTabSelectedListener listener) {
clearItems();
mItems = MiscUtils.inflateMenuFromResource((Activity) getContext(), menuRes);
mMenuListener = listener;
updateItems(mItems);
}
/**
* Set items from an XML menu resource file.
*
* @param menuRes the menu resource to inflate items from.
* @param listener listener for tab change events.
*/
public void setItemsFromMenu(@MenuRes int menuRes, OnMenuTabClickListener listener) {
clearItems();
mItems = MiscUtils.inflateMenuFromResource((Activity) getContext(), menuRes);
mMenuListener = listener;
updateItems(mItems);
if (mItems != null && mItems.length > 0
&& mItems instanceof BottomBarTab[]) {
listener.onMenuTabSelected(((BottomBarTab) mItems[mCurrentTabPosition]).id);
}
}
/**
* Deprecated. Use {@link #setOnTabClickListener(OnTabClickListener)} instead.
*/
@Deprecated
public void setOnItemSelectedListener(OnTabSelectedListener listener) {
mListener = listener;
}
/**
* Set a listener that gets fired when the selected tab changes.
*
* @param listener a listener for monitoring changes in tab selection.
*/
public void setOnTabClickListener(OnTabClickListener listener) {
mListener = listener;
if (mItems != null && mItems.length > 0) {
listener.onTabSelected(mCurrentTabPosition);
}
}
/**
* Select a tab at the specified position.
*
* @param position the position to select.
*/
public void selectTabAtPosition(int position, boolean animate) {
if (mItems == null || mItems.length == 0) {
throw new UnsupportedOperationException("Can't select tab at " +
"position " + position + ". This BottomBar has no items set yet.");
} else if (position > mItems.length - 1 || position < 0) {
throw new IndexOutOfBoundsException("Can't select tab at position " +
position + ". This BottomBar has no items at that position.");
}
View oldTab = mItemContainer.findViewWithTag(TAG_BOTTOM_BAR_VIEW_ACTIVE);
View newTab = mItemContainer.getChildAt(position);
unselectTab(oldTab, animate);
selectTab(newTab, animate);
updateSelectedTab(position);
shiftingMagic(oldTab, newTab, false);
}
/**
* Sets the default tab for this BottomBar that is shown until the user changes
* the selection.
*
* @param defaultTabPosition the default tab position.
*/
public void setDefaultTabPosition(int defaultTabPosition) {
if (mIsComingFromRestoredState) return;
if (mItems == null) {
mCurrentTabPosition = defaultTabPosition;
return;
} else if (mItems.length == 0 || defaultTabPosition > mItems.length - 1
|| defaultTabPosition < 0) {
throw new IndexOutOfBoundsException("Can't set default tab at position " +
defaultTabPosition + ". This BottomBar has no items at that position.");
}
selectTabAtPosition(defaultTabPosition, false);
}
/**
* Get the current selected tab position.
*
* @return the position of currently selected tab.
*/
public int getCurrentTabPosition() {
return mCurrentTabPosition;
}
/**
* Hide the BottomBar.
*/
public void hide() {
setBarVisibility(GONE);
}
/**
* Show the BottomBar.
*/
public void show() {
setBarVisibility(VISIBLE);
}
/**
* Set the maximum number of tabs, after which the tabs should be shifting
* ones with a background color.
* <p/>
* NOTE: You must call this method before setting any items.
*
* @param count maximum number of fixed tabs.
*/
public void setMaxFixedTabs(int count) {
if (mItems != null) {
throw new UnsupportedOperationException("This BottomBar already has items! " +
"You must call the setMaxFixedTabs() method before specifying any items.");
}
mMaxFixedTabCount = count;
}
/**
* Always show the titles and icons also on inactive tabs, even if there's more
* than three of them.
*/
public void useFixedMode() {
if (mItems != null) {
throw new UnsupportedOperationException("This BottomBar already has items! " +
"You must call the forceFixedMode() method before specifying any items.");
}
mMaxFixedTabCount = -1;
}
/**
* Call this method in your Activity's onSaveInstanceState
* to keep the BottomBar's state on configuration change.
*
* @param outState the Bundle to save data to.
*/
public void onSaveInstanceState(Bundle outState) {
outState.putInt(STATE_CURRENT_SELECTED_TAB, mCurrentTabPosition);
if (mBadgeMap != null && mBadgeMap.size() > 0) {
if (mBadgeStateMap == null) {
mBadgeStateMap = new HashMap<>();
}
for (Integer key : mBadgeMap.keySet()) {
BottomBarBadge badgeCandidate = (BottomBarBadge) mOuterContainer
.findViewWithTag(mBadgeMap.get(key));
if (badgeCandidate != null) {
mBadgeStateMap.put(key, badgeCandidate.isVisible());
}
}
outState.putSerializable(STATE_BADGE_STATES_BUNDLE, mBadgeStateMap);
}
if (mFragmentManager != null
&& mFragmentContainer != 0
&& mItems != null
&& mItems instanceof BottomBarFragment[]) {
BottomBarFragment bottomBarFragment = (BottomBarFragment) mItems[mCurrentTabPosition];
if (bottomBarFragment.getFragment() != null) {
bottomBarFragment.getFragment().onSaveInstanceState(outState);
} else if (bottomBarFragment.getSupportFragment() != null) {
bottomBarFragment.getSupportFragment().onSaveInstanceState(outState);
}
}
}
/**
* Map a background color for a Tab, that changes the whole BottomBar
* background color when the Tab is selected.
*
* @param tabPosition zero-based index for the tab.
* @param color a hex color for the tab, such as 0xFF00FF00.
*/
public void mapColorForTab(int tabPosition, int color) {
if (mItems == null || mItems.length == 0) {
throw new UnsupportedOperationException("You have no BottomBar Tabs set yet. " +
"Please set them first before calling the mapColorForTab method.");
} else if (tabPosition > mItems.length - 1 || tabPosition < 0) {
throw new IndexOutOfBoundsException("Cant map color for Tab " +
"index " + tabPosition + ". You have no BottomBar Tabs at that position.");
}
if (mIsDarkTheme || !mIsShiftingMode || mIsTabletMode) return;
if (mColorMap == null) {
mColorMap = new HashMap<>();
}
if (tabPosition == mCurrentTabPosition
&& mCurrentBackgroundColor != color) {
mCurrentBackgroundColor = color;
mBackgroundView.setBackgroundColor(color);
}
mColorMap.put(tabPosition, color);
}
/**
* Map a background color for a Tab, that changes the whole BottomBar
* background color when the Tab is selected.
*
* @param tabPosition zero-based index for the tab.
* @param color a hex color for the tab, such as "#00FF000".
*/
public void mapColorForTab(int tabPosition, String color) {
mapColorForTab(tabPosition, Color.parseColor(color));
}
/**
* Deprecated. Use {@link #useDarkTheme()} instead.
*/
@Deprecated
public void useDarkTheme(boolean darkThemeEnabled) {
mIsDarkTheme = darkThemeEnabled;
useDarkTheme();
}
/**
* Use dark theme instead of the light one.
* <p/>
* NOTE: You might want to change your active tab color to something else
* using {@link #setActiveTabColor(int)}, as the default primary color might
* not have enough contrast for the dark background.
*/
public void useDarkTheme() {
if (!mIsDarkTheme && mItems != null && mItems.length > 0) {
darkThemeMagic();
for (int i = 0; i < mItemContainer.getChildCount(); i++) {
View bottomBarTab = mItemContainer.getChildAt(i);
((ImageView) bottomBarTab.findViewById(R.id.bb_bottom_bar_icon))
.setColorFilter(mWhiteColor);
if (i == mCurrentTabPosition) {
selectTab(bottomBarTab, false);
} else {
unselectTab(bottomBarTab, false);
}
}
}
mIsDarkTheme = true;
}
/**
* Ignore the automatic Night Mode detection and use a light theme by default,
* even if the Night Mode is on.
*/
public void ignoreNightMode() {
if (mItems != null && mItems.length > 0) {
throw new UnsupportedOperationException("This BottomBar " +
"already has items! You must call ignoreNightMode() " +
"before setting any items.");
}
mIgnoreNightMode = true;
}
/**
* Set a custom color for an active tab when there's three
* or less items.
* <p/>
* NOTE: This value is ignored on mobile devices if you have more than
* three items.
*
* @param activeTabColor a hex color used for active tabs, such as "#00FF000".
*/
public void setActiveTabColor(String activeTabColor) {
setActiveTabColor(Color.parseColor(activeTabColor));
}
/**
* Set a custom color for an active tab when there's three
* or less items.
* <p/>
* NOTE: This value is ignored if you have more than three items.
*
* @param activeTabColor a hex color used for active tabs, such as 0xFF00FF00.
*/
public void setActiveTabColor(int activeTabColor) {
mCustomActiveTabColor = activeTabColor;
if (mItems != null && mItems.length > 0) {
selectTabAtPosition(mCurrentTabPosition, false);
}
}
/**
* Creates a new Badge (for example, an indicator for unread messages) for a Tab at
* the specified position.
*
* @param tabPosition zero-based index for the tab.
* @param backgroundColor a color for this badge, such as "#FF0000".
* @param initialCount text displayed initially for this Badge.
* @return a {@link BottomBarBadge} object.
*/
public BottomBarBadge makeBadgeForTabAt(int tabPosition, String backgroundColor, int initialCount) {
return makeBadgeForTabAt(tabPosition, Color.parseColor(backgroundColor), initialCount);
}
/**
* Creates a new Badge (for example, an indicator for unread messages) for a Tab at
* the specified position.
*
* @param tabPosition zero-based index for the tab.
* @param backgroundColor a color for this badge, such as 0xFFFF0000.
* @param initialCount text displayed initially for this Badge.
* @return a {@link BottomBarBadge} object.
*/
public BottomBarBadge makeBadgeForTabAt(int tabPosition, int backgroundColor, int initialCount) {
if (mItems == null || mItems.length == 0) {
throw new UnsupportedOperationException("You have no BottomBar Tabs set yet. " +
"Please set them first before calling the makeBadgeForTabAt() method.");
} else if (tabPosition > mItems.length - 1 || tabPosition < 0) {
throw new IndexOutOfBoundsException("Cant make a Badge for Tab " +
"index " + tabPosition + ". You have no BottomBar Tabs at that position.");
}
final View tab = mItemContainer.getChildAt(tabPosition);
BottomBarBadge badge = new BottomBarBadge(mContext, tabPosition,
tab, backgroundColor);
badge.setTag(TAG_BADGE + tabPosition);
badge.setCount(initialCount);
tab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleClick((View) tab.getParent());
}
});
tab.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return handleLongClick((View) tab.getParent());
}
});
if (mBadgeMap == null) {
mBadgeMap = new HashMap<>();
}
mBadgeMap.put(tabPosition, badge.getTag());
boolean canShow = true;
if (mIsComingFromRestoredState && mBadgeStateMap != null
&& mBadgeStateMap.containsKey(tabPosition)) {
canShow = mBadgeStateMap.get(tabPosition);
}
if (canShow && mCurrentTabPosition != tabPosition
&& initialCount != 0) {
badge.show();
} else {
badge.hide();
}
return badge;
}
/**
* Set a custom TypeFace for the tab titles.
* The .ttf file should be located at "/src/main/assets".
*
* @param typeFacePath path for the custom typeface in the assets directory.
*/
public void setTypeFace(String typeFacePath) {
Typeface typeface = Typeface.createFromAsset(mContext.getAssets(),
typeFacePath);
if (mItemContainer != null && mItemContainer.getChildCount() > 0) {
for (int i = 0; i < mItemContainer.getChildCount(); i++) {
View bottomBarTab = mItemContainer.getChildAt(i);
TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title);
title.setTypeface(typeface);
}
} else {
mPendingTypeface = typeface;
}
}
/**
* Set a custom text appearance for the tab title.
*
* @param resId path to the custom text appearance.
*/
public void setTextAppearance(@StyleRes int resId) {
if (mItemContainer != null && mItemContainer.getChildCount() > 0) {
for (int i = 0; i < mItemContainer.getChildCount(); i++) {
View bottomBarTab = mItemContainer.getChildAt(i);
TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title);
MiscUtils.setTextAppearance(title, resId);
}
} else {
mPendingTextAppearance = resId;
}
}
/**
* Hide the shadow that's normally above the BottomBar.
*/
public void hideShadow() {
if (mShadowView != null) {
mShadowView.setVisibility(GONE);
}
}
/**
* Prevent the BottomBar drawing behind the Navigation Bar and making
* it transparent. Must be called before setting items.
*/
public void noNavBarGoodness() {
if (mItems != null) {
throw new UnsupportedOperationException("This BottomBar already has items! " +
"You must call noNavBarGoodness() before setting the items, preferably " +
"right after attaching it to your layout.");
}
mDrawBehindNavBar = false;
}
/**
* Force the BottomBar to behave exactly same on tablets and phones,
* instead of showing a left menu on tablets.
*/
public void noTabletGoodness() {
if (mItems != null) {
throw new UnsupportedOperationException("This BottomBar already has items! " +
"You must call noTabletGoodness() before setting the items, preferably " +
"right after attaching it to your layout.");
}
mIgnoreTabletLayout = true;
}
/**
* Don't resize the tabs when selecting a new one, so every tab is the same0 if you have more than three
* tabs. The text still displays the scale animation and the icon moves up, but the badass width animation
* is ignored.
*/
public void noResizeGoodness() {
mIgnoreShiftingResize = true;
}
/**
* Get this BottomBar's height (or width), depending if the BottomBar
* is on the bottom (phones) or the left (tablets) of the screen.
*
* @param listener {@link OnSizeDeterminedListener} to get the size when it's ready.
*/
public void getBarSize(final OnSizeDeterminedListener listener) {
final int sizeCandidate = mIsTabletMode ?
mOuterContainer.getWidth() : mOuterContainer.getHeight();
if (sizeCandidate == 0) {
mOuterContainer.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
listener.onSizeReady(mIsTabletMode ?
mOuterContainer.getWidth() : mOuterContainer.getHeight());
ViewTreeObserver obs = mOuterContainer.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return;
}
listener.onSizeReady(sizeCandidate);
}
/**
* Get the actual BottomBar that has the tabs inside it for whatever what you may want
* to do with it.
*
* @return the BottomBar.
*/
public View getBar() {
return mOuterContainer;
}
/**
* Super ugly hacks
* ----------------------------/
*/
/**
* If you get some unwanted extra padding in the top (such as
* when using CoordinatorLayout), this fixes it.
*/
public void noTopOffset() {
mUseTopOffset = false;
}
/**
* If your ActionBar gets inside the status bar for some reason,
* this fixes it.
*/
public void useOnlyStatusBarTopOffset() {
mUseOnlyStatusBarOffset = true;
}
/**
* ------------------------------------------- //
*/
public BottomBar(Context context) {
super(context);
init(context, null, 0, 0);
}
public BottomBar(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs, 0, 0);
}
public BottomBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs, defStyleAttr, 0);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public BottomBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs, defStyleAttr, defStyleRes);
}
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
mDarkBackgroundColor = ContextCompat.getColor(getContext(), R.color.bb_darkBackgroundColor);
mWhiteColor = ContextCompat.getColor(getContext(), R.color.white);
mPrimaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary);
mInActiveColor = ContextCompat.getColor(getContext(), R.color.bb_inActiveBottomBarItemColor);
mScreenWidth = MiscUtils.getScreenWidth(mContext);
mTwoDp = MiscUtils.dpToPixel(mContext, 2);
mTenDp = MiscUtils.dpToPixel(mContext, 10);
mMaxFixedItemWidth = MiscUtils.dpToPixel(mContext, 168);
mMaxInActiveShiftingItemWidth = MiscUtils.dpToPixel(mContext, 96);
}
private void initializeViews() {
mIsTabletMode = !mIgnoreTabletLayout &&
mContext.getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode);
ViewCompat.setElevation(this, MiscUtils.dpToPixel(mContext, 8));
View rootView = View.inflate(mContext, mIsTabletMode ?
R.layout.bb_bottom_bar_item_container_tablet : R.layout.bb_bottom_bar_item_container,
null);
mTabletRightBorder = rootView.findViewById(R.id.bb_tablet_right_border);
mUserContentContainer = (ViewGroup) rootView.findViewById(R.id.bb_user_content_container);
mShadowView = rootView.findViewById(R.id.bb_bottom_bar_shadow);
mOuterContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_outer_container);
mItemContainer = (ViewGroup) rootView.findViewById(R.id.bb_bottom_bar_item_container);
mBackgroundView = rootView.findViewById(R.id.bb_bottom_bar_background_view);
mBackgroundOverlay = rootView.findViewById(R.id.bb_bottom_bar_background_overlay);
if (mIsShy && mIgnoreTabletLayout) {
mPendingUserContentView = null;
}
if (mPendingUserContentView != null) {
ViewGroup.LayoutParams params = mPendingUserContentView.getLayoutParams();
if (params == null) {
params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
}
if (mIsTabletMode && mIsShy) {
((ViewGroup) mPendingUserContentView.getParent()).removeView(mPendingUserContentView);
}
mUserContentContainer.addView(mPendingUserContentView, 0, params);
mPendingUserContentView = null;
}
if (mIsShy && !mIsTabletMode) {
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
if (!mShyHeightAlreadyCalculated) {
((CoordinatorLayout.LayoutParams) getLayoutParams())
.setBehavior(new BottomNavigationBehavior(getOuterContainer().getHeight(), 0, isShy(), mIsTabletMode));
}
ViewTreeObserver obs = getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
}
addView(rootView);
}
/**
* Makes this BottomBar "shy". In other words, it hides on scroll.
*/
private void toughChildHood(boolean useExtraOffset) {
mIsShy = true;
mUseExtraOffset = useExtraOffset;
}
protected boolean isShy() {
return mIsShy;
}
protected void shyHeightAlreadyCalculated() {
mShyHeightAlreadyCalculated = true;
}
protected boolean useExtraOffset() {
return mUseExtraOffset;
}
protected ViewGroup getUserContainer() {
return mUserContentContainer;
}
protected View getOuterContainer() {
return mOuterContainer;
}
protected boolean drawBehindNavBar() {
return mDrawBehindNavBar;
}
protected boolean useTopOffset() {
return mUseTopOffset;
}
protected boolean useOnlyStatusbarOffset() {
return mUseOnlyStatusBarOffset;
}
protected void setBarVisibility(int visibility) {
if (mIsShy) {
toggleShyVisibility(visibility == VISIBLE);
return;
}
if (mOuterContainer != null) {
mOuterContainer.setVisibility(visibility);
}
if (mBackgroundView != null) {
mBackgroundView.setVisibility(visibility);
}
if (mBackgroundOverlay != null) {
mBackgroundOverlay.setVisibility(visibility);
}
}
/**
* Toggle translation of BottomBar to hidden and visible in a CoordinatorLayout.
*
* @param visible true resets translation to 0, false translates view to hidden
*/
protected void toggleShyVisibility(boolean visible) {
BottomNavigationBehavior<BottomBar> from = BottomNavigationBehavior.from(this);
if (from != null) {
from.setHidden(this, visible);
}
}
@Override
public void onClick(View v) {
handleClick(v);
}
private void handleClick(View v) {
if (v.getTag().equals(TAG_BOTTOM_BAR_VIEW_INACTIVE)) {
View oldTab = findViewWithTag(TAG_BOTTOM_BAR_VIEW_ACTIVE);
unselectTab(oldTab, true);
selectTab(v, true);
shiftingMagic(oldTab, v, true);
}
updateSelectedTab(findItemPosition(v));
}
private void shiftingMagic(View oldTab, View newTab, boolean animate) {
if (!mIsTabletMode && mIsShiftingMode && !mIgnoreShiftingResize) {
if (oldTab instanceof FrameLayout) {
// It's a badge, goddammit!
oldTab = ((FrameLayout) oldTab).getChildAt(0);
}
if (newTab instanceof FrameLayout) {
// It's a badge, goddammit!
newTab = ((FrameLayout) newTab).getChildAt(0);
}
if (animate) {
MiscUtils.resizeTab(oldTab, oldTab.getWidth(), mInActiveShiftingItemWidth);
MiscUtils.resizeTab(newTab, newTab.getWidth(), mActiveShiftingItemWidth);
} else {
oldTab.getLayoutParams().width = mInActiveShiftingItemWidth;
newTab.getLayoutParams().width = mActiveShiftingItemWidth;
}
}
}
private void updateSelectedTab(int newPosition) {
final boolean notifyMenuListener = mMenuListener != null && mItems instanceof BottomBarTab[];
final boolean notifyRegularListener = mListener != null;
if (newPosition != mCurrentTabPosition) {
handleBadgeVisibility(mCurrentTabPosition, newPosition);
mCurrentTabPosition = newPosition;
if (notifyRegularListener) {
notifyRegularListener(mListener, false, mCurrentTabPosition);
}
if (notifyMenuListener) {
notifyMenuListener(mMenuListener, false, ((BottomBarTab) mItems[mCurrentTabPosition]).id);
}
updateCurrentFragment();
} else {
if (notifyRegularListener) {
notifyRegularListener(mListener, true, mCurrentTabPosition);
}
if (notifyMenuListener) {
notifyMenuListener(mMenuListener, true, ((BottomBarTab) mItems[mCurrentTabPosition]).id);
}
}
}
@SuppressWarnings("deprecation")
private void notifyRegularListener(Object listener, boolean isReselection, int position) {
if (listener instanceof OnTabClickListener) {
OnTabClickListener onTabClickListener = (OnTabClickListener) listener;
if (!isReselection) {
onTabClickListener.onTabSelected(position);
} else {
onTabClickListener.onTabReSelected(position);
}
} else if (listener instanceof OnTabSelectedListener) {
OnTabSelectedListener onTabSelectedListener = (OnTabSelectedListener) listener;
if (!isReselection) {
onTabSelectedListener.onItemSelected(position);
}
}
}
@SuppressWarnings("deprecation")
private void notifyMenuListener(Object listener, boolean isReselection, @IdRes int menuItemId) {
if (listener instanceof OnMenuTabClickListener) {
OnMenuTabClickListener onMenuTabClickListener = (OnMenuTabClickListener) listener;
if (!isReselection) {
onMenuTabClickListener.onMenuTabSelected(menuItemId);
} else {
onMenuTabClickListener.onMenuTabReSelected(menuItemId);
}
} else if (listener instanceof OnMenuTabSelectedListener) {
OnMenuTabSelectedListener onMenuTabSelectedListener = (OnMenuTabSelectedListener) listener;
if (!isReselection) {
onMenuTabSelectedListener.onMenuItemSelected(menuItemId);
}
}
}
private void handleBadgeVisibility(int oldPosition, int newPosition) {
if (mBadgeMap == null) {
return;
}
if (mBadgeMap.containsKey(oldPosition)) {
BottomBarBadge oldBadge = (BottomBarBadge) mOuterContainer
.findViewWithTag(mBadgeMap.get(oldPosition));
if (oldBadge.getAutoShowAfterUnSelection()) {
oldBadge.show();
} else {
oldBadge.hide();
}
}
if (mBadgeMap.containsKey(newPosition)) {
BottomBarBadge newBadge = (BottomBarBadge) mOuterContainer
.findViewWithTag(mBadgeMap.get(newPosition));
newBadge.hide();
}
}
@Override
public boolean onLongClick(View v) {
return handleLongClick(v);
}
private boolean handleLongClick(View v) {
if ((mIsShiftingMode || mIsTabletMode) && v.getTag().equals(TAG_BOTTOM_BAR_VIEW_INACTIVE)) {
Toast.makeText(mContext, mItems[findItemPosition(v)].getTitle(mContext), Toast.LENGTH_SHORT).show();
}
return true;
}
private void updateItems(final BottomBarItemBase[] bottomBarItems) {
if (mItemContainer == null) {
initializeViews();
}
int index = 0;
int biggestWidth = 0;
mIsShiftingMode = mMaxFixedTabCount >= 0 && mMaxFixedTabCount < bottomBarItems.length;
if (!mIsDarkTheme && !mIgnoreNightMode
&& MiscUtils.isNightMode(mContext)) {
mIsDarkTheme = true;
}
if (mIsDarkTheme) {
darkThemeMagic();
} else if (!mIsTabletMode && mIsShiftingMode) {
mDefaultBackgroundColor = mCurrentBackgroundColor = mPrimaryColor;
mBackgroundView.setBackgroundColor(mDefaultBackgroundColor);
if (mContext instanceof Activity) {
navBarMagic((Activity) mContext, this);
}
}
View[] viewsToAdd = new View[bottomBarItems.length];
for (BottomBarItemBase bottomBarItemBase : bottomBarItems) {
int layoutResource;
if (mIsShiftingMode && !mIsTabletMode) {
layoutResource = R.layout.bb_bottom_bar_item_shifting;
} else {
layoutResource = mIsTabletMode ?
R.layout.bb_bottom_bar_item_fixed_tablet : R.layout.bb_bottom_bar_item_fixed;
}
View bottomBarTab = View.inflate(mContext, layoutResource, null);
ImageView icon = (ImageView) bottomBarTab.findViewById(R.id.bb_bottom_bar_icon);
icon.setImageDrawable(bottomBarItemBase.getIcon(mContext));
if (!mIsTabletMode) {
TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title);
title.setText(bottomBarItemBase.getTitle(mContext));
if (mPendingTextAppearance != -1) {
MiscUtils.setTextAppearance(title, mPendingTextAppearance);
}
if (mPendingTypeface != null) {
title.setTypeface(mPendingTypeface);
}
}
if (mIsDarkTheme || (!mIsTabletMode && mIsShiftingMode)) {
icon.setColorFilter(mWhiteColor);
}
if (bottomBarItemBase instanceof BottomBarTab) {
bottomBarTab.setId(((BottomBarTab) bottomBarItemBase).id);
}
if (index == mCurrentTabPosition) {
selectTab(bottomBarTab, false);
} else {
unselectTab(bottomBarTab, false);
}
if (!mIsTabletMode) {
if (bottomBarTab.getWidth() > biggestWidth) {
biggestWidth = bottomBarTab.getWidth();
}
viewsToAdd[index] = bottomBarTab;
} else {
mItemContainer.addView(bottomBarTab);
}
bottomBarTab.setOnClickListener(this);
bottomBarTab.setOnLongClickListener(this);
index++;
}
if (!mIsTabletMode) {
int proposedItemWidth = Math.min(
MiscUtils.dpToPixel(mContext, mScreenWidth / bottomBarItems.length),
mMaxFixedItemWidth
);
mInActiveShiftingItemWidth = (int) (proposedItemWidth * 0.9);
mActiveShiftingItemWidth = (int) (proposedItemWidth + (proposedItemWidth * (bottomBarItems.length * 0.1)));
for (View bottomBarView : viewsToAdd) {
LinearLayout.LayoutParams params;
if (mIsShiftingMode && !mIgnoreShiftingResize) {
if (TAG_BOTTOM_BAR_VIEW_ACTIVE.equals(bottomBarView.getTag())) {
params = new LinearLayout.LayoutParams(mActiveShiftingItemWidth,
LinearLayout.LayoutParams.WRAP_CONTENT);
} else {
params = new LinearLayout.LayoutParams(mInActiveShiftingItemWidth,
LinearLayout.LayoutParams.WRAP_CONTENT);
}
} else {
params = new LinearLayout.LayoutParams(proposedItemWidth,
LinearLayout.LayoutParams.WRAP_CONTENT);
}
bottomBarView.setLayoutParams(params);
mItemContainer.addView(bottomBarView);
}
}
if (mPendingTextAppearance != -1) {
mPendingTextAppearance = -1;
}
if (mPendingTypeface != null) {
mPendingTypeface = null;
}
}
private void darkThemeMagic() {
if (!mIsTabletMode) {
mBackgroundView.setBackgroundColor(mDarkBackgroundColor);
} else {
mItemContainer.setBackgroundColor(mDarkBackgroundColor);
mTabletRightBorder.setBackgroundColor(ContextCompat.getColor(mContext, R.color.bb_tabletRightBorderDark));
}
}
private void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mCurrentTabPosition = savedInstanceState.getInt(STATE_CURRENT_SELECTED_TAB, -1);
mBadgeStateMap = (HashMap<Integer, Boolean>) savedInstanceState
.getSerializable(STATE_BADGE_STATES_BUNDLE);
if (mCurrentTabPosition == -1) {
mCurrentTabPosition = 0;
Log.e("BottomBar", "You must override the Activity's onSave" +
"InstanceState(Bundle outState) and call BottomBar.onSaveInstanc" +
"eState(outState) there to restore the state properly.");
}
mIsComingFromRestoredState = true;
mShouldUpdateFragmentInitially = true;
}
}
private void selectTab(View tab, boolean animate) {
tab.setTag(TAG_BOTTOM_BAR_VIEW_ACTIVE);
ImageView icon = (ImageView) tab.findViewById(R.id.bb_bottom_bar_icon);
TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title);
int tabPosition = findItemPosition(tab);
if (!mIsShiftingMode || mIsTabletMode) {
int activeColor = mCustomActiveTabColor != 0 ?
mCustomActiveTabColor : mPrimaryColor;
icon.setColorFilter(activeColor);
if (title != null) {
title.setTextColor(activeColor);
}
}
if (mIsDarkTheme) {
if (title != null) {
ViewCompat.setAlpha(title, 1.0f);
}
ViewCompat.setAlpha(icon, 1.0f);
}
if (title == null) {
return;
}
int translationY = mIsShiftingMode ? mTenDp : mTwoDp;
if (animate) {
ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(title)
.setDuration(ANIMATION_DURATION)
.scaleX(1)
.scaleY(1);
if (mIsShiftingMode) {
titleAnimator.alpha(1.0f);
}
titleAnimator.start();
ViewCompat.animate(tab)
.setDuration(ANIMATION_DURATION)
.translationY(-translationY)
.start();
if (mIsShiftingMode) {
ViewCompat.animate(icon)
.setDuration(ANIMATION_DURATION)
.alpha(1.0f)
.start();
}
handleBackgroundColorChange(tabPosition, tab);
} else {
ViewCompat.setScaleX(title, 1);
ViewCompat.setScaleY(title, 1);
ViewCompat.setTranslationY(tab, -translationY);
if (mIsShiftingMode) {
ViewCompat.setAlpha(icon, 1.0f);
ViewCompat.setAlpha(title, 1.0f);
}
}
}
private void unselectTab(View tab, boolean animate) {
tab.setTag(TAG_BOTTOM_BAR_VIEW_INACTIVE);
ImageView icon = (ImageView) tab.findViewById(R.id.bb_bottom_bar_icon);
TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title);
if (!mIsShiftingMode || mIsTabletMode) {
int inActiveColor = mIsDarkTheme ? mWhiteColor : mInActiveColor;
icon.setColorFilter(inActiveColor);
if (title != null) {
title.setTextColor(inActiveColor);
}
}
if (mIsDarkTheme) {
if (title != null) {
ViewCompat.setAlpha(title, 0.6f);
}
ViewCompat.setAlpha(icon, 0.6f);
}
if (title == null) {
return;
}
float scale = mIsShiftingMode ? 0 : 0.86f;
if (animate) {
ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(title)
.setDuration(ANIMATION_DURATION)
.scaleX(scale)
.scaleY(scale);
if (mIsShiftingMode) {
titleAnimator.alpha(0);
}
titleAnimator.start();
ViewCompat.animate(tab)
.setDuration(ANIMATION_DURATION)
.translationY(0)
.start();
if (mIsShiftingMode) {
ViewCompat.animate(icon)
.setDuration(ANIMATION_DURATION)
.alpha(0.6f)
.start();
}
} else {
ViewCompat.setScaleX(title, scale);
ViewCompat.setScaleY(title, scale);
ViewCompat.setTranslationY(tab, 0);
if (mIsShiftingMode) {
ViewCompat.setAlpha(icon, 0.6f);
ViewCompat.setAlpha(title, 0);
}
}
}
private void handleBackgroundColorChange(int tabPosition, View tab) {
if (mIsDarkTheme || !mIsShiftingMode || mIsTabletMode) return;
if (mColorMap != null && mColorMap.containsKey(tabPosition)) {
handleBackgroundColorChange(
tab, mColorMap.get(tabPosition));
} else {
handleBackgroundColorChange(tab, mDefaultBackgroundColor);
}
}
private void handleBackgroundColorChange(View tab, int color) {
MiscUtils.animateBGColorChange(tab,
mBackgroundView,
mBackgroundOverlay,
color);
mCurrentBackgroundColor = color;
}
private int findItemPosition(View viewToFind) {
int position = 0;
for (int i = 0; i < mItemContainer.getChildCount(); i++) {
View candidate = mItemContainer.getChildAt(i);
if (candidate.equals(viewToFind)) {
position = i;
break;
}
}
return position;
}
private void updateCurrentFragment() {
if (!mShouldUpdateFragmentInitially && mFragmentManager != null
&& mFragmentContainer != 0
&& mItems != null
&& mItems instanceof BottomBarFragment[]) {
BottomBarFragment newFragment = ((BottomBarFragment) mItems[mCurrentTabPosition]);
if (mFragmentManager instanceof android.support.v4.app.FragmentManager
&& newFragment.getSupportFragment() != null) {
((android.support.v4.app.FragmentManager) mFragmentManager).beginTransaction()
.replace(mFragmentContainer, newFragment.getSupportFragment())
.commit();
} else if (mFragmentManager instanceof android.app.FragmentManager
&& newFragment.getFragment() != null) {
((android.app.FragmentManager) mFragmentManager).beginTransaction()
.replace(mFragmentContainer, newFragment.getFragment())
.commit();
}
}
mShouldUpdateFragmentInitially = false;
}
private void clearItems() {
if (mItemContainer != null) {
int childCount = mItemContainer.getChildCount();
if (childCount > 0) {
for (int i = 0; i < childCount; i++) {
mItemContainer.removeView(mItemContainer.getChildAt(i));
}
}
}
if (mFragmentManager != null) {
mFragmentManager = null;
}
if (mFragmentContainer != 0) {
mFragmentContainer = 0;
}
if (mItems != null) {
mItems = null;
}
}
private static void navBarMagic(Activity activity, final BottomBar bottomBar) {
Resources res = activity.getResources();
int softMenuIdentifier = res
.getIdentifier("config_showNavigationBar", "bool", "android");
int navBarIdentifier = res.getIdentifier("navigation_bar_height",
"dimen", "android");
int navBarHeight = 0;
if (navBarIdentifier > 0) {
navBarHeight = res.getDimensionPixelSize(navBarIdentifier);
}
if (!bottomBar.drawBehindNavBar()
|| navBarHeight == 0
|| (!(softMenuIdentifier > 0 && res.getBoolean(softMenuIdentifier)))) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
&& ViewConfiguration.get(activity).hasPermanentMenuKey()) {
return;
}
/**
* Copy-paste coding made possible by:
* http://stackoverflow.com/a/14871974/940036
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Display d = activity.getWindowManager().getDefaultDisplay();
DisplayMetrics realDisplayMetrics = new DisplayMetrics();
d.getRealMetrics(realDisplayMetrics);
int realHeight = realDisplayMetrics.heightPixels;
int realWidth = realDisplayMetrics.widthPixels;
DisplayMetrics displayMetrics = new DisplayMetrics();
d.getMetrics(displayMetrics);
int displayHeight = displayMetrics.heightPixels;
int displayWidth = displayMetrics.widthPixels;
boolean hasSoftwareKeys = (realWidth - displayWidth) > 0
|| (realHeight - displayHeight) > 0;
if (!hasSoftwareKeys) {
return;
}
}
/**
* End of delicious copy-paste code
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
activity.getWindow().getAttributes().flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
if (bottomBar.useTopOffset()) {
int offset;
int statusBarResource = res
.getIdentifier("status_bar_height", "dimen", "android");
if (statusBarResource > 0) {
offset = res.getDimensionPixelSize(statusBarResource);
} else {
offset = MiscUtils.dpToPixel(activity, 25);
}
if (!bottomBar.useOnlyStatusbarOffset()) {
TypedValue tv = new TypedValue();
if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
offset += TypedValue.complexToDimensionPixelSize(tv.data,
res.getDisplayMetrics());
} else {
offset += MiscUtils.dpToPixel(activity, 56);
}
}
bottomBar.getUserContainer().setPadding(0, offset, 0, 0);
}
final View outerContainer = bottomBar.getOuterContainer();
final int navBarHeightCopy = navBarHeight;
bottomBar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@Override
public void onGlobalLayout() {
bottomBar.shyHeightAlreadyCalculated();
int newHeight = outerContainer.getHeight() + navBarHeightCopy;
outerContainer.getLayoutParams().height = newHeight;
if (bottomBar.isShy()) {
int defaultOffset = bottomBar.useExtraOffset() ? navBarHeightCopy : 0;
bottomBar.setTranslationY(defaultOffset);
((CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams())
.setBehavior(new BottomNavigationBehavior(newHeight, defaultOffset, bottomBar.isShy(), bottomBar.mIsTabletMode));
}
ViewTreeObserver obs = outerContainer.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
}
}
}
| [
"1226097512@qq.com"
] | 1226097512@qq.com |
c3882057840427cf0bac9493548f5b936957f1f4 | 6baf1fe00541560788e78de5244ae17a7a2b375a | /hollywood/com.oculus.alpenglow-EnterpriseServer/sources/X/AnonymousClass0e1.java | ef2883a150eddecf4b49f6cf948cacc7d9934207 | [] | no_license | phwd/quest-tracker | 286e605644fc05f00f4904e51f73d77444a78003 | 3d46fbb467ba11bee5827f7cae7dfeabeb1fd2ba | refs/heads/main | 2023-03-29T20:33:10.959529 | 2021-04-10T22:14:11 | 2021-04-10T22:14:11 | 357,185,040 | 4 | 2 | null | 2021-04-12T12:28:09 | 2021-04-12T12:28:08 | null | UTF-8 | Java | false | false | 616 | java | package X;
import android.text.StaticLayout;
import android.text.TextDirectionHeuristic;
import android.text.TextDirectionHeuristics;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
@RequiresApi(23)
/* renamed from: X.0e1 reason: invalid class name */
public class AnonymousClass0e1 extends AnonymousClass04V {
@Override // X.AnonymousClass04V
public void A00(StaticLayout.Builder builder, TextView textView) {
builder.setTextDirection((TextDirectionHeuristic) AnonymousClass04W.A00(textView, "getTextDirectionHeuristic", TextDirectionHeuristics.FIRSTSTRONG_LTR));
}
}
| [
"cyuubiapps@gmail.com"
] | cyuubiapps@gmail.com |
c6cdf230c16a807da17d94a58c52a7aef79640e6 | 189d820ad0527b71a04596e385c6a84f904669d0 | /codes/src/innerclasses/Games.java | 371078e709bf90dde3512f3adb623a45e83efcd3 | [
"Apache-2.0"
] | permissive | jhwsx/Think4JavaExamples | 30484e128ce43ed3d1da0104b77d8e3fedee7b59 | bf912a14def15c11a9a5eada308ddaae8e31ff8f | refs/heads/master | 2023-07-06T17:27:18.738304 | 2021-08-08T12:33:57 | 2021-08-08T12:33:57 | 198,008,875 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,741 | java | package innerclasses;
/**
* <pre>
* author : wangzhichao
* e-mail : wangzhichao@adups.com
* time : 2019/07/27
* desc :
* version: 1.0
* </pre>
*/
interface Game {
boolean move();
}
interface GameFactory {
Game getGame();
}
class Checkers implements Game {
private Checkers() {
//no instance
}
private int moves = 0;
private static final int MOVES = 3;
@Override
public boolean move() {
System.out.println("Checkers move " + moves);
return ++moves != MOVES;
}
public static GameFactory factory = new GameFactory() {
@Override
public Game getGame() {
return new Checkers();
}
};
}
//class CheckersFactory implements GameFactory {
//
// @Override
// public Game getGame() {
// return new Checkers();
// }
//}
class Chess implements Game {
private Chess() {
//no instance
}
private int moves = 0;
private static final int MOVES = 4;
@Override
public boolean move() {
System.out.println("Chess move " + moves);
return ++moves != MOVES;
}
public static GameFactory factory = new GameFactory() {
@Override
public Game getGame() {
return new Chess();
}
};
}
//class ChessFactory implements GameFactory {
//
// @Override
// public Game getGame() {
// return new Chess();
// }
//}
public class Games {
public static void playGame(GameFactory factory) {
Game game = factory.getGame();
while (game.move()) {
;
}
}
public static void main(String[] args) {
playGame(Checkers.factory);
playGame(Chess.factory);
}
}
| [
"wangzhichao@adups.com"
] | wangzhichao@adups.com |
c7fe13d895ae9c4cfe0454576bdb0f2157c0445e | 4621985a5ef435898d3e9954baa5e88bfdeef4a9 | /app/src/androidTest/java/com/mydreamworld/advancedparse/ExampleInstrumentedTest.java | 787aa4e8f8af478933d3c9bd792a65a041af8be7 | [] | no_license | prawinrajan/Advanced-parse | 759daceaf26a044b5e4d4e4396337b971da887a5 | 36e9cd215fc7a85589ddaa6ce1e7ce93bf982a1d | refs/heads/master | 2022-11-26T19:32:28.045409 | 2020-08-05T06:18:21 | 2020-08-05T06:18:21 | 285,198,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 776 | java | package com.mydreamworld.advancedparse;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.mydreamworld.advancedparse", appContext.getPackageName());
}
}
| [
"prawinrajan2@gmail.com"
] | prawinrajan2@gmail.com |
67237f5ab9c89514c270004fb10121e236470a89 | 11afb3afde3d2d0094f41bc09c20776274485414 | /hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetApplicationAttemptReportRequest.java | 66974028532a9692104d58b2ca7e3073492a6dd6 | [
"Apache-2.0"
] | permissive | aixuebo/had2.6.0-hadoop-yarn-project | fabaa60f480ebd7a153d8bf65b5c22ebb086f846 | e49e67ddaf4ea5ed208133e4122c82651ada0e8a | refs/heads/master | 2021-01-17T15:24:34.160183 | 2017-07-07T11:22:43 | 2017-07-07T11:22:43 | 49,939,152 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,698 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.protocolrecords;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ApplicationHistoryProtocol;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.util.Records;
/**
* <p>
* The request sent by a client to the <code>ResourceManager</code> to get an
* {@link ApplicationAttemptReport} for an application attempt.
* </p>
*
* <p>
* The request should include the {@link ApplicationAttemptId} of the
* application attempt.
* </p>
*
* @see ApplicationAttemptReport
* @see ApplicationHistoryProtocol#getApplicationAttemptReport(GetApplicationAttemptReportRequest)
* 获取某一个ApplicationAttempt实例的详细信息
*/
@Public
@Unstable
public abstract class GetApplicationAttemptReportRequest {
@Public
@Unstable
public static GetApplicationAttemptReportRequest newInstance(
ApplicationAttemptId applicationAttemptId) {
GetApplicationAttemptReportRequest request =
Records.newRecord(GetApplicationAttemptReportRequest.class);
request.setApplicationAttemptId(applicationAttemptId);
return request;
}
/**
* Get the <code>ApplicationAttemptId</code> of an application attempt.
*
* @return <code>ApplicationAttemptId</code> of an application attempt
*/
@Public
@Unstable
public abstract ApplicationAttemptId getApplicationAttemptId();
/**
* Set the <code>ApplicationAttemptId</code> of an application attempt
*
* @param applicationAttemptId
* <code>ApplicationAttemptId</code> of an application attempt
*/
@Public
@Unstable
public abstract void setApplicationAttemptId(
ApplicationAttemptId applicationAttemptId);
}
| [
"78608544@qq.com"
] | 78608544@qq.com |
7ef76b714cf4e2172965703a2d9bb2b89b5f7dc9 | 3711fb68b9b525d521275a978b02ab28f79505d2 | /bj_1110_while.java | 8dceffb5cfd49a457ff921010552f17969cc2574 | [] | no_license | raccoon-ccoder/baekjun_algorithm | 4bfb21ca9d38da374676f9f8724f3fca2aac30f9 | ac22867c8a2cf7e7d7d4b4f8155123c0c08d2eee | refs/heads/main | 2023-03-30T06:29:22.672525 | 2021-03-30T14:43:36 | 2021-03-30T14:43:36 | 348,340,456 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,017 | java | /* 0<n, n<100인 정수 n이 있을때 다음과 같이 연산할 수 있다. 먼저 주어진 수가 10보다 작으면 앞에 0을 붙여 두자리 수로 만들고
* 각 자리의 숫자를 더한다. 그 다음, 주어진 수의 가장 오른쪽 자리 수와 앞에서 구한 합의 가장 오른쪽 자리 수를 이어 붙여 새로운 수를 만든다
* 예시를 보면 26이 시작일때, 2+6=8이고 새로운 수는 68이다.6+8=14이다. 새로운 수는 84이다. 8+4=12이며 새로운 수는 42이다.
* 4+2=6이며 새로운 수는 26이다. 위의 예는 4번만에 원래 수로 돌아온다. 따라서 26의 사이클 길이는 4이다.
* 정수 n이 주어졌을 때, n의 사이클 길이는 구하는 프로그램을 작성해라.
*/
import java.util.*;
public class bj_1110_while {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
int answer = input; // 입력값의 복사값
int count = 0; // 사이클 횟수
if(input>=10) { // 입력값이 10보다 클 때
while(true) {
int x = input/10;
int y = input%10;
int result = (y*10) + ((x+y)%10);
count++;
if(result==answer) {
System.out.println(count);
break;
}
x = result/10;
y = result%10;
input = (y*10) + ((x+y)%10);
count++;
if(answer==input) {
System.out.println(count);
break;
}
}
} else { // 입력값이 10보다 작을때
int x = 0;
int y = input;
int result = y*10 + y;
count++;
if(input==result) {
System.out.println(count);
}else {
while(true) {
x = result/10;
y = result%10;
input = (y*10) + ((x+y)%10);
count++;
if(input==answer) {
System.out.println(count);
break;
}
x = input/10;
y = input%10;
result = (y*10) + ((x+y)%10);
count++;
if(result==answer) {
System.out.println(count);
break;
}
}
}
}
}
}
| [
"qorwjddus96@naver.com"
] | qorwjddus96@naver.com |
7c1bba667536409310ff65d4d9b2f30d5e0197b8 | fa34634b84455bf809dbfeeee19f8fb7e26b6f76 | /3.JavaMultithreading/src/com/javarush/task/task24/task2404/Solution.java | 96d28cc7899acf28eddba413471462a52545eb0c | [
"Apache-2.0"
] | permissive | Ponser2000/JavaRushTasks | 3b4bdd2fa82ead3c72638f0f2826db9f871038cc | e6eb2e8ee2eb7df77273f2f0f860f524400f72a2 | refs/heads/main | 2023-04-04T13:23:52.626862 | 2021-03-25T10:43:04 | 2021-03-25T10:43:04 | 322,064,721 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,591 | java | package com.javarush.task.task24.task2404;
/*
Рефакторинг Rectangle
*/
public class Solution {
public static void main(String[] args) {
Rectangle rectangle = new Rectangle(1, 2, 3, 4);
//System.out.println(getHeight(rectangle));
//System.out.println(getWidth(rectangle));
/////////////////////expected//////////////////
System.out.println(getHeight(rectangle.castToHasHeight()));
System.out.println(getWidth(rectangle.castToHasWidth()));
}
public static double getHeight(HasHeight rectangle) {
return rectangle.getHeight();
}
public static double getWidth(HasWidth rectangle) {
return rectangle.getWidth();
}
public static class Rectangle {
private Point point1;
private Point point2;
public Rectangle(double x1, double y1, double x2, double y2) {
point1 = new Point(x1, y1);
point2 = new Point(x2, y2);
}
public HasHeight castToHasHeight() {
class Height implements HasHeight {
@Override
public double getHeight() {
return Math.abs(point1.getY() - point2.getY());
}
}
return new Height();
}
public HasWidth castToHasWidth() {
class Width implements HasWidth{
@Override
public double getWidth() {
return Math.abs(point1.getX() - point2.getX());
}
}
return new Width();
}
}
}
| [
"ponser2000@gmail.com"
] | ponser2000@gmail.com |
3f2e9ccfe203cda9e98337948cd13e43277b7932 | ec31bf8d7dc2bc771f7fba140e3c78035b585308 | /src/com.eci.youku/src/com/eci/youku/dao/ShopDao.java | 453438aadbd2f311cef555bb41a031127a44ba27 | [] | no_license | kinzohuny/test | c759f058fa93de8161b693ce63978930923eb8e8 | 6b88db0f434ae6f15dcdb6a5e14fa6e2b1e9e642 | refs/heads/master | 2020-12-15T05:34:12.511218 | 2019-04-23T04:36:40 | 2019-04-23T04:36:40 | 14,917,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,658 | java | package com.eci.youku.dao;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.eci.youku.core.DatabaseManage;
import com.eci.youku.model.ShopModel;
import com.eci.youku.util.StringUtils;
public class ShopDao {
public static String SQL_QUERY = "select s.sid,s.title,s.url,s.tk_url,s.logo_url,s.pic_url,s.sort,s.status,s.created,s.updated,count(i.iid) as item_num,cast(sum(i.status) as signed) as item_on_num"
+ " from youku_shop s left join youku_item i on s.sid=i.sid"
+ " where 1=1";
public static String SQL_INSERT = "replace into youku_shop (sid,title,url,tk_url,logo_url,pic_url,sort,status,created,updated) values";
public static String SQL_DELETE = "delete from youku_shop where sid in ";
public static String SQL_UPDATE_STATUS = "update youku_shop set status=? where sid in ";
public static String SQL_UPDATE = "update youku_shop"
+ " set title=?,url=?,tk_url=?,logo_url=?,pic_url=?,sort=?,status=?,updated=now()"
+ " where sid=?";
private static String QUERY_LIST_BYUPDATED = "select sid, title, nick, status, created, updated"
+ " from youku_shop"
+ " where updated >= ?"
+ " order by updated";
public List<ShopModel> queryListByUpdated(Timestamp lastUpdate) throws SQLException{
return DatabaseManage.queryList(ShopModel.class, QUERY_LIST_BYUPDATED, lastUpdate);
}
public int delete(String ids) throws SQLException{
if(StringUtils.isNotEmpty(ids)){
Object[] paras = ids.split(",");
return DatabaseManage.update(SQL_DELETE+getInSql(paras.length), paras);
}
return 0;
}
public int updateStatus(String ids, int status) throws SQLException{
if(StringUtils.isNotEmpty(ids)){
Object[] idArr = ids.split(",");
Object[] paras = (status+","+ids).split(",");
return DatabaseManage.update(SQL_UPDATE_STATUS+getInSql(idArr.length), paras);
}
return 0;
}
public int update(ShopModel model) throws SQLException{
if(model!=null){
Object[] paras = new Object[8];
paras[0] = model.getTitle();
paras[1] = model.getUrl();
paras[2] = model.getTk_url();
paras[3] = model.getLogo_url();
paras[4] = model.getPic_url();
paras[5] = model.getSort();
paras[6] = model.getStatus();
paras[7] = model.getSid();
return DatabaseManage.update(SQL_UPDATE, paras);
}
return 0;
}
private String getInSql(int num){
StringBuffer buffer = new StringBuffer("(");
for(int i = 0; i < num; i++){
buffer.append("?,");
}
buffer.setLength(buffer.length()-1);
buffer.append(")");
return buffer.toString();
}
public int insert(List<ShopModel> list) throws SQLException{
if(list!=null&&!list.isEmpty()){
StringBuffer buffer = new StringBuffer();;
for(ShopModel model : list){
buffer.append("(");
buffer.append(model.getSid()).append(",");
buffer.append("'").append(model.getTitle()).append("',");
buffer.append("'").append(model.getUrl()).append("',");
buffer.append("'").append(model.getTk_url()).append("',");
buffer.append("'").append(model.getLogo_url()).append("',");
buffer.append("'").append(model.getPic_url()).append("',");
buffer.append(model.getSort()).append(",");
buffer.append(model.getStatus()).append(",");
buffer.append("now(),");
buffer.append("now()");
buffer.append("),");
}
buffer.setLength(buffer.length()-1);
return DatabaseManage.update(SQL_INSERT+buffer.toString());
}
return 0;
}
public ShopModel queryById(String sid) throws SQLException {
ShopModel model = null;
Map<String, Object> map = new HashMap<String, Object>();
map.put("sid", sid);
List<ShopModel> list = queryForList(map);
if(!list.isEmpty()){
model = list.get(0);
}
return model;
}
public List<ShopModel> queryForList(Map<String, Object> map) throws SQLException{
StringBuffer buffer = new StringBuffer();
List<Object> paraList = new ArrayList<Object>();
if(map!=null&&map.size()>0){
for(String key : map.keySet()){
if("status".equalsIgnoreCase(key)){
buffer.append(" and s.status=?");
paraList.add(map.get(key));
}
if("sid".equalsIgnoreCase(key)){
buffer.append(" and s.sid=?");
paraList.add(map.get(key));
}
if("sidLike".equalsIgnoreCase(key)){
buffer.append(" and s.sid like ?");
paraList.add(map.get(key));
}
if("titleLike".equalsIgnoreCase(key)){
buffer.append(" and s.title like ?");
paraList.add(map.get(key));
}
}
}
buffer.append(" group by s.sid order by s.status desc,s.sort");
List<Map<String, Object>> resultList = DatabaseManage.queryMapList(SQL_QUERY+buffer.toString(), paraList.toArray());
List<ShopModel> list = new ArrayList<ShopModel>();
for(Map<String, Object> result : resultList){
ShopModel model = new ShopModel();
model.setSid((Long)result.get("sid"));
model.setTitle((String)result.get("title"));
model.setUrl((String)result.get("url"));
model.setTk_url((String)result.get("tk_url"));
model.setLogo_url((String)result.get("logo_url"));
model.setPic_url((String)result.get("pic_url"));
model.setSort((Long)result.get("sort"));
model.setStatus((Integer)result.get("status"));
model.setCreated((Timestamp)result.get("created"));
model.setUpdated((Timestamp)result.get("updated"));
model.setItem_num((Long)result.get("item_num"));
model.setItem_on_num((Long)result.get("item_on_num"));
list.add(model);
}
return list;
}
}
| [
"kinzo@qq.com"
] | kinzo@qq.com |
4e14836e9dba0405ec0ef08eda1416fc726322bf | 957961873263da90e4b0c1a320d9903ad4b1abcf | /app/src/main/java/com/ns/newsapp/data/Article.java | 235f1b0a3e796ea2dcd3c4e299d4f7c36217f8d8 | [] | no_license | Neerajsh8851/NewsApp | ac13532705fd9d2215743759275865ee90af3272 | e0544ceb1762c95cb1c4466e57aca28f2fdfbefc | refs/heads/master | 2023-09-04T12:04:13.761877 | 2021-11-01T15:38:50 | 2021-11-01T15:38:50 | 423,089,261 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 221 | java | package com.ns.newsapp.data;
public class Article {
public String url;
public String urlToImage;
public String title;
public String publishedAt;
public String description;
public Source source;
}
| [
"nsxylush@gmail.com"
] | nsxylush@gmail.com |
c6cf6c7165fa08b2a52093def84393c0ce1afb4e | 47c258bc6002d84a0ab3f80fd9f32c32936e2f47 | /src/main/java/com/ebenyx/oraklus/relation/entity/Lit.java | ba189c3578c30f5ebb1f882917933340229c48da | [] | no_license | innocentk33/oraklus-core | ebe987b98215d71c7184942d426367d25c9662b6 | c4cdfcaedece8f7d2ec33af4bfaf30c79c71c4f6 | refs/heads/master | 2020-05-16T11:09:15.682331 | 2019-04-18T09:34:07 | 2019-04-18T09:34:07 | 183,007,263 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,251 | java | package com.ebenyx.oraklus.relation.entity;
import javax.persistence.*;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import com.ebenyx.oraklus.utils.BaseEntity;
/**
* Lit entity class ...
* @author Brice-Boris BEDA
* @version 1.0, 16/04/2019
*/
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Scope("prototype")
@Component("myLit")
@Table(name="LIT")
public class Lit extends BaseEntity<Long>{
/**
* <p> Lit ...</p>
*/
@Getter @Setter
@Column(name="NUMERO")
private Integer numero;
/**
* <p> Lit ...</p>
*/
@Getter @Setter
@Column(name="DATE_ENTREE")
private LocalDate dateEntree;
/**
* <p> Lit ...</p>
*/
@Getter @Setter
@Column(name="MAX_HEURE")
private LocalDateTime maxHeure;
/**
* <p> Lit ...</p>
*/
@ManyToOne
@Getter @Setter
@JoinColumn(name = "STATUT", nullable=false)
private Statut statut;
/**
* <p> Lit ...</p>
*/
@ManyToOne
@Getter @Setter
@JoinColumn(name = "TYPE_LIT", nullable=false)
private Type_Lit typeLit;
} | [
"bbeda@ebenyx.com"
] | bbeda@ebenyx.com |
2285ba7a9c9ba8aa5014f09010f87270f6897371 | 733e6a4fa3b43b937613d8a60663dfa868055d11 | /src/main/java/fr/mby/saml2/sp/api/om/IRequestWaitingForResponse.java | 672cc7acee069fea89c492e097dafb36ef16b10c | [
"Apache-2.0"
] | permissive | redikod/java-saml2-sp | 77546a39e1d3083e8088ab44930a914cecb78cd9 | 696b544a601b90b37ed5377206cb5810732c927e | refs/heads/master | 2020-03-23T02:24:06.421132 | 2016-03-09T20:24:01 | 2016-03-09T20:24:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,162 | java | /**
* Copyright (C) 2012 RECIA http://www.recia.fr
* @Author (C) 2012 Maxime Bossard <mxbossard@gmail.com>
*
* 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 fr.mby.saml2.sp.api.om;
import fr.mby.saml2.sp.api.core.ISaml20IdpConnector;
import fr.mby.saml2.sp.api.query.IQuery;
/**
* Base interface for a SAML Request which need a SAML Response.
*
* @author GIP RECIA 2012 - Maxime BOSSARD.
*
*/
public interface IRequestWaitingForResponse extends IQuery {
/**
* The IdP connector which build this request.
* @return The IdP connector which build this request
*/
ISaml20IdpConnector getIdpConnectorBuilder();
}
| [
"mxbossard@gmail.com"
] | mxbossard@gmail.com |
ed90135698bd3f83e7831a3eadd713a313ce7a6b | 03753db1ceea68a19b36bc66a1a8b32eeb8215a7 | /cos-base/src/main/java/com/chaoren/base/db/permissions/service/IResourceService.java | 61bd072a336aab8aabcf45ab7ae84f446bdc45c0 | [] | no_license | yuedongfang/cos | c36049264a4f33b9a06be934376e4a8353148e17 | 71a9ef5a3e31d0e5d39feaf1f20e12291466234e | refs/heads/master | 2021-08-28T23:08:20.424030 | 2017-12-13T07:56:28 | 2017-12-13T07:56:28 | 114,084,080 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 537 | java | package com.chaoren.base.db.permissions.service;
import com.baomidou.mybatisplus.service.IService;
import com.chaoren.base.db.permissions.model.Resource;
import com.chaoren.base.db.permissions.model.ShiroUser;
import com.chaoren.base.result.Tree;
import java.util.List;
/**
*
* Resource 表数据服务层接口
*
*/
public interface IResourceService extends IService<Resource> {
List<Resource> selectAll();
List<Tree> selectAllMenu();
List<Tree> selectAllTree();
List<Tree> selectTree(ShiroUser shiroUser);
} | [
"yuedongfang@126.com"
] | yuedongfang@126.com |
da096a58b602258e0b647b47d2be39323443783f | 02194399335358d5a7a06afede6f54743e9af365 | /src/main/java/com/example/demo/config/WechatMpConfig.java | c0bf6104fd052148c949006fdb64e761edb3bb08 | [] | no_license | letianxing1994/wechat-book-store | 2b6a69f517908d7b884f2e0eaf2bb3f57d98ecd6 | 64130e34008d9f54424cf8dcb2693553d0b39bba | refs/heads/master | 2020-12-23T06:47:39.641387 | 2020-01-29T20:17:53 | 2020-01-29T20:17:53 | 237,072,811 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,090 | java | package com.example.demo.config;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Component
public class WechatMpConfig {
@Autowired
private WechatAccountConfig accountConfig;
@Bean
public WxMpService wxMpService(){
WxMpService wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
return wxMpService;
}
@Bean
public WxMpConfigStorage wxMpConfigStorage(){
WxMpConfigStorage wxMpConfigStorage = new WxMpInMemoryConfigStorage();
((WxMpInMemoryConfigStorage) wxMpConfigStorage).setAppId(accountConfig.getMpAppId());
((WxMpInMemoryConfigStorage) wxMpConfigStorage).setSecret(accountConfig.getMpAppSecret());
return wxMpConfigStorage;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
963c9db6120f163cced5905fb92d30e9cd39ec3c | 58adc1eb647fec7611e8ecf42cc0c0bb170f60b3 | /backend/src/main/java/com/xebia/assessmenttool/entity/Assessment.java | 8a9d146b793dcfe5f4f1d5c3e60ee2e8085f6aa4 | [] | no_license | sankalpnarayan27/sankalp_tool | 10757fa293772ccd2b4454722ebc5c70abfbcb82 | 8dc8b39afc28a7a34dc8e8c1fd157ff04406f8c6 | refs/heads/master | 2020-08-10T22:47:55.166459 | 2019-10-11T13:08:50 | 2019-10-11T13:08:50 | 214,436,597 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,787 | java | package com.xebia.assessmenttool.entity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xebia.assessmenttool.enums.Status;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.*;
@Setter
@Getter
@Entity
@Table(name = "organisationTest") //todo this table needs to be renamed in the database.
@JsonIgnoreProperties({"hibernateLazyInitializer"})
public class Assessment extends BaseEntity implements Comparable<Assessment> {
@ManyToOne
@JoinColumn(name = "org_id")
@JsonBackReference
private Organisation organisation;
@Column(name = "testName")
private String testName;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinTable(name = "ORGANISATION_TEST_FRAMEWORK",
joinColumns = @JoinColumn(name = "ORGANISATION_TEST_ID"),
inverseJoinColumns = @JoinColumn(name = "FRAMEWORK_ID"))
private Set<Framework> frameworkSet = new HashSet<>();
@OneToMany(mappedBy = "assessment", cascade = CascadeType.ALL)
private List<DraftQuestion> draftQuestions = new ArrayList<>();
@Enumerated(EnumType.STRING)
private Status status;
@Override
public int compareTo(Assessment o) {
return getCreatedDate().compareTo(o.getCreatedDate());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Assessment)) {
return false;
}
Assessment that = (Assessment) o;
return getCreatedDate().equals(that.getCreatedDate());
}
@Override
public int hashCode() {
return Objects.hash(getCreatedDate());
}
}
| [
"56334939+sankalpnarayan27@users.noreply.github.com"
] | 56334939+sankalpnarayan27@users.noreply.github.com |
c19a0f79336c1b7be9610cc51c1acfe0db4975c7 | 71ac029e406f7f73ea62a945619736bad70c9ec7 | /TestProjects-ejb/src/main/java/org/javabeanstack/model/appcatalog/AppUser.java | e00c4f144e56cf5239a50c3e345be03ac1d0f0b7 | [] | no_license | jencisopy/TestProject | 039ee5bd64ba9ae4ca1fb49542e90496a262f200 | 1fc7f5a00f2d1a1ffd714a9d9a76bc1f1dfa8882 | refs/heads/master | 2022-02-12T06:28:06.259672 | 2020-08-24T13:36:51 | 2020-08-24T13:36:51 | 154,874,233 | 2 | 0 | null | 2022-02-09T23:23:48 | 2018-10-26T18:03:14 | Java | UTF-8 | Java | false | false | 12,350 | java | package org.javabeanstack.model.appcatalog;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.javabeanstack.data.DataRow;
import org.javabeanstack.error.ErrorManager;
import org.javabeanstack.model.IAppCompanyAllowed;
import org.javabeanstack.model.IAppUser;
import org.javabeanstack.model.IAppUserMember;
import org.javabeanstack.util.Fn;
import org.javabeanstack.util.LocalDates;
import org.javabeanstack.util.Strings;
import org.apache.log4j.Logger;
@Entity
@Table(name = "appuser", uniqueConstraints = {
@UniqueConstraint(columnNames = {"code"})})
@SequenceGenerator(name = "APPUSER_SEQ", allocationSize = 1, sequenceName = "APPUSER_SEQ")
public class AppUser extends DataRow implements IAppUser {
private static final Logger LOGGER = Logger.getLogger(AppUser.class);
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "APPUSER_SEQ")
@Basic(optional = false)
@Column(name = "iduser")
private Long iduser;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 30)
@Column(name = "code")
private String code;
@Basic(optional = false)
@NotNull(message = "Debe ingresar el nombre de usuario")
@Size(min = 1, max = 50)
@Column(name = "fullname")
private String fullName;
@Column(name = "pass")
private String pass;
@Transient
private String passConfirm = Strings.replicate("*", 20);
@Transient
private String passConfirm2 = Strings.replicate("*", 20);
@Size(max = 50)
@Column(name = "description")
private String description;
@Size(max = 100)
@Column(name = "email1")
private String email1;
@Size(max = 100)
@Column(name = "email2")
private String email2;
@Size(max = 50)
@Column(name = "telefono1")
private String telefono1;
@Size(max = 50)
@Column(name = "celular1")
private String celular1;
@Size(max = 50)
@Column(name = "celular2")
private String celular2;
@Column(name = "disabled")
private Boolean disabled = false;
@Column(name = "expiredDate")
private LocalDateTime expiredDate;
@Size(max = 2)
@Column(name = "rol")
private String rol;
@Column(name = "type")
private Short type;
@Column(name = "avatar")
private byte[] avatar;
@Column(name = "fechamodificacion")
private LocalDateTime fechamodificacion;
@OneToMany(mappedBy = "usermember")
private List<AppUserMember> userMemberList = new ArrayList<>();
@Column(name = "idcompany")
private Long idcompany;
public AppUser() {
queryUK = "select o from AppUser o where code = :code";
}
@Override
public Long getIduser() {
return iduser;
}
@Override
public void setIduser(Long iduser) {
this.iduser = iduser;
}
@Override
public String getLogin() {
if (code != null) {
code = code.trim();
}
return code;
}
@Override
public void setLogin(String codigo) {
this.code = codigo;
}
@Override
public String getCode() {
if (code != null) {
code = code.trim();
}
return code;
}
@Override
public void setCode(String code) {
this.code = code;
}
@Override
public String getFullName() {
if (fullName != null) {
fullName = fullName.trim();
}
return fullName;
}
@Override
public void setFullName(String nombre) {
this.fullName = nombre;
}
@Override
public String getPass() {
if (pass != null) {
pass = pass.trim();
}
return pass;
}
@Override
public void setPass(String clave) {
this.pass = clave;
}
@Override
public String getPassConfirm() {
if (passConfirm != null) {
passConfirm = passConfirm.trim();
}
return passConfirm;
}
@Override
public void setPassConfirm(String passConfirm) {
this.passConfirm = passConfirm;
}
@Override
public String getPassConfirm2() {
if (passConfirm2 != null) {
passConfirm2 = passConfirm2.trim();
}
return passConfirm2;
}
@Override
public void setPassConfirm2(String passConfirm2) {
this.passConfirm2 = passConfirm2;
}
@Override
public String getDescription() {
if (description != null) {
description = description.trim();
}
return description;
}
@Override
public void setDescription(String descripcion) {
this.description = descripcion;
}
@Override
public Boolean getDisabled() {
return disabled;
}
@Override
public void setDisabled(Boolean disable) {
this.disabled = disable;
}
@Override
public LocalDateTime getExpiredDate() {
return expiredDate;
}
@Override
public void setExpiredDate(LocalDateTime expira) {
this.expiredDate = expira;
}
@Override
public String getRol() {
return Fn.nvl(rol,"30").trim().toUpperCase();
}
@Override
public String getHighRol() {
// Este es el valor del usuario normal
String result="30";
try{
if (this.getUserMemberList() == null || this.getUserMemberList().isEmpty()){
return Fn.nvl(rol,"30").trim();
}
for (IAppUserMember userMember: this.getUserMemberList()){
String role = Fn.nvl(userMember.getUserGroup().getRol(),"30").trim();
if (Integer.parseInt(role) < Integer.parseInt(result)){
result = role;
}
}
}
catch (Exception exp) {
ErrorManager.showError(exp, LOGGER);
result = Fn.nvl(rol,"30").trim();
}
return result.toUpperCase();
}
@Override
public String getAllRoles() {
// Este es el valor del usuario normal
String result = "30";
try {
// Si es grupo
if (this.getType() == 2) {
result = Fn.nvl(rol, "30").trim();
} else {
// Si es usuario
if (this.getUserMemberList() == null || this.getUserMemberList().isEmpty()) {
return Fn.nvl(rol, "30").trim();
}
String roles = "";
for (IAppUserMember userMember : this.getUserMemberList()) {
roles += Fn.nvl(userMember.getUserGroup().getRol(), "30").trim()+",";
}
result = roles;
}
} catch (Exception exp) {
ErrorManager.showError(exp, LOGGER);
result = Fn.nvl(rol, "30").trim();
}
return result.toUpperCase();
}
@Override
public void setRol(String rol) {
this.rol = rol;
}
@Override
public String getAppRol() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setAppRol(String appRol) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Short getType() {
return type;
}
@Override
public void setType(Short type) {
this.type = type;
}
public LocalDateTime getFechamodificacion() {
return fechamodificacion;
}
public void setFechamodificacion(LocalDateTime fechamodificacion) {
this.fechamodificacion = fechamodificacion;
}
@Override
public List<IAppUserMember> getUserMemberList() {
return (List<IAppUserMember>) (List<?>) userMemberList;
}
@Override
public void setUserMemberList(List<IAppUserMember> userMemberList) {
this.userMemberList = (List<AppUserMember>) (List<?>) userMemberList;
}
@Override
public Long getIdcompany() {
return idcompany;
}
@Override
public void setIdcompany(Long idcompany) {
this.idcompany = idcompany;
}
@Override
public List<IAppCompanyAllowed> getAppCompanyAllowedList() {
return null;
}
@Override
public void setAppCompanyAllowedList(List<IAppCompanyAllowed> dicPermisoEmpresaList) {
//this.dicPermisoEmpresaList = (List<DicPermisoEmpresa>)(List<?>)dicPermisoEmpresaList;
}
@Override
public byte[] getAvatar() {
return avatar;
}
@Override
public void setAvatar(byte[] avatar) {
this.avatar = avatar;
}
public String getEmail1() {
return email1;
}
public void setEmail1(String email1) {
this.email1 = email1;
}
public String getEmail2() {
return email2;
}
public void setEmail2(String email2) {
this.email2 = email2;
}
public String getTelefono1() {
return telefono1;
}
public void setTelefono1(String telefono1) {
this.telefono1 = telefono1;
}
public String getCelular1() {
return celular1;
}
public void setCelular1(String celular1) {
this.celular1 = celular1;
}
public String getCelular2() {
return celular2;
}
public void setCelular2(String celular2) {
this.celular2 = celular2;
}
@Override
public int hashCode() {
int hash = 5;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final AppUser other = (AppUser) obj;
if (!Objects.equals(this.iduser, other.iduser)) {
return false;
}
return true;
}
@Override
public boolean equivalent(Object o) {
if (!(o instanceof AppUser)) {
return false;
}
AppUser obj = (AppUser) o;
return (this.code.trim().equals(obj.getLogin().trim()));
}
@Override
public String toString() {
return "Usuario{" + "idusuario=" + iduser + ", codigo=" + code + ", nombre=" + fullName + ", descripcion=" + description + ", disable=" + disabled + ", expira=" + expiredDate + ", rol=" + rol + ", tipo=" + type + '}';
}
@PreUpdate
@PrePersist
public void preUpdate() {
fechamodificacion = LocalDateTime.now();
if (expiredDate == null) {
expiredDate = LocalDates.toDateTime("31/12/9999 00:00:00");
}
}
/**
* Si se aplica o no el filtro por defecto en la selección de datos. Este
* metodo se modifica en las clases derivadas si se debe cambiar el
* comportamiento.
*
* @return verdadero si y falso no
*/
@Override
public boolean isApplyDBFilter() {
return false;
}
@Override
public final boolean isAdministrator(){
return getAllRoles().contains("20") || getRol().contains("00");
}
}
| [
"jorge.enciso.r@gmail.com"
] | jorge.enciso.r@gmail.com |
5c013aa4ce299fdf165c3b066bad85be11954241 | 4a23c15ba59701e237d85fbf27dc62a034e60e4b | /nemo-190428/src/it/unipr/netsec/nemo/ip/Ip4Host.java | 484d5225b7ddfe9c9fc3759e62fbadbc8e619fdb | [] | no_license | DanLangas/SOFTX_2019_12 | 3da278ef0e56bd29b96ff9bfddb264563262d03f | 77e87278821e14f0b7896a3a8b8e55a52d481ba6 | refs/heads/master | 2022-05-11T09:58:47.577802 | 2019-05-07T14:02:58 | 2019-05-07T14:02:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,891 | java | /*
* Copyright 2018 NetSec Lab - University of Parma
*
* 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.
*
* Author(s):
* Luca Veltri (luca.veltri@unipr.it)
*/
package it.unipr.netsec.nemo.ip;
import java.io.IOException;
import java.io.PrintStream;
import java.net.DatagramPacket;
import java.net.SocketException;
import org.zoolu.util.ByteUtils;
import org.zoolu.util.LoggerLevel;
import org.zoolu.util.Random;
import org.zoolu.util.SystemUtils;
import it.unipr.netsec.ipstack.icmp4.PingClient;
import it.unipr.netsec.ipstack.ip4.Ip4Address;
import it.unipr.netsec.ipstack.ip4.Ip4Layer;
import it.unipr.netsec.ipstack.ip4.Ip4Node;
import it.unipr.netsec.ipstack.ip4.IpAddress;
import it.unipr.netsec.ipstack.net.NetInterface;
import it.unipr.netsec.ipstack.tcp.TcpLayer;
import it.unipr.netsec.ipstack.udp.DatagramSocket;
import it.unipr.netsec.ipstack.udp.UdpLayer;
import it.unipr.netsec.nemo.http.HttpRequestHandle;
import it.unipr.netsec.nemo.http.HttpServer;
import it.unipr.netsec.nemo.http.HttpServerListener;
import it.unipr.netsec.nemo.link.DataLink;
/** IPv4 Host.
* <p>
* It is an IP node with a web server (port 80), a UDP echo server (port 7), and a PING client.
*/
public class Ip4Host extends Ip4Node {
/** Debug mode */
public static boolean DEBUG=false;
/** Prints a debug message. */
void debug(String str) {
//SystemUtils.log(LoggerLevel.DEBUG,toString()+": "+str);
SystemUtils.log(LoggerLevel.DEBUG,Ip4Host.class.getSimpleName()+"["+getID()+"]: "+str);
}
/** IP layer built on top of this node and used by the PING client */
Ip4Layer ip_layer;
/** UDP layer for the echo server */
UdpLayer udp_layer;
/** TCP layer for the HTTP server */
TcpLayer tcp_layer;
/** Creates a new host.
* @param ni network interface
* @param gw default router */
public Ip4Host(NetInterface ni, IpAddress gw) {
super(new NetInterface[] {ni});
ip_layer=new Ip4Layer(this);
if (gw!=null) getRoutingTable().setDefaultRoute(gw);
}
/** Creates a new host.
* @param link attached link
* @param addr the IP address
* @param gw default router */
public Ip4Host(IpLink link, Ip4Address addr, Ip4Address gw) {
this(new IpLinkInterface(link,addr),gw);
}
/** Creates a new host.
* The IP address and default router are automatically configured
* @param link attached link */
public Ip4Host(IpLink link) {
this(new IpLinkInterface(link),(link.getRouters().length>0?(IpAddress)link.getRouters()[0]:null));
}
/** Gets the host address.
* @return the first address of the network interface */
public Ip4Address getAddress() {
return (Ip4Address)getNetInterfaces()[0].getAddresses()[0];
}
/** Starts a UDP echo server. */
public void startUdpEchoServer() {
try {
udp_layer=new UdpLayer(ip_layer);
new Thread(new Runnable() {
@Override
public void run() {
try {
udpEchoServer(udp_layer);
}
catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
catch (SocketException e) {
e.printStackTrace();
}
}
/** UDP echo server.
* @param udp_layer UDP layer
* @throws IOException */
private void udpEchoServer(UdpLayer udp_layer) throws IOException {
DatagramSocket udp_socket=new DatagramSocket(udp_layer,7);
DatagramPacket datagram_packet=new DatagramPacket(new byte[1024],0);
while (true) {
udp_socket.receive(datagram_packet);
debug("UDP ECHO: received data: "+ByteUtils.asHex(datagram_packet.getData(),datagram_packet.getOffset(),datagram_packet.getLength()));
datagram_packet.setPort(5555);
debug("UDP ECHO: reply to: "+datagram_packet.getAddress().getHostAddress().toString());
udp_socket.send(datagram_packet);
}
}
/** Starts a HTTP server. */
public void startHttpServer() {
try {
tcp_layer=new TcpLayer(ip_layer);
new Thread(new Runnable() {
@Override
public void run() {
try {
httpServer(tcp_layer);
}
catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
catch (IOException e) {
e.printStackTrace();
}
}
/** HTTP server.
* @param tcp_layer TCP layer
* @throws IOException */
private void httpServer(TcpLayer tcp_layer) throws IOException {
new HttpServer(tcp_layer,80,new HttpServerListener() {
@Override
public void onHttpRequest(HttpRequestHandle req_handle) {
if (req_handle.getMethod().equals("GET") && req_handle.getRequestURL().equals("/")) {
String resource_value="<html>\r\n" +
"<body>\r\n" +
"<h1>Hello, World!</h1>\r\n" +
"<p>Random value: "+Random.nextHexString(8)+"</p>\r\n" +
"</body>\r\n" +
"</html>";
req_handle.setContentType("text/html");
req_handle.setResourceValue(resource_value.getBytes());
req_handle.setResponseCode(200);
}
}
});
}
/** Runs a ping session.
* It sends a given number of ICMP Echo Request messages and captures the corresponding ICMP Echo Reply responses.
* @param target_ip_addr IP address of the target node
* @param count the number of ICMP Echo requests to be sent
* @param out output where ping results are printed */
public void ping(final Ip4Address target_ip_addr, int count, final PrintStream out) {
new PingClient(ip_layer,target_ip_addr,count,out);
}
/*@Override
public String toString() {
return getClass().getSimpleName()+'['+getAddress()+']';
}*/
}
| [
"viviana.letizia@gmail.com"
] | viviana.letizia@gmail.com |
d52e2e9b5f496242827a5c08c51a3fbed3b8b707 | 52512c50bf518375ba19005f4927692267690e29 | /desafioSolutis/src/main/java/com/desafioSolutis/model/PalavraEntity.java | 36e11c93c9bcab1658d17f4a615034f49c4a9f19 | [] | no_license | fredryco/desafioSl | 6cf303ea7e3e183788745991b77e774de8c12989 | 1cc85b94ed6898a3dbcdf7a1fa771aa9957c945f | refs/heads/master | 2020-03-28T15:05:39.743209 | 2018-09-14T22:41:44 | 2018-09-14T22:41:44 | 148,555,042 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 808 | java | package com.desafioSolutis.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class PalavraEntity {
@Id
@GeneratedValue
private Integer id;
private String palavra;
private String letra;
public PalavraEntity() {
super();
}
public PalavraEntity(String palavra, String letra) {
super();
this.palavra = palavra;
this.letra = letra;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getPalavra() {
return palavra;
}
public void setPalavra(String palavra) {
this.palavra = palavra;
}
public String getLetra() {
return letra;
}
public void setLetra(String letra) {
this.letra = letra;
}
}
| [
"Fred@DESKTOP-D11NP9D"
] | Fred@DESKTOP-D11NP9D |
ff88232e16e8613213b01d2d0e203a59b3855d9a | 42a1de4494e777b93e68c512432c8a3524511c87 | /config-server/src/test/java/com/bcht/sprigcloud/server/ConfigServerApplicationTests.java | 1ab6a337dc41d9345293fbc9b0fc13cae0019c0d | [] | no_license | s499151096/SpringCloudConfig | 2891ca60a2f5a83b8eae366dba1181909e87a5c9 | a817d9b25e8f6320fe5aaa5220a5af9378dffbd6 | refs/heads/master | 2021-01-23T03:00:00.915426 | 2017-03-24T07:44:39 | 2017-03-24T07:44:39 | 86,040,726 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 349 | java | package com.bcht.sprigcloud.server;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigServerApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"499151096@qq.com"
] | 499151096@qq.com |
89e86257054a3de461e8ed9959a046ae6dddaf2b | bcd28d9f3fa0b9b3745f327b3ea278ca120d7172 | /Throw and throws/src/throwsAndThrow/exception.java | 1ca4335ee625ff261b9e701624d33ef70f226dfc | [] | no_license | Hunter007Hacker/Data-Structure-and-Algorithm | c23671457d5caef13ce8b9d8f0d96b4a26504b23 | 8934f0424677958eaf372c06b4e52efa88650a50 | refs/heads/main | 2023-08-29T00:40:19.136109 | 2021-10-28T13:45:55 | 2021-10-28T13:45:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 471 | java | package throwsAndThrow;
import java.io.FileNotFoundException;
import java.io.FileReader;
public class exception {
public static void main(String[] args) {
try {
someMethode();
} catch (FileNotFoundException e) {
System.out.println("catch exception from someMethode");
}
}
public static void someMethode() throws FileNotFoundException {
System.out.println("Print from someMethode");
throw new FileNotFoundException();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
e6aec01ac80245e8544df38246bd52ee9e1a424c | 2fb68165619abb9085a3510f3084567b84e19a18 | /day12_xml/src/jsoup/XPath.java | 4b76689a515ceece51bcf0c2c4d8eb7a74826781 | [] | no_license | GithubRobot01/itheima02 | 1395a9b3d1f6e407e9a5a3b0f77b5343c649b483 | e0b9cf4e4784938fb216202822468ced26f981c6 | refs/heads/master | 2022-12-23T09:51:17.469243 | 2019-09-16T10:23:57 | 2019-09-16T10:23:57 | 202,896,754 | 1 | 0 | null | 2022-12-16T02:24:43 | 2019-08-17T15:18:25 | TSQL | UTF-8 | Java | false | false | 2,260 | java | package jsoup;
import cn.wanghaomiao.xpath.exception.XpathSyntaxErrorException;
import cn.wanghaomiao.xpath.model.JXDocument;
import cn.wanghaomiao.xpath.model.JXNode;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class XPath {
public static void main(String[] args) throws IOException, XpathSyntaxErrorException {
/* 1. selector:选择器
* 使用的方法:Elements select(String cssQuery)
* 语法:参考Selector类中定义的语法
2. XPath:XPath即为XML路径语言,它是一种用来确定XML(标准通用标记语言的子集)文档中某部分位置的语言
* 使用Jsoup的Xpath需要额外导入jar包。
* 查询w3cshool参考手册,使用xpath的语法完成查询*/
//1.获取student.xml的path
String path = XPath.class.getClassLoader().getResource("student.xml").getPath();
//2.获取Document对象
Document document = Jsoup.parse(new File(path), "utf-8");
//3.根据document对象,创建JXDocument对象
JXDocument jxDocument = new JXDocument(document);
//4.结合xpath语法查询
//4.1查询所有student标签
List<JXNode> jxNodes = jxDocument.selN("//student");
for (JXNode jxNode : jxNodes) {
System.out.println(jxNode);
}
System.out.println("-------------");
//4.2查询所有student标签下的name标签
List<JXNode> jxNodes1 = jxDocument.selN("//student/name");
for (JXNode jxNode : jxNodes1) {
System.out.println(jxNode);
}
System.out.println("----------------");
//4.3查询student标签下带有id属性的name标签
List<JXNode> jxNodes2 = jxDocument.selN("//student/name[@id]");
for (JXNode jxNode : jxNodes2) {
System.out.println(jxNode);
}
System.out.println("------------------");
//4.4查询student标签下带有id属性的name标签 并且id属性值为1
List<JXNode> jxNodes3 = jxDocument.selN("//student/name[@id='1']");
for (JXNode jxNode : jxNodes3) {
System.out.println(jxNode);
}
}
}
| [
"1440035864@qq.com"
] | 1440035864@qq.com |
d1d975097caf08d716b7a06d4e57f716f8427445 | 1ea4406414e9113b0316c114a17556d5344d4949 | /src/ro/nextreports/server/search/DrillDownSearchEntry.java | 3f3a1ef113e53f81f42516e9559db89e2aaf2f50 | [
"Apache-2.0"
] | permissive | nextreports/nextreports-server | 34039167a0bd4f22d13b26d35b131ab886a300d9 | 0a6b5bde7cb6228a16e7109aaaac8595155c492e | refs/heads/master | 2023-07-10T23:40:50.158795 | 2023-06-30T17:25:32 | 2023-06-30T17:25:32 | 12,408,453 | 30 | 21 | Apache-2.0 | 2023-06-30T17:25:33 | 2013-08-27T14:37:09 | Java | UTF-8 | Java | false | false | 1,458 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ro.nextreports.server.search;
import org.apache.wicket.model.StringResourceModel;
public class DrillDownSearchEntry extends SearchEntry {
private Tristate drill;
public Tristate getDrill() {
return drill;
}
public void setDrill(Tristate drill) {
this.drill = drill;
}
public String getMessage() {
StringBuilder sb = new StringBuilder();
sb.append("* ").append(new StringResourceModel("ActionContributor.Search.entry.drill", null).getString()).append(" = '");
sb.append(drill.getName());
sb.append("'");
return sb.toString();
}
}
| [
"decebal.suiu@gmail.com"
] | decebal.suiu@gmail.com |
112aa8c6bcf5be973c6640a6040a3c596dcbb77f | 30368e49dbd11fb52fb89e78365ead54924fec9d | /src/com/mvc/entityReport/EquipRoom.java | f11d187a3402871df92759c4bdb56cf2fe48ed19 | [] | no_license | wangqian234/gywyext | 91acb75cc128e938a8498f624d2f34abcaf81fbc | 454071ea790adc119e391774490c9890600b100e | refs/heads/master | 2021-07-21T03:11:47.481655 | 2018-12-27T13:48:26 | 2018-12-27T13:48:26 | 142,310,287 | 0 | 6 | null | 2018-12-27T13:48:27 | 2018-07-25T14:19:18 | JavaScript | UTF-8 | Java | false | false | 1,888 | java | package com.mvc.entityReport;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="equip_room")
public class EquipRoom {
private Integer equip_room_id;//设备位置编号,主键
private String equip_room_name;//设备位置名称
private Project project;//设备所属项目编号,外键
private String equip_room_memo;//设备位置备注
private Integer equip_room_isdeleted;//设备位置是否删除 0:存在 1:已删除
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "equip_room_id",unique=true,nullable=false, length = 11)
public Integer getEquip_room_id() {
return equip_room_id;
}
public void setEquip_room_id(Integer equip_room_id) {
this.equip_room_id = equip_room_id;
}
@Column(name = "equip_room_name", length = 64)
public String getEquip_room_name() {
return equip_room_name;
}
public void setEquip_room_name(String equip_room_name) {
this.equip_room_name = equip_room_name;
}
@ManyToOne
@JoinColumn(name="proj_id")
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
@Column(name = "equip_room_memo", length = 255)
public String getEquip_room_memo() {
return equip_room_memo;
}
public void setEquip_room_memo(String equip_room_memo) {
this.equip_room_memo = equip_room_memo;
}
@Column(name = "equip_room_isdeleted", length = 1,columnDefinition = "INT not null default 0")
public Integer getEquip_room_isdeleted() {
return equip_room_isdeleted;
}
public void setEquip_room_isdeleted(Integer equip_room_isdeleted) {
this.equip_room_isdeleted = equip_room_isdeleted;
}
} | [
"565059807@qq.com"
] | 565059807@qq.com |
799e44f936bfccf0d40ac071926da61673cb3fa1 | 1cef28a3e4676fd75b4e344a1bdf5046642a02c2 | /1.4 Learn to help yourself/BasicActivityApp/app/src/main/java/ro/danserboi/basicactivityapp/ui/slideshow/SlideshowViewModel.java | c60172a615294ff3e9458b0d8e0bd3a6f20d5c30 | [] | no_license | danserboi/Android-Developer-Fundamentals-V2-Codelabs | dbfb368431b9fac16f89bcef41b055e10f31329c | c46bb06bf86616f7f6d8eba0758c38379262da83 | refs/heads/master | 2022-12-04T21:10:28.606008 | 2020-08-28T13:37:09 | 2020-08-28T13:37:09 | 291,049,610 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package ro.danserboi.basicactivityapp.ui.slideshow;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
public class SlideshowViewModel extends ViewModel {
private MutableLiveData<String> mText;
public SlideshowViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is slideshow fragment");
}
public LiveData<String> getText() {
return mText;
}
} | [
"danserboi@gmail.com"
] | danserboi@gmail.com |
496b3e690c8071aaec8c8ddc1554918a38b39cb7 | a23feef7eb400488ae312750d9086982531e80d7 | /source/Bank.java | 76a85fd8b0210dfa1b0804294934f04c098a1ec7 | [] | no_license | yocoal/VialFiller | 1eefe4c38d6f66863303d650da53885dcacc6198 | b2f2b75a71f19d4b15c47aef8f8a9fb8bf89e85e | refs/heads/master | 2020-02-26T13:22:14.966241 | 2016-09-22T06:48:34 | 2016-09-22T06:48:34 | 68,482,756 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,576 | java | package marbletables.vialfiller;
import org.powerbot.script.rt4.Bank.Amount;
import org.powerbot.script.rt4.ClientContext;
public class Bank extends Task<ClientContext>{
private int bankIds;
private int emptyVialId = 229;
public Bank(ClientContext ctx)
{
super(ctx);
}
/**
* if inventory does not have 28 empty vials, and a bank is nearby
*/
@Override
public boolean activate()
{
return (ctx.inventory.select().id(emptyVialId).size()< 28 && ctx.bank.present());
}
/**
* deposit everything and withdraw empty vials
*/
@Override
public void execute()
{
if(!ctx.bank.opened())
{
ctx.bank.open();
return;
}
// if # vials inventory does not equal total # items in inventory
// we know we have non empty vials or other random items in your inventory
// so deposit all of these items if this is the case
if(ctx.inventory.select().count()>=1 && ctx.inventory.select().id(emptyVialId).count() != ctx.inventory.select().count())
{
ctx.bank.depositInventory();
return;
}
// if you only have empty vials in your inventory ( also includes if you have NO Items in inventory)
// withdraw all empty vials
if(ctx.inventory.select().count() == ctx.inventory.select().id(emptyVialId).count() && ctx.inventory.select().id(emptyVialId).count() <28)
{
ctx.bank.withdraw(emptyVialId, Amount.ALL);
}
// close the bank if you have 28 empty vials
if(ctx.inventory.select().id(emptyVialId).count() == 28)
{
ctx.bank.close();
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
0b0cd047aed447d517ec0f6c1339063754f9215b | f26946669c09499cd62d8f3e9dc5c2329c8ecf53 | /src/main/java/org/elsys/dao/UserStatisticsDao.java | f6761df54741e3bb7377c11b4432eae901b68f6b | [] | no_license | Catishere/FlagsGame | de87f243a22958e880b7e1af8bd3b13860fecf26 | 48287fc6c0c0e6f84bab9a42fc8eb4e1627b03e9 | refs/heads/master | 2021-04-06T02:27:40.711145 | 2018-05-03T09:28:52 | 2018-05-03T09:28:52 | 125,245,069 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package org.elsys.dao;
import org.elsys.entity.UserAchievement;
import org.elsys.entity.UserStatistics;
import java.util.List;
public interface UserStatisticsDao {
void insert(UserStatistics userStatistics);
void update(UserStatistics userStatistics);
void delete(long id);
List<UserStatistics> findByUserId(long id);
}
| [
"viktor.gyoshev@gmail.com"
] | viktor.gyoshev@gmail.com |
dd5100eeacd221e0fef2e8c0d5d95cbd7e8cea40 | fe3e7da45d8b29f97594f85aa99bd1ffb5ccc35f | /src/main/java/com/lihe/concurrency/annotation/NonReCommend.java | 0e70f09540efe11832115080233c5c2fd61841c2 | [] | no_license | xiaoranli/concurrency | 81bea320a9b008e89f0d857b2592affc43e762f9 | b2b74360553128c8909f53623a4232bbf068e6f0 | refs/heads/master | 2020-05-17T18:27:04.982606 | 2019-04-29T02:46:13 | 2019-04-29T02:46:13 | 183,884,754 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 389 | java | package com.lihe.concurrency.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* * 用来标记【不推荐】的类或者写法
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface NonReCommend {
String value() default "";
} | [
"919993677@qq.com"
] | 919993677@qq.com |
bbc67362e4a0049a4db7f4e94870f00f84f014d9 | 75f9402d603cdb2f8c6a8df1924d4aa9981ff5d2 | /src-subjects/ZipMe/src/net/sf/zipme/CheckedOutputStream.java | 040c4c892fd6f282dd618c9fa7c6e9ec46097152 | [] | no_license | damorim/spl-test-amplification | 2b2c0809469bb6b3da1ea4e65658e952b0d44d18 | 6cd279991b3220c2e9b73c979f77479415adc7b7 | refs/heads/master | 2021-01-13T01:27:51.191901 | 2013-06-05T22:34:18 | 2013-06-05T22:34:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,554 | java | //
//#if BASE
package net.sf.zipme;
import java.io.IOException;
import java.io.OutputStream;
/**
* OutputStream that computes a checksum of data being written using a
* supplied Checksum object.
* @see Checksum
* @author Tom Tromey
* @date May 17, 1999
*/
public class CheckedOutputStream extends OutputStream {
/**
* This is the subordinate <code>OutputStream</code> that this class
* redirects its method calls to.
*/
protected OutputStream out;
/**
* Creates a new CheckInputStream on top of the supplied OutputStream
* using the supplied Checksum.
*/
public CheckedOutputStream( OutputStream out, Checksum cksum){
this.out=out;
this.sum=cksum;
}
/**
* Returns the Checksum object used. To get the data checksum computed so
* far call <code>getChecksum.getValue()</code>.
*/
public Checksum getChecksum(){
return sum;
}
/**
* Writes one byte to the OutputStream and updates the Checksum.
*/
public void write( int bval) throws IOException {
out.write(bval);
//#if ADLER32CHECKSUM
sum.update(bval);
//#endif
}
/**
* This method writes all the bytes in the specified array to the underlying
* <code>OutputStream</code>. It does this by calling the three parameter
* version of this method - <code>write(byte[], int, int)</code> in this
* class instead of writing to the underlying <code>OutputStream</code>
* directly. This allows most subclasses to avoid overriding this method.
* @param buf The byte array to write bytes from
* @exception IOException If an error occurs
*/
public void write( byte[] buf) throws IOException {
write(buf,0,buf.length);
}
/**
* Writes the byte array to the OutputStream and updates the Checksum.
*/
public void write( byte[] buf, int off, int len) throws IOException {
out.write(buf,off,len);
//#if ADLER32CHECKSUM
sum.update(buf,off,len);
//#endif
}
/**
* This method closes the underlying <code>OutputStream</code>. Any
* further attempts to write to this stream may throw an exception.
* @exception IOException If an error occurs
*/
public void close() throws IOException {
flush();
out.close();
}
/**
* This method attempt to flush all buffered output to be written to the
* underlying output sink.
* @exception IOException If an error occurs
*/
public void flush() throws IOException {
out.flush();
}
/**
* The checksum object.
*/
private Checksum sum;
}
//#endif | [
"sabrinadfs@gmail.com"
] | sabrinadfs@gmail.com |
251057c2ee694dfb4bce80098e68e3ccf5e75f15 | 368952aab931bf1672e5ac10a0efc6b5d3e2b3cf | /app/src/main/java/com/icostel/arhitecturesample/api/session/SessionStore.java | ef691c76a936de3e293140aa7046d453624e7e6c | [] | no_license | adamorban/ArchitectureSample | 359ad976323f513632fbc55ef82b387c9bb87460 | 4b3ec338cdac4eb3c852f339bf6dba97b764e382 | refs/heads/master | 2020-04-11T11:59:34.508001 | 2018-11-14T15:29:16 | 2018-11-14T15:29:16 | 161,765,923 | 0 | 0 | null | 2018-12-14T09:59:21 | 2018-12-14T09:59:21 | null | UTF-8 | Java | false | false | 1,074 | java | package com.icostel.arhitecturesample.api.session;
import android.content.SharedPreferences;
import com.icostel.arhitecturesample.di.qualifers.PerUser;
import com.icostel.arhitecturesample.utils.prefs.PersistentSetting;
import javax.inject.Inject;
import javax.inject.Singleton;
import androidx.annotation.Nullable;
@Singleton
public class SessionStore extends PersistentSetting<SessionData> {
private final SessionData sessionData;
@Inject
public SessionStore(@PerUser SharedPreferences preferences, SessionData sessionData) {
super(preferences);
this.sessionData = sessionData;
}
public void setUserSessionToken(String userSessionToken) {
this.sessionData.setUserToken(userSessionToken);
updateValue(this.sessionData);
}
public @Nullable
String getUserSessionToken() {
return this.sessionData.getUserToken();
}
@Override
protected String key() {
return "session";
}
@Override
protected Class<SessionData> clazz() {
return SessionData.class;
}
}
| [
"ignat.costel@gmail.com"
] | ignat.costel@gmail.com |
a7c20f0cb92fff08b8e8ed759e59fb79ecf7514c | a862cc7900e7931747c7322639a19236c7792ef9 | /produtor/src/main/java/InjectionBinder.java | f73ef18266fdaac6ed92389f7004ed6de726ecec | [] | no_license | danielcr10/inf1802-tweets-kafka-cassandra | c9178bf54b2b549c373c460593ae23d5fd35169f | 6ed9f786154abfca2454a55027cb3da9cfd63df1 | refs/heads/master | 2022-11-28T01:49:21.109185 | 2019-07-10T14:52:23 | 2019-07-10T14:52:23 | 196,008,878 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 310 | java | import org.glassfish.hk2.utilities.binding.AbstractBinder;
import javax.inject.Singleton;
public class InjectionBinder extends AbstractBinder {
@Override
protected void configure() {
bind(Stream.class)
.to(LifecycleManager.class)
.in(Singleton.class);
}
}
| [
"daniel.ahnuc10@gmail.com"
] | daniel.ahnuc10@gmail.com |
5b68a38eb6e76a77304b72a73411adb191cdb69d | 6e5c4c250d13f416a652482c0a4c9b36257ea51c | /lemon-boot-project/lemon-boot-framework/src/main/java/com/lemon/framework/storage/LocalStorageProvider.java | f0fc0b2fae1dc8304db5ebfbd56f123f69f2f1bf | [] | no_license | jesushai/OSSRH-66902 | 2e6fa7b3127286eec3a66965da556c3da3dde2e2 | b67262ccb383aeb7bdbe82554068c81ffcaf45d5 | refs/heads/main | 2023-04-21T12:55:52.286156 | 2021-05-12T10:41:27 | 2021-05-12T10:41:27 | 355,470,097 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,663 | java | package com.lemon.framework.storage;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.stream.Stream;
/**
* 名称:服务器本地对象存储服务<p>
* 描述:<p>
*
* @author hai-zhang
* @since 2020/4/28
*/
@Slf4j
@Data
public class LocalStorageProvider implements StorageProvider {
private String storagePath;
private String address;
private Path rootLocation;
public void setStoragePath(String storagePath) {
this.storagePath = storagePath;
this.rootLocation = Paths.get(storagePath);
try {
Files.createDirectories(rootLocation);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
public void store(InputStream inputStream, long contentLength, String contentType, String keyName) {
try {
Files.copy(inputStream, rootLocation.resolve(keyName), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
public Stream<Path> loadAll() {
try {
return Files.walk(rootLocation, 1)
.filter(path -> !path.equals(rootLocation))
.map(path -> rootLocation.relativize(path));
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
public Path load(String filename) {
return rootLocation.resolve(filename);
}
@Override
public Resource loadAsResource(String filename) {
try {
Path file = load(filename);
Resource resource = new UrlResource(file.toUri());
if (resource.exists() || resource.isReadable()) {
return resource;
} else {
return null;
}
} catch (MalformedURLException e) {
log.error(e.getMessage(), e);
return null;
}
}
@Override
public void delete(String filename) {
Path file = load(filename);
try {
Files.delete(file);
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
@Override
public String generateUrl(String keyName) {
return address + keyName;
}
} | [
"wx_79ec24d57f8047a283238537bac04936@git.code.tencent.com"
] | wx_79ec24d57f8047a283238537bac04936@git.code.tencent.com |
531346eda67f9b12815e14ea7e3928156ab1f6ba | 4b065b52e48a4caabfd7271c5ce953f6125a01d8 | /src/main/java/org/openfact/core/representations/idm/ErrorRepresentation.java | 7c504b449f20ae5c734c9d4abf54226bf40fcd4e | [] | no_license | olanaso/openfact | 459a7b6f5deb73aa1dc5174761897c92adc80923 | cd2f6cf666e6d7a4716422230868ec53575afddf | refs/heads/master | 2020-03-20T02:45:21.414621 | 2018-05-10T16:05:55 | 2018-05-10T16:05:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 305 | java | package org.openfact.core.representations.idm;
public class ErrorRepresentation {
private String message;
public ErrorRepresentation() {
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| [
"carlosthe19916@gmail.com"
] | carlosthe19916@gmail.com |
23671baf4222ae5c7714037eeccd56043b25b273 | b4105765d13f8ff54cd38e7fdaa316773ed0d400 | /src/main/java/org/zt/sweet/lang/ComboException.java | 55a7a7070f26d9e0a5b3acb1b74835e2af094d88 | [
"Apache-2.0"
] | permissive | StruggleBird/sweet-java-lib | 21b3e89269a2920ba58afab373b90f94b047cf40 | 22c2922b6abe8c3bacd17782626c8f76013a18be | refs/heads/master | 2022-06-25T04:26:23.662571 | 2019-10-31T01:03:11 | 2019-10-31T01:03:11 | 29,386,829 | 1 | 1 | NOASSERTION | 2022-06-17T01:50:39 | 2015-01-17T09:46:50 | Java | UTF-8 | Java | false | false | 2,054 | java | package org.zt.sweet.lang;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;
@SuppressWarnings("serial")
public class ComboException extends RuntimeException {
public ComboException() {
list = new LinkedList<Throwable>();
}
private List<Throwable> list;
public ComboException add(Throwable e) {
list.add(e);
return this;
}
@Override
public Throwable getCause() {
return list.isEmpty() ? null : list.get(0);
}
@Override
public String getLocalizedMessage() {
StringBuilder sb = new StringBuilder();
for (Throwable e : list)
sb.append(e.getLocalizedMessage()).append('\n');
return sb.toString();
}
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder();
for (Throwable e : list)
sb.append(e.getMessage()).append('\n');
return sb.toString();
}
@Override
public StackTraceElement[] getStackTrace() {
List<StackTraceElement> eles = new LinkedList<StackTraceElement>();
for (Throwable e : list)
for (StackTraceElement ste : e.getStackTrace())
eles.add(ste);
return eles.toArray(new StackTraceElement[eles.size()]);
}
@Override
public void printStackTrace() {
for (Throwable e : list) {
e.printStackTrace();
}
}
@Override
public void printStackTrace(PrintStream s) {
for (Throwable e : list) {
e.printStackTrace(s);
}
}
@Override
public void printStackTrace(PrintWriter s) {
for (Throwable e : list) {
e.printStackTrace(s);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (Throwable e : list)
sb.append(e.toString()).append('\n');
return sb.toString();
}
}
| [
"mjhx_zt@qq.com"
] | mjhx_zt@qq.com |
cc608e4f82ade181ffdaec34045cc7add8ee5d3d | 2787cb76c8462d9628eb8244dfe3f8b0a2822cee | /ServletRequestListenerDemo/src/HitCountServlet.java | fd3551ee40bec42d1c5c4bbdad2123481ccaad0d | [] | no_license | deekshasethi02/CoreJava | cf57027759ceadb8501ce67ea3fbab713668b4f2 | a1f83c0c3527876c55c5cd2b6d74af65ba729e70 | refs/heads/master | 2020-04-24T09:02:05.680073 | 2019-02-21T10:29:03 | 2019-02-21T10:29:03 | 171,850,217 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,011 | java |
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/hitCount")
public class HitCountServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void init() throws ServletException {
System.out.println("init() called :" + this.getClass().getName());
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h2> This is target servlet </h2>");
out.println("hits on this app :" + MyServletRequestListener.count);
}
public void destroy() {
System.out.println("destroy() called :" + this.getClass().getName());
}
}
| [
"deeksha.sethi@yash.com"
] | deeksha.sethi@yash.com |
9e622385ea64d1c6d99dbede762abdd3784b5e14 | 43a0d708d87c65ecc2e6f684674f9cb2cca4b0fd | /server_client_crypto_test/DummyClient/app/src/main/java/pt/ulisboa/tecnico/cmu/command/HelloCommand.java | e17f74eaacea90912dc895c7f90cf2a74da64599 | [] | no_license | lbpassos/Hop-on-Hop-off | 8e1b77fe13ec7b2c934b8a2e722adadeb0fe3154 | 3b753f0b43a33ddfb18d3e6cd7940488181fee91 | refs/heads/master | 2020-03-09T07:28:55.461932 | 2018-06-01T17:42:33 | 2018-06-01T17:42:33 | 128,665,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 452 | java | package pt.ulisboa.tecnico.cmu.command;
import pt.ulisboa.tecnico.cmu.response.Response;
public class HelloCommand implements Command {
private static final long serialVersionUID = -8807331723807741905L;
private String message;
public HelloCommand(String message) {
this.message = message;
}
@Override
public Response handle(CommandHandler chi) {
return chi.handle(this);
}
public String getMessage() {
return this.message;
}
}
| [
"ist426300@i5-023.tagus.ist.utl.pt"
] | ist426300@i5-023.tagus.ist.utl.pt |
186b9d02c9104914983d3bdc1adf731b63970f77 | bd1129eac7a2880dc2646e4a6617000619e6e622 | /gsonpath-compiler/src/test/resources/generator/standard/polymorphism/using_interface/TypesList_GsonTypeAdapter.java | 26404229371f397d3758d87b6bee4c5e3910fc72 | [
"MIT"
] | permissive | morristech/gsonpath | d0794774918b671234df5547183527412ddc852f | b441ae79beffddf14af1f0cf7b070079138bef5d | refs/heads/master | 2021-01-06T20:39:50.987451 | 2017-07-02T13:13:20 | 2017-07-02T13:13:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,360 | java | package generator.standard.polymorphism.using_interface;
import static gsonpath.GsonUtil.*;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.Streams;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import generator.standard.polymorphism.Type;
import gsonpath.internal.StrictArrayTypeAdapter;
import java.io.IOException;
import java.lang.Class;
import java.lang.Override;
import java.lang.String;
import java.util.Map;
public final class TypesList_GsonTypeAdapter extends TypeAdapter<TypesList> {
private final Gson mGson;
private StrictArrayTypeAdapter itemsGsonSubtype;
public TypesList_GsonTypeAdapter(Gson gson) {
this.mGson = gson;
}
@Override
public TypesList read(JsonReader in) throws IOException {
// Ensure the object is not null.
if (!isValidValue(in)) {
return null;
}
generator.standard.polymorphism.Type[] value_items = null;
int jsonFieldCounter0 = 0;
in.beginObject();
while (in.hasNext()) {
if (jsonFieldCounter0 == 1) {
in.skipValue();
continue;
}
switch (in.nextName()) {
case "items":
jsonFieldCounter0++;
value_items = (generator.standard.polymorphism.Type[]) getItemsGsonSubtype().read(in);
break;
default:
in.skipValue();
break;
}
}
in.endObject();
return new TypesList_GsonPathModel(
value_items
);
}
@Override
public void write(JsonWriter out, TypesList value) throws IOException {
}
private StrictArrayTypeAdapter getItemsGsonSubtype() {
if (itemsGsonSubtype == null) {
itemsGsonSubtype = new StrictArrayTypeAdapter<>(new ItemsGsonSubtype(mGson), Type.class, false);
}
return itemsGsonSubtype;
}
private static final class ItemsGsonSubtype extends TypeAdapter<Type> {
private final Map<String, TypeAdapter<? extends Type>> typeAdaptersDelegatedByValueMap;
private final Map<Class<? extends Type>, TypeAdapter<? extends Type>> typeAdaptersDelegatedByClassMap;
private ItemsGsonSubtype(Gson gson) {
typeAdaptersDelegatedByValueMap = new java.util.HashMap<>();
typeAdaptersDelegatedByClassMap = new java.util.HashMap<>();
typeAdaptersDelegatedByValueMap.put("type1", gson.getAdapter(generator.standard.polymorphism.Type1.class));
typeAdaptersDelegatedByClassMap.put(generator.standard.polymorphism.Type1.class, gson.getAdapter(generator.standard.polymorphism.Type1.class));
typeAdaptersDelegatedByValueMap.put("type2", gson.getAdapter(generator.standard.polymorphism.Type2.class));
typeAdaptersDelegatedByClassMap.put(generator.standard.polymorphism.Type2.class, gson.getAdapter(generator.standard.polymorphism.Type2.class));
}
@Override
public Type read(JsonReader in) throws IOException {
JsonElement jsonElement = Streams.parse(in);
JsonElement typeValueJsonElement = jsonElement.getAsJsonObject().remove("type");
if (typeValueJsonElement == null) {
throw new JsonParseException("cannot deserialize generator.standard.polymorphism.Type because it does not define a field named 'type'");
}
java.lang.String value = typeValueJsonElement.getAsString();
TypeAdapter<? extends generator.standard.polymorphism.Type> delegate = typeAdaptersDelegatedByValueMap.get(value);
if (delegate == null) {
return null;
}
generator.standard.polymorphism.Type result = delegate.fromJsonTree(jsonElement);
return result;
}
@Override
public void write(JsonWriter out, Type value) throws IOException {
if (value == null) {
out.nullValue();
return;
}
TypeAdapter delegate = typeAdaptersDelegatedByClassMap.get(value.getClass());
delegate.write(out, value);
}
}
} | [
"lachlandevelopment@gmail.com"
] | lachlandevelopment@gmail.com |
76d54dd75426f2f351c03e4214c9274fcda631ee | 0a8cbc76e5d984f9a0b6b54fb6a5ff7dd93f572d | /explicacoes/ForComBreak.java | 1db145e9fdd4bbb50270d59aef952db88dc98f5e | [] | no_license | WesleydeOz/PraticandoJava-pdfComExercicios_2007 | 57ac4b95c5869aa834ce99120dacef4faf5e30da | 3d4eaa9e5ddb9cf859e18643541b017ea242b8a7 | refs/heads/main | 2023-06-17T23:39:59.896138 | 2021-06-17T19:09:31 | 2021-06-17T19:09:31 | 376,662,021 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 221 | java | package explicacoes;
public class ForComBreak {
public static void main(String[] args) {
int i = 0;
for(i=0; i<=10; i++) {
if(i == 7) {
break;
}
System.out.println(i);
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
23f0ba2f15d7ac06dfcae63b589c2488a3943bc2 | 0f11a23826e00ae1599bbd6f039fb644b8001ba2 | /src/main/java/com/hsrm/business/concretes/JobSeekerManager.java | 6cd6f22d9d7c5253f67773b1d42b0786b88124df | [] | no_license | ShahinRashidbayli/hrms | 39b30e60df553f6d3fd27c5570cc29bc9fda14a3 | 6a572239b0cd997da499d6fac24b67f0178b52ce | refs/heads/master | 2023-06-18T23:14:35.032022 | 2021-07-17T21:32:07 | 2021-07-17T21:32:07 | 386,079,436 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 812 | java | package com.hsrm.business.concretes;
import com.hsrm.business.abstracts.JobSeekerService;
import com.hsrm.core.utilities.results.Result;
import com.hsrm.core.utilities.results.SuccessResult;
import com.hsrm.dataAccess.abstracts.JobSeekerDao;
import com.hsrm.entities.concretes.JobSeeker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class JobSeekerManager implements JobSeekerService {
private JobSeekerDao jobSeekerDao;
@Autowired
public JobSeekerManager(JobSeekerDao jobSeekerDao) {
super();
this.jobSeekerDao = jobSeekerDao;
}
@Override
public Result add(JobSeeker jobSeeker) {
this.jobSeekerDao.save(jobSeeker);
return new SuccessResult("JobSeeker added.");
}
}
| [
"reshidshahin@outlook.com"
] | reshidshahin@outlook.com |
412f5e30c919cb2589caddec487767af8dc12495 | 7b3aad782107025658d340f52cf6d51a8373a8b8 | /src/com/jeeplus/modules/abc/lantern/web/LanternController.java | 6473fba2a16ac7fa180fee0b2b414dee06f1ce34 | [] | no_license | Qifeng-Wu/Showhand | be50c1ba7001394cc1475f6e0dfa2503c07c22f4 | 74108df65d07d317d877b30a9b3728d8c03777a2 | refs/heads/master | 2023-04-05T08:02:37.351805 | 2021-04-11T12:36:57 | 2021-04-11T12:36:57 | 312,972,050 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,854 | java | package com.jeeplus.modules.abc.lantern.web;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
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.servlet.mvc.support.RedirectAttributes;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.abc.common.entity.ActivityTime;
import com.jeeplus.modules.abc.common.service.ActivityTimeService;
import com.jeeplus.modules.abc.lantern.entity.Lantern;
import com.jeeplus.modules.abc.lantern.service.LanternService;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
/**
* 元宵节猜灯谜Controller
* @author stephen
* @version 2021-2-22
*/
@Controller
@RequestMapping(value = "${adminPath}/abc/lantern")
public class LanternController extends BaseController {
@Autowired
private LanternService lanternService;
@Autowired
private ActivityTimeService activityTimeService;
@ModelAttribute
public Lantern get(@RequestParam(required=false) String id) {
Lantern entity = null;
if (StringUtils.isNotBlank(id)){
entity = lanternService.get(id);
}
if (entity == null){
entity = new Lantern();
}
return entity;
}
/**
* 列表页面
*/
@RequiresPermissions("abc:lantern:list")
@RequestMapping(value = {"list", ""})
public String list(@ModelAttribute("lantern")Lantern lantern, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Lantern> page = lanternService.findPage(new Page<Lantern>(request, response), lantern);
model.addAttribute("page", page);
return "modules/abc/lantern/lanternList";
}
/**
* 查看,增加,编辑表单页面
*/
@RequestMapping(value = "form")
public String form(Lantern lantern, Model model) {
model.addAttribute("lantern", lantern);
return "modules/abc/lantern/lanternForm";
}
/**
* 保存
*/
@RequestMapping(value = "save")
public String save(Lantern lantern, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, lantern)){
return form(lantern, model);
}
if(lantern.getOpenId()==null) {
lantern.setCreateTime(new Date());
}
lantern.setUpdateTime(new Date());
lanternService.customSave(lantern);
addMessage(redirectAttributes, "保存成功");
return "redirect:"+Global.getAdminPath()+"/abc/lantern/?repage";
}
/**
* 删除
*/
@RequestMapping(value = "delete")
public String delete(Lantern lantern, RedirectAttributes redirectAttributes) {
lanternService.delete(lantern);
addMessage(redirectAttributes, "删除成功");
return "redirect:"+Global.getAdminPath()+"/abc/lantern/?repage";
}
/**
* 批量删除
*/
@RequestMapping(value = "deleteAll")
public String deleteAll(String ids, RedirectAttributes redirectAttributes) {
String idArray[] =ids.split(",");
for(String id : idArray){
lanternService.delete(lanternService.get(id));
}
addMessage(redirectAttributes, "批量删除成功");
return "redirect:"+Global.getAdminPath()+"/abc/lantern/?repage";
}
/**
* 导出excel文件
*/
@RequestMapping(value = "export", method=RequestMethod.POST)
public String exporQisile(Lantern lantern, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes, String ids) {
try {
String fileName = "元宵节猜灯谜"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<Lantern> page = new Page<>();
if (StringUtils.isNotBlank(ids)) {
String idArray[] = ids.split(",");
List<Lantern> list = new ArrayList<>();
for (String id : idArray) {
Lantern Farm = lanternService.get(id);
list.add(Farm);
}
page.setList(list);
} else {
lantern.setStatus(2);
lantern.setFilter(1);
page = lanternService.findPage(new Page<Lantern>(request, response, -1), lantern);
}
new ExportExcel("元宵节猜灯谜", Lantern.class).setDataList(page.getList()).write(response, fileName).dispose();
return null;
} catch (Exception e) {
addMessage(redirectAttributes, "导出元宵节猜灯谜信息失败!失败信息:"+e.getMessage());
}
return "redirect:"+Global.getAdminPath()+"/abc/lantern/?repage";
}
/**
* 跳转活动时间设置页面
*/
@RequestMapping(value = "activityTime")
public String activityTime(ActivityTime activityTime, Model model) {
activityTime.setType(1);
List<ActivityTime> list = activityTimeService.findList(activityTime);
if(list!=null && list.size()>0) {
activityTime = list.get(0);
}
model.addAttribute("activityTime", activityTime);
return "modules/abc/lantern/activityTimeForm";
}
/**
* 保存活动时间
*/
@RequestMapping(value = "activityTimeSave")
public String activityTimeSave(ActivityTime activityTime, HttpServletRequest request, RedirectAttributes redirectAttributes) {
activityTime.setType(1);
activityTimeService.customSave(activityTime);
addMessage(redirectAttributes, "活动时间设置成功");
return "redirect:"+Global.getAdminPath()+"/abc/lantern/?repage";
}
} | [
"215046999@qq.com"
] | 215046999@qq.com |
d711d977a4f081bf850f385d91d74010bd469fd4 | ca992e8df8bdb3a75b02284f8fca8db5a0a64311 | /bos_management/src/main/java/cn/itcast/bos/dao/RoleRepository.java | db0e1617a36bcaaa372fdf5f3a5dd763f16a9ad6 | [] | no_license | chenxup/bos | d992e6b2aa2ade9cf24279f36c4174df06cb7726 | c0a81b746b902f5db66add91029956279b2670e0 | refs/heads/master | 2021-07-08T14:27:26.032566 | 2017-10-06T08:33:04 | 2017-10-06T08:33:04 | 103,370,416 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 504 | java | package cn.itcast.bos.dao;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import cn.itcast.bos.domain.system.Role;
public interface RoleRepository extends JpaRepository<Role,Integer>,JpaSpecificationExecutor<Role> {
@Query("from Role r inner join fetch r.users u where u.id=?")
List<Role> findByUser(Integer id);
}
| [
"123"
] | 123 |
83ffd8d27a324e37b28de72cb1681b98b4697aef | dc0687deb615a6a1fa18edef08dd136a9a9023dc | /src/main/java/br/com/casadocodigo/loja/controllers/CarrinhoComprasController.java | 583bc98fe8255adb974fa8ae7cfb05188e74e8a7 | [] | no_license | EduardoSantosGit/casadocodigo-java | 6908e2fa29132b8d71e8ac427cde16a7c3748b10 | c24adc645b07572765722aa9517b40ea51c1e7d3 | refs/heads/master | 2021-01-18T20:25:40.068541 | 2017-03-26T22:00:35 | 2017-03-26T22:00:35 | 85,506,408 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,783 | java | package br.com.casadocodigo.loja.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.ModelAndView;
import br.com.casadocodigo.loja.daos.ProdutoDAO;
import br.com.casadocodigo.loja.model.CarrinhoCompras;
import br.com.casadocodigo.loja.model.CarrinhoItem;
import br.com.casadocodigo.loja.model.Produto;
import br.com.casadocodigo.loja.model.TipoPreco;
@Controller
@RequestMapping("/carrinho")
@Scope(value=WebApplicationContext.SCOPE_REQUEST) //ATENDE UM REQUEST E MORRE
public class CarrinhoComprasController {
@Autowired
private ProdutoDAO produtoDAO;
@Autowired
private CarrinhoCompras carrinho;
@RequestMapping("/add")
public ModelAndView add(Integer produtoId, TipoPreco tipoPreco){
ModelAndView modelAndView = new ModelAndView("redirect:/carrinho");
CarrinhoItem carrinhoItem = criaItem(produtoId,tipoPreco);
carrinho.add(carrinhoItem);
return modelAndView;
}
@RequestMapping(method=RequestMethod.GET)
public ModelAndView itens(){
return new ModelAndView("carrinho/itens");
}
private CarrinhoItem criaItem(Integer produtoId, TipoPreco tipoPreco) {
Produto produto = produtoDAO.find(produtoId);
CarrinhoItem carrinhoItem = new CarrinhoItem(produto,tipoPreco);
return carrinhoItem;
}
@RequestMapping("/remover")
public ModelAndView remover(Integer produtoId,TipoPreco tipoPreco){
carrinho.remover(produtoId,tipoPreco);
return new ModelAndView("redirect:/carrinho");
}
}
| [
"eduardosantos058@gmail.com"
] | eduardosantos058@gmail.com |
051723e0550373eb7c74801607ea26c8fc0428a2 | 95e944448000c08dd3d6915abb468767c9f29d3c | /sources/com/p280ss/android/ugc/aweme/commerce/OfflineInfo.java | 9c8e7da555b778e55061a238e1b4962358678961 | [] | no_license | xrealm/tiktok-src | 261b1faaf7b39d64bb7cb4106dc1a35963bd6868 | 90f305b5f981d39cfb313d75ab231326c9fca597 | refs/heads/master | 2022-11-12T06:43:07.401661 | 2020-07-04T20:21:12 | 2020-07-04T20:21:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 865 | java | package com.p280ss.android.ugc.aweme.commerce;
import com.google.gson.p276a.C6593c;
import java.io.Serializable;
/* renamed from: com.ss.android.ugc.aweme.commerce.OfflineInfo */
public class OfflineInfo implements Serializable {
@C6593c(mo15949a = "action")
public String action;
@C6593c(mo15949a = "offline_info_type")
public int offlineInfoType;
@C6593c(mo15949a = "text")
public String text;
public String getAction() {
return this.action;
}
public int getOfflineInfoType() {
return this.offlineInfoType;
}
public String getText() {
return this.text;
}
public void setAction(String str) {
this.action = str;
}
public void setOfflineInfoType(int i) {
this.offlineInfoType = i;
}
public void setText(String str) {
this.text = str;
}
}
| [
"65450641+Xyzdesk@users.noreply.github.com"
] | 65450641+Xyzdesk@users.noreply.github.com |
4fc5f351c03aba32e362745086da821385f2e2e3 | 807ecdfc994cc49a7812b78a3233f55bb5bfa79f | /ms-feign-wage-determine-service/src/main/java/com/bilqu/wage/determine/service/WageCalculator.java | 6ffedd858deb911995c118345ae8d78435c7b5db | [] | no_license | vimalraj84/proj-spring-cloud-netflix | 373c52bea0751c110946086d170d08b2864d27b2 | 4674ec1a2becf5fcb8351dff9fb10a4868d73955 | refs/heads/master | 2021-08-02T21:02:32.812613 | 2021-07-22T19:43:10 | 2021-07-22T19:43:10 | 181,697,497 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 975 | java | package com.bilqu.wage.determine.service;
import java.math.BigDecimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import com.bilqu.wage.determine.bo.EmpPayroll;
import com.bilqu.wage.determine.proxy.WageServiceProxy;
@RestController
public class WageCalculator {
@Autowired
private WageServiceProxy wageServiceProxy;
@GetMapping(path = "/calcWage/roll/{roll}/hours/{hours}")
public EmpPayroll calculateWages(@PathVariable ("roll") String roll, @PathVariable("hours") int hours) {
EmpPayroll wageServiceResponse = wageServiceProxy.getWageByRoll(roll) ;
System.out.format("wageServiceResponse \n %s \n" ,wageServiceResponse);
wageServiceResponse.setTotalPay(new BigDecimal(wageServiceResponse.getWage() * hours));
return wageServiceResponse;
}
}
| [
"vkarunakaran@deloitte.com"
] | vkarunakaran@deloitte.com |
35dd07a60f6dc87b92f75681c4c574e602d0227e | f30eacb34c01718bb3ad9324c601080676876722 | /src/com/spring/audience/Audience.java | 7a9aeefd32947a504f514311ab94eb6bee9c71b3 | [] | no_license | turnon/Spring2 | 1fbcee50f7248e0a9092725f3ece501f01d4ea98 | 4975dece4c67d0eddc8acc213044a3754bfb8082 | refs/heads/master | 2021-01-19T17:55:52.283168 | 2014-10-08T01:46:54 | 2014-10-08T01:46:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 596 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.spring.audience;
/**
*
* @author Administrator
*/
public class Audience {
public void takeSeats() {
System.out.println("..Audience take Seats");
}
public void turnOffCellPhone() {
System.out.println("..Audience turn Off CellPhone");
}
public void applaud() {
System.out.println("..Audience applaud");
}
public void demandRefund() {
System.out.println("..Audience demand Refund");
}
}
| [
"Administrator@china"
] | Administrator@china |
e8c4f7e6d7f3ce33772e4ca8aeeb98c84979d676 | 59e4005bbf9392f19c8b8a9c4d4b516d8d1a4cdc | /src/main/java/com/team32/ong/model/Testimonial.java | ee6f2f1f696712d89bb5701b22feb13f94b4e574 | [] | no_license | sol-dev/ONG-Somos-Mas | 1b8033cb1a929a90bdc43805ec28371aa6582f69 | ef82763a195e7afcb10f7f79a3f32b9e1feaaa88 | refs/heads/master | 2023-06-16T18:43:49.313346 | 2021-07-08T15:32:00 | 2021-07-08T15:32:00 | 381,507,090 | 0 | 0 | null | 2021-07-08T15:32:01 | 2021-06-29T22:00:58 | null | UTF-8 | Java | false | false | 1,251 | java | package com.team32.ong.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table (name = "Testimonials")
@SQLDelete(sql = "UPDATE testimonials SET deleted=true WHERE id = ?")
@Where(clause = "deleted = false")
public class Testimonial{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotEmpty(message = "Name may not be empty")
@Column(name="name", nullable = false)
private String name;
@NotEmpty(message = "Image may not be empty")
@Column(name="image")
private String image;
@Column(name="content")
private String content;
@CreationTimestamp
@Column(name = "created_date")
private LocalDateTime createdDate;
@UpdateTimestamp
@Column(name = "last_modified_date")
private LocalDateTime modifiedDate;
@Column(name="deleted")
private Boolean deleted;
}
| [
"lomatiasleandro@gmail.com"
] | lomatiasleandro@gmail.com |
7d8a8970467adb58f811e51040ad765ef7e2b9d7 | cad743b8beca98bd9368d083d2e8d5460be246b5 | /android/liplibrary/src/main/java/com/logitech/lip/account/AccountTokenTracker.java | 064f5b79e8c009e7c5939d26c0e6d0385bfe9862 | [] | no_license | schavaLogi/CECTest | 6b273551f69a26cfd70c937c7b12128c8af679a3 | a61b8fb6761b9c02c94d83725943ff2634595f79 | refs/heads/master | 2021-08-11T20:59:02.412601 | 2017-11-14T04:36:27 | 2017-11-14T04:36:27 | 109,939,190 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 3,006 | java | /*
* Copyright (c) 2015 Logitech, Inc. All Rights Reserved
*
* This program is a trade secret of LOGITECH, and it is not to be reproduced,
* published, disclosed to others, copied, adapted, distributed or displayed
* without the prior written authorization of LOGITECH.
*
* Licensee agrees to attach or embed this notice on all copies of the program
* including partial copies or modified versions thereof.
*/
package com.logitech.lip.account;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import com.logitech.lip.LIPSdk;
import com.logitech.lip.account.model.AccountToken;
/**
* This class can be extended to receive notifications of account token changes The {@link
* #stopTracking()} method should be called in the onDestroy() method of the receiving Activity or
* Fragment.
*/
public abstract class AccountTokenTracker {
public static final String ACTION_CURRENT_ACCOUNT_TOKEN_CHANGED =
"com.logitech.lipsdk.ACTION_CURRENT_ACCOUNT_TOKEN_CHANGED";
/*key to retrieve access token info in intent bundle */
static final String EXTRA_ACCOUNT_ACCESS_TOKEN =
"com.logitech.lipsdk.EXTRA_ACCOUNT_TOKEN";
private final BroadcastReceiver receiver;
private final LocalBroadcastManager broadcastManager;
private boolean isTracking = false;
protected abstract void onAccountTokenChanged(AccountToken accountToken);
public AccountTokenTracker() {
LIPSdk.isInitialized();
this.receiver = new CurrentAccessTokenBroadcastReceiver();
this.broadcastManager = LocalBroadcastManager.getInstance(
LIPSdk.getContext());
// startTracking();
}
/**
* Starts tracking the current access token
*/
public void startTracking() {
if (isTracking) {
return;
}
addBroadcastReceiver();
isTracking = true;
}
/**
* Stops tracking the current Account token.
*/
public void stopTracking() {
if (!isTracking) {
return;
}
broadcastManager.unregisterReceiver(receiver);
isTracking = false;
}
public boolean isTracking() {
return isTracking;
}
private class CurrentAccessTokenBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_CURRENT_ACCOUNT_TOKEN_CHANGED.equals(intent.getAction())) {
AccountToken token = intent.getParcelableExtra(AccountTokenTracker.EXTRA_ACCOUNT_ACCESS_TOKEN);
onAccountTokenChanged(token);
}
}
}
private void addBroadcastReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_CURRENT_ACCOUNT_TOKEN_CHANGED);
broadcastManager.registerReceiver(receiver, filter);
}
}
| [
"schava@logitech.com"
] | schava@logitech.com |
73a7f2ce6d0d064533abbab5d1bacb8f5eeacf94 | 4273a5f535c3f03df92ec7615044ccdd5d866e8b | /android/src/main/java/com/pedro/builder/rtsp/RtspBuilderSurfaceMode.java | 96e8e10dfb4d76b7bebd6a4b3aa2037aea665efc | [] | no_license | orenk86/react-native-videocore | 633998540d56a6a0b9c3315cebdd7e1f081c6c6e | 4cb8dddef8ade71e045dca6caa7bf325f9817cae | refs/heads/master | 2021-01-20T01:42:58.334180 | 2017-10-09T14:00:01 | 2017-10-09T14:00:01 | 101,297,550 | 0 | 1 | null | 2017-10-09T14:00:02 | 2017-08-24T13:25:49 | Objective-C | UTF-8 | Java | false | false | 2,334 | java | package com.pedro.builder.rtsp;
import android.content.Context;
import android.media.MediaCodec;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.SurfaceView;
import com.pedro.builder.base.BuilderSurfaceModeBase;
import com.pedro.rtsp.rtsp.Protocol;
import com.pedro.rtsp.rtsp.RtspClient;
import com.pedro.rtsp.utils.ConnectCheckerRtsp;
import java.nio.ByteBuffer;
/**
* Created by pedro on 4/06/17.
* This builder is under test, rotation only work with hardware because use encoding surface mode.
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class RtspBuilderSurfaceMode extends BuilderSurfaceModeBase {
private RtspClient rtspClient;
public RtspBuilderSurfaceMode(SurfaceView surfaceView, Protocol protocol,
ConnectCheckerRtsp connectCheckerRtsp) {
super(surfaceView, surfaceView.getContext());
rtspClient = new RtspClient(connectCheckerRtsp, protocol);
}
public RtspBuilderSurfaceMode(Context context, Protocol protocol, ConnectCheckerRtsp connectCheckerRtsp) {
super(context);
rtspClient = new RtspClient(connectCheckerRtsp, protocol);
}
@Override
public void setAuthorization(String user, String password) {
rtspClient.setAuthorization(user, password);
}
@Override
protected void prepareAudioRtp(boolean isStereo, int sampleRate) {
rtspClient.setIsStereo(isStereo);
rtspClient.setSampleRate(sampleRate);
}
@Override
public boolean prepareAudio() {
microphoneManager.setSampleRate(16000);
audioEncoder.setSampleRate(16000);
microphoneManager.createMicrophone();
rtspClient.setSampleRate(microphoneManager.getSampleRate());
return audioEncoder.prepareAudioEncoder();
}
@Override
protected void startStreamRtp(String url) {
rtspClient.setUrl(url);
}
@Override
protected void stopStreamRtp() {
rtspClient.disconnect();
}
@Override
protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) {
rtspClient.sendAudio(aacBuffer, info);
}
@Override
protected void onSPSandPPSRtp(ByteBuffer sps, ByteBuffer pps) {
rtspClient.setSPSandPPS(sps, pps);
rtspClient.connect();
}
@Override
protected void getH264DataRtp(ByteBuffer h264Buffer, MediaCodec.BufferInfo info) {
rtspClient.sendVideo(h264Buffer, info);
}
}
| [
"oren@panda-os.com"
] | oren@panda-os.com |
8852136c50589e3de7fd85c2ef31aa5530dbafc3 | 231a828518021345de448c47c31f3b4c11333d0e | /src/pdf/bouncycastle/asn1/DEROutputStream.java | 028b9bf6aa1d171d562309d50fb26a3fd5ca6f09 | [] | no_license | Dynamit88/PDFBox-Java | f39b96b25f85271efbb3a9135cf6a15591dec678 | 480a576bc97fc52299e1e869bb80a1aeade67502 | refs/heads/master | 2020-05-24T14:58:29.287880 | 2019-05-18T04:25:21 | 2019-05-18T04:25:21 | 187,312,933 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package pdf.bouncycastle.asn1;
import java.io.IOException;
import java.io.OutputStream;
/**
* Stream that outputs encoding based on distinguished encoding rules.
*/
public class DEROutputStream
extends ASN1OutputStream
{
public DEROutputStream(
OutputStream os)
{
super(os);
}
public void writeObject(
ASN1Encodable obj)
throws IOException
{
if (obj != null)
{
obj.toASN1Primitive().toDERObject().encode(this);
}
else
{
throw new IOException("null object detected");
}
}
ASN1OutputStream getDERSubStream()
{
return this;
}
ASN1OutputStream getDLSubStream()
{
return this;
}
}
| [
"vtuse@mail.ru"
] | vtuse@mail.ru |
ee43326a93f7e61517fa9b067b6da2e9336658dc | a785ca1b4f00eb44248cd5f4e40224d465d33f02 | /Bank2.java | 0fc03dd0c3dd72b950c4159e42732d2ec71226aa | [] | no_license | WillIsenhour/CSC-143 | 7fc41946eee8c0108cff93e807aa8f97ebbcd4dc | 55a3bbf9203297d8764645783f2e28b33796e772 | refs/heads/master | 2020-04-24T23:33:23.567800 | 2014-11-24T23:11:15 | 2014-11-24T23:11:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,808 | java | import java.util.*;
import java.io.*;
public class Bank2
{
public static void main(String[] args) throws FileNotFoundException
{
double total = fileRead();
System.out.println("Total:\t " + total);
}//end main
public static double fileRead() throws FileNotFoundException
{
File file = new File("AcctInfo.txt");
Scanner inputFile = new Scanner(file);
PrintWriter outputFile = new PrintWriter("AcctSummary2.txt");
double total;
while(inputFile.hasNext())
{
String acctNumber = inputFile.nextLine();
String acctType = inputFile.nextLine();
String custName = inputFile.nextLine();
String custType = inputFile.nextLine();
String balance_str = inputFile.nextLine();
String space = inputFile.nextLine();
outputFile.println("Account Number:\t " + acctNumber);
outputFile.println("Account Type:\t " + acctType);
outputFile.println("Customer Name:\t " + custName);
outputFile.println("Customer Type:\t " + custType);
//Converts balance_str into a number
double balance = Double.parseDouble(balance_str);
//Calls this crazy new thing
double monthlyFee = calcMonthlyFee(acctType, custType, balance);
outputFile.printf("Account Balance: $%.2f", balance);
outputFile.println();
outputFile.printf("Monthly Fee: $%.2f", monthlyFee);
//Adds a space after each account block because DAYUM
outputFile.println();
outputFile.println();
total = total + balance;
}//end while
return total;
}//end fileRead
public static double calcMonthlyFee(String acctType, String custType, double balance)
{
double monthlyFee;
if (acctType.equals("Savings"))
{
monthlyFee = 0.0;
}
else
{
if (custType.equals("Value"))
{
if (balance >= 1500)
{
monthlyFee = 0.0;
}
else
{
monthlyFee = 5.0;
}
}
else if (custType.equals("Advantage"))
{
if (balance >= 1000)
{
monthlyFee = 0.0;
}
else
{
monthlyFee = 10.0;
}
}
else
{
if (balance >= 25000)
{
monthlyFee = 0.0;
}
else
{
monthlyFee = 30.0;
}
}
}
return monthlyFee;
}//end calcMonthlyFee
}//end class | [
"wisenho1@LT5132-04.lab.cpcc.edu"
] | wisenho1@LT5132-04.lab.cpcc.edu |
465bc9962a7d6b2d5f4392dfd7fe8b646e1ab218 | 59caad8d37d857e0b19925d68f873f0f96d721ee | /app/src/main/java/com/example/coffeebrewapp/Data/ProfileData/ProfileData.java | 34de0afbbf14cd14c41badd8b1b7cb9d9ead608d | [] | no_license | Crisiluluman/CoffeeBrewApp | 521853898658490cdead4f4bd3ae4fd993569645 | 07b6982771d704a52d6df96ec3a70df8cf9c8827 | refs/heads/main | 2023-05-02T19:21:09.376796 | 2021-05-20T21:29:08 | 2021-05-20T21:29:08 | 356,726,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 500 | java | package com.example.coffeebrewapp.Data.ProfileData;
public class ProfileData {
private String username;
private String imageSource;
public ProfileData() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getImageSource() {
return imageSource;
}
public void setImageSource(String imageURL) {
this.imageSource = imageURL;
}
}
| [
"kawazu-maner@hotmail.com"
] | kawazu-maner@hotmail.com |
fd1a11f06d3d4bda5609f3f6d7875716b9fe67c4 | 22dabd65c00bfcdd797b93c3f03860cfa6192779 | /pharmacy-manager/manager-pojo/src/main/java/com/yaojie/pojo/ItemCat.java | ec115a6e85e78625f6b188609d073a8c18d83792 | [] | no_license | xiazecheng/pharmacy | 38568c9e200e243bb519ec4a0697fad29eed3fd2 | fd0037cca0683d5806379183aeee3610e6e3dc9b | refs/heads/master | 2020-12-30T12:37:13.815210 | 2017-05-16T02:18:31 | 2017-05-16T02:18:31 | 91,404,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,776 | java | package com.yaojie.pojo;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "tb_item_cat")
public class ItemCat extends BasePojo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Long parentId;
private String name;
private Integer status;
private Integer sortOrder;
private Boolean isParent;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSortOrder() {
return sortOrder;
}
public void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}
public Boolean getIsParent() {
return isParent;
}
public void setIsParent(Boolean isParent) {
this.isParent = isParent;
}
// 扩展字段,支持EasyUItree的显示,这样就可以避免再写一个第一版中的EasyuiTreeNode类,同时也省了第一版中
//在service中的一系列对easyuiTreeNode的处理
public String getText() {
return this.getName();
}
public String getState() {
return this.getIsParent() ? "closed" : "open";
}
}
| [
"madao@promote.cache-dns.local"
] | madao@promote.cache-dns.local |
e1e8249f3063b28b294debac1de8eaae84142afa | 5ba1eb0d4a3aca74098318ad136fb7cadcf0a2e8 | /server/src/main/java/com/spellbook/repository/DefaultRepository.java | 187261455b96e6f5fb054dd1435db9102fdd2738 | [] | no_license | akhramtsov/dnd-3.5e-spellbook | c306b98f448ff4496c8d309f999ca03cefb09b30 | 36309a44e8aa44fcf16e2b9c9c53835048919526 | refs/heads/master | 2020-09-22T00:56:21.374572 | 2020-01-10T13:16:10 | 2020-01-10T13:16:10 | 224,993,449 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,515 | java | package com.spellbook.repository;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Table;
import org.jooq.UpdatableRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.UUID;
@Component
public abstract class DefaultRepository<C, R extends UpdatableRecord<R>> {
@Autowired
private DSLContext dslContext;
protected abstract Table<R> getDaoTable();
protected abstract Field<UUID> getIdField();
protected abstract Class<C> getPogoClass();
protected DSLContext getContext() {
return this.dslContext;
}
protected R convertPojoToRecord(Object pojo) {
return this.dslContext.newRecord(getDaoTable(), pojo);
}
public List<C> findByIdsIntoPojos(List<UUID> idList) {
if (CollectionUtils.isEmpty(idList)) {
throw new IllegalArgumentException("Ids list must be set!");
}
return dslContext.selectFrom(getDaoTable())
.where(getIdField().in(idList))
.fetch()
.into(getPogoClass());
}
public List<C> findAll() {
return dslContext.selectFrom(getDaoTable())
.fetch()
.into(getPogoClass());
}
public void save(Object pojo) {
dslContext.insertInto(getDaoTable())
.set(convertPojoToRecord(pojo))
.execute();
}
}
| [
"hramtsov_a_i@mail.ru"
] | hramtsov_a_i@mail.ru |
8b0a905ef298feb3076c3b3553368e9b864c6dd0 | 4f08b887b554d9c5c95d92678f199fed8e27b49e | /interview-preparation-kit/warm-up-challenges/SalesByMatch.java | dce23f41e7724dcc227157f030b84e412c54f4b1 | [] | no_license | sifo/hackerrank | 5bcf44ab5fb99f4139986db1a1634165eb6666fe | a6f5452dc3eafe0ae9b8f0002321eedcc9b926bd | refs/heads/master | 2022-01-20T19:33:15.326330 | 2021-12-25T00:10:35 | 2021-12-25T00:10:35 | 113,945,344 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 432 | java | import java.util.Scanner;
public class SalesByMatch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] t = new int[100];
for(int i = 0; i < n; i++) {
t[sc.nextInt()-1]++;
}
int res = 0;
for(int i = 0; i < t.length; i++) {
res += t[i]/2;
}
System.out.println(res);
}
}
| [
"jean.vilver@gmail.com"
] | jean.vilver@gmail.com |
5d82522e7a7b82dcbeda407218f73c5d93bd327a | 1cb471f2e86e44a40ef568df25fe68397c16b816 | /src/main/java/com/shi/zookeeper/demo/watch/CallBackMonitor.java | 9c792811a67098b7a1b0a8f67390548f0a1ccebd | [] | no_license | Shihaahs/annie | c0f3a5decb389557bfce26f108a55631fd8b75e9 | 3a536a3cb155975f678200fd5387f22a3442e87a | refs/heads/master | 2022-12-25T11:42:49.257974 | 2020-04-07T03:30:52 | 2020-04-07T03:30:52 | 246,024,597 | 0 | 0 | null | 2022-12-14T20:39:58 | 2020-03-09T12:02:47 | FreeMarker | UTF-8 | Java | false | false | 2,840 | java | package com.shi.zookeeper.demo.watch;
import org.apache.zookeeper.AsyncCallback.StatCallback;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;
import java.util.Arrays;
import static org.apache.zookeeper.KeeperException.Code;
/**
* @Author: Wuer
* @email: syj@shushi.pro
* @Date: 2020/4/2 10:43 上午
*/
public class CallBackMonitor implements StatCallback {
private ZooKeeper zk;
private String zNode;
boolean dead;
private DataCallBackMonitor dataCallBackMonitor;
private byte[] preData;
public CallBackMonitor(ZooKeeper zk, String zNode, DataCallBackMonitor dataCallBackMonitor) {
this.zk = zk;
this.zNode = zNode;
this.dataCallBackMonitor = dataCallBackMonitor;
//zk上node创建监听事件
zk.exists(zNode, true, this, null);
}
/**
* 异步方法收到zk集群数据后回调触发
*/
@Override
public void processResult(int i, String s, Object o, Stat stat) {
boolean exists;
switch (i) {
case Code.Ok:
exists = true;
break;
case Code.NoNode:
exists = false;
break;
case Code.SessionExpired:
case Code.NoAuth:
dead = true;
dataCallBackMonitor.closing(i);
return;
default:
zk.exists(zNode, true, this, null);
return;
}
byte[] b = null;
if (exists) {
try {
b = zk.getData(zNode, false, null);
} catch (InterruptedException e) {
return;
} catch (KeeperException e) {
e.printStackTrace();
}
}
if ((null == b && b != preData) || (b != null && !Arrays.equals(preData, b))) {
dataCallBackMonitor.exists(b);
preData = b;
}
}
public void handle(WatchedEvent event) {
String path = event.getPath();
if (event.getType().equals(Watcher.Event.EventType.None)) {
switch (event.getState()) {
case SyncConnected:
break;
case Expired:
//zk 事件过期
dead = true;
dataCallBackMonitor.closing(KeeperException.Code.SESSIONEXPIRED.intValue());
break;
}
} else {
if (path != null && path.equals(zNode)) {
zk.exists(zNode, true, this, null);
}
}
}
public interface DataCallBackMonitor {
void exists(byte[] data);
void closing(int rc);
}
}
| [
"syj@shushi.pro"
] | syj@shushi.pro |
e08b4cf9f6768e53a67bcf9d0209eeebe6300d7c | 9b6a5c3eacb84f76c05e71572dc5c7bcbac69714 | /recorder/src/main/java/com/blogspot/tonyatkins/recorder/activity/RecordSoundActivity.java | be2c7c33d8e33be4da942d8246f43e9202704d32 | [] | no_license | deepakbaliga/BescomMeeting | 922d16db5e4fb6005878d018081ad1c59bd16ddc | dca0d4a0235a16ba84d3dcaf91459b9957111140 | refs/heads/master | 2021-01-01T04:12:02.992982 | 2016-05-26T07:59:41 | 2016-05-26T07:59:41 | 58,665,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,089 | java | /**
* Copyright 2013 Tony Atkins <duhrer@gmail.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Tony Atkins ''AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Tony Atkins OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
*/
package com.blogspot.tonyatkins.recorder.activity;
import java.io.File;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.blogspot.tonyatkins.recorder.Constants;
import com.blogspot.tonyatkins.recorder.InstrumentedRecorder;
import com.blogspot.tonyatkins.recorder.R;
import com.blogspot.tonyatkins.recorder.views.RecorderTimerView;
import com.blogspot.tonyatkins.recorder.views.VolumeBarGraphView;
public class RecordSoundActivity extends AppCompatActivity {
public final static int REQUEST_CODE = 777;
public final static int SOUND_SAVED = 766;
public final static int CANCELLED = 755;
private InstrumentedRecorder recorder = new InstrumentedRecorder();
private MediaPlayer mediaPlayer = new MediaPlayer();
private TextView recordingStatusText;
private ImageButton recordButton;
private ImageButton playButton;
private ImageButton stopButton;
private Button saveButton;
private Button cancelButton;
private String soundFilePath;
private String soundFileName = "new-file";
private Context context = this;
private Intent intent;
private LinearLayout recordingStatusButtonBlock;
static final String RECORDING_BUNDLE = "recordingBundle";
public static final String FILE_NAME_KEY = "record-sound-filename";
public static final String OUTPUT_DIR_KEY = "output-dir";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.record_sound);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Record Discussion");
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
intent = new Intent();
String soundDirectory = Constants.SOUND_DIRECTORY;
Bundle parentBundle = getIntent().getExtras();
if (parentBundle != null) {
// try to figure out the filename from the bundle
String bundleFilename = parentBundle.getString(FILE_NAME_KEY);
if (bundleFilename != null && bundleFilename.length() > 0) {
soundFileName = sanitizeFileName(bundleFilename);
}
String bundleOutputDir = parentBundle.getString(OUTPUT_DIR_KEY);
if (bundleOutputDir != null && bundleOutputDir.length() > 0) {
soundDirectory = bundleOutputDir;
}
}
File soundDir = new File(soundDirectory);
if (!soundDir.exists()) {
if (soundDir.mkdirs()) {
Log.d(Constants.TAG, "Created sound directory.");
}
else {
Log.e(Constants.TAG, "Unable to create sound directory.");
}
}
soundFilePath = soundDirectory + "/" + soundFileName + ".mp3";
// check to see if there's an existing file name and add a numeral until there's no conflict.
File soundFile = new File(soundFilePath);
if (soundFile.exists()) {
int suffix = 1;
while (soundFile.exists()) {
soundFile = new File(soundFilePath.replace(".mp3", "-" + suffix + ".mp3"));
suffix++;
}
soundFilePath = soundFile.getAbsolutePath();
}
// TODO: eventually, we'll need to manage the abandoned files and clean them up.
// Throw a warning and disable the "save" button if there's no mic
try {
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setOutputFile(soundFilePath);
}
catch (Exception e) {
Toast.makeText(this, "Sound recording is only possible on units with a microphone installed.", Toast.LENGTH_SHORT).show();
Log.e(getClass().toString(), "Error opening microphone:", e);
finish();
}
recordingStatusButtonBlock = (LinearLayout) findViewById(R.id.RecordingStatusButtonBlock);
recordingStatusButtonBlock.setVisibility(View.INVISIBLE);
recordingStatusText = (TextView) findViewById(R.id.RecordingStatusText);
recordingStatusText.setText("Press 'Record' to start recording.");
RecorderTimerView timerView = (RecorderTimerView) findViewById(R.id.timerView);
timerView.setRecorder(recorder);
VolumeBarGraphView volumeBarGraphView = (VolumeBarGraphView) findViewById(R.id.volumeBarGraphView);
volumeBarGraphView.setRecorder(recorder);
// Grab the handles of our buttons
playButton = (ImageButton) findViewById(R.id.play_button);
stopButton = (ImageButton) findViewById(R.id.stop_button);
recordButton = (ImageButton) findViewById(R.id.record_button);
recordButton.setOnClickListener(new StartRecordingListener());
saveButton = (Button) findViewById(R.id.edit_sound_save);
cancelButton = (Button) findViewById(R.id.edit_sound_cancel);
cancelButton.setOnClickListener(new CancelListener());
}
private String sanitizeFileName(String fileName) {
return fileName.toLowerCase().trim().replaceAll("[^a-z0-9]+", "-");
}
private class StartRecordingListener implements OnClickListener {
public void onClick(View v) {
recordingStatusButtonBlock.setVisibility(View.INVISIBLE);
// disable the play and save buttons
playButton.setOnClickListener(null);
saveButton.setOnClickListener(null);
recordingStatusText.setText("Recording...");
try {
v.setOnClickListener(new StopRecordingListener());
stopButton.setOnClickListener(new StopRecordingListener());
// make sure the file we're writing to exists
File file = new File(soundFilePath);
file.createNewFile();
recorder.prepare();
recorder.start();
} catch (Exception e) {
recordingStatusText.setText("Can't start recorder:" + e.getMessage());
Log.e(getClass().toString(), "Can't start recorder:", e);
}
}
}
private class StopRecordingListener implements OnClickListener {
public void onClick(View v) {
v.setOnClickListener(new StartRecordingListener());
stopButton.setOnClickListener(null);
try {
// stop the recording
recorder.stop();
recorder.release();
try {
// wire up the playback
mediaPlayer.setDataSource(soundFilePath);
mediaPlayer.prepare();
playButton.setOnClickListener(new PlayRecordingListener());
recordingStatusText.setText("Recorded " + mediaPlayer.getDuration()/1000d + " seconds of audio.'Play' to preview, 'Save' to finish, or 'Cancel' to exit.");
recordingStatusButtonBlock.setVisibility(View.VISIBLE);
} catch (Exception e) {
recordingStatusText.setText("Can't setup preview playback:" + e.getMessage());
Log.e(getClass().toString(), "Can't setup preview playback:", e);
}
} catch (Exception e) {
Toast.makeText(context, "No recording in progress to stop.", Toast.LENGTH_LONG).show();
Log.e(getClass().toString(), "No recording in progress to stop.", e);
}
saveButton.setOnClickListener(new SaveListener());
}
}
private class PlayRecordingListener implements OnClickListener {
public void onClick(View v) {
try {
// disable recording during playing
recordButton.setOnClickListener(null);
mediaPlayer.start();
recordingStatusText.setText("Previewing audio. Press 'Stop' to finish preview.");
// wire up the stop button
stopButton.setOnClickListener(new StopPlaybackListener());
// wire up the play button to stop if it's hit again
playButton.setOnClickListener(new StopPlaybackListener());
// Can't save until we're finished recording
saveButton.setOnClickListener(new StopPlaybackListener());
} catch (Exception e) {
Log.e(getClass().toString(), "Can't play recording:", e);
}
}
}
private class StopPlaybackListener implements OnClickListener {
public void onClick(View v) {
mediaPlayer.stop();
mediaPlayer.release();
Toast.makeText(context, "Stopped playback of preview.", Toast.LENGTH_LONG).show();
// the stop button should no longer be clickable
stopButton.setOnClickListener(null);
// the play button should play again
playButton.setOnClickListener(new PlayRecordingListener());
// reenable recording after playback
recordButton.setOnClickListener(new StartRecordingListener());
// wire up the save button now that we have content
saveButton.setOnClickListener(new SaveListener());
}
}
private class CancelListener implements OnClickListener {
public void onClick(View arg0) {
setResult(CANCELLED);
finish();
}
}
private class SaveListener implements OnClickListener {
public void onClick(View arg0) {
Intent returnedIntent = new Intent();
File soundFile = new File(soundFilePath);
if (soundFile.exists() && soundFile.length() > 0) {
Uri uri = Uri.fromFile(soundFile);
returnedIntent.setData(uri);
}
setResult(Activity.RESULT_OK,returnedIntent);
finish();
}
}
@Override
public void finish() {
recorder.release();
mediaPlayer.release();
super.finish();
}
}
| [
"deepak.baliga9@gmail.com"
] | deepak.baliga9@gmail.com |
815f4e01d3aa42cd989e81bc7236954a3ad8aa4f | f538b56104c45e04f70ef3473a971d4a67e1b089 | /client/java/netxms-client/src/main/java/org/netxms/client/objecttools/ObjectToolDetails.java | fc73bc6169315d7b2a580efd2aa4605880e7589f | [] | no_license | phongtran0715/SpiderClient | 85d5d0559c6af0393cd058c25584074d80f8df9a | fdc264a85b7ff52c5dc2b6bb3cc83da62aad2aff | refs/heads/master | 2020-03-20T20:07:12.075655 | 2018-08-10T08:37:10 | 2018-08-10T08:37:10 | 137,671,006 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 8,751 | java | /**
* NetXMS - open source network management system
* Copyright (C) 2003-2010 Victor Kirhenshtein
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.netxms.client.objecttools;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.netxms.base.Logger;
import org.netxms.base.NXCPCodes;
import org.netxms.base.NXCPMessage;
import org.netxms.client.ObjectMenuFilter;
/**
* Detailed information about object tool
*
*/
public class ObjectToolDetails extends ObjectTool {
private boolean modified;
private List<Long> accessList;
private List<ObjectToolTableColumn> columns;
/**
* Create new tool object
*
* @param toolId
* tool id
* @param type
* tool type
* @param name
* tool name
*/
public ObjectToolDetails(long toolId, int type, String name) {
modified = false;
this.id = toolId;
this.type = type;
this.name = name;
data = "";
flags = 0;
description = "";
filter = new ObjectMenuFilter();
confirmationText = "";
accessList = new ArrayList<Long>(0);
columns = new ArrayList<ObjectToolTableColumn>(0);
commandName = "";
commandShortName = "";
imageData = null;
inputFields = new HashMap<String, InputField>();
createDisplayName();
}
/**
* Create object tool from NXCP message containing detailed tool
* information. Intended to be called only by NXCSession methods.
*
* @param msg
* NXCP message
*/
public ObjectToolDetails(NXCPMessage msg) {
modified = false;
id = msg.getFieldAsInt64(NXCPCodes.VID_TOOL_ID);
name = msg.getFieldAsString(NXCPCodes.VID_NAME);
type = msg.getFieldAsInt32(NXCPCodes.VID_TOOL_TYPE);
data = msg.getFieldAsString(NXCPCodes.VID_TOOL_DATA);
flags = msg.getFieldAsInt32(NXCPCodes.VID_FLAGS);
description = msg.getFieldAsString(NXCPCodes.VID_DESCRIPTION);
String filterData = msg.getFieldAsString(NXCPCodes.VID_TOOL_FILTER);
confirmationText = msg
.getFieldAsString(NXCPCodes.VID_CONFIRMATION_TEXT);
commandName = msg.getFieldAsString(NXCPCodes.VID_COMMAND_NAME);
commandShortName = msg
.getFieldAsString(NXCPCodes.VID_COMMAND_SHORT_NAME);
imageData = msg.getFieldAsBinary(NXCPCodes.VID_IMAGE_DATA);
try {
filter = ObjectMenuFilter.createFromXml(filterData);
} catch (Exception e) {
filter = new ObjectMenuFilter();
Logger.debug("ObjectToolDetails.ObjectToolDetails",
"Failed to convert object tool filter to string");
}
Long[] acl = msg.getFieldAsUInt32ArrayEx(NXCPCodes.VID_ACL);
accessList = (acl != null) ? new ArrayList<Long>(Arrays.asList(acl))
: new ArrayList<Long>(0);
int count = msg.getFieldAsInt32(NXCPCodes.VID_NUM_COLUMNS);
columns = new ArrayList<ObjectToolTableColumn>(count);
long varId = NXCPCodes.VID_COLUMN_INFO_BASE;
for (int i = 0; i < count; i++) {
columns.add(new ObjectToolTableColumn(msg, varId));
varId += 4;
}
count = msg.getFieldAsInt32(NXCPCodes.VID_NUM_FIELDS);
inputFields = new HashMap<String, InputField>(count);
long fieldId = NXCPCodes.VID_FIELD_LIST_BASE;
for (int i = 0; i < count; i++) {
InputField f = new InputField(msg, fieldId);
inputFields.put(f.getName(), f);
fieldId += 10;
}
if ((type == TYPE_ACTION) || (type == TYPE_FILE_DOWNLOAD)
|| (type == TYPE_LOCAL_COMMAND)
|| (type == TYPE_SERVER_COMMAND) || (type == TYPE_URL)) {
validateInputFields();
}
createDisplayName();
}
/**
* Fill NXCP message with tool's data.
*
* @param msg
* NXCP message
*/
public void fillMessage(NXCPMessage msg) {
msg.setFieldInt32(NXCPCodes.VID_TOOL_ID, (int) id);
msg.setField(NXCPCodes.VID_NAME, name);
msg.setField(NXCPCodes.VID_DESCRIPTION, description);
msg.setField(NXCPCodes.VID_TOOL_FILTER, filter.createXml());
msg.setField(NXCPCodes.VID_CONFIRMATION_TEXT, confirmationText);
msg.setField(NXCPCodes.VID_TOOL_DATA, data);
msg.setFieldInt16(NXCPCodes.VID_TOOL_TYPE, type);
msg.setFieldInt32(NXCPCodes.VID_FLAGS, flags);
msg.setField(NXCPCodes.VID_COMMAND_NAME, commandName);
msg.setField(NXCPCodes.VID_COMMAND_SHORT_NAME, commandShortName);
if (imageData != null)
msg.setField(NXCPCodes.VID_IMAGE_DATA, imageData);
msg.setFieldInt32(NXCPCodes.VID_ACL_SIZE, accessList.size());
msg.setField(NXCPCodes.VID_ACL,
accessList.toArray(new Long[accessList.size()]));
msg.setFieldInt16(NXCPCodes.VID_NUM_COLUMNS, columns.size());
long fieldId = NXCPCodes.VID_COLUMN_INFO_BASE;
for (int i = 0; i < columns.size(); i++) {
ObjectToolTableColumn c = columns.get(i);
msg.setField(fieldId++, c.getName());
msg.setField(fieldId++, c.getSnmpOid());
msg.setFieldInt16(fieldId++, c.getFormat());
msg.setFieldInt16(fieldId++, c.getSubstringIndex());
}
msg.setFieldInt16(NXCPCodes.VID_NUM_FIELDS, inputFields.size());
fieldId = NXCPCodes.VID_FIELD_LIST_BASE;
for (InputField f : inputFields.values()) {
f.fillMessage(msg, fieldId);
fieldId += 10;
}
}
/**
* @return the accessList
*/
public List<Long> getAccessList() {
return accessList;
}
/**
* @return the columns
*/
public List<ObjectToolTableColumn> getColumns() {
return columns;
}
/**
* Add or replace input field definition.
*
* @param f
*/
public void addInputField(InputField f) {
inputFields.put(f.getName(), f);
modified = true;
}
/**
* Set input field definitions
*
* @param fields
*/
public void setInputFields(Collection<InputField> fields) {
inputFields.clear();
for (InputField f : fields)
inputFields.put(f.getName(), f);
modified = true;
}
/**
* @param id
* the id to set
*/
public void setId(long id) {
this.id = id;
modified = true;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
createDisplayName();
modified = true;
}
/**
* @param type
* the type to set
*/
public void setType(int type) {
this.type = type;
modified = true;
}
/**
* @param flags
* the flags to set
*/
public void setFlags(int flags) {
this.flags = flags;
modified = true;
}
/**
* @param description
* the description to set
*/
public void setDescription(String description) {
this.description = description;
modified = true;
}
/**
* @param data
* the data to set
*/
public void setData(String data) {
this.data = data;
modified = true;
}
/**
* @param confirmationText
* the confirmationText to set
*/
public void setConfirmationText(String confirmationText) {
this.confirmationText = confirmationText;
modified = true;
}
/**
* @return the modified
*/
public boolean isModified() {
return modified;
}
/**
* @param accessList
* the accessList to set
*/
public void setAccessList(List<Long> accessList) {
this.accessList = accessList;
modified = true;
}
/**
* @param columns
* the columns to set
*/
public void setColumns(List<ObjectToolTableColumn> columns) {
this.columns = columns;
modified = true;
}
/**
* @param commandName
*/
public void setCommandName(String commandName) {
this.commandName = commandName;
modified = true;
}
/**
* @param commandShortName
*/
public void setCommandShortName(String commandShortName) {
this.commandShortName = commandShortName;
modified = true;
}
/**
* @param imageData
*/
public void setImageData(byte[] imageData) {
this.imageData = imageData;
modified = true;
}
/**
* Update menu filter information
*
* @param filterText
* menu filter text
* @param filterType
* menu filter type
*/
public void setFilter(String filterText, int filterType) {
filter.setFilter(filterText, filterType);
modified = true;
}
/**
* Update menu filter flags
*
* @param flags
* new value for menu filter flag
* @see ObjectMenuFilter
*/
public void setFilterFlags(int flags) {
filter.flags = flags;
modified = true;
}
}
| [
"phongtran0715@gmail.com"
] | phongtran0715@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.