blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
132 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
28 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
352
8606005114a0728eba65f8e5c82bccb0888c8469
b99fa625369bd8a1152510a61b4b5d278e1a226e
/.svn/pristine/86/8606005114a0728eba65f8e5c82bccb0888c8469.svn-base
04469ea86b57bf26ca75891e6af216e000c2ff0d
[ "Apache-2.0" ]
permissive
wanliyang10010/Shop
557d2f508e94d7bd9f91cc169a6432e0da4ba8d6
25184cd860b0bdb434e3efd09d65c6aa7dbebf0b
refs/heads/master
2021-01-10T01:37:57.971461
2016-01-23T09:42:16
2016-01-23T09:42:16
50,230,836
4
5
null
null
null
null
UTF-8
Java
false
false
1,633
package cn.xaut.shop.pojo; /** * StageGoods entity. @author MyEclipse Persistence Tools */ public class StageGoods implements java.io.Serializable { // Fields private Integer sgoodsId; private String goodsname; private Integer points; private String remark; private String url; private String state; // Constructors /** default constructor */ public StageGoods() { } /** full constructor */ public StageGoods(String goodsname, Integer points, String remark, String url) { this.goodsname = goodsname; this.points = points; this.remark = remark; this.url = url; } // Property accessors public Integer getSgoodsId() { return this.sgoodsId; } public void setSgoodsId(Integer sgoodsId) { this.sgoodsId = sgoodsId; } public String getGoodsname() { return this.goodsname; } public void setGoodsname(String goodsname) { this.goodsname = goodsname; } public Integer getPoints() { return this.points; } public void setPoints(Integer points) { this.points = points; } public String getRemark() { return this.remark; } public void setRemark(String remark) { this.remark = remark; } public String getUrl() { return this.url; } public void setUrl(String url) { this.url = url; } public String getState() { return this.state; } public void setState(String state) { this.state = state; } }
[ "418517650@qq.com" ]
418517650@qq.com
dfdad082df6cdd3c5c1aab764fc429370f2a157c
262f07fc25576cfed862b62d29aa4bc331cf249d
/server/src/main/java/hnx/quickfix/fields/PT_TotalTradedValue.java
fc5ea590039697d626712d560831421e3e71b0fb
[]
no_license
LongNB8/fixhnxdemo1
8d2b46fa992e2adfe6ec9baa8c16356531599d50
f69712c7339dbfd931b2a6a82c15abfaa6b58f78
refs/heads/master
2023-04-05T13:38:43.033136
2021-04-12T14:55:57
2021-04-12T14:55:57
357,230,139
0
0
null
null
null
null
UTF-8
Java
false
false
1,163
java
/* Generated Java Source File */ /******************************************************************************* * Copyright (c) quickfixengine.org All rights reserved. * * This file is part of the QuickFIX FIX Engine * * This file may be distributed under the terms of the quickfixengine.org * license as defined by quickfixengine.org and appearing in the file * LICENSE included in the packaging of this file. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. * * See http://www.quickfixengine.org/LICENSE for licensing information. * * Contact ask@quickfixengine.org if any conditions of this licensing * are not clear to you. ******************************************************************************/ package hnx.quickfix.fields; import quickfix.DoubleField; public class PT_TotalTradedValue extends DoubleField { static final long serialVersionUID = 20050617; public static final int FIELD = 9141; public PT_TotalTradedValue() { super(9141); } public PT_TotalTradedValue(double data) { super(9141, data); } }
[ "long17000547@gmail.com" ]
long17000547@gmail.com
8843e3bb80b09b71c684c5f0de0efc82b0cf9952
c98a98486663b2fd4654e9d0b80b57776f6b4db8
/java/src/main/java/solutions/Q237.java
77064bd5b5faebf4c55976d1f48d4b074ab0d6cd
[]
no_license
renkeji/leetcode
6ae31d63cd4819ebd2a69be0665d04907fc8cc3c
1d40d357ff20a0560656727a07bf3e1c00dc4cb8
refs/heads/master
2020-05-22T04:24:48.263249
2017-05-21T22:26:05
2017-05-21T22:26:05
41,816,676
0
0
null
null
null
null
UTF-8
Java
false
false
565
java
package solutions; import solutions.datastructures.ListNode; /** * Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. * * Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function. */ public class Q237 extends Solution { public void deleteNode(ListNode node) { if (node.next != null) { node.val = node.next.val; node.next = node.next.next; } } }
[ "kren@apple.com" ]
kren@apple.com
68a5f09b3b573ad02eacf7e3ff8fe3d5e84e1586
ca959cbaab6cf6d324089e21b28f0dffda35ad45
/src/main/java/com/pas/edu/entity/ApplyChildRequest.java
7994c5e2370b428abd164df0b3fa845ff569a089
[]
no_license
xuzhaodeng/ChildrenSunshine
1d3a2a7112bed908eba4d7531af62b02cf39f105
6870af9e30a67d5ec1ff06a70f5d1eb0a41b8a81
refs/heads/master
2020-12-02T22:51:54.393551
2017-07-03T08:35:04
2017-07-03T08:35:04
96,193,863
0
0
null
null
null
null
UTF-8
Java
false
false
381
java
package com.pas.edu.entity; import lombok.Data; import org.hibernate.validator.constraints.NotEmpty; /** * Author: eric * CreateDate: 2017/6/3 * Modified: eric * ModifiedDate: 2017/6/3 * Email: ericli_wang@163.com * Version: 1.0 * Desc: */ @Data public class ApplyChildRequest { @NotEmpty private String childName; @NotEmpty private String childIdCard; }
[ "ericli_wang@163.com" ]
ericli_wang@163.com
9ac941b8b67df568da21aed6ab9484e47faa16e9
8f061a80956eb8d3f3c02dec46e3dc766c2639e4
/HolaQuilla/app/src/main/java/com/example/silviocantillo/holaquilla/ui/DecoracionLineaDivisoria.java
9be14238c0e2b410e18aee3e3fb741332a20a436
[]
no_license
sjcantillo/holaquilla
c79005c2d3c2846575069a597ad540ccc8d70f71
74bfe41839362fee295616e740d1d08029268fa0
refs/heads/master
2020-12-02T18:06:55.843031
2017-07-06T22:23:21
2017-07-06T22:23:21
96,475,791
1
0
null
null
null
null
UTF-8
Java
false
false
1,354
java
package com.example.silviocantillo.holaquilla.ui; import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.view.View; import com.example.silviocantillo.holaquilla.R; /** * Created by silvio.cantillo on 06/07/2017. */ public class DecoracionLineaDivisoria extends RecyclerView.ItemDecoration { private Drawable lineaDivisoria; public DecoracionLineaDivisoria(Context context) { lineaDivisoria = ContextCompat.getDrawable(context, R.drawable.linea_divisoria); } @Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = parent.getPaddingLeft(); int right = parent.getWidth() - parent.getPaddingRight(); int childCount = parent.getChildCount(); for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); int top = child.getBottom() + params.bottomMargin; int bottom = top + lineaDivisoria.getIntrinsicHeight(); lineaDivisoria.setBounds(left, top, right, bottom); lineaDivisoria.draw(c); } } }
[ "silvio.cantillo@pragma.com.co" ]
silvio.cantillo@pragma.com.co
07df8e17c68447a2c9582f2e93922a5cf2f74861
abf9653a9917dc575b641535c3ef4ad207167278
/src/main/java/it/si2001/springangular/configuration/AppInitializer.java
b23d5c0e26675745ee489a2b0af59de52853865b
[]
no_license
mopetkova/todo-WebAppSpringMVC
9f83fc21b54b998f3166df1aa05dfa937c4d9a09
f5403250563a0066e7fb353e9886c5b7f1d79a72
refs/heads/master
2020-03-22T07:43:47.530665
2018-07-16T07:17:16
2018-07-16T07:17:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
562
java
package it.si2001.springangular.configuration; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class[] { AppConfig.class }; } @Override protected Class<?>[] getServletConfigClasses() { return null; } @Override protected String[] getServletMappings() { return new String[] { "/" }; } }
[ "monika.petkova@si2001.it" ]
monika.petkova@si2001.it
50f5899fe40f696c988ce5c019b7b1b3f7135e7b
8f9f3da98d559b9fcf10aa3ed5887d6daf455dd8
/app/src/main/java/com/example/sportracker/Models/UserStatistics.java
7e9f386c0f16e1a26bbf82c84be8ba4e9397e0fb
[]
no_license
tomporat247/college-sportracker
b94d4125eb203c991d2871a6657e83b3b69b53fc
ef79bd5fe00603880b6000f20690789c871835fd
refs/heads/master
2023-06-13T23:41:45.910609
2021-07-02T10:09:10
2021-07-02T10:09:10
314,877,447
0
0
null
null
null
null
UTF-8
Java
false
false
1,629
java
package com.example.sportracker.Models; import java.util.ArrayList; import java.util.List; import java.util.Map; public class UserStatistics extends User { private int totalWins; private int totalLosses; private List<Contest> userContests; public UserStatistics(String id, Map<String, Object> firestoreDocument, List<Contest> userContests) { super(id, firestoreDocument); this.userContests = userContests; this.calculateStatistics(); } public UserStatistics(Contest contest) { super(); this.userContests = new ArrayList<Contest>() {{ add(contest); }}; this.calculateStatistics(); } public int getTotalWins() { return totalWins; } public int getTotalLosses() { return totalLosses; } private void calculateStatistics() { this.totalWins = 0; this.totalLosses = 0; this.userContests.forEach(contest -> contest.getMatches().forEach(match -> { if (match.getWinningTeamUserIds().contains(this.getId())) { this.totalWins++; } else if (match.getLosingTeamUserIds().contains(this.getId())) { this.totalLosses++; } })); } public float getWinLossRatio() { if (this.totalLosses == 0) { return this.totalWins == 0 ? 0 : 1; } else { return ((float) this.totalWins) / this.totalLosses; } } public int getPlusMinus() { return this.totalWins - this.totalLosses; } }
[ "tomporat247@gmail.com" ]
tomporat247@gmail.com
50f3647573b75824593a7d225751da8a4da7cd7a
96bd7fe8f062797cf149a36aabfd235ca1b4b2f4
/src/main/java/skunkworks/locator/Application.java
9ddf1552f8a162006c72a23abe9f001f823fdb67
[]
no_license
udisch/locator
e3da7d37d6b1bbf2cbc2386eb464aaaae0615008
fdfab84917f87b7e58c475216e3a335c58be3ae2
refs/heads/master
2021-06-20T15:27:56.691360
2017-02-19T10:25:19
2017-02-19T10:25:19
40,671,183
0
0
null
null
null
null
UTF-8
Java
false
false
304
java
package skunkworks.locator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
[ "udi@Udis-MacBook-Pro.local" ]
udi@Udis-MacBook-Pro.local
1d686a29ef1341f46dbb678030c3ee46d96fdd95
2aa354b14a2b88f56b33549cf48e213ad0786009
/src/main/java/cn/com/taiji/entity/UserloginKey.java
36f1af4711acaec305072d5e2e1f117836b101a9
[]
no_license
fengliqiang199545/FranChouChou
ed6a623c7de17a41669859f6e6cea4ae8af5600c
8e92ddba7266bed744bc11c280f729f467f54a0d
refs/heads/master
2020-04-16T18:30:32.445253
2019-01-24T09:48:04
2019-01-24T09:48:04
164,090,603
0
0
null
null
null
null
UTF-8
Java
false
false
1,828
java
package cn.com.taiji.entity; public class UserloginKey { /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column userlogin.userID * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ private Integer userid; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column userlogin.role * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ private Integer role; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column userlogin.userID * * @return the value of userlogin.userID * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ public Integer getUserid() { return userid; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column userlogin.userID * * @param userid the value for userlogin.userID * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ public void setUserid(Integer userid) { this.userid = userid; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column userlogin.role * * @return the value of userlogin.role * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ public Integer getRole() { return role; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column userlogin.role * * @param role the value for userlogin.role * * @mbg.generated Wed Jan 09 11:47:48 CST 2019 */ public void setRole(Integer role) { this.role = role; } }
[ "fengliqiang@example.com" ]
fengliqiang@example.com
71998588c43e8c74db8d3c1000b5fb48253bb09c
3bd758cfe7f35d22a9e353e358ff2888d72beff6
/app/src/main/java/beauty/beautydemo/custview/imageprocessing/filter/effect/SmoothToonFilter.java
5db1fd2e8c945db44b6cccd8e00f85a34501a50c
[]
no_license
ControlToday/beauty
e144fc9e3ee4b1950c9ca6400749a8fd2923612f
b0ddd8d45b42dd272bd7ed908d05a87b0f1ad503
refs/heads/master
2022-09-08T21:28:02.329571
2020-05-21T07:26:08
2020-05-21T07:26:08
265,634,904
0
0
null
2020-05-20T17:12:20
2020-05-20T17:12:19
null
UTF-8
Java
false
false
1,051
java
package beauty.beautydemo.custview.imageprocessing.filter.effect; import beauty.beautydemo.custview.imageprocessing.filter.GroupFilter; import beauty.beautydemo.custview.imageprocessing.filter.processing.GaussianBlurFilter; /** * This uses a similar process as the GPUImageToonFilter, only it precedes the toon effect with a Gaussian blur to smooth out noise. * blurSize: A multiplier for the prepass blur size, ranging from 0.0 on up * threshold: The sensitivity of the edge detection, with lower values being more sensitive. Ranges from 0.0 to 1.0 * quantizationLevels: The number of color levels to represent in the final image. * @author Chris Batt */ public class SmoothToonFilter extends GroupFilter { public SmoothToonFilter(float blurSize, float threshold, float quantizationLevels) { GaussianBlurFilter blur = new GaussianBlurFilter(blurSize); ToonFilter toon = new ToonFilter(threshold, quantizationLevels); blur.addTarget(toon); toon.addTarget(this); registerInitialFilter(blur); registerTerminalFilter(toon); } }
[ "jiwei.lou@foxmail.com" ]
jiwei.lou@foxmail.com
96f2089e13ffd71b2afc27843d2b841c629562e8
555b07cc4fe2f7d5ba29e18c1f3cfcf49c34a95e
/leagueofjava/ClassSet/Content/UserContent.java
bae78485c9087d8dedf1fcd4bbf0526bf8acd750
[]
no_license
dart-bird/ERICA_LOL
74ba5833e26e85537a271ca41d190711caeb88e1
72c20a9d8f6d10bc84a09f2761050a741c0bae2c
refs/heads/master
2022-04-05T08:05:37.146346
2019-12-22T13:42:15
2019-12-22T13:42:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
10,568
java
package ClassSet.Content; import ClassSet.ReadWriter.Reader; import ClassSet.ReadWriter.Writer; import java.util.ArrayList; import java.io.File; import java.io.IOException; //import ClassSet.Content.PlayerContent; import java.util.*; public class UserContent extends PlayerContent { private String UserData = ""; private String UserDeck = ""; ArrayList<String> list = new ArrayList<String>(); // 정보 정리에 필요한 리스트 private HashMap<String, String> userdata = new HashMap<String, String>(); // 사용자 정보 정리 사전 private HashMap<String, String> userdeck = new HashMap<String, String>(); // 사용자 덱 선발, 후보 정리 사전 private HashMap<Integer, ArrayList<String>> userdeckClassfic_ingame = new HashMap<Integer, ArrayList<String>>(); // 선발된 // 선수 // 정보 // 정리 // 사전 private HashMap<Integer, ArrayList<String>> userdeckClassfic_outgame = new HashMap<Integer, ArrayList<String>>(); // 후보선수 // 정보 // 정리 // 사전 private String tmpStr = ""; private int dataIndex = 0; private String dataOfkey = ""; public UserContent(File file, File file2, File file3) throws IOException { super(file); UserData = ""; UserDeck = ""; tmpStr = ""; dataIndex = 0; loadContent(file3); // in PlayerContent loadUserData(file); pushUserData(); loadUserDeck(file2); pushUserDeck("INGAME"); pushUserDeck("OUTGAME"); } private void loadUserData(File file) throws IOException { Reader rUserData = new Reader(file); rUserData.loadContent(file); UserData = rUserData.getContent(); } private void loadUserDeck(File file2) throws IOException { Reader rUserDeck = new Reader(file2); rUserDeck.loadContent(file2); UserDeck = rUserDeck.getContent(); } public void setUserDeckByName(int data_1, int data_2){ StringBuffer tmpUserdeck = new StringBuffer(); tmpStr = userdeck.get("INGAME"); String[] data = tmpStr.split(","); data = reformData(data); for(int i=0; i<data.length; i++){ if(Integer.parseInt(data[i]) == data_1){ data[i] = Integer.toString(data_2); } if (i==0) tmpUserdeck.append(data[i]); //처음에는 ,가 들어가면 안되서 제한함 else tmpUserdeck.append("," + data[i]); } UserDeck = tmpUserdeck.toString(); System.out.println(UserDeck); tmpUserdeck = new StringBuffer(); tmpStr = userdeck.get("OUTGAME"); data = tmpStr.split(","); data = reformData(data); System.out.println("data split in OUTGAME"+data[0].toString()); for(int i=0; i<data.length; i++){ if(Integer.parseInt(data[i]) == data_2){ data[i] = Integer.toString(data_1); } if (i==0) tmpUserdeck.append(data[i]); //처음에는 ,가 들어가면 안되서 제한함 else tmpUserdeck.append("," + data[i]); } UserDeck += "/" + tmpUserdeck.toString(); System.out.println(UserDeck); } public void writeUserContent(File file, String Content, boolean append){ Writer wUserContent = new Writer(file); wUserContent.writeContent(file, Content, append); } public String getUserPlayerStat(int key, int statIndex){ list = userdeckClassfic_ingame.get(key); return list.get(statIndex); } public HashMap <Integer, ArrayList<String>> getHashMapUserPlayer(){ return userdeckClassfic_ingame; } private void pushUserData() { try { dataOfkey =""; String[] data = UserData.split(","); data = reformData(data); userdata.put("id", data[0]); userdata.put("pw", data[1]); userdata.put("exp", data[2]); userdata.put("gold", data[3]); } catch (Exception e) { System.out.println("사용자 정보 없음"); } } public void pushUserDeck(String key) { try { userdeck.put("INGAME",UserDeck.substring(0, UserDeck.indexOf('/'))); //'/'를 기준으로 선발 후보를 나뉨. userdeck.put("OUTGAME",UserDeck.substring(UserDeck.indexOf('/')+1)); //System.out.println(userdeck.get("OUTGAME")); dataOfkey =""; tmpStr = userdeck.get(key); String[] data = tmpStr.split(","); for(int i=0; i<data.length; i++){ list = new ArrayList<String>(); //list를 매번마다 초기화 시켜줌. data = reformData(data); //dataOfkey += getPlayerdata(Integer.parseInt(data[i]))+ "\n"; // 선수 목록 편하게 보기 위에 뉴라인 먹임 dataOfkey의 문자열을 other에 적용 String[] splitData = getPlayerdata(Integer.parseInt(data[i])).split("/"); for (int j = 0; j < 7; j++) { // 선수 하나의 정보 7개를 리스트로 저장 list.add(splitData[j]); } if(key == "INGAME") userdeckClassfic_ingame.put(i,list); // 각 선발선수 정보 정리 if(key == "OUTGAME") userdeckClassfic_outgame.put(i,list); // 각 후발선수 정보 정리 } } catch (Exception e) { System.out.println("사용자 덱 정보 없음"); } } public String getUserDataList() { //review parsing result return UserData; } public String getUserDeckList() { //review parsing result return UserDeck; } public String getUserData(String key){ return userdata.get(key).toString(); } public boolean chkUserDeckName(String name){ boolean bool = false; for(int i=0; i<userdeckClassfic_outgame.size(); i++){ list = userdeckClassfic_outgame.get(i); //후보 선수정보가 분류된 사전을 불러옵니다. //System.out.println(list.get(0)); if(name.equals(list.get(0).toString())){ //후보 선수정보 중 이름을 불러옵니다. bool = true; } } return bool; } public String[] reformData(String[] data){ for(int i=0; i<data.length; i++){ if (data[i].length() > 0 && data[i].charAt(data[i].length()-1)=='\n') { data[i] = data[i].substring(0, data[i].length()-1); } //data_deck.gdata 뒤에 \n을 삭제 해줌. 그래야 정상적으로 parse가 됨 } return data; } public HashMap <Integer,ArrayList<String>> getUserPlayerHashMap() { return userdeckClassfic_ingame; } public Integer getUserDeckIndex(String key, String position) { String index = ""; tmpStr = userdeck.get(key); String[] data = tmpStr.split(","); data = reformData(data); System.out.println(data[0].toString()); switch (position) { case "top": index = data[0].toString(); break; case "mid": index = data[1].toString(); break; case "dealer": index = data[2].toString(); break; case "supporter": index = data[3].toString(); break; case "jungle": index = data[4].toString(); break; default: for(int i=0; i<userdeckClassfic_outgame.size(); i++){ list = userdeckClassfic_outgame.get(i); //후보 선수정보가 분류된 사전을 불러옵니다. if(position.equals(list.get(0))){ //후보 선수정보 중 이름을 불러옵니다. System.out.println("this is default in for in if: " + position + "i" + i); index = data[i].toString(); } } break; } return Integer.parseInt(index); } public String getUserDeck(String key, String position){ try { //name에 nick, team, skillshot, roaming, cs, object 키를 담았으면좋겠음 switch(position){ case "top": list = userdeckClassfic_ingame.get(0); return getPlayerInformation(list); case "mid": list = userdeckClassfic_ingame.get(1); return getPlayerInformation(list); case "dealer": list = userdeckClassfic_ingame.get(2); return getPlayerInformation(list); case "supporter": list = userdeckClassfic_ingame.get(3); return getPlayerInformation(list); case "jungle": list = userdeckClassfic_ingame.get(4); return getPlayerInformation(list); case "other": for(int i=0; i<userdeckClassfic_outgame.size(); i++){ list = userdeckClassfic_outgame.get(i); dataOfkey += getPlayerInformation(list) + "\n\n"; } return dataOfkey; } return " "; } catch (NumberFormatException e) { return "선수 없음"; } catch (Exception e) { System.out.println("선수없음"); return " "; } } }
[ "okokrt@gmail.com" ]
okokrt@gmail.com
b6eaa1164b356859cb3124bcb3d3ed9f63e5e68a
a29696f1a0fdb569a2b7b8a8dde86a4d95b21f41
/app/src/androidTest/java/com/sevent/toucheventverification/MainActivityTest.java
98b8a8a2375902f8bb5bf94137e94c36a36ae26c
[]
no_license
holiday9/TouchEvent
35b4a2ab062a45ae0f36c143dfe94a305e0f20d9
4dc18a992d954c451d9db6ce0c1962196134d86c
refs/heads/master
2021-05-27T17:29:49.688706
2015-05-05T13:43:13
2015-05-05T13:43:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,315
java
package com.sevent.toucheventverification; import android.app.Instrumentation; import android.test.ActivityInstrumentationTestCase2; import android.view.ViewGroup; import android.widget.EditText; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; /** * Created by htyuan on 15-4-29. */ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> { private Instrumentation mInstrumentation; private MainActivity mActivity; public MainActivityTest() { super(MainActivity.class); } protected void setUp() throws Exception { super.setUp(); mInstrumentation = getInstrumentation(); mActivity = getActivity(); } public void testBuildOrderedChildList() { Exception ee = null; // ArrayList<View> buildOrderedChildList() { ArrayList<ViewGroup> childs = null; MyChildFrameLayout childFrameLayout = (MyChildFrameLayout) mActivity.findViewById(R.id.frame_child); try { childs = (ArrayList<ViewGroup>) ReflectUtil.invokeMethod(childFrameLayout, "buildOrderedChildList", null, null); } catch (Exception e) { ee = e; System.out.println(ee.toString()); } assertNull(ee); assertNull(childs); } }
[ "htyuan80@gmail.com" ]
htyuan80@gmail.com
7507da289cd006f7e812cc2cdc67c9264598de4e
ed3cb95dcc590e98d09117ea0b4768df18e8f99e
/project_1_1/src/g/a/g/Calc_1_1_6061.java
208d52583d2a2d51035ccc9f8e874af4e59ed0d6
[]
no_license
chalstrick/bigRepo1
ac7fd5785d475b3c38f1328e370ba9a85a751cff
dad1852eef66fcec200df10083959c674fdcc55d
refs/heads/master
2016-08-11T17:59:16.079541
2015-12-18T14:26:49
2015-12-18T14:26:49
48,244,030
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package g.a.g; public class Calc_1_1_6061 { /** @return the sum of a and b */ public int add(int a, int b) { return a+b; } }
[ "christian.halstrick@sap.com" ]
christian.halstrick@sap.com
7c4370da969b2b096ddcbb753b5657a0f43afd02
4a25a4e6041102bd920d50bccb7c980818ac051e
/src/com/ucsc/ir/searchengine/indexer/DocumentIndexer.java
57482a33de4e904f131b5981c414d49e291b64a2
[]
no_license
sanjanamaiya/Search-engine
6b05b6f0e76a4ebc6c02b97069a6925e8667f6ad
e48a1403de9cdea92b1cab721d2f1ac77c0d8e2f
refs/heads/master
2021-01-17T09:40:29.594390
2015-09-29T06:58:51
2015-09-29T07:00:18
38,454,707
0
0
null
null
null
null
UTF-8
Java
false
false
4,269
java
package com.ucsc.ir.searchengine.indexer; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.logging.Logger; /** * Parses file containing OHSUMED documents * The format of an OHSUMED doc: * .I sequential identifier (important note: documents should be processed in this order) * .U MEDLINE identifier (UI) (<DOCNO> used for relevance judgements) * .M Human-assigned MeSH terms (MH) * .T Title (TI) * .P Publication type (PT) * .W Abstract (AB) * .A Author (AU) * .S Source (SO) * * @author sanjana * */ public class DocumentIndexer { private static final Logger LOGGER = Logger.getLogger(DocumentIndexer.class.getName()); public void indexFile(String fileLocation) { File sourcefile = new File(fileLocation); if (sourcefile.exists()) { BufferedReader reader = null; try { StringBuilder document = new StringBuilder(); reader = new BufferedReader(new FileReader(sourcefile)); String content = reader.readLine(); //int sectionCount = 0; while (content != null) { // Each doc within file starts at ".I" //sectionCount = 0; if (content.startsWith(IndexContants.DOC_SEQUENTIAL_IDENTIFIER)) { // Start of document in file document = new StringBuilder(); String docId = content.split("\\s+")[1]; content = reader.readLine(); while (content != null) { if (content.startsWith(IndexContants.DOC_SEQUENTIAL_IDENTIFIER)) { break; } if (content.startsWith(IndexContants.DOC_MEDLINE_IDENTIFIER)) { content = reader.readLine(); //sectionCount++; docId = content; } else if (isSectionBeginning(content)) { if (shouldSkipSection(content)) { content = reader.readLine(); } document.append(" "); //sectionCount++; } else { //String newcontent = formatSection(content, sectionCount); document.append(content); } content = reader.readLine(); } // Have the complete document, parse it and send it to the Indexer LuceneIndexer.getInstance().indexFile(document.toString(), docId); //System.out.println("Done building index for doc: " + docId); } } System.out.println("Checking tokens..."); } catch (IOException e) { LOGGER.warning("Exception thrown while reading file: " + fileLocation + ", Exception: " + e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } LuceneIndexer.getInstance().closeWriter(); } } } private boolean shouldSkipSection(String content) { return (!(content.startsWith(IndexContants.DOC_TITLE) || content.startsWith(IndexContants.DOC_MESH_TERMS) || content.startsWith(IndexContants.DOC_ABSTRACT))); } /*protected String formatSection(String content, int sectionCount) { OHSUMED docSection = OHSUMED.valueOf(sectionCount); switch (docSection) { case DOC_ABSTRACT: case DOC_TITLE: content = content.replaceAll("\\(|\\)", ""); break; default: break; } return content; }*/ /** * Tokenize the keywords and send to the Indexer * @param string * @throws IOException */ /*private void addDocumentToIndex(String docId, String docString) throws IOException { // Maybe MeSH strings need to be split only on ; ??? //String[] keyList = docString.split(",\\s*|;\\s*|\\.\\s*|\\s+"); //docString.split("[,;.W+]"); //Indexer keyWordIndexer = Indexer.getInstance(); //keyWordIndexer.processDocument(docId, keyList); }*/ private boolean isSectionBeginning(String line) { return (line.startsWith(IndexContants.DOC_ABSTRACT) || line.startsWith(IndexContants.DOC_AUTHOR) || line.startsWith(IndexContants.DOC_MEDLINE_IDENTIFIER) || line.startsWith(IndexContants.DOC_MESH_TERMS) || line.startsWith(IndexContants.DOC_PUBLICATION_TYPE) || line.startsWith(IndexContants.DOC_SOURCE) || line.startsWith(IndexContants.DOC_TITLE)); } }
[ "sanjana.maiya@gmail.com" ]
sanjana.maiya@gmail.com
bd9d62dea989ceccec6a5148d772b676b8ec0d22
4b919348dea3b3686043d554586ba72ceacf1b25
/schedule-task/src/main/java/com/woods/www/scheduletask/quartz/SimpleJob.java
e93f68a2ca84cd68e2277b6d32f723f6ff5f31c3
[]
no_license
woodscpp/SpringBootLearn
b820aad1281fe5bebcdc9382a8073bb215f9fa69
7e8bec60d63a6946b90317c57af469fce640c1b4
refs/heads/master
2020-09-27T11:45:26.307470
2019-12-09T15:40:12
2019-12-09T15:40:12
226,507,965
0
0
null
null
null
null
UTF-8
Java
false
false
388
java
package com.woods.www.scheduletask.quartz; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Date; /** * @author: woods * @date: 2019/12/7 * @description: */ @Component @Slf4j public class SimpleJob { public void sayHello(){ log.info("simple job>>>{}, Thread>>>{}", new Date(), Thread.currentThread().getId()); } }
[ "woodscpp@163.com" ]
woodscpp@163.com
cff81dcb945341749bd1f6bc4ed289a0ba161660
8ce1213559cffdccd43bcaed8cc40f55624fe1a3
/src/LiKouPractice/Pro730.java
fedc1de35aef1007cccb0b3c04ddbffebdab7ee4
[]
no_license
MAwei-MV/LeeCode-Recording
7b706da8327800f5ed9c65c24256402268813c56
dea88523a8b75910e8714ed5d6972837eba7523b
refs/heads/master
2023-03-30T03:26:43.856881
2021-04-09T10:28:10
2021-04-09T10:28:10
356,167,935
0
0
null
null
null
null
UTF-8
Java
false
false
116
java
package LiKouPractice; public class Pro730 { public int countPalindromicSubsequences(String S) { return 1; } }
[ "15717325053@163.com" ]
15717325053@163.com
002c8cbd6df19afc777b7fec17c3c50fd6e6e865
a5128099178a19d5e2f5f103001f4e4b7154a819
/src/test/java/net/cassite/vproxy/test/cases/TestIpParser.java
e758e2105c49c5fedbaf23f27fb2a23e4a5dde85
[ "MIT" ]
permissive
AlexZFX/vproxy
bf4a5288a27ce508b4fe2e0e3909921bf406ada9
9ed242444eac83ca80dc17bb587ac65de7f47ba2
refs/heads/master
2020-04-18T01:37:59.700846
2019-02-26T15:34:39
2019-02-26T15:34:39
167,126,386
0
0
MIT
2019-01-23T06:00:57
2019-01-23T06:00:52
Java
UTF-8
Java
false
false
5,349
java
package net.cassite.vproxy.test.cases; import net.cassite.vproxy.util.Utils; import org.junit.Test; import java.net.Inet6Address; import java.net.InetAddress; import static org.junit.Assert.*; public class TestIpParser { @Test public void parseIpv4() { int a = 192; int b = 168; int c = 12; int d = 34; String s = a + "." + b + "." + c + "." + d; byte[] bytes = Utils.parseIpv4String(s); assert bytes != null; assertEquals((byte) a, bytes[0]); assertEquals((byte) b, bytes[1]); assertEquals((byte) c, bytes[2]); assertEquals((byte) d, bytes[3]); a = 192; b = 168; c = 0; d = 0; s = a + "." + b + "." + c + "." + d; bytes = Utils.parseIpv4String(s); assert bytes != null; assertEquals((byte) a, bytes[0]); assertEquals((byte) b, bytes[1]); assertEquals((byte) c, bytes[2]); assertEquals((byte) d, bytes[3]); } @Test public void parseIpv4Fail() { assertNull(Utils.parseIpv4String("1")); assertNull(Utils.parseIpv4String("a.b.c.d")); assertNull(Utils.parseIpv4String("1.2.3.")); assertNull(Utils.parseIpv4String("...")); assertNull(Utils.parseIpv4String("1.2..")); assertNull(Utils.parseIpv4String("..3.4")); assertNull(Utils.parseIpv4String("1...4")); assertNull(Utils.parseIpv4String("256.1.1.1")); assertNull(Utils.parseIpv4String("1.256.1.1")); } private void check(String s) throws Exception { InetAddress addr = InetAddress.getByName(s); byte[] b1 = addr.getAddress(); byte[] b2 = Utils.parseIpv6String(s); assert b2 != null; if (addr instanceof Inet6Address) { assertArrayEquals(b1, b2); } else { for (int i = 0; i < 10; ++i) { assertEquals(0, b2[i]); } for (int i = 11; i < 12; ++i) { assertEquals((byte) 0xFF, b2[i]); } for (int i = 0; i < 4; ++i) { assertEquals(b1[i], b2[i + 12]); } } if (s.startsWith("[")) { return; } check("[" + s + "]"); } @Test public void parseIpv6() throws Exception { // https://tools.ietf.org/html/rfc4291#section-2.2 check("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789"); check("2001:DB8:0:0:8:800:200C:417A"); check("FF01:0:0:0:0:0:0:101"); check("0:0:0:0:0:0:0:1"); check("0:0:0:0:0:0:0:0"); check("2001:DB8::8:800:200C:417A"); check("FF01::101"); check("::1"); check("::"); check("0:0:0:0:0:0:13.1.68.3"); check("0:0:0:0:0:FFFF:129.144.52.38"); check("::13.1.68.3"); check("::FFFF:129.144.52.38"); // my test cases check("1::"); check("1a2b::3c4d"); check("22::"); check("333::"); check("4444::"); // https://stackoverflow.com/questions/10995273/test-case-for-validation-ipv4-embedded-ipv6-addresses check("2001:db8:c000:221::"); check("2001:db8:1c0:2:21::"); check("2001:db8:122:c000:2:2100::"); check("2001:db8:122:3c0:0:221::"); check("2001:db8:122:344:c0:2:2100::"); check("2001:db8:122:344::192.0.2.33"); } // from guava // https://github.com/google/guava/blob/master/guava-tests/test/com/google/common/net/InetAddressesTest.java#L42 // Copyright (C) 2008 The Guava Authors // apache2 license String[] bogusInputs = { "", "016.016.016.016", "016.016.016", "016.016", "016", "000.000.000.000", "000", "0x0a.0x0a.0x0a.0x0a", "0x0a.0x0a.0x0a", "0x0a.0x0a", "0x0a", "42.42.42.42.42", "42.42.42", "42.42", "42", "42..42.42", "42..42.42.42", "42.42.42.42.", "42.42.42.42...", ".42.42.42.42", "...42.42.42.42", "42.42.42.-0", "42.42.42.+0", ".", "...", "bogus", "bogus.com", "192.168.0.1.com", "12345.67899.-54321.-98765", "257.0.0.0", "42.42.42.-42", "3ffe::1.net", "3ffe::1::1", "1::2::3::4:5", "::7:6:5:4:3:2:", // should end with ":0" ":6:5:4:3:2:1::", // should begin with "0:" "2001::db:::1", "FEDC:9878", "+1.+2.+3.4", "1.2.3.4e0", "::7:6:5:4:3:2:1:0", // too many parts "7:6:5:4:3:2:1:0::", // too many parts "9:8:7:6:5:4:3::2:1", // too many parts "0:1:2:3::4:5:6:7", // :: must remove at least one 0. "3ffe:0:0:0:0:0:0:0:1", // too many parts (9 instead of 8) "3ffe::10000", // hextet exceeds 16 bits "3ffe::goog", "3ffe::-0", "3ffe::+0", "3ffe::-1", ":", ":::", "::1.2.3", "::1.2.3.4.5", "::1.2.3.4:", "1.2.3.4::", "2001:db8::1:", ":2001:db8::1", ":1:2:3:4:5:6:7", "1:2:3:4:5:6:7:", ":1:2:3:4:5:6:" }; @Test public void parseIpFail() { for (String ip : bogusInputs) { assertNull(Utils.parseIpString(ip)); } } }
[ "wkgcass@hotmail.com" ]
wkgcass@hotmail.com
56602928f44a31ed6285c5ce3bea76585154cb66
571d6943cb7720b51359dd24a954c5049851801c
/src/main/java/com/alexsoft/utils/deleted/SmartphoneShopsRepository.java
8a6ea568d627f574ff58b516e5b80e9ccf2ae8c0
[]
no_license
Sancher17/PricesBack
4b8799898b1f5f85b351f38e72d6d97ef9a6a31b
1cf467953090d4185b0b6404307e52b2073a1cc9
refs/heads/master
2022-12-20T16:48:26.474850
2020-09-23T12:28:41
2020-09-23T12:28:41
297,962,631
0
0
null
null
null
null
UTF-8
Java
false
false
360
java
package com.alexsoft.utils.deleted;//package com.prices.db.shops; // //import com.prices.entyties.categories.shops.SmartphoneShops; //import org.springframework.data.jpa.repository.JpaRepository; // //public interface SmartphoneShopsRepository extends JpaRepository<SmartphoneShops, Long> { // // SmartphoneShops getByProductId(String productID); // // //}
[ "aliaksandr_kavalenka_wp@senla.eu" ]
aliaksandr_kavalenka_wp@senla.eu
c94e4f7788a29578efed4300d11ef641a7a92ef5
383b7ec8cbe4001a483051c88d26ac85c26bb7cc
/oc-profile/src/main/java/com/orientalcomics/profile/web/annotations/LoginRequired.java
acf6819797a9b750e92ebd3e074427d8d33353fb
[]
no_license
jojozoo/fc-profile
f4977b4c289f9785d800a1001d2def8ef44bf3d5
54a9964c85a2e224154b91dfc8482fc2b160afc4
refs/heads/master
2021-03-12T20:18:28.405356
2014-05-22T06:32:55
2014-05-22T06:32:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
456
java
package com.orientalcomics.profile.web.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ ElementType.TYPE, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited public @interface LoginRequired { }
[ "ccdany@outlook.com" ]
ccdany@outlook.com
4a3092defc46a0ae274de7226e70bb7d5c0d32d8
a9d23f6e778fa1945cf3a79f5eb69c8c720552bc
/Project2Service/src/main/java/soap/LogServicePublisher.java
4805ccc2302c0320bce2bf6f29f2c2ddf1ffab51
[]
no_license
Tianxiang-Concordia/SOEN487Project2
b3585bd8dc8a866ac2c1d6d95ebc8534228e493b
0fa7cb5ee41c5b8c6547e58efa51d34641284d64
refs/heads/master
2023-03-25T18:58:48.159117
2021-03-15T15:00:22
2021-03-15T15:00:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
514
java
package soap; import javax.xml.ws.Endpoint; import java.io.IOException; public class LogServicePublisher { static int port = 8090; static String servicePath = "/logs"; static String BASE_URI = "http://localhost:" + port + servicePath; public static void main(String[] args) throws IOException { System.out.println("SOAP Service listening on " + BASE_URI + "?wsdl"); Endpoint.publish(BASE_URI, new LogServiceImpl()); System.out.println("Server is running"); } }
[ "zhangyanqi2011@gmail.com" ]
zhangyanqi2011@gmail.com
02eae9e410505456594da51554033fe2be295611
166c2de35e7988cacfb10c54fef07b3eb2f13b36
/demos/substance-demo/src/main/java/org/pushingpixels/demo/substance/main/check/svg/flags/cn.java
0c06528e5c4ebfd51deb08590ef3e4c69cfbd35b
[ "BSD-3-Clause" ]
permissive
jusu/radiance
66fc331ee3696e02607fba838bc00da8673f16f2
e310541a8afce48bc0a733b0c317f26b63b7633b
refs/heads/master
2020-04-04T17:34:21.704244
2018-11-02T04:02:18
2018-11-02T04:02:18
null
0
0
null
null
null
null
UTF-8
Java
false
false
10,097
java
package org.pushingpixels.demo.substance.main.check.svg.flags; import java.awt.*; import java.awt.geom.*; import javax.swing.plaf.UIResource; import org.pushingpixels.neon.icon.IsHiDpiAware; import org.pushingpixels.neon.icon.ResizableIcon; import org.pushingpixels.neon.icon.NeonIcon; import org.pushingpixels.neon.icon.NeonIconUIResource; /** * This class has been automatically generated using <a * href="https://github.com/kirill-grouchnikov/radiance">Photon SVG transcoder</a>. */ public class cn implements ResizableIcon, IsHiDpiAware { @SuppressWarnings("unused") private void innerPaint(Graphics2D g) { Shape shape = null; Paint paint = null; Stroke stroke = null; float origAlpha = 1.0f; Composite origComposite = g.getComposite(); if (origComposite instanceof AlphaComposite) { AlphaComposite origAlphaComposite = (AlphaComposite)origComposite; if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { origAlpha = origAlphaComposite.getAlpha(); } } AffineTransform defaultTransform_ = g.getTransform(); // g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, -0.0f, -0.0f)); // _0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_0 paint = new Color(222, 41, 16, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.0, 0.0); ((GeneralPath)shape).lineTo(512.0, 0.0); ((GeneralPath)shape).lineTo(512.0, 512.0); ((GeneralPath)shape).lineTo(0.0, 512.0); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_0); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_1 = g.getTransform(); g.transform(new AffineTransform(76.80000305175781f, 0.0f, 0.0f, 76.80000305175781f, 128.0f, 128.0f)); // _0_1 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_1_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_1_0 paint = new Color(255, 222, 0, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.95, -0.31); ((GeneralPath)shape).lineTo(-0.587, 0.81); ((GeneralPath)shape).lineTo(0.0, -1.0); ((GeneralPath)shape).lineTo(0.588, 0.81); ((GeneralPath)shape).lineTo(-0.952, -0.31); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_1_0); g.setTransform(defaultTransform__0_1); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_2 = g.getTransform(); g.transform(new AffineTransform(-13.15839958190918f, -21.939199447631836f, 21.939199447631836f, -13.15839958190918f, 256.0f, 51.20000076293945f)); // _0_2 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_2_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_2_0 paint = new Color(255, 222, 0, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.95, -0.31); ((GeneralPath)shape).lineTo(-0.587, 0.81); ((GeneralPath)shape).lineTo(0.0, -1.0); ((GeneralPath)shape).lineTo(0.588, 0.81); ((GeneralPath)shape).lineTo(-0.952, -0.31); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_2_0); g.setTransform(defaultTransform__0_2); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_3 = g.getTransform(); g.transform(new AffineTransform(-3.609726894426369f, -25.344227967703123f, 25.344227967703123f, -3.609726894426369f, 307.19519708753614f, 102.38619879841089f)); // _0_3 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_3_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_3_0 paint = new Color(255, 222, 0, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.95, -0.31); ((GeneralPath)shape).lineTo(-0.587, 0.81); ((GeneralPath)shape).lineTo(0.0, -1.0); ((GeneralPath)shape).lineTo(0.588, 0.81); ((GeneralPath)shape).lineTo(-0.952, -0.31); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_3_0); g.setTransform(defaultTransform__0_3); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_4 = g.getTransform(); g.transform(new AffineTransform(7.039999961853027f, -24.627199172973633f, 24.627199172973633f, 7.039999961853027f, 307.20001220703125f, 179.1999969482422f)); // _0_4 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_4_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_4_0 paint = new Color(255, 222, 0, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.95, -0.31); ((GeneralPath)shape).lineTo(-0.587, 0.81); ((GeneralPath)shape).lineTo(0.0, -1.0); ((GeneralPath)shape).lineTo(0.588, 0.81); ((GeneralPath)shape).lineTo(-0.952, -0.31); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_4_0); g.setTransform(defaultTransform__0_4); g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_5 = g.getTransform(); g.transform(new AffineTransform(16.0f, -19.968000411987305f, 19.968000411987305f, 16.0f, 256.0f, 230.39999389648438f)); // _0_5 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_5_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_5_0 paint = new Color(255, 222, 0, 255); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.95, -0.31); ((GeneralPath)shape).lineTo(-0.587, 0.81); ((GeneralPath)shape).lineTo(0.0, -1.0); ((GeneralPath)shape).lineTo(0.588, 0.81); ((GeneralPath)shape).lineTo(-0.952, -0.31); ((GeneralPath)shape).closePath(); g.setPaint(paint); g.fill(shape); g.setTransform(defaultTransform__0_5_0); g.setTransform(defaultTransform__0_5); g.setTransform(defaultTransform__0); g.setTransform(defaultTransform_); } /** * Returns the X of the bounding box of the original SVG image. * * @return The X of the bounding box of the original SVG image. */ public static double getOrigX() { return 0.0; } /** * Returns the Y of the bounding box of the original SVG image. * * @return The Y of the bounding box of the original SVG image. */ public static double getOrigY() { return 0.0; } /** * Returns the width of the bounding box of the original SVG image. * * @return The width of the bounding box of the original SVG image. */ public static double getOrigWidth() { return 512.0; } /** * Returns the height of the bounding box of the original SVG image. * * @return The height of the bounding box of the original SVG image. */ public static double getOrigHeight() { return 512.0; } /** The current width of this resizable icon. */ private int width; /** The current height of this resizable icon. */ private int height; /** * Creates a new transcoded SVG image. It is recommended to use the * {@link #of(int, int)} method to obtain a pre-configured instance. */ public cn() { this.width = (int) getOrigWidth(); this.height = (int) getOrigHeight(); } @Override public int getIconHeight() { return height; } @Override public int getIconWidth() { return width; } @Override public void setDimension(Dimension newDimension) { this.width = newDimension.width; this.height = newDimension.height; } @Override public boolean isHiDpiAware() { return true; } @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.translate(x, y); double coef1 = (double) this.width / getOrigWidth(); double coef2 = (double) this.height / getOrigHeight(); double coef = Math.min(coef1, coef2); g2d.clipRect(0, 0, this.width, this.height); g2d.scale(coef, coef); g2d.translate(-getOrigX(), -getOrigY()); if (coef1 != coef2) { if (coef1 < coef2) { int extraDy = (int) ((getOrigWidth() - getOrigHeight()) / 2.0); g2d.translate(0, extraDy); } else { int extraDx = (int) ((getOrigHeight() - getOrigWidth()) / 2.0); g2d.translate(extraDx, 0); } } Graphics2D g2ForInner = (Graphics2D) g2d.create(); innerPaint(g2ForInner); g2ForInner.dispose(); g2d.dispose(); } /** * Returns a new instance of this icon with specified dimensions. * * @param width Required width of the icon * @param height Required height of the icon * @return A new instance of this icon with specified dimensions. */ public static NeonIcon of(int width, int height) { cn base = new cn(); base.width = width; base.height = height; return new NeonIcon(base); } /** * Returns a new {@link UIResource} instance of this icon with specified dimensions. * * @param width Required width of the icon * @param height Required height of the icon * @return A new {@link UIResource} instance of this icon with specified dimensions. */ public static NeonIconUIResource uiResourceOf(int width, int height) { cn base = new cn(); base.width = width; base.height = height; return new NeonIconUIResource(base); } }
[ "kirill.grouchnikov@gmail.com" ]
kirill.grouchnikov@gmail.com
951377447823f041741d365b60885877e25539d0
3a6529b9b9093d9bc9099bf4ea3b7b1958544636
/app/src/main/java/com/selfcompany/tuturutest/subjects/CitiesTo.java
d5cd168c0dc14b9879b40a50188163d82de24098
[]
no_license
drilion/tuturu_test
b46bd101d1f7a7a6d909133e5a60e3b9277890b0
2a8b37e585819bc1149e91af0df47805947bff80
refs/heads/master
2020-12-02T05:43:39.783730
2016-09-07T19:40:30
2016-09-07T19:40:30
67,636,245
0
0
null
null
null
null
UTF-8
Java
false
false
2,277
java
package com.selfcompany.tuturutest.subjects; import com.bignerdranch.expandablerecyclerview.Model.ParentListItem; import com.google.gson.annotations.SerializedName; import java.util.List; import io.realm.RealmList; import io.realm.RealmModel; import io.realm.RealmObject; import io.realm.annotations.PrimaryKey; /** * Created by Sergey on 04.09.2016. */ public class CitiesTo extends RealmObject implements CityDataInterface{ @SerializedName("countryTitle") private String countryTitle; @SerializedName("point") private Point point; @SerializedName("districtTitle") private String districtTitle; @SerializedName("cityId") @PrimaryKey private int cityId; @SerializedName("cityTitle") private String cityTitle; @SerializedName("regionTitle") private String regionTitle; @SerializedName("stations") private RealmList<Stations> stations; public CitiesTo(){ } @Override public void setCountryTitle(String countryTitle){ this.countryTitle = countryTitle; } @Override public String getCountryTitle(){ return this.countryTitle; } @Override public void setPoint(Point point){ this.point = point; } @Override public Point getPoint(){ return this.point; } @Override public void setDistrictTitle(String districtTitle){ this.districtTitle = districtTitle; } @Override public String getDistrictTitle(){ return this.districtTitle; } @Override public void setCityId(int cityId){ this.cityId = cityId; } @Override public int getCityId(){ return this.cityId; } @Override public void setCityTitle(String cityTitle){ this.cityTitle = cityTitle; } @Override public String getCityTitle(){ return this.cityTitle; } @Override public void setRegionTitle(String regionTitle){ this.regionTitle = regionTitle; } @Override public String getRegionTitle(){ return this.regionTitle; } @Override public void setStations(RealmList<Stations> stations){ this.stations = stations; } @Override public RealmList<Stations> getStations(){ return this.stations; } }
[ "Sergey" ]
Sergey
6a368aaddd9937a53f3815b10a8038ee5d33db5d
d3d38f40a7fa968f5e7d5095c429359083987c89
/src/test/java/com/wbs/web/rest/EntryCategoryResourceIntTest.java
1ee3b693644496e752837f6fe0065618dca22270
[]
no_license
stupant/timesheet
ee547595f54e40cd9a02c000ba70bb4b6ccf67df
fff5e75677b9d65042250866dbba61ef72b41c2e
refs/heads/master
2021-06-26T15:26:23.855027
2017-07-21T00:35:18
2017-07-21T00:35:18
93,479,860
1
2
null
2020-09-18T11:48:27
2017-06-06T05:32:58
Java
UTF-8
Java
false
false
9,690
java
package com.wbs.web.rest; import com.wbs.TimesheetApp; import com.wbs.domain.EntryCategory; import com.wbs.repository.EntryCategoryRepository; import com.wbs.web.rest.errors.ExceptionTranslator; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; import org.springframework.http.MediaType; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.hasItem; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; /** * Test class for the EntryCategoryResource REST controller. * * @see EntryCategoryResource */ @RunWith(SpringRunner.class) @SpringBootTest(classes = TimesheetApp.class) public class EntryCategoryResourceIntTest { private static final String DEFAULT_NAME = "AAAAAAAAAA"; private static final String UPDATED_NAME = "BBBBBBBBBB"; @Autowired private EntryCategoryRepository entryCategoryRepository; @Autowired private MappingJackson2HttpMessageConverter jacksonMessageConverter; @Autowired private PageableHandlerMethodArgumentResolver pageableArgumentResolver; @Autowired private ExceptionTranslator exceptionTranslator; private MockMvc restEntryCategoryMockMvc; private EntryCategory entryCategory; @Before public void setup() { MockitoAnnotations.initMocks(this); EntryCategoryResource entryCategoryResource = new EntryCategoryResource(entryCategoryRepository); this.restEntryCategoryMockMvc = MockMvcBuilders.standaloneSetup(entryCategoryResource) .setCustomArgumentResolvers(pageableArgumentResolver) .setControllerAdvice(exceptionTranslator) .setMessageConverters(jacksonMessageConverter).build(); } /** * Create an entity for this test. * * This is a static method, as tests for other entities might also need it, * if they test an entity which requires the current entity. */ public static EntryCategory createEntity() { EntryCategory entryCategory = new EntryCategory() .name(DEFAULT_NAME); return entryCategory; } @Before public void initTest() { entryCategoryRepository.deleteAll(); entryCategory = createEntity(); } @Test public void createEntryCategory() throws Exception { int databaseSizeBeforeCreate = entryCategoryRepository.findAll().size(); // Create the EntryCategory restEntryCategoryMockMvc.perform(post("/api/entry-categories") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entryCategory))) .andExpect(status().isCreated()); // Validate the EntryCategory in the database List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeCreate + 1); EntryCategory testEntryCategory = entryCategoryList.get(entryCategoryList.size() - 1); assertThat(testEntryCategory.getName()).isEqualTo(DEFAULT_NAME); } @Test public void createEntryCategoryWithExistingId() throws Exception { int databaseSizeBeforeCreate = entryCategoryRepository.findAll().size(); // Create the EntryCategory with an existing ID entryCategory.setId("existing_id"); // An entity with an existing ID cannot be created, so this API call must fail restEntryCategoryMockMvc.perform(post("/api/entry-categories") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entryCategory))) .andExpect(status().isBadRequest()); // Validate the Alice in the database List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeCreate); } @Test public void checkNameIsRequired() throws Exception { int databaseSizeBeforeTest = entryCategoryRepository.findAll().size(); // set the field null entryCategory.setName(null); // Create the EntryCategory, which fails. restEntryCategoryMockMvc.perform(post("/api/entry-categories") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entryCategory))) .andExpect(status().isBadRequest()); List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeTest); } @Test public void getAllEntryCategories() throws Exception { // Initialize the database entryCategoryRepository.save(entryCategory); // Get all the entryCategoryList restEntryCategoryMockMvc.perform(get("/api/entry-categories?sort=id,desc")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.[*].id").value(hasItem(entryCategory.getId()))) .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString()))); } @Test public void getEntryCategory() throws Exception { // Initialize the database entryCategoryRepository.save(entryCategory); // Get the entryCategory restEntryCategoryMockMvc.perform(get("/api/entry-categories/{id}", entryCategory.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(entryCategory.getId())) .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString())); } @Test public void getNonExistingEntryCategory() throws Exception { // Get the entryCategory restEntryCategoryMockMvc.perform(get("/api/entry-categories/{id}", Long.MAX_VALUE)) .andExpect(status().isNotFound()); } @Test public void updateEntryCategory() throws Exception { // Initialize the database entryCategoryRepository.save(entryCategory); int databaseSizeBeforeUpdate = entryCategoryRepository.findAll().size(); // Update the entryCategory EntryCategory updatedEntryCategory = entryCategoryRepository.findOne(entryCategory.getId()); updatedEntryCategory .name(UPDATED_NAME); restEntryCategoryMockMvc.perform(put("/api/entry-categories") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(updatedEntryCategory))) .andExpect(status().isOk()); // Validate the EntryCategory in the database List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeUpdate); EntryCategory testEntryCategory = entryCategoryList.get(entryCategoryList.size() - 1); assertThat(testEntryCategory.getName()).isEqualTo(UPDATED_NAME); } @Test public void updateNonExistingEntryCategory() throws Exception { int databaseSizeBeforeUpdate = entryCategoryRepository.findAll().size(); // Create the EntryCategory // If the entity doesn't have an ID, it will be created instead of just being updated restEntryCategoryMockMvc.perform(put("/api/entry-categories") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(entryCategory))) .andExpect(status().isCreated()); // Validate the EntryCategory in the database List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeUpdate + 1); } @Test public void deleteEntryCategory() throws Exception { // Initialize the database entryCategoryRepository.save(entryCategory); int databaseSizeBeforeDelete = entryCategoryRepository.findAll().size(); // Get the entryCategory restEntryCategoryMockMvc.perform(delete("/api/entry-categories/{id}", entryCategory.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<EntryCategory> entryCategoryList = entryCategoryRepository.findAll(); assertThat(entryCategoryList).hasSize(databaseSizeBeforeDelete - 1); } @Test public void equalsVerifier() throws Exception { TestUtil.equalsVerifier(EntryCategory.class); EntryCategory entryCategory1 = new EntryCategory(); entryCategory1.setId("id1"); EntryCategory entryCategory2 = new EntryCategory(); entryCategory2.setId(entryCategory1.getId()); assertThat(entryCategory1).isEqualTo(entryCategory2); entryCategory2.setId("id2"); assertThat(entryCategory1).isNotEqualTo(entryCategory2); entryCategory1.setId(null); assertThat(entryCategory1).isNotEqualTo(entryCategory2); } }
[ "nguyendinhtrung141@gmail.com" ]
nguyendinhtrung141@gmail.com
de8ef7ac836c307db2141bd6d198420c3d84fb04
0deb56bdcf91ca229bf61da0cf3cf3406223fb2c
/SmartLife-webrtc/sdk/WhiteBoardLibWrapper/SVGLib/src/main/java/com/coocaa/svg/parser/SvgXmlPathParser.java
3e74930cdcd5d45f237a56780d63b96199fca879
[]
no_license
soulcure/airplay
2ceb0a6707b2d4a69f85dd091b797dcb6f2c9d46
37dd3a890148a708d8aa6f95ac84355606af6a18
refs/heads/master
2023-04-11T03:49:15.246072
2021-04-16T09:15:03
2021-04-16T09:15:03
357,804,553
1
2
null
null
null
null
UTF-8
Java
false
false
2,597
java
/* * Copyright (C) 2015 Jorge Castillo Pérez * * 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.coocaa.svg.parser; import android.graphics.Path; import android.os.SystemClock; import android.util.Log; import com.coocaa.svg.data.SvgPathNode; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; /** * Entity to parse Svg paths to {@link Path} items understandable by the Android SDK. Obtained * from romainnurik Muzei implementation to avoid rewriting . * * @author romainnurik */ public class SvgXmlPathParser { private DocumentBuilder docBuilder; private Document mDoc; String TAG = "SVG-PathParser"; public SvgXmlPathParser() { try { docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } } public SvgPathNode parse(String data) { Log.d(TAG, "start parse : " + data); long start = SystemClock.uptimeMillis(); InputStream is = null; try { is = new ByteArrayInputStream(data.getBytes("utf-8")); mDoc = docBuilder.parse(is); } catch (Exception e) { e.printStackTrace(); } finally { if(is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } if(mDoc == null) { return null; } Element element = mDoc.getDocumentElement(); SvgPathNode node = new SvgPathNode(); NamedNodeMap map = element.getAttributes(); node.tagName = element.getTagName(); if(map != null) { node.parse(map); } return node; } }
[ "chenqiongyao@coocaa.com" ]
chenqiongyao@coocaa.com
e948d8301b1f25e620f2e4e8904656cce719118b
465ec97b801fbae0b7c4373c9bcd0374b0365310
/post/src/main/java/com/exercise/post/LocalDateTimeAttributeConverter.java
ef25e5c968eaa432d2f4c8976408791aa19aad99
[]
no_license
Shirankl/postsProjRep
6ee07becfd5345d078fd845866dabe458049c8b8
21435e8c2ce0858dfdcc6d3690e3e87dccfb55ab
refs/heads/master
2020-07-13T07:00:49.732072
2019-08-28T21:41:05
2019-08-28T21:41:05
205,025,692
0
0
null
null
null
null
UTF-8
Java
false
false
622
java
package com.exercise.post; import java.sql.Timestamp; import java.time.LocalDateTime; import javax.persistence.AttributeConverter; import javax.persistence.Converter; @Converter(autoApply = true) public class LocalDateTimeAttributeConverter implements AttributeConverter<LocalDateTime, Timestamp> { @Override public Timestamp convertToDatabaseColumn(LocalDateTime locDateTime) { return locDateTime == null ? null : Timestamp.valueOf(locDateTime); } @Override public LocalDateTime convertToEntityAttribute(Timestamp sqlTimestamp) { return sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime(); } }
[ "shiran@wishi.me" ]
shiran@wishi.me
9e185289c09ad5f73dc191a2069a9c8a2c276662
64747cf8919c81c4cbab6256b0f5d785256d822b
/src/com/lidroid/xutils/db/converter/DoubleColumnConverter.java
8536e720524a30d8876bce7d9cad0139f8124fed
[]
no_license
scv1990/Pary
ffc0853f472a61832b06bcc02ed561a92700c9d1
062462bdd2bf0035ab893f1d20eec916bdb8f4d1
refs/heads/master
2020-04-06T07:11:43.843935
2016-08-29T03:40:59
2016-08-29T03:40:59
64,647,352
0
0
null
null
null
null
UTF-8
Java
false
false
822
java
package com.lidroid.xutils.db.converter; import android.database.Cursor; import android.text.TextUtils; import com.lidroid.xutils.db.sqlite.ColumnDbType; /** * Author: wyouflf * Date: 13-11-4 * Time: 下午10:51 */ public class DoubleColumnConverter implements ColumnConverter<Double> { @Override public Double getFieldValue(final Cursor cursor, int index) { return cursor.isNull(index) ? null : cursor.getDouble(index); } @Override public Double getFieldValue(String fieldStringValue) { if (TextUtils.isEmpty(fieldStringValue)) return null; return Double.valueOf(fieldStringValue); } @Override public Object fieldValue2ColumnValue(Double fieldValue) { return fieldValue; } @Override public ColumnDbType getColumnDbType() { return ColumnDbType.REAL; } }
[ "fuqinhq@163.com" ]
fuqinhq@163.com
16b5a54d8d53c270bb37ebdf258535a3bdb1d577
55298bc5fee41900de3371b104d3ca9514e13e3c
/ControlServer/src/controlserver/mainServer.java
689398dae25daf4b44a6d15ecc26596661a3d0ba
[]
no_license
SmithYan/ControlServer
a0723de07ac910882155bddd49ed3c9ad5969325
3736ae68682f96d049d049d990d9645327819f70
refs/heads/master
2020-03-25T15:11:28.454501
2018-08-09T14:19:31
2018-08-09T14:19:31
143,870,373
0
0
null
null
null
null
GB18030
Java
false
false
13,161
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 controlserver; import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.ActionEvent; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JTextArea; /** * 服务器端控制 * * @author wy521 */ public class mainServer extends javax.swing.JFrame { JDesktopPane desktopPane; ServerSocket[] ss = new ServerSocket[20]; ServerToOneClient stoc; Socket socket; private static final long serialVersionUID = 1L; /** * Creates new form mainServer */ public mainServer() { initComponents(); //声明容器指向this.getContentPane() Container contentPane = this.getContentPane(); //设置容器中的排列方式 contentPane.setLayout(new BorderLayout()); /*建立一个新的JDesktopPane并加入于contentPane中 */ desktopPane = new JDesktopPane(); contentPane.add(desktopPane); } /** * 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() { jMenuItem1 = new javax.swing.JMenuItem(); jButton1 = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jMenuBar = new javax.swing.JMenuBar(); jMenuConnect = new javax.swing.JMenu(); jMenuItemConnectAll = new javax.swing.JMenuItem(); jMenuItemConnectSome = new javax.swing.JMenuItem(); jMenuItemSaveIPAndPort = new javax.swing.JMenuItem(); jMenuNewJFrame = new javax.swing.JMenu(); jMenuItemJFrameAll = new javax.swing.JMenuItem(); jMenuItemJFrameOne = new javax.swing.JMenuItem(); jMenuItemJFrameSome = new javax.swing.JMenuItem(); jMenuCloseJFrame = new javax.swing.JMenu(); jMenuItemCloseAll = new javax.swing.JMenuItem(); jMenuItemCloseSome = new javax.swing.JMenuItem(); jMenuItemExit = new javax.swing.JMenuItem(); jMenuJFrameHelp = new javax.swing.JMenu(); jMenuItem1.setText("jMenuItem1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("ServerControl"); setSize(new java.awt.Dimension(1000, 618)); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("jButton2"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jMenuBar.setMinimumSize(new java.awt.Dimension(70, 40)); jMenuBar.setName(""); // NOI18N jMenuConnect.setText("连接"); jMenuItemConnectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK)); jMenuItemConnectAll.setText("连接所有客户端"); jMenuItemConnectAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemConnectAllActionPerformed(evt); } }); jMenuConnect.add(jMenuItemConnectAll); jMenuItemConnectSome.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK)); jMenuItemConnectSome.setText("连接单个或多个客户端"); jMenuItemConnectSome.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemConnectSomeActionPerformed(evt); } }); jMenuConnect.add(jMenuItemConnectSome); jMenuItemSaveIPAndPort.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemSaveIPAndPort.setText("保存所有IP以及端口到本地"); jMenuConnect.add(jMenuItemSaveIPAndPort); jMenuBar.add(jMenuConnect); jMenuNewJFrame.setText("新建"); jMenuItemJFrameAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK)); jMenuItemJFrameAll.setText("打开所有客户端控制窗口"); jMenuNewJFrame.add(jMenuItemJFrameAll); jMenuItemJFrameOne.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK)); jMenuItemJFrameOne.setText("打开单个客户端控制窗口"); jMenuNewJFrame.add(jMenuItemJFrameOne); jMenuItemJFrameSome.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemJFrameSome.setText("打开一组客户端控制窗口"); jMenuNewJFrame.add(jMenuItemJFrameSome); jMenuBar.add(jMenuNewJFrame); jMenuCloseJFrame.setText("关闭"); jMenuItemCloseAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemCloseAll.setText("关闭所有客户端"); jMenuCloseJFrame.add(jMenuItemCloseAll); jMenuItemCloseSome.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemCloseSome.setText("关闭单个或多个客户端"); jMenuCloseJFrame.add(jMenuItemCloseSome); jMenuItemExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK)); jMenuItemExit.setText("退出程序"); jMenuItemExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemExitActionPerformed(evt); } }); jMenuCloseJFrame.add(jMenuItemExit); jMenuBar.add(jMenuCloseJFrame); jMenuJFrameHelp.setText("帮助"); jMenuBar.add(jMenuJFrameHelp); setJMenuBar(jMenuBar); 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(67, 67, 67) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1) .addGroup(layout.createSequentialGroup() .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(47, 47, 47) .addComponent(jButton2))) .addContainerGap(364, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(82, 82, 82) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2)) .addContainerGap(318, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jMenuItemExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemExitActionPerformed System.exit(0); }//GEN-LAST:event_jMenuItemExitActionPerformed private void jMenuItemConnectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConnectAllActionPerformed }//GEN-LAST:event_jMenuItemConnectAllActionPerformed private void jMenuItemConnectSomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemConnectSomeActionPerformed JInternalFrameSubformTemplate j = new JInternalFrameSubformTemplate("连接客户端", desktopPane, true); j.setVisible(true); }//GEN-LAST:event_jMenuItemConnectSomeActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try { ss[0] = new ServerSocket(8888); while (true) { socket = ss[0].accept(); try { stoc = new ServerToOneClient(socket); stoc.sendToClient("lianjiechenggong", socket); } catch (IOException e) { ss[0].close(); } } } catch (IOException ex) { try { ss[0].close(); } catch (IOException ex1) { } } finally { try { ss[0].close(); } catch (IOException ex) { } } }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed try { stoc.sendToClient(this.jTextField1.getText(), socket); } catch (IOException ex) { } }//GEN-LAST:event_jButton2ActionPerformed /** * @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(mainServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(mainServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(mainServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(mainServer.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 mainServer().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JMenuBar jMenuBar; private javax.swing.JMenu jMenuCloseJFrame; private javax.swing.JMenu jMenuConnect; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItemCloseAll; private javax.swing.JMenuItem jMenuItemCloseSome; private javax.swing.JMenuItem jMenuItemConnectAll; private javax.swing.JMenuItem jMenuItemConnectSome; private javax.swing.JMenuItem jMenuItemExit; private javax.swing.JMenuItem jMenuItemJFrameAll; private javax.swing.JMenuItem jMenuItemJFrameOne; private javax.swing.JMenuItem jMenuItemJFrameSome; private javax.swing.JMenuItem jMenuItemSaveIPAndPort; private javax.swing.JMenu jMenuJFrameHelp; private javax.swing.JMenu jMenuNewJFrame; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables }
[ "wy521wywy@163.com" ]
wy521wywy@163.com
af814a64614b28c96ea732e3922074a63b8fd0d4
ad252fb1c0b549154c8d1064b2febd1232573a5e
/service-user/src/main/java/com/example/user/domain/UserActivity.java
a1a9bac9ebb69342cb8c25eaa2a666c1ff2213a5
[]
no_license
bigpig245/iCommece
ea1ab785d301554e57f745837c5763e92bd7f0b3
e40cad2f6aaa4f47d1bc8bbc326e8d66753aa5c1
refs/heads/main
2023-03-12T23:02:08.339252
2021-02-25T11:44:11
2021-02-25T16:11:30
342,224,625
0
0
null
null
null
null
UTF-8
Java
false
false
1,974
java
package com.example.user.domain; import com.example.user.dto.enumeration.Action; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; import java.time.LocalDateTime; @Entity @Table(name = "user_activity", schema = "service_user") public class UserActivity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence_c_generator") @GenericGenerator( name = "sequence_c_generator", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = { @org.hibernate.annotations.Parameter(name = "sequence_name", value = "service_user.user_activity_id_seq"), @org.hibernate.annotations.Parameter(name = "initial_value", value = "1000"), @org.hibernate.annotations.Parameter(name = "increment_size", value = "1") } ) private Long id; @Column(name = "action", nullable = false) @Enumerated(EnumType.STRING) private Action action; @Column(name = "url", nullable = false) private String url; @Column(name = "query") private String query; @Column(name = "trackedDate", nullable = false) private LocalDateTime trackedDate; @Column(name = "user_id", nullable = false) private Long userId; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Action getAction() { return action; } public void setAction(Action action) { this.action = action; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getQuery() { return query; } public void setQuery(String query) { this.query = query; } public LocalDateTime getTrackedDate() { return trackedDate; } public void setTrackedDate(LocalDateTime trackedDate) { this.trackedDate = trackedDate; } public Long getUserId() { return userId; } public void setUserId(Long userId) { this.userId = userId; } }
[ "trangthinguyen@qasymphony.com" ]
trangthinguyen@qasymphony.com
ef8cd6332fd032c00737cbd2f97e19b167c6e077
6ba746c5d03c7c58d5687fcce3bf7ebbf43422f4
/src/MainFrame.java
efcc1d22efe16fd481bab5280e5c7ba9bf85de3f
[]
no_license
bhumikasaivamani/AIProject
b78ea998096d39dab9243b2b7d6ee0457b4f4a80
8f5db61c5c95344e574dd179a8e4f33c62c6cac7
refs/heads/master
2021-01-01T05:31:40.437723
2014-05-06T07:39:12
2014-05-06T07:39:12
19,421,640
0
1
null
null
null
null
UTF-8
Java
false
false
14,109
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. */ /** * * @author Bhumika */ public class MainFrame extends javax.swing.JFrame implements Runnable { public GUIThread parent; /** * Creates new form MainFrame */ public MainFrame() { initComponents(); } public MainFrame(GUIThread o) { initComponents(); buttonPressed = false; parent = o; } /** * 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") private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jPanel4 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jPanel5 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setName("TopicPanel"); // NOI18N jLabel1.setText(" DISEASE/SYMPTOM/DRUG ONTOLOGY - KNOWLEDGE REPRESENTATION"); jLabel1.setToolTipText(""); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(32, 32, 32) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 651, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(61, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) .addContainerGap()) ); jLabel2.setText("WELCOME"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 495, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE) .addContainerGap()) ); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 497, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(22, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) ); jButton1.setText("Submit"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(76, 76, 76) .addComponent(jButton1) .addContainerGap(88, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap(20, Short.MAX_VALUE) .addComponent(jButton1)) ); jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jList1ValueChanged(evt); } }); jScrollPane2.setViewportView(jList1); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 295, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(236, 236, 236) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(21, 21, 21) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel1.getAccessibleContext().setAccessibleName(""); pack(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //String text=jTextArea1.getText(); //System.out.println("BP"); buttonPressed = true; } /** * @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(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainFrame.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 MainFrame().setVisible(true); } }); } private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) { // TODO add your handling code here: jTextArea1.setText(jList1.getSelectedValue()+","); } // Variables declaration - do not modify public javax.swing.JButton jButton1; public javax.swing.JLabel jLabel1; public javax.swing.JLabel jLabel2; public javax.swing.JPanel jPanel1; public javax.swing.JPanel jPanel2; public javax.swing.JPanel jPanel3; public javax.swing.JPanel jPanel4; public javax.swing.JPanel jPanel5; public javax.swing.JScrollPane jScrollPane1; public javax.swing.JScrollPane jScrollPane2; public javax.swing.JTextArea jTextArea1; public javax.swing.JList jList1; public boolean buttonPressed; // End of variables declaration @Override public void run() { // TODO Auto-generated method stub while(true) { System.out.print(""); while(!buttonPressed) { System.out.print(""); } parent.bp = true; buttonPressed = false; } } }
[ "bhumika.blossom@gmail.com" ]
bhumika.blossom@gmail.com
a2a7e5f7485bd8744efd765ed27d0bf02dbf76cc
a8ee42ca3f1fcb7d841c9c0908e73614c23eeb02
/android/MyApplication/app/src/main/java/com/mobile/zxw/myapplication/until/Utils.java
56b537b7568da28dce828dfa3c9e1f2fdefbf7e8
[]
no_license
mateng04/ZXW
2d4f1ee3f8f06038d396512b33d3a56ea98edbe4
405de0af6bf16ff2b40cc4ecece1fbfb9b77b836
refs/heads/master
2020-03-19T07:35:54.518753
2019-06-27T08:18:07
2019-06-27T08:18:07
136,129,358
0
0
null
null
null
null
UTF-8
Java
false
false
3,858
java
package com.mobile.zxw.myapplication.until; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.AssetManager; import android.support.v7.app.AlertDialog; import android.text.TextUtils; import com.mobile.zxw.myapplication.activity.LoginPageActivity; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Locale; /** */ public class Utils { public static String readAssetsTXT(Context context, String fileName) { try { AssetManager assetManager = context.getAssets();//获取assets文件下的资源 InputStream is = assetManager.open(fileName); //打开 byte[] bytes = new byte[1024]; int leng; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((leng = is.read(bytes)) != -1) { baos.write(bytes, 0, leng); } return new String(baos.toByteArray()); } catch (IOException e) { e.printStackTrace(); return null; } } public static String getTime() { return new SimpleDateFormat("MM-dd HH:mm", Locale.CHINA).format(new Date()); } public static boolean checkname(String name) { int n = 0; for(int i = 0; i < name.length(); i++) { n = (int)name.charAt(i); if(!(19968 <= n && n <40869)) { return false; } } return true; } public static boolean checkString(String content) { boolean result = content.matches("[a-zA-Z0-9]+");//判断英文和数字 return result; } public static boolean isMobileNO(String mobiles) { String telRegex = "[1][3456789]\\d{9}"; // "[1]"代表第1位为数字1,"[3578]"代表第二位可以为3、5、8中的一个,"\\d{9}"代表后面是可以是0~9的数字,有9位。 if (TextUtils.isEmpty(mobiles)) { return false; } else return mobiles.matches(telRegex); } public static void getLoginDialog(Context context){ AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("提示" ) ; builder.setMessage("你还没登录或注册,请登录或注册" ) ; builder.setPositiveButton("确定",new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { context.startActivity(new Intent(context, LoginPageActivity.class)); } }); builder.setNegativeButton("取消", null); builder.show(); } /** * 判断 用户是否安装QQ客户端 */ public static boolean isQQClientAvailable(Context context) { final PackageManager packageManager = context.getPackageManager(); List<PackageInfo> pinfo = packageManager.getInstalledPackages(0); if (pinfo != null) { for (int i = 0; i < pinfo.size(); i++) { String pn = pinfo.get(i).packageName; if (pn.equalsIgnoreCase("com.tencent.qqlite") || pn.equalsIgnoreCase("com.tencent.mobileqq")) { return true; } } } return false; } /** * 判断 Uri是否有效 */ public static boolean isValidIntent(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); return !activities.isEmpty(); } }
[ "307003873@qq.com" ]
307003873@qq.com
e534d49c7f98342187015debf410d1f6e79ac64d
815d640f58bd19a8e1cf93b1beecb707fbd326b1
/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/monitor/AbstractMonitor.java
6e032dc366c1ff5db836dba7e53874eba36ca0a7
[]
no_license
smipo/spring-data-mongodb-2.1.18.RELEASE
5ebc35841039e4135ade81b7f05490c76f716354
36b32e7f67e7d31caea6d3169da902934821cbb5
refs/heads/main
2023-05-03T08:06:58.949879
2021-05-08T11:01:30
2021-05-08T11:01:30
365,442,705
0
0
null
null
null
null
UTF-8
Java
false
false
1,451
java
/* * Copyright 2002-2020 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 * * https://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.data.mongodb.monitor; import org.bson.Document; import com.mongodb.MongoClient; import com.mongodb.client.MongoDatabase; /** * Base class to encapsulate common configuration settings when connecting to a database * * @author Mark Pollack * @author Oliver Gierke * @author Christoph Strobl */ public abstract class AbstractMonitor { private final MongoClient mongoClient; protected AbstractMonitor(MongoClient mongoClient) { this.mongoClient = mongoClient; } public Document getServerStatus() { return getDb("admin").runCommand(new Document("serverStatus", 1).append("rangeDeleter", 1).append("repl", 1)); } public MongoDatabase getDb(String databaseName) { return mongoClient.getDatabase(databaseName); } protected MongoClient getMongoClient() { return mongoClient; } }
[ "liushuaishuai@rr.tv" ]
liushuaishuai@rr.tv
32436b9737699b389217827b85de67e7d85bcd3b
003d4180a02583db70de358a5766f8b7ad5666a2
/src/main/java/cn/sinjinsong/server/model/Cookie.java
8ab3fc123e350e8cfab41fb34b0980d1cc629600
[]
no_license
lisx/HTTPServer
b011568d69dfd21a973deea48a242befdc26307d
3ef8f07686e602a27c97e5da3ac4ffe1a975c894
refs/heads/master
2021-05-15T03:37:18.090418
2017-07-21T15:20:42
2017-07-21T15:20:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
291
java
package cn.sinjinsong.server.model; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; /** * Created by SinjinSong on 2017/7/21. */ @Data @NoArgsConstructor @AllArgsConstructor public class Cookie { private String key; private String value; }
[ "151070063@smail.nju.edu.cn" ]
151070063@smail.nju.edu.cn
a60a1ce934f30f72b50f085534a877f53c27e5f1
69826abc7c96a6df13e1a7afcdf7e5ae4e389f8f
/src/main/java/com/patrykkosieradzki/quizletify/api/google/GoogleTranslator.java
5446521f3965936b3f92ecf47cf53fc636ab0cb9
[ "Apache-2.0" ]
permissive
k0siara/Quizletify-Desktop
f9735b16d33ac71cf9496ee45f64f80b2fb7fec2
eb12a643b64d3b817376bb87e42223dbb4038d7f
refs/heads/master
2020-05-27T21:24:19.593732
2017-03-02T13:45:58
2017-03-02T13:45:58
65,403,916
0
0
null
null
null
null
UTF-8
Java
false
false
4,380
java
package com.patrykkosieradzki.quizletify.api.google; import org.json.JSONArray; import org.json.JSONObject; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; public class GoogleTranslator { private final static String API_KEY = ""; private final int TRANSLATIONS_AT_ONCE_LIMIT = 50; public static String translationFromText(String text, Language source, Language target) { try { text = URLEncoder.encode(text, "UTF-8"); URL url = new URL("https://www.googleapis.com/language/translate/v2?" + "key=" + API_KEY + "&source=" + source + "&target=" + target + "&q=" + text); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); if (connection.getResponseCode() != 200) throw new GoogleException("Wrong API Key"); String line; BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream())); StringBuilder builder = new StringBuilder(); while ((line = reader.readLine()) != null) builder.append(line).append("\n"); JSONObject json = new JSONObject(builder.toString()); String translation = json .getJSONObject("data") .getJSONArray("translations") .getJSONObject(0) .getString("translatedText"); return translation; } catch (Exception e) { e.printStackTrace(); } return null; } public ArrayList<String> translationsFromArray(ArrayList<String> texts, Language source, Language target) throws IOException, GoogleException { ArrayList<String> translations = new ArrayList<String>(); ArrayList<String> textsToTranslate = new ArrayList<String>(); for (int i = 0; i < texts.size(); i++) { if ((i % TRANSLATIONS_AT_ONCE_LIMIT == 0 && i != 0) || i == texts.size() - 1) { StringBuilder URL = new StringBuilder("https://www.googleapis.com/language/translate/v2?" + "key=" + API_KEY + "&source=" + source + "&target=" + target); for (String text : textsToTranslate) { URL.append("&q=" + text); } URLEncoder.encode(URL.toString(), "UTF-8"); URL url = new URL(URL.toString()); HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); if (connection.getResponseCode() != 200) throw new GoogleException("Wrong API Key"); String line; BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream())); StringBuilder builder = new StringBuilder(); while ((line = reader.readLine()) != null) builder.append(line).append("\n"); JSONArray jsonTranslations = new JSONObject(builder.toString()) .getJSONObject("data") .getJSONArray("translations"); for(int j = 0; j < jsonTranslations.length(); j++) { translations.add(jsonTranslations .getJSONObject(j) .getString("translatedText")); } textsToTranslate.clear(); textsToTranslate.add(texts.get(i)); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } else { if (i == texts.size() - 2) { textsToTranslate.add(texts.get(i)); textsToTranslate.add(texts.get(i + 1)); } else textsToTranslate.add(texts.get(i)); } } return translations; } }
[ "patryk.kosieradzki@gmail.com" ]
patryk.kosieradzki@gmail.com
bdd903e85d43955dbe80485211e1f0d625aed765
05ac4f770906fe39a9772894165cdd42a291b5d1
/Problema1/src/problema1/Problema1.java
bfcf6815b41b254672a7ae93c339335c5220669b
[]
no_license
GabrielSalasR/Problema-1
20fa0e6fc7560a8bf451ac32c3eea223319e1a59
5c0218716e1d31dac93898d1f66d15839198f15f
refs/heads/master
2021-01-10T16:43:34.646344
2016-03-12T00:59:38
2016-03-12T00:59:38
53,621,427
0
0
null
null
null
null
UTF-8
Java
false
false
488
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 problema1; /** * * @author Gabo */ public class Problema1 { /** * @param args the command line arguments */ public static void main(String[] args) { for (int i = 0; i < 100; i++) { System.out.println(i + 1); } } }
[ "Gabo@Gabriel" ]
Gabo@Gabriel
cfcf1b208a18358dffa41daf228fc2ed506a8890
546d29e1adc03f7f6d98d12ba93eef2a3401d15f
/src/main/java/examples/SynchronizedFactorizer.java
d50ebfd923488291450841f3923e663a82aeddf4
[]
no_license
gailo22/concurrency
9d8841596157c9fc1148a1489a7c75271b27e951
7bc99f6ff75c6b9f34c416a24ffe41c6d86dfc7a
refs/heads/master
2021-01-15T17:08:03.074512
2014-06-16T03:44:10
2014-06-16T03:44:10
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,206
java
package examples; import java.math.BigInteger; import javax.servlet.*; import annotations.*; /** * SynchronizedFactorizer * <p/> * Servlet that caches last result, but with unnacceptably poor concurrency * * @author Brian Goetz and Tim Peierls */ @ThreadSafe public class SynchronizedFactorizer extends GenericServlet implements Servlet { @GuardedBy("this") private BigInteger lastNumber; @GuardedBy("this") private BigInteger[] lastFactors; public synchronized void service(ServletRequest req, ServletResponse resp) { BigInteger i = extractFromRequest(req); if (i.equals(lastNumber)) encodeIntoResponse(resp, lastFactors); else { BigInteger[] factors = factor(i); lastNumber = i; lastFactors = factors; encodeIntoResponse(resp, factors); } } void encodeIntoResponse(ServletResponse resp, BigInteger[] factors) { } BigInteger extractFromRequest(ServletRequest req) { return new BigInteger("7"); } BigInteger[] factor(BigInteger i) { // Doesn't really factor return new BigInteger[]{i}; } }
[ "yidao620@gmail.com" ]
yidao620@gmail.com
737a69007428577d2cdf072eff7f586b02401822
c47c18cf944d7ed70e3bcd8023673868449111b6
/src/models/Course.java
f88e8b8eb876c5b97a92ba8a000392f24cfc91a9
[]
no_license
sochetanie/JavaOracleSchoolManagmentSystem
a777e6d8635037206dde40503f1f39a9754985df
1afd561d5c7ec5eb20d4055bacacd4beecf15808
refs/heads/master
2020-03-27T05:31:12.084664
2018-08-24T18:45:50
2018-08-24T18:45:50
146,027,864
2
0
null
null
null
null
UTF-8
Java
false
false
758
java
package models; public class Course { private int course_id; private String course_name; private Double minimum_gpa; public Course(int course_id, String course_name, Double minimum_gpa) { this.course_id = course_id; this.course_name = course_name; this.minimum_gpa = minimum_gpa; } public Course() {} public int getCourse_id() { return course_id; } public void setCourse_id(int course_id) { this.course_id = course_id; } public String getCourse_name() { return course_name; } public void setCourse_name(String course_name) { this.course_name = course_name; } public Double getMinimum_gpa() { return minimum_gpa; } public void setMinimum_gpa(Double minimum_gpa) { this.minimum_gpa = minimum_gpa; } }
[ "github email address" ]
github email address
17083933a214563564b6b8631fbd61c9873085a0
676fbc9262e23d935bcde57b78c8ac9f74c0f10b
/guimall-member/src/main/java/com/atguigu/glimall/member/service/impl/MemberServiceImpl.java
6e2c9b63eb94b6373867c2efcf20236d96401aa2
[ "Apache-2.0" ]
permissive
Wesley-D-Wills/glimail
10d8c68220e5c75d4fb5532df11401f571c5c90c
c3e064ac513e2fa058b916a4d4e6c0769e42f00d
refs/heads/main
2023-03-19T21:52:09.094656
2021-03-08T15:27:11
2021-03-08T15:27:11
338,297,219
0
0
null
null
null
null
UTF-8
Java
false
false
969
java
package com.atguigu.glimall.member.service.impl; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.atguigu.common.utils.PageUtils; import com.atguigu.common.utils.Query; import com.atguigu.glimall.member.dao.MemberDao; import com.atguigu.glimall.member.entity.MemberEntity; import com.atguigu.glimall.member.service.MemberService; @Service("memberService") public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> implements MemberService { @Override public PageUtils queryPage(Map<String, Object> params) { IPage<MemberEntity> page = this.page( new Query<MemberEntity>().getPage(params), new QueryWrapper<MemberEntity>() ); return new PageUtils(page); } }
[ "819269647@qq.com" ]
819269647@qq.com
a9b200bfc27be571155a316fd9fc0bbaccf07c97
c78e8338af6575af291754da1f51e0bccd00521d
/dev-timeline-chat/src/main/java/com/sky7th/devtimeline/chat/domain/chattingMessage/dto/ChattingUserResponseDto.java
ea2c7210dce7336ed4dee7e09e9c897f5219260c
[]
no_license
sky7th/dev-timeline
0099153c440ae15dbebb1fa089c91b06e960d239
f46fc6cd37a9ef85fa61d42cdad3499466793e56
refs/heads/master
2023-04-08T23:55:49.860902
2021-04-19T16:33:28
2021-04-19T16:33:28
250,259,244
7
1
null
2020-11-25T06:47:49
2020-03-26T12:59:05
Java
UTF-8
Java
false
false
625
java
package com.sky7th.devtimeline.chat.domain.chattingMessage.dto; import com.sky7th.devtimeline.user.domain.User; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; @AllArgsConstructor @NoArgsConstructor @Getter @ToString public class ChattingUserResponseDto implements Serializable { private Long userId; private String name; private String imageUrl; public static ChattingUserResponseDto of(User entity) { return new ChattingUserResponseDto(entity.getId(), entity.getName(), entity.getImageUrl()); } }
[ "xoghk0321@gmail.com" ]
xoghk0321@gmail.com
fb80f4e13c5c24809c52c2c62b750499bdde9a28
2dee94131eba7a7001d86a2314e335b8593d878b
/app/src/androidTest/java/com/bawei/demo_022601/ExampleInstrumentedTest.java
4abac2f25c352ea398220a24ba3ff4e21ee42b6f
[]
no_license
lccmyt/Demo_022601
1265c76f6d1ca6996bcdb4fcab51640f43eae13f
447ce084e6d648863512485d017d42ee7b27cfdd
refs/heads/master
2021-02-04T22:12:25.246377
2020-02-28T08:35:13
2020-02-28T08:35:13
243,715,023
0
0
null
null
null
null
UTF-8
Java
false
false
713
java
package com.bawei.demo_022601; import android.content.Context; import androidx.test.InstrumentationRegistry; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.bawei.demo_022601", appContext.getPackageName()); } }
[ "1072535025@qq.com" ]
1072535025@qq.com
af2fffbd4357e03993c738598271399631069b90
c605ed5881b44fe114fca2d4c5e482d7b3ddf9df
/java/GatewayController/src/org/alljoyn/gatewaycontroller/sdk/RemotedApp.java
8d5887cfe8b732b9d19d05216d420998668d29dd
[]
no_license
alljoyn/gateway-gwagent
6c90d74067bb53febf2635ea7f7013edc136892c
ce65eec48edcd9f16834dcef58e0e1c7b4519663
refs/heads/master
2021-09-11T12:35:32.882379
2018-04-06T21:46:35
2018-04-06T21:46:35
112,537,196
0
0
null
null
null
null
UTF-8
Java
false
false
4,432
java
/****************************************************************************** * Copyright (c) 2014, AllSeen Alliance. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************************/ package org.alljoyn.gatewaycontroller.sdk; import java.util.List; import java.util.UUID; /** * The application that may be reached by the Gateway Connector Application via * the configured interfaces and object paths */ public class RemotedApp extends AnnouncedApp { /** * Configuration of the object paths and interfaces that are used by the * Gateway Connector Application to reach this remoted application */ private final List<RuleObjectDescription> ruleObjDescriptions; /** * Constructor * * @param appName * The name of the application * @param appId * The application id * @param deviceName * The name of the device * @param deviceId * The device id * @param ruleObjDescriptions * object path and interfaces that are used for {@link AclRules} creation * @throws IllegalArgumentException * If bad arguments have been received */ public RemotedApp(String appName, UUID appId, String deviceName, String deviceId, List<RuleObjectDescription> ruleObjDescriptions) { super(null, appName, appId, deviceName, deviceId); if (deviceId == null || deviceId.length() == 0) { throw new IllegalArgumentException("DeviceId is undefined"); } if (deviceName == null || deviceName.length() == 0) { throw new IllegalArgumentException("DeviceName is undefined"); } if (appId == null) { throw new IllegalArgumentException("AppId is undefined"); } if (appName == null || appName.length() == 0) { throw new IllegalArgumentException("AppName is undefined"); } if (ruleObjDescriptions == null) { throw new IllegalArgumentException("ruleObjDescriptions is undefined"); } this.ruleObjDescriptions = ruleObjDescriptions; } /** * Constructor * * @param discoveredApp * The {@link AnnouncedApp} to be used to build this * {@link RemotedApp} * @param ruleObjDescriptions * object path and interfaces that are used for {@link AclRules} creation * @throws IllegalArgumentException * If bad arguments have been received */ public RemotedApp(AnnouncedApp discoveredApp, List<RuleObjectDescription> ruleObjDescriptions) { this(discoveredApp.getAppName(), discoveredApp.getAppId(), discoveredApp.getDeviceName(), discoveredApp.getDeviceId(), ruleObjDescriptions); } /** * Configuration of the object paths and interfaces that are used by the * Gateway Connector Application to reach this remoted application * * @return List of {@link RuleObjectDescription} */ public List<RuleObjectDescription> getRuleObjectDescriptions() { return ruleObjDescriptions; } /** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder("RemotedApp ["); sb.append("appName='").append(getAppName()).append("',") .append("appId='").append(getAppId()).append("',") .append("deviceName='").append(getDeviceName()).append("',") .append("deviceId='").append(getDeviceId()).append("']"); return sb.toString(); } }
[ "aaronp@qce.qualcomm.com" ]
aaronp@qce.qualcomm.com
fd836dae91392fd5e93495214e2fe98fd7f54440
065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be
/eclipsejdt_cluster/20794/tar_1.java
8e2a848af461148e9c09ebcf63264b7d2684cb82
[]
no_license
martinezmatias/GenPat-data-C3
63cfe27efee2946831139747e6c20cf952f1d6f6
b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4
refs/heads/master
2022-04-25T17:59:03.905613
2020-04-15T14:41:34
2020-04-15T14:41:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
416,393
java
/******************************************************************************* * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.core.tests.model; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import junit.framework.Test; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.search.*; import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.core.ClassFile; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.core.SourceMethod; import org.eclipse.jdt.internal.core.index.DiskIndex; import org.eclipse.jdt.internal.core.index.Index; import org.eclipse.jdt.internal.core.search.AbstractSearchScope; import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; import org.eclipse.jdt.internal.core.search.matching.AndPattern; import org.eclipse.jdt.internal.core.search.indexing.IndexManager; import org.eclipse.jdt.internal.core.search.matching.MatchLocator; import org.eclipse.jdt.internal.core.search.matching.PatternLocator; import org.eclipse.jdt.internal.core.search.matching.TypeDeclarationPattern; /** * Non-regression tests for bugs fixed in Java Search engine. */ public class JavaSearchBugsTests extends AbstractJavaSearchTests { private final static int UI_DECLARATIONS = DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE; public JavaSearchBugsTests(String name) { super(name); this.endChar = ""; } public static Test suite() { return buildModelTestSuite(JavaSearchBugsTests.class); } static { // org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; } class TestCollector extends JavaSearchResultCollector { public List matches = new ArrayList(); public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { super.acceptSearchMatch(searchMatch); this.matches.add(searchMatch); } } class ReferenceCollector extends JavaSearchResultCollector { protected IJavaElement getElement(SearchMatch searchMatch) { IJavaElement element = super.getElement(searchMatch); IJavaElement localElement = null; ReferenceMatch refMatch = (ReferenceMatch) this.match; localElement = refMatch.getLocalElement(); if (localElement != null) { return localElement; } return element; } } class TypeReferenceCollector extends ReferenceCollector { protected void writeLine() throws CoreException { super.writeLine(); TypeReferenceMatch typeRefMatch = (TypeReferenceMatch) this.match; IJavaElement[] others = typeRefMatch.getOtherElements(); int length = others==null ? 0 : others.length; if (length > 0) { this.line.append("+["); for (int i=0; i<length; i++) { IJavaElement other = others[i]; if (i>0) this.line.append(','); this.line.append(other.getElementName()); } this.line.append(']'); } } } IJavaSearchScope getJavaSearchScope() { return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")}); } IJavaSearchScope getJavaSearchScopeBugs(String packageName, boolean addSubpackages) throws JavaModelException { if (packageName == null) return getJavaSearchScope(); return getJavaSearchPackageScope("JavaSearchBugs", packageName, addSubpackages); } public ICompilationUnit getWorkingCopy(String path, String source) throws JavaModelException { if (this.wcOwner == null) { this.wcOwner = new WorkingCopyOwner() {}; } return getWorkingCopy(path, source, this.wcOwner); } /* (non-Javadoc) * @see org.eclipse.jdt.core.tests.model.SuiteOfTestCases#setUpSuite() */ public void setUpSuite() throws Exception { super.setUpSuite(); JAVA_PROJECT = setUpJavaProject("JavaSearchBugs", "1.5"); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b95152.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b123679.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b140156.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b164791.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b166348.jar", false); } public void tearDownSuite() throws Exception { deleteProject("JavaSearchBugs"); super.tearDownSuite(); } protected void setUp () throws Exception { super.setUp(); this.resultCollector = new TestCollector(); this.resultCollector.showAccuracy(true); } /** * @bug 41018: Method reference not found * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=41018" */ public void testBug41018() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b41018/A.java", "package b41018;\n" + "public class A {\n" + " protected void anotherMethod() {\n" + " methodA(null);\n" + " }\n" + " private Object methodA(ClassB.InnerInterface arg3) {\n" + " return null;\n" + " }\n" + "}\n" + "class ClassB implements InterfaceB {\n" + "}\n" + "interface InterfaceB {\n" + " interface InnerInterface {\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("A"); IMethod method = type.getMethod("methodA", new String[] { "QClassB.InnerInterface;" }); search(method, REFERENCES); assertSearchResults( "src/b41018/A.java void b41018.A.anotherMethod() [methodA(null)] EXACT_MATCH" ); } public void testBug6930_AllConstructorDeclarations01() throws Exception { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01.java", "package p6930;\n" + "public class AllConstructorDeclarations01 {\n" + " public AllConstructorDeclarations01() {}\n" + " public AllConstructorDeclarations01(Object o) {}\n" + " public AllConstructorDeclarations01(Object o, String s) {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/p6930/AllConstructorDeclarations01b.java", "package p6930;\n" + "public class AllConstructorDeclarations01b {\n" + "}\n" ); ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector(); searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "p6930.AllConstructorDeclarations01#AllConstructorDeclarations01()\n" + "p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o)\n" + "p6930.AllConstructorDeclarations01#AllConstructorDeclarations01(Object o,String s)\n" + "p6930.AllConstructorDeclarations01b#AllConstructorDeclarations01b()*", requestor ); } public void testBug6930_AllConstructorDeclarations02() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, ""); createJar(new String[] { "p6930/AllConstructorDeclarations02.java", "package p6930;\n" + "public class AllConstructorDeclarations02 {\n" + " public AllConstructorDeclarations02() {}\n" + " public AllConstructorDeclarations02(Object o) {}\n" + " public AllConstructorDeclarations02(Object o, String s) {}\n" + "}", "p6930/AllConstructorDeclarations02b.java", "package p6930;\n" + "public class AllConstructorDeclarations02b {\n" + "}" }, p.getProject().getLocation().append("lib6930.jar").toOSString()); refresh(p); ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector(); searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "p6930.AllConstructorDeclarations02#AllConstructorDeclarations02()\n" + "p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o)\n" + "p6930.AllConstructorDeclarations02#AllConstructorDeclarations02(java.lang.Object o,java.lang.String s)\n" + "p6930.AllConstructorDeclarations02b#AllConstructorDeclarations02b()", requestor ); } finally { deleteProject("P"); } } public void testBug6930_AllConstructorDeclarations03() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {"src"}, new String[] {}, "bin"); createFolder("/P/src/p6930"); createFile( "/P/src/p6930/AllConstructorDeclarations03.java", "package p6930;\n" + "public class AllConstructorDeclarations03 {\n" + " public AllConstructorDeclarations03() {}\n" + " public AllConstructorDeclarations03(Object o) {}\n" + " public AllConstructorDeclarations03(Object o, String s) {}\n" + "}"); createFile( "/P/src/p6930/AllConstructorDeclarations03b.java", "package p6930;\n" + "public class AllConstructorDeclarations03b {\n" + "}"); refresh(p); ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector(); searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "p6930.AllConstructorDeclarations03#AllConstructorDeclarations03()\n" + "p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o)\n" + "p6930.AllConstructorDeclarations03#AllConstructorDeclarations03(Object o,String s)\n" + "p6930.AllConstructorDeclarations03b#AllConstructorDeclarations03b()*", requestor ); } finally { deleteProject("P"); } } public void testBug6930_AllConstructorDeclarations04() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, "","1.5"); createJar( new String[] { "p6930/AllConstructorDeclarations04.java", "package p6930;\n" + "public class AllConstructorDeclarations04 {\n" + " public AllConstructorDeclarations04(java.util.Collection<Object> c) {}\n" + "}" }, p.getProject().getLocation().append("lib6930.jar").toOSString(), new String[]{getExternalJCLPathString("1.5")}, "1.5"); refresh(p); ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector(); searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "p6930.AllConstructorDeclarations04#AllConstructorDeclarations04(java.util.Collection<java.lang.Object> c)", requestor ); } finally { deleteProject("P"); } } public void testBug6930_AllConstructorDeclarations05() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib6930.jar"}, ""); createJar(new String[] { "p6930/AllConstructorDeclarations05.java", "package p6930;\n" + "public class AllConstructorDeclarations05 {\n" + " public class AllConstructorDeclarations05b {\n" + " public AllConstructorDeclarations05b(Object o) {}\n" + " }\n" + "}" }, p.getProject().getLocation().append("lib6930.jar").toOSString()); refresh(p); ConstructorDeclarationsCollector requestor = new ConstructorDeclarationsCollector(); searchAllConstructorDeclarations("AllConstructorDeclarations", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "p6930.AllConstructorDeclarations05#AllConstructorDeclarations05()", requestor ); } finally { deleteProject("P"); } } /** * @bug 70827: [Search] wrong reference match to private method of supertype * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=70827" */ public void testBug70827() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b70827/A.java", "package b70827;\n" + "class A {\n" + " private void privateMethod() {\n" + " }\n" + "}\n" + "class Second extends A {\n" + " void call() {\n" + " int i= privateMethod();\n" + " }\n" + " int privateMethod() {\n" + " return 1;\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("A"); IMethod method = type.getMethod("privateMethod", new String[] {}); search(method, REFERENCES); assertSearchResults( "" ); } /** * @bug 71279: [Search] NPE in TypeReferenceLocator when moving CU with unresolved type reference * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=71279" */ public void testBug71279() throws CoreException { JavaSearchResultCollector result = new JavaSearchResultCollector() { public void beginReporting() { addLine("Starting search..."); } public void endReporting() { addLine("Done searching."); } }; this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b71279/AA.java", "package b71279;\n" + "public class AA {\n" + " Unknown ref;\n" + "}\n" ); new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], result, null); assertSearchResults( "Starting search...\n" + "Done searching.", result); } /** * @bug 72866: [search] references to endVisit(MethodInvocation) reports refs to endVisit(SuperMethodInvocation) * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=72866" */ public void testBug72866() throws CoreException { this.workingCopies = new ICompilationUnit[4]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b72866/A.java", "package b72866;\n" + "public abstract class A {\n" + " public abstract void foo(V v);\n" + "}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b72866/SX.java", "package b72866;\n" + "public class SX extends A {\n" + " public void foo(V v) {\n" + " v.bar(this);\n" + " }\n" + "}\n" , owner ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b72866/V.java", "package b72866;\n" + "public class V {\n" + " void bar(A a) {}\n" + " void bar(X x) {}\n" + " void bar(SX s) {}\n" + "}\n" , owner ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b72866/X.java", "package b72866;\n" + "public class X extends A {\n" + " public void foo(V v) {\n" + " v.bar(this);\n" + " }\n" + "}\n" , owner ); IType type = this.workingCopies[2].getType("V"); IMethod method = type.getMethod("bar", new String[] {"QX;"}); search(method, REFERENCES); assertSearchResults( "src/b72866/X.java void b72866.X.foo(V) [bar(this)] EXACT_MATCH" ); } /** * @bug 73112: [Search] SearchEngine doesn't find all fields multiple field declarations * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=73112" */ public void testBug73112a() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73112/A.java", "package b73112;\n" + "public class A {\n" + " int fieldA73112a = 1, fieldA73112b = new Integer(2).intValue(), fieldA73112c = fieldA73112a + fieldA73112b;\n" + " int fieldA73112d;\n" + " \n" + " public void method(){}\n" + "}\n"); // search field references to first multiple field search("fieldA73112*", FIELD, ALL_OCCURRENCES); assertSearchResults( "src/b73112/A.java b73112.A.fieldA73112a [fieldA73112a] EXACT_MATCH\n" + "src/b73112/A.java b73112.A.fieldA73112b [fieldA73112b] EXACT_MATCH\n" + "src/b73112/A.java b73112.A.fieldA73112c [fieldA73112c] EXACT_MATCH\n" + "src/b73112/A.java b73112.A.fieldA73112c [fieldA73112a] EXACT_MATCH\n" + "src/b73112/A.java b73112.A.fieldA73112c [fieldA73112b] EXACT_MATCH\n" + "src/b73112/A.java b73112.A.fieldA73112d [fieldA73112d] EXACT_MATCH" ); } public void testBug73112b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = super.getWorkingCopy("/JavaSearchBugs/src/b73112/B.java", "package b73112;\n" + "public class B {\n" + " int fieldB73112a, fieldB73112b = 10;\n" + " int fieldB73112c = fieldB73112a + fieldB73112b, fieldB73112d = fieldB73112c + fieldB73112a, fieldB73112e;\n" + " \n" + " public void method(){}\n" + "}\n"); // search field references to first multiple field search("fieldB73112*", FIELD, ALL_OCCURRENCES); assertSearchResults( "src/b73112/B.java b73112.B.fieldB73112a [fieldB73112a] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112b [fieldB73112b] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112c [fieldB73112c] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112c [fieldB73112a] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112c [fieldB73112b] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112d [fieldB73112d] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112d [fieldB73112c] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112d [fieldB73112a] EXACT_MATCH\n" + "src/b73112/B.java b73112.B.fieldB73112e [fieldB73112e] EXACT_MATCH" ); } /** * @bug 73336: [1.5][search] Search Engine does not find type references of actual generic type parameters * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=73336" */ public void testBug73336() throws CoreException { this.workingCopies = new ICompilationUnit[6]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336/A.java", "package b73336;\n" + "public class A {}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336/AA.java", "package b73336;\n" + "public class AA extends A {}\n", owner ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336/B.java", "package b73336;\n" + "public class B extends X<A, A> {\n" + " <T> void foo(T t) {}\n" + "}\n", owner ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336/C.java", "package b73336;\n" + "public class C implements I<A> {\n" + " public void foo() {\n" + " B b = new B();\n" + " b.<A>foo(new A());\n" + " }\n" + "}\n", owner ); this.workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/b73336/I.java", "package b73336;\n" + "public interface I<T> {\n" + " public void foo();\n" + "}\n", owner ); this.workingCopies[5] = getWorkingCopy("/JavaSearchBugs/src/b73336/X.java", "package b73336;\n" + "public class X<T, U> {\n" + " <V> void foo(V v) {}\n" + " class Member<T> {\n" + " void foo() {}\n" + " }\n" + "}\n", owner ); // search for first and second method should both return 2 inaccurate matches IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES); //, getJavaSearchScopeBugs("b73336", false)); assertSearchResults( "src/b73336/AA.java b73336.AA [A] EXACT_MATCH\n" + "src/b73336/B.java b73336.B [A] EXACT_MATCH\n" + "src/b73336/B.java b73336.B [A] EXACT_MATCH\n" + "src/b73336/C.java b73336.C [A] EXACT_MATCH\n" + "src/b73336/C.java void b73336.C.foo() [A] EXACT_MATCH\n" + "src/b73336/C.java void b73336.C.foo() [A] EXACT_MATCH" ); } public void testBug73336b() throws CoreException { this.workingCopies = new ICompilationUnit[4]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336b/A.java", "package b73336b;\n" + "public class A {}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336b/B.java", "package b73336b;\n" + "public class B extends X<A, A> {\n" + "}\n", owner ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336b/C.java", "package b73336b;\n" + "public class C extends X<A, A>.Member<A> {\n" + " public C() {\n" + " new X<A, A>().super();\n" + " }\n" + "}\n", owner ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336b/X.java", "package b73336b;\n" + "public class X<T, U> {\n" + " <V> void foo(V v) {}\n" + " class Member<T> {\n" + " void foo() {}\n" + " }\n" + "}\n", owner ); // search for first and second method should both return 2 inaccurate matches IType type = this.workingCopies[0].getType("A"); // search(type, REFERENCES, getJavaSearchScopeBugs("b73336b", false)); search(type, REFERENCES); //, getJavaSearchScopeBugs("b73336", false)); assertSearchResults( "src/b73336b/B.java b73336b.B [A] EXACT_MATCH\n" + "src/b73336b/B.java b73336b.B [A] EXACT_MATCH\n" + "src/b73336b/C.java b73336b.C [A] EXACT_MATCH\n" + "src/b73336b/C.java b73336b.C [A] EXACT_MATCH\n" + "src/b73336b/C.java b73336b.C [A] EXACT_MATCH\n" + "src/b73336b/C.java b73336b.C() [A] EXACT_MATCH\n" + "src/b73336b/C.java b73336b.C() [A] EXACT_MATCH" ); } // Verify that no NPE was raised on following case (which produces compiler error) public void testBug73336c() throws CoreException { this.workingCopies = new ICompilationUnit[4]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73336c/A.java", "package b73336c;\n" + "public class A {}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73336c/B.java", "package b73336c;\n" + "public class B extends X<A, A> {\n" + "}\n", owner ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b73336c/C.java", "package b73336c;\n" + "public class C implements X<A, A>.Interface<A> {\n" + " void bar() {}\n" + "}\n", owner ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b73336c/X.java", "package b73336c;\n" + "public class X<T, U> {\n" + " interface Interface<V> {\n" + " void bar();\n" + " }\n" + "}\n", owner ); // search for first and second method should both return 2 inaccurate matches IType type = this.workingCopies[0].getType("A"); // search(type, REFERENCES, getJavaSearchScopeBugs("b73336c", false)); search(type, REFERENCES); //, getJavaSearchScopeBugs("b73336", false)); assertSearchResults( "src/b73336c/B.java b73336c.B [A] EXACT_MATCH\n" + "src/b73336c/B.java b73336c.B [A] EXACT_MATCH\n" + "src/b73336c/C.java b73336c.C [A] EXACT_MATCH\n" + "src/b73336c/C.java b73336c.C [A] EXACT_MATCH\n" + "src/b73336c/C.java b73336c.C [A] EXACT_MATCH" ); } /** * @bug 73696: searching only works for IJavaSearchConstants.TYPE, but not CLASS or INTERFACE * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=73696" */ public void testBug73696() throws CoreException { this.workingCopies = new ICompilationUnit[2]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b73696/C.java", "package b73696;\n" + "public class C implements I {\n" + "}", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b73696/I.java", "package b73696;\n" + "public interface I {}\n", owner ); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(this.workingCopies); // Interface declaration TypeDeclarationPattern pattern = new TypeDeclarationPattern( null, null, null, IIndexConstants.INTERFACE_SUFFIX, SearchPattern.R_PATTERN_MATCH ); new SearchEngine(new ICompilationUnit[] {this.workingCopies[1]}).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, scope, this.resultCollector, null); // Class declaration pattern = new TypeDeclarationPattern( null, null, null, IIndexConstants.CLASS_SUFFIX, SearchPattern.R_PATTERN_MATCH ); new SearchEngine(new ICompilationUnit[] {this.workingCopies[0]}).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, scope, this.resultCollector, null); assertSearchResults( "src/b73696/I.java b73696.I [I] EXACT_MATCH\n" + "src/b73696/C.java b73696.C [C] EXACT_MATCH" ); } /** * @bug 74776: [Search] Wrong search results for almost identical method * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=74776" */ public void testBug74776() throws CoreException { this.workingCopies = new ICompilationUnit[3]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b74776/A.java", "package b74776;\n" + "public class A {\n" + " /**\n" + " * @deprecated Use {@link #foo(IRegion)} instead\n" + " * @param r\n" + " */\n" + " void foo(Region r) {\n" + " foo((IRegion)r);\n" + " }\n" + " void foo(IRegion r) {\n" + " }\n" + "}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b74776/IRegion.java", "package b74776;\n" + "public interface IRegion {\n" + "}\n", owner ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b74776/Region.java", "package b74776;\n" + "public class Region implements IRegion {\n" + "\n" + "}\n", owner ); // search method references IType type = this.workingCopies[0].getType("A"); IMethod method = type.getMethod("foo", new String[] { "QRegion;" }); search(method, REFERENCES); assertSearchResults(""); } /** * @bug 75816: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=75816" */ public void testBug75816() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/test75816.jar", "", "Test.class").getType(); IType innerType = type.getType("Inner"); IMethod[] methods = innerType.getMethods(); assertEquals("Wrong number of method.", 1, methods.length); search(methods[0], REFERENCES); assertSearchResults( "lib/test75816.jar Test.Inner Test.newInner(java.lang.Object) EXACT_MATCH" ); } /** * @bug 77093: [search] No references found to method with member type argument * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=77093" */ private void setUpBug77093() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b77093/X.java", "package b77093;\n" + "public class X {\n" + " class Z {\n" + " }\n" + " Z[][] z_arrays;\n" + " X() {\n" + " this(new Z[10][]);\n" + " }\n" + " X(Z[][] arrays) {\n" + " z_arrays = arrays;\n" + " }\n" + " private void foo(Z[] args) {\n" + " }\n" + " void bar() {\n" + " for (int i=0; i<z_arrays.length; i++)\n" + " foo(z_arrays[i]);\n" + " }\n" + "}" ); } public void testBug77093constructor() throws CoreException { setUpBug77093(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("X", new String[] {"[[QZ;"}); // Search for constructor declarations and references search(method, ALL_OCCURRENCES); assertSearchResults( "src/b77093/X.java b77093.X() [this(new Z[10][]);] EXACT_MATCH\n"+ "src/b77093/X.java b77093.X(Z[][]) [X] EXACT_MATCH" ); } public void testBug77093field() throws CoreException { setUpBug77093(); IType type = this.workingCopies[0].getType("X"); IField field = type.getField("z_arrays"); // Search for field declarations and references search(field, ALL_OCCURRENCES); assertSearchResults( "src/b77093/X.java b77093.X.z_arrays [z_arrays] EXACT_MATCH\n" + "src/b77093/X.java b77093.X(Z[][]) [z_arrays] EXACT_MATCH\n" + "src/b77093/X.java void b77093.X.bar() [z_arrays] EXACT_MATCH\n" + "src/b77093/X.java void b77093.X.bar() [z_arrays] EXACT_MATCH" ); } public void testBug77093method() throws CoreException { setUpBug77093(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] {"[QZ;"}); search(method, ALL_OCCURRENCES); assertSearchResults( "src/b77093/X.java void b77093.X.foo(Z[]) [foo] EXACT_MATCH\n" + "src/b77093/X.java void b77093.X.bar() [foo(z_arrays[i])] EXACT_MATCH" ); } /** * @bug 77388: [compiler] Reference to constructor includes space after closing parenthesis */ public void testBug77388() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b77388/Test.java", "package b77388;\n" + "class Test {\n" + " Test(int a, int b) { }\n" + " void take(Test mc) { }\n" + " void run() {\n" + " take( new Test(1, 2) ); // space in \") )\" is in match\n" + " }\n" + "}"); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("Test", new String[] {"I", "I"}); // Search for constructor references search(method, REFERENCES); assertSearchResults( "src/b77388/Test.java void b77388.Test.run() [new Test(1, 2)] EXACT_MATCH" ); } /** * @bug 78082: [1.5][search] FieldReferenceMatch in static import should not include qualifier * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=78082" */ public void testBug78082() throws CoreException { this.workingCopies = new ICompilationUnit[2]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b78082/M.java", "package b78082;\n" + "public class M {\n" + " static int VAL=78082;\n" + "}\n", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b78082/XY.java", "package b78082;\n" + "import static b78082.M.VAL;\n" + "public class XY {\n" + " double val = VAL;\n" + " double val2= b78082.M.VAL;\n" + "}\n", owner ); // search field references IType type = this.workingCopies[0].getType("M"); IField field = type.getField("VAL"); search(field, ALL_OCCURRENCES); assertSearchResults( "src/b78082/M.java b78082.M.VAL [VAL] EXACT_MATCH\n" + "src/b78082/XY.java [VAL] EXACT_MATCH\n" + "src/b78082/XY.java b78082.XY.val [VAL] EXACT_MATCH\n" + "src/b78082/XY.java b78082.XY.val2 [VAL] EXACT_MATCH" ); } /** * @bug 79267: [search] Refactoring of static generic member fails partially * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=79267" */ public void testBug79267() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79267/Test.java", "package b79267;\n" + "public class Test {\n" + " private static final X<String, String> BEFORE = new X<String, String>(4);\n" + "\n" + " static {\n" + " BEFORE.put(\"key1\",\"value1\");\n" + " BEFORE.put(\"key2\",\"value2\");\n" + " }\n" + " \n" + " private static final X<Y, Object> objectToPrimitiveMap = new X<Y, Object>(8);\n" + "\n" + " static {\n" + " objectToPrimitiveMap.put(new Y<Object>(new Object()), new Object());\n" + " }\n" + "}\n" + "\n" + "class X<T, U> {\n" + " X(int x) {}\n" + " void put(T t, U u) {}\n" + "}\n" + "\n" + "class Y<T> {\n" + " Y(T t) {}\n" + "}\n"); // search field references IType type = this.workingCopies[0].getType("Test"); IField field = type.getField("BEFORE"); search(field, REFERENCES); field = type.getField("objectToPrimitiveMap"); search(field, REFERENCES); assertSearchResults( "src/b79267/Test.java b79267.Test.static {} [BEFORE] EXACT_MATCH\n" + "src/b79267/Test.java b79267.Test.static {} [BEFORE] EXACT_MATCH\n" + "src/b79267/Test.java b79267.Test.static {} [objectToPrimitiveMap] EXACT_MATCH" ); } /** * @bug 79378: [search] IOOBE when inlining a method * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=79378" */ public void testBug79378() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79378/A.java", "package b79378;\n" + "public class Test {\n" + " void foo79378(String s, RuntimeException[] exceptions) {}\n" + " void foo79378(RuntimeException[] exceptions) {}\n" + " void call() {\n" + " String s= null; \n" + " Exception[] exceptions= null;\n" + " foo79378(s, exceptions);\n" + " }\n" + "}\n" ); IMethod[] methods = this.workingCopies[0].getType("Test").getMethods(); assertEquals("Invalid number of methods", 3, methods.length); search(methods[0], REFERENCES); assertSearchResults( "src/b79378/A.java void b79378.Test.call() [foo79378(s, exceptions)] POTENTIAL_MATCH" ); } public void testBug79378b() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79378/A.java", "package b79378;\n" + "public class Test {\n" + " void foo79378(String s, RuntimeException[] exceptions) {}\n" + " void foo79378(RuntimeException[] exceptions) {}\n" + " void call() {\n" + " String s= null; \n" + " Exception[] exceptions= null;\n" + " foo79378(s, exceptions);\n" + " }\n" + "}\n" ); IMethod[] methods = this.workingCopies[0].getType("Test").getMethods(); assertEquals("Invalid number of methods", 3, methods.length); search(methods[1], REFERENCES); assertSearchResults(""); } /** * @bug 79803: [1.5][search] Search for references to type A reports match for type variable A * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=79803" */ public void testBug79803() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79803/A.java", "package b79803;\n" + "class A<A> {\n" + " A a;\n" + " b79803.A pa= new b79803.A();\n" + "}\n" ); IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b79803/A.java b79803.A.pa [b79803.A] EXACT_MATCH\n" + "src/b79803/A.java b79803.A.pa [b79803.A] EXACT_MATCH" ); } public void testBug79803string() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79803/A.java", "package b79803;\n" + "class A<A> {\n" + " A a;\n" + " b79803.A pa= new b79803.A();\n" + "}\n" ); search("A", TYPE, REFERENCES); assertSearchResults( "src/b79803/A.java b79803.A.a [A] EXACT_MATCH\n" + "src/b79803/A.java b79803.A.pa [A] EXACT_MATCH\n" + "src/b79803/A.java b79803.A.pa [A] EXACT_MATCH" ); } /** * @bug 79860: [1.5][search] Search doesn't find type reference in type parameter bound * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=79860" */ public void testBug79860() throws CoreException { this.workingCopies = new ICompilationUnit[2]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79860/X.java", "package b79860;\n" + "public class X<T extends A> { }\n" + "class A { }", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b79860/Y.java", "package b79860;\n" + "public class Y<T extends B&I1&I2&I3> { }\n" + "class B { }\n" + "interface I1 {}\n" + "interface I2 {}\n" + "interface I3 {}\n", owner ); IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES); assertSearchResults( "src/b79860/X.java b79860.X [A] EXACT_MATCH" ); } public void testBug79860string() throws CoreException { this.workingCopies = new ICompilationUnit[2]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79860/X.java", "package b79860;\n" + "public class X<T extends A> { }\n" + "class A { }", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b79860/Y.java", "package b79860;\n" + "public class Y<T extends B&I1&I2&I3> { }\n" + "class B { }\n" + "interface I1 {}\n" + "interface I2 {}\n" + "interface I3 {}\n", owner ); search("I?", TYPE, REFERENCES); assertSearchResults( "src/b79860/Y.java b79860.Y [I1] EXACT_MATCH\n" + "src/b79860/Y.java b79860.Y [I2] EXACT_MATCH\n" + "src/b79860/Y.java b79860.Y [I3] EXACT_MATCH" ); } /** * @bug 79990: [1.5][search] Search doesn't find type reference in type parameter bound * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=79990" */ private void setUpBug79990() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79990/Test.java", "package b79990;\n" + "class Test<T> {\n" + " public void first(Exception num) {}\n" + " public void second(T t) {}\n" + "}\n" + "class Sub extends Test<Exception> {\n" + " public void first(Exception num) {}\n" + " public void second(Exception t) {}\n" + "}\n" );} public void testBug79990() throws CoreException { setUpBug79990(); IMethod method = this.workingCopies[0].getType("Test").getMethods()[0]; search(method, DECLARATIONS); assertSearchResults( "src/b79990/Test.java void b79990.Test.first(Exception) [first] EXACT_MATCH\n" + "src/b79990/Test.java void b79990.Sub.first(Exception) [first] EXACT_MATCH" ); } public void testBug79990b() throws CoreException { setUpBug79990(); IMethod method = this.workingCopies[0].getType("Test").getMethods()[1]; search(method, DECLARATIONS); assertSearchResults( "src/b79990/Test.java void b79990.Test.second(T) [second] EXACT_MATCH\n" + "src/b79990/Test.java void b79990.Sub.second(Exception) [second] EXACT_MATCH" ); } public void testBug79990c() throws CoreException { setUpBug79990(); IMethod method = this.workingCopies[0].getType("Test").getMethods()[1]; search(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b79990/Test.java void b79990.Test.second(T) [second] EXACT_MATCH\n" + "src/b79990/Test.java void b79990.Sub.second(Exception) [second] EXACT_MATCH" ); } public void testBug79990d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b79990/Test.java", "package b79990;\n" + "public class Test<T> {\n" + " void methodT(T t) {}\n" + "}\n" + "class Sub<X> extends Test<X> {\n" + " void methodT(X x) {} // overrides Super#methodT(T)\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Test").getMethods()[0]; search(method, DECLARATIONS); assertSearchResults( "src/b79990/Test.java void b79990.Test.methodT(T) [methodT] EXACT_MATCH\n" + "src/b79990/Test.java void b79990.Sub.methodT(X) [methodT] EXACT_MATCH" ); } /** * @bug 80084: [1.5][search]Rename field fails on field based on parameterized type with member type parameter * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=80084" */ public void testBug80084() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80084/Test.java", "package b80084;\n" + "class List<T> {}\n" + "public class Test {\n" + " void foo(List<Exception> le) {}\n" + " void bar() {\n" + " List<Exception> le = new List<Exception>();\n" + " foo(le);\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QList<QException;>;" } ); search(method, REFERENCES); assertSearchResults( "src/b80084/Test.java void b80084.Test.bar() [foo(le)] EXACT_MATCH" ); } /** * @bug 80194: [1.5][search]Rename field fails on field based on parameterized type with member type parameter * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=80194" */ private void setUpBug80194() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80194/Test.java", "package b80194;\n" + "interface Map<K, V> {}\n" + "class HashMap<K, V> implements Map {}\n" + "public class Test {\n" + " void callDoSomething() {\n" + " final Map<String, Object> map = new HashMap<String, Object>();\n" + " doSomething(map);\n" + " doSomething(map, true);\n" + " doSomething(true);\n" + " }\n" + " void doSomething(final Map<String, Object> map) {}\n" + " void doSomething(final Map<String, Object> map, final boolean flag) {}\n" + " void doSomething(final boolean flag) {}\n" + "}\n" ); } public void testBug80194() throws CoreException, JavaModelException { setUpBug80194(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("doSomething", new String[] { "QMap<QString;QObject;>;" } ); search(method, REFERENCES); assertSearchResults( "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(map)] EXACT_MATCH" ); } public void testBug80194b() throws CoreException, JavaModelException { setUpBug80194(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("doSomething", new String[] { "QMap<QString;QObject;>;", "Z" } ); search(method, REFERENCES); assertSearchResults( "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(map, true)] EXACT_MATCH" ); } public void testBug80194string1() throws CoreException, JavaModelException { setUpBug80194(); search("doSomething(boolean)", METHOD, ALL_OCCURRENCES); assertSearchResults( "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(map)] EXACT_MATCH\n" + "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(true)] EXACT_MATCH\n" + "src/b80194/Test.java void b80194.Test.doSomething(boolean) [doSomething] EXACT_MATCH" ); } public void testBug80194string2() throws CoreException, JavaModelException { setUpBug80194(); search("doSomething(Map<String,Object>)", METHOD, ALL_OCCURRENCES); assertSearchResults( "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(map)] EXACT_MATCH\n" + "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(true)] EXACT_MATCH\n" + "src/b80194/Test.java void b80194.Test.doSomething(Map<String,Object>) [doSomething] EXACT_MATCH" ); } public void testBug80194string3() throws CoreException, JavaModelException { setUpBug80194(); search("doSomething(Map<String,Object>,boolean)", METHOD, ALL_OCCURRENCES); assertSearchResults( "src/b80194/Test.java void b80194.Test.callDoSomething() [doSomething(map, true)] EXACT_MATCH\n" + "src/b80194/Test.java void b80194.Test.doSomething(Map<String,Object>, boolean) [doSomething] EXACT_MATCH" ); } /** * @bug 80223: [search] Declaration search doesn't consider visibility to determine overriding methods * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=80223" */ public void testBug80223() throws CoreException { this.workingCopies = new ICompilationUnit[2]; WorkingCopyOwner owner = new WorkingCopyOwner() {}; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80223/a/A.java", "package b80223.a;\n" + "public class A {\n" + " void m() {}\n" + "}", owner ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b80223/b/B.java", "package b80223.b;\n" + "public class B extends b80223.a.A {\n" + " void m() {}\n" + "}", owner ); // search for method declaration should find only A match IType type = this.workingCopies[0].getType("A"); IMethod method = type.getMethod("m", new String[0]); search(method, DECLARATIONS); assertSearchResults( "src/b80223/a/A.java void b80223.a.A.m() [m] EXACT_MATCH" ); } /** * @bug 80264: [search] Search for method declarations in workspace, disregarding declaring type * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=80264" * * Following tests also verify * @bug 87778: [search] doesn't find all declarations of method with covariant return type * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=87778" */ // Methods private void setUpBug80264_Methods() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80264/Methods.java", "package b80264;\n" + "class Methods {\n" + " Methods stable() { return null; }\n" + " Methods covariant() { return null; }\n" + "}\n" + "class MethodsSub extends Methods {\n" + " Methods stable() { return null; }\n" + " MethodsSub covariant() { return null; }\n" + "}\n" + "class MethodsOther {\n" + " Methods stable() { return null; }\n" + " Methods covariant() { return null; }\n" + "}\n" ); } public void testBug80264_Methods() throws CoreException { setUpBug80264_Methods(); IType type = this.workingCopies[0].getType("Methods"); IMethod[] methods = type.getMethods(); search(methods[0], DECLARATIONS); search(methods[1], DECLARATIONS); assertSearchResults( "src/b80264/Methods.java Methods b80264.Methods.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsSub.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.Methods.covariant() [covariant] EXACT_MATCH\n" + "src/b80264/Methods.java MethodsSub b80264.MethodsSub.covariant() [covariant] EXACT_MATCH" ); } public void testBug80264_MethodsIgnoreDeclaringType() throws CoreException, JavaModelException { setUpBug80264_Methods(); IType type = this.workingCopies[0].getType("Methods"); IMethod[] methods = type.getMethods(); search(methods[0], DECLARATIONS|IGNORE_DECLARING_TYPE); search(methods[1], DECLARATIONS|IGNORE_DECLARING_TYPE); assertSearchResults( "src/b80264/Methods.java Methods b80264.Methods.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsSub.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsOther.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.Methods.covariant() [covariant] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsOther.covariant() [covariant] EXACT_MATCH" ); } public void testBug80264_MethodsIgnoreReturnType() throws CoreException, JavaModelException { setUpBug80264_Methods(); IType type = this.workingCopies[0].getType("Methods"); IMethod[] methods = type.getMethods(); search(methods[0], DECLARATIONS|IGNORE_RETURN_TYPE); search(methods[1], DECLARATIONS|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Methods.java Methods b80264.Methods.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsSub.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.Methods.covariant() [covariant] EXACT_MATCH\n" + "src/b80264/Methods.java MethodsSub b80264.MethodsSub.covariant() [covariant] EXACT_MATCH" ); } public void testBug80264_MethodsIgnoreBothTypes() throws CoreException, JavaModelException { setUpBug80264_Methods(); IType type = this.workingCopies[0].getType("Methods"); IMethod[] methods = type.getMethods(); search(methods[0], DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); search(methods[1], DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Methods.java Methods b80264.Methods.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsSub.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsOther.stable() [stable] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.Methods.covariant() [covariant] EXACT_MATCH\n" + "src/b80264/Methods.java MethodsSub b80264.MethodsSub.covariant() [covariant] EXACT_MATCH\n" + "src/b80264/Methods.java Methods b80264.MethodsOther.covariant() [covariant] EXACT_MATCH" ); } // Classes private void setUpBug80264_Classes() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80264/Classes.java", "package b80264;\n" + "class Classes {\n" + " class Inner {}\n" + "}\n" + "class ClassesSub extends Classes {\n" + " class Inner {}\n" + "}\n" + "class ClassesOther {\n" + " class Inner {}\n" + "}\n" ); } public void testBug80264_Classes() throws CoreException { setUpBug80264_Classes(); IType type = this.workingCopies[0].getType("Classes").getType("Inner"); search(type, DECLARATIONS); assertSearchResults( "src/b80264/Classes.java b80264.Classes$Inner [Inner] EXACT_MATCH" ); } public void testBug80264_ClassesIgnoreDeclaringType() throws CoreException, JavaModelException { setUpBug80264_Classes(); IType type = this.workingCopies[0].getType("Classes").getType("Inner"); search(type, DECLARATIONS|IGNORE_DECLARING_TYPE); assertSearchResults( "src/b80264/Classes.java b80264.Classes$Inner [Inner] EXACT_MATCH\n" + "src/b80264/Classes.java b80264.ClassesSub$Inner [Inner] EXACT_MATCH\n" + "src/b80264/Classes.java b80264.ClassesOther$Inner [Inner] EXACT_MATCH" ); } public void testBug80264_ClassesIgnoreReturnType() throws CoreException, JavaModelException { setUpBug80264_Classes(); IType type = this.workingCopies[0].getType("Classes").getType("Inner"); search(type, DECLARATIONS|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Classes.java b80264.Classes$Inner [Inner] EXACT_MATCH" ); } public void testBug80264_ClassesIgnoreTypes() throws CoreException, JavaModelException { setUpBug80264_Classes(); IType type = this.workingCopies[0].getType("Classes").getType("Inner"); search(type, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Classes.java b80264.Classes$Inner [Inner] EXACT_MATCH\n" + "src/b80264/Classes.java b80264.ClassesSub$Inner [Inner] EXACT_MATCH\n" + "src/b80264/Classes.java b80264.ClassesOther$Inner [Inner] EXACT_MATCH" ); } // Fields private void setUpBug80264_Fields() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80264/Fields.java", "package b80264;\n" + "class Fields {\n" + " Fields field1;\n" + " Fields field2;\n" + "}\n" + "class FieldsSub extends Fields {\n" + " Fields field1;\n" + " FieldsSub field2;\n" + "}\n" + "class FieldsOther {\n" + " Fields field1;\n" + " Fields field2;\n" + "}\n" ); } public void testBug80264_Fields() throws CoreException { setUpBug80264_Fields(); IType type = this.workingCopies[0].getType("Fields"); IField[] fields = type.getFields(); search(fields[0], DECLARATIONS); search(fields[1], DECLARATIONS); assertSearchResults( "src/b80264/Fields.java b80264.Fields.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.Fields.field2 [field2] EXACT_MATCH" ); } public void testBug80264_FieldsIgnoreDeclaringType() throws CoreException, JavaModelException { setUpBug80264_Fields(); IType type = this.workingCopies[0].getType("Fields"); IField[] fields = type.getFields(); search(fields[0], DECLARATIONS|IGNORE_DECLARING_TYPE); search(fields[1], DECLARATIONS|IGNORE_DECLARING_TYPE); assertSearchResults( "src/b80264/Fields.java b80264.Fields.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsSub.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsOther.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.Fields.field2 [field2] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsOther.field2 [field2] EXACT_MATCH" ); } public void testBug80264_FieldsIgnoreReturnType() throws CoreException, JavaModelException { setUpBug80264_Fields(); IType type = this.workingCopies[0].getType("Fields"); IField[] fields = type.getFields(); search(fields[0], DECLARATIONS|IGNORE_RETURN_TYPE); search(fields[1], DECLARATIONS|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Fields.java b80264.Fields.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.Fields.field2 [field2] EXACT_MATCH" ); } public void testBug80264_FieldsIgnoreBothTypes() throws CoreException, JavaModelException { setUpBug80264_Fields(); IType type = this.workingCopies[0].getType("Fields"); IField[] fields = type.getFields(); search(fields[0], DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); search(fields[1], DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b80264/Fields.java b80264.Fields.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsSub.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsOther.field1 [field1] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.Fields.field2 [field2] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsSub.field2 [field2] EXACT_MATCH\n" + "src/b80264/Fields.java b80264.FieldsOther.field2 [field2] EXACT_MATCH" ); } /** * @bug 80890: [search] Strange search engine behaviour * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=80890" */ public void testBug80890() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b80890/A.java", "package b80890;\n" + "public class A {\n" + " protected void foo(Exception e) {}\n" + " protected void foo(String s) {}\n" + "}\n" + "class B1 extends A {\n" + " public void bar1() {\n" + " foo(null);\n" + " }\n" + "}\n" + "class B2 extends A {\n" + " public void bar2() {\n" + " foo(null);\n" + " }\n" + "}\n" ); // search for first and second method should both return 2 inaccurate matches IType type = this.workingCopies[0].getType("A"); IMethod method = type.getMethods()[0]; search(method, REFERENCES); method = type.getMethods()[1]; search(method, REFERENCES); assertSearchResults( "src/b80890/A.java void b80890.B1.bar1() [foo(null)] POTENTIAL_MATCH\n" + "src/b80890/A.java void b80890.B2.bar2() [foo(null)] POTENTIAL_MATCH\n" + "src/b80890/A.java void b80890.B1.bar1() [foo(null)] POTENTIAL_MATCH\n" + "src/b80890/A.java void b80890.B2.bar2() [foo(null)] POTENTIAL_MATCH" ); } /** * @bug 80918: [1.5][search] ClassCastException when searching for references to binary type * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=80918" */ public void testBug80918() throws CoreException { IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Exception.class").getType(); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")}, IJavaSearchScope.SOURCES); search(type, REFERENCES, SearchPattern.R_CASE_SENSITIVE|SearchPattern.R_ERASURE_MATCH, scope); assertSearchResults( "" // do not expect to find anything, just verify that no CCE happens ); } /** * @bug 81084: [1.5][search]Rename field fails on field based on parameterized type with member type parameter * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=81084" */ public void testBug81084a() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b81084a/Test.java", "package b81084a;\n" + "class List<E> {}\n" + "public class Test {\n" + " class Element{}\n" + " static class Inner {\n" + " private final List<Element> fList1;\n" + " private final List<Test.Element> fList2;\n" + " public Inner(List<Element> list) {\n" + " fList1 = list;\n" + " fList2 = list;\n" + " }\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test").getType("Inner"); IField field1 = type.getField("fList1"); search(field1, REFERENCES); IField field2 = type.getField("fList2"); search(field2, REFERENCES); assertSearchResults( "src/b81084a/Test.java b81084a.Test$Inner(List<Element>) [fList1] EXACT_MATCH\n" + "src/b81084a/Test.java b81084a.Test$Inner(List<Element>) [fList2] EXACT_MATCH" ); } public void testBug81084string() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b81084a/Test.java", "package b81084a;\n" + "class List<E> {}\n" + "public class Test {\n" + " class Element{}\n" + " static class Inner {\n" + " private final List<Element> fList1;\n" + " private final List<Test.Element> fList2;\n" + " public Inner(List<Element> list) {\n" + " fList1 = list;\n" + " fList2 = list;\n" + " }\n" + " }\n" + "}\n" ); search("fList1", FIELD, REFERENCES); search("fList2", FIELD, REFERENCES); assertSearchResults( "src/b81084a/Test.java b81084a.Test$Inner(List<Element>) [fList1] EXACT_MATCH\n" + "src/b81084a/Test.java b81084a.Test$Inner(List<Element>) [fList2] EXACT_MATCH" ); } public void testBug81084b() throws CoreException, JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b81084b/Test.java", "package b81084b;\n" + "class List<E> {}\n" + "public class Test {\n" + " class Element{}\n" + " static class Inner {\n" + " private final List<? extends Element> fListb1;\n" + " private final List<? extends Test.Element> fListb2;\n" + " public Inner(List<Element> list) {\n" + " fListb1 = list;\n" + " fListb2 = list;\n" + " }\n" + " }\n" + "}\n" ); // search element patterns IType type = this.workingCopies[0].getType("Test").getType("Inner"); IField field1 = type.getField("fListb1"); search(field1, REFERENCES); IField field2 = type.getField("fListb2"); search(field2, REFERENCES); assertSearchResults( "src/b81084b/Test.java b81084b.Test$Inner(List<Element>) [fListb1] EXACT_MATCH\n" + "src/b81084b/Test.java b81084b.Test$Inner(List<Element>) [fListb2] EXACT_MATCH" ); } /** * @bug 81556: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=81556" */ public void testBug81556() throws CoreException { ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b81556.a", "X81556.java"); IType type = unit.getType("X81556"); IMethod method = type.getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/b81556/a/A81556.java void b81556.a.A81556.bar(XX81556) [foo()] EXACT_MATCH" ); } /** * @bug 82088: [search][javadoc] Method parameter types references not found in @see/@link tags * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=82088" */ public void testBug82088method() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82088/m/Test.java", "package b82088.m;\n" + "/**\n" + " * @see #setA(A)\n" + " */\n" + "public class Test {\n" + " A a;\n" + " public void setA(A a) {\n" + " this.a = a;\n" + " }\n" + "}\n" + "class A {}\n" ); IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES); assertSearchResults( "src/b82088/m/Test.java b82088.m.Test [A] EXACT_MATCH\n" + "src/b82088/m/Test.java b82088.m.Test.a [A] EXACT_MATCH\n" + "src/b82088/m/Test.java void b82088.m.Test.setA(A) [A] EXACT_MATCH" ); } public void testBug82088constructor() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82088/c/Test.java", "package b82088.c;\n" + "/**\n" + " * @see #Test(A)\n" + " */\n" + "public class Test {\n" + " A a;\n" + " Test(A a) {\n" + " this.a = a;\n" + " }\n" + "}\n" + "class A {}\n" ); IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES); assertSearchResults( "src/b82088/c/Test.java b82088.c.Test [A] EXACT_MATCH\n" + "src/b82088/c/Test.java b82088.c.Test.a [A] EXACT_MATCH\n" + "src/b82088/c/Test.java b82088.c.Test(A) [A] EXACT_MATCH" ); } /** * @bug 82208: [1.5][search][annot] Search for annotations misses references in default and values constructs * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=82208" */ private void setUpBug82208() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82208/Test.java", "package b82208;\n" + "interface B82208_I {}\n" + "enum B82208_E {}\n" + "@interface B82208_A {}\n" + "public class B82208 {}\n" ); } public void testBug82208_TYPE() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", TYPE, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_I [B82208_I] EXACT_MATCH\n" + "src/b82208/Test.java b82208.B82208_E [B82208_E] EXACT_MATCH\n" + "src/b82208/Test.java b82208.B82208_A [B82208_A] EXACT_MATCH\n" + "src/b82208/Test.java b82208.B82208 [B82208] EXACT_MATCH" ); } public void testBug82208_CLASS() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", CLASS, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208 [B82208] EXACT_MATCH" ); } public void testBug82208_INTERFACE() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", INTERFACE, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_I [B82208_I] EXACT_MATCH" ); } public void testBug82208_ENUM() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", ENUM, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_E [B82208_E] EXACT_MATCH" ); } public void testBug82208_ANNOTATION_TYPE() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", ANNOTATION_TYPE, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_A [B82208_A] EXACT_MATCH" ); } public void testBug82208_CLASS_AND_INTERFACE() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", CLASS_AND_INTERFACE, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_I [B82208_I] EXACT_MATCH\n" + "src/b82208/Test.java b82208.B82208 [B82208] EXACT_MATCH" ); } public void testBug82208_CLASS_AND_ENUMERATION() throws CoreException { this.resultCollector.showRule(); setUpBug82208(); search("B82208*", CLASS_AND_ENUM, ALL_OCCURRENCES); assertSearchResults( "src/b82208/Test.java b82208.B82208_E [B82208_E] EXACT_MATCH\n" + "src/b82208/Test.java b82208.B82208 [B82208] EXACT_MATCH" ); } /** * @bug 82673: [1.5][search][annot] Search for annotations misses references in default and values constructs * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012" */ public void testBug82673() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b82673/Test.java", "package b82673;\n" + "public class Test {\n" + " void test1() {\n" + " class Dummy {};\n" + " Dummy d = new Dummy();\n" + " new X();\n" + " }\n" + " \n" + " void test2() {\n" + " class Dummy {};\n" + " Dummy d = new Dummy();\n" + " new Y();\n" + " }\n" + "}\n" + "class X {}\n" + "class Y {}\n" ); IType type = selectType(this.workingCopies[0], "Test").getMethod("test1", new String[0]).getType("Dummy", 1); search(type, REFERENCES); assertSearchResults( "src/b82673/Test.java void b82673.Test.test1() [Dummy] EXACT_MATCH\n" + "src/b82673/Test.java void b82673.Test.test1() [Dummy] EXACT_MATCH" ); } /** * @bug 83012: [1.5][search][annot] Search for annotations misses references in default and values constructs * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83012" */ public void testBug83012() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83012/Test.java", "package b83012;\n" + "@interface A {\n" + " String value() default \"\";\n" + "}\n" + "@interface Main {\n" + " A first() default @A(\"Void\");\n" + " A second();\n" + "}\n" + "\n" + "@Main(first=@A(\"\"), second=@A(\"2\"))\n" + "public class Test {\n" + "}\n" ); IType type = selectType(this.workingCopies[0], "A"); search(type, REFERENCES); assertSearchResults( "src/b83012/Test.java A b83012.Main.first() [A] EXACT_MATCH\n" + "src/b83012/Test.java A b83012.Main.first() [A] EXACT_MATCH\n" + "src/b83012/Test.java A b83012.Main.second() [A] EXACT_MATCH\n" + "src/b83012/Test.java b83012.Test [A] EXACT_MATCH\n" + "src/b83012/Test.java b83012.Test [A] EXACT_MATCH" ); } /** * @bug 83230: [1.5][search][annot] search for annotation elements does not seem to be implemented yet * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83230" */ private void setUpBug83230_Explicit() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", "package b83230;\n" + "@interface Author {\n" + " String[] authorName() default \"FREDERIC\";\n" + " int[] age();\n" + " int ageMin = 20;\n" + " @interface Surname {}\n" + " class Address {\n" + " String city;\n" + " public void foo(Object obj) {}\n" + " }\n" + "}\n" + "\n" + "@Author(authorName=\"FREDERIC\", age=41)\n" + "public class Test {\n" + " @Author(authorName={\"FREDERIC\", \"JEROME\"}, age={41, 35} )\n" + " Test() {}\n" + " @Author(authorName=\"PHILIPPE\", age=37)\n" + " void foo() {\n" + " @Author(authorName=\"FREDERIC\", age=41)\n" + " final Object obj = new Object() {};\n" + " @Author(authorName=\"FREDERIC\", age=41)\n" + " class Local {\n" + " @Author(authorName=\"FREDERIC\", age=41)\n" + " String foo() {\n" + " Author.Address address = new Author.Address();\n" + " address.foo(obj);\n" + " return address.city;\n" + " }\n" + " }\n" + " }\n" + " @Author(authorName=\"DAVID\", age=28)\n" + " int min = Author.ageMin;\n" + "}\n" ); } public void testBug83230_Explicit() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IMethod method = selectMethod(this.workingCopies[0], "authorName"); search(method, REFERENCES); assertSearchResults( "src/b83230/Test.java b83230.Test [authorName] EXACT_MATCH\n" + "src/b83230/Test.java b83230.Test.min [authorName] EXACT_MATCH\n" + "src/b83230/Test.java b83230.Test() [authorName] EXACT_MATCH\n" + "src/b83230/Test.java void b83230.Test.foo():Local#1 [authorName] EXACT_MATCH\n" + "src/b83230/Test.java String void b83230.Test.foo():Local#1.foo() [authorName] EXACT_MATCH\n" + "src/b83230/Test.java void b83230.Test.foo() [authorName] EXACT_MATCH\n" + "src/b83230/Test.java void b83230.Test.foo() [authorName] EXACT_MATCH" ); } public void testBug83230_Explicit01() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IMethod method = selectMethod(this.workingCopies[0], "authorName"); search(method, DECLARATIONS); assertSearchResults( "src/b83230/Test.java String[] b83230.Author.authorName() [authorName] EXACT_MATCH" ); } public void testBug83230_Explicit02() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IType type = selectType(this.workingCopies[0], "Address"); search(type, REFERENCES); assertSearchResults( "src/b83230/Test.java String void b83230.Test.foo():Local#1.foo() [Author.Address] EXACT_MATCH\n" + "src/b83230/Test.java String void b83230.Test.foo():Local#1.foo() [Author.Address] EXACT_MATCH" ); } public void testBug83230_Explicit03() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IMethod method = selectMethod(this.workingCopies[0], "foo"); search(method, REFERENCES); assertSearchResults( "src/b83230/Test.java String void b83230.Test.foo():Local#1.foo() [foo(obj)] EXACT_MATCH" ); } public void testBug83230_Explicit04() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IField field = selectField(this.workingCopies[0], "city"); search(field, REFERENCES); assertSearchResults( "src/b83230/Test.java String void b83230.Test.foo():Local#1.foo() [city] EXACT_MATCH" ); } public void testBug83230_Explicit05() throws CoreException { this.resultCollector.showRule(); setUpBug83230_Explicit(); IField field = selectField(this.workingCopies[0], "ageMin"); search(field, REFERENCES); assertSearchResults( "src/b83230/Test.java b83230.Test.min [ageMin] EXACT_MATCH" ); } public void testBug83230_Implicit01() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", "package b83230;\n" + "@interface Annot {\n" + " int value();\n" + "}\n" + "@Annot(41)\n" + "public class Test {\n" + " @Annot(10)\n" + " public void foo() {}\n" + " @Annot(21)\n" + " int bar;\n" + "}\n" ); IType type = selectType(this.workingCopies[0], "Annot"); IMethod method = type.getMethod("value", new String[0]); search(method, REFERENCES); assertSearchResults( "src/b83230/Test.java b83230.Test [41] EXACT_MATCH\n" + "src/b83230/Test.java b83230.Test.bar [21] EXACT_MATCH\n" + "src/b83230/Test.java void b83230.Test.foo() [10] EXACT_MATCH" ); } public void testBug83230_Implicit02() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83230/Test.java", "package b83230;\n" + "@interface A {\n" + " String value() default \"\";\n" + "}\n" + "@interface Main {\n" + " A first() default @A(\"Void\");\n" + " A second();\n" + "}\n" + "\n" + "@Main(first=@A(\"\"), second=@A(\"2\"))\n" + "public class Test {\n" + "}\n" ); IType type = selectType(this.workingCopies[0], "A"); IMethod method = type.getMethod("value", new String[0]); search(method, REFERENCES); assertSearchResults( "src/b83230/Test.java A b83230.Main.first() [\"Void\"] EXACT_MATCH\n" + "src/b83230/Test.java b83230.Test [\"\"] EXACT_MATCH\n" + "src/b83230/Test.java b83230.Test [\"2\"] EXACT_MATCH" ); } /** * @bug 83304: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83304" */ public void testBug83304() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Test.java", "package b83304;\n" + "public class Test {\n" + " void foo() {\n" + " Class<? extends Throwable> l1= null;\n" + " Class<Exception> l2= null;\n" + " \n" + " Class<String> string_Class;\n" + " }\n" + "}\n" ); IType type = selectType(this.workingCopies[0], "Class", 3); search(type, REFERENCES, ERASURE_RULE, getJavaSearchWorkingCopiesScope()); assertSearchResults( "src/b83304/Test.java void b83304.Test.foo() [Class] ERASURE_MATCH\n" + "src/b83304/Test.java void b83304.Test.foo() [Class] ERASURE_MATCH\n" + "src/b83304/Test.java void b83304.Test.foo() [Class] EXACT_MATCH" ); } private void setUpBug83304_TypeParameterizedElementPattern() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Types.java", "package b83304;\n" + "import g1.t.s.def.Generic;\n" + "public class Types {\n" + " public Generic gen;\n" + " public Generic<Object> gen_obj;\n" + " public Generic<Exception> gen_exc;\n" + " public Generic<?> gen_wld;\n" + " public Generic<? extends Throwable> gen_thr;\n" + " public Generic<? super RuntimeException> gen_run;\n" + "}\n" ); } public void testBug83304_TypeParameterizedElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_TypeParameterizedElementPattern(); IType type = selectType(this.workingCopies[0], "Generic", 4); search(type, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Types.java [g1.t.s.def.Generic] EQUIVALENT_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen [Generic] EQUIVALENT_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_obj [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_exc [Generic] EXACT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_wld [Generic] EQUIVALENT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_thr [Generic] EQUIVALENT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_run [Generic] EQUIVALENT_MATCH\n" + "lib/JavaSearch15.jar g1.t.s.def.Generic<T> g1.t.s.def.Generic.foo() ERASURE_MATCH" ); } public void testBug83304_TypeGenericElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_TypeParameterizedElementPattern(); IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g1.t.s.def", "Generic.class").getType(); search(type, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Types.java [g1.t.s.def.Generic] EQUIVALENT_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen [Generic] ERASURE_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_obj [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_exc [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_wld [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_thr [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_run [Generic] ERASURE_MATCH\n" + "lib/JavaSearch15.jar g1.t.s.def.Generic<T> g1.t.s.def.Generic.foo() EXACT_MATCH" ); } public void testBug83304_TypeStringPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_TypeParameterizedElementPattern(); search("Generic<? super Exception>", TYPE, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Types.java [Generic] EQUIVALENT_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen [Generic] EQUIVALENT_RAW_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_obj [Generic] EQUIVALENT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_exc [Generic] EQUIVALENT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_wld [Generic] EQUIVALENT_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_thr [Generic] ERASURE_MATCH\n" + "src/b83304/Types.java b83304.Types.gen_run [Generic] ERASURE_MATCH\n" + "lib/JavaSearch15.jar g1.t.s.def.Generic<T> g1.t.s.def.Generic.foo() ERASURE_MATCH" ); } private void setUpBug83304_MethodParameterizedElementPattern() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Methods.java", "package b83304;\n" + "import g5.m.def.Single;\n" + "public class Methods {\n" + " void test() {\n" + " Single<Exception> gs = new Single<Exception>();\n" + " Exception exc = new Exception();\n" + " gs.<Throwable>generic(exc);\n" + " gs.<Exception>generic(exc);\n" + " gs.<String>generic(\"\");\n" + " }\n" + "}\n" ); } public void testBug83304_MethodParameterizedElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_MethodParameterizedElementPattern(); IMethod method = selectMethod(this.workingCopies[0], "generic", 2); search(method, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] ERASURE_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] EXACT_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(\"\")] ERASURE_MATCH" ); } public void testBug83304_MethodGenericElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_MethodParameterizedElementPattern(); IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.m.def", "Single.class").getType(); IMethod method = type.getMethod("generic", new String[] { "TU;" }); search(method, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] ERASURE_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] ERASURE_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(\"\")] ERASURE_MATCH" ); } public void testBug83304_MethodStringPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_MethodParameterizedElementPattern(); search("<Exception>generic", METHOD, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] ERASURE_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(exc)] EXACT_MATCH\n" + "src/b83304/Methods.java void b83304.Methods.test() [generic(\"\")] ERASURE_MATCH" ); } private void setUpBug83304_ConstructorGenericElementPattern() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83304/Constructors.java", "package b83304;\n" + "import g5.c.def.Single;\n" + "public class Constructors {\n" + " void test() {\n" + " Exception exc= new Exception();\n" + " new <Throwable>Single<String>(\"\", exc);\n" + " new <Exception>Single<String>(\"\", exc);\n" + " new <String>Single<String>(\"\", \"\");\n" + " }\n" + "}\n" ); } public void testBug83304_ConstructorGenericElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_ConstructorGenericElementPattern(); IMethod method = selectMethod(this.workingCopies[0], "Single", 3); search(method, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Constructors.java void b83304.Constructors.test() [new <Throwable>Single<String>(\"\", exc)] ERASURE_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <Exception>Single<String>(\"\", exc)] EXACT_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <String>Single<String>(\"\", \"\")] ERASURE_MATCH" ); } public void testBug83304_ConstructorParameterizedElementPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_ConstructorGenericElementPattern(); IType type = getClassFile("JavaSearchBugs", "lib/JavaSearch15.jar", "g5.c.def", "Single.class").getType(); IMethod method = type.getMethod("Single", new String[] { "TT;", "TU;" }); search(method, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Constructors.java void b83304.Constructors.test() [new <Throwable>Single<String>(\"\", exc)] ERASURE_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <Exception>Single<String>(\"\", exc)] ERASURE_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <String>Single<String>(\"\", \"\")] ERASURE_MATCH" ); } public void testBug83304_ConstructorStringPattern() throws CoreException { this.resultCollector.showRule(); setUpBug83304_ConstructorGenericElementPattern(); search("<Exception>Single", CONSTRUCTOR, REFERENCES, ERASURE_RULE); assertSearchResults( "src/b83304/Constructors.java void b83304.Constructors.test() [new <Throwable>Single<String>(\"\", exc)] ERASURE_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <Exception>Single<String>(\"\", exc)] EXACT_MATCH\n" + "src/b83304/Constructors.java void b83304.Constructors.test() [new <String>Single<String>(\"\", \"\")] ERASURE_MATCH\n" + "lib/JavaSearch15.jar g5.m.def.Single<T> g5.m.def.Single.returnParamType() ERASURE_MATCH\n" + "lib/JavaSearch15.jar g5.m.def.Single<T> g5.m.def.Single.complete(U, g5.m.def.Single<T>) ERASURE_MATCH" ); } /** * @bug 83804: [1.5][javadoc] Missing Javadoc node for package declaration * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83804" */ private void setUpBug83804_Type() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83804/package-info.java", "/**\n" + " * Valid javadoc.\n" + " * @see Test\n" + " * @see Unknown\n" + " * @see Test#foo()\n" + " * @see Test#unknown()\n" + " * @see Test#field\n" + " * @see Test#unknown\n" + " * @param unexpected\n" + " * @throws unexpected\n" + " * @return unexpected \n" + " */\n" + "package b83804;\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b83804/Test.java", "/**\n" + " * Invalid javadoc\n" + " */\n" + "package b83804;\n" + "public class Test {\n" + " public int field;\n" + " public void foo() {}\n" + "}\n" ); } public void testBug83804_Type() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug83804_Type(); IType type = this.workingCopies[1].getType("Test"); search(type, REFERENCES); assertSearchResults( "src/b83804/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b83804/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b83804/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b83804/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b83804/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC" ); } public void testBug83804_Method() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug83804_Type(); IMethod[] methods = this.workingCopies[1].getType("Test").getMethods(); assertEquals("Invalid number of methods", 1, methods.length); search(methods[0], REFERENCES); assertSearchResults( "src/b83804/package-info.java [foo()] EXACT_MATCH INSIDE_JAVADOC" ); } public void testBug83804_Field() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug83804_Type(); IField[] fields = this.workingCopies[1].getType("Test").getFields(); assertEquals("Invalid number of fields", 1, fields.length); search(fields[0], REFERENCES); assertSearchResults( "src/b83804/package-info.java [field] EXACT_MATCH INSIDE_JAVADOC" ); } /** * @bug 83388: [1.5][search] Search for varargs method not finding match * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83388" */ public void testBug83388() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java", "package b83388;\n" + "import b83388.*;\n" + "public class R {}\n" ); IImportDeclaration importDeclaration = this.workingCopies[0].getImport("pack"); assertNotNull("Cannot find \"pack\" import declaration for "+this.workingCopies[0].getElementName(), importDeclaration); SearchPattern pattern = SearchPattern.createPattern( "pack", PACKAGE, DECLARATIONS, EXACT_RULE); assertNotNull("Pattern should not be null", pattern); MatchLocator.setFocus(pattern, importDeclaration); new SearchEngine(this.workingCopies).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchScope(), this.resultCollector, null ); assertSearchResults( "src/b83388/R.java b83388 [No source] EXACT_MATCH" ); } public void testBug83388b() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83388/R.java", "package b83388;\n" + "import b83388.*;\n" + "public class R {}\n" ); IPackageDeclaration packageDeclaration = this.workingCopies[0].getPackageDeclaration("pack"); assertNotNull("Cannot find \"pack\" import declaration for "+this.workingCopies[0].getElementName(), packageDeclaration); SearchPattern pattern = SearchPattern.createPattern( "pack", PACKAGE, DECLARATIONS, EXACT_RULE); assertNotNull("Pattern should not be null", pattern); MatchLocator.setFocus(pattern, packageDeclaration); new SearchEngine(this.workingCopies).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchScope(), this.resultCollector, null ); assertSearchResults( "src/b83388/R.java b83388 [No source] EXACT_MATCH" ); } /** * @bug 83693: [search][javadoc] References to methods/constructors: range does not include parameter lists * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83693" */ public void testBug83693() throws CoreException { this.resultCollector.showRule(); this.resultCollector.showInsideDoc(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83693/A.java", "package b83693;\n" + "import static b83693.A.m;\n" + "/**\n" + " * @see A#m(int)\n" + " */\n" + "class A {\n" + " static void m(int i) {\n" + " b83693.A.m(i);\n" + " }\n" + "}" ); IMethod[] methods = this.workingCopies[0].getType("A").getMethods(); assertEquals("Invalid number of methods", 1, methods.length); search(methods[0], REFERENCES); assertSearchResults( "src/b83693/A.java [b83693.A.m] EXACT_MATCH OUTSIDE_JAVADOC\n" + "src/b83693/A.java b83693.A [m(int)] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b83693/A.java void b83693.A.m(int) [m(i)] EXACT_MATCH OUTSIDE_JAVADOC" ); } /** * @bug 83716: [search] refs to 2-arg constructor on Action found unexpected matches * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=83716" * * Note that this test does verify that bug is really fixed, but only that it has no impact * on existing behavior. It was not really possible to put a test in this suite to verify that * bug is effectively fixed as it appears only to potential match found in plugin dependencies... */ public void testBug83716() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b83716/X.java", "package b83716;\n" + "public class X {\n" + " X() {}\n" + " X(int x) {}\n" + "}\n" + "class Y extends X {\n" + " Y(int y) {\n" + " }\n" + "}" ); search("X", CONSTRUCTOR, REFERENCES); assertSearchResults( "src/b83716/X.java b83716.Y(int) [Y] EXACT_MATCH" ); } /** * @bug 84100: [1.5][search] Search for varargs method not finding match * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84100" */ private void setUpBug84100() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84100/X.java", "package b84100;\n" + "public class X {\n" + " void foo() {}\n" + " void foo(String s) {}\n" + " void foo(String... xs) {}\n" + " void foo(int x, String... xs) {}\n" + " void foo(String s, int x, String... xs) {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b84100/Z.java", "package b84100;\n" + "public class Z {\n" + " X x;\n" + " void foo() {\n" + " x.foo();\n" + " x.foo(\"\");\n" + " x.foo(\"\", \"\");\n" + " x.foo(\"\", \"\", null);\n" + " x.foo(3, \"\", \"\");\n" + " x.foo(\"\", 3, \"\", \"\");\n" + " }\n" + "}\n" ); } public void testBug84100() throws CoreException { this.resultCollector.showRule(); setUpBug84100(); IMethod method = selectMethod(this.workingCopies[0], "foo", 1); search(method, REFERENCES); assertSearchResults( "src/b84100/Z.java void b84100.Z.foo() [foo()] EXACT_MATCH" ); } public void testBug84100b() throws CoreException { this.resultCollector.showRule(); setUpBug84100(); IMethod method = selectMethod(this.workingCopies[0], "foo", 2); search(method, REFERENCES); assertSearchResults( "src/b84100/Z.java void b84100.Z.foo() [foo(\"\")] EXACT_MATCH" ); } public void testBug84100c() throws CoreException { this.resultCollector.showRule(); setUpBug84100(); IMethod method = selectMethod(this.workingCopies[0], "foo", 3); search(method, REFERENCES); assertSearchResults( "src/b84100/Z.java void b84100.Z.foo() [foo(\"\", \"\")] EXACT_MATCH\n" + "src/b84100/Z.java void b84100.Z.foo() [foo(\"\", \"\", null)] EXACT_MATCH" ); } public void testBug84100d() throws CoreException { this.resultCollector.showRule(); setUpBug84100(); IMethod method = selectMethod(this.workingCopies[0], "foo", 4); search(method, REFERENCES); assertSearchResults( "src/b84100/Z.java void b84100.Z.foo() [foo(3, \"\", \"\")] EXACT_MATCH" ); } public void testBug84100e() throws CoreException { this.resultCollector.showRule(); setUpBug84100(); IMethod method = selectMethod(this.workingCopies[0], "foo", 5); search(method, REFERENCES); assertSearchResults( "src/b84100/Z.java void b84100.Z.foo() [foo(\"\", 3, \"\", \"\")] EXACT_MATCH" ); } /** * @bug 84121: [1.5][search][varargs] reference to type reported as inaccurate in vararg * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84121" */ public void testBug84121() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84121/Test.java", "package b84121;\n" + "public class Test {\n" + " void foo(Test... t) {}\n" + " void foo(int x, Test... t) {}\n" + " void foo(Test[] t1, Test... t2) {}\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); search(type, REFERENCES); assertSearchResults( "src/b84121/Test.java void b84121.Test.foo(Test ...) [Test] EXACT_MATCH\n" + "src/b84121/Test.java void b84121.Test.foo(int, Test ...) [Test] EXACT_MATCH\n" + "src/b84121/Test.java void b84121.Test.foo(Test[], Test ...) [Test] EXACT_MATCH\n" + "src/b84121/Test.java void b84121.Test.foo(Test[], Test ...) [Test] EXACT_MATCH" ); } /** * @bug 84724: [1.5][search] Search for varargs method not finding match * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84724" */ private void setUpBug84724() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84724/X.java", "package b84724;\n" + "public class X {\n" + " X(String s) {}\n" + " X(String... v) {}\n" + " X(int x, String... v) {}\n" + " X(String s, int x, String... v) {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b84724/Z.java", "package b84724;\n" + "public class Z {\n" + " void foo() {\n" + " new X();\n" + " new X(\"\");\n" + " new X(\"\", \"\");\n" + " new X(\"\", \"\", null);\n" + " new X(3, \"\", \"\");\n" + " new X(\"\", 3, \"\", \"\");\n" + " }\n" + "}\n" ); } public void testBug84724() throws CoreException { this.resultCollector.showRule(); setUpBug84724(); IMethod method = selectMethod(this.workingCopies[0], "X", 2); search(method, REFERENCES); assertSearchResults( "src/b84724/Z.java void b84724.Z.foo() [new X(\"\")] EXACT_MATCH" ); } public void testBug84724b() throws CoreException { this.resultCollector.showRule(); setUpBug84724(); IMethod method = selectMethod(this.workingCopies[0], "X", 3); search(method, REFERENCES); assertSearchResults( "src/b84724/Z.java void b84724.Z.foo() [new X()] EXACT_MATCH\n" + "src/b84724/Z.java void b84724.Z.foo() [new X(\"\", \"\")] EXACT_MATCH\n" + "src/b84724/Z.java void b84724.Z.foo() [new X(\"\", \"\", null)] EXACT_MATCH" ); } public void testBug84724c() throws CoreException { this.resultCollector.showRule(); setUpBug84724(); IMethod method = selectMethod(this.workingCopies[0], "X", 4); search(method, REFERENCES); assertSearchResults( "src/b84724/Z.java void b84724.Z.foo() [new X(3, \"\", \"\")] EXACT_MATCH" ); } public void testBug84724d() throws CoreException { this.resultCollector.showRule(); setUpBug84724(); IMethod method = selectMethod(this.workingCopies[0], "X", 5); search(method, REFERENCES); assertSearchResults( "src/b84724/Z.java void b84724.Z.foo() [new X(\"\", 3, \"\", \"\")] EXACT_MATCH" ); } /** * @bug 84727: [1.5][search] String pattern search does not work with multiply nested types * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=84727" */ private void setUpBug84727() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b84727/A.java", "package b84727;\n" + "public interface A {\n" + " Set<Set<Exception>> getXYZ(List<Set<Exception>> arg);\n" + " void getXYZ(String s);\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b84727/X.java", "package b84727;\n" + "public class X {\n" + " A a;\n" + " void foo() {\n" + " a.getXYZ(new ArrayList());\n" + " a.getXYZ(\"\");\n" + " }\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b84727/List.java", "package b84727;\n" + "public interface List<E> {}\n" + "interface Set<E> {}\n" + "class ArrayList<E> implements List<E> {}" ); } public void testBug84727() throws CoreException { this.resultCollector.showRule(); setUpBug84727(); IMethod[] methods = this.workingCopies[0].getType("A").getMethods(); assertEquals("Invalid number of methods", 2, methods.length); search(methods[0], REFERENCES); assertSearchResults( "src/b84727/X.java void b84727.X.foo() [getXYZ(new ArrayList())] EXACT_MATCH" ); } public void testBug84727b() throws CoreException { this.resultCollector.showRule(); setUpBug84727(); IMethod[] methods = this.workingCopies[0].getType("A").getMethods(); assertEquals("Invalid number of methods", 2, methods.length); search(methods[1], REFERENCES); assertSearchResults( "src/b84727/X.java void b84727.X.foo() [getXYZ(\"\")] EXACT_MATCH" ); } /** * @bug 85810: [1.5][search] Missed type parameter reference in implements clause * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=85810" */ public void testBug85810() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b85810/Test.java", "package b85810;\n" + "public class Test<E> implements In<Test<E>> {\n" + " E e;\n" + "}\n" + "interface In<T> {}\n" ); ITypeParameter param = selectTypeParameter(this.workingCopies[0], "E"); search(param, REFERENCES); assertSearchResults( "src/b85810/Test.java b85810.Test [E] EXACT_MATCH\n" + "src/b85810/Test.java b85810.Test.e [E] EXACT_MATCH" ); } /** * @bug 86596: [search] Search for type finds segments in import * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86596" */ public void testBug86596() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86596/aa/link/A.java", "package b86596.aa.link;\n" + "public interface A {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b86596/bb/Link.java", "package b86596.bb;\n" + "public class Link{}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b86596/cc/X.java", "package b86596.cc;\n" + "import b86596.aa.link.A;\n" + "import b86596.bb.Link;\n" + "public class X {\n" + " A a;\n" + " Link l;\n" + "}\n" ); search("Link", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH); assertSearchResults( "src/b86596/cc/X.java [Link] EXACT_RAW_MATCH\n" + "src/b86596/cc/X.java b86596.cc.X.l [Link] EXACT_MATCH" ); } /** * @bug 86642: [search] no match found of package-visible supertypes in subtypes * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86642" */ public void testBug86642() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86642/A.java", "package b86642;\n" + "class A {\n" + " public void m() {}\n" + " protected void f(A a){}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b86642/B.java", "package b86642;\n" + "public class B extends A{\n" + " protected void f(A a){\n" + " a.m();\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("A"); search(type, REFERENCES); assertSearchResults( "src/b86642/A.java void b86642.A.f(A) [A] EXACT_MATCH\n" + "src/b86642/B.java b86642.B [A] EXACT_MATCH\n" + "src/b86642/B.java void b86642.B.f(A) [A] EXACT_MATCH" ); } /** * @bug 86293: [search] Search for method declaration with pattern "run()" reports match in binary field instead of anonymous class * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86293" */ public void testBug86293() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b86293.jar", "", "I86293.class").getType(); IMethod method = type.getMethod("m86293", new String[0]); search(method, DECLARATIONS); assertSearchResults( "lib/b86293.jar void <anonymous>.m86293() EXACT_MATCH\n" + "lib/b86293.jar void I86293.m86293() EXACT_MATCH" ); } /** * @bug 86380: [1.5][search][annot] Add support to find references inside annotations on a package declaration * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=86380" */ private void setUpBug86380() throws CoreException { this.resultCollector.showInsideDoc(); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b86380/package-info.java", "/**\n" + " * @see Annot#field\n" + " */\n" + "@Annot(value=11)\n" + "package b86380;\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b86380/Test.java", "package b86380;\n" + "@Annot(12) public class Test {\n" + " public int field = Annot.field;\n" + " public void foo() {}\n" + "}\n" ); } public void testBug86380_Type() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug86380(); ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); IType type = unit.getType("Annot"); search(type, REFERENCES); assertSearchResults( "src/b86380/Test.java b86380.Test [Annot] EXACT_MATCH OUTSIDE_JAVADOC\n" + "src/b86380/Test.java b86380.Test.field [Annot] EXACT_MATCH OUTSIDE_JAVADOC\n" + "src/b86380/package-info.java [Annot] EXACT_MATCH INSIDE_JAVADOC\n" + "src/b86380/package-info.java [Annot] EXACT_MATCH OUTSIDE_JAVADOC" ); } public void testBug86380_Method() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug86380(); ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); IMethod[] methods = unit.getType("Annot").getMethods(); assertEquals("Invalid number of methods", 1, methods.length); search(methods[0], REFERENCES); assertSearchResults( "src/b86380/Test.java b86380.Test [12] EXACT_MATCH OUTSIDE_JAVADOC\n" + "src/b86380/package-info.java [value] EXACT_MATCH OUTSIDE_JAVADOC" ); } public void testBug86380_Field() throws CoreException { this.resultCollector.showInsideDoc(); setUpBug86380(); ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b86380", "Annot.java"); IField[] fields = unit.getType("Annot").getFields(); assertEquals("Invalid number of fields", 1, fields.length); search(fields[0], REFERENCES); assertSearchResults( "src/b86380/Test.java b86380.Test.field [field] EXACT_MATCH OUTSIDE_JAVADOC\n" + "src/b86380/package-info.java [field] EXACT_MATCH INSIDE_JAVADOC" ); } /** * @bug 88174: [1.5][search][annot] Search for annotations misses references in default and values constructs * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=88174" */ public void testBug88174() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88174/Test.java", "package b88174;\n" + "public enum Test {\n" + " a {\n" + " int getTheValue() { // not found\n" + " return 0;\n" + " }\n" + " };\n" + " abstract int getTheValue();\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b88174/X.java", "package b88174;\n" + "public class X {\n" + " X x = new X() {\n" + " int getTheValue() {\n" + " return 0;\n" + " }\n" + " };\n" + " int getTheValue() { return 0; }\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Test").getMethod("getTheValue", new String[0]); search(method, DECLARATIONS | IGNORE_DECLARING_TYPE); assertSearchResults( "src/b88174/Test.java int b88174.Test.a:<anonymous>#1.getTheValue() [getTheValue] EXACT_MATCH\n" + "src/b88174/Test.java int b88174.Test.getTheValue() [getTheValue] EXACT_MATCH\n" + "src/b88174/X.java int b88174.X.x:<anonymous>#1.getTheValue() [getTheValue] EXACT_MATCH\n" + "src/b88174/X.java int b88174.X.getTheValue() [getTheValue] EXACT_MATCH" ); } /** * @bug 87627: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=87627" */ public void testBug87627() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b87627.jar", "b87627", "List.class").getType(); ITypeParameter[] parameters = type.getTypeParameters(); assertNotNull(type.getFullyQualifiedName()+" should have parameters", parameters); assertEquals("Wrong number of parameters", 1, parameters.length); search(parameters[0], REFERENCES); assertSearchResults( "lib/b87627.jar b87627.List EXACT_MATCH\n" + "lib/b87627.jar boolean b87627.List.addAll(b87627.Collection<? extends E>) EXACT_MATCH" ); } /** * @bug 88300: [search] Reference search result is changed by placement of private method * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=88300" */ public void testBug88300() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88300/SubClass.java", "package b88300;\n" + "public class SubClass extends SuperClass {\n" + " private void aMethod(String x) {\n" + " }\n" + " public void aMethod(Object x) {\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b88300/SuperClass.java", "package b88300;\n" + "public class SuperClass {\n" + " public void aMethod(Object x) {\n" + " }\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b88300/User.java", "package b88300;\n" + "public class User {\n" + " public void methodUsingSubClassMethod() {\n" + " SuperClass user = new SubClass();\n" + " user.aMethod(new Object());\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("SubClass"); search(type.getMethods()[1], REFERENCES); assertSearchResults( "src/b88300/User.java void b88300.User.methodUsingSubClassMethod() [aMethod(new Object())] EXACT_MATCH" ); } public void testBug88300b() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88300/SubClass.java", "package b88300;\n" + "public class SubClass extends SuperClass {\n" + " public void aMethod(Object x) {\n" + " }\n" + " private void aMethod(String x) {\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b88300/SuperClass.java", "package b88300;\n" + "public class SuperClass {\n" + " public void aMethod(Object x) {\n" + " }\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b88300/User.java", "package b88300;\n" + "public class User {\n" + " public void methodUsingSubClassMethod() {\n" + " SuperClass user = new SubClass();\n" + " user.aMethod(new Object());\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("SubClass"); search(type.getMethods()[0], REFERENCES); assertSearchResults( "src/b88300/User.java void b88300.User.methodUsingSubClassMethod() [aMethod(new Object())] EXACT_MATCH" ); } public void testBug88300c() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b88300/not/fixed/ConditionalFlowInfo.java", "package b88300.not.fixed;\n" + "public class ConditionalFlowInfo extends FlowInfo {\n" + " public FlowInfo info;\n" + " ConditionalFlowInfo(FlowInfo info){\n" + " this.info = info;\n" + " }\n" + " public void markAsDefinitelyNull(FieldBinding field) {\n" + " info.markAsDefinitelyNull(field);\n" + " }\n" + " public void markAsDefinitelyNull(LocalVariableBinding local) {\n" + " info.markAsDefinitelyNull(local);\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b88300/not/fixed/FlowInfo.java", "package b88300.not.fixed;\n" + "\n" + "class FieldBinding {\n" + " int id;\n" + "}\n" + "class LocalVariableBinding extends FieldBinding {}\n" + "\n" + "public abstract class FlowInfo {\n" + " abstract public void markAsDefinitelyNull(LocalVariableBinding local);\n" + " abstract public void markAsDefinitelyNull(FieldBinding field);\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b88300/not/fixed/UnconditionalFlowInfo.java", "package b88300.not.fixed;\n" + "public class UnconditionalFlowInfo extends FlowInfo {\n" + " final private void markAsDefinitelyNull(int position) {}\n" + " public void markAsDefinitelyNull(FieldBinding field) {\n" + " markAsDefinitelyNull(field.id);\n" + " }\n" + " public void markAsDefinitelyNull(LocalVariableBinding local) {\n" + " markAsDefinitelyNull(local.id + 1);\n" + " }\n" + "}\n" ); IType type = this.workingCopies[2].getType("UnconditionalFlowInfo"); search(type.getMethods()[2], REFERENCES); assertSearchResults( "src/b88300/not/fixed/ConditionalFlowInfo.java void b88300.not.fixed.ConditionalFlowInfo.markAsDefinitelyNull(LocalVariableBinding) [markAsDefinitelyNull(local)] EXACT_MATCH" ); } /** * @bug 89686: [1.5][search] JavaModelException on ResolvedSourceMethod during refactoring * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=89686" */ public void testBug89686() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b89686/A.java", "package b89686;\n" + "public enum Color {\n" + " RED, GREEN(), BLUE(17), PINK((1+(1+1))) {/*anon*/};\n" + " Color() {}\n" + " Color(int i) {}\n" + "}" ); IType type = this.workingCopies[0].getType("Color"); IMethod method = type.getMethod("Color", new String[0]); search(method, REFERENCES); assertSearchResults( "src/b89686/A.java b89686.Color.RED [RED] EXACT_MATCH\n" + "src/b89686/A.java b89686.Color.GREEN [GREEN()] EXACT_MATCH" ); } public void testBug89686b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b89686/A.java", "package b89686;\n" + "public enum Color {\n" + " RED, GREEN(), BLUE(17), PINK((1+(1+1))) {/*anon*/};\n" + " Color() {}\n" + " Color(int i) {}\n" + "}" ); IType type = this.workingCopies[0].getType("Color"); IMethod method = type.getMethod("Color", new String[] { "I"} ); search(method, REFERENCES); assertSearchResults( "src/b89686/A.java b89686.Color.BLUE [BLUE(17)] EXACT_MATCH\n" + "src/b89686/A.java b89686.Color.PINK [PINK((1+(1+1)))] EXACT_MATCH" ); } /** * @bug 89848: [search] does not find method references in anonymous class of imported jarred plugin * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=89848" */ public void testBug89848() throws CoreException { IType classFile = getClassFile("JavaSearchBugs", "lib", "b89848", "X.class").getType(); IMethod method = classFile.getMethod("foo", new String[0]); search(method, ALL_OCCURRENCES); assertSearchResults( "lib/b89848/Test.class void b89848.Test.foo() EXACT_MATCH\n" + "lib/b89848/X.class void b89848.X.foo() EXACT_MATCH" ); } /** * @bug 90779: [search] Constructor Declaration search with ignoring declaring and return type also ignores type name * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=90779" */ public void testBug90779() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b90779/A.java", "package b90779;\n" + "public class A {\n" + " public A() {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b90779/B.java", "package b90779;\n" + "public class B {\n" + " public B() {}\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b90779/C.java", "package b90779;\n" + "public class C {\n" + " public C() {}\n" + "}\n" ); IType type = this.workingCopies[0].getType("A"); IMethod[] methods = type.getMethods(); assertEquals("Wrong number of methods", 1, methods.length); search(methods[0], DECLARATIONS | IGNORE_DECLARING_TYPE | IGNORE_RETURN_TYPE); assertSearchResults( "src/b90779/A.java b90779.A() [A] EXACT_MATCH" ); } /** * @bug 90915: [1.5][search] NPE in PatternLocator * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=90915" */ public void testBug90915() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b90915/X.java", "package b90915;\n" + "import g5.m.def.Single;\n" + "public class X<T> {\n" + " void foo() {\n" + " Single<String> single = new Single<String>() {\n" + " public <U> String generic(U u) { return \"\"; }\n" + " public void paramTypesArgs(Single<String> gs) {}\n" + " };\n" + " single.paramTypesArgs(null);\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("X"); IMethod[] methods = type.getMethods(); assertEquals("Wrong number of methods", 1, methods.length); IType anonymous = methods[0].getType("", 1); assertNotNull("Cannot find anonymous in method foo()", anonymous); methods = anonymous.getMethods(); assertEquals("Wrong number of methods", 2, methods.length); search(methods[1], REFERENCES); assertSearchResults( "src/b90915/X.java void b90915.X.foo() [paramTypesArgs(null)] EXACT_MATCH" ); } /** * @bug 91542: [1.5][search] JavaModelException on ResolvedSourceMethod during refactoring * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=91542" */ public void testBug91542() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b91542/A.java", "package b91542;\n" + "\n" + "class A<T> {\n" + " void a(A<T> a){}\n" + "}\n" + "\n" + "class B<T> extends A<T> {\n" + " protected void foo() { \n" + " a(this);\n" + " }\n" + "}" ); IType type = this.workingCopies[0].getType("B"); IMethod method = type.getMethod("foo", new String[0]); searchDeclarationsOfSentMessages(method, this.resultCollector); assertSearchResults( "src/b91542/A.java void b91542.A.a(A<T>) [a(A<T> a)] EXACT_MATCH" ); } /** * @bug 91078: [search] Java search for package reference wrongly identifies inner class as package * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=91078" */ public void testBug91078() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b91078/test/Example.java", "package b91078.test;\n" + "import b91078.util.HashMap;\n" + "import b91078.util.Map;\n" + "public class Example {\n" + " public Map.Entry logAll(Object obj) {\n" + " if (obj instanceof b91078.util.HashMap) {\n" + " HashMap map = (HashMap) obj;\n" + " return map.entry;\n" + " }\n" + " if (obj instanceof b91078.util.HashMap.Entry) {\n" + " Map.Entry entry = (Map.Entry) obj;\n" + " return entry;\n" + " }\n" + " return null;\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b91078/util/HashMap.java", "package b91078.util;\n" + "public class HashMap implements Map {\n" + " public Entry entry;\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b91078/util/Map.java", "package b91078.util;\n" + "public interface Map {\n" + " class Entry{}\n" + "}\n" ); search("*", PACKAGE, REFERENCES, getJavaSearchWorkingCopiesScope(this.workingCopies[0])); assertSearchResults( "src/b91078/test/Example.java [b91078.util] EXACT_MATCH\n" + "src/b91078/test/Example.java [b91078.util] EXACT_MATCH\n" + "src/b91078/test/Example.java Map.Entry b91078.test.Example.logAll(Object) [b91078.util] EXACT_MATCH\n" + "src/b91078/test/Example.java Map.Entry b91078.test.Example.logAll(Object) [b91078.util] EXACT_MATCH" ); } /** * @bug 92264: [search] all types names should support patterns for package/enclosing type name * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92264" */ public void testBug92264a() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( "*.lang".toCharArray(), SearchPattern.R_PATTERN_MATCH, // case insensitive IIndexConstants.ONE_STAR, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.CharSequence\n" + "java.lang.Class\n" + "java.lang.CloneNotSupportedException\n" + "java.lang.Comparable\n" + "java.lang.Deprecated\n" + "java.lang.Enum\n" + "java.lang.Error\n" + "java.lang.Exception\n" + "java.lang.IllegalMonitorStateException\n" + "java.lang.InterruptedException\n" + "java.lang.Object\n" + "java.lang.RuntimeException\n" + "java.lang.String\n" + "java.lang.Throwable", requestor); } public void testBug92264b() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( "*.lang*".toCharArray(), SearchPattern.R_PATTERN_MATCH, // case insensitive "*tion".toCharArray(), SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.CloneNotSupportedException\n" + "java.lang.Exception\n" + "java.lang.IllegalMonitorStateException\n" + "java.lang.InterruptedException\n" + "java.lang.RuntimeException\n" + "java.lang.annotation.Annotation\n" + "java.lang.annotation.Retention", requestor); } public void testBug92264c() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( "*.test*".toCharArray(), SearchPattern.R_PATTERN_MATCH, // case insensitive IIndexConstants.ONE_STAR, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "Test$Inner\n" + "b123679.test.Test\n" + "b123679.test.Test$StaticClass\n" + "b123679.test.Test$StaticClass$Member\n" + "b124645.test.A_124645\n" + "b124645.test.X_124645\n" + "b127628.Test127628$Member127628\n" + "b95794.Test$Color\n" + "pack.age.Test$Member\n" + "test.Test$StaticClass\n" + "test.Test$StaticClass$Member", requestor); } public void testBug92264d() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( "b12*".toCharArray(), SearchPattern.R_PATTERN_MATCH, // case insensitive new char[] { 'X' }, SearchPattern.R_PREFIX_MATCH, // case insensitive TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b124645.test.X_124645\n" + "b124645.xy.X_124645", requestor); } /** * @bug 92944: [1.5][search] SearchEngine#searchAllTypeNames doesn't honor enum or annotation element kind * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92944" */ private void setUpBug92944() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b92944/Test.java", "package b92944;\n" + "interface B92944_I {}\n" + "enum B92944_E {}\n" + "@interface B92944_A {}\n" + "public class B92944 {}\n" ); } public void testBug92944_TYPE() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, getJavaSearchScopeBugs("b92944", true), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b92944.B92944\n" + "b92944.B92944_A\n" + "b92944.B92944_E\n" + "b92944.B92944_I", requestor); } public void testBug92944_CLASS() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, IIndexConstants.ONE_STAR, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); // Remove interface, enum and annotation assertSearchResults( "Unexpected all type names", "b92944.B92944", requestor); } public void testBug92944_CLASS_AND_INTERFACE() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS_AND_INTERFACE, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); // Remove enum and annotation assertSearchResults( "Unexpected all type names", "b92944.B92944\n" + "b92944.B92944_I", // Annotation is an interface in java.lang requestor); } public void testBug92944_CLASS_AND_ENUM() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive CLASS_AND_ENUM, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); // Remove interface and annotation assertSearchResults( "Unexpected all type names", "b92944.B92944\n" + "b92944.B92944_E", requestor); } public void testBug92944_INTERFACE() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive INTERFACE, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b92944.B92944_I", requestor); } public void testBug92944_ENUM() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive ENUM, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b92944.B92944_E", requestor); } public void testBug92944_ANNOTATION_TYPE() throws CoreException { this.resultCollector.showRule(); setUpBug92944(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive ANNOTATION_TYPE, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b92944.B92944_A", requestor); } /** * @bug 93392: [1.5][search][annot] search for annotation elements does not seem to be implemented yet * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=93392" * * Note that this test valid also: * @bug 94062: [1.5][search][annot] search for annotation elements incorrect match range * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=94062" */ public void testBug93392() throws CoreException { TestCollector collector = new TestCollector(); collector.showAccuracy(true); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b93392/Test.java", "package b93392;\n" + "@interface Annot {\n" + " int value();\n" + "}\n" + "@Annot(41)\n" + "public class Test {\n" + " @Annot(21)\n" + " int bar;\n" + " @Annot(10)\n" + " public void foo() {}\n" + "}\n" ); IType type = selectType(this.workingCopies[0], "Annot"); IMethod method = type.getMethod("value", new String[0]); search(method, REFERENCES, getJavaSearchScope(), collector); assertSearchResults( "src/b93392/Test.java b93392.Test [41] EXACT_MATCH\n" + "src/b93392/Test.java b93392.Test.bar [21] EXACT_MATCH\n" + "src/b93392/Test.java void b93392.Test.foo() [10] EXACT_MATCH", collector ); // Verify matches positions String source = this.workingCopies[0].getSource(); String str = "@Annot("; // First match assertEquals("Invalid number of matches", 3, collector.matches.size()); int index= source.indexOf(str)+str.length(); assertEquals("Invalid offset for first match", index, ((SearchMatch)collector.matches.get(0)).getOffset()); assertEquals("Invalid length for first match", 2, ((SearchMatch)collector.matches.get(0)).getLength()); // Second match index= source.indexOf(str, index)+str.length(); assertEquals("Invalid offset for second match", index, ((SearchMatch)collector.matches.get(1)).getOffset()); assertEquals("Invalid length for second match", 2, ((SearchMatch)collector.matches.get(1)).getLength()); // Last match index= source.indexOf(str, index)+str.length(); assertEquals("Invalid offset for last match", index, ((SearchMatch)collector.matches.get(2)).getOffset()); assertEquals("Invalid length for last match", 2, ((SearchMatch)collector.matches.get(2)).getLength()); } /** * @bug 94160: [1.5][search] Generic method in superclass does not exist * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=94160" */ public void testBug94160() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b94160/Test.java", "package b94160;\n" + "public class Test {\n" + " <T> List<T> generateList(Class<T> clazz) {\n" + " return new ArrayList<T>();\n" + " }\n" + "}\n" + "class CTest extends Test {\n" + " private List<String> myList = generateList(String.class);\n" + " CTest() {\n" + " myList = new ArrayList<String>();\n" + " }\n" + "}\n" + "interface List<E> {}\n" + "class ArrayList<E> implements List<E> {}" ); IType type = this.workingCopies[0].getType("CTest"); IField field = type.getField("myList"); new SearchEngine(this.workingCopies).searchDeclarationsOfSentMessages(field, this.resultCollector, null); assertSearchResults( "src/b94160/Test.java List<T> b94160.Test.generateList(Class<T>) [generateList(Class<T> clazz)] EXACT_MATCH" ); } /** * @bug 94389: [search] InvocationTargetException on Rename * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=94389" */ public void testBug94389() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b94389/Test.java", "package b94389;\n" + "public class Test {\n" + " public void foo() {}\n" + " public void foo() {}\n" + " public void foo() {}\n" + " public void foo() {}\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); IMethod[] methods = type.getMethods(); int methodsLength = methods.length; // Perform search on each duplicate method IJavaSearchScope scope = getJavaSearchScope(); for (int m=0; m<methodsLength; m++) { // Search method declaration TestCollector collector = new TestCollector(); search(methods[m], DECLARATIONS, scope, collector); assertSearchResults( "src/b94389/Test.java void b94389.Test.foo() [foo]\n" + "src/b94389/Test.java void b94389.Test.foo() [foo]\n" + "src/b94389/Test.java void b94389.Test.foo() [foo]\n" + "src/b94389/Test.java void b94389.Test.foo() [foo]", collector ); // Verify that all matches have correct occurence count int size = collector.matches.size(); for (int i=0; i<size; i++) { assertEquals("Invalid foo method occurence count (m="+(m+1)+")", i+1, ((SourceMethod) methods[i]).occurrenceCount); } } } /** * @bug 94718: [1.5][search][annot] Find references in workspace breaks on an annotation * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=94718" */ public void testBug94718() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b94718/SetUp.java", "package b94718;\n" + "public @interface SetUp {\n" + " String value() {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b94718/Test.java", "package b94718;\n" + "@SetUp(\"howdy\")\n" + "public class Test {\n" + "}\n" ); IType type = this.workingCopies[1].getType("SetUp"); search(type, REFERENCES, SearchEngine.createWorkspaceScope()); assertSearchResults( "src/b94718/Test.java b94718.Test [SetUp] EXACT_MATCH" ); } /** * @bug 95152: [search] Field references not found when type is a qualified member type [regression] * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=95152" */ public void testBug95152_jar01() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T1$T12.class").getType(); // search constructor first level member search(type.getMethods()[0], REFERENCES); type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T1$T12$T13.class").getType(); // search constructor second level member search(type.getMethods()[0], REFERENCES); assertSearchResults( "lib/b95152.jar b95152.T1() EXACT_MATCH\n" + "lib/b95152.jar b95152.T1() EXACT_MATCH" ); } public void testBug95152_jar02() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T2$T22.class").getType(); // search constructor first level member search(type.getMethods()[0], REFERENCES); type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T2$T22$T23.class").getType(); // search constructor second level member search(type.getMethods()[0], REFERENCES); assertSearchResults( "lib/b95152.jar b95152.T2(int) EXACT_MATCH\n" + "lib/b95152.jar b95152.T2(int) EXACT_MATCH" ); } public void testBug95152_jar03() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T3$T32.class").getType(); // search constructor first level member search(type.getMethods()[0], REFERENCES); type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T3$T32$T33.class").getType(); // search constructor second level member search(type.getMethods()[0], REFERENCES); assertSearchResults( "lib/b95152.jar b95152.T3(b95152.T3) EXACT_MATCH\n" + "lib/b95152.jar b95152.T3(b95152.T3) EXACT_MATCH" ); } public void testBug95152_jar04() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T4$T42.class").getType(); // search constructor first level member search(type.getMethods()[0], REFERENCES); type = getPackageFragment("JavaSearchBugs", "lib/b95152.jar", "b95152").getClassFile("T4$T42$T43.class").getType(); // search constructor second level member search(type.getMethods()[0], REFERENCES); assertSearchResults( "lib/b95152.jar b95152.T4(b95152.T4, java.lang.String) EXACT_MATCH\n" + "lib/b95152.jar b95152.T4(b95152.T4, java.lang.String) EXACT_MATCH" ); } public void testBug95152_wc01() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b95152/T.java", "package b95152;\n" + "public class T {\n" + " T2 c2;\n" + " T2.T3 c3;\n" + " T() {\n" + " c2 = new T2();\n" + " c3 = c2.new T3();\n" + " }\n" + " class T2 {\n" + " T2() {}\n" + " class T3 {\n" + " T3() {}\n" + " }\n" + " }\n" + "}\n" ); // search constructor first level member IType type = this.workingCopies[0].getType("T").getType("T2"); search(type.getMethods()[0], REFERENCES); // search constructor second level member type = type.getType("T3"); search(type.getMethods()[0], REFERENCES); // verify searches results assertSearchResults( "src/b95152/T.java b95152.T() [new T2()] EXACT_MATCH\n" + "src/b95152/T.java b95152.T() [c2.new T3()] EXACT_MATCH" ); } public void testBug95152_wc02() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b95152/T.java", "package b95152;\n" + "public class T {\n" + " T2 c2;\n" + " T2.T3 c3;\n" + " T(int c) {\n" + " c2 = new T2(c);\n" + " c3 = c2.new T3(c);\n" + " }\n" + " class T2 {\n" + " T2(int x) {}\n" + " class T3 {\n" + " T3(int x) {}\n" + " }\n" + " }\n" + "}\n" ); // search constructor first level member IType type = this.workingCopies[0].getType("T").getType("T2"); search(type.getMethods()[0], REFERENCES); // search constructor second level member type = type.getType("T3"); search(type.getMethods()[0], REFERENCES); // verify searches results assertSearchResults( "src/b95152/T.java b95152.T(int) [new T2(c)] EXACT_MATCH\n" + "src/b95152/T.java b95152.T(int) [c2.new T3(c)] EXACT_MATCH" ); } public void testBug95152_wc03() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b95152/T.java", "package b95152;\n" + "public class T {\n" + " T2 c2;\n" + " T2.T3 c3;\n" + " T(T c) {\n" + " c2 = new T2(c);\n" + " c3 = c2.new T3(c2);\n" + " }\n" + " class T2 {\n" + " T2(T c) {}\n" + " class T3 {\n" + " T3(T2 c) {}\n" + " }\n" + " }\n" + "}\n" ); // search constructor first level member IType type = this.workingCopies[0].getType("T").getType("T2"); search(type.getMethods()[0], REFERENCES); // search constructor second level member type = type.getType("T3"); search(type.getMethods()[0], REFERENCES); // verify searches results assertSearchResults( "src/b95152/T.java b95152.T(T) [new T2(c)] EXACT_MATCH\n" + "src/b95152/T.java b95152.T(T) [c2.new T3(c2)] EXACT_MATCH" ); } public void testBug95152_wc04() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b95152/T.java", "package b95152;\n" + "public class T {\n" + " T2 c2;\n" + " T2.T3 c3;\n" + " T(T c, String str) {\n" + " c2 = new T2(c, str);\n" + " c3 = c2.new T3(c2, str);\n" + " }\n" + " class T2 {\n" + " T2(T c, String str) {}\n" + " class T3 {\n" + " T3(T2 c, String str) {}\n" + " }\n" + " }\n" + "}\n" ); // search constructor first level member IType type = this.workingCopies[0].getType("T").getType("T2"); search(type.getMethods()[0], REFERENCES); // search constructor second level member type = type.getType("T3"); search(type.getMethods()[0], REFERENCES); // verify searches results assertSearchResults( "src/b95152/T.java b95152.T(T, String) [new T2(c, str)] EXACT_MATCH\n" + "src/b95152/T.java b95152.T(T, String) [c2.new T3(c2, str)] EXACT_MATCH" ); } /** * @bug 95794: [1.5][search][annot] Find references in workspace breaks on an annotation * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=95794" */ public void testBug95794() throws CoreException { ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java"); IType type = unit.getType("Test"); // Verify matches TestCollector occurencesCollector = new TestCollector(); occurencesCollector.showAccuracy(true); search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); assertSearchResults( "src/b95794/Test.java [b95794.Test] EXACT_MATCH\n" + "src/b95794/Test.java [b95794.Test] EXACT_MATCH\n" + "src/b95794/Test.java b95794.Test [Test] EXACT_MATCH\n" + "src/b95794/Test.java b95794.Test.there [Test] EXACT_MATCH", occurencesCollector ); // Verify with references matches TestCollector referencesCollector = new TestCollector(); search(type, REFERENCES, getJavaSearchScope(), referencesCollector); assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size()); } public void testBug95794b() throws CoreException { this.resultCollector.showRule(); ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java"); IType type = unit.getType("Test").getType("Color"); // Verify matches TestCollector occurencesCollector = new TestCollector(); occurencesCollector.showAccuracy(true); search(type, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); assertSearchResults( "src/b95794/Test.java [b95794.Test.Color] EXACT_MATCH\n" + "src/b95794/Test.java [b95794.Test.Color] EXACT_MATCH\n" + "src/b95794/Test.java void b95794.Test.main(String[]) [Color] EXACT_MATCH\n" + "src/b95794/Test.java b95794.Test$Color [Color] EXACT_MATCH", occurencesCollector ); // Verify with references matches TestCollector referencesCollector = new TestCollector(); search(type, REFERENCES, getJavaSearchScope(), referencesCollector); assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size()); } public void testBug95794c() throws CoreException { this.resultCollector.showRule(); ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b95794", "Test.java"); IField field = unit.getType("Test").getType("Color").getField("WHITE"); // Verify matches TestCollector occurencesCollector = new TestCollector(); occurencesCollector.showAccuracy(true); search(field, ALL_OCCURRENCES, getJavaSearchScope(), occurencesCollector); assertSearchResults( "src/b95794/Test.java [WHITE] EXACT_MATCH\n" + "src/b95794/Test.java void b95794.Test.main(String[]) [WHITE] EXACT_MATCH\n" + "src/b95794/Test.java b95794.Test$Color.WHITE [WHITE] EXACT_MATCH", occurencesCollector ); // Verify with references matches TestCollector referencesCollector = new TestCollector(); search(field, REFERENCES, getJavaSearchScope(), referencesCollector); assertEquals("Problem with occurences or references number of matches: ", occurencesCollector.matches.size()-1, referencesCollector.matches.size()); } /** * @bug 96761: [1.5][search] Search for declarations of generic method finds non-overriding method * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=96761" */ public void testBug96761() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96761/Generic.java", "package b96761;\n" + "public class Generic<G> {\n" + " void take(G g) {\n" + " }\n" + "}\n" + "class Impl extends Generic<RuntimeException> {\n" + " void take(InterruptedException g) {\n" + " }\n" + " void take(RuntimeException g) {\n" + " }\n" + "}" ); IType type = this.workingCopies[0].getType("Generic"); IMethod method= type.getMethods()[0]; search(method, REFERENCES); assertSearchResults(""); // Expect no result } /** * @bug 96763: [1.5][search] Search for method declarations does not find overridden method with different signature * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=96763" */ public void testBug96763() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java", "package b96763;\n" + "class Test<T> {\n" + " public void first(Exception num) {}\n" + " public void second(T t) {}\n" + "}\n" + "class Sub extends Test<Exception> {\n" + " public void first(Exception num) {}\n" + " public void second(Exception t) {}\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Sub").getMethods()[0]; search(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b96763/Test.java void b96763.Test.first(Exception) [first] EXACT_MATCH\n" + "src/b96763/Test.java void b96763.Sub.first(Exception) [first] EXACT_MATCH" ); } public void testBug96763b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java", "package b96763;\n" + "class Test<T> {\n" + " public void first(Exception num) {}\n" + " public void second(T t) {}\n" + "}\n" + "class Sub extends Test<Exception> {\n" + " public void first(Exception num) {}\n" + " public void second(Exception t) {}\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Sub").getMethods()[1]; search(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b96763/Test.java void b96763.Test.second(T) [second] EXACT_MATCH\n" + "src/b96763/Test.java void b96763.Sub.second(Exception) [second] EXACT_MATCH" ); } public void testBug96763c() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java", "package b96763;\n" + "public class Test<T> {\n" + " void methodT(T t) {}\n" + "}\n" + "class Sub<X> extends Test<X> {\n" + " void methodT(X x) {} // overrides Super#methodT(T)\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Sub").getMethods()[0]; search(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE); assertSearchResults( "src/b96763/Test.java void b96763.Test.methodT(T) [methodT] EXACT_MATCH\n" + "src/b96763/Test.java void b96763.Sub.methodT(X) [methodT] EXACT_MATCH" ); } /** * @bug 97087: [1.5][search] Can't find reference of generic class's constructor. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97087" */ public void testBug97087() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.resultCollector.showRule(); this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java", "package b97087;\n" + "public class Bug<Type> {\n" + " Bug(){}\n" + "}\n" + "class Foo extends Bug<String>{\n" + " Foo(){}\n" + "}\n" + "class Bar extends Bug<Exception>{\n" + " Bar(){super();}\n" + "}" ); IType type = this.workingCopies[0].getType("Bug"); IMethod method= type.getMethods()[0]; search(method, REFERENCES, SearchPattern.R_ERASURE_MATCH); assertSearchResults( "src/b97087/Bug.java b97087.Foo() [Foo] EXACT_MATCH\n" + "src/b97087/Bug.java b97087.Bar() [super();] ERASURE_MATCH" ); } /** * @bug 97120: * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97120" */ public void testBug97120() throws CoreException { IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Throwable.class").getType(); IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "E*".toCharArray(), SearchPattern.R_PATTERN_MATCH, TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.Error\n" + "java.lang.Exception", requestor ); } /** * @bug 97322: [search] Search for method references sometimes reports potential match with differing argument count * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97322" */ public void testBug97322() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97322/Test.java", "package b97322;\n" + "class Test {\n" + " static void myMethod(int a, String b) {}\n" + " void call() {\n" + " myMethod(12);\n" + " }\n" + "}" ); IType type = this.workingCopies[0].getType("Test"); IMethod method= type.getMethods()[0]; search(method, REFERENCES); assertSearchResults(""); // Expect no result } /** * @bug 97547: [search] Package search does not find references in member types import clause * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97547" */ public void testBug97547() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97547/IX.java", "package b97547;\n" + "public interface IX {\n" + " public interface IX1 {}\n" + "}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b97547/X.java", "package b97547;\n" + "import b97547.IX.*;\n" + "class X {\n" + " IX x;\n" + "}" ); IPackageDeclaration[] packages = this.workingCopies[0].getPackageDeclarations(); assertTrue("Invalid number of packages declaration!", packages!=null && packages.length==1); search(packages[0], REFERENCES); assertSearchResults( "src/b97547/X.java [b97547] EXACT_MATCH" ); } /** * @bug 97606: [1.5][search] Raw type reference is reported as exact match for qualified names * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97606" */ public void testBug97606() throws CoreException { this.workingCopies = new ICompilationUnit[4]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/def/L.java", "package b97606.pack.def;\n" + "public interface L<E> {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/def/LL.java", "package b97606.pack.def;\n" + "public class LL<E> implements L<E> {\n" + " public Object clone() {\n" + " return null;\n" + " }\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/ref/K.java", "package b97606.pack.ref;\n" + "public interface K {}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/ref/X.java", "package b97606.pack.ref;\n" + "public class X implements K {\n" + " private b97606.pack.def.LL sg;\n" + " protected synchronized b97606.pack.def.L<K> getSG() {\n" + " return (sg != null) \n" + " ? (b97606.pack.def.L) sg.clone()\n" + " : null;\n" + " }\n" + "}\n" ); IPath rootPath = new Path("/JavaSearchBugs/src/b97606"); IPath pathDef = rootPath.append("pack").append("def"); IPath pathRef = rootPath.append("pack").append("ref"); try { createFolder(pathDef); createFolder(pathRef); this.workingCopies[0].commitWorkingCopy(true, null); this.workingCopies[1].commitWorkingCopy(true, null); this.workingCopies[2].commitWorkingCopy(true, null); this.workingCopies[3].commitWorkingCopy(true, null); this.resultCollector.showRule(); IType type = this.workingCopies[0].getType("L"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH); assertSearchResults( "src/b97606/pack/def/LL.java b97606.pack.def.LL [L] ERASURE_MATCH\n" + "src/b97606/pack/ref/X.java b97606.pack.def.L<K> b97606.pack.ref.X.getSG() [b97606.pack.def.L] ERASURE_MATCH\n" + "src/b97606/pack/ref/X.java b97606.pack.def.L<K> b97606.pack.ref.X.getSG() [b97606.pack.def.L] ERASURE_RAW_MATCH" ); } finally { deleteFolder(rootPath); } } public void testBug97606b() throws CoreException { this.workingCopies = new ICompilationUnit[4]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/def/L.java", "package b97606.pack.def;\n" + "public interface L<E> {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/def/LL.java", "package b97606.pack.def;\n" + "public class LL<E> implements L<E> {\n" + " public Object clone() {\n" + " return null;\n" + " }\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/ref/K.java", "package b97606.pack.ref;\n" + "public interface K {}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b97606/pack/ref/X.java", "package b97606.pack.ref;\n" + "import b97606.pack.def.*;\n" + "public class X implements K {\n" + " private LL sg;\n" + " protected synchronized L<K> getSG() {\n" + " return (sg != null) \n" + " ? (L) sg.clone()\n" + " : null;\n" + " }\n" + "}\n" ); IPath rootPath = new Path("/JavaSearchBugs/src/b97606"); IPath pathDef = rootPath.append("pack").append("def"); IPath pathRef = rootPath.append("pack").append("ref"); try { createFolder(pathDef); createFolder(pathRef); this.workingCopies[0].commitWorkingCopy(true, null); this.workingCopies[1].commitWorkingCopy(true, null); this.workingCopies[2].commitWorkingCopy(true, null); this.workingCopies[3].commitWorkingCopy(true, null); this.resultCollector.showRule(); IType type = this.workingCopies[0].getType("L"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH); assertSearchResults( "src/b97606/pack/def/LL.java b97606.pack.def.LL [L] ERASURE_MATCH\n" + "src/b97606/pack/ref/X.java L<K> b97606.pack.ref.X.getSG() [L] ERASURE_MATCH\n" + "src/b97606/pack/ref/X.java L<K> b97606.pack.ref.X.getSG() [L] ERASURE_RAW_MATCH" ); } finally { deleteFolder(rootPath); } } /** * @bug 97614: [1.5][search] Refactoring: renaming of field of a (complex) parametrized type does not replace all occurrences * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97614" */ public void testBug97614() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97614/W.java", "package b97614;\n" + "public class W {\n" + " private final Map<String, Y<?, ? extends b97614.X.XX<?, ?>, ? >> m1 = null; // (a)\n" + " public void getStore(final Object o) {\n" + " m1.get(o); // (b)\n" + " }\n" + "}\n" + "interface Map<K, V> {\n" + " V get(Object k);\n" + "}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b97614/X.java", "package b97614;\n" + "import java.io.Serializable;\n" + "public interface X<T extends X<T, U, V>, \n" + " U extends X.XX<T, V>, \n" + " V extends X.XY> {\n" + " public interface XX<TT extends X<TT, ?, UU>, \n" + " UU extends X.XY> \n" + " extends Serializable {\n" + " }\n" + " public interface XY extends Serializable {\n" + " }\n" + "}" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b97614/Y.java", "package b97614;\n" + "public class Y<T extends X<T, U, V>, U extends X.XX<T, V>, V extends X.XY> {\n" + "}\n" ); IField field = this.workingCopies[0].getType("W").getField("m1"); search(field, REFERENCES); assertSearchResults( "src/b97614/W.java void b97614.W.getStore(Object) [m1] EXACT_MATCH" ); } /** * @bug 98378: [search] does not find method references in anonymous class of imported jarred plugin * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=98378" */ public void testBug98378() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b98378/X.java", "package b98378;\n" + "public class X implements java.lang.CharSequence {\n" + " public int length() {\n" + " return 1;\n" + " }\n" + "}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b98378/Y.java", "package b98378;\n" + "public class Y {\n" + " public int length() {\n" + " return -1;\n" + " }\n" + "}\n" ); String jclPath = getExternalJCLPathString("1.5"); IType type = getClassFile("JavaSearchBugs", jclPath, "java.lang", "CharSequence.class").getType(); IMethod method = type.getMethod("length", new String[] {}); search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type, this.wcOwner)); assertSearchResults( jclPath + " int java.lang.CharSequence.length() EXACT_MATCH\n" + jclPath + " int java.lang.String.length() EXACT_MATCH" ); } public void testBug98378b() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b98378/X.java", "package b98378;\n" + "public class X implements java.lang.CharSequence {\n" + " public int length() {\n" + " return 1;\n" + " }\n" + "}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b98378/Y.java", "package b98378;\n" + "public class Y {\n" + " public int length() {\n" + " return -1;\n" + " }\n" + "}\n" ); String jclPath = getExternalJCLPathString("1.5"); IType type = getClassFile("JavaSearchBugs", jclPath, "java.lang", "CharSequence.class").getType(); IMethod method = type.getMethod("length", new String[] {}); search(method, DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE, SearchEngine.createHierarchyScope(type, this.wcOwner)); assertSearchResults( "src/b98378/X.java int b98378.X.length() [length] EXACT_MATCH\n" + jclPath + " int java.lang.CharSequence.length() EXACT_MATCH\n" + jclPath + " int java.lang.String.length() EXACT_MATCH" ); } /** * @bug 99600: [search] Java model exception on "Move to new file" on inner type with inner type * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=99600" */ public void testBug99600() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b99600/Test.java", "package b99600;\n" + "public class Test {\n" + " public class C1 {}\n" + " public class C2 {\n" + " class C3 {\n" + " int foo(C1 c) { return 0; }\n" + " }\n" + " public void foo(C1 c, int i) {\n" + " new C3().foo(c);\n" + " }\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test").getType("C2"); new SearchEngine(this.workingCopies).searchDeclarationsOfSentMessages(type, this.resultCollector, null); assertSearchResults( "src/b99600/Test.java int b99600.Test$C2$C3.foo(C1) [foo(C1 c)] EXACT_MATCH" ); } /** * @bug 99903: [1.5][search] range wrong for package-info * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=99903" */ public void testBug99903_annotation() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b99903/package-info.java", "/**\n" + " * @see Test\n" + " */\n" + "@Annot\n" + "package b99903;\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b99903/Test.java", "package b99903;\n" + "public class Test {\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b99903/Annot.java", "package b99903;\n" + "public @interface Annot {\n" + "}\n" ); IType type = this.workingCopies[2].getType("Annot"); search(type, REFERENCES); assertSearchResults( "src/b99903/package-info.java [Annot] EXACT_MATCH" ); } public void testBug99903_javadoc() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b99903/package-info.java", "/**\n" + " * @see Test\n" + " */\n" + "@Annot\n" + "package b99903;\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b99903/Test.java", "package b99903;\n" + "public class Test {\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b99903/Annot.java", "package b99903;\n" + "public @interface Annot {\n" + "}\n" ); this.resultCollector.showInsideDoc(); IType type = this.workingCopies[1].getType("Test"); search(type, REFERENCES); assertSearchResults( "src/b99903/package-info.java [Test] EXACT_MATCH INSIDE_JAVADOC" ); } /** * @bug 100695: [1.5][search] Renaming a field of generic array type has no effect * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=100695" */ public void testBug100695() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " Class<Class>[] foo;\n" + " Class<Class>[] bar = foo;\n" + " Test() {\n" + " foo = null;\n" + " }\n" + "}\n" ); IField field = this.workingCopies[0].getType("Test").getField("foo"); search(field, REFERENCES); assertSearchResults( "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" ); } public void testBug100695a() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " Class<Class>[] foo;\n" + " Class<Class>[] bar = foo;\n" + " Test() {\n" + " foo = null;\n" + " }\n" + "}\n" ); IField field = this.workingCopies[0].getType("Test").getField("foo"); search(field, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" ); } public void testBug100695b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " Class<Class> foo;\n" + " Class<Class> bar = foo;\n" + " Test() {\n" + " foo = null;\n" + " }\n" + "}\n" ); IField field = this.workingCopies[0].getType("Test").getField("foo"); search(field, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" ); } public void testBug100695c() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " Class[] foo;\n" + " Class[] bar = foo;\n" + " Test() {\n" + " foo = null;\n" + " }\n" + "}\n" ); IField field = this.workingCopies[0].getType("Test").getField("foo"); search(field, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" ); } public void testBug100695d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " public Class<Class>[] foo(Class<Class>[] a) {\n" + " return a;\n" + " }\n" + " void bar() {\n" + " foo(new Class[0]);\n" + " }\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Test").getMethods()[0]; search(method, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java Class<Class>[] b100695.Test.foo(Class<Class>[]) [foo] EXACT_MATCH\n" + "src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH" ); } public void testBug100695e() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " public Class<Class> foo(Class<Class> a) {\n" + " return a;\n" + " }\n" + " void bar() {\n" + " foo(null);\n" + " }\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Test").getMethods()[0]; search(method, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java Class<Class> b100695.Test.foo(Class<Class>) [foo] EXACT_MATCH\n" + "src/b100695/Test.java void b100695.Test.bar() [foo(null)] EXACT_MATCH" ); } public void testBug100695f() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", "package b100695;\n" + "public class Test {\n" + " public Class[] foo(Class[] a) {\n" + " return a;\n" + " }\n" + " void bar() {\n" + " foo(new Class[0]);\n" + " }\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("Test").getMethods()[0]; search(method, ALL_OCCURRENCES); assertSearchResults( "src/b100695/Test.java Class[] b100695.Test.foo(Class[]) [foo] EXACT_MATCH\n" + "src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH" ); } /** * @bug 100772: [1.5][search] Search for declarations in hierarchy reports to many matches * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=100772" */ private void setUpBug100772_HierarchyScope_ClassAndSubclass() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", "package b100772;\n" + "class Test<T> {\n" + " public void foo(T t) {}\n" + " public void foo(Class c) {}\n" + "}\n" + "class Sub extends Test<String> {\n" + " public void foo(String str) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_HierarchyScope_ClassAndSubclass01() throws CoreException { setUpBug100772_HierarchyScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_ClassAndSubclass02() throws CoreException { setUpBug100772_HierarchyScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_ClassAndSubclass03() throws CoreException { setUpBug100772_HierarchyScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_ClassAndSubclass04() throws CoreException { setUpBug100772_HierarchyScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_ClassAndSubclass05() throws CoreException { setUpBug100772_HierarchyScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH" ); } private void setUpBug100772_HierarchyScope_InterfacesAndClass() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", "package b100772;\n" + "interface Test<T> {\n" + " public void foo(T t);\n" + " public void foo(Class c);\n" + "}\n" + "interface Sub extends Test<String> {\n" + " public void foo(String str);\n" + " public void foo(Exception e);\n" + "}\n" + "class X implements Test<String> {\n" + " public void foo(String str) {}\n" + " public void foo(Class c) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_HierarchyScope_InterfacesAndClass01() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass02() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass03() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass04() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass05() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass06() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass07() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_InterfacesAndClass08() throws CoreException { setUpBug100772_HierarchyScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.X.foo(Exception) [foo] EXACT_MATCH" ); } private void setUpBug100772_HierarchyScope_Complex() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", "package b100772;\n" + "public class X<T> implements IX<T> {\n" + " public void foo(T t) {}\n" + "}\n" + "class XX extends X<String> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" + "interface IX<U> {\n" + " public void foo(U u);\n" + "}\n" + "class Y implements IX<String> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" + "interface IXX<V extends Exception> {\n" + " public void foo(V v);\n" + "}\n" + "class Z extends Y implements IXX<Exception> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_HierarchyScope_Complex01() throws CoreException { setUpBug100772_HierarchyScope_Complex(); IType type = this.workingCopies[0].getType("IX"); IMethod method = type.getMethod("foo", new String[] { "QU;" }); search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_Complex02() throws CoreException { setUpBug100772_HierarchyScope_Complex(); IType type = this.workingCopies[0].getType("Z"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_Complex03() throws CoreException { setUpBug100772_HierarchyScope_Complex(); IType type = this.workingCopies[0].getType("Z"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.Y.foo(Exception) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH" ); } public void testBug100772_HierarchyScope_Complex04() throws CoreException { setUpBug100772_HierarchyScope_Complex(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); assertSearchResults( "src/b100772/Test.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH" ); } private void setUpBug100772_ProjectScope_ClassAndSubclass() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", "package b100772;\n" + "class Test<T> {\n" + " public void foo(T t) {}\n" + " public void foo(Class c) {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b100772/Sub.java", "package b100772;\n" + "class Sub extends Test<String> {\n" + " public void foo(String str) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_ProjectScope_ClassAndSubclass01() throws CoreException { setUpBug100772_ProjectScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_ClassAndSubclass02() throws CoreException { setUpBug100772_ProjectScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_ClassAndSubclass03() throws CoreException { setUpBug100772_ProjectScope_ClassAndSubclass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_ClassAndSubclass04() throws CoreException { setUpBug100772_ProjectScope_ClassAndSubclass(); IType type = this.workingCopies[1].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_ClassAndSubclass05() throws CoreException { setUpBug100772_ProjectScope_ClassAndSubclass(); IType type = this.workingCopies[1].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH" ); } private void setUpBug100772_ProjectScope_InterfacesAndClass() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", "package b100772;\n" + "interface Test<T> {\n" + " public void foo(T t);\n" + " public void foo(Class c);\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b100772/Sub.java", "package b100772;\n" + "interface Sub extends Test<String> {\n" + " public void foo(String str);\n" + " public void foo(Exception e);\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b100772/X.java", "package b100772;\n" + "class X implements Test<String> {\n" + " public void foo(String str) {}\n" + " public void foo(Class c) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_ProjectScope_InterfacesAndClass01() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass02() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass03() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass04() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[1].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass05() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[1].getType("Sub"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(Exception) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass06() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[2].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass07() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[2].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QClass;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(Class) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_InterfacesAndClass08() throws CoreException { setUpBug100772_ProjectScope_InterfacesAndClass(); IType type = this.workingCopies[2].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/Sub.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(Exception) [foo] EXACT_MATCH" ); } private void setUpBug100772_ProjectScope_Complex() throws CoreException { this.workingCopies = new ICompilationUnit[6]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/X.java", "package b100772;\n" + "public class X<T> implements IX<T> {\n" + " public void foo(T t) {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b100772/XX.java", "package b100772;\n" + "class XX extends X<String> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b100772/IX.java", "package b100772;\n" + "interface IX<U> {\n" + " public void foo(U u);\n" + "}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b100772/Y.java", "package b100772;\n" + "class Y implements IX<String> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); this.workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/b100772/IXX.java", "package b100772;\n" + "interface IXX<V extends Exception> {\n" + " public void foo(V v);\n" + "}\n" ); this.workingCopies[5] = getWorkingCopy("/JavaSearchBugs/src/b100772/Z.java", "package b100772;\n" + "class Z extends Y implements IXX<Exception> {\n" + " public void foo(String s) {}\n" + " public void foo(Exception e) {}\n" + "}\n" ); } public void testBug100772_ProjectScope_Complex01() throws CoreException { setUpBug100772_ProjectScope_Complex(); IType type = this.workingCopies[2].getType("IX"); IMethod method = type.getMethod("foo", new String[] { "QU;" }); search(method, DECLARATIONS); assertSearchResults( "src/b100772/IX.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + "src/b100772/X.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/XX.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Y.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Z.java void b100772.Z.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_Complex02() throws CoreException { setUpBug100772_ProjectScope_Complex(); IType type = this.workingCopies[5].getType("Z"); IMethod method = type.getMethod("foo", new String[] { "QString;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/IX.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + "src/b100772/XX.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Y.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + "src/b100772/Z.java void b100772.Z.foo(String) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_Complex03() throws CoreException { setUpBug100772_ProjectScope_Complex(); IType type = this.workingCopies[5].getType("Z"); IMethod method = type.getMethod("foo", new String[] { "QException;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/IXX.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + "src/b100772/XX.java void b100772.XX.foo(Exception) [foo] EXACT_MATCH\n" + "src/b100772/Y.java void b100772.Y.foo(Exception) [foo] EXACT_MATCH\n" + "src/b100772/Z.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH" ); } public void testBug100772_ProjectScope_Complex04() throws CoreException { setUpBug100772_ProjectScope_Complex(); IType type = this.workingCopies[0].getType("X"); IMethod method = type.getMethod("foo", new String[] { "QT;" }); search(method, UI_DECLARATIONS); assertSearchResults( "src/b100772/X.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + "src/b100772/IX.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + "src/b100772/XX.java void b100772.XX.foo(String) [foo] EXACT_MATCH" ); } /** * @bug 108088: [search] Inaccurate search match for method invocations with literal arguments * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=108088" */ public void testBug108088() throws CoreException { ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b108088", "Test108088.java"); IType type = unit.getType("A108088"); IMethod method = type.getMethod("subroutine", new String[] { "F" }); SearchPattern pattern = SearchPattern.createPattern(method, REFERENCES, EXACT_RULE); assertNotNull("Pattern should not be null", pattern); search(pattern, getJavaSearchScope(), this.resultCollector); assertSearchResults( "src/b108088/B108088.java void b108088.B108088.doit(A108088, String) [subroutine(1.2f)] EXACT_MATCH" ); } /** * @bug 109695: [search] Numbers should be treated as upper-case letters in CamelCase matching * @test Ensure that camel case pattern including numbers return correct set of types * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=109695" */ public void testBug109695() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/IDocumentExtension.java", "public interface IDocumentExtension {}\n" + "interface IDocumentExtension2 {}\n" + "interface IDocumentExtension3 {}\n" + "interface IDocumentExtension135 {}\n" + "interface IDocumentExtension315 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("IDE3", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("IDE3", validatedRule, requestor); assertSearchResults( "IDocumentExtension135\n" + "IDocumentExtension3\n" + "IDocumentExtension315", requestor ); } public void testBug109695b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/IDocumentProviderExtension.java", "public interface IDocumentProviderExtension {}\n" + "interface IDocumentProviderExtension2 {}\n" + "interface IDocumentProviderExtension3 {}\n" + "interface IDocumentProviderExtension4 {}\n" + "interface IDocumentProviderExtension5 {}\n" + "interface IDocumentProviderExtension12345 {}\n" + "interface IDocumentProviderExtension54321 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("IDPE3", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("IDPE3", validatedRule, requestor); assertSearchResults( "IDocumentProviderExtension12345\n" + "IDocumentProviderExtension3\n" + "IDocumentProviderExtension54321", requestor ); } public void testBug109695c() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/IPerspectiveListener.java", "public interface IPerspectiveListener {}\n" + "interface IPerspectiveListener2 {}\n" + "interface IPerspectiveListener3 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("IPL3", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("IPL3", validatedRule, requestor); assertSearchResults( "IPerspectiveListener3", requestor ); } public void testBug109695d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/IPropertySource.java", "public interface IPropertySource {}\n" + "interface IPropertySource2 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("IPS2", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("IPS2", validatedRule, requestor); assertSearchResults( "IPropertySource2", requestor ); } public void testBug109695e() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/IWorkbenchWindowPulldownDelegate.java", "public interface IWorkbenchWindowPulldownDelegate {}\n" + "interface IWorkbenchWindowPulldownDelegate1 {}\n" + "interface IWorkbenchWindowPulldownDelegate2 {}\n" + "interface IWorkbenchWindowPulldownDelegate3 {}\n" + "interface IWorkbenchWindowPulldownDelegate4 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("IWWPD2", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("IWWPD2", validatedRule, requestor); assertSearchResults( "IWorkbenchWindowPulldownDelegate2", requestor ); } public void testBug109695f() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/UTF16DocumentScannerSupport.java", "public class UTF16DocumentScannerSupport {}\n" + "class UTF1DocScannerSupport {}\n" + "class UTF6DocScannerSupport {}\n" + "class UTFDocScannerSupport {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("UTF16DSS", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("UTF16DSS", validatedRule, requestor); assertSearchResults( "UTF16DocumentScannerSupport", requestor ); } public void testBug109695g() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/UTF16DocumentScannerSupport.java", "public class UTF16DocumentScannerSupport {}\n" + "class UTF1DocScannerSupport {}\n" + "class UTF6DocScannerSupport {}\n" + "class UTFDocScannerSupport {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("UTF1DSS", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("UTF1DSS", validatedRule, requestor); assertSearchResults( "UTF16DocumentScannerSupport\n" + "UTF1DocScannerSupport", requestor ); } public void testBug109695h() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/UTF16DocumentScannerSupport.java", "public class UTF16DocumentScannerSupport {}\n" + "class UTF1DocScannerSupport {}\n" + "class UTF6DocScannerSupport {}\n" + "class UTFDocScannerSupport {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("UTF6DSS", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("UTF6DSS", validatedRule, requestor); assertSearchResults( "UTF16DocumentScannerSupport\n" + "UTF6DocScannerSupport", requestor ); } public void testBug109695i() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/UTF16DocumentScannerSupport.java", "public class UTF16DocumentScannerSupport {}\n" + "class UTF1DocScannerSupport {}\n" + "class UTF6DocScannerSupport {}\n" + "class UTFDocScannerSupport {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); int validatedRule = SearchPattern.validateMatchRule("UTFDSS", SearchPattern.R_CAMELCASE_MATCH); searchAllTypeNames("UTFDSS", validatedRule, requestor); assertSearchResults( "UTF16DocumentScannerSupport\n" + "UTF1DocScannerSupport\n" + "UTF6DocScannerSupport\n" + "UTFDocScannerSupport", requestor ); } /** * To get these tests search matches in a workspace, do NOT forget to modify files * to set them as working copies. * * @test Bug 110060: [plan][search] Add support for Camel Case search pattern * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110060" */ // Types search private void setUpBug110060_TypePattern() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110060/Test.java", "package b110060;\n" + "public class Test {\n" + " Aaa a1;\n" + " AAa a2;\n" + " AaAaAa a3;\n" + " AAxx a4;\n" + " AxA a5;\n" + " AxxAyy a6;\n" + "}\n" + "class AAa {}\n" + "class Aaa {}\n" + "class AaAaAa {}\n" + "class AAxx {}\n" + "class AxA {}\n" + "class AxxAyy {}\n" ); } public void testBug110060_TypePattern01() throws CoreException { setUpBug110060_TypePattern(); search("AA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern01_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern02() throws CoreException { setUpBug110060_TypePattern(); search("AA", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AAa [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Aaa [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AaAaAa [AaAaAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AAxx [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AxA [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AxxAyy [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern02_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AA", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AAa [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AAxx [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AxA [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.AxxAyy [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern03() throws CoreException { setUpBug110060_TypePattern(); search("AAx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH" ); } public void testBug110060_TypePattern03_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AAx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH" ); } public void testBug110060_TypePattern04() throws CoreException { setUpBug110060_TypePattern(); search("Axx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern04_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("Axx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_TypePattern05() throws CoreException { setUpBug110060_TypePattern(); search("Ax", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern05_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("Ax", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_TypePattern06() throws CoreException { setUpBug110060_TypePattern(); search("A*A*", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH\n" + getExternalJCLPathString("1.5") + " java.lang.Deprecated EXACT_MATCH" // due to the import java.lang.annotation.* ); } public void testBug110060_TypePattern06_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("A*A*", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a4 [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a5 [AxA] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH\n" + getExternalJCLPathString("1.5") + " java.lang.Deprecated EXACT_MATCH" // due to the import java.lang.annotation.* ); } public void testBug110060_TypePattern07() throws CoreException { setUpBug110060_TypePattern(); search("aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); // Invalid camel case pattern => replace the camel case flag by prefix match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH" ); } public void testBug110060_TypePattern07_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); // Invalid camel case pattern => replace the camel case flag by exact match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH" ); } public void testBug110060_TypePattern08() throws CoreException { setUpBug110060_TypePattern(); search("Aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); // Invalid camel case pattern => replace the camel case flag by prefix match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a3 [AaAaAa] EXACT_MATCH" ); } public void testBug110060_TypePattern08_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("Aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); // Invalid camel case pattern => replace the camel case flag by exact match one (case insensitive) assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.a2 [AAa] EXACT_MATCH" ); } public void testBug110060_TypePattern09() throws CoreException { setUpBug110060_TypePattern(); search("Aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE); // Invalid camel case pattern => replace the camel case flag by prefix match one keeping case sensitive assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH" ); } public void testBug110060_TypePattern09_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("Aaa", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE); // Invalid camel case pattern => replace the camel case flag by exact match one keeping case sensitive assertSearchResults( "src/b110060/Test.java b110060.Test.a1 [Aaa] EXACT_MATCH" ); } public void testBug110060_TypePattern10() throws CoreException { setUpBug110060_TypePattern(); search("AxAx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults(""); } public void testBug110060_TypePattern10_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AxAx", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_TypePattern11() throws CoreException { setUpBug110060_TypePattern(); search("AxxA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern11_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AxxA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern12() throws CoreException { setUpBug110060_TypePattern(); search("AxXA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.a6 [AxxAyy] EXACT_MATCH" ); } public void testBug110060_TypePattern12_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); search("AxXA", TYPE, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } // Search all type names requests public void testBug110060_AllTypeNames01() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AA", SearchPattern.R_CAMELCASE_MATCH, requestor); assertSearchResults("Unexpected all type names", "b110060.AAa\n" + "b110060.AAxx\n" + "b110060.AaAaAa\n" + "b110060.Aaa\n" + "b110060.AxA\n" + "b110060.AxxAyy", requestor); } public void testBug110060_AllTypeNames01_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AA", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, requestor); assertSearchResults("Unexpected all type names", "b110060.AAa\n" + "b110060.AAxx\n" + "b110060.AxA\n" + "b110060.AxxAyy", requestor); } public void testBug110060_AllTypeNames02() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_MATCH, requestor); // Invalid camel case pattern => replace the camel case flag with prefix match one (case insensitive) assertSearchResults("Unexpected all type names", "b110060.AAa\n" + "b110060.AaAaAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames02_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, requestor); // Invalid camel case pattern => replace the camel case flag with exact match one (case insensitive) assertSearchResults("Unexpected all type names", "b110060.AAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames03() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AAa", SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults("Unexpected all type names", "b110060.AAa\n" + "b110060.AaAaAa", requestor); } public void testBug110060_AllTypeNames03_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AAa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults("Unexpected all type names", "b110060.AAa", requestor); } public void testBug110060_AllTypeNames04() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AA", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "Unexpected all type names", "b110060.AAa\n" + "b110060.AAxx\n" + "b110060.AaAaAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames05() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AAA", SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames06() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("AA", SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults( "Unexpected all type names", "b110060.AAa\n" + "b110060.AAxx", requestor); } public void testBug110060_AllTypeNames07() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH, requestor); // Invalid camel case pattern => replace the camel case flag with prefix match one (case insensitive) assertSearchResults( "Unexpected all type names", "b110060.AAa\n" + "b110060.AaAaAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames07_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_PREFIX_MATCH, requestor); // Invalid camel case pattern => replace the camel case flag with exact match one (case insensitive) assertSearchResults( "Unexpected all type names", "b110060.AAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames08() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); // Invalid camel case pattern => replace the camel case flag with prefix match one keeping case sensitive assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames08_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); // Invalid camel case pattern => replace the camel case flag with exact match one keeping case sensitive assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames09() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); // Invalid camel case pattern => reset the camel case flag keeping prefix match and case sensitive ones assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames09_SamePartCount() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aaa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); // Invalid camel case pattern => reset the camel case flag exact match keeping case sensitive assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames12() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aa", SearchPattern.R_PREFIX_MATCH, requestor); assertSearchResults( "Unexpected all type names", "b110060.AAa\n" + "b110060.AAxx\n" + "b110060.AaAaAa\n" + "b110060.Aaa", requestor); } public void testBug110060_AllTypeNames13() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aa", SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults( "Unexpected all type names", "", requestor); } public void testBug110060_AllTypeNames14() throws CoreException { setUpBug110060_TypePattern(); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); searchAllTypeNames("aa", SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE, requestor); assertSearchResults( "Unexpected all type names", "", requestor); } // Constructor search private void setUpBug110060_ConstructorPattern() throws CoreException { this.workingCopies = new ICompilationUnit[5]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110060/AAAA.java", "package b110060;\n" + "public class AAAA {\n" + " AAAA() {}\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b110060/AAxx.java", "package b110060;\n" + "public class AAxx {\n" + " AAxx() {}\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b110060/AxxAyy.java", "package b110060;\n" + "public class AxxAyy {\n" + " AxxAyy() {}\n" + "}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b110060/AxAyAz.java", "package b110060;\n" + "public class AxAyAz {\n" + " AxAyAz() {}\n" + "}\n" ); this.workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/b110060/Test.java", "package b110060;\n" + "public class Test {\n" + " AAAA aaaa = new AAAA();\n" + " AAxx aaxx = new AAxx();\n" + " AxAyAz axayaz = new AxAyAz();\n" + " AxxAyy axxayy = new AxxAyy();\n" + "}\n" ); } public void testBug110060_ConstructorPattern01() throws CoreException { setUpBug110060_ConstructorPattern(); search("AA", CONSTRUCTOR, REFERENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aaaa [new AAAA()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axayaz [new AxAyAz()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern01_SamePartCount() throws CoreException { setUpBug110060_ConstructorPattern(); search("AA", CONSTRUCTOR, REFERENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern02() throws CoreException { setUpBug110060_ConstructorPattern(); search("AA", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/AAAA.java b110060.AAAA() [AAAA] EXACT_MATCH\n" + "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/AxAyAz.java b110060.AxAyAz() [AxAyAz] EXACT_MATCH\n" + "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaaa [new AAAA()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axayaz [new AxAyAz()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern02_SamePartCount() throws CoreException { setUpBug110060_ConstructorPattern(); search("AA", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern03() throws CoreException { setUpBug110060_ConstructorPattern(); search("AAx", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern03_SamePartCount() throws CoreException { setUpBug110060_ConstructorPattern(); search("AAx", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern04() throws CoreException { setUpBug110060_ConstructorPattern(); search("AxA", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/AxAyAz.java b110060.AxAyAz() [AxAyAz] EXACT_MATCH\n" + "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axayaz [new AxAyAz()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern04_SamePartCount() throws CoreException { setUpBug110060_ConstructorPattern(); search("AxA", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern05() throws CoreException { setUpBug110060_ConstructorPattern(); search("A*A*", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/AAAA.java b110060.AAAA() [AAAA] EXACT_MATCH\n" + "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/AxAyAz.java b110060.AxAyAz() [AxAyAz] EXACT_MATCH\n" + "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaaa [new AAAA()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axayaz [new AxAyAz()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } public void testBug110060_ConstructorPattern05_SamePartCount() throws CoreException { setUpBug110060_ConstructorPattern(); search("A*A*", CONSTRUCTOR, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/AAAA.java b110060.AAAA() [AAAA] EXACT_MATCH\n" + "src/b110060/AAxx.java b110060.AAxx() [AAxx] EXACT_MATCH\n" + "src/b110060/AxAyAz.java b110060.AxAyAz() [AxAyAz] EXACT_MATCH\n" + "src/b110060/AxxAyy.java b110060.AxxAyy() [AxxAyy] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaaa [new AAAA()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aaxx [new AAxx()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axayaz [new AxAyAz()] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.axxayy [new AxxAyy()] EXACT_MATCH" ); } // Methods search private void setUpBug110060_MethodPattern() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110060/Test.java", "package b110060;\n" + "public class Test {\n" + " void aMethodWithNothingSpecial() {}\n" + " void aMethodWith1Digit() {}\n" + " void aMethodWith1DigitAnd_AnUnderscore() {}\n" + " void aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() {}\n" + " void otherMethodWhichStartsWithAnotherLetter() {}\n" + " void testReferences() {\n" + " aMethodWith1Digit();\n" + " aMethodWith1DigitAnd_AnUnderscore();\n" + " aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores();\n" + " aMethodWithNothingSpecial();\n" + " otherMethodWhichStartsWithAnotherLetter();\n" + " }\n" + "}\n" ); } public void testBug110060_MethodPattern01() throws CoreException { setUpBug110060_MethodPattern(); search("MWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern01_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("MWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern02() throws CoreException { setUpBug110060_MethodPattern(); search("AMWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern02_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("AMWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern03() throws CoreException { setUpBug110060_MethodPattern(); search("aMWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH" ); } public void testBug110060_MethodPattern03_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMWD", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH" ); } public void testBug110060_MethodPattern04() throws CoreException { setUpBug110060_MethodPattern(); search("aMW", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWithNothingSpecial() [aMethodWithNothingSpecial] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWithNothingSpecial()] EXACT_MATCH" ); } public void testBug110060_MethodPattern04_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMW", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "" ); } public void testBug110060_MethodPattern05() throws CoreException { setUpBug110060_MethodPattern(); search("aMethod", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWithNothingSpecial() [aMethodWithNothingSpecial] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWithNothingSpecial()] EXACT_MATCH" ); } public void testBug110060_MethodPattern05_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMethod", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern06() throws CoreException { setUpBug110060_MethodPattern(); search("aMethodWith1", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH" ); } public void testBug110060_MethodPattern06_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMethodWith1", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_MethodPattern07() throws CoreException { setUpBug110060_MethodPattern(); search("*Method*With*A*", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWithNothingSpecial() [aMethodWithNothingSpecial] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.otherMethodWhichStartsWithAnotherLetter() [otherMethodWhichStartsWithAnotherLetter] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWithNothingSpecial()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [otherMethodWhichStartsWithAnotherLetter()] EXACT_MATCH" ); } public void testBug110060_MethodPattern07_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("*Method*With*A*", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); // Invalid camel case pattern => replace the camel case flag with pattern match one (case insensitive) assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWithNothingSpecial() [aMethodWithNothingSpecial] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.otherMethodWhichStartsWithAnotherLetter() [otherMethodWhichStartsWithAnotherLetter] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWithNothingSpecial()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [otherMethodWhichStartsWithAnotherLetter()] EXACT_MATCH" ); } public void testBug110060_MethodPattern08() throws CoreException { setUpBug110060_MethodPattern(); search("aMW1D", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.aMethodWith1DigitAnd_AnUnderscore() [aMethodWith1DigitAnd_AnUnderscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1DigitAnd_AnUnderscore()] EXACT_MATCH" ); } public void testBug110060_MethodPattern08_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMW1D", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Digit() [aMethodWith1Digit] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Digit()] EXACT_MATCH" ); } public void testBug110060_MethodPattern09() throws CoreException { setUpBug110060_MethodPattern(); search("aMWOOODASU", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH" ); } public void testBug110060_MethodPattern09_SamePartCount() throws CoreException { setUpBug110060_MethodPattern(); search("aMWOOODASU", METHOD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java void b110060.Test.aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aMethodWith1Or2_Or_3_Or__4__DigitsAnd_Several_Underscores()] EXACT_MATCH" ); } // Fields search private void setUpBug110060_FieldPattern() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110060/Test.java", "package b110060;\n" + "public class Test {\n" + " Object aFieldWithNothingSpecial;\n" + " Object aFieldWithS$Dollar;\n" + " Object aFieldWith$Several$DollarslAnd1DigitAnd_1Underscore;\n" + " Object aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars;\n" + " Object otherFieldWhichStartsWithAnotherLetter;\n" + " void testReferences() {\n" + " Object o0 = aFieldWithNothingSpecial;\n" + " Object o1 = aFieldWithS$Dollar;\n" + " Object o2 = aFieldWith$Several$DollarslAnd1DigitAnd_1Underscore;\n" + " Object o3 = aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars;\n" + " }\n" + " Object oF = otherFieldWhichStartsWithAnotherLetter;\n" + "}\n" ); } public void testBug110060_FieldPattern01() throws CoreException { setUpBug110060_FieldPattern(); search("aFWSD", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aFieldWithS$Dollar [aFieldWithS$Dollar] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.aFieldWith$Several$DollarslAnd1DigitAnd_1Underscore [aFieldWith$Several$DollarslAnd1DigitAnd_1Underscore] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aFieldWithS$Dollar] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aFieldWith$Several$DollarslAnd1DigitAnd_1Underscore] EXACT_MATCH" ); } public void testBug110060_FieldPattern01_SamePartCount() throws CoreException { setUpBug110060_FieldPattern(); search("aFWSD", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aFieldWithS$Dollar [aFieldWithS$Dollar] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aFieldWithS$Dollar] EXACT_MATCH" ); } public void testBug110060_FieldPattern02() throws CoreException { setUpBug110060_FieldPattern(); search("afwsd", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults(""); } public void testBug110060_FieldPattern02_SamePartCount() throws CoreException { setUpBug110060_FieldPattern(); search("afwsd", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_FieldPattern03() throws CoreException { setUpBug110060_FieldPattern(); search("aFWS$", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aFieldWithS$Dollar [aFieldWithS$Dollar] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aFieldWithS$Dollar] EXACT_MATCH" ); } public void testBug110060_FieldPattern03_SamePartCount() throws CoreException { setUpBug110060_FieldPattern(); search("aFWS$", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults(""); } public void testBug110060_FieldPattern04() throws CoreException { setUpBug110060_FieldPattern(); search("aSFWSCD", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars [aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars] EXACT_MATCH" ); } public void testBug110060_FieldPattern04_SamePartCount() throws CoreException { setUpBug110060_FieldPattern(); search("aSFWSCD", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars [aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars] EXACT_MATCH\n" + "src/b110060/Test.java void b110060.Test.testReferences() [aStrangeFieldWith$$$$$$$$$$$$$$$SeveraContiguousDollars] EXACT_MATCH" ); } public void testBug110060_FieldPattern05() throws CoreException { setUpBug110060_FieldPattern(); search("oF", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.otherFieldWhichStartsWithAnotherLetter [otherFieldWhichStartsWithAnotherLetter] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.oF [oF] EXACT_MATCH\n" + "src/b110060/Test.java b110060.Test.oF [otherFieldWhichStartsWithAnotherLetter] EXACT_MATCH" ); } public void testBug110060_FieldPattern05new() throws CoreException { setUpBug110060_FieldPattern(); search("oF", FIELD, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b110060/Test.java b110060.Test.oF [oF] EXACT_MATCH" ); } /** * @test Bug 110291: [search] BasicSearchEngine return constructor declarations that doesn't exist in source * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110291" */ public void testBug110291() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110291/Test110291XX.java", "package b110291;\n" + "public class Test110291XX {\n" + " class Test110291YY {}" + "}\n" ); search("Test110291", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PREFIX_MATCH); assertSearchResults( "src/b110291/Test110291XX.java b110291.Test110291XX$Test110291YY [Test110291YY] EXACT_MATCH" ); } /** * @test Bug 110336: [plan][search] Should optionally return the local variable for type reference * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110336" */ public void testBug110336a() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " <TP extends Test> void method(Class<Test> clazz) {\n" + " Test localVar1 = new Test();\n" + " Class<Test> localVar2 = new Class<Test>();\n" + " localVar1.method(localVar2);\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java void b110336.Test.method(Class<Test>).TP [Test]\n" + "src/b110336/Test.java void b110336.Test.method(Class<Test>).clazz [Test]\n" + "src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar1 [Test]\n" + "src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar1 [Test]\n" + "src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar2 [Test]\n" + "src/b110336/Test.java void b110336.Test.method(Class<Test>).localVar2 [Test]", collector ); } public void testBug110336b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " void method1(Test methodParam) {\n" + " Test localVar1 = new Test(){\n" + " Class c = Test.class;\n" + " <TP extends Test> void foo(){\n" + " Test o = (Test) null;\n" + " }\n" + " };\n" + " } \n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1 [Test]\n" + "src/b110336/Test.java void b110336.Test.method1(Test):<anonymous>#1.c [Test]\n" + "src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().TP [Test]\n" + "src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().o [Test]\n" + "src/b110336/Test.java void void b110336.Test.method1(Test):<anonymous>#1.foo().o [Test]\n" + "src/b110336/Test.java void b110336.Test.method1(Test).methodParam [Test]\n" + "src/b110336/Test.java void b110336.Test.method1(Test).localVar1 [Test]", collector ); } public void testBug110336c() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test<TP extends X> {\n" + " X x;\n" + "\n" + "}\n" + "class X {}\n" ); IType type = this.workingCopies[0].getType("X"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java b110336.Test.TP [X]\n" + "src/b110336/Test.java b110336.Test.x [X]", collector ); } public void testBug110336d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " Test a1Test = null, b1Test = new Test(), c1Test;\n" + " Test a2Test = new Test(), b2Test, c2Test = null;\n" + " Test a3Test, b3Test = null, c3Test = new Test();\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java b110336.Test.a1Test [Test]+[b1Test,c1Test]\n" + "src/b110336/Test.java b110336.Test.b1Test [Test]\n" + "src/b110336/Test.java b110336.Test.a2Test [Test]+[b2Test,c2Test]\n" + "src/b110336/Test.java b110336.Test.a2Test [Test]\n" + "src/b110336/Test.java b110336.Test.a3Test [Test]+[b3Test,c3Test]\n" + "src/b110336/Test.java b110336.Test.c3Test [Test]", collector ); } public void testBug110336e() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " void foo() {\n" + " Test lv1 = null, lv2 = new Test(), lv3;\n" + " Test lv4 = new Test(), lv5, lv6 = null;\n" + " Test lv7, lv8 = null, lv9 = new Test();\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java void b110336.Test.foo().lv1 [Test]+[lv2,lv3]\n" + "src/b110336/Test.java void b110336.Test.foo().lv2 [Test]\n" + "src/b110336/Test.java void b110336.Test.foo().lv4 [Test]+[lv5,lv6]\n" + "src/b110336/Test.java void b110336.Test.foo().lv4 [Test]\n" + "src/b110336/Test.java void b110336.Test.foo().lv7 [Test]+[lv8,lv9]\n" + "src/b110336/Test.java void b110336.Test.foo().lv9 [Test]", collector ); } public void testBug110336f() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test extends Exception {\n" + " void foo(Test test1) { // <- no local element\n" + " Test test2; // <- local element\n" + " try {\n" + " throw new Test();\n" + " }\n" + " catch (Test test4) { // <- no local element\n" + " }\n" + " for(Test test3;;) {} // <- local element\n" + " }\n" + "\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java void b110336.Test.foo(Test).test1 [Test]\n" + "src/b110336/Test.java void b110336.Test.foo(Test).test2 [Test]\n" + "src/b110336/Test.java void b110336.Test.foo(Test) [Test]\n" + "src/b110336/Test.java void b110336.Test.foo(Test).test4 [Test]\n" + "src/b110336/Test.java void b110336.Test.foo(Test).test3 [Test]", collector ); } public void testBug110336g() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " {\n" + " Test lv1 = null, lv2 = new Test(), lv3;\n" + " Test lv4 = new Test(), lv5, lv6 = null;\n" + " Test lv7, lv8 = null, lv9 = new Test();\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java b110336.Test.{}.lv1 [Test]+[lv2,lv3]\n" + "src/b110336/Test.java b110336.Test.{}.lv2 [Test]\n" + "src/b110336/Test.java b110336.Test.{}.lv4 [Test]+[lv5,lv6]\n" + "src/b110336/Test.java b110336.Test.{}.lv4 [Test]\n" + "src/b110336/Test.java b110336.Test.{}.lv7 [Test]+[lv8,lv9]\n" + "src/b110336/Test.java b110336.Test.{}.lv9 [Test]", collector ); } public void testBug110336h() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110336/Test.java", "package b110336;\n" + "public class Test {\n" + " static {\n" + " Test lv1 = null, lv2 = new Test(), lv3;\n" + " Test lv4 = new Test(), lv5, lv6 = null;\n" + " Test lv7, lv8 = null, lv9 = new Test();\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/b110336/Test.java b110336.Test.static {}.lv1 [Test]+[lv2,lv3]\n" + "src/b110336/Test.java b110336.Test.static {}.lv2 [Test]\n" + "src/b110336/Test.java b110336.Test.static {}.lv4 [Test]+[lv5,lv6]\n" + "src/b110336/Test.java b110336.Test.static {}.lv4 [Test]\n" + "src/b110336/Test.java b110336.Test.static {}.lv7 [Test]+[lv8,lv9]\n" + "src/b110336/Test.java b110336.Test.static {}.lv9 [Test]", collector ); } /** * @test Bug 110422: [search] BasicSearchEngine doesn't find all type declarations * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=110422" */ public void testBug110422a() throws CoreException { search("TestP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "lib/b110422.jar b110422.TestPrefix EXACT_MATCH" ); } public void testBug110422b() throws CoreException { search("TESTP", TYPE, DECLARATIONS, SearchPattern.R_PREFIX_MATCH); assertSearchResults( "lib/b110422.jar b110422.TestPrefix EXACT_MATCH" ); } /** * @bug 113671: [search] AIOOBE in SearchEngine#searchAllTypeNames * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=113671" */ public void testBug113671() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( "java.lang".toCharArray(), SearchPattern.R_EXACT_MATCH, CharOperation.NO_CHAR, SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, getJavaSearchScope(), requestor, WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.CharSequence\n" + "java.lang.Class\n" + "java.lang.CloneNotSupportedException\n" + "java.lang.Comparable\n" + "java.lang.Deprecated\n" + "java.lang.Enum\n" + "java.lang.Error\n" + "java.lang.Exception\n" + "java.lang.IllegalMonitorStateException\n" + "java.lang.InterruptedException\n" + "java.lang.Object\n" + "java.lang.RuntimeException\n" + "java.lang.String\n" + "java.lang.Throwable", requestor); } /** * @test Bug 114539: [search] Internal error when refactoring code with errors * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=114539" */ public void testBug114539() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b114539/Foo.java", "package b114539;\n" + "public class Foo {\n" + " int bar=Bar.FOO;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b114539/Bar.java", "package b114539;\n" + "public class Bar {\n" + " private static final int FOO=0;\n" + "}\n" ); IField field = this.workingCopies[1].getType("Bar").getField("FOO"); search(field, REFERENCES); assertSearchResults( "src/b114539/Foo.java b114539.Foo.bar [FOO] POTENTIAL_MATCH" ); } /** * @bug 116459: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=116459" */ public void testBug116459() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/p1/X.java", "package p1;\n" + "class X<T> {\n" + " X<T> gen;\n" + " X<String> param;\n" + " X raw;\n" + "}" ); IType type = this.workingCopies[0].getType("X"); this.resultCollector.showRule(); search(type, REFERENCES, ERASURE_RULE); assertSearchResults( "src/p1/X.java p1.X.gen [X] EXACT_MATCH\n" + "src/p1/X.java p1.X.param [X] ERASURE_MATCH\n" + "src/p1/X.java p1.X.raw [X] ERASURE_RAW_MATCH" ); } /** * @test Bug 119545: [search] Binary java method model elements returned by SearchEngine have unresolved parameter types * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=119545" */ public void testBug119545() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b119545/Test.java", "package b119545;\n" + "class Test {\n" + " void foo(Object o1, Object o2){\n" + " if (o1.equals(o2)) {}\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); IMethod method = type.getMethods()[0]; searchDeclarationsOfSentMessages(method, this.resultCollector); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " boolean java.lang.Object.equals(java.lang.Object) EXACT_MATCH" ); } /** * @test Bug 120816: [search] NullPointerException at ...jdt.internal.compiler.lookup.SourceTypeBinding.getMethods * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=120816" */ public void testBug120816a() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b120816/Test.java", "package b120816;\n" + "public class Test<E> {\n" + " String foo(E e) { return \"\"; }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b120816/Sub.java", "package b120816;\n" + "public class Sub extends Test<Exception> {\n" + " String foo(RuntimeException e) { return \"\"; }\n" + " String foo(Exception e) {\n" + " return super.foo(e);\n" + " }\n" + "}\n" ); search("* String (Exception)", METHOD, DECLARATIONS); assertSearchResults( "src/b120816/Sub.java String b120816.Sub.foo(Exception) [foo] EXACT_MATCH" ); } public void testBug120816b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b120816/Test.java", "package b120816;\n" + "public class Test<E> {\n" + " String foo(E e) { return \"\"; }\n" + "}\n" + "class Sub extends Test<Exception> {\n" + " String foo(RuntimeException e) { return \"\"; }\n" + " String foo(Exception e) {\n" + " return super.foo(e);\n" + " }\n" + "}\n" ); search("* String (Exception)", METHOD, DECLARATIONS); assertSearchResults( "src/b120816/Test.java String b120816.Sub.foo(Exception) [foo] EXACT_MATCH" ); } /** * @test Bug 122442: [search] API inconsistency with IJavaSearchConstants.IMPLEMENTORS and SearchPattern * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=122442" */ private void setUpBug122442a() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b122442/I.java", "package b122442;\n" + "public interface I {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b122442/II.java", "package b122442;\n" + "public interface II extends I {}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b122442/X.java", "package b122442;\n" + "public class X implements I {}\n" ); } public void testBug122442a() throws CoreException { setUpBug122442a(); search("I", TYPE, IMPLEMENTORS); assertSearchResults( "src/b122442/II.java b122442.II [I] EXACT_MATCH\n" + "src/b122442/X.java b122442.X [I] EXACT_MATCH" ); } public void testBug122442b() throws CoreException { setUpBug122442a(); search("I", INTERFACE, IMPLEMENTORS); assertSearchResults( "src/b122442/II.java b122442.II [I] EXACT_MATCH" ); } public void testBug122442c() throws CoreException { setUpBug122442a(); search("I", CLASS, IMPLEMENTORS); assertSearchResults( "src/b122442/X.java b122442.X [I] EXACT_MATCH" ); } private void setUpBug122442d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b122442/User.java", "class Klass {}\n" + "interface Interface {}\n" + "class User {\n" + " void m() {\n" + " new Klass() {};\n" + " new Interface() {};\n" + " }\n" + "}\n" + "class Sub extends Klass {}" ); } public void testBug122442d() throws CoreException { setUpBug122442d(); search("Interface", TYPE, IMPLEMENTORS); assertSearchResults( "src/b122442/User.java void b122442.User.m():<anonymous>#2 [Interface] EXACT_MATCH" ); } public void testBug122442e() throws CoreException { setUpBug122442d(); search("Interface", INTERFACE, IMPLEMENTORS); assertSearchResults( "" // expected no result ); } public void testBug122442f() throws CoreException { setUpBug122442d(); search("Interface", CLASS, IMPLEMENTORS); assertSearchResults( "src/b122442/User.java void b122442.User.m():<anonymous>#2 [Interface] EXACT_MATCH" ); } public void testBug122442g() throws CoreException { setUpBug122442d(); search("Klass", TYPE, IMPLEMENTORS); assertSearchResults( "src/b122442/User.java void b122442.User.m():<anonymous>#1 [Klass] EXACT_MATCH\n" + "src/b122442/User.java b122442.Sub [Klass] EXACT_MATCH" ); } public void testBug122442h() throws CoreException { setUpBug122442d(); search("Klass", INTERFACE, IMPLEMENTORS); assertSearchResults( "" // expected no result ); } public void testBug122442i() throws CoreException { setUpBug122442d(); search("Klass", CLASS, IMPLEMENTORS); assertSearchResults( "src/b122442/User.java void b122442.User.m():<anonymous>#1 [Klass] EXACT_MATCH\n" + "src/b122442/User.java b122442.Sub [Klass] EXACT_MATCH" ); } /** * @bug 123679: [search] Field references not found when type is a qualified member type [regression] * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=123679" */ public void testBug123679() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b123679.jar", "pack").getClassFile("I123679.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b123679.jar test.<anonymous> EXACT_MATCH\n" + "lib/b123679.jar test.Test$StaticClass$Member.parent EXACT_MATCH\n" + "lib/b123679.jar test.<anonymous> EXACT_MATCH\n" + "lib/b123679.jar test.Test$StaticClass$Member(test.Test.StaticClass, java.lang.Object) EXACT_MATCH\n" + "lib/b123679.jar test.Test$StaticClass$Member(test.Test.StaticClass, java.lang.Object) EXACT_MATCH\n" + "lib/b123679.jar pack.I123679 test.Test$StaticClass$Member.getParent() EXACT_MATCH" ); } public void testBug123679_cu() throws CoreException { ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b123679.pack", "I123679.java"); IType type = unit.getType("I123679"); search(type, REFERENCES); assertSearchResults( "src/b123679/test/Test.java [b123679.pack.I123679] EXACT_MATCH\n" + "src/b123679/test/Test.java b123679.test.Test$StaticClass$Member.parent [I123679] EXACT_MATCH\n" + "src/b123679/test/Test.java b123679.test.Test$StaticClass$Member(Object):<anonymous>#1 [I123679] EXACT_MATCH\n" + "src/b123679/test/Test.java b123679.test.Test$StaticClass$Member(Object) [I123679] EXACT_MATCH\n" + "src/b123679/test/Test.java b123679.test.Test$StaticClass$Member(Object) [I123679] EXACT_MATCH\n" + "src/b123679/test/Test.java I123679 b123679.test.Test$StaticClass$Member.getParent() [I123679] EXACT_MATCH" ); } public void testBug123679_wc() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/I122679.java", "package pack;\n" + "public interface I123679 {\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", "package test;\n" + "import pack.I123679;\n" + "public class Test {\n" + " static class StaticClass {\n" + " class Member {\n" + " private I123679 parent;\n" + " Member(Object obj) {\n" + " if (obj instanceof I123679) {\n" + " parent = (I123679) obj;\n" + " } else {\n" + " parent = new I123679() {};\n" + " }\n" + " }\n" + " I123679 getParent() {\n" + " return parent;\n" + " }\n" + " }\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("I123679"); search(type, REFERENCES); assertSearchResults( "src/test/Test.java [pack.I123679] EXACT_MATCH\n" + "src/test/Test.java test.Test$StaticClass$Member.parent [I123679] EXACT_MATCH\n" + "src/test/Test.java test.Test$StaticClass$Member(Object):<anonymous>#1 [I123679] EXACT_MATCH\n" + "src/test/Test.java test.Test$StaticClass$Member(Object) [I123679] EXACT_MATCH\n" + "src/test/Test.java test.Test$StaticClass$Member(Object) [I123679] EXACT_MATCH\n" + "src/test/Test.java I123679 test.Test$StaticClass$Member.getParent() [I123679] EXACT_MATCH" ); } /** * @bug 124469: [search] AIOOBE in PatternLocator when searching for dependency extent from manifest * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124469" */ public void testBug124469a() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b124469.jar pack.E pack.A1.value() EXACT_MATCH\n" + "lib/b124469.jar pack.E[] pack.A1.list() EXACT_MATCH\n" + "lib/b124469.jar pack.E pack.A2.value() EXACT_MATCH\n" + "lib/b124469.jar pack.E[] pack.A2.list() EXACT_MATCH\n" + "lib/b124469.jar pack.E pack.A3.value() EXACT_MATCH\n" + "lib/b124469.jar pack.E[] pack.A3.list() EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469b() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "A1.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b124469.jar pack.A1 pack.A2.annot() EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469c() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "A2.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b124469.jar pack.A2 pack.A3.annot() EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469d() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "A3.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469e() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CC"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH" ); } public void testBug124469f() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CF"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH" ); } public void testBug124469g() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CM"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469h() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CP"); search(field, REFERENCES); assertSearchResults( "" // expected no result as parameters annotations are not stored in class file ); } public void testBug124469i() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CV"); search(field, REFERENCES); assertSearchResults( "" // expected no result as parameters annotations are not stored in class file ); } public void testBug124469j() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CAC"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH\n" + "lib/b124469.jar test.C EXACT_MATCH" ); } public void testBug124469k() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CAF"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH\n" + "lib/b124469.jar test.F.field EXACT_MATCH" ); } public void testBug124469l() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CAM"); search(field, REFERENCES); assertSearchResults( "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH\n" + "lib/b124469.jar void test.M.foo() EXACT_MATCH" ); } public void testBug124469m() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CAP"); search(field, REFERENCES); assertSearchResults( "" // expected no result as parameters annotations are not stored in class file ); } public void testBug124469n() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b124469.jar", "pack", "E.class").getType(); IField field = type.getField("CAV"); search(field, REFERENCES); assertSearchResults( "" // expected no result as parameters annotations are not stored in class file ); } /** * @bug 124489: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124489" */ public void testBug124489() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Foo.java", "public class Foo<T> {}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/Bar.java", "public class Bar {\n" + " Foo<String> f = new Foo<String>();\n" + " Foo f2 = new Foo();\n" + "}" ); IType type = this.workingCopies[0].getType("Foo"); this.resultCollector.showRule(); new SearchEngine(this.workingCopies).search( SearchPattern.createPattern(type, REFERENCES), new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchScope(), this.resultCollector, null ); assertSearchResults( "src/Bar.java Bar.f [Foo] ERASURE_MATCH\n" + "src/Bar.java Bar.f [Foo] ERASURE_MATCH\n" + "src/Bar.java Bar.f2 [Foo] ERASURE_RAW_MATCH\n" + "src/Bar.java Bar.f2 [Foo] ERASURE_RAW_MATCH" ); } /** * @bug 124624: [search] Camel case matching routines should support end character * @test Ensure that camel case pattern may use end character * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124624" */ private void setupBug124624() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "class HashMap {}\n" + "class HtmlMapper {}\n" + "class HashMapEntry {}\n" + "class HaxMapxxxx {}\n" ); } public void testBug124624_HM_CamelCase() throws CoreException { setupBug124624(); search("HM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HM_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaM_CamelCase() throws CoreException { setupBug124624(); search("HaM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaM_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HaM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HashM_CamelCase() throws CoreException { setupBug124624(); search("HashM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH" ); } public void testBug124624_HashM_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HashM", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH" ); } public void testBug124624_HMa_CamelCase() throws CoreException { setupBug124624(); search("HMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HMa_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaMa_CamelCase() throws CoreException { setupBug124624(); search("HaMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaMa_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HaMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HashMa_CamelCase() throws CoreException { setupBug124624(); search("HashMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH" ); } public void testBug124624_HashMa_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HashMa", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH" ); } public void testBug124624_HMap_CamelCase() throws CoreException { setupBug124624(); search("HMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HMap_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HtmlMapper [HtmlMapper] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaMap_CamelCase() throws CoreException { setupBug124624(); search("HaMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HaMap_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HaMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HaxMapxxxx [HaxMapxxxx] EXACT_MATCH" ); } public void testBug124624_HashMap_CamelCase() throws CoreException { setupBug124624(); search("HashMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH\n" + "src/Test.java HashMapEntry [HashMapEntry] EXACT_MATCH" ); } public void testBug124624_HashMap_CamelCaseSamePartCount() throws CoreException { setupBug124624(); search("HashMap", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/Test.java HashMap [HashMap] EXACT_MATCH" ); } /** * @test Bug 124645: [search] for implementors does not find subclasses of binary classes * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=124645" */ public void testBug124645a() throws CoreException { IClassFile classFile = getClassFile("JavaSearchBugs", "lib/b124645.jar", "xy", "BE_124645.class"); IType type = classFile.getType(); search(type, IMPLEMENTORS); assertSearchResults( "src/b124645/xy/X_124645.java b124645.xy.X_124645$Y [BE_124645] EXACT_MATCH\n" + "src/b124645/xy/Y_124645.java b124645.xy.Y_124645 [BE_124645] EXACT_MATCH\n" + "lib/b124645.jar xy.BX_124645$Y EXACT_MATCH\n" + "lib/b124645.jar xy.BY_124645 EXACT_MATCH" ); } public void testBug124645b() throws CoreException { IClassFile classFile = getClassFile("JavaSearchBugs", "lib/b124645.jar", "test", "BE_124645.class"); IType type = classFile.getType(); search(type, IMPLEMENTORS); assertSearchResults( "src/b124645/test/A_124645.java b124645.test.A_124645 [BE_124645] EXACT_MATCH\n" + "src/b124645/test/A_124645.java void b124645.test.A_124645.m():<anonymous>#1 [BE_124645] EXACT_MATCH\n" + "src/b124645/test/X_124645.java b124645.test.X_124645 [BE_124645] EXACT_MATCH\n" + "src/b124645/test/X_124645.java void b124645.test.X_124645.m():Y_124645#1 [BE_124645] EXACT_MATCH\n" + "lib/b124645.jar test.BA_124645 EXACT_MATCH\n" + "lib/b124645.jar test.<anonymous> EXACT_MATCH\n" + "lib/b124645.jar test.BX_124645 EXACT_MATCH\n" + "lib/b124645.jar test.Y EXACT_MATCH" ); } public void testBug124645c() throws CoreException { IClassFile classFile = getClassFile("JavaSearchBugs", "lib/b124645.jar", "", "BC_124645.class"); IType type = classFile.getType(); search(type, IMPLEMENTORS); assertSearchResults( "lib/b124645.jar <anonymous> EXACT_MATCH" ); } public void testBug124645d() throws CoreException { IClassFile classFile = getClassFile("JavaSearchBugs", "lib/b124645.jar", "", "BI_124645.class"); IType type = classFile.getType(); search(type, IMPLEMENTORS); assertSearchResults( "lib/b124645.jar <anonymous> EXACT_MATCH" ); } /** * @bug 125178: [search] AIOOBE in PatternLocator when searching for dependency extent from manifest * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=125178" */ public void testBug125178() throws CoreException { // Need a working copy as anonymous are not indexed... ProblemRequestor problemRequestor = new ProblemRequestor(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b125178/X.java", "package b125178;\n" + "import pack.age.Test;\n" + "public class X {\n" + " public static void main(String[] args) {\n" + " new Test().foo(100);\n" + " }\n" + "}\n", newWorkingCopyOwner(problemRequestor) ); assertEquals("CU Should not have any problem!", "----------\n" + "----------\n", problemRequestor.problems.toString() ); // Get anonymous from IPackageFragment jar = getPackageFragment("JavaSearchBugs", "lib/b125178.jar", "pack.age"); IJavaElement[] children = jar.getChildren(); assertNotNull("We should have children for in default package of lib/b125178.jar", children); for (int i=0,l=children.length; i<l; i++) { assertTrue("Jar should only have class files!", children[i] instanceof ClassFile); IType type = ((ClassFile)children[i]).getType(); if (type.isAnonymous()) { search(type, REFERENCES); } } assertSearchResults( "" // no result expected ); } /** * @bug 126330: Type reference not found in jar file if sources was not already opened * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=126330" */ public void testBug126330() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b126330.jar", "").getClassFile("A126330.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b126330.jar B126330.a EXACT_MATCH" ); } /** * @bug 127628: [index] CodeAssist doesn't filter deprecated types * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=127628" */ public void testBug127628() throws CoreException { class DeprecatedTypesRequestor extends SearchTests.SearchTypeNameRequestor { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { if ((modifiers & ClassFileConstants.AccDeprecated) != 0) { char[] typeName = CharOperation.concat( CharOperation.concatWith(enclosingTypeNames, '$'), simpleTypeName, '$'); this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.'))); } } } TypeNameRequestor requestor = new DeprecatedTypesRequestor(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b127628.Test127628", requestor); } /** * @bug 128877: [search] reports inexistent IMethod for binary constructor of inner class * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=128877" */ public void testBug128877a() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType(); IMethod method = type.getMethod("Test", new String[0]); search(method, REFERENCES); assertSearchResults( "lib/b128877.jar pack.X$Sub(pack.X) EXACT_MATCH" ); } public void testBug128877b() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType(); IMethod method = type.getMethod("Test", new String[] { "Ljava.lang.String;" }); search(method, REFERENCES); assertSearchResults( "lib/b128877.jar pack.X$Sub(pack.X, java.lang.String) EXACT_MATCH" ); } public void testBug128877c() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType(); IMethod method = type.getMethod("foo128877", new String[] { "I" }); search(method, REFERENCES); assertSearchResults( "lib/b128877.jar pack.X$Sub(pack.X) EXACT_MATCH" ); } /** * To get these tests search matches in a workspace, do NOT forget to modify files * to set them as working copies. * * @test Bug 130390: CamelCase algorithm cleanup and improvement * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=130390" */ private void setUpBug130390() throws CoreException { this.workingCopies = new ICompilationUnit[4]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b130390/TZ.java", "package b130390;\n" + "public class TZ {\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b130390/TimeZone.java", "package b130390;\n" + "public class TimeZone{\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b130390/Npe.java", "package b130390;\n" + "public class Npe {\n" + "}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b130390/NullPointerException.java", "package b130390;\n" + "public class NullPointerException {\n" + "}\n" ); } public void testBug130390_CamelCase() throws CoreException { setUpBug130390(); search("NuPoEx", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("NuPoEx", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390b_CamelCase() throws CoreException { setUpBug130390(); search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH\n" + "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390b_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390c_CamelCase() throws CoreException { setUpBug130390(); search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390c_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("NPE", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390d_CamelCase() throws CoreException { setUpBug130390(); search("Npe", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH" ); } public void testBug130390d_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("Npe", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH" ); } public void testBug130390e_CamelCase() throws CoreException { setUpBug130390(); search("Npe", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH" ); } public void testBug130390e_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("Npe", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/Npe.java b130390.Npe [Npe] EXACT_MATCH" ); } public void testBug130390f_CamelCase() throws CoreException { setUpBug130390(); search("NullPE", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_MATCH); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390f_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("NullPE", TYPE, ALL_OCCURRENCES, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH); assertSearchResults( "src/b130390/NullPointerException.java b130390.NullPointerException [NullPointerException] EXACT_MATCH" ); } public void testBug130390g_CamelCase() throws CoreException { setUpBug130390(); search("TZ", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/TZ.java b130390.TZ [TZ] EXACT_MATCH\n" + "src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH" ); } public void testBug130390g_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("TZ", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/TZ.java b130390.TZ [TZ] EXACT_MATCH\n" + "src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH" ); } public void testBug130390h_CamelCase() throws CoreException { setUpBug130390(); search("TiZo", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH" ); } public void testBug130390h_CamelCaseSamePartCount() throws CoreException { setUpBug130390(); search("TiZo", TYPE, DECLARATIONS, SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH | SearchPattern.R_CASE_SENSITIVE); assertSearchResults( "src/b130390/TimeZone.java b130390.TimeZone [TimeZone] EXACT_MATCH" ); } /** * To get these tests search matches in a workspace, do NOT forget to modify files * to set them as working copies. * * @bug 137087: Open Type - missing matches when using mixed case pattern * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=137087" */ public void testBug137087_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "runtimeEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH" ); } public void testBug137087b_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "Runtimeex"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH" ); } public void testBug137087c_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "runtimeexception"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH" ); } public void testBug137087d_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "Runtimexception"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( "" // no match expected as pattern is missing a 'e' ); } public void testBug137087e_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "IllegalMSException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.IllegalMonitorStateException EXACT_MATCH" ); } public void testBug137087f_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "illegalMsExceptionSException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( "" // expected no result as uppercase characters in pattern do not match any camelcase ones in existing types ); } public void testBug137087g_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "clonenotsupportedex"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087h_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "CloneNotSupportedEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087i_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "cloneNotsupportedEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087j_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "ClonenotSupportedexc"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087k_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "cloneNotSupportedExcep"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087l_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "Clonenotsupportedexception"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087m_CamelCase() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_MATCH; String pattern = "CloneNotSupportedException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } // Same tests using SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH public void testBug137087_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "runtimeEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults(""); } public void testBug137087b_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "Runtimeex"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults(""); } public void testBug137087c_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "runtimeexception"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.RuntimeException EXACT_MATCH" ); } public void testBug137087d_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "Runtimexception"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( "" // no match expected as pattern is missing a 'e' ); } public void testBug137087e_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "IllegalMSException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.IllegalMonitorStateException EXACT_MATCH" ); } public void testBug137087f_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "illegalMsExceptionSException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( "" // expected no result as uppercase characters in pattern do not match any camel case ones in existing types ); } public void testBug137087g_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "clonenotsupportedex"; search(pattern, TYPE, DECLARATIONS, matchRule); // Invalid camel case match pattern => replaced with exact match one (case insensitive) assertSearchResults(""); } public void testBug137087h_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "CloneNotSupportedEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087i_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "cloneNotsupportedEx"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults(""); } public void testBug137087j_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "ClonenotSupportedexc"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults(""); } public void testBug137087k_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "cloneNotSupportedExcep"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults(""); } public void testBug137087l_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "Clonenotsupportedexception"; search(pattern, TYPE, DECLARATIONS, matchRule); // Invalid camel case match pattern => replaced with exact match one (case insensitive) assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } public void testBug137087m_CamelCaseSamePartCount() throws CoreException { int matchRule = SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH; String pattern = "CloneNotSupportedException"; search(pattern, TYPE, DECLARATIONS, matchRule); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.CloneNotSupportedException EXACT_MATCH" ); } /** * @bug 137984: [search] Field references not found when type is a qualified member type [regression] * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=137984" */ public void testBug137984_jar() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b137984.jar", "").getClassFile("CJ.class").getType(); IField field = type.getField("c3"); search(field, REFERENCES); assertSearchResults( "lib/b137984.jar CJ(int) EXACT_MATCH" ); } public void testBug137984_cu() throws CoreException { ICompilationUnit unit = getCompilationUnit("JavaSearchBugs", "src", "b137984", "C.java"); IField field = unit.getType("C").getField("c3"); search(field, REFERENCES); assertSearchResults( "src/b137984/C.java b137984.C(int) [c3] EXACT_MATCH" ); } public void testBug137984_wc() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/CW.java", "public class CW {\n" + " CW2 c2;\n" + " CW2.CW3 c3;\n" + " CW(int c) {\n" + " c2 = new CW2(c);\n" + " c3 = c2.new CW3(c);\n" + " }\n" + " class CW2 {\n" + " CW2(int x) {}\n" + " class CW3 {\n" + " CW3(int x) {}\n" + " }\n" + " }\n" + "}\n" ); IField field = this.workingCopies[0].getType("CW").getField("c3"); search(field, REFERENCES); assertSearchResults( "src/CW.java CW(int) [c3] EXACT_MATCH" ); } /** * @bug 140156: [1.5][search] Invalid method handle with parameterized parameters when no source is attached * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=140156" */ public void testBug140156() throws CoreException { IType type = getPackageFragment("JavaSearchBugs", "lib/b140156.jar", "").getClassFile("X.class").getType(); IMethod method = type.getMethods()[1]; assertEquals("Search wrong method!!!", "foo", method.getElementName()); search(method, DECLARATIONS); assertSearchResults( "lib/b140156.jar void X.foo(List<T>) [No source] EXACT_MATCH" ); } /** * @bug 142044: [search] "And" Pattern fails with NullPointerException * @test Verify that no NPE occurs while using a {@link AndPattern} * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=142044" * @deprecated As using deprecated method */ /* Bug test case: Following test does not produce any result due to the fact that each type reference on type only match one of the pattern => it always fails while making a AND on both matches... However, consider the bug fixed as we do not get the NPE... */ public void testBug142044() throws CoreException { IType type1 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern leftPattern = SearchPattern.createPattern(type1, IMPLEMENTORS); IType type2 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_B.java").getType("I142044_B"); SearchPattern rightPattern = SearchPattern.createPattern(type2, IMPLEMENTORS); search(SearchPattern.createAndPattern(leftPattern, rightPattern), getJavaSearchScope(), this.resultCollector); assertSearchResults(""); } /** * @deprecated As using deprecated method */ public void testBug142044_Identical() throws CoreException { IType type1 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern leftPattern = SearchPattern.createPattern(type1, IMPLEMENTORS); IType type2 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern rightPattern = SearchPattern.createPattern(type2, IMPLEMENTORS); search(SearchPattern.createAndPattern(leftPattern, rightPattern), getJavaSearchScope(), this.resultCollector); assertSearchResults( "src/b142044/X142044.java b142044.X142044$XX1 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044.java b142044.X142044$XX12 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_A.java b142044.X142044_A [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_AB.java b142044.X142044_AB [I142044_A] EXACT_MATCH" ); } /** * @deprecated As using deprecated method */ public void testBug142044_And01() throws CoreException { SearchPattern leftPattern = createPattern("X*", CLASS, DECLARATIONS, true); IType iType = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern rightPattern = SearchPattern.createPattern(iType, IMPLEMENTORS); search(SearchPattern.createAndPattern(leftPattern, rightPattern), getJavaSearchScope(), this.resultCollector); assertSearchResults(""); // currently no results as only same kind of pattern are ANDoable... } /** * @deprecated As using deprecated method */ public void testBug142044_And02() throws CoreException { IType type1 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern leftPattern = SearchPattern.createPattern(type1, IMPLEMENTORS); SearchPattern rightPattern = createPattern("I*", CLASS, IMPLEMENTORS, true); search(SearchPattern.createAndPattern(leftPattern, rightPattern), getJavaSearchScope(), this.resultCollector); assertSearchResults( "src/b142044/X142044.java b142044.X142044$XX1 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044.java b142044.X142044$XX12 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_A.java b142044.X142044_A [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_AB.java b142044.X142044_AB [I142044_A] EXACT_MATCH" ); } /** * @deprecated As using deprecated method */ public void testBug142044_Or() throws CoreException { IType type1 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_A.java").getType("I142044_A"); SearchPattern leftPattern = SearchPattern.createPattern(type1, IMPLEMENTORS); IType type2 = getCompilationUnit("JavaSearchBugs", "src", "b142044", "I142044_B.java").getType("I142044_B"); SearchPattern rightPattern = SearchPattern.createPattern(type2, IMPLEMENTORS); search(SearchPattern.createOrPattern(leftPattern, rightPattern), getJavaSearchScope(), this.resultCollector); assertSearchResults( "src/b142044/X142044.java b142044.X142044$XX1 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044.java b142044.X142044$XX2 [I142044_B] EXACT_MATCH\n" + "src/b142044/X142044.java b142044.X142044$XX12 [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044.java b142044.X142044$XX12 [I142044_B] EXACT_MATCH\n" + "src/b142044/X142044_A.java b142044.X142044_A [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_AB.java b142044.X142044_AB [I142044_A] EXACT_MATCH\n" + "src/b142044/X142044_AB.java b142044.X142044_AB [I142044_B] EXACT_MATCH\n" + "src/b142044/X142044_B.java b142044.X142044_B [I142044_B] EXACT_MATCH" ); } /** * @bug 144044: [search] NPE when trying to find references to field variable * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=144044" */ public void testBug144044() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test1/p/Test.java", "package test1.p;\n" + "import test1.q.X;\n" + "public class Test {\n" + " String foo(X val) {\n" + " return val.str;\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test1/q/X.java", "package test1.q;\n" + "public class X {\n" + " String str;\n" + "}\n" ); IType type = this.workingCopies[1].getType("X"); IField field = type.getField("str"); search(field, REFERENCES); assertSearchResults( "src/test1/p/Test.java String test1.p.Test.foo(X) [str] POTENTIAL_MATCH" ); } public void testBug144044b() throws CoreException { this.workingCopies = new ICompilationUnit[4]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test2/p/Test.java", "package test2.p;\n" + "import test2.q.X;\n" + "public class Test {\n" + " X foo() {\n" + " return X.y_field.z_field.x_field.y_field.z_field.x_field;\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test2/q/X.java", "package test2.q;\n" + "public class X {\n" + " public static Y y_field;\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/test2/q/Y.java", "package test2.q;\n" + "public class Y {\n" + " public static Z z_field;\n" + "}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/test2/q/Z.java", "package test2.q;\n" + "public class Z {\n" + " static X x_field;\n" + "}\n" ); IType type = this.workingCopies[3].getType("Z"); IField field = type.getField("x_field"); search(field, REFERENCES); assertSearchResults( "src/test2/p/Test.java X test2.p.Test.foo() [x_field] POTENTIAL_MATCH\n" + "src/test2/p/Test.java X test2.p.Test.foo() [x_field] POTENTIAL_MATCH" ); } /** * @bug 148215: [search] correct results are missing in java search * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=148215" */ public void testBug148215_Types() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b148215.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b148215.jar", "test.pack", "Test.class").getType(); IMethod method = type.getMethods()[1]; searchDeclarationsOfReferencedTypes(method, this.resultCollector); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java.lang.Object EXACT_MATCH\n" + ""+ getExternalJCLPathString("1.5") + " java.lang.String EXACT_MATCH\n" + "lib/b148215.jar test.def.Reference EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b148215.jar")); } } public void testBug148215_Messages() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b148215.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b148215.jar", "test.pack", "Test.class").getType(); IMethod method = type.getMethods()[1]; searchDeclarationsOfSentMessages(method, this.resultCollector); assertSearchResults( "lib/b148215.jar void test.pack.Test.bar(java.lang.String) EXACT_MATCH\n" + "lib/b148215.jar void test.pack.Test.bar(test.def.Reference) EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b148215.jar")); } } public void testBug148215_Fields() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b148215.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b148215.jar", "test.pack", "Test.class").getType(); IMethod method = type.getMethods()[1]; searchDeclarationsOfAccessedFields(method, this.resultCollector); assertSearchResults( "lib/b148215.jar test.pack.Test.sField EXACT_MATCH\n" + "lib/b148215.jar test.pack.Test.rField EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b148215.jar")); } } /** * @bug 148380: [search] get IType from TypeNameRequestor result * @test new SearchEngine.searchAllTypeName API method using {@link TypeNameMatchRequestor} * instead of {@link TypeNameRequestor} * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=148380" */ public void testBug148380_SearchAllTypes_wc() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[4]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b148380/I.java", "package b148380;\n" + "public interface I {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b148380/X.java", "package b148380;\n" + "public class X {}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b148380/Sub.java", "package b148380;\n" + "public class Sub extends X {}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/b148380/Y.java", "package b148380;\n" + "public class Y {}\n" ); IJavaSearchScope scope = getJavaSearchScope(); TypeNameMatchCollector requestor1 = new TypeNameMatchCollector(); new SearchEngine(this.workingCopies).searchAllTypeNames( "b148380".toCharArray(), SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, scope, requestor1, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); String expected = "class Sub [in [Working copy] Sub.java [in b148380 [in src [in JavaSearchBugs]]]]\n" + "class X [in [Working copy] X.java [in b148380 [in src [in JavaSearchBugs]]]]\n" + "class Y [in [Working copy] Y.java [in b148380 [in src [in JavaSearchBugs]]]]\n" + "interface I [in [Working copy] I.java [in b148380 [in src [in JavaSearchBugs]]]]"; assertSearchResults(expected, requestor1); // Expected same result with the wc owner TypeNameMatchCollector requestor2 = new TypeNameMatchCollector(); new SearchEngine(this.wcOwner).searchAllTypeNames( "b148380".toCharArray(), SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.TYPE, scope, requestor2, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults(expected, requestor2); } public void testBug148380_SearchAllTypes_cu() throws CoreException, JavaModelException { IJavaSearchScope scope = getJavaSearchScope(); TypeNameMatchCollector requestor = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "Bug".toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults( "Bug148380 (not open) [in Bug148380.class [in <default> [in lib [in JavaSearchBugs]]]]", requestor ); } public void testBug148380_SearchAllTypes_cu_wksp() throws CoreException, JavaModelException { IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); TypeNameMatchCollector requestor = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "Bug".toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults( "Bug148380 (not open) [in Bug148380.class [in <default> [in lib [in JavaSearchBugs]]]]", requestor ); } /** * @bug 153765: [search] Reference to package is not found in qualified annotation * @test Ensure that references to package are also found in qualified annotation * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=153765" */ public void testBug153765() throws CoreException { try { createFolder("/JavaSearchBugs/src/b153765"); createFile("/JavaSearchBugs/src/b153765/Unimportant.java", "package b153765;\n" + "public @interface Unimportant {}\n" ); createFolder("/JavaSearchBugs/src/b153765/test"); createFile("/JavaSearchBugs/src/b153765/test/SomeClass.java", "package test;\n" + "public class SomeClass {\n" + " @b153765.Unimportant public void foo() {}\n" + "}" ); waitUntilIndexesReady(); IPackageFragment packageFragment = getPackage("/JavaSearchBugs/src/b153765"); this.resultCollector.showSelection(); search(packageFragment, REFERENCES); assertSearchResults( "src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [ @�|b153765|�.Unimportant public void foo() {}] EXACT_MATCH" ); } finally { deleteFolder("/JavaSearchBugs/src/b153765"); } } /** * @bug 156340: [search] searchAllTypeNames return nothing for empty prefix * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156340" */ public void testBug156340() throws CoreException { TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); IPackageFragment fragment = getPackageFragment("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang"); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { fragment }); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, CharOperation.NO_CHAR, SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, scope, requestor, WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "java.lang.CharSequence\n" + "java.lang.Class\n" + "java.lang.CloneNotSupportedException\n" + "java.lang.Comparable\n" + "java.lang.Deprecated\n" + "java.lang.Enum\n" + "java.lang.Error\n" + "java.lang.Exception\n" + "java.lang.IllegalMonitorStateException\n" + "java.lang.InterruptedException\n" + "java.lang.Object\n" + "java.lang.RuntimeException\n" + "java.lang.String\n" + "java.lang.Throwable", requestor); } /** * @bug 156177: [1.5][search] interfaces and annotations could be found with only one requets of searchAllTypeName * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156177" */ public void testBug156177() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b156177/Test.java", "package b156177;\n" + "interface B156177_I {}\n" + "enum B156177_E {}\n" + "@interface B156177_A {}\n" + "public class B156177 {}\n" ); TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine(this.workingCopies).searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PATTERN_MATCH, // case insensitive INTERFACE_AND_ANNOTATION, getJavaSearchWorkingCopiesScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null ); assertSearchResults( "Unexpected all type names", "b156177.B156177_A\n" + "b156177.B156177_I", requestor); } /** * @bug 156491: [1.5][search] interfaces and annotations could be found with only one requets of searchAllTypeName * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491" */ public void testBug156491() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " void noMatch(Y y) {\n" + " y.toString();\n" + " toString();\n" + " }\n" + " void validMatches(X x) {\n" + " x.toString();\n" + " }\n" + " void superInvocationMatches(Object o) {\n" + " o.toString();\n" + " }\n" + " void interfaceMatches(I i) {\n" + " i.toString();\n" + " }\n" + " void subtypeMatches(Sub s) {\n" + " s.toString();\n" + " }\n" + "}\n" + "interface I {}\n" + "class X {\n" + " public String toString() {\n" + " return \"X\";\n" + " }\n" + "}\n" + "class Sub extends X {}\n" + "class Y {\n" + " public String toString() {\n" + " return \"Y\";\n" + " }\n" + "}\n" ); IMethod method = this.workingCopies[0].getType("X").getMethod("toString", new String[0]); this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR; search(method, REFERENCES); assertSearchResults( "src/pack/Test.java void pack.Test.validMatches(X) [toString()] EXACT_MATCH\n" + "src/pack/Test.java void pack.Test.superInvocationMatches(Object) [toString()] EXACT_MATCH SUPER INVOCATION\n" + "src/pack/Test.java void pack.Test.subtypeMatches(Sub) [toString()] EXACT_MATCH\n" + "lib/b125178.jar java.lang.String pack.age.Test.foo(int) EXACT_MATCH SUPER INVOCATION" ); } private void setUpBug156491() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/other/Test.java", "package other;\n" + "public class Test {\n" + " void testInterface(I i) {\n" + " i.test();\n" + " }\n" + " void testSuperInvocation(L1 l) {\n" + " l.test();\n" + " }\n" + " void testInvocation(L2 l) {\n" + " l.test();\n" + " }\n" + "}\n" + "class L1 implements I {\n" + " public void test() {}\n" + "}\n" + "interface I {\n" + " void test();\n" + "}\n" + "class L2 extends L1 {\n" + " public void test() {}\n" + "}" ); } public void testBug156491a() throws CoreException { this.resultCollector.showRule(); setUpBug156491(); IMethod method = this.workingCopies[0].getType("L2").getMethod("test", new String[0]); this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR; search(method, REFERENCES); assertSearchResults( "src/other/Test.java void other.Test.testInterface(I) [test()] EXACT_MATCH SUPER INVOCATION\n" + "src/other/Test.java void other.Test.testSuperInvocation(L1) [test()] EXACT_MATCH SUPER INVOCATION\n" + "src/other/Test.java void other.Test.testInvocation(L2) [test()] EXACT_MATCH" ); } public void testBug156491b() throws CoreException { this.resultCollector.showRule(); setUpBug156491(); IMethod method = this.workingCopies[0].getType("L1").getMethod("test", new String[0]); this.resultCollector.showFlavors = PatternLocator.SUPER_INVOCATION_FLAVOR; search(method, REFERENCES); assertSearchResults( "src/other/Test.java void other.Test.testInterface(I) [test()] EXACT_MATCH SUPER INVOCATION\n" + "src/other/Test.java void other.Test.testSuperInvocation(L1) [test()] EXACT_MATCH" // since bug 160301 fix, subclass overridden method calls are not reported //"src/other/Test.java void other.Test.testInvocation(L2) [test()] EXACT_MATCH" ); } /** * @bug 160301: [search] too many matches found for method references * @test Ensure that correct number of method references are found * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160301" */ public void testBug160301() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " class A {\n" + " void foo() {}\n" + " void bar() {\n" + " foo();\n" + " }\n" + " }\n" + " class B extends A {\n" + " void foo() {}\n" + " void bar() {\n" + " foo();\n" + " }\n" + " }\n" + " class C extends B {\n" + " void method() {\n" + " foo();\n" + " }\n" + " }\n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("A").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/Test.java void Test$A.bar() [foo()] EXACT_MATCH" ); } public void testBug160301b() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", "package test;\n" + "public class Test {\n" + " class A {\n" + " void foo() {}\n" + " }\n" + " class B extends A {}\n" + " class C extends B {\n" + " void foo() {}\n" + " }\n" + " class D extends C {}\n" + " void a() {\n" + " new A().foo();\n" + " }\n" + " void b() {\n" + " new B().foo();\n" + " }\n" + " void c() {\n" + " new C().foo();\n" + " }\n" + " void d() {\n" + " new D().foo();\n" + " }\n" + " \n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("A").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/test/Test.java void test.Test.a() [foo()] EXACT_MATCH\n" + "src/test/Test.java void test.Test.b() [foo()] EXACT_MATCH" ); } public void testBug160301_Interface() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " interface I {\n" + " void foo();\n" + " }\n" + " class A1 implements I {\n" + " public void foo() {}\n" + " void a1() {\n" + " foo();\n" + " }\n" + " }\n" + " class B1 extends A1 {\n" + " void b1() {\n" + " foo();\n" + " }\n" + " }\n" + " class C1 extends B1 {\n" + " public void foo() {}\n" + " void c1() {\n" + " foo();\n" + " }\n" + " }\n" + " abstract class A2 implements I {\n" + " void a2() {\n" + " foo();\n" + " }\n" + " }\n" + " class B2 extends A2 {\n" + " public void foo() {}\n" + " void b2() {\n" + " foo();\n" + " }\n" + " }\n" + " class A3 implements I {\n" + " public void foo() {}\n" + " void a3() {\n" + " foo();\n" + " }\n" + " }\n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("I").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/Test.java void Test$A1.a1() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$B1.b1() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$A2.a2() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$B2.b2() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$A3.a3() [foo()] EXACT_MATCH" ); } public void testBug160301_Abstract() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " abstract class Abstract {\n" + " abstract void foo();\n" + " }\n" + " class A1 extends Abstract {\n" + " public void foo() {}\n" + " void a1() {\n" + " foo(); // valid match as A1.foo() is the first override in sub-class\n" + " }\n" + " }\n" + " class B1 extends A1 {\n" + " void b1() {\n" + " foo(); // valid match as B1 does not override A.foo()\n" + " }\n" + " }\n" + " class C1 extends B1 {\n" + " public void foo() {}\n" + " void c1() {\n" + " foo(); // invalid match as C1 does override A.foo()\n" + " }\n" + " }\n" + " abstract class A2 extends Abstract {\n" + " void a2() {\n" + " foo(); // valid match as A2 does not override Abstract.foo()\n" + " }\n" + " }\n" + " class B2 extends A2 {\n" + " public void foo() {}\n" + " void b2() {\n" + " foo(); // valid match as B2.foo() is the first override in sub-class\n" + " }\n" + " }\n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("Abstract").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/Test.java void Test$A1.a1() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$B1.b1() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$A2.a2() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$B2.b2() [foo()] EXACT_MATCH" ); } public void testBug160301_Abstract2() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " abstract class Abstract {\n" + " public abstract void foo();\n" + " }\n" + " abstract class A extends Abstract {\n" + " public abstract void foo();\n" + " void a() {\n" + " foo(); // valid match as A is abstract => does not override Abstract.foo()\n" + " }\n" + " }\n" + " class B extends A {\n" + " public void foo() {}\n" + " void b() {\n" + " foo(); // valid match as B.foo() is the first override in sub-class\n" + " }\n" + " }\n" + " class C extends B {\n" + " public void foo() {}\n" + " void c() {\n" + " foo(); // invalid match as C.foo() overrides Abstract.foo() \n" + " }\n" + " }\n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("Abstract").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/Test.java void Test$A.a() [foo()] EXACT_MATCH\n" + "src/Test.java void Test$B.b() [foo()] EXACT_MATCH" ); } public void testBug160301_Abstract3() throws CoreException { this.resultCollector.showRule(); this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " abstract class Abstract {\n" + " public abstract void foo();\n" + " }\n" + " class A extends Abstract {\n" + " public void foo() {}\n" + " void a() {\n" + " foo(); // valid match as A.foo() is the first override in sub-class\n" + " }\n" + " }\n" + " abstract class B extends A {\n" + " public abstract void foo();\n" + " void b() {\n" + " foo(); // invalid match as B.foo() is hidden by the override A.foo()\n" + " }\n" + " }\n" + " class C extends B {\n" + " public void foo() {}\n" + " void c() {\n" + " foo(); // invalid match as C.foo() overrides A.foo()\n" + " }\n" + " }\n" + "}" ); IMethod method = this.workingCopies[0].getType("Test").getType("Abstract").getMethod("foo", new String[0]); search(method, REFERENCES); assertSearchResults( "src/Test.java void Test$A.a() [foo()] EXACT_MATCH" ); } /** * @bug 160323: [search] TypeNameMatch: support hashCode/equals * @test Ensure that match equals and hashCode methods return same values than those of stored {@link IType}. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160323" */ public void testBug160323() throws CoreException { // Search all type names with TypeNameMatchRequestor TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with TypeNameRequestor TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, null, SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Should have same types with these 2 searches assertTrue("We should get some types!", collector.size() > 0); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 160324: [search] SearchEngine.searchAllTypeNames(char[][], char[][], TypeNameMatchRequestor * @test Ensure that types found using {@link SearchEngine#searchAllTypeNames(char[][], char[][], IJavaSearchScope, TypeNameMatchRequestor, int, org.eclipse.core.runtime.IProgressMonitor) new API method} * are the same than with already existing API method using {@link TypeNameRequestor}... * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160324" */ public void testBug160324a() throws CoreException { boolean debug = false; // Search all type names with new API TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( null, null, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, null, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); if (debug) System.out.println("TypeNameRequestor results: \n"+requestor); // Should have same types with these 2 searches assertTrue("We should get some types!", collector.size() > 0); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } public void testBug160324b() throws CoreException { // Search all type names with new API TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( null, new char[][] { "Test".toCharArray() }, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, new char[][] { "Test".toCharArray() }, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Should have same types with these 2 searches assertTrue("We should get some types!", collector.size() > 0); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 160494: [search] searchAllTypeNames(char[][], char[][],...) fails to find types in default package * @test Ensure that types of default packge are found when empty package is specified in package lists * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160494" */ public void testBug160324c() throws CoreException { boolean debug = false; char[][] packagesList = new char[][] { CharOperation.NO_CHAR, "b110422".toCharArray(), "b123679.test".toCharArray(), "b89848".toCharArray(), "b95794".toCharArray(), "pack".toCharArray(), "pack.age".toCharArray() }; char[][] typesList = new char[][] { "Test".toCharArray(), "TestPrefix".toCharArray() }; // Search all type names with new API TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( packagesList, typesList, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); if (debug) System.out.println("TypeNameMatchRequestor results: \n"+collector); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( packagesList, typesList, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); if (debug) System.out.println("TypeNameRequestor results: \n"+requestor); // Should have same types with these 2 searches assertEquals("Wrong number of found types!", packagesList.length, collector.size()); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 160854: [search] No type is found using seachAllTypeNames(char[][],char[][],...) methods when no type names is specified * @test Ensure that types are found when typeNames parameter is null... * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=160854" */ public void testBug160854() throws CoreException { char[][] packagesList = new char[][] { "java.lang".toCharArray() }; // Search all type names with new API TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( packagesList, null, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( packagesList, null, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Should have same types with these 2 searches assertSearchResults("Wrong types found!", "java.lang.CharSequence\n" + "java.lang.Class\n" + "java.lang.CloneNotSupportedException\n" + "java.lang.Comparable\n" + "java.lang.Deprecated\n" + "java.lang.Enum\n" + "java.lang.Error\n" + "java.lang.Exception\n" + "java.lang.IllegalMonitorStateException\n" + "java.lang.InterruptedException\n" + "java.lang.Object\n" + "java.lang.RuntimeException\n" + "java.lang.String\n" + "java.lang.Throwable", requestor ); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 161028: [search] NPE on organize imports in TypeNameMatch.equals * @test Ensure that no NPE may happen calling <code>equals(Object)</code>, * <code>hashCode()</code> or <code>toString()</code> methods. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=161028" */ public void testBug161028() throws CoreException { TypeNameMatch match1 = SearchEngine.createTypeNameMatch(null, 0); assertEquals("Should be equals!", match1, match1); assertEquals("Wrong toString value!", "org.eclipse.jdt.internal.core.search.JavaSearchTypeNameMatch@0", match1.toString()); TypeNameMatch match2 = SearchEngine.createTypeNameMatch(null, 0); assertFalse("Should NOT be identical!", match1 == match2); assertTrue("Should be equals!", match1.equals(match2)); assertTrue("Should be equals!", match2.equals(match1)); assertEquals("Wrong toString value!", match1, match2); assertEquals("Should have same hashCode!", match1.hashCode(), match2.hashCode()); } /** * @bug 161190: [search] All type search doesn't find all types * @test Ensure that access rules does not change searchAllTypeNames results. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=161190" */ public void testBug161190() throws CoreException { char[][] packagesList = new char[][] { "xy".toCharArray() }; // Search all type names with new API TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( packagesList, null, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( packagesList, null, getJavaSearchScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults("Wrong types found!", "xy.BE_124645\n" + "xy.BX_124645\n" + "xy.BY_124645", requestor ); // Should have same types with these 2 searches assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 163984: [search] no results from SearchEngine.searchAllTypeNames with types in scope * @test Ensure that types are found even when scope is made of elements * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=163984" */ public void testBug163984() throws CoreException { // Search all type names with TypeNameMatchRequestor TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; ICompilationUnit[] elements = getCompilationUnits("JavaSearchBugs", "src", "b163984"); IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, new char[] { '*' }, SearchPattern.R_PATTERN_MATCH, IJavaSearchConstants.TYPE, scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with TypeNameRequestor TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, new char[] { '*' }, SearchPattern.R_PATTERN_MATCH, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Should have same types with these 2 searches assertEquals("We should get 3 types!", 3, collector.size()); assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 164121: [search] Misses declarations of method parameters * @test Ensure that param declaration are correctly found by search engine * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=164121" */ private void setUpBug164121() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/A.java", "class A {\n" + " int x(int param) {\n" + " param = 2 + 2;\n" + " int x = param + 2;\n" + " return param - x;\n" + " }\n" + "}\n" ); } public void testBug164121a() throws CoreException { this.resultCollector.showRule(); setUpBug164121(); ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param"); search(param, DECLARATIONS); assertSearchResults( "src/A.java int A.x(int).param [param] EXACT_MATCH" ); } public void testBug164121b() throws CoreException { this.resultCollector.showRule(); setUpBug164121(); ILocalVariable param = getLocalVariable(this.workingCopies[0], "param", "param"); search(param, ALL_OCCURRENCES); assertSearchResults( "src/A.java int A.x(int).param [param] EXACT_MATCH\n" + "src/A.java int A.x(int) [param] EXACT_MATCH\n" + "src/A.java int A.x(int) [param] EXACT_MATCH\n" + "src/A.java int A.x(int) [param] EXACT_MATCH" ); } /** * @bug 164791: [search] Type reference reports anonymous type in invalid class file * @test Ensure that match on anonymous type in local type is well reported * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791" */ public void testBug164791() throws CoreException { IType type = getClassFile("JavaSearchBugs", "lib/b164791.jar", "pack", "ELPM.class").getType(); JavaSearchResultCollector collector = new JavaSearchResultCollector() { public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { super.acceptSearchMatch(searchMatch); IJavaElement element = (IJavaElement) searchMatch.getElement(); assertTrue("Search match element "+element.getElementName()+" should exist!!!", element.exists()); } }; collector.showAccuracy(true); search(type, REFERENCES, getJavaSearchScope(), collector); assertSearchResults( "lib/b164791.jar test.<anonymous> EXACT_MATCH\n" + "lib/b164791.jar test.<anonymous> EXACT_MATCH", collector ); } /** * @bug 166348: [search] Stack trace console resolves wrong source * @test Ensure that only type with same qualification is found in class files * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=166348" */ public void testBug166348() throws CoreException { search("Test166348", TYPE, DECLARATIONS); assertSearchResults( "lib/b166348.jar pack.Test166348 [No source] EXACT_MATCH\n" + "lib/b166348.jar test.Test166348 [No source] EXACT_MATCH" ); } public void testBug166348_Qualified() throws CoreException { search("test.Test166348", TYPE, DECLARATIONS); assertSearchResults( "lib/b166348.jar test.Test166348 [No source] EXACT_MATCH" ); } /** * @bug 167190: [search] TypeNameMatchRequestorWrapper causing ClassCastException * @test Ensure that types are found even when scope is not a {@link org.eclipse.jdt.internal.core.search.JavaSearchScope} * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=167190" */ public void testBug167190() throws CoreException, JavaModelException { IJavaSearchScope scope = new AbstractSearchScope() { IJavaSearchScope jsScope = getJavaSearchScope(); public void processDelta(IJavaElementDelta delta, int eventType) { // we should have no delta on this test case } public boolean encloses(String resourcePath) { return this.jsScope.encloses(resourcePath); } public boolean encloses(IJavaElement element) { return this.jsScope.encloses(element); } public IPath[] enclosingProjectsAndJars() { return this.jsScope.enclosingProjectsAndJars(); } }; // Search all type names with TypeNameMatchRequestor TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); } }; new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "C".toCharArray(), // need a prefix which returns most of different types (class file, CU, member,...) SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, scope, collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Search all type names with old API TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "C".toCharArray(), // need a prefix which returns most of different types (class file, CU, member,...) SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); // Should have same types with these 2 searches assertEquals("Found types sounds not to be correct", requestor.toString(), collector.toString()); } /** * @bug 178596: [search] Search for method references does not find references to interface method * @test Ensure that searching method reference finds the interface method reference * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=178596" */ public void testBug178596() throws CoreException { this.workingCopies = new ICompilationUnit[5]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/ClassA.java", "public class ClassA implements InterfaceA {\n" + " public void setValue(int aValue) {\n" + " }\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/ClassB.java", "public class ClassB extends ClassA implements InterfaceB {}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/InterfaceA.java", "public interface InterfaceA {\n" + " public void setValue(int aValue);\n" + "}\n" ); this.workingCopies[3] = getWorkingCopy("/JavaSearchBugs/src/InterfaceB.java", "public interface InterfaceB extends InterfaceA {}\n" ); this.workingCopies[4] = getWorkingCopy("/JavaSearchBugs/src/Main.java", "public class Main {\n" + " public static void main(String[] args) {\n" + " new Main().run();\n" + " }\n" + " private void run() {\n" + " InterfaceB anB = new ClassB();\n" + " anB.setValue(123);\n" + " }\n" + "}\n" ); JavaSearchResultCollector testCollector = new JavaSearchResultCollector() { public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { super.acceptSearchMatch(searchMatch); assertTrue("Method reference match should be super invocation one!", ((MethodReferenceMatch)searchMatch).isSuperInvocation()); } }; testCollector.showAccuracy(true); IMethod method = this.workingCopies[0].getType("ClassA").getMethod("setValue", new String[] { "I" }); search(method, REFERENCES, getJavaSearchScope(), testCollector); assertSearchResults( "src/Main.java void Main.run() [setValue(123)] EXACT_MATCH", testCollector ); } /** * @bug 178847 [search] Potential matches found when searching references to IJavaElement#getResource() * @test Ensure that accurate matches are found * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=178847" */ public void testBug178847() throws CoreException { try { createJavaProject("P1", new String[] {"src" }, "bin"); createFolder("/P1/src/p"); createFile( "/P1/src/p/X.java", "package p;\n" + "public class X{\n" + "}" ); createFile( "/P1/src/p/Y.java", "package p;\n" + "public class Y extends X {\n" + " public static void foo() {}\n" + "}" ); getProject("P1").build(IncrementalProjectBuilder.FULL_BUILD, null); deleteFile("/P1/bin/p/X.class"); createJavaProject("P2", new String[] {""}, new String[] {"JCL_LIB", "/P1/bin"}, ""); this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/P2/Test1.java", "public class Test1 {\n" + " void bar() {\n" + " p.Y.foo();\n" + " new p.X();\n" + // cause AbortCompilation here " }\n" + "}" ); this.workingCopies[1] = getWorkingCopy("/P2/Test2.java", "public class Test2 {\n" + " void foo() {}\n" + " void bar() {\n" + " foo();\n" + " }\n" + "}" ); IMethod method = this.workingCopies[1].getType("Test2").getMethod("foo", new String[0]); search(method, REFERENCES, EXACT_RULE, SearchEngine.createWorkspaceScope(), this.resultCollector); assertSearchResults( "Test2.java void Test2.bar() [foo()] EXACT_MATCH" ); } finally { deleteProjects(new String[] {"P1", "P2" }); } } /** * @bug 181488 [index] Lots of unbuffered sequential reads in DiskIndex * @test Ensure that indexing does not happen while reopening workspace (see bug 195091) * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=181488" */ public void testBug181488a() throws CoreException { waitUntilIndexesReady(); IndexManager manager = JavaModelManager.getIndexManager(); Index index = manager.getIndex(JAVA_PROJECT.getPath(), true, false); File indexFile = index.getIndexFile(); simulateExit(); long lastModified = indexFile.lastModified(); simulateRestart(); waitUntilIndexesReady(); Index newIndex = manager.getIndex(JAVA_PROJECT.getPath(), true, false); assertEquals("Index file should be unchanged!!!", lastModified, newIndex.getIndexFile().lastModified()); } public void testBug181488b() throws CoreException { IJavaProject project = createJavaProject("Bug181488"); try { waitUntilIndexesReady(); IndexManager manager = JavaModelManager.getIndexManager(); Index index = manager.getIndex(project.getPath(), true, false); assertEquals("Index file should at least contains the signature!!!", DiskIndex.SIGNATURE.length()+6, index.getIndexFile().length()); } finally { deleteProject(project); } } /** * @bug 185452 [search] for all packages seems hung * @test Ensure that all package declarations are found only once * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=185452" */ public void testBug185452() throws CoreException { JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true); search( "*", PACKAGE, DECLARATIONS, SearchEngine.createWorkspaceScope(), packageCollector); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " \n" + ""+ getExternalJCLPathString("1.5") + " java\n" + ""+ getExternalJCLPathString("1.5") + " java.io\n" + ""+ getExternalJCLPathString("1.5") + " java.lang\n" + ""+ getExternalJCLPathString("1.5") + " java.lang.annotation\n" + ""+ getExternalJCLPathString("1.5") + " java.util\n" + "lib \n" + "lib/JavaSearch15.jar [No source]\n" + "lib/JavaSearch15.jar g1 [No source]\n" + "lib/JavaSearch15.jar g1.t [No source]\n" + "lib/JavaSearch15.jar g1.t.s [No source]\n" + "lib/JavaSearch15.jar g1.t.s.def [No source]\n" + "lib/JavaSearch15.jar g5 [No source]\n" + "lib/JavaSearch15.jar g5.c [No source]\n" + "lib/JavaSearch15.jar g5.c.def [No source]\n" + "lib/JavaSearch15.jar g5.m [No source]\n" + "lib/JavaSearch15.jar g5.m.def [No source]\n" + "lib/b110422.jar [No source]\n" + "lib/b110422.jar b110422 [No source]\n" + "lib/b123679.jar [No source]\n" + "lib/b123679.jar pack [No source]\n" + "lib/b123679.jar test [No source]\n" + "lib/b124469.jar [No source]\n" + "lib/b124469.jar pack [No source]\n" + "lib/b124469.jar test [No source]\n" + "lib/b124645.jar [No source]\n" + "lib/b124645.jar test [No source]\n" + "lib/b124645.jar xy [No source]\n" + "lib/b125178.jar [No source]\n" + "lib/b125178.jar pack [No source]\n" + "lib/b125178.jar pack.age [No source]\n" + "lib/b126330.jar [No source]\n" + "lib/b128877.jar [No source]\n" + "lib/b128877.jar pack [No source]\n" + "lib/b137984.jar [No source]\n" + "lib/b140156.jar [No source]\n" + "lib/b164791.jar [No source]\n" + "lib/b164791.jar pack [No source]\n" + "lib/b164791.jar test [No source]\n" + "lib/b166348.jar [No source]\n" + "lib/b166348.jar pack [No source]\n" + "lib/b166348.jar test [No source]\n" + "lib/b86293.jar [No source]\n" + "lib/b87627.jar [No source]\n" + "lib/b87627.jar b87627 [No source]\n" + "lib/b89848 b89848\n" + "lib/b95152.jar [No source]\n" + "lib/b95152.jar b95152 [No source]\n" + "lib/test75816.jar [No source]\n" + "lib/test81556.jar [No source]\n" + "lib/test81556.jar b81556 [No source]\n" + "lib/test81556.jar b81556.b [No source]\n" + "src \n" + "src/b108088 b108088\n" + "src/b123679 b123679\n" + "src/b123679/pack b123679.pack\n" + "src/b123679/test b123679.test\n" + "src/b124645 b124645\n" + "src/b124645/test b124645.test\n" + "src/b124645/xy b124645.xy\n" + "src/b127628 b127628\n" + "src/b137984 b137984\n" + "src/b142044 b142044\n" + "src/b163984 b163984\n" + "src/b201064 b201064\n" + "src/b81556 b81556\n" + "src/b81556/a b81556.a\n" + "src/b86380 b86380\n" + "src/b95794 b95794", packageCollector); } /** * @bug 194185 [search] for package declarations finds also sub-packages * @test Ensure that exact package is found when no * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=194185" */ public void testBug194185() throws CoreException { JavaSearchResultCollector packageCollector = new JavaSearchResultCollector(true); search( "java", PACKAGE, DECLARATIONS, SearchEngine.createWorkspaceScope(), packageCollector); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " java", packageCollector); } /** * @bug 195489: [search] References not found while using SearchEngine.searchDeclarationsOfReferencedTypes * @test Verify that the type declaration match is always outside the javadoc and that the workaround described in bug 108053 works well * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=108053" * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=195489" */ public void testBug195489a() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", "package b195489;\n" + "/**\n" + " * @see Ref\n" + " */\n" + "public class Test {\n" + " public Ref ref;\n" + " public Ref getRef() {\n" + " return this.ref;\n" + " }\n" + "}\n" + "class Ref {}" ); this.resultCollector.showInsideDoc(); new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); assertSearchResults( "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" ); } public void testBug195489b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", "package b195489;\n" + "public class Test {\n" + " public Ref ref;\n" + " /**\n" + " * @see Ref\n" + " */\n" + " public Ref getRef() {\n" + " return this.ref;\n" + " }\n" + "}\n" + "class Ref {}" ); this.resultCollector.showInsideDoc(); new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); assertSearchResults( "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" ); } public void testBug195489c() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", "package b195489;\n" + "/**\n" + " * @see Ref\n" + " */\n" + "public class Test {\n" + "}\n" + "class Ref {}" ); this.resultCollector.showInsideDoc(); new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); assertSearchResults( "src/b195489/Test.java b195489.Ref [Ref] EXACT_MATCH OUTSIDE_JAVADOC" ); } // test case for bug 108053 workaround public void testBug195489d() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b195489/Test.java", "package b195489;\n" + "/**\n" + " * @see Ref\n" + " */\n" + "public class Test {\n" + "}\n" + "class Ref {}" ); this.resultCollector.showInsideDoc(); String docCommentSupport = JAVA_PROJECT.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true); JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.DISABLED); try { new SearchEngine(this.workingCopies).searchDeclarationsOfReferencedTypes(this.workingCopies[0], this.resultCollector, null); assertSearchResults(""); } finally { JAVA_PROJECT.setOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, docCommentSupport); } } /** * @bug 196339: [search] SearchEngine not returning correct result * @test 1) That potential match are now well found while searching for implementors * 2) That there's a workaround for this problem * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=196339" * @throws CoreException */ public void testBug196339() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b196339/x/y/z/Test.java", "package b196339.xy.y.z;\n" + "import a.b.c.Foo196339;\n" + "public class Test implements Foo196339 {\n" + "}\n" ); search("a.b.c.Foo196339", IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS); assertSearchResults( "src/b196339/x/y/z/Test.java b196339.x.y.z.Test [Foo196339] POTENTIAL_MATCH" ); } // Possible workaround until this bug is fixed // Following test passed before the fix for bug 196339 was applied public void testBug196339b() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b196339/x/y/z/Test1.java", "package b196339.xy.y.z;\n" + "import a.b.c.Foo196339;\n" + "public class Test1 implements Foo196339 {\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/b196339/x/y/z/Test2.java", "package b196339.xy.y.z;\n" + "import a.b.c.*;\n" + "public class Test2 implements Foo196339 {\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/b196339/x/y/z/Test3.java", "package b196339.xy.y.z;\n" + "public class Test3 implements a.b.c.Foo196339 {\n" + "}\n" ); final String qualifiedType = "a.b.c.Foo196339"; JavaSearchResultCollector collector = new JavaSearchResultCollector() { public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { Object element = searchMatch.getElement(); if (element instanceof IType) { IType type = (IType) element; // Look if super interface names matches the qualified type String[] superInterfaces = type.getSuperInterfaceNames(); int length = superInterfaces == null ? 0 : superInterfaces.length; for (int i=0; i<length; i++) { if (superInterfaces[i].equals(qualifiedType)) { super.acceptSearchMatch(searchMatch); return; } } // Look if an import declaration matches the qualified type IImportDeclaration[] imports = ((ICompilationUnit) type.getAncestor(IJavaElement.COMPILATION_UNIT)).getImports(); length = imports == null ? 0 : imports.length; for (int i=0; i<length; i++) { String importName = imports[i].getElementName(); if (importName.equals(qualifiedType)) { super.acceptSearchMatch(searchMatch); return; } if (imports[i].isOnDemand()) { int idx = importName.lastIndexOf('.'); if (idx > 0 && importName.substring(0, idx).equals(qualifiedType.substring(0, idx))) { super.acceptSearchMatch(searchMatch); return; } } } } } }; search("Foo196339", IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS, getJavaSearchScope(), collector); assertSearchResults( "src/b196339/x/y/z/Test1.java b196339.x.y.z.Test1 [Foo196339]\n" + "src/b196339/x/y/z/Test2.java b196339.x.y.z.Test2 [Foo196339]\n" + "src/b196339/x/y/z/Test3.java b196339.x.y.z.Test3 [a.b.c.Foo196339]", collector ); } /** * @bug 199004: [search] Java Search in 'JRE libraries' finds matches in Application Libraries * @test 1) That only match in system libraries are returned when SYSTEM_LIBRARIES is used in scope * 2) That only match outside system libraries are returned when SYSTEM_LIBRARIES is NOT used in scope * 3) That match in system libraries are returned when no mask is used in scope * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=199004" * @throws CoreException */ public void testBug199004_SystemLibraries() throws CoreException { DefaultContainerInitializer intializer = new DefaultContainerInitializer(new String[] {"JavaSearchBugs", "/JavaSearchBugs/lib/b199004.jar"}) { protected DefaultContainer newContainer(char[][] libPaths) { return new DefaultContainer(libPaths) { public int getKind() { return IClasspathContainer.K_SYSTEM; } }; } }; ContainerInitializer.setInitializer(intializer); Path libPath = new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"); addClasspathEntry(JAVA_PROJECT, JavaCore.newContainerEntry(libPath)); try { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JAVA_PROJECT }, IJavaSearchScope.SYSTEM_LIBRARIES); search("length", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope); assertSearchResults( "lib/b199004.jar int Test.length() EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, libPath); } } public void testBug199004_DefaultSystemLibraries() throws CoreException { DefaultContainerInitializer intializer = new DefaultContainerInitializer(new String[] {"JavaSearchBugs", "/JavaSearchBugs/lib/b199004.jar"}) { protected DefaultContainer newContainer(char[][] libPaths) { return new DefaultContainer(libPaths) { public int getKind() { return IClasspathContainer.K_DEFAULT_SYSTEM; } }; } }; ContainerInitializer.setInitializer(intializer); Path libPath = new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"); addClasspathEntry(JAVA_PROJECT, JavaCore.newContainerEntry(libPath)); try { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JAVA_PROJECT }, IJavaSearchScope.SYSTEM_LIBRARIES); search("length", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope); assertSearchResults( "lib/b199004.jar int Test.length() EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, libPath); } } public void testBug199004_ApplicationLibraries() throws CoreException { DefaultContainerInitializer intializer = new DefaultContainerInitializer(new String[] {"JavaSearchBugs", "/JavaSearchBugs/lib/b199004.jar"}) { protected DefaultContainer newContainer(char[][] libPaths) { return new DefaultContainer(libPaths) { public int getKind() { return IClasspathContainer.K_SYSTEM; } }; } }; ContainerInitializer.setInitializer(intializer); Path libPath = new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"); addClasspathEntry(JAVA_PROJECT, JavaCore.newContainerEntry(libPath)); try { int mask = IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS; IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { JAVA_PROJECT }, mask); search("length", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS, scope); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " int java.lang.CharSequence.length() EXACT_MATCH\n" + ""+ getExternalJCLPathString("1.5") + " int java.lang.String.length() EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, libPath); } } public void testBug199004_NoMask() throws CoreException { DefaultContainerInitializer intializer = new DefaultContainerInitializer(new String[] {"JavaSearchBugs", "/JavaSearchBugs/lib/b199004.jar"}) { protected DefaultContainer newContainer(char[][] libPaths) { return new DefaultContainer(libPaths) { public int getKind() { return IClasspathContainer.K_SYSTEM; } }; } }; ContainerInitializer.setInitializer(intializer); Path libPath = new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"); addClasspathEntry(JAVA_PROJECT, JavaCore.newContainerEntry(libPath)); try { search("length", IJavaSearchConstants.METHOD, IJavaSearchConstants.DECLARATIONS); assertSearchResults( ""+ getExternalJCLPathString("1.5") + " int java.lang.CharSequence.length() EXACT_MATCH\n" + ""+ getExternalJCLPathString("1.5") + " int java.lang.String.length() EXACT_MATCH\n" + "lib/b199004.jar int Test.length() EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, libPath); } } /** * @bug 200064: [search] ResourceException while searching for method reference * @test Ensure that indexing still works properly after close/restart * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=200064" */ public void testBug200064() throws CoreException { waitUntilIndexesReady(); simulateExitRestart(); waitUntilIndexesReady(); // Search all type names with TypeNameMatchRequestor TypeNameMatchCollector collector = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( null, SearchPattern.R_EXACT_MATCH, "Object".toCharArray(), SearchPattern.R_PREFIX_MATCH, IJavaSearchConstants.TYPE, getJavaSearchScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults( "Object (not open) [in Object.class [in java.lang [in "+ getExternalJCLPathString("1.5") + "]]]", collector ); } /** * @bug 201064: [search] SearchEngine.searchAllTypeNames(..) does not find CamelCase match * @test Ensure that indexing still works properly after close/restart * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=201064" */ public void testBug201064a_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CCase", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064b_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaCase", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064c_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelCase", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064d_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CC", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064e_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaC", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064f_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelC", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064g_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CCa", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064h_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaCa", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064i_CamelCase() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelCa", SearchPattern.R_CAMELCASE_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCaseEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CamelCasexxEntry (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } // Same tests using SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH public void testBug201064a_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CCase", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064b_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaCase", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064c_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelCase", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064d_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CC", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064e_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaC", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064f_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelC", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064g_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CCa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CxxxxCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064h_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CaCa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]\n" + "CatCasexx (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } public void testBug201064i_CamelCaseSamePartCount() throws CoreException { TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("CamelCa", SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH, collector); assertSearchResults( "CamelCase (not open) [in CamelCase.java [in b201064 [in src [in JavaSearchBugs]]]]", collector ); } /** * @bug 204652 "Open Type": ClassCastException in conjunction with a class folder * @test Ensure that no ClassCastException is thrown for a library folder with a jar like name * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652" */ public void testBug204652() throws CoreException { IJavaProject javaProject = getJavaProject("JavaSearchBugs"); IClasspathEntry[] originalRawClasspath = javaProject.getRawClasspath(); try { addLibraryEntry(javaProject, new Path("/JavaSearchBugs/b204652.jar"), false/*not exported*/); TypeNameMatchCollector collector = new TypeNameMatchCollector(); searchAllTypeNames("b204652", null, SearchPattern.R_PREFIX_MATCH, collector); IPackageFragment pkg = getPackage("/JavaSearchBugs/b204652.jar/b204652"); pkg.open(null); IType result = (IType) collector.matches.get(0); assertTrue("Resulting type should exist", result.exists()); } finally { javaProject.setRawClasspath(originalRawClasspath, null); } } /** * @bug 207657: [search] Exception when refactoring member type to top-level. * @test Ensure that searching method reference does not find wrong interface call * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=207657" */ public void testBug207657() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Relationship.java", "package test;\n" + "public class Relationship {\n" + " static public class End extends ConnectionEnd<Visitor> {\n" + " public void accept(Visitor visitor) {\n" + " visitor.visitRelationshipEnd(this);\n" + " }\n" + " }\n" + "}\n" + "interface Visitor {\n" + " boolean visitRelationshipEnd(Relationship.End end);\n" + " boolean visitAssociationEnd(Association.End end);\n" + "}\n" + "abstract class ConnectionEnd<V extends Visitor> {\n" + " public abstract void accept( V visitor );\n" + "}\n" + "class Association extends Relationship {\n" + " static public class RelEnd extends Relationship.End {\n" + " public void accept(Visitor visitor) {\n" + " visitor.visitAssociationEnd(this);\n" + " }\n" + " }\n" + "}\n" ); IType type = this.workingCopies[0].getType("Relationship").getType("End"); searchDeclarationsOfSentMessages(type, this.resultCollector); assertSearchResults( "src/test/Relationship.java boolean test.Visitor.visitRelationshipEnd(Relationship.End) [visitRelationshipEnd(Relationship.End end)] EXACT_MATCH" ); } /** * @bug 209054: [search] for references to method finds wrong interface call * @test Ensure that searching method reference does not find wrong interface call * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209054" */ public void testBug209054() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/xy/Try.java", "package xy;\n" + "public class Try implements IReferenceUpdating {\n" + " IMovePolicy fInter;\n" + " boolean canDo() { // find references\n" + " return fInter.canDo(); // not a reference\n" + " }\n" + "}\n" + "interface IMovePolicy extends IReferenceUpdating {\n" + " boolean canDo();\n" + "}\n" + "interface IReferenceUpdating {}" ); IMethod method = this.workingCopies[0].getType("Try").getMethod("canDo", new String[0]); search(method, REFERENCES); assertSearchResults(""); } /** * @bug 209778: [search] TypeReferenceMatch#getOtherElements() fails for match in annotation * @test Ensure that the local element is no longer a local variable * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209778" */ public void testBug209778() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/xy/Try.java", "package xy;\n" + "\n" + "public class Try {\n" + " void tryB(int tryKind) {\n" + " @Constants(Try.class) int tryCopy, tryCopy2= tryKind;\n" + " }\n" + " @Constants(value= Try.class) Object fTryA, fTryB;\n" + "}\n" + "\n" + "@interface Constants {\n" + " Class<?> value();\n" + "}" ); IType type = this.workingCopies[0].getType("Try"); TypeReferenceCollector collector = new TypeReferenceCollector(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/xy/Try.java @Constants(value=Try.class) [Try]\n" + "src/xy/Try.java @Constants(value=Try.class) [Try]", collector ); } /** * @bug 209996: [search] Add a way to access the most local enclosing annotation for reference search matches * @test Verify the behavior of the new Search API {@link ReferenceMatch#getLocalElement()} * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=209996" */ public void testBug209996a() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", "package test;\n" + "public class Test {\n" + " void method() {\n" + " @Annot(clazz=Test.class) int x;\n" + " }\n" + "}\n" + "@interface Annot {\n" + " Class clazz();\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); ReferenceCollector collector = new ReferenceCollector(); collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/test/Test.java @Annot(clazz=Test.class) [ @Annot(clazz=�|Test|�.class) int x;]", collector ); } public void testBug209996b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", "package test;\n" + "public class Test {\n" + " @Deprecated foo() {}\n" + "}\n" ); ReferenceCollector collector = new ReferenceCollector(); collector.showSelection(); search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/test/Test.java @Deprecated() [ @�|Deprecated|� foo() {}]", collector ); } public void testBug209996_c5() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment5/Ref.java", "package comment5;\n" + "public class Ref {\n" + " void doA(Ref ref) {}\n" + " void doB(List<Ref> ref) {}\n" + " void doC(@Tag(Ref.class) Ref ref) {}\n" + " void dontD(@Tag(Ref.class) Object ref) {}\n" + "}\n" + "\n" + "@interface Tag {\n" + " Class value();\n" + "}\n" + "class List<T> {\n" + "}\n" ); IType type = this.workingCopies[0].getType("Ref"); ReferenceCollector collector = new ReferenceCollector(); collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/comment5/Ref.java void comment5.Ref.doA(Ref).ref [ void doA(�|Ref|� ref) {}]\n" + "src/comment5/Ref.java void comment5.Ref.doB(List<Ref>).ref [ void doB(List<�|Ref|�> ref) {}]\n" + "src/comment5/Ref.java @Tag(value=Ref.class) [ void doC(@Tag(�|Ref|�.class) Ref ref) {}]\n" + "src/comment5/Ref.java void comment5.Ref.doC(Ref).ref [ void doC(@Tag(Ref.class) �|Ref|� ref) {}]\n" + "src/comment5/Ref.java @Tag(value=Ref.class) [ void dontD(@Tag(�|Ref|�.class) Object ref) {}]", collector ); } public void testBug209996_c10() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment10/Ref.java", "package comment10;\n" + "@Num(number= Num.CONST)\n" + "@interface Num {\n" + " public static final int CONST= 42;\n" + " int number();\n" + "}\n" ); IField field = this.workingCopies[0].getType("Num").getField("CONST"); ReferenceCollector collector = new ReferenceCollector(); collector.showSelection(); search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/comment10/Ref.java @Num(number=Num.CONST) [@Num(number= Num.�|CONST|�)]", collector ); } public void testBug209996_c22_3() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/comment22/Test.java", "package comment22;\n" + "public class Test {\n" + " @Tag Test test1, test2, test3;\n" + " void method() {\n" + " @Tag Test local= null;\n" + " @Tag Test local1, local2, local3;\n" + " }\n" + "}\n" + "@interface Tag {}\n" ); IType type = this.workingCopies[0].getType("Tag"); TypeReferenceCollector collector = new TypeReferenceCollector(); collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/comment22/Test.java @Tag() [ @�|Tag|� Test test1, test2, test3;]\n" + "src/comment22/Test.java @Tag() [ @�|Tag|� Test local= null;]\n" + "src/comment22/Test.java @Tag() [ @�|Tag|� Test local1, local2, local3;]", collector ); } public void testBug209996_c22_4() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/test/Test.java", "package test;\n" + "public class TestMethodReference {\n" + " @Annot(clazz = test.Test.class) int x, y;\n" + "}\n" + "@interface Annot {\n" + " Class clazz();\n" + "}\n" ); IType type = this.workingCopies[0].getType("Test"); TypeReferenceCollector collector = new TypeReferenceCollector(); collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( "src/test/Test.java @Annot(clazz=test.Test.class) [ @Annot(clazz = �|test.Test|�.class) int x, y;]", collector ); } /** * @bug 210689: [search] Type references are not found in import declarations when JUnit tests only use working copies * @test Ensure that import references are found when searching on working copies not written on disk * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210689" */ public void testBug210689() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test210689.java", "package pack;\n" + "public class Test210689 {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test210689;\n" + "public class X extends Test210689 {}\n" ); search(this.workingCopies[0].getType("Test210689"), REFERENCES); assertSearchResults( "src/test/X.java [pack.Test210689] EXACT_MATCH\n" + "src/test/X.java test.X [Test210689] EXACT_MATCH" ); } /** * @bug 210567: [1.5][search] Parameterized type reference not found when used in type parameter bounds * @test Ensure that all type references are found when used in type variables * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210567" */ public void testBug210567() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/generics/Generic.java", "package generics;\n" + "import java.io.Serializable;\n" + "import type.def.Types;\n" + "public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends A<? super Types>> {\n" + " Generic<? extends Types, ?, ?> field;\n" + " Comparable<String> comp;\n" + " Class<? extends Exception> clazz;\n" + "}\n" + "\n" + "class A<R> {}" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/type/def/Types.java", "package type.def;\n" + "public class Types {\n" + "}\n" ); this.resultCollector.showSelection(); search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/generics/Generic.java [import �|java.io.Serializable|�;] EXACT_MATCH\n" + "src/generics/Generic.java [import �|type.def.Types|�;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends �|Types|�, U extends Types & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends �|Types|� & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & �|Comparable|�<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<�|Types|�> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & �|Serializable|�, V extends A<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends �|A|�<? super Types>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends A<? super �|Types|�>> {] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.field [ �|Generic|�<? extends Types, ?, ?> field;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.field [ Generic<? extends �|Types|�, ?, ?> field;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.comp [ �|Comparable|�<String> comp;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.comp [ Comparable<�|String|�> comp;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.clazz [ �|Class|�<? extends Exception> clazz;] EXACT_MATCH\n" + "src/generics/Generic.java generics.Generic.clazz [ Class<? extends �|Exception|�> clazz;] EXACT_MATCH" ); } /** * @bug 210691: [search] Type references position invalid in import references when using "*" pattern * @test Ensure that all qualified type reference in import references is selected when using "*" pattern * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=210691" */ public void testBug210691() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/Ref.java", "package test;\n" + "import pack.Test;\n" + "public class Ref {\n" + " Test test;\n" + "}\n" ); this.resultCollector.showSelection(); search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/Ref.java [import �|pack.Test|�;] EXACT_MATCH\n" + "src/test/Ref.java test.Ref.test [ �|Test|� test;] EXACT_MATCH" ); } /** * @bug 211366: [search] does not return references to types in binary classes * @test Ensure that annotations references are found in a class file without source * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=211366" */ public void testBug211366() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType(); this.resultCollector.showMatchKind(); search(type, REFERENCES); assertSearchResults( "TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211366.jar")); } } public void testBug211366_OrPattern() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType(); SearchPattern rightPattern = SearchPattern.createPattern(type, REFERENCES); SearchPattern leftPattern = SearchPattern.createPattern(type, DECLARATIONS); SearchPattern pattern = SearchPattern.createOrPattern(leftPattern, rightPattern); this.resultCollector.showMatchKind(); new SearchEngine(this.workingCopies).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchScope(), this.resultCollector, null ); assertSearchResults( "TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + "TypeDeclarationMatch: lib/b211366.jar test.Bug [No source] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211366.jar")); } } public void testBug211366_ComplexOrPattern() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211366.jar", false); try { IType bType = getClassFile("JavaSearchBugs", "lib/b211366.jar", "test", "Bug.class").getType(); SearchPattern leftPattern = SearchPattern.createOrPattern( SearchPattern.createPattern("field", FIELD, DECLARATIONS, SearchPattern.R_CASE_SENSITIVE), SearchPattern.createPattern(bType, REFERENCES)); SearchPattern rightPattern = SearchPattern.createOrPattern( SearchPattern.createPattern("Member", TYPE, DECLARATIONS, SearchPattern.R_EXACT_MATCH), SearchPattern.createOrPattern( SearchPattern.createPattern("method", METHOD, DECLARATIONS, SearchPattern.R_EXACT_MATCH), SearchPattern.createPattern("Bug", TYPE, REFERENCES, SearchPattern.R_EXACT_MATCH))); IPackageFragmentRoot root = JAVA_PROJECT.getPackageFragmentRoot("/JavaSearchBugs/lib/b211366.jar"); this.resultCollector.sorted = true; this.resultCollector.showMatchKind(); new SearchEngine(this.workingCopies).search( SearchPattern.createOrPattern(leftPattern, rightPattern), new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, SearchEngine.createJavaSearchScope(new IJavaElement[] { root }), this.resultCollector, null ); assertSearchResults( "FieldDeclarationMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + "MethodDeclarationMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "TypeDeclarationMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.Test [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestInner$Member [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar pack.TestMembers.field [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "TypeReferenceMatch: lib/b211366.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211366.jar")); } } /** * @bug 211857: [search] Standard annotations references not found on binary fields and methods when no source is attached * @test Ensure that annotations references on fields and methods are found in a class file without source * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=211857" */ public void testBug211857() throws CoreException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211857.jar", false); try { IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Deprecated.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b211857.jar pack.Test [No source] EXACT_MATCH\n" + "lib/b211857.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "lib/b211857.jar pack.TestMembers.field [No source] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211857.jar")); } } /** * @bug 211872: [search] References to annotations not found in class file without source * @test Ensure that annotations references are found in the specific class file without source * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=211872" */ public void testBug211872_ns() throws CoreException, IOException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211872_ns.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b211872_ns.jar", "test", "Bug.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b211872_ns.jar pack.Test [No source] EXACT_MATCH\n" + "lib/b211872_ns.jar pack.TestMembers$Member [No source] EXACT_MATCH\n" + "lib/b211872_ns.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) [No source] EXACT_MATCH\n" + "lib/b211872_ns.jar pack.TestMembers.field [No source] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211872_ns.jar")); } } public void testBug211872_ws() throws CoreException, IOException { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b211872_ws.jar", false); try { IType type = getClassFile("JavaSearchBugs", "lib/b211872_ws.jar", "test", "Bug.class").getType(); search(type, REFERENCES); assertSearchResults( "lib/b211872_ws.jar pack.Test EXACT_MATCH\n" + "lib/b211872_ws.jar pack.Test EXACT_MATCH\n" + "lib/b211872_ws.jar pack.TestMembers.field EXACT_MATCH\n" + "lib/b211872_ws.jar void pack.TestMembers.method(java.lang.Object, java.lang.String) EXACT_MATCH\n" + "lib/b211872_ws.jar pack.TestMembers$Member EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b211872_ws.jar")); } } /** * @bug 181981: [model] Linked Source Folders with Parallel package structure do not work with occurrences * @test Ensure that source folder nesting doesn't cause non existing elements to be returned * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=181981" */ public void testBug181981() throws CoreException { try { IJavaProject project = createJavaProject("P", new String[] { "", "src"}, new String[] {"JCL_LIB"}, null, null, "bin", null, null, new String[][] {new String[] {"src/"}, new String[0]}, "1.4"); createFolder("/P/p1"); createFile( "/P/p1/X.java", "package p1;\n" + "public class X {\n" + " public void foo() {}\n" + "}" ); createFile( "/P/p1/Y.java", "package p1;\n" + "public class Y {\n" + " public void bar(X x) {\n" + " x.foo();\n" + " }\n" + "}" ); createFolder("/P/src/p2"); createFile( "/P/src/p2/Z.java", "package p2;\n" + "public class Z {\n" + " public void bar(p1.X x) {\n" + " x.foo();\n" + " }\n" + "}" ); IMethod method = getCompilationUnit("/P/p1/X.java").getType("X").getMethod("foo", new String[0]); search(method, REFERENCES, EXACT_RULE, SearchEngine.createJavaSearchScope(new IJavaProject[] {project}), this.resultCollector); assertSearchResults( "p1/Y.java void p1.Y.bar(X) [foo()] EXACT_MATCH\n" + "src/p2/Z.java void p2.Z.bar(p1.X) [foo()] EXACT_MATCH" ); } finally { deleteProject("P"); } } /** * @bug 216875: [search] Field- and LocalVariableReferenceMatch confuse read/write for field access on LHS * @test Ensure that read access is found inside qualified name reference * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=216875" */ public void testBug216875() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " int fField;\n" + " void m() {\n" + " Test test; // refs to test\n" + " test = new Test();\n" + " test.fField = 42; // match for t is writeAccess, should be readAccess\n" + " }\n" + "\n" + "}\n" ); this.resultCollector.showSelection(); ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test"); search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/Test.java void Test.m() [ �|test|�.fField = 42; // match for t is writeAccess, should be readAccess] EXACT_MATCH" ); } public void testBug216875b() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " S fWrapped; // refs to fWrapped\n" + " void wrapper() {\n" + " fWrapped.fField = 12; // match for fWrapped is writeAccess\n" + " }\n" + "}\n" + "class S {\n" + " int fField;" + "}" ); this.resultCollector.showSelection(); IField field = this.workingCopies[0].getType("Test").getField("fWrapped"); search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/Test.java void Test.wrapper() [ �|fWrapped|�.fField = 12; // match for fWrapped is writeAccess] EXACT_MATCH" ); } public void testBug216875c() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " void foo(Test t1, Test t2) {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] EXACT_MATCH" ); } public void testBug216875d() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " Test t1, t2;\n" + " void foo() {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] EXACT_MATCH" ); } public void testBug216875e() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " void foo(Test t1, Test t2) {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] EXACT_MATCH" ); } public void testBug216875f() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " Test t1, t2;\n" + " void foo() {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo() [ �|t1|� = t2;] EXACT_MATCH" ); } public void testBug216875g() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " void foo(Test t1, Test t2) {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); this.resultCollector.showAccess(); this.resultCollector.showAccuracy(false); ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] WRITE ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] READ ACCESS" ); } public void testBug216875h() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " Test t1, t2;\n" + " void foo() {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); this.resultCollector.showAccess(); this.resultCollector.showAccuracy(false); IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/test/X.java void test.X.foo() [ �|t1|� = t2;] WRITE ACCESS\n" + "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] READ ACCESS\n" + "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] READ ACCESS\n" + "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] READ ACCESS" ); } /** * @bug 218397: [search] Can't find references of generic local class. * @test Ensure that the generic local class reference is well found (no CCE) * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=218397" */ public void testBug218397() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Bug.java", "class Bug{\n" + " {\n" + " class Inner<Type extends Number> {\n" + " Row field;//LINE 3\n" + " class Row{}\n" + " }\n" + " }\n" + "}" ); this.resultCollector.showSelection(); IType type = selectType(this.workingCopies[0], "Row"); search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/Bug.java Bug.{}:Inner#1.field [ �|Row|� field;//LINE 3] EXACT_MATCH" ); } /** * @bug 221081: [search] Java Search should default to widest scope * @test Ensure that user can search to type/method/field references/declarations in only * one call to SearchEngine * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=221081" */ public void testBug221081() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " Test test;\n" + " void test(Test test) {\n" + " if (test == this.test) {\n" + " //\n" + " }\n" + " }\n" + "}\n" ); this.resultCollector.showSelection(); this.resultCollector.showRule(); SearchPattern typePattern = SearchPattern.createPattern("test", TYPE, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); SearchPattern methPattern = SearchPattern.createPattern("test", METHOD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); SearchPattern fieldPattern = SearchPattern.createPattern("test", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); SearchPattern pattern = SearchPattern.createOrPattern(typePattern, methPattern); pattern = SearchPattern.createOrPattern(pattern, fieldPattern); new SearchEngine(this.workingCopies).search( pattern, new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchWorkingCopiesScope(), this.resultCollector, null); assertSearchResults( "src/Test.java Test [public class �|Test|� {] EXACT_MATCH\n" + "src/Test.java Test.test [ Test �|test|�;] EXACT_MATCH\n" + "src/Test.java Test.test [ �|Test|� test;] EXACT_MATCH\n" + "src/Test.java void Test.test(Test) [ void �|test|�(Test test) {] EXACT_MATCH\n" + "src/Test.java void Test.test(Test) [ void test(�|Test|� test) {] EXACT_MATCH\n" + "src/Test.java void Test.test(Test) [ if (test == this.�|test|�) {] EXACT_MATCH" ); } /** * @bug 221110: [search] NPE at org.eclipse.jdt.internal.compiler.util.SimpleLookupTable.removeKey * @test Ensure that no NPE occurs while searching for reference to generic class * when referenced in a unbound wildcard parameterized type * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=221110" */ public void testBug221110() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/X.java", "public class X<T> {\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/Y.java", "public class Y<T extends X<?>> {\n" + "}\n" ); this.resultCollector.showSelection(); this.resultCollector.showRule(); IType type = this.workingCopies[0].getType("X"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/Y.java Y [public class Y<T extends �|X|�<?>> {] ERASURE_MATCH" ); } public void testBug221110b() throws CoreException { this.workingCopies = new ICompilationUnit[3]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/I.java", "public interface I<T> {\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/X.java", "public class X<T> {\n" + "}\n" ); this.workingCopies[2] = getWorkingCopy("/JavaSearchBugs/src/Z.java", "public class Z<T extends X<?> & I<?>> {\n" + "}\n" ); this.resultCollector.showSelection(); this.resultCollector.showRule(); IType type = this.workingCopies[0].getType("I"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( "src/Z.java Z [public class Z<T extends X<?> & �|I|�<?>> {] ERASURE_MATCH" ); } /** * @bug 222284: [search] ZipException while searching if linked jar doesn't exist any longer * @test Ensure that no exception is raised while searching for a type of the missing jar file * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=222284" */ public void testBug222284() throws Exception { String jarName = "lib222284.jar"; String jarPath = getExternalPath()+jarName; IFile jarFile = JAVA_PROJECT.getProject().getFile(jarName); try { // Create jar and add it to JavaSearchBugs project build path String[] pathsAndContents = new String[] { "pack/Ref.java", "package pack;\n" + "public class Ref {\n" + "}", }; createJar(pathsAndContents, jarPath); jarFile.createLink(new Path(jarPath), IResource.NONE, null); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib222284.jar", null); // Create file and wait for indexes createFile("/JavaSearchBugs/src/Test.java", "import pack.Ref;" + "public class Test {\n" + " Ref ref;" + "}\n" ); waitUntilIndexesReady(); // Exit, delete jar and restart simulateExit(); deleteExternalResource(jarName); simulateRestart(); // Search for references to a class of deleted jar file, expect no result search("pack.Ref", TYPE, REFERENCES); assertSearchResults( "src/Test.java [Ref] POTENTIAL_MATCH\n" + "src/Test.java Test.ref [Ref] POTENTIAL_MATCH" ); } finally { deleteResource(jarFile); removeClasspathEntry(JAVA_PROJECT, new Path(jarPath)); } } /** * @bug 228464: Annotation.getMemberValuePairs() empty for single attribute with empty value * @test Ensure that annotation are correctly recovered * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=228464" */ public void testBug228464() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " void m() {\n" + " @TestAnnotation(name=) Test iii;\n" + " }\n" + "\n" + "}\n" ); this.resultCollector.showSelection(); IType type = this.workingCopies[0].getType("Test"); search(type, REFERENCES, getJavaSearchWorkingCopiesScope()); IAnnotation[] annotations = new IAnnotation[0]; if (this.resultCollector.match != null && this.resultCollector.match instanceof ReferenceMatch) { IJavaElement element = ((ReferenceMatch)this.resultCollector.match).getLocalElement(); if (element instanceof ILocalVariable) { annotations = ((ILocalVariable)element).getAnnotations(); } } assertAnnotationsEqual( "@TestAnnotation(name=<null>)\n", annotations); } /** * @bug 228852: classes opened via Open Type not found * @test Ensure that types found in an internal jar exist when using a workspace scope * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=228852" */ public void testBug228852a() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib228852.jar"}, ""); createJar(new String[] { "p228852/X228852.java", "package p228852;\n" + "public class X228852 {\n" + "}" }, p.getProject().getLocation().append("lib228852.jar").toOSString()); refresh(p); char[][] packagesList = new char[][] { "p228852".toCharArray() }; TypeNameMatchCollector collector = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( packagesList, null, SearchEngine.createWorkspaceScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertTrue("p228852.X228852 should exist", ((IJavaElement) collector.matches.get(0)).exists()); } finally { deleteProject("P"); } } /** * @bug 228852: classes opened via Open Type not found * @test Ensure that types found in an internal jar exist when using a Java search scope * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=228852" */ public void testBug228852b() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"/P/lib228852.jar"}, ""); createJar(new String[] { "p228852/X228852.java", "package p228852;\n" + "public class X228852 {\n" + "}" }, p.getProject().getLocation().append("lib228852.jar").toOSString()); refresh(p); char[][] packagesList = new char[][] { "p228852".toCharArray() }; TypeNameMatchCollector collector = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( packagesList, null, SearchEngine.createJavaSearchScope(new IJavaElement[] {p}), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertTrue("p228852.X228852 should exist", ((IJavaElement) collector.matches.get(0)).exists()); } finally { deleteProject("P"); } } /** * @bug 231622: Some classes from Missing classes from Cntrl-Shift-T * @test Ensure that types added through a container are found using a workspace scope * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=231622" */ public void testBug231622() throws Exception { try { IJavaProject p = createJavaProject("P", new String[] {}, new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, ""); createJar(new String[] { "p231622/X231622.java", "package p231622;\n" + "public class X231622 {\n" + "}" }, p.getProject().getLocation().append("lib231622.jar").toOSString()); refresh(p); DefaultContainerInitializer initializer = new DefaultContainerInitializer(new String[] {"P", "/P/lib231622.jar"}); ContainerInitializer.setInitializer(initializer); initializer.initialize(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"), p); char[][] packagesList = new char[][] { "p231622".toCharArray() }; TypeNameMatchCollector collector = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( packagesList, null, SearchEngine.createWorkspaceScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults( "X231622 (not open) [in X231622.class [in p231622 [in lib231622.jar [in P]]]]", collector); } finally { deleteProject("P"); } } /** * @bug 250083: Search indexes are not correctly updated * @test Ensure that a library that is no longer referenced, modified, and referenced again is re-indexed * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083" */ public void testBug250083() throws Exception { String libPath = getExternalResourcePath("lib250083.jar"); try { Util.createJar( new String[] { "p250083/Y250083.java", "package p250083;\n" + "public class Y250083 {}" }, new HashMap(), libPath); createJavaProject("P", new String[0], new String[] {libPath}, ""); waitUntilIndexesReady(); deleteExternalFile(libPath); deleteProject("P"); Util.createJar( new String[] { "p250083/X250083.java", "package p250083;\n" + "public class X250083 {}" }, new HashMap(), libPath); createJavaProject("P", new String[0], new String[] {libPath}, ""); TypeNameMatchCollector collector = new TypeNameMatchCollector(); new SearchEngine().searchAllTypeNames( null, new char[][] {"X250083".toCharArray()}, SearchEngine.createWorkspaceScope(), collector, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); assertSearchResults( "X250083 (not open) [in X250083.class [in p250083 [in "+ getExternalPath() + "lib250083.jar]]]", collector); } finally { deleteExternalFile(libPath); deleteProject("P"); } } /** * @bug 261722: [search] NPE after removing a project * @test Ensure that no NPE occurs when project is deleted before the end of the search request * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=261722" */ public void testBug261722() throws Exception { IPath projectPath = null; IJavaProject javaProject = null; try { // Create jar and project final int MAX = 10; final String[] pathsAndContents = new String[(1+MAX)*2]; pathsAndContents[0] = "p261722/X.java"; pathsAndContents[1] = "package p261722;\n" + "public class X {}"; for (int i=1; i<=MAX; i++) { String className = (i<10) ? "X0"+i : "X"+i; pathsAndContents[i*2] = "p261722/"+className+".java"; pathsAndContents[i*2+1] = "package p261722;\n" + "public class "+className+" extends X {}"; } javaProject = createJavaProject("P"); projectPath = javaProject.getProject().getLocation(); addLibrary(javaProject, "lib261722.jar", "lib261722.zip", pathsAndContents, "1.4"); waitUntilIndexesReady(); // Create a specific requestor slowed down to give the main thread // a chance to delete the project before the end of the search request class TestSearchRequestor extends SearchRequestor { int count = 0; public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { try { Thread.sleep(100); } catch (InterruptedException e) { // skip } this.count++; } } // Search in separated thread final TestSearchRequestor requestor = new TestSearchRequestor(); final SearchPattern pattern = SearchPattern.createPattern("X*", IJavaSearchConstants.DECLARATIONS, IJavaSearchConstants.TYPE, SearchPattern.R_PATTERN_MATCH); final IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); Runnable search = new Runnable() { public void run() { try { new SearchEngine().search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, requestor, null); } catch (CoreException e) { throw new RuntimeException(e); } } }; Thread thread = new Thread(search); thread.start(); // Delete project in current thread after being sure that the search // request was started while (requestor.count < (MAX/3)) { Thread.sleep(10); } deleteProject(javaProject); // Wait until search thread is finished while (thread.isAlive()) { Thread.sleep(100); } // Verify search results assertEquals("Unexpected matches count", MAX+1, requestor.count); } finally { if (projectPath != null) { deleteFile("/P/lib261722.jar"); deleteFile("/P/lib261722.zip"); } } } /** * @bug 265065: [search] java.lang.ClassCastException while running "Refactor...Extract Class" * @test Ensure that no CCE occurs while using an OrPattern made of VariablePattern * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=265065" */ public void testBug265065() throws CoreException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/MyClass.java", "public class MyClass {\n" + " class MyPrivateClass {\n" + " public String type = TYPE_A;\n" + " public Object value = null;\n" + " public MyPrivateClass(String type, Object value) {\n" + " this.type = type;\n" + " this.value = value;\n" + " }\n" + " }\n" + "\n" + " private static final String TYPE_A = \"A\";\n" + " private static final String TYPE_B = \"B\";\n" + " private static final String TYPE_C = \"C\";\n" + "\n" + " void foo (Object value) {\n" + " MyPrivateClass mpc = new MyPrivateClass(TYPE_B, value);\n" + " if (mpc.value == null) {\n" + " mpc.type = TYPE_C;\n" + " }\n" + " }\n" + "}\n" ); this.resultCollector.showRule(); this.resultCollector.showAccess(); SearchPattern leftPattern = SearchPattern.createPattern("MyClass.MyPrivateClass.value Object", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); SearchPattern rightPattern = SearchPattern.createPattern("MyClass.MyPrivateClass.type String", FIELD, ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE); new SearchEngine(this.workingCopies).search( SearchPattern.createOrPattern(leftPattern, rightPattern), new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchWorkingCopiesScope(), this.resultCollector, null); assertSearchResults( "src/MyClass.java void MyClass.foo(Object) [value] EXACT_MATCH READ ACCESS\n" + "src/MyClass.java void MyClass.foo(Object) [type] EXACT_MATCH READ ACCESS\n" + "src/MyClass.java MyClass$MyPrivateClass.type [type] EXACT_MATCH\n" + "src/MyClass.java MyClass$MyPrivateClass.value [value] EXACT_MATCH\n" + "src/MyClass.java MyClass$MyPrivateClass(String, Object) [type] EXACT_MATCH WRITE ACCESS\n" + "src/MyClass.java MyClass$MyPrivateClass(String, Object) [value] EXACT_MATCH WRITE ACCESS" ); } public void testBug265065b() throws CoreException { this.workingCopies = new ICompilationUnit[2]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/pack/Test.java", "package pack;\n" + "public class Test {\n" + " public int field;\n" + "}\n" ); this.workingCopies[1] = getWorkingCopy("/JavaSearchBugs/src/test/X.java", "package test;\n" + "import pack.Test;\n" + "public class X {\n" + " void foo(Test t1, Test t2) {\n" + " t1 = t2;\n" + " t1.field = t1.field;\n" + " t2.field = t1.field;\n" + " }\n" + "}\n" ); this.resultCollector.showAccess(); ILocalVariable localVar1 = selectLocalVariable(this.workingCopies[1], "t1"); SearchPattern leftPattern = createPattern(localVar1, IJavaSearchConstants.REFERENCES); ILocalVariable localVar2 = selectLocalVariable(this.workingCopies[1], "t2"); SearchPattern rightPattern = createPattern(localVar2, IJavaSearchConstants.REFERENCES); new SearchEngine(this.workingCopies).search( SearchPattern.createOrPattern(leftPattern, rightPattern), new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}, getJavaSearchWorkingCopiesScope(), this.resultCollector, null); assertSearchResults( "src/test/X.java void test.X.foo(Test, Test) [t1] EXACT_MATCH WRITE ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [t2] EXACT_MATCH READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [t1] EXACT_MATCH READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [t1] EXACT_MATCH READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [t2] EXACT_MATCH READ ACCESS\n" + "src/test/X.java void test.X.foo(Test, Test) [t1] EXACT_MATCH READ ACCESS" ); } /** * @bug 266582: [search] NPE finding references * @test Ensure that no NPE occurs when searching for type references * in a project which has the same jar twice on its classpath * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=266582" */ public void testBug266582() throws Exception { addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b266582a.jar", false); addLibraryEntry(JAVA_PROJECT, "/JavaSearchBugs/lib/b266582b.jar", false); try { createFile("/JavaSearchBugs/src/A.java", "import foo.JohnsonException;\n" + "class A {\n" + " void foo() throws JohnsonException {}\n" + "}" ); IType type = getClassFile("JavaSearchBugs", "/JavaSearchBugs/lib/b266582a.jar", "foo", "JohnsonException.class").getType(); search(type, REFERENCES); assertSearchResults( "src/A.java [foo.JohnsonException] EXACT_MATCH\n" + "src/A.java void A.foo() [JohnsonException] EXACT_MATCH" ); } finally { removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b266582a.jar")); removeClasspathEntry(JAVA_PROJECT, new Path("/JavaSearchBugs/lib/b266582b.jar")); } } /** * @bug 266837: SourceField.getConstant does not supply a value if type is fully qualified * @test Ensure that source field constant is not null when fully qualified type String is used * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=266837" */ public void testBug266837() throws Exception { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", "public class Test {\n" + " private static final java.lang.String f266837 = \"myString\";\n" + "}\n" ); SearchRequestor requestor = new SearchRequestor() { public void acceptSearchMatch(SearchMatch searchMatch) throws CoreException { IField sourceField = (IField) searchMatch.getElement(); assertEquals("Unexpected source field constant!", "\"myString\"", sourceField.getConstant()); } }; search("f266837", FIELD, DECLARATIONS, requestor); } }
[ "375833274@qq.com" ]
375833274@qq.com
f9b3e5a594c9adf1a66604e0801b9cc8149f8587
fb4e89cc96cf56ff1d8d189a4282c70168a67709
/isystem-service/isystem-service-fileupload/src/main/java/com/yksys/isystem/service/fileupload/mapper/AttachmentMapper.java
4582e449ab3010a4fde7f90ac4567f1a43573428
[ "Apache-2.0" ]
permissive
289011505/YK-iSystem
5a517dbb6d4487463b32d84d99c2c70a6b2d9c55
8dbaba1f395a0f67d21d4fa9c06a194cb0312a28
refs/heads/master
2022-04-23T02:49:18.087595
2020-04-20T09:37:05
2020-04-20T09:37:05
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,918
java
package com.yksys.isystem.service.fileupload.mapper; import com.yksys.isystem.common.pojo.Attachment; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; /** * @program: YK-iSystem * @description: 系统mapper * @author: YuKai Fan * @create: 2019-12-03 14:56 **/ public interface AttachmentMapper { /** * 新增 * @param attachment 实体 * @return */ int addAttachment(Attachment attachment); /** * 批量新增 * @param list 集合 */ void addAttachments(@Param(value = "list") List<Attachment> list); /** * 根据id查询指定 * @param id 主键 * @return */ Map<String, Object> getAttachmentById(String id); /** * 根据id修改 * @param attachment 实体 * @return */ int editAttachmentById(Attachment attachment); /** * 批量修改 * * @param attachment 实体 * @param ids 主键集合 */ void editAttachmentByIds(@Param("map") Attachment attachment, @Param("list") List<String> ids); /** * 根据id删除 * @param id * @return */ int delAttachmentById(String id); /** * 批量删除 * * @param ids 主键集合 * @return dao成功失败标志 */ int delAttachmentByIds(List<String> ids); /** * 真删除 * * @param id 主键 * @return dao成功失败标志 */ int delAttachmentRealById(String id); /** * 真批量删除 * * @param ids 主键集合 * @return dao成功失败标志 */ int delAttachmentRealByIds(List<String> ids); /** * 全部真删除 * @return */ int delAllAttachmentReal(); /** * 获取所有. * @param map 页面表单 * @return 结果集合 */ List<Map<String, Object>> getAttachments(Map<String, Object> map); }
[ "goodMorning_glb@yukaifan.com" ]
goodMorning_glb@yukaifan.com
b0cadbd02e7df27f12560140d537e92b153637a8
d713a0d183761f49069ff2892b55d16055bf999d
/src/main/java/designpattern/iterator/Client.java
579cb845103473c99a474676a10ae28fbd9a799e
[]
no_license
duomengwuyou/usefullearnstaff
adaf2e6ace620ddee129ef603198d51ca7a5bddd
f667ca3e6c94efc2ddb492c61191e550bc6207e8
refs/heads/master
2021-01-10T12:21:22.066587
2015-12-02T15:22:50
2015-12-02T15:22:50
47,265,300
0
0
null
null
null
null
GB18030
Java
false
false
570
java
package designpattern.iterator; /** * 迭代器模式就是为集合类里面的数据访问提供了一种统一的接口, * * 集合类里面不提供直接访问数据的方式,而是通过iterator里面来做。 * * 迭代器和集合是相辅相成的。 * * */ public class Client { public static void main(String[] args) { // TODO Auto-generated method stub Aggregate a = new ConcreteAggregate(); a.add(1); a.add("long"); IteratorInterface ite = a.iterator(); while(ite.hasNext()){ System.out.println(ite.next()); } } }
[ "1098756763@qq.com" ]
1098756763@qq.com
f8b40bc1486dc7bb94cc834860f8ee92e90fd70d
abd2baf221d10149e4e8a551eab9a15afe183923
/app/src/main/java/com/example/a3rdattempt/BlogRecyclerAdapter.java
7d7c78b05ddc4786b4ab5deae663e2f9c6048971
[]
no_license
MoMus2000/3rdAttempt
e9625e13a9397053e073cd5800eceaa90d3871ef
62f991369760c20e6ce8d02876f37e76e3e60c7d
refs/heads/master
2022-12-02T14:29:28.828861
2020-08-25T18:21:29
2020-08-25T18:21:29
290,291,142
1
0
null
null
null
null
UTF-8
Java
false
false
2,761
java
package com.example.a3rdattempt; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import android.widget.VideoView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.firestore.FirebaseFirestore; import org.w3c.dom.Text; import java.util.List; public class BlogRecyclerAdapter extends RecyclerView.Adapter<BlogRecyclerAdapter.ViewHolder> { public List<BlogPost> blogPostList; public Context context; private FirebaseFirestore firebaseFirestore; private FirebaseAuth firebaseAuth; BlogRecyclerAdapter(List<BlogPost> blogPostList) { this.blogPostList = blogPostList; } @NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.blog_list_item, parent, false); context = parent.getContext(); firebaseFirestore = FirebaseFirestore.getInstance(); firebaseAuth = FirebaseAuth.getInstance(); return new ViewHolder(view); } @Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { String desc_data = blogPostList.get(position).getDesc(); holder.setDescText(desc_data); String image_url = blogPostList.get(position).getImageUrl(); String thumbUri = blogPostList.get(position).getImageThumb(); holder.setBlogImage(image_url, thumbUri); } @Override public int getItemCount() { return blogPostList.size(); } public class ViewHolder extends RecyclerView.ViewHolder{ private View mView; private TextView descView; private ImageView blogImageView; public ViewHolder(@NonNull View itemView) { super(itemView); mView = itemView; } public void setDescText(String text){ descView = mView.findViewById(R.id.Description); descView.setText(text); } public void setBlogImage(String downloadUri, String thumbUri){ blogImageView = mView.findViewById(R.id.BLOGIMAGE); RequestOptions requestOptions = new RequestOptions(); requestOptions.placeholder(R.drawable.image_placeholder); Glide.with(context).applyDefaultRequestOptions(requestOptions).load(downloadUri).thumbnail( Glide.with(context).load(thumbUri) ).into(blogImageView); } } }
[ "muhammadmustafa4000@gmail.com" ]
muhammadmustafa4000@gmail.com
64fa9c28f9e565e83cf4fc8aa3d92ed83fa9b04a
a6ea8f76ca133b1d5c2f5c1990bb3273a17dedac
/src/test/java/com/platzi/javatests/movies/service/MovieServiceShould.java
de41a6dd11fd08629735a1c1e5b8065bd417d144
[]
no_license
fauObregon/javatests
ccb7b627ff72b346b34aabb31d7f5eb835dc3512
3e49847bbe47e213d837b6cb1ab96b3008da2507
refs/heads/master
2022-01-22T02:39:11.143965
2020-03-20T05:51:51
2020-03-20T05:51:51
248,677,209
0
0
null
2022-01-21T23:39:33
2020-03-20T05:42:20
Java
UTF-8
Java
false
false
2,236
java
package com.platzi.javatests.movies.service; import com.platzi.javatests.movies.data.MovieRepository; import com.platzi.javatests.movies.model.Genre; import com.platzi.javatests.movies.model.Movie; import org.hamcrest.CoreMatchers; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import static org.junit.Assert.*; public class MovieServiceShould { private MovieRepository movieRepository; private MovieService movieService; @Before public void setUp(){ movieRepository = Mockito.mock(MovieRepository.class); Mockito.when(movieRepository.findAll()).thenReturn( Arrays.asList( new Movie(1, "Dark Knight", 152, Genre.ACTION), new Movie(2, "Memento", 113, Genre.THRILLER), new Movie(3, "There's Something About Mary", 119, Genre.COMEDY), new Movie(4, "Super 8", 112, Genre.THRILLER), new Movie(5, "Scream", 111, Genre.HORROR), new Movie(6, "Home Alone", 103, Genre.COMEDY), new Movie(7, "Matrix", 136, Genre.ACTION) ) ); movieService = new MovieService(movieRepository); } @Test public void return_movies_by_genre() { Collection<Movie> movies = movieService.findMoviesByGenre(Genre.COMEDY); assertThat(getMovieIds(movies), CoreMatchers.is(Arrays.asList(3,6))); } @Test public void return_movies_by_lenght() { Collection<Movie> movies = movieService.findMoviesByLength(120); assertThat(getMovieIds(movies), CoreMatchers.is(Arrays.asList(2,3,4,5,6))); } @Test public void return_movies_by_name() { Collection<Movie> movies = movieService.findMoviesByName("super"); assertThat(getMovieIds(movies), CoreMatchers.is(Arrays.asList(4))); } private List<Integer> getMovieIds(Collection<Movie> movies) { return movies.stream().map(movie -> movie.getId()).collect(Collectors.toList()); } }
[ "fau.obregon@gmail.com" ]
fau.obregon@gmail.com
9414ce698f457a802d613a89733442f2fa04303a
fa4be8afcf2d76620213cc760fa285724d033115
/EnterpriseProjects/ServletsJSPJSTL/src/main/java/ai/beans/ColorBean.java
dd83d15c3da944f6f00e524bb0eaacdc7deaacd6
[]
no_license
CiesielskiB/PP2021_TAKE
e643fdf08e1afaaa053c916250eae9141019e46d
8deb2a93cb03f9e28d551f5459980da7a9012bf6
refs/heads/master
2023-04-21T18:47:45.905359
2021-05-21T10:09:38
2021-05-21T10:09:38
344,782,270
0
0
null
null
null
null
UTF-8
Java
false
false
1,117
java
package ai.beans; public class ColorBean { private String foregroundColor; private String backgroundColor; private String visibleFrame; public ColorBean() { } /** * @return the foregroundColor */ public String getForegroundColor() { return foregroundColor; } /** * @param foregroundColor the foregroundColor to set */ public void setForegroundColor(String foregroundColor) { this.foregroundColor = foregroundColor; } /** * @return the backgroundColor */ public String getBackgroundColor() { return backgroundColor; } /** * @param backgroundColor the backgroundColor to set */ public void setBackgroundColor(String backgroundColor) { this.backgroundColor = backgroundColor; } /** * @return the visibleFrame */ public String getVisibleFrame() { return visibleFrame; } /** * @param visibleFrame the visibleFrame to set */ public void setVisibleFrame(String visibleFrame) { this.visibleFrame = visibleFrame; } }
[ "Miketen1997@gmail.com" ]
Miketen1997@gmail.com
7a02ff877fb31e0990122abf6c583945e963937e
ace60742a8ce1c70ff390081a97c559f96123c4e
/src/main/java/com/yi/common/utils/MessageUtils.java
4215c2ecf3da86bf68640e5cd80a24533944eede
[]
no_license
wanfengsky/IPv6--Network-teaching-platform
f7e03d258655d992af16021922476ce36c53a44c
4756777165bfd4453078f3f2dbeec9ee7d291ce1
refs/heads/main
2023-06-26T20:13:30.472442
2021-08-01T09:35:13
2021-08-01T09:35:13
358,507,481
0
0
null
null
null
null
UTF-8
Java
false
false
686
java
package com.yi.common.utils; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; import com.yi.common.utils.spring.SpringUtils; /** * 获取i18n资源文件 */ public class MessageUtils { /** * 根据消息键和参数 获取消息 委托给spring messageSource * * @param code 消息键 * @param args 参数 * @return 获取国际化翻译值 */ public static String message(String code, Object... args) { MessageSource messageSource = SpringUtils.getBean(MessageSource.class); return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); } }
[ "liupeisky@foxmail.com" ]
liupeisky@foxmail.com
dd1239f39c88574bb0025cbd6d3b3e2e11494b4a
0e41f7db31a0cfafe4ba6ee1d7458ec60b6f38e0
/src/main/java/com/wql/boot/wqlboot/web/aspect/LoggerAspect.java
bef1968a39c98b41bc5e84ce4a41fda5f162a92c
[]
no_license
wangqiulin/wql-boot
234b23a297449882ceb3f8a741fc445229d62979
24b4418908fa1014ef15851cf12c7ea7d313827e
refs/heads/master
2023-07-25T07:02:44.441665
2020-04-01T03:44:05
2020-04-01T03:44:05
133,121,945
0
0
null
2023-07-16T21:55:19
2018-05-12T06:54:37
Java
UTF-8
Java
false
false
11,349
java
package com.wql.boot.wqlboot.web.aspect; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Stream; import javax.annotation.Resource; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @Aspect @Component @ConditionalOnExpression("${log.aspect:true}") public class LoggerAspect { public static final Logger log = LoggerFactory.getLogger(LoggerAspect.class); public static final String UNKNOWN = "unknown"; private ThreadLocal<Long> startTimeMillis = new ThreadLocal<>(); public final String MAC_ADDRESS_PREFIX = "MAC Address = "; public final String LOOPBACK_ADDRESS = "127.0.0.1"; @Autowired private HttpServletRequest request; @Resource private ObjectMapper mapper; /** * 日志打印脱敏关键字段是否开启默认开启 */ @Value("${log.aspect.desensitization.enabled:true}") private boolean desensitizationEnabled; /** * 日志打印脱敏关键词 */ @Value("#{'${log.aspect.desensitization.words:password}'.split(',')}") private List<String> words; /** * 敏感替换词 */ @Value("${log.aspect.desensitization.replace:******}") private String replace; @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) || " + "@annotation(org.springframework.web.bind.annotation.GetMapping) || " + "@annotation(org.springframework.web.bind.annotation.PostMapping)") public void log() { } @Before("log()") public void before(JoinPoint joinPoint) { try { // 记录方法开始执行的时间 startTimeMillis.set(System.currentTimeMillis()); String ip = UNKNOWN; String mac = UNKNOWN; String submitMethod = request.getMethod(); // 请求path String path = request.getRequestURI().substring(request.getContextPath().length()).split(";")[0]; // 打印请求日志 printRequestLog(joinPoint, ip, mac, submitMethod, path); } catch (Exception e) { log.warn("请求切面before日志打印失败", e); } } /** * @param joinPoint * @param ip * @param mac * @param submitMethod * @param path */ private void printRequestLog(JoinPoint joinPoint, String ip, String mac, String submitMethod, String path) { StringBuilder sb = new StringBuilder( "\n-------------------------------------begin-------------------------------------"); sb.append("\nrequest info is -------->\n"); String method = joinPoint.getSignature().getName(); // sb.append("ip : ").append(ip).append("\n"); // sb.append("mac : ").append(mac).append("\n"); sb.append("url : ").append(path).append("\n"); sb.append("reqMethod : ").append(submitMethod).append("\n"); sb.append("Controller : ").append(joinPoint.getTarget().getClass().getName()).append(".(") .append(joinPoint.getTarget().getClass().getSimpleName()).append(".java:1)"); sb.append("\nMethod : ").append(method).append("\n"); try { sb.append("args : ").append(printArgs(excludeArgs(joinPoint.getArgs())) + "\n"); } catch (Exception e) { log.warn("controller请求参数序列化异常", e); } log.info(sb.toString()); } /** * 打印参数日志 * * @param obj * @return */ private String printArgs(Object obj) { String result = null; try { result = mapper.writeValueAsString(desensitizationArgs(obj)); } catch (JsonProcessingException e) { log.warn("printArgs失败", e); } return result; } /** * 参数去敏感 * * @param obj * @return */ @SuppressWarnings("all") private Object desensitizationArgs(Object obj) { Object result = obj; if (desensitizationEnabled) { if (obj != null) { try { Object rs; if (obj instanceof Collection || obj instanceof Map) { rs = obj; } else { rs = mapper.readValue(mapper.writeValueAsString(obj), Object.class); } if (rs instanceof Collection) { Collection temp = new ArrayList<>(); for (Object o : (Collection) rs) { if (isBasicType(o)) { temp.add(o); } else { temp.add(desensitizationArgs(o)); } } result = temp; } else if (rs instanceof Map) { Map<String, Object> temp = new LinkedHashMap<>(); ((Map<String, Object>) rs).forEach((k, v) -> { if (isBasicType(v)) { if (words.contains(k)) { temp.put(k, replace); } else { temp.put(k, v); } } else { temp.put(k, desensitizationArgs(v)); } }); result = temp; } } catch (IOException e) { log.warn("对象转map失败", e); } } } return result; } private boolean isBasicType(Object obj) { if (obj instanceof Number || obj instanceof Date || obj instanceof String || obj instanceof Number[] || obj instanceof Date[] || obj instanceof String[] || obj instanceof Character[] ) { return true; } return false; } /** * 排除掉request,response对象 * * @param args * @return */ private Object[] excludeArgs(Object[] args) { return Stream.of(args).filter( arg -> !(arg instanceof ServletRequest || arg instanceof ServletResponse || arg instanceof HttpSession)) .toArray(); } @AfterReturning(pointcut = "log()", returning = "returnValue") public void afterReturning(JoinPoint joinPoint, Object returnValue) { try { // 记录方法执行完成的时间 Long startTime = startTimeMillis.get(); startTimeMillis.remove(); StringBuilder sb = new StringBuilder("response info is --->(耗时:" + (System.currentTimeMillis() - startTime) + "ms)\n" + printArgs(returnValue)); sb.append("\n-------------------------------------end-------------------------------------"); log.info(sb.toString()); } catch (Exception e) { log.warn("请求切面afterReturning日志打印失败", e); } } /** * 通过HttpServletRequest返回IP地址 * * @param request HttpServletRequest * @return ip String * @throws Exception */ public String getIpAddress(HttpServletRequest request) { String ip = ""; try { ip = request.getHeader("x-forwarded-for"); if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getHeader("Proxy-Client-IP"); } if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getHeader("WL-Proxy-Client-IP"); } if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_CLIENT_IP"); } if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getHeader("HTTP_X_FORWARDED_FOR"); } if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { ip = request.getRemoteAddr(); } } catch (Exception e) { } return ip; } /** * 通过IP地址获取MAC地址 * * @param ip String,127.0.0.1格式 * @return mac String * @throws Exception */ public String getMACAddress(String ip) { String macAddress = ""; try { String line = ""; // 如果为127.0.0.1,则获取本地MAC地址。 if (LOOPBACK_ADDRESS.equals(ip)) { InetAddress inetAddress = InetAddress.getLocalHost(); // 貌似此方法需要JDK1.6。 byte[] mac = NetworkInterface.getByInetAddress(inetAddress).getHardwareAddress(); // 下面代码是把mac地址拼装成String StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { if (i != 0) { sb.append("-"); } // mac[i] & 0xFF 是为了把byte转化为正整数 String s = Integer.toHexString(mac[i] & 0xFF); sb.append(s.length() == 1 ? 0 + s : s); } // 把字符串所有小写字母改为大写成为正规的mac地址并返回 macAddress = sb.toString().trim().toUpperCase(); return macAddress; } // 获取非本地IP的MAC地址 Process p = Runtime.getRuntime().exec("nbtstat -A " + ip); InputStreamReader isr = new InputStreamReader(p.getInputStream()); BufferedReader br = new BufferedReader(isr); while ((line = br.readLine()) != null) { if (line != null) { int index = line.indexOf(MAC_ADDRESS_PREFIX); if (index != -1) { macAddress = line.substring(index + MAC_ADDRESS_PREFIX.length()).trim().toUpperCase(); } } } br.close(); } catch (Exception e) { log.error("getMACAddress error ", e); } return macAddress; } }
[ "wangqiulin@netwisdom.cn" ]
wangqiulin@netwisdom.cn
4d0956c15e041bd096e060d1d7e09bc72409da05
6cdc07012dc9a429aa37b6f9c18d4f00d53f3474
/src/test/com/fh/shop/TestOSS.java
b04ba3114f0bcf6c3e548db93ff8e0e44b048697
[]
no_license
zhujunliang12/shop-admin
2d8c0ea34c0ed3a8324920adf26ae2589cb9e27c
01222a3d637ddc338c4d19c17b639156681bb7ef
refs/heads/master
2022-11-28T17:53:05.974203
2020-08-09T13:03:41
2020-08-09T13:03:41
286,226,304
0
0
null
null
null
null
UTF-8
Java
false
false
2,436
java
package com.fh.shop; import com.aliyun.oss.OSS; import com.aliyun.oss.OSSClientBuilder; import org.junit.Test; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; public class TestOSS { /** * 测试oss文件上传 */ @Test public void testOss() { // Endpoint以杭州为例,其它Region请按实际情况填写。 String endpoint = "oss-cn-beijing.aliyuncs.com"; // 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用RAM子账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建。 String accessKeyId = "LTAI4GKZurzwinq8ecfUmcJm"; String accessKeySecret = "UtUpWPJ6YMb6lZzS8v7bCpAeWB3VR9"; String Bucket = "1907aa.oss-cn-beijing.aliyuncs.com"; // 创建OSSClient实例。 OSS ossClient = new OSSClientBuilder( ).build(endpoint, accessKeyId, accessKeySecret); // 上传文件流。 InputStream inputStream = null; try { inputStream = new FileInputStream("D:\\img\\timg.jpg"); } catch (FileNotFoundException e) { e.printStackTrace( ); } ossClient.putObject("1907aa", "b.jpg", inputStream); // 关闭OSSClient。 ossClient.shutdown( ); } @Test public void delete() { // Endpoint以杭州为例,其它Region请按实际情况填写。 String endpoint = "oss-cn-beijing.aliyuncs.com"; // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。 String accessKeyId = "LTAI4GKZurzwinq8ecfUmcJm"; String accessKeySecret = "UtUpWPJ6YMb6lZzS8v7bCpAeWB3VR9"; String bucketName = "1907aa"; String objectName = "787a0122-3d89-47c3-b4e2-f7d4a4012ea8.jpg"; // 创建OSSClient实例。 OSS ossClient = new OSSClientBuilder( ).build(endpoint, accessKeyId, accessKeySecret); // 删除文件。如需删除文件夹,请将ObjectName设置为对应的文件夹名称。如果文件夹非空,则需要将文件夹下的所有object删除后才能删除该文件夹。 ossClient.deleteObject(bucketName, objectName); // 关闭OSSClient。 ossClient.shutdown( ); } }
[ "260006856@qq.com" ]
260006856@qq.com
e8e26ffd1b73a4bffddbe9ad78d3531737a2d894
9064939782a4665bf355b7657a9c22838ef7743e
/src/main/java/com/pockey/utils/CookieUtil.java
dc801c6f49a3a3f8ce433c585769947e2cac3b68
[]
no_license
shaunqing/sell
8f5a6cdc4646e6a69e2b2a3a72d6650b5c42e72d
25909b34cf61245416d69a11912805115df6c952
refs/heads/master
2021-09-05T09:57:50.569473
2018-01-26T07:13:15
2018-01-26T07:13:15
108,402,656
0
0
null
null
null
null
UTF-8
Java
false
false
1,527
java
package com.pockey.utils; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.Map; /** * cookie工具类 * * @author LIQing * @create 2017-12-12 8:52 */ public class CookieUtil { /** * 设置cookie * * @param response * @param name * @param value * @param maxAge */ public static void set(HttpServletResponse response, String name, String value, int maxAge) { Cookie cookie = new Cookie(name, value); cookie.setPath("/"); cookie.setMaxAge(maxAge); response.addCookie(cookie); } /** * 获取cookie * * @param request * @param name * @return */ public static Cookie get(HttpServletRequest request, String name) { Map<String, Cookie> cookieMap = readCookieMap(request); if (cookieMap.containsKey(name)) { return cookieMap.get(name); } else { return null; } } /** * cookie封装为map * * @param request * @return */ private static Map<String, Cookie> readCookieMap(HttpServletRequest request) { Map<String, Cookie> cookieMap = new HashMap<>(); Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { cookieMap.put(cookie.getName(), cookie); } } return cookieMap; } }
[ "shaunqing@gmai.com" ]
shaunqing@gmai.com
69bf3aa3784bac28cddc056542db6cc298ba332e
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/17/17_0a5dbe869eedf204b0fd7ac7721dc93e8e3ea32a/XDI3ParserManual/17_0a5dbe869eedf204b0fd7ac7721dc93e8e3ea32a_XDI3ParserManual_t.java
e3ed6557f7a170abaff9f1e3ba2304df8bc94dad
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
11,648
java
package xdi2.core.xri3.parser.manual; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import xdi2.core.constants.XDIConstants; import xdi2.core.xri3.XDI3Parser; import xdi2.core.xri3.XDI3Segment; import xdi2.core.xri3.XDI3Statement; import xdi2.core.xri3.XDI3SubSegment; import xdi2.core.xri3.XDI3XRef; /** * An XRI parser implemented manually in pure Java. * This parse has not been automatically generated from an ABNF. */ public class XDI3ParserManual extends XDI3Parser { private static final Logger log = LoggerFactory.getLogger(XDI3ParserManual.class); @Override public XDI3Statement parseXDI3Statement(String string) { if (log.isTraceEnabled()) log.trace("Parsing statement: " + string); String temp = stripXs(string); String[] parts = temp.split("/"); if (parts.length != 3) throw new ParserException("Invalid statement: " + string + " (wrong number of segments: " + parts.length + ")"); int split0 = parts[0].length(); int split1 = parts[1].length(); String subjectString = string.substring(0, split0); String predicateString = string.substring(split0 + 1, split0 + split1 + 1); String objectString = string.substring(split0 + split1 + 2); XDI3Segment subject = this.parseXDI3Segment(subjectString); XDI3Segment predicate = this.parseXDI3Segment(predicateString); if (XDIConstants.XRI_S_LITERAL.equals(predicateString)) { String object = this.parseString(objectString); return this.makeXDI3Statement(string, subject, predicate, object); } else if (XDIConstants.XRI_S_CONTEXT.equals(predicateString)) { XDI3SubSegment object = this.parseXDI3SubSegment(objectString); return this.makeXDI3Statement(string, subject, predicate, object); } else { XDI3Segment object = this.parseXDI3Segment(objectString); return this.makeXDI3Statement(string, subject, predicate, object); } } @Override public XDI3Segment parseXDI3Segment(String string) { if (log.isTraceEnabled()) log.trace("Parsing segment: " + string); int start = 0, pos = 0; String pair; Stack<String> pairs = new Stack<String> (); List<XDI3SubSegment> subSegments = new ArrayList<XDI3SubSegment> (); while (pos < string.length()) { // parse beginning of subsegment if (pos < string.length() && (pair = cla(string.charAt(pos))) != null) { pairs.push(pair); pos++; } if (pos < string.length() && (pair = att(string.charAt(pos))) != null) { pairs.push(pair); pos++; } if (pos < string.length() && cs(string.charAt(pos)) != null) pos++; if (pos < string.length() && (pair = xs(string.charAt(pos))) != null) { pairs.push(pair); pos++; } // parse to the end of the subsegment while (pos < string.length()) { // no open pairs? if (pairs.isEmpty()) { // reached beginning of the next subsegment if (cla(string.charAt(pos)) != null) break; if (att(string.charAt(pos)) != null) break; if (cs(string.charAt(pos)) != null) break; if (xs(string.charAt(pos)) != null) break; } // at least one pair still open? if (! pairs.isEmpty()) { // new pair being opened? pair = cla(string.charAt(pos)); if (pair == null) pair = att(string.charAt(pos)); if (pair == null) pair = xs(string.charAt(pos)); if (pair != null) { pairs.push(pair); pos++; continue; } // pair being closed? if (string.charAt(pos) == pairs.peek().charAt(1)) { pairs.pop(); pos++; continue; } } pos++; } if (! pairs.isEmpty()) throw new ParserException("Missing closing character '" + pairs.peek().charAt(1) + "'."); subSegments.add(this.parseXDI3SubSegment(string.substring(start, pos))); start = pos; } // done return this.makeXDI3Segment(string, subSegments); } @Override public XDI3SubSegment parseXDI3SubSegment(String string) { if (log.isTraceEnabled()) log.trace("Parsing subsegment: " + string); Character cs = null; String cla = null; String att = null; String literal = null; XDI3XRef xref = null; int pos = 0, len = string.length(); // extract class pair if (pos < len && (cla = cla(string.charAt(pos))) != null) { if (string.charAt(len - 1) != cla.charAt(1)) throw new ParserException("Invalid subsegment: " + string + " (invalid closing '" + cla.charAt(1) + "' character for class)"); pos++; len--; } // extract attribute pair if (pos < len && (att = att(string.charAt(pos))) != null) { if (string.charAt(len - 1) != att.charAt(1)) throw new ParserException("Invalid subsegment: " + string + " (invalid closing '" + att.charAt(1) + "' character for attribute)"); pos++; len--; } // extract cs if (pos < len && (cs = cs(string.charAt(pos))) != null) { pos++; } // parse the rest, either xref or literal if (pos < len) { if (xs(string.charAt(pos)) != null) { xref = this.parseXDI3XRef(string.substring(pos, len)); } else { if (pos == 0) throw new ParserException("Invalid subsegment: " + string + " (no cs, xref)"); literal = parseLiteral(string.substring(pos, len)); } } // done return this.makeXDI3SubSegment(string, cs, cla != null, att != null, literal, xref); } @Override public XDI3XRef parseXDI3XRef(String string) { if (log.isTraceEnabled()) log.trace("Parsing xref: " + string); String xs = xs(string.charAt(0)); if (xs == null) throw new ParserException("Invalid xref: " + string + " (no opening delimiter)"); if (string.charAt(string.length() - 1) != xs.charAt(1)) throw new ParserException("Invalid xref: " + string + " (invalid closing '" + xs.charAt(1) + "' character)"); if (string.length() == 2) return this.makeXDI3XRef(string, xs, null, null, null, null, null, null); String value = string.substring(1, string.length() - 1); String temp = stripXs(value); XDI3Segment segment = null; XDI3Statement statement = null; XDI3Segment partialSubject = null; XDI3Segment partialPredicate = null; String iri = null; String literal = null; if (isIri(temp)) { iri = value; } else { int segments = StringUtils.countMatches(temp, "/") + 1; if (segments == 3) { statement = this.parseXDI3Statement(value); } else if (segments == 2) { String[] parts = temp.split("/"); int split0 = parts[0].length(); partialSubject = this.parseXDI3Segment(value.substring(0, split0)); partialPredicate = this.parseXDI3Segment(value.substring(split0 + 1)); } else if (cs(value.charAt(0)) != null || cla(value.charAt(0)) != null || att(value.charAt(0)) != null || xs(value.charAt(0)) != null) { segment = this.parseXDI3Segment(value); } else { literal = value; } } return this.makeXDI3XRef(string, xs, segment, statement, partialSubject, partialPredicate, iri, literal); } public String parseString(String string) { if (log.isTraceEnabled()) log.trace("Parsing string: " + string); if (string.length() < 2) throw new ParserException("Invalid string: " + string); if (string.charAt(0) != '"') throw new ParserException("Invalid string: " + string + " (no opening double quotes)"); if (string.charAt(string.length() - 1) != '"') throw new ParserException("Invalid string: " + string + " (no closing double quotes)"); return string.substring(1, string.length() - 1); } private static String stripQuotes(String string) { string = stripPattern(string, Pattern.compile(".*(\\([^\\(\\)]*\\)).*")); return string; } private static String stripXs(String string) { string = stripPattern(string, Pattern.compile(".*(\\([^\\(\\)]*\\)).*")); string = stripPattern(string, Pattern.compile(".*(\\{[^\\{\\}]*\\}).*")); string = stripPattern(string, Pattern.compile(".*(\"[^\"]*\").*")); return string; } private static String stripPattern(String string, Pattern pattern) { String temp = string; while (true) { Matcher matcher = pattern.matcher(temp); if (! matcher.matches()) break; StringBuffer newtemp = new StringBuffer(); newtemp.append(temp.substring(0, matcher.start(1))); for (int i=matcher.start(1); i<matcher.end(1); i++) newtemp.append(" "); newtemp.append(temp.substring(matcher.end(1))); temp = newtemp.toString(); } return temp; } private static boolean isIri(String string) { int indexColon = string.indexOf(':'); int indexEquals = string.indexOf(XDIConstants.CS_EQUALS.charValue()); int indexAt = string.indexOf(XDIConstants.CS_AT.charValue()); int indexPlus = string.indexOf(XDIConstants.CS_PLUS.charValue()); int indexDollar = string.indexOf(XDIConstants.CS_DOLLAR.charValue()); int indexStar = string.indexOf(XDIConstants.CS_STAR.charValue()); int indexBang = string.indexOf(XDIConstants.CS_BANG.charValue()); if (indexColon == -1) return false; if (indexEquals != -1 && indexEquals < indexColon) return false; if (indexAt != -1 && indexAt < indexColon) return false; if (indexPlus != -1 && indexPlus < indexColon) return false; if (indexDollar != -1 && indexDollar < indexColon) return false; if (indexStar != -1 && indexStar < indexColon) return false; if (indexBang != -1 && indexBang < indexColon) return false; return true; } /* * Helper methods */ private static Character cs(char c) { for (Character cs : XDIConstants.CS_ARRAY) if (cs.charValue() == c) return cs; return null; } private static String cla(char c) { if (XDIConstants.XS_CLASS.charAt(0) == c) return XDIConstants.XS_CLASS; return null; } private static String att(char c) { if (XDIConstants.XS_ATTRIBUTE.charAt(0) == c) return XDIConstants.XS_ATTRIBUTE; return null; } private static String xs(char c) { if (XDIConstants.XS_ROOT.charAt(0) == c) return XDIConstants.XS_ROOT; if (XDIConstants.XS_VARIABLE.charAt(0) == c) return XDIConstants.XS_VARIABLE; return null; } private static String parseLiteral(String string) { try { string = URLDecoder.decode(string, "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new ParserException(ex.getMessage(), ex); } for (int pos=0; pos<string.length(); pos++) { char c = string.charAt(pos); if (c >= 0x41 && c <= 0x5A) continue; if (c >= 0x61 && c <= 0x7A) continue; if (c >= 0x30 && c <= 0x39) continue; if (c == '-') continue; if (c == '.') continue; if (c == ':') continue; if (c == '_') continue; if (c == '~') continue; if (c >= 0xA0 && c <= 0xD7FF) continue; if (c >= 0xF900 && c <= 0xFDCF) continue; if (c >= 0xFDF0 && c <= 0xFFEF) continue; throw new ParserException("Invalid character '" + c + "' at position " + pos + " of literal " + string); } return string; } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
f1324ce13a77b8f98f70756a7b1ae867295f85c7
311b5428a1ecbe1a3ffd6e0eb3a8e270394ad9db
/1DAM_Ejercicios_Hoja_6/src/ejercicio55/Empleado.java
810cc61fb8911a69815214ffecfe3c855f2d2b9e
[]
no_license
stl333/primeroDAM
b96ba81cb5172a6f4216f7104a3cc36f99262d0d
b78cd9f7263bd32d918effeff7546f0966a0eed1
refs/heads/master
2020-03-08T16:34:35.851217
2018-04-05T17:58:35
2018-04-05T17:58:35
128,243,197
0
0
null
null
null
null
UTF-8
Java
false
false
655
java
package ejercicio55; public class Empleado { private String nombre; private String telefono; private static int numeroEmpleados = 0; public Empleado(String nombre, String telefono) { this.nombre = nombre; this.telefono = telefono; numeroEmpleados++; } public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public String getTelefono() { return telefono; } public void setTelefono(String telefono) { this.telefono = telefono; } public static int getNumeroEmpleados() // al ser estático, se le llama directamente con la clase { return numeroEmpleados; } }
[ "sergio93_tl@hotmail.com" ]
sergio93_tl@hotmail.com
67c65c1ccd1c5e5e976b2edc14baffb30d4d97e0
162fced8b60293404e8a7ea3e6093314f0657d6c
/BmPPmp/src/main/java/com/lti/service/JourDetailsSeviceImpl.java
8364f12b1ac59c3e455071436d9978be4830f55c
[]
no_license
SaiCharan87s/BmPPmp
e9890361f49e29a2b1ddac26706904f143cc1ec8
d4c87aed9522624d2f6db22f5a51d9460f74946c
refs/heads/master
2023-08-02T14:49:42.070804
2021-09-26T07:12:44
2021-09-26T07:12:44
410,266,802
0
0
null
null
null
null
UTF-8
Java
false
false
1,991
java
package com.lti.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.lti.dao.JourDetailsDao; import com.lti.dao.NumberException; import com.lti.model.JourDetails; import com.lti.model.JourDetailsException; @Service public class JourDetailsSeviceImpl implements JourDetailsService { @Autowired JourDetailsDao jourDetailsDao; @Override public List<JourDetails> selectAllJourDetails() { // TODO Auto-generated method stub return jourDetailsDao.selectAllJourDetails(); } @Override public JourDetails selectJourDetails(int journey_id) throws JourDetailsException { // TODO Auto-generated method stub return jourDetailsDao.selectJourDetails(journey_id); } @Override public List<JourDetails> selectJourDetailsbySourceLocation(String sourceLoc) throws JourDetailsException { // TODO Auto-generated method stub return jourDetailsDao.selectJourDetailsbySourceLocation(sourceLoc); } @Override public List<JourDetails> selectJourDetailsbyDestinationLocation(String destinationLoc) throws JourDetailsException { return jourDetailsDao.selectJourDetailsbyDestinationLocation(destinationLoc); } @Override public List<JourDetails> selectJourDetailsbyJourneyID(int journeyId) throws JourDetailsException { // TODO Auto-generated method stub return jourDetailsDao.selectJourDetailsbyJourneyID(journeyId); } @Override public int selectAvailableSeates(String busNo, int journeyId) throws JourDetailsException { // TODO Auto-generated method stub return jourDetailsDao.selectAvailableSeates(busNo, journeyId); } @Override public void changeAvailableSeats(int jID, int rID) throws NumberException { // TODO Auto-generated method stub System.out.println("changeAvailableSeats"); try { jourDetailsDao.changeAvailableSeats(jID,rID); System.out.println("Seats Count Changed"); } catch(NumberException e) { e.printStackTrace(); } } }
[ "pickraju24@gmail.com" ]
pickraju24@gmail.com
10bb6aa0d00c9d57a03960b31167457069ccf3bc
1399a94600e999e1aac1f46f0659f305625e1cef
/src/main/java/vehiculos/Camion.java
e389aa7d14ae89d1fbaee31f3e5895f53568dafd
[]
no_license
POO-UNALMED/taller-6-kricotl
b05fcfb9977a09281d8f84253184724feecb32c2
776d86b50fabc8a512ae343ea38397e14d0c74b7
refs/heads/master
2022-12-21T01:50:47.735954
2020-10-05T20:17:53
2020-10-05T20:17:53
301,497,498
0
0
null
null
null
null
UTF-8
Java
false
false
501
java
package vehiculos; public class Camion extends Vehiculo { public int ejes; public static int cantidadCamiones=0; public int getEjes() { return ejes; } public void setEjes(int ejes) { this.ejes = ejes; } public Camion(String placa, String nombre, int precio, int peso, Fabricante fabricante, int ejes) { super(placa, 2, 80, nombre, precio, peso, "4X2", fabricante); this.ejes = ejes; cantidadCamiones++; } public int getcantidadCamiones() { return cantidadCamiones; } }
[ "69688276+Saherrerap@users.noreply.github.com" ]
69688276+Saherrerap@users.noreply.github.com
3e0aa7febb852d32bbd12736e1e4c492401afaa4
c39b0a0e8a4010f1b1d8617bfb0f933bbc6460bf
/introduction/Simple Java Database Swing Application/Part 12 - Packaging and Distribution/src/main/java/com/javacreed/examples/app/DbHelper.java
db299763dfaafd3abe69508df731ff167f7a1766
[]
no_license
rkmishracs/java-creed-examples
4ac00308174acaaf46e0448dce7750166174b548
b5070604842dd8933ca4284a47a7144c8b1f22d7
refs/heads/master
2016-09-06T08:10:14.959217
2015-03-14T12:24:13
2015-03-14T12:24:13
42,683,378
0
1
null
null
null
null
UTF-8
Java
false
false
2,913
java
/** * Copyright 2012-2014 Java Creed. * * Licensed under the Apache License, Version 2.0 (the "<em>License</em>"); * 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.javacreed.examples.app; import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.util.Properties; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.googlecode.flyway.core.Flyway; public class DbHelper { private static final Logger LOGGER = LoggerFactory.getLogger(DbHelper.class); private static final DbHelper INSTANCE = new DbHelper(); public static Connection getConnection() throws SQLException { return DbHelper.getInstance().getDataSource().getConnection(); } public static DbHelper getInstance() { return DbHelper.INSTANCE; } private BasicDataSource ds; private DbHelper() { } public void close() { if (ds != null) { DbHelper.LOGGER.debug("Closing the data source"); try { ds.close(); } catch (final SQLException e) { DbHelper.LOGGER.error("Failed to close the data source", e); } } } public DataSource getDataSource() { return ds; } public void init() { DbHelper.LOGGER.debug("Loading properties"); final Properties properties = new Properties(); properties.put("db.path", "target/db"); properties.put("db.username", "sa"); properties.put("db.password", ""); try { properties.load(getClass().getResourceAsStream("/app.properties")); } catch (final IOException e) { DbHelper.LOGGER.error("Failed to load the properties"); } DbHelper.LOGGER.debug("Creating the data source"); ds = new BasicDataSource(); ds.setDriverClassName("org.h2.Driver"); ds.setUrl("jdbc:h2:" + properties.getProperty("db.path")); ds.setUsername(properties.getProperty("db.username")); ds.setPassword(properties.getProperty("db.password")); DbHelper.LOGGER.debug("Executing Flyway (database migration)"); final Flyway flyway = new Flyway(); flyway.setDataSource(ds); flyway.migrate(); } public void registerShutdownHook() { Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { close(); } })); } }
[ "albertattard@gmail.com" ]
albertattard@gmail.com
f30ce2d0a405640e420537d699d2d6c17d47d288
092c76fcc6c411ee77deef508e725c1b8277a2fe
/hybris/bin/ext-platform-optional/platformwebservices/custom/src/de/hybris/platform/cronjob/customdto/CronJobDTO.java
cc6330d0d0cdb899a920b7a3d6406a9ce7f15155
[ "MIT" ]
permissive
BaggaShivanshu2/hybris-bookstore-tutorial
4de5d667bae82851fe4743025d9cf0a4f03c5e65
699ab7fd8514ac56792cb911ee9c1578d58fc0e3
refs/heads/master
2022-11-28T12:15:32.049256
2020-08-05T11:29:14
2020-08-05T11:29:14
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,368
java
/* * [y] hybris Platform * * Copyright (c) 2000-2016 SAP SE * All rights reserved. * * This software is the confidential and proprietary information of SAP * Hybris ("Confidential Information"). You shall not disclose such * Confidential Information and shall use it only in accordance with the * terms of the license agreement you entered into with SAP Hybris. */ package de.hybris.platform.cronjob.customdto; import de.hybris.platform.core.dto.ItemDTO; import de.hybris.platform.core.dto.c2l.CurrencyDTO; import de.hybris.platform.core.dto.c2l.LanguageDTO; import de.hybris.platform.core.dto.user.UserDTO; import de.hybris.platform.cronjob.dto.JobDTO; import de.hybris.platform.cronjob.model.CronJobModel; import de.hybris.platform.webservices.model.nodefactory.GenericNodeFactory; import de.hybris.platform.webservices.objectgraphtransformer.HybrisEnumValueToStringConverter; import de.hybris.platform.webservices.objectgraphtransformer.StringToHybrisEnumValueConverter; import de.hybris.platform.webservices.util.objectgraphtransformer.GraphNode; import de.hybris.platform.webservices.util.objectgraphtransformer.GraphProperty; import java.util.HashSet; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; @GraphNode(target = CronJobModel.class, factory = GenericNodeFactory.class, uidProperties = "code") @XmlRootElement(name = "cronjob") public class CronJobDTO extends ItemDTO { protected final Set<String> modifiedPropsSet = new HashSet<String>(); // unique attributes private String code = null; // primitive attributes private Boolean logToDatabase = null; private Boolean logToFile = null; private String emailAddress = null; private String timeTable = null; private Boolean requestAbort = null; private Boolean changeRecordingEnabled = null; private Integer nodeID = null; private Boolean singleExecutable = null; private Boolean removeOnExit = null; private String logText = null; private Boolean requestAbortStep = null; private Integer priority = null; private Boolean active = null; // references private UserDTO sessionUser = null; private CurrencyDTO sessionCurrency = null; private LanguageDTO sessionLanguage = null; // refers string private String status = null; //CronJobStatus private String logLevelFile = null; //JobLogLevel private String result = null; //CronJobResult //private String job = null; //JobModel private JobDTO job = null; //JobModel private String logLevelDatabase = null; //JobLogLevel private String errorMode = null; // ErrorMode @XmlAttribute public String getCode() { return code; } public Boolean getLogToDatabase() { return logToDatabase; } public Boolean getLogToFile() { return logToFile; } public String getEmailAddress() { return emailAddress; } public String getTimeTable() { return timeTable; } public Boolean getRequestAbort() { return requestAbort; } public Boolean getChangeRecordingEnabled() { return changeRecordingEnabled; } public Integer getNodeID() { return nodeID; } public Boolean getSingleExecutable() { return singleExecutable; } public Boolean getRemoveOnExit() { return removeOnExit; } public String getLogText() { return logText; } public Boolean getRequestAbortStep() { return requestAbortStep; } public Integer getPriority() { return priority; } public Boolean getActive() { return active; } public UserDTO getSessionUser() { return sessionUser; } public CurrencyDTO getSessionCurrency() { return sessionCurrency; } public LanguageDTO getSessionLanguage() { return sessionLanguage; } @GraphProperty(interceptor = StringToHybrisEnumValueConverter.class) public String getStatus() { return status; } @GraphProperty(interceptor = StringToHybrisEnumValueConverter.class) public String getLogLevelFile() { return logLevelFile; } @GraphProperty(interceptor = StringToHybrisEnumValueConverter.class) public String getResult() { return result; } // @GraphProperty(interceptor = StringToJobModelConverter.class) // public String getJob() // { // return job; // } public JobDTO getJob() { return this.job; } @GraphProperty(interceptor = StringToHybrisEnumValueConverter.class) public String getLogLevelDatabase() { return logLevelDatabase; } @GraphProperty(interceptor = StringToHybrisEnumValueConverter.class) public String getErrorMode() { return errorMode; } public void setCode(final String code) { this.modifiedPropsSet.add("code"); this.code = code; } public void setLogToDatabase(final Boolean logToDatabase) { this.modifiedPropsSet.add("logToDatabase"); this.logToDatabase = logToDatabase; } public void setLogToFile(final Boolean logToFile) { this.modifiedPropsSet.add("logToFile"); this.logToFile = logToFile; } public void setEmailAddress(final String emailAddress) { this.modifiedPropsSet.add("emailAddress"); this.emailAddress = emailAddress; } public void setTimeTable(final String timeTable) { this.modifiedPropsSet.add("timeTable"); this.timeTable = timeTable; } public void setRequestAbort(final Boolean requestAbort) { this.modifiedPropsSet.add("requestAbort"); this.requestAbort = requestAbort; } public void setChangeRecordingEnabled(final Boolean changeRecordingEnabled) { this.modifiedPropsSet.add("changeRecordingEnabled"); this.changeRecordingEnabled = changeRecordingEnabled; } public void setNodeID(final Integer nodeID) { this.modifiedPropsSet.add("nodeID"); this.nodeID = nodeID; } public void setSingleExecutable(final Boolean singleExecutable) { this.modifiedPropsSet.add("singleExecutable"); this.singleExecutable = singleExecutable; } public void setRemoveOnExit(final Boolean removeOnExit) { this.modifiedPropsSet.add("removeOnExit"); this.removeOnExit = removeOnExit; } public void setLogText(final String logText) { this.modifiedPropsSet.add("logText"); this.logText = logText; } public void setRequestAbortStep(final Boolean requestAbortStep) { this.modifiedPropsSet.add("requestAbortStep"); this.requestAbortStep = requestAbortStep; } public void setPriority(final Integer priority) { this.modifiedPropsSet.add("priority"); this.priority = priority; } public void setActive(final Boolean active) { this.modifiedPropsSet.add("active"); this.active = active; } public void setSessionUser(final UserDTO sessionUser) { this.modifiedPropsSet.add("sessionUser"); this.sessionUser = sessionUser; } public void setSessionCurrency(final CurrencyDTO sessionCurrency) { this.modifiedPropsSet.add("sessionCurrency"); this.sessionCurrency = sessionCurrency; } public void setSessionLanguage(final LanguageDTO sessionLanguage) { this.modifiedPropsSet.add("sessionLanguage"); this.sessionLanguage = sessionLanguage; } @GraphProperty(interceptor = HybrisEnumValueToStringConverter.class) public void setStatus(final String status) { this.modifiedPropsSet.add("status"); this.status = status; } @GraphProperty(interceptor = HybrisEnumValueToStringConverter.class) public void setResult(final String result) { this.modifiedPropsSet.add("result"); this.result = result; } // @GraphProperty(interceptor = JobModelToStringConverter.class) // public void setJob(final String job) // { // this.modifiedPropsSet.add("job"); // this.job = job; // } //@GraphProperty(interceptor = JobModelToStringConverter.class) public void setJob(final JobDTO job) { this.modifiedPropsSet.add("job"); this.job = job; } @GraphProperty(interceptor = HybrisEnumValueToStringConverter.class) public void setLogLevelFile(final String logLevelFile) { this.modifiedPropsSet.add("logLevelFile"); this.logLevelFile = logLevelFile; } @GraphProperty(interceptor = HybrisEnumValueToStringConverter.class) public void setLogLevelDatabase(final String logLevelDatabase) { this.modifiedPropsSet.add("logLevelDatabase"); this.logLevelDatabase = logLevelDatabase; } @GraphProperty(interceptor = HybrisEnumValueToStringConverter.class) public void setErrorMode(final String errorMode) { this.modifiedPropsSet.add("errorMode"); this.errorMode = errorMode; } @Override public Set<String> getModifiedProperties() { return this.modifiedPropsSet; } }
[ "xelilim@hotmail.com" ]
xelilim@hotmail.com
c8603c9e47f101cd597ace5da4f29acc717a8ea6
5455cb795588916e525be7f91d5203e59b4380ea
/tools/core/src/main/java/org/jboss/mapper/camel/config/SamplingDefinition.java
a014ac07e5b0c202497ef2ca58fd6bf82d4becd2
[ "Apache-2.0" ]
permissive
jewzaam/data-mapper
cb4d893e3125dc90474bef2ac56d8dd93ba9dd54
fb055312e5f484a4e3c8f3b190c91dfc046cd5c0
refs/heads/master
2021-01-17T01:50:24.998582
2014-12-18T22:00:38
2014-12-18T22:00:38
28,236,129
0
0
null
null
null
null
UTF-8
Java
false
false
3,149
java
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2014.11.26 at 02:37:57 PM EST // package org.jboss.mapper.camel.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for samplingDefinition complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="samplingDefinition"> * &lt;complexContent> * &lt;extension base="{http://camel.apache.org/schema/spring}output"> * &lt;sequence> * &lt;/sequence> * &lt;attribute name="samplePeriod" type="{http://www.w3.org/2001/XMLSchema}long" /> * &lt;attribute name="messageFrequency" type="{http://www.w3.org/2001/XMLSchema}long" /> * &lt;attribute name="units" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;anyAttribute processContents='skip' namespace='##other'/> * &lt;/extension> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "samplingDefinition") public class SamplingDefinition extends Output { @XmlAttribute(name = "samplePeriod") protected Long samplePeriod; @XmlAttribute(name = "messageFrequency") protected Long messageFrequency; @XmlAttribute(name = "units") protected String units; /** * Gets the value of the samplePeriod property. * * @return * possible object is * {@link Long } * */ public Long getSamplePeriod() { return samplePeriod; } /** * Sets the value of the samplePeriod property. * * @param value * allowed object is * {@link Long } * */ public void setSamplePeriod(Long value) { this.samplePeriod = value; } /** * Gets the value of the messageFrequency property. * * @return * possible object is * {@link Long } * */ public Long getMessageFrequency() { return messageFrequency; } /** * Sets the value of the messageFrequency property. * * @param value * allowed object is * {@link Long } * */ public void setMessageFrequency(Long value) { this.messageFrequency = value; } /** * Gets the value of the units property. * * @return * possible object is * {@link String } * */ public String getUnits() { return units; } /** * Sets the value of the units property. * * @param value * allowed object is * {@link String } * */ public void setUnits(String value) { this.units = value; } }
[ "kbabo@redhat.com" ]
kbabo@redhat.com
f8a79d9ee2281c37edccae3cc58aaf8e3facd04e
e859887b747f955c09d1f199639dc9c8636b19b9
/src/main/java/com/example/demo/controller/ActionController.java
5769074eb60f9b07f636b95e82d837163e4b0e81
[]
no_license
lanxiaozhu/swagger
6a20e106bc95ebbe21e1fe17c065a5f5b0a2fb59
358b60c1008c311e1f11b2e903cad2bc416d7800
refs/heads/master
2021-06-09T19:48:56.590825
2021-04-13T15:01:20
2021-04-13T15:01:20
146,388,880
0
0
null
null
null
null
UTF-8
Java
false
false
2,281
java
package com.example.demo.controller; import com.alibaba.fastjson.JSONObject; import com.example.demo.bean.User; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.HashMap; import java.util.Map; @RestController @RequestMapping(value="/users") // 通过这里配置使下面的映射都在/users下,可去除 public class ActionController { static Map<Long, User> users = Collections.synchronizedMap(new HashMap<Long, User>()); @ResponseBody @RequestMapping(value = "/updatePassword",method = RequestMethod.POST) //API增加说明 @ApiOperation(value="修改用户密码", notes="根据用户id修改密码") /** * 参数增加说明 * @Param name @Value value * required 是否必填 * dataType 数据类型 */ @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "Integer"), @ApiImplicitParam(name = "password", value = "旧密码", required = true, dataType = "String"), @ApiImplicitParam(name = "newPassword", value = "新密码", required = true, dataType = "String") }) public String updatePassword(@RequestParam(value="userId") Integer userId, @RequestParam(value="password") String password, @RequestParam(value="newPassword") String newPassword){ if(userId <= 0 || userId > 2){ return "sss"; } if(StringUtils.isEmpty(password) || StringUtils.isEmpty(newPassword)){ return "sss"; } if(password.equals(newPassword)){ return "ssa"; } return "sss!"; } @ApiOperation(value="创建用户", notes="根据User对象创建用户") @ApiImplicitParam(name = "user", value = "用户详细实体user", required = true, dataType = "User") @RequestMapping(value="", method=RequestMethod.POST) public String postUser(@RequestBody User user) { users.put(user.getId(), user); return "success"; } }
[ "932874056@qq.com" ]
932874056@qq.com
25b4851ef358f1f002367f261b872e7e4dbc81ba
81e3b9e43628e2224110056590348610ab88364b
/src/com/hamologist/leetcode/medium/kth_smallest_element_in_a_bst/Main.java
00414a98db870b2dafe1c4d9d2769b819f70cb9e
[]
no_license
hamologist/leetcode-solutions-java
17512ea11d7563c92b9ac767058d16bc62b1cf5a
a1ca443b488e54709d10f1e631be81e5363ce73e
refs/heads/master
2023-07-26T14:14:36.199965
2021-09-05T17:31:49
2021-09-05T17:31:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,287
java
package com.hamologist.leetcode.medium.kth_smallest_element_in_a_bst; import com.hamologist.leetcode.shared.TreeNode; public class Main { public static void main(String[] args) { Solution solution = new Solution(); System.out.println(solution.kthSmallest(new TreeNode( 3, new TreeNode( 1, null, new TreeNode(2) ), new TreeNode(4) ), 1)); } } class Solution { public int kthSmallest(TreeNode root, int k) { return Inner.solve(root, k); } private static class Inner { int count; int k; int ans; Inner(int k) { count = 0; this.k = k; ans = 0; } void kthSmallest(TreeNode root) { if (root == null) { return; } kthSmallest(root.left); if (count < k) { count += 1; ans = root.val; } kthSmallest(root.right); } static int solve(TreeNode root, int k) { Inner inner = new Inner(k); inner.kthSmallest(root); return inner.ans; } } }
[ "hamologist@gmail.com" ]
hamologist@gmail.com
8731c1f1150465777e33465463a69c9f8fbf83e6
c45372b087eca044073a47aadefa637e3eda82c0
/src/main/java/enums/productEnums/ProductTypeEnum.java
7ed92d4b43aa52999fcc8654b81935d2637fa8b6
[]
no_license
OleksiyH/CalibratorATQC
1ff9cd923c70bb8f13d23457a7c1ffd080589bd7
4ac2fcbcbb4d9f4355a65110b168207113f1f9a5
refs/heads/master
2016-09-13T07:45:56.559500
2016-04-29T20:41:13
2016-04-29T20:41:13
57,290,634
0
0
null
null
null
null
UTF-8
Java
false
false
894
java
package enums.productEnums; /** * Created by Oleksiy on 23.04.2016. */ public enum ProductTypeEnum { AUTO_RENEW("0"), NON_RENEWED("1"), //TODO "For trial product, Conversion product is required" - figure out what is conversion product or leave TRIAL commented //TODO Update: Trial type can be selected, if Trial Print Type is selected.... no need for Conversion product then TRIAL("3"), GIFT("4"), GIFT_BUNDLE("5"); private final String value; ProductTypeEnum(String value) { this.value = value; } public String getValue() { return value; } public static ProductTypeEnum get(String value) { ProductTypeEnum anEnum = null; for (ProductTypeEnum colour : ProductTypeEnum.values()) { if (colour.getValue().equals(value)) anEnum = colour; } return anEnum; } }
[ "oleksiy.havrylyuk@gmail.com" ]
oleksiy.havrylyuk@gmail.com
5d57546fb81d0cce41ebb58eab09a998a267674a
70bd23821a168c5dfba4938b2fff67185f54a12e
/manager/src/main/java/com/manager/manager/model/SysPermission.java
682c079f35ae434268682fd7701fd55e2428b81a
[]
no_license
zrc19980929/Manager
807f6b5eabddc2ab5c98289ff8d655e55339435d
c73348eceede98c19dddceb266a894411531bfd1
refs/heads/master
2022-07-03T05:31:19.794573
2020-03-06T04:12:16
2020-03-06T04:25:18
245,328,865
0
0
null
2022-06-17T02:55:38
2020-03-06T04:20:15
Java
UTF-8
Java
false
false
708
java
package com.manager.manager.model; import lombok.Data; import java.util.List; @Data public class SysPermission extends BaseEntity<Integer> { private static final long serialVersionUID = -6525908145032868837L; private Integer parentId; private String name; private String css; private String href; private Integer type; private String permission; private Integer sort; private List<SysPermission> child; @Override public String toString() { return "SysPermission{" + "parentId=" + parentId + ", name='" + name + '\'' + ", css='" + css + '\'' + ", href='" + href + '\'' + ", type=" + type + ", permission='" + permission + '\'' + ", sort=" + sort + '}'; } }
[ "879825487@qq.com" ]
879825487@qq.com
1114a2e13c35e152f306ff42bfc205ac39c21d7c
846a7668ac964632bdb6db639ab381be11c13b77
/android/packages/apps/Settings/src/com/android/settings/DisplaySettings.java
8cfd0eee9134e65241105396518d7050a2551db2
[ "Apache-2.0" ]
permissive
BPI-SINOVOIP/BPI-A64-Android8
f2900965e96fd6f2a28ced68af668a858b15ebe1
744c72c133b9bf5d2e9efe0ab33e01e6e51d5743
refs/heads/master
2023-05-21T08:02:23.364495
2020-07-15T11:27:51
2020-07-15T11:27:51
143,945,191
2
0
null
null
null
null
UTF-8
Java
false
false
6,798
java
/* * Copyright (C) 2010 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.settings; import android.content.Context; import android.provider.SearchIndexableResource; import com.android.internal.hardware.AmbientDisplayConfiguration; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.display.AmbientDisplayPreferenceController; import com.android.settings.display.AutoBrightnessPreferenceController; import com.android.settings.display.AutoRotatePreferenceController; import com.android.settings.display.AwColorTemperaturePreferenceController; import com.android.settings.display.AwEnhanceModePreferenceController; import com.android.settings.display.AwHdmiPreferenceController; import com.android.settings.display.AwSmartBacklightPreferenceController; import com.android.settings.display.BrightnessLevelPreferenceController; import com.android.settings.display.CameraGesturePreferenceController; import com.android.settings.display.ColorModePreferenceController; import com.android.settings.display.FontSizePreferenceController; import com.android.settings.display.LiftToWakePreferenceController; import com.android.settings.display.NightDisplayPreferenceController; import com.android.settings.display.NightModePreferenceController; import com.android.settings.display.ScreenSaverPreferenceController; import com.android.settings.display.TapToWakePreferenceController; import com.android.settings.display.ThemePreferenceController; import com.android.settings.display.TimeoutPreferenceController; import com.android.settings.display.VrDisplayPreferenceController; import com.android.settings.display.WallpaperPreferenceController; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; import com.android.settingslib.core.AbstractPreferenceController; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.ArrayList; import java.util.List; public class DisplaySettings extends DashboardFragment { private static final String TAG = "DisplaySettings"; public static final String KEY_AUTO_BRIGHTNESS = "auto_brightness"; public static final String KEY_DISPLAY_SIZE = "screen_zoom"; private static final String KEY_SCREEN_TIMEOUT = "screen_timeout"; private static final String KEY_AMBIENT_DISPLAY = "ambient_display"; @Override public int getMetricsCategory() { return MetricsEvent.DISPLAY; } @Override protected String getLogTag() { return TAG; } @Override public void onAttach(Context context) { super.onAttach(context); mProgressiveDisclosureMixin.setTileLimit(4); } @Override protected int getPreferenceScreenResId() { return R.xml.display_settings; } @Override protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { return buildPreferenceControllers(context, getLifecycle()); } @Override protected int getHelpResource() { return R.string.help_uri_display; } private static List<AbstractPreferenceController> buildPreferenceControllers( Context context, Lifecycle lifecycle) { final List<AbstractPreferenceController> controllers = new ArrayList<>(); controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); controllers.add(new AutoRotatePreferenceController(context, lifecycle)); controllers.add(new CameraGesturePreferenceController(context)); controllers.add(new FontSizePreferenceController(context)); controllers.add(new LiftToWakePreferenceController(context)); controllers.add(new NightDisplayPreferenceController(context)); controllers.add(new NightModePreferenceController(context)); controllers.add(new ScreenSaverPreferenceController(context)); controllers.add(new AmbientDisplayPreferenceController( context, new AmbientDisplayConfiguration(context), KEY_AMBIENT_DISPLAY)); controllers.add(new TapToWakePreferenceController(context)); controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); controllers.add(new VrDisplayPreferenceController(context)); controllers.add(new WallpaperPreferenceController(context)); controllers.add(new ThemePreferenceController(context)); controllers.add(new BrightnessLevelPreferenceController(context, lifecycle)); controllers.add(new ColorModePreferenceController(context)); controllers.add(new AwHdmiPreferenceController(context)); controllers.add(new AwEnhanceModePreferenceController(context)); controllers.add(new AwSmartBacklightPreferenceController(context)); controllers.add(new AwColorTemperaturePreferenceController(context)); return controllers; } public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @Override public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled) { final ArrayList<SearchIndexableResource> result = new ArrayList<>(); final SearchIndexableResource sir = new SearchIndexableResource(context); sir.xmlResId = R.xml.display_settings; result.add(sir); return result; } @Override public List<String> getNonIndexableKeys(Context context) { List<String> keys = super.getNonIndexableKeys(context); keys.add(KEY_DISPLAY_SIZE); keys.add(WallpaperPreferenceController.KEY_WALLPAPER); keys.add(KEY_AMBIENT_DISPLAY); return keys; } @Override public List<AbstractPreferenceController> getPreferenceControllers(Context context) { return buildPreferenceControllers(context, null); } }; }
[ "mingxin.android@gmail.com" ]
mingxin.android@gmail.com
055ac5b0b6c49b6bacdc02492f290421c53a679d
1c35b0e07bddf304dd3c4f03d847db72936b2ea6
/src/main/java/github/com/dautofreitas/quiz/rest/dto/RespostaDTO.java
e539ea22912e0a491092d0d1c861ef1ffff1c0ea
[]
no_license
dautofreitas/back-end-quiz
7a42c9ac156d199cd02dcbe9723c9b0621c718d3
4f960e38e5438036a5332827d44507821266f3c9
refs/heads/master
2022-11-21T00:35:51.276108
2020-07-21T03:11:45
2020-07-21T03:11:45
268,413,041
0
0
null
null
null
null
UTF-8
Java
false
false
673
java
package github.com.dautofreitas.quiz.rest.dto; public class RespostaDTO { private Integer id; private String titulo; private boolean correta; private boolean selecionada; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTitulo() { return titulo; } public void setTitulo(String titulo) { this.titulo = titulo; } public boolean getCorreta() { return correta; } public void setCorreta(boolean correta) { this.correta = correta; } public boolean getSelecionada() { return selecionada; } public void setSelecionada(boolean selecionada) { this.selecionada = selecionada; } }
[ "c0512913@globalvale.onmicrosoft.com" ]
c0512913@globalvale.onmicrosoft.com
2f77d2bca80e1889d5186db69340a04a08735ad7
efcf4caf8f49fda222ee79bc74152e783abf764d
/src/main/java/homeworks/hw6/ex1/HomePageGherkin.java
7ae63509b108c51aa8f3c510bd4c260db968defb
[]
no_license
cxqwer/ChebotarevAleksandr
8b8179404ec71c2dd262d0b4ebd969c2a86a6aea
aa69a585b0c26a1bbde3ffa780b239634ead6dea
refs/heads/master
2020-04-18T03:13:53.667347
2019-03-09T12:29:31
2019-03-09T12:29:31
167,191,467
1
1
null
2019-02-19T12:35:17
2019-01-23T13:53:15
Java
UTF-8
Java
false
false
3,783
java
package homeworks.hw6.ex1; import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import homeworks.hw3.enums.HomePageData; import homeworks.hw3.enums.Users; import homeworks.hw4.enums.SubcategoryData; import org.openqa.selenium.support.FindBy; import java.util.List; import java.util.stream.Collectors; import static com.codeborne.selenide.CollectionCondition.texts; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Condition.visible; import static com.codeborne.selenide.WebDriverRunner.getWebDriver; import static org.testng.Assert.assertEquals; public class HomePageGherkin { @FindBy(css = "[id='user-icon']") private SelenideElement loginIcon; @FindBy(css = "[id='name']") private SelenideElement userField; @FindBy(css = "[id='password']") private SelenideElement passwordField; @FindBy(css = "[id='login-button']") private SelenideElement submitButton; @FindBy(css = "[id='user-name']") private SelenideElement userName; @FindBy(css = "[class='benefit-icon']") private ElementsCollection pictures; @FindBy(css = "[class='benefit-txt']") private ElementsCollection picturesTexts; @FindBy(css = "[class='main-title text-center']") private SelenideElement headlineText; @FindBy(css = "[class='main-txt text-center']") private SelenideElement descriptionText; @FindBy(css = "[class='menu-title']") private ElementsCollection serviceOnLeftSection; @FindBy(css = "ul.uui-navigation.nav.navbar-nav.m-l8 li.dropdown") private SelenideElement serviceOnHeader; @FindBy(css = "[class='dropdown-menu'] li") private ElementsCollection dropDownService; @FindBy(css = "[class='sub'] li") private ElementsCollection dropDownServiceLeft; public void login(Users user) { loginIcon.click(); userField.sendKeys(user.login); passwordField.sendKeys(user.password); submitButton.click(); } public void checkTitle(HomePageData homePageTitle) { assertEquals(getWebDriver().getTitle(), homePageTitle.toString()); } public void checkUserIsLoggined(Users user) { userName.shouldHave(visible, text(user.name)); } public void checkElementsExists() { pictures.shouldHave(CollectionCondition.size(4)); for (SelenideElement picture : pictures) { picture.should(visible); } picturesTexts.shouldHave(CollectionCondition.size(4)); for (SelenideElement pictureText : picturesTexts) { pictureText.should(visible); } headlineText.should(visible); descriptionText.should(visible); } public void clickHeaderService() { serviceOnHeader.click(); } public void checkHeaderService(List<SubcategoryData> options) { dropDownService.shouldHaveSize(options.size()); List<String> expectedTexts = options.stream().map(SubcategoryData::toString).collect(Collectors.toList()); dropDownService.shouldHave(texts(expectedTexts)); } public void clickLeftService() { serviceOnLeftSection.get(0).click(); } public void checkLeftService(List<SubcategoryData> options) { dropDownServiceLeft.shouldHaveSize(options.size()); List<String> expectedTexts = options.stream().map(SubcategoryData::toString).collect(Collectors.toList()); dropDownServiceLeft.shouldHave(texts(expectedTexts)); } public void openPageInServiceOfHeader(SubcategoryData category) { dropDownService.get(category.getNumber()-1).click(); } // public void openUserTable() { // dropDownService.get(4).click(); // } }
[ "cxqwer@yandex.ru" ]
cxqwer@yandex.ru
82d73fa6994b746524d8c0cb74101d52636aa63e
1b7da32bf3bf44b7b7e205992a515e6ad2e5357d
/src/MemoryCardFunctions/src/main/java/io/theclouddeveloper/memorycards/di/DIModule.java
76203888e266bace77780c8342ae46034713f1f9
[]
no_license
Nxtra/Java-DynamoDB-enhanced-client
c7ab5392f56191d9df46982236ee58c91b90a0b6
537143fc29b43b62acef050a6dd01908c23bce79
refs/heads/master
2022-06-17T07:22:23.605689
2020-05-10T12:58:45
2020-05-10T12:58:45
257,988,768
1
0
null
null
null
null
UTF-8
Java
false
false
2,074
java
package io.theclouddeveloper.memorycards.di; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import dagger.Module; import dagger.Provides; import io.theclouddeveloper.memorycards.model.MemoryCard; import software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient; import software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable; import software.amazon.awssdk.enhanced.dynamodb.TableSchema; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import javax.inject.Named; import javax.inject.Singleton; @Module public class DIModule { @Provides @Named("Region") Region provideRegion(){ return System.getenv("REGION") != null ? Region.of(System.getenv("REGION")) : Region.of("us-east-1"); } @Provides @Named("TableName") String provideTableName(){ return System.getenv("TABLE_NAME"); } @Provides @Singleton @Named("MemoryCardTableSchema") TableSchema<MemoryCard> provideMemoryCardTableSchema(){ return TableSchema.fromBean(MemoryCard.class); } @Provides @Singleton DynamoDbClient provideDynamoDBClient(@Named("Region") Region region){ return DynamoDbClient.builder() .region(region) .build(); } @Provides @Singleton DynamoDbEnhancedClient provideDynamoDbEnhancedClient(DynamoDbClient dynamoDbClient){ return DynamoDbEnhancedClient.builder() .dynamoDbClient(dynamoDbClient) .build(); } @Provides @Singleton DynamoDbTable<MemoryCard> provideDynamoDbTable(DynamoDbEnhancedClient dynamoDbEnhancedClient, @Named("TableName") String tableName, @Named("MemoryCardTableSchema") TableSchema<MemoryCard> tableSchema ){ return dynamoDbEnhancedClient.table(tableName, tableSchema); } @Provides @Singleton Gson provideGson(){ return new GsonBuilder().create(); } }
[ "nickvanhoof1@gmail.com" ]
nickvanhoof1@gmail.com
3025128aaeec31dd65c30cbacd09c289e3844f0a
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/11/11_443e458362561d9689581c7e15794ce877dbe2fa/Program/11_443e458362561d9689581c7e15794ce877dbe2fa_Program_s.java
21139a38d17373ac5933656864be9f7a5d9d0360
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
6,164
java
/** * jcbnfp — A parser for JCBNF (Jacky's Compilable BNF) * * Copyright (C) 2012 Mattias Andrée <maandree@kth.se> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ package se.kth.maandree.jcbnfp; import java.util.*; import java.io.*; /** * This is the main entry point of the program * * @author Mattias Andrée, <a href="mailto:maandree@kth.se">maandree@kth.se</a> * @version 1.0 */ public class Program { /** * Forbidden constructor */ private Program() { assert false : "You may not create instances of this class."; } /** * This is the main entry point of the program * * @param args Command line arguments */ public static void main(final String... args) { final PrintStream stderr = System.err; final PrintStream stdout = System.out; final PrintStream devNull = new PrintStream(new OutputStream() { public void write(int b) { /* do nothing */ } }); final String jcbnfFile = args[0]; final String parseFile = args[1]; final String main = args[2]; InputStream gis = null, fis = null; try { System.setOut(devNull); System.setErr(devNull); System.out.println("--- Parsing Syntax ---\n\n"); gis = new BufferedInputStream(new FileInputStream(new File(jcbnfFile))); final HashMap<String, Definition> defs = GrammarParser.parseGrammar(gis); for (final Definition def : defs.values()) { printGrammar(def); System.out.println("\n"); } System.out.println("--- Parsing code ---\n\n"); final Parser parser = new Parser(defs, main); fis = new BufferedInputStream(new FileInputStream(new File(parseFile))); final ParseTree tree = parser.parse(fis); System.out.println("\n"); System.setOut(stdout); System.setErr(stderr); if (tree == null) System.out.println("===### Grammar did not match ###===\n\n"); else { System.out.println("--- Parsed code ---\n\n"); printTree(tree, parser.data); System.out.println("\n"); } } catch (final SyntaxFileError err) { System.err.println("ERROR: " + err.getMessage()); if (err.getCause() != null) err.getCause().printStackTrace(System.err); } catch (final UndefiniedDefinitionException err) { System.err.println("ERROR: " + err.getMessage()); } catch (final RuntimeException err) { System.err.print("ERROR: "); err.printStackTrace(System.err); } catch (final Throwable err) { System.err.println("---SYSTEM ERROR---"); err.printStackTrace(System.err); } finally { if (gis != null) try { gis.close(); } catch (final Throwable err) { //Ignore } if (fis != null) try { fis.close(); } catch (final Throwable err) { //Ignore } } } /** * Prints out a parsed tree * * @param tree The tree * @param data The parsed data * * @throws Exception Yay! */ public static void printTree(final ParseTree tree, final int[] data) throws Exception { final ArrayDeque<ParseTree> nodes = new ArrayDeque<ParseTree>(); final ArrayDeque<String> indents = new ArrayDeque<String>(); nodes.add(tree); indents.add(""); ParseTree node; while ((node = nodes.pollLast()) != null) { String indent = indents.pollLast(); System.err.print(indent); System.err.print(node.definition.definition); System.err.print(" :: ("); System.err.print(node.intervalStart); System.err.print(", "); System.err.print(node.intervalEnd - node.intervalStart); System.err.print(", "); System.err.print(node.intervalEnd); System.err.print(") \"\033[32m"); System.err.write(Escaper.escape(data, node.intervalStart, node.intervalEnd - node.intervalStart)); System.err.println("\033[39m\"\033[35m"); System.err.println(indent + "(:: " + node.definition.name + " ::)"); //node.definition.definition.printGrammar(indent + "::= "); System.err.print("\033[21;33m"); for (final int[] warning : node.definition.warnings) System.err.println(indent + "w-- " + Util.intArrayToString(warning)); for (final int[] warning : node.definition.uniques) System.err.println(indent + "w== " + Util.intArrayToString(warning)); System.err.print("\033[31m"); for (final int[] error : node.definition.oopses) System.err.println(indent + "<-- " + Util.intArrayToString(error)); System.err.print("\033[1m"); for (final int[] error : node.definition.panics) System.err.println(indent + "<== " + Util.intArrayToString(error)); System.err.print("\033[21;39m"); indent += " "; for (int i = node.children.size() - 1; i >= 0; i--) { nodes.offerLast(node.children.get(i)); indents.offerLast(indent); } } } /** * Prints out a definition * * @param definition The definition */ @SuppressWarnings({"rawtypes", "unchecked"}) public static void printGrammar(final Definition definition) { System.err.print(definition.toString()); System.out.println("(:: " + definition.name + " ::)"); if (definition.definition != null) definition.definition.printGrammar("::= "); if (definition.compiles != null) definition.compiles.printGrammar("==> "); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
7bced8825aa6dfc77c7d4dc11f4dc3f9eee24f80
4560dcc6564baea1b5e3f4b2e0cfa401a19b644f
/boardTest/src/main/java/com/springbook/biz/board/impl/BoardDAO.java
851e9d25984ee859216f40352c610d8213cb19a5
[]
no_license
taeheon1/SpringExam
4c11f5170aafb3aaca01c7065f4e5559c1b4cf05
8081a93d188d8c1366090b4571ac4d545cf36ccc
refs/heads/master
2022-10-19T03:36:46.790482
2020-06-12T09:30:09
2020-06-12T09:30:09
268,393,484
0
0
null
null
null
null
UTF-8
Java
false
false
3,788
java
package com.springbook.biz.board.impl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import org.springframework.stereotype.Repository; import com.springbook.biz.board.BoardVO; import com.springbook.biz.common.JDBCUtil; @Repository("boardDAO") public class BoardDAO { // JDBC 관련 변수 private Connection conn = null; private PreparedStatement stmt = null; private ResultSet rs = null; // SQL 명령어들 private final String BOARD_INSERT = "insert into board(seq, title, writer,content) values ((select nvl(max(seq), 0)+1 from board) ,?,?,?)"; private final String BOARD_UPDATE = "update board set title=?,content=? where seq=?"; private final String BOARD_DELETE = "delete board where seq=?"; private final String BOARD_GET = "select * from board where seq=?"; private final String BOARD_LIST = "select * from board order by seq desc"; // CRUD 기능의 메소드 구현 // 글 등록 public void insertBoard(BoardVO vo) { System.out.println("===> JDBC로 insertBoard() 기능 처리"); try { conn = JDBCUtil.getConnection(); stmt = conn.prepareStatement(BOARD_INSERT); stmt.setString(1, vo.getTitle()); stmt.setString(2, vo.getWriter()); stmt.setString(3, vo.getContent()); stmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtil.close(stmt, conn); } } // 글 수정 public void updateBoard(BoardVO vo) { System.out.println("===> JDBC로 updateBoard() 기능 처리"); try { conn = JDBCUtil.getConnection(); stmt = conn.prepareStatement(BOARD_UPDATE); stmt.setString(1, vo.getTitle()); stmt.setString(2, vo.getContent()); stmt.setInt(3, vo.getSeq()); stmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtil.close(stmt, conn); } } // 글 삭제 public void deleteBoard(BoardVO vo) { System.out.println("===> JDBC로 deleteBoard() 기능 처리"); try { conn = JDBCUtil.getConnection(); stmt = conn.prepareStatement(BOARD_DELETE); stmt.setInt(1, vo.getSeq()); stmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtil.close(stmt, conn); } } // 글 상세 조회 public BoardVO getBoard(BoardVO vo) { System.out.println("===> JDBC로 getBoard() 기능 처리"); BoardVO board = null; try { conn = JDBCUtil.getConnection(); stmt = conn.prepareStatement(BOARD_GET); stmt.setInt(1, vo.getSeq()); rs = stmt.executeQuery(); if(rs.next()) { board = new BoardVO(); board.setSeq(rs.getInt("SEQ")); board.setTitle(rs.getString("TITLE")); board.setWriter(rs.getString("WRITER")); board.setContent(rs.getString("CONTENT")); board.setRegDate(rs.getDate("REGDATE")); board.setCnt(rs.getInt("CNT")); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtil.close(rs, stmt, conn); } return board; } // 글 목록 조회 public List<BoardVO> getBoardList(BoardVO vo) { System.out.println("===> JDBC로 getBoardList() 기능 처리"); List<BoardVO> boardList = new ArrayList<BoardVO>(); try { conn = JDBCUtil.getConnection(); stmt = conn.prepareStatement(BOARD_LIST); rs = stmt.executeQuery(); while(rs.next()) { BoardVO board = new BoardVO(); board.setSeq(rs.getInt("SEQ")); board.setTitle(rs.getString("TITLE")); board.setWriter(rs.getString("WRITER")); board.setContent(rs.getString("CONTENT")); board.setRegDate(rs.getDate("REGDATA")); board.setCnt(rs.getInt("CNT")); boardList.add(board); } } catch (Exception e) { e.printStackTrace(); } finally { JDBCUtil.close(rs, stmt, conn); } return boardList; } }
[ "pengdoong95@gmail.com" ]
pengdoong95@gmail.com
8a746e69ac79566561d409b0e2aa8e4f7118b949
8e309eb1ccda3b4d788262fffeff9d3ad39dc7b7
/Presentation/src/main/java/com/pencorp/cleanarchitecture/UIThread.java
459b9cd251847d9d15a7073e3da12e7d6a931688
[]
no_license
Pentico/CleanArchitectureTemplate
9550c0f995c30e9fa9775105c7514afb6eedf5f1
22ccf129520d3210c3bceecfa006f1ca9a208753
refs/heads/master
2021-01-21T11:19:12.050172
2017-03-11T18:21:18
2017-03-11T18:21:18
83,555,601
0
0
null
null
null
null
UTF-8
Java
false
false
611
java
package com.pencorp.cleanarchitecture; /** * Created by Tuane on 5/03/17. */ import com.pencorp.domain.executor.PostExecutionThread; import javax.inject.Inject; import javax.inject.Singleton; import rx.Scheduler; import rx.android.schedulers.AndroidSchedulers; /** * MainThread (UI Thread) implementation based on a {@link rx.Scheduler} * which will execute actions on the Android UI thread */ @Singleton public class UIThread implements PostExecutionThread { @Inject public UIThread() {} @Override public Scheduler getScheduler() { return AndroidSchedulers.mainThread(); } }
[ "morulaneat@gmail.com" ]
morulaneat@gmail.com
35b8d82d314ca80a6e493224447b34c10aeebc70
0493ffe947dad031c7b19145523eb39209e8059a
/OpenJdk8uTest/src/test/sun/security/mscapi/AccessKeyStore.java
ae72d4fa99ee1ef6cf2b5c1c31405e101cf8fef7
[]
no_license
thelinh95/Open_Jdk8u_Test
7612f1b63b5001d1df85c1df0d70627b123de80f
4df362a71e680dbd7dfbb28c8922e8f20373757a
refs/heads/master
2021-01-16T19:27:30.506632
2017-08-13T23:26:05
2017-08-13T23:26:05
100,169,775
0
1
null
null
null
null
UTF-8
Java
false
false
5,705
java
package test.sun.security.mscapi; /* * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @see AccessKeyStore.sh */ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.Provider; import java.security.Security; import java.security.UnrecoverableKeyException; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.security.interfaces.RSAKey; import java.util.Enumeration; import sun.security.mscapi.Key; import sun.security.mscapi.KeyStore; import test.java.security.*; import test.java.security.cert.*; public class AccessKeyStore { public static void main(String[] args) throws Exception { // Check that a security manager has been installed if (System.getSecurityManager() == null) { throw new Exception("A security manager has not been installed"); } Provider p = Security.getProvider("SunMSCAPI"); System.out.println("SunMSCAPI provider classname is " + p.getClass().getName()); KeyStore keyStore = KeyStore.getInstance("Windows-MY", p); /* * If a SecurityManager exists then this will trigger a * SecurityException if the following permission has not * been granted: * * SecurityPermission("authProvider.SunMSCAPI") */ try { keyStore.load(null, null); if (args.length > 0 && "-deny".equals(args[0])) { throw new Exception( "Expected KeyStore.load to throw a SecurityException"); } } catch (SecurityException se) { if (args.length > 0 && "-deny".equals(args[0])) { System.out.println("Caught the expected exception: " + se); return; } else { throw se; } } int i = 0; for (Enumeration<String> e = keyStore.aliases(); e.hasMoreElements(); ) { String alias = e.nextElement(); displayEntry(keyStore, alias, i++); } } private static void displayEntry(KeyStore keyStore, String alias, int index) throws KeyStoreException, NoSuchAlgorithmException { if (keyStore.isKeyEntry(alias)) { System.out.println("[" + index + "]\n " + alias + " [key-entry]\n"); try { Key key = keyStore.getKey(alias, null); if (key instanceof RSAKey) { System.out.println(" Key type: " + key.getAlgorithm() + " (" + ((RSAKey)key).getModulus().bitLength() + " bit)\n"); } else { System.out.println(" Key type: " + key.getAlgorithm() + "\n"); } } catch (UnrecoverableKeyException e) { System.out.println(" Key type: Unknown\n"); } Certificate[] chain = keyStore.getCertificateChain(alias); if (chain != null) { System.out.println(" Certificate chain: "); for (int i = 0; i < chain.length; i ++) { System.out.println(" ["+ (i + 1) + "]"); displayCert(chain[i], " "); } } } else { System.out.println("[" + index + "]\n " + alias + " [trusted-cert-entry]\n"); Certificate[] chain = keyStore.getCertificateChain(alias); if (chain != null) { System.out.println(" Certificate chain: "); for (int i = 0; i < chain.length; i ++) { System.out.println(" ["+ (i + 1) + "]"); displayCert(chain[i], " "); } } } System.out.println("-------------------------------------------------"); } private static void displayCert(Certificate cert, String tab) { if (cert instanceof X509Certificate) { X509Certificate x = (X509Certificate) cert; System.out.println( tab + "Owner: " + x.getSubjectDN().toString() + "\n" + tab + "Issuer: " + x.getIssuerDN().toString() + "\n" + tab + "Serial number: " + x.getSerialNumber().toString(16) + "\n"+ tab + "Valid from: " + x.getNotBefore().toString() + "\n" + tab + " until: " + x.getNotAfter().toString()); } else { System.out.println(tab + "[unknown certificate format]"); } System.out.println(); } }
[ "truongthelinh95@gmail.com" ]
truongthelinh95@gmail.com
35639636667861331e0232f7282feed980d8e6f7
01700aba5c4a1cceeffbb7721a6c39ceb8e3bbce
/app/src/main/java/com/example/overseas_guide/usa.java
6f6fb78e858a86f1a3e298477ce623b71d604a08
[]
no_license
pavanxenon/Overseas_Guide
35915534878c615ecf8959d7ee7c49f31be49cb0
fa2836e83b6fcbd5a2906da8637ad063db123d06
refs/heads/master
2023-05-02T08:41:38.616325
2021-04-29T14:12:59
2021-04-29T14:12:59
362,838,632
0
0
null
null
null
null
UTF-8
Java
false
false
2,201
java
package com.example.overseas_guide; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class usa extends AppCompatActivity { private Button u1; private Button u2; private Button u3; private Button u4; private Button u5; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_usa); u1 = findViewById(R.id.u1); u2 = findViewById(R.id.u2); u3 = findViewById(R.id.u3); u4 = findViewById(R.id.u4); u5 = findViewById(R.id.u5); u1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent categoryIntent = new Intent(usa.this, usa1.class); startActivity(categoryIntent); finish(); } }); u2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent categoryIntent = new Intent(usa.this,usa2.class); startActivity(categoryIntent); finish(); } }); u3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent categoryIntent = new Intent(usa.this,usa3.class); startActivity(categoryIntent); finish(); } }); u4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent categoryIntent = new Intent(usa.this,usa4.class); startActivity(categoryIntent); finish(); } }); u5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent categoryIntent = new Intent(usa.this,usa5.class); startActivity(categoryIntent); finish(); } }); } }
[ "pavan.kumar.uspd@gmail.com" ]
pavan.kumar.uspd@gmail.com
5c7b65e70f2540683f9673dc38c8c9350a12b2b1
29106442e1cf9f4b8b8f4f509408063eeb7a3657
/app/src/main/java/com/smartlab/drivetrain/license/Result.java
411171bae35daef1af133a98c0d09c349643cd82
[ "Apache-2.0" ]
permissive
tempest1/ChinaDriveTrainingMobileAndroid
883740238892885b3b62bbcb43f6347738f847aa
bc7796cbc472470a1c1e4a4c3332822b1b1bdf8e
refs/heads/master
2020-05-30T14:17:54.575603
2016-09-22T06:39:54
2016-09-22T06:39:54
68,892,325
0
0
null
null
null
null
UTF-8
Java
false
false
542
java
package com.smartlab.drivetrain.license; import android.os.Bundle; import com.smartlab.drivetrain.base.BaseActivity; /** * Created by smartlab on 15/10/24. */ public class Result extends BaseActivity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //获取用户的分数使用,然后将其分数绘制到View上面 // setContentView(); } @Override protected void initData() { } @Override protected void initView() { } }
[ "505675592@qq.com" ]
505675592@qq.com
72a5488b7b5b6b119c21e8bd1bc759a1a5ec8c04
08c2837347889fb8a79e73bf653011105362635e
/src/13_ID_GUI_Database/backend/Buku1921743014Dhuta.java
d9f91b8dcdcf9994c43061a2bd75d9cbe0728b1e
[]
no_license
pamungkas93/prak.PBO.
64fe1ddfc90cf9244a1ecacc936ce805b38960a6
e3dfb5bb6c386dee3cc9acadd53040b8ac98c48a
refs/heads/master
2020-07-16T23:40:20.111231
2019-12-07T20:19:44
2019-12-07T20:19:44
205,892,709
0
0
null
null
null
null
UTF-8
Java
false
false
7,794
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package backend; import java.util.ArrayList; import java.sql.*; /** * * @author ASUS */ public class Buku1921743014Dhuta { private int idbuku; private Kategori1921743014Dhuta kategori = new Kategori1921743014Dhuta(); private String judul; private String penerbit; private String penulis; public int getIdbuku() { return idbuku; } public void setIdbuku(int idbuku) { this.idbuku = idbuku; } public Kategori1921743014Dhuta getKategori() { return kategori; } public void setKategori(Kategori1921743014Dhuta kategori) { this.kategori = kategori; } public String getJudul() { return judul; } public void setJudul(String judul) { this.judul = judul; } public String getPenerbit() { return penerbit; } public void setPenerbit(String penerbit) { this.penerbit = penerbit; } public String getPenulis() { return penulis; } public void setPenulis(String penulis) { this.penulis = penulis; } public Buku1921743014Dhuta() { } public Buku1921743014Dhuta(Kategori1921743014Dhuta kategori, String judul, String penerbit, String penulis) { this.kategori = kategori; this.judul = judul; this.penerbit = penerbit; this.penulis = penulis; } public Buku1921743014Dhuta getById(int id) { Buku1921743014Dhuta buku = new Buku1921743014Dhuta(); ResultSet rs = DBHelper1921743014Dhuta.selectQuery("SELECT " + " b.idbuku AS idbuku," + " b.judul AS judul," + " b.penerbit AS penerbit," + " b.penulis AS penulis," + " k.idkategori AS idkategori," + " k.nama AS nama," + " k.keterangan AS keterangan" + " FROM buku b" + " LEFT JOIN kategori k ON b.idkategori = k.idkategori" + " WHERE b.idbuku = '" + id + "'"); try { while(rs.next()) { buku = new Buku1921743014Dhuta(); buku.setIdbuku(rs.getInt("idbuku")); buku.getKategori().setIdKategori(rs.getInt("idkategori")); buku.getKategori().setNama(rs.getString("nama")); buku.getKategori().setKeterangan(rs.getString("keterangan")); buku.setJudul(rs.getString("judul")); buku.setPenerbit(rs.getString("penerbit")); buku.setPenulis(rs.getString("penulis")); } } catch (Exception e) { e.printStackTrace(); } return buku; } public ArrayList<Buku1921743014Dhuta> getAll() { ArrayList<Buku1921743014Dhuta> ListBuku = new ArrayList(); ResultSet rs = DBHelper1921743014Dhuta.selectQuery("SELECT " + " b.idbuku AS idbuku," + " b.judul AS judul," + " b.penerbit AS penerbit," + " b.penulis AS penulis," + " k.idkategori AS idkategori," + " k.nama AS nama," + " k.keterangan AS keterangan" + " FROM buku b" + " LEFT JOIN kategori k ON b.idkategori = k.idkategori"); try { while(rs.next()) { Buku1921743014Dhuta buku = new Buku1921743014Dhuta(); buku.setIdbuku(rs.getInt("idbuku")); buku.getKategori().setIdKategori(rs.getInt("idkategori")); buku.getKategori().setNama(rs.getString("nama")); buku.getKategori().setKeterangan(rs.getString("keterangan")); buku.setJudul(rs.getString("judul")); buku.setPenerbit(rs.getString("penerbit")); buku.setPenulis(rs.getString("penulis")); ListBuku.add(buku); } } catch (Exception e) { e.printStackTrace(); } return ListBuku; } public ArrayList<Buku1921743014Dhuta> search(String keyword) { ArrayList<Buku1921743014Dhuta> ListBuku = new ArrayList(); ResultSet rs = DBHelper1921743014Dhuta.selectQuery("SELECT " + " b.idbuku AS idbuku," + " b.judul AS judul," + " b.penerbit AS penerbit," + " b.penulis AS penulis," + " k.idkategori AS idkategori," + " k.nama AS nama," + " k.keterangan AS keterangan" + " FROM buku b" + " LEFT JOIN kategori k ON b.idkategori = k.idkategori" + " WHERE b.judul LIKE '%" + keyword + "%'" + " OR b.penerbit LIKE '%" + keyword + "%'" + " OR b.penulis LIKE '%" + keyword + "%'"); try { while(rs.next()) { Buku1921743014Dhuta buku = new Buku1921743014Dhuta(); buku.setIdbuku(rs.getInt("idbuku")); buku.getKategori().setIdKategori(rs.getInt("idkategori")); buku.getKategori().setNama(rs.getString("nama")); buku.getKategori().setKeterangan(rs.getString("keterangan")); buku.setJudul(rs.getString("judul")); buku.setPenerbit(rs.getString("penerbit")); buku.setPenulis(rs.getString("penulis")); ListBuku.add(buku); } } catch (Exception e) { e.printStackTrace(); } return ListBuku; } public void save() { if(getById(idbuku).getIdbuku() == 0) { String SQL = "INSERT INTO buku (judul, idkategori, penulis, penerbit) VALUES(" + "'" + this.judul + "', " + "'" + this.getKategori().getIdKategori() + "', " + "'" + this.penulis + "', " + "'" + this.penerbit + "'" + ")"; this.idbuku = DBHelper1921743014Dhuta.insertQueryGetId(SQL); } else { String SQL = "UPDATE buku SET" + " judul = '" + this.judul + "', " + " idkategori = '" + this.getKategori().getIdKategori() + "', " + " penulis = '" + this.penulis + "', " + " penerbit = '" + this.penerbit + "' " + " WHERE idbuku = '" + this.idbuku + "'"; DBHelper1921743014Dhuta.executeQuery(SQL); } } public void delete() { String SQL = "DELETE FROM buku WHERE idbuku = '" + this.idbuku + "'"; DBHelper1921743014Dhuta.executeQuery(SQL); } }
[ "dhutadhuta4@gmail.com" ]
dhutadhuta4@gmail.com
fd6a47ed7e33b61dab74cf088061fbd04720b047
450f0f8fb4fc6ad4328769c85dc51b0cc722a3af
/src/Lesson_08/page_232/Of76.java
918abc75b36df9c2f9c4e287e5fcea252028f58c
[]
no_license
menelaoszetas1990/Head_First-Java-Exceries
9f5d5fb31fcc5ed4f6ad338082b470e091a98077
7cae0522128189d2435886793e99698b5ec3777d
refs/heads/master
2021-01-21T10:46:11.742774
2017-09-05T14:43:35
2017-09-05T14:43:35
101,985,727
0
0
null
null
null
null
UTF-8
Java
false
false
345
java
package Lesson_08.page_232; class Of76 extends Clowns { public static void main (String[] args) { Nose[] i = new Nose[3]; i[0] = new Acts(); i[1] = new Clowns(); i[2] = new Of76(); for (int x = 0; x < 3; x++) { System.out.println(i[x].iMethod() + " " + i[x].getClass()); } } }
[ "menelaoszetas@gmail.com" ]
menelaoszetas@gmail.com
db666b29cdb026b5aea2080458be85819a4015d9
222168eb7495d16e4fdb697c2d965a6feee0c9ff
/src/zeszyt/Y.java
025e7482c328f02a7f9f608d035f92dbacccf629
[]
no_license
AsSoon/zeszyt
9b8fde30ea4bd5acbf4c697067d980889cf904b0
bdf3a5a3d91695764505ce4ad61da3ae9fb1a129
refs/heads/master
2016-09-06T04:40:00.919403
2015-04-22T17:10:08
2015-04-22T17:10:08
33,821,241
0
0
null
2015-04-20T18:21:14
2015-04-12T15:01:12
Java
UTF-8
Java
false
false
70
java
package zeszyt; public interface Y { public void myMethod(); }
[ "absinthic@gmail.com" ]
absinthic@gmail.com
69948b61dd7b26193a44fd9f916c7eee574b5e37
dd6ebebb4bca3165d2b29f80bb76875c3b25f921
/src/main/java/com/tidepool/api/authentication/AccountService.java
b40e9445fbe14bae59e22661fe2a16969f32e01d
[]
no_license
tidepool/api-old
5c48344c6f328b2b41147afb790612ccd35e512a
dacb2f8f6842ccb06e22af1c7c5b4f56a0511b2d
refs/heads/master
2020-04-12T19:29:37.716536
2012-12-10T21:51:01
2012-12-10T21:51:01
5,969,589
0
0
null
null
null
null
UTF-8
Java
false
false
594
java
package com.tidepool.api.authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import com.tidepool.api.model.Account; public class AccountService { public Account getAccount() { if (SecurityContextHolder.getContext().getAuthentication() != null) { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof UserDetails) { return ((Account)principal); } else { return null; } } return null; } }
[ "jshoop@quantbench.com" ]
jshoop@quantbench.com
38f9baf9499a17ef80b6e380f52687069f8f749a
7b0e4598bdd084ee1f77418168cc97fe76739be2
/November2020Selenium/src/MukeshOtwaniActionClass/MouseHover.java
1a894021376a4af221a380051c422a9fda04eaec
[]
no_license
SagarRajendraGujar/Bappa
7096241e70bd66fdfb37669936a9c774f26a3afd
c7995a4713d99bbaae04653797367571f6be55a7
refs/heads/main
2023-08-28T23:00:21.514777
2021-10-14T07:58:10
2021-10-14T07:58:10
415,100,165
0
0
null
null
null
null
UTF-8
Java
false
false
1,352
java
package MukeshOtwaniActionClass; import java.io.IOException; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; public class MouseHover extends BaseTest { public static void main(String[] args) throws IOException, InterruptedException { init(); launch("chromebrowser"); navigateUrl("mousehoverurl"); //driver.get("http://seleniumpractise.blogspot.in/2016/08/how-to-perform-mouse-hover-in-selenium.html"); WebElement element=driver.findElement(By.cssSelector("body.variant-bold:nth-child(2) div.content:nth-child(3) div.content-outer div.fauxborder-left.content-fauxborder-left div.content-inner div.main-outer:nth-child(3) div.fauxborder-left.main-fauxborder-left div.region-inner.main-inner div.columns.fauxcolumns div.columns-inner:nth-child(4) div.column-center-outer div.column-center-inner div.main.section div.widget.Blog div.blog-posts.hfeed div.date-outer div.date-posts div.post-outer div.post.hentry.uncustomized-post-template div.post-body.entry-content:nth-child(6) div:nth-child(1) div.dropdown:nth-child(3) > button.dropbtn:nth-child(1)")); Actions act=new Actions(driver); act.moveToElement(element).perform(); Thread.sleep(5000); } }
[ "sagargujar2511@gmail.com" ]
sagargujar2511@gmail.com
3f403a99fb446056573b5d6e481557c86adc2e03
83b32890a07c413271339dbc5ee9fd87a4ceb53c
/src/vista/PanelInicio.java
97f679413706a5751b273c6fa6d3dc7ef8304085
[]
no_license
larremano/thebighandtheory
f3413f406a8b5531f2245167854e6098651f209f
ab097caf47ae4cbea24a0b95208a93baeb552131
refs/heads/master
2020-04-25T11:57:36.747920
2013-02-24T16:26:16
2013-02-24T16:26:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,464
java
package vista; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import modelo.Fecha; public class PanelInicio extends JPanel { private static final long serialVersionUID = 1L; private ControladorVentana cv = null; private JPanel jPBotonera = null; private JPanel jPCampos = null; private JLabel jLFechaActual = null; private JLabel jLabel = null; private JButton jBNuevoContacto = null; private JButton jBVerContactos = null; private JButton jBNuevaCita = null; public PanelInicio(ControladorVentana cv) { super(); this.cv = cv; initialize(); } private void initialize() { BorderLayout borderLayout = new BorderLayout(); this.setLayout(borderLayout); this.setSize(new Dimension(650, 200)); this.add(getJPCampos(), BorderLayout.NORTH); this.add(getJPBotonera(), BorderLayout.SOUTH); jLFechaActual.setText(Fecha.fechaActual()); } private JPanel getJPBotonera() { if (jPBotonera == null) { GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); gridBagConstraints8.insets = new Insets(20, 20, 20, 20); gridBagConstraints8.gridy = 0; gridBagConstraints8.gridx = 2; GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); gridBagConstraints7.gridx = 1; gridBagConstraints7.insets = new Insets(20, 20, 20, 20); gridBagConstraints7.gridy = 0; GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); gridBagConstraints6.gridx = 0; gridBagConstraints6.insets = new Insets(20, 20, 20, 20); gridBagConstraints6.gridy = 0; jPBotonera = new JPanel(); jPBotonera.setLayout(new GridBagLayout()); jPBotonera.add(getJBNuevoContacto(), gridBagConstraints6); jPBotonera.add(getJBVerContactos(), gridBagConstraints7); jPBotonera.add(getJBNuevaCita(), gridBagConstraints8); } return jPBotonera; } private JPanel getJPCampos() { if (jPCampos == null) { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.insets = new Insets(10, 20, 10, 20); gridBagConstraints1.gridy = 0; jLFechaActual = new JLabel(); jLFechaActual.setText("JLabel"); jLFechaActual.setFont(new Font("Dialog", Font.BOLD, 24)); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.insets = new Insets(10, 20, 10, 20); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.gridy = 0; jLabel = new JLabel(); jLabel.setText("Hoy es:"); jLabel.setFont(new Font("Dialog", Font.BOLD, 24)); jPCampos = new JPanel(); jPCampos.setLayout(new GridBagLayout()); jPCampos.add(jLabel, gridBagConstraints); jPCampos.add(jLFechaActual, gridBagConstraints1); } return jPCampos; } private JButton getJBNuevoContacto() { if (jBNuevoContacto == null) { jBNuevoContacto = new JButton(); jBNuevoContacto.setText("Nuevo Contacto"); jBNuevoContacto .addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { nuevoContacto(); } }); } return jBNuevoContacto; } protected void nuevoContacto() { cv.crearPanelContactoNuevo(); } private JButton getJBVerContactos() { if (jBVerContactos == null) { jBVerContactos = new JButton(); jBVerContactos.setText("Ver Contactos"); jBVerContactos .addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { verContactos(); } }); } return jBVerContactos; } protected void verContactos() { cv.crearPanelListarContactos(); } private JButton getJBNuevaCita() { if (jBNuevaCita == null) { jBNuevaCita = new JButton(); jBNuevaCita.setText("Nueva Cita"); jBNuevaCita.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { nuevaCita(); } }); } return jBNuevaCita; } protected void nuevaCita() { } }
[ "larremano@gmail.com" ]
larremano@gmail.com
1589abf0ba37d6b617975945abe22b5495bbf17d
640f1729b931c856ff1b13c39dbdca168b0bb2f8
/axel-web/src/main/java/org/xmlactions/pager/actions/menu/SubMenu.java
928262483b861beb0101e12a87da674d7569c59e
[ "Apache-2.0" ]
permissive
mwjmurphy/Axel-Framework
469ad68d1c1ec9dd0d9967e946dbab36764e412f
2b58769c48d642a6d3f24ec0622e87f2118ecef4
refs/heads/master
2022-12-23T18:57:02.359663
2020-05-05T13:46:21
2020-05-05T13:46:21
41,671,109
3
1
Apache-2.0
2022-12-16T00:44:51
2015-08-31T11:08:16
Roff
UTF-8
Java
false
false
3,053
java
package org.xmlactions.pager.actions.menu; import java.util.List; import org.xmlactions.action.config.IExecContext; import org.xmlactions.common.theme.Theme; import org.xmlactions.pager.actions.form.ThemeConst; import org.xmlactions.pager.actions.form.templates.Html; import org.xmlactions.pager.actions.form.templates.HtmlDiv; import org.xmlactions.pager.actions.form.templates.HtmlTable; public class SubMenu { private String id; private String position; private String left; private String top; private String bottom; private String right; private String width; private String height; private List<SubMenuItem> subMenuItems; //<div id="home.menu" style="position: fixed; left: 220px; display:none" onmouseout="hide('home.menu')"> //<table class="table sub_menu" width="100px"> // <tr class="menu-font" onclick="show('about_us.menu')"> // <td align="left"><img src="css/chrome-logo.png" height="12"/></td> // <td align="left">one</td> // </tr> public Html mapToHtml(IExecContext execContext, Theme theme, String zindex) { HtmlDiv div = new HtmlDiv(); div.setId(id); StringBuilder sb = new StringBuilder(); if (position != null) {sb.append("position:" + position + ";");} if (left != null) { sb.append("left:" + left + ";");} if (top != null) {sb.append("top:" + top + ";");} if (bottom != null) {sb.append("bottom:" + bottom + ";");} if (right != null) {sb.append("right:" + right + ";");} if (zindex != null) {sb.append("z-index:" + zindex + ";");} sb.append("display:none;"); div.setStyle(sb.toString()); div.setOnMouseOut("hide('" + id + "')"); HtmlTable table = div.addTable(); table.setClazz(theme.getValue(ThemeConst.SUBMENU.toString())); if (width != null) {table.setWidth(width);} if (subMenuItems != null) { for (SubMenuItem subMenuItem : subMenuItems ) { Html tr = subMenuItem.mapToHtml(execContext, theme, zindex); table.addChild(tr); } } return div; } public void setSubMenuItems(List<SubMenuItem> subMenuItems) { this.subMenuItems = subMenuItems; } public List<SubMenuItem> getSubMenuItems() { return subMenuItems; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } public String getLeft() { return left; } public void setLeft(String left) { this.left = left; } public String getTop() { return top; } public void setTop(String top) { this.top = top; } public String getBottom() { return bottom; } public void setBottom(String bottom) { this.bottom = bottom; } public String getRight() { return right; } public void setRight(String right) { this.right = right; } public String getWidth() { return width; } public void setWidth(String width) { this.width = width; } public void setId(String id) { this.id = id; } public String getId() { return id; } }
[ "mike.murphy@travelsmart.co.uk" ]
mike.murphy@travelsmart.co.uk
381210fa254c50beaf036a9981fd9d176e805542
56ede60dac669bc7c9b8e777447de4029c0209bf
/Banking/src/Main.java
2b51ffba81dcb5f8c0c3f88c003ed3fa06c0b647
[]
no_license
yangzc23/testin
6386548921e78774b9456cd8346745cbcdd5396c
fa4ad1fef0cd0d97f8f93486df641e26fc2f0a3e
refs/heads/master
2020-03-29T21:06:13.762267
2018-11-24T05:14:34
2018-11-24T05:14:34
150,349,692
1
0
null
null
null
null
UTF-8
Java
false
false
1,416
java
import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet({"/Main"}) public class Main extends HttpServlet { private static final long serialVersionUID = 1L; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String turnPage = (String)request.getAttribute("turnPage"); String user = request.getParameter("user"); String pass = request.getParameter("pass"); Verifying vf = new Verifying(); vf.setPass(pass); vf.setUser(user); request.setAttribute("Verifying", Boolean.valueOf(vf.isVerifiying())); if (vf.isVerifiying()) { if (("/Main".equals(turnPage)) && (vf.isVerifiying())) { request.getRequestDispatcher("/main.jsp").forward(request, response); } } else { out.println("<script type=\"text/javascript\">"); out.println("alert(\"用户名或密码错误,请重新登陆!\")"); out.println("window.location.href=\"/Banking/index.html\";"); out.println("</script>"); } out.flush(); out.close(); } }
[ "testin123" ]
testin123
49165bdfc5af43d965500a39bfa51ffdc946b0c1
a10cb46de27156b1f7803ede2111188be94bbee8
/android/app/src/debug/java/com/nectars_28450/ReactNativeFlipper.java
8b9204fc13012d37bd60446890543ad3c280e617
[]
no_license
crowdbotics-apps/nectars-28450
76efecce2ba21173dda1b8748256b1dd5e2be13a
fb330ba7aa7288387aaccfe0a91bb1ce909868ae
refs/heads/master
2023-06-06T16:53:03.740768
2021-07-05T05:21:49
2021-07-05T05:21:49
383,022,117
0
0
null
null
null
null
UTF-8
Java
false
false
3,268
java
/** * Copyright (c) Facebook, Inc. and its affiliates. * * <p>This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ package com.nectars_28450; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; import com.facebook.flipper.android.utils.FlipperUtils; import com.facebook.flipper.core.FlipperClient; import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; import com.facebook.flipper.plugins.inspector.DescriptorMapping; import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; import com.facebook.flipper.plugins.react.ReactFlipperPlugin; import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; import com.facebook.react.ReactInstanceManager; import com.facebook.react.bridge.ReactContext; import com.facebook.react.modules.network.NetworkingModule; import okhttp3.OkHttpClient; public class ReactNativeFlipper { public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { if (FlipperUtils.shouldEnableFlipper(context)) { final FlipperClient client = AndroidFlipperClient.getInstance(context); client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); client.addPlugin(new ReactFlipperPlugin()); client.addPlugin(new DatabasesFlipperPlugin(context)); client.addPlugin(new SharedPreferencesFlipperPlugin(context)); client.addPlugin(CrashReporterPlugin.getInstance()); NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); NetworkingModule.setCustomClientBuilder( new NetworkingModule.CustomClientBuilder() { @Override public void apply(OkHttpClient.Builder builder) { builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); } }); client.addPlugin(networkFlipperPlugin); client.start(); // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized // Hence we run if after all native modules have been initialized ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); if (reactContext == null) { reactInstanceManager.addReactInstanceEventListener( new ReactInstanceManager.ReactInstanceEventListener() { @Override public void onReactContextInitialized(ReactContext reactContext) { reactInstanceManager.removeReactInstanceEventListener(this); reactContext.runOnNativeModulesQueueThread( new Runnable() { @Override public void run() { client.addPlugin(new FrescoFlipperPlugin()); } }); } }); } else { client.addPlugin(new FrescoFlipperPlugin()); } } } }
[ "team@crowdbotics.com" ]
team@crowdbotics.com
b8c74158777e6eac96b3baee231c70180313997a
1f7acf2c8de3510c50d4207c401ddd5b7368f91f
/src/test/java/edu/iu/finch/core/NexRadTest.java
566a8ac948bba18e03037d3418dbf6bbcd08dd11
[]
no_license
airavata-courses/TeamFinch
be2b05b63660628f20e7e954acfeb39ff52bb36b
4b64efd77c939277b7656910f95b64abcb6c67b9
refs/heads/master
2021-01-22T00:24:12.129621
2016-09-28T21:26:33
2016-09-28T21:26:33
67,431,499
0
0
null
null
null
null
UTF-8
Java
false
false
969
java
package edu.iu.finch.core; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AnonymousAWSCredentials; import com.amazonaws.services.s3.model.S3ObjectSummary; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.List; /** * Created by syodage on 9/11/16. */ public class NexRadTest { private AWSCredentials credentials; private NexRad nexRad; @BeforeMethod public void setUp() throws Exception { credentials = new AnonymousAWSCredentials(); nexRad = new NexRad(credentials); } @Test public void testListBucket() throws Exception { List<S3ObjectSummary> summaries = nexRad.listBucket("2016/01/01/" + NexRadStation.FOP1); Assert.assertNotNull(summaries); Assert.assertEquals(summaries.size(), 156); } @Test public void testGetS3Object() throws Exception { Assert.assertTrue(true); } }
[ "shameerainfo@gmail.com" ]
shameerainfo@gmail.com
3d3745b722c328d31e0d3bd36ded92632f357cd6
e5bbe13f73d23610a26cb2c7ad812f00fe4c6ec4
/app/src/main/java/com/example/project_akhir/isi_deskripsi_kfc.java
32b46e8ce36bb7cbeecbc5c023f7e81ad5c05eb1
[]
no_license
Rhama1018/Nongki_Skuuy
03270af3dc499e769359556b3bc699cf1af2fe0a
c00ab927322f50a1b48510d3f92f86cb33a692db
refs/heads/master
2020-09-12T19:23:17.867321
2019-11-18T19:18:25
2019-11-18T19:18:25
222,519,018
1
0
null
null
null
null
UTF-8
Java
false
false
869
java
package com.example.project_akhir; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; public class isi_deskripsi_kfc extends AppCompatActivity { Button btn_show_info11; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_isi_deskripsi_kfc); btn_show_info11 = (Button)findViewById(R.id.btn_show_info11); btn_show_info11.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ getSupportFragmentManager().beginTransaction().add(R.id.frame_layout1, new ShowFragment()).commit(); } }); } }
[ "rhamashandy7@gmail.com" ]
rhamashandy7@gmail.com
a44b77578871a52819ae4e34c185671257724606
a4657b8a05d70c4ad74b385b02856a230125bef7
/DoItAndroid/Part2/chapter10/SampleVideoRecorder/app/src/main/java/org/techtown/media/video/recorder/MainActivity.java
e07dfd2d549472468e30a3c12b267d5358905eda
[]
no_license
SODA1127/if2moldistudy
2d322b4b6fe79aa123963ec9a454858dd0f774ce
448e05aa3e9fb698547fc2db48d80ace0e58dab4
refs/heads/master
2020-04-09T20:35:13.666565
2018-06-09T05:12:11
2018-06-09T05:12:11
124,242,642
1
1
null
null
null
null
UTF-8
Java
false
false
8,340
java
package org.techtown.media.video.recorder; import android.Manifest; import android.content.ContentValues; import android.content.Intent; import android.content.pm.PackageManager; import android.hardware.Camera; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.FrameLayout; import android.widget.Toast; /** * 동영상을 녹화하는 방법에 대해 알 수 있습니다. * * @author Mike * */ public class MainActivity extends AppCompatActivity { public static final String TAG = "MainActivity"; private static String EXTERNAL_STORAGE_PATH = ""; private static String RECORDED_FILE = "video_recorded"; private static int fileIndex = 0; private static String filename = ""; MediaPlayer player; MediaRecorder recorder; private Camera camera = null; SurfaceHolder holder; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // check external storage String state = Environment.getExternalStorageState(); if (!state.equals(Environment.MEDIA_MOUNTED)) { Log.d(TAG, "External Storage Media is not mounted."); } else { EXTERNAL_STORAGE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath(); } // create a SurfaceView instance and add it to the layout SurfaceView surface = new SurfaceView(this); holder = surface.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); FrameLayout frame = (FrameLayout) findViewById(R.id.videoLayout); frame.addView(surface); Button recordBtn = (Button) findViewById(R.id.recordBtn); Button recordStopBtn = (Button) findViewById(R.id.recordStopBtn); Button playBtn = (Button) findViewById(R.id.playBtn); Button playStopBtn = (Button) findViewById(R.id.playStopBtn); recordBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { if (recorder == null) { recorder = new MediaRecorder(); } recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); filename = createFilename(); Log.d(TAG, "current filename : " + filename); recorder.setOutputFile(filename); recorder.setPreviewDisplay(holder.getSurface()); recorder.prepare(); recorder.start(); } catch (Exception ex) { Log.e(TAG, "Exception : ", ex); recorder.release(); recorder = null; } } }); recordStopBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (recorder == null) return; recorder.stop(); recorder.reset(); recorder.release(); recorder = null; ContentValues values = new ContentValues(10); values.put(MediaStore.MediaColumns.TITLE, "RecordedVideo"); values.put(MediaStore.Audio.Media.ALBUM, "Video Album"); values.put(MediaStore.Audio.Media.ARTIST, "Mike"); values.put(MediaStore.Audio.Media.DISPLAY_NAME, "Recorded Video"); values.put(MediaStore.MediaColumns.DATE_ADDED, System.currentTimeMillis() / 1000); values.put(MediaStore.MediaColumns.MIME_TYPE, "video/mp4"); values.put(MediaStore.Audio.Media.DATA, filename); Uri videoUri = getContentResolver().insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); if (videoUri == null) { Log.d("SampleVideoRecorder", "Video insert failed."); return; } sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, videoUri)); } }); playBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (player == null) { player = new MediaPlayer(); } try { player.setDataSource(filename); player.setDisplay(holder); player.prepare(); player.start(); } catch (Exception e) { Log.e(TAG, "Video play failed.", e); } } }); playStopBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (player == null) return; player.stop(); player.release(); player = null; } }); checkDangerousPermissions(); } private void checkDangerousPermissions() { String[] permissions = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA }; int permissionCheck = PackageManager.PERMISSION_GRANTED; for (int i = 0; i < permissions.length; i++) { permissionCheck = ContextCompat.checkSelfPermission(this, permissions[i]); if (permissionCheck == PackageManager.PERMISSION_DENIED) { break; } } if (permissionCheck == PackageManager.PERMISSION_GRANTED) { Toast.makeText(this, "권한 있음", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "권한 없음", Toast.LENGTH_LONG).show(); if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) { Toast.makeText(this, "권한 설명 필요함.", Toast.LENGTH_LONG).show(); } else { ActivityCompat.requestPermissions(this, permissions, 1); } } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == 1) { for (int i = 0; i < permissions.length; i++) { if (grantResults[i] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(this, permissions[i] + " 권한이 승인됨.", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, permissions[i] + " 권한이 승인되지 않음.", Toast.LENGTH_LONG).show(); } } } } private String createFilename() { fileIndex++; String newFilename = ""; if (EXTERNAL_STORAGE_PATH == null || EXTERNAL_STORAGE_PATH.equals("")) { // use internal memory newFilename = RECORDED_FILE + fileIndex + ".mp4"; } else { newFilename = EXTERNAL_STORAGE_PATH + "/" + RECORDED_FILE + fileIndex + ".mp4"; } return newFilename; } protected void onPause() { if (camera != null) { camera.release(); camera = null; } if (recorder != null) { recorder.release(); recorder = null; } if (player != null) { player.release(); player = null; } super.onPause(); } }
[ "dlrlwjd1127@naver.com" ]
dlrlwjd1127@naver.com
1f9e6beeb7697eaf192232533584536d39c7911d
ed42b5f57b06f6e4bc87c4edacb06dc7931bfba6
/src/demo_staticDropDown.java
546d48db9b325ffe5996aae4a8944ce7d45ba1ab
[]
no_license
samiullah/SeleniumCodeExamples
46dcc703f860346e3018abefa4520d372e18eeb5
4d6d503951006c85e25b1bb1449b4f27a1e4d670
refs/heads/master
2022-12-01T04:28:13.486135
2020-08-14T11:21:11
2020-08-14T11:21:11
279,070,552
1
0
null
null
null
null
UTF-8
Java
false
false
787
java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; public class demo_staticDropDown { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "chromedriver"); WebDriver driver = new ChromeDriver(); driver.get("https://www.rahulshettyacademy.com/AutomationPractice/"); WebElement s = driver.findElement(By.id("dropdown-class-example")); Select select = new Select(s); //select.selectByIndex(2); //select.selectByVisibleText("Option1"); select.selectByValue("option3"); driver.quit(); } }
[ "sami@Samis-MacBook-Air.local" ]
sami@Samis-MacBook-Air.local
5f03d6729f468f0fa8129fa30c6aff58122a31d0
c978b38042c719e28265a67f6638b6ad0ccd27a5
/src/CrackingTheCodingInterview/Q16_11_Diving_Board/QuestionA.java
6e9b0ea19daed16fb052da90418705f4135ee62d
[]
no_license
gspyadav/LeetCodeFishercoder
2a2a70c47608db75df9b847260067196f03d785a
0f135f2a468466f783ce763b6666c34f17b17bd0
refs/heads/master
2023-07-11T04:44:58.018418
2023-06-26T07:04:09
2023-06-26T07:04:09
192,256,996
1
1
null
null
null
null
UTF-8
Java
false
false
827
java
package CrackingTheCodingInterview.Q16_11_Diving_Board; import java.util.HashSet; public class QuestionA { public static int counter = 0; public static HashSet<Integer> allLengths(int k, int shorter, int longer) { HashSet<Integer> lengths = new HashSet<Integer>(); getAllLengths(k, 0, shorter, longer, lengths); return lengths; } public static void getAllLengths(int k, int total, int shorter, int longer, HashSet<Integer> lengths) { counter++; if (k == 0) { lengths.add(total); return; } getAllLengths(k - 1, total + shorter, shorter, longer, lengths); getAllLengths(k - 1, total + longer, shorter, longer, lengths); } public static void main(String[] args) { HashSet<Integer> lengths = allLengths(12, 1, 3); System.out.println(lengths.toString()); System.out.println(counter); } }
[ "gspyadav.m@gmail.com" ]
gspyadav.m@gmail.com
2e88e11a7765649ee4a0d7726c52da7ff5813f68
f89c06deaa559dc1ee6d94258bf7e25738f03083
/java_progrms/src/Dynamic_Table/Filewriter.java
15cff571d424ce23525081ec65ec4c77601aa8df
[]
no_license
Devarajgunjali/gunjali
588837dd29a4c3c1ad6dcf93ed2313d7c3e5381d
6ac0648583c12ef8b7323c90cbc379286ef00df2
refs/heads/master
2022-07-14T18:42:47.508865
2019-09-13T09:35:13
2019-09-13T09:35:13
204,955,516
0
0
null
2022-06-29T17:38:34
2019-08-28T14:47:01
HTML
UTF-8
Java
false
false
352
java
package Dynamic_Table; import java.io.FileWriter; import java.io.IOException; public class Filewriter { public static void main(String args[]){ try { FileWriter wr = new FileWriter ("C:/Users/dell/Desktop/automation.txt"); wr.write("Welcome to eagle"); wr.close(); } catch (IOException e) { } } }
[ "devarajgunjali91@gmail.com" ]
devarajgunjali91@gmail.com
43fe635557d61727c0aed5220f2d562a8bf1c20d
5148293c98b0a27aa223ea157441ac7fa9b5e7a3
/Method_Scraping/xml_scraping/NicadOutputFile_t1_beam_2nd/Nicad_t1_beam_2nd82.java
0cbd96b94c510c9a230d1419e2ac9a8d2523b760
[]
no_license
ryosuke-ku/TestCodeSeacherPlus
cfd03a2858b67a05ecf17194213b7c02c5f2caff
d002a52251f5461598c7af73925b85a05cea85c6
refs/heads/master
2020-05-24T01:25:27.000821
2019-08-17T06:23:42
2019-08-17T06:23:42
187,005,399
0
0
null
null
null
null
UTF-8
Java
false
false
684
java
// clone pairs:1475:91% // 1259:beam/runners/flink/src/main/java/org/apache/beam/runners/flink/FlinkJobServerDriver.java public class Nicad_t1_beam_2nd82 { public static FlinkJobServerDriver fromParams(String[] args) { FlinkServerConfiguration configuration = new FlinkServerConfiguration(); CmdLineParser parser = new CmdLineParser(configuration); try { parser.parseArgument(args); } catch (CmdLineException e) { LOG.error("Unable to parse command line arguments.", e); printUsage(parser); throw new IllegalArgumentException("Unable to parse command line arguments.", e); } return fromConfig(configuration); } }
[ "naist1020@gmail.com" ]
naist1020@gmail.com
787d80aee53fbae3abf3fca010ce8a7d311205c3
dfc8399c326a963314658747370d55354dd237aa
/apptools/storemanager-parent/storemanager-domain/src/main/java/com/cxy/apptools/domain/storemanager/Cxyunit.java
28f27d85f622129750579e3ae67f10117469c62b
[]
no_license
hzzz1234/cxyStoreManagement
9ad2fa7af9cfb4dfa74c934955ec594ae37cadd2
700e82f678a37261bb458e395ec14f5ab2b9fe17
refs/heads/master
2021-01-10T10:12:37.899881
2016-04-21T14:12:11
2016-04-21T14:12:11
43,764,304
0
0
null
null
null
null
UTF-8
Java
false
false
1,104
java
package com.cxy.apptools.domain.storemanager; import java.util.Date; public class Cxyunit { private Integer unitid; private String unitname; private Integer deleted; private Date createTime; private Date datachangeLasttime; public Integer getUnitid() { return unitid; } public void setUnitid(Integer unitid) { this.unitid = unitid; } public String getUnitname() { return unitname; } public void setUnitname(String unitname) { this.unitname = unitname == null ? null : unitname.trim(); } public Integer getDeleted() { return deleted; } public void setDeleted(Integer deleted) { this.deleted = deleted; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getDatachangeLasttime() { return datachangeLasttime; } public void setDatachangeLasttime(Date datachangeLasttime) { this.datachangeLasttime = datachangeLasttime; } }
[ "pandiansinian@163.com" ]
pandiansinian@163.com
72f9d2e0e89456b52dd55011b58a2aa13f462d87
6b3656be55de903c887461c78f63a6d255363ce8
/app/src/main/java/com/example/developer/instagram/MainActivity.java
e4d68803e10363320544b26b7772e9cd9db449e8
[]
no_license
Javohir6949/Instagram
9e29c54ef45e7101148bfe052d06ef4d4054fa5d
3741207c985fcb96337461509732777e6343808f
refs/heads/master
2020-03-14T16:34:20.926490
2018-05-02T12:45:01
2018-05-02T12:45:01
131,700,671
0
0
null
null
null
null
UTF-8
Java
false
false
7,105
java
package com.example.developer.instagram; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.RelativeLayout; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private boolean firstTime = true; private ImageView allNew; private ImageView search; private ImageView addNew; private ImageView event; private ImageView profile; private RelativeLayout allNewClick; private RelativeLayout searchClick; private RelativeLayout addNewClick; private RelativeLayout eventClick; private RelativeLayout profileClick; private int previous; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); allNew = findViewById(R.id.allNew); search = findViewById(R.id.search); addNew = findViewById(R.id.addNew); event = findViewById(R.id.event); profile = findViewById(R.id.profile); allNewClick = findViewById(R.id.allNewClick); searchClick = findViewById(R.id.searchClick); addNewClick = findViewById(R.id.addNewClick); eventClick = findViewById(R.id.eventClick); profileClick = findViewById(R.id.profileClick); allNew.setOnClickListener(this); search.setOnClickListener(this); addNew.setOnClickListener(this); event.setOnClickListener(this); profile.setOnClickListener(this); getSupportFragmentManager() .beginTransaction() .add(R.id.fragmentMother, new Fragment1()) .commit(); allNewClick.setOnClickListener(this); searchClick.setOnClickListener(this); addNewClick.setOnClickListener(this); eventClick.setOnClickListener(this); profileClick.setOnClickListener(this); } @Override protected void onResume() { super.onResume(); if (firstTime == false){ setAllGrey(); if(previous == 1){ allNew.setColorFilter(getResources().getColor(R.color.customBlack)); }else if(previous == 2){ search.setColorFilter(getResources().getColor(R.color.customBlack)); }else if(previous == 4){ event.setColorFilter(getResources().getColor(R.color.customBlack)); }else if(previous == 5){ profile.setColorFilter(getResources().getColor(R.color.customBlack)); } } } @Override public void onClick(View v) { switch (v.getId()) { case R.id.allNewClick:{ previous = 1; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment1()) .commit(); allNew.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.searchClick:{ previous = 2; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment2()) .commit(); search.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.addNewClick:{ firstTime = false; setAllGrey(); Intent intent = new Intent(this,ActivityAdd.class); startActivity(intent); addNew.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.eventClick:{ previous = 4; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment4()) .commit(); event.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.profileClick:{ previous = 5; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment5()) .commit(); profile.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.allNew:{ previous = 1; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment1()) .commit(); allNew.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.search:{ previous = 2; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment2()) .commit(); search.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.addNew:{ firstTime = false; setAllGrey(); Intent intent = new Intent(this,ActivityAdd.class); startActivity(intent); addNew.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.event:{ previous = 4; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment4()) .commit(); event.setColorFilter(getResources().getColor(R.color.customBlack)); break; } case R.id.profile:{ previous = 5; setAllGrey(); getSupportFragmentManager() .beginTransaction() .replace(R.id.fragmentMother, new Fragment5()) .commit(); profile.setColorFilter(getResources().getColor(R.color.customBlack)); break; } } } private void setAllGrey() { allNew.setColorFilter(getResources().getColor(R.color.customGrey)); search.setColorFilter(getResources().getColor(R.color.customGrey)); addNew.setColorFilter(getResources().getColor(R.color.customGrey)); event.setColorFilter(getResources().getColor(R.color.customGrey)); profile.setColorFilter(getResources().getColor(R.color.customGrey)); } }
[ "javaturin@mail.ru" ]
javaturin@mail.ru
e99eb9284fd2f2d35a844ed64d529dd72e6fe33f
46a9a252ea9d80f8ba3cc61d3d495a728c43031b
/src/ch03/DateTest.java
059ea2229dcb327a69c88e9884c084e350947f4b
[]
no_license
humility0310/ch03
db491f24b51c53e9342adb83e04d61ae3dfe61a9
4de34dc26a8bd423feeb8539d7b06e183246a029
refs/heads/master
2021-01-12T13:23:17.173485
2016-09-26T02:56:00
2016-09-26T02:56:00
68,971,860
0
0
null
null
null
null
UTF-8
Java
false
false
1,644
java
package ch03; import java.text.SimpleDateFormat; import java.util.Date; public class DateTest { public static void main(String[] args) { Date now = new Date(); // System.out.println(now); // 년, 월(0-11), 일 Date d1 = new Date(2000, 9, 23);// depercated-> 없어질 예정(비추천하는거) printDate(d1); // 년, 월(0-11), 일, 시간, 분 Date d2 = new Date(2000, 8, 1, 12, 30);// depercated-> 없어질 예정(비추천하는거) // System.out.println(d2); printDate(d2); // 년, 월(0-11), 일, 시간, 분 Date d3 = new Date(2000, 8, 1, 12, 30, 30);// depercated-> 없어질 // 예정(비추천하는거) // System.out.println(d3); printDate(d3); // 1970년 1월1일 00:00:00 기준으로 밀리세컨드값으로 세팅 // 년, 월(0-11), 일, 시간, 분 long milliseconds = 1000L * 60 * 60 * 24 * 365 * 40; Date d4 = new Date(milliseconds); // System.out.println(d4); printDate(d4); printDate2(d4); } private static void printDate(Date d) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy년 MM월 dd일 hh:mm:ss"); System.out.println(sdf.format(d)); } private static void printDate2(Date d) { //년도 + 1900 int year = d.getYear(); //월 + 1 int month = d.getMonth(); //일 int date = d.getDate(); //시 int hour = d.getHours(); //분 int min= d.getMinutes(); //초 int sec = d.getSeconds(); System.out.println((year+1900) + "년" + (month+1)+"월"+ (date)+"일"+ (hour)+"시"+ (min)+"분"+ (sec)+"초"); } }
[ "bit-user@bit" ]
bit-user@bit
055760d999092566a309e66942363103b2e9f394
9e820657fe9bd62d2f5165cfeb135249774fb7ee
/07. NestedLoops/Lab/src/Combination.java
a5fb20b3f19f2c387ba771c73e14430a90e5c975
[ "MIT" ]
permissive
bfartsov/java-basics
5ebdf2816a9fbd1dfba3ff7e96f93ec3159ebf17
30c68384a1658344939fd776b89ff1835f5fe680
refs/heads/master
2020-04-05T07:33:28.479305
2018-11-03T21:24:04
2018-11-03T21:24:04
null
0
0
null
null
null
null
UTF-8
Java
false
false
780
java
import java.util.Scanner; public class Combination { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = Integer.parseInt(scan.nextLine()); int result = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= n; k++) { for (int l = 0; l <= n; l++) { for (int m = 0; m <= n; m++) { int combination = i + j + k + l + m; if (combination == n) { result++; } } } } } } System.out.println(result); } }
[ "ipetkow90@gmail.com" ]
ipetkow90@gmail.com
4894faa849b6bb64f1fb70f2f0b724e714a55454
29558085831b44915b2e70952904d4c6d71bd8e8
/FindSumPair.java
4661f2f7f522ec553731d40eefee14be7f87f954
[]
no_license
chenkunchuang/2017Algo
27c3533c332393c4e5526a59cce6cf1d8b7f521e
1f649502facfd4a87191c69e99b6f3ab4c0d5267
refs/heads/master
2020-12-03T00:15:01.975921
2017-07-24T01:44:41
2017-07-24T01:44:41
96,003,669
0
0
null
null
null
null
UTF-8
Java
false
false
2,048
java
import java.util.*; public class FindSumPair { public void findPair(List<Integer> list) { System.out.println("enter findpair "); HashMap<Integer, List<List<Integer>>> map = new HashMap<>(); List<Integer> pair = new ArrayList<>(); for(int i=0; i<list.size()-1; i++) { //for(int j=i+1; j<list.size(); j++) { if(list.get(i)!=list.get(i+1)) { int sum = list.get(i) + list.get(i+1); //System.out.println("sum " + sum + " i " + list.get(i) + " j " + list.get(i+1)); //List<List<Integer>> pairs = map.getOrDefault(sum, new ArrayList<>()); pair.add(list.get(i)); pair.add(list.get(i+1)); /* if(map.containsKey(sum)!=true) { // This is wrong since you actually create a list, not a list of list //map.put(sum, new ArrayList(pair)); //map.put(sum, new ArrayList().add(pair)); } //else { List<List<Integer>> pairs = map.get(sum); if(pairs.contains(pair)!=true) pairs.add(new ArrayList(pair)); map.put(sum, pairs); } */ List<List<Integer>> alist = map.getOrDefault(sum, new ArrayList<>()); if(alist.contains(pair)!=true) alist.add(new ArrayList(pair)); map.put(sum, alist); pair.clear(); } } } System.out.println("map size " + map.size()); for(Map.Entry<Integer, List<List<Integer>>> entry: map.entrySet()) { //System.out.println("sum " + entry.getKey() + " value" + entry.getValue()+ " size " + entry.getValue().size()); if(entry.getValue().size()>1) { System.out.print(entry.getKey() + " :"); for(List<Integer> pairlist: entry.getValue()) System.out.print("("+pairlist.get(0) + "," + pairlist.get(1)+") "); System.out.println(); } } return; } public static void main(String[] args) { // TODO Auto-generated method stub int[] ar = {1,7,4,6,2,3,5,6}; //Arrays.sort(ar); List<Integer> list = new ArrayList<>(); for(int n: ar) list.add(n); FindSumPair obj = new FindSumPair(); obj.findPair(list); } }
[ "Chenkun.chuang@gmail.com" ]
Chenkun.chuang@gmail.com
c94157f320dfc14e29cd4681d65596058dab7dff
b3bc5907bde316eb5a32ae354243c04213636003
/IKDA/app/src/main/java/com/alifstudio/mustikaiman/MyAdapter/TabSetup.java
d1037f407b4e3565af3e3ad9481f501efdeacd58
[ "Apache-2.0" ]
permissive
jokosusilo1/Alifstudio
e8028093e3e2c3f6353067c3eea22ada5ec08eaa
0bc1ab66ae3dd684a0ec40851099caacca2f782f
refs/heads/main
2022-12-26T13:18:28.780662
2020-10-17T17:18:50
2020-10-17T17:18:50
304,928,514
0
0
null
null
null
null
UTF-8
Java
false
false
945
java
package com.alifstudio.mustikaiman.MyAdapter; import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.Fragment; import java.util.ArrayList; import java.util.List; import androidx.fragment.app.FragmentManager; public class TabSetup extends FragmentPagerAdapter { private final List<Fragment>fragmentList=new ArrayList<>(); private final List<String>fragmentTitle=new ArrayList<>(); public TabSetup(FragmentManager mFragment){ super(mFragment); } @Override public int getCount() { return fragmentList.size(); } @Override public Fragment getItem(int posisi) { return fragmentList.get(posisi); } public void addFragment(Fragment mFragment ,String str){ fragmentList.add(mFragment); fragmentTitle.add(str); } @Override public CharSequence getPageTitle(int position) { return fragmentTitle.get(position); } }
[ "djokostiaji@gmail.com" ]
djokostiaji@gmail.com
b06357d923335bebc03964f526409ba95bc88a29
4fe278796209d5cdfcaa9a5f9339095f357255eb
/spi/src/main/java/com/lightbend/streams/spi/Stage.java
a263a4aaf4a28e490a4a52540e92be184d247c2a
[ "CC0-1.0" ]
permissive
ktoso/reactive-streams-utils
fe761d46ce0c9406281c093c20158cde82334782
0c232afb8a24fd7442d0132823c70791cd39857a
refs/heads/master
2021-04-27T13:01:58.269046
2018-02-22T04:18:17
2018-02-22T04:18:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,294
java
/************************************************************************ * Licensed under Public Domain (CC0) * * * * To the extent possible under law, the person who associated CC0 with * * this code has waived all copyright and related or neighboring * * rights to this code. * * * * You should have received a copy of the CC0 legalcode along with this * * work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.* ************************************************************************/ package com.lightbend.streams.spi; import java.util.concurrent.Flow; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collector; /** * A stage of a Reactive Streams graph. * * A Reactive Streams engine will walk a graph of stages to produce {@link Publisher}, {@link Subscriber} and * {@link Processor} instances that handle the stream according to the sequence of stages. */ public interface Stage { /** * Whether this stage has an inlet - ie, when built, will it implement the {@link Subscriber} interface? * * @return True if this stage has an inlet. */ default boolean hasInlet() { return false; } /** * Whether this stage has an outlet - ie, when built, will it implement the {@link Publisher} interface? * * @return True if this stage has an outlet. */ default boolean hasOutlet() { return false; } /** * Convenience interface for inlet stages. */ interface Inlet extends Stage { @Override default boolean hasInlet() { return true; } } /** * Convenience interface for outlet stages. */ interface Outlet extends Stage { @Override default boolean hasOutlet() { return true; } } /** * A map stage. * * The given mapper function should be invoked on each element consumed, and the output of the function should be * emitted. * * Any {@link RuntimeException} thrown by the function should be propagated down the stream as an error. */ final class Map implements Inlet, Outlet { private final Function<?, ?> mapper; public Map(Function<?, ?> mapper) { this.mapper = mapper; } /** * The mapper function. * * @return The mapper function. */ public Function<?, ?> getMapper() { return mapper; } } /** * A filter stage. * * The given predicate should be invoked on each element consumed, and if it returns true, the element should be * emitted. * * Any {@link RuntimeException} thrown by the function should be propagated down the stream as an error. */ final class Filter implements Inlet, Outlet { private final Predicate<?> predicate; public Filter(Predicate<?> predicate) { this.predicate = predicate; } /** * The predicate. * * @return The predicate. */ public Predicate<?> getPredicate() { return predicate; } } /** * A publisher stage. * * The given publisher should be subscribed to whatever subscriber is provided to this graph, via any other subsequent * stages. */ final class Publisher implements Outlet { private final Flow.Publisher<?> publisher; public Publisher(Flow.Publisher<?> publisher) { this.publisher = publisher; } /** * The publisher. * * @return The publisher. */ public Flow.Publisher<?> getPublisher() { return publisher; } } /** * A single element publisher stage. * * When built, should produce a publisher that emits the single element, then completes the stream. */ final class OfSingle implements Outlet { private final Object element; public OfSingle(Object element) { this.element = element; } /** * The element to emit. * * @return The element. */ public Object getElement() { return element; } } /** * An empty publisher stage. * * When built, should produce a publisher that simply completes the stream. */ final class Empty implements Outlet { private Empty() { } public static final Empty INSTANCE = new Empty(); } /** * A publisher of many values. * * When built, should produce a publisher that produces all the values (until cancelled) emitted by this iterables * iterator, followed by completion of the stream. * * Any exceptions thrown by the iterator must be propagated downstream. */ final class OfMany implements Outlet { private final java.lang.Iterable<?> elements; public OfMany(java.lang.Iterable<?> elements) { this.elements = elements; } /** * The elements to emit. * * @return The elements to emit. */ public java.lang.Iterable<?> getElements() { return elements; } } /** * A processor stage. * * When built, should connect upstream of the graph to the inlet of this processor, and downstream to the outlet. */ final class Processor implements Inlet, Outlet { private final Flow.Processor<?, ?> processor; public Processor(Flow.Processor<?, ?> processor) { this.processor = processor; } /** * The processor. * * @return The processor. */ public Flow.Processor<?, ?> getProcessor() { return processor; } } /** * A subscriber stage that emits the first element encountered. * * When built, the {@link java.util.concurrent.CompletionStage} should emit an {@link java.util.Optional} of the first * element emitted. If no element is emitted before completion of the stream, it should emit an empty optional. Once * the element has been emitted, the stream should be cancelled if not already complete. * * If an error is emitted before the first element is encountered, the stream must redeem the completion stage with * that error. */ final class FindFirst implements Inlet { private FindFirst() { } public static final FindFirst INSTANCE = new FindFirst(); } /** * A subscriber. * * When built, the {@link java.util.concurrent.CompletionStage} should emit <code>null</code> when the stream * completes normally, or an error if the stream terminates with an error. * * Implementing this will typically require inserting a handler before the subscriber that listens for errors. */ final class Subscriber implements Inlet { private final Flow.Subscriber<?> subscriber; public Subscriber(Flow.Subscriber<?> subscriber) { this.subscriber = subscriber; } /** * The subscriber. * * @return The subscriber. */ public Flow.Subscriber<?> getSubscriber() { return subscriber; } } /** * A collect stage. * * This should use the collectors supplier to create an accumulated value, and then the accumulator BiConsumer should * be used to accumulate the received elements in the value. Finally, the returned * {@link java.util.concurrent.CompletionStage} should be redeemed by value returned by the finisher function applied * to the accumulated value when the stream terminates normally, or should be redeemed with an error if the stream * terminates with an error. * * If the collector throws an exception, the stream must be cancelled, and the * {@link java.util.concurrent.CompletionStage} must be redeemed with that error. */ final class Collect implements Inlet { private final Collector<?, ?, ?> collector; public Collect(Collector<?, ?, ?> collector) { this.collector = collector; } public Collector<?, ?, ?> getCollector() { return collector; } } /** * A failed publisher. * * When built, this should produce a publisher that immediately fails the stream with the passed in error. */ final class Failed implements Outlet { private final Throwable error; public Failed(Throwable error) { this.error = error; } public Throwable getError() { return error; } } }
[ "james@jazzy.id.au" ]
james@jazzy.id.au
a6efb598fb2e9990806f659d61085970f5d05bb2
7be6ebc6742f0c2bba6c6c14cf4a27c6d479d65d
/modules/taop-utils/src/main/java/cn/taop/container/impl/InitializingBean.java
b6a328a150b9f81f80d71602d4854c34962e078b
[ "Apache-2.0" ]
permissive
duduwolf/taop
873db7c8fb8caf1b66dcd6677d6655177ea600f0
e731668bd6629c426aaef17cd25f7711b2335c66
refs/heads/master
2020-12-24T15:50:08.156373
2017-02-04T10:13:12
2017-02-04T10:13:12
11,723,210
0
1
null
2016-03-09T23:09:40
2013-07-28T17:35:14
Java
UTF-8
Java
false
false
338
java
/** * Copyright 2009-2010 taop.cn * All rights reserved. */ package cn.taop.container.impl; import cn.taop.container.Container; /** * 继承了此接口的bean,可以自定义类的初始化动作 * * @author duduwolf */ public interface InitializingBean { void afterContainerSetup(Container container); }
[ "dudulq@gmail.com" ]
dudulq@gmail.com
2a90304e9afb2ae894b5aeb2c77299a7675cde47
f77c2988a65916f685888beb07fd8bdfdc26ec83
/springbootMangodb/springbootMangodb/src/main/java/com/formation/springbootMangodb/dao/CustomerRepository.java
a90c65b363315a7cbaae1085ea89179ca0a5dc31
[]
no_license
khaledboussaba/my_workspaces_al34
8306d7544b7e8d207077bc6f87cea1284e663007
bb15ae2463a08772b00144dc4c53fb8959a10f8c
refs/heads/master
2022-12-14T03:35:13.992147
2020-02-21T15:49:07
2020-02-21T15:49:07
224,636,612
0
0
null
2022-12-13T17:49:51
2019-11-28T11:17:49
Java
UTF-8
Java
false
false
380
java
package com.formation.springbootMangodb.dao; import java.util.List; import org.springframework.data.mongodb.repository.MongoRepository; import com.formation.springbootMangodb.entity.Person; public interface CustomerRepository extends MongoRepository<Person, String> { public Person findByFirstName(String firstName); public List<Person> findByLastName(String lastName); }
[ "khaledboussaba@gmail.com" ]
khaledboussaba@gmail.com
3040c8525eb3f9208553efa14a7816ad408a7cd6
684f49e5d10205e903505a80f007fb505552deea
/kalle/src/main/java/com/yanzhenjie/kalle/cookie/DBCookieStore.java
428916ab118530befcf20cce4abf4cabe731b963
[]
no_license
ibaozi-cn/Net
76d28955e659594cc0a91ec9629e21b0b0f591ef
c5eb338c6d4b3ff16d44c2ced6e1471718cf2a9c
refs/heads/master
2022-11-19T20:23:13.197728
2020-07-24T05:28:20
2020-07-24T05:28:20
282,770,328
1
0
null
2020-07-27T02:00:18
2020-07-27T02:00:18
null
UTF-8
Java
false
false
6,584
java
/* * Copyright © 2018 Zhenjie Yan. * * 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.yanzhenjie.kalle.cookie; import android.content.Context; import android.text.TextUtils; import com.yanzhenjie.kalle.cookie.db.CookieDao; import com.yanzhenjie.kalle.cookie.db.Field; import com.yanzhenjie.kalle.cookie.db.Where; import java.net.HttpCookie; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * Created in Dec 17, 2015 7:20:52 PM. */ public class DBCookieStore implements CookieStore, Field { private final static int MAX_COOKIE_SIZE = 888; private Lock mLock; private CookieDao mCookieDao; private DBCookieStore(Builder builder) { mLock = new ReentrantLock(); mCookieDao = new CookieDao(builder.mContext); Where where = Where.newBuilder() .add(EXPIRY, Where.Options.EQUAL, -1) .or(EXPIRY, Where.Options.EQUAL, 0) .build(); mCookieDao.delete(where.toString()); } public static Builder newBuilder(Context context) { return new Builder(context); } private static URI getEffectiveURI(final URI uri) { URI effectiveURI; try { effectiveURI = new URI("http", uri.getHost(), uri.getPath(), null, null); } catch (URISyntaxException e) { effectiveURI = uri; } return effectiveURI; } @Override public List<HttpCookie> get(URI uri) { mLock.lock(); try { uri = getEffectiveURI(uri); Where.Builder whereBuilder = Where.newBuilder(); String host = uri.getHost(); if (!TextUtils.isEmpty(host)) { Where.Builder subBuilder = Where.newBuilder() .add(DOMAIN, Where.Options.EQUAL, host) .or(DOMAIN, Where.Options.EQUAL, "." + host); int firstDot = host.indexOf("."); int lastDot = host.lastIndexOf("."); if (firstDot > 0) { if (lastDot > firstDot) { String domain = host.substring(firstDot, host.length()); if (!TextUtils.isEmpty(domain)) { subBuilder.or(DOMAIN, Where.Options.EQUAL, domain); } } if (lastDot > firstDot + 1) { String domain = host.substring(firstDot + 1, host.length()); if (!TextUtils.isEmpty(domain)) { subBuilder.or(DOMAIN, Where.Options.EQUAL, domain); } } } whereBuilder.set(subBuilder.build().toString()); } String path = uri.getPath(); if (!TextUtils.isEmpty(path)) { Where.Builder subBuilder = Where.newBuilder() .add(PATH, Where.Options.EQUAL, path) .or(PATH, Where.Options.EQUAL, "/") .orNull(PATH); int lastSplit = path.lastIndexOf("/"); while (lastSplit > 0) { path = path.substring(0, lastSplit); subBuilder.or(PATH, Where.Options.EQUAL, path); lastSplit = path.lastIndexOf("/"); } subBuilder.bracket(); whereBuilder.and(subBuilder.build()); } whereBuilder.or(URL, Where.Options.EQUAL, uri.toString()); Where where = whereBuilder.build(); List<Cookie> cookieList = mCookieDao.getList(where.toString(), null, null, null); List<HttpCookie> returnedCookies = new ArrayList<>(); for (Cookie cookie : cookieList) { if (!Cookie.isExpired(cookie)) returnedCookies.add(Cookie.toHttpCookie(cookie)); } return returnedCookies; } finally { mLock.unlock(); } } @Override public void add(URI uri, HttpCookie httpCookie) { mLock.lock(); try { if (uri != null && httpCookie != null) { uri = getEffectiveURI(uri); mCookieDao.replace(Cookie.toCookie(uri.toString(), httpCookie)); trimSize(); } } finally { mLock.unlock(); } } @Override public void remove(HttpCookie httpCookie) { mLock.lock(); try { Where.Builder whereBuilder = Where.newBuilder().add(NAME, Where.Options.EQUAL, httpCookie.getName()); String domain = httpCookie.getDomain(); if (!TextUtils.isEmpty(domain)) whereBuilder.and(DOMAIN, Where.Options.EQUAL, domain); String path = httpCookie.getPath(); if (!TextUtils.isEmpty(path)) { if (path.length() > 1 && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } whereBuilder.and(PATH, Where.Options.EQUAL, path); } mCookieDao.delete(whereBuilder.build().toString()); } finally { mLock.unlock(); } } @Override public void clear() { mLock.lock(); try { mCookieDao.deleteAll(); } finally { mLock.unlock(); } } private void trimSize() { int count = mCookieDao.count(); if (count > MAX_COOKIE_SIZE) { List<Cookie> rmList = mCookieDao.getList(null, null, Integer.toString(count - MAX_COOKIE_SIZE), null); if (rmList != null) mCookieDao.delete(rmList); } } public static class Builder { private Context mContext; private Builder(Context context) { this.mContext = context; } public DBCookieStore build() { return new DBCookieStore(this); } } }
[ "liangjinggpx@gmail.com" ]
liangjinggpx@gmail.com
74d7edc24e2365ab7a73cdd6028793fbf38fd716
6283e53dc2d707bd29b6462cf577b1571037c3bf
/java/features/protected/src/main/java/io/mart/packet1/NonPublicClass.java
ff142ad88548d0dcf6a061b149729a261bc4be2a
[]
no_license
amartyushov/Experiments
2d95ebc442ae5707f8435f828a04aacca110dfc1
5af4e006e81c9d401a328c033c1fd9357da60131
refs/heads/master
2023-09-01T17:25:43.409389
2023-09-01T06:59:07
2023-09-01T06:59:07
90,235,236
0
2
null
2022-02-10T08:39:12
2017-05-04T07:40:54
Java
UTF-8
Java
false
false
119
java
package io.mart.packet1; class NonPublicClass { public int value = 5; public int getValue() { return value; } }
[ "amartyushov@gmail.com" ]
amartyushov@gmail.com
352840d3fe3eb7b161a9a4596e7a43acacc24606
7c3ce7bdd4469b9b57bb1506cf0e1d89b4eb665d
/src/ExemploCalculadora.java
5968c335391ea560b964a10d4387b80b99412fda
[]
no_license
Guizal/Java
d7c33f52385c632398a6d2b672e0b8d1d950a38f
2d3058df5792cc57befb32aef9c8c03a16a5fcca
refs/heads/master
2023-06-22T16:51:24.691992
2021-07-22T00:08:21
2021-07-22T00:08:21
388,276,922
0
0
null
null
null
null
UTF-8
Java
false
false
17,676
java
public class ExemploCalculadora extends javax.swing.JFrame { public ExemploCalculadora() { initComponents(); } // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel2 = new javax.swing.JPanel(); NUM1 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); NUM2 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); RESULTADO = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); SUBT = new javax.swing.JButton(); MULT = new javax.swing.JButton(); QUADRADO = new javax.swing.JButton(); CUBO = new javax.swing.JButton(); LIMPAR = new javax.swing.JButton(); RAIZ = new javax.swing.JButton(); FAT = new javax.swing.JButton(); DIV = new javax.swing.JButton(); jTextField1 = new javax.swing.JTextField(); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); NUM1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NUM1ActionPerformed(evt); } }); jButton1.setText("+"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel1.setText("Primeiro Número"); jLabel1.addAncestorListener(new javax.swing.event.AncestorListener() { public void ancestorMoved(javax.swing.event.AncestorEvent evt) { } public void ancestorAdded(javax.swing.event.AncestorEvent evt) { jLabel1AncestorAdded(evt); } public void ancestorRemoved(javax.swing.event.AncestorEvent evt) { } }); NUM2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NUM2ActionPerformed(evt); } }); jLabel2.setText("Segundo Número"); RESULTADO.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RESULTADOActionPerformed(evt); } }); jLabel3.setText("Resultado"); SUBT.setText("-"); SUBT.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SUBTActionPerformed(evt); } }); MULT.setText("*"); MULT.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MULTActionPerformed(evt); } }); QUADRADO.setText("X²"); QUADRADO.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { QUADRADOActionPerformed(evt); } }); CUBO.setText("X³"); CUBO.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CUBOActionPerformed(evt); } }); LIMPAR.setText("C"); LIMPAR.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LIMPARActionPerformed(evt); } }); RAIZ.setText("sqrt"); RAIZ.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RAIZActionPerformed(evt); } }); FAT.setText("n!"); FAT.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { FATActionPerformed(evt); } }); DIV.setText("/"); DIV.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DIVActionPerformed(evt); } }); jTextField1.setBackground(new java.awt.Color(1, 51, 255)); jTextField1.setForeground(new java.awt.Color(1, 0, 0)); jTextField1.setText("Calculadora"); jTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(41, 41, 41) .addComponent(jLabel3) .addGap(54, 54, 54) .addComponent(RESULTADO)) .addGroup(layout.createSequentialGroup() .addGap(104, 104, 104) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(SUBT, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CUBO, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(MULT, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(DIV, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(QUADRADO, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(FAT, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(RAIZ, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LIMPAR, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(0, 108, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(40, 40, 40) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(NUM1) .addComponent(NUM2)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(NUM1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(7, 7, 7) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(NUM2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(5, 5, 5) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(RESULTADO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(MULT) .addComponent(LIMPAR) .addComponent(DIV)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(RAIZ) .addComponent(QUADRADO)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(FAT) .addComponent(SUBT) .addComponent(CUBO)) .addGap(23, 23, 23)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void NUM2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NUM2ActionPerformed }//GEN-LAST:event_NUM2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed double N1, N2, R; N1= Double.parseDouble(NUM1.getText()); N2 = Double.parseDouble(NUM2.getText()); R= N1 +N2;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_jButton1ActionPerformed private void RESULTADOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RESULTADOActionPerformed }//GEN-LAST:event_RESULTADOActionPerformed private void SUBTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SUBTActionPerformed double N1, N2, R; N1= Double.parseDouble(NUM1.getText()); N2 = Double.parseDouble(NUM2.getText()); R = N1 - N2;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_SUBTActionPerformed private void MULTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MULTActionPerformed double N1, N2, R; N1= Double.parseDouble(NUM1.getText()); N2 = Double.parseDouble(NUM2.getText()); R= N1 * N2;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_MULTActionPerformed private void DIVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DIVActionPerformed double N1, N2, R; N1= Double.parseDouble(NUM1.getText()); N2 = Double.parseDouble(NUM2.getText()); R= N1/N2;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_DIVActionPerformed private void CUBOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CUBOActionPerformed double N1, R; N1= Double.parseDouble(NUM1.getText()); R= N1*N1*N1;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_CUBOActionPerformed private void QUADRADOActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QUADRADOActionPerformed double N1, R; N1= Double.parseDouble(NUM1.getText()); R= N1 * N1;RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_QUADRADOActionPerformed private void FATActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FATActionPerformed double N1, f = 1,i = 2,R; N1= Double.parseDouble(NUM1.getText()); while(i<=N1){ f = f*i; i = i + 1; } R = f;RESULTADO.setText(String.valueOf(f)); }//GEN-LAST:event_FATActionPerformed private void LIMPARActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LIMPARActionPerformed NUM1.setText(""); NUM2.setText(""); RESULTADO.setText(""); }//GEN-LAST:event_LIMPARActionPerformed private void RAIZActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RAIZActionPerformed double N1, R; N1= Double.parseDouble(NUM1.getText()); R = Math.sqrt(N1);RESULTADO.setText(String.valueOf(R)); }//GEN-LAST:event_RAIZActionPerformed private void NUM1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NUM1ActionPerformed }//GEN-LAST:event_NUM1ActionPerformed private void jLabel1AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jLabel1AncestorAdded }//GEN-LAST:event_jLabel1AncestorAdded private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed }//GEN-LAST:event_jTextField1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { 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(ExemploCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(ExemploCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(ExemploCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(ExemploCalculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ExemploCalculadora().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton CUBO; private javax.swing.JButton DIV; private javax.swing.JButton FAT; private javax.swing.JButton LIMPAR; private javax.swing.JButton MULT; private javax.swing.JTextField NUM1; private javax.swing.JTextField NUM2; private javax.swing.JButton QUADRADO; private javax.swing.JButton RAIZ; private javax.swing.JTextField RESULTADO; private javax.swing.JButton SUBT; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel2; private javax.swing.JTextField jTextField1; // End of variables declaration//GEN-END:variables }
[ "Guilherme@LAPTOP-JQ6TVTQC" ]
Guilherme@LAPTOP-JQ6TVTQC
6faec807e9027978582196edf44b2311cea2619a
9a6ab5dfb3db9606464d5e83932dc412aa83bf08
/src/com/huofu/RestaurantOS/api/delivery/SetDeliveryOrderDeliverying.java
dbe7615a1307b254e26df964436e65a144551d1d
[]
no_license
sekdariusz/padAndroid
4cf172d19c520a2b3f34cc4d34a91823096603de
25858ab2d5d7c4a19a9f8445feac75d5cc7519f5
refs/heads/master
2021-12-13T13:27:20.049413
2017-03-19T08:41:20
2017-03-19T08:41:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
478
java
package com.huofu.RestaurantOS.api.delivery; import com.huofu.RestaurantOS.api.BaseApi; /** * author: Created by zzl on 15/8/31. */ public class SetDeliveryOrderDeliverying extends BaseApi{ @Override public String getApiAction() { return "5wei/delivery/order/delivering"; } @Override protected ApiResponse responseObjectParse(ApiResponse response) { if(this.isResponseOk(response)) { } return response; } }
[ "zhangzhonglei@163.com" ]
zhangzhonglei@163.com