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
64e0b38a876957489fd64cd9600fc3905e203852
3cfc0137913e89e5809e17d991968233f6258f33
/Java6CatrinescuNicoleta/src/calculatoroop/Screen.java
b0e31025283c0f65a69890e6df84c646041f0447
[]
no_license
ncatrinescu/Java6CatrinescuNicoleta
c1fc68f8e718ccec3e32d389986bd711146c6c3d
1cf486639d48bc65cc39526d963f8d95d2681e34
refs/heads/master
2021-09-07T02:55:48.298652
2018-02-16T09:13:34
2018-02-16T09:13:34
103,754,403
0
0
null
null
null
null
UTF-8
Java
false
false
1,255
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 calculatoroop; /** * * @author Amastasia */ public class Screen { private int valoareAfisata = 0; /** Method display specified parameter value */ public void display(int valueToDisplay){ System.out.println(valueToDisplay); valoareAfisata = valueToDisplay; } /** Method display specified parameter value */ public void clear(){ System.out.println(0); valoareAfisata = 0; } /** * Get the value of valoareAfisata * * @return the value of valoareAfisata */ public int getValoareAfisata() { return valoareAfisata; } /** * Set the value of valoareAfisata * * @param valoareAfisata new value of valoareAfisata */ public void setValoareAfisata(int valoareAfisata) { this.valoareAfisata = valoareAfisata; } public void displayMessage(String message){ System.out.println(message); } }
[ "Amastasia@Amastasia-PC" ]
Amastasia@Amastasia-PC
832cdd401ac23061951573d8175ac491eefe1d12
3b791885ccccbfe704ec9a28149625c242b4b0f4
/app/src/main/java/com/yutao/yilan_master_mine/HtmlData/ApiService.java
68e3407970e551f241c4fed23f651a9f969f43f3
[]
no_license
YutaoAnswer/YiLan-master-Demo
3c27f30ef4045203bc845d433ea5ed561730cb79
99adb56202f18e0a4fb257ba5f559b9a8ab2756d
refs/heads/master
2021-01-12T01:01:14.090712
2017-01-08T09:18:14
2017-01-08T09:18:14
78,331,590
0
0
null
null
null
null
UTF-8
Java
false
false
610
java
package com.yutao.yilan_master_mine.HtmlData; import retrofit2.http.GET; import retrofit2.http.Query; import rx.Observable; /** * Created by Administrator on 2017/1/7. */ public interface ApiService { @GET("social/") Observable <String> getString(@Query("key")String key, @Query("num") String num, @Query("page") int page); @GET("social/") Observable <NewsGson> getNewsData(@Query("key")String key,@Query("num") String num,@Query("page") int page); @GET("meinv/") Observable <MeiNvGson> getPictureData(@Query("key")String key,@Query("num") String num,@Query("page") int page); }
4d2757c4856cab9c006508b18ce068161211b6d7
a6d213f2011412e7ac3991e349cdc19ef05b5d9a
/quytm-study_english-7492255dfa3a/app/src/main/java/com/mta/studyenglish/helper/PrefManager.java
4b8117dd5f932e0a5ddcd538ce262323ec1890d7
[]
no_license
DucThanh6111996/AndroidMobile
5bcb59b0db7cc825eb3da2bbc990655ca4062039
c76cd03cc98af9cf9037f283fb089d02926a609c
refs/heads/master
2020-05-07T05:45:29.373959
2019-11-24T15:09:56
2019-11-24T15:09:56
180,283,086
0
0
null
null
null
null
UTF-8
Java
false
false
1,736
java
package com.mta.studyenglish.helper; import android.content.Context; import android.content.SharedPreferences; /** * Khởi tạo đối tượng Shared preference * Lưu các giá trị đánh dấu lần đầu login và trạng thái đã login hay chưa? */ public class PrefManager { private static String TAG = PrefManager.class.getSimpleName(); private static int PRIVATE_MODE = 0; private static final String PREF_NAME = "study_english_session"; private static final String KEY_IS_LOGGED_IN = "is_login"; private static final String KEY_IS_FIRST_LOGGED_IN = "is_first_login"; private static final String KEY_USERNAME = "username"; private static SharedPreferences pref = null; private static SharedPreferences.Editor editor; public PrefManager(Context context) { if (pref == null) { pref = context.getSharedPreferences(PREF_NAME, PRIVATE_MODE); editor = pref.edit(); } } public static void setIsFirstLogin(boolean isFirstLogin) { editor.putBoolean(KEY_IS_FIRST_LOGGED_IN, isFirstLogin); editor.commit(); } public static void setLogin(boolean isLoggedIn) { editor.putBoolean(KEY_IS_LOGGED_IN, isLoggedIn); editor.commit(); } public static boolean isFirstLoggedIn() { return pref.getBoolean(KEY_IS_FIRST_LOGGED_IN, true); } public static boolean isLoggedIn() { return pref.getBoolean(KEY_IS_LOGGED_IN, false); } public static void setUsername(String username) { editor.putString(KEY_USERNAME, username); editor.commit(); } public static String getUsername() { return pref.getString(KEY_USERNAME, "username"); } }
7e13fb5a7ade2fe5e9d7230f63432edbbea660b1
12f1d0ab0807937b1b8c1e7a5d0cff03b20d118c
/Exp/Exp4/src/problem5/StringEncryptor.java
44ee0c6ca7d801649412aa264ac6002f9fc857f4
[]
no_license
DSapphire/JavaNotes
61b7396842c59fc5d724a3f7161bc89a657d7b88
2e31eae39629f25295ad701a9cf5ef12f9c30007
refs/heads/master
2020-04-01T13:09:55.325433
2015-06-19T00:34:02
2015-06-19T00:34:02
37,692,856
0
0
null
null
null
null
UTF-8
Java
false
false
2,917
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 problem5; import java.util.HashMap; import java.util.Random; /** * * @author Duan */ public class StringEncryptor { public String key1="abcdefghijklmnopqrstuvwxyz "; public String key2="veknohzf iljxdmygbrcswqupta"; public HashMap<Character,Character> keyMap1; public HashMap<Character,Character> keyMap2; public StringEncryptor(){ this.keyMap1=new HashMap<Character,Character>(27); this.keyMap2=new HashMap<Character,Character>(27); } public String encode1(String orig){ StringBuffer sb=new StringBuffer();//orig.length() for(int i=0;i<orig.length();i++){ for(int j=0;j<key1.length();j++){ if(orig.charAt(i)==key1.charAt(j)){ sb.append(key2.charAt(j)); break; } } } String encode=sb.toString(); return encode; } public String decode1(String encode){ StringBuffer sb=new StringBuffer();//encode.length() for(int i=0;i<encode.length();i++){ for(int j=0;j<key1.length();j++){ if(encode.charAt(i)==key2.charAt(j)){ sb.append(key1.charAt(j)); break; } } } String orig=sb.toString(); return orig; } public void setEncodeSeed(long seed){ StringBuffer sb1=new StringBuffer(key1); StringBuffer sb2=new StringBuffer(key2); Random ran=new Random(seed); int i,j,k; for(i=0;i<27;i++){ j=ran.nextInt(sb1.length()-i); k=ran.nextInt(sb2.length()-i); Character ch1=new Character(sb1.charAt(j)); Character ch2=new Character(sb2.charAt(k)); keyMap1.put(ch1,ch2); keyMap2.put(ch2,ch1); sb1.setCharAt(j,sb1.charAt(sb1.length()-i-1)); sb2.setCharAt(k,sb2.charAt(sb2.length()-i-1)); } } public String encode2(String orig){ StringBuffer sb=new StringBuffer();//orig.length() for(int i=0;i<orig.length();i++){ Character ch1=new Character(orig.charAt(i)); Character ch2=keyMap1.get(ch1); sb.append(ch2.charValue()); } String encode=sb.toString(); return encode; } public String decode2(String encode){ StringBuffer sb=new StringBuffer();//encode.length() for(int i=0;i<encode.length();i++){ Character ch2=new Character(encode.charAt(i)); Character ch1=keyMap2.get(ch2); sb.append(ch1.charValue()); } String orig=sb.toString(); return orig; } public static void main(String[] args) { StringEncryptor se=new StringEncryptor(); String orig="we will break out of prison at dawn"; System.out.println("orig="+orig); String encod1=se.encode1(orig); System.out.println("encod1="+encod1); String decod1=se.decode1(encod1); System.out.println("decod1="+decod1); se.setEncodeSeed(12);//System.currentTimeMillis() String encod2=se.encode2(orig); System.out.println("encod2="+encod2); String decod2=se.decode2(encod2); System.out.println("decod2="+decod2); } }
e98801d301699bda0c320f47530e8f4f80f7f0b4
03d84adbc3a1e115915175fb1b0b4086d5430bc5
/leyou-item/leyou-item-service/src/main/java/com/leyou/item/mapper/BrandMapper.java
a5bd948058a45aaa037389954e50bbe46cfde9ee
[]
no_license
toughChow/leyou
8378f74a04f946451dd06ff2ba82dfefd1fbfa6a
f0736f6d1c44b2b85d35ac56ca677a5f2440217f
refs/heads/master
2022-12-04T03:49:20.869123
2019-07-15T15:14:49
2019-07-15T15:14:49
195,729,683
0
0
null
2022-11-16T11:32:52
2019-07-08T03:24:12
Java
UTF-8
Java
false
false
1,225
java
package com.leyou.item.mapper; import com.leyou.item.pojo.Brand; import org.apache.ibatis.annotations.*; import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper; import tk.mybatis.mapper.common.Mapper; import java.util.List; /** * @Author: 98050 * @Time: 2018-08-07 19:15 * @Feature: */ @org.apache.ibatis.annotations.Mapper public interface BrandMapper extends Mapper<Brand>, SelectByIdListMapper<Brand,Long> { /** * 新增商品分类和品牌中间表数据 * @param cid 商品分类id * @param bid 品牌id * @return */ @Insert("INSERT INTO tb_category_brand (category_id, brand_id) VALUES (#{cid},#{bid})") int insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid); /** * 根据brand id删除中间表相关数据 * @param bid */ @Delete("DELETE FROM tb_category_brand WHERE brand_id = #{bid}") void deleteByBrandIdInCategoryBrand(@Param("bid") Long bid); /** * 根据category id查询brand,左连接 * @param cid * @return */ @Select("SELECT b.* FROM tb_brand b LEFT JOIN tb_category_brand cb ON b.id=cb.brand_id WHERE cb.category_id=#{cid}") List<Brand> queryBrandByCategoryId(Long cid); }
1cce113934e874ce0d7369475a54a80862a49d91
784dcdcd2fe8bcb0c832f8f7555c5364adb8f65c
/src/main/java/com/cm/controller/ProfileController.java
00e8e64a0b7cd31b0f3d2ae533438190d1e4be52
[]
no_license
Ansh2103/java-project
006f92ca28ec12a023ff0a1df545caed8f6e4211
33befda1525476360c44a3b495fe7ec2475d7d12
refs/heads/master
2022-10-06T16:03:21.531559
2020-06-04T02:55:55
2020-06-04T02:55:55
269,245,769
0
0
null
null
null
null
UTF-8
Java
false
false
2,054
java
package com.cm.controller; import java.awt.print.Pageable; import java.lang.reflect.Method; import java.util.List; import javax.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.cm.model.UserDao; import com.cm.repository.UserRepository; import com.cm.service.ProfileService; import com.fasterxml.jackson.annotation.JacksonInject.Value; @Transactional @RestController public class ProfileController { @Autowired private ProfileService pr; @Autowired UserRepository ur; @CrossOrigin(origins = "*") @RequestMapping(value="/profile/{name}" , method = RequestMethod.GET) public UserDao viewProfile(@PathVariable String name){ return pr.viewProfile(name) ; } // @CrossOrigin(origins = "*") // @RequestMapping(value="/profile" , method = RequestMethod.GET) // public Iterable<UserDao> viewProfile1(){ // // return pr.viewProfile() ; // } @CrossOrigin(origins = "*") @RequestMapping(value="/users") public List<String> viewProfile(){ // System.out.println("chandan"); return pr.users(); // } @CrossOrigin(origins = "*") @RequestMapping(value="/userall" , method = RequestMethod.GET) public Iterable<UserDao> viewuser(){ return ur.findAll(); } @CrossOrigin(origins ="*") @RequestMapping(value = "/delete/{name}",method = RequestMethod.DELETE) public void delete(@PathVariable String name) { ur.deleteByUsername(name); } }
cf841991f040f6ef5177d4e6790c316a181664e1
c07a66959c96c8601e575cceab3c298d4c7df967
/study/androidstudy/workspace/web/spring-workspace/Day08_AOP/src/test02/MyAspect.java
009c42f513634499ca9a61fbdaed019756686fb9
[ "MIT" ]
permissive
chanjungkim/oldPage
73afcabe63c3daba85e8366ae1b261cf6094d935
0ca19767bed89d2ba04c1db6ac036ae9b1f1bb99
refs/heads/master
2021-08-29T12:32:17.113147
2017-12-14T01:05:32
2017-12-14T01:05:32
74,274,610
0
0
null
null
null
null
UHC
Java
false
false
423
java
package test02; public class MyAspect { public void myBefore() { System.out.println("배가 고프다."); } public void myAfterReturning() { System.out.println("음식을 먹는다."); } public void myAfterThrowing() { System.out.println("엄마를 부른다~!!!"); } public void myAfter() { System.out.println("설거지를 한다."); } }
5002cb267db201c189a2c6cb71805f12b851e811
c6e1e58c90ad656647daef5d084cfec51e111664
/VideotecaHibernate/src/java/modelo/City.java
e0931b98cf18d60e28f8af71af918afc4f90cbae
[]
no_license
manuelgdc/HibernateProyectos
7f222b3ca1ca4a0c79b2d22bcc762f0e7f726f05
089cfc3d2c0344d50715b78102050cb6717a700c
refs/heads/master
2021-05-08T23:33:16.083692
2018-05-26T12:49:21
2018-05-26T12:49:21
119,714,654
0
0
null
null
null
null
UTF-8
Java
false
false
1,547
java
package modelo; // Generated 10-ene-2018 20:07:23 by Hibernate Tools 4.3.1 import java.util.Date; import java.util.HashSet; import java.util.Set; /** * City generated by hbm2java */ public class City implements java.io.Serializable { private Short cityId; private Country country; private String city; private Date lastUpdate; private Set addresses = new HashSet(0); public City() { } public City(Country country, String city) { this.country = country; this.city = city; } public City(Country country, String city, Date lastUpdate, Set addresses) { this.country = country; this.city = city; this.lastUpdate = lastUpdate; this.addresses = addresses; } public Short getCityId() { return this.cityId; } public void setCityId(Short cityId) { this.cityId = cityId; } public Country getCountry() { return this.country; } public void setCountry(Country country) { this.country = country; } public String getCity() { return this.city; } public void setCity(String city) { this.city = city; } public Date getLastUpdate() { return this.lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } public Set getAddresses() { return this.addresses; } public void setAddresses(Set addresses) { this.addresses = addresses; } }
9015b7f1bbba95427e65cbdba8a7db9991f472b2
840615da97e0f1f394ea4c340db57480f059378a
/P5/MyLinkedList.java
2f24147851f94a5f6769c530a276a494ff18b3be
[]
no_license
zil317/Data-Structure
6fb2201b663da60689b132291c811cf728c9bd1e
2964b47040cae05f13d15dc4db4f4d8c98b6b8d8
refs/heads/master
2021-09-04T20:41:11.363476
2018-01-22T08:28:14
2018-01-22T08:28:14
118,421,458
0
0
null
null
null
null
UTF-8
Java
false
false
5,404
java
import java.util.*; import java.io.*; /**This class is to create a Linkedlist*/ public class MyLinkedList<E> extends MyAbstractList<E>{ /**create variable head and tail*/ private Node<E> head; private Node<E> tail; /**constructor */ public MyLinkedList(){ } /**constructor */ public MyLinkedList(E[] objects){ super(objects); } /** Add an element to the beginning of the list */ public void addFirst(E e) { Node<E> newNode = new Node<E>(e); newNode.next = head; head = newNode; size++; if (tail == null) tail = head; } /** Add an element to the end of the list */ public void addLast(E e) { Node<E> newNode = new Node<E>(e); if (tail == null) { head = tail = newNode; } else { tail.next = newNode; tail = tail.next; } size++; } /** Remove the head node and * return the object that is contained in the removed node. */ public E removeFirst() { if (size == 0) { return null; } else { Node<E> temp = head; head = head.next; size--; if (head == null) { tail = null; } return temp.element; } } /** Remove the last node and * return the object that is contained in the removed node. */ public E removeLast() { if (size == 0) { return null; } else if (size == 1) { Node<E> temp = head; head = tail = null; size = 0; return temp.element; } else { Node<E> current = head; for (int i = 0; i < size - 2; i++) { current = current.next; } Node<E> temp = tail; tail = current; tail.next = null; size--; return temp.element; } } /**return true if the list contains the element e*/ public boolean contains (E e) { Node<E> current = head; for (int i =0; i < size; i++) { if (current.element.equals(e)) return true; current = current.next; } return false; } /**return the element from this list at the specified index. return null if the index of invalid*/ public E get(int index){ Node<E> node = head; if(index >= size || index < 0){ return null; } if (index <size && index >= 0){ for(int i=0; i<index; i++){ node = node.next; } } return node.element; } /**return the index of the first matching element in this list. Return -1 if no match is found. The index starts at 0*/ public int indexOf (E e){ Node<E> current = head; for (int i=0; i<size; i++) { if (current.element.equals(e)) { return i; } current = current.next; } return -1; } /**Remove the list of elements from start index to end index from the list, and returns a new linked list consisting of just these elements. * if start > end or either index out of bounds, then return null.*/ public MyLinkedList <E> extractSublist(int start, int end){ if(start < 0|| start > this.size()-1||end < 0 || end >this.size()-1){ throw new IndexOutOfBoundsException("Index out of bound"); } if(start > end){ return null; } MyLinkedList<E> list = new MyLinkedList<E>(); for (int i = start; i<=end; i++){ list.add(start, get(start)); remove(start); // size--; } //list.size = end+1-start; return list; } /**adds the list prefix to the front of the existing list. Updates all relevent fileds for consistency*/ public void prepend (MyLinkedList<E> prefix){ prefix.tail.next = this.head; this.head = prefix.head; if(size == 0){ this.tail = prefix.tail; } size=prefix.size+this.size; } /**Add a new element at the specified index in this list. The index of the head element is 0*/ public void add(int index, E e){ if (index == 0){ addFirst(e); } else if (index >= size){ addLast(e); } else{ Node<E>current = head; for (int i=1; i< index; i++){ current = current.next; } Node<E> temp = current.next; current.next = new Node<E>(e); (current.next).next = temp; size++; } } /**remove the element at the specified position in this list. Return the element that was removed from the list*/ public E remove(int index){ if (index < 0 || index >= size) { return null; } else if (index == 0) { return removeFirst(); } else if (index == size - 1) { return removeLast(); } else { Node<E> previous = head; for (int i = 1; i < index; i++) { previous = previous.next; } Node<E> current = previous.next; previous.next = current.next; size--; return current.element; } } /** Replace the element at the specified position in this list * with the specified element. */ public Object set(int index, E e){ return null; } /**clear method*/ public void clear(){ } /** Return the index of the last matching element in this list * Return -1 if no match. */ public int lastIndexOf(E e) { System.out.println("Implementation left as an exercise"); return 0; } /**Node class*/ private static class Node<E> { E element; Node<E> next; public Node(E element) { this.element = element; } } }
9a25dba6089f5b520ca8c189aa3dc3430cb5460b
dfe00183ecbed1f1aa10abb285cf2a2a18c17509
/src/main/java/com/fong/forumdddcqrs/query/repository/PostQueryObject.java
dbe198c4ca9f0424d91b7bd22c9eb148d0043b2e
[]
no_license
FongX777/forum-ddd-cqrs
d739eb9226219dc207766ad1629e8406e89acdc7
1d9a786589265304872ad45025bc269c7bfb50ac
refs/heads/main
2023-05-03T23:39:50.258509
2021-05-20T14:39:08
2021-05-20T14:39:08
369,239,910
1
0
null
null
null
null
UTF-8
Java
false
false
620
java
package com.fong.forumdddcqrs.query.repository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.annotations.Query; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.stereotype.Repository; @Repository public interface PostQueryObject extends ElasticsearchRepository<PostESDocument, String> { @Query("{\"multi_match\": { \"query\": \"?0\", \"fields\": [\"subject\", \"body\"] } }") Page<PostESDocument> findPostsByKeyword(String keyword, Pageable pageable); }
c190aa5b64543fbfec4f3de0009f80feac0c05d8
b1a1f2c1cac765c42301a15824851a97535ebda6
/app/src/main/java/com/newtest/novusapp/AvailableCardsActivity.java
598ac4ac95dc68ecc64ad60d24d060b2118f24e8
[]
no_license
tupaloYa/NovusApp
9f23040d957ed52f58639213a3c48a316fac5992
e9efa46402756b4217e3c60589c1e6af068ca5e5
refs/heads/master
2020-12-31T07:43:08.945119
2015-11-18T11:04:38
2015-11-18T11:04:38
40,296,727
0
0
null
null
null
null
UTF-8
Java
false
false
1,728
java
package com.newtest.novusapp; import android.app.Activity; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; /** * Created by ROOT-PC on 16.10.2015. */ public class AvailableCardsActivity extends AppCompatActivity { private Button listPurchaseBtn; private Button showBonusBtn; private Button removeBtn; TextView bonusPts; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_available_cards); setActionBarTitle(R.string.avCards); listPurchaseBtn = (Button) findViewById(R.id.listPurchaseBtn); showBonusBtn = (Button) findViewById(R.id.showBonusBtn); removeBtn = (Button) findViewById(R.id.removeBtn); listPurchaseBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); showBonusBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bonusPts = (TextView) findViewById(R.id.bonusPtsText); bonusPts.setText("?? ????? ????? 25 ???????? ??????"); } }); removeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); } public void setActionBarTitle(int actionBarTitle) { getSupportActionBar().setTitle(actionBarTitle); } }
e7e2a268b624e2a44cd1ca47a4239eecef874e9b
6d60a8adbfdc498a28f3e3fef70366581aa0c5fd
/codebase/selected/seltrans/356375.java
d12426096c4ea1bb7cdbc18ec02bbdcd68fc93da
[]
no_license
rayhan-ferdous/code2vec
14268adaf9022d140a47a88129634398cd23cf8f
c8ca68a7a1053d0d09087b14d4c79a189ac0cf00
refs/heads/master
2022-03-09T08:40:18.035781
2022-02-27T23:57:44
2022-02-27T23:57:44
140,347,552
0
1
null
null
null
null
UTF-8
Java
false
false
31,721
java
package org . t2framework . confeito . apache . commons . io ; import java . io . File ; import java . io . FileFilter ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . net . URL ; import java . util . ArrayList ; import java . util . Collection ; import java . util . Date ; import java . util . List ; import java . util . zip . CRC32 ; import java . util . zip . CheckedInputStream ; import java . util . zip . Checksum ; public class FileUtils { public FileUtils ( ) { super ( ) ; } public static final long ONE_KB = 1024 ; public static final long ONE_MB = ONE_KB * ONE_KB ; public static final long ONE_GB = ONE_KB * ONE_MB ; public static final File [ ] EMPTY_FILE_ARRAY = new File [ 0 ] ; public static FileInputStream openInputStream ( File file ) throws IOException { if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { throw new IOException ( "File '" + file + "' exists but is a directory" ) ; } if ( file . canRead ( ) == false ) { throw new IOException ( "File '" + file + "' cannot be read" ) ; } } else { throw new FileNotFoundException ( "File '" + file + "' does not exist" ) ; } return new FileInputStream ( file ) ; } public static FileOutputStream openOutputStream ( File file ) throws IOException { if ( file . exists ( ) ) { if ( file . isDirectory ( ) ) { throw new IOException ( "File '" + file + "' exists but is a directory" ) ; } if ( file . canWrite ( ) == false ) { throw new IOException ( "File '" + file + "' cannot be written to" ) ; } } else { File parent = file . getParentFile ( ) ; if ( parent != null && parent . exists ( ) == false ) { if ( parent . mkdirs ( ) == false ) { throw new IOException ( "File '" + file + "' could not be created" ) ; } } } return new FileOutputStream ( file ) ; } public static String byteCountToDisplaySize ( long size ) { String displaySize ; if ( size / ONE_GB > 0 ) { displaySize = String . valueOf ( size / ONE_GB ) + " GB" ; } else if ( size / ONE_MB > 0 ) { displaySize = String . valueOf ( size / ONE_MB ) + " MB" ; } else if ( size / ONE_KB > 0 ) { displaySize = String . valueOf ( size / ONE_KB ) + " KB" ; } else { displaySize = String . valueOf ( size ) + " bytes" ; } return displaySize ; } public static void touch ( File file ) throws IOException { if ( ! file . exists ( ) ) { OutputStream out = openOutputStream ( file ) ; IOUtils . closeQuietly ( out ) ; } boolean success = file . setLastModified ( System . currentTimeMillis ( ) ) ; if ( ! success ) { throw new IOException ( "Unable to set the last modification time for " + file ) ; } } public static boolean contentEquals ( File file1 , File file2 ) throws IOException { boolean file1Exists = file1 . exists ( ) ; if ( file1Exists != file2 . exists ( ) ) { return false ; } if ( ! file1Exists ) { return true ; } if ( file1 . isDirectory ( ) || file2 . isDirectory ( ) ) { throw new IOException ( "Can't compare directories, only files" ) ; } if ( file1 . length ( ) != file2 . length ( ) ) { return false ; } if ( file1 . getCanonicalFile ( ) . equals ( file2 . getCanonicalFile ( ) ) ) { return true ; } InputStream input1 = null ; InputStream input2 = null ; try { input1 = new FileInputStream ( file1 ) ; input2 = new FileInputStream ( file2 ) ; return IOUtils . contentEquals ( input1 , input2 ) ; } finally { IOUtils . closeQuietly ( input1 ) ; IOUtils . closeQuietly ( input2 ) ; } } public static File toFile ( URL url ) { if ( url == null || ! url . getProtocol ( ) . equals ( "file" ) ) { return null ; } else { String filename = url . getFile ( ) . replace ( '/' , File . separatorChar ) ; int pos = 0 ; while ( ( pos = filename . indexOf ( '%' , pos ) ) >= 0 ) { if ( pos + 2 < filename . length ( ) ) { String hexStr = filename . substring ( pos + 1 , pos + 3 ) ; char ch = ( char ) Integer . parseInt ( hexStr , 16 ) ; filename = filename . substring ( 0 , pos ) + ch + filename . substring ( pos + 3 ) ; } } return new File ( filename ) ; } } public static File [ ] toFiles ( URL [ ] urls ) { if ( urls == null || urls . length == 0 ) { return EMPTY_FILE_ARRAY ; } File [ ] files = new File [ urls . length ] ; for ( int i = 0 ; i < urls . length ; i ++ ) { URL url = urls [ i ] ; if ( url != null ) { if ( url . getProtocol ( ) . equals ( "file" ) == false ) { throw new IllegalArgumentException ( "URL could not be converted to a File: " + url ) ; } files [ i ] = toFile ( url ) ; } } return files ; } public static URL [ ] toURLs ( File [ ] files ) throws IOException { URL [ ] urls = new URL [ files . length ] ; for ( int i = 0 ; i < urls . length ; i ++ ) { urls [ i ] = files [ i ] . toURI ( ) . toURL ( ) ; } return urls ; } public static void copyFileToDirectory ( File srcFile , File destDir ) throws IOException { copyFileToDirectory ( srcFile , destDir , true ) ; } public static void copyFileToDirectory ( File srcFile , File destDir , boolean preserveFileDate ) throws IOException { if ( destDir == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( destDir . exists ( ) && destDir . isDirectory ( ) == false ) { throw new IllegalArgumentException ( "Destination '" + destDir + "' is not a directory" ) ; } copyFile ( srcFile , new File ( destDir , srcFile . getName ( ) ) , preserveFileDate ) ; } public static void copyFile ( File srcFile , File destFile ) throws IOException { copyFile ( srcFile , destFile , true ) ; } public static void copyFile ( File srcFile , File destFile , boolean preserveFileDate ) throws IOException { if ( srcFile == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destFile == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( srcFile . exists ( ) == false ) { throw new FileNotFoundException ( "Source '" + srcFile + "' does not exist" ) ; } if ( srcFile . isDirectory ( ) ) { throw new IOException ( "Source '" + srcFile + "' exists but is a directory" ) ; } if ( srcFile . getCanonicalPath ( ) . equals ( destFile . getCanonicalPath ( ) ) ) { throw new IOException ( "Source '" + srcFile + "' and destination '" + destFile + "' are the same" ) ; } if ( destFile . getParentFile ( ) != null && destFile . getParentFile ( ) . exists ( ) == false ) { if ( destFile . getParentFile ( ) . mkdirs ( ) == false ) { throw new IOException ( "Destination '" + destFile + "' directory cannot be created" ) ; } } if ( destFile . exists ( ) && destFile . canWrite ( ) == false ) { throw new IOException ( "Destination '" + destFile + "' exists but is read-only" ) ; } doCopyFile ( srcFile , destFile , preserveFileDate ) ; } private static void doCopyFile ( File srcFile , File destFile , boolean preserveFileDate ) throws IOException { if ( destFile . exists ( ) && destFile . isDirectory ( ) ) { throw new IOException ( "Destination '" + destFile + "' exists but is a directory" ) ; } FileInputStream input = new FileInputStream ( srcFile ) ; try { FileOutputStream output = new FileOutputStream ( destFile ) ; try { IOUtils . copy ( input , output ) ; } finally { IOUtils . closeQuietly ( output ) ; } } finally { IOUtils . closeQuietly ( input ) ; } if ( srcFile . length ( ) != destFile . length ( ) ) { throw new IOException ( "Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'" ) ; } if ( preserveFileDate ) { destFile . setLastModified ( srcFile . lastModified ( ) ) ; } } public static void copyDirectoryToDirectory ( File srcDir , File destDir ) throws IOException { if ( srcDir == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( srcDir . exists ( ) && srcDir . isDirectory ( ) == false ) { throw new IllegalArgumentException ( "Source '" + destDir + "' is not a directory" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( destDir . exists ( ) && destDir . isDirectory ( ) == false ) { throw new IllegalArgumentException ( "Destination '" + destDir + "' is not a directory" ) ; } copyDirectory ( srcDir , new File ( destDir , srcDir . getName ( ) ) , true ) ; } public static void copyDirectory ( File srcDir , File destDir ) throws IOException { copyDirectory ( srcDir , destDir , true ) ; } public static void copyDirectory ( File srcDir , File destDir , boolean preserveFileDate ) throws IOException { copyDirectory ( srcDir , destDir , null , preserveFileDate ) ; } public static void copyDirectory ( File srcDir , File destDir , FileFilter filter ) throws IOException { copyDirectory ( srcDir , destDir , filter , true ) ; } public static void copyDirectory ( File srcDir , File destDir , FileFilter filter , boolean preserveFileDate ) throws IOException { if ( srcDir == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( srcDir . exists ( ) == false ) { throw new FileNotFoundException ( "Source '" + srcDir + "' does not exist" ) ; } if ( srcDir . isDirectory ( ) == false ) { throw new IOException ( "Source '" + srcDir + "' exists but is not a directory" ) ; } if ( srcDir . getCanonicalPath ( ) . equals ( destDir . getCanonicalPath ( ) ) ) { throw new IOException ( "Source '" + srcDir + "' and destination '" + destDir + "' are the same" ) ; } List < String > exclusionList = null ; if ( destDir . getCanonicalPath ( ) . startsWith ( srcDir . getCanonicalPath ( ) ) ) { File [ ] srcFiles = filter == null ? srcDir . listFiles ( ) : srcDir . listFiles ( filter ) ; if ( srcFiles != null && srcFiles . length > 0 ) { exclusionList = new ArrayList < String > ( srcFiles . length ) ; for ( int i = 0 ; i < srcFiles . length ; i ++ ) { File copiedFile = new File ( destDir , srcFiles [ i ] . getName ( ) ) ; exclusionList . add ( copiedFile . getCanonicalPath ( ) ) ; } } } doCopyDirectory ( srcDir , destDir , filter , preserveFileDate , exclusionList ) ; } private static void doCopyDirectory ( File srcDir , File destDir , FileFilter filter , boolean preserveFileDate , List < String > exclusionList ) throws IOException { if ( destDir . exists ( ) ) { if ( destDir . isDirectory ( ) == false ) { throw new IOException ( "Destination '" + destDir + "' exists but is not a directory" ) ; } } else { if ( destDir . mkdirs ( ) == false ) { throw new IOException ( "Destination '" + destDir + "' directory cannot be created" ) ; } if ( preserveFileDate ) { destDir . setLastModified ( srcDir . lastModified ( ) ) ; } } if ( destDir . canWrite ( ) == false ) { throw new IOException ( "Destination '" + destDir + "' cannot be written to" ) ; } File [ ] files = filter == null ? srcDir . listFiles ( ) : srcDir . listFiles ( filter ) ; if ( files == null ) { throw new IOException ( "Failed to list contents of " + srcDir ) ; } for ( int i = 0 ; i < files . length ; i ++ ) { File copiedFile = new File ( destDir , files [ i ] . getName ( ) ) ; if ( exclusionList == null || ! exclusionList . contains ( files [ i ] . getCanonicalPath ( ) ) ) { if ( files [ i ] . isDirectory ( ) ) { doCopyDirectory ( files [ i ] , copiedFile , filter , preserveFileDate , exclusionList ) ; } else { doCopyFile ( files [ i ] , copiedFile , preserveFileDate ) ; } } } } public static void copyURLToFile ( URL source , File destination ) throws IOException { InputStream input = source . openStream ( ) ; try { FileOutputStream output = openOutputStream ( destination ) ; try { IOUtils . copy ( input , output ) ; } finally { IOUtils . closeQuietly ( output ) ; } } finally { IOUtils . closeQuietly ( input ) ; } } public static void deleteDirectory ( File directory ) throws IOException { if ( ! directory . exists ( ) ) { return ; } cleanDirectory ( directory ) ; if ( ! directory . delete ( ) ) { String message = "Unable to delete directory " + directory + "." ; throw new IOException ( message ) ; } } public static boolean deleteQuietly ( File file ) { if ( file == null ) { return false ; } try { if ( file . isDirectory ( ) ) { cleanDirectory ( file ) ; } } catch ( Exception e ) { } try { return file . delete ( ) ; } catch ( Exception e ) { return false ; } } public static void cleanDirectory ( File directory ) throws IOException { if ( ! directory . exists ( ) ) { String message = directory + " does not exist" ; throw new IllegalArgumentException ( message ) ; } if ( ! directory . isDirectory ( ) ) { String message = directory + " is not a directory" ; throw new IllegalArgumentException ( message ) ; } File [ ] files = directory . listFiles ( ) ; if ( files == null ) { throw new IOException ( "Failed to list contents of " + directory ) ; } IOException exception = null ; for ( int i = 0 ; i < files . length ; i ++ ) { File file = files [ i ] ; try { forceDelete ( file ) ; } catch ( IOException ioe ) { exception = ioe ; } } if ( null != exception ) { throw exception ; } } public static boolean waitFor ( File file , int seconds ) { int timeout = 0 ; int tick = 0 ; while ( ! file . exists ( ) ) { if ( tick ++ >= 10 ) { tick = 0 ; if ( timeout ++ > seconds ) { return false ; } } try { Thread . sleep ( 100 ) ; } catch ( InterruptedException ignore ) { } catch ( Exception ex ) { break ; } } return true ; } public static String readFileToString ( File file , String encoding ) throws IOException { InputStream in = null ; try { in = openInputStream ( file ) ; return IOUtils . toString ( in , encoding ) ; } finally { IOUtils . closeQuietly ( in ) ; } } public static String readFileToString ( File file ) throws IOException { return readFileToString ( file , null ) ; } public static byte [ ] readFileToByteArray ( File file ) throws IOException { InputStream in = null ; try { in = openInputStream ( file ) ; return IOUtils . toByteArray ( in ) ; } finally { IOUtils . closeQuietly ( in ) ; } } public static List < String > readLines ( File file , String encoding ) throws IOException { InputStream in = null ; try { in = openInputStream ( file ) ; return IOUtils . readLines ( in , encoding ) ; } finally { IOUtils . closeQuietly ( in ) ; } } public static List < String > readLines ( File file ) throws IOException { return readLines ( file , null ) ; } public static LineIterator lineIterator ( File file , String encoding ) throws IOException { InputStream in = null ; try { in = openInputStream ( file ) ; return IOUtils . lineIterator ( in , encoding ) ; } catch ( IOException ex ) { IOUtils . closeQuietly ( in ) ; throw ex ; } catch ( RuntimeException ex ) { IOUtils . closeQuietly ( in ) ; throw ex ; } } public static LineIterator lineIterator ( File file ) throws IOException { return lineIterator ( file , null ) ; } public static void writeStringToFile ( File file , String data , String encoding ) throws IOException { OutputStream out = null ; try { out = openOutputStream ( file ) ; IOUtils . write ( data , out , encoding ) ; } finally { IOUtils . closeQuietly ( out ) ; } } public static void writeStringToFile ( File file , String data ) throws IOException { writeStringToFile ( file , data , null ) ; } public static void writeByteArrayToFile ( File file , byte [ ] data ) throws IOException { OutputStream out = null ; try { out = openOutputStream ( file ) ; out . write ( data ) ; } finally { IOUtils . closeQuietly ( out ) ; } } public static void writeLines ( File file , String encoding , Collection < String > lines ) throws IOException { writeLines ( file , encoding , lines , null ) ; } public static void writeLines ( File file , Collection < String > lines ) throws IOException { writeLines ( file , null , lines , null ) ; } public static void writeLines ( File file , String encoding , Collection < String > lines , String lineEnding ) throws IOException { OutputStream out = null ; try { out = openOutputStream ( file ) ; IOUtils . writeLines ( lines , lineEnding , out , encoding ) ; } finally { IOUtils . closeQuietly ( out ) ; } } public static void writeLines ( File file , Collection < String > lines , String lineEnding ) throws IOException { writeLines ( file , null , lines , lineEnding ) ; } public static void forceDelete ( File file ) throws IOException { if ( file . isDirectory ( ) ) { deleteDirectory ( file ) ; } else { boolean filePresent = file . exists ( ) ; if ( ! file . delete ( ) ) { if ( ! filePresent ) { throw new FileNotFoundException ( "File does not exist: " + file ) ; } String message = "Unable to delete file: " + file ; throw new IOException ( message ) ; } } } public static void forceDeleteOnExit ( File file ) throws IOException { if ( file . isDirectory ( ) ) { deleteDirectoryOnExit ( file ) ; } else { file . deleteOnExit ( ) ; } } private static void deleteDirectoryOnExit ( File directory ) throws IOException { if ( ! directory . exists ( ) ) { return ; } cleanDirectoryOnExit ( directory ) ; directory . deleteOnExit ( ) ; } private static void cleanDirectoryOnExit ( File directory ) throws IOException { if ( ! directory . exists ( ) ) { String message = directory + " does not exist" ; throw new IllegalArgumentException ( message ) ; } if ( ! directory . isDirectory ( ) ) { String message = directory + " is not a directory" ; throw new IllegalArgumentException ( message ) ; } File [ ] files = directory . listFiles ( ) ; if ( files == null ) { throw new IOException ( "Failed to list contents of " + directory ) ; } IOException exception = null ; for ( int i = 0 ; i < files . length ; i ++ ) { File file = files [ i ] ; try { forceDeleteOnExit ( file ) ; } catch ( IOException ioe ) { exception = ioe ; } } if ( null != exception ) { throw exception ; } } public static void forceMkdir ( File directory ) throws IOException { if ( directory . exists ( ) ) { if ( directory . isFile ( ) ) { String message = "File " + directory + " exists and is " + "not a directory. Unable to create directory." ; throw new IOException ( message ) ; } } else { if ( ! directory . mkdirs ( ) ) { String message = "Unable to create directory " + directory ; throw new IOException ( message ) ; } } } public static long sizeOfDirectory ( File directory ) { if ( ! directory . exists ( ) ) { String message = directory + " does not exist" ; throw new IllegalArgumentException ( message ) ; } if ( ! directory . isDirectory ( ) ) { String message = directory + " is not a directory" ; throw new IllegalArgumentException ( message ) ; } long size = 0 ; File [ ] files = directory . listFiles ( ) ; if ( files == null ) { return 0L ; } for ( int i = 0 ; i < files . length ; i ++ ) { File file = files [ i ] ; if ( file . isDirectory ( ) ) { size += sizeOfDirectory ( file ) ; } else { size += file . length ( ) ; } } return size ; } public static boolean isFileNewer ( File file , File reference ) { if ( reference == null ) { throw new IllegalArgumentException ( "No specified reference file" ) ; } if ( ! reference . exists ( ) ) { throw new IllegalArgumentException ( "The reference file '" + file + "' doesn't exist" ) ; } return isFileNewer ( file , reference . lastModified ( ) ) ; } public static boolean isFileNewer ( File file , Date date ) { if ( date == null ) { throw new IllegalArgumentException ( "No specified date" ) ; } return isFileNewer ( file , date . getTime ( ) ) ; } public static boolean isFileNewer ( File file , long timeMillis ) { if ( file == null ) { throw new IllegalArgumentException ( "No specified file" ) ; } if ( ! file . exists ( ) ) { return false ; } return file . lastModified ( ) > timeMillis ; } public static boolean isFileOlder ( File file , File reference ) { if ( reference == null ) { throw new IllegalArgumentException ( "No specified reference file" ) ; } if ( ! reference . exists ( ) ) { throw new IllegalArgumentException ( "The reference file '" + file + "' doesn't exist" ) ; } return isFileOlder ( file , reference . lastModified ( ) ) ; } public static boolean isFileOlder ( File file , Date date ) { if ( date == null ) { throw new IllegalArgumentException ( "No specified date" ) ; } return isFileOlder ( file , date . getTime ( ) ) ; } public static boolean isFileOlder ( File file , long timeMillis ) { if ( file == null ) { throw new IllegalArgumentException ( "No specified file" ) ; } if ( ! file . exists ( ) ) { return false ; } return file . lastModified ( ) < timeMillis ; } public static long checksumCRC32 ( File file ) throws IOException { CRC32 crc = new CRC32 ( ) ; checksum ( file , crc ) ; return crc . getValue ( ) ; } public static Checksum checksum ( File file , Checksum checksum ) throws IOException { if ( file . isDirectory ( ) ) { throw new IllegalArgumentException ( "Checksums can't be computed on directories" ) ; } InputStream in = null ; try { in = new CheckedInputStream ( new FileInputStream ( file ) , checksum ) ; IOUtils . copy ( in , new OutputStream ( ) { @ Override public void write ( byte [ ] b , int off , int len ) { } @ Override public void write ( int b ) { } @ Override public void write ( byte [ ] b ) throws IOException { } } ) ; } finally { IOUtils . closeQuietly ( in ) ; } return checksum ; } public static void moveDirectory ( File srcDir , File destDir ) throws IOException { if ( srcDir == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( ! srcDir . exists ( ) ) { throw new FileNotFoundException ( "Source '" + srcDir + "' does not exist" ) ; } if ( ! srcDir . isDirectory ( ) ) { throw new IOException ( "Source '" + srcDir + "' is not a directory" ) ; } if ( destDir . exists ( ) ) { throw new IOException ( "Destination '" + destDir + "' already exists" ) ; } boolean rename = srcDir . renameTo ( destDir ) ; if ( ! rename ) { copyDirectory ( srcDir , destDir ) ; deleteDirectory ( srcDir ) ; if ( srcDir . exists ( ) ) { throw new IOException ( "Failed to delete original directory '" + srcDir + "' after copy to '" + destDir + "'" ) ; } } } public static void moveDirectoryToDirectory ( File src , File destDir , boolean createDestDir ) throws IOException { if ( src == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination directory must not be null" ) ; } if ( ! destDir . exists ( ) && createDestDir ) { destDir . mkdirs ( ) ; } if ( ! destDir . exists ( ) ) { throw new FileNotFoundException ( "Destination directory '" + destDir + "' does not exist [createDestDir=" + createDestDir + "]" ) ; } if ( ! destDir . isDirectory ( ) ) { throw new IOException ( "Destination '" + destDir + "' is not a directory" ) ; } moveDirectory ( src , new File ( destDir , src . getName ( ) ) ) ; } public static void moveFile ( File srcFile , File destFile ) throws IOException { if ( srcFile == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destFile == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( ! srcFile . exists ( ) ) { throw new FileNotFoundException ( "Source '" + srcFile + "' does not exist" ) ; } if ( srcFile . isDirectory ( ) ) { throw new IOException ( "Source '" + srcFile + "' is a directory" ) ; } if ( destFile . exists ( ) ) { throw new IOException ( "Destination '" + destFile + "' already exists" ) ; } if ( destFile . isDirectory ( ) ) { throw new IOException ( "Destination '" + destFile + "' is a directory" ) ; } boolean rename = srcFile . renameTo ( destFile ) ; if ( ! rename ) { copyFile ( srcFile , destFile ) ; if ( ! srcFile . delete ( ) ) { FileUtils . deleteQuietly ( destFile ) ; throw new IOException ( "Failed to delete original file '" + srcFile + "' after copy to '" + destFile + "'" ) ; } } } public static void moveFileToDirectory ( File srcFile , File destDir , boolean createDestDir ) throws IOException { if ( srcFile == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination directory must not be null" ) ; } if ( ! destDir . exists ( ) && createDestDir ) { destDir . mkdirs ( ) ; } if ( ! destDir . exists ( ) ) { throw new FileNotFoundException ( "Destination directory '" + destDir + "' does not exist [createDestDir=" + createDestDir + "]" ) ; } if ( ! destDir . isDirectory ( ) ) { throw new IOException ( "Destination '" + destDir + "' is not a directory" ) ; } moveFile ( srcFile , new File ( destDir , srcFile . getName ( ) ) ) ; } public static void moveToDirectory ( File src , File destDir , boolean createDestDir ) throws IOException { if ( src == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destDir == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( ! src . exists ( ) ) { throw new FileNotFoundException ( "Source '" + src + "' does not exist" ) ; } if ( src . isDirectory ( ) ) { moveDirectoryToDirectory ( src , destDir , createDestDir ) ; } else { moveFileToDirectory ( src , destDir , createDestDir ) ; } } }
df4585a4f08e3ec255f7d7c10c1dd09bdca3b102
edc907ea74b852d2d7b7beaa4e03d13e14b96b28
/anylog-base/src/main/java/com/github/jobop/anylog/core/interactive/user/servlet/FieldWrapper.java
7d6aa40c65b9ba50f924dfaa80c4c7dd366878a5
[]
no_license
ilikesomethingthis/anylog
ebbe7c14f3ca2d55232b8a0849f910ed21f53739
564ce3d2c5f2362f59bcd999f92a0abdfa607ce3
refs/heads/master
2020-06-16T15:51:03.938111
2019-07-07T16:00:54
2019-07-07T16:00:54
195,627,717
0
0
null
2019-07-07T08:28:51
2019-07-07T08:28:51
null
UTF-8
Java
false
false
707
java
package com.github.jobop.anylog.core.interactive.user.servlet; public class FieldWrapper { private String fieldName; private String fieldDesc; private boolean canNull; private Object value; public String getFieldName() { return fieldName; } public void setFieldName(String fieldName) { this.fieldName = fieldName; } public String getFieldDesc() { return fieldDesc; } public void setFieldDesc(String fieldDesc) { this.fieldDesc = fieldDesc; } public boolean isCanNull() { return canNull; } public void setCanNull(boolean canNull) { this.canNull = canNull; } public Object getValue() { return value; } public void setValue(Object value) { this.value = value; } }
0e43b18433449db753d64bb94f9f65ebbb99271a
30d6753c4886b8c028d5e3979c8a780f60ff250f
/app/src/main/java/com/qbb/qchina/main/ui/fragment/FindFragment.java
97167a7ebb1edd74babb4ad794e1e8dbe41a839a
[]
no_license
bingbing9527/QChina
f326861b1064229945a90310f8cc2d99ec3eb9c8
b192fd642bd15acbc4834f1723d887d9dcdadbf7
refs/heads/master
2021-01-21T23:05:06.617023
2017-06-23T06:35:53
2017-06-23T06:35:54
95,090,977
1
0
null
null
null
null
UTF-8
Java
false
false
1,365
java
package com.qbb.qchina.main.ui.fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.qbb.qchina.R; import com.qbb.qchina.core.ui.BaseFragment; /** * 创建日期:2017/5/15 15:31 * * @author Qian Bing Bing * 类说明:发现Fragment */ public class FindFragment extends BaseFragment { private static final String FRAGMENT_INDEX = "fragment_index"; public static FindFragment newInstance(int index){ Bundle bundle = new Bundle(); bundle.putInt(FRAGMENT_INDEX, index); FindFragment fragment = new FindFragment(); fragment.setArguments(bundle); return fragment; } @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_home, container, false); } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); TextView textView = (TextView) view.findViewById(R.id.tv_content); textView.setText("Fragment---3"); Log.e("tag","Fragment---3"); } }
cf1441bd400325d7b1093fb19b088d26b7b4999a
4be25d47d3e19ac2bad157d56fd01d8652bcbef6
/app/src/main/java/com/bitm/alfa_travel_mate/model/TravelMoment.java
92b6924f97a37972b1851b71151fe183344f7df1
[]
no_license
il7team/projectAndroid
f97a651d77e69f8e9ec3aa7ce96840d0dae650cf
283ebb82e52ba7bd24af9af9544476b53fcbc4ef
refs/heads/master
2021-05-03T07:26:01.790635
2018-02-13T15:01:43
2018-02-13T15:01:43
120,607,922
0
0
null
2018-02-13T14:53:43
2018-02-07T11:43:15
Java
UTF-8
Java
false
false
1,514
java
package com.bitm.alfa_travel_mate.model; /** * Created by Shamon on 5/2/2017. */ public class TravelMoment { private String momentId; private String eventId; private String description; private String imageUrl; String date; String time; public TravelMoment(String momentId,String eventId,String description, String imageUrl, String date, String time) { this.momentId = momentId; this.eventId = eventId; this.description = description; this.imageUrl = imageUrl; this.date = date; this.time = time; } public TravelMoment() { } public String getMomentId() { return momentId; } public void setMomentId(String eventId) { this.momentId = eventId; } public String getEventId() { return eventId; } public void setEventId(String eventId) { this.eventId = eventId; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getImageUrl() { return imageUrl; } public void setImageUrl(String imageUrl) { this.imageUrl = imageUrl; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } }
e8e6bc386d028630b38dc3a9e2615db726bfe702
879e18003ad14b0fd5a85ad515a0fed2c991f3f8
/Laboratorio/Prácticas/PL3/PlantsVsZombies/src/clases/ZombieDeportista.java
461cea0688755c6c3665430175ba25a476191fe7
[ "MIT" ]
permissive
lauram15a/Programacion
16ec5d19d88f6cd4a0bfdddbfd2e7eea02e27938
40406207b7ec0bc00d18dc8850dcdd15da436af2
refs/heads/main
2023-07-08T14:19:12.069191
2021-08-14T14:00:27
2021-08-14T14:00:27
396,023,155
0
0
null
null
null
null
UTF-8
Java
false
false
883
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 clases; /** * * @author laura */ public class ZombieDeportista extends Zombie{ //constructor public ZombieDeportista(int coste, int resistencia, int danio, int ciclo, int velocidad) { super(coste, resistencia, danio, ciclo, velocidad); } /** * Crea un objeto ZombieComun * * Deportista: es más rápido, pero menos resistente. Camina un paso cada ciclo y tiene resistencia 2 puntos de vida. * * @return ZombieComun */ public static ZombieDeportista crearZombieDeportista() { ZombieDeportista zmbD= new ZombieDeportista(0, 2, 1, 1, 0); //resistencia, danio, ciclo, velocidad return zmbD; } }
e95a7b1e3e9c26cc2ef92351adbd4f04fc3a11a7
485404ad2c3865f61abb5838f9795fd2284cca70
/hwshop/src/main/java/com/hwrky/shop/controller/ProductController.java
07d1163907ad0bc07c6dacb238a961f25bbf061b
[]
no_license
ancyshi/wangyun
12899c13efe0958016406281d74c1b74dc7d6f04
2b5a4791a0cc630d83b0185daa8a8711a027e3f8
refs/heads/master
2020-12-28T13:38:55.213552
2019-08-11T16:01:13
2019-08-11T16:01:13
238,353,247
0
1
null
2020-02-05T02:41:04
2020-02-05T02:41:03
null
UTF-8
Java
false
false
877
java
package com.hwrky.shop.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.hwrky.shop.entity.Category; import com.hwrky.shop.entity.Product; import com.hwrky.shop.service.ProductService; @Controller @RequestMapping(value="/product") public class ProductController { @Autowired private ProductService productService; @RequestMapping(value="/add") public String addProduct() { return "productmanage"; } @RequestMapping(value="/doadd") public String doAddProduct(Product product) { if(productService.add(product)) { System.out.println("成功"); return "insertsuccess"; }else { System.out.println("失败"); } return "insertfail"; } }
c799f0c7372929dff7f848783b5c63eb24c7eb97
c03c722a50d725b0de85c91983c9fd3390d53009
/JavaPlanetLanderWithLibZ/src/br/ol/planetlander/entity/HUD.java
9de61e91c49bfea68c9969e9de7c44d0bab4deb0
[]
no_license
leonardo-ono/JavaPlanetLanderWithLibZ
352afa40c67b7e4115f0fa2cb07f6709c53264dc
92a3663af99b8bd6d6f008c575dd642144c968c8
refs/heads/master
2021-01-12T05:48:29.551818
2018-05-14T13:16:47
2018-05-14T13:16:47
77,202,335
1
0
null
null
null
null
UTF-8
Java
false
false
1,824
java
package br.ol.planetlander.entity; import br.ol.planetlander.PlanetLanderEntity; import br.ol.planetlander.PlanetLanderGame; import me.winspeednl.libz.core.GameCore; import me.winspeednl.libz.screen.Font; import me.winspeednl.libz.screen.Render; /** * HUD class. * * @author Leonardo Ono ([email protected]) */ public class HUD extends PlanetLanderEntity { private final String fuelMessage = "FUEL:"; private Ship ship; private Terrain terrain; public HUD(PlanetLanderGame game) { super(game); } @Override public void init(GameCore gc) { x = 32; y = 10; h = 6; ship = game.getParameter("getShip", Ship.class); terrain = game.getParameter("getTerrain", Terrain.class); } @Override public void render(GameCore gc, Render render) { if (!visible) { return; } String currentLevel = "LEVEL: " + terrain.currentLevel; game.drawText(render, currentLevel, 0xFFFFFFFF, 0, 10, PlanetLanderGame.SCREEN_WIDTH - 10, 3, Font.STANDARD); game.drawText(render, fuelMessage, 0xFFFFFFFF, 10, 10, Font.STANDARD); for (int dx = 0; dx < ship.fuel; dx++) { for (int dy = 0; dy < h; dy++) { render.setPixel(x + dx, y + dy, 0xFFFF0000); } } render.drawRect(x - 1, y - 1, 102, 6, 0xFFFFFFFF, 1, false); } // broadcast messages @Override public void stateChanged() { switch (game.getState()) { case READY: case PLAYING: case CLEARED: case GAME_OVER: visible = true; break; default: visible = false; } } }
de7b4208bc6b16a48663124a1640de270ab35dd0
6e57bdc0a6cd18f9f546559875256c4570256c45
/packages/apps/TvSettings/Settings/src/com/android/tv/settings/device/apps/AllAppsActivity.java
fd4e0a43ab3fb792028492c8ed64ac02ad2d1c6f
[ "Apache-2.0" ]
permissive
dongdong331/test
969d6e945f7f21a5819cd1d5f536d12c552e825c
2ba7bcea4f9d9715cbb1c4e69271f7b185a0786e
refs/heads/master
2023-03-07T06:56:55.210503
2020-12-07T04:15:33
2020-12-07T04:15:33
134,398,935
2
1
null
2022-11-21T07:53:41
2018-05-22T10:26:42
null
UTF-8
Java
false
false
2,491
java
/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.tv.settings.device.apps; import android.app.Fragment; import android.os.Bundle; import com.android.tv.settings.BaseSettingsFragment; import com.android.tv.settings.TvSettingsActivity; /** * Activity allowing the management of apps settings. */ public class AllAppsActivity extends TvSettingsActivity { // Used for storage only. public static final String EXTRA_VOLUME_UUID = "volumeUuid"; public static final String EXTRA_VOLUME_NAME = "volumeName"; @Override protected Fragment createSettingsFragment() { final Bundle args = getIntent().getExtras(); String volumeUuid = null; String volumeName = null; if (args != null && args.containsKey(EXTRA_VOLUME_UUID)) { volumeUuid = args.getString(EXTRA_VOLUME_UUID); volumeName = args.getString(EXTRA_VOLUME_NAME); } return SettingsFragment.newInstance(volumeUuid, volumeName); } /** * Fragment allowing the management of apps settings. */ public static class SettingsFragment extends BaseSettingsFragment { /** Creates a new instance of the fragment. */ public static SettingsFragment newInstance(String volumeUuid, String volumeName) { final Bundle b = new Bundle(2); b.putString(EXTRA_VOLUME_UUID, volumeUuid); b.putString(EXTRA_VOLUME_NAME, volumeName); final SettingsFragment f = new SettingsFragment(); f.setArguments(b); return f; } @Override public void onPreferenceStartInitialScreen() { final String volumeUuid = getArguments().getString(EXTRA_VOLUME_UUID); final String volumeName = getArguments().getString(EXTRA_VOLUME_NAME); startPreferenceFragment(AllAppsFragment.newInstance(volumeUuid, volumeName)); } } }
b9b19910b3cb3d1efe28cb5bcd1b51dd3073ef64
405d5f8663a32b050f1a715756fdc63f231b196d
/src/mobi/cangol/mobile/onetv/navigation/SlidingMenu.java
a89d75c12cec2f8eb9d97d7657aa796e00e00431
[ "Apache-2.0" ]
permissive
Cangol/OneTV
aad8feb43bf13edea48ecf1ee6a9edbcfb9a955a
ff918f2e977c467ce4f56552d6915acf8562fdb0
refs/heads/master
2021-05-28T01:58:20.388917
2013-11-19T13:48:48
2013-11-19T13:48:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
28,754
java
package mobi.cangol.mobile.onetv.navigation; import java.lang.reflect.Method; import mobi.cangol.mobile.onetv.R; import mobi.cangol.mobile.onetv.navigation.CustomViewAbove.OnPageChangeListener; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Log; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.RelativeLayout; public class SlidingMenu extends RelativeLayout { private static final String TAG = "SlidingMenu"; private static final boolean DEBUG=false; public static final int SLIDING_WINDOW = 0; public static final int SLIDING_CONTENT = 1; private boolean mActionbarOverlay = false; /** Constant value for use with setTouchModeAbove(). Allows the SlidingMenu to be opened with a swipe * gesture on the screen's margin */ public static final int TOUCHMODE_MARGIN = 0; /** Constant value for use with setTouchModeAbove(). Allows the SlidingMenu to be opened with a swipe * gesture anywhere on the screen */ public static final int TOUCHMODE_FULLSCREEN = 1; /** Constant value for use with setTouchModeAbove(). Denies the SlidingMenu to be opened with a swipe * gesture */ public static final int TOUCHMODE_NONE = 2; /** Constant value for use with setMode(). Puts the menu to the left of the content. */ public static final int LEFT = 0; /** Constant value for use with setMode(). Puts the menu to the right of the content. */ public static final int RIGHT = 1; /** Constant value for use with setMode(). Puts menus to the left and right of the content. */ public static final int LEFT_RIGHT = 2; private CustomViewAbove mViewAbove; private CustomViewBehind mViewBehind; private OnOpenListener mOpenListener; private OnOpenListener mSecondaryOpenListner; private OnCloseListener mCloseListener; /** * The listener interface for receiving onOpen events. * The class that is interested in processing a onOpen * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addOnOpenListener<code> method. When * the onOpen event occurs, that object's appropriate * method is invoked */ public interface OnOpenListener { /** * On open. */ public void onOpen(); } /** * The listener interface for receiving onOpened events. * The class that is interested in processing a onOpened * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addOnOpenedListener<code> method. When * the onOpened event occurs, that object's appropriate * method is invoked. * * @see OnOpenedEvent */ public interface OnOpenedListener { /** * On opened. */ public void onOpened(); } /** * The listener interface for receiving onClose events. * The class that is interested in processing a onClose * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addOnCloseListener<code> method. When * the onClose event occurs, that object's appropriate * method is invoked. * * @see OnCloseEvent */ public interface OnCloseListener { /** * On close. */ public void onClose(); } /** * The listener interface for receiving onClosed events. * The class that is interested in processing a onClosed * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addOnClosedListener<code> method. When * the onClosed event occurs, that object's appropriate * method is invoked. * * @see OnClosedEvent */ public interface OnClosedListener { /** * On closed. */ public void onClosed(); } /** * The Interface CanvasTransformer. */ public interface CanvasTransformer { /** * Transform canvas. * * @param canvas the canvas * @param percentOpen the percent open */ public void transformCanvas(Canvas canvas, float percentOpen); } /** * Instantiates a new SlidingMenu. * * @param context the associated Context */ public SlidingMenu(Context context) { this(context, null); } /** * Instantiates a new SlidingMenu and attach to Activity. * * @param activity the activity to attach slidingmenu * @param slideStyle the slidingmenu style */ public SlidingMenu(Activity activity, int slideStyle) { this(activity, null); this.attachToActivity(activity, slideStyle); } /** * Instantiates a new SlidingMenu. * * @param context the associated Context * @param attrs the attrs */ public SlidingMenu(Context context, AttributeSet attrs) { this(context, attrs, 0); } /** * Instantiates a new SlidingMenu. * * @param context the associated Context * @param attrs the attrs * @param defStyle the def style */ public SlidingMenu(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); LayoutParams behindParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mViewBehind = new CustomViewBehind(context); addView(mViewBehind, behindParams); LayoutParams aboveParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mViewAbove = new CustomViewAbove(context); addView(mViewAbove, aboveParams); // register the CustomViewBehind with the CustomViewAbove mViewAbove.setCustomViewBehind(mViewBehind); mViewBehind.setCustomViewAbove(mViewAbove); mViewAbove.setOnPageChangeListener(new OnPageChangeListener() { public static final int POSITION_OPEN = 0; public static final int POSITION_CLOSE = 1; public static final int POSITION_SECONDARY_OPEN = 2; public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { if (position == POSITION_OPEN && mOpenListener != null) { mOpenListener.onOpen(); } else if (position == POSITION_CLOSE && mCloseListener != null) { mCloseListener.onClose(); } else if (position == POSITION_SECONDARY_OPEN && mSecondaryOpenListner != null ) { mSecondaryOpenListner.onOpen(); } } }); // now style everything! TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingMenu); // set the above and behind views if defined in xml int mode = ta.getInt(R.styleable.SlidingMenu_mode, LEFT); setMode(mode); int viewAbove = ta.getResourceId(R.styleable.SlidingMenu_viewAbove, -1); if (viewAbove != -1) { setContent(viewAbove); } else { setContent(new FrameLayout(context)); } int viewBehind = ta.getResourceId(R.styleable.SlidingMenu_viewBehind, -1); if (viewBehind != -1) { setMenu(viewBehind); } else { setMenu(new FrameLayout(context)); } int touchModeAbove = ta.getInt(R.styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN); setTouchModeAbove(touchModeAbove); int touchModeBehind = ta.getInt(R.styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN); setTouchModeBehind(touchModeBehind); int offsetBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindOffset, -1); int widthBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindWidth, -1); if (offsetBehind != -1 && widthBehind != -1) throw new IllegalStateException("Cannot set both behindOffset and behindWidth for a SlidingMenu"); else if (offsetBehind != -1) setBehindOffset(offsetBehind); else if (widthBehind != -1) setBehindWidth(widthBehind); else setBehindOffset(0); float scrollOffsetBehind = ta.getFloat(R.styleable.SlidingMenu_behindScrollScale, 0.33f); setBehindScrollScale(scrollOffsetBehind); int shadowRes = ta.getResourceId(R.styleable.SlidingMenu_shadowDrawable, -1); if (shadowRes != -1) { setShadowDrawable(shadowRes); } int shadowWidth = (int) ta.getDimension(R.styleable.SlidingMenu_shadowWidth, 0); setShadowWidth(shadowWidth); boolean fadeEnabled = ta.getBoolean(R.styleable.SlidingMenu_fadeEnabled, true); setFadeEnabled(fadeEnabled); float fadeDeg = ta.getFloat(R.styleable.SlidingMenu_fadeDegree, 0.33f); setFadeDegree(fadeDeg); boolean selectorEnabled = ta.getBoolean(R.styleable.SlidingMenu_selectorEnabled, false); setSelectorEnabled(selectorEnabled); int selectorRes = ta.getResourceId(R.styleable.SlidingMenu_selectorDrawable, -1); if (selectorRes != -1) setSelectorDrawable(selectorRes); ta.recycle(); } /** * Attaches the SlidingMenu to an entire Activity * * @param activity the Activity * @param slideStyle either SLIDING_CONTENT or SLIDING_WINDOW */ public void attachToActivity(Activity activity, int slideStyle) { attachToActivity(activity, slideStyle, false); } /** * Attaches the SlidingMenu to an entire Activity * * @param activity the Activity * @param slideStyle either SLIDING_CONTENT or SLIDING_WINDOW * @param actionbarOverlay whether or not the ActionBar is overlaid */ public void attachToActivity(Activity activity, int slideStyle, boolean actionbarOverlay) { if (slideStyle != SLIDING_WINDOW && slideStyle != SLIDING_CONTENT) throw new IllegalArgumentException("slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT"); if (getParent() != null) throw new IllegalStateException("This SlidingMenu appears to already be attached"); // get the window background TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowBackground}); int background = a.getResourceId(0, 0); a.recycle(); switch (slideStyle) { case SLIDING_WINDOW: mActionbarOverlay = false; ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); // save ActionBar themes that have transparent assets decorChild.setBackgroundResource(background); decor.removeView(decorChild); decor.addView(this); setContent(decorChild); break; case SLIDING_CONTENT: mActionbarOverlay = actionbarOverlay; // take the above view out of ViewGroup contentParent = (ViewGroup)activity.findViewById(android.R.id.content); View content = contentParent.getChildAt(0); contentParent.removeView(content); contentParent.addView(this); setContent(content); // save people from having transparent backgrounds if (content.getBackground() == null) content.setBackgroundResource(background); break; } } /** * Set the above view content from a layout resource. The resource will be inflated, adding all top-level views * to the above view. * * @param res the new content */ public void setContent(int res) { setContent(LayoutInflater.from(getContext()).inflate(res, null)); } /** * Set the above view content to the given View. * * @param view The desired content to display. */ public void setContent(View view) { mViewAbove.setContent(view); showContent(); } /** * Retrieves the current content. * @return the current content */ public View getContent() { return mViewAbove.getContent(); } /** * Set the behind view (menu) content from a layout resource. The resource will be inflated, adding all top-level views * to the behind view. * * @param res the new content */ public void setMenu(int res) { setMenu(LayoutInflater.from(getContext()).inflate(res, null)); } /** * Set the behind view (menu) content to the given View. * * @param view The desired content to display. */ public void setMenu(View v) { mViewBehind.setContent(v); } /** * Retrieves the main menu. * @return the main menu */ public View getMenu() { return mViewBehind.getContent(); } /** * Set the secondary behind view (right menu) content from a layout resource. The resource will be inflated, adding all top-level views * to the behind view. * * @param res the new content */ public void setSecondaryMenu(int res) { setSecondaryMenu(LayoutInflater.from(getContext()).inflate(res, null)); } /** * Set the secondary behind view (right menu) content to the given View. * * @param view The desired content to display. */ public void setSecondaryMenu(View v) { mViewBehind.setSecondaryContent(v); // mViewBehind.invalidate(); } /** * Retrieves the current secondary menu (right). * @return the current menu */ public View getSecondaryMenu() { return mViewBehind.getSecondaryContent(); } /** * Sets the sliding enabled. * * @param b true to enable sliding, false to disable it. */ public void setSlidingEnabled(boolean b) { mViewAbove.setSlidingEnabled(b); } /** * Checks if is sliding enabled. * * @return true, if is sliding enabled */ public boolean isSlidingEnabled() { return mViewAbove.isSlidingEnabled(); } /** * Sets which side the SlidingMenu should appear on. * @param mode must be either SlidingMenu.LEFT or SlidingMenu.RIGHT */ public void setMode(int mode) { if (mode != LEFT && mode != RIGHT && mode != LEFT_RIGHT) { throw new IllegalStateException("SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT"); } mViewBehind.setMode(mode); } /** * Returns the current side that the SlidingMenu is on. * @return the current mode, either SlidingMenu.LEFT or SlidingMenu.RIGHT */ public int getMode() { return mViewBehind.getMode(); } /** * Sets whether or not the SlidingMenu is in static mode (i.e. nothing is moving and everything is showing) * * @param b true to set static mode, false to disable static mode. */ public void setStatic(boolean b) { if (b) { setSlidingEnabled(false); mViewAbove.setCustomViewBehind(null); mViewAbove.setCurrentItem(1); // mViewBehind.setCurrentItem(0); } else { mViewAbove.setCurrentItem(1); // mViewBehind.setCurrentItem(1); mViewAbove.setCustomViewBehind(mViewBehind); setSlidingEnabled(true); } } /** * Opens the menu and shows the menu view. */ public void showMenu() { showMenu(true); } /** * Opens the menu and shows the menu view. * * @param animate true to animate the transition, false to ignore animation */ public void showMenu(boolean animate) { mViewAbove.setCurrentItem(0, animate); } /** * Opens the menu and shows the secondary menu view. Will default to the regular menu * if there is only one. */ public void showSecondaryMenu() { showSecondaryMenu(true); } /** * Opens the menu and shows the secondary (right) menu view. Will default to the regular menu * if there is only one. * * @param animate true to animate the transition, false to ignore animation */ public void showSecondaryMenu(boolean animate) { mViewAbove.setCurrentItem(2, animate); } /** * Closes the menu and shows the above view. */ public void showContent() { showContent(true); } /** * Closes the menu and shows the above view. * * @param animate true to animate the transition, false to ignore animation */ public void showContent(boolean animate) { mViewAbove.setCurrentItem(1, animate); } /** * Toggle the SlidingMenu. If it is open, it will be closed, and vice versa. */ public void toggle() { toggle(true); } /** * Toggle the SlidingMenu. If it is open, it will be closed, and vice versa. * * @param animate true to animate the transition, false to ignore animation */ public void toggle(boolean animate) { if (isMenuShowing()) { showContent(animate); } else { showMenu(animate); } } /** * Checks if is the behind view showing. * * @return Whether or not the behind view is showing */ public boolean isMenuShowing() { return mViewAbove.getCurrentItem() == 0 || mViewAbove.getCurrentItem() == 2; } /** * Checks if is the behind view showing. * * @return Whether or not the behind view is showing */ public boolean isSecondaryMenuShowing() { return mViewAbove.getCurrentItem() == 2; } /** * Gets the behind offset. * * @return The margin on the right of the screen that the behind view scrolls to */ public int getBehindOffset() { return ((RelativeLayout.LayoutParams)mViewBehind.getLayoutParams()).rightMargin; } /** * Sets the behind offset. * * @param i The margin, in pixels, on the right of the screen that the behind view scrolls to. */ public void setBehindOffset(int i) { // RelativeLayout.LayoutParams params = ((RelativeLayout.LayoutParams)mViewBehind.getLayoutParams()); // int bottom = params.bottomMargin; // int top = params.topMargin; // int left = params.leftMargin; // params.setMargins(left, top, i, bottom); mViewBehind.setWidthOffset(i); } /** * Sets the behind offset. * * @param resID The dimension resource id to be set as the behind offset. * The menu, when open, will leave this width margin on the right of the screen. */ public void setBehindOffsetRes(int resID) { int i = (int) getContext().getResources().getDimension(resID); setBehindOffset(i); } /** * Sets the above offset. * * @param i the new above offset, in pixels */ public void setAboveOffset(int i) { mViewAbove.setAboveOffset(i); } /** * Sets the above offset. * * @param resID The dimension resource id to be set as the above offset. */ public void setAboveOffsetRes(int resID) { int i = (int) getContext().getResources().getDimension(resID); setAboveOffset(i); } /** * Sets the behind width. * * @param i The width the Sliding Menu will open to, in pixels */ @SuppressWarnings("deprecation") public void setBehindWidth(int i) { int width; Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); try { Class<?> cls = Display.class; Class<?>[] parameterTypes = {Point.class}; Point parameter = new Point(); Method method = cls.getMethod("getSize", parameterTypes); method.invoke(display, parameter); width = parameter.x; } catch (Exception e) { width = display.getWidth(); } setBehindOffset(width-i); } /** * Sets the behind width. * * @param res The dimension resource id to be set as the behind width offset. * The menu, when open, will open this wide. */ public void setBehindWidthRes(int res) { int i = (int) getContext().getResources().getDimension(res); setBehindWidth(i); } /** * Gets the behind scroll scale. * * @return The scale of the parallax scroll */ public float getBehindScrollScale() { return mViewBehind.getScrollScale(); } /** * Gets the touch mode margin threshold * @return the touch mode margin threshold */ public int getTouchmodeMarginThreshold() { return mViewBehind.getMarginThreshold(); } /** * Set the touch mode margin threshold * @param touchmodeMarginThreshold */ public void setTouchmodeMarginThreshold(int touchmodeMarginThreshold) { mViewBehind.setMarginThreshold(touchmodeMarginThreshold); } /** * Sets the behind scroll scale. * * @param f The scale of the parallax scroll (i.e. 1.0f scrolls 1 pixel for every * 1 pixel that the above view scrolls and 0.0f scrolls 0 pixels) */ public void setBehindScrollScale(float f) { if (f < 0 && f > 1) throw new IllegalStateException("ScrollScale must be between 0 and 1"); mViewBehind.setScrollScale(f); } /** * Sets the behind canvas transformer. * * @param t the new behind canvas transformer */ public void setBehindCanvasTransformer(CanvasTransformer t) { mViewBehind.setCanvasTransformer(t); } /** * Gets the touch mode above. * * @return the touch mode above */ public int getTouchModeAbove() { return mViewAbove.getTouchMode(); } /** * Controls whether the SlidingMenu can be opened with a swipe gesture. * Options are {@link #TOUCHMODE_MARGIN TOUCHMODE_MARGIN}, {@link #TOUCHMODE_FULLSCREEN TOUCHMODE_FULLSCREEN}, * or {@link #TOUCHMODE_NONE TOUCHMODE_NONE} * * @param i the new touch mode */ public void setTouchModeAbove(int i) { if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN && i != TOUCHMODE_NONE) { throw new IllegalStateException("TouchMode must be set to either" + "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE."); } mViewAbove.setTouchMode(i); } /** * Controls whether the SlidingMenu can be opened with a swipe gesture. * Options are {@link #TOUCHMODE_MARGIN TOUCHMODE_MARGIN}, {@link #TOUCHMODE_FULLSCREEN TOUCHMODE_FULLSCREEN}, * or {@link #TOUCHMODE_NONE TOUCHMODE_NONE} * * @param i the new touch mode */ public void setTouchModeBehind(int i) { if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN && i != TOUCHMODE_NONE) { throw new IllegalStateException("TouchMode must be set to either" + "TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN or TOUCHMODE_NONE."); } mViewBehind.setTouchMode(i); } /** * Sets the shadow drawable. * * @param resId the resource ID of the new shadow drawable */ public void setShadowDrawable(int resId) { setShadowDrawable(getContext().getResources().getDrawable(resId)); } /** * Sets the shadow drawable. * * @param d the new shadow drawable */ public void setShadowDrawable(Drawable d) { mViewBehind.setShadowDrawable(d); } /** * Sets the secondary (right) shadow drawable. * * @param resId the resource ID of the new shadow drawable */ public void setSecondaryShadowDrawable(int resId) { setSecondaryShadowDrawable(getContext().getResources().getDrawable(resId)); } /** * Sets the secondary (right) shadow drawable. * * @param d the new shadow drawable */ public void setSecondaryShadowDrawable(Drawable d) { mViewBehind.setSecondaryShadowDrawable(d); } /** * Sets the shadow width. * * @param resId The dimension resource id to be set as the shadow width. */ public void setShadowWidthRes(int resId) { setShadowWidth((int)getResources().getDimension(resId)); } /** * Sets the shadow width. * * @param pixels the new shadow width, in pixels */ public void setShadowWidth(int pixels) { mViewBehind.setShadowWidth(pixels); } /** * Enables or disables the SlidingMenu's fade in and out * * @param b true to enable fade, false to disable it */ public void setFadeEnabled(boolean b) { mViewBehind.setFadeEnabled(b); } /** * Sets how much the SlidingMenu fades in and out. Fade must be enabled, see * {@link #setFadeEnabled(boolean) setFadeEnabled(boolean)} * * @param f the new fade degree, between 0.0f and 1.0f */ public void setFadeDegree(float f) { mViewBehind.setFadeDegree(f); } /** * Enables or disables whether the selector is drawn * * @param b true to draw the selector, false to not draw the selector */ public void setSelectorEnabled(boolean b) { mViewBehind.setSelectorEnabled(true); } /** * Sets the selected view. The selector will be drawn here * * @param v the new selected view */ public void setSelectedView(View v) { mViewBehind.setSelectedView(v); } /** * Sets the selector drawable. * * @param res a resource ID for the selector drawable */ public void setSelectorDrawable(int res) { mViewBehind.setSelectorBitmap(BitmapFactory.decodeResource(getResources(), res)); } /** * Sets the selector drawable. * * @param b the new selector bitmap */ public void setSelectorBitmap(Bitmap b) { mViewBehind.setSelectorBitmap(b); } /** * Add a View ignored by the Touch Down event when mode is Fullscreen * * @param v a view to be ignored */ public void addIgnoredView(View v) { mViewAbove.addIgnoredView(v); } /** * Remove a View ignored by the Touch Down event when mode is Fullscreen * * @param v a view not wanted to be ignored anymore */ public void removeIgnoredView(View v) { mViewAbove.removeIgnoredView(v); } /** * Clear the list of Views ignored by the Touch Down event when mode is Fullscreen */ public void clearIgnoredViews() { mViewAbove.clearIgnoredViews(); } /** * Sets the OnOpenListener. {@link OnOpenListener#onOpen() OnOpenListener.onOpen()} will be called when the SlidingMenu is opened * * @param listener the new OnOpenListener */ public void setOnOpenListener(OnOpenListener listener) { //mViewAbove.setOnOpenListener(listener); mOpenListener = listener; } /** * Sets the OnOpenListner for secondary menu {@link OnOpenListener#onOpen() OnOpenListener.onOpen()} will be called when the secondary SlidingMenu is opened * * @param listener the new OnOpenListener */ public void setSecondaryOnOpenListner(OnOpenListener listener) { mSecondaryOpenListner = listener; } /** * Sets the OnCloseListener. {@link OnCloseListener#onClose() OnCloseListener.onClose()} will be called when any one of the SlidingMenu is closed * * @param listener the new setOnCloseListener */ public void setOnCloseListener(OnCloseListener listener) { //mViewAbove.setOnCloseListener(listener); mCloseListener = listener; } /** * Sets the OnOpenedListener. {@link OnOpenedListener#onOpened() OnOpenedListener.onOpened()} will be called after the SlidingMenu is opened * * @param listener the new OnOpenedListener */ public void setOnOpenedListener(OnOpenedListener listener) { mViewAbove.setOnOpenedListener(listener); } /** * Sets the OnClosedListener. {@link OnClosedListener#onClosed() OnClosedListener.onClosed()} will be called after the SlidingMenu is closed * * @param listener the new OnClosedListener */ public void setOnClosedListener(OnClosedListener listener) { mViewAbove.setOnClosedListener(listener); } public static class SavedState extends BaseSavedState { private final int mItem; public SavedState(Parcelable superState, int item) { super(superState); mItem = item; } private SavedState(Parcel in) { super(in); mItem = in.readInt(); } public int getItem() { return mItem; } /* (non-Javadoc) * @see android.view.AbsSavedState#writeToParcel(android.os.Parcel, int) */ public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); out.writeInt(mItem); } public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { public SavedState createFromParcel(Parcel in) { return new SavedState(in); } public SavedState[] newArray(int size) { return new SavedState[size]; } }; } /* (non-Javadoc) * @see android.view.View#onSaveInstanceState() */ @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState, mViewAbove.getCurrentItem()); return ss; } /* (non-Javadoc) * @see android.view.View#onRestoreInstanceState(android.os.Parcelable) */ @Override protected void onRestoreInstanceState(Parcelable state) { SavedState ss = (SavedState)state; super.onRestoreInstanceState(ss.getSuperState()); mViewAbove.setCurrentItem(ss.getItem()); } /* (non-Javadoc) * @see android.view.ViewGroup#fitSystemWindows(android.graphics.Rect) */ @SuppressLint("NewApi") @Override protected boolean fitSystemWindows(Rect insets) { int leftPadding = insets.left; int rightPadding = insets.right; int topPadding = insets.top; int bottomPadding = insets.bottom; if (!mActionbarOverlay) { Log.v(TAG, "setting padding!"); setPadding(leftPadding, topPadding, rightPadding, bottomPadding); } return true; } private Handler mHandler = new Handler(); @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void manageLayers(float percentOpen) { if (Build.VERSION.SDK_INT < 11) return; boolean layer = percentOpen > 0.0f && percentOpen < 1.0f; final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE; if (layerType != getContent().getLayerType()) { mHandler.post(new Runnable() { public void run() { if(DEBUG)Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE)); getContent().setLayerType(layerType, null); getMenu().setLayerType(layerType, null); if (getSecondaryMenu() != null) { getSecondaryMenu().setLayerType(layerType, null); } } }); } } }
135bb5ad814480161f0f805266dda46edbf274ea
6be39fc2c882d0b9269f1530e0650fd3717df493
/weixin反编译/sources/com/tencent/mm/protocal/c/yh.java
fcb7f8aa1583d31f7871b9466f09019f4e09ecd1
[]
no_license
sir-deng/res
f1819af90b366e8326bf23d1b2f1074dfe33848f
3cf9b044e1f4744350e5e89648d27247c9dc9877
refs/heads/master
2022-06-11T21:54:36.725180
2020-05-07T06:03:23
2020-05-07T06:03:23
155,177,067
5
0
null
null
null
null
UTF-8
Java
false
false
3,232
java
package com.tencent.mm.protocal.c; import e.a.a.b; import e.a.a.c.a; import java.util.LinkedList; public final class yh extends bek { public int kyA; public LinkedList<hl> wpz = new LinkedList(); protected final int a(int i, Object... objArr) { int fW; byte[] bArr; if (i == 0) { a aVar = (a) objArr[0]; if (this.wRa == null) { throw new b("Not all required fields were included: BaseResponse"); } if (this.wRa != null) { aVar.fZ(1, this.wRa.bkL()); this.wRa.a(aVar); } aVar.fX(2, this.kyA); aVar.d(3, 8, this.wpz); return 0; } else if (i == 1) { if (this.wRa != null) { fW = e.a.a.a.fW(1, this.wRa.bkL()) + 0; } else { fW = 0; } return (fW + e.a.a.a.fU(2, this.kyA)) + e.a.a.a.c(3, 8, this.wpz); } else if (i == 2) { bArr = (byte[]) objArr[0]; this.wpz.clear(); e.a.a.a.a aVar2 = new e.a.a.a.a(bArr, unknownTagHandler); for (fW = com.tencent.mm.bp.a.a(aVar2); fW > 0; fW = com.tencent.mm.bp.a.a(aVar2)) { if (!super.a(aVar2, this, fW)) { aVar2.cKx(); } } if (this.wRa != null) { return 0; } throw new b("Not all required fields were included: BaseResponse"); } else if (i != 3) { return -1; } else { e.a.a.a.a aVar3 = (e.a.a.a.a) objArr[0]; yh yhVar = (yh) objArr[1]; int intValue = ((Integer) objArr[2]).intValue(); LinkedList JD; int size; com.tencent.mm.bp.a fiVar; e.a.a.a.a aVar4; boolean z; switch (intValue) { case 1: JD = aVar3.JD(intValue); size = JD.size(); for (intValue = 0; intValue < size; intValue++) { bArr = (byte[]) JD.get(intValue); fiVar = new fi(); aVar4 = new e.a.a.a.a(bArr, unknownTagHandler); for (z = true; z; z = fiVar.a(aVar4, fiVar, com.tencent.mm.bp.a.a(aVar4))) { } yhVar.wRa = fiVar; } return 0; case 2: yhVar.kyA = aVar3.AEQ.rz(); return 0; case 3: JD = aVar3.JD(intValue); size = JD.size(); for (intValue = 0; intValue < size; intValue++) { bArr = (byte[]) JD.get(intValue); fiVar = new hl(); aVar4 = new e.a.a.a.a(bArr, unknownTagHandler); for (z = true; z; z = fiVar.a(aVar4, fiVar, com.tencent.mm.bp.a.a(aVar4))) { } yhVar.wpz.add(fiVar); } return 0; default: return -1; } } } }
13325f74b97da1d9fa7fde86cef002f36bcf94a6
6a4e0a0c296c7defd8abc70e37c4f6449f6d4dcc
/src/main/java/TestngProject/com/scripts/BaseTest.java
0b1e2c2005d37c8faf2312ba06eb9c7217516794
[]
no_license
Aparna2002/FirstJenkinsRepo
db267794fa015ffb5e1b47df5fd88e37b96c5d25
7d1334aace85387600f15bf2d987a217f1d1eea9
refs/heads/master
2022-07-16T10:09:59.984139
2020-04-17T18:07:55
2020-04-17T18:07:55
230,076,003
1
0
null
2020-10-13T18:26:54
2019-12-25T09:12:35
HTML
UTF-8
Java
false
false
2,383
java
package TestngProject.com.scripts; import java.io.FileInputStream; import java.io.IOException; import java.util.Date; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.apache.log4j.PropertyConfigurator; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import com.relevantcodes.extentreports.ExtentReports; import com.relevantcodes.extentreports.ExtentTest; public class BaseTest { public static WebDriver driver; public static String projectpath=System.getProperty("user.dir"); public static Properties prop; public static ExtentReports report= ExtentManager.getInstance(); public static ExtentTest test; public static String screenshotFilename=null; /* * public static ExtentReports report= ExtentManager.getInstance(); public * static ExtentTest test; */ static { Date dt=new Date(); screenshotFilename=dt.toString().replace(':', '_')+".png"; } public static void init() throws IOException { FileInputStream fis=new FileInputStream(projectpath+"\\data.properties"); prop=new Properties(); prop.load(fis); PropertyConfigurator.configure(projectpath+"\\log4j.properties"); } public static void launch(String browser) { if(prop.getProperty(browser).equals("chrome")) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\GOPALAKRISHNA\\Desktop\\Selenium Jars\\chromedriver_win32\\chromedriver.exe"); driver=new ChromeDriver(); } else if(prop.getProperty(browser).equals("gecko")) { System.getProperty("wedriver.chrome.driver", "C:\\Users\\GOPALAKRISHNA\\Desktop\\Selenium Jars\\geckodriver-v0.26.0-win64\\geckodriver.exe" ); driver=new FirefoxDriver(); System.out.println("chromebrowser"); } } public static void navigateurl(String url) { // driver.get(prop.getProperty(url)); driver.navigate().to(prop.getProperty(url)); } public static void waitforElement(WebElement locator,int seconds) { WebDriverWait wait=new WebDriverWait(driver, seconds); wait.until(ExpectedConditions.elementToBeClickable(locator)); } }
a9cabdbac15e5c24d41c6aad891a10c406c75405
741d96311262fb777bf29375ac583016ecc05c3e
/src/main/java/com/boot/utils/HttpResult.java
011f83a13c0d14b10c908527a2583c96e1ca4fba
[]
no_license
zhaohfup/springboot-mybatis
3571171f2358ed8b0c6477375b0cbb9e9ce94727
d99e7fbbe427e4b4ce608e546888a079f8117f13
refs/heads/master
2021-01-19T17:03:21.561589
2017-09-14T06:45:02
2017-09-14T06:45:02
101,040,293
0
0
null
null
null
null
UTF-8
Java
false
false
1,279
java
package com.boot.utils; import com.alibaba.fastjson.JSONObject; public class HttpResult { /** * 状态码 */ private Integer code; /** * 返回数据 */ private String result; public HttpResult() { } public HttpResult(Integer code, String result) { this.code = code; this.result = result; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getResult() { JSONObject json = JSONObject.parseObject(result); if(json.containsKey("result")){ JSONObject result = json.getJSONObject("result"); return result.toJSONString(); } return result; } public String getResultCode() { JSONObject json = JSONObject.parseObject(result); if(json.containsKey("result")){ JSONObject status = json.getJSONObject("status"); return status.getString("code"); } return result; } public void setResult(String result) { this.result = result; } @Override public String toString() { return String.format("{\"code\":\"%s\",\"result\":%s}", code, result); } }
3c62fcb0b604c4f78a30d9c555fb889684303aab
3dc6e512452d074ed8cb75ef8e8238f89ffa866d
/algoliasearch-common/src/main/java/com/algolia/search/http/AlgoliaRequestKind.java
300793185847a697c5704d4572b51e2d17981dd0
[ "MIT" ]
permissive
wietsevenema/algoliasearch-client-java-2
36258a91f2a918c3387a59746d7597d1ffdc84d8
5602826acd22a1e7f0aae0e6c50b9dd5d7610fa8
refs/heads/master
2021-04-26T23:40:09.140016
2018-08-07T11:23:38
2018-08-07T11:23:38
123,835,137
0
0
null
2018-03-04T22:28:14
2018-03-04T22:28:14
null
UTF-8
Java
false
false
124
java
package com.algolia.search.http; public enum AlgoliaRequestKind { SEARCH_API_READ, SEARCH_API_WRITE, ANALYTICS_API }
f0aabd0aefa1e9ed492c3840d855fd3c3a0c0af0
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/XWIKI-13138-3-28-NSGA_II-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/store/XWikiHibernateStore_ESTest.java
aa2e2c331ea202670e5f6a0ed8c65e050332662e
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
564
java
/* * This file was automatically generated by EvoSuite * Fri Apr 03 05:16:55 UTC 2020 */ package com.xpn.xwiki.store; import org.junit.Test; import static org.junit.Assert.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true) public class XWikiHibernateStore_ESTest extends XWikiHibernateStore_ESTest_scaffolding { @Test public void notGeneratedAnyTest() { // EvoSuite did not generate any tests } }
919f5df75ecc4cd49dba4fd23fa8193168fcaad1
80f6fc80507fa9d23c1a7a2e26f4a0e8db0b59b6
/base/trunk/RMdbIntegration/src/com/epac/plugin/dbIntegration/meta/MetaTable.java
35bb58a86f7e94f34789ed073cab2b8e1bd9101f
[]
no_license
BackupTheBerlios/rmframework-svn
433ef7ea147ddb888092689b9d16ac3b8908f40e
062e95e247275365ecf612a92e792927d30d9d96
refs/heads/master
2021-03-12T20:14:26.065677
2011-10-18T17:41:57
2011-10-18T17:41:57
40,801,991
0
0
null
null
null
null
UTF-8
Java
false
false
1,181
java
package com.epac.plugin.dbIntegration.meta; import java.util.ArrayList; import java.util.List; public class MetaTable { private String id; private String name; private List<IMetaColumn> columnList = new ArrayList<IMetaColumn>(); private List<IMetaIndex> indexList = new ArrayList<IMetaIndex>(); public MetaTable(String id, String name) { this.id = id; this.name = name; } /** * The id of the table * @return */ public String getId() { return id; } /** * The name of the table (mostly the same than the id) * @return the name */ public String getName() { return name; } public void addColumn(IMetaColumn column) { columnList.add(column); } /** * The a column of the table by id * @param id * @return */ public IMetaColumn getColumnById(String id) { for (int i = 0; i < columnList.size(); i++) { if (columnList.get(i).getId().equals(id)) return columnList.get(i); } return new NullMetaColumn(); } public void addIndex(IMetaIndex index) { indexList.add(index); } public List<IMetaColumn> getColumnList() { return columnList; } public List<IMetaIndex> getMetaIndexList() { return indexList; } }
[ "pusteblume@ee2c9ef0-5c3b-0410-85e1-eabd887c3043" ]
pusteblume@ee2c9ef0-5c3b-0410-85e1-eabd887c3043
58dca481a5b7ffdd80bbd9ba2403c4eacedf8329
7bb654971928951a5e4107aa9f836c54705916a2
/halyard-cli/src/main/java/com/netflix/spinnaker/halyard/cli/command/v1/plugins/AbstractHasPluginCommand.java
e77ea0d5eea1aceed4a469a3114149f15c4e824e
[ "Apache-2.0" ]
permissive
armory-io/halyard
ef03b89f038b479c5a9dfee9ff8b9bdb88f33060
595cf43305f82de22a46d64560bd5dfacb89874e
refs/heads/master
2023-07-28T06:29:32.276212
2023-05-02T23:13:36
2023-05-02T23:13:36
151,161,526
2
3
Apache-2.0
2023-07-07T18:59:05
2018-10-01T21:21:06
Java
UTF-8
Java
false
false
1,995
java
/* * Copyright 2019 Armory, Inc. * * 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.netflix.spinnaker.halyard.cli.command.v1.plugins; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.netflix.spinnaker.halyard.cli.command.v1.config.AbstractConfigCommand; import com.netflix.spinnaker.halyard.cli.services.v1.Daemon; import com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler; import com.netflix.spinnaker.halyard.config.model.v1.plugins.Plugin; import java.util.ArrayList; import java.util.List; /** An abstract definition for commands that accept plugins as a main parameter */ @Parameters(separators = "=") public abstract class AbstractHasPluginCommand extends AbstractConfigCommand { @Parameter(description = "The name of the plugin to operate on.", arity = 1) private List<String> plugins = new ArrayList<>(); @Override public String getMainParameter() { return "plugin"; } public Plugin getPlugin() { return new OperationHandler<Plugin>() .setFailureMesssage("Failed to get plugin") .setOperation(Daemon.getPlugin(getCurrentDeployment(), plugins.get(0), false)) .get(); } public String getPluginName() { switch (plugins.size()) { case 0: throw new IllegalArgumentException("No plugin supplied"); case 1: return plugins.get(0); default: throw new IllegalArgumentException("More than one plugin supplied"); } } }
f418c914b7b6f356ab971e268ccd0b6bb4e0bc91
b9ac9e785180a60e5668b90a6ce3c08ad90e3e0e
/src/org/codeforces/algos/contests/CFR565DIV3DivideIt.java
454c77726a06929ee967d505eabc69a831995398
[]
no_license
rkaranam/smart-interviews
b2455d20879f0c2cc80cfe3eac995dfbad0144be
b0c6c83570081b427c263dac55a97ed3c9f99d93
refs/heads/master
2020-05-30T09:49:51.414397
2019-08-19T06:04:19
2019-08-19T06:04:19
189,655,418
1
1
null
null
null
null
UTF-8
Java
false
false
894
java
package org.codeforces.algos.contests; import java.io.BufferedReader; import java.io.InputStreamReader; // Result: AC public class CFR565DIV3DivideIt { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int tc = Integer.parseInt(br.readLine()); for (int i = 0; i < tc; i++) { long inp = Long.parseLong(br.readLine()); int count = 0; if (inp == 1) { System.out.println(0); } else { while (inp != 1) { if (inp % 2 == 0) { inp = inp / 2; count++; } if (inp % 3 == 0) { inp = (2 * inp) / 3; count++; } if (inp % 5 == 0) { inp = (4 * inp) / 5; count++; } if((inp % 2) != 0 && (inp % 3) != 0 && (inp % 5) != 0 && inp != 1) { count = -1; break; } } System.out.println(count); } } } }
a3fd37ee51314aca4ffa01aa5324911e7b5fcc02
559cb366be7e6b46d7072a803b7fb858380e9d2d
/src/main/java/com/zaxxer/hikari/metrics/prometheus/PrometheusMetricsTracker.java
5d03c1ad48e6251940e6992df6b2582a712c1e0d
[ "Apache-2.0" ]
permissive
ElfoLiNk/HikariCP
fd5b57e8f8a47152ade06ea91b91f8bbb5b4e723
2a92bcf2c78ca1a033d3c3826eeb65dc98ac7985
refs/heads/dev
2022-10-01T10:17:19.989393
2021-05-21T08:56:20
2021-05-21T08:56:20
117,736,286
1
0
Apache-2.0
2022-03-13T16:14:34
2018-01-16T20:14:34
Java
UTF-8
Java
false
false
4,562
java
/* * Copyright (C) 2013 Brett Wooldridge * * 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.zaxxer.hikari.metrics.prometheus; import com.zaxxer.hikari.metrics.IMetricsTracker; import com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory.RegistrationStatus; import io.prometheus.client.CollectorRegistry; import io.prometheus.client.Counter; import io.prometheus.client.Summary; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import static com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory.RegistrationStatus.REGISTERED; class PrometheusMetricsTracker implements IMetricsTracker { private final static Counter CONNECTION_TIMEOUT_COUNTER = Counter.build() .name("hikaricp_connection_timeout_total") .labelNames("pool") .help("Connection timeout total count") .create(); private final static Summary ELAPSED_ACQUIRED_SUMMARY = createSummary("hikaricp_connection_acquired_nanos", "Connection acquired time (ns)"); private final static Summary ELAPSED_USAGE_SUMMARY = createSummary("hikaricp_connection_usage_millis", "Connection usage (ms)"); private final static Summary ELAPSED_CREATION_SUMMARY = createSummary("hikaricp_connection_creation_millis", "Connection creation (ms)"); private final static Map<CollectorRegistry, RegistrationStatus> registrationStatuses = new ConcurrentHashMap<>(); private final String poolName; private final HikariCPCollector hikariCPCollector; private final Counter.Child connectionTimeoutCounterChild; private final Summary.Child elapsedAcquiredSummaryChild; private final Summary.Child elapsedUsageSummaryChild; private final Summary.Child elapsedCreationSummaryChild; PrometheusMetricsTracker(String poolName, CollectorRegistry collectorRegistry, HikariCPCollector hikariCPCollector) { registerMetrics(collectorRegistry); this.poolName = poolName; this.hikariCPCollector = hikariCPCollector; this.connectionTimeoutCounterChild = CONNECTION_TIMEOUT_COUNTER.labels(poolName); this.elapsedAcquiredSummaryChild = ELAPSED_ACQUIRED_SUMMARY.labels(poolName); this.elapsedUsageSummaryChild = ELAPSED_USAGE_SUMMARY.labels(poolName); this.elapsedCreationSummaryChild = ELAPSED_CREATION_SUMMARY.labels(poolName); } private void registerMetrics(CollectorRegistry collectorRegistry) { if (registrationStatuses.putIfAbsent(collectorRegistry, REGISTERED) == null) { CONNECTION_TIMEOUT_COUNTER.register(collectorRegistry); ELAPSED_ACQUIRED_SUMMARY.register(collectorRegistry); ELAPSED_USAGE_SUMMARY.register(collectorRegistry); ELAPSED_CREATION_SUMMARY.register(collectorRegistry); } } @Override public void recordConnectionAcquiredNanos(long elapsedAcquiredNanos) { elapsedAcquiredSummaryChild.observe(elapsedAcquiredNanos); } @Override public void recordConnectionUsageMillis(long elapsedBorrowedMillis) { elapsedUsageSummaryChild.observe(elapsedBorrowedMillis); } @Override public void recordConnectionCreatedMillis(long connectionCreatedMillis) { elapsedCreationSummaryChild.observe(connectionCreatedMillis); } @Override public void recordConnectionTimeout() { connectionTimeoutCounterChild.inc(); } private static Summary createSummary(String name, String help) { return Summary.build() .name(name) .labelNames("pool") .help(help) .quantile(0.5, 0.05) .quantile(0.95, 0.01) .quantile(0.99, 0.001) .maxAgeSeconds(TimeUnit.MINUTES.toSeconds(5)) .ageBuckets(5) .create(); } @Override public void close() { hikariCPCollector.remove(poolName); CONNECTION_TIMEOUT_COUNTER.remove(poolName); ELAPSED_ACQUIRED_SUMMARY.remove(poolName); ELAPSED_USAGE_SUMMARY.remove(poolName); ELAPSED_CREATION_SUMMARY.remove(poolName); } }
400c0b83f058d9dace13374c9cc9e92815b4b0cc
9549c82493a396e049abcf001bcf6fbe45b10686
/stream-demo/src/main/java/com/datax/stream/flatmap/TestMap.java
8e980878b63743517a3ff3af375884055370452b
[]
no_license
liuwenbo6688/flink-demo
1c8c479555e1f89b35575601460148bf7c862b90
3a5715bcb971d9c0d8e0cab86ba1f5de33c78183
refs/heads/master
2023-06-08T18:34:03.021385
2021-06-25T05:06:13
2021-06-25T05:06:13
329,849,775
0
0
null
null
null
null
UTF-8
Java
false
false
982
java
package com.datax.stream.flatmap; import org.apache.flink.api.common.functions.MapFunction; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; /** * */ public class TestMap { public static void main(String[] args) throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); /** * 生成10-15 */ DataStream<Long> input = env.generateSequence(10, 15); DataStream plusOne = input.map(new MapFunction<Long, Long>() { @Override public Long map(Long value) throws Exception { /** * 1进1出 */ System.out.println("--------------------" + value); return value + 10; } }); plusOne.print(); env.execute(); } }
6b19d4a7899c5d3be3c16b056f7fcf3620130c50
f28a955d7d9fed9c366a58a20d8a5b646e126da5
/EliminarArreglo.java
dd2fe0135dcc413e0c0ff48bac3c50dae83c867f
[]
no_license
Hienkaab/MOANSO-FLORERIA
7f105fa5e6a6187f0c1d792b2f14f6173a09444d
0ea1d02f1e9eae45947bf335d3e7b15742a73f56
refs/heads/master
2021-08-22T06:27:58.846171
2017-11-29T14:18:28
2017-11-29T14:18:28
105,775,884
1
0
null
null
null
null
UTF-8
Java
false
false
18,874
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 GUI; import javax.swing.JOptionPane; import Conexion.Conexion; import UpperEssential.UpperEssentialLookAndFeel; import java.sql.*; import java.util.*; import javax.swing.table.DefaultTableModel; import java.sql.DriverManager; import java.sql.SQLException; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * @author Admin */ public class EliminarArreglo extends javax.swing.JFrame { CallableStatement cst; Connection cn; Statement stm; ResultSet rs; public EliminarArreglo() { initComponents(); CargarCategoria(); this.setLocationRelativeTo(null); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); tblLista = new javax.swing.JTable(); jLabel2 = new javax.swing.JLabel(); txtCodigo = new javax.swing.JTextField(); btnEliminar = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); btnIngresar = new javax.swing.JButton(); btnModificar = new javax.swing.JButton(); btnEliminar1 = new javax.swing.JButton(); btnLista = new javax.swing.JButton(); btnLista1 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); fondo1 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); cbxCategoria = new javax.swing.JComboBox<>(); jLabel11 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setMaximumSize(new java.awt.Dimension(1600, 915)); setMinimumSize(new java.awt.Dimension(1600, 915)); setPreferredSize(new java.awt.Dimension(1600, 915)); getContentPane().setLayout(null); jLabel1.setFont(new java.awt.Font("Nirmala UI Semilight", 1, 24)); // NOI18N jLabel1.setText("BUSCAR CODIGO"); getContentPane().add(jLabel1); jLabel1.setBounds(30, 290, 430, 60); tblLista.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null}, {null, null}, {null, null}, {null, null} }, new String [] { "Title 1", "Title 2" } )); jScrollPane1.setViewportView(tblLista); getContentPane().add(jScrollPane1); jScrollPane1.setBounds(40, 360, 430, 460); jLabel2.setFont(new java.awt.Font("Segoe UI Semilight", 1, 24)); // NOI18N jLabel2.setText("INGRESAR CODIGO A ELIMINAR"); getContentPane().add(jLabel2); jLabel2.setBounds(530, 310, 410, 70); txtCodigo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CODIGO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI Semilight", 1, 24))); // NOI18N getContentPane().add(txtCodigo); txtCodigo.setBounds(580, 390, 290, 80); btnEliminar.setBackground(new java.awt.Color(255, 255, 255)); btnEliminar.setFont(new java.awt.Font("Segoe UI Semilight", 1, 24)); // NOI18N btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/eliminar.png"))); // NOI18N btnEliminar.setText("ELIMINAR"); btnEliminar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnEliminarActionPerformed(evt); } }); getContentPane().add(btnEliminar); btnEliminar.setBounds(590, 510, 260, 90); jButton2.setBackground(new java.awt.Color(255, 255, 255)); jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/descarga.png"))); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); getContentPane().add(jButton2); jButton2.setBounds(1430, 790, 110, 60); btnIngresar.setBackground(new java.awt.Color(255, 255, 255)); btnIngresar.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N btnIngresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/8761.png"))); // NOI18N btnIngresar.setText("Ingresar"); btnIngresar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnIngresarActionPerformed(evt); } }); getContentPane().add(btnIngresar); btnIngresar.setBounds(1160, 300, 310, 70); btnModificar.setBackground(new java.awt.Color(255, 255, 255)); btnModificar.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/edit2_icon-icons.com_61199.png"))); // NOI18N btnModificar.setText("Modificar"); btnModificar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnModificarActionPerformed(evt); } }); getContentPane().add(btnModificar); btnModificar.setBounds(1160, 390, 310, 70); btnEliminar1.setBackground(new java.awt.Color(255, 255, 255)); btnEliminar1.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N btnEliminar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/eliminar.png"))); // NOI18N btnEliminar1.setText("Eliminar"); btnEliminar1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnEliminar1ActionPerformed(evt); } }); getContentPane().add(btnEliminar1); btnEliminar1.setBounds(1160, 480, 310, 70); btnLista.setBackground(new java.awt.Color(255, 255, 255)); btnLista.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N btnLista.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/list-on-a-notebook-stroke-symbol_icon-icons.com_57808.png"))); // NOI18N btnLista.setText("Lista "); btnLista.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnListaActionPerformed(evt); } }); getContentPane().add(btnLista); btnLista.setBounds(1160, 570, 320, 70); btnLista1.setBackground(new java.awt.Color(255, 255, 255)); btnLista1.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N btnLista1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Vendedor.png"))); // NOI18N btnLista1.setText("Trabajadores"); btnLista1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLista1ActionPerformed(evt); } }); getContentPane().add(btnLista1); btnLista1.setBounds(1160, 660, 320, 70); jLabel4.setFont(new java.awt.Font("Segoe UI Light", 1, 48)); // NOI18N jLabel4.setText("Bienvenido"); getContentPane().add(jLabel4); jLabel4.setBounds(1190, 220, 280, 70); fondo1.setFont(new java.awt.Font("Segoe UI Semilight", 1, 36)); // NOI18N fondo1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3)); getContentPane().add(fondo1); fondo1.setBounds(1130, 210, 380, 560); jLabel3.setFont(new java.awt.Font("Segoe Script", 3, 160)); // NOI18N jLabel3.setText("Rosa Belén"); getContentPane().add(jLabel3); jLabel3.setBounds(260, 10, 960, 180); cbxCategoria.setFont(new java.awt.Font("Segoe UI Semilight", 1, 18)); // NOI18N cbxCategoria.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cbxCategoriaActionPerformed(evt); } }); getContentPane().add(cbxCategoria); cbxCategoria.setBounds(190, 210, 320, 50); jLabel11.setFont(new java.awt.Font("Segoe UI Semilight", 1, 24)); // NOI18N jLabel11.setText("CATEGORIA:"); getContentPane().add(jLabel11); jLabel11.setBounds(30, 220, 220, 32); pack(); }// </editor-fold>//GEN-END:initComponents private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed String codigo; codigo = this.txtCodigo.getText(); eliminarArreglo(codigo); EntradaAdmin entrar = new EntradaAdmin(); entrar.setVisible(true); dispose(); }//GEN-LAST:event_btnEliminarActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed close(); // JOptionPane.showMessageDialog(null, "Hasta Luego"); }//GEN-LAST:event_jButton2ActionPerformed private void btnIngresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIngresarActionPerformed // TODO add your handling code here: RegistrarArreglo entrar = new RegistrarArreglo(); entrar.setVisible(true); dispose(); }//GEN-LAST:event_btnIngresarActionPerformed private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed // TODO add your handling code here: ModificarArreglo entrar = new ModificarArreglo(); entrar.setVisible(true); dispose(); }//GEN-LAST:event_btnModificarActionPerformed private void btnEliminar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminar1ActionPerformed // TODO add your handling code here: EliminarArreglo entrar = new EliminarArreglo(); entrar.setVisible(true); dispose(); }//GEN-LAST:event_btnEliminar1ActionPerformed private void btnListaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnListaActionPerformed // TODO add your handling code here: EntradaAdmin entrar = new EntradaAdmin(); entrar.setVisible(true); dispose(); }//GEN-LAST:event_btnListaActionPerformed private void btnLista1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLista1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_btnLista1ActionPerformed private void cbxCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxCategoriaActionPerformed listarCategoria(); Llenar(); }//GEN-LAST:event_cbxCategoriaActionPerformed public void CargarCategoria(){ Connection cn=null; Vector registros=null; try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); cn=DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=Floreria;" +"user=sa;password=123456"); Statement stm=cn.createStatement(); String query2="Select distinct * from categoriaArreglo"; ResultSet rs=stm.executeQuery(query2); registros=new Vector(); while(rs.next()){ cbxCategoria.addItem(rs.getString("nombre_cat")); } }catch(SQLException e){ JOptionPane.showMessageDialog(rootPane, e.getMessage()); }catch(ClassNotFoundException e){} } private Vector listarCategoria() { Connection con=null; Statement stm=null; Vector reg=null; try{ con = Conexion.getConexion(); stm=con.createStatement(); ResultSet rs = stm.executeQuery("SELECT * FROM Arreglo A JOIN categoriaArreglo C" + " ON A.categ = C.cod_cat "); reg = new Vector(); while(rs.next()){ Vector item = new Vector(); item.add(rs.getString("cod")); item.add(rs.getString("nombre")); //item.add(rs.getInt("stock")); //item.add(rs.getString("nombre_cat")); reg.add(item); } } catch(Exception e){ System.out.print(e); } return reg; } private Vector listar() { Connection con=null; Statement stm=null; Vector reg=null; try{ con = Conexion.getConexion(); stm=con.createStatement(); ResultSet rs = stm.executeQuery("SELECT * FROM Arreglo A JOIN categoriaArreglo C" + " ON A.categ = C.cod_cat and nombre_cat='"+cbxCategoria.getSelectedItem()+"' "); reg = new Vector(); while(rs.next()){ Vector item = new Vector(); item.add(rs.getString("cod")); item.add(rs.getString("nombre")); reg.add(item); } } catch(Exception e){ System.out.print(e); } return reg; } // private Vector listar() { // Connection con=null; // Statement stm=null; // Vector reg=null; // try{ // con = Conexion.getConexion(); // stm=con.createStatement(); // ResultSet rs = stm.executeQuery("SELECT * FROM Arreglo " // + "ORDER BY COD;"); // reg = new Vector(); // // while(rs.next()){ // Vector item = new Vector(); // item.add(rs.getString("cod")); // item.add(rs.getString("nombre")); // reg.add(item); // } // } // catch(Exception e){ // System.out.print(e); // } // return reg; // } private void Llenar() { Vector colu = new Vector(); colu.addElement("Codigo"); colu.addElement("Nombre"); Vector reg = new Vector(); reg = listar(); DefaultTableModel dtm = new DefaultTableModel(reg, colu); this.tblLista.setModel(dtm); } private void close(){ if (JOptionPane.showConfirmDialog(rootPane, "¿Desea Volver al Inicio?", "Cerrar Ventana", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){ // Marca_salida(); Login c = new Login(); c.setVisible(true); dispose(); } } /** * @param args the command line arguments */ public static void main(String args[]) throws UnsupportedLookAndFeelException { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(EliminarArreglo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(EliminarArreglo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(EliminarArreglo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(EliminarArreglo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> UIManager.setLookAndFeel(new UpperEssentialLookAndFeel()); UIManager.setLookAndFeel(new UpperEssentialLookAndFeel("C:\\Users\\Janet\\Desktop\\26-11-17\\Lib UpperEssential\\Chocolate.theme")); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new EliminarArreglo().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnEliminar; private javax.swing.JButton btnEliminar1; private javax.swing.JButton btnIngresar; private javax.swing.JButton btnLista; private javax.swing.JButton btnLista1; private javax.swing.JButton btnModificar; private javax.swing.JComboBox<String> cbxCategoria; private javax.swing.JLabel fondo1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable tblLista; private javax.swing.JTextField txtCodigo; // End of variables declaration//GEN-END:variables private void eliminarArreglo(String codigo) { try { cst = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;" + "database=Floreria;user=sa;password=123456;").prepareCall("{call sp_Eliminar(?)}"); cst.setString("Cod", codigo); int rpta = cst.executeUpdate(); if (rpta == 1) { JOptionPane.showMessageDialog(this,"* "+ codigo+ " eliminado correctamente!!", "Atencion", JOptionPane.INFORMATION_MESSAGE); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } } }
9b7a7947ecce6c9ba8d1816a11ff80cbb6835511
d232c236f88f2442d971c6fd54be397ed217c468
/app/src/main/java/com/yushilei/xmly4fm/BaseApplication.java
85d9a5d6266d1a672082141e61eb65ebe022018e
[]
no_license
Frida240/Xmly4Fm
fc33550bc4599c87850c04ba5ed75941914633e1
ba4c630fc80fef7de3060451150423f468ab721b
refs/heads/master
2021-05-31T20:51:06.739216
2016-02-26T04:22:34
2016-02-26T04:22:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
325
java
package com.yushilei.xmly4fm; import android.app.Application; import com.facebook.drawee.backends.pipeline.Fresco; /** * Created by yushilei on 2016/1/22. */ public class BaseApplication extends Application { @Override public void onCreate() { super.onCreate(); Fresco.initialize(this); } }
7356227d4246ccb6c235b63e46a9eb5b47313340
6754185afe91793676404f4d75aa034b1787a3ea
/JavaTip/src/main/java/com/ngocvm/example/Day51/Trainer.java
4671aab9240e624ea8ef0be219b0110995e663a8
[]
no_license
ngocvm/learnjava
bfcf04ff64693626d2ea0700c8908a177ab2e3b3
6b96b91c3e9ca939448fbc794f9679ea8cb6be92
refs/heads/master
2023-04-06T19:39:16.612774
2022-10-19T02:49:34
2022-10-19T02:49:34
214,346,762
0
0
null
2022-10-19T02:49:36
2019-10-11T04:57:43
Java
UTF-8
Java
false
false
512
java
package com.ngocvm.example.Day51; public class Trainer { public void teach(Animal animal) { animal.move(); animal.eat(); animal.sleep(); } public static void main(String[] args) { Trainer trainer = new Trainer(); Dog dog = new Dog(); Bird bird = new Bird(); Fish fish = new Fish(); Snake snake = new Snake(); trainer.teach(dog); trainer.teach(bird); trainer.teach(fish); trainer.teach(snake); } }
560f3c4e36d4651057b6a03e1ec8e578c7b4d926
e476db3e716e5c5aa4f71bab1735554a73b72ab9
/Department Project/CreateAccountMain.java
57c0bb8b85a5403e1430bf7fc8e55cb18151afc0
[]
no_license
sami-malla/java
a31858f407f7211f85dc55d7035a6b2fa5a310a5
4aef9e1afdce486e420aa71f4276a102a153497c
refs/heads/master
2020-09-14T14:35:01.107260
2019-12-03T12:48:50
2019-12-03T12:48:50
223,157,484
0
0
null
null
null
null
UTF-8
Java
false
false
614
java
package com.hcl.department; import java.util.List; public class CreateAccountMain { public static void main(String[] args) { DepartmentDAO dao=new DepartmentDAO(); List<Department> DepartmentList=dao.showDepartment(); for (Department department : DepartmentList) { System.out.println("Deptno" +department.getDeptno()); System.out.println("Dname" +department.getDname()); System.out.println("Loc" +department.getLoc()); System.out.println("City" +department.getCity()); System.out.println("Head" +department.getHead()); } } }
67f6297f97a672735b6d3c8052bdded6bd373989
702ea22b3234309c69968d47cf472f63ea0bfd56
/src/ventanas/VentanaAcceso.java
5ddf683c1e519135a30cd1ee364da8fd05e38a28
[]
no_license
luiscruzs/6sis1b_Eqmuseo
90da08fe258d34b380196dd08f385723c3211f2b
7a96fcbd4271d3a04a3684fad91accc2d9a93a1b
refs/heads/master
2022-12-01T01:36:11.307157
2020-08-07T20:29:53
2020-08-07T20:29:53
285,038,937
0
0
null
null
null
null
ISO-8859-10
Java
false
false
3,990
java
package ventanas; import java.awt.BorderLayout; import java.awt.Color; import java.awt.EventQueue; import java.awt.Font; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import imagen.fondo; @SuppressWarnings("serial") public class VentanaAcceso extends JFrame { @SuppressWarnings("unused") private JPanel contentPane; private JPasswordField cont; private JTextField usu; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { //UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel"); VentanaAcceso frame = new VentanaAcceso(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public VentanaAcceso() { setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\crair\\Downloads\\1626195.png")); setTitle("INICIO"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); fondo p = new fondo(); p.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(p); p.setLayout(null); JLabel lblNewLabel = new JLabel("BIENVENIDO"); lblNewLabel.setForeground(Color.YELLOW); lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 17)); lblNewLabel.setBounds(173, 11, 119, 30); p.add(lblNewLabel); cont = new JPasswordField(); cont.setBounds(173, 144, 119, 20); p.add(cont); JLabel lblNewLabel_1 = new JLabel("USUARIO"); lblNewLabel_1.setForeground(Color.YELLOW); lblNewLabel_1.setFont(new Font("Wide Latin", Font.BOLD | Font.ITALIC, 10)); lblNewLabel_1.setBounds(173, 119, 119, 14); p.add(lblNewLabel_1); JLabel lblNewLabel_2 = new JLabel("CONTRASE\u00D1A"); lblNewLabel_2.setForeground(Color.YELLOW); lblNewLabel_2.setFont(new Font("Wide Latin", Font.BOLD | Font.ITALIC, 10)); lblNewLabel_2.setBounds(159, 175, 157, 14); p.add(lblNewLabel_2); usu = new JTextField(); usu.setBounds(173, 85, 119, 20); p.add(usu); usu.setColumns(10); JButton btnNewButton = new JButton("Aceptar"); btnNewButton.addActionListener(new ActionListener() { @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent arg0) { //CONTRASEŅAprimer campo USUARIO segundo campo if(cont.getText().contentEquals("54321") & usu.getText().contentEquals("taquilla")) { /*taquilla ejem1 = new taquilla(); ejem1.setVisible(true); dispose();*/ } else if(cont.getText().contentEquals("123456") & usu.getText().contentEquals("Bobras")) { Vobras ejem2 = new Vobras(); ejem2.setVisible(true); dispose(); } else if(cont.getText().contentEquals("USE3MN") & usu.getText().contentEquals("userh")) { /*rh ejem3 = new rh(); ejem3.setVisible(true); dispose();*/ } else if(cont.getText().contentEquals("USEGGMN") & usu.getText().contentEquals("usegerente")) { /*gerente ejem4 = new gerente(); ejem4.setVisible(true); dispose();*/ }else { JOptionPane.showMessageDialog(null,"Usuario no reconocido"); } } }); btnNewButton.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 11)); btnNewButton.setBounds(59, 215, 89, 23); p.add(btnNewButton); JButton btnNewButton_1 = new JButton("Cancelar"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); btnNewButton_1.setFont(new Font("Verdana", Font.BOLD | Font.ITALIC, 11)); btnNewButton_1.setBounds(265, 215, 89, 23); p.add(btnNewButton_1); } }
7ec311a8002a9668b32fd632aa5fa6a1637132ab
6484ee2538367807cf6da122107432ac59ea1ea7
/app/src/main/java/com/abdulaziz/goappsaziz/ui/home/HomeViewModel.java
547d43685803c41a56082c60d63fb55d600dcde9
[]
no_license
AbdulAzizTIFA/TugasAppmob3ke2
19d69730ddda2876bda3e23126251162e4766f5a
7e55d1b7e05232ebe15f1fa66a1b32f35765dfb9
refs/heads/main
2023-04-06T16:57:17.809987
2021-04-03T17:47:27
2021-04-03T17:47:27
354,354,407
0
0
null
null
null
null
UTF-8
Java
false
false
447
java
package com.abdulaziz.goappsaziz.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; } }
82f53de6fb2f02343902af2f62371d75c05af62c
ea561cc3cb6c887cadd99facb92049f4e88200c3
/janus-plugin/src/main/java/de/codecentric/janus/plugin/bootstrap/step/RepositoryCommitStep.java
1c27345edd9cf905bb3fdcc28aeceabc09e0642a
[ "Apache-2.0" ]
permissive
codecentric/janus-plugin
5b2e6b2e89272327fad42b51251fdb628ebc9346
eb94ec33d855eb88d64f9fc21df4875bdeeffc83
refs/heads/master
2023-03-21T23:36:53.767665
2012-05-21T09:56:50
2012-05-21T09:56:50
4,884,127
0
0
null
null
null
null
UTF-8
Java
false
false
1,621
java
/* * Copyright (C) 2012 codecentric AG * * 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 de.codecentric.janus.plugin.bootstrap.step; import de.codecentric.janus.plugin.bootstrap.BootstrapLogger; import de.codecentric.janus.plugin.bootstrap.ParsedFormData; /** * @author Ben Ripkens <[email protected]> */ public class RepositoryCommitStep extends AbstractBuildDependentStep { public RepositoryCommitStep(ParsedFormData data, BootstrapLogger logger) { super(data, logger); } @Override protected String beforeMessage() { return "Commiting changes to (remote) repository."; } @Override protected String successMessage() { return "Successfully commited all changes."; } @Override protected String failMessage(String buildUrl) { return "Failed to commit changes. Build job " + getBuildJobName() + "failed. See " + buildUrl + " for details."; } @Override protected String getBuildJobName() { return data.getVcsConfiguration().getCommitBuildJob(); } }
cabe657557cc49a2833dc3ceffd9045e7d140e85
b562e704a25ff234a436fa6dc1f08faeb3581eb4
/visitors/src/main/java/com/dynamicobjx/visitorapp/activities/ExhibitorDetailsActivity.java
df11f71b258c7529dba87779bbb02e26d23cf11c
[]
no_license
rashanonto/EASTS_APP
96f62ae01c698aa15edfa0d24ca242eab61e6dab
ecd6255d7effb351c89f45ef744114ca858f816a
refs/heads/master
2021-01-01T06:10:09.157503
2015-09-07T01:12:22
2015-09-07T01:12:22
41,987,991
0
0
null
null
null
null
UTF-8
Java
false
false
15,944
java
package com.dynamicobjx.visitorapp.activities; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.animation.DecelerateInterpolator; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.bumptech.glide.Glide; import com.dynamicobjx.visitorapp.R; import com.dynamicobjx.visitorapp.models.Exhibitor; import com.easyandroidanimations.library.Animation; import com.easyandroidanimations.library.AnimationListener; import com.easyandroidanimations.library.FlipHorizontalAnimation; import com.easyandroidanimations.library.RotationAnimation; import com.parse.ParseException; import com.parse.ParseObject; import com.parse.SaveCallback; import java.util.ArrayList; import java.util.Arrays; import butterknife.ButterKnife; import butterknife.InjectView; public class ExhibitorDetailsActivity extends BaseActivity { @InjectView(R.id.tvFav) TextView tvFav; @InjectView(R.id.tvExhibitorName) TextView tvExhibitorName; @InjectView(R.id.Vlogo) ImageView ivLogo; @InjectView(R.id.tvExhibitorDesc) TextView tvExhibitorDesc; @InjectView(R.id.llContacts) LinearLayout llContacts; @InjectView(R.id.llEmail) LinearLayout llEmail; @InjectView(R.id.llFax) LinearLayout llFax; @InjectView(R.id.llWeb) LinearLayout llWeb; @InjectView(R.id.tvBoothNo) TextView tvBoothNo; @InjectView(R.id.tvLocateOnMap) TextView tvLocateOnMap; @InjectView(R.id.llCategories) LinearLayout llCategories; @InjectView(R.id.llCompanyDesc) LinearLayout llCompanyDesc; @InjectView(R.id.tvSchedEvent) TextView tvSchedEvent; @InjectView(R.id.tvContactPerson) TextView tvContactPerson; @InjectView(R.id.tvAddress) TextView tvAddress; private LayoutInflater inflater; private Exhibitor exhibitor; private String lastScreen = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_exhibitor_details); ButterKnife.inject(this); setFont(getTfSegoe(),tvExhibitorDesc); setFont(getTfSegoe(),tvBoothNo); setFont(getTfSegoe(),tvLocateOnMap); setFont(getTfSegoe(),tvSchedEvent); setFont(getTfSegoe(),tvContactPerson); setFont(getTfSegoe(),tvAddress); inflater = LayoutInflater.from(this); Bundle bundle = getIntent().getExtras(); lastScreen = getIntent().getStringExtra("lastScreen"); initActionBar("Exhibitor Details").setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); animateToRight(ExhibitorDetailsActivity.this); } }); exhibitor = bundle.getParcelable("exhibitor"); if (exhibitor.getPackageType().equals("C")) { llCompanyDesc.setVisibility(View.GONE); } else { llCompanyDesc.setVisibility(View.VISIBLE); } tvExhibitorName.setText(exhibitor.getCompanyName()); tvExhibitorDesc.setText(exhibitor.getDecsription()); tvBoothNo.setText(exhibitor.getBoothNo()); tvSchedEvent.setText(exhibitor.getScheduleEvent()); tvAddress.setText(exhibitor.getAddress()); tvContactPerson.setText(exhibitor.getContactPerson()); setContactsLayout(llContacts); setEmailLayout(llEmail); setFaxLayout(llFax); setWebLayout(llWeb); Glide.with(this).load(exhibitor.getLogoUrl()).into(ivLogo); if (lastScreen.equals("Home")) { getMyBookMarks(); if (!getMyFavorites().contains(exhibitor.getObjectId())) { ParseObject visitor = getVisitor().get(0); getMyFavorites().add(exhibitor.getObjectId()); visitor.remove("myBookMarked"); visitor.addAll("myBookMarked",getMyFavorites()); visitor.saveEventually(); exhibitor.setFavorite(true); tvFav.setText(getResources().getString(R.string.fa_star_empty)); showToast(exhibitor.getCompanyName() + " successfully into your visits"); } else { showToast(exhibitor.getCompanyName() + " already in your visits"); exhibitor.setFavorite(false); tvFav.setText(getResources().getString(R.string.fa_star_full)); } tvFav.setVisibility(View.GONE); } else { tvFav.setVisibility(View.VISIBLE); if (exhibitor.isFavorite()) { tvFav.setText(getResources().getString(R.string.fa_star_full)); } else { tvFav.setText(getResources().getString(R.string.fa_star_empty)); } } setFont(getTfBootstrap(),tvFav); tvFav.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new FlipHorizontalAnimation(view) .setDuration(500) .setInterpolator(new DecelerateInterpolator()) .setPivot(RotationAnimation.PIVOT_CENTER) .setListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { boolean isFavorite = exhibitor.isFavorite(); isFavorite = !isFavorite; ArrayList<String> toUpdate = new ArrayList<>(); ParseObject visitor = getVisitor().get(0); if (isFavorite) { exhibitor.setFavorite(true); Log.d("myFave","update to true"); tvFav.setText(getResources().getString(R.string.fa_star_full)); visitor.addUnique("myBookMarked", exhibitor.getObjectId()); getMyFavorites().add(exhibitor.getObjectId()); visitor.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.d("myFave","successfully saved!"); } else { Log.d("myFave","error while saving --> " + e.toString()); } } }); } else { exhibitor.setFavorite(false); Log.d("myFave","update to false"); for (String s : getMyFavorites()) { if (!s.equals(exhibitor.getObjectId())) { toUpdate.add(s); } } tvFav.setText(getResources().getString(R.string.fa_star_empty)); Log.d("myFave","to update --> " + toUpdate.toString()); visitor.remove("myBookMarked"); visitor.addAll("myBookMarked", toUpdate); visitor.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.d("myFave","successfully saved!"); } else { Log.d("myFave","error while saving --> " + e.toString()); } } }); } } }).animate(); } }); setMenuFont(); if (exhibitor.getCategories().size() > 0) { for (int i = 0 ; i < exhibitor.getCategories().size() ; i++) { llCategories.addView(setCategoriesLayout( exhibitor.getCategories().get(i),exhibitor.getCategoriesId().get(i))); } } else { setCategoriesLayout("No categories found",""); } tvLocateOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(ExhibitorDetailsActivity.this,MapsActivity.class)); animateToRight(ExhibitorDetailsActivity.this); finish(); } }); } private void setMenuFont() { int[] iconIds = {R.id.tvIconContact,R.id.tvIconEmail,R.id.tvIconFax,R.id.tvIconWebsite, R.id.tvIconLocate,R.id.tvIconBoothNo,R.id.tvIconAddress}; for (int i = 0 ; i < iconIds.length ; i++) { setFont(getTfBootstrap(),(TextView)findViewById(iconIds[i])); } } @Override public void onBackPressed() { super.onBackPressed(); finish(); animateToRight(ExhibitorDetailsActivity.this); } private void setContactsLayout(LinearLayout parent) { ArrayList<String> contacts = new ArrayList<>(); if (exhibitor.getContactNo().contains(";")) { contacts.addAll(Arrays.asList(exhibitor.getContactNo().split(";"))); } else { contacts.add(exhibitor.getContactNo()); } for (String c : contacts) { TextView textView = (TextView)inflater.inflate(R.layout.row_exhibitor_details,null); setFont(getTfSegoe(),textView); textView.setText(c.trim()); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String number = ((TextView)view).getText().toString(); if (number.equals(("Not available"))) { showToast("number not available!"); } else { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:" + number)); startActivity(intent); } } }); parent.addView(textView); } } private void setEmailLayout(LinearLayout parent) { ArrayList<String> email = new ArrayList<>(); if (exhibitor.getEmail().contains(";")) { email.addAll(Arrays.asList(exhibitor.getEmail().split(";"))); } else { email.add(exhibitor.getEmail()); } for (String c : email) { TextView textView = (TextView)inflater.inflate(R.layout.row_exhibitor_details,null); setFont(getTfSegoe(),textView); textView.setText(c.trim()); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String email = ((TextView)view).getText().toString(); if (email.equals(("Not available"))) { showToast("Email not available!"); } else { final Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{email}); startActivity(intent); } } }); parent.addView(textView); } } private void setFaxLayout(LinearLayout parent) { ArrayList<String> fax = new ArrayList<>(); if (exhibitor.getFax().contains(";")) { fax.addAll(Arrays.asList(exhibitor.getFax().split(";"))); } else { fax.add(exhibitor.getFax()); } for (String c : fax) { TextView textView = (TextView)inflater.inflate(R.layout.row_exhibitor_details,null); setFont(getTfSegoe(),textView); textView.setText(c.trim()); parent.addView(textView); } } private void setWebLayout(LinearLayout parent) { ArrayList<String> web = new ArrayList<>(); if (exhibitor.getWebsite().contains(";")) { web.addAll(Arrays.asList(exhibitor.getWebsite().split(";"))); } else { web.add(exhibitor.getWebsite()); } for (String c : web) { TextView textView = (TextView)inflater.inflate(R.layout.row_exhibitor_details,null); setFont(getTfSegoe(),textView); textView.setText(c.trim()); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String url = ((TextView)view).getText().toString(); if (url.equals(("Not available"))) { showToast("Website not available!"); } else { if (!url.contains("http://")) { url = "http://" + url; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } } }); parent.addView(textView); } } private View setCategoriesLayout(final String category, final String categoryId) { View view = inflater.inflate(R.layout.dynamic_categories_layout, null); TextView tvTag = (TextView)view.findViewById(R.id.tvTagIcon); TextView tvNewCategory = (TextView)view.findViewById(R.id.tvNewCategory); setFont(getTfSegoe(),tvNewCategory); setFont(getTfBootstrap(), tvTag); tvNewCategory.setText(category); if (categoryId.equals("")) { tvTag.setVisibility(View.GONE); } else { tvNewCategory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TextView tvCat = (TextView)view; ArrayList<Exhibitor> exhibitorBySelectedCategory = new ArrayList<>(); String selectedCategory = tvCat.getText().toString(); for (Exhibitor exhibitor : getExhibitorList()) { ArrayList<String> exhibitorCategories = exhibitor.getCategories(); if (exhibitorCategories.contains(selectedCategory)) { exhibitorBySelectedCategory.add(exhibitor); } } sortArrayList(exhibitorBySelectedCategory); Bundle bundle = new Bundle(); bundle.putString("lastScreen", selectedCategory); bundle.putParcelableArrayList("exhibitorByCategory", exhibitorBySelectedCategory); Intent intent = new Intent(ExhibitorDetailsActivity.this, ExhibitorsActivity.class); intent.putExtras(bundle); startActivity(intent); animateToLeft(ExhibitorDetailsActivity.this); finish(); } }); } return view; } }
6fa5f0e5066c1387aa2df0149c6f4d5e0a2a01c4
77db6f1498a01c5a3e2cde703d3cef59297ec2d0
/her/src/main/java/com/eeit95/her/model/dao/font/FontDescriptionDAOHibernate.java
0b7fbcc27041e0ac64e15a542161451533057b69
[]
no_license
EEIT95Team01/her
96320c7f768f486f7187bc8c11d7feb50b5b947f
0be0ea7275dfe81607c0f49b7aa9a17b7fcc984e
refs/heads/master
2021-01-01T18:41:21.350981
2017-08-24T15:55:03
2017-08-24T15:55:03
98,409,840
0
0
null
null
null
null
UTF-8
Java
false
false
4,770
java
package com.eeit95.her.model.dao.font; import java.io.File; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Repository; import com.eeit95.her.model.advertisement.AdvertisementBean; import com.eeit95.her.model.card.CardDescriptionBean; import com.eeit95.her.model.dao.advertisement.AdvertisementDAOHibernate; import com.eeit95.her.model.font.FontBean; import com.eeit95.her.model.font.FontDescriptionBean; import com.eeit95.her.model.font.FontDescriptionDAOInterface; import com.eeit95.her.model.misc.SpringJavaConfiguration; @Repository public class FontDescriptionDAOHibernate implements FontDescriptionDAOInterface { @Autowired private SessionFactory sessionFactory; public Session getSession() { return sessionFactory.getCurrentSession(); } @Override public FontDescriptionBean insert(FontDescriptionBean fontDescriptionBean) { if (fontDescriptionBean != null) { Criteria criteria = this.getSession().createCriteria(FontDescriptionBean.class); criteria.add(Restrictions.eq("fontId", fontDescriptionBean.getFontId())); criteria.add(Restrictions.eq("orderNo", fontDescriptionBean.getOrderNo())); List<FontDescriptionBean> list = criteria.list(); if (list.isEmpty()) { this.getSession().save(fontDescriptionBean); return fontDescriptionBean; } } return null; } @Override public FontDescriptionBean update(FontDescriptionBean fontDescriptionBean) { Criteria criteria = this.getSession().createCriteria(FontDescriptionBean.class); criteria.add(Restrictions.eq("fontId", fontDescriptionBean.getFontId())); criteria.add(Restrictions.eq("orderNo", fontDescriptionBean.getOrderNo())); List<FontDescriptionBean> list = criteria.list(); FontDescriptionBean result = list.get(0); if (result != null) { result.setText(fontDescriptionBean.getText()); result.setImage(fontDescriptionBean.getImage()); } return result; } @Override public boolean delete(String fontId) { // List<FontDescriptionBean> bean = this.getSession().get(FontDescriptionBean.class, fontId); List<FontDescriptionBean> list = null; Session session = this.getSession(); Criteria criteria = session.createCriteria(FontDescriptionBean.class); criteria.add(Restrictions.eq("fontId", fontId)); list = criteria.list(); if (!list.isEmpty()) { for(FontDescriptionBean fontDescriptionBeans : list) { this.getSession().delete(fontDescriptionBeans); } return true; } return false; } @Override public List<FontDescriptionBean> selectById(String fontId) { List<FontDescriptionBean> result = null; Session session = this.getSession(); // Criteria criteria = session.createCriteria(FontDescriptionBean.class); // criteria.add(Restrictions.eq("fontId", fontBean)); // result = criteria.list(); String Select_By_Id = "from FontDescriptionBean where fontId = ?"; Query query = session.createQuery(Select_By_Id); query.setParameter(0, fontId); result = query.list(); return result; } @Override public List<FontDescriptionBean> selectAll() { List<FontDescriptionBean> list = null; Session session = this.getSession(); Criteria criteria = session.createCriteria(FontDescriptionBean.class); // criteria.addOrder(Order.asc("fontId")); // criteria.addOrder(Order.asc("orderNo")); list = criteria.list(); return list; } public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(SpringJavaConfiguration.class); SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory"); FontDescriptionDAOHibernate dao = (FontDescriptionDAOHibernate) context.getBean("fontDescriptionDAOHibernate"); try { sessionFactory.getCurrentSession().beginTransaction(); List<FontDescriptionBean> list = dao.selectById("f01701110001"); for (FontDescriptionBean bean : list) { System.out.print(bean.getFontId() + ", "); System.out.print(bean.getOrderNo() + ", "); System.out.print(bean.getText() + ", "); System.out.print(bean.getImage()); System.out.println(); } sessionFactory.getCurrentSession().getTransaction().commit(); } catch (RuntimeException ex) { sessionFactory.getCurrentSession().getTransaction().rollback(); } } }
[ "123@test" ]
123@test
cd69aa2152e2038efeb4475d37b46e3f170e9c28
cf8874dc8ddfb346cf50eede4416a0c53d7543b9
/sql/src/main/java/ru/job4j/tracker/di/Main.java
4e3d52bd6aa3488e0a65e59d8b6a59bf1b270ce8
[]
no_license
BaikovSergey/junior
9aac804244f5b8227967c8821c12f250d3b7d9fb
531a5e56253963130366a529a73d5a67668f52d2
refs/heads/master
2022-12-22T10:26:46.950288
2020-10-22T13:58:02
2020-10-22T13:58:02
174,133,491
0
0
null
2022-12-16T05:14:26
2019-03-06T11:37:33
Java
UTF-8
Java
false
false
435
java
package ru.job4j.tracker.di; import ru.job4j.tracker.ConsoleInput; public class Main { public static void main(String[] args) { Context context = new Context(); context.reg(Store.class); context.reg(ConsoleInput.class); context.reg(StartUIdi.class); StartUIdi ui = context.get(StartUIdi.class); ui.add("Petr Arsentev"); ui.add("Ivan ivanov"); ui.print(); } }
507b3044f0627d3c45db6f7602b28309933cfa9e
484731b4e755488d1e56906c57bbdf4971265e64
/src/stream1/reader/FileReaderTest.java
d460b6c11c5255aaf5036fea529434cf05ebf95e
[]
no_license
alstndhffla/Java_programming
58cfff03053c5d128d9a1b7ef665a14af54f91df
37679274834fde82c3cb1cb9f6535203ca25c0a1
refs/heads/master
2023-04-20T04:29:04.137442
2021-05-10T10:06:19
2021-05-10T10:06:19
351,691,065
0
0
null
null
null
null
UTF-8
Java
false
false
348
java
package stream1.reader; import java.io.FileReader; import java.io.IOException; public class FileReaderTest { public static void main(String[] args) { try(FileReader fr = new FileReader("reader.txt")){ int i; while( (i = fr.read()) != -1){ System.out.print((char)i); } }catch (IOException e) { e.printStackTrace(); } } }
9fc3ecad942d1c6bad7dc5da0922e99314953a1c
a0bee769df014535ca503891906b6d9042c7ff43
/build/app/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/me/dm7/barcodescanner/core/R.java
3e6ea86a473ece67e5b42cb779bd3bd4adb86630
[]
no_license
25mordad/dotraveladministrator
352374d46f15e9c3bafae26c1d30d3855094d38a
0c7a53a7c86cf9849634e95d184ef9ce07437a32
refs/heads/master
2020-03-29T09:27:00.367267
2019-04-05T15:11:24
2019-04-05T15:11:24
149,759,001
1
0
null
null
null
null
UTF-8
Java
false
false
2,633
java
/* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * gradle plugin from the resource data it found. It * should not be modified by hand. */ package me.dm7.barcodescanner.core; public final class R { private R() {} public static final class attr { private attr() {} public static final int borderAlpha = 0x7f03003c; public static final int borderColor = 0x7f03003d; public static final int borderLength = 0x7f03003e; public static final int borderWidth = 0x7f03003f; public static final int cornerRadius = 0x7f030070; public static final int finderOffset = 0x7f030098; public static final int laserColor = 0x7f0300bf; public static final int laserEnabled = 0x7f0300c0; public static final int maskColor = 0x7f0300da; public static final int roundedCorner = 0x7f030100; public static final int shouldScaleToFill = 0x7f03010a; public static final int squaredFinder = 0x7f030115; } public static final class color { private color() {} public static final int viewfinder_border = 0x7f05006a; public static final int viewfinder_laser = 0x7f05006b; public static final int viewfinder_mask = 0x7f05006c; } public static final class integer { private integer() {} public static final int viewfinder_border_length = 0x7f09000b; public static final int viewfinder_border_width = 0x7f09000c; } public static final class styleable { private styleable() {} public static final int[] BarcodeScannerView = { 0x7f03003c, 0x7f03003d, 0x7f03003e, 0x7f03003f, 0x7f030070, 0x7f030098, 0x7f0300bf, 0x7f0300c0, 0x7f0300da, 0x7f030100, 0x7f03010a, 0x7f030115 }; public static final int BarcodeScannerView_borderAlpha = 0; public static final int BarcodeScannerView_borderColor = 1; public static final int BarcodeScannerView_borderLength = 2; public static final int BarcodeScannerView_borderWidth = 3; public static final int BarcodeScannerView_cornerRadius = 4; public static final int BarcodeScannerView_finderOffset = 5; public static final int BarcodeScannerView_laserColor = 6; public static final int BarcodeScannerView_laserEnabled = 7; public static final int BarcodeScannerView_maskColor = 8; public static final int BarcodeScannerView_roundedCorner = 9; public static final int BarcodeScannerView_shouldScaleToFill = 10; public static final int BarcodeScannerView_squaredFinder = 11; } }
b3966df5c94bec8c6a537dee993b4f51a93eeb43
70302bf5f2f15873b7fad1ea4db59b8633653d49
/demoServer/src/main/java/com/example/demoserver/SnapMessageControlImpl.java
c5fe9ca2751f9618d42f7eedb41a5a9b69cf12c8
[]
no_license
yangjw/BinderDemo
c390f6c8b878456d21556949d39883fe922e3219
3a2f410b2b54f07549875aa0f81cdbbcb0c97d22
refs/heads/main
2023-06-05T11:45:04.529879
2021-06-21T07:57:39
2021-06-21T07:57:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,443
java
package com.example.demoserver; import android.os.RemoteException; import android.util.Log; import com.margin.base.utils.L; import java.util.ArrayList; import java.util.List; /** * Created by : mr.lu * Created at : 2021/6/8 at 23:27 * Description: */ public class SnapMessageControlImpl extends MessageController.Stub { private static final L.TAG TAG = new L.TAG("MessageControl"); private List<SnapMessage> mMessages; private SnapMessageControlImpl() { mMessages = new ArrayList<>(); initData(); } public static MessageController.Stub CREATE() { return new SnapMessageControlImpl(); } @Override public List<SnapMessage> getMessages() throws RemoteException { L.i(TAG, "getMessages"); return mMessages; } @Override public void sendMessage(SnapMessage message) throws RemoteException { L.i(TAG, " sendMessage >>> " + message); if (message == null) { L.i(TAG, "sendMessage: message is null"); return; } addMessage(message); } private void initData() { int count = 5; int num = 1; while (num <= count) { mMessages.add(new SnapMessage("text", "hello," + num)); num++; } L.d(TAG, "initData: dataSize = " + mMessages.size()); } private void addMessage(SnapMessage message) { mMessages.add(message); } }
605e980acefbf5e21983f7458657f34cfd0e2d91
5064ad1c5f675d6273199c452eb47e0f2e04b26a
/src/main/java/com/crescendo/ats/config/apidoc/package-info.java
84a026ecf06f7e3ffe4bb318d2f3886befbb2e99
[]
no_license
josephhatton/ats
859d0615369230c2d5e33694f2d50d3a76e79da8
08bcf4dffba4d5f3233d6682b4a84d1eb311b19f
refs/heads/master
2021-01-10T09:21:09.844096
2016-03-14T17:02:01
2016-03-14T17:02:03
53,867,663
0
0
null
null
null
null
UTF-8
Java
false
false
78
java
/** * Swagger api specific code. */ package com.crescendo.ats.config.apidoc;
467dd45ef3ca34dadac4c5d7b77e66e08f4f0388
495c5bf489a49b3be28a7725c914ec676bf7edc3
/src/main/java/com/hzwealth/sms/common/beanvalidator/DefaultGroup.java
aec7ac9e3e4e0312df3f3e96072f55ef3ea08e9e
[]
no_license
1813232166/hz-sms-master
15f0f1ec84c80e9a48cb5c31232d4785350a2a53
0060fb4764faa4248d8d61bfaab603ce96e2c4ea
refs/heads/master
2021-07-13T12:46:25.333178
2017-10-18T07:22:02
2017-10-18T07:22:02
103,233,892
0
0
null
null
null
null
UTF-8
Java
false
false
139
java
package com.hzwealth.sms.common.beanvalidator; /** * 默认Bean验证组 * @author Administrator */ public interface DefaultGroup { }
ad9fff286a109033087eda026f5616899621e1ec
01a7bd1c5634a0d9f0e0afa716239550925aa32e
/app/src/main/java/com/newborntown/animations/activity/StartActivity.java
7b02ec38769ddd06d4aa3d23d04a6e20b9f052e8
[]
no_license
androidLvmeng/Animations
7b17c62519c5a1e2b31f4bdb723e37f3fd6c5db0
73854dd8aa95694f8f2acce160ac3bcfbd8cb21a
refs/heads/master
2021-01-21T21:38:43.123276
2017-06-20T08:05:19
2017-06-20T08:05:19
94,864,843
0
0
null
null
null
null
UTF-8
Java
false
false
593
java
package com.newborntown.animations.activity; import android.app.Activity; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import com.newborntown.animations.opengl.SparkView; /** * Created by sunzhishuai on 17/6/19. * E-mail [email protected] */ public class StartActivity extends Activity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); SparkView sparkView = new SparkView(this); setContentView(sparkView); } }
6c6a9339e3c380538c58f847da7be202d72f406b
b9ecfb9c6bad2c5f59a22939755087517a646e4b
/haruno-annotation-support/src/main/java/io/github/harunobot/annotation/HarunoPluginInteractiveHandler.java
fd8cd82467214b1e6442ecd8f72e30432490171f
[]
no_license
harunobot/HarunoBot
5145ce9620b5ec38e6fc3124efeacc47f83739c4
e76e9d68f00dc288d0b70b7cf96f3b3c2318aad5
refs/heads/master
2023-03-18T08:53:24.633728
2021-03-10T16:34:31
2021-03-10T16:34:31
313,335,564
0
0
null
null
null
null
UTF-8
Java
false
false
768
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 io.github.harunobot.annotation; import io.github.harunobot.plugin.data.type.PluginMatcherType; import io.github.harunobot.plugin.data.type.PluginReceivedType; import io.github.harunobot.plugin.data.type.PluginTextType; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * * @author iTeam_VEP */ @Target({ElementType.METHOD, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface HarunoPluginInteractiveHandler { }
968d1ebde49e7a30d68eba18e78cfc198106479c
6635d25fd222f5cbd887247a63d54788dfa924fd
/Module_02/Project_02/ATM.java
612da84b531fba4b8fcc558a3fa4bcc180aa40a7
[]
no_license
ccoffey91/CPSC_1213
2334a2517e5f044172c0d7d79a9b3429cccf2195
84a4c5eb7b84981b468ad9fbaf22e48a1d046e65
refs/heads/master
2020-03-21T08:29:13.575105
2018-05-29T05:05:57
2018-05-29T05:05:57
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,449
java
import java.util.Scanner; // Required for the Scanner object. /** * ATM.java prompts the user to enter a value in whole dollars, * makes the appropriate calculations, and then displays the * applicable combination of twenties, tens, fives, and ones. * In addition, the input value should not exceed 500 dollars. * * @author Robert Goodson * @version January 20, 2018 */ public class ATM { /** * @param args Command Line Arguments (Not Used) */ public static void main(String[] args) { // Variable declarations and assignments. int userInput = 0; int firstRemain = 0, secondRemain = 0, thirdRemain = 0; int twenties = 0, tens = 0, fives = 0, ones = 0; // Required for the Scanner object. Scanner keyboard = new Scanner(System.in); // Prompt the user to enter a dollar amount. System.out.print("Enter the amount: "); userInput = keyboard.nextInt(); /* * A decision structure that performs the following tasks: * a) Calculates the remainder(s) via the modulus operator; * b) Utilizes the remainder(s) to calculate the number of * bills for each denomation; and * c) Sends the results to standard output for display * via the appropriate format. * d) In addition, if the standard input is greater than * 500, an error message will appear. */ if (userInput <= 500) { firstRemain = userInput % 20; twenties = (userInput - firstRemain) / 20; secondRemain = firstRemain % 10; tens = (firstRemain - secondRemain) / 10; thirdRemain = secondRemain % 5; fives = (secondRemain - thirdRemain) / 5; ones = thirdRemain; System.out.print("Bills by denomination:\n\t" + "$20: " + twenties + "\n\t" + "$10: " + tens + "\n\t" + "$5: " + fives + "\n\t" + "$1: " + ones + "\n"); System.out.print("$" + userInput + " = (" + twenties + " * $20) + (" + tens + " * $10) + (" + fives + " * $5) + (" + ones + " * $1)"); } else { System.out.print("Limit of $500 exceeded!"); } } }
1bb31a9d9d5f228c16ea418fa2b26cd16faca02d
bbed71ee552e9d86fb51eb1930168d2ded62ee6c
/app/src/main/java/com/jetec/wicloud/Pageview/PageThreeView.java
501b904539436fecb4dc67740a315a4105c930ed
[]
no_license
smartgamegoy/WiCloud
b3448bf9c16b1ee7d99d5d058c635775345f8a4b
bcfb6ec56b9f9243ac59f4360c57baaff85b3784
refs/heads/master
2020-05-23T19:55:29.879451
2019-07-10T02:13:35
2019-07-10T02:13:35
186,922,550
0
0
null
null
null
null
UTF-8
Java
false
false
2,381
java
package com.jetec.wicloud.Pageview; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Vibrator; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; import com.jetec.wicloud.R; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import static android.content.Context.VIBRATOR_SERVICE; import static java.lang.Thread.sleep; public class PageThreeView extends PageView { private Uri uri = Uri.parse("http://www.jetec.com.tw/#services2"); private Bitmap preview_bitmap; private Vibrator vibrator; private int flag = 0; public PageThreeView(final Context context) { super(context); @SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.pageone, null); vibrator = (Vibrator) context.getSystemService(VIBRATOR_SERVICE); ImageView imageView = view.findViewById(R.id.imageView); Runnable getimage = () -> { String imageUri = "http://www.jetec.com.tw/W8_Banner1/images/gallery/20181024_UAF08B_flomwmeter.png"; preview_bitmap = fetchImage(imageUri); flag = 1; }; new Thread(getimage).start(); for(;flag == 0;){ try{ sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } imageView.setImageBitmap(preview_bitmap); imageView.setOnClickListener(v -> { vibrator.vibrate(100); Intent intent = new Intent(Intent.ACTION_VIEW, uri); context.startActivity(intent); }); addView(view); } private Bitmap fetchImage( String urlstr ) { try { URL url; url = new URL(urlstr); HttpURLConnection c = ( HttpURLConnection ) url.openConnection(); c.setDoInput( true ); c.connect(); InputStream is = c.getInputStream(); Bitmap img; img = BitmapFactory.decodeStream(is); return img; } catch (IOException e) { e.printStackTrace(); } return null; } }
02e4a64b0d2c5cc922cdee2e0ff70b647ffdc63e
5bc81c7da4cb53c347c4da580843f53e019c980d
/src/com/mingrisoft/widget/AlphaScrollPane.java
b9b40eeb1b3395d5542f08f8bf3b620d603cf806
[]
no_license
Liyadi/gitHubTest
4b9be350bb674a57773dfbffb653e64780b03c16
11642315f8dcd7a45441248feba7b1c089a29ae1
refs/heads/master
2021-05-15T03:41:17.222003
2017-12-04T02:28:55
2017-12-04T02:28:55
110,061,516
0
0
null
null
null
null
GB18030
Java
false
false
3,025
java
package com.mingrisoft.widget; import java.awt.*; import java.beans.*; import java.io.Serializable; import javax.swing.*; import javax.swing.border.LineBorder; public class AlphaScrollPane extends JScrollPane { private static final long serialVersionUID = 1L; private boolean borderPaint = false; private boolean headerOpaquae = true; private boolean viewportBorderPaint = false; /** * This is the default constructor */ public AlphaScrollPane() { super(); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setSize(300, 200); setBackground(new Color(151, 188, 229)); setOpaque(false); addPropertyChangeListener(new PropertyChangeAdapter()); } private final class PropertyChangeAdapter implements PropertyChangeListener, Serializable { public void propertyChange(PropertyChangeEvent e) { String name = e.getPropertyName(); if (name.equals("ancestor")) { JViewport header = getColumnHeader(); if (header != null) { // header.setBackground(getBackground()); JComponent view = (JComponent) header.getView(); if (view instanceof CTable) view.setOpaque(isOpaque()); header.setOpaque(headerOpaquae); } getViewport().setOpaque(isOpaque());// 使滚动视图透明 if (!viewportBorderPaint) setViewportBorder(null);// 取消滚动视图的边框 if (!isBorderPaint())// 绘制边框 setBorder(null); } if (name.equals("background")) { setBorder(new LineBorder(getBackground(), 1, true)); } } } public boolean isBorderPaint() { return borderPaint; } public void setBorderPaint(boolean borderPaint) { this.borderPaint = borderPaint; } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); Component[] components = getComponents(); for (Component component : components) { component.setEnabled(enabled); } Component view = getViewport().getView(); if (view != null) view.setEnabled(enabled); if (getColumnHeader() != null) getColumnHeader().setEnabled(enabled); } public void setHeaderOpaquae(boolean headerOpaquae) { this.headerOpaquae = headerOpaquae; } public boolean isViewportBorderPaint() { return viewportBorderPaint; } public void setViewportBorderPaint(boolean viewportBorderPaint) { this.viewportBorderPaint = viewportBorderPaint; } }
f9dc7a09836646df7ff1c421683fa21fa0f27c5f
26f7b8a232d36c2461048c21418de298d93de3a4
/src/main/java/dao/DaoIngredient.java
53717eaf41e1cef35a312202abc7e76ea83241f8
[]
no_license
mkamadeus/wbd-ws-factory
6a47ce10d9332e16137da771b4f0c95331db4ecb
d9e2d4d062dde0200bed7f00bedf7bc4d9632f6e
refs/heads/master
2023-01-20T14:28:57.581693
2020-11-29T07:57:08
2020-11-29T07:57:08
317,098,482
0
0
null
null
null
null
UTF-8
Java
false
false
4,179
java
package dao; import data.Ingredient; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Optional; public class DaoIngredient implements IngredientDao{ private DaoIngredient(){} private static class SingletonHelper { private static final DaoIngredient INSTANCE = new DaoIngredient(); } public static DaoIngredient getInstance(){ return DaoIngredient.SingletonHelper.INSTANCE; } @Override public Optional<Ingredient> find(String id) throws SQLException { String query = "SELECT name, uuid FROM `ingredients` WHERE id=?"; String name; String uuid; Optional<Ingredient> ingredient = Optional.empty(); Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, id); ResultSet resultSet = statement.executeQuery(); if(resultSet.next()){ name = resultSet.getString("name"); uuid = resultSet.getString("uuid"); ingredient = Optional.of(new Ingredient(Integer.parseInt(id), name, uuid)); } return ingredient; } @Override public List<Ingredient> findAll() throws SQLException { List<Ingredient> ingredientList = new ArrayList<>(); String query = "SELECT id, name, uuid FROM `ingredients`"; Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query); ResultSet resultSet = statement.executeQuery(); while(resultSet.next()){ int id = resultSet.getInt("id"); String name = resultSet.getString("name"); String uuid = resultSet.getString("uuid"); ingredientList.add(new Ingredient(id, name, uuid)); } return ingredientList; } @Override public int save(Ingredient ingredient) throws SQLException { String query = "INSERT INTO `ingredients` (name, uuid) VALUES (?, ?)"; Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); statement.setString(1, ingredient.getName()); statement.setString(2, ingredient.getUUID()); statement.executeUpdate(); int id; ResultSet rs = statement.getGeneratedKeys(); if (rs.next()) { id = rs.getInt(1); } else{ throw new SQLException("No rows affected."); } rs.close(); return id; } @Override public boolean update(Ingredient ingredient) throws SQLException { String query = "UPDATE `ingredients` SET name = ?, uuid = ? WHERE id = ?"; Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, ingredient.getName()); statement.setString(2, ingredient.getUUID()); statement.setInt(3, ingredient.getId()); return statement.executeUpdate() > 0; } @Override public boolean delete(Ingredient ingredient) throws SQLException { String query = "DELETE FROM `ingredients` WHERE id = ?"; Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query); statement.setInt(1, ingredient.getId()); return statement.executeUpdate() > 0; } public Optional<Ingredient> findByUUID(String uuid) throws SQLException { String query = "SELECT id, name FROM `ingredients` WHERE uuid = ?"; int id; String name; Optional<Ingredient> ingredient = Optional.empty(); Connection conn = DataSourceFactory.getConn(); PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, uuid); ResultSet resultSet = statement.executeQuery(); if(resultSet.next()){ id = resultSet.getInt("id"); name = resultSet.getString("name"); ingredient = Optional.of(new Ingredient(id, name, uuid)); } return ingredient; } }
1a368b107667e3fc4461ea8f51e3b3ba86cbe639
dd470400ec2099443645a0dc3f1477952a68ed5c
/MiContentProvider-master/app/src/test/java/com/example/micontentprovider/ExampleUnitTest.java
f35605f9eb8f2b603847219a5490818d8d25cac5
[]
no_license
FranciscoPaniagua/Programacion-Mobil-2
ad4c24fed589aa39c9f7638aebf8945a86199268
a3253569f73c77208cc6d0bcc2b95e969e0cabfd
refs/heads/master
2022-07-28T13:50:26.160730
2020-05-24T20:43:54
2020-05-24T20:43:54
266,574,630
0
0
null
null
null
null
UTF-8
Java
false
false
390
java
package com.example.micontentprovider; 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); } }
bdf096e80b6ace3a97c29b859c8bdd16804ab99f
1a4a12ba56cb43328a4460f8e531325c39bf6e3d
/src/coverbooker/BestOptionSorter.java
cf097901b0058cbe11a9d7c5fb621f1a299ef37c
[]
no_license
zakkary88/TyperFinal
59751647e26863dffd5cd7f7f4c3f3884e83b67b
e3da9ef1e0af774cbc7ece18d72df320afb065d4
refs/heads/master
2021-01-19T16:23:42.585816
2013-09-15T15:36:16
2013-09-15T15:36:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,867
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package coverbooker; /** * * @author Marcin */ public class BestOptionSorter { private double firstPlace; private double secondPlace; public BestOptionSorter() { firstPlace = 0.0; secondPlace = 0.0; } /* * Konstruktor potrzeby tylko, gdy funkcja sort jest prywatna! public BestOptionSorter(double homePChance, double drawPChance, double awayPChance) { sort(drawPChance, drawPChance, awayPChance); } */ public void sort(double homePChance, double drawPChance, double awayPChance) { if(homePChance > drawPChance) { if(homePChance > awayPChance) { firstPlace = homePChance; if(drawPChance > awayPChance) secondPlace = drawPChance; else secondPlace = awayPChance; } else { firstPlace = awayPChance; secondPlace = homePChance; } } else { if(drawPChance > awayPChance) { firstPlace = drawPChance; if(homePChance > awayPChance) secondPlace = homePChance; else secondPlace = awayPChance; } else { firstPlace = awayPChance; secondPlace = drawPChance; } } } public double getBestOption() { return firstPlace + secondPlace; } public double getFirstPlace() { return firstPlace; } public double getSecondPlace() { return secondPlace; } }
6b6dd977bbc01ab4fc2152fcc49cc944a7544546
723c1d0add95b685f69939a3af16faabe88bea8c
/askme/src/main/java/de/htwsaar/pib2021/inet/config/MvcConfig.java
42c0859443a49bbaa5535cd4eb734c396914d851
[ "Apache-2.0" ]
permissive
ej-feras/askme
30a6c679186bf9fcadf5c74aa26479a3db3839dd
eb4224e50df3d631bbc647091c3c1cbaf425ffcc
refs/heads/main
2023-04-08T07:53:47.771550
2021-04-16T00:25:05
2021-04-16T00:25:05
348,918,395
0
0
null
null
null
null
UTF-8
Java
false
false
1,932
java
package de.htwsaar.pib2021.inet.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; @Configuration @EnableWebMvc public class MvcConfig implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/images/**", "/css/**", "/js/**", "vendor/**").addResourceLocations( "classpath:/static/images/", "classpath:/static/css/", "classpath:/static/js/", "classpath:/static/vendor/"); } @Bean public ViewResolver getViewResolver() { InternalResourceViewResolver resolver = new InternalResourceViewResolver(); resolver.setPrefix("templates/"); resolver.setSuffix(".html"); return resolver; } @Bean InternalResourceViewResolver jspViewResolver() { final InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setPrefix("/WEB-INF/view/jsp/"); viewResolver.setSuffix(".jsp"); viewResolver.setViewClass(JstlView.class); return viewResolver; } @Bean public ClassLoaderTemplateResolver templateResolver() { ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); templateResolver.setPrefix("templates/"); templateResolver.setCacheable(false); templateResolver.setSuffix(".html"); templateResolver.setTemplateMode("HTML5"); templateResolver.setCharacterEncoding("UTF-8"); return templateResolver; } }
bc760b8245eca2a8f3aaf6ccdc504491b9ca3bcc
7a680d9a2193db750c2f3da6d09a9e0d75c562f3
/src/anml/RoboCat.java
5ee34b83d4ea3ce575e4fa84492195ed94f13591
[]
no_license
SashaKoroleva/Kotiki
4e3ead5179b9be486a0f70d4d3af215328645fc8
b934304161265436378fa17c1cb64f6cf1df87ab
refs/heads/master
2020-07-04T14:16:44.207253
2016-11-18T18:35:32
2016-11-18T18:35:32
74,156,565
0
0
null
null
null
null
UTF-8
Java
false
false
366
java
package anml; /** * Created by sasha_koroleva on 18.11.2016. */ public class RoboCat extends Robot { public RoboCat(String name) { super(name); } @Override public void makeASound() { System.out.println("Бип-бип! Бип-бип!"); } @Override public String getName() { return super.getName(); } }
0aecbe49d50e25c2aeafd93999ed1bf2cd5c0752
5d54ed52f0ac5f24e903b844e207f228f643030e
/src/main/java/com/flixbus/miniproject/usecase/bus/EditBus.java
0e206beb09bbde86aaafcc8628e556bd6bfe2136
[]
no_license
newarcher36/miniproject
5bd50a93f546c594ddb512b885490300a4780525
79cbd8acfaa07a22d2744fb1c4d82642abdbefd1
refs/heads/master
2022-09-15T21:18:04.834753
2020-01-13T21:47:36
2020-01-13T21:47:36
222,464,238
0
0
null
2022-09-08T01:04:00
2019-11-18T14:09:11
Java
UTF-8
Java
false
false
1,497
java
package com.flixbus.miniproject.usecase.bus; import com.flixbus.miniproject.domain.bus.Bus; import com.flixbus.miniproject.domain.bus.BusRepository; import com.flixbus.miniproject.domain.exception.BusNotFoundException; import com.flixbus.miniproject.domain.exception.DuplicatePlateNumberException; import javax.inject.Named; @Named public class EditBus { private final BusRepository busRepository; public EditBus(BusRepository busRepository) { this.busRepository = busRepository; } public void execute(Bus bus) { long busId = bus.getId(); Bus currentBus = busRepository.findBusById(bus.getId()) .orElseThrow(() -> new BusNotFoundException("Bus not found with id: " + busId)); if (hasPlateNumberChanged(bus, currentBus)) { checkPlateNumberDuplicated(bus); } busRepository.save(bus); } private boolean hasPlateNumberChanged(Bus busToEdit, Bus currentBus) { return !busToEdit.getPlateNumber().equals(currentBus.getPlateNumber()); } private void checkPlateNumberDuplicated(Bus busToEdit) { final String plateNumber = busToEdit.getPlateNumber(); if (isPlateNumberDuplicated(plateNumber)) { throw new DuplicatePlateNumberException("Another bus has already this plate number: " + plateNumber); } } private boolean isPlateNumberDuplicated(String plateNumber) { return busRepository.existsByPlateNumber(plateNumber); } }
47c6f63ecced12a9650607440e8fbd663f225594
ce1364955273921131f2d27951a1a537e23b26b3
/br.ProdutosDeDefesa/src/main/java/br/ProdutosDeDefesa/Compra.java
1a823cfcd2db65f3d3ce1a0574b8d1c783576ff6
[]
no_license
JoseHumbertoJr/Projeto-Banco-de-Dados-2
a123ecf61ddc5c079383b7e21759b2c054735ec4
d2b1e79a9604309e89bea9b2e31babfb9b0a7ae0
refs/heads/master
2020-04-06T21:06:58.159965
2018-11-16T12:58:15
2018-11-16T12:58:15
157,792,951
0
0
null
null
null
null
UTF-8
Java
false
false
829
java
package br.ProdutosDeDefesa; public class Compra { private long id; private String data; private String produto; private String classificacao; private long id_empresa; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getData() { return data; } public void setData(String data) { this.data = data; } public String getProduto() { return produto; } public void setProduto(String produto) { this.produto = produto; } public String getClassificacao() { return classificacao; } public void setClassificacao(String classificacao) { this.classificacao = classificacao; } public long getId_empresa() { return id_empresa; } public void setId_empresa(long id_empresa) { this.id_empresa = id_empresa; } }
ab4088c3577bc1f62e8f829993c587ece4a5dbd5
bcbd5cdbec730aec758a94fcd8b0136171f08663
/output/Spring/SHDP/sources/SHDP_2_2_0/raw/547.java
198fa1bee36778d664fd8e48ba4f1fca5d7956c3
[]
no_license
RosePasta/BugTypeBasedIRBL
28c85e1d7f28b2da8a2f12cc4d9c24754a0afe90
55b0f82cf185a3a871926cc7a266072f8e497510
refs/heads/master
2022-05-06T08:38:38.138869
2022-04-20T06:34:38
2022-04-20T06:34:38
188,862,575
1
3
null
2019-11-21T09:48:44
2019-05-27T14:52:28
Java
UTF-8
Java
false
false
2,547
java
/* * Copyright 2013 the original author or authors. * * 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 org.springframework.yarn.batch.repository; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.yarn.am.GenericRpcMessage; import org.springframework.yarn.am.RpcMessage; import org.springframework.yarn.batch.repository.JobRepositoryService; import org.springframework.yarn.integration.ip.mind.AppmasterMindScOperations; import org.springframework.yarn.integration.ip.mind.binding.BaseObject; import org.springframework.yarn.integration.ip.mind.binding.BaseResponseObject; /** * Faking appmaster service client operations for * batch job repository access using in-memory * map based repository. * * @author Janne Valkealahti * */ public class StubAppmasterScOperations implements AppmasterMindScOperations { private JobRepository jobRepository; private JobRepositoryService jobRepositoryService; public StubAppmasterScOperations() { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); try { factory.afterPropertiesSet(); jobRepository = factory.getObject(); jobRepositoryService = new JobRepositoryService(); jobRepositoryService.setJobRepository(jobRepository); } catch (Exception e) { } } @Override public RpcMessage<?> get(RpcMessage<?> message) { BaseObject baseObject = (BaseObject) message.getBody(); BaseResponseObject baseResponseObject = jobRepositoryService.get(baseObject); return new GenericRpcMessage<BaseResponseObject>(baseResponseObject); } @Override public BaseResponseObject doMindRequest(BaseObject request) { RpcMessage<?> message = new GenericRpcMessage<BaseObject>(request); RpcMessage<?> rpcMessage = get(message); BaseResponseObject baseResponseObject = (BaseResponseObject) rpcMessage.getBody(); return baseResponseObject; } }
c165025e2f5d2e4e4b84c86baf1607229736c4e3
8b5d4adc86b4fb0b4caefcd9e994bac7f167ddea
/src/MyTest/SerializeTest/First.java
f6325bf22c8b5c0193cab3e019c02d239cd76bd1
[]
no_license
ButerD/JavaMentor
922ba6170d2f86494a49d190daba337b6e21fb8c
cafc412b459c9578e8263bcb57855cde75cf04f6
refs/heads/master
2023-07-12T17:08:26.889222
2021-08-11T15:16:39
2021-08-11T15:16:39
383,543,508
0
0
null
null
null
null
UTF-8
Java
false
false
1,107
java
package MyTest.SerializeTest; import java.io.Serializable; public class First { private String f1; private int fNum; public First() { } public String getF1() { return f1; } public void setF1(String f1) { this.f1 = f1; } public int getfNum() { return fNum; } public void setfNum(int fNum) { this.fNum = fNum; } @Override public String toString() { return "First{" + "f1='" + f1 + '\'' + ", fNum=" + fNum + '}'; } } class Second extends First implements Serializable{ private String s2; private int sNum; public String getS2() { return s2; } public void setS2(String s2) { this.s2 = s2; } public int getsNum() { return sNum; } public void setsNum(int sNum) { this.sNum = sNum; } @Override public String toString() { return "Second{" + "s2='" + s2 + '\'' + ", sNum=" + sNum + "} " + super.toString(); } }
7220039879c349b2f3d8e42ff2abbdaf48d2b3ee
2e59950c3a0e32c9748c1e3303d5530f6e9b67ca
/Thinksns_v4.0/src/com/abcs/haiwaigou/fragment/GoodCartFragment.java
bf365908a9e42752c55af1d2090e91cc005d40aa
[]
no_license
xiaozhugua/Myhuarenb
a27e87451c792a76ade79fc29d7050997ac2bdf6
9a81815ce90a7b4e5c22ff99fb8fc5e13844d326
refs/heads/master
2021-01-23T02:05:42.432793
2017-05-31T04:05:42
2017-05-31T04:05:42
92,902,840
0
1
null
null
null
null
UTF-8
Java
false
false
4,073
java
package com.abcs.haiwaigou.fragment; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.abcs.haiwaigou.activity.GoodsDetailActivity; import com.abcs.haiwaigou.broadcast.MyBroadCastReceiver; import com.abcs.haiwaigou.model.Goods; import com.abcs.haiwaigou.utils.LoadPicture; import com.abcs.haiwaigou.utils.NumberUtils; import com.abcs.sociax.android.R; /** * Created by Administrator on 2016/2/18. */ public class GoodCartFragment extends Fragment { MyBroadCastReceiver myBroadCastReceiver; private LinearLayout linear_tuijian_root; private TextView t_tuijian_goods_name; private TextView t_tuijian_goods_money; private TextView t_tuijian_buy; private ImageView img_tuijian_goods_icon; public ImageView img_mohu; Goods dataList; int position; public static GoodCartFragment getInstance(Goods data, int position) { GoodCartFragment f = new GoodCartFragment(); Bundle b = new Bundle(); b.putSerializable("data", data); b.putInt("position", position); f.setArguments(b); return f; } MyBroadCastReceiver.UpdateUI updateUI=new MyBroadCastReceiver.UpdateUI() { @Override public void updateShopCar(Intent intent) { } @Override public void updateCarNum(Intent intent) { } @Override public void updateCollection(Intent intent) { } @Override public void update(Intent intent) { } }; @Override public void onCreate(@Nullable Bundle savedInstanceState) { myBroadCastReceiver=new MyBroadCastReceiver(getContext(),updateUI); myBroadCastReceiver.register(); } @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.hwg_item_country_tuijian2, null); img_mohu = (ImageView) view.findViewById(R.id.img_mohu); img_tuijian_goods_icon = (ImageView) view.findViewById(R.id.img_tuijian_goods_icon); LoadPicture loadPicture = new LoadPicture(); dataList = (Goods) getArguments().getSerializable("data"); loadPicture.initPicture(img_tuijian_goods_icon, dataList.getPicarr()); // loadPicture.initPicture(img_tuijian_goods_icon,goodsList.get(i).getPicarr()); linear_tuijian_root = (LinearLayout) view.findViewById(R.id.linear_tuijian_root); linear_tuijian_root.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), GoodsDetailActivity.class); intent.putExtra("sid", dataList.getSid()); intent.putExtra("pic", dataList.getPicarr()); startActivity(intent); } }); t_tuijian_goods_name = (TextView) view.findViewById(R.id.t_tuijian_goods_name); t_tuijian_goods_name.setText(dataList.getTitle()); // t_tuijian_goods_name.setText(goodsList.get(i).getTitle()); t_tuijian_goods_money = (TextView) view.findViewById(R.id.t_tuijian_goods_money); t_tuijian_goods_money.setText(NumberUtils.formatPrice(dataList.getMoney())); // t_tuijian_goods_money.setText(NumberUtils.formatPrice(goodsList.get(i).getMoney())); t_tuijian_buy = (TextView) view.findViewById(R.id.t_tuijian_buy); t_tuijian_buy.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // showToast("购买成功!"); } }); return view; } @Override public void onDestroy() { myBroadCastReceiver.unRegister(); super.onDestroy(); } }
b11fddf7313672cfd58602a0730588273f24ff3c
23967d2799b5cbec8f4a93f23ff0daa1227291f8
/app/src/test/java/com/tfs/mkaratusi/mkaratusi/ExampleUnitTest.java
d20a11328b428cad5714502654b7abee4174f754
[]
no_license
jkisanga/MkaratusiApp
42bc06596a1431ed4c75ab37e416f2805e2457a8
56330f0609abc989066206c089eaabd1249c8180
refs/heads/master
2021-05-01T14:58:57.158263
2018-02-20T19:31:19
2018-02-20T19:31:19
121,026,194
0
0
null
null
null
null
UTF-8
Java
false
false
405
java
package com.tfs.mkaratusi.mkaratusi; 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() throws Exception { assertEquals(4, 2 + 2); } }
1a20613fdc8c9ff35aaf3a3628a3edb039cdd5e4
4b357baaf50738adc29b1205f79a82c0df8e90ff
/app/src/main/java/xyz/yxwzyyk/bandwagoncontrol/app/Configure.java
f923345b7079adf8bb24ff54fad255bd157697eb
[]
no_license
ysjsssl/BandwagonControl
bb9d9bae5a7857ef72ac4a24d77cbaa89195a62d
ef5c97c324984568faf4f70b986e2532f64de6d2
refs/heads/master
2021-01-25T02:30:26.757342
2016-01-28T08:19:36
2016-01-28T08:19:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
459
java
package xyz.yxwzyyk.bandwagoncontrol.app; /** * Created by yyk on 12/12/15. */ public class Configure { public static final String HOST_URL = "https://api.kiwivm.it7.net/v1/"; public static final String GET_INFO = "getLiveServiceInfo"; public static final String REBOOT = "restart"; public static final String STOP = "stop"; public static final String START = "start"; public static final String BASICSHELL = "basicShell/exec"; }
929f97cf1cf446777dd1bba0760b0bc0a48fe959
ffacee583e9d6023e0f526dac9c6804dad541c5c
/kafka-etl/kafka-etl-run/src/main/java/org/kafka/etl/kafka/impl/AvroToJsonDeserializer.java
8a2c3fc3f97555da108978a39cf704ccee5d7327
[ "Apache-2.0" ]
permissive
docapostiotalliance/kafka-etl
689aa2666074ca25c659e795f69acd1e7daf230f
d48d76f18f47dbd26a0e832d2850e2a907912284
refs/heads/master
2022-03-23T14:56:14.257093
2022-03-04T11:10:58
2022-03-04T11:10:58
235,133,219
11
3
Apache-2.0
2022-02-21T09:24:27
2020-01-20T15:27:27
Java
UTF-8
Java
false
false
3,897
java
package org.kafka.etl.kafka.impl; import com.sun.org.apache.xpath.internal.operations.Bool; import io.vertx.core.json.JsonObject; import org.apache.avro.Schema; import org.apache.avro.io.BinaryDecoder; import org.apache.avro.io.DatumReader; import org.apache.avro.io.DecoderFactory; import org.apache.avro.reflect.ReflectDatumReader; import org.kafka.etl.kafka.IDeserializer; import org.kafka.etl.utils.JsonUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.ByteArrayInputStream; import java.util.Arrays; import java.util.Map; import static org.apache.commons.lang3.StringUtils.isNotBlank; public class AvroToJsonDeserializer implements IDeserializer { private static final Logger LOGGER = LoggerFactory.getLogger(AvroToJsonDeserializer.class); public final Schema schema; private final DatumReader<?> reader; private final Integer dataBytesStartOffset; private final boolean failOnEmptyJson; public AvroToJsonDeserializer(String jsonSchema, Integer dataBytesStartOffset, boolean failOnEmptyJson) { this.schema = new Schema.Parser().parse(jsonSchema); this.dataBytesStartOffset = dataBytesStartOffset; this.failOnEmptyJson = failOnEmptyJson; reader = new ReflectDatumReader<>(schema); } @Override public void configure(Map<String, ?> map, boolean b) { // Nothing to do } @Override public String deserialize(String s, byte[] data) { LOGGER.debug( "[AvroToJsonDeserializer][deserialize] start deserializing the byte array using Avro; schema = {}", schema.getFullName()); if (data == null) { LOGGER.debug("[AvroToJsonDeserializer][deserialize] No data received to be deserialized!"); return null; } try { LOGGER.debug( "[AvroToJsonDeserializer][deserialize] Initializing data reader from Avro schema!"); BinaryDecoder decoder = DecoderFactory.get() .binaryDecoder(new ByteArrayInputStream(stripFirstOffsets(data)), null); Object decodedValue = reader.read(null, decoder); String rtn = decodedValue.toString(); if (JsonUtils.isValid(rtn)) { LOGGER.debug( "[AvroToJsonDeserializer][deserialize] decodedValue.toString is a valid JSON String : ", rtn); if (failOnEmptyJson && isEmptyJson(rtn)) { throw new IllegalStateException( "[AvroToJsonDeserializer][deserialize] deserializedValue.toString is empty : " + rtn); } return rtn; } if (decodedValue instanceof String && JsonUtils.isValid((String) decodedValue)) { rtn = (String) decodedValue; LOGGER.debug("[AvroToJsonDeserializer][deserialize] decodedValue is a valid JSON String : ", rtn); if (failOnEmptyJson && isEmptyJson(rtn)) { throw new IllegalStateException( "[AvroToJsonDeserializer][deserialize] deserializedValue is empty : " + rtn); } return rtn; } LOGGER.info( "[AvroToJsonDeserializer][deserialize] neither decodedValue.toString or decodedValue are valid JSON String"); return JsonUtils.toJson(decodedValue); } catch (Exception e) { LOGGER.error( "[AvroToJsonDeserializer][deserialize] Error while deserializing data, e.type = {}, e.msg = {}", e.getClass().getSimpleName(), e.getMessage()); throw new IllegalArgumentException(e); } } private boolean isEmptyJson(String json) { JsonObject jo = new JsonObject(json); return !jo.stream().filter(e -> null != e.getValue() && isNotBlank(e.getValue().toString())) .findAny().isPresent(); } public byte[] stripFirstOffsets(byte[] data) { return Arrays.copyOfRange(data, dataBytesStartOffset, data.length); } @Override public void close() { // Nothing to do } }
5f2196cf031677ce6ba3752075e36d370106bf14
883b7801d828a0994cae7367a7097000f2d2e06a
/python/experiments/projects/CESNET-perun/real_error_dataset/1/26/ModulesUtilsBlImpl.java
99cf929fcca0efb27d17f28ac8a9ad96e110a4a9
[]
no_license
pombredanne/styler
9c423917619912789289fe2f8982d9c0b331654b
f3d752d2785c2ab76bacbe5793bd8306ac7961a1
refs/heads/master
2023-07-08T05:55:18.284539
2020-11-06T05:09:47
2020-11-06T05:09:47
null
0
0
null
null
null
null
UTF-8
Java
false
false
54,854
java
package cz.metacentrum.perun.core.blImpl; import cz.metacentrum.perun.auditparser.AuditParser; import cz.metacentrum.perun.core.api.*; import cz.metacentrum.perun.core.api.exceptions.*; import cz.metacentrum.perun.core.bl.ModulesUtilsBl; import cz.metacentrum.perun.core.bl.PerunBl; import cz.metacentrum.perun.core.impl.PerunSessionImpl; import cz.metacentrum.perun.core.impl.Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.math.BigDecimal; import java.net.URI; import java.net.URISyntaxException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import java.util.stream.Collectors; /** * @author Michal Stava <[email protected]> */ public class ModulesUtilsBlImpl implements ModulesUtilsBl { final static Logger log = LoggerFactory.getLogger(ServicesManagerBlImpl.class); private PerunBl perunBl; Map<String,String> perunNamespaces = null; public static final String A_E_namespace_minGID = AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-minGID"; public static final String A_E_namespace_maxGID = AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-maxGID"; public static final String A_G_unixGID_namespace = AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace"; public static final String A_G_unixGroupName_namespace = AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace"; public static final String A_R_unixGID_namespace = AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace"; public static final String A_R_unixGroupName_namespace = AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGroupName-namespace"; public static final String A_F_unixGID_namespace = AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace"; public static final String A_F_unixGroupName_namespace = AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace"; public static final String A_F_googleGroupName_namespace = AttributesManager.NS_FACILITY_ATTR_DEF + ":googleGroupNameNamespace"; private static final String A_E_usedGids = AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":usedGids"; //Often used patterns public static final Pattern quotaWithMetricsPattern = Pattern.compile("^([0-9]+([.][0-9]+)?[KMGTPE]?):([0-9]+([.][0-9]+)?[KMGTPE]?)$"); public static final Pattern quotaWithoutMetricsPattern = Pattern.compile("^([0-9]+)(:)([0-9]+)$"); public static final Pattern numberPattern = Pattern.compile("[0-9]+([.][0-9]+)?"); public static final Pattern letterPattern = Pattern.compile("[A-Z]"); public static final Pattern fqdnPattern = Pattern.compile("^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+[a-zA-Z]{2,63}\\.?$"); public final static List<String> reservedNamesForUnixGroups = Arrays.asList("root", "daemon", "tty", "bin", "sys", "sudo", "nogroup", "hadoop", "hdfs", "mapred", "yarn", "hsqldb", "derby", "jetty", "hbase", "zookeeper", "users", "oozie", "hive"); public final static List<String> unpermittedNamesForUserLogins = Arrays.asList("arraysvcs", "at", "backup", "bin", "daemon", "Debian-exim", "flexlm", "ftp", "games", "gdm", "glite", "gnats", "haldaemon", "identd", "irc", "libuuid", "list", "lp", "mail", "man", "messagebus", "news", "nobody", "ntp", "openslp", "pcp", "polkituser", "postfix", "proxy", "pulse", "puppet", "root", "saned", "smmsp", "smmta", "sshd", "statd", "suse-ncc", "sync", "sys", "uucp", "uuidd", "www-data", "wwwrun", "zenssh", "tomcat6", "tomcat7", "tomcat8", "nn", "dn", "rm", "nm", "sn", "jn", "jhs", "http", "yarn", "hdfs", "mapred", "hadoop", "hsqldb", "derby", "jetty", "hbase", "zookeeper", "hive", "hue", "oozie", "httpfs"); //Definition of K = KB, M = MB etc. public static final long M = 1024; public static final long G = M * 1024; public static final long T = G * 1024; public static final long P = T * 1024; public static final long E = P * 1024; public ModulesUtilsBlImpl() { } public boolean isNamespaceEqualsToFacilityUnixGroupNameNamespace(PerunSessionImpl sess, Facility facility, String namespace) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException{ Utils.notNull(facility, "facility"); Utils.notNull(namespace, "namespace"); Utils.notNull(sess, "perunSessionImpl"); Attribute facilityNamespaceAttr = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, A_F_unixGroupName_namespace + ":" + namespace); if(facilityNamespaceAttr.getValue() == null) return false; if(!namespace.equals(facilityNamespaceAttr.getValue())) { return false; } return true; } public List<Resource> findCollisionResourcesWithSameGroupName(PerunSessionImpl sess, Resource resource, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(resource, "resource"); Attribute resourceUnixGroupName = getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, A_R_unixGroupName_namespace + ":" + namespace); List<Resource> resourcesWithSameUnixGroupName = getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, resourceUnixGroupName); resourcesWithSameUnixGroupName.remove(resource); return resourcesWithSameUnixGroupName; } public List<Resource> findCollisionResourcesWithSameGroupName(PerunSessionImpl sess, Group group, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(group, "group"); Utils.notNull(namespace, "namespace"); Attribute groupUnixGroupName = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGroupName_namespace + ":" + namespace); Attribute copyResourceUnixGroupName = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGroupName_namespace + ":" + namespace)); copyResourceUnixGroupName.setValue(groupUnixGroupName.getValue()); return getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, copyResourceUnixGroupName); } public List<Group> findCollisionGroupsWithSamgeGroupName(PerunSessionImpl sess, Resource resource, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(resource, "resource"); Utils.notNull(namespace, "namespace"); Attribute resourceUnixGroupName = getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, A_R_unixGroupName_namespace + ":" + namespace); Attribute copyGroupUnixGroupName = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_G_unixGroupName_namespace + ":" + namespace)); copyGroupUnixGroupName.setValue(resourceUnixGroupName.getValue()); return getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, copyGroupUnixGroupName); } public List<Group> findCollisionGroupsWithSamgeGroupName(PerunSessionImpl sess, Group group, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(group, "group"); Utils.notNull(namespace, "namespace"); Attribute groupUnixGroupName = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGroupName_namespace + ":" + namespace); List<Group> groupsWithsameGroupName = getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, groupUnixGroupName); groupsWithsameGroupName.remove(group); return groupsWithsameGroupName; } public List<Resource> findCollisionResourcesWithSameGid(PerunSessionImpl sess, Resource resource, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(resource, "resource"); Utils.notNull(namespace, "namespace"); Attribute resourceUnixGid = getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, A_R_unixGID_namespace + ":" + namespace); List<Resource> resourcesWithSameGid = getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, resourceUnixGid); resourcesWithSameGid.remove(resource); return resourcesWithSameGid; } public List<Resource> findCollisionResourcesWithSameGid(PerunSessionImpl sess, Group group, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(group, "group"); Utils.notNull(namespace, "namespace"); Attribute groupUnixGid = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGID_namespace + ":" + namespace); Attribute copyResourceUnixGid = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGID_namespace + ":" + namespace)); copyResourceUnixGid.setValue(groupUnixGid.getValue()); return getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, copyResourceUnixGid); } public List<Group> findCollisionGroupsWithSamgeGroupGid(PerunSessionImpl sess, Resource resource, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(resource, "resource"); Utils.notNull(namespace, "namespace"); Attribute resourceUnixGid = getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, A_R_unixGID_namespace + ":" + namespace); Attribute copyGroupUnixGid = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_G_unixGID_namespace + ":" + namespace)); copyGroupUnixGid.setValue(resourceUnixGid.getValue()); return getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, copyGroupUnixGid); } public List<Group> findCollisionGroupsWithSamgeGroupGid(PerunSessionImpl sess, Group group, String namespace) throws InternalErrorException, WrongAttributeAssignmentException, AttributeNotExistsException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(group, "group"); Utils.notNull(namespace, "namespace"); Attribute groupUnixGid = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGID_namespace + ":" + namespace); List<Group> groupsWithSameUnixGid = getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, groupUnixGid); groupsWithSameUnixGid.remove(group); return groupsWithSameUnixGid; } public boolean hasAccessToWriteToAttributeForAnyResource(PerunSessionImpl sess, AttributeDefinition attrDef, List<Resource> resources) throws InternalErrorException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(attrDef, "attributeDefinition"); if(resources == null || resources.isEmpty()) return false; for(Resource r: resources) { if(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, attrDef , r, null)) return true; } return false; } public boolean hasAccessToWriteToAttributeForAnyGroup(PerunSessionImpl sess, AttributeDefinition attrDef, List<Group> groups) throws InternalErrorException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(attrDef, "attributeDefinition"); if(groups == null || groups.isEmpty()) return false; for(Group g: groups) { if(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, attrDef, g, null)) return true; } return false; } public Pair<Integer, Integer> getMinAndMaxGidForNamespace(PerunSessionImpl sess, String namespace) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(namespace, "namespace"); Attribute minGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, namespace, A_E_namespace_minGID); Integer minGid = null; if(minGidAttribute.getValue() != null) minGid = (Integer) minGidAttribute.getValue(); Attribute maxGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, namespace, A_E_namespace_maxGID); Integer maxGid = null; if(maxGidAttribute.getValue() != null) maxGid = (Integer) maxGidAttribute.getValue(); return new Pair(minGid, maxGid); } public Integer getFirstFreeGidForResourceOrGroup(PerunSessionImpl sess, String namespace) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException { Utils.notNull(sess, "perunSessionImpl"); Utils.notNull(namespace, "namespace"); Pair<Integer, Integer> minAndMaxGid = this.getMinAndMaxGidForNamespace(sess, namespace); //If there is no min or max gid, return null instead of number, its same like no free gid was able if(minAndMaxGid == null || minAndMaxGid.getLeft() == null || minAndMaxGid.getRight() == null) return null; AttributeDefinition resourceUnixGid = getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGID_namespace + ":" + namespace); List<Object> allGids = sess.getPerunBl().getAttributesManagerBl().getAllValues(sess, resourceUnixGid); AttributeDefinition groupUnixGid = getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_G_unixGID_namespace + ":" + namespace); allGids.addAll(sess.getPerunBl().getAttributesManagerBl().getAllValues(sess, groupUnixGid)); //note: it doesn't matter if the group is not active (isUnixGroup attribute != 1) for(int i = minAndMaxGid.getLeft(); i < minAndMaxGid.getRight(); i++) { if(!allGids.contains(i)) { return i; } } return null; } public void checkIfGIDIsWithinRange(PerunSessionImpl sess, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException, AttributeNotExistsException, WrongAttributeValueException { Utils.notNull(attribute, "attribute"); Integer gid = null; if(attribute.getValue() != null) gid = (Integer) attribute.getValue(); if(gid == null) throw new WrongAttributeValueException(attribute, "Gid with null value is not allowed."); String gidNamespace = attribute.getFriendlyNameParameter(); Attribute minGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_minGID); if(minGidAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, minGidAttribute); Integer minGid = (Integer) minGidAttribute.getValue(); Attribute maxGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_maxGID); if(maxGidAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, maxGidAttribute); Integer maxGid = (Integer) maxGidAttribute.getValue(); if ( gid < minGid || gid > maxGid ) { throw new WrongAttributeValueException(attribute,"GID number is not in allowed values min: "+minGid+", max:"+maxGid); } } public void checkIfListOfGIDIsWithinRange(PerunSessionImpl sess, User user, Attribute attribute) throws InternalErrorException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException, AttributeNotExistsException, WrongAttributeValueException { Utils.notNull(attribute, "attribute"); List<String> gIDs = (List<String>)attribute.getValue(); if (gIDs != null){ for(String sGid : gIDs){ try{ Integer gid = new Integer(sGid); String gidNamespace = attribute.getFriendlyNameParameter(); Attribute minGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_minGID); if(minGidAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, minGidAttribute, "Attribute minGid cannot be null"); Integer minGid = (Integer) minGidAttribute.getValue(); Attribute maxGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_maxGID); if(maxGidAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(attribute, maxGidAttribute, "Attribute maxGid cannot be null"); Integer maxGid = (Integer) maxGidAttribute.getValue(); if ( gid < minGid || gid > maxGid ) { throw new WrongAttributeValueException(attribute,"GID number is not in allowed values min: "+minGid+", max:"+maxGid); } }catch(NumberFormatException ex){ throw new WrongAttributeValueException(attribute ,user,"attribute is not a number", ex); } } } } public Integer getFreeGID(PerunSessionImpl sess, Attribute attribute) throws InternalErrorException, AttributeNotExistsException, WrongAttributeAssignmentException { Utils.notNull(attribute, "attribute"); String gidNamespace = attribute.getFriendlyNameParameter(); Attribute minGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_minGID); if(minGidAttribute.getValue() == null) return 0; Integer minGid = (Integer) minGidAttribute.getValue(); Attribute maxGidAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_namespace_maxGID); if(maxGidAttribute.getValue() == null) return 0; Integer maxGid = (Integer) maxGidAttribute.getValue(); List<Integer> allGids = new ArrayList<>(); Attribute usedGids = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, gidNamespace, A_E_usedGids); if(usedGids.getValue() == null) return minGid; else { Map<String,String> usedGidsValue = (Map<String, String>) usedGids.getValue(); Set<String> keys = usedGidsValue.keySet(); for(String key: keys) { allGids.add(Integer.parseInt(usedGidsValue.get(key))); } } for(int i = minGid; i < maxGid; i++) { if(!allGids.contains(i)) { return i; } } return null; } public Integer getCommonGIDOfGroupsWithSameNameInSameNamespace(PerunSessionImpl sess, List<Group> groupsWithSameGroupNameInSameNamespace, String gidNamespace, Integer commonGID) throws InternalErrorException, WrongAttributeAssignmentException { //If there are no groups, return commonGID from param (it can be null) if(groupsWithSameGroupNameInSameNamespace == null || groupsWithSameGroupNameInSameNamespace.isEmpty()) return commonGID; Utils.notNull(gidNamespace, "gidNamespace"); Group commonGIDGroup = null; //only for more verbose exception messages for(Group g: groupsWithSameGroupNameInSameNamespace) { try { Attribute attr = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, g, A_G_unixGID_namespace + ":" + gidNamespace); if(attr.getValue() != null) { if(commonGID == null) { commonGIDGroup = g; commonGID = (Integer) attr.getValue(); } else { if(!commonGID.equals((Integer) attr.getValue())) throw new ConsistencyErrorException("There are at least 1 groups/resources with same GroupName in same namespace but with different GID in same namespaces. Conflict found: " + g + "(gid=" + attr.getValue()+ ") and " + commonGIDGroup + "(gid=" + commonGID + ")"); } } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } } return commonGID; } public Integer getCommonGIDOfResourcesWithSameNameInSameNamespace(PerunSessionImpl sess, List<Resource> resourcesWithSameGroupNameInSameNamespace, String gidNamespace, Integer commonGID) throws InternalErrorException, WrongAttributeAssignmentException { //If there are no resources, return commonGID from param (it can be null) if(resourcesWithSameGroupNameInSameNamespace == null || resourcesWithSameGroupNameInSameNamespace.isEmpty()) return commonGID; Utils.notNull(gidNamespace,"gidNamespace"); Resource commonGIDResource = null; //only for more verbose exception messages for(Resource r: resourcesWithSameGroupNameInSameNamespace) { try { Attribute attr = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, r, A_R_unixGID_namespace + ":" + gidNamespace); if(attr.getValue() != null) { if(commonGID == null) { commonGIDResource = r; commonGID = (Integer) attr.getValue(); } else { if(!commonGID.equals((Integer) attr.getValue())) throw new ConsistencyErrorException("There are at least 1 groups/resources with same GroupName in same namespace but with different GID in same namespaces. Conflict found: " + r + "(gid=" + attr.getValue()+ ") and " + commonGIDResource + "(gid=" + commonGID + ")"); } } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } } return commonGID; } public int haveTheSameAttributeWithTheSameNamespace(PerunSessionImpl sess, Group group, Attribute attr) throws InternalErrorException, WrongAttributeAssignmentException { Utils.notNull(group, "group"); Utils.notNull(attr, "attr"); String attributeNamespace = attr.getFriendlyNameParameter(); if(attributeNamespace == null || attributeNamespace.isEmpty()) throw new InternalErrorException("Attribute has no namespace, this method can't be use."); try { Attribute testingAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, attr.getName()); if(testingAttribute.getValue() == null) return -1; else { if(!testingAttribute.getValue().equals(attr.getValue())) return 1; } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } return 0; } public int haveTheSameAttributeWithTheSameNamespace(PerunSessionImpl sess, Resource resource, Attribute attr) throws InternalErrorException, WrongAttributeAssignmentException{ Utils.notNull(resource, "resource"); Utils.notNull(attr, "attr"); String attributeNamespace = attr.getFriendlyNameParameter(); if(attributeNamespace == null || attributeNamespace.isEmpty()) throw new InternalErrorException("Attribute has no namespace, this method can't be use."); try { Attribute testingAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, resource, attr.getName()); if(testingAttribute.getValue() == null) return -1; else { if(!testingAttribute.getValue().equals(attr.getValue())) return 1; } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } return 0; } public boolean haveRightToWriteAttributeInAnyGroupOrResource(PerunSessionImpl sess, List<Group> groups, List<Resource> resources, AttributeDefinition groupAttribute, AttributeDefinition resourceAttribute) throws InternalErrorException { if(groups != null && !groups.isEmpty() && groupAttribute != null) { for(Group g: groups) { if(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, groupAttribute, g, null)) return true; } } if(resources != null && !resources.isEmpty() && resourceAttribute != null) { for(Resource r: resources) { if(AuthzResolver.isAuthorizedForAttribute(sess, ActionType.WRITE, resourceAttribute, r, null)) return true; } } return false; } public List<Attribute> getListOfResourceGIDsFromListOfGroupGIDs(PerunSessionImpl sess, List<Attribute> groupGIDs) throws InternalErrorException, AttributeNotExistsException { List<Attribute> resourceGIDs = new ArrayList<Attribute>(); if(groupGIDs == null || groupGIDs.isEmpty()) { return resourceGIDs; } for(Attribute a: groupGIDs) { Attribute resourceGID = new Attribute(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGID_namespace + ":" + a.getFriendlyNameParameter())); resourceGID.setValue(a.getValue()); resourceGIDs.add(resourceGID); } return resourceGIDs; } public List<Attribute> getListOfGroupGIDsFromListOfResourceGIDs(PerunSessionImpl sess, List<Attribute> resourceGIDs) throws InternalErrorException, AttributeNotExistsException { List<Attribute> groupGIDs = new ArrayList<Attribute>(); if(resourceGIDs == null || resourceGIDs.isEmpty()) { return groupGIDs; } for(Attribute a: resourceGIDs) { Attribute groupGID = new Attribute(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_G_unixGID_namespace + ":" + a.getFriendlyNameParameter())); groupGID.setValue(a.getValue()); groupGIDs.add(groupGID); } return groupGIDs; } public Set<String> getSetOfGIDNamespacesWhereFacilitiesHasTheSameGroupNameNamespace(PerunSessionImpl sess, List<Facility> facilities, Attribute unixGroupNameNamespace) throws InternalErrorException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { Set<String> gidNamespaces = new HashSet<String>(); if(facilities == null || facilities.isEmpty()) return gidNamespaces; Utils.notNull(facilities, "facilities"); for(Facility f: facilities) { Attribute facilityGroupNameNamespace; try { facilityGroupNameNamespace = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, f, A_F_unixGroupName_namespace); if(facilityGroupNameNamespace.getValue() != null) { //if they are same, save GID-namespace from this facility to hashSet if(unixGroupNameNamespace.getFriendlyNameParameter().equals((String) facilityGroupNameNamespace.getValue())) { Attribute facilityGIDNamespace = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, f, A_F_unixGID_namespace); //If facilityGIDNamespace exists and is not null, save to the hashSet of gidNamespaces if(facilityGIDNamespace.getValue() != null) { gidNamespaces.add((String) facilityGIDNamespace.getValue()); } } } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } } return gidNamespaces; } public Set<String> getSetOfGroupNameNamespacesWhereFacilitiesHasTheSameGIDNamespace(PerunSessionImpl sess, List<Facility> facilities, Attribute unixGIDNamespace) throws InternalErrorException, WrongAttributeAssignmentException, WrongReferenceAttributeValueException { Set<String> groupNameNamespaces = new HashSet<String>(); if(facilities == null || facilities.isEmpty()) return groupNameNamespaces; Utils.notNull(unixGIDNamespace, "unixGIDNamespace"); for(Facility f: facilities) { Attribute facilityGIDNamespace; try { facilityGIDNamespace = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, f, A_F_unixGID_namespace); if(facilityGIDNamespace.getValue() != null) { //if they are same, save GroupName-namespace from this facility to hashSet if(unixGIDNamespace.getFriendlyNameParameter().equals((String) facilityGIDNamespace.getValue())) { Attribute facilityGroupNameNamespace = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, f, A_F_unixGroupName_namespace); //If facilityGroupNameNamespace exists and is not null, save to the hashSet of gidNamespaces if(facilityGroupNameNamespace.getValue() != null) { groupNameNamespaces.add((String) facilityGroupNameNamespace.getValue()); } else { throw new WrongReferenceAttributeValueException(unixGIDNamespace, facilityGroupNameNamespace, "Facility has gidNamespace set, but groupNameNamespace not set."); } } } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } } return groupNameNamespaces; } public void checkReservedUnixGroupNames(Attribute groupNameAttribute) throws InternalErrorException, WrongAttributeValueException { if(groupNameAttribute == null) return; checkPerunNamespacesMap(); String reservedNames = perunNamespaces.get(groupNameAttribute.getFriendlyName() + ":reservedNames"); if (reservedNames != null) { List<String> reservedNamesList = Arrays.asList(reservedNames.split("\\s*,\\s*")); if (reservedNamesList.contains(groupNameAttribute.getValue())) throw new WrongAttributeValueException(groupNameAttribute, "This groupName is reserved."); } else { //Property not found in our attribute map, so we will use the default hardcoded values instead if (reservedNamesForUnixGroups.contains(groupNameAttribute.getValue())) throw new WrongAttributeValueException(groupNameAttribute, "This groupName is reserved."); } } public void checkUnpermittedUserLogins(Attribute loginAttribute) throws InternalErrorException, WrongAttributeValueException { if(loginAttribute == null) return; checkPerunNamespacesMap(); String unpermittedNames = perunNamespaces.get(loginAttribute.getFriendlyName() + ":reservedNames"); if (unpermittedNames != null) { List<String> unpermittedNamesList = Arrays.asList(unpermittedNames.split("\\s*,\\s*")); if (unpermittedNamesList.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } else { //Property not found in our attribute map, so we will use the default hardcoded values instead if (unpermittedNamesForUserLogins.contains(loginAttribute.getValue())) throw new WrongAttributeValueException(loginAttribute, "This login is not permitted."); } } @Override public Attribute getGoogleGroupNameNamespaceAttributeWithNotNullValue(PerunSessionImpl sess, Resource resource) throws InternalErrorException, WrongReferenceAttributeValueException { Facility facility = sess.getPerunBl().getResourcesManagerBl().getFacility(sess, resource); try { Attribute googleGroupNameNamespaceAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, A_F_googleGroupName_namespace); if(googleGroupNameNamespaceAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(googleGroupNameNamespaceAttribute); return googleGroupNameNamespaceAttribute; } catch(AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } catch(WrongAttributeAssignmentException ex) { throw new InternalErrorException(ex); } } public Attribute getUnixGroupNameNamespaceAttributeWithNotNullValue(PerunSessionImpl sess, Resource resource) throws InternalErrorException, WrongReferenceAttributeValueException { Facility facility = sess.getPerunBl().getResourcesManagerBl().getFacility(sess, resource); try { Attribute unixGroupNameNamespaceAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, A_F_unixGroupName_namespace); if(unixGroupNameNamespaceAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(unixGroupNameNamespaceAttribute); return unixGroupNameNamespaceAttribute; } catch(AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } catch(WrongAttributeAssignmentException ex) { throw new InternalErrorException(ex); } } public Attribute getUnixGIDNamespaceAttributeWithNotNullValue(PerunSessionImpl sess, Resource resource) throws InternalErrorException, WrongReferenceAttributeValueException { Facility facility = sess.getPerunBl().getResourcesManagerBl().getFacility(sess, resource); try { Attribute unixGIDNamespaceAttribute = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, A_F_unixGID_namespace); if(unixGIDNamespaceAttribute.getValue() == null) throw new WrongReferenceAttributeValueException(unixGIDNamespaceAttribute); return unixGIDNamespaceAttribute; } catch(AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } catch(WrongAttributeAssignmentException ex) { throw new InternalErrorException(ex); } } public boolean isGroupUnixGIDNamespaceFillable(PerunSessionImpl sess, Group group, Attribute groupUnixGIDNamespace) throws InternalErrorException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { Utils.notNull(group, "group"); Utils.notNull(groupUnixGIDNamespace, "groupUnixGIDNamespace"); //Get All Facilities from group Set<Facility> facilitiesOfGroup = new HashSet<Facility>(); List<Resource> resourcesOfGroup = sess.getPerunBl().getResourcesManagerBl().getAssignedResources(sess, group); for(Resource r: resourcesOfGroup) { facilitiesOfGroup.add(sess.getPerunBl().getResourcesManagerBl().getFacility(sess, r)); } //Prepare list of gid namespaces of all facilities which have the same groupName namespace like this unixGroupName namespace Set<String> groupNameNamespaces = this.getSetOfGroupNameNamespacesWhereFacilitiesHasTheSameGIDNamespace(sess, new ArrayList<Facility>(facilitiesOfGroup), groupUnixGIDNamespace); if(!groupNameNamespaces.isEmpty()) { for(String s: groupNameNamespaces) { try { Attribute groupNameNamespace = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGroupName_namespace + ":" + s); if(groupNameNamespace.getValue() != null) { return true; } } catch (AttributeNotExistsException ex) { throw new ConsistencyErrorException(ex); } } } return false; } @Override public boolean isNameOfEmailValid(PerunSessionImpl sess, String email) { if (email == null) return false; Matcher emailMatcher = Utils.emailPattern.matcher(email); if (emailMatcher.find()) return true; return false; } public void checkFormatOfShell(String shell, Attribute attribute) throws WrongAttributeValueException { //previous regex ^/[-a-zA-Z0-9_/]*$" Pattern pattern = Pattern.compile("^(/[-_a-zA-Z0-9]+)+$"); Matcher match = pattern.matcher(shell); if (!match.matches()) { throw new WrongAttributeValueException(attribute, "Bad shell attribute format " + shell); } } public void checkAttributeRegex(Attribute attribute, String defaultRegex) throws InternalErrorException, WrongAttributeValueException { if (attribute == null || attribute.getValue() == null) throw new InternalErrorException("Attribute or it's value is null."); String attributeValue = (String) attribute.getValue(); checkPerunNamespacesMap(); String regex = perunNamespaces.get(attribute.getFriendlyName() + ":regex"); if (regex != null) { //Check if regex is valid try { Pattern.compile(regex); } catch (PatternSyntaxException e) { log.error("Regex pattern \"" + regex + "\" from \"" + attribute.getFriendlyName() + ":regex\"" + " property of perun-namespaces.properties file is invalid."); throw new InternalErrorException("Regex pattern \"" + regex + "\" from \"" + attribute.getFriendlyName() + ":regex\"" + " property of perun-namespaces.properties file is invalid."); } if(!attributeValue.matches(regex)) { throw new WrongAttributeValueException(attribute, "Wrong format. Regex: \"" + regex +"\" expected for this attribute:"); } } else { //Regex property not found in our attribute map, so use the default hardcoded regex if (defaultRegex == null) return; if (!attributeValue.matches(defaultRegex)) { throw new WrongAttributeValueException(attribute, "Wrong format. Regex: \"" + defaultRegex +"\" expected for this attribute:"); } } } /** * Internal protected method. * Checks this.perunNamespaces map, which is always initialized as null. * If null, it tries to load the configuration into this map from a perun-namespaces.properties file. * If the file does not exist, it creates an empty HashMap, so it's not null anymore. */ protected void checkPerunNamespacesMap() { if (perunNamespaces == null) { try { perunNamespaces = BeansUtils.getAllPropertiesFromCustomConfiguration("perun-namespaces.properties"); } catch (InternalErrorException e) { perunNamespaces = new HashMap<>(); } } } @Override public Map<String, Pair<BigDecimal, BigDecimal>> checkAndTransferQuotas(Attribute quotasAttribute, PerunBean firstPlaceholder, PerunBean secondPlaceholder, boolean withMetrics) throws InternalErrorException, WrongAttributeValueException { //firstPlaceholder can't be null if(firstPlaceholder == null) throw new InternalErrorException("Missing first mandatory placeHolder (PerunBean)."); //Quotas attribute must exists with not null value if(quotasAttribute == null || quotasAttribute.getValue() == null) throw new InternalErrorException("Attribute quotas for checking and transfering can't be null."); //Prepare result container and value of attribute Map<String, Pair<BigDecimal, BigDecimal>> transferedQuotas = new HashMap<>(); Map<String, String> defaultQuotasMap = (Map<String, String>) quotasAttribute.getValue(); //List to test if all paths are unique (/var/log and /var/log/ are the same so these two paths are not unique) List<String> uniquePaths = new ArrayList<>(); for(String path: defaultQuotasMap.keySet()) { //null is not correct path for volume on File System if(path == null || path.isEmpty()) throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "The path of some volume where quota should be set is null."); //testing if path is unique String canonicalPath; try { canonicalPath = new URI(path).normalize().getPath(); if(!canonicalPath.endsWith("/")) canonicalPath = canonicalPath.concat("/"); } catch (URISyntaxException ex) { throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "Path '" + path + "' is not correct form."); } if(uniquePaths.contains(canonicalPath)) throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "Paths are not unique, there are two same paths: " + path); else uniquePaths.add(canonicalPath); String quota = defaultQuotasMap.get(path); //quota can't be null, if exists in attribute, must be set in some way if(quota == null) throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "The quota of some volume where quota should be set is null."); //check format of quota parameter (for data with metrics, for count of files without metrics) Matcher quotaMatcher; if(withMetrics) { quotaMatcher = ModulesUtilsBlImpl.quotaWithMetricsPattern.matcher(quota); if(!quotaMatcher.matches()) throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "Format of quota in quotas attribute is not correct."); } else { quotaMatcher = ModulesUtilsBlImpl.quotaWithoutMetricsPattern.matcher(quota); if(!quotaMatcher.matches()) throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "Format of quota in quotas attribute is not correct."); } //Parse quotas to variables String softQuota = quotaMatcher.group(1); String hardQuota = quotaMatcher.group(3); //Parse number pattern and letter pattern from whole quotas //SoftQuotaNumber BigDecimal softQuotaAfterTransfer; BigDecimal hardQuotaAfterTransfer; //special behavior with metrics if(withMetrics) { String softQuotaNumber = null; Matcher numberMatcher = numberPattern.matcher(softQuota); if(!numberMatcher.find()) throw new ConsistencyErrorException("Matcher can't find number in softQuota '" + softQuota + "' in attribute " + quotasAttribute); softQuotaNumber = numberMatcher.group(); //SoftQuotaLetter String softQuotaLetter = null; Matcher letterMatcher = letterPattern.matcher(softQuota); //in this case no letter means default and default is G if(!letterMatcher.find()) softQuotaLetter = "G"; else softQuotaLetter = letterMatcher.group(); //HardQuotaNumber String hardQuotaNumber = null; numberMatcher = numberPattern.matcher(hardQuota); if(!numberMatcher.find()) throw new ConsistencyErrorException("Matcher can't find number in hardQuota '" + hardQuota + "' in attribute " + quotasAttribute); hardQuotaNumber = numberMatcher.group(); //HardQuotaLetter String hardQuotaLetter; letterMatcher = letterPattern.matcher(hardQuota); //in this case no letter means default and default is G if(!letterMatcher.find()) hardQuotaLetter = "G"; else hardQuotaLetter = letterMatcher.group(); //Prepare whole big decimal numbers softQuotaAfterTransfer = new BigDecimal(softQuotaNumber); hardQuotaAfterTransfer = new BigDecimal(hardQuotaNumber); //multiplying for softQuota switch (softQuotaLetter) { case "K": break; //K is basic metric, no need to multiply it case "G": softQuotaAfterTransfer = softQuotaAfterTransfer.multiply(BigDecimal.valueOf(G)); break; case "M": softQuotaAfterTransfer = softQuotaAfterTransfer.multiply(BigDecimal.valueOf(M)); break; case "T": softQuotaAfterTransfer = softQuotaAfterTransfer.multiply(BigDecimal.valueOf(T)); break; case "P": softQuotaAfterTransfer = softQuotaAfterTransfer.multiply(BigDecimal.valueOf(P)); break; case "E": softQuotaAfterTransfer = softQuotaAfterTransfer.multiply(BigDecimal.valueOf(E)); break; default: throw new ConsistencyErrorException("There is not allowed character in soft quota letter '" + softQuotaLetter + "'."); } //multiplying for softQuota switch (hardQuotaLetter) { case "K": break; //K is basic metric, no need to multiply it case "G": hardQuotaAfterTransfer = hardQuotaAfterTransfer.multiply(BigDecimal.valueOf(G)); break; case "M": hardQuotaAfterTransfer = hardQuotaAfterTransfer.multiply(BigDecimal.valueOf(M)); break; case "T": hardQuotaAfterTransfer = hardQuotaAfterTransfer.multiply(BigDecimal.valueOf(T)); break; case "P": hardQuotaAfterTransfer = hardQuotaAfterTransfer.multiply(BigDecimal.valueOf(P)); break; case "E": hardQuotaAfterTransfer = hardQuotaAfterTransfer.multiply(BigDecimal.valueOf(E)); break; default: throw new ConsistencyErrorException("There is not allowed character in hard quota letter '" + hardQuotaLetter + "'."); } //easy way without metrics } else { softQuotaAfterTransfer = new BigDecimal(softQuota); hardQuotaAfterTransfer = new BigDecimal(hardQuota); } //test comparing softQuota and hardQuota (softQuota must be less or equals than hardQuota, 0 means unlimited) //1] if softQuota is unlimited, but hardQuota not = exception if(softQuotaAfterTransfer.compareTo(BigDecimal.valueOf(0)) == 0 && hardQuotaAfterTransfer.compareTo(BigDecimal.valueOf(0)) != 0) { throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "SoftQuota is set to unlimited (0) but hardQuota is limited to '" + hardQuota + "'."); //2] if hardQuota is not unlimited but still it is less then softQuota = exception } else if(hardQuotaAfterTransfer.compareTo(BigDecimal.valueOf(0)) != 0 && hardQuotaAfterTransfer.compareTo(softQuotaAfterTransfer) < 0) { throw new WrongAttributeValueException(quotasAttribute, firstPlaceholder, secondPlaceholder, "One of quotas is not correct. HardQuota '" + hardQuota + "' is less then softQuota '" + softQuota + "'."); } //other cases are ok transferedQuotas.put(canonicalPath, new Pair(softQuotaAfterTransfer, hardQuotaAfterTransfer)); } return transferedQuotas; } @Override public Map<String, String> transferQuotasBackToAttributeValue(Map<String, Pair<BigDecimal, BigDecimal>> transferedQuotasMap, boolean withMetrics) throws InternalErrorException { Map<String, String> attributeQuotasValue = new HashMap<>(); //if null or empty, return empty attribute value map for quotas if(transferedQuotasMap == null || transferedQuotasMap.isEmpty()) return attributeQuotasValue; //every path with quotas transfer step by step for(String path: transferedQuotasMap.keySet()) { Pair<BigDecimal, BigDecimal> quotas = transferedQuotasMap.get(path); BigDecimal softQuotaBD = quotas.getLeft(); BigDecimal hardQuotaBD = quotas.getRight(); //Divide decimal till it is still natural number //Soft Quota String softQuota = "0"; //Zero means unlimited, stay the same if(softQuotaBD.compareTo(BigDecimal.ZERO) != 0) { if(withMetrics) softQuota = Utils.bigDecimalBytesToReadableStringWithMetric(softQuotaBD); else softQuota = softQuotaBD.toPlainString(); } //Hard Quota String hardQuota = "0"; //Zero means unlimited, stay the same if(hardQuotaBD.compareTo(BigDecimal.ZERO) != 0) { if(withMetrics) hardQuota = Utils.bigDecimalBytesToReadableStringWithMetric(hardQuotaBD); else hardQuota = hardQuotaBD.toPlainString(); } //add softQuota and hardQuota to result (50T:60T) attributeQuotasValue.put(path, softQuota + ":" + hardQuota); } return attributeQuotasValue; } @Override public Map<String,Pair<BigDecimal, BigDecimal>> mergeMemberAndResourceTransferedQuotas(Map<String, Pair<BigDecimal, BigDecimal>> firstQuotas, Map<String, Pair<BigDecimal, BigDecimal>> secondQuotas) { //if one of them is empty, return the other one (even if it is empty too) if(firstQuotas.isEmpty()) return secondQuotas; if(secondQuotas.isEmpty()) return firstQuotas; Map<String,Pair<BigDecimal, BigDecimal>> mergedTransferedQuotas = new HashMap<>(); //first go through firstQuotas values for(String path: firstQuotas.keySet()) { Pair<BigDecimal, BigDecimal> newValue; Pair<BigDecimal, BigDecimal> firstQuotasValue = firstQuotas.get(path); Pair<BigDecimal, BigDecimal> secondQuotasValue = secondQuotas.get(path); //if there is no values for merge, use them if(secondQuotasValue == null) { newValue = firstQuotasValue; mergedTransferedQuotas.put(path, newValue); //if there are values to merge, merge them } else { BigDecimal softQuota; BigDecimal hardQuota; //merge softQuota if(firstQuotasValue.getLeft().compareTo(new BigDecimal("0")) == 0 || secondQuotasValue.getLeft().compareTo(new BigDecimal("0")) == 0) softQuota = new BigDecimal("0"); else { if(firstQuotasValue.getLeft().compareTo(secondQuotasValue.getLeft()) >= 0) softQuota = firstQuotasValue.getLeft(); else softQuota = secondQuotasValue.getLeft(); } //merge hardQuota if(firstQuotasValue.getRight().compareTo(new BigDecimal("0")) == 0 || secondQuotasValue.getRight().compareTo(new BigDecimal("0")) == 0) hardQuota = new BigDecimal("0"); else { if(firstQuotasValue.getRight().compareTo(secondQuotasValue.getRight()) >= 0) hardQuota = firstQuotasValue.getRight(); else hardQuota = secondQuotasValue.getRight(); } //set new merged values newValue = new Pair(softQuota, hardQuota); mergedTransferedQuotas.put(path, newValue); //remove them from second quotas (they are not unique) secondQuotas.remove(path); } } //save rest of values from secondQuotas (only unique in second quotas are still there, not exists in first quotas) for(String path: secondQuotas.keySet()) { mergedTransferedQuotas.put(path, secondQuotas.get(path)); } return mergedTransferedQuotas; } public Map<String, Pair<BigDecimal, BigDecimal>> countUserFacilityQuotas(List<Map<String, Pair<BigDecimal, BigDecimal>>> allUserQuotas) { Map<String, Pair<BigDecimal, BigDecimal>> resultTransferredQuotas = new HashMap<>(); //for every transfered map of merged quotas count one result transfered map for(Map<String, Pair<BigDecimal, BigDecimal>> mapValue : allUserQuotas) { //for every path in one transfered map for(String pathKey: mapValue.keySet()) { //if path not exists in result map, add it with it's values if(!resultTransferredQuotas.containsKey(pathKey)) { resultTransferredQuotas.put(pathKey, mapValue.get(pathKey)); //if path already exists in result map, sum their quotas together } else { Pair<BigDecimal, BigDecimal> quotasValue1 = resultTransferredQuotas.get(pathKey); Pair<BigDecimal, BigDecimal> quotasValue2 = mapValue.get(pathKey); //for soft quota (left part of pair) BigDecimal softQuota = BigDecimal.ZERO; if(quotasValue1.getLeft().compareTo(BigDecimal.ZERO) != 0 && quotasValue2.getLeft().compareTo(BigDecimal.ZERO) != 0) { softQuota = quotasValue1.getLeft().add(quotasValue2.getLeft()); } //for hard quota (right part of pair) BigDecimal hardQuota = BigDecimal.ZERO; if(quotasValue1.getRight().compareTo(BigDecimal.ZERO) != 0 && quotasValue2.getRight().compareTo(BigDecimal.ZERO) != 0) { hardQuota = quotasValue1.getRight().add(quotasValue2.getRight()); } //create new pair of summed numbers Pair<BigDecimal, BigDecimal> finalQuotasValue = new Pair(softQuota, hardQuota); //add new summed pair to the result map resultTransferredQuotas.put(pathKey, finalQuotasValue); } } } //return result map return resultTransferredQuotas; } @Override public boolean isFQDNValid(PerunSessionImpl sess, String fqdn) { if (fqdn == null) return false; Matcher fqdnMatcher = fqdnPattern.matcher(fqdn); return fqdnMatcher.find(); } /** * Normalize string for purpose of generating safe login value. * * @return normalized string */ public static String normalizeStringForLogin(String toBeNormalized) { if (toBeNormalized == null || toBeNormalized.trim().isEmpty()) return null; toBeNormalized = toBeNormalized.toLowerCase(); toBeNormalized = java.text.Normalizer.normalize(toBeNormalized, java.text.Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+",""); toBeNormalized = toBeNormalized.replaceAll("[^a-zA-Z]+", ""); // unable to fill login for users without name or with partial name if (toBeNormalized == null || toBeNormalized.isEmpty()) { return null; } return toBeNormalized; } /** * Shared logic for purpose of login generation */ public static class LoginGenerator { /** * Define joining function for anonymous classes */ public interface LoginGeneratorFunction { /** * Generate login for user using his name * @param firstName * @param lastName * @return generated login */ public String generateLogin(String firstName, String lastName); } /** * Generate login for user using his name and joining function * * @param user User to get data from * @param function Function to join fist/lastName to login * @return generated login */ public String generateLogin(User user, LoginGeneratorFunction function) { String firstName = user.getFirstName(); String lastName = user.getLastName(); // get only first part of first name and remove spec. chars if (firstName != null && !firstName.isEmpty()) { firstName = ModulesUtilsBlImpl.normalizeStringForLogin(firstName.split(" ")[0]); } // get only last part of last name and remove spec. chars if (lastName != null && !lastName.isEmpty()) { List<String> names = Arrays.asList(lastName.split(" ")); lastName = names.get(names.size() - 1); lastName = ModulesUtilsBlImpl.normalizeStringForLogin(lastName.split(" ")[0]); } // unable to fill login for users without name or with partial name if (firstName == null || firstName.isEmpty() || lastName == null || lastName.isEmpty()) { return null; } return function.generateLogin(firstName, lastName); } } public User getUserFromMessage(PerunSessionImpl sess, String message) throws InternalErrorException { List<PerunBean> perunBeans = AuditParser.parseLog(message); User user = null; UserExtSource userExtSource = null; Member member = null; for(PerunBean perunBean: perunBeans) { if(perunBean instanceof User) { user = (User) perunBean; break; } else if (perunBean instanceof UserExtSource && userExtSource == null) { userExtSource = (UserExtSource) perunBean; } else if (perunBean instanceof Member && member == null) { member = (Member) perunBean; } } //if we don't have object user, try to parse user id from userExtSource (-1 means no userId was defined) if(user == null && userExtSource != null && userExtSource.getUserId() != -1) { try { user = getPerunBl().getUsersManagerBl().getUserById(sess, userExtSource.getUserId()); } catch (UserNotExistsException ex) { log.debug("User from UserExtSource {} can't be found by id in Perun. Probably not exists any more or UserExtSource was audited without proper UserId!", userExtSource); return null; } } else if (user == null && member != null) { try { user = getPerunBl().getUsersManagerBl().getUserById(sess, member.getUserId()); } catch (UserNotExistsException ex) { log.debug("User from Member {} can't be found by id in Perun. Probably not exists any more or Member was audited without proper UserId!", userExtSource); return null; } } return user; } public Map<Integer, Integer> checkAndConvertGIDRanges(Attribute gidRangesAttribute) throws InternalErrorException, WrongAttributeValueException { //Prepare structure for better working with GID Ranges Map<Integer, Integer> convertedRanges = new HashMap<>(); //For null attribute throw an exception if(gidRangesAttribute == null) throw new InternalErrorException("Can't get value from null attribute!"); Map<String, String> gidRanges = (LinkedHashMap) gidRangesAttribute.getValue(); //Return empty map if there is empty input of gidRanges in method parameters if(gidRanges == null || gidRanges.isEmpty()) return convertedRanges; //Check every range if it is in correct format and it is valid range for(String minimumOfRange: gidRanges.keySet()) { //Check not null if(minimumOfRange == null || minimumOfRange.isEmpty()) throw new WrongAttributeValueException(gidRangesAttribute, "Minimum in one of gid ranges is empty!"); String maximumOfRange = gidRanges.get(minimumOfRange); if(maximumOfRange == null || maximumOfRange.isEmpty()) throw new WrongAttributeValueException(gidRangesAttribute, "Maximum in one of gid ranges is empty!"); //Transfer string to numbers Integer minimum; Integer maximum; try { minimum = Integer.valueOf(minimumOfRange); maximum = Integer.valueOf(maximumOfRange); } catch (NumberFormatException ex) { throw new WrongAttributeValueException(gidRangesAttribute, "Min or max value of some range is not correct number format."); } //Check if min value from range is bigger than 0 if(minimum < 1) throw new WrongAttributeValueException(gidRangesAttribute, "Minimum of one of gid ranges is less than 0."); //Check if it is correct range if(minimum>maximum) throw new WrongAttributeValueException(gidRangesAttribute, "One of gid ranges is not correct range. Minimum of this range is bigger then it's maximum."); //Put this valid range to the map of correct gid ranges convertedRanges.put(minimum, maximum); } //Check gid ranges overlaps (there should be no overlaps) Integer lastMaxValue = 0; for(Integer minValue: convertedRanges.keySet().stream().sorted().collect(Collectors.toList())) { if(minValue <= lastMaxValue) throw new WrongAttributeValueException(gidRangesAttribute, "There is an overlap between two gid ranges."); lastMaxValue = convertedRanges.get(minValue); } return convertedRanges; } public PerunBl getPerunBl() { return this.perunBl; } public void setPerunBl(PerunBl perunBl) { this.perunBl = perunBl; } }
e4ad3ccee8a953f4fdd266b935832ecea9797666
8e638dbd3c3402ec09ffa65f5356f5fe5ff1dd48
/trunk/src/main/java/com/pengzu/entity/Blogroll.java
060d10686c17876348a09b6e20c8679116440b0e
[]
no_license
jackieonway/springboot-cms
6d2cb4284774a32bbb356ddd7d41ac98d6b4f11a
3394ce79e821c2309dc373784db35de3a67aac0f
refs/heads/master
2023-03-04T00:19:29.384776
2022-08-01T08:02:58
2022-08-01T08:02:58
149,561,666
4
9
null
2023-08-29T02:04:24
2018-09-20T06:24:37
Java
UTF-8
Java
false
false
2,860
java
package com.pengzu.entity; import java.util.Date; public class Blogroll { private Long id; private String blogrollName; private String blogrollUrl; private String description; private String blogrollImageUrl; private Date createDate; private Date modifyDate; private Long userId; private Integer status; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getBlogrollName() { return blogrollName; } public void setBlogrollName(String blogrollName) { this.blogrollName = blogrollName == null ? null : blogrollName.trim(); } public String getBlogrollUrl() { return blogrollUrl; } public void setBlogrollUrl(String blogrollUrl) { this.blogrollUrl = blogrollUrl == null ? null : blogrollUrl.trim(); } public String getDescription() { return description; } public void setDescription(String description) { this.description = description == null ? null : description.trim(); } public String getBlogrollImageUrl() { return blogrollImageUrl; } public void setBlogrollImageUrl(String blogrollImageUrl) { this.blogrollImageUrl = blogrollImageUrl == null ? null : blogrollImageUrl.trim(); } public Date getCreateDate() { return createDate; } public void setCreateDate(Date createDate) { this.createDate = createDate; } public Date getModifyDate() { return modifyDate; } public void setModifyDate(Date modifyDate) { this.modifyDate = modifyDate; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); sb.append("\"id\":") .append(id); sb.append(",\"blogrollName\":\"") .append(blogrollName).append('\"'); sb.append(",\"blogrollUrl\":\"") .append(blogrollUrl).append('\"'); sb.append(",\"description\":\"") .append(description).append('\"'); sb.append(",\"blogrollImageUrl\":\"") .append(blogrollImageUrl).append('\"'); sb.append(",\"createDate\":\"") .append(createDate).append('\"'); sb.append(",\"modifyDate\":\"") .append(modifyDate).append('\"'); sb.append(",\"userId\":") .append(userId); sb.append(",\"status\":") .append(status); sb.append('}'); return sb.toString(); } }
a45c445dfab1a07eb7d538d1e744b054e0590118
09d80c156b2ccac11ebd26ae0049124f270e1221
/src/main/java/analytics/util/AlphanumComparator.java
e7e488a0a923133ef2c7eba18478b24a1be01066
[]
no_license
monobinab/RealTimeScoring
1417cbbae212b1e13561730e678359c6ab2105e7
88d8f19d5e115562836555a0098bbba15bcfd4f9
refs/heads/master
2021-05-01T17:28:05.691501
2016-10-31T22:17:04
2016-10-31T22:17:04
79,425,196
0
0
null
null
null
null
UTF-8
Java
false
false
4,308
java
package analytics.util; /* * The Alphanum Algorithm is an improved sorting algorithm for strings * containing numbers. Instead of sorting numbers in ASCII order like * a standard sort, this algorithm sorts numbers in numeric order. * * The Alphanum Algorithm is discussed at http://www.DaveKoelle.com * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ import java.util.Comparator; /** * This is an updated version with enhancements made by Daniel Migowski, * Andre Bogus, and David Koelle * * To convert to use Templates (Java 1.5+): * - Change "implements Comparator" to "implements Comparator<String>" * - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)" * - Remove the type checking and casting in compare(). * * To use this class: * Use the static "sort" method from the java.util.Collections class: * Collections.sort(your list, new AlphanumComparator()); */ public class AlphanumComparator implements Comparator { private final boolean isDigit(char ch) { return ch >= 48 && ch <= 57; } /** Length of string is passed in for improved efficiency (only need to calculate it once) **/ private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker); if (!isDigit(c)) break; chunk.append(c); marker++; } } else { while (marker < slength) { c = s.charAt(marker); if (isDigit(c)) break; chunk.append(c); marker++; } } return chunk.toString(); } public int compare(Object o1, Object o2) { if (!(o1 instanceof String) || !(o2 instanceof String)) { return 0; } String s1 = (String)o1; String s2 = (String)o2; int thisMarker = 0; int thatMarker = 0; int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); // If both chunks contain numeric characters, sort them numerically int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { // Simple chunk comparison by length. int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); // If equal, the first different number counts if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) return result; } return s1Length - s2Length; } }
3993909c310fefc86cc5381972044862f373fbec
978d68fe0d10713e3a6d2916bff1df70af24d39a
/org.yli.xreq.common/src/org/yli/xreq/common/osgi/OSGiUtil.java
2d17fd442ea502c95a4cb214b5bd6c56b1b10750
[]
no_license
bloodlee/XRequirement
e5be1c55c9fbdd7d921a2a3db9663501c13fedbb
dcf2abaed2021fe3ddd14aeace3823b74fc8680c
refs/heads/master
2020-05-29T21:44:17.317664
2013-04-21T09:48:12
2013-04-21T09:48:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
601
java
package org.yli.xreq.common.osgi; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; public class OSGiUtil { /** * Query service in bundle context * @param clz the service class. * @param context the bundle context. * @return the service. If service is not there, null will be returned. */ public static <T> T queryService(Class<T> clz, BundleContext context) { ServiceReference<T> serviceRef = context.getServiceReference(clz); if (serviceRef != null) { return context.getService(serviceRef); } else { return null; } } }
ce2986697e36f933a136742ff562805b3851a56f
25d6dd80871f65e8422df4cf25463de3f6168853
/app/src/main/java/com/example/android/charlesmusicplayer/SectionsPagerAdapter.java
1d089f505156defc47cf78b7291e24a99d0bce13
[]
no_license
prinxcharles/CharlesMusicPlayer
07b94608e2195547ec86d6182aa9e728eef1f66c
af9b1365850d23bbc0371d43d391e1078866ada9
refs/heads/master
2020-03-30T05:29:02.233658
2018-09-28T23:34:38
2018-09-28T23:34:42
150,801,658
0
0
null
null
null
null
UTF-8
Java
false
false
1,614
java
package com.example.android.charlesmusicplayer; import android.content.Context; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.example.android.charlesmusicplayer.AlbumFragment; import com.example.android.charlesmusicplayer.R; import com.example.android.charlesmusicplayer.TrackFragment; public class SectionsPagerAdapter extends FragmentPagerAdapter { private Context mContext; public SectionsPagerAdapter(Context context, FragmentManager fm) { super(fm); mContext = context; } @Override public Fragment getItem(int position) { if (position == 0) { return new TrackFragment(); } else if (position == 1) { return new AlbumFragment(); } else if (position == 2) { return new ArtistFragment(); } else{ return new GenreFragment(); } } @Override public int getCount() { return 4; } // This determines the title for each tab @Override public CharSequence getPageTitle(int position) { // Generate title based on item position switch (position) { case 0: return mContext.getString(R.string.tracks); case 1: return mContext.getString(R.string.albums); case 2: return mContext.getString(R.string.artists); case 3: return mContext.getString(R.string.genre); default: return null; } } }
e56636dc558891e5ed7803df410bbf8f3098e308
9235cdc7d4b8acdc38132bd60c362ae0cffda872
/src/test/java/io/spotnext/kakao/ExternalFrameworkTest.java
52bed7f6e286c84f04c692bd932efb0ee11c687e
[ "Apache-2.0" ]
permissive
mojo2012/kakao
8c4edd3c4e6147f1e5160e3cce858ac9e2c17714
6e68aa85a8e7e470e5d6ab204a446cfece857816
refs/heads/master
2021-06-13T09:20:03.617344
2019-08-22T13:19:26
2019-08-22T13:19:26
190,124,047
4
0
null
null
null
null
UTF-8
Java
false
false
455
java
package io.spotnext.kakao; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import io.spotnext.kakao.support.NSBundle; public class ExternalFrameworkTest { @Test public void testLoadBundle() { var bundle = new NSBundle("TestBundle.bundle", this.getClass()); assertNotNull(bundle); assertTrue(bundle.isLoaded()); assertTrue(bundle.isClassLoaded("TestWindowController")); } }
[ "" ]
01bd7937d4a6132ffde850dd353676150ea98bbf
1346575ae688f1e45ee9d7a34a5511d908ff1468
/app/src/main/java/wanba/ott/activity/MikeLingActivity.java
f92fe24b461df30adf7e2fe202a4edd34283e4c8
[]
no_license
wanbatv/wanba_ott
9288f7ed2014055704890e0d967bc22586a63803
b762968fab9ada54e58df258e5a727f1c41fb439
refs/heads/master
2021-01-10T01:35:09.676942
2015-05-27T06:08:03
2015-05-27T06:08:03
36,206,561
0
2
null
null
null
null
UTF-8
Java
false
false
3,618
java
package wanba.ott.activity; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import com.android.volley.Response.ErrorListener; import com.android.volley.Response.Listener; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest; import wanba.ott.activity.R; import wanba.ott.abstracts.activity.FullScreenActivity; import wanba.ott.util.AppUtil; import android.net.Uri; import android.os.Bundle; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.MediaController; import android.widget.Toast; import android.widget.VideoView; /** * MikeLing 页 * * @author zhangyus * */ public class MikeLingActivity extends FullScreenActivity { VideoView mVideoView; MediaController mc; OpenActivityAction openActivityAction; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mike_ling); // LinearLayout linear = (LinearLayout) findViewById(R.id.LinearLayout1); // // 显示进度条 // AppUtil.showProgress(this, "mikeling", // new int[] { R.id.LinearLayout1, }); // // // // 加载背景图片 // AppUtil.getInstance(MikeLingActivity.this).loadImageBitmap(linear, // getIntent().getStringExtra("background"), true); String cateCode = getIntent().getStringExtra("cate_code"); String url = AppUtil.getAferAddCateArgsUrl( getString(R.string.ott_content), cateCode); JsonObjectRequest request = new JsonObjectRequest(url, null, new Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { if (response != null) { try { JSONArray array = response.getJSONArray("results"); JSONArray currDataArray = new JSONArray(); for (int i = 0; i < array.length(); i++) { if (array.getJSONObject(i).getInt("code") == getIntent() .getIntExtra("index", 0)) { currDataArray.put(array.getJSONObject(i)); } } ViewGroup grid = (ViewGroup) findViewById(R.id.ml_grid); for (int i = 0; i < grid.getChildCount(); i++) { // AppUtil.getInstance(MikeLingActivity.this) // .loadImageBitmap( // grid.getChildAt(i), // currDataArray.getJSONObject(i) // .getString("icon"), false); grid.getChildAt(i) .setOnClickListener( new OpenActivityAction( MikeLingActivity.this, SimplePlayerActivity.class, AppUtil.toMap( MikeLingActivity.this, currDataArray .getJSONObject(i)))); } playVod(currDataArray.getJSONObject(0).optString( "play_url", getString(R.string.mikeling_url))); } catch (JSONException e) { e.printStackTrace(); } } } }, new ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { Toast.makeText(MikeLingActivity.this, "读取数据失败,请检查网络连接!", Toast.LENGTH_LONG).show(); } }); AppUtil.getInstance(MikeLingActivity.this).getRequestQueue() .add(request); // ViewGroup viewGroup = (ViewGroup) findViewById(R.id.ml_grid); // // super.bindOnClickListener(viewGroup, openActivityAction); // playVod(); } protected void playVod(String dataPath) { try { mVideoView = (VideoView) findViewById(R.id.simple_video_view); // String dataPath = // getResources().getString(R.string.mikeling_url); mVideoView.requestFocus(); mVideoView.setVideoURI(Uri.parse(dataPath)); mVideoView.start(); } catch (Exception e) { } } }
e7aee6dd7b5e2e51665c6f3a0637c844699ea94e
c8f1e756364ccd536ab2428c67e346286f6f9723
/app/src/main/java/com/obdsim/activities/MainActivity.java
162816bdea9f4960ff34e595d8e48cc79beea9a2
[]
no_license
LeandroCoello/OBDSim
f48065bfb8ec570e093925b3d28a6cc676b8104e
3abef868711499d4bccbdcec4b04045fb52e1912
refs/heads/master
2021-01-25T00:48:16.041881
2017-11-08T23:48:30
2017-11-08T23:48:30
94,692,752
1
0
null
null
null
null
UTF-8
Java
false
false
8,410
java
package com.obdsim.activities; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothSocket; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; import com.obdsim.persistence.ObdCommandContract; import com.obdsim.persistence.entities.MockObdCommand; import com.obdsim.tasks.BluetoothTask; import com.obdsim.R; import com.obdsim.persistence.DataBaseService; import com.obdsim.utils.ConfirmDialog; import com.obdsim.utils.Constants; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.UUID; public class MainActivity extends AppCompatActivity { private static final int REQUEST_ENABLE_BT = 1234; private static final int UPDATE_COMMAND = 0; int waitTime = Constants.WAIT_TIME; // Name for the SDP record when creating server socket private static final String NAME_SECURE = "BluetoothChatSecure"; private static final String NAME_INSECURE = "BluetoothChatInsecure"; // Unique UUID for this application private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); private static final UUID MY_UUID_SECURE = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66"); private static final UUID MY_UUID_INSECURE = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66"); private static BluetoothTask listeningThread; private ListView status; private Button startButton; private Button stopButton; private List<String> states = new ArrayList<String>(); private DataBaseService dataBaseService; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); status = (ListView)findViewById(R.id.status); startButton = (Button) findViewById(R.id.startButton); stopButton = (Button) findViewById(R.id.stopButton); stopButton.setEnabled(false); status.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_main,states)); dataBaseService = new DataBaseService(this); enableBluetooth(); } @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, UPDATE_COMMAND, 0, "Update Wait Time"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case UPDATE_COMMAND: ConfirmDialog.getWaitTimeDialog(this).show(); } return false; } public void start(View v){ states = new ArrayList<String>(); status.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item_main,states)); updateStatus(getString(R.string.connecting), 0); BluetoothAdapter ba = startBluetooth(); if ( ba != null ) { startButton.setEnabled(false); stopButton.setEnabled(true); if (listeningThread != null && !listeningThread.isCancelled()) { listeningThread.cancel(true); listeningThread = null; } listeningThread = new BluetoothTask(ba, this); listeningThread.execute(); } else { updateStatus(getString(R.string.no_bluetooth_adapter),2); } } public void stop(View v){ showToast(getString(R.string.stopped_listening)); states.clear(); status.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item,states)); startButton.setEnabled(true); stopButton.setEnabled(false); if (listeningThread != null && !listeningThread.isCancelled()) { BluetoothSocket socket = listeningThread.getSocket(); if (socket == null) { return; } InputStream in = null; try { in = socket.getInputStream(); in.close(); OutputStream out = socket.getOutputStream(); out.close(); socket.close(); } catch (IOException e) { updateStatus(e.getMessage(), 2); } listeningThread.cancel(true); listeningThread = null; } } public void showCommands(View v) { startActivity(new Intent(this, CommandsActivity.class)); } public void showStateCommands(View v) { startActivity(new Intent(this, StateCommandsActivity.class)); } protected BluetoothAdapter startBluetooth(){ //Getting de Bluetooth Adapter BluetoothAdapter mBluetoothAdapter = getBluetoothAdapter(); if (mBluetoothAdapter == null) { // Device does not support Bluetooth showToast(getString(R.string.no_bluetooth)); updateStatus(getString(R.string.no_bluetooth),2); return mBluetoothAdapter; } //Asking for enable Bluetooth if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } //Getting the paired devices /*Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices(); // If there are paired devices if (pairedDevices.size() > 0) { // Loop through paired devices for (BluetoothDevice device : pairedDevices) { // Do something with each device } }*/ return mBluetoothAdapter; } public static String getNameSecure() { return NAME_SECURE; } public static String getNameInsecure() { return NAME_INSECURE; } public static UUID getMyUuid() { return MY_UUID; } public static UUID getMyUuidSecure() { return MY_UUID_SECURE; } public static UUID getMyUuidInsecure() { return MY_UUID_INSECURE; } public Button getStartButton() { return startButton; } public Button getStopButton() { return stopButton; } public void updateStatus(String newState, Integer type) { if (type == 0) { newState = "[INFO] " + newState; } if (type == 1) { newState = "[WARN] " + newState; } if (type == 2) { newState = "[ERROR] " + newState; } if (type == 3) { newState = "[INFO][RECEIVED] " + newState; } if (type == 4) { newState = "[INFO][SENT] " + newState; } states.add(newState); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item_main,states); status.setAdapter(adapter); status.setSelection(adapter.getCount()); } public void enableBluetooth() { if(getBluetoothAdapter()!= null && !getBluetoothAdapter().isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, 1); } } private BluetoothAdapter getBluetoothAdapter() { return BluetoothAdapter.getDefaultAdapter(); } @Override protected void onDestroy() { BluetoothAdapter ba = getBluetoothAdapter(); if (ba != null && ba.isEnabled()) { ba.disable(); } super.onDestroy(); } public void showToast(String msg) { Toast.makeText(getApplicationContext(),msg, Toast.LENGTH_LONG).show(); } public DataBaseService getDataBaseService() { return dataBaseService; } public int getWaitTime() { return waitTime; } public void setWaitTime(int waitTime) { this.waitTime = waitTime; if (listeningThread != null) { listeningThread.setWaitTime(waitTime); } } @Override public void onBackPressed(){ if(listeningThread !=null && !listeningThread.isCancelled()) { listeningThread.cancel(true); listeningThread = null; } super.onBackPressed(); } }
a4e27c758eaad26d3830aa66ef5a7b2fbafafcb1
a3312d49ea7d9d1d0a56382fb6a2fedfed318056
/src/main/java/io/rakam/clickhouse/StreamConfig.java
338fdfd1906040397ba05e6d38965ef69500de87
[]
no_license
maduhu/rakam-clickhouse-worker
9684f8009c43b31d0be421ddae960146dc76bcd7
eedf514727f8b2be2c5e56051c5a137848de3f56
refs/heads/master
2021-01-15T17:19:20.013270
2016-07-23T17:15:44
2016-07-23T17:15:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,059
java
package io.rakam.clickhouse; import io.airlift.configuration.Config; import io.airlift.units.DataSize; import java.time.Duration; import static io.airlift.units.DataSize.Unit.GIGABYTE; public class StreamConfig { private Duration maxFlushDuration = Duration.ofSeconds(5); private int maxFlushRecords = 50_000; private String appName = "consumer"; @Config("stream.max-flush-duration") public void setMaxFlushDuration(Duration maxFlushDuration) { this.maxFlushDuration = maxFlushDuration; } @Config("event.store.kinesis.app_name") public void setAppName(String appName) { this.appName = appName; } public String getAppName() { return appName; } @Config("stream.max-flush-records") public void setMaxFlushRecords(int maxFlushRecords) { this.maxFlushRecords = maxFlushRecords; } public Duration getMaxFlushDuration() { return maxFlushDuration; } public int getMaxFlushRecords() { return maxFlushRecords; } }
a2a730f5a52a690fa510e75cd59eb2c46deb4322
3a809e0150e2b62d31ae8966e14e08e09c546313
/src/main/java/com/sx/reflect/HiddenC.java
0b83362d427e7c0db9d2564871f981289df829e5
[]
no_license
shenxuan52142/SSM_Study
7d48c6dc60519778e0b238cad91f29ca3a5efba1
5d0a916938b319fe888b11c96ef230d8c468ab2d
refs/heads/master
2020-03-24T23:22:31.409273
2019-03-29T10:46:46
2019-03-29T10:46:46
143,130,667
0
0
null
null
null
null
UTF-8
Java
false
false
109
java
package com.sx.reflect; public class HiddenC { public static A makeA(){ return new C(); } }
9a17893f81fca715481d3877dfd23dd1b6287b8c
2552a2e621fe436164d1137b98e2678d0c97ab97
/FirstSpringBootAppTest/src/main/java/com/bikash/FirstSpringBootAppTestApplication.java
77d874ef56811e5ac32a750516b8bdd961192668
[]
no_license
nyodbikash/SpringDataProject
8543f0debd816125023fedc393385ac5b9ea54ad
491d337c1e19d1ee6d77d27cf7861ff690a78a53
refs/heads/master
2023-07-03T00:20:02.968976
2021-08-03T04:59:13
2021-08-03T04:59:13
391,098,834
0
0
null
null
null
null
UTF-8
Java
false
false
335
java
package com.bikash; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class FirstSpringBootAppTestApplication { public static void main(String[] args) { SpringApplication.run(FirstSpringBootAppTestApplication.class, args); } }
58827f1b570ee5cccc825d382eaf7f0b0b21b12c
7e385975ef6aa9a7371e832676f38ede744a833f
/src/main/java/com/example/Response.java
b1bf0d68fdfcd9d5f56fc2a304c55e08c9a526cb
[]
no_license
vivekkumar7442/springboot-react
49e7dbc7b97a457b96db90965ab5a9ec94f8a3cb
c01414cd35b3de4ed780865ba0d518628f1ad723
refs/heads/master
2023-05-30T15:41:03.485644
2021-06-02T00:12:37
2021-06-02T00:12:37
368,392,701
0
1
null
null
null
null
UTF-8
Java
false
false
395
java
package com.example; import org.springframework.http.HttpHeaders; public class Response { private String data; private HttpHeaders headers; public String getData() { return data; } public void setData(String data) { this.data = data; } public HttpHeaders getHeaders() { return headers; } public void setHeaders(HttpHeaders headers) { this.headers = headers; } }
cd0e31647d5b60bd22e5f17e171d0d2824ae4892
d228df0b49768f42543a4ef1cd36d292f2901b7b
/src/main/java/com/arc/docker/DockerApplication.java
8adf6ab40e7d8d47daed422ceafb569084274cd0
[ "MIT" ]
permissive
lamymay/docker
97528ed73c5108549edf312dc4b2b6126bf2004c
6759c01277e25fc4c994f03225310d2206900590
refs/heads/master
2020-06-27T05:52:26.139731
2019-08-19T02:20:51
2019-08-19T02:20:51
199,861,921
0
0
null
null
null
null
UTF-8
Java
false
false
944
java
package com.arc.docker; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @SpringBootApplication public class DockerApplication { public static void main(String[] args) { SpringApplication.run(DockerApplication.class, args); } @GetMapping("/info") public ResponseEntity code2() { ResponseEntity responseEntity = new ResponseEntity<Object>("hello-info", HttpStatus.OK); return responseEntity; } @GetMapping("/info2") public ResponseEntity info2() { ResponseEntity responseEntity = new ResponseEntity<Object>("hello-info-2", HttpStatus.OK); return responseEntity; } }
9b8794a06ed20eea17839d812a51f88a34da6097
3cddceb55c6c393cab24af9915289d14f245e020
/src/Modelo/Cliente.java
1e77ff3a294eb4419e787a565f07f209ff399ae0
[]
no_license
leticiasoaress/CadastroCliente
272f5e4301278f428a5dd888e8b5bd52ba1b5a5e
470e877ab90ef4cfd69e0694dafcbec4014ad4ef
refs/heads/master
2023-01-10T21:22:40.978976
2020-11-02T20:57:15
2020-11-02T20:57:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,201
java
package Modelo; public class Cliente { public int id; public String nome; public String tel_Residencial; public String tel_Comercial; public String tel_Celular; public String email; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public String getTel_Residencial() { return tel_Residencial; } public void setTel_Residencial(String tel_Residencial) { this.tel_Residencial = tel_Residencial; } public String getTel_Comercial() { return tel_Comercial; } public void setTel_Comercial(String tel_Comercial) { this.tel_Comercial = tel_Comercial; } public String getTel_Celular() { return tel_Celular; } public void setTel_Celular(String tel_Celular) { this.tel_Celular = tel_Celular; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } }
[ "Leticia@Leticia-PC" ]
Leticia@Leticia-PC
2453fc962ca54c27c5cd2898b25098767f5b0351
1cc8785ce8a53a8e7df4e524ea475b04d4960ed0
/app/src/main/java/com/openclassrooms/realestatemanager/injections/Injections.java
a469d4e06e709a353574dccccd38d886db245e12
[]
no_license
JohanneBoisvilliers/RealEstateManager
d1ca5f90c9fe712fed9b21bce9393e8b019b87bf
5850d1642bc8bb201e448362aadeb2727b7c8ad2
refs/heads/master
2020-05-18T01:57:47.499920
2019-10-18T09:24:56
2019-10-18T09:24:56
184,102,921
1
0
null
2019-10-18T09:24:57
2019-04-29T16:06:29
Java
UTF-8
Java
false
false
1,780
java
package com.openclassrooms.realestatemanager.injections; import android.content.Context; import com.openclassrooms.realestatemanager.database.RealEstateDatabase; import com.openclassrooms.realestatemanager.repositories.PhotoDataRepository; import com.openclassrooms.realestatemanager.repositories.RealEstateDataRepository; import com.openclassrooms.realestatemanager.repositories.UserDataRepository; import java.util.concurrent.Executor; import java.util.concurrent.Executors; public class Injections { public static RealEstateDataRepository provideRealEstateDataSource(Context context) { RealEstateDatabase database = RealEstateDatabase.getInstance(context); return new RealEstateDataRepository(database.realEstateDao()); } public static PhotoDataRepository providePhotoDataSource(Context context) { RealEstateDatabase database = RealEstateDatabase.getInstance(context); return new PhotoDataRepository(database.photoDao()); } public static UserDataRepository provideUserDateSource(Context context) { RealEstateDatabase database = RealEstateDatabase.getInstance(context); return new UserDataRepository(database.userDao()); } public static Executor provideExecutor(){ return Executors.newSingleThreadExecutor(); } public static ViewModelFactory provideViewModelFactory(Context context) { RealEstateDataRepository realEstateDataSource = provideRealEstateDataSource(context); PhotoDataRepository photoDataSource = providePhotoDataSource(context); UserDataRepository userDataSource = provideUserDateSource(context); Executor executor = provideExecutor(); return new ViewModelFactory(realEstateDataSource,photoDataSource,userDataSource, executor); } }
8f5ae61f24823f85094b2a4d0087e69e29e27579
719db14d08262cbbf4be58b7a53c7baf07c5c2fd
/system_develop_management/system_management_web/target/tomcat/work/Tomcat/localhost/_/org/apache/jsp/pages/user_002drole_002dadd_jsp.java
6105a0ffbd34fd3415165e1a3d0157aeddf24478
[]
no_license
zhaonan0212/Delta
07041abbbe3988e6689dc20be869c28a40a729e1
17ded5ffc4de568d83808521f001f012f93f1680
refs/heads/master
2022-12-23T06:35:50.893885
2019-08-08T08:54:20
2019-08-08T08:54:20
201,173,943
0
0
null
2022-12-15T23:43:07
2019-08-08T03:51:24
JavaScript
UTF-8
Java
false
false
42,705
java
/* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/7.0.47 * Generated at: 2019-03-12 03:47:10 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp.pages; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class user_002drole_002dadd_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static org.apache.jasper.runtime.ProtectedFunctionMapper _jspx_fnmap_0; static { _jspx_fnmap_0= org.apache.jasper.runtime.ProtectedFunctionMapper.getMapForFunction("fn:contains", org.apache.taglibs.standard.functions.Functions.class, "contains", new Class[] {java.lang.String.class, java.lang.String.class}); } private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvar_005fitems; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fif_0026_005ftest; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public void _jspInit() { _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvar_005fitems = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); _005fjspx_005ftagPool_005fc_005fif_0026_005ftest = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvar_005fitems.release(); _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.release(); } public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n"); out.write("<html>\r\n"); out.write("<head>\r\n"); out.write(" <!-- 页面meta -->\r\n"); out.write(" <meta charset=\"utf-8\">\r\n"); out.write(" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\r\n"); out.write(" <title>数据 - AdminLTE2定制版</title>\r\n"); out.write(" <meta name=\"description\" content=\"AdminLTE2定制版\">\r\n"); out.write(" <meta name=\"keywords\" content=\"AdminLTE2定制版\">\r\n"); out.write("\r\n"); out.write(" <!-- Tell the browser to be responsive to screen width -->\r\n"); out.write(" <meta\r\n"); out.write(" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\"\r\n"); out.write(" name=\"viewport\">\r\n"); out.write("\r\n"); out.write("\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap/css/bootstrap.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/font-awesome/css/font-awesome.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/ionicons/css/ionicons.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/iCheck/square/blue.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/morris/morris.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/jvectormap/jquery-jvectormap-1.2.2.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datepicker/datepicker3.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/daterangepicker/daterangepicker.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datatables/dataTables.bootstrap.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/treeTable/jquery.treetable.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/treeTable/jquery.treetable.theme.default.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/select2/select2.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/colorpicker/bootstrap-colorpicker.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/adminLTE/css/AdminLTE.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/adminLTE/css/skins/_all-skins.min.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/css/style.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/ionslider/ion.rangeSlider.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/ionslider/ion.rangeSlider.skinNice.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-slider/slider.css\">\r\n"); out.write(" <link rel=\"stylesheet\"\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css\">\r\n"); out.write("</head>\r\n"); out.write("\r\n"); out.write("<body class=\"hold-transition skin-purple sidebar-mini\">\r\n"); out.write("\r\n"); out.write("<div class=\"wrapper\">\r\n"); out.write("\r\n"); out.write(" <!-- 页面头部 -->\r\n"); out.write(" "); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "header.jsp", out, false); out.write("\r\n"); out.write(" <!-- 页面头部 /-->\r\n"); out.write(" <!-- 导航侧栏 -->\r\n"); out.write(" "); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "aside.jsp", out, false); out.write("\r\n"); out.write(" <!-- 导航侧栏 /-->\r\n"); out.write("\r\n"); out.write(" <!-- 内容区域 -->\r\n"); out.write(" <div class=\"content-wrapper\">\r\n"); out.write("\r\n"); out.write(" <!-- 内容头部 -->\r\n"); out.write(" <section class=\"content-header\">\r\n"); out.write(" <h1>\r\n"); out.write(" 用户管理\r\n"); out.write(" <small>添加角色表单</small>\r\n"); out.write(" </h1>\r\n"); out.write(" <ol class=\"breadcrumb\">\r\n"); out.write(" <li><a href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/index.jsp\"><i\r\n"); out.write(" class=\"fa fa-dashboard\"></i> 首页</a></li>\r\n"); out.write(" <li><a\r\n"); out.write(" href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/user/findAll.do\">用户管理</a></li>\r\n"); out.write(" <li class=\"active\">添加角色表单</li>\r\n"); out.write(" </ol>\r\n"); out.write(" </section>\r\n"); out.write(" <!-- 内容头部 /-->\r\n"); out.write("\r\n"); out.write(" <form\r\n"); out.write(" action=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/user/addRoleToUser.do\"\r\n"); out.write(" method=\"post\">\r\n"); out.write(" <!-- 正文区域 -->\r\n"); out.write(" <section class=\"content\"><input type=\"hidden\" name=\"userId\"\r\n"); out.write(" value=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${user.id}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("\">\r\n"); out.write(" <table id=\"dataList\"\r\n"); out.write(" class=\"table table-bordered table-striped table-hover dataTable\">\r\n"); out.write(" <thead>\r\n"); out.write(" <tr>\r\n"); out.write(" <th class=\"\" style=\"padding-right: 0px\">\r\n"); out.write(" <input id=\"selall\"\r\n"); out.write(" type=\"checkbox\" class=\"icheckbox_square-blue\"></th>\r\n"); out.write(" <th class=\"sorting_asc\">ID</th>\r\n"); out.write(" <th class=\"sorting\">角色名称</th>\r\n"); out.write(" <th class=\"sorting\">角色描述</th>\r\n"); out.write(" </tr>\r\n"); out.write(" </thead>\r\n"); out.write(" <tbody>\r\n"); out.write(" "); if (_jspx_meth_c_005fforEach_005f0(_jspx_page_context)) return; out.write("\r\n"); out.write(" </tbody>\r\n"); out.write("\r\n"); out.write(" </table>\r\n"); out.write(" <!--订单信息/--> <!--工具栏-->\r\n"); out.write(" <div class=\"box-tools text-center\">\r\n"); out.write(" <button type=\"submit\" class=\"btn bg-maroon\">保存</button>\r\n"); out.write(" <button type=\"button\" class=\"btn bg-default\"\r\n"); out.write(" onclick=\"history.back(-1);\">返回\r\n"); out.write(" </button>\r\n"); out.write(" </div>\r\n"); out.write(" <!--工具栏/--> </section>\r\n"); out.write(" <!-- 正文区域 /-->\r\n"); out.write(" </form>\r\n"); out.write(" </div>\r\n"); out.write(" <!-- 内容区域 /-->\r\n"); out.write("\r\n"); out.write(" <!-- 底部导航 -->\r\n"); out.write(" <footer class=\"main-footer\">\r\n"); out.write(" <div class=\"pull-right hidden-xs\">\r\n"); out.write(" <b>Version</b> 1.0.8\r\n"); out.write(" </div>\r\n"); out.write(" <strong>Copyright &copy; 2014-2017 <a\r\n"); out.write(" href=\"http://www.itcast.cn\">研究院研发部</a>.\r\n"); out.write(" </strong> All rights reserved.\r\n"); out.write(" </footer>\r\n"); out.write(" <!-- 底部导航 /-->\r\n"); out.write("\r\n"); out.write("</div>\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/jQuery/jquery-2.2.3.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/jQueryUI/jquery-ui.min.js\"></script>\r\n"); out.write("<script>\r\n"); out.write(" $.widget.bridge('uibutton', $.ui.button);\r\n"); out.write("</script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap/js/bootstrap.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/raphael/raphael-min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/morris/morris.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/sparkline/jquery.sparkline.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/jvectormap/jquery-jvectormap-world-mill-en.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/knob/jquery.knob.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/daterangepicker/moment.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/daterangepicker/daterangepicker.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/daterangepicker/daterangepicker.zh-CN.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datepicker/bootstrap-datepicker.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/slimScroll/jquery.slimscroll.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/fastclick/fastclick.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/iCheck/icheck.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/adminLTE/js/app.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/treeTable/jquery.treetable.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/select2/select2.full.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/colorpicker/bootstrap-colorpicker.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-markdown/js/bootstrap-markdown.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-markdown/js/markdown.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-markdown/js/to-markdown.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/ckeditor/ckeditor.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/input-mask/jquery.inputmask.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/input-mask/jquery.inputmask.date.extensions.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/input-mask/jquery.inputmask.extensions.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datatables/jquery.dataTables.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/datatables/dataTables.bootstrap.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/chartjs/Chart.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/flot/jquery.flot.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/flot/jquery.flot.resize.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/flot/jquery.flot.pie.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/flot/jquery.flot.categories.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/ionslider/ion.rangeSlider.min.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-slider/bootstrap-slider.js\"></script>\r\n"); out.write("<script\r\n"); out.write(" src=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js\"></script>\r\n"); out.write("\r\n"); out.write("<script>\r\n"); out.write(" $(document).ready(function () {\r\n"); out.write(" // 选择框\r\n"); out.write(" $(\".select2\").select2();\r\n"); out.write("\r\n"); out.write(" // WYSIHTML5编辑器\r\n"); out.write(" $(\".textarea\").wysihtml5({\r\n"); out.write(" locale: 'zh-CN'\r\n"); out.write(" });\r\n"); out.write(" // 全选操作\r\n"); out.write(" $(\"#selall\").click(function () {\r\n"); out.write(" var clicks = $(this).is(':checked');\r\n"); out.write(" if (!clicks) {\r\n"); out.write(" $(\"#dataList td input[type='checkbox']\").iCheck(\"uncheck\");\r\n"); out.write(" } else {\r\n"); out.write(" $(\"#dataList td input[type='checkbox']\").iCheck(\"check\");\r\n"); out.write(" }\r\n"); out.write(" $(this).data(\"clicks\", !clicks);\r\n"); out.write(" });\r\n"); out.write(" });\r\n"); out.write("\r\n"); out.write(" // 设置激活菜单\r\n"); out.write(" function setSidebarActive(tagUri) {\r\n"); out.write(" var liObj = $(\"#\" + tagUri);\r\n"); out.write(" if (liObj.length > 0) {\r\n"); out.write(" liObj.parent().parent().addClass(\"active\");\r\n"); out.write(" liObj.addClass(\"active\");\r\n"); out.write(" }\r\n"); out.write(" }\r\n"); out.write("</script>\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("</body>\r\n"); out.write("\r\n"); out.write("</html>"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } private boolean _jspx_meth_c_005fforEach_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:forEach org.apache.taglibs.standard.tag.rt.core.ForEachTag _jspx_th_c_005fforEach_005f0 = (org.apache.taglibs.standard.tag.rt.core.ForEachTag) _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvar_005fitems.get(org.apache.taglibs.standard.tag.rt.core.ForEachTag.class); _jspx_th_c_005fforEach_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fforEach_005f0.setParent(null); // /pages/user-role-add.jsp(116,20) name = items type = javax.el.ValueExpression reqTime = true required = false fragment = false deferredValue = true expectedTypeName = java.lang.Object deferredMethod = false methodSignature = null _jspx_th_c_005fforEach_005f0.setItems(new org.apache.jasper.el.JspValueExpression("/pages/user-role-add.jsp(116,20) '${roleList}'",_el_expressionfactory.createValueExpression(_jspx_page_context.getELContext(),"${roleList}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext())); // /pages/user-role-add.jsp(116,20) name = var type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fforEach_005f0.setVar("role"); int[] _jspx_push_body_count_c_005fforEach_005f0 = new int[] { 0 }; try { int _jspx_eval_c_005fforEach_005f0 = _jspx_th_c_005fforEach_005f0.doStartTag(); if (_jspx_eval_c_005fforEach_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n"); out.write(" <tr>\r\n"); out.write(" <td><input name=\"ids\"\r\n"); out.write(" "); if (_jspx_meth_c_005fif_005f0(_jspx_th_c_005fforEach_005f0, _jspx_page_context, _jspx_push_body_count_c_005fforEach_005f0)) return true; out.write("\r\n"); out.write(" type=\"checkbox\" value=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${role.id}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("\"></td>\r\n"); out.write(" <td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${role.id}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("</td>\r\n"); out.write(" <td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${role.roleName }", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("</td>\r\n"); out.write(" <td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${role.roleDesc}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false)); out.write("</td>\r\n"); out.write("\r\n"); out.write(" </tr>\r\n"); out.write(" "); int evalDoAfterBody = _jspx_th_c_005fforEach_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fforEach_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { return true; } } catch (java.lang.Throwable _jspx_exception) { while (_jspx_push_body_count_c_005fforEach_005f0[0]-- > 0) out = _jspx_page_context.popBody(); _jspx_th_c_005fforEach_005f0.doCatch(_jspx_exception); } finally { _jspx_th_c_005fforEach_005f0.doFinally(); _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvar_005fitems.reuse(_jspx_th_c_005fforEach_005f0); } return false; } private boolean _jspx_meth_c_005fif_005f0(javax.servlet.jsp.tagext.JspTag _jspx_th_c_005fforEach_005f0, javax.servlet.jsp.PageContext _jspx_page_context, int[] _jspx_push_body_count_c_005fforEach_005f0) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:if org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); _jspx_th_c_005fif_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fif_005f0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_c_005fforEach_005f0); // /pages/user-role-add.jsp(119,39) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fif_005f0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${fn:contains(roleNames,role.roleName)}", java.lang.Boolean.class, (javax.servlet.jsp.PageContext)_jspx_page_context, _jspx_fnmap_0, false)).booleanValue()); int _jspx_eval_c_005fif_005f0 = _jspx_th_c_005fif_005f0.doStartTag(); if (_jspx_eval_c_005fif_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("checked=\"checked\""); int evalDoAfterBody = _jspx_th_c_005fif_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fif_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); return true; } _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); return false; } }
99f1d1f73b42b0e4306f37dcf62e362e2cf0135b
ca0e9689023cc9998c7f24b9e0532261fd976e0e
/src/com/tencent/mm/plugin/backup/ui/BakChatRecoverCheckUI$6.java
0a740fe5debaeaca1ab64049f372014d3b8de802
[]
no_license
honeyflyfish/com.tencent.mm
c7e992f51070f6ac5e9c05e9a2babd7b712cf713
ce6e605ff98164359a7073ab9a62a3f3101b8c34
refs/heads/master
2020-03-28T15:42:52.284117
2016-07-19T16:33:30
2016-07-19T16:33:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
546
java
package com.tencent.mm.plugin.backup.ui; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; final class BakChatRecoverCheckUI$6 implements DialogInterface.OnClickListener { BakChatRecoverCheckUI$6(BakChatRecoverCheckUI paramBakChatRecoverCheckUI) {} public final void onClick(DialogInterface paramDialogInterface, int paramInt) {} } /* Location: * Qualified Name: com.tencent.mm.plugin.backup.ui.BakChatRecoverCheckUI.6 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */
8aeb97730b9b222ef5ea160164bbefb7676017d7
613061df99b8bf6ffc385919fce6147ab0777f89
/app/src/main/java/com/stevesun/andrew/ui/home/HomeViewModel.java
082fa877e488db222a961511009781d85f2e31db
[]
no_license
SteveSunTech/Andrew
38cdff1fc67d86c305cc46ed863fa7123c43b074
00b6bc1057f94e5163a258f0b720d295f570103e
refs/heads/master
2023-03-01T04:41:01.092845
2021-02-06T19:42:10
2021-02-06T19:42:10
336,185,448
0
0
null
null
null
null
UTF-8
Java
false
false
980
java
package com.stevesun.andrew.ui.home; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Transformations; import androidx.lifecycle.ViewModel; import com.stevesun.andrew.model.Article; import com.stevesun.andrew.model.NewsResponse; import com.stevesun.andrew.repository.NewsRepository; public class HomeViewModel extends ViewModel { private final NewsRepository repository; private final MutableLiveData<String> countryInput = new MutableLiveData<>(); public HomeViewModel(NewsRepository newsRepository) { this.repository = newsRepository; } public void setCountryInput(String country) { countryInput.setValue(country); } public void setFavoriteArticleInput(Article article) { repository.favoriteArticle(article); } public LiveData<NewsResponse> getTopHeadlines() { return Transformations.switchMap(countryInput, repository::getTopHeadlines); } }
4c6843b827624ec76e2ea9e49345a0d361510fe8
43b53bfb21a4c0e65871adfe1dd6451789d49830
/src/supportTools/SwarmMapInit.java
71305ac41854ed9913c75957845c2eb7ed0bb94a
[]
no_license
CS-537-Spring-2016/ROVER_12
0718b3d10b152f6b243c7f193a714393568129d0
7f24cb9afd4e408ae27777d08b3eff49b03c2b1a
refs/heads/master
2021-01-17T15:41:02.930509
2016-06-04T07:00:49
2016-06-04T07:00:49
55,834,857
0
1
null
null
null
null
UTF-8
Java
false
false
9,960
java
package supportTools; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import org.json.simple.JSONObject; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import common.Coord; import common.MapTile; import common.PlanetMap; import common.RoverLocations; import common.ScienceLocations; import enums.RoverName; import enums.Science; import enums.Terrain; import json.GlobalReader; import json.MyWriter; public class SwarmMapInit { private String mapName; private int mapWidth; private int mapHeight; private PlanetMap planetMap; private RoverLocations roverLocations; private ScienceLocations scienceLocations; private Coord startPosCoord = null; private Coord targetPosCoord = null; public SwarmMapInit(int notUsed) { // for testing purposes this.mapWidth = 5; this.mapHeight = 5; this.planetMap = new PlanetMap(mapWidth, mapHeight); this.planetMap.loadSmallExampleTestPlanetMapTerrain(); this.roverLocations = new RoverLocations(); this.roverLocations.loadExampleTestRoverLocations(); this.scienceLocations = new ScienceLocations(); this.scienceLocations.loadExampleTestScienceLocations(); this.mapName = ""; this.startPosCoord = new Coord(1,1); this.targetPosCoord = new Coord(2,2); } public SwarmMapInit() { this.mapWidth = 0; this.mapHeight = 0; this.planetMap = new PlanetMap(mapWidth, mapHeight); this.roverLocations = new RoverLocations(); this.scienceLocations = new ScienceLocations(); this.mapName = ""; } public SwarmMapInit(String name, int width, int height, PlanetMap planetMapIn, RoverLocations roverLoc, ScienceLocations scienceLoc) { this.mapWidth = width; this.mapHeight = height; this.planetMap = planetMapIn; this.roverLocations = roverLoc; this.scienceLocations = scienceLoc; this.mapName = name; this.startPosCoord = planetMapIn.getStartPosition(); this.targetPosCoord = planetMapIn.getTargetPosition(); } public void saveToJson(String fileName) { MyWriter mapwriter = new MyWriter(this, fileName); } public void loadFromJson(String fileName) { Gson gson = new GsonBuilder() .setPrettyPrinting() .enableComplexMapKeySerialization() .create(); GlobalReader gread = new GlobalReader(fileName); JSONObject jInit = new JSONObject();// getJSONObject() jInit = gread.getJSONObject(); SwarmMapInit tswarm = new SwarmMapInit(); tswarm = gson.fromJson(jInit.toJSONString(), new TypeToken<SwarmMapInit>() { }.getType()); this.mapWidth = tswarm.mapWidth; this.mapHeight = tswarm.mapHeight; this.planetMap = tswarm.planetMap; this.roverLocations = tswarm.roverLocations; this.scienceLocations = tswarm.scienceLocations; this.mapName = tswarm.mapName; this.startPosCoord = tswarm.planetMap.getStartPosition(); this.targetPosCoord = tswarm.planetMap.getTargetPosition(); } public int getMapWidth() { return mapWidth; } public int getMapHeight() { return mapHeight; } public PlanetMap getPlanetMap() { return planetMap; } public RoverLocations getRoverLocations() { return roverLocations; } public ScienceLocations getScienceLocations() { return scienceLocations; } public void parseInputFromDisplayTextFile(String fileName) throws IOException { this.roverLocations = new RoverLocations(); this.scienceLocations = new ScienceLocations(); FileReader input = new FileReader(fileName); BufferedReader bufRead = new BufferedReader(input); String myLine = null; // line 1 - map name this.mapName = bufRead.readLine(); System.out.println("MapInit: " + this.mapName); // line 2 - map width and height Coord mapSize = extractCoord(bufRead.readLine()); this.mapWidth = mapSize.xpos; this.mapHeight = mapSize.ypos; // line 3 - start position (x, y) coordinate Coord startPos = extractCoord(bufRead.readLine()); // line 4 - target position x coordinate Coord targetPos = extractCoord(bufRead.readLine()); // line 5 - skip past the map letter key bufRead.readLine(); // line 6 - skip past the column number lines bufRead.readLine(); // line 7 - skip past the top row of underline characters bufRead.readLine(); this.planetMap = new PlanetMap(this.mapWidth, this.mapHeight, startPos, targetPos); double yCount = 0.0; while ((myLine = bufRead.readLine()) != null) { //might consider breaking based on map height check int yPos = (int) yCount; for (int i = 0; i < mapWidth; i++) { // grab the 2nd and 3rd character in a 3 character block based on i String tstr = myLine.substring(i * 3 + 1, i * 3 + 3); if (isInteger(tstr)) { String rName = "ROVER_" + tstr; roverLocations.putRover(RoverName.getEnum(rName), new Coord(i, yPos)); } else if (tstr.startsWith("__") || tstr.startsWith(" ")) { // do nothing } else { String posOne = tstr.substring(0, 1); if (!posOne.equals("_")) { planetMap.setTile(new MapTile(posOne), i, yPos); } else { planetMap.setTile(new MapTile("N"), i, yPos); } String posTwo = tstr.substring(1, 2); if (!posTwo.equals("_")) { scienceLocations.putScience(new Coord(i, yPos), Science.getEnum(posTwo)); } else { // do nothing } } } yCount += 0.5; } } public void printToDisplayTextFile() { String printMapString = makeInitString(); System.out.println("MapInit: " + printMapString); } public void saveToDisplayTextFile(String fileName) throws IOException { String printMapString = makeInitString(); try { File file = new File(fileName); FileWriter fileWriter = new FileWriter(file); fileWriter.write(printMapString); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } } public String makeInitString(){ StringBuilder printMap = new StringBuilder(); printMap.append(this.mapName + "\n"); printMap.append(this.planetMap.getWidth() + " " + this.planetMap.getHeight() + " Map_Width_Height\n"); printMap.append(planetMap.getStartPosition().xpos + " " + planetMap.getStartPosition().ypos + " StartPosition(x,y)\n"); printMap.append(planetMap.getTargetPosition().xpos + " " + planetMap.getTargetPosition().ypos + " TargetPosition(x,y)\n"); printMap.append("KEY:<Terrain> R = Rock; G = Gravel; S = Sand; X = abyss; <Science> Y = Radioactive; C = Crystal; M = Mineral; O = Organic; <Rover> ##\n"); // print column numbers printMap.append(" "); // shift right one space for (int i = 0; i < mapWidth; i++) { printMap.append(i + " "); // set spacing on number of digits in column number if(i < 10){ printMap.append(" "); } } printMap.append("\n"); // draw top row of lines int rowCount = 0; for (int h = 0; h < mapWidth; h++) { printMap.append(" __"); } printMap.append("\n"); for (int j = 0; j < mapHeight; j++) { for (int i = 0; i < mapWidth; i++) { // check for rover if (roverLocations.containsCoord(new Coord(i, j))) { String rNum = roverLocations.getName(new Coord(i, j)).toString(); printMap.append("|" + rNum.substring(6)); } else { printMap.append("| "); } } printMap.append("| " + rowCount++ + "\n"); // Print row numbers at end of row for (int k = 0; k < mapWidth; k++) { Coord tcor = new Coord(k, j); if (planetMap.getTile(tcor).getTerrain() != Terrain.SOIL) { printMap.append("|"); printMap.append(planetMap.getTile(tcor).getTerrain().getTerString()); if (scienceLocations.checkLocation(tcor)) { printMap.append(scienceLocations.scanLocation(tcor).getSciString()); } else { printMap.append("_"); } } else if (planetMap.getTile(tcor).getTerrain() == Terrain.SOIL) { printMap.append("|_"); if (scienceLocations.checkLocation(tcor)) { printMap.append(scienceLocations.scanLocation(tcor).getSciString()); } else { printMap.append("_"); } } else { printMap.append("|__"); } } printMap.append("|\n"); } String printMapString = printMap.toString(); return printMapString; } public static Coord extractCoord(String inputString) { if (inputString.lastIndexOf(" ") != -1) { String xPosStr = inputString.substring(0, inputString.indexOf(" ")); String yPosStr = inputString.substring(inputString.indexOf(" ") +1, inputString.lastIndexOf(" ")); return new Coord(Integer.parseInt(xPosStr), Integer.parseInt(yPosStr)); } return null; } // placeholder hack code till something better is inserted public static boolean isInteger(String s) { try { Integer.parseInt(s); } catch (NumberFormatException e) { return false; } catch (NullPointerException e) { return false; } // only got here if we didn't return false return true; } /* * These are only used for testing and development */ public void loadExampleTest() { // for testing purposes this.mapWidth = 30; this.mapHeight = 30; this.planetMap = new PlanetMap(mapWidth, mapHeight); this.planetMap.loadExampleTestPlanetMapTerrain(); this.roverLocations = new RoverLocations(); this.roverLocations.loadExampleTestRoverLocations(); this.scienceLocations = new ScienceLocations(); this.scienceLocations.loadExampleTestScienceLocations(); this.mapName = ""; } public void loadSmallExampleTest() { // for testing purposes this.mapWidth = 5; this.mapHeight = 5; this.planetMap = new PlanetMap(mapWidth, mapHeight); this.planetMap.loadSmallExampleTestPlanetMapTerrain(); this.roverLocations = new RoverLocations(); this.roverLocations.loadSmallExampleTestRoverLocations(); this.scienceLocations = new ScienceLocations(); this.scienceLocations.loadSmallExampleTestScienceLocations(); this.mapName = ""; } }
f2341b4c9fdfa6b140fd0dca586109a7ffa0f01e
969844c3119e6fa8a19e4db533bb1ef3dc97a3dd
/src/main/java/HouseRobberII.java
715d8fc115f028df0a9e60198d07f9c4634da6a6
[]
no_license
israkul9/LeetCode
2f52796133bec9f897aa4fef0a20edc1a9f77799
b9699f5bb8f6b248b788911e4cdd378c6a9aceb2
refs/heads/master
2023-01-31T05:33:45.439042
2020-12-07T18:34:54
2020-12-07T18:34:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,042
java
import common.LeetCode; /** * @author RakhmedovRS * @created 10/14/2020 */ @LeetCode(id = 213, name = "House Robber II", url = "https://leetcode.com/problems/house-robber-ii/") public class HouseRobberII { public int rob(int[] nums) { int len = nums.length; if (len == 0) { return 0; } else if (len == 1) { return nums[0]; } else if (len == 2) { return Math.max(nums[0], nums[1]); } else if (len == 3) { return Math.max(nums[0], Math.max(nums[1], nums[2])); } else { int[] skip = new int[len]; int[] take = new int[len]; take[0] = nums[0]; for (int i = 1; i < len - 1; i++) { take[i] = skip[i - 1] + nums[i]; skip[i] = Math.max(skip[i - 1], take[i - 1]); } int max = Math.max(take[len - 2], skip[len - 2]); skip[1] = 0; take[1] = nums[1]; for (int i = 2; i < len; i++) { take[i] = skip[i - 1] + nums[i]; skip[i] = Math.max(skip[i - 1], take[i - 1]); } max = Math.max(max, Math.max(take[len - 1], skip[len - 1])); return max; } } }
2ba2c713764604c5a43e48af58017d493116c58d
4ed25daac502f6aa2901cd0d83b9610e4e3764b8
/src/test/java/ch/alpine/owl/bot/rn/R1IntegratorTest.java
a536d028ccdf5abd95159728fdcfa9715350829d
[]
no_license
datahaki/owl
d84a9e667b306013b9f3c320f61c767df60f2ce5
7b46b080e0dd55ee578af413461f9d6c34ff1de6
refs/heads/master
2023-08-17T10:42:42.790051
2023-08-04T16:17:13
2023-08-04T16:17:13
342,946,447
2
0
null
2022-06-19T11:08:59
2021-02-27T19:59:43
Java
UTF-8
Java
false
false
1,030
java
// code by jph package ch.alpine.owl.bot.rn; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import ch.alpine.owl.math.flow.Integrator; import ch.alpine.owl.math.model.SingleIntegratorStateSpaceModel; import ch.alpine.tensor.RationalScalar; import ch.alpine.tensor.Tensor; import ch.alpine.tensor.Tensors; import ch.alpine.tensor.chq.ExactTensorQ; import ch.alpine.tensor.qty.Quantity; class R1IntegratorTest { @Test void testSimple() { Tensor xn = R1Integrator.direct(Tensors.fromString("{3[m], 1[m*s^-1]}"), Quantity.of(2, "m*s^-2"), Quantity.of(10, "s")); assertEquals(xn, Tensors.fromString("{113[m], 21[m*s^-1]}")); } @Test void testIntegrator() { Integrator integrator = R1Integrator.INSTANCE; Tensor tensor = integrator.step( // SingleIntegratorStateSpaceModel.INSTANCE, Tensors.vector(10, 2), Tensors.vector(1), RationalScalar.HALF); assertEquals(tensor, Tensors.fromString("{89/8, 5/2}")); ExactTensorQ.require(tensor); } }
a7f3b973ba07dd7f4a214637fd6dab51b32464a0
8a4f125214a167d50488eaf6fd62918813460f6f
/src/gui/LogInFrame.java
cd73d6101b9ebeec0d25a583876738dbe8993918
[]
no_license
FrederikGP/ChatClient
da1e8dcad853f12411ee566deedaddf3b8d249d2
d8592aeb5a46b5f3ebebd200e91637eff66ac5ce
refs/heads/master
2021-01-17T17:33:31.050305
2016-10-09T15:32:34
2016-10-09T15:32:34
70,412,142
0
0
null
null
null
null
UTF-8
Java
false
false
5,722
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 gui; /** * * @author Frederik */ public class LogInFrame extends javax.swing.JFrame { private boolean windowCloser; /** * Creates new form LogInFrame */ public LogInFrame() { initComponents(); this.windowCloser = true; this.label1.setText("Please type in a username below."); this.textField1.setText(""); this.jButton1.setText("Submit"); } public void setWindowCloser(boolean b){this.windowCloser = b;} public boolean getWindowCloser(){return this.windowCloser;} /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { textField1 = new java.awt.TextField(); label1 = new java.awt.Label(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); textField1.setText("textField1"); label1.setText("label1"); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(53, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1) .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(47, 47, 47)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(57, 57, 57) .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(65, 65, 65) .addComponent(jButton1) .addContainerGap(103, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed setWindowCloser(false); ClientFrame frame = new ClientFrame(); frame.setLocation(650, 300); frame.setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(LogInFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(LogInFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(LogInFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(LogInFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new LogInFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private java.awt.Label label1; private java.awt.TextField textField1; // End of variables declaration//GEN-END:variables }
43e4af09041e073fbdb9d1b0ddf7590d22a64269
18c9a80a83a96a453f45f18c580684f2b6af7679
/src/tramcity/server/connection/JDBCConnectionPool.java
c2143b400537f8dd4c2a6512ce0bbf7bbd7ea0e3
[]
no_license
hatran1995/tramcity
8505b2566a871d90af12b8ed06f3ad16fe2fdcfe
c315ef7fc94588e0dfaf4a292f123f70e1e6f90b
refs/heads/master
2023-01-25T01:28:12.122482
2020-12-06T19:59:53
2020-12-06T19:59:53
302,651,483
0
0
null
null
null
null
UTF-8
Java
false
false
4,084
java
package tramcity.server.connection; import java.sql.*; import java.util.ArrayList; public class JDBCConnectionPool { public static int countConnectionsUsing = 0; public ArrayList<Connection> ConnectionsReadyToUse = new ArrayList<Connection>(); private static String CONNECT_LINK = "jdbc:mysql://127.0.0.1:3306/puzzle_db?serverTimezone=UTC"; // private static String CONNECT_LINK = "jdbc:mysql://172.31.249.177:3306/puzzle_01?serverTimezone=UTC"; private static int MAX_CONNEXION=20; private static int MIN_CONNEXION=0; public JDBCConnectionPool() { // TODO Auto-generated constructor stub while( getSize()< MIN_CONNEXION) { initConnection(); System.out.println("Add Connection: ReadyToUse:"+ ConnectionsReadyToUse.size() + " - InUse:" + countConnectionsUsing); } } public JDBCConnectionPool(int minConnection, int maxConnection) { // TODO Auto-generated constructor stub MIN_CONNEXION = minConnection; MAX_CONNEXION = maxConnection; while( getSize()< MIN_CONNEXION) { initConnection(); System.out.println("Add Connection: ReadyToUse:"+ ConnectionsReadyToUse.size() + " - InUse:" + countConnectionsUsing); } } //return public synchronized Connection getConnection() throws InterruptedException { System.out.println("Start get connection!"); while (ConnectionsReadyToUse.isEmpty()) { // create new connection pool if(countConnectionsUsing < MAX_CONNEXION ) { initConnection(); System.out.println("Add Connection: ReadyToUse:"+ ConnectionsReadyToUse.size() + " - InUse:" + countConnectionsUsing); } else { // max //break; try { System.out.println("Veuillez patientez. Nombre excessif de connexions."); wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } Connection tempConnection = ConnectionsReadyToUse.get(0); ConnectionsReadyToUse.remove(0); countConnectionsUsing += 1; System.out.println("Use Connection: ReadyToUse:"+ ConnectionsReadyToUse.size() + " - InUse:" + countConnectionsUsing); return tempConnection; } public synchronized void returnConnection (Connection c) throws InterruptedException, SQLException { if (c.isClosed()) { System.out.println("Connection is Closed"); countConnectionsUsing = countConnectionsUsing>0?countConnectionsUsing-1:0; initConnection(); }else { ConnectionsReadyToUse.add(c); countConnectionsUsing = countConnectionsUsing>0?countConnectionsUsing-1:0; System.out.println("Return Connection: ReadyToUse:"+ ConnectionsReadyToUse.size() + " - InUse:" + countConnectionsUsing); notifyAll(); } } public void initConnection() { try{ if (getSize()<MAX_CONNEXION) { // Connection conn = DriverManager.getConnection(CONNECT_LINK, "root", "toto"); Connection conn = DriverManager.getConnection(CONNECT_LINK, "root", ""); if (conn != null) { System.out.println("Add new connection pool success!"); ConnectionsReadyToUse.add(conn); if(countConnectionsUsing > 0) notifyAll(); // return conn; } else { System.out.println("Failed to create new connection pool!"); // return null; } }else { System.out.println("Limited connection!"); // return null; } } catch (SQLException e) { System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); // return null; } catch (Exception e) { e.printStackTrace(); // return null; } } public void closeAllConnection() throws SQLException { for(Connection c: ConnectionsReadyToUse) { c.close(); } ConnectionsReadyToUse.clear(); } public int getSize() { // TODO Auto-generated method stub return ConnectionsReadyToUse.size()+countConnectionsUsing; } }
37e45ac1534496a622aaec3ef9c32b81b310184d
e54d50fb2bccf56163fef18e15cbb5fffc182f66
/database/src/main/java/by/forecasts/dto/TournamentShortViewDto.java
032ee1b152c190524b864aff355ea1a4dd3b5971
[]
no_license
rizhnitsyn/forecasts
6284f51094fa45417da35723c9b2d65905ff61b0
b3bc6efd5c6852ba3c5b988826bc4e748c94b0a8
refs/heads/master
2021-05-10T22:09:06.831952
2018-03-22T14:45:43
2018-03-22T14:45:43
118,248,268
0
0
null
2018-03-22T14:45:47
2018-01-20T14:06:52
Java
UTF-8
Java
false
false
1,789
java
package by.forecasts.dto; import by.forecasts.entities.Team; import by.forecasts.entities.Tournament; import by.forecasts.entities.TournamentState; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotNull; import java.time.LocalDate; @Getter @Setter @AllArgsConstructor @NoArgsConstructor public class TournamentShortViewDto { private Long id; @NotEmpty(message = "errors.field.empty") private String name; @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate startDate; @NotNull(message = "errors.field.empty") private Team team; private TournamentState state; private Boolean registered; private Long matchesCount; public TournamentShortViewDto(Long id, String name, LocalDate startDate) { this.id = id; this.name = name; this.startDate = startDate; } public TournamentShortViewDto(Long id, String name, LocalDate startDate, Team team, TournamentState state, Boolean registered) { this.id = id; this.name = name; this.startDate = startDate; this.team = team; this.state = state; this.registered = registered; } public TournamentShortViewDto(Tournament tournament, Boolean registered) { this.id = tournament.getId(); this.name = tournament.getName(); this.startDate = tournament.getStartDate(); this.team = tournament.getOrganizer(); this.state = tournament.getTournamentState(); this.registered = registered; } }
44da4624ae52a359f1da761edc0ea7b4968c8adf
5fe7e088cd299f9f1498a26d97a9ef5c7fe53469
/src/HelloWorld.java
a2e6b77281ac5a3fa0e76016848033325dddc621
[]
no_license
matthew-r-walker/codeup-java-exercises
e34e624fa8fd802d0dc23991bb43f868b417cd9d
08f61ba8346e1e4a661f31340d330ec3852eea98
refs/heads/main
2023-06-08T07:36:36.690879
2021-07-03T03:21:21
2021-07-03T03:21:21
369,643,662
0
0
null
null
null
null
UTF-8
Java
false
false
1,620
java
public class HelloWorld { public static void main(String[] agrs) { System.out.print("Hello"); System.out.print(", World!"); int myFavoriteNumber = 4; System.out.println(myFavoriteNumber); String myString = "I'm a string!"; System.out.println(myString); float myNumber = 3.14F; System.out.println(myNumber); // This will output 5 then 6 because x is incremented after it is printed // int x = 5; // System.out.println(x++); // System.out.println(x); // This will output 6 then 6 because x is incremented before it is printed int x = 5; System.out.println(++x); System.out.println(x); // this will not work because class is a reserved word // int class = 5; String theNumberThree = "three"; Object o = theNumberThree; System.out.println(o); // cannot cast a string class to a int class // int three = (int) o; // cannot convert string to int // int three = (int) "three"; x = 4; x += 5; x = 3; int y = 4; y *= x; x = 10; y = 2; x /= y; y -= x; int num300 = 33000; short num = 40; byte bigByte = Byte.MAX_VALUE; System.out.println(bigByte); ++bigByte; System.out.println(++bigByte); num = (short) num300; System.out.println(num); int medInt = 50000; num = (short) medInt; int bigInt = Integer.MAX_VALUE; System.out.println(++bigInt); } }
cbb52856c852a3a2d30ee7b827da2507f003e548
557df904bb103fbf8d97452eec784fd2cae8e5ce
/PolygonUtils.java
84403fd4c26c3ff44bd926c72a3b719591e34429
[]
no_license
skordemir/shortestpath
396d2f25cc3a2f56969f0b8f57c1e9759556bcc7
a777e4a0d8c6aebcce0dab591227641f6aeabd80
refs/heads/master
2020-07-02T04:25:11.527466
2019-09-01T17:24:06
2019-09-01T17:24:06
201,415,293
0
0
null
null
null
null
UTF-8
Java
false
false
5,734
java
package com.havelsan.visgraph.sampler; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author skordemir * */ public class PolygonUtils { private static final int polygonMaxVerts = 4; private static final int polygonMinVerts = 3; /** * will create a polygon in the given coordinates * * @param numPoints * @param boundX * @param boundY * @return */ public static XPolygon createPolygon(int numPoints, int boundX, int boundY) { Point[] points = new Point[numPoints]; for (int i = 0; i < numPoints; i++) { Point p = new Point(Math.random() * boundX, Math.random() * boundY); points[i] = p; } XPolygon path = new XPolygon(); for (int i = 0; i < points.length; i++) { path.add(points[i]); } return path; } /** * will assign vertex counts to polygons * * @param numPolygons * @param vertsPerPoly * @param vertCount */ public static void assingRandomVertx(int numPolygons, Integer[] vertsPerPoly ) { for (int i = 0; i < numPolygons; i++) { int numVerts = RandomUtil.getRandomInterval(polygonMinVerts, polygonMaxVerts); vertsPerPoly[i] = numVerts; } } public static void craeteVisibilityGraphs(List<Point[]> segments, List<Point> vertices) { // loop all lines for (int i = 0; i < vertices.size(); i++) { for (int j = i + 1; j < vertices.size(); j++) { Point a = vertices.get(i); Point b = vertices.get(j); boolean intersect = checkTwoPointsIntersect(segments, a, b); if (!intersect) { a.addVisiblePoint(b); b.addVisiblePoint(a); } } } } private static boolean checkTwoPointsIntersect(List<Point[]> segments, Point a, Point b) { boolean intersect = false; for (Point[] pointArray : segments) { Point c = pointArray[0]; Point d = pointArray[1]; intersect = doIntersect(a, b, c, d); if(a.equals(c) || a.equals(d) || b.equals(d) || b.equals(c)) intersect=false; if (intersect) return true; } return false; } public static boolean polygonIntersect(List<Point[]> realSegments, XPolygon p) { List<Point[]> segments = new ArrayList<>(); createSegments(segments, p); for (Point[] pointArray : segments) { Point a = pointArray[0]; Point b = pointArray[1]; boolean intersect = checkTwoPointsIntersect(realSegments, a, b); if (intersect) return intersect; } return false; } /** * will find all the segments of points * * @param segments * @param polygon * @param vertIndex * @return */ public static void createSegments(List<Point[]> segments, XPolygon polygon) { List<Point> points = polygon.getPoints(); for (int i = 0; i < points.size(); i++) { int k = i + 1 == points.size() ? 0 : i + 1; int a = i; int b = k; Point[] pointArray = new Point[2]; pointArray[0] = points.get(a); pointArray[1] = points.get(b); segments.add(pointArray); } } // Given three colinear points p, q, r, the function checks if // point q lies on line segment 'pr' private static boolean onSegment(Point p, Point q, Point r) { if (q.getX() <= Math.max(p.getX(), r.getX()) && q.getX() >= Math.min(p.getX(), r.getX()) && q.getY() <= Math.max(p.getY(), r.getY()) && q.getY() >= Math.min(p.getY(), r.getY())) return true; return false; } // To find orientation of ordered triplet (p, q, r). // The function returns following values // 0 --> p, q and r are colinear // 1 --> Clockwise // 2 --> Counterclockwise private static int orientation(Point p, Point q, Point r) { // See https://www.geeksforgeeks.org/orientation-3-ordered-points/ // for details of below formula. int val = (int) ((q.getY() - p.getY()) * (r.getX() - q.getX()) - (q.getX() - p.getX()) * (r.getY() - q.getY())); if (val == 0) return 0; // colinear return (val > 0) ? 1 : 2; // clock or counterclock wise } // The main function that returns true if line segment 'p1q1' // and 'p2q2' intersect. private static boolean doIntersect(Point p1, Point q1, Point p2, Point q2) { // Find the four orientations needed for general and // special cases int o1 = orientation(p1, q1, p2); int o2 = orientation(p1, q1, q2); int o3 = orientation(p2, q2, p1); int o4 = orientation(p2, q2, q1); // General case if (o1 != o2 && o3 != o4) return true; // Special Cases // p1, q1 and p2 are colinear and p2 lies on segment p1q1 if (o1 == 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and q2 are colinear and q2 lies on segment p1q1 if (o2 == 0 && onSegment(p1, q2, q1)) return true; // p2, q2 and p1 are colinear and p1 lies on segment p2q2 if (o3 == 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and q1 are colinear and q1 lies on segment p2q2 if (o4 == 0 && onSegment(p2, q1, q2)) return true; return false; // Doesn't fall in any of the above cases } public static void main(String[] args) { Point p1 = new Point(1, 1); Point q1 = new Point(3, 7); Point p2 = new Point(4, 2); Point q2 = new Point(10, 8); if (doIntersect(p1, q1, p2, q2)) System.out.println("Yes"); else System.out.println("No"); p1 = new Point(10, 1); q1 = new Point(0, 10); p2 = new Point(0, 0); q2 = new Point(10, 10); if (doIntersect(p1, q1, p2, q2)) System.out.println("Yes"); else System.out.println("No"); p1 = new Point(-5, -5); q1 = new Point(0, 0); p2 = new Point(1, 1); q2 = new Point(10, 10); ; if (doIntersect(p1, q1, p2, q2)) System.out.println("Yes"); else System.out.println("No"); } }
36a6de8b50eee575465e486b7c4929c66c0dfb78
df808d8f8e3ebe22bd3452aeb0aef81fc343b97c
/src/main/java/com/xkeam/database/util/LoggerUtil.java
992b552809aeb79fe23d1338a6a44f5e543dd070
[]
no_license
kyhoolee/XkeamDatabase
7626c4d0d4c3309b9d67c63a1f2f2b78a989bff3
35292f2091d9d11910ccfc450780da217e35d726
refs/heads/master
2021-01-10T07:56:55.342464
2015-11-14T07:08:16
2015-11-14T07:08:16
46,165,375
0
0
null
null
null
null
UTF-8
Java
false
false
5,728
java
package com.xkeam.database.util; import java.io.File; import java.util.Properties; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; public class LoggerUtil { private static final String folder_logs = "./logs"; // @SuppressWarnings("deprecation") // public static Logger getLogger(String loggerName) { // if (Logger.exists(loggerName) != null) { // return Logger.getLogger(loggerName); // } // // try { // // Properties properties = new Properties(); // properties.put("log4j.logger." + loggerName, "INFO, " + loggerName); // properties.put("log4j.additivity." + loggerName, "false"); // properties.put("log4j.appender." + loggerName, // "org.apache.log4j.FileAppender \n"); // properties.put("log4j.appender." + loggerName + ".File", // folder_logs + "/" + loggerName + ".txt"); // // properties.put("log4j.appender." + loggerName + ".DatePattern", // // "'.'yyyy-MM-dd"); // // properties.put("log4j.appender." + loggerName + ".ImmediateFlush", // "true"); // // properties.put("log4j.appender." + loggerName + ".layout", // "org.apache.log4j.PatternLayout"); // properties.put("log4j.appender." + loggerName // + ".layout.ConversionPattern", // "%d{dd MMM yyyy HH:mm:ss.SSS} [%t] %-5p %c - \n %m%n \n"); // // PropertyConfigurator.configure(properties); // return LogManager.getLogger(loggerName); // } catch (Exception e) { // return Logger.getRootLogger(); // } // // } // @SuppressWarnings("deprecation") public static Logger getLogger(String loggerName, String outputFile) { if (Logger.exists(loggerName) != null) { return Logger.getLogger(loggerName); } try { String folder = folder_logs + "/" + outputFile; folder = folder.replaceAll("[^/]+$", ""); folder = folder.substring(0, folder.length() - 1); File file = new File(folder); if (!file.exists()) file.mkdir(); Properties properties = new Properties(); properties.put("log4j.logger." + loggerName, "INFO, " + loggerName); properties.put("log4j.additivity." + loggerName, "false"); properties.put("log4j.appender." + loggerName, "org.apache.log4j.FileAppender"); properties.put("log4j.appender." + loggerName + ".File", folder_logs + "/" + outputFile); // properties.put("log4j.appender." + loggerName + ".DatePattern", // "'.'yyyy-MM-dd"); properties.put("log4j.appender." + loggerName + ".ImmediateFlush", "true"); properties.put("log4j.appender." + loggerName + ".layout", "org.apache.log4j.PatternLayout"); properties.put("log4j.appender." + loggerName + ".layout.ConversionPattern", "%d{dd MMM yyyy HH:mm:ss.SSS} [%t] %-5p %c - \n %m%n \n"); PropertyConfigurator.configure(properties); return LogManager.getLogger(loggerName); } catch (Exception e) { return Logger.getRootLogger(); } } // // @SuppressWarnings("deprecation") // public static Logger getDailyLogger(String loggerName, String outputFile) { // if (Logger.exists(loggerName) != null) { // return Logger.getLogger(loggerName); // } // try { // // String folder = folder_logs + "/" + outputFile; // folder = folder.replaceAll("[^/]+$", ""); // folder = folder.substring(0, folder.length() - 1); // File file = new File(folder); // if (!file.exists()) // file.mkdir(); // // Properties properties = new Properties(); // properties.put("log4j.logger." + loggerName, "INFO, " + loggerName); // properties.put("log4j.additivity." + loggerName, "false"); // properties.put("log4j.appender." + loggerName, // "org.apache.log4j.DailyRollingFileAppender"); // properties.put("log4j.appender." + loggerName + ".File", // folder_logs + "/" + outputFile); // properties.put("log4j.appender." + loggerName + ".DatePattern", // "'.'yyyy-MM-dd"); // properties.put("log4j.appender." + loggerName + ".ImmediateFlush", // "true"); // properties.put("log4j.appender." + loggerName + ".layout", // "org.apache.log4j.PatternLayout"); // properties.put("log4j.appender." + loggerName // + ".layout.ConversionPattern", // "%d{dd MMM yyyy HH:mm:ss.SSS} [%t] %-5p %c - \n %m%n \n"); // // PropertyConfigurator.configure(properties); // return LogManager.getLogger(loggerName); // } catch (Exception e) { // return Logger.getRootLogger(); // } // } @SuppressWarnings("deprecation") public static Logger getDailyLogger(String loggerName) { if (Logger.exists(loggerName) != null) { return Logger.getLogger(loggerName); } try { Properties properties = new Properties(); properties.put("log4j.logger." + loggerName, "INFO, " + loggerName); properties.put("log4j.additivity." + loggerName, "false"); properties.put("log4j.appender." + loggerName, "org.apache.log4j.DailyRollingFileAppender \n"); properties.put("log4j.appender." + loggerName + ".File", folder_logs + "/" + loggerName + ".txt"); properties.put("log4j.appender." + loggerName + ".DatePattern", "'.'yyyy-MM-dd"); properties.put("log4j.appender." + loggerName + ".ImmediateFlush", "true"); properties.put("log4j.appender." + loggerName + ".layout", "org.apache.log4j.PatternLayout"); properties.put("log4j.appender." + loggerName + ".layout.ConversionPattern", "%d{dd MMM yyyy HH:mm:ss.SSS} [%t] %-5p %c - \n %m%n \n"); PropertyConfigurator.configure(properties); return LogManager.getLogger(loggerName); } catch (Exception e) { return Logger.getRootLogger(); } } public static void main(String[] args) { // LoggerUtil loggerUtil = new LoggerUtil(); // Logger.getLogger("match_1").info("start"); // loggerUtil.getDailyLogger("C1").info("start"); } }
118aea08c813afd53859b713dcd6c7f30fca91ef
854049138a347ddc651f2e106712869ae0145ccb
/src/main/java/com/utils/HibernateSessionFactory.java
c5aec08d42a5f27c96160a6da9045a807ee933b6
[]
no_license
alexandr-ryabykh/SpringTest
5aea9ddd2224e5831dd02ac8bd68b871fbc9a207
35af5cb7966268b8cc360c5af578056bc4eb9c80
refs/heads/master
2021-01-15T15:32:03.857149
2016-09-04T13:26:40
2016-09-04T13:26:40
59,738,537
0
1
null
2016-06-17T07:16:44
2016-05-26T09:39:34
Java
UTF-8
Java
false
false
798
java
package com.utils; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateSessionFactory { private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { return new Configuration().configure("/com/utils/hibernate.cfg.xml").buildSessionFactory(); } catch (Exception e) { System.err.println("Initial SessionFactory creation failed: " + e); throw new ExceptionInInitializerError(e); } } public static SessionFactory getSessionFactory() { return sessionFactory; } public static void shutdown() { // Close caches and connection pools getSessionFactory().close(); } }
e22efeea02ec588d6c6ce686139b5293fd12f689
772ca5654e2d4258d73a78dcf445e8268978f226
/src/test/java/Example.java
88b247dd8728f55b304e976e2b70bdaa544d3c22
[]
no_license
TheTrueRandom/JavaChessUCI
a5788937b3248ecc35a8b7af5b287fb9a8fd7b9b
cc27c3e839c1d83c895afd182490ad812a698598
refs/heads/master
2020-03-28T20:00:38.143055
2018-09-27T20:07:01
2018-09-27T20:07:01
149,029,899
5
2
null
2018-09-27T19:40:35
2018-09-16T19:44:56
Java
UTF-8
Java
false
false
1,355
java
import output.CalculationResult; public class Example { public static void main(String[] args) throws Exception { UCIEngine engine = new UCIEngine("/usr/bin/stockfish"); engine.start(); System.out.println("Name: " + engine.getName()); System.out.println("Author: " + engine.getAuthor()); engine.getOptions().entrySet().forEach(System.out::println); engine.setOption("Threads", 8); engine.setOption("MultiPV", 2); engine.addInfoListener((uciEngine, info) -> { System.out.println(uciEngine.getName() + " information during calculation: " + info); }); engine.uciNewGame(); engine.isReady(); engine.startPos("e2e4", "e7e5"); CalculationResult calculationResult = engine.goMovetime(100); System.out.println("Bestmove: " + calculationResult.getBestmove()); System.out.println("Ponder: " + calculationResult.getPonder()); System.out.println("Bestmove multipv 1: " + calculationResult.getBestmovePv(1)); System.out.println("Bestmove multipv 2: " + calculationResult.getBestmovePv(2)); System.out.println("Score Information for multipv 1: " + calculationResult.getLastScoreInfo(1)); System.out.println("Score Information for multipv 2: " + calculationResult.getLastScoreInfo(2)); } }
5d2fce8c6f4402896d11d355eece723663528f0d
f61fd5d88f86db005697a11bebea806863a21139
/src/main/java/com/gvillena/MainForm.java
549219055920cd6b70ae08f702ce3c10c2467d1d
[]
no_license
Chris947/ExamenFinal
6b3fa1a9af5e1bb07ec94cf764433e5375373205
58732257db4a3e60995b01d702a986bebf95fb97
refs/heads/master
2021-05-06T07:05:26.304712
2017-12-12T02:33:35
2017-12-12T02:33:35
113,933,667
0
0
null
null
null
null
UTF-8
Java
false
false
34,095
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.gvillena; import com.google.gson.Gson; import com.google.gson.stream.JsonWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractListModel; import javax.swing.DefaultListModel; import javax.swing.ListModel; import javax.swing.SpinnerListModel; /** * * @author alumno */ public class MainForm extends javax.swing.JFrame { ArrayList<TelefonoMovil> ListaTelefonosMoviles; ArrayList<PlanPostPago> ListaPlanesPostPago; private void test() { // Lista de Planes Post Pago ArrayList<PlanPostPago> listaPlanes = new ArrayList<PlanPostPago>(); // Declaracion PlanPostPago plan01; PlanPostPago plan02; PlanPostPago plan03; // Inicializacion plan01 = new PlanPostPago(); plan02 = new PlanPostPago(); plan03 = new PlanPostPago(); // CLARO MAX 99 plan01.setCodigoPlan("CMX99"); plan01.setNombrePlan("Claro MAX 99"); plan01.setInternet(500); plan01.setMinutos(1000); plan01.setRpc(10000); plan01.setSms(500); // CLARO MAX 149 plan02.setCodigoPlan("CMX149"); plan02.setNombrePlan("Claro MAX 149"); plan02.setInternet(1000); plan02.setMinutos(3000); plan02.setRpcIlimitado(true); plan02.setSms(1000); // CLARO MAX 189 plan03.setCodigoPlan("CMX189"); plan03.setNombrePlan("Claro MAX 189"); plan03.setInternet(3000); plan03.setMinutosIlimitado(true); plan03.setRpcIlimitado(true); plan03.setSmsIlimitado(true); listaPlanes.add(plan01); listaPlanes.add(plan02); listaPlanes.add(plan03); for (PlanPostPago listaPlan : listaPlanes) { System.out.println("NOMBRE PLAN: " + listaPlan.getNombrePlan()); } Gson gson = new Gson(); String json = gson.toJson(listaPlanes); System.out.println(json); JsonWriter writer; try { writer = new JsonWriter(new FileWriter("D:\\jsonPlanes.txt")); writer.jsonValue(json); writer.flush(); } catch (IOException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } } /** * Creates new form MainForm */ public MainForm() { initComponents(); // Inicializando ListaTelefonosMoviles = new ArrayList<TelefonoMovil>(); ListaPlanesPostPago = new ArrayList<PlanPostPago>(); String jsonClaro = ""; String jsonPlanes = ""; Scanner scannerClaro; Scanner scannerPlanes; // 2 try { scannerClaro = new Scanner(new FileReader("D:\\jsonClaro.txt")); scannerPlanes = new Scanner(new FileReader("D:\\jsonPlanes.txt")); StringBuilder sbClaro = new StringBuilder(); while (scannerClaro.hasNext()) { sbClaro.append(scannerClaro.next()); } StringBuilder sbPlanes = new StringBuilder(); while (scannerPlanes.hasNext()) { sbPlanes.append(scannerPlanes.next()); } jsonClaro = sbClaro.toString(); jsonPlanes = sbPlanes.toString(); } catch (FileNotFoundException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex); } // Gson gson = new Gson(); // TelefonoMovil[] listaClaro = null; PlanPostPago[] listaPlanes = null; // listaClaro = gson.fromJson(jsonClaro, TelefonoMovil[].class); listaPlanes = gson.fromJson(jsonPlanes, PlanPostPago[].class); // for (int i = 0; i < listaClaro.length; i++) { ListaTelefonosMoviles.add(listaClaro[i]); } // for (int i = 0; i < listaPlanes.length; i++) { ListaPlanesPostPago.add(listaPlanes[i]); } // for (PlanPostPago listaPlan : ListaPlanesPostPago) { System.out.println(""); System.out.println("CODIGO : " + listaPlan.getCodigoPlan()); System.out.println("NOMBRE : " + listaPlan.getNombrePlan()); System.out.println("INTERNET : " + listaPlan.getInternet()); System.out.println("MINUTOS : " + listaPlan.getMinutos()); System.out.println("RPC : " + listaPlan.getRpc()); System.out.println("SMS : " + listaPlan.getSms()); System.out.println(""); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; buttonGroup1 = new javax.swing.ButtonGroup(); pblEquiposMovilles = new javax.swing.JScrollPane(); lstEquiposMoviles = new javax.swing.JList(); lblTEquiposMoviles = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); spPlanesPostpago = new javax.swing.JSpinner(); lblDescripcion = new javax.swing.JLabel(); plCaracteristicas = new javax.swing.JPanel(); plPantalla = new javax.swing.JPanel(); lblPantallaImg = new javax.swing.JLabel(); lblPantalla = new javax.swing.JLabel(); lblTPantalla = new javax.swing.JLabel(); plCamara = new javax.swing.JPanel(); lblCamara = new javax.swing.JLabel(); lblTCamara = new javax.swing.JLabel(); lblCamaraImg = new javax.swing.JLabel(); plProcesador = new javax.swing.JPanel(); lblProcesador = new javax.swing.JLabel(); lblTProcesador = new javax.swing.JLabel(); lblProcesadorImg = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); plBeneficiosPlan = new javax.swing.JPanel(); plMinutos = new javax.swing.JPanel(); lblMinutosT = new javax.swing.JLabel(); lblMinutos = new javax.swing.JLabel(); plInternet = new javax.swing.JPanel(); lblInternetT = new javax.swing.JLabel(); lblInternet = new javax.swing.JLabel(); plRPC = new javax.swing.JPanel(); lblRPCT = new javax.swing.JLabel(); lblRPC = new javax.swing.JLabel(); plSMS = new javax.swing.JPanel(); lblSMST = new javax.swing.JLabel(); lblSMS = new javax.swing.JLabel(); jBComprar = new javax.swing.JButton(); lblTPrecio = new javax.swing.JLabel(); lblPrecio = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); lstEquiposMoviles.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); lstEquiposMoviles.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { lstEquiposMovilesValueChanged(evt); } }); pblEquiposMovilles.setViewportView(lstEquiposMoviles); lblTEquiposMoviles.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N lblTEquiposMoviles.setText("EQUIPOS DISPONIBLES"); jLabel1.setFont(new java.awt.Font("Dialog", 1, 40)); // NOI18N jLabel1.setText("TIENDA CLARO"); spPlanesPostpago.setFont(new java.awt.Font("Dialog", 1, 30)); // NOI18N spPlanesPostpago.setModel(new javax.swing.SpinnerListModel(new String[] {"Claro MAX 99", "Claro MAX 149", "Claro MAX 189"})); spPlanesPostpago.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spPlanesPostpagoStateChanged(evt); } }); lblDescripcion.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N lblDescripcion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblDescripcion.setText("TELEFONO MOVIL"); plPantalla.setPreferredSize(new java.awt.Dimension(250, 159)); plPantalla.setLayout(new java.awt.GridBagLayout()); lblPantallaImg.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblPantallaImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/icon-pantalla.png"))); // NOI18N lblPantallaImg.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3); plPantalla.add(lblPantallaImg, gridBagConstraints); lblPantalla.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N lblPantalla.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblPantalla.setText("-"); lblPantalla.setFocusable(false); lblPantalla.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; plPantalla.add(lblPantalla, gridBagConstraints); lblTPantalla.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblTPantalla.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); lblTPantalla.setText("PANTALLA"); lblTPantalla.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); lblTPantalla.setVerticalTextPosition(javax.swing.SwingConstants.TOP); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; plPantalla.add(lblTPantalla, gridBagConstraints); plCaracteristicas.add(plPantalla); plCamara.setPreferredSize(new java.awt.Dimension(250, 159)); plCamara.setLayout(new java.awt.GridBagLayout()); lblCamara.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N lblCamara.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblCamara.setText("-"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 6); plCamara.add(lblCamara, gridBagConstraints); lblTCamara.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblTCamara.setText("CAMARA"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; plCamara.add(lblTCamara, gridBagConstraints); lblCamaraImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/icon-camara.png"))); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 12); plCamara.add(lblCamaraImg, gridBagConstraints); plCaracteristicas.add(plCamara); plProcesador.setPreferredSize(new java.awt.Dimension(250, 159)); plProcesador.setLayout(new java.awt.GridBagLayout()); lblProcesador.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N lblProcesador.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblProcesador.setText("-"); lblProcesador.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); plProcesador.add(lblProcesador, gridBagConstraints); lblTProcesador.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblTProcesador.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblTProcesador.setText("PROCESADOR"); lblTProcesador.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); plProcesador.add(lblTProcesador, gridBagConstraints); lblProcesadorImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/icon-procesador.png"))); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); plProcesador.add(lblProcesadorImg, gridBagConstraints); plCaracteristicas.add(plProcesador); jLabel2.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N jLabel2.setText("¡Elige el mejor plan para ti!"); java.awt.GridBagLayout plBeneficiosPlanLayout = new java.awt.GridBagLayout(); plBeneficiosPlanLayout.columnWidths = new int[] {0, 4, 0}; plBeneficiosPlanLayout.rowHeights = new int[] {0, 4, 0}; plBeneficiosPlan.setLayout(plBeneficiosPlanLayout); plMinutos.setLayout(new java.awt.BorderLayout()); lblMinutosT.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblMinutosT.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMinutosT.setText("MINUTOS"); plMinutos.add(lblMinutosT, java.awt.BorderLayout.CENTER); lblMinutos.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N lblMinutos.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMinutos.setText("Ilimitado"); plMinutos.add(lblMinutos, java.awt.BorderLayout.PAGE_START); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(21, 29, 21, 29); plBeneficiosPlan.add(plMinutos, gridBagConstraints); plInternet.setLayout(new java.awt.BorderLayout()); lblInternetT.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblInternetT.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblInternetT.setText("INTERNET"); plInternet.add(lblInternetT, java.awt.BorderLayout.PAGE_END); lblInternet.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N lblInternet.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblInternet.setText("Ilimitado"); plInternet.add(lblInternet, java.awt.BorderLayout.PAGE_START); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(21, 29, 21, 29); plBeneficiosPlan.add(plInternet, gridBagConstraints); plRPC.setLayout(new java.awt.BorderLayout()); lblRPCT.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblRPCT.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblRPCT.setText("RPC"); plRPC.add(lblRPCT, java.awt.BorderLayout.CENTER); lblRPC.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N lblRPC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblRPC.setText("Ilimitado"); plRPC.add(lblRPC, java.awt.BorderLayout.PAGE_START); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.insets = new java.awt.Insets(21, 29, 21, 29); plBeneficiosPlan.add(plRPC, gridBagConstraints); plSMS.setLayout(new java.awt.BorderLayout()); lblSMST.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N lblSMST.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblSMST.setText("SMS"); plSMS.add(lblSMST, java.awt.BorderLayout.CENTER); lblSMS.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N lblSMS.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblSMS.setText("Ilimitado"); plSMS.add(lblSMS, java.awt.BorderLayout.PAGE_START); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.insets = new java.awt.Insets(21, 29, 21, 29); plBeneficiosPlan.add(plSMS, gridBagConstraints); jBComprar.setFont(new java.awt.Font("Berlin Sans FB", 1, 20)); // NOI18N jBComprar.setText("! COMPRAR !"); jBComprar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBComprarActionPerformed(evt); } }); lblTPrecio.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N lblTPrecio.setText("Precio: "); lblPrecio.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N lblPrecio.setText("S/. 2700"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(pblEquiposMovilles, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblTEquiposMoviles) .addComponent(jLabel1)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(plCaracteristicas, javax.swing.GroupLayout.PREFERRED_SIZE, 790, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGap(204, 204, 204) .addComponent(lblDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(174, 174, 174) .addComponent(jLabel2)) .addGroup(layout.createSequentialGroup() .addGap(53, 53, 53) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(lblTPrecio) .addGap(18, 18, 18) .addComponent(lblPrecio) .addGap(51, 51, 51) .addComponent(jBComprar) .addGap(85, 85, 85)) .addGroup(layout.createSequentialGroup() .addComponent(spPlanesPostpago, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30) .addComponent(plBeneficiosPlan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addContainerGap(36, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jLabel1) .addGap(30, 30, 30) .addComponent(lblTEquiposMoviles) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(pblEquiposMovilles, javax.swing.GroupLayout.PREFERRED_SIZE, 387, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(72, 72, 72) .addComponent(lblDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(plCaracteristicas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(46, 46, 46) .addComponent(jLabel2) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(plBeneficiosPlan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spPlanesPostpago, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblPrecio) .addComponent(lblTPrecio)) .addGap(64, 64, 64)) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jBComprar, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); pack(); }// </editor-fold>//GEN-END:initComponents private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened // DefaultListModel<String> listaEquiposClaroModel = new DefaultListModel<String>(); for (TelefonoMovil telefonoMovil : ListaTelefonosMoviles) { listaEquiposClaroModel.addElement(telefonoMovil.getDescripcion()); } lstEquiposMoviles.setModel(listaEquiposClaroModel); // ArrayList<String> listaPlanesString = new ArrayList<String>(); for (PlanPostPago planPostPago : ListaPlanesPostPago) { listaPlanesString.add(planPostPago.getNombrePlan()); } spPlanesPostpago.setModel(new SpinnerListModel(listaPlanesString)); }//GEN-LAST:event_formWindowOpened private void lstEquiposMovilesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstEquiposMovilesValueChanged if (!evt.getValueIsAdjusting()) { int indiceSeleccionado = lstEquiposMoviles.getSelectedIndex(); if (indiceSeleccionado != -1) { TelefonoMovil telMovSel = ListaTelefonosMoviles.get(indiceSeleccionado); String descripcion = telMovSel.getDescripcion(); String pantalla = telMovSel.getPantalla(); String camara = telMovSel.getCamara(); String procesador = telMovSel.getProcesador(); lblDescripcion.setText(descripcion); lblPantalla.setText(pantalla); lblCamara.setText(camara); lblProcesador.setText(procesador); } } // // if (!evt.getValueIsAdjusting()) { // if (btnClaro.isSelected()) { // switch (lstEquiposMoviles.getSelectedIndex()) { // case 0: // System.out.println("CLARO 0"); // lblPantalla.setText("4.3\""); // lblCamara.setText("6MP"); // lblProcesador.setText("1.3GHz"); // lblDescripcion.setText("Galaxy S7 (Claro)"); // break; // case 1: // System.out.println("CLARO 1"); // lblPantalla.setText("6.2\""); // lblCamara.setText("8MP"); // lblProcesador.setText("2.3GHz"); // lblDescripcion.setText("iPhone 7 (Claro)"); // break; // case 2: // System.out.println("CLARO 2"); // lblPantalla.setText("7.3\""); // lblCamara.setText("10MP"); // lblProcesador.setText("2.7GHz"); // lblDescripcion.setText("LG k8 (Claro)"); // break; // } // } // else if (btnMovistar.isSelected()) // { // switch (lstEquiposMoviles.getSelectedIndex()) { // case 0: // System.out.println("MOVISTAR 0"); // lblPantalla.setText("6.3\""); // lblCamara.setText("5MP"); // lblProcesador.setText("1.7GHz"); // lblDescripcion.setText("Galaxy S7 (Movistar)"); // break; // case 1: // System.out.println("MOVISTAR 1"); // lblPantalla.setText("4.3\""); // lblCamara.setText("4MP"); // lblProcesador.setText("2.2GHz"); // lblDescripcion.setText("iPhone 7 (Movistar)"); // break; // case 2: // System.out.println("MOVISTAR 2"); // lblPantalla.setText("5.1\""); // lblCamara.setText("7MP"); // lblProcesador.setText("1.2GHz"); // lblDescripcion.setText("LG k8 (Movistar)"); // break; // } // } // } }//GEN-LAST:event_lstEquiposMovilesValueChanged private void spPlanesPostpagoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spPlanesPostpagoStateChanged String planSeleccionado = String.valueOf(spPlanesPostpago.getValue()); for (PlanPostPago planPostPago : ListaPlanesPostPago) { if (planPostPago.getNombrePlan().equals(planSeleccionado)) { lblMinutos.setText(planPostPago.getMinutos()); lblInternet.setText(planPostPago.getInternet()); lblRPC.setText(planPostPago.getRpc()); lblSMS.setText(planPostPago.getSms()); } } }//GEN-LAST:event_spPlanesPostpagoStateChanged private void jBComprarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBComprarActionPerformed String tplan=spPlanesPostpago.getValue().toString(); // TODO add your handling code here: Modulo_de_Pago modulo = new Modulo_de_Pago(); modulo. setVisible(true); this.setVisible(false); Modulo_de_Pago.jTFImporteTotal1.setText(lblPrecio.getText()); Modulo_de_Pago.jTFPlan.setText(tplan); Modulo_de_Pago.jTFEquipos.setText(lblDescripcion.getText()); /*Modulo_de_Pago g = new Modulo_de_Pago(); g.setCadena(.getText); g.setVisible(true); }//GEN-LAST:event_jBComprarActionPerformed */} /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MainForm().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jBComprar; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel lblCamara; private javax.swing.JLabel lblCamaraImg; private javax.swing.JLabel lblDescripcion; private javax.swing.JLabel lblInternet; private javax.swing.JLabel lblInternetT; private javax.swing.JLabel lblMinutos; private javax.swing.JLabel lblMinutosT; private javax.swing.JLabel lblPantalla; private javax.swing.JLabel lblPantallaImg; private javax.swing.JLabel lblPrecio; private javax.swing.JLabel lblProcesador; private javax.swing.JLabel lblProcesadorImg; private javax.swing.JLabel lblRPC; private javax.swing.JLabel lblRPCT; private javax.swing.JLabel lblSMS; private javax.swing.JLabel lblSMST; private javax.swing.JLabel lblTCamara; private javax.swing.JLabel lblTEquiposMoviles; private javax.swing.JLabel lblTPantalla; private javax.swing.JLabel lblTPrecio; private javax.swing.JLabel lblTProcesador; private javax.swing.JList lstEquiposMoviles; private javax.swing.JScrollPane pblEquiposMovilles; private javax.swing.JPanel plBeneficiosPlan; private javax.swing.JPanel plCamara; private javax.swing.JPanel plCaracteristicas; private javax.swing.JPanel plInternet; private javax.swing.JPanel plMinutos; private javax.swing.JPanel plPantalla; private javax.swing.JPanel plProcesador; private javax.swing.JPanel plRPC; private javax.swing.JPanel plSMS; private javax.swing.JSpinner spPlanesPostpago; // End of variables declaration//GEN-END:variables }
[ "CHRISTIAN@LAPTOP-HQR13VEJ" ]
CHRISTIAN@LAPTOP-HQR13VEJ
1c08c36eaa281d0cd4c13cc65ae6982f81017cb0
5ea30b9c473ea87c298aac6d1333e1f5b277ed3b
/src/test/java/BaseTest/BaseTest.java
ae60bbde979073a71d756d64b415e0c68387a183
[]
no_license
SergeiChirkov/httpbinTests
defe00ca913be6ffe6909db0a9d94b1f674152cd
2625569de8039a88933bd0859c4ae54e6be2a46e
refs/heads/master
2022-12-30T09:37:40.035272
2020-06-06T21:28:02
2020-06-06T21:28:02
269,726,509
0
0
null
2020-10-13T22:35:25
2020-06-05T17:52:01
Java
UTF-8
Java
false
false
766
java
package BaseTest; import Logging.Logger; import Report.CucumberReport; import io.cucumber.java.Before; import io.cucumber.java.Scenario; import io.cucumber.plugin.ConcurrentEventListener; import io.cucumber.plugin.event.EventHandler; import io.cucumber.plugin.event.EventPublisher; import io.cucumber.plugin.event.TestRunFinished; public class BaseTest implements ConcurrentEventListener { @Override public void setEventPublisher(EventPublisher eventPublisher) { eventPublisher.registerHandlerFor(TestRunFinished.class, teardown); } private EventHandler<TestRunFinished> teardown = event -> { afterAll(); }; private void afterAll() { CucumberReport.build(); } @Before public void startUp(Scenario scenario) { Logger.setScenario(scenario); } }
7ee6f7960606cf22f8b1d50d97a88742aa2d2de4
222cfe58de73a4e80a6742908c72cb5309f514f4
/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/testhelpers/types/BlindlyEqualsPoint.java
9db77a1da22751011becfa734336031b44791e6f
[ "Apache-2.0" ]
permissive
jqno/equalsverifier
7455f2c35135b5ec835c01f78c1bfe7fab513eac
fbc499c52c556a3a37136be2654dca9d9d0b4e11
refs/heads/main
2023-09-05T21:31:32.210726
2023-09-05T12:38:54
2023-09-05T12:39:06
33,067,279
680
128
Apache-2.0
2023-09-02T18:59:34
2015-03-29T09:12:21
Java
UTF-8
Java
false
false
812
java
package nl.jqno.equalsverifier.testhelpers.types; public class BlindlyEqualsPoint { private final int x; private final int y; public BlindlyEqualsPoint(int x, int y) { this.x = x; this.y = y; } protected boolean blindlyEquals(Object o) { if (!(o instanceof BlindlyEqualsPoint)) { return false; } BlindlyEqualsPoint p = (BlindlyEqualsPoint) o; return p.x == this.x && p.y == this.y; } @Override public boolean equals(Object o) { return this.blindlyEquals(o) && ((BlindlyEqualsPoint) o).blindlyEquals(this); } @Override public int hashCode() { return x + (31 * y); } @Override public String toString() { return getClass().getSimpleName() + ":" + x + "," + y; } }
4a17898d69ba982cad3d3a0a68dbf4a322ad36dd
9fbea49cf8dfea4a8dd1d7bd0d4371f0773c5840
/screen-process/src/main/java/cn/screen/adaptation/process/ScreenAnnotationProcess.java
b9667380d5d0b7befa16529e418c681ee22fea3f
[]
no_license
loan-app/loanshop-android
01184c6803106f747cf27717eb3d722c129d8552
f19d028b8d9cdac77d4364d5b0dadc54f9cdfe24
refs/heads/master
2021-02-12T10:39:52.896508
2020-07-13T02:02:22
2020-07-13T02:02:22
244,586,912
0
0
null
null
null
null
UTF-8
Java
false
false
5,276
java
package cn.screen.adaptation.process; import com.google.auto.service.AutoService; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; import org.apache.commons.collections4.CollectionUtils; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Filer; import javax.annotation.processing.Messager; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.Processor; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Types; import javax.tools.Diagnostic; import cn.screen.adaptation.annotation.IdentificationEnum; import cn.screen.adaptation.annotation.ScreenAdaptation; /** * Created to :注解处理器. * * @author WANG * @date 2018/10/10 */ @AutoService(Processor.class) public class ScreenAnnotationProcess extends AbstractProcessor { private Messager mMessager; private Filer mFiler; private Types mTypeUtils; private ClassName xScreenType = ClassName.get("cn.screen.adaptation.screen_lib", "ScreenAdaptation"); private ClassName arrlyListType = ClassName.get("java.util", "ArrayList"); private ClassName hashMapType = ClassName.get("java.util", "HashMap"); @Override public synchronized void init(ProcessingEnvironment processingEnvironment) { super.init(processingEnvironment); mMessager = processingEnvironment.getMessager(); mFiler = processingEnvironment.getFiler(); mTypeUtils = processingEnvironment.getTypeUtils(); } @Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) { mMessager.printMessage(Diagnostic.Kind.NOTE, "处理开始--------------------"); try { Set<? extends Element> elements = roundEnvironment.getElementsAnnotatedWith(ScreenAdaptation.class); if (CollectionUtils.isNotEmpty(elements)) { processBaseWidth(elements); } } catch (Exception e) { return false; } mMessager.printMessage(Diagnostic.Kind.NOTE, "处理结束--------------------"); return true; } private void processBaseWidth(Set<? extends Element> elements) throws IOException { FieldSpec fieldSpec = FieldSpec.builder(HashMap.class, Options.WIDTH_FIELD_LIST) .addModifiers(Modifier.PRIVATE) .initializer("new HashMap<String,IdentificationEnum>()") .addJavadoc(Options.WIDTH_FIELD_DOC) .build(); MethodSpec.Builder methodBuild = MethodSpec.methodBuilder(Options.WIDTH_METHOD_NAME) .addModifiers(Modifier.PRIVATE) .returns(hashMapType) .addJavadoc(Options.WIDTH_METHOD_DOC); for (Element element : elements) { if (ElementKind.CLASS == element.getKind()) { TypeElement typeElement = (TypeElement) element; String classPath = typeElement.getQualifiedName().toString(); ScreenAdaptation screenAdaptation = typeElement.getAnnotation(ScreenAdaptation.class); IdentificationEnum identificationEnum = screenAdaptation.value(); mMessager.printMessage(Diagnostic.Kind.NOTE, "classPath--------------------" + classPath); methodBuild.addStatement(Options.WIDTH_FIELD_LIST + ".put($S,$N)", classPath, "IdentificationEnum." + identificationEnum); } } methodBuild.addStatement("return " + Options.WIDTH_FIELD_LIST); MethodSpec methodSpec = methodBuild.build(); MethodSpec constructorMethod = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addParameter(xScreenType, "xScreenBean") .addStatement("xScreenBean.setBaseWidthActivitys($N())", methodSpec) .build(); TypeSpec typeSpec = TypeSpec.classBuilder(Options.WIDTH_CLASS_NAME) .addModifiers(Modifier.PUBLIC) .addMethod(methodSpec) .addMethod(constructorMethod) .addField(fieldSpec) .addJavadoc("自动生成,请勿擅修改\n") .build(); JavaFile javaFile = JavaFile.builder(Options.PACKAGE_NAME, typeSpec) .build(); javaFile.writeTo(mFiler); } @Override public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } @Override public Set<String> getSupportedAnnotationTypes() { Set<String> annotations = new HashSet<>(); annotations.add(ScreenAdaptation.class.getCanonicalName()); return annotations; } }
42f43d02e2189e27a79e5bf7f2f014f70fc5f313
f4c3dc804ec6e7617a0ef561afb76058a7298fee
/udemyJava6/PizzaDelivery.java
f30c19fdc89eb897860a6cc1e282bc4921c4978e
[]
no_license
SolerJapan/JavaUdemyProjects
a29695493b5bb6b5b065f7c956c228e9c5646e2a
599cbe330887ec59c96554e08b54049a4c1746e1
refs/heads/main
2023-04-19T06:49:09.515692
2021-04-30T01:08:43
2021-04-30T01:08:43
362,988,791
0
0
null
null
null
null
WINDOWS-1252
Java
false
false
1,612
java
package udemyJava6; import java.util.Scanner; public class PizzaDelivery { public static void main(String[] args) { Scanner scan = new Scanner(System.in); /** Task 1: * 1. Ask the user: How many pizza toppings do you want?. * 2. Then, pick up the result using Scanner. */ System.out.println("How many pizza toppings do you want? " ); int tnum = scan.nextInt(); scan.nextLine(); // Task 2 – Create the array here String toppings[] = new String[tnum]; /** Task 3 * print Great, enter each topping! * Create a for loop that runs through the length of the array. * */ System.out.println("great " ); for (int i=0; i<toppings.length; i++) { System.out.println("give me topping " + i ); toppings[i] = scan.nextLine(); } /** Task 4 – Pick up the user's toppings and store them in the array. * * See the workbook article for more detail * */ /** Task 5 – Loop through the length of the array and print each topping * * See the workbook article for more detail * */ for (int j=0; j<toppings.length; j++) { System.out.println( j + ":" + toppings[j]); } /** Task 6 – Confirm the order * * See the workbook article for more detail * */ scan.close(); } }
2fbdab99c71b9c9897865cc56e8e8e0aa4806e0c
fca9bdd39da862b404b6e0a78286444575e63810
/lib_common_ui/src/main/java/com/wu/lib_common_ui/recyclerview/CommonAdapter.java
21a14c73b71dc245b22d61401f541c753a767667
[]
no_license
wuhaoxi/PluginApp
5db10a545ec98d9a0e457e02a49a9a89a5b0b86d
31caccae57b8386de2ced722148903bc734591e1
refs/heads/main
2023-05-13T16:13:57.457207
2021-05-31T16:09:33
2021-05-31T16:09:33
363,587,170
2
1
null
null
null
null
UTF-8
Java
false
false
1,289
java
package com.wu.lib_common_ui.recyclerview; import android.content.Context; import android.view.LayoutInflater; import com.wu.lib_common_ui.recyclerview.base.ItemViewDelegate; import com.wu.lib_common_ui.recyclerview.base.ViewHolder; import java.util.List; public abstract class CommonAdapter <T> extends MultiItemTypeAdapter<T> { protected Context mContext; protected int mLayoutId; protected List<T> mDatas; protected LayoutInflater mInflater; public CommonAdapter(final Context context, final int layoutId, List<T> datas) { super(context, datas); mContext = context; mInflater = LayoutInflater.from(context); mLayoutId = layoutId; mDatas = datas; addItemViewDelegate(new ItemViewDelegate<T>() { @Override public int getItemViewLayoutId() { return layoutId; } @Override public boolean isForViewType(T item, int position) { return true; } @Override public void convert(ViewHolder holder, T t, int position) { CommonAdapter.this.convert(holder, t, position); } }); } protected abstract void convert(ViewHolder holder, T t, int position); }
10c84d93edacd399b0d4651da12ead75abd3081a
3583b10c65ba9eeef175d186a344ce37f35430bc
/src/test/java/testObjects/AuthorizationDoc.java
e6326eea0164bb239727ad980cfb8da76d9d844d
[]
no_license
svetast/MedCardDesktop
58acf9f5280aa1bb140df79c920709c0d1cb5466
020438e0d1422e066a01ccf936712d0567ed3b4b
refs/heads/master
2021-01-17T14:33:13.242902
2017-06-13T08:07:50
2017-06-13T08:07:50
84,091,312
0
0
null
null
null
null
UTF-8
Java
false
false
1,105
java
package testObjects; import org.openqa.selenium.By; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; public class AuthorizationDoc extends TestBase { //Login Success as Doctor @Test public void testAuthorizationDoc() throws Exception { BasePage.waitPause(); LOG.info("Start DOC autorization"); LoginDocPage.authorizationDoc(); BasePage.waitAction(); LOG.info("Get name of active window :"); // наименование открытого окна ResultPage.getDocTitle(driver); assertEquals (driver.findElement(By.name("Пользователь :: Сидоров Василий Владимирович. (Врач) 10.12.253.23 Тестовая БД->LocalHost")).toString(), "[[WiniumDriver: on ANY (AwesomeSession)] -> name: Пользователь :: Сидоров Василий Владимирович. (Врач) 10.12.253.23 Тестовая БД->LocalHost]"); LOG.info("start the close of the main menu"); MainPage.closeMainWindow(); } }
0f6218e2efe2583553119508606c58dfcada92b1
9e3d30424f48c57482fb2cf7773fde1f49254f84
/app/src/test/java/com/leary/littlefairy/beautifulapp/ExampleUnitTest.java
3f7f2da58a18ed1c145153087f51e5ca19602934
[]
no_license
learyR/BeautifulApp
4c794cca8250db0a488d7d20c18a0a254795d68b
f911d532660087ce1fd35ebeb622631e2d7d8c48
refs/heads/master
2021-09-14T18:17:28.731731
2018-05-17T03:31:08
2018-05-17T03:31:08
113,415,839
0
0
null
null
null
null
UTF-8
Java
false
false
412
java
package com.leary.littlefairy.beautifulapp; 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() throws Exception { assertEquals(4, 2 + 2); } }