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
8a66863e43a7fb814ecb3e88746e10b37018c9b3
3e5891022aed9a23691898414c0e50d28b4e504a
/focus-module/gateway/src/main/java/com/focus/module/gateway/swagger/SwaggerProvider.java
e420d17fdc93cf3fb9fd2f90a50251d670ae2650
[]
no_license
doublecancel/focus
c066229f041507852ae183a3fc47a007f3b8b9e2
5364d1c18a40257d05341b66fc6eee442d8c9435
refs/heads/master
2022-07-13T16:12:08.277375
2019-08-13T11:23:40
2019-08-13T11:23:40
187,060,365
0
0
null
2022-06-21T01:08:17
2019-05-16T16:03:38
Java
UTF-8
Java
false
false
2,137
java
package com.focus.module.gateway.swagger; import lombok.AllArgsConstructor; import org.springframework.cloud.gateway.config.GatewayProperties; import org.springframework.cloud.gateway.route.RouteLocator; import org.springframework.cloud.gateway.support.NameUtils; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import springfox.documentation.swagger.web.SwaggerResource; import springfox.documentation.swagger.web.SwaggerResourcesProvider; import java.util.ArrayList; import java.util.List; @Component @Primary @AllArgsConstructor public class SwaggerProvider implements SwaggerResourcesProvider { public static final String API_URI = "/v2/api-docs"; private final RouteLocator routeLocator; private final GatewayProperties gatewayProperties; @Override public List<SwaggerResource> get() { List<SwaggerResource> resources = new ArrayList<>(); List<String> routes = new ArrayList<>(); //取出gateway的route routeLocator.getRoutes().subscribe(route -> routes.add(route.getId())); //结合配置的route-路径(Path),和route过滤,只获取有效的route节点 gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId())) .forEach(routeDefinition -> routeDefinition.getPredicates().stream() .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") .replace("/**", API_URI))))); return resources; } private SwaggerResource swaggerResource(String name, String location) { SwaggerResource swaggerResource = new SwaggerResource(); swaggerResource.setName(name); swaggerResource.setLocation(location); swaggerResource.setSwaggerVersion("2.0"); return swaggerResource; } }
[ "liuxianglei@m-chain.com" ]
liuxianglei@m-chain.com
a8bcbead62687a9ff453494821369b9d1d354328
a370ff524a6e317488970dac65d93a727039f061
/src/main/java/template/algo/MatroidIntersect.java
1ea28621f836baff608cc86b8072cade88348a85
[]
no_license
taodaling/contest
235f4b2a033ecc30ec675a4526e3f031a27d8bbf
86824487c2e8d4fc405802fff237f710f4e73a5c
refs/heads/master
2023-04-14T12:41:41.718630
2023-04-10T14:12:47
2023-04-10T14:12:47
213,876,299
9
1
null
2021-06-12T06:33:05
2019-10-09T09:28:43
Java
UTF-8
Java
false
false
3,957
java
package template.algo; import template.primitve.generated.datastructure.IntegerDequeImpl; import java.util.Arrays; import java.util.function.Consumer; /** * O(r) invoke computeAdj and extend. O(r^2n) */ public class MatroidIntersect { protected IntegerDequeImpl dq; protected int[] dists; protected boolean[] added; protected boolean[][] adj1; protected boolean[][] adj2; protected int n; protected boolean[] x1; protected boolean[] x2; protected static int distInf = (int) 1e9; protected int[] pre; protected Consumer<boolean[]> callback; protected static Consumer<boolean[]> nilCallback = x -> { }; public void setCallback(Consumer<boolean[]> callback) { if (callback == null) { callback = nilCallback; } this.callback = callback; } public MatroidIntersect(int n) { this.n = n; dq = new IntegerDequeImpl(n); dists = new int[n]; added = new boolean[n]; adj1 = new boolean[n][]; adj2 = new boolean[n][]; x1 = new boolean[n]; x2 = new boolean[n]; pre = new int[n]; setCallback(nilCallback); } protected boolean adj(int i, int j) { if (added[i]) { return adj1[i][j]; } else { return adj2[j][i]; } } protected boolean expand(MatroidIndependentSet a, MatroidIndependentSet b, int round) { Arrays.fill(x1, false); Arrays.fill(x2, false); a.prepare(added); b.prepare(added); a.extend(added, x1); b.extend(added, x2); for (int i = 0; i < n; i++) { if (x1[i] && x2[i]) { pre[i] = -1; xorPath(i); return true; } } for (int i = 0; i < n; i++) { if (added[i]) { Arrays.fill(adj1[i], false); Arrays.fill(adj2[i], false); } } a.computeAdj(added, adj1); b.computeAdj(added, adj2); Arrays.fill(dists, distInf); Arrays.fill(pre, -1); dq.clear(); for (int i = 0; i < n; i++) { if (added[i]) { continue; } //right if (x1[i]) { dists[i] = 0; dq.addLast(i); } } int tail = -1; while (!dq.isEmpty()) { int head = dq.removeFirst(); if (x2[head]) { tail = head; break; } for (int j = 0; j < n; j++) { if (added[head] != added[j] && adj(head, j) && dists[j] > dists[head] + 1) { dists[j] = dists[head] + 1; dq.addLast(j); pre[j] = head; } } } if (tail == -1) { return false; } xorPath(tail); return true; } protected void xorPath(int tail) { boolean[] last1 = new boolean[n]; boolean[] last2 = new boolean[n]; for (boolean add = true; tail != -1; tail = pre[tail], add = !add) { assert added[tail] != add; added[tail] = add; if (add) { adj1[tail] = last1; adj2[tail] = last2; } else { last1 = adj1[tail]; last2 = adj2[tail]; adj1[tail] = null; adj2[tail] = null; } } } /** * Find a basis with largest possible size * * @param a * @param b * @return */ public boolean[] intersect(MatroidIndependentSet a, MatroidIndependentSet b) { Arrays.fill(added, false); int round = 0; callback.accept(added); while (expand(a, b, round)) { round++; callback.accept(added); } return added; } }
[ "taodaling@gmail.com" ]
taodaling@gmail.com
df497b6018c63de4c527132bfde9144ff3b1be95
ceced64751c092feca544ab3654cf40d4141e012
/DesignModel/src/main/java/com/pri/observer/Client.java
03f11e71a0a87c553b01e96b26bbd5f42eb1bff3
[]
no_license
1163646727/pri_play
80ec6fc99ca58cf717984db82de7db33ef1e71ca
fbd3644ed780c91bfc535444c54082f4414b8071
refs/heads/master
2022-06-30T05:14:02.082236
2021-01-05T08:02:40
2021-01-05T08:02:40
196,859,419
0
0
null
null
null
null
UTF-8
Java
false
false
1,039
java
package com.pri.observer; /** * className: Client <BR> * description: 客户端<BR> * remark: 观察者模式测试<BR> * author: ChenQi <BR> * createDate: 2019-09-02 20:14 <BR> */ public class Client { public static void main(String[] args) { // 实例化具体观察者 ChenQi; RealObserver realObserver = new RealObserver(); // 创建微信用户 ChenQi; WeiXinUser weiXinUser1 = new WeiXinUser("张三"); WeiXinUser weiXinUser2 = new WeiXinUser("李四"); WeiXinUser weiXinUser3 = new WeiXinUser("王五"); // 添加订阅者,是一个订阅主题的行为 ChenQi; realObserver.registerObserver(weiXinUser1); realObserver.registerObserver(weiXinUser2); realObserver.registerObserver(weiXinUser3); // 公众号更新消息发布给订阅的微信用户,是一个发布行为 ChenQi; realObserver.notifyAllObserver("公众号内容更新!"); realObserver.notifyAllObserver("测试是否消费成功!"); } }
[ "1163646727@qq.com" ]
1163646727@qq.com
a382794f073a3254f45e7bb1f9301f8c0a052bca
b084fbf785f5b115cc60b37ac0e32a3fe6e4fe30
/src/main/java/com/group_finity/mascot/script/Script.java
a6b7abf713ee727d67506d575dc548ee8548e518
[ "BSD-2-Clause" ]
permissive
helpimnotdrowning/shimeji-universal
efcc22d765a13454f32c7211da192129a4f892e3
bbfbef081da6d457c6c29a8e214a11d996ca9cd3
refs/heads/master
2023-07-27T22:30:42.018080
2021-09-11T04:00:37
2021-09-11T04:00:37
404,561,888
0
0
NOASSERTION
2021-09-09T02:38:24
2021-09-09T02:38:24
null
UTF-8
Java
false
false
2,247
java
package com.group_finity.mascot.script; import com.group_finity.mascot.exception.VariableException; import javax.script.*; /** * Original Author: Yuki Yamada of Group Finity (http://www.group-finity.com/Shimeji/) * Currently developed by Shimeji-ee Group. */ public class Script extends Variable { private static final ScriptEngineManager manager = new ScriptEngineManager(); private static final ScriptEngine engine = manager.getEngineByMimeType("text/javascript"); private final String source; private final boolean clearAtInitFrame; private final CompiledScript compiled; private Object value; public Script(final String source, final boolean clearAtInitFrame) throws VariableException { this.source = source; this.clearAtInitFrame = clearAtInitFrame; try { this.compiled = ((Compilable) engine).compile(this.source); } catch (final ScriptException e) { throw new VariableException("An error occurred in compiling a script: " + this.source, e); } } @Override public String toString() { return this.isClearAtInitFrame() ? "#{" + this.getSource() + "}" : "${" + this.getSource() + "}"; } @Override public void init() { setValue(null); } @Override public void initFrame() { if (this.isClearAtInitFrame()) { setValue(null); } } @Override public synchronized Object get(final VariableMap variables) throws VariableException { if (getValue() != null) { return getValue(); } try { setValue(getCompiled().eval(variables)); } catch (final ScriptException e) { throw new VariableException("An error occurred in script evaluation: " + this.source, e); } return getValue(); } private Object getValue() { return this.value; } private void setValue(final Object value) { this.value = value; } private boolean isClearAtInitFrame() { return this.clearAtInitFrame; } private CompiledScript getCompiled() { return this.compiled; } private String getSource() { return this.source; } }
[ "tigerhix@gmail.com" ]
tigerhix@gmail.com
50610b76c52f7071d0a866999d4e6f0bfe1b74e3
36c0a0e21f3758284242b8d2e40b60c36bd23468
/src/main/java/com/datasphere/server/query/druid/aggregations/CountAggregation.java
40a022c8fed44b3e91c5f5908a433bb3f87302b6
[ "LicenseRef-scancode-mulanpsl-1.0-en" ]
permissive
neeeekoooo/datasphere-service
0185bca5a154164b4bc323deac23a5012e2e6475
cb800033ba101098b203dbe0a7e8b7f284319a7b
refs/heads/master
2022-11-15T01:10:05.530442
2020-02-01T13:54:36
2020-02-01T13:54:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,008
java
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.datasphere.server.query.druid.aggregations; import com.fasterxml.jackson.annotation.JsonTypeName; import com.datasphere.server.query.druid.Aggregation; @JsonTypeName("count") public class CountAggregation implements Aggregation { String name; public CountAggregation(String name){ this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
[ "jack_r_ge@126.com" ]
jack_r_ge@126.com
704bf67a3f864517d9bf99f63b2c6f3d9f08e900
6e3d08c5660e27eb00233c73b302ecd918895098
/pet-clinic-data/src/main/java/guru/springframework/sfgpetclinic/model/Visit.java
e2341c06ae07f398ada373e208fb8c78c862ee45
[ "Apache-2.0" ]
permissive
wyzx/sfg-pet-clinic
ad4b3e410ab716a166a6015ac4fdeffd50328f53
a7aa31d7e6f186799d16c44f4ff89f295dc2e235
refs/heads/master
2020-05-07T10:05:04.995077
2019-07-24T16:57:08
2019-07-24T16:57:08
180,404,267
0
0
null
null
null
null
UTF-8
Java
false
false
702
java
package guru.springframework.sfgpetclinic.model; import java.time.LocalDate; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Setter @Getter @NoArgsConstructor @AllArgsConstructor @Builder @Entity @Table(name = "visits") public class Visit extends BaseEntity { @Column(name = "date") private LocalDate date; @Column(name = "description") private String description; @ManyToOne @JoinColumn(name = "pet_id") private Pet pet; }
[ "xav_pav@yahoo.fr" ]
xav_pav@yahoo.fr
594196c3133e18c06189259310b0641cede8dd00
86152af493decf40f53d7951d4c7f8a60f363d64
/seoulMarketDayAndroid/seoulMarketDayAndroid/app/src/main/java/com/stm/market/fragment/video/presenter/impl/MarketVideoPresenterImpl.java
1bd07a7ba95eb19e77d6ea3ba237cbc230f81c8f
[ "MIT" ]
permissive
MobileSeoul/2017seoul-15
b54fb7d95c6bf685203d9948e4087385b02f6170
620eb72e4cdba9f355327b66a299da257c5b0b40
refs/heads/master
2021-09-05T14:39:35.702491
2018-01-29T00:15:01
2018-01-29T00:15:01
119,310,262
5
1
null
null
null
null
UTF-8
Java
false
false
4,270
java
package com.stm.market.fragment.video.presenter.impl; import com.stm.common.dao.File; import com.stm.common.dao.Market; import com.stm.common.dao.User; import com.stm.common.dto.HttpErrorDto; import com.stm.common.flag.DefaultFileFlag; import com.stm.common.flag.InfiniteScrollFlag; import com.stm.market.fragment.video.interactor.MarketVideoInteractor; import com.stm.market.fragment.video.interactor.impl.MarketVideoInteractorImpl; import com.stm.market.fragment.video.presenter.MarketVideoPresenter; import com.stm.market.fragment.video.view.MarketVideoView; import java.util.List; /** * Created by ㅇㅇ on 2017-08-24. */ public class MarketVideoPresenterImpl implements MarketVideoPresenter { private MarketVideoInteractor marketVideoInteractor; private MarketVideoView marketVideoView; public MarketVideoPresenterImpl(MarketVideoView marketVideoView) { this.marketVideoInteractor = new MarketVideoInteractorImpl(this); this.marketVideoView = marketVideoView; } @Override public void init(User user, Market market) { marketVideoView.showProgressDialog(); marketVideoInteractor.setUser(user); marketVideoInteractor.setMarket(market); if (user != null) { String accessToken = user.getAccessToken(); marketVideoInteractor.setMarketRepository(accessToken); marketVideoInteractor.setFileRepository(accessToken); } else { marketVideoInteractor.setMarketRepository(); marketVideoInteractor.setFileRepository(); } } @Override public void onCreateView() { marketVideoView.setScrollViewOnScrollChangeListener(); Market market = marketVideoInteractor.getMarket(); long marketId = market.getId(); long offset = InfiniteScrollFlag.DEFAULT_OFFSET; marketVideoView.setScrollViewOnScrollChangeListener(); marketVideoInteractor.getFileListByIdAndTypeAndOffset(marketId, DefaultFileFlag.VIDEO_THUMBNAIL_TYPE, offset); } @Override public void onScrollChange(int difference) { if (difference <= 0) { marketVideoView.showProgressDialog(); Market market = marketVideoInteractor.getMarket(); long marketId = market.getId(); List<File> files = marketVideoInteractor.getFiles(); long offset = files.size(); marketVideoInteractor.getFileListByIdAndTypeAndOffset(marketId, DefaultFileFlag.VIDEO_THUMBNAIL_TYPE, offset); } } @Override public void onNetworkError(HttpErrorDto httpErrorDto) { if (httpErrorDto == null) { marketVideoView.showMessage("네트워크 불안정합니다. 다시 시도하세요."); } else { marketVideoView.showMessage(httpErrorDto.message()); } } @Override public void onClickVideo(File file, int position) { marketVideoView.showProgressDialog(); marketVideoInteractor.updateFileByHits(file, position); } @Override public void onSuccessGetFileListByIdAndTypeAndOffset(List<File> newFiles) { List<File> files = marketVideoInteractor.getFiles(); int fileSize = files.size(); int newFileSize = newFiles.size(); if (newFileSize > 0) { if(fileSize == 0){ marketVideoInteractor.setFiles(newFiles); marketVideoView.clearMarketVideoAdapter(); marketVideoView.setMarketVideoAdapterItem(newFiles); } else { marketVideoInteractor.setFilesAddAll(newFiles); marketVideoView.marketVideoAdapterNotifyItemRangeInserted(fileSize, newFileSize); } } else { marketVideoView.showEmptyView(); } marketVideoView.goneProgressDialog(); } @Override public void onSuccessUpdateFileByHits(int position) { List<File> files = marketVideoInteractor.getFiles(); File file = files.get(position); int prevHit = file.getHits(); file.setHits(prevHit + 1); marketVideoView.marketVideoAdapterNotifyItemChanged(position); marketVideoView.goneProgressDialog(); marketVideoView.navigateToVideoPlayerActivity(file); } }
[ "mobile@seoul.go.kr" ]
mobile@seoul.go.kr
284aaa4f7c3788e275cbf4c44abc7ef485c64e83
62d5f786cd248518f475acba5cdc8ec0c162c107
/scalable-ot-core/src/main/java/com/brotherjing/core/loadbalance/ServerEntity.java
c76bde78d69b209ae62baf8d7af7619085010fa0
[ "MIT" ]
permissive
Sudarsan-Sridharan/scalable-ot-java-backend
566e55ec0f826d23fca822e8f5a35e1ba1eb16fb
75287dcd02d6187b2f0895ff4af06fcb5799e9d2
refs/heads/master
2023-03-04T10:25:22.019141
2019-11-27T10:42:32
2019-11-27T10:42:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
416
java
package com.brotherjing.core.loadbalance; import lombok.Builder; import lombok.Data; import lombok.ToString; @Data @Builder @ToString public class ServerEntity { private String host; private int serverPort; private int dubboPort; public String getServerAddress() { return host + ":" + serverPort; } public String getDubboAddress() { return host + ":" + dubboPort; } }
[ "yang_ji@worksap.co.jp" ]
yang_ji@worksap.co.jp
0c2505d83ba318596abeac72db30b9157a48b540
322e857697c3bc562d7dec3fa4be145583916fd9
/ObjectsClasses/src/ObjectClassesExample.java
033cb668d43655469dbfe0239db6c9412a571e59
[]
no_license
gitsourced/JavaTutorials
a63fbe0d707c7bcdb1faa134822a739fad423376
062b0af4d73d79defed9799de3c5259674e7ada8
refs/heads/master
2022-11-04T21:50:05.515279
2020-06-26T22:44:01
2020-06-26T22:44:01
263,464,989
0
0
null
null
null
null
UTF-8
Java
false
false
315
java
public class ObjectClassesExample { public static void main(String[] args) { String name = new String("Bob"); System.out.println(name.toUpperCase()); System.out.println(name.toLowerCase()); System.out.println(name.equalsIgnoreCase("bob")); System.out.println(name.charAt(1)); } }
[ "COMPSCISTUDY@DESKTOP-M2PCUTN" ]
COMPSCISTUDY@DESKTOP-M2PCUTN
a763a44385728bdb6211ac7917ab78953d9c8a36
2a342d6d34693a0307684dcf8a2b0e2a8c56979c
/src/main/java/com/loiclude/PtitQuiz/model/Target.java
4078b7e12ff1dac9be03c44ba40638651a0be87d
[]
no_license
nguyentriloi/PtitQiz
2a5e4d8686666bf4656e66438967350bee374e53
1bbd08f679ec7243d15cf449100a5ed36163a975
refs/heads/master
2020-05-01T09:02:23.202844
2019-06-22T05:39:48
2019-06-22T05:39:48
177,390,543
0
0
null
null
null
null
UTF-8
Java
false
false
1,275
java
package com.loiclude.PtitQuiz.model; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "target") public class Target { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "date") private Date date; @Column(name = "id_monhoc") private Integer idMonhoc; @Column(name = "soccer") private Integer soccer; @Column(name = "ma_sv") private String maSv; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public Integer getIdMonhoc() { return idMonhoc; } public void setIdMonhoc(Integer idMonhoc) { this.idMonhoc = idMonhoc; } public Integer getSoccer() { return soccer; } public void setSoccer(Integer soccer) { this.soccer = soccer; } public String getMaSv() { return maSv; } public void setMaSv(String maSv) { this.maSv = maSv; } }
[ "Meograce@123" ]
Meograce@123
3fffb8a9e32898ce4c357683bea91c12f557d984
61af113714ca14303a8aa5901013fabe78b911d7
/src/main/java/aura/hadoop/mapreduce/mapreduce_writablecomparable01/ScoreDriver.java
171ec3f3dec733a1d937e5538de77985b072dd98
[]
no_license
linyongfei001/SSODemo
0c57b05290e22d3914df64eb257c9a4a34963c76
60edaff9ae600870fc548161f6eca90df4854cd4
refs/heads/master
2022-12-22T09:26:09.015376
2019-07-02T07:39:05
2019-07-02T07:39:05
190,027,538
0
0
null
2022-12-16T07:46:07
2019-06-03T15:00:28
Java
UTF-8
Java
false
false
1,195
java
package aura.hadoop.mapreduce.mapreduce_writablecomparable01; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class ScoreDriver { public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException { System.setProperty("HADOOP_USER_NAME", "hadoop"); Configuration conf=new Configuration(); Job job=Job.getInstance(conf); job.setJarByClass(ScoreDriver.class); job.setMapperClass(ScoreMapper.class); job.setReducerClass(ScoreReducer.class); //设置map和reduce的输出 如果map和reduce的输出的key value类型一样 只需要设置一个 //设置最终的输出类型就可以 job.setOutputKeyClass(ScoreBean.class); job.setOutputValueClass(Text.class); FileInputFormat.addInputPath(job, new Path("hdfs://hadoop01:9000/scorein")); FileOutputFormat.setOutputPath(job, new Path("hdfs://hadoop01:9000/scoreout06")); job.waitForCompletion(true); } }
[ "1451500795@qq.com" ]
1451500795@qq.com
e1a487c33d959b629c955b9eda03a847415e41a6
276df0eab5504f7e0253153175ff8cab0a2705ae
/Engine/mahout-core/org/apache/mahout/cf/taste/impl/common/SamplingIterator.java
2e9cf491897535158cf1c639daf74f0975d45c82
[]
no_license
ankitgoswami/SuggestionEngine
0b9b56d276e515d1e6ede0f2c5e83ebb8ed30011
9279f47f0aa2df81f21d9150375df2c8418204e7
refs/heads/master
2016-09-05T23:26:16.245404
2012-03-01T10:22:53
2012-03-01T10:22:53
3,546,476
2
2
null
null
null
null
UTF-8
Java
false
false
2,800
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.mahout.cf.taste.impl.common; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Random; /** * Wraps an {@link Iterator} and returns only some subset of the elements that it would, as determined by a sampling * rate parameter. */ public final class SamplingIterator<T> implements Iterator<T> { private static final Random r = RandomUtils.getRandom(); private final Iterator<? extends T> delegate; private final double samplingRate; private T next; private boolean hasNext; public SamplingIterator(Iterator<? extends T> delegate, double samplingRate) { this.delegate = delegate; this.samplingRate = samplingRate; this.hasNext = true; doNext(); } @Override public boolean hasNext() { return hasNext; } @Override public T next() { if (hasNext) { T result = next; doNext(); return result; } throw new NoSuchElementException(); } private void doNext() { boolean found = false; if (delegate instanceof SkippingIterator) { SkippingIterator<? extends T> skippingDelegate = (SkippingIterator<? extends T>) delegate; int toSkip = 0; while (r.nextDouble() >= samplingRate) { toSkip++; } // Really, would be nicer to select value from geometric distribution, for small values of samplingRate if (toSkip > 0) { skippingDelegate.skip(toSkip); } if (skippingDelegate.hasNext()) { next = skippingDelegate.next(); found = true; } } else { while (delegate.hasNext()) { T delegateNext = delegate.next(); if (r.nextDouble() < samplingRate) { next = delegateNext; found = true; break; } } } if (!found) { hasNext = false; next = null; } } /** * @throws UnsupportedOperationException */ @Override public void remove() { throw new UnsupportedOperationException(); } }
[ "sharadjain.sj@gmail.com" ]
sharadjain.sj@gmail.com
4fbc6d5da6080b5dbe7c02f703243f609d2870cc
5eaa268d2b26a1e6b9c8ed8ef5d024a4e4c3c7f8
/src/week08/zoo_v2/Fish.java
c939d32402b5bbedc82c1d934bc1f6b2cc3b744b
[]
no_license
nordnes/CS102
df0389ae3277526ea8c51ff44d0ac221ddf2b668
35e313eb606a46e4e414056f9ee91acf7572c39d
refs/heads/master
2020-05-01T08:32:37.405783
2018-05-15T07:36:09
2018-05-15T07:36:09
null
0
0
null
null
null
null
UTF-8
Java
false
false
262
java
package week08.zoo_v2; public abstract class Fish extends Animal implements Swimmer { public Fish(String name, String color) { super(name, color); } public void swim() { System.out.println(this.getName() + " is swimming."); } }
[ "baris.aktemur@ozyegin.edu.tr" ]
baris.aktemur@ozyegin.edu.tr
0c9631cc8bfeeca79f6480a8a6397d0c1e5efa50
ed166738e5dec46078b90f7cca13a3c19a1fd04b
/minor/guice-OOM-error-reproduction/src/main/java/gen/I_Gen147.java
a1e25fb7ebde63c028903b30472205efeaa27fed
[]
no_license
michalradziwon/script
39efc1db45237b95288fe580357e81d6f9f84107
1fd5f191621d9da3daccb147d247d1323fb92429
refs/heads/master
2021-01-21T21:47:16.432732
2016-03-23T02:41:50
2016-03-23T02:41:50
22,663,317
2
0
null
null
null
null
UTF-8
Java
false
false
331
java
package gen; public class I_Gen147 { @com.google.inject.Inject public I_Gen147(I_Gen148 i_gen148){ System.out.println(this.getClass().getCanonicalName() + " created. " + i_gen148 ); } @com.google.inject.Inject public void injectInterfaceWithoutImpl(gen.InterfaceWithoutImpl i){} // should expolode :) }
[ "michal.radzi.won@gmail.com" ]
michal.radzi.won@gmail.com
0c059c59c84cd4d451a9b627e1a781f4597f77cb
5d0b2e4b8bafa0784a778a74694092a876265ba7
/chicha/src/main/java/sw/chicha/Schedule/domain/Schedule.java
6b126f49ca6ff5a1f39387f73057110e27f53cc0
[]
no_license
leeyeonjeong/chicha
936d3cc058284986dd20052f8d06d2d2af31cf34
24667ef5d7c5fc449b6533ebdb61c874c2a8a45b
refs/heads/master
2023-08-04T19:47:30.969303
2021-09-15T04:19:01
2021-09-15T04:19:01
301,101,730
0
0
null
null
null
null
UTF-8
Java
false
false
1,921
java
package sw.chicha.Schedule.domain; import lombok.*; import org.springframework.data.annotation.CreatedDate; import sw.chicha.Calendar.domain.Calendar; import sw.chicha.Coach.domain.Coach; import sw.chicha.Coach.dto.CoachDto; import sw.chicha.Member.domain.Therapist; import javax.persistence.*; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) // 기본 생성자 (protected type) @Entity @Getter public class Schedule { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; private String state; // 전체 상태 private String start; private String end; private String repitation; private String memo; private String child; private String gender; private String birthday; private String session; private String counseling; @CreatedDate private LocalDate createdDate; @ManyToOne @JoinColumn(name = "calendar_id") private Calendar calendar; @OneToOne @JoinColumn(name = "coach_id") private Coach coach; @Builder public Schedule(Long id, String name, String state, String start, String end, String repitation,String memo,String child, String gender, String birthday, LocalDate createdDate,Calendar calendar,Coach coach, String session, String counseling) { this.id = id; this.name = name; this.state = state; this.start = start; this.end = end; this.repitation = repitation; this.memo = memo; this.child = child; this.gender = gender; this.birthday = birthday; this.createdDate = createdDate; this.calendar = calendar; this.coach = coach; this.session = session; this.counseling = counseling; } }
[ "lee965870@naver.com" ]
lee965870@naver.com
01ffa93373d068bb86221454b0a714deda0797a2
8a84d4f9824c0fd28bb3646d2fe8f2c0f32af760
/e-vending/src/main/java/com/mkyong/users/dao/UserDao.java
24f1da3893219f3feb10a2be93c1817bdf4cab91
[]
no_license
Severov/e-vending
ec52c8c30c0610219d1fb3975d0b4c6ce801ed7f
ee65d88d796f4f32f78ab6c5f98bf5862e5dfe3d
refs/heads/master
2021-01-10T15:36:39.192331
2015-10-28T15:10:18
2015-10-28T15:10:18
45,034,267
0
0
null
null
null
null
UTF-8
Java
false
false
383
java
package com.mkyong.users.dao; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.mkyong.users.model.User; public interface UserDao { User findByUserName(String username); @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) void saveUser(User user); }
[ "mishka@debian-pavilion" ]
mishka@debian-pavilion
e7f84d5600950552425f88a7ec89fc8e9ab2b87f
860abece3545a35328cea17054bf7abbcd09ee69
/Source Code/OSMS/OSMSValidator/OSMSValidatorREST/src/main/java/com/gcom/osms/validator/rest/OSMSValidatorService.java
ea485484d16bb70153c7c999ff07567e17fed9ae
[]
no_license
message-switch/main
6dcdc7b0307daac6539642c9a2e729de37557d70
b7d7ca8515c53da6db7639267c250aeb4002f810
refs/heads/master
2021-05-11T06:57:31.883699
2018-10-24T20:24:53
2018-10-24T20:24:53
118,005,211
0
1
null
null
null
null
UTF-8
Java
false
false
2,396
java
/** * Copyright (c) GCOM Software Inc, NY. All Rights Reserved. * * THIS INFORMATION IS COMPANY CONFIDENTIAL. * * NOTICE: This material is a confidential trade secret and proprietary * information of GCOM Software Inc, NY which may not be reproduced, used, sold, or * transferred to any third party without the prior written consent of GCOM Software Inc, NY. */ package com.gcom.osms.validator.rest; import java.nio.file.Files; import java.nio.file.Paths; import javax.enterprise.context.RequestScoped; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.gcom.osms.validator.common.ValidatorRequest; import com.gcom.osms.validator.common.ValidatorResponse; import com.gcom.osms.validator.exception.OSMSValidatorServiceException; import com.gcom.osms.validator.service.RuleValidatorService; import com.gcom.osms.validator.services.impl.RuleValidatorServiceImpl; @Path("/OSMSValidator") @Consumes("application/json") @Produces("application/json") @RequestScoped /** * * Rest service for OSMSValidations * */ public class OSMSValidatorService { /** The Constant LOGGER. */ private static final Logger LOGGER = LoggerFactory.getLogger(OSMSValidatorService.class); /** * Instantiate Constructor */ public OSMSValidatorService() { } /** * Execute validations * @param request * @return * @throws OSMSValidatorServiceException */ @POST @Path("validate") public ValidatorResponse validate(final ValidatorRequest request) throws OSMSValidatorServiceException { LOGGER.debug("inside validate params{request: {}}"+request); RuleValidatorService ruleValidatorService = new RuleValidatorServiceImpl(); ValidatorResponse response = ruleValidatorService.executeValidations(request); LOGGER.debug("end validate "+response); return response; } public static void main(String[] args) throws Exception { String fileName = "C://Users/jchalamala/Desktop/projects/OSMS/Message Log XML/FQ.xml"; String content = new String(Files.readAllBytes(Paths.get(fileName))); ValidatorRequest request = new ValidatorRequest(); request.setMessage(content); request.setContentType("XML"); request.setMke("FQ"); request.setInputSource("NLETS"); OSMSValidatorService m = new OSMSValidatorService(); m.validate(request); } }
[ "mdiwan@gcomsoft.com" ]
mdiwan@gcomsoft.com
1f5d5ec762841d2e0c80b92f69c1ab857e29ee98
ad64a14fac1f0d740ccf74a59aba8d2b4e85298c
/linkwee-supermarket/src/main/java/com/linkwee/web/dao/CimProductMapper.java
ee52dcb8e2629b4ef4af0b5f96d2f644175864aa
[]
no_license
zhangjiayin/supermarket
f7715aa3fdd2bf202a29c8683bc9322b06429b63
6c37c7041b5e1e32152e80564e7ea4aff7128097
refs/heads/master
2020-06-10T16:57:09.556486
2018-10-30T07:03:15
2018-10-30T07:03:15
193,682,975
0
1
null
2019-06-25T10:03:03
2019-06-25T10:03:03
null
UTF-8
Java
false
false
11,469
java
package com.linkwee.web.dao; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.session.RowBounds; import com.linkwee.api.request.cim.HotProductRequest; import com.linkwee.api.request.cim.ProductCateForShowRequest; import com.linkwee.api.request.cim.ProductDetailRequest; import com.linkwee.api.request.cim.ProductPageList4Request; import com.linkwee.api.request.cim.ProductPageListClassifyRequest; import com.linkwee.api.request.cim.ProductPageListLimitRequest; import com.linkwee.api.request.cim.ProductPageListRecommendRequest; import com.linkwee.api.request.cim.ProductPageListRequest; import com.linkwee.api.request.cim.ProductStatisticsRequest; import com.linkwee.api.request.cim.ScreenProductPageListRequest; import com.linkwee.api.request.cim.SelectedProductsListRequest; import com.linkwee.api.response.cim.ProductDetailResponse; import com.linkwee.api.response.cim.ProductInvestResponse; import com.linkwee.api.response.cim.ProductPageList4Response; import com.linkwee.api.response.cim.ProductPageListResponse; import com.linkwee.api.response.cim.ProductStatistics460Response; import com.linkwee.api.response.cim.ProductStatisticsResponse; import com.linkwee.core.datatable.DataTable; import com.linkwee.core.generic.GenericDao; import com.linkwee.core.orm.paging.Page; import com.linkwee.openapi.response.OmsProductResponse; import com.linkwee.web.model.CimProduct; import com.linkwee.web.request.ProductListDataRequest; import com.linkwee.web.request.ProductSaleDetailRequest; import com.linkwee.web.request.ProductSaleListRequest; import com.linkwee.web.request.ProductsSalesStatisticsRequest; import com.linkwee.web.response.ProductDetailForManageResponse; import com.linkwee.web.response.ProductListForManageResponse; import com.linkwee.web.response.ProductSaleDetailResponse; import com.linkwee.web.response.ProductSaleListResponse; import com.linkwee.web.response.ProductsSalesStatisticsResponse; import com.linkwee.web.response.act.ProductPageResponse; import com.linkwee.web.response.orgInfo.OrgSaleProductResponse; /** * * @描述: Dao接口 * * @创建人: liqi * * @创建时间:2016年07月14日 18:23:34 * * Copyright (c) 深圳领会科技有限公司-版权所有 */ public interface CimProductMapper extends GenericDao<CimProduct,Long>{ /** * 封装DataTable对象查询 * @param dt * @param page * @return */ List<CimProduct> selectBySearchInfo(@Param("dt")DataTable dt,RowBounds page); /** * 查询热门产品 * @param userId * @param page * @return */ List<ProductPageListResponse> queryHotProduct(HotProductRequest hotProductRequest,RowBounds page); /** * 理财-产品列表 * @param userId * @param page * @return */ List<ProductPageListResponse> queryProductPageList(ProductPageListRequest productPageListRequest,Page<ProductPageListResponse> page); /** * 理财-理财师推荐产品列表 带排序 * @param userId * @param page * @return */ List<ProductPageListResponse> queryRecdProductPageList(ProductPageListRecommendRequest productPageListRecommendRequest,Page<ProductPageListResponse> page); /** * 查询机构在售产品列表 * @param orgNumber 机构编码 * @param page 分页信息 * @return */ List<OrgSaleProductResponse> queryOrgSaleProducts(@Param("orgNumber")String orgNumber,RowBounds page); /** * 查询产品详情 * @param productDetailRequest * @return */ ProductDetailResponse queryProductDetail(ProductDetailRequest productDetailRequest); /** * 获取浮动期限产品 - * @return */ List<CimProduct> getFlowProducts(); /** * 查询筛选产品 * @param productPageListRequest * @param page * @return */ List<ProductPageListResponse> queryProductScreenPageList(ScreenProductPageListRequest productPageListRequest, Page<ProductPageListResponse> page); /** * 根据条件查询产品 * @param orgNumber * @param proName * @param page * @return */ List<ProductPageResponse> queryProductByProductName(@Param("orgNumber")String orgNumber,@Param("proName")String proName,RowBounds page); /** * 根据条件查询产品 * @param pids * @param page * @return */ List<ProductPageResponse> queryProductByProductIds(@Param("pids")String[] pids); /** * 管理后台查询产品列表 * @param productListDataRequest * @param page * @return */ List<ProductListForManageResponse> selectProductListForManage(@Param("query")ProductListDataRequest productListDataRequest,Page<ProductListForManageResponse> page); /** * 后台管理-根据产品id查询产品详情 * @param productId * @return */ ProductDetailForManageResponse queryProductDetailForManerge(String productId); /** * 产品审核 * @param auditType 审核类型 partAudit-部分审核 allAudit-全部审核 * @param auditCode 审核code 0-审核通过 1-审核未通过 * @param productTableIdList 待审核的产品表主键id列 格式 1,2,3,4 * @return */ void productAudit(@Param("auditType")String auditType,@Param("auditCode")Integer auditCode,@Param("productTableIdList")String productTableIdList); /** * 后台管理系统-查询产品销售列表 * @param productSaleListRequest * @param page * @return */ List<ProductSaleListResponse> selectProductSaleListForManage(@Param("query")ProductSaleListRequest productSaleListRequest,Page<ProductSaleListResponse> page); /** * 后台管理系统-查询产品销售详情 * @param productSaleDetailRequest * @return */ List<ProductSaleDetailResponse> selectProductSaleDetail(@Param("query")ProductSaleDetailRequest productSaleDetailRequest); /** * 查询产品销售统计 为data-tables封装 * @param productsSalesStatisticsRequest * @param page * @return */ List<ProductsSalesStatisticsResponse> selectSalesStatisticsByDatatables(@Param("query")ProductsSalesStatisticsRequest productsSalesStatisticsRequest,Page<ProductsSalesStatisticsResponse> page); /** * 查询产品销售统计 * @param productsSalesStatisticsRequest * @param page * @return */ List<ProductsSalesStatisticsResponse> selectSalesStatisticsByDatatables(@Param("query")ProductsSalesStatisticsRequest productsSalesStatisticsRequest); /** * 查询询产品销售详情(PC) * @param productId * @param page * @return */ List<ProductInvestResponse> getProductInvestList(@Param("productId")String productId,RowBounds page); /** * 查询产品分类统计 * @param productStatisticsRequest * @return */ List<ProductStatisticsResponse> productClassifyStatistics(ProductStatisticsRequest productStatisticsRequest); /** * 查询产品分类统计 * @param productStatisticsRequest * @return */ List<ProductStatistics460Response> productClassifyStatistics460(ProductStatisticsRequest productStatisticsRequest); /** * 理财师推荐产品 统计 * @param productStatisticsExtendRequest * @return */ ProductStatisticsResponse queryRecdProductStatistics(ProductStatisticsRequest productStatisticsRequest); /** * 根据产品分类查询产品分类列表 翻页 * @param productPageListClassifyRequest * @param page * @return */ List<ProductPageListResponse> queryProductCatePageList(ProductPageListClassifyRequest productPageListClassifyRequest,Page<ProductPageListResponse> page); /** * 根据产品分类查询产品分类列表 翻页 * @param productPageListClassifyRequest * @param page * @return */ List<ProductPageList4Response> queryProductCatePageList460(ProductPageList4Request productPageList4Request,Page<ProductPageList4Response> page); /** * 扩展产品分类查询产品分类列表 翻页 * @param productPageListClassifyRequest * @param page * @return */ List<ProductPageListResponse> queryProductCateExtendsPageList(ProductPageListClassifyRequest productPageListClassifyRequest,Page<ProductPageListResponse> page); /** * 扩展产品分类 产品 统计 * 901-首投标 902-复投标 * @param productStatisticsRequest * @return */ ProductStatisticsResponse queryProductCateExtendsStatistics(ProductStatisticsRequest productStatisticsRequest); /** * 查询产品可展示的标签列表 * @param productId * @return */ ArrayList<String> queryProductCateForShow(ProductCateForShowRequest productCateForShowRequest); /** * 根据机构代码更改产品的佣金 * @param orgNumber 机构代码 * @param feeRatio 佣金 * @return */ int updateFeeRatioByOrgNumber(@Param("orgNumber")String orgNumber, @Param("feeRatio")BigDecimal feeRatio); /** * 热推产品列表分页 * @param productPageListClassifyRequest * @param page * @return */ List<ProductPageListResponse> queryHotRecommendPageList(ProductPageListClassifyRequest productPageListClassifyRequest,Page<ProductPageListResponse> page); /** * 理财师最新推荐的产品 * @param productPageListRecommendRequest * @return */ ProductPageListResponse queryNewestRecdProduct(ProductPageListRecommendRequest productPageListRecommendRequest); /** * 没有投资记录的平台的新手标 * @param productPageListClassifyRequest * @return */ ProductPageListResponse queryNotInvestPlatformNewerProduct(ProductPageListClassifyRequest productPageListClassifyRequest); /** * * @param productPageListClassifyRequest * @return */ ProductPageListResponse queryProductCateList(ProductPageListClassifyRequest productPageListClassifyRequest); /** * 热推产品列表(TOP10) * @param ProductPageListRequest * @param page * @return */ List<ProductPageListResponse> queryHotRecommendPageListTop(ProductPageListRequest productPageListRequest); /** * 查询产品补全理财师排行榜 * @param productPageListLimitRequest * @return */ List<ProductPageListResponse> queryAddProductPageList(ProductPageListLimitRequest productPageListLimitRequest); /** * 查询产品列表4.0 * @param productPageList4Request * @param page * @return */ List<ProductPageList4Response> queryProductPageList4(ProductPageList4Request productPageList4Request,Page<ProductPageList4Response> page); /** * 查询产品列表统计4.0 * @param productPageList4Request * @return */ Integer productPageListStatistics4(ProductPageList4Request productPageList4Request); /** * 猎财大师首页精选产品 * @return */ List<ProductPageList4Response> querySelectedProducts(ProductPageListRequest productPageListRequest); /** * 猎财大师首页精选产品列表 * @param selectedProductsListRequest * @param page * @return */ List<ProductPageList4Response> querySelectedProductsList(SelectedProductsListRequest selectedProductsListRequest,Page<ProductPageList4Response> page); /** * 开放平台接入领会理财产品列表 * @param queryProductSql * @return */ List<OmsProductResponse> queryOmsProductList(@Param("queryProductSql")String queryProductSql,Page<OmsProductResponse> page); }
[ "liqimoon@qq.com" ]
liqimoon@qq.com
cc5d5562ba71c926795c0d110461adb2273fc104
2fdc9e132234f68c939360f4213447129e7b9f4d
/spring-boot-distributedlock/src/main/java/com/darren/center/springboot/filter/FilterChain.java
4aad8536d29e59094d91665751e36acc4eea7264
[]
no_license
axin1240101543/spring-boot
20086a3a9afb1f14b294097ee1fd41b2a91e5e67
af305bd7e367bd3422a879ab568660107d6fb529
refs/heads/master
2022-07-04T14:46:01.129482
2019-09-12T08:53:40
2019-09-12T08:53:40
176,437,648
0
2
null
2022-06-17T02:10:24
2019-03-19T06:14:52
CSS
UTF-8
Java
false
false
335
java
package com.darren.center.springboot.filter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public interface FilterChain { /** * 构建处理链 * @param request * @param response */ void handler(HttpServletRequest request, HttpServletResponse response); }
[ "1240101543@qq.com" ]
1240101543@qq.com
f8761833687391e68efb747ec20bd82214a19af0
dcb181bcde682958930a48184e9422b7f15d3fbd
/Testowy/src/RoomState.java
46d5af6df64f582093ee8abefde453607d6d033d
[]
no_license
jalowiec/test
10c9f28501c90947c27f1bf5a9a104bb56298587
76acc8f2fc08b98b31771c0a3692d9168ca3cb13
refs/heads/master
2020-03-10T02:58:43.937276
2018-04-20T19:07:40
2018-04-20T19:07:40
129,146,472
0
0
null
null
null
null
UTF-8
Java
false
false
72
java
public interface RoomState { public void stateDescription(); }
[ "lukasz.jalowiecki@gmail.com" ]
lukasz.jalowiecki@gmail.com
74f3e0f5325be4d33d04a4134778ff324e6a04d9
a703e00b9a7d317941187663a10d438a1a651b0c
/src/coinpurse/Valuable.java
9388de1c56679d15a7efaae8ee456dfc26413eee
[]
no_license
Pimwalun/coinpurse
3e1368f97cdd6229d3a4a1d3ca2852e5fb13b7fd
cad2795214c16570a86f00e52e5ba5145c62b2c8
refs/heads/master
2021-01-22T05:54:11.022095
2017-02-26T16:39:09
2017-02-26T16:39:09
81,719,122
0
0
null
null
null
null
UTF-8
Java
false
false
435
java
package coinpurse; /** * An interface for objects having a monetary value and currency. * @author Pimwalun Witchawanitchanun */ public interface Valuable extends Comparable<Valuable>{ /** * Get the monetary value of this object, in its own currency. * @return the value of this object */ public double getValue(); /** * Get the currency of item. * @return the currency of item */ public String getCurrency(); }
[ "janny25522009@hotmail.com" ]
janny25522009@hotmail.com
ed724f75663cebc8848b0c32fb82a456fd67a4ab
aa7fc9a5c155160d634df58a8b29b847e2305d5e
/emailtemplates-ui-starter/src/main/java/io/jmix/autoconfigure/emailtemplatesui/package-info.java
98734872d4901efb6415f2ac07ad941ad5c974bb
[ "Apache-2.0" ]
permissive
stvliu/jmix-emailtemplates
b2993554cccc2fd091825d7b9add2e65f701a708
7fe96ae540b53f09c165392c7493e6ec10677591
refs/heads/master
2023-03-29T17:53:36.831239
2021-03-24T13:37:40
2021-03-24T13:37:40
null
0
0
null
null
null
null
UTF-8
Java
false
false
693
java
/* * Copyright 2020 Haulmont. * * 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. */ @Internal package io.jmix.autoconfigure.emailtemplatesui; import io.jmix.core.annotation.Internal;
[ "orlova@haulmont.com" ]
orlova@haulmont.com
0857aeed73ed61255168ec153c9eebd26334b733
e545e261e5cadb90f6e9431de8b0a1311be28f2a
/src/main/java/com/library/controller/exceptions/BorrowNotFoundException.java
e0855e59a1c150998343ed521a07ab5d78acd18a
[]
no_license
daniellsoon/library-rest-api
b508b9814881db1258d3767c8a3867ffe1f1e711
fbf68599b0ca6c25d5bfa8c0d3ce44617f2bc844
refs/heads/master
2022-12-16T08:34:41.401027
2020-09-10T22:55:55
2020-09-10T22:55:55
262,011,755
0
0
null
null
null
null
UTF-8
Java
false
false
257
java
package com.library.controller.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value = HttpStatus.NOT_FOUND) public class BorrowNotFoundException extends Exception { }
[ "daniel.adamiec@hotmail.com" ]
daniel.adamiec@hotmail.com
cdb2fd51e6692137a530d8d65d31d29fb4579c4a
456ea24b146ca940807cfb7605f41be17f9b14e2
/project1027/SwingMail/src/com/swingmall/cart/Cart.java
5363e32f69c08270a62cd9054defb507b9f89e04
[]
no_license
ShinHyungjin/Java_WorkSpace
88832cba936ec9dd292908c65dde165182130e0f
1bfecfb8e830c40cbe85e7475f1cdf2ae507044b
refs/heads/master
2023-01-28T08:20:10.436036
2020-12-04T05:02:22
2020-12-04T05:02:22
305,313,266
0
0
null
null
null
null
UTF-8
Java
false
false
3,571
java
/* * 장바구니 페이지를 정의한다 * */ package com.swingmall.cart; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JPanel; import com.swingmall.main.Page; import com.swingmall.main.ShopMain; public class Cart extends Page{ JPanel bt_container; //버튼을 묶어줄 컨테이너 JButton bt_pay;//결제단계로 가기 JButton bt_del; //장바구니 비우기 //장바구니 역할을 컬렉션 프레임웍 객체를 선언 HashMap<Integer,CartVO> cartList; JPanel p_content; public Cart(ShopMain shopMain) { super(shopMain); cartList = new HashMap<Integer, CartVO>(); //this.setBackground(Color.BLACK); bt_container = new JPanel(); bt_pay = new JButton("결제하기"); bt_del = new JButton("장바구니 비우기"); //스타일 bt_container.setPreferredSize(new Dimension(ShopMain.WIDTH, 100)); bt_container.setBackground(Color.CYAN); //getCartList(); bt_container.add(bt_pay); bt_container.add(bt_del); add(bt_container, BorderLayout.SOUTH); bt_del.addActionListener((e) -> { removeAll(); }); } //장바구니에 넣기 public void addCart(CartVO vo) { //상품1건을 장바구니에 추가하기!!! cartList.put(vo.getProduct_id(), vo); //key와 값을 저장 } //장바구니 삭제하기 public void removeCart(int key) { //상품1건을 장바구니에서 제거하기 cartList.remove(key); } //장바구니 비우기 public void removeAll() { //모든 상품을 장바구니에서 제거하기 if(JOptionPane.showConfirmDialog(this, "정말 모든 내역을 삭제하시겠습니까?")==JOptionPane.OK_OPTION) { cartList.clear(); getCartList(); } } public void updateCart(int key, int ea) { cartList.get(key).setEa(ea); } //장바구니 목록 가져오기 (주의: 맵은 순서가 없는 집합이므로 먼저 일렬로 늘어뜨려야 한다..그 후 접근..) public void getCartList() { Set<Integer> set = cartList.keySet(); //키들을 set으로 반환받는다..즉 맵은 한번에 일렬로 늘어서는 것이 아니라, set으로 먼저 //key를 가져와야 함 Iterator<Integer> it = set.iterator(); //add()하기 전에 기존에 붙어있던 모든 컴포넌트는 제거 int count=0; if(p_content!=null) { this.remove(p_content); this.revalidate(); this.updateUI(); this.repaint(); } p_content = new JPanel(); p_content.setPreferredSize(new Dimension(ShopMain.WIDTH-350, 500)); while(it.hasNext()) {//요소가 있는 동안.. int key=it.next();//요소를 추출 System.out.println("key : "+key); CartVO vo=cartList.get(key); //디자인을 표현하는 CartItem에 CartVO의 정보를 채워넣자!! CartItem item = new CartItem(vo); item.bt_del.addActionListener((e) -> { if(JOptionPane.showConfirmDialog(this, "정말 삭제하시겠습니까?")==JOptionPane.OK_OPTION) { removeCart(vo.getProduct_id()); getCartList(); } }); item.bt_update.addActionListener((e) -> { if(JOptionPane.showConfirmDialog(this, "정말 수량을 수정 하시겠습니까?")==JOptionPane.OK_OPTION) { updateCart(vo.getProduct_id(), Integer.parseInt(item.t_ea.getText())); getCartList(); } }); p_content.add(item); count++; } add(p_content); this.updateUI(); System.out.println("count is "+count); } }
[ "shinhyungjin@naver.com" ]
shinhyungjin@naver.com
7f26515e0b63603c5bb1e83d9221fafaa967e779
7a4a3daf299c451a7f5104e7632027240dace19b
/Week_07/itjun-week07-homework02/base-mysql-proxy/src/main/java/io/itjun/week07/work14/datasource/SlaveDatasource.java
a3e151f82092b27c5726e5e57010a54df70cbee8
[]
no_license
itjun/JAVA-01
6135aefad5f660c8b805de27f1093d4c8e387c6c
bd1d1822625a0a70e1c16a1ae46029ac285fcc33
refs/heads/main
2023-05-01T15:37:28.874177
2021-05-16T13:56:31
2021-05-16T13:56:31
325,822,092
0
0
null
2020-12-31T15:03:19
2020-12-31T15:03:18
null
UTF-8
Java
false
false
736
java
package io.itjun.week07.work14.datasource; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import java.util.ArrayList; import java.util.List; @Configuration @ConfigurationProperties(prefix = "datasource") public class SlaveDatasource { List<BaseDataSourceAttribute> slave = new ArrayList<BaseDataSourceAttribute>(); public SlaveDatasource() { } public SlaveDatasource(List<BaseDataSourceAttribute> slave) { this.slave = slave; } public List<BaseDataSourceAttribute> getSlave() { return slave; } public void setSlave(List<BaseDataSourceAttribute> slave) { this.slave = slave; } }
[ "l1091462907@gmail.com" ]
l1091462907@gmail.com
f99ae417bd5fd902ce847e312b8571f5304fd010
b24e0163985b052650e81d1381a71a0ab5219472
/src/main/java/dev/omoladecodes/employeemanagement/exception/ResourceNotFoundException.java
d4d3a2d3603a2fb783820832ab605f1eb00405ff
[]
no_license
Omojolade/EmployeeManagementSystem
1ed0c79da3dccd0cabb1edc291c7ada60a5b5740
aba31d46c2de2f355962b7cb513d658f109e9947
refs/heads/master
2023-07-27T00:40:58.441573
2021-09-11T00:29:01
2021-09-11T00:29:01
405,247,195
0
0
null
null
null
null
UTF-8
Java
false
false
946
java
package dev.omoladecodes.employeemanagement.exception; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; @ResponseStatus(value= HttpStatus.NOT_FOUND) public class ResourceNotFoundException extends RuntimeException{ private static final long serialVersionUID = 1L; private String resourceName; private String fieldName; private Object fieldValue; public ResourceNotFoundException(String resourceName, String fieldName, Object fieldValue) { super(String.format("%s not found %s : '%s'", resourceName,fieldName,fieldValue)); this.resourceName = resourceName; this.fieldName = fieldName; this.fieldValue = fieldValue; } public String getResourceName() { return resourceName; } public String getFieldName() { return fieldName; } public Object getFieldValue() { return fieldValue; } }
[ "omoladeomololu@gmail.com" ]
omoladeomololu@gmail.com
d705d0b4207c021b79849b697683f64d5f9d2654
672122a49e104424393c413eeac954f4ae33ed1a
/src/main/java/com/example/landsale/repository/UserRepository.java
3f6e5808ca31394ea0a2778a8f5c5a0107f146f3
[]
no_license
RavinduLakmal/landsale
627185f14df235eaebc23cd93949dec3789e4b75
54a069530109a5e9d2bd18608a3da2dfa19e73d3
refs/heads/master
2021-06-16T04:50:46.599916
2019-07-11T08:15:12
2019-07-11T08:15:12
193,671,072
0
0
null
2021-04-26T19:20:05
2019-06-25T08:53:02
Java
UTF-8
Java
false
false
326
java
package com.example.landsale.repository; import com.example.landsale.entit.User; import com.example.landsale.repository.custom.UserCustom; import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository<User,Long>, UserCustom { User findByUsername(String userName); }
[ "ravindulakmal624@gmail.com" ]
ravindulakmal624@gmail.com
af93a9734a7560602ba10279a12d064f640e141d
0bbf0904d118db2b9365544e728fdbc3540dd278
/src/main/java/jhaturanga/commons/Pair.java
6031c196f3015a8db400d46d71777f3c68addbb9
[ "MIT" ]
permissive
apaz4/Jhaturanga
e6b627c5bef1e473da37a226c051c7198680e44f
0e10592651c6ca7526af15ac81e4c24993c677c2
refs/heads/master
2023-08-16T16:53:46.634670
2021-10-01T08:34:26
2021-10-01T08:34:26
412,389,851
0
0
null
null
null
null
UTF-8
Java
false
false
1,712
java
package jhaturanga.commons; /* * A standard generic Pair<X,Y>, with getters, hashCode, equals, and toString well implemented. */ public final class Pair<X, Y> { private final X x; private final Y y; public Pair(final X x, final Y y) { super(); this.x = x; this.y = y; } /** * Get the first value of the pair. * * @return the X value of the pair */ public X getX() { return x; } /** * Get the second value of the pair. * * @return the Y value of the pair */ public Y getY() { return y; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((x == null) ? 0 : x.hashCode()); result = prime * result + ((y == null) ? 0 : y.hashCode()); return result; } @SuppressWarnings("rawtypes") @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Pair other = (Pair) obj; if (x == null) { if (other.x != null) { return false; } } else if (!x.equals(other.x)) { return false; } if (y == null) { if (other.y != null) { return false; } } else if (!y.equals(other.y)) { return false; } return true; } @Override public String toString() { return "Pair [x=" + x + ", y=" + y + "]"; } }
[ "apaz4@miners.utep.edu" ]
apaz4@miners.utep.edu
26f548076aebf56a272044bb7a9cef4781be86ff
2b6cfe45e00bdefad33432d8a29baae82391fc3b
/src/main/java/com/gahon/utils/IpUtils.java
8ef6360442de88979c182a0bd47e6f8bb253733d
[]
no_license
Gahon1995/GahonUtils
beedb7adb0600a816ab68e49af385bed8d715ad4
42a3bd5d3641fedcaf6a1204bd1b5bb61b2354d9
refs/heads/master
2022-12-21T02:33:36.281924
2021-04-15T15:52:20
2021-04-15T15:52:20
233,371,123
0
0
null
2022-12-16T05:11:32
2020-01-12T09:57:59
Java
UTF-8
Java
false
false
1,876
java
package com.gahon.utils; import javax.servlet.http.HttpServletRequest; /** * @author Gahon * @date 2020/1/12 */ public class IpUtils { /** * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, * <p> * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 * <p> * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, * 192.168.1.100 * <p> * 用户真实IP为: 192.168.1.110 * * @param request * @return */ public static String getIpAddr(HttpServletRequest request) { String ip = request.getHeader("X-Forwarded-For"); if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { ip = request.getHeader("X-Real-IP"); } 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(); } if (ip.contains(",")) { return ip.split(",")[0]; } else { return ip; } } }
[ "Gahon1995@gmail.com" ]
Gahon1995@gmail.com
3adf5bf653fc03689bcd29492b764d2c046ec963
400a926f706d2e754dea1235dd34eac782653a52
/atishay-workspace-Dec-9-0300hrs/target/robocode-1.7.2.2-Beta-src/robocode-1.7.2.2-Beta/robocode.samples/src/main/java/sampleex/Slave.java
e29bf25c1b61b8f7fa81a9e3c4f304cbcda3c008
[]
no_license
atishayjain25/Virtual-Combat
bfe42cc8a2ddac634ad17512f9376c53ab45752f
634ac7216426bf0aa8fa855a517c3b7253bc6fef
refs/heads/master
2016-09-09T20:19:47.549261
2010-12-13T15:25:23
2010-12-13T15:25:23
1,131,494
0
0
null
null
null
null
UTF-8
Java
false
false
1,226
java
/******************************************************************************* * Copyright (c) 2001, 2008 Mathew A. Nelson and Robocode contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://robocode.sourceforge.net/license/cpl-v10.html * * Contributors: * Pavel Savara * - Initial implementation *******************************************************************************/ package sampleex; import robocode.AdvancedRobot; import robocode.HitByBulletEvent; import robocode.ScannedRobotEvent; /** * This is robot derived from AdvancedRobot. * Only reason to use this inheritance and this class is that external robots are unable to call RobotPeer directly */ class Slave extends AdvancedRobot { final MasterBase parent; public Slave(MasterBase parent) { this.parent = parent; } public void run() { parent.run(); } public void onScannedRobot(ScannedRobotEvent e) { parent.onScannedRobot(e); } public void onHitByBullet(HitByBulletEvent e) { parent.onHitByBullet(e); } }
[ "atishayjain25@gmail.com" ]
atishayjain25@gmail.com
3e9dc9790fdd3ff340683642d2f62f93df831f89
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/10/10_ff53eaf3dd2a020888e9c9290f08a723f9be3dbb/ArchiveFragment/10_ff53eaf3dd2a020888e9c9290f08a723f9be3dbb_ArchiveFragment_s.java
7e28d25cbdc49a326ab2c0c0d50fc20faee497bc
[]
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
2,801
java
package se.slashat.slashat.fragment; import se.slashat.slashat.CallbackPair; import se.slashat.slashat.R; import se.slashat.slashat.adapter.EpisodeDetailAdapter; import se.slashat.slashat.adapter.PersonAdapter; import se.slashat.slashat.adapter.PersonalAdapter; import se.slashat.slashat.androidservice.EpisodePlayer; import se.slashat.slashat.async.EpisodeLoaderAsyncTask; import se.slashat.slashat.model.Episode; import se.slashat.slashat.model.Personal; import se.slashat.slashat.service.PersonalService; import android.app.ProgressDialog; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; public class ArchiveFragment extends ListFragment implements CallbackPair<Episode, Boolean> { public final static String EPISODEPLAYER = "episodePlayer"; public static final String ADAPTER = "adapter"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_archive, container, false); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle bundle = savedInstanceState == null ? getArguments() : savedInstanceState; @SuppressWarnings("unchecked") ArrayAdapter<Personal> adapter = (ArrayAdapter<Personal>) bundle.getSerializable(ADAPTER); // If no adapter is found in the bundle create a new one with all // people. if (adapter == null) { EpisodeLoaderAsyncTask episodeLoaderAsyncTask = new EpisodeLoaderAsyncTask(this); episodeLoaderAsyncTask.execute(); }else{ setListAdapter(adapter); } } /** * Callback from the Adapter requesting an episode to be played. */ @Override public void call(Episode episode, Boolean showDetails) { if (showDetails) { EpisodeDetailAdapter p = new EpisodeDetailAdapter(getActivity(), R.layout.archive_item_details, new Episode[] { episode },this); Bundle bundle = new Bundle(); bundle.putSerializable(ADAPTER, p); ArchiveFragment archiveFragment = new ArchiveFragment(); archiveFragment.setArguments(bundle); FragmentSwitcher.getInstance().switchFragment(archiveFragment, true); } else { ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setTitle("Buffrar avsnitt"); progressDialog.setMessage(episode.getFullEpisodeName()); progressDialog.show(); EpisodePlayer.getEpisodePlayer().stopPlay(); EpisodePlayer.getEpisodePlayer().initializePlayer(episode.getStreamUrl(), episode.getFullEpisodeName(), 0, progressDialog); } } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
3bce8df444d5df54b1fbd7d9f87d7b8d9f5a8340
fc31b57a1d225e0971b6def80293cb403ba35fdd
/Surveillance/src/Location.java
9617551077a8aceb117072ff5971219d7f3840db
[]
no_license
KovaxG/Distributed-Control-Systems-Project
7e95322c53ccf487b31cac208ae5883ee97921e0
890cbd54228e54c61517db75806974701afc7968
refs/heads/master
2020-06-14T09:42:05.716804
2017-01-16T14:50:22
2017-01-16T14:50:22
75,202,330
0
0
null
null
null
null
UTF-8
Java
false
false
619
java
public class Location { private int ID; private String latitude; private String longitude; private long timestamp; public Location(int id, String lat, String lon, long ts) { ID = id; latitude = lat; longitude = lon; timestamp = ts; } // End of Location public int getID() {return ID;} public String getLat() {return latitude;} public String getLon() {return longitude;} public long getTS() {return timestamp;} /// Actually to DIY JSON public String toString() { return "(" + ID + ", " + latitude + ", " + longitude + ", " + timestamp + ")"; } // End of toString } // End of Class Location
[ "georgesmth202@gmail.com" ]
georgesmth202@gmail.com
8a0fc1dce8869062fb2017a0b197232f26682cdb
fde82278bf3fe393ae9610be8d4b33a73074dc68
/app/src/main/java/com/lzh/volleywrapdemo/model/WeatherModel.java
496983f3b3bccaea46b45e0b551d933a0e8d6e2a
[]
no_license
jason0539/VolleyWrapDemo
ef97d7c501d954282a8fa2742a868a17ba7ad0fb
7798fae507d3dec29506d1a3fb4fce969d9411d7
refs/heads/master
2021-01-10T10:36:49.549397
2016-04-15T12:28:33
2016-04-15T12:28:33
52,347,421
0
0
null
null
null
null
UTF-8
Java
false
false
1,182
java
package com.lzh.volleywrapdemo.model; import org.json.JSONObject; import com.lzh.volleywrap.baseframe.http.HttpResponseListener; import com.lzh.volleywrap.middleframe.HttpClientWrapper; import com.lzh.volleywrapdemo.utils.DemoConstant; import android.text.TextUtils; /** * liuzhenhui 16/2/22.下午8:59 */ public class WeatherModel { private static final String TAG = WeatherModel.class.getSimpleName(); public void getWeather(final WeatherCallback callback) { HttpResponseListener<JSONObject> listener = new HttpResponseListener<JSONObject>() { @Override public void onResponse(JSONObject response) { if (response != null) { callback.success(response.toString()); } } @Override public void onError(String msg) { if (!TextUtils.isEmpty(msg)) { callback.fail(msg); } } }; HttpClientWrapper.getInstance().getWeather(DemoConstant.API_KEY, listener); } public interface WeatherCallback { void fail(String msg); void success(String msg); } }
[ "jason0539@163.com" ]
jason0539@163.com
81423650b6f31c5ea7041c7a443f95c146760cae
12bbc5f851b94ff93663e623b8e2727058dd7cd8
/src/main/java/vn/homtech/dtls/config/LoggingConfiguration.java
8595cfdcc8f55684329280eefbf43dbb399ba007
[]
no_license
tkmd123/DTLS
3678e80b548c0b615037d47f4b2f4cff3e4fadaf
b23c967ea3883cfb2c9cf8c5b3027560b10ba6ca
refs/heads/master
2021-07-01T11:22:16.132273
2018-11-16T10:58:32
2018-11-16T10:58:32
157,855,134
0
1
null
2020-09-18T12:19:13
2018-11-16T10:58:23
Java
UTF-8
Java
false
false
6,578
java
package vn.homtech.dtls.config; import java.net.InetSocketAddress; import java.util.Iterator; import io.github.jhipster.config.JHipsterProperties; import ch.qos.logback.classic.AsyncAppender; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.boolex.OnMarkerEvaluator; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.LoggerContextListener; import ch.qos.logback.core.Appender; import ch.qos.logback.core.filter.EvaluatorFilter; import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.spi.FilterReply; import net.logstash.logback.appender.LogstashTcpSocketAppender; import net.logstash.logback.encoder.LogstashEncoder; import net.logstash.logback.stacktrace.ShortenedThrowableConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; @Configuration public class LoggingConfiguration { private static final String LOGSTASH_APPENDER_NAME = "LOGSTASH"; private static final String ASYNC_LOGSTASH_APPENDER_NAME = "ASYNC_LOGSTASH"; private final Logger log = LoggerFactory.getLogger(LoggingConfiguration.class); private LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); private final String appName; private final String serverPort; private final JHipsterProperties jHipsterProperties; public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort, JHipsterProperties jHipsterProperties) { this.appName = appName; this.serverPort = serverPort; this.jHipsterProperties = jHipsterProperties; if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { addLogstashAppender(context); addContextListener(context); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { setMetricsMarkerLogbackFilter(context); } } private void addContextListener(LoggerContext context) { LogbackLoggerContextListener loggerContextListener = new LogbackLoggerContextListener(); loggerContextListener.setContext(context); context.addListener(loggerContextListener); } private void addLogstashAppender(LoggerContext context) { log.info("Initializing Logstash logging"); LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender(); logstashAppender.setName(LOGSTASH_APPENDER_NAME); logstashAppender.setContext(context); String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}"; // More documentation is available at: https://github.com/logstash/logstash-logback-encoder LogstashEncoder logstashEncoder = new LogstashEncoder(); // Set the Logstash appender config from JHipster properties logstashEncoder.setCustomFields(customFields); // Set the Logstash appender config from JHipster properties logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort())); ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter(); throwableConverter.setRootCauseFirst(true); logstashEncoder.setThrowableConverter(throwableConverter); logstashEncoder.setCustomFields(customFields); logstashAppender.setEncoder(logstashEncoder); logstashAppender.start(); // Wrap the appender in an Async appender for performance AsyncAppender asyncLogstashAppender = new AsyncAppender(); asyncLogstashAppender.setContext(context); asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME); asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize()); asyncLogstashAppender.addAppender(logstashAppender); asyncLogstashAppender.start(); context.getLogger("ROOT").addAppender(asyncLogstashAppender); } // Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender private void setMetricsMarkerLogbackFilter(LoggerContext context) { log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME); OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator(); onMarkerMetricsEvaluator.setContext(context); onMarkerMetricsEvaluator.addMarker("metrics"); onMarkerMetricsEvaluator.start(); EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>(); metricsFilter.setContext(context); metricsFilter.setEvaluator(onMarkerMetricsEvaluator); metricsFilter.setOnMatch(FilterReply.DENY); metricsFilter.start(); for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) { for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) { Appender<ILoggingEvent> appender = it.next(); if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) { log.debug("Filter metrics logs from the {} appender", appender.getName()); appender.setContext(context); appender.addFilter(metricsFilter); appender.start(); } } } } /** * Logback configuration is achieved by configuration file and API. * When configuration file change is detected, the configuration is reset. * This listener ensures that the programmatic configuration is also re-applied after reset. */ class LogbackLoggerContextListener extends ContextAwareBase implements LoggerContextListener { @Override public boolean isResetResistant() { return true; } @Override public void onStart(LoggerContext context) { addLogstashAppender(context); } @Override public void onReset(LoggerContext context) { addLogstashAppender(context); } @Override public void onStop(LoggerContext context) { // Nothing to do. } @Override public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) { // Nothing to do. } } }
[ "jhipster-bot@jhipster.tech" ]
jhipster-bot@jhipster.tech
979b69785d1d4283238357d8b8833279a836b378
5e67d7d5bf36ca31bdf45cfb73afe1e82a5730f2
/src/homeWork/P4/Exe.java
430e9c62b967b131a770c5634cd115026b3fa7c3
[]
no_license
matasstoskus/Java
3415ea7c85d754968d04af82c71fa616259d9209
9718b9f46b8c6c1c78e61659de485b9aba0a932b
refs/heads/master
2022-12-26T06:10:38.386118
2020-10-06T07:13:42
2020-10-06T07:13:42
292,279,385
0
0
null
null
null
null
UTF-8
Java
false
false
1,421
java
package homeWork.P4; public class Exe { public static void main(String args[]) { int a[] = {1, 2, 5, 6, 3, 2}; int b[] = {44, 66, 99, 77, 33, 22, 55}; System.out.println("Smallest: " + getSmallest(a, 6)); System.out.println("Smallest: " + getSmallest(b, 7)); System.out.println("Largest: " + getLargest(a, 6)); System.out.println("Largest: " + getLargest(b, 7)); System.out.println("Sum: " + getSum(a)); System.out.println("Sum: " + getSum(b)); } public static int getSmallest(int[] a, int total) { int temp; for (int i = 0; i < total; i++) { for (int j = i + 1; j < total; j++) { if (a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } return a[0]; } public static int getLargest(int[] a, int total) { int temp; for (int i = 0; i < total; i++) { for (int j = i + 1; j < total; j++) { if (a[i] > a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } return a[total - 1]; } public static int getSum(int[] a) { int sum = 0; for (int value : a) { sum += value; } return sum; } }
[ "mac@MacBook-Air.Dlink" ]
mac@MacBook-Air.Dlink
80de20dd260a2b139d7f68ec79124e43dbadf84a
192bba47612258e74d4db83ed846ed386c0efbe8
/LTHDT/thuchanhonline/lthdt/ctu/edu/vn/SinhVien1.java
e272ef1193cae1b7866010b8cc95c3c9350d1733
[]
no_license
Tamabcxyz/javacode
68369518e2052abb2220608213233c01e7099843
f856cbd1934874114705cf3421ca97a1e65b5023
refs/heads/master
2020-05-16T20:06:09.795304
2019-04-25T01:49:45
2019-04-25T01:49:45
183,277,418
0
0
null
null
null
null
UTF-8
Java
false
false
978
java
package thuchanhonline.lthdt.ctu.edu.vn; public class SinhVien1 extends SinhVien{ private double diemTB; private XepLoai loai; public SinhVien1() { super(); // TODO Auto-generated constructor stub } public SinhVien1(int ma, String ten,double diemTB) { super(ma, ten); this.diemTB = diemTB; this.loai=kqloai(); // TODO Auto-generated constructor stub } public SinhVien1(SinhVien a) { super(a); // TODO Auto-generated constructor stub } public double getDiemTB() { return diemTB; } public void setDiemTB(float diemTB) { this.diemTB = diemTB; } public XepLoai kqloai() { if(this.diemTB>=8) { loai=XepLoai.gioi; } else if(this.diemTB>6.5&&diemTB<=8) { loai=XepLoai.kha; } else if(this.diemTB>5&&diemTB<6.5) { loai=XepLoai.trungbinh; } else { loai=XepLoai.yeu; } return loai; } public String toString() { String s=super.toString(); return s+" \tDiem TB "+this.diemTB+" \txep loai: "+this.loai.getMota(); } }
[ "minhtam16071999@gmail.com" ]
minhtam16071999@gmail.com
14a7b07d8d1f72798c3ed3d9b501bf73dd0cf9d6
329307375d5308bed2311c178b5c245233ac6ff1
/src/com/tencent/mm/protocal/b/jy.java
80e1c0b84e0d9922f1791860d551f4b22f950753
[]
no_license
ZoneMo/com.tencent.mm
6529ac4c31b14efa84c2877824fa3a1f72185c20
dc4f28aadc4afc27be8b099e08a7a06cee1960fe
refs/heads/master
2021-01-18T12:12:12.843406
2015-07-05T03:21:46
2015-07-05T03:21:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,785
java
package com.tencent.mm.protocal.b; import java.util.LinkedList; public final class jy extends com.tencent.mm.al.a { public LinkedList bDC = new LinkedList(); protected final int a(int paramInt, Object... paramVarArgs) { if (paramInt == 0) { ((a.a.a.c.a)paramVarArgs[0]).d(1, 8, bDC); return 0; } if (paramInt == 1) { return a.a.a.a.c(1, 8, bDC) + 0; } if (paramInt == 2) { paramVarArgs = (byte[])paramVarArgs[0]; bDC.clear(); paramVarArgs = new a.a.a.a.a(paramVarArgs, hfZ); for (paramInt = com.tencent.mm.al.a.a(paramVarArgs); paramInt > 0; paramInt = com.tencent.mm.al.a.a(paramVarArgs)) { if (!super.a(paramVarArgs, this, paramInt)) { paramVarArgs.aVo(); } } return 0; } if (paramInt == 3) { Object localObject1 = (a.a.a.a.a)paramVarArgs[0]; jy localjy = (jy)paramVarArgs[1]; paramInt = ((Integer)paramVarArgs[2]).intValue(); switch (paramInt) { default: return -1; } paramVarArgs = ((a.a.a.a.a)localObject1).pL(paramInt); int i = paramVarArgs.size(); paramInt = 0; while (paramInt < i) { Object localObject2 = (byte[])paramVarArgs.get(paramInt); localObject1 = new kc(); localObject2 = new a.a.a.a.a((byte[])localObject2, hfZ); for (boolean bool = true; bool; bool = ((kc)localObject1).a((a.a.a.a.a)localObject2, (com.tencent.mm.al.a)localObject1, com.tencent.mm.al.a.a((a.a.a.a.a)localObject2))) {} bDC.add(localObject1); paramInt += 1; } return 0; } return -1; } } /* Location: * Qualified Name: com.tencent.mm.protocal.b.jy * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */
[ "reverseengineeringer@hackeradmin.com" ]
reverseengineeringer@hackeradmin.com
afdbcc4ed165a913659321a03e6c97f29a24a74b
431ea1047c8862f9051bc447f3e1a4fd637a5248
/src/java/com/Model/User.java
82144b96740dba1cc6d92bbf81254ff3e63ff135
[]
no_license
raoelson/GestionCommades
c82ae3cd5abe3516cefbcc6bd59059ecf8e35ec3
cdecacd2493876152a1e31efa046e4cce9d24843
refs/heads/master
2021-07-04T14:38:38.434012
2017-09-28T12:15:11
2017-09-28T12:15:11
105,139,083
0
0
null
null
null
null
UTF-8
Java
false
false
846
java
package com.Model; // Generated 19 oct. 2015 12:59:09 by Hibernate Tools 3.6.0 /** * User generated by hbm2java */ public class User implements java.io.Serializable { private Integer id; private String login; private String password; public User() { } public User(String login, String password) { this.login = login; this.password = password; } public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getLogin() { return this.login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } }
[ "raoelsonmaoris@gmail.com" ]
raoelsonmaoris@gmail.com
7fe910b60d9e1b158ddc6c72c6813a60176fdc9b
2d19d2ef3cc4ef4a4af94642b7fd0534ce048764
/GamesUtils/src/main/java/com/ongraph/greatsgames/exception/GreatGamesAuthenticationException.java
5b90923fd667c8c4d6effebe6a72f2dc513de52a
[]
no_license
RinkalTomar/great_game
09dcdc4f348dc0700dd16a05f24714fb07691e88
d5bffe0ac80d1abbdcc6bd4302d782b81cb20049
refs/heads/master
2022-12-21T09:45:53.406316
2020-02-02T16:44:04
2020-02-02T16:44:04
237,784,707
0
0
null
2022-12-16T04:31:03
2020-02-02T14:38:09
Java
UTF-8
Java
false
false
219
java
package com.ongraph.greatsgames.exception; public class GreatGamesAuthenticationException extends GreatGamesException { public GreatGamesAuthenticationException(String message) { super(message); } }
[ "rinkalsinghtomar89@gmail.com" ]
rinkalsinghtomar89@gmail.com
2dbba66a1ae3e667b4e17df45812e3509fd3f63b
d7c4e9eb15d40fe62b02394520a8eba4725674f2
/src/best/dafu.java
292a732e3b948e5a4e19edce955aabe45cd753d3
[]
no_license
wangkunProject/javaweb
32ef68773d2a62d82346dda34bc33c37f22e1a5c
5db1cb11d120df65d21eebc95ab5a4dd667897e0
refs/heads/master
2022-12-09T00:26:23.404591
2020-09-09T11:42:47
2020-09-09T11:42:47
294,088,838
0
0
null
null
null
null
UTF-8
Java
false
false
60
java
package best; public class dafu { int sdf=23563434; }
[ "2295013046@qq.com" ]
2295013046@qq.com
09dca4ee80f1ef3446373889404352dc394ad6f8
8ba0fb28b3c73510dbab16af944835e19557812a
/src/java/view/ListTeams.java
1b66aa0b032741d47fbad6f66e847d9c3d014641
[]
no_license
Perreault-Dale/FinalServlets
de37552b6273d53072a16467fee8d54bf199e107
c33e6051b5adeb86dee8b6233a6b0370033ef022
refs/heads/master
2020-03-08T18:34:40.508092
2018-04-11T21:52:15
2018-04-11T21:52:15
128,308,977
0
0
null
null
null
null
UTF-8
Java
false
false
607
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 view; import control.TeamControl; import java.util.List; import model.Team; /** * * @author Dale */ public class ListTeams implements Handler { @Override public String execute() { List<Team> tl = TeamControl.getRecords(); if (tl.isEmpty()) { tl = TeamControl.InitialLoad(); } String html = TeamControl.formatHtml(tl); return html; } }
[ "per15038@byui.edu" ]
per15038@byui.edu
e58b975a55544b785b98917a4a566f302a228014
065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be
/eclipseswt_cluster/7640/src_0.java
63005d1c52e5679ab7b844b44a2d97dcdc26d36b
[]
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
133,584
java
/******************************************************************************* * Copyright (c) 2000, 2015 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.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; /** * Instances of this class implement a selectable user interface * object that displays a list of images and strings and issues * notification when selected. * <p> * The item children that may be added to instances of this class * must be of type <code>TableItem</code>. * </p><p> * Style <code>VIRTUAL</code> is used to create a <code>Table</code> whose * <code>TableItem</code>s are to be populated by the client on an on-demand basis * instead of up-front. This can provide significant performance improvements for * tables that are very large or for which <code>TableItem</code> population is * expensive (for example, retrieving values from an external source). * </p><p> * Here is an example of using a <code>Table</code> with style <code>VIRTUAL</code>: * <code><pre> * final Table table = new Table (parent, SWT.VIRTUAL | SWT.BORDER); * table.setItemCount (1000000); * table.addListener (SWT.SetData, new Listener () { * public void handleEvent (Event event) { * TableItem item = (TableItem) event.item; * int index = table.indexOf (item); * item.setText ("Item " + index); * System.out.println (item.getText ()); * } * }); * </pre></code> * </p><p> * Note that although this class is a subclass of <code>Composite</code>, * it does not normally make sense to add <code>Control</code> children to * it, or set a layout on it, unless implementing something like a cell * editor. * </p><p> * <dl> * <dt><b>Styles:</b></dt> * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL, NO_SCROLL</dd> * <dt><b>Events:</b></dt> * <dd>Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem</dd> * </dl> * </p><p> * Note: Only one of the styles SINGLE, and MULTI may be specified. * </p><p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> * * @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a> * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a> * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> * @noextend This class is not intended to be subclassed by clients. */ public class Table extends Composite { long /*int*/ modelHandle, checkRenderer; int itemCount, columnCount, lastIndexOf, sortDirection; long /*int*/ ignoreCell; TableItem [] items; TableColumn [] columns; TableItem currentItem; TableColumn sortColumn; ImageList imageList, headerImageList; boolean firstCustomDraw; int drawState, drawFlags; GdkColor drawForeground; boolean ownerDraw, ignoreSize, ignoreAccessibility; static final int CHECKED_COLUMN = 0; static final int GRAYED_COLUMN = 1; static final int FOREGROUND_COLUMN = 2; static final int BACKGROUND_COLUMN = 3; static final int FONT_COLUMN = 4; static final int FIRST_COLUMN = FONT_COLUMN + 1; static final int CELL_PIXBUF = 0; static final int CELL_TEXT = 1; static final int CELL_FOREGROUND = 2; static final int CELL_BACKGROUND = 3; static final int CELL_FONT = 4; static final int CELL_TYPES = CELL_FONT + 1; /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a composite control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see SWT#SINGLE * @see SWT#MULTI * @see SWT#CHECK * @see SWT#FULL_SELECTION * @see SWT#HIDE_SELECTION * @see SWT#VIRTUAL * @see SWT#NO_SCROLL * @see Widget#checkSubclass * @see Widget#getStyle */ public Table (Composite parent, int style) { super (parent, checkStyle (style)); // A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=457196 if (OS.GTK3) { addListener(SWT.MeasureItem, new Listener() { public void handleEvent(Event event) { layout(); removeListener(SWT.MeasureItem, this); } }); } } @Override void _addListener (int eventType, Listener listener) { super._addListener (eventType, listener); if (!ownerDraw) { switch (eventType) { case SWT.MeasureItem: case SWT.EraseItem: case SWT.PaintItem: ownerDraw = true; recreateRenderers (); break; } } } TableItem _getItem (int index) { if ((style & SWT.VIRTUAL) == 0) return items [index]; if (items [index] != null) return items [index]; return items [index] = new TableItem (this, SWT.NONE, index, false); } static int checkStyle (int style) { /* * Feature in Windows. Even when WS_HSCROLL or * WS_VSCROLL is not specified, Windows creates * trees and tables with scroll bars. The fix * is to set H_SCROLL and V_SCROLL. * * NOTE: This code appears on all platforms so that * applications have consistent scroll bar behavior. */ if ((style & SWT.NO_SCROLL) == 0) { style |= SWT.H_SCROLL | SWT.V_SCROLL; } /* GTK is always FULL_SELECTION */ style |= SWT.FULL_SELECTION; return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0); } @Override long /*int*/ cellDataProc (long /*int*/ tree_column, long /*int*/ cell, long /*int*/ tree_model, long /*int*/ iter, long /*int*/ data) { if (cell == ignoreCell) return 0; long /*int*/ path = OS.gtk_tree_model_get_path (tree_model, iter); int [] index = new int [1]; OS.memmove (index, OS.gtk_tree_path_get_indices (path), 4); TableItem item = _getItem (index[0]); OS.gtk_tree_path_free (path); if (item != null) OS.g_object_set_qdata (cell, Display.SWT_OBJECT_INDEX2, item.handle); boolean isPixbuf = OS.GTK_IS_CELL_RENDERER_PIXBUF (cell); boolean isText = OS.GTK_IS_CELL_RENDERER_TEXT (cell); if (isText && OS.GTK3) { OS.gtk_cell_renderer_set_fixed_size (cell, -1, -1); } if (!(isPixbuf || isText)) return 0; int modelIndex = -1; boolean customDraw = false; if (columnCount == 0) { modelIndex = Table.FIRST_COLUMN; customDraw = firstCustomDraw; } else { TableColumn column = (TableColumn) display.getWidget (tree_column); if (column != null) { modelIndex = column.modelIndex; customDraw = column.customDraw; } } if (modelIndex == -1) return 0; boolean setData = false; if ((style & SWT.VIRTUAL) != 0) { if (!item.cached) { lastIndexOf = index[0]; setData = checkData (item); } } long /*int*/ [] ptr = new long /*int*/ [1]; if (setData) { ptr [0] = 0; if (isPixbuf) { OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1); OS.g_object_set (cell, OS.GTK3 ? OS.gicon : OS.pixbuf, ptr [0], 0); if (ptr [0] != 0) OS.g_object_unref (ptr [0]); } else { OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1); if (ptr [0] != 0) { OS.g_object_set (cell, OS.text, ptr [0], 0); OS.g_free (ptr [0]); } } } if (customDraw) { if (!ownerDraw) { ptr [0] = 0; OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1); if (ptr [0] != 0) { OS.g_object_set (cell, OS.cell_background_gdk, ptr [0], 0); OS.gdk_color_free (ptr [0]); } } if (!isPixbuf) { ptr [0] = 0; OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1); if (ptr [0] != 0) { OS.g_object_set (cell, OS.foreground_gdk, ptr [0], 0); OS.gdk_color_free (ptr [0]); } ptr [0] = 0; OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1); if (ptr [0] != 0) { OS.g_object_set (cell, OS.font_desc, ptr [0], 0); OS.pango_font_description_free (ptr [0]); } } } if (setData) { ignoreCell = cell; setScrollWidth (tree_column, item); ignoreCell = 0; } return 0; } boolean checkData (TableItem item) { if (item.cached) return true; if ((style & SWT.VIRTUAL) != 0) { item.cached = true; Event event = new Event (); event.item = item; event.index = indexOf (item); int mask = OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID; int signal_id = OS.g_signal_lookup (OS.row_changed, OS.gtk_tree_model_get_type ()); OS.g_signal_handlers_block_matched (modelHandle, mask, signal_id, 0, 0, 0, handle); currentItem = item; sendEvent (SWT.SetData, event); //widget could be disposed at this point currentItem = null; if (isDisposed ()) return false; OS.g_signal_handlers_unblock_matched (modelHandle, mask, signal_id, 0, 0, 0, handle); if (item.isDisposed ()) return false; } return true; } @Override protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } /** * Adds the listener to the collection of listeners who will * be notified when the user changes the receiver's selection, by sending * it one of the messages defined in the <code>SelectionListener</code> * interface. * <p> * When <code>widgetSelected</code> is called, the item field of the event object is valid. * If the receiver has the <code>SWT.CHECK</code> style and the check selection changes, * the event object detail field contains the value <code>SWT.CHECK</code>. * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked. * The item field of the event object is valid for default selection, but the detail field is not used. * </p> * * @param listener the listener which should be notified when the user changes the receiver's selection * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SelectionListener * @see #removeSelectionListener * @see SelectionEvent */ public void addSelectionListener (SelectionListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Selection, typedListener); addListener (SWT.DefaultSelection, typedListener); } int calculateWidth (long /*int*/ column, long /*int*/ iter) { OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false); /* * Bug in GTK. The width calculated by gtk_tree_view_column_cell_get_size() * always grows in size regardless of the text or images in the table. * The fix is to determine the column width from the cell renderers. */ //This workaround is causing the problem Bug 459834 in GTK3. So reverting the workaround for GTK3 if (OS.GTK3) { int [] width = new int [1]; OS.gtk_tree_view_column_cell_get_size (column, null, null, null, width, null); return width [0]; } else { int width = 0; int [] w = new int [1]; OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0); width += 2 * w [0]; long /*int*/ list = OS.gtk_cell_layout_get_cells(column); if (list == 0) return 0; long /*int*/ temp = list; while (temp != 0) { long /*int*/ renderer = OS.g_list_data (temp); if (renderer != 0) { gtk_cell_renderer_get_preferred_size (renderer, handle, w, null); width += w [0]; } temp = OS.g_list_next (temp); } OS.g_list_free (list); if (OS.gtk_tree_view_get_grid_lines(handle) > OS.GTK_TREE_VIEW_GRID_LINES_NONE) { OS.gtk_widget_style_get (handle, OS.grid_line_width, w, 0) ; width += 2 * w [0]; } return width; } } /** * Clears the item at the given zero-relative index in the receiver. * The text, icon and other attributes of the item are set to the default * value. If the table was created with the <code>SWT.VIRTUAL</code> style, * these attributes are requested again as needed. * * @param index the index of the item to clear * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear (int index) { checkWidget (); if (!(0 <= index && index < itemCount)) { error(SWT.ERROR_INVALID_RANGE); } TableItem item = items [index]; if (item != null) item.clear (); } /** * Removes the items from the receiver which are between the given * zero-relative start and end indices (inclusive). The text, icon * and other attributes of the items are set to their default values. * If the table was created with the <code>SWT.VIRTUAL</code> style, * these attributes are requested again as needed. * * @param start the start index of the item to clear * @param end the end index of the item to clear * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear (int start, int end) { checkWidget (); if (start > end) return; if (!(0 <= start && start <= end && end < itemCount)) { error (SWT.ERROR_INVALID_RANGE); } if (start == 0 && end == itemCount - 1) { clearAll(); } else { for (int i=start; i<=end; i++) { TableItem item = items [i]; if (item != null) item.clear(); } } } /** * Clears the items at the given zero-relative indices in the receiver. * The text, icon and other attributes of the items are set to their default * values. If the table was created with the <code>SWT.VIRTUAL</code> style, * these attributes are requested again as needed. * * @param indices the array of indices of the items * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clear (int [] indices) { checkWidget (); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); if (indices.length == 0) return; for (int i=0; i<indices.length; i++) { if (!(0 <= indices [i] && indices [i] < itemCount)) { error (SWT.ERROR_INVALID_RANGE); } } for (int i=0; i<indices.length; i++) { TableItem item = items [indices [i]]; if (item != null) item.clear(); } } /** * Clears all the items in the receiver. The text, icon and other * attributes of the items are set to their default values. If the * table was created with the <code>SWT.VIRTUAL</code> style, these * attributes are requested again as needed. * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SWT#VIRTUAL * @see SWT#SetData * * @since 3.0 */ public void clearAll () { checkWidget (); for (int i=0; i<itemCount; i++) { TableItem item = items [i]; if (item != null) item.clear(); } } @Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; Point size = computeNativeSize (handle, wHint, hHint, changed); if (size.x == 0 && wHint == SWT.DEFAULT) size.x = DEFAULT_WIDTH; /* * in GTK 3.8 computeNativeSize returning 0 for height. * So if the height is returned as zero calculate the table height * based on the number of items in the table */ if (OS.GTK3 && size.y == 0 && hHint == SWT.DEFAULT) { size.y = getItemCount() * getItemHeight(); } /* * In case the table doesn't contain any elements, * getItemCount returns 0 and size.y will be 0 * so need to assign default height */ if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT; Rectangle trim = computeTrim (0, 0, size.x, size.y); size.x = trim.width; size.y = trim.height; return size; } void createColumn (TableColumn column, int index) { int modelIndex = FIRST_COLUMN; if (columnCount != 0) { int modelLength = OS.gtk_tree_model_get_n_columns (modelHandle); boolean [] usedColumns = new boolean [modelLength]; for (int i=0; i<columnCount; i++) { int columnIndex = columns [i].modelIndex; for (int j = 0; j < CELL_TYPES; j++) { usedColumns [columnIndex + j] = true; } } while (modelIndex < modelLength) { if (!usedColumns [modelIndex]) break; modelIndex++; } if (modelIndex == modelLength) { long /*int*/ oldModel = modelHandle; long /*int*/[] types = getColumnTypes (columnCount + 4); // grow by 4 rows at a time long /*int*/ newModel = OS.gtk_list_store_newv (types.length, types); if (newModel == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ [] ptr = new long /*int*/ [1]; int [] ptr1 = new int [1]; for (int i=0; i<itemCount; i++) { long /*int*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (newItem == 0) error (SWT.ERROR_NO_HANDLES); OS.gtk_list_store_append (newModel, newItem); TableItem item = items [i]; if (item != null) { long /*int*/ oldItem = item.handle; /* the columns before FOREGROUND_COLUMN contain int values, subsequent columns contain pointers */ for (int j=0; j<FOREGROUND_COLUMN; j++) { OS.gtk_tree_model_get (oldModel, oldItem, j, ptr1, -1); OS.gtk_list_store_set (newModel, newItem, j, ptr1 [0], -1); } for (int j=FOREGROUND_COLUMN; j<modelLength; j++) { OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1); OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1); if (ptr [0] != 0) { if (types [j] == OS.G_TYPE_STRING ()) { OS.g_free ((ptr [0])); } else if (types [j] == OS.GDK_TYPE_COLOR()) { OS.gdk_color_free (ptr [0]); } else if (types [j] == OS.GDK_TYPE_PIXBUF()) { OS.g_object_unref (ptr [0]); } else if (types [j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) { OS.pango_font_description_free (ptr [0]); } } } OS.gtk_list_store_remove (oldModel, oldItem); OS.g_free (oldItem); item.handle = newItem; } else { OS.g_free (newItem); } } OS.gtk_tree_view_set_model (handle, newModel); setModel (newModel); } } long /*int*/ columnHandle = OS.gtk_tree_view_column_new (); if (columnHandle == 0) error (SWT.ERROR_NO_HANDLES); if (index == 0 && columnCount > 0) { TableColumn checkColumn = columns [0]; createRenderers (checkColumn.handle, checkColumn.modelIndex, false, checkColumn.style); } createRenderers (columnHandle, modelIndex, index == 0, column == null ? 0 : column.style); if ((style & SWT.VIRTUAL) == 0 && columnCount == 0) { OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_GROW_ONLY); } else { OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_FIXED); } OS.gtk_tree_view_column_set_resizable (columnHandle, true); OS.gtk_tree_view_column_set_clickable (columnHandle, true); OS.gtk_tree_view_column_set_min_width (columnHandle, 0); OS.gtk_tree_view_insert_column (handle, columnHandle, index); /* * Bug in GTK3. The column header has the wrong CSS styling if it is hidden * when inserting to the tree widget. The fix is to hide the column only * after it is inserted. */ if (columnCount != 0) OS.gtk_tree_view_column_set_visible (columnHandle, false); if (column != null) { column.handle = columnHandle; column.modelIndex = modelIndex; } if (!searchEnabled ()) { OS.gtk_tree_view_set_search_column (handle, -1); } else { /* Set the search column whenever the model changes */ int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex; OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT); } } @Override void createHandle (int index) { state |= HANDLE; fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); OS.gtk_widget_set_has_window (fixedHandle, true); scrolledHandle = OS.gtk_scrolled_window_new (0, 0); if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ [] types = getColumnTypes (1); modelHandle = OS.gtk_list_store_newv (types.length, types); if (modelHandle == 0) error (SWT.ERROR_NO_HANDLES); handle = OS.gtk_tree_view_new_with_model (modelHandle); if (handle == 0) error (SWT.ERROR_NO_HANDLES); if ((style & SWT.CHECK) != 0) { checkRenderer = OS.gtk_cell_renderer_toggle_new (); if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES); OS.g_object_ref (checkRenderer); } createColumn (null, 0); OS.gtk_container_add (fixedHandle, scrolledHandle); OS.gtk_container_add (scrolledHandle, handle); int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_MULTIPLE : OS.GTK_SELECTION_BROWSE; long /*int*/ selectionHandle = OS.gtk_tree_view_get_selection (handle); OS.gtk_tree_selection_set_mode (selectionHandle, mode); OS.gtk_tree_view_set_headers_visible (handle, false); int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER; int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER; OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp); if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); if ((style & SWT.VIRTUAL) != 0) { OS.g_object_set (handle, OS.fixed_height_mode, true, 0); } if (!searchEnabled ()) { OS.gtk_tree_view_set_search_column (handle, -1); } } void createItem (TableColumn column, int index) { if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE); if (columnCount == 0) { column.handle = OS.gtk_tree_view_get_column (handle, 0); OS.gtk_tree_view_column_set_sizing (column.handle, OS.GTK_TREE_VIEW_COLUMN_FIXED); OS.gtk_tree_view_column_set_visible (column.handle, false); column.modelIndex = FIRST_COLUMN; createRenderers (column.handle, column.modelIndex, true, column.style); column.customDraw = firstCustomDraw; firstCustomDraw = false; } else { createColumn (column, index); } long /*int*/ boxHandle = gtk_box_new (OS.GTK_ORIENTATION_HORIZONTAL, false, 3); if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ labelHandle = OS.gtk_label_new_with_mnemonic (null); if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ imageHandle = OS.gtk_image_new (); if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES); OS.gtk_container_add (boxHandle, imageHandle); OS.gtk_container_add (boxHandle, labelHandle); OS.gtk_widget_show (boxHandle); OS.gtk_widget_show (labelHandle); column.labelHandle = labelHandle; column.imageHandle = imageHandle; OS.gtk_tree_view_column_set_widget (column.handle, boxHandle); if (OS.GTK3) { column.buttonHandle = OS.gtk_tree_view_column_get_button(column.handle); } else { long /*int*/ widget = OS.gtk_widget_get_parent (boxHandle); while (widget != handle) { if (OS.GTK_IS_BUTTON (widget)) { column.buttonHandle = widget; break; } widget = OS.gtk_widget_get_parent (widget); } } if (columnCount == columns.length) { TableColumn [] newColumns = new TableColumn [columns.length + 4]; System.arraycopy (columns, 0, newColumns, 0, columns.length); columns = newColumns; } System.arraycopy (columns, index, columns, index + 1, columnCount++ - index); columns [index] = column; if ((state & FONT) != 0) { column.setFontDescription (getFontDescription ()); } if (columnCount >= 1) { for (int i=0; i<itemCount; i++) { TableItem item = items [i]; if (item != null) { Font [] cellFont = item.cellFont; if (cellFont != null) { Font [] temp = new Font [columnCount]; System.arraycopy (cellFont, 0, temp, 0, index); System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1); item.cellFont = temp; } } } } /* * Feature in GTK. The tree view does not resize immediately if a table * column is created when the table is not visible. If the width of the * new column is queried, GTK returns an incorrect value. The fix is to * ensure that the columns are resized before any queries. */ if(!isVisible ()) { forceResize(); } } void createItem (TableItem item, int index) { if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE); if (itemCount == items.length) { int length = drawCount <= 0 ? items.length + 4 : Math.max (4, items.length * 3 / 2); TableItem [] newItems = new TableItem [length]; System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } item.handle = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (item.handle == 0) error (SWT.ERROR_NO_HANDLES); /* * Feature in GTK. It is much faster to append to a list store * than to insert at the end using gtk_list_store_insert(). */ if (index == itemCount) { OS.gtk_list_store_append (modelHandle, item.handle); } else { OS.gtk_list_store_insert (modelHandle, item.handle, index); } System.arraycopy (items, index, items, index + 1, itemCount++ - index); items [index] = item; } void createRenderers (long /*int*/ columnHandle, int modelIndex, boolean check, int columnStyle) { OS.gtk_tree_view_column_clear (columnHandle); if ((style & SWT.CHECK) != 0 && check) { OS.gtk_tree_view_column_pack_start (columnHandle, checkRenderer, false); OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.active, CHECKED_COLUMN); OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN); if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN); if (ownerDraw) { OS.gtk_tree_view_column_set_cell_data_func (columnHandle, checkRenderer, display.cellDataProc, handle, 0); OS.g_object_set_qdata (checkRenderer, Display.SWT_OBJECT_INDEX1, columnHandle); } } long /*int*/ pixbufRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_pixbuf_get_type (), 0) : OS.gtk_cell_renderer_pixbuf_new (); if (pixbufRenderer == 0) { error (SWT.ERROR_NO_HANDLES); } else { // set default size this size is used for calculating the icon and text positions in a table if ((!ownerDraw) && (OS.GTK3)) { OS.gtk_cell_renderer_set_fixed_size(pixbufRenderer, 16, 16); } } long /*int*/ textRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_text_get_type (), 0) : OS.gtk_cell_renderer_text_new (); if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES); if (ownerDraw) { OS.g_object_set_qdata (pixbufRenderer, Display.SWT_OBJECT_INDEX1, columnHandle); OS.g_object_set_qdata (textRenderer, Display.SWT_OBJECT_INDEX1, columnHandle); } /* * Feature in GTK. When a tree view column contains only one activatable * cell renderer such as a toggle renderer, mouse clicks anywhere in a cell * activate that renderer. The workaround is to set a second cell renderer * to be activatable. */ if ((style & SWT.CHECK) != 0 && check) { OS.g_object_set (pixbufRenderer, OS.mode, OS.GTK_CELL_RENDERER_MODE_ACTIVATABLE, 0); } /* Set alignment */ if ((columnStyle & SWT.RIGHT) != 0) { OS.g_object_set(textRenderer, OS.xalign, 1f, 0); OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true); OS.gtk_tree_view_column_pack_end (columnHandle, pixbufRenderer, false); OS.gtk_tree_view_column_set_alignment (columnHandle, 1f); } else if ((columnStyle & SWT.CENTER) != 0) { OS.g_object_set(textRenderer, OS.xalign, 0.5f, 0); OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false); OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true); OS.gtk_tree_view_column_set_alignment (columnHandle, 0.5f); } else { OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false); OS.gtk_tree_view_column_pack_start (columnHandle, textRenderer, true); OS.gtk_tree_view_column_set_alignment (columnHandle, 0f); } /* Add attributes */ OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.GTK3 ? OS.gicon : OS.pixbuf, modelIndex + CELL_PIXBUF); if (!ownerDraw) { OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN); OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN); } OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, modelIndex + CELL_TEXT); OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.foreground_gdk, FOREGROUND_COLUMN); OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.font_desc, FONT_COLUMN); boolean customDraw = firstCustomDraw; if (columnCount != 0) { for (int i=0; i<columnCount; i++) { if (columns [i].handle == columnHandle) { customDraw = columns [i].customDraw; break; } } } if ((style & SWT.VIRTUAL) != 0 || customDraw || ownerDraw) { OS.gtk_tree_view_column_set_cell_data_func (columnHandle, textRenderer, display.cellDataProc, handle, 0); OS.gtk_tree_view_column_set_cell_data_func (columnHandle, pixbufRenderer, display.cellDataProc, handle, 0); } } @Override void createWidget (int index) { super.createWidget (index); items = new TableItem [4]; columns = new TableColumn [4]; itemCount = columnCount = 0; // In GTK 3 font description is inherited from parent widget which is not how SWT has always worked, // reset to default font to get the usual behavior if (OS.GTK3) { setFontDescription(defaultFont().handle); } } @Override int applyThemeBackground () { return -1; /* No Change */ } GdkColor defaultBackground () { return display.COLOR_LIST_BACKGROUND; } GdkColor defaultForeground () { return display.COLOR_LIST_FOREGROUND; } @Override void deregister () { super.deregister (); display.removeWidget (OS.gtk_tree_view_get_selection (handle)); if (checkRenderer != 0) display.removeWidget (checkRenderer); display.removeWidget (modelHandle); } /** * Deselects the item at the given zero-relative index in the receiver. * If the item at the index was already deselected, it remains * deselected. Indices that are out of range are ignored. * * @param index the index of the item to deselect * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void deselect (int index) { checkWidget(); if (index < 0 || index >= itemCount) return; boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Deselects the items at the given zero-relative indices in the receiver. * If the item at the given zero-relative index in the receiver * is selected, it is deselected. If the item at the index * was not selected, it remains deselected. The range of the * indices is inclusive. Indices that are out of range are ignored. * * @param start the start index of the items to deselect * @param end the end index of the items to deselect * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void deselect (int start, int end) { checkWidget(); boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); for (int index=start; index<=end; index++) { if (index < 0 || index >= itemCount) continue; OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle); } OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Deselects the items at the given zero-relative indices in the receiver. * If the item at the given zero-relative index in the receiver * is selected, it is deselected. If the item at the index * was not selected, it remains deselected. Indices that are out * of range and duplicate indices are ignored. * * @param indices the array of indices for the items to deselect * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void deselect (int [] indices) { checkWidget(); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); for (int i=0; i<indices.length; i++) { int index = indices[i]; if (index < 0 || index >= itemCount) continue; OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle); } OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Deselects all selected items in the receiver. * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void deselectAll () { checkWidget(); boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_selection_unselect_all (selection); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } void destroyItem (TableColumn column) { int index = 0; while (index < columnCount) { if (columns [index] == column) break; index++; } if (index == columnCount) return; long /*int*/ columnHandle = column.handle; if (columnCount == 1) { firstCustomDraw = column.customDraw; } System.arraycopy (columns, index + 1, columns, index, --columnCount - index); columns [columnCount] = null; OS.gtk_tree_view_remove_column (handle, columnHandle); if (columnCount == 0) { long /*int*/ oldModel = modelHandle; long /*int*/[] types = getColumnTypes (1); long /*int*/ newModel = OS.gtk_list_store_newv (types.length, types); if (newModel == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ [] ptr = new long /*int*/ [1]; int [] ptr1 = new int [1]; for (int i=0; i<itemCount; i++) { long /*int*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (newItem == 0) error (SWT.ERROR_NO_HANDLES); OS.gtk_list_store_append (newModel, newItem); TableItem item = items [i]; if (item != null) { long /*int*/ oldItem = item.handle; /* the columns before FOREGROUND_COLUMN contain int values, subsequent columns contain pointers */ for (int j=0; j<FOREGROUND_COLUMN; j++) { OS.gtk_tree_model_get (oldModel, oldItem, j, ptr1, -1); OS.gtk_list_store_set (newModel, newItem, j, ptr1 [0], -1); } for (int j=FOREGROUND_COLUMN; j<FIRST_COLUMN; j++) { OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1); OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1); if (ptr [0] != 0) { if (j == FOREGROUND_COLUMN || j == BACKGROUND_COLUMN) { OS.gdk_color_free (ptr [0]); } else if (j == FONT_COLUMN) { OS.pango_font_description_free (ptr [0]); } } } OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_PIXBUF, ptr, -1); OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_PIXBUF, ptr [0], -1); if (ptr [0] != 0) OS.g_object_unref (ptr [0]); OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_TEXT, ptr, -1); OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_TEXT, ptr [0], -1); OS.g_free (ptr [0]); OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FOREGROUND, ptr, -1); OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FOREGROUND, ptr [0], -1); if (ptr [0] != 0) OS.gdk_color_free (ptr [0]); OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_BACKGROUND, ptr, -1); OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_BACKGROUND, ptr [0], -1); if (ptr [0] != 0) OS.gdk_color_free (ptr [0]); OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FONT, ptr, -1); OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FONT, ptr [0], -1); if (ptr [0] != 0) OS.pango_font_description_free (ptr [0]); OS.gtk_list_store_remove (oldModel, oldItem); OS.g_free (oldItem); item.handle = newItem; } else { OS.g_free (newItem); } } OS.gtk_tree_view_set_model (handle, newModel); setModel (newModel); createColumn (null, 0); } else { for (int i=0; i<itemCount; i++) { TableItem item = items [i]; if (item != null) { long /*int*/ iter = item.handle; int modelIndex = column.modelIndex; OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_PIXBUF, (long /*int*/)0, -1); OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_TEXT, (long /*int*/)0, -1); OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FOREGROUND, (long /*int*/)0, -1); OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_BACKGROUND, (long /*int*/)0, -1); OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FONT, (long /*int*/)0, -1); Font [] cellFont = item.cellFont; if (cellFont != null) { if (columnCount == 0) { item.cellFont = null; } else { Font [] temp = new Font [columnCount]; System.arraycopy (cellFont, 0, temp, 0, index); System.arraycopy (cellFont, index + 1, temp, index, columnCount - index); item.cellFont = temp; } } } } if (index == 0) { TableColumn checkColumn = columns [0]; createRenderers (checkColumn.handle, checkColumn.modelIndex, true, checkColumn.style); } } if (!searchEnabled ()) { OS.gtk_tree_view_set_search_column (handle, -1); } else { /* Set the search column whenever the model changes */ int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex; OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT); } } void destroyItem (TableItem item) { int index = 0; while (index < itemCount) { if (items [index] == item) break; index++; } if (index == itemCount) return; long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_list_store_remove (modelHandle, item.handle); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); System.arraycopy (items, index + 1, items, index, --itemCount - index); items [itemCount] = null; if (itemCount == 0) resetCustomDraw (); } @Override boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) { boolean selected = false; if (filter) { long /*int*/ [] path = new long /*int*/ [1]; if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) { if (path [0] != 0) { long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) selected = true; OS.gtk_tree_path_free (path [0]); } } else { return false; } } boolean dragDetect = super.dragDetect (x, y, filter, false, consume); if (dragDetect && selected && consume != null) consume [0] = true; return dragDetect; } @Override long /*int*/ eventWindow () { return paintWindow (); } boolean fixAccessibility () { /* * Bug in GTK. With GTK 2.12, when assistive technologies is on, the time * it takes to add or remove several rows to the model is very long. This * happens because the accessible object asks each row for its data, including * the rows that are not visible. The the fix is to block the accessible object * from receiving row_added and row_removed signals and, at the end, send only * a notify signal with the "model" detail. * * Note: The test bellow has to be updated when the real problem is fixed in * the accessible object. */ return true; } @Override void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) { super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); for (int i=0; i<columnCount; i++) { TableColumn column = columns [i]; if (column.toolTipText != null) { column.setToolTipText(oldShell, null); column.setToolTipText(newShell, column.toolTipText); } } } @Override GdkColor getBackgroundColor () { return getBaseColor (); } @Override public Rectangle getClientArea () { checkWidget (); forceResize (); OS.gtk_widget_realize (handle); long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle); long /*int*/ binWindow = OS.gtk_tree_view_get_bin_window (handle); int [] binX = new int [1], binY = new int [1]; OS.gdk_window_get_origin (binWindow, binX, binY); int [] fixedX = new int [1], fixedY = new int [1]; OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY); long /*int*/ clientHandle = clientHandle (); GtkAllocation allocation = new GtkAllocation (); OS.gtk_widget_get_allocation (clientHandle, allocation); int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; Rectangle rect = new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height); if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) { rect.y += getHeaderHeight(); } return rect; } @Override int getClientWidth () { int [] w = new int [1], h = new int [1]; OS.gtk_widget_realize (handle); gdk_window_get_size(OS.gtk_tree_view_get_bin_window(handle), w, h); return w[0]; } /** * Returns the column at the given, zero-relative index in the * receiver. Throws an exception if the index is out of range. * Columns are returned in the order that they were created. * If no <code>TableColumn</code>s were created by the programmer, * this method will throw <code>ERROR_INVALID_RANGE</code> despite * the fact that a single column of data may be visible in the table. * This occurs when the programmer uses the table like a list, adding * items but never creating a column. * * @param index the index of the column to return * @return the column at the given index * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#getColumnOrder() * @see Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move */ public TableColumn getColumn (int index) { checkWidget(); if (!(0 <= index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE); return columns [index]; } /** * Returns the number of columns contained in the receiver. * If no <code>TableColumn</code>s were created by the programmer, * this value is zero, despite the fact that visually, one column * of items may be visible. This occurs when the programmer uses * the table like a list, adding items but never creating a column. * * @return the number of columns * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getColumnCount () { checkWidget(); return columnCount; } long /*int*/[] getColumnTypes (int columnCount) { long /*int*/[] types = new long /*int*/ [FIRST_COLUMN + (columnCount * CELL_TYPES)]; // per row data types [CHECKED_COLUMN] = OS.G_TYPE_BOOLEAN (); types [GRAYED_COLUMN] = OS.G_TYPE_BOOLEAN (); types [FOREGROUND_COLUMN] = OS.GDK_TYPE_COLOR (); types [BACKGROUND_COLUMN] = OS.GDK_TYPE_COLOR (); types [FONT_COLUMN] = OS.PANGO_TYPE_FONT_DESCRIPTION (); // per cell data for (int i=FIRST_COLUMN; i<types.length; i+=CELL_TYPES) { types [i + CELL_PIXBUF] = OS.GDK_TYPE_PIXBUF (); types [i + CELL_TEXT] = OS.G_TYPE_STRING (); types [i + CELL_FOREGROUND] = OS.GDK_TYPE_COLOR (); types [i + CELL_BACKGROUND] = OS.GDK_TYPE_COLOR (); types [i + CELL_FONT] = OS.PANGO_TYPE_FONT_DESCRIPTION (); } return types; } /** * Returns an array of zero-relative integers that map * the creation order of the receiver's items to the * order in which they are currently being displayed. * <p> * Specifically, the indices of the returned array represent * the current visual order of the items, and the contents * of the array represent the creation order of the items. * </p><p> * Note: This is not the actual structure used by the receiver * to maintain its list of items, so modifying the array will * not affect the receiver. * </p> * * @return the current visual order of the receiver's items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move * * @since 3.1 */ public int [] getColumnOrder () { checkWidget (); if (columnCount == 0) return new int [0]; long /*int*/ list = OS.gtk_tree_view_get_columns (handle); if (list == 0) return new int [0]; int i = 0, count = OS.g_list_length (list); int [] order = new int [count]; long /*int*/ temp = list; while (temp != 0) { long /*int*/ column = OS.g_list_data (temp); if (column != 0) { for (int j=0; j<columnCount; j++) { if (columns [j].handle == column) { order [i++] = j; break; } } } temp = OS.g_list_next (temp); } OS.g_list_free (list); return order; } /** * Returns an array of <code>TableColumn</code>s which are the * columns in the receiver. Columns are returned in the order * that they were created. If no <code>TableColumn</code>s were * created by the programmer, the array is empty, despite the fact * that visually, one column of items may be visible. This occurs * when the programmer uses the table like a list, adding items but * never creating a column. * <p> * Note: This is not the actual structure used by the receiver * to maintain its list of items, so modifying the array will * not affect the receiver. * </p> * * @return the items in the receiver * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#getColumnOrder() * @see Table#setColumnOrder(int[]) * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move */ public TableColumn [] getColumns () { checkWidget(); TableColumn [] result = new TableColumn [columnCount]; System.arraycopy (columns, 0, result, 0, columnCount); return result; } TableItem getFocusItem () { long /*int*/ [] path = new long /*int*/ [1]; OS.gtk_tree_view_get_cursor (handle, path, null); if (path [0] == 0) return null; TableItem item = null; long /*int*/ indices = OS.gtk_tree_path_get_indices (path [0]); if (indices != 0) { int [] index = new int []{-1}; OS.memmove (index, indices, 4); item = _getItem (index [0]); } OS.gtk_tree_path_free (path [0]); return item; } @Override GdkColor getForegroundColor () { return getTextColor (); } /** * Returns the width in pixels of a grid line. * * @return the width of a grid line in pixels * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getGridLineWidth () { checkWidget(); return 0; } /** * Returns the height of the receiver's header * * @return the height of the header or zero if the header is not visible * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 2.0 */ public int getHeaderHeight () { checkWidget (); if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0; if (columnCount > 0) { GtkRequisition requisition = new GtkRequisition (); int height = 0; for (int i=0; i<columnCount; i++) { long /*int*/ buttonHandle = columns [i].buttonHandle; if (buttonHandle != 0) { gtk_widget_get_preferred_size (buttonHandle, requisition); height = Math.max (height, requisition.height); } } return height; } OS.gtk_widget_realize (handle); long /*int*/ fixedWindow = gtk_widget_get_window (fixedHandle); long /*int*/ binWindow = OS.gtk_tree_view_get_bin_window (handle); int [] binY = new int [1]; OS.gdk_window_get_origin (binWindow, null, binY); int [] fixedY = new int [1]; OS.gdk_window_get_origin (fixedWindow, null, fixedY); return binY [0] - fixedY [0]; } /** * Returns <code>true</code> if the receiver's header is visible, * and <code>false</code> otherwise. * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, this method * may still indicate that it is considered visible even though * it may not actually be showing. * </p> * * @return the receiver's header's visibility state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public boolean getHeaderVisible () { checkWidget(); return OS.gtk_tree_view_get_headers_visible (handle); } /** * Returns the item at the given, zero-relative index in the * receiver. Throws an exception if the index is out of range. * * @param index the index of the item to return * @return the item at the given index * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public TableItem getItem (int index) { checkWidget(); if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE); return _getItem (index); } /** * Returns the item at the given point in the receiver * or null if no such item exists. The point is in the * coordinate system of the receiver. * <p> * The item that is returned represents an item that could be selected by the user. * For example, if selection only occurs in items in the first column, then null is * returned if the point is outside of the item. * Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy, * determines the extent of the selection. * </p> * * @param point the point used to locate the item * @return the item at the given point, or null if the point is not in a selectable item * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the point is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public TableItem getItem (Point point) { checkWidget(); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); long /*int*/ [] path = new long /*int*/ [1]; OS.gtk_widget_realize (handle); int y = point.y; if (getHeaderVisible() && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) { y -= getHeaderHeight(); } if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, y, path, null, null, null)) return null; if (path [0] == 0) return null; long /*int*/ indices = OS.gtk_tree_path_get_indices (path [0]); TableItem item = null; if (indices != 0) { int [] index = new int [1]; OS.memmove (index, indices, 4); item = _getItem (index [0]); } OS.gtk_tree_path_free (path [0]); return item; } /** * Returns the number of items contained in the receiver. * * @return the number of items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemCount () { checkWidget (); return itemCount; } /** * Returns the height of the area which would be used to * display <em>one</em> of the items in the receiver. * * @return the height of one item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getItemHeight () { checkWidget(); if (itemCount == 0) { long /*int*/ column = OS.gtk_tree_view_get_column (handle, 0); int [] w = new int [1], h = new int [1]; ignoreSize = true; OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h); int height = h [0]; if (OS.GTK3) { long /*int*/ textRenderer = getTextRenderer (column); OS.gtk_cell_renderer_get_preferred_height_for_width (textRenderer, handle, 0, h, null); height += h [0]; } ignoreSize = false; return height; } else { int height = 0; long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); OS.gtk_tree_model_get_iter_first (modelHandle, iter); int columnCount = Math.max (1, this.columnCount); for (int i=0; i<columnCount; i++) { long /*int*/ column = OS.gtk_tree_view_get_column (handle, i); OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false); int [] w = new int [1], h = new int [1]; OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h); height = Math.max (height, h [0]); } OS.g_free (iter); return height; } } /** * Returns a (possibly empty) array of <code>TableItem</code>s which * are the items in the receiver. * <p> * Note: This is not the actual structure used by the receiver * to maintain its list of items, so modifying the array will * not affect the receiver. * </p> * * @return the items in the receiver * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public TableItem [] getItems () { checkWidget(); TableItem [] result = new TableItem [itemCount]; if ((style & SWT.VIRTUAL) != 0) { for (int i=0; i<itemCount; i++) { result [i] = _getItem (i); } } else { System.arraycopy (items, 0, result, 0, itemCount); } return result; } /** * Returns <code>true</code> if the receiver's lines are visible, * and <code>false</code> otherwise. Note that some platforms draw * grid lines while others may draw alternating row colors. * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, this method * may still indicate that it is considered visible even though * it may not actually be showing. * </p> * * @return the visibility state of the lines * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public boolean getLinesVisible() { checkWidget(); if (OS.GTK3) { return OS.gtk_tree_view_get_grid_lines(handle) > OS.GTK_TREE_VIEW_GRID_LINES_NONE; } else { return OS.gtk_tree_view_get_rules_hint (handle); } } long /*int*/ getPixbufRenderer (long /*int*/ column) { long /*int*/ list = OS.gtk_cell_layout_get_cells(column); if (list == 0) return 0; long /*int*/ originalList = list; long /*int*/ pixbufRenderer = 0; while (list != 0) { long /*int*/ renderer = OS.g_list_data (list); if (OS.GTK_IS_CELL_RENDERER_PIXBUF (renderer)) { pixbufRenderer = renderer; break; } list = OS.g_list_next (list); } OS.g_list_free (originalList); return pixbufRenderer; } /** * Returns an array of <code>TableItem</code>s that are currently * selected in the receiver. The order of the items is unspecified. * An empty array indicates that no items are selected. * <p> * Note: This is not the actual structure used by the receiver * to maintain its selection, so modifying the array will * not affect the receiver. * </p> * @return an array representing the selection * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public TableItem [] getSelection () { checkWidget(); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null); long /*int*/ originalList = list; if (list != 0) { int count = OS.g_list_length (list); int [] treeSelection = new int [count]; int length = 0; for (int i=0; i<count; i++) { long /*int*/ data = OS.g_list_data (list); long /*int*/ indices = OS.gtk_tree_path_get_indices (data); if (indices != 0) { int [] index = new int [1]; OS.memmove (index, indices, 4); treeSelection [length] = index [0]; length++; } OS.gtk_tree_path_free (data); list = OS.g_list_next (list); } OS.g_list_free (originalList); TableItem [] result = new TableItem [length]; for (int i=0; i<result.length; i++) result [i] = _getItem (treeSelection [i]); return result; } return new TableItem [0]; } /** * Returns the number of selected items contained in the receiver. * * @return the number of selected items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getSelectionCount () { checkWidget(); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); return OS.gtk_tree_selection_count_selected_rows (selection); } /** * Returns the zero-relative index of the item which is currently * selected in the receiver, or -1 if no item is selected. * * @return the index of the selected item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getSelectionIndex () { checkWidget(); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null); long /*int*/ originalList = list; if (list != 0) { int [] index = new int [1]; boolean foundIndex = false; while (list != 0) { long /*int*/ data = OS.g_list_data (list); if (foundIndex == false) { long /*int*/ indices = OS.gtk_tree_path_get_indices (data); if (indices != 0) { OS.memmove (index, indices, 4); foundIndex = true; } } list = OS.g_list_next (list); OS.gtk_tree_path_free (data); } OS.g_list_free (originalList); return index [0]; } return -1; } /** * Returns the zero-relative indices of the items which are currently * selected in the receiver. The order of the indices is unspecified. * The array is empty if no items are selected. * <p> * Note: This is not the actual structure used by the receiver * to maintain its selection, so modifying the array will * not affect the receiver. * </p> * @return the array of indices of the selected items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int [] getSelectionIndices () { checkWidget(); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); long /*int*/ list = OS.gtk_tree_selection_get_selected_rows (selection, null); long /*int*/ originalList = list; if (list != 0) { int count = OS.g_list_length (list); int [] treeSelection = new int [count]; int length = 0; for (int i=0; i<count; i++) { long /*int*/ data = OS.g_list_data (list); long /*int*/ indices = OS.gtk_tree_path_get_indices (data); if (indices != 0) { int [] index = new int [1]; OS.memmove (index, indices, 4); treeSelection [length] = index [0]; length++; } list = OS.g_list_next (list); OS.gtk_tree_path_free (data); } OS.g_list_free (originalList); int [] result = new int [length]; System.arraycopy (treeSelection, 0, result, 0, length); return result; } return new int [0]; } /** * Returns the column which shows the sort indicator for * the receiver. The value may be null if no column shows * the sort indicator. * * @return the sort indicator * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see #setSortColumn(TableColumn) * * @since 3.2 */ public TableColumn getSortColumn () { checkWidget (); return sortColumn; } /** * Returns the direction of the sort indicator for the receiver. * The value will be one of <code>UP</code>, <code>DOWN</code> * or <code>NONE</code>. * * @return the sort direction * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see #setSortDirection(int) * * @since 3.2 */ public int getSortDirection () { checkWidget (); return sortDirection; } long /*int*/ getTextRenderer (long /*int*/ column) { long /*int*/ list = OS.gtk_cell_layout_get_cells(column); if (list == 0) return 0; long /*int*/ originalList = list; long /*int*/ textRenderer = 0; while (list != 0) { long /*int*/ renderer = OS.g_list_data (list); if (OS.GTK_IS_CELL_RENDERER_TEXT (renderer)) { textRenderer = renderer; break; } list = OS.g_list_next (list); } OS.g_list_free (originalList); return textRenderer; } /** * Returns the zero-relative index of the item which is currently * at the top of the receiver. This index can change when items are * scrolled or new items are added or removed. * * @return the index of the top item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getTopIndex () { checkWidget(); long /*int*/ [] path = new long /*int*/ [1]; OS.gtk_widget_realize (handle); if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return 0; if (path [0] == 0) return 0; long /*int*/ indices = OS.gtk_tree_path_get_indices (path[0]); int[] index = new int [1]; if (indices != 0) OS.memmove (index, indices, 4); OS.gtk_tree_path_free (path [0]); return index [0]; } @Override long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { GdkEventButton gdkEvent = new GdkEventButton (); OS.memmove (gdkEvent, event, GdkEventButton.sizeof); if (gdkEvent.window != OS.gtk_tree_view_get_bin_window (handle)) return 0; long /*int*/ result = super.gtk_button_press_event (widget, event); if (result != 0) return result; /* * Feature in GTK. In a multi-select table view, when multiple items are already * selected, the selection state of the item is toggled and the previous selection * is cleared. This is not the desired behaviour when bringing up a popup menu. * Also, when an item is reselected with the right button, the tree view issues * an unwanted selection event. The workaround is to detect that case and not * run the default handler when the item is already part of the current selection. */ int button = gdkEvent.button; if (button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) { long /*int*/ [] path = new long /*int*/ [1]; if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) { if (path [0] != 0) { long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) result = 1; OS.gtk_tree_path_free (path [0]); } } } /* * Feature in GTK. When the user clicks in a single selection GtkTreeView * and there are no selected items, the first item is selected automatically * before the click is processed, causing two selection events. The is fix * is the set the cursor item to be same as the clicked item to stop the * widget from automatically selecting the first item. */ if ((style & SWT.SINGLE) != 0 && getSelectionCount () == 0) { long /*int*/ [] path = new long /*int*/ [1]; if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) { if (path [0] != 0) { long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_view_set_cursor (handle, path [0], 0, false); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_path_free (path [0]); } } } //If Mouse double-click pressed, manually send a DefaultSelection. See Bug 312568. if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) { sendTreeDefaultSelection (); } return result; } @Override long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { GdkEventKey keyEvent = new GdkEventKey (); OS.memmove (keyEvent, event, GdkEventKey.sizeof); int key = keyEvent.keyval; keyPressDefaultSelectionHandler (event, key); return super.gtk_key_press_event (widget, event); } /** * Used to emulate DefaultSelection event. See Bug 312568. * @param event the gtk key press event that was fired. */ void keyPressDefaultSelectionHandler (long /*int*/ event, int key) { int keymask = gdk_event_get_state (event); switch (key) { case OS.GDK_Return: //Send Default selection return only when no other modifier is pressed. if ((keymask & (OS.GDK_MOD1_MASK | OS.GDK_SHIFT_MASK | OS.GDK_CONTROL_MASK | OS.GDK_SUPER_MASK | OS.GDK_META_MASK | OS.GDK_HYPER_MASK)) == 0) { sendTreeDefaultSelection (); } break; case OS.GDK_space: //Shift + Space is a legal DefaultSelection event. (as per row-activation signal documentation). //But do not send if another modifier is pressed. if ((keymask & (OS.GDK_MOD1_MASK | OS.GDK_CONTROL_MASK | OS.GDK_SUPER_MASK | OS.GDK_META_MASK | OS.GDK_HYPER_MASK)) == 0) { sendTreeDefaultSelection (); } break; } } //Used to emulate DefaultSelection event. See Bug 312568. //Feature in GTK. 'row-activation' event comes before DoubleClick event. //This is causing the editor not to get focus after doubleclick. //The solution is to manually send the DefaultSelection event after a doubleclick, //and to emulate it for Space/Return. void sendTreeDefaultSelection() { //Note, similar DefaultSelectionHandling in SWT List/Table/Tree TableItem tableItem = getFocusItem (); if (tableItem == null) return; Event event = new Event (); event.item = tableItem; sendSelectionEvent (SWT.DefaultSelection, event, false); } @Override long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event) { long /*int*/ window = OS.GDK_EVENT_WINDOW (event); if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0; return super.gtk_button_release_event (widget, event); } @Override long /*int*/ gtk_changed (long /*int*/ widget) { TableItem item = getFocusItem (); if (item != null) { Event event = new Event (); event.item = item; sendSelectionEvent (SWT.Selection, event, false); } return 0; } @Override long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) { switch (OS.GDK_EVENT_TYPE (gdkEvent)) { case OS.GDK_EXPOSE: { /* * Bug in GTK. SWT connects the expose-event 'after' the default * handler of the signal. If the tree has no children, then GTK * sends expose signal only 'before' the default signal handler. * The fix is to detect this case in 'event_after' and send the * expose event. */ if (OS.gtk_tree_model_iter_n_children (modelHandle, 0) == 0) { gtk_expose_event (widget, gdkEvent); } break; } } return super.gtk_event_after (widget, gdkEvent); } void drawInheritedBackground (long /*int*/ eventPtr, long /*int*/ cairo) { if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) { Control control = findBackgroundControl (); if (control != null) { long /*int*/ window = OS.gtk_tree_view_get_bin_window (handle); long /*int*/ rgn = 0; if (eventPtr != 0) { GdkEventExpose gdkEvent = new GdkEventExpose (); OS.memmove (gdkEvent, eventPtr, GdkEventExpose.sizeof); if (window != gdkEvent.window) return; rgn = gdkEvent.region; } int [] width = new int [1], height = new int [1]; gdk_window_get_size (window, width, height); int bottom = 0; if (itemCount != 0) { long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, itemCount - 1); long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); GdkRectangle rect = new GdkRectangle (); OS.gtk_tree_view_get_cell_area (handle, path, 0, rect); bottom = rect.y + rect.height; OS.gtk_tree_path_free (path); OS.g_free (iter); } if (height [0] > bottom) { drawBackground (control, window, cairo, rgn, 0, bottom, width [0], height [0] - bottom); } } } } @Override long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) { if ((state & OBSCURED) != 0) return 0; drawInheritedBackground (0, cairo); return super.gtk_draw (widget, cairo); } @Override long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) { if ((state & OBSCURED) != 0) return 0; drawInheritedBackground (eventPtr, 0); return super.gtk_expose_event (widget, eventPtr); } @Override long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) { long /*int*/ window = OS.GDK_EVENT_WINDOW (event); if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0; return super.gtk_motion_notify_event (widget, event); } @Override long /*int*/ gtk_row_deleted (long /*int*/ model, long /*int*/ path) { if (ignoreAccessibility) { OS.g_signal_stop_emission_by_name (model, OS.row_deleted); } return 0; } @Override long /*int*/ gtk_row_inserted (long /*int*/ model, long /*int*/ path, long /*int*/ iter) { if (ignoreAccessibility) { OS.g_signal_stop_emission_by_name (model, OS.row_inserted); } return 0; } @Override long /*int*/ gtk_start_interactive_search(long /*int*/ widget) { if (!searchEnabled()) { OS.g_signal_stop_emission_by_name(widget, OS.start_interactive_search); return 1; } return 0; } @Override long /*int*/ gtk_toggled (long /*int*/ renderer, long /*int*/ pathStr) { long /*int*/ path = OS.gtk_tree_path_new_from_string (pathStr); if (path == 0) return 0; long /*int*/ indices = OS.gtk_tree_path_get_indices (path); if (indices != 0) { int [] index = new int [1]; OS.memmove (index, indices, 4); TableItem item = _getItem (index [0]); item.setChecked (!item.getChecked ()); Event event = new Event (); event.detail = SWT.CHECK; event.item = item; sendSelectionEvent (SWT.Selection, event, false); } OS.gtk_tree_path_free (path); return 0; } @Override void gtk_widget_size_request (long /*int*/ widget, GtkRequisition requisition) { /* * Bug in GTK. For some reason, gtk_widget_size_request() fails * to include the height of the tree view items when there are * no columns visible. The fix is to temporarily make one column * visible. */ if (columnCount == 0) { super.gtk_widget_size_request (widget, requisition); return; } long /*int*/ columns = OS.gtk_tree_view_get_columns (handle), list = columns; boolean fixVisible = columns != 0; while (list != 0) { long /*int*/ column = OS.g_list_data (list); if (OS.gtk_tree_view_column_get_visible (column)) { fixVisible = false; break; } list = OS.g_list_next (list); } long /*int*/ columnHandle = 0; if (fixVisible) { columnHandle = OS.g_list_data (columns); OS.gtk_tree_view_column_set_visible (columnHandle, true); } super.gtk_widget_size_request (widget, requisition); if (fixVisible) { OS.gtk_tree_view_column_set_visible (columnHandle, false); } if (columns != 0) OS.g_list_free (columns); } void hideFirstColumn () { long /*int*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0); OS.gtk_tree_view_column_set_visible (firstColumn, false); } @Override void hookEvents () { super.hookEvents (); long /*int*/ selection = OS.gtk_tree_view_get_selection(handle); OS.g_signal_connect_closure (selection, OS.changed, display.getClosure (CHANGED), false); OS.g_signal_connect_closure (handle, OS.row_activated, display.getClosure (ROW_ACTIVATED), false); if (checkRenderer != 0) { OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.getClosure (TOGGLED), false); } OS.g_signal_connect_closure (handle, OS.start_interactive_search, display.getClosure (START_INTERACTIVE_SEARCH), false); if (fixAccessibility ()) { OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.getClosure (ROW_INSERTED), true); OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.getClosure (ROW_DELETED), true); } } /** * Searches the receiver's list starting at the first column * (index 0) until a column is found that is equal to the * argument, and returns the index of that column. If no column * is found, returns -1. * * @param column the search column * @return the index of the column * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the column is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int indexOf (TableColumn column) { checkWidget(); if (column == null) error (SWT.ERROR_NULL_ARGUMENT); for (int i=0; i<columnCount; i++) { if (columns [i] == column) return i; } return -1; } /** * Searches the receiver's list starting at the first item * (index 0) until an item is found that is equal to the * argument, and returns the index of that item. If no item * is found, returns -1. * * @param item the search item * @return the index of the item * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the item is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int indexOf (TableItem item) { checkWidget(); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) { if (items [lastIndexOf] == item) return lastIndexOf; if (items [lastIndexOf + 1] == item) return ++lastIndexOf; if (items [lastIndexOf - 1] == item) return --lastIndexOf; } if (lastIndexOf < itemCount / 2) { for (int i=0; i<itemCount; i++) { if (items [i] == item) return lastIndexOf = i; } } else { for (int i=itemCount - 1; i>=0; --i) { if (items [i] == item) return lastIndexOf = i; } } return -1; } /** * Returns <code>true</code> if the item is selected, * and <code>false</code> otherwise. Indices out of * range are ignored. * * @param index the index of the item * @return the selection state of the item at the index * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public boolean isSelected (int index) { checkWidget(); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); byte [] buffer = Converter.wcsToMbcs (null, Integer.toString (index), true); long /*int*/ path = OS.gtk_tree_path_new_from_string (buffer); boolean answer = OS.gtk_tree_selection_path_is_selected (selection, path); OS.gtk_tree_path_free (path); return answer; } @Override boolean mnemonicHit (char key) { for (int i=0; i<columnCount; i++) { long /*int*/ labelHandle = columns [i].labelHandle; if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true; } return false; } @Override boolean mnemonicMatch (char key) { for (int i=0; i<columnCount; i++) { long /*int*/ labelHandle = columns [i].labelHandle; if (labelHandle != 0 && mnemonicMatch (labelHandle, key)) return true; } return false; } @Override long /*int*/ paintWindow () { OS.gtk_widget_realize (handle); if (fixedHandle != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0)) { OS.gtk_widget_realize (fixedHandle); return OS.gtk_widget_get_window(fixedHandle); } return OS.gtk_tree_view_get_bin_window (handle); } void recreateRenderers () { if (checkRenderer != 0) { display.removeWidget (checkRenderer); OS.g_object_unref (checkRenderer); checkRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_toggle_get_type(), 0) : OS.gtk_cell_renderer_toggle_new (); if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES); OS.g_object_ref (checkRenderer); display.addWidget (checkRenderer, this); OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.getClosure (TOGGLED), false); } if (columnCount == 0) { createRenderers (OS.gtk_tree_view_get_column (handle, 0), Table.FIRST_COLUMN, true, 0); } else { for (int i = 0; i < columnCount; i++) { TableColumn column = columns [i]; createRenderers (column.handle, column.modelIndex, i == 0, column.style); } } } @Override void redrawBackgroundImage () { Control control = findBackgroundControl (); if (control != null && control.backgroundImage != null) { redrawWidget (0, 0, 0, 0, true, false, false); } } @Override void register () { super.register (); display.addWidget (OS.gtk_tree_view_get_selection (handle), this); if (checkRenderer != 0) display.addWidget (checkRenderer, this); display.addWidget (modelHandle, this); } @Override void releaseChildren (boolean destroy) { if (items != null) { for (int i=0; i<itemCount; i++) { TableItem item = items [i]; if (item != null && !item.isDisposed ()) { item.release (false); } } items = null; } if (columns != null) { for (int i=0; i<columnCount; i++) { TableColumn column = columns [i]; if (column != null && !column.isDisposed ()) { column.release (false); } } columns = null; } super.releaseChildren (destroy); } @Override void releaseWidget () { super.releaseWidget (); if (modelHandle != 0) OS.g_object_unref (modelHandle); modelHandle = 0; if (checkRenderer != 0) OS.g_object_unref (checkRenderer); checkRenderer = 0; if (imageList != null) imageList.dispose (); if (headerImageList != null) headerImageList.dispose (); imageList = headerImageList = null; currentItem = null; } /** * Removes the item from the receiver at the given * zero-relative index. * * @param index the index for the item * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void remove (int index) { checkWidget(); if (!(0 <= index && index < itemCount)) error (SWT.ERROR_ITEM_NOT_REMOVED); long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); TableItem item = items [index]; boolean disposed = false; if (item != null) { disposed = item.isDisposed (); if (!disposed) { OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ()); item.release (false); } } else { OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); } if (!disposed) { long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_list_store_remove (modelHandle, iter); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); System.arraycopy (items, index + 1, items, index, --itemCount - index); items [itemCount] = null; } OS.g_free (iter); } /** * Removes the items from the receiver which are * between the given zero-relative start and end * indices (inclusive). * * @param start the start of the range * @param end the end of the range * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void remove (int start, int end) { checkWidget(); if (start > end) return; if (!(0 <= start && start <= end && end < itemCount)) { error (SWT.ERROR_INVALID_RANGE); } long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (iter == 0) error (SWT.ERROR_NO_HANDLES); if (fixAccessibility ()) { ignoreAccessibility = true; } int index = end; while (index >= start) { OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); TableItem item = items [index]; if (item != null && !item.isDisposed ()) item.release (false); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_list_store_remove (modelHandle, iter); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); index--; } if (fixAccessibility ()) { ignoreAccessibility = false; OS.g_object_notify (handle, OS.model); } OS.g_free (iter); index = end + 1; System.arraycopy (items, index, items, start, itemCount - index); for (int i=itemCount-(index-start); i<itemCount; i++) items [i] = null; itemCount = itemCount - (index - start); } /** * Removes the items from the receiver's list at the given * zero-relative indices. * * @param indices the array of indices of the items * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> * <li>ERROR_NULL_ARGUMENT - if the indices array is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void remove (int [] indices) { checkWidget(); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); if (indices.length == 0) return; int [] newIndices = new int [indices.length]; System.arraycopy (indices, 0, newIndices, 0, indices.length); sort (newIndices); int start = newIndices [newIndices.length - 1], end = newIndices [0]; if (!(0 <= start && start <= end && end < itemCount)) { error (SWT.ERROR_INVALID_RANGE); } long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); int last = -1; long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (iter == 0) error (SWT.ERROR_NO_HANDLES); if (fixAccessibility ()) { ignoreAccessibility = true; } for (int i=0; i<newIndices.length; i++) { int index = newIndices [i]; if (index != last) { TableItem item = items [index]; boolean disposed = false; if (item != null) { disposed = item.isDisposed (); if (!disposed) { OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ()); item.release (false); } } else { OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); } if (!disposed) { OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_list_store_remove (modelHandle, iter); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); System.arraycopy (items, index + 1, items, index, --itemCount - index); items [itemCount] = null; } last = index; } } if (fixAccessibility ()) { ignoreAccessibility = false; OS.g_object_notify (handle, OS.model); } OS.g_free (iter); } /** * Removes all of the items from the receiver. * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void removeAll () { checkWidget(); int index = itemCount - 1; while (index >= 0) { TableItem item = items [index]; if (item != null && !item.isDisposed ()) item.release (false); --index; } items = new TableItem [4]; itemCount = 0; long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixAccessibility ()) { ignoreAccessibility = true; } OS.gtk_list_store_clear (modelHandle); if (fixAccessibility ()) { ignoreAccessibility = false; OS.g_object_notify (handle, OS.model); } OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); resetCustomDraw (); if (!searchEnabled ()) { OS.gtk_tree_view_set_search_column (handle, -1); } else { /* Set the search column whenever the model changes */ int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex; OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT); } } /** * Removes the listener from the collection of listeners who will * be notified when the user changes the receiver's selection. * * @param listener the listener which should no longer be notified * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see SelectionListener * @see #addSelectionListener(SelectionListener) */ public void removeSelectionListener(SelectionListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Selection, listener); eventTable.unhook (SWT.DefaultSelection,listener); } void sendMeasureEvent (long /*int*/ cell, long /*int*/ width, long /*int*/ height) { if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell) && hooks (SWT.MeasureItem)) { long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2); TableItem item = null; boolean isSelected = false; if (iter != 0) { long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); int [] buffer = new int [1]; OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4); int index = buffer [0]; item = _getItem (index); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); isSelected = OS.gtk_tree_selection_path_is_selected (selection, path); OS.gtk_tree_path_free (path); } if (item != null) { int columnIndex = 0; if (columnCount > 0) { long /*int*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1); for (int i = 0; i < columnCount; i++) { if (columns [i].handle == columnHandle) { columnIndex = i; break; } } } int [] contentWidth = new int [1], contentHeight = new int [1]; if (width != 0) OS.memmove (contentWidth, width, 4); if (height != 0) OS.memmove (contentHeight, height, 4); if (OS.GTK3) { OS.gtk_cell_renderer_get_preferred_height_for_width (cell, handle, contentWidth[0], contentHeight, null); } Image image = item.getImage (columnIndex); int imageWidth = 0; if (image != null) { Rectangle bounds = image.getBounds (); imageWidth = bounds.width; } contentWidth [0] += imageWidth; GC gc = new GC (this); gc.setFont (item.getFont (columnIndex)); Event event = new Event (); event.item = item; event.index = columnIndex; event.gc = gc; event.width = contentWidth [0]; event.height = contentHeight [0]; if (isSelected) event.detail = SWT.SELECTED; sendEvent (SWT.MeasureItem, event); gc.dispose (); contentWidth [0] = event.width - imageWidth; if (contentHeight [0] < event.height) contentHeight [0] = event.height; if (width != 0) OS.memmove (width, contentWidth, 4); if (height != 0) OS.memmove (height, contentHeight, 4); if (OS.GTK3) { OS.gtk_cell_renderer_set_fixed_size (cell, contentWidth [0], contentHeight [0]); } } } } @Override long /*int*/ rendererGetPreferredWidthProc (long /*int*/ cell, long /*int*/ handle, long /*int*/ minimun_size, long /*int*/ natural_size) { long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell)); GtkCellRendererClass klass = new GtkCellRendererClass (); OS.memmove (klass, g_class); OS.call (klass.get_preferred_width, cell, handle, minimun_size, natural_size); sendMeasureEvent (cell, minimun_size, 0); return 0; } @Override long /*int*/ rendererGetSizeProc (long /*int*/ cell, long /*int*/ widget, long /*int*/ cell_area, long /*int*/ x_offset, long /*int*/ y_offset, long /*int*/ width, long /*int*/ height) { long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell)); GtkCellRendererClass klass = new GtkCellRendererClass (); OS.memmove (klass, g_class); OS.call_get_size (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height); sendMeasureEvent (cell, width, height); return 0; } @Override long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ cr, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ flags) { rendererRender (cell, cr, 0, widget, background_area, cell_area, 0, flags); return 0; } @Override long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) { rendererRender (cell, 0, window, widget, background_area, cell_area, expose_area, flags); return 0; } void rendererRender (long /*int*/ cell, long /*int*/ cr, long /*int*/ window, long /*int*/ widget, long /*int*/ background_area, long /*int*/ cell_area, long /*int*/ expose_area, long /*int*/ flags) { TableItem item = null; long /*int*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2); if (iter != 0) { long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); int [] buffer = new int [1]; OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4); int index = buffer [0]; item = _getItem (index); OS.gtk_tree_path_free (path); } long /*int*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1); int columnIndex = 0; if (columnCount > 0) { for (int i = 0; i < columnCount; i++) { if (columns [i].handle == columnHandle) { columnIndex = i; break; } } } if (item != null) { if (OS.GTK_IS_CELL_RENDERER_TOGGLE (cell) || ( (OS.GTK_IS_CELL_RENDERER_PIXBUF (cell) || OS.GTK_VERSION > OS.VERSION(3, 13, 0)) && (columnIndex != 0 || (style & SWT.CHECK) == 0))) { drawFlags = (int)/*64*/flags; drawState = SWT.FOREGROUND; long /*int*/ [] ptr = new long /*int*/ [1]; OS.gtk_tree_model_get (modelHandle, item.handle, Table.BACKGROUND_COLUMN, ptr, -1); if (ptr [0] == 0) { int modelIndex = columnCount == 0 ? Table.FIRST_COLUMN : columns [columnIndex].modelIndex; OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1); } if (ptr [0] != 0) { drawState |= SWT.BACKGROUND; OS.gdk_color_free (ptr [0]); } if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED; if (!OS.GTK3 || (flags & OS.GTK_CELL_RENDERER_SELECTED) == 0) { if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED; } GdkRectangle rect = new GdkRectangle (); long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect); OS.gtk_tree_path_free (path); // A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=459117 if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { GdkRectangle r2 = new GdkRectangle (); OS.gdk_cairo_get_clip_rectangle (cr, r2); rect.x = r2.x; rect.width = r2.width; } if ((drawState & SWT.SELECTED) == 0) { if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) { Control control = findBackgroundControl (); if (control != null) { if (cr != 0) { Cairo.cairo_save (cr); if (!OS.GTK3){ Cairo.cairo_reset_clip (cr); } } drawBackground (control, window, cr, 0, rect.x, rect.y, rect.width, rect.height); if (cr != 0) { Cairo.cairo_restore (cr); } } } } //send out measure before erase long /*int*/ textRenderer = getTextRenderer (columnHandle); if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null); if (hooks (SWT.EraseItem)) { boolean wasSelected = (drawState & SWT.SELECTED) != 0; if (wasSelected) { Control control = findBackgroundControl (); if (control == null) control = this; if (!OS.GTK3){ if (cr != 0) { Cairo.cairo_save (cr); Cairo.cairo_reset_clip (cr); } drawBackground (control, window, cr, 0, rect.x, rect.y, rect.width, rect.height); if (cr != 0) { Cairo.cairo_restore (cr); } } } GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); } else { gc.setBackground (item.getBackground (columnIndex)); gc.setForeground (item.getForeground (columnIndex)); } gc.setFont (item.getFont (columnIndex)); if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x; if (OS.GTK_VERSION >= OS.VERSION(3, 9, 0) && cr != 0) { GdkRectangle r = new GdkRectangle(); OS.gdk_cairo_get_clip_rectangle(cr, r); gc.setClipping(rect.x, r.y, r.width, r.height); if (OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { rect.width = r.width; } } else { gc.setClipping (rect.x, rect.y, rect.width, rect.height); } Event event = new Event (); event.item = item; event.index = columnIndex; event.gc = gc; event.x = rect.x; event.y = rect.y; event.width = rect.width; event.height = rect.height; event.detail = drawState; sendEvent (SWT.EraseItem, event); drawForeground = null; drawState = event.doit ? event.detail : 0; if (OS.GTK3) { drawState |= SWT.BACKGROUND; } drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED); if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED; if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED; if ((drawState & SWT.SELECTED) != 0) { if (OS.GTK3) { Cairo.cairo_save (cr); Cairo.cairo_reset_clip (cr); long /*int*/ context = OS.gtk_widget_get_style_context (widget); OS.gtk_style_context_save (context); OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_CELL); OS.gtk_style_context_set_state (context, OS.GTK_STATE_FLAG_SELECTED); OS.gtk_render_background(context, cr, rect.x, rect.y, rect.width, rect.height); OS.gtk_style_context_restore (context); Cairo.cairo_restore (cr); } else { long /*int*/ style = OS.gtk_widget_get_style (widget); //TODO - parity and sorted byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true); OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height); } } else { if (wasSelected) drawForeground = gc.getForeground ().handle; } gc.dispose(); } } } if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) { GC gc = getGC(cr); gc.setBackground (item.getBackground (columnIndex)); GdkRectangle rect = new GdkRectangle (); OS.memmove (rect, background_area, GdkRectangle.sizeof); gc.fillRectangle (rect.x, rect.y, rect.width, rect.height); gc.dispose (); } if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) { long /*int*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell)); GtkCellRendererClass klass = new GtkCellRendererClass (); OS.memmove (klass, g_class); if (drawForeground != null && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) { OS.g_object_set (cell, OS.foreground_gdk, drawForeground, 0); } if (OS.GTK3) { OS.call (klass.render, cell, cr, widget, background_area, cell_area, drawFlags); } else { OS.call (klass.render, cell, window, widget, background_area, cell_area, expose_area, drawFlags); } } if (item != null) { if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) { if (hooks (SWT.PaintItem)) { GdkRectangle rect = new GdkRectangle (); long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect); OS.gtk_tree_path_free (path); // A workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=459117 if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { GdkRectangle r2 = new GdkRectangle (); OS.gdk_cairo_get_clip_rectangle (cr, r2); rect.x = r2.x; rect.width = r2.width; } ignoreSize = true; int [] contentX = new int [1], contentWidth = new int [1]; gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null); OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null); ignoreSize = false; Image image = item.getImage (columnIndex); int imageWidth = 0; if (image != null) { Rectangle bounds = image.getBounds (); imageWidth = bounds.width; } // On gtk >3.9 and <3.14.8 the clip rectangle does not have image area into clip rectangle // need to adjust clip rectangle with image width if (cr != 0 && OS.GTK_VERSION > OS.VERSION(3, 9, 0) && OS.GTK_VERSION <= OS.VERSION(3, 14, 8)) { rect.x -= imageWidth; rect.width +=imageWidth; } contentX [0] -= imageWidth; contentWidth [0] += imageWidth; GC gc = getGC(cr); if ((drawState & SWT.SELECTED) != 0) { Color background, foreground; if (OS.gtk_widget_has_focus (handle) || OS.GTK3) { background = display.getSystemColor (SWT.COLOR_LIST_SELECTION); foreground = display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT); } else { /* * Feature in GTK. When the widget doesn't have focus, then * gtk_paint_flat_box () changes the background color state_type * to GTK_STATE_ACTIVE. The fix is to use the same values in the GC. */ background = Color.gtk_new (display, display.COLOR_LIST_SELECTION_INACTIVE); foreground = Color.gtk_new (display, display.COLOR_LIST_SELECTION_TEXT_INACTIVE); } gc.setBackground (background); gc.setForeground (foreground); } else { gc.setBackground (item.getBackground (columnIndex)); Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex); gc.setForeground (foreground); } gc.setFont (item.getFont (columnIndex)); if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x; gc.setClipping (rect.x, rect.y, rect.width, rect.height); Event event = new Event (); event.item = item; event.index = columnIndex; event.gc = gc; event.x = rect.x + contentX [0]; event.y = rect.y; event.width = contentWidth [0]; event.height = rect.height; event.detail = drawState; sendEvent (SWT.PaintItem, event); gc.dispose(); } } } } private GC getGC(long /*int*/ cr) { GC gc; if (OS.GTK3){ GCData gcData = new GCData(); gcData.cairo = cr; gc = GC.gtk_new(this, gcData ); } else { gc = new GC (this); } return gc; } void resetCustomDraw () { if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return; int end = Math.max (1, columnCount); for (int i=0; i<end; i++) { boolean customDraw = columnCount != 0 ? columns [i].customDraw : firstCustomDraw; if (customDraw) { long /*int*/ column = OS.gtk_tree_view_get_column (handle, i); long /*int*/ textRenderer = getTextRenderer (column); OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, 0, 0, 0); if (columnCount != 0) columns [i].customDraw = false; } } firstCustomDraw = false; } @Override void reskinChildren (int flags) { if (items != null) { for (int i=0; i<itemCount; i++) { TableItem item = items [i]; if (item != null) item.reskin (flags); } } if (columns != null) { for (int i=0; i<columnCount; i++) { TableColumn column = columns [i]; if (!column.isDisposed ()) column.reskin (flags); } } super.reskinChildren (flags); } boolean searchEnabled () { /* Disable searching when using VIRTUAL */ if ((style & SWT.VIRTUAL) != 0) return false; return true; } /** * Selects the item at the given zero-relative index in the receiver. * If the item at the index was already selected, it remains * selected. Indices that are out of range are ignored. * * @param index the index of the item to select * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void select (int index) { checkWidget(); if (!(0 <= index && index < itemCount)) return; boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); TableItem item = _getItem (index); OS.gtk_tree_selection_select_iter (selection, item.handle); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Selects the items in the range specified by the given zero-relative * indices in the receiver. The range of indices is inclusive. * The current selection is not cleared before the new items are selected. * <p> * If an item in the given range is not selected, it is selected. * If an item in the given range was already selected, it remains selected. * Indices that are out of range are ignored and no items will be selected * if start is greater than end. * If the receiver is single-select and there is more than one item in the * given range, then all indices are ignored. * </p> * * @param start the start of the range * @param end the end of the range * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#setSelection(int,int) */ public void select (int start, int end) { checkWidget (); if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return; if (itemCount == 0 || start >= itemCount) return; start = Math.max (0, start); end = Math.min (end, itemCount - 1); boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); for (int index=start; index<=end; index++) { TableItem item = _getItem (index); OS.gtk_tree_selection_select_iter (selection, item.handle); } OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Selects the items at the given zero-relative indices in the receiver. * The current selection is not cleared before the new items are selected. * <p> * If the item at a given index is not selected, it is selected. * If the item at a given index was already selected, it remains selected. * Indices that are out of range and duplicate indices are ignored. * If the receiver is single-select and multiple indices are specified, * then all indices are ignored. * </p> * * @param indices the array of indices for the items to select * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#setSelection(int[]) */ public void select (int [] indices) { checkWidget (); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); int length = indices.length; if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return; boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); for (int i=0; i<length; i++) { int index = indices [i]; if (!(0 <= index && index < itemCount)) continue; TableItem item = _getItem (index); OS.gtk_tree_selection_select_iter (selection, item.handle); } OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } /** * Selects all of the items in the receiver. * <p> * If the receiver is single-select, do nothing. * </p> * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void selectAll () { checkWidget(); if ((style & SWT.SINGLE) != 0) return; boolean fixColumn = showFirstColumn (); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_selection_select_all (selection); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); if (fixColumn) hideFirstColumn (); } void selectFocusIndex (int index) { /* * Note that this method both selects and sets the focus to the * specified index, so any previous selection in the list will be lost. * gtk does not provide a way to just set focus to a specified list item. */ if (!(0 <= index && index < itemCount)) return; TableItem item = _getItem (index); long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle); long /*int*/ selection = OS.gtk_tree_view_get_selection (handle); OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_view_set_cursor (handle, path, 0, false); /* * Bug in GTK. For some reason, when an event loop is run from * within a key pressed handler and a dialog is displayed that * contains a GtkTreeView, gtk_tree_view_set_cursor() does * not set the cursor or select the item. The fix is to select the * item with gtk_tree_selection_select_iter() as well. * * NOTE: This happens in GTK 2.2.1 and is fixed in GTK 2.2.4. */ OS.gtk_tree_selection_select_iter (selection, item.handle); OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED); OS.gtk_tree_path_free (path); } @Override void setBackgroundColor (GdkColor color) { super.setBackgroundColor (color); if (!OS.GTK3) { OS.gtk_widget_modify_base (handle, 0, color); } else { // Setting the background color overrides the selected background color // so we have to reset it the default. GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = new GdkRGBA (); selectedBackground.alpha = 1; selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF; selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF; selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF; OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground); } } @Override void setBackgroundPixmap (Image image) { ownerDraw = true; recreateRenderers (); } @Override int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { int result = super.setBounds (x, y, width, height, move, resize); /* * Bug on GTK. The tree view sometimes does not get a paint * event or resizes to a one pixel square when resized in a new * shell that is not visible after any event loop has been run. The * problem is intermittent. It doesn't seem to happen the first time * a new shell is created. The fix is to ensure the tree view is realized * after it has been resized. */ OS.gtk_widget_realize (handle); return result; } /** * Sets the order that the items in the receiver should * be displayed in to the given argument which is described * in terms of the zero-relative ordering of when the items * were added. * * @param order the new order to display the items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the item order is null</li> * <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li> * </ul> * * @see Table#getColumnOrder() * @see TableColumn#getMoveable() * @see TableColumn#setMoveable(boolean) * @see SWT#Move * * @since 3.1 */ public void setColumnOrder (int [] order) { checkWidget (); if (order == null) error (SWT.ERROR_NULL_ARGUMENT); if (columnCount == 0) { if (order.length > 0) error (SWT.ERROR_INVALID_ARGUMENT); return; } if (order.length != columnCount) error (SWT.ERROR_INVALID_ARGUMENT); boolean [] seen = new boolean [columnCount]; for (int i = 0; i<order.length; i++) { int index = order [i]; if (index < 0 || index >= columnCount) error (SWT.ERROR_INVALID_RANGE); if (seen [index]) error (SWT.ERROR_INVALID_ARGUMENT); seen [index] = true; } for (int i=0; i<order.length; i++) { long /*int*/ column = columns [order [i]].handle; long /*int*/ baseColumn = i == 0 ? 0 : columns [order [i-1]].handle; OS.gtk_tree_view_move_column_after (handle, column, baseColumn); } } @Override void setFontDescription (long /*int*/ font) { super.setFontDescription (font); TableColumn[] columns = getColumns (); for (int i = 0; i < columns.length; i++) { if (columns[i] != null) { columns[i].setFontDescription (font); } } } @Override void setForegroundColor (GdkColor color) { setForegroundColor (handle, color, false); } /** * Marks the receiver's header as visible if the argument is <code>true</code>, * and marks it invisible otherwise. * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, marking * it visible may not actually cause it to be displayed. * </p> * * @param show the new visibility state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setHeaderVisible (boolean show) { checkWidget (); OS.gtk_tree_view_set_headers_visible (handle, show); } /** * Sets the number of items contained in the receiver. * * @param count the number of items * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 */ public void setItemCount (int count) { checkWidget (); count = Math.max (0, count); if (count == itemCount) return; boolean isVirtual = (style & SWT.VIRTUAL) != 0; if (!isVirtual) setRedraw (false); remove (count, itemCount - 1); int length = Math.max (4, (count + 3) / 4 * 4); TableItem [] newItems = new TableItem [length]; System.arraycopy (items, 0, newItems, 0, itemCount); items = newItems; if (isVirtual) { long /*int*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ()); if (iter == 0) error (SWT.ERROR_NO_HANDLES); if (fixAccessibility ()) { ignoreAccessibility = true; } for (int i=itemCount; i<count; i++) { OS.gtk_list_store_append (modelHandle, iter); } if (fixAccessibility ()) { ignoreAccessibility = false; OS.g_object_notify (handle, OS.model); } OS.g_free (iter); itemCount = count; } else { for (int i=itemCount; i<count; i++) { new TableItem (this, SWT.NONE, i, true); } } if (!isVirtual) setRedraw (true); } /** * Marks the receiver's lines as visible if the argument is <code>true</code>, * and marks it invisible otherwise. Note that some platforms draw grid lines * while others may draw alternating row colors. * <p> * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, marking * it visible may not actually cause it to be displayed. * </p> * * @param show the new visibility state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setLinesVisible (boolean show) { checkWidget(); if (!OS.GTK3) { OS.gtk_tree_view_set_rules_hint (handle, show); } //Note: this is overriden by the active theme in GTK3. OS.gtk_tree_view_set_grid_lines (handle, show ? OS.GTK_TREE_VIEW_GRID_LINES_VERTICAL : OS.GTK_TREE_VIEW_GRID_LINES_NONE); } void setModel (long /*int*/ newModel) { display.removeWidget (modelHandle); OS.g_object_unref (modelHandle); modelHandle = newModel; display.addWidget (modelHandle, this); if (fixAccessibility ()) { OS.g_signal_connect_closure (modelHandle, OS.row_inserted, display.getClosure (ROW_INSERTED), true); OS.g_signal_connect_closure (modelHandle, OS.row_deleted, display.getClosure (ROW_DELETED), true); } } @Override void setOrientation (boolean create) { super.setOrientation (create); for (int i=0; i<itemCount; i++) { if (items[i] != null) items[i].setOrientation (create); } for (int i=0; i<columnCount; i++) { if (columns[i] != null) columns[i].setOrientation (create); } } @Override void setParentBackground () { ownerDraw = true; recreateRenderers (); } @Override void setParentWindow (long /*int*/ widget) { long /*int*/ window = eventWindow (); OS.gtk_widget_set_parent_window (widget, window); } @Override public void setRedraw (boolean redraw) { checkWidget(); super.setRedraw (redraw); if (redraw && drawCount == 0) { /* Resize the item array to match the item count */ if (items.length > 4 && items.length - itemCount > 3) { int length = Math.max (4, (itemCount + 3) / 4 * 4); TableItem [] newItems = new TableItem [length]; System.arraycopy (items, 0, newItems, 0, itemCount); items = newItems; } } } void setScrollWidth (long /*int*/ column, TableItem item) { if (columnCount != 0 || currentItem == item) return; int width = OS.gtk_tree_view_column_get_fixed_width (column); int itemWidth = calculateWidth (column, item.handle); if (width < itemWidth) { OS.gtk_tree_view_column_set_fixed_width (column, itemWidth); } } /** * Sets the column used by the sort indicator for the receiver. A null * value will clear the sort indicator. The current sort column is cleared * before the new column is set. * * @param column the column used by the sort indicator or <code>null</code> * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.2 */ public void setSortColumn (TableColumn column) { checkWidget (); if (column != null && column.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); if (sortColumn != null && !sortColumn.isDisposed()) { OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false); } sortColumn = column; if (sortColumn != null && sortDirection != SWT.NONE) { OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true); OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1); } } /** * Sets the direction of the sort indicator for the receiver. The value * can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>. * * @param direction the direction of the sort indicator * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.2 */ public void setSortDirection (int direction) { checkWidget (); if (direction != SWT.UP && direction != SWT.DOWN && direction != SWT.NONE) return; sortDirection = direction; if (sortColumn == null || sortColumn.isDisposed ()) return; if (sortDirection == SWT.NONE) { OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false); } else { OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true); OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1); } } /** * Selects the item at the given zero-relative index in the receiver. * The current selection is first cleared, then the new item is selected, * and if necessary the receiver is scrolled to make the new selection visible. * * @param index the index of the item to select * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#deselectAll() * @see Table#select(int) */ public void setSelection (int index) { checkWidget (); boolean fixColumn = showFirstColumn (); deselectAll (); selectFocusIndex (index); showSelection (); if (fixColumn) hideFirstColumn (); } /** * Selects the items in the range specified by the given zero-relative * indices in the receiver. The range of indices is inclusive. * The current selection is cleared before the new items are selected, * and if necessary the receiver is scrolled to make the new selection visible. * <p> * Indices that are out of range are ignored and no items will be selected * if start is greater than end. * If the receiver is single-select and there is more than one item in the * given range, then all indices are ignored. * </p> * * @param start the start index of the items to select * @param end the end index of the items to select * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#deselectAll() * @see Table#select(int,int) */ public void setSelection (int start, int end) { checkWidget (); deselectAll(); if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return; if (itemCount == 0 || start >= itemCount) return; boolean fixColumn = showFirstColumn (); start = Math.max (0, start); end = Math.min (end, itemCount - 1); selectFocusIndex (start); if ((style & SWT.MULTI) != 0) { select (start, end); } showSelection (); if (fixColumn) hideFirstColumn (); } /** * Selects the items at the given zero-relative indices in the receiver. * The current selection is cleared before the new items are selected, * and if necessary the receiver is scrolled to make the new selection visible. * <p> * Indices that are out of range and duplicate indices are ignored. * If the receiver is single-select and multiple indices are specified, * then all indices are ignored. * </p> * * @param indices the indices of the items to select * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#deselectAll() * @see Table#select(int[]) */ public void setSelection (int [] indices) { checkWidget (); if (indices == null) error (SWT.ERROR_NULL_ARGUMENT); deselectAll (); int length = indices.length; if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return; boolean fixColumn = showFirstColumn (); selectFocusIndex (indices [0]); if ((style & SWT.MULTI) != 0) { select (indices); } showSelection (); if (fixColumn) hideFirstColumn (); } /** * Sets the receiver's selection to the given item. * The current selection is cleared before the new item is selected, * and if necessary the receiver is scrolled to make the new selection visible. * <p> * If the item is not in the receiver, then it is ignored. * </p> * * @param item the item to select * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the item is null</li> * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.2 */ public void setSelection (TableItem item) { if (item == null) error (SWT.ERROR_NULL_ARGUMENT); setSelection (new TableItem [] {item}); } /** * Sets the receiver's selection to be the given array of items. * The current selection is cleared before the new items are selected, * and if necessary the receiver is scrolled to make the new selection visible. * <p> * Items that are not in the receiver are ignored. * If the receiver is single-select and multiple items are specified, * then all items are ignored. * </p> * * @param items the array of items * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the array of items is null</li> * <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#deselectAll() * @see Table#select(int[]) * @see Table#setSelection(int[]) */ public void setSelection (TableItem [] items) { checkWidget (); if (items == null) error (SWT.ERROR_NULL_ARGUMENT); boolean fixColumn = showFirstColumn (); deselectAll (); int length = items.length; if (!(length == 0 || ((style & SWT.SINGLE) != 0 && length > 1))) { boolean first = true; for (int i = 0; i < length; i++) { int index = indexOf (items [i]); if (index != -1) { if (first) { first = false; selectFocusIndex (index); } else { select (index); } } } showSelection (); } if (fixColumn) hideFirstColumn (); } /** * Sets the zero-relative index of the item which is currently * at the top of the receiver. This index can change when items * are scrolled or new items are added and removed. * * @param index the index of the top item * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setTopIndex (int index) { checkWidget(); if (!(0 <= index && index < itemCount)) return; long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, _getItem (index).handle); OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f); OS.gtk_tree_path_free (path); } /** * Shows the column. If the column is already showing in the receiver, * this method simply returns. Otherwise, the columns are scrolled until * the column is visible. * * @param column the column to be shown * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the column is null</li> * <li>ERROR_INVALID_ARGUMENT - if the column has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 */ public void showColumn (TableColumn column) { checkWidget (); if (column == null) error (SWT.ERROR_NULL_ARGUMENT); if (column.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); if (column.parent != this) return; OS.gtk_tree_view_scroll_to_cell (handle, 0, column.handle, false, 0, 0); } boolean showFirstColumn () { /* * Bug in GTK. If no columns are visible, changing the selection * will fail. The fix is to temporarily make a column visible. */ int columnCount = Math.max (1, this.columnCount); for (int i=0; i<columnCount; i++) { long /*int*/ column = OS.gtk_tree_view_get_column (handle, i); if (OS.gtk_tree_view_column_get_visible (column)) return false; } long /*int*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0); OS.gtk_tree_view_column_set_visible (firstColumn, true); return true; } /** * Shows the item. If the item is already showing in the receiver, * this method simply returns. Otherwise, the items are scrolled until * the item is visible. * * @param item the item to be shown * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the item is null</li> * <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#showSelection() */ public void showItem (TableItem item) { checkWidget (); if (item == null) error (SWT.ERROR_NULL_ARGUMENT); if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (item.parent != this) return; showItem (item.handle); } void showItem (long /*int*/ iter) { long /*int*/ path = OS.gtk_tree_model_get_path (modelHandle, iter); OS.gtk_tree_view_scroll_to_cell (handle, path, 0, false, 0, 0); OS.gtk_tree_path_free (path); } /** * Shows the selection. If the selection is already showing in the receiver, * this method simply returns. Otherwise, the items are scrolled until * the selection is visible. * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Table#showItem(TableItem) */ public void showSelection () { checkWidget(); TableItem [] selection = getSelection (); if (selection.length == 0) return; TableItem item = selection [0]; showItem (item.handle); } @Override void updateScrollBarValue (ScrollBar bar) { super.updateScrollBarValue (bar); /* * Bug in GTK. Scrolling changes the XWindow position * and makes the child widgets appear to scroll even * though when queried their position is unchanged. * The fix is to queue a resize event for each child to * force the position to be corrected. */ long /*int*/ parentHandle = parentingHandle (); long /*int*/ list = OS.gtk_container_get_children (parentHandle); if (list == 0) return; long /*int*/ temp = list; while (temp != 0) { long /*int*/ widget = OS.g_list_data (temp); if (widget != 0) OS.gtk_widget_queue_resize (widget); temp = OS.g_list_next (temp); } OS.g_list_free (list); } @Override long /*int*/ windowProc (long /*int*/ handle, long /*int*/ arg0, long /*int*/ user_data) { switch ((int)/*64*/user_data) { case EXPOSE_EVENT_INVERSE: { /* * Feature in GTK. When the GtkTreeView has no items it does not propagate * expose events. The fix is to fill the background in the inverse expose * event. */ if (itemCount == 0 && (state & OBSCURED) == 0) { if ((state & PARENT_BACKGROUND) != 0 || backgroundImage != null) { Control control = findBackgroundControl (); if (control != null) { GdkEventExpose gdkEvent = new GdkEventExpose (); OS.memmove (gdkEvent, arg0, GdkEventExpose.sizeof); long /*int*/ window = OS.gtk_tree_view_get_bin_window (handle); if (window == gdkEvent.window) { drawBackground (control, window, gdkEvent.region, gdkEvent.area_x, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height); } } } } break; } } return super.windowProc (handle, arg0, user_data); } }
[ "375833274@qq.com" ]
375833274@qq.com
11e0ebb0ffbec01ddd07d9ed7fdfb98ae9b4fb2b
b743fa1a7b41b918ab3513047ae2ca462270cb06
/Classy_Android/app/src/main/java/csci201/classy/Adapters/DepartmentAdapter.java
cdeffb8d9f9dda820f7ed4a6a4d8346ef5629d63
[]
no_license
tsinghal/Classy
3133b1b4621e4e8105ecac1dfedc28b4005da081
ed349e56ff7b65986214849d28cfb16f5bd4a4cc
refs/heads/master
2021-01-20T06:46:55.442638
2017-08-26T23:04:33
2017-08-26T23:04:33
101,517,066
0
0
null
null
null
null
UTF-8
Java
false
false
1,486
java
package csci201.classy.Adapters; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; import java.util.Map; import csci201.classy.R; /** * Created by edward on 11/16/16. */ public class DepartmentAdapter extends ArrayAdapter { Context context; int resource; Object[] objects; public DepartmentAdapter(Context context, int resource, Object[] objects) { super(context, resource, objects); this.context = context; this.resource = resource; this.objects = objects; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); convertView = inflater.inflate(resource, parent, false); } Map<String, Object> dataItem = (Map<String, Object>) objects[position]; //set all of convertview TextView departmentNameTextView = (TextView) convertView.findViewById(R.id.departmentNameTextView); departmentNameTextView.setText((String) dataItem.get("name")); TextView departmentCodeTextView = (TextView) convertView.findViewById(R.id.departmentCodeTextView); departmentCodeTextView.setText((String) dataItem.get("code")); return convertView; } }
[ "tsinghal@usc.edu" ]
tsinghal@usc.edu
1b67bcf19dc41dce3376fab9f5eefee16b1eacb3
67104e5f13432ce15212975b4d71fb169fbf2a05
/MuberRESTfulGrupo18/src/main/java/bd2/Muber/model/Driver.java
02dab4f03a25c41e88cbd8c6fa567a7fae6bd4f4
[]
no_license
ErwinGutbrod/MuberEtapa2
742119dae56470749df2b4418df7e675e32d2241
6e2cbcec486bfc6aa4155b6db0c2acc9e67fe766
refs/heads/master
2021-01-20T00:41:07.805406
2017-05-22T14:00:21
2017-05-22T14:00:21
89,171,652
0
0
null
null
null
null
UTF-8
Java
false
false
431
java
package bd2.Muber.model; import java.util.Calendar; public class Driver extends User{ //Attributes private Calendar licenseExpirationDate; //Constructor public Driver(){ super(); } //Getters & Setters public Calendar getLicenseExpirationDate() { return licenseExpirationDate; } public void setLicenseExpirationDate(Calendar licenseExpirationDate) { this.licenseExpirationDate = licenseExpirationDate; } }
[ "Erwin@DESKTOP-0D3IOUK" ]
Erwin@DESKTOP-0D3IOUK
6366dad17dcf192a7b523da78316506d749cd8df
12ddd902bc6a9ac00ecf03f7706ff827e925dbbe
/src/TemplateMethod/Multiliplty.java
59e2e44f6d8ce3b7129bc94529b445be06ab0e1f
[]
no_license
chengyue5923/javaMethod
09bfa177ff5a3b24506d00c1127996d6b7e9d6d0
bd4d107ca42fb57c23c02100e89dd49868261be2
refs/heads/master
2021-01-20T13:07:05.653569
2017-05-06T09:15:49
2017-05-06T09:15:49
90,451,350
1
0
null
null
null
null
UTF-8
Java
false
false
198
java
package TemplateMethod; public class Multiliplty extends AnstractCalculator { @Override public int calculate(int num1, int num2) { // TODO Auto-generated method stub return num1*num2; } }
[ "chengyue5923@163.com" ]
chengyue5923@163.com
e3810aaed3df28ff5a028ff3c69a662beeade219
e85305c47876735317032fe47812ca4c8775a403
/src/problems/JewelsAndStones0771.java
ffdc98d3a3c68adf4c709ff50853ea8b03e35773
[]
no_license
arenasoy/LeetCode
76840c32f0a574640c00ccbdb5d80024363e7b21
e4de91422cf1743acc90b21b30b8930c2279c1a5
refs/heads/master
2021-05-24T15:41:33.785481
2020-10-05T18:55:20
2020-10-05T18:55:20
253,636,908
0
0
null
null
null
null
UTF-8
Java
false
false
525
java
package problems; import java.util.*; public class JewelsAndStones0771 { //O(N) time, O(N) space public int numJewelsInStones(String J, String S) { int result = 0; Set<Character> set = new HashSet<Character>(); for (int i = 0; i < J.length(); i++) { set.add(J.charAt(i)); } for (int i = 0; i < S.length(); i++) { if (set.contains(S.charAt(i))) result++; } return result; } }
[ "caro.arenas2607@gmail.com" ]
caro.arenas2607@gmail.com
62c6c92957296ed592e594b337ff59afa80e336e
0c0b99d02617b62139171349a6f95d81730c6eef
/app/src/main/java/com/quintus/labs/reminder/ReminderContract.java
b8f1a3b34bff825ba63edbf48f1fdb5a6dd282b6
[]
no_license
rohitnotes/Reminder
68207ac6eed2aba31d99979d0d2ceb701750f735
51849bcaa3be385b121686a4e6be1b87e01ebeec
refs/heads/master
2021-09-14T21:01:09.129446
2018-05-19T15:17:09
2018-05-19T15:17:09
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,222
java
package com.quintus.labs.reminder; import android.content.ContentResolver; import android.net.Uri; import android.provider.BaseColumns; /** * Created by quintuslabs on 10/06/17. */ public final class ReminderContract { /** * The authority of the provider. */ public static final String AUTHORITY = "com.quintus.labs.reminder"; /** * The content URI for the top-level * authority. */ public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + AUTHORITY); public static final String PATH_ALL = "all"; public static final String PATH_ALL_ID = "all/#"; public static final String PATH_NOTE = "note"; public static final String PATH_NOTE_ID = "note/#"; public static final String PATH_ALERT = "alert"; public static final String PATH_ALERT_ID = "alert/#"; public static final String _ID = "_id"; public static final String TYPE = "type"; public static final String TITLE = "title"; public static final String CONTENT = "content"; public static final String TIME = "time"; public static final String FREQUENCY = "frequency"; public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY}; public static final class Notes implements BaseColumns { public static final String TABLE_NAME = "reminders"; public static final String _ID = "_id"; public static final String TYPE = "type"; public static final String TITLE = "title"; public static final String CONTENT = "content"; public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_NOTE).build(); // Custom MIME types public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_NOTE; public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_NOTE; public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT}; } public static final class Alerts implements BaseColumns { public static final String TABLE_NAME = "reminders"; public static final String _ID = "_id"; public static final String TYPE = "type"; public static final String TITLE = "title"; public static final String CONTENT = "content"; public static final String TIME = "time"; public static final String FREQUENCY = "frequency"; public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_ALERT).build(); // Custom MIME types public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_ALERT; public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_ALERT; public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY}; } public static final class All implements BaseColumns { public static final String TABLE_NAME = "reminders"; public static final String _ID = "_id"; public static final String TYPE = "type"; public static final String TITLE = "title"; public static final String CONTENT = "content"; public static final String TIME = "time"; public static final String FREQUENCY = "frequency"; public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_ALL).build(); // Custom MIME types public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_ALL; public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + AUTHORITY + "/" + PATH_ALL; public static final String[] PROJECTION_ALL = {_ID, TYPE, TITLE, CONTENT, TIME, FREQUENCY}; } }
[ "quintus.labs@gmail.com" ]
quintus.labs@gmail.com
5f6082bdedec0cd4a8cfe5f40ea9a70ab84b91cd
7e14a944b5e26a919d9bd286a4c7f62cf42a4ca7
/RM-EMPRESARIAL-ejb/src/main/java/com/rm/empresarial/servicio/ProvinciaServicio.java
c740fb498016701b3ac19edf72b480f05827ee2a
[]
no_license
bryan1090/RegistroPropiedad
7bcca20dbb1a67da97c85716b67d516916aee3fa
182406c840187a6cc31458f38522f717cc34e258
refs/heads/master
2022-07-07T08:06:20.251959
2020-01-02T03:02:34
2020-01-02T03:02:34
231,295,897
0
0
null
2022-06-30T20:22:05
2020-01-02T02:50:13
Java
UTF-8
Java
false
false
444
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.rm.empresarial.servicio; import com.rm.empresarial.puente.ProvinciaPuente; import javax.ejb.LocalBean; import javax.ejb.Stateless; /** * * @author Prueba */ @LocalBean @Stateless public class ProvinciaServicio extends ProvinciaPuente{ }
[ "42019366+bryan1090@users.noreply.github.com" ]
42019366+bryan1090@users.noreply.github.com
1cb45c95d84e0f048e0d9c03ce029b903d6ad955
bee3260be858709a32595c7df5fc64f934c00f8b
/src/main/java/com/schlenz/blackjack/Hand.java
3fcb68786c23fa0b5f28d4832f595d877db7e2ad
[ "Apache-2.0" ]
permissive
eschlenz/Blackjack-Testing-Playground
8beb9d1afb81ff79dc1742267b9858463d1db13f
52a3d03f99321e36afe43a512b98601e9d5175e5
refs/heads/master
2020-03-27T13:29:16.771896
2018-08-29T14:57:21
2018-08-29T14:57:21
146,612,449
0
0
null
null
null
null
UTF-8
Java
false
false
189
java
package com.schlenz.blackjack; public interface Hand { void takeDealtCard(Card card); int getHandValue(); boolean isBusted(); boolean isSoft(); String getHandInfo(); }
[ "eschlenz@ibotta.com" ]
eschlenz@ibotta.com
18e50b0d69d27f5df73a70221e61f34e3186f527
5245085c230929cdb91db049672f8f276646560c
/mula-base/src/main/java/org/mula/finance/core/io/RewireDBImporter.java
307180277fd8ff6285365f04fefdfd5cbef5a3e9
[]
no_license
katrinaannhadi/MULAFinanceApp
9e7371778d2fe2fbcc61e94cd6d3832409cd6115
3130dbd1dfc7438268621cf0320c0856e836e00e
refs/heads/master
2022-04-25T04:50:36.130679
2020-04-30T03:51:17
2020-04-30T03:51:17
258,404,445
1
0
null
null
null
null
UTF-8
Java
false
false
6,133
java
/* Mula */ package org.mula.finance.core.io; import androidx.annotation.*; import org.mula.finance.core.database.Cursor; import org.mula.finance.core.database.Database; import org.mula.finance.core.database.DatabaseOpener; import org.mula.finance.core.models.Frequency; import org.mula.finance.core.models.Habit; import org.mula.finance.core.models.HabitList; import org.mula.finance.core.models.ModelFactory; import org.mula.finance.core.models.Reminder; import org.mula.finance.core.models.Timestamp; import org.mula.finance.core.models.WeekdayList; import org.mula.finance.core.utils.DateUtils; import java.io.*; import java.util.*; import javax.inject.*; /** * Class that imports database files exported by Rewire. */ public class RewireDBImporter extends AbstractImporter { private ModelFactory modelFactory; @NonNull private final DatabaseOpener opener; @Inject public RewireDBImporter(@NonNull HabitList habits, @NonNull ModelFactory modelFactory, @NonNull DatabaseOpener opener) { super(habits); this.modelFactory = modelFactory; this.opener = opener; } @Override public boolean canHandle(@NonNull File file) throws IOException { if (!isSQLite3File(file)) return false; Database db = opener.open(file); Cursor c = db.query("select count(*) from SQLITE_MASTER " + "where name='CHECKINS' or name='UNIT'"); boolean result = (c.moveToNext() && c.getInt(0) == 2); c.close(); db.close(); return result; } @Override public void importHabitsFromFile(@NonNull File file) throws IOException { Database db = opener.open(file); db.beginTransaction(); createHabits(db); db.setTransactionSuccessful(); db.endTransaction(); db.close(); } private void createHabits(Database db) { Cursor c = null; try { c = db.query("select _id, name, description, schedule, " + "active_days, repeating_count, days, period " + "from habits"); if (!c.moveToNext()) return; do { int id = c.getInt(0); String name = c.getString(1); String description = c.getString(2); int schedule = c.getInt(3); String activeDays = c.getString(4); int repeatingCount = c.getInt(5); int days = c.getInt(6); int periodIndex = c.getInt(7); Habit habit = modelFactory.buildHabit(); habit.setName(name); habit.setDescription(description == null ? "" : description); int periods[] = { 7, 31, 365 }; int numerator, denominator; switch (schedule) { case 0: numerator = activeDays.split(",").length; denominator = 7; break; case 1: numerator = days; denominator = (periods[periodIndex]); break; case 2: numerator = 1; denominator = repeatingCount; break; default: throw new IllegalStateException(); } habit.setFrequency(new Frequency(numerator, denominator)); habitList.add(habit); createReminder(db, habit, id); createCheckmarks(db, habit, id); } while (c.moveToNext()); } finally { if (c != null) c.close(); } } private void createCheckmarks(@NonNull Database db, @NonNull Habit habit, int rewireHabitId) { Cursor c = null; try { String[] params = { Integer.toString(rewireHabitId) }; c = db.query( "select distinct date from checkins where habit_id=? and type=2", params); if (!c.moveToNext()) return; do { String date = c.getString(0); int year = Integer.parseInt(date.substring(0, 4)); int month = Integer.parseInt(date.substring(4, 6)); int day = Integer.parseInt(date.substring(6, 8)); GregorianCalendar cal = DateUtils.getStartOfTodayCalendar(); cal.set(year, month - 1, day); habit.getRepetitions().toggle(new Timestamp(cal)); } while (c.moveToNext()); } finally { if (c != null) c.close(); } } private void createReminder(Database db, Habit habit, int rewireHabitId) { String[] params = { Integer.toString(rewireHabitId) }; Cursor c = null; try { c = db.query( "select time, active_days from reminders where habit_id=? limit 1", params); if (!c.moveToNext()) return; int rewireReminder = Integer.parseInt(c.getString(0)); if (rewireReminder <= 0 || rewireReminder >= 1440) return; boolean reminderDays[] = new boolean[7]; String activeDays[] = c.getString(1).split(","); for (String d : activeDays) { int idx = (Integer.parseInt(d) + 1) % 7; reminderDays[idx] = true; } int hour = rewireReminder / 60; int minute = rewireReminder % 60; WeekdayList days = new WeekdayList(reminderDays); Reminder reminder = new Reminder(hour, minute, days); habit.setReminder(reminder); habitList.update(habit); } finally { if (c != null) c.close(); } } }
[ "katrinaann.abdulhadi@student.unsw.edu.au" ]
katrinaann.abdulhadi@student.unsw.edu.au
aeb743b02bcaa3f00792de0ae9b7c5b1f31cc426
eefd94a670861c01cff074b80daa32e3393e296f
/todolist1/src/main/java/com/example/todolist1/business/abstracts/UserService.java
09936a88d87e3bc7153396d5fb5723dd0464bdce
[]
no_license
kaankullac/todolist
05b86a75902d0e1d46bb299bc2cd2f746aecbf5b
6eaf3516e60bfe85a334485aa5a1173ff301cc76
refs/heads/master
2023-08-26T21:36:53.700350
2021-10-28T12:37:34
2021-10-28T12:37:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
374
java
package com.example.todolist1.business.abstracts; import java.util.List; import com.example.todolist1.core.utilities.result.Result; import com.example.todolist1.entities.concretes.User; public interface UserService { List<User> getAll(); Result Add(User user); Result Delete(User user); User GetUserByEmail(String email); boolean ExistUserByEmail(String email); }
[ "80275437+kaankullac@users.noreply.github.com" ]
80275437+kaankullac@users.noreply.github.com
048f4878cc2d2c9c2838dbed383030c8ed48d773
7ab2047c2dab9b9fd29901e71f5521a2b8293f3b
/src/main/java/ghidra/app/cmd/data/rtti/gcc/VtableModel.java
14541fc3b9954ab210609c61137afe3b901fea6a
[ "MIT" ]
permissive
ohyeah521/Ghidra-Cpp-Class-Analyzer-1
03bb6eddd63f2b2ea4128a4bb142f87ac583cb3e
49e9d43ff5673516c23e3787d0f8631db08807bc
refs/heads/master
2020-12-10T05:45:05.720555
2020-01-07T02:00:29
2020-01-07T02:00:29
233,516,647
1
0
MIT
2020-01-13T05:16:24
2020-01-13T05:16:23
null
UTF-8
Java
false
false
13,277
java
package ghidra.app.cmd.data.rtti.gcc; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import ghidra.program.model.data.Array; import ghidra.program.model.data.ArrayDataType; import ghidra.program.model.data.DataType; import ghidra.program.model.address.Address; import ghidra.program.model.listing.Function; import ghidra.program.model.listing.Program; import ghidra.program.model.data.DataTypeManager; import ghidra.program.model.data.InvalidDataTypeException; import ghidra.program.model.data.PointerDataType; import ghidra.program.model.mem.MemoryAccessException; import ghidra.program.model.mem.MemoryBufferImpl; import ghidra.util.Msg; import ghidra.app.cmd.data.rtti.ClassTypeInfo; import ghidra.app.cmd.data.rtti.Vtable; import ghidra.app.cmd.data.rtti.gcc.GnuUtils; import ghidra.app.cmd.data.rtti.gcc.factory.TypeInfoFactory; import static ghidra.app.util.datatype.microsoft.MSDataTypeUtils.getAbsoluteAddress; /** * Model for GNU Vtables */ public class VtableModel implements Vtable { public static final String SYMBOL_NAME = "vtable"; public static final String CONSTRUCTION_SYMBOL_NAME = "construction-"+SYMBOL_NAME; public static final String DESCRIPTION = "Vtable Model"; public static final String MANGLED_PREFIX = "_ZTV"; private Program program; private boolean isValid = true; private Address address; private static final int FUNCTION_TABLE_ORDINAL = 2; private static final int MAX_PREFIX_ELEMENTS = 3; private int arrayCount; private boolean construction; private Set<Function> functions = new HashSet<>(); private ClassTypeInfo type = null; private long[] offsets; private List<VtablePrefixModel> vtablePrefixes; public static final VtableModel NO_VTABLE = new VtableModel(); private VtableModel() { isValid = false; } public VtableModel(Program program, Address address, ClassTypeInfo type) { this(program, address, type, -1, false); } public VtableModel(Program program, Address address) { this(program, address, null, -1, false); } /** * Constructs a new VtableModel * * @param program program the vtable is in. * @param address starting address of the vtable or the first typeinfo pointer. * @param type the ClassTypeInfo this vtable belongs to. * @param arrayCount the maximum vtable table count, if known. * @param construction true if this should be a construction vtable. */ public VtableModel(Program program, Address address, ClassTypeInfo type, int arrayCount, boolean construction) { this.program = program; this.address = address; this.type = type; this.arrayCount = arrayCount; this.construction = construction; if (TypeInfoUtils.isTypeInfoPointer(program, address)) { if (this.type == null) { Address typeAddress = getAbsoluteAddress(program, address); this.type = (ClassTypeInfo) TypeInfoFactory.getTypeInfo(program, typeAddress); } } else if (this.type == null) { int length = VtableUtils.getNumPtrDiffs(program, address); DataType ptrdiff_t = GnuUtils.getPtrDiff_t(program.getDataTypeManager()); Address typePointerAddress = address.add(length * ptrdiff_t.getLength()); Address typeAddress = getAbsoluteAddress(program, typePointerAddress); this.type = (ClassTypeInfo) TypeInfoFactory.getTypeInfo(program, typeAddress); } try { setupVtablePrefixes(); this.isValid = !vtablePrefixes.isEmpty(); } catch (InvalidDataTypeException e) { this.isValid = false; } } @Override public ClassTypeInfo getTypeInfo() throws InvalidDataTypeException { validate(); if (type == null) { type = VtableUtils.getTypeInfo(program, address); } return type; } @Override public void validate() throws InvalidDataTypeException { if (!isValid) { if (address != null) { throw new InvalidDataTypeException( "Vtable at "+address.toString()+" is not valid."); } throw new InvalidDataTypeException( "Invalid Vtable."); } } @Override public int hashCode() { try { getTypeInfo(); if (type != null) { return type.hashCode(); } } catch (InvalidDataTypeException e) {} return super.hashCode(); } @Override public boolean equals(Object object) { if (!(object instanceof VtableModel)) { return false; } try { getTypeInfo(); ClassTypeInfo otherType = ((VtableModel) object).getTypeInfo(); if (type != null && otherType != null) { return type.equals(otherType); } } catch (InvalidDataTypeException e) {} return super.equals(object); } /** * Gets the corrected start address of the vtable. * * @return the correct start address or NO_ADDRESS if invalid. */ public Address getAddress() { return address; } @Override public Address[] getTableAddresses() throws InvalidDataTypeException { validate(); Address[] result = new Address[vtablePrefixes.size()]; for (int i = 0; i < result.length; i++) { try { result[i] = vtablePrefixes.get(i).getTableAddress(); } catch (IndexOutOfBoundsException e) { result = Arrays.copyOf(result, i); break; } } return result; } @Override public Function[][] getFunctionTables() throws InvalidDataTypeException { validate(); Address[] tableAddresses = getTableAddresses(); if (tableAddresses.length == 0) { return new Function[0][]; } Function[][] result = new Function[tableAddresses.length][]; for (int i = 0; i < tableAddresses.length; i++) { result[i] = VtableUtils.getFunctionTable(program, tableAddresses[i]); } return result; } @Override public boolean containsFunction(Function function) throws InvalidDataTypeException { if (functions.isEmpty()) { getFunctionTables(); } return functions.contains(function); } /** * @see ghidra.program.model.data.DataType#getLength() * @return */ public int getLength() { if (!isValid) { return 0; } int size = 0; for (VtablePrefixModel prefix : vtablePrefixes) { size += prefix.getPrefixSize(); } return size; } /** * Gets the ptrdiff_t value within the base offset array. * * @param index the index in the vtable_prefix array. * @param ordinal the offset ordinal. * @return the offset value. * @throws InvalidDataTypeException */ public long getOffset(int index, int ordinal) throws InvalidDataTypeException { validate(); if (ordinal >= getElementCount()) { return Long.MAX_VALUE; } return vtablePrefixes.get(index).getBaseOffset(ordinal); } /** * Gets the whole ptrdiff_t array. * * @return the whole ptrdiff_t array. * @throws InvalidDataTypeException */ public long[] getBaseOffsetArray() throws InvalidDataTypeException { validate(); if (offsets == null) { offsets = vtablePrefixes.get(0).getBaseOffsets(); } return offsets; } /** * Gets the number of vtable_prefix's in this vtable. * * @return the number of vtable_prefix's in this vtable. * @throws InvalidDataTypeException */ public int getElementCount() throws InvalidDataTypeException { validate(); return vtablePrefixes.size(); } private Address getNextPrefixAddress() { int size = 0; for (VtablePrefixModel prefix : vtablePrefixes) { size += prefix.getPrefixSize(); } return address.add(size); } public List<DataType> getDataTypes() { List<DataType> result = new ArrayList<>(vtablePrefixes.size() * MAX_PREFIX_ELEMENTS); for (VtablePrefixModel prefix : vtablePrefixes) { result.addAll(prefix.dataTypes); } return result; } private void setupVtablePrefixes() throws InvalidDataTypeException { vtablePrefixes = new ArrayList<>(); int count = construction ? 2 : type.getVirtualParents().size()+1; VtablePrefixModel prefix = new VtablePrefixModel(getNextPrefixAddress(), count); if (!prefix.isValid()) { return; } if (TypeInfoUtils.isTypeInfoPointer(program, address)) { address = prefix.prefixAddress; } if (arrayCount < 0) { while (prefix.isValid()) { vtablePrefixes.add(prefix); prefix = new VtablePrefixModel(getNextPrefixAddress()); } } else { vtablePrefixes.add(prefix); for (int i = 1; i < arrayCount; i++) { prefix = new VtablePrefixModel(getNextPrefixAddress()); if (!prefix.isValid()) { break; } vtablePrefixes.add(prefix); } } } public List<VtablePrefixModel> getVtablePrefixes() { return vtablePrefixes; } private class VtablePrefixModel { private Address prefixAddress; private List<DataType> dataTypes; private VtablePrefixModel(Address prefixAddress) { this(prefixAddress, -1); } private VtablePrefixModel(Address prefixAddress, int ptrDiffs) { this.prefixAddress = prefixAddress; int numPtrDiffs = ptrDiffs > 0 ? ptrDiffs : VtableUtils.getNumPtrDiffs(program, prefixAddress); dataTypes = new ArrayList<>(3); if (numPtrDiffs > 0) { DataTypeManager dtm = program.getDataTypeManager(); DataType ptrdiff_t = GnuUtils.getPtrDiff_t(dtm); int pointerSize = program.getDefaultPointerSize(); if (TypeInfoUtils.isTypeInfoPointer(program, prefixAddress)) { this.prefixAddress = prefixAddress.subtract(numPtrDiffs * ptrdiff_t.getLength()); } dataTypes.add(new ArrayDataType(ptrdiff_t, numPtrDiffs, ptrdiff_t.getLength(), dtm)); dataTypes.add(new PointerDataType(null, pointerSize, dtm)); Address tableAddress = this.prefixAddress.add(getPrefixSize()); int tableSize = VtableUtils.getFunctionTableLength(program, tableAddress); if (tableSize > 0) { ArrayDataType table = new ArrayDataType( PointerDataType.dataType, tableSize, pointerSize, dtm); dataTypes.add(table); } } } private boolean isValid() { if (dataTypes.size() > 1) { int offset = dataTypes.get(0).getLength(); Address pointee = getAbsoluteAddress( program, prefixAddress.add(offset)); if (pointee != null) { return pointee.equals(type.getAddress()); } } return false; } private int getPrefixSize() { int size = 0; for (DataType dt : dataTypes) { size += dt.getLength(); } return size; } private Address getTableAddress() { int size = 0; for (int i = 0; i < FUNCTION_TABLE_ORDINAL; i++) { size += dataTypes.get(i).getLength(); } return prefixAddress.add(size); } private long[] getBaseOffsets() { try { Array array = (Array) dataTypes.get(0); MemoryBufferImpl prefixBuf = new MemoryBufferImpl( program.getMemory(), prefixAddress); int length = array.getElementLength(); long[] result = new long[array.getNumElements()]; for (int i = 0; i < result.length; i++) { result[i] = prefixBuf.getBigInteger(i*length, length, true).longValue(); } return result; } catch (MemoryAccessException e) { Msg.error(this, "Failed to retreive base offsets at "+prefixAddress, e); return new long[0]; } } private long getBaseOffset(int ordinal) { Array array = (Array) dataTypes.get(0); if (ordinal >= array.getElementLength()) { return -1; } return getBaseOffsets()[ordinal]; } } }
[ "ajs222@njit.edu" ]
ajs222@njit.edu
bfebc2c5e0e0a9992b79a183244502740fdba688
fddd2931431d326d151e7a2b5374124539398b5c
/src/battlecard/Nidhogg.java
3e453dbc2b7ca5c9d3f249edd26934d17ea7ca23
[]
no_license
strtsoia/AgeOfMyth
f7f83af0b20f7a99f6ed13ecf32981da5fc89e7f
4df92700a4ec37c9d0180bcf653856c7923482e5
refs/heads/master
2021-01-16T19:04:50.212846
2011-11-14T23:25:33
2011-11-14T23:25:33
2,656,218
1
0
null
null
null
null
UTF-8
Java
false
false
987
java
package battlecard; import java.util.Hashtable; import global.GlobalDef; public final class Nidhogg extends BattleCard{ private static Nidhogg nidhogg; private Nidhogg() { cost.put(GlobalDef.Resources.FAVOR, 1); cost.put(GlobalDef.Resources.GOLD, 4); cost.put(GlobalDef.Resources.FOOD, 0); cost.put(GlobalDef.Resources.WOOD, 0); } private final int rolls = 7; private int bonus = 0; private Hashtable<GlobalDef.Resources, Integer> cost = new Hashtable<GlobalDef.Resources, Integer>(); public int getRolls() { return rolls + bonus; } public Hashtable<GlobalDef.Resources, Integer> getCost() { return cost; } public static Nidhogg getInstance() { if(nidhogg == null){ nidhogg = new Nidhogg(); return nidhogg; } return nidhogg; } public void CheckBonus(BattleCard opponent) { if (GiantKiller.contains(opponent)) bonus = 4; else bonus = 0; } }
[ "strtsoia@gmail.com" ]
strtsoia@gmail.com
465de71ae342001e1340c8a6f48e36149e799d38
fc3940a77a19fc3790264a2a06670655306274b9
/app/src/androidTest/java/com/example/istbr/dagitikdersproje/ExampleInstrumentedTest.java
b9417437c6a6892dcdd4237e63a228a9f84fab1c
[]
no_license
BurakSSonmez/Number-Guessing-Game
5e330ec5c43adea286b13c0529a4180c23e4df4f
8d71c8c7d33feeafa25635c0d4dba2e3aec9737b
refs/heads/master
2021-02-18T10:07:47.059022
2021-01-03T15:29:18
2021-01-03T15:29:18
245,185,120
0
0
null
null
null
null
UTF-8
Java
false
false
752
java
package com.example.istbr.dagitikdersproje; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.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.example.istbr.dagitikdersproje", appContext.getPackageName()); } }
[ "buraksezaisonmez@gmail.com" ]
buraksezaisonmez@gmail.com
76a17c13c0e53e064f6cca15708d73309cb21eef
3aa02b7ca7fea1352653c579451fb3b59438bdad
/src/main/java/me/tassu/queue/queue/QueueManager.java
0e5b6b4801a9bb95e70549072f93ed5c738fdb4d
[ "MIT" ]
permissive
supertassu/Queue
44ba749a87b4fe44477c6f70e0e482005bafb04e
c17e46526e743a97f15588b2fd084a28af277567
refs/heads/master
2021-08-07T08:32:01.982009
2018-11-03T11:49:49
2018-11-03T11:49:49
129,263,347
2
1
null
null
null
null
UTF-8
Java
false
false
5,244
java
/* * MIT License * * Copyright (c) 2018 Tassu * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package me.tassu.queue.queue; import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.Singleton; import lombok.val; import me.tassu.queue.QueuePlugin; import me.tassu.queue.file.ConfigFile; import me.tassu.queue.file.FileManager; import me.tassu.queue.message.Message; import me.tassu.queue.message.MessageManager; import me.tassu.queue.queue.impl.SimpleQueue; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.config.Configuration; import java.util.Optional; import java.util.Set; @Singleton public class QueueManager { private QueuePlugin plugin; @Inject public QueueManager(QueuePlugin plugin, FileManager fileManager, MessageManager messageManager) { this.plugin = plugin; queueConfig = fileManager.getQueueFile(); queueResettingMsg = messageManager.getMessage("QUEUE_RESET"); } private ConfigFile queueConfig; private Message queueResettingMsg; private Set<IQueue> queueSet = Sets.newHashSet(); /** * Reloads and clears all queues. */ public void refreshQueues() { queueSet.forEach(queue -> queue.getPlayers().forEach(player -> queueResettingMsg .addPlaceholder("QUEUE_NAME", queue.getName()) .send(player))); queueSet.clear(); queueConfig.getKeys().forEach(key -> queueSet.add(loadQueueFromConfig(key)) ); } /** * loads a queue from configuration * * @param id queue id * @return the queue */ private IQueue loadQueueFromConfig(String id) { val config = queueConfig.getSection(id); if (config == null) return null; if (config.getString("type").equalsIgnoreCase("SimpleQueue")) { SimpleQueue.Builder queue = SimpleQueue.builder() .id(id) .server(ProxyServer.getInstance().getServerInfo(config.getString("server"))) .name(config.getString("display")) .messager(QueueMessagingProperties.fromConfig(config)); if (config.getKeys().contains("sendDelay")) { queue.sendDelay(config.getInt("sendDelay")); } if (config.getKeys().contains("requiredProtocol")) { val protocol = config.getSection("requiredProtocol"); if (protocol.getKeys().contains("exact")) { queue.requiredExactProtocol(protocol.getInt("exact")); } else { if (protocol.getKeys().contains("min")) { queue.requiredMinProtocol(protocol.getInt("min")); } if (protocol.getKeys().contains("max")) { queue.requiredMaxProtocol(protocol.getInt("max")); } } } return queue.build(); } else { plugin.getLogger().severe("unknown queue type " + config.getString("type")); } return null; } /** * refreshes & clears a queue * * @param queue specific queue */ public void refreshQueue(String queue) { IQueue tempQueue = queueSet.stream().filter(it -> it.getId().equalsIgnoreCase(queue)).findFirst().orElseThrow(() -> new IllegalArgumentException("queue not found")); queueResettingMsg.send(tempQueue.getPlayers().toArray(new ProxiedPlayer[0])); queueSet.removeIf(it -> it.getId().equalsIgnoreCase(queue)); queueSet.add(loadQueueFromConfig(queue)); } /** * @return All queues on the system. */ public Set<IQueue> getAllQueues() { return Sets.newHashSet(queueSet); } public Optional<IQueue> getQueueById(String name) { return getAllQueues().stream().filter(it -> it.getId().equalsIgnoreCase(name)).findFirst(); } public Optional<IQueue> getQueueForPlayer(ProxiedPlayer player) { return getAllQueues().stream().filter(it -> it.isQueued(player)).findFirst(); } }
[ "git@tassu.me" ]
git@tassu.me
fb0fa7f189c1426bc32a2eb5820f695542f63f77
21d5650428c145e96c2db75e81fb26ad8eb2a662
/com/syntax/class04/HW1.java
ab913e7e0046eb6db7f7df47d827f5c9b263a874
[]
no_license
OlgaLiV/Selenium
f904f33cba4e21c532b8ffad8a0e6cedb0dddf0a
c90434fc55d80ac3c5fe728de70990d927f53f9e
refs/heads/master
2023-01-24T19:43:16.162926
2020-11-25T23:30:17
2020-11-25T23:30:17
283,334,265
0
0
null
null
null
null
UTF-8
Java
false
false
2,040
java
package com.syntax.class04; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class HW1 { public static String url = "http://166.62.36.207/syntaxpractice/basic-radiobutton-demo.html"; public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "drivers/chromedriver"); WebDriver driver = new ChromeDriver(); driver.get(url); List<WebElement> optionRadioButtons = driver.findElements(By.xpath("//input[@name = 'optradio']")); for (WebElement sexRadioButton : optionRadioButtons) { if (sexRadioButton.isEnabled()) { String radioButton = sexRadioButton.getAttribute("value"); if (radioButton.equals("Female")) { sexRadioButton.click(); break; } } } List<WebElement> optionRadioButtons2 = driver.findElements(By.xpath("//input[@name = 'gender']")); for (WebElement sexRadioButton2 : optionRadioButtons2) { if(sexRadioButton2.isEnabled()) {} String radioButton2 = sexRadioButton2.getAttribute("value"); if(radioButton2.equals("Female")) { sexRadioButton2.click(); break; } } List<WebElement> ageButtons = driver.findElements(By.xpath("//input[@name = 'ageGroup']")); for (WebElement ageCheck : ageButtons) { String ageRadio = ageCheck.getAttribute("value"); if(ageRadio.equals("15 - 50")) { ageCheck.click(); Thread.sleep(1000); break; } } driver.findElement(By.xpath("//button[text() = 'Get values']")).click(); WebElement buttonGetValues = driver.findElement(By.cssSelector("p[class = 'groupradiobutton']")); if(buttonGetValues.isDisplayed()) { String resultText = buttonGetValues.getText(); if(resultText.contains("Sex : Female") && resultText.contains("15 - 50")) { System.out.println("Input is correct"); }else { System.out.println("Incorrect input"); } } Thread.sleep(2000); driver.quit(); } }
[ "9755609@gmail.com" ]
9755609@gmail.com
343b8c3f0e4547db587d59bfada84336dde0d275
7ab6f4e52dd665714e244c6f34e08f1fd4ef3469
/ciyuanplus2/app/src/main/java/com/ciyuanplus/mobile/activity/chat/UserMessageListActivity.java
62d8a1dc50735245aac37f4c50609fe1aa9021ec
[]
no_license
heqianqian0516/ciyuan
2e9f8f84a1595317e8911cfece2e3f3919ebddeb
44410726a8f7e4467f06fab1ae709451ef293b3b
refs/heads/master
2020-07-11T04:11:24.935457
2019-11-06T03:37:45
2019-11-06T03:37:45
204,436,467
0
0
null
null
null
null
UTF-8
Java
false
false
13,706
java
package com.ciyuanplus.mobile.activity.chat; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.ciyuanplus.mobile.MyBaseActivity; import com.ciyuanplus.mobile.R; import com.ciyuanplus.mobile.adapter.UserNoticesAdapter; import com.ciyuanplus.mobile.image_select.utils.StatusBarCompat; import com.ciyuanplus.mobile.inter.MyOnClickListener; import com.ciyuanplus.mobile.manager.SharedPreferencesManager; import com.ciyuanplus.mobile.manager.UserInfoData; import com.ciyuanplus.mobile.module.comment_detail.CommentDetailActivity; import com.ciyuanplus.mobile.module.forum_detail.daily_detail.DailyDetailActivity; import com.ciyuanplus.mobile.module.forum_detail.food_detail.FoodDetailActivity; import com.ciyuanplus.mobile.module.forum_detail.note_detail.NoteDetailActivity; import com.ciyuanplus.mobile.module.forum_detail.stuff_detail.StuffDetailActivity; import com.ciyuanplus.mobile.module.forum_detail.twitter_detail.TwitterDetailActivity; import com.ciyuanplus.mobile.module.others.new_others.OthersActivity; import com.ciyuanplus.mobile.net.ApiContant; import com.ciyuanplus.mobile.net.LiteHttpManager; import com.ciyuanplus.mobile.net.MyHttpListener; import com.ciyuanplus.mobile.net.ResponseData; import com.ciyuanplus.mobile.net.bean.FreshNewItem; import com.ciyuanplus.mobile.net.bean.NoticeItem; import com.ciyuanplus.mobile.net.parameter.GetNoticeListApiParameter; import com.ciyuanplus.mobile.net.response.NoticeListResponse; import com.ciyuanplus.mobile.pulltorefresh.XListView; import com.ciyuanplus.mobile.statistics.StatisticsConstant; import com.ciyuanplus.mobile.statistics.StatisticsManager; import com.ciyuanplus.mobile.utils.Constants; import com.ciyuanplus.mobile.utils.Utils; import com.ciyuanplus.mobile.widget.CommonToast; import com.ciyuanplus.mobile.widget.TitleBarView; import com.litesuits.http.exception.HttpException; import com.litesuits.http.request.StringRequest; import com.litesuits.http.request.param.HttpMethods; import com.litesuits.http.response.Response; import com.scwang.smartrefresh.layout.SmartRefreshLayout; import com.scwang.smartrefresh.layout.api.RefreshLayout; import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener; import com.scwang.smartrefresh.layout.listener.OnRefreshListener; import java.util.ArrayList; import java.util.Arrays; import androidx.annotation.Nullable; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.Unbinder; /** * Created by Alen on 2017/6/22. * <p> * 新粉丝列表页面 评论和赞 收藏 */ public class UserMessageListActivity extends MyBaseActivity implements OnRefreshListener, OnLoadMoreListener { @BindView(R.id.m_user_message_list) XListView mUserMessageList; @BindView(R.id.m_user_message_null_lp) LinearLayout mUserMessageNullLp; @BindView(R.id.m_user_message_list_common_title) TitleBarView m_js_common_title; @BindView(R.id.smartRefreshLayout) SmartRefreshLayout mRefreshLayout; @BindView(R.id.tv_notice) TextView noticeText; private String mType; private UserNoticesAdapter mAdapter; private final ArrayList<NoticeItem> mlist = new ArrayList<>(); private int mPage = 0; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_user_message_list); StatusBarCompat.compat(this, getResources().getColor(R.color.title)); mType = getIntent().getStringExtra(Constants.INTENT_ACTIVITY_TYPE); if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) { StatisticsManager.onEventInfo(StatisticsConstant.MODULE_COMMENTS, StatisticsConstant.OP_COMMENTS_PAGE_LOAD); } else { StatisticsManager.onEventInfo(StatisticsConstant.MODULE_FANS, StatisticsConstant.OP_FANS_PAGE_LOAD); } this.initView(); this.requestList(); } private void requestList() { StringRequest postRequest = new StringRequest(ApiContant.URL_HEAD + ApiContant.REQUEST_USER_NOTICE_LIST_URL); postRequest.setMethod(HttpMethods.Post); int PAGE_SIZE = 20; postRequest.setHttpBody(new GetNoticeListApiParameter(mPage + "", PAGE_SIZE + "", mType).getRequestBody()); String sessionKey = SharedPreferencesManager.getString( Constants.SHARED_PREFERENCES_SET, Constants.SHARED_PREFERENCES_LOGIN_USER_SESSION_KEY, ""); if (!Utils.isStringEmpty(sessionKey)) postRequest.addHeader("authToken", sessionKey); postRequest.setHttpListener(new MyHttpListener<String>(this) { @Override public void onSuccess(String s, Response<String> response) { super.onSuccess(s, response); finishRefreshAndLoadMore(); NoticeListResponse response1 = new NoticeListResponse(s); if (Utils.isStringEquals(response1.mCode, ResponseData.CODE_OK) && response1.noticeListInfo.list != null) { if (response1.noticeListInfo.list.length > 0) { if (mPage == 0) mlist.clear(); mlist.addAll(Arrays.asList(response1.noticeListInfo.list)); mAdapter.notifyDataSetChanged(); mPage++; updateView(); } } else { CommonToast.getInstance(response1.mMsg, Toast.LENGTH_SHORT).show(); } } @Override public void onFailure(HttpException e, Response<String> response) { super.onFailure(e, response); // mUserMessageList.stopRefresh(); // mUserMessageList.stopLoadMore(); finishRefreshAndLoadMore(); } }); LiteHttpManager.getInstance().executeAsync(postRequest); } private void initView() { Unbinder unbinder = ButterKnife.bind(this); m_js_common_title.setOnBackListener(new MyOnClickListener() { @Override public void performRealClick(View v) { onBackPressed(); } }); m_js_common_title.setTitle(Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS) ? "评论和赞" : "新粉丝"); noticeText.setText(Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS) ? "暂无消息" : "暂无新粉丝"); mAdapter = new UserNoticesAdapter(this, mlist); this.mUserMessageList.setAdapter(mAdapter); mUserMessageList.setPullLoadEnable(false); mUserMessageList.setPullRefreshEnable(false); // mUserMessageList.setXListViewListener(this); mRefreshLayout.setOnRefreshListener(this); mRefreshLayout.setOnLoadMoreListener(this); mUserMessageList.setOnItemClickListener((parent, view, position, id) -> { if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) { StatisticsManager.onEventInfo(StatisticsConstant.MODULE_COMMENTS, StatisticsConstant.OP_COMMENTS_LIST_ITEM_CLICK); } else { StatisticsManager.onEventInfo(StatisticsConstant.MODULE_FANS, StatisticsConstant.OP_FANS_LIST_ITEM_CLICK); } if (id == -1) { return; } int index = (int) id; Log.e("UserMessageListActivity", "position = " + position); Log.e("UserMessageListActivity", "id = " + id); NoticeItem item = mAdapter.getItem(index); Log.e("UserMessageListActivity", "item = " + item.toString()); if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_FOLLOW)) { // 如果是被关注了 // 如果是匿名 或者 是自己发布的帖子,不允许进入他人页面 if (Utils.isStringEquals(item.fromUserUuid, UserInfoData.getInstance().getUserInfoItem().uuid)) return; Intent intent = new Intent(UserMessageListActivity.this, OthersActivity.class); intent.putExtra(Constants.INTENT_USER_ID, item.fromUserUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (Utils.isStringEquals(mType, GetNoticeListApiParameter.TYPE_NEWS)) { // 如果是评论和赞 if (item.noticeType == 1) { // 评论 Intent intent = new Intent(UserMessageListActivity.this, CommentDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_COMMENT_ID_ITEM, item.currentBizUuid); intent.putExtra(Constants.INTENT_ACTIVITY_TYPE, "UserMessageListActivity"); intent.putExtra(Constants.INTENT_RENDER_TYPE, item.renderType); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (item.noticeType == 2 || item.noticeType == 9) {// 赞 if (item.bizType == FreshNewItem.FRESH_ITEM_STUFF) {//宝贝 Intent intent = new Intent(UserMessageListActivity.this, StuffDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (item.bizType == FreshNewItem.FRESH_ITEM_DAILY) { Intent intent = new Intent(UserMessageListActivity.this, DailyDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (item.bizType == FreshNewItem.FRESH_ITEM_POST || item.bizType == FreshNewItem.FRESH_ITEM_ANSWER) { // 长文和说说 Intent intent = new Intent(UserMessageListActivity.this, TwitterDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (item.bizType == FreshNewItem.FRESH_ITEM_NEWS || item.bizType == FreshNewItem.FRESH_ITEM_NOTE || item.bizType == FreshNewItem.FRESH_ITEM_NEWS_COLLECTION) { Intent intent = new Intent(UserMessageListActivity.this, NoteDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } else if (item.bizType == FreshNewItem.FRESH_ITEM_FOOD || item.bizType == FreshNewItem.FRESH_ITEM_LIVE || item.bizType == FreshNewItem.FRESH_ITEM_COMMENT) { Intent intent = new Intent(UserMessageListActivity.this, FoodDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); UserMessageListActivity.this.startActivity(intent); } } else if (item.noticeType == 5) {// 回复 Intent intent = new Intent(UserMessageListActivity.this, CommentDetailActivity.class); intent.putExtra(Constants.INTENT_NEWS_ID_ITEM, item.bizUuid); intent.putExtra(Constants.INTENT_COMMENT_ID_ITEM, item.currentBizUuid); intent.putExtra(Constants.INTENT_ACTIVITY_TYPE, "UserMessageListActivity"); intent.putExtra(Constants.INTENT_RENDER_TYPE, item.renderType); intent.putExtra(Constants.INTENT_BIZE_TYPE, item.bizType); Log.e("UserMessageListActivity", "INTENT_NEWS_ID_ITEM = " + item.bizUuid); Log.e("UserMessageListActivity", "INTENT_COMMENT_ID_ITEM = " + item.currentBizUuid); Log.e("UserMessageListActivity", "NTENT_RENDER_TYPE = " + item.renderType); Log.e("UserMessageListActivity", "INTENT_BIZE_TYPE = " + item.bizType); UserMessageListActivity.this.startActivity(intent); } } }); } private void updateView() { if (mlist.size() > 0) { mUserMessageNullLp.setVisibility(View.GONE); this.mUserMessageList.setVisibility(View.VISIBLE); } else { mUserMessageNullLp.setVisibility(View.VISIBLE); this.mUserMessageList.setVisibility(View.GONE); } } @Override public void onRefresh(RefreshLayout refreshlayout) { mPage = 0; requestList(); } @Override public void onLoadMore(RefreshLayout refreshlayout) { requestList(); } private void finishRefreshAndLoadMore() { mRefreshLayout.finishRefresh(); mRefreshLayout.finishLoadMore(); } }
[ "xixi0516@163.com" ]
xixi0516@163.com
91baaaeb348ac24c086eb265ea292aa3986d64f4
1d9957b6ebaa74fe311bd97b6131f502db2f25f2
/data-manager-web/src/main/java/com/magotzis/dm/model/DataHistory.java
9b13d0a9c97aa99d2111c3e974154715e93b9884
[]
no_license
Magotzis/data-manager-server
74579fabf88857d44c00835813cc561842a22dc7
a2bb25b884ce1a2ad9f84284ab4acf51cdcb0da5
refs/heads/master
2021-05-03T07:40:05.170728
2018-05-13T12:21:30
2018-05-13T12:21:30
120,553,699
1
0
null
null
null
null
UTF-8
Java
false
false
1,941
java
package com.magotzis.dm.model; import java.util.Date; /** * @author dengyq on 10:33 2018/4/10 */ public class DataHistory { private int id; private int userId; private String applyContent; private int state; private String errorMsg; private String content; private Date updateTime; private int type; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getApplyContent() { return applyContent; } public void setApplyContent(String applyContent) { this.applyContent = applyContent; } public int getState() { return state; } public void setState(int state) { this.state = state; } public String getErrorMsg() { return errorMsg; } public void setErrorMsg(String errorMsg) { this.errorMsg = errorMsg; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public int getType() { return type; } public void setType(int type) { this.type = type; } @Override public String toString() { return "DataHistory{" + "id=" + id + ", userId=" + userId + ", applyContent='" + applyContent + '\'' + ", state=" + state + ", errorMsg='" + errorMsg + '\'' + ", content='" + content + '\'' + ", updateTime=" + updateTime + ", type=" + type + '}'; } }
[ "magotzis@foxmail.com" ]
magotzis@foxmail.com
98263e79da97a64736d0272d205fc1be16970db1
b732c150b6a2376d0390f993141dfcb60593e43f
/Assignment 1 (Banking System)/Assignment1/src/main/java/connection/ConnectionDB.java
e91a7aebb9dfa4ab27367241152492e5d1376b47
[]
no_license
CodreaAncuta/Software-Design-Assignments
063cd88574686f9fc43ed724d444b3ee4b9bbfb7
49a98a78d7df3085b0010e51aa26c4837178a499
refs/heads/master
2021-10-27T15:18:30.979213
2019-04-17T21:20:20
2019-04-17T21:20:20
110,878,965
0
0
null
null
null
null
UTF-8
Java
false
false
2,058
java
package connection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; public class ConnectionDB { private static final Logger LOGGER = Logger.getLogger(ConnectionDB.class.getName()); private static final String DRIVER = "com.mysql.cj.jdbc.Driver"; private static final String DBURL = "jdbc:mysql://127.0.0.1:3306/bank?useSSL=false"; private static final String USER = "root"; private static final String PASS = "root"; private static ConnectionDB singleInstance = new ConnectionDB(); private ConnectionDB() { try { Class.forName(DRIVER); } catch (ClassNotFoundException e) { e.printStackTrace(); } } private Connection createConnection() { Connection connection = null; try { connection = DriverManager.getConnection(DBURL, USER, PASS); } catch (SQLException e) { LOGGER.log(Level.WARNING, "An error occured while trying to connect to the database"); e.printStackTrace(); } return connection; } public static Connection getConnection() { return singleInstance.createConnection(); } public static void close(Connection connection) { if (connection != null) { try { connection.close(); } catch (SQLException e) { LOGGER.log(Level.WARNING, "An error occured while trying to close the connection"); } } } public static void close(Statement statement) { if (statement != null) { try { statement.close(); } catch (SQLException e) { LOGGER.log(Level.WARNING, "An error occured while trying to close the statement"); } } } public static void close(ResultSet resultSet) { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { LOGGER.log(Level.WARNING, "An error occured while trying to close the ResultSet"); } } } /*public static void main(String[] args) { Connection dbConnection = ConnectionDB.getConnection(); System.out.println(dbConnection); }*/ }
[ "33701210+CodreaAncuta@users.noreply.github.com" ]
33701210+CodreaAncuta@users.noreply.github.com
a71d05bd745ee0e9cc6a260f03c5002611ce8423
5d45404ffb115717717482f04177f268d29062a4
/src/br/com/tg/repositorio/RepositorioStatusPessoa.java
ba0ce40882e58bdc36aaf96dbb8d57adb77c2a1f
[]
no_license
tgondim/auxPlot
67afbfef8b4a5a7b61ad193de94ab60d7567999b
b657ca43905b14bbfb83f9757e4956bfef15bd5d
refs/heads/master
2020-06-03T08:45:28.785806
2010-09-02T15:54:51
2010-09-02T15:54:51
null
0
0
null
null
null
null
UTF-8
Java
false
false
418
java
package br.com.tg.repositorio; import java.util.List; import br.com.tg.entidades.StatusPessoa; public interface RepositorioStatusPessoa { public void inserir(StatusPessoa statusPessoa); public void atualizar(StatusPessoa statusPessoa); public StatusPessoa getStatusPessoa(Integer idStatusPessoa); public List<StatusPessoa> listar(); public void remover(StatusPessoa statusPessoa); }
[ "gondim@gondim-PC" ]
gondim@gondim-PC
0f7ff83d0db82db7d85fcba2e318d04f673c826c
15129fbd583734e1133d642950e1712303d06669
/satellite-api/src/main/java/com/baidu/deimos/satellite/api/DeimosSatelliteAPI.java
9f2953344386250489bc34cecd4618d674427db3
[]
no_license
ahmatjan/SedaFramework
98241b1dadca7b67f11a07bc0a5f9b4724269d26
5074fdaa41d1be1af0f9f9f40dd95a85490a6fe2
refs/heads/master
2020-12-31T03:03:44.387182
2014-09-24T03:47:20
2014-09-24T03:47:20
null
0
0
null
null
null
null
GB18030
Java
false
false
7,739
java
package com.baidu.deimos.satellite.api; import java.util.HashMap; import java.util.Map; import org.springframework.amqp.rabbit.core.ChannelCallback; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import com.baidu.deimos.satellite.api.bo.DeimosSatelliteRequest; import com.baidu.deimos.satellite.api.constant.Infotype; import com.baidu.deimos.satellite.api.constant.SatApiConstant; import com.rabbitmq.client.Channel; /** * 提供给使用方的API,用以辅助进行消息推送。 * * Created on Jan 15, 2014 2:41:25 PM * @author chenchao03 * @version 1.0 * @since 1.0 */ public class DeimosSatelliteAPI { @Autowired private RabbitTemplate amqpTemplate; boolean keepAlive = false; /** * 消息推送函数。仅需消息主体内容即可 * * @param content * 消息内容 * @author chenchao03 * @date Nov 29, 2013 */ public void pub(Object content) { pub(null, null, null, null, content, null, null, null); } /** * 消息推送函数。仅需消息内容以及消息类型 * * @param content * 消息内容主体 * @param infotype * 消息类型 * @author chenchao03 * @date Dec 25, 2013 */ public void pub(Object content, Infotype infotype) { pub(null, null, null, null, content, null, infotype, null); } /** * 消息推送函数。推送报警使用 * * @param content * 消息内容 * @param infotype * 消息类型 * @author chenchao03 * @date Dec 25, 2013 */ public void pubAlarm(Object content, Infotype infotype) { pub(null, null, "collect.alarm.*", null, content, null, infotype, null); } /** * 带错误异常的消息推送 * * @param content * 消息内容 * @param t * 异常信息 * @author chenchao03 * @date Nov 29, 2013 */ public void pub(Object content, Throwable t) { pub(null, null, null, null, content, t, null, null); } /** * 带上pubkey * * @param pubKey * 发布消息的key * @param content * 消息内容 * @param t * 异常信息 * @author chenchao03 * @date Nov 29, 2013 */ public void pub(String pubKey, Object content, Throwable t) { pub(null, null, pubKey, null, content, t, null, null); } /** * 带上exchange, 设置是否需要长连接 * * @param exchangeName * 交换机名字 * @param pubKey * 推送的key * @param content * 消息内容 * @param t * 异常信息 * @author chenchao03 * @date Nov 30, 2013 */ public void pub(String exchangeName, String pubKey, Object content, Throwable t) { pub(null, exchangeName, pubKey, null, content, t, null, null); } /** * 带上exchange,不带异常,带上keepAlive和附加信息 * * @param exchangeName * 交换机名字 * @param pubKey * 推送消息的key * @param content * 消息内容 * @param keepAlive * 是否保持长连接 * @param appendMsg * 附加信息 * @author chenchao03 * @date Nov 29, 2013 */ public void pub(String exchangeName, String pubKey, Object content, boolean keepAlive, Map<String, Object> appendMsg) { this.keepAlive = keepAlive; pub(null, exchangeName, pubKey, null, content, null, null, appendMsg); } /** * 通用发布消息函数 * * @param timeStamp * 时间戳。默认为当前时间 * @param exchangeName * 发布到的交换机。默认为deimos-common * @param pubKey * 发布的内容key。默认为collect.log,即收集log。因为其最常用 * @param client * 客户端,默认为FC-AO * @param content * 消息内容主体 * @param e * 异常信息。由于需要printstack,所以只能把整个对象传递过去。 * @param appendMsg * 填入附加信息 * @param infoType * 消息类型 * @author chenchao03 * @date Nov 29, 2013 */ public void pub(Long timeStamp, String exchangeName, String pubKey, String client, Object content, Throwable e, Infotype infoType, Map<String, Object> appendMsg) { if (content == null) { return; } DeimosSatelliteRequest request = new DeimosSatelliteRequest(); if (client != null && !client.trim().equals("")) { request.setClient(client); } if (exchangeName != null && !exchangeName.trim().equals("")) { request.setDestination(exchangeName); } if (pubKey != null && !pubKey.trim().equals("")) { request.setPubKey(pubKey); } request.setTimestamp(timeStamp == null ? System.currentTimeMillis() : timeStamp); Map<String, Object> data = new HashMap<String, Object>(); data.put(SatApiConstant.EXCEPTION, e); if (appendMsg != null && !appendMsg.isEmpty()) { data.putAll(appendMsg); } request.setData(data); request.setRealData(content); request.setInfoType(infoType != null ? infoType : Infotype.INFOTYPE_LOG_INFO); amqpTemplate.convertAndSend(request.getDestination(), request.getPubKey(), request); // 是否保持长连接,默认不保持长连接,如果需要则调用close函数 if (!keepAlive) { this.close(); } } /** * 给logtype打上info * * @param content * 消息内容 * @author chenchao03 * @date Nov 29, 2013 */ public void infoPub(String content) { pub(null, null, "collect.log.info", null, content, null, Infotype.INFOTYPE_LOG_INFO, null); } /** * 给logtype打上warn * * @param content * 消息内容 * @author chenchao03 * @date Nov 29, 2013 */ public void warnPub(String content) { pub(null, null, "collect.log.warn", null, content, null, Infotype.INFOTYPE_LOG_WARN, null); } /** * 给logtype打上debug * * @param content * 消息内容 * @author chenchao03 * @date Nov 29, 2013 */ public void debugPub(String content) { pub(null, null, "collect.log.debug", null, content, null, Infotype.INFOTYPE_LOG_DEBUG, null); } /** * 给logtype打上error * * @param content * 消息内容 * @author chenchao03 * @date Nov 29, 2013 */ public void errorPub(String content) { pub(null, null, "collect.log.error", null, content, null, Infotype.INFOTYPE_MONITOR_INFO, null); } /** * 给logtype打上error * * @param content * 消息内容 * @param t * 异常信息 * @author chenchao03 * @date Nov 29, 2013 */ public void errorPub(String content, Throwable t) { pub(null, null, "collect.log.error", null, content, t, Infotype.INFOTYPE_MONITOR_INFO, null); } /** * 显示关闭 * * @author chenchao03 * @date Nov 30, 2013 */ public void close() { amqpTemplate.execute(new ChannelCallback<Object>() { public Object doInRabbit(Channel channel) throws Exception { channel.close(); channel.abort(); channel.getConnection().close(); return null; } }); } }
[ "chao289@126.com" ]
chao289@126.com
f2a1ad9ac611fafed2b074d1cdd70c7a5ad77468
90122c18b51d027810b54bc519caeefd8b2f587b
/app/src/main/java/ru/evendate/android/models/EventRegistered.java
d57585fd9b68f7505666d6061efa1b103ab129f5
[]
no_license
KardanovIR/evendate-android
c9da1b458f7fc5140a27c55efb808feedb4a70a7
87fce26681fdc51fcb9ab57123a0d9c9d2de2b89
refs/heads/master
2021-03-24T12:43:11.271688
2017-11-22T22:14:33
2017-11-22T22:14:33
53,123,544
0
0
null
null
null
null
UTF-8
Java
false
false
695
java
package ru.evendate.android.models; import java.util.ArrayList; import java.util.Date; import java.util.List; import ru.evendate.android.network.ServiceUtils; /** * Created by Aedirn on 07.03.17. */ public interface EventRegistered { String FIELDS_LIST = "dates" + ServiceUtils.encloseFields(EventDate.FIELDS_LIST) + "," + "location,my_tickets_count,sold_tickets_count," + "tickets" + ServiceUtils.encloseFields(Ticket.FIELDS_LIST, Ticket.ORDER_BY); int getEntryId(); String getTitle(); String getLocation(); Date getNearestDateTime(); List<Ticket> getTickets(); int getMyTicketsCount(); ArrayList<EventDate> getDateList(); }
[ "nillsondg@gmail.com" ]
nillsondg@gmail.com
040c57452450d776649b83d40b1305dca8d24e68
c7579eac78326015a53d89ea4dd8124660e707b1
/tddl-qatest/src/test/java/com/taobao/tddl/qatest/matrix/join/JoinTest.java
10ca500ec3879598e65e3d011a30ccd546aef9e2
[ "Apache-2.0" ]
permissive
quyixiao/TDDL
07f3db5e4a78ec19b68dfb4b5d98fb9d7edb2a60
1bc33f047f94b878f6e13edb06c03dc3f8c2cb21
refs/heads/master
2023-04-02T02:28:51.288020
2021-03-30T03:58:26
2021-03-30T03:58:26
352,864,306
0
0
null
null
null
null
UTF-8
Java
false
false
13,610
java
package com.taobao.tddl.qatest.matrix.join; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized.Parameters; import com.taobao.tddl.qatest.BaseMatrixTestCase; import com.taobao.tddl.qatest.BaseTestCase; import com.taobao.tddl.qatest.ExecuteTableName; import com.taobao.tddl.qatest.util.EclipseParameterized; /** * join测试 * * @author zhuoxue * @since 5.0.1 */ @RunWith(EclipseParameterized.class) public class JoinTest extends BaseMatrixTestCase { // common fields private final long module_id = Math.abs(rand.nextLong()); private final long hostgroup_id = Math.abs(rand.nextLong()); // monitor_module_info fields private final long product_id = Math.abs(rand.nextLong()); private final String module_name = "my_module_name"; private final long parent_module_id = Math.abs(rand.nextLong()); private final String applevel = "my_applevel"; private final String apprisk = "my_apprisk"; private final long sequence = Math.abs(rand.nextLong()); private final String module_description = "my_module_description"; private final String alias_name = "my_alias_name"; // monitor_host_info fields private final long host_id = Math.abs(rand.nextLong()); private final String host_name = "my_host_name"; private final String host_ip = "my_host_ip"; private final String host_type_id = "my_host_type_id"; private final String station_id = "my_station_id"; private final String snmp_community = "my_snmp_community"; private final String status = "my_status"; private final long host_flag = Math.abs(rand.nextLong()); // monitor_hostgroup_info fields private final String gstation_id = "my_gstation_id"; private final String hostgroup_name = "my_hostgroup_name"; private final long nagios_id = Math.abs(rand.nextLong()); private final long hostgroup_flag = Math.abs(rand.nextLong()); String[] columnParam = { "APPNAME", "HOSTIP", "STATIONID", "HOSTGROUPNAME" }; @Parameters(name = "{index}:table0={0},table1={1},table2={2},table3={3},table4={4}") public static List<String[]> prepareDate() { return Arrays.asList(ExecuteTableName.hostinfoHostgoupStudentModuleinfoModulehostTable(dbType)); } public JoinTest(String monitor_host_infoTableName, String monitor_hostgroup_infoTableName, String studentTableName, String monitor_module_infoTableName, String monitor_module_hostTableName) throws Exception{ BaseTestCase.host_info = monitor_host_infoTableName; BaseTestCase.hostgroup_info = monitor_hostgroup_infoTableName; BaseTestCase.studentTableName = studentTableName; BaseTestCase.module_info = monitor_module_infoTableName; BaseTestCase.module_host = monitor_module_hostTableName; init(); } public void init() throws Exception { tddlUpdateData("delete from " + module_info, null); tddlUpdateData("delete from " + host_info, null); tddlUpdateData("delete from " + hostgroup_info, null); mysqlUpdateData("delete from " + module_info, null); mysqlUpdateData("delete from " + host_info, null); mysqlUpdateData("delete from " + hostgroup_info, null); // insert monitor_module_info String sql = "replace into " + module_info + "(module_id, product_id,module_name, parent_module_id, applevel, apprisk, sequence,module_description, alias_name) values(?,?,?,?,?,?,?,?,?)"; tddlUpdateData(sql, Arrays.asList(new Object[] { module_id, product_id, module_name, parent_module_id, applevel, apprisk, sequence, module_description, alias_name })); mysqlUpdateData(sql, Arrays.asList(new Object[] { module_id, product_id, module_name, parent_module_id, applevel, apprisk, sequence, module_description, alias_name })); // insert monitor_host_info sql = "replace into " + host_info + "(host_id, host_name, host_ip,host_type_id, hostgroup_id, station_id, snmp_community, status, host_flag) values(?,?,?,?,?,?,?,?,?)"; tddlUpdateData(sql, Arrays.asList(new Object[] { host_id, host_name, host_ip, host_type_id, hostgroup_id, station_id, snmp_community, status, host_flag })); mysqlUpdateData(sql, Arrays.asList(new Object[] { host_id, host_name, host_ip, host_type_id, hostgroup_id, station_id, snmp_community, status, host_flag })); // insert monitor_hostgroup_info sql = "replace into " + hostgroup_info + "(hostgroup_id, station_id,hostgroup_name, module_id, nagios_id, hostgroup_flag) values(?,?,?,?,?,?)"; tddlUpdateData(sql, Arrays.asList(new Object[] { hostgroup_id, gstation_id, hostgroup_name, module_id, nagios_id, hostgroup_flag })); mysqlUpdateData(sql, Arrays.asList(new Object[] { hostgroup_id, gstation_id, hostgroup_name, module_id, nagios_id, hostgroup_flag })); } @After public void destory() throws Exception { psConRcRsClose(rc, rs); } // private static void prepare(String insert, Object[] args) throws // Exception { // ResultCursor rc = execute(null, insert, Arrays.asList(args)); // Assert.assertEquals(Integer.valueOf(1), rc.getIngoreTableName(rc.next(), // ResultCursor.AFFECT_ROW)); // Assert.assertNull(rc.getException()); // rc.close(); // } /** * 三表join,直接在from后面跟三张表(不指点join类型)where a.module_id = c.module_id and * c.hostgroup_id = b.hostgroup_id and b.status=status * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinA() throws Exception { String sql = "select a.module_name as appname ,a.applevel as applevel, b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + host_info + " b ," + hostgroup_info + " c " + "where a.module_id = c.module_id and c.hostgroup_id = b.hostgroup_id and b.status='" + status + "'"; String[] columnParam = { "APPNAME", "HOSTIP", "STATIONID", "HOSTGROUPNAME", "applevel" }; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and a.applevel=applevel and * c.nagios_id=nagios_id * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinA1() throws Exception { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + host_info + " b ," + "" + module_info + " a ," + hostgroup_info + " c " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and b.status=status * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinB() throws Exception { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + host_info + " b ," + hostgroup_info + " c " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status + "'"; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and b.status=status and * a.applevel=applevel and c.nagios_id=nagios_id * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinB1() throws Exception { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + host_info + " b ," + hostgroup_info + " c " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status + "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * c.hostgroup_id = b.hostgroup_id and b.status=status * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinC() throws Exception { // bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询 if (module_info.contains("mysql")) { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info + " c, " + host_info + " b " + "where c.module_id = a.module_id and c.hostgroup_id = b.hostgroup_id and b.status='" + status + "'"; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and b.status=status and * a.applevel=applevel and c.nagios_id=nagios_id * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinC1() throws Exception { // bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询 if (module_info.contains("mysql")) { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info + " c, " + host_info + " b " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status + "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and b.status=status * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinD() throws Exception { // bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询 if (module_info.contains("mysql")) { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info + " c, " + host_info + " b " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status + "'"; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } } /** * 三表join,直接在from后面跟三张表(不指点join类型) where c.module_id = a.module_id and * b.hostgroup_id = c.hostgroup_id and b.status=status and * a.applevel=applevel and c.nagios_id=nagios_id * * @author zhuoxue * @since 5.0.1 */ @Test public void testJoinD1() throws Exception { // bdb数据库join测试以下测试用例抛出异常,原因目前只支持单值查询 if (module_info.contains("mysql")) { String sql = "select a.module_name as appname , b.host_ip as hostip,b.station_id as stationid," + "c.hostgroup_name as hostgroupname from " + module_info + " a ," + "" + hostgroup_info + " c, " + host_info + " b " + "where c.module_id = a.module_id and b.hostgroup_id = c.hostgroup_id and b.status='" + status + "' and a.applevel='" + applevel + "' and c.nagios_id=" + nagios_id; selectContentSameAssert(sql, columnParam, Collections.EMPTY_LIST); } } }
[ "2621048238@qq.com" ]
2621048238@qq.com
2748826b8b97fa9ab1e92e8af3a2155854462f0a
d0acf844cae913c3fa8520b15e156c1db2da9125
/src/main/java/cg/wbd/grandemonstration/service/StudentService.java
0a81b128d3f49f3beb3d67459f28d62c5c5a0771
[]
no_license
hung060798/demo1-nhom
39a9b74326d92260d5b26fcea0115e7e11d2c319
7e6fa8859159456cc6ffd1aa28cc4ebd4f48953d
refs/heads/master
2023-08-15T23:02:04.209913
2021-09-26T08:34:20
2021-09-26T08:34:20
409,624,836
0
0
null
null
null
null
UTF-8
Java
false
false
1,097
java
package cg.wbd.grandemonstration.service; import cg.wbd.grandemonstration.models.Student; import cg.wbd.grandemonstration.repository.IStudentRepo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; @Service public class StudentService implements IStudentService{ @Autowired IStudentRepo studentRepo; @Override public Page<Student> findAll(Pageable pageable) { return studentRepo.findAll(pageable); } @Override public Optional<Student> findOne(Long id) { return studentRepo.findById(id); } @Override public void save(Student student) { studentRepo.save(student); } @Override public void delete(Long id ) { studentRepo.deleteById(id); } @Override public Iterable<Student> findAllByNameContaining(String nameStudent) { return studentRepo.findAllByNameContaining(nameStudent); } }
[ "hungpppp12@gmail.com" ]
hungpppp12@gmail.com
3deeb2a652d7735e1ddf6bf77f082182298ac8a6
384b095e4c3cf5ee6820bbec1c411242ad34ce2d
/src/ie/lyit/hotel/Person.java
8b83578a0d8f05d6f0d9dfe0ac1464cc02154e7c
[]
no_license
dean0193/l00097028_hotel
3918b97737f781b8413732615c10ef7cdce8d55c
b6976ac111353e9b615fa34f1d9d0a030170e0a3
refs/heads/master
2021-08-23T10:41:53.077103
2017-12-04T15:18:55
2017-12-04T15:18:55
113,059,457
0
0
null
null
null
null
UTF-8
Java
false
false
2,298
java
/** * Dean Comiskey L00097028 * Software Implementation * Description: Models a Person * Date: 25/09/2017 **/ package ie.lyit.hotel; import java.io.Serializable; public abstract class Person implements Serializable{ protected Name name; // COMPOSITION - Person HAS-A name protected String address; protected String phoneNumber; // Default Constructor // Called when object is created like this // ==> Person pObj = new Person(); // NOTE-This won't work because Person is abstract public Person(){ name=new Name(); address=null; phoneNumber=null; } // Initialisation Constructor // Called when object would have been created like this (not possible cos abstract!) // ==> Person pObj = new Person("Mr", "Joe", "Doe", "2 Hi Road, Ennis", "087 1234567"); public Person(String t, String fN, String sn, String address, String phoneNumber){ name=new Name(t, fN, sn); // Calls Name initialisation constructor this.address=address; this.phoneNumber=phoneNumber; } // toString() method // ==> Calls Name's toString() to display name and // then displays address and phoneNumber @Override // Overrides Object toString() public String toString(){ return name + "," + address + "," + phoneNumber; } // equals() method // ==> Called when comparing an object with another object, // e.g. - if(p1.equals(p2)) // ==> Calls Name's equals() to compare name to personIn's name, and // compares phoneNumber to personIn's phoneNumber @Override // Overrides Object equals() public boolean equals(Object obj){ Person pObject; if (obj instanceof Person) pObject = (Person)obj; else return false; return(name.equals(pObject.name) && address.equals(pObject.address) && phoneNumber.equals(pObject.phoneNumber)); } // set() and get() methods public void setName(Name nameIn){ name = nameIn; } public Name getName(){ return name; } public void setAddress(String addressIn){ address = addressIn; } public String getAddress(){ return address; } public void setPhoneNumber(String phoneNumberIn){ phoneNumber = phoneNumberIn; } public String getPhoneNumber(){ return phoneNumber; } }
[ "Dean@192.168.1.10" ]
Dean@192.168.1.10
d60e19bfc2adc812bb5b8f9f14e7b365ab9b465d
6d9b29b0ff89bfc307fda40f336cb2fe8babeab8
/src/main/java/seedu/meeting/commons/events/ui/JumpToMeetingListRequestEvent.java
b8fef2673317e688c553ef97d60b0f635b7cb910
[ "MIT" ]
permissive
PakornUe/main
945619adb53dda93abd011de2c9e02c2a68d9fcd
dd2a9f510e7119c39dc88cf8cdf7dfc76eb3ddf6
refs/heads/master
2021-09-28T00:03:32.070328
2018-11-11T14:10:46
2018-11-11T14:10:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
544
java
package seedu.meeting.commons.events.ui; import seedu.meeting.commons.core.index.Index; import seedu.meeting.commons.events.BaseEvent; /** * Indicates a request to jump to the list of meetings. * {@author jeffreyooi} */ public class JumpToMeetingListRequestEvent extends BaseEvent { public final int targetIndex; public JumpToMeetingListRequestEvent(Index targetIndex) { this.targetIndex = targetIndex.getZeroBased(); } @Override public String toString() { return getClass().getSimpleName(); } }
[ "7553066+Zenious@users.noreply.github.com" ]
7553066+Zenious@users.noreply.github.com
099db01441a423fc6d22171cd79185051b25708e
cdc1d2c416b79abce38941608cf058cfba1a6592
/src/main/java/com/pla/core/domain/model/BranchName.java
7722de54e0b7c56c97645e3a4f8fd3f6fcdb1674
[]
no_license
ekochnev/pla
e3824d8b5a6b03ba056188697246275c80bfba92
b48b2c9a0d284395e7458293bff9e70a6f795f84
refs/heads/master
2021-05-15T21:16:08.734937
2015-08-21T11:57:30
2015-08-21T11:57:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
482
java
package com.pla.core.domain.model; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import javax.persistence.Embeddable; import java.io.Serializable; /** * Created by User on 3/24/2015. */ @Embeddable @EqualsAndHashCode(of = "branchName") @NoArgsConstructor @Getter public class BranchName implements Serializable { private String branchName; public BranchName(String branchName) { this.branchName = branchName; } }
[ "nischitha_ramanna@nthdimenzion.com" ]
nischitha_ramanna@nthdimenzion.com
449285210d9c135ac0bf23376a077ff771277ead
c94d12c362ab57c315b355dcc81afa5f07e84a38
/presentation/src/main/java/com/sixthsolution/easymvp/tvmaze/internal/di/module/RepositoryModule.java
0a57ddef2e1f88b569a1e921c7d0627406eb8e14
[]
no_license
mohamad-amin/TvMaze-CleanArchitecture
28baa183f506ab991759b24d505b7a90fe2d5683
4d9b75fd788fce49275d92c1cc1eca4f1302d1f6
refs/heads/master
2021-01-19T22:21:06.401722
2016-10-25T11:05:06
2016-10-25T11:05:06
71,249,678
1
0
null
null
null
null
UTF-8
Java
false
false
766
java
package com.sixthsolution.easymvp.tvmaze.internal.di.module; import com.sixthsolution.easymvp.data.repository.FilmDataRepository; import com.sixthsolution.easymvp.data.repository.FilmSearchRepository; import com.sixthsolution.easymvp.domain.repository.FilmRepository; import com.sixthsolution.easymvp.domain.repository.SearchRepository; import dagger.Module; import dagger.Provides; /** * @author MohamadAmin Mohamadi (mohammadi.mohamadamin@gmail.com) on 10/21/16. */ @Module public class RepositoryModule { @Provides FilmRepository provideFilmRepository(FilmDataRepository repository) { return repository; } @Provides SearchRepository provideSearchRepository(FilmSearchRepository repository) { return repository; } }
[ "mohamadamin@aut.ac.ir" ]
mohamadamin@aut.ac.ir
c3e667b32962816bc293813290d0d550fb330e47
65c587993fd89625640af404c9a2b60ee24735e6
/automation_practice/src/main/java/com/generic/MasterPageFactory.java
fffb785f35f631b45e6937102af0d15a5290550c
[]
no_license
studentqa2020/susmita-Nishir-14
74203961a113abb2cc009dbce33c1f075521fb9d
c1126a887fe9b6b1a46a4e7796ea9cc7ad97bf86
refs/heads/master
2023-06-06T12:19:21.537390
2021-06-27T18:21:50
2021-06-27T18:21:50
380,806,958
0
0
null
null
null
null
UTF-8
Java
false
false
798
java
package com.generic; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; public class MasterPageFactory { MasterPageFactory(WebDriver driver) { PageFactory.initElements(driver, this); } public WebElement getSigninBtn() { return signinBtn; } public WebElement getEmail() { return email; } public WebElement getPass() { return pass; } public WebElement getLoginbtn() { return loginbtn; } @FindBy(xpath="//*[@class='login']") private WebElement signinBtn; @FindBy(xpath="//*[@id='email']") private WebElement email; @FindBy(xpath="//*[@id='passwd']") private WebElement pass; @FindBy(xpath="//*[@class='icon-lock left']") private WebElement loginbtn; }
[ "sikan@LAPTOP-7AE2PAGQ" ]
sikan@LAPTOP-7AE2PAGQ
40379e2423c695be978b07903c8cefdb9374656e
9cf6615a785c489b7b9e960115f615d245682356
/EnglishGraduateWord/src/main/java/com/english/database/EnglishDBOperate.java
3c96841afda0bfd3553f6dc730ea0d33bdb1c35a
[]
no_license
malijie/EnglishWord
e9afa780c1453c7c86dfb47a87a47bfef0a7d2ec
3e4a1ec5b43a26a9d5a060a061d47113026e7d30
refs/heads/master
2021-05-16T05:25:17.774075
2018-12-03T15:11:00
2018-12-03T15:11:00
58,785,007
0
0
null
null
null
null
UTF-8
Java
false
false
19,060
java
package com.english.database; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.text.Html; import android.widget.Toast; import com.english.model.ReadingInfo; import com.english.model.WordInfo; import com.english.model.WrittingInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class EnglishDBOperate { private SQLiteDatabase db = null; private final String QUERY_ALL_WORDS = "select * from vocabulary"; private final String QUERY_WORDS_BY_INDEX = "SELECT * FROM VOCABULARY WHERE ID BETWEEN "; private final String UPDATE_WORDS = "UPDATE VOCABULARY SET"; private Context context; public EnglishDBOperate(SQLiteDatabase db, Context context){ this.db = db; this.context = context; } /** * * @return ���ؿγ����� */ public int getLessonsSize(){ String strCount = "0"; Cursor result = null; try{ db.beginTransaction(); db.setTransactionSuccessful(); String sql = "select count(id) as total from vocabulary"; result = db.rawQuery(sql, null); if(!result.isAfterLast() ){ result.moveToFirst(); strCount = result.getString(result.getColumnIndex("total")); } }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return Integer.parseInt(strCount); } /** * 将当前课程的正确率置为0 * @param index 课程号 */ public void resumeAccuracyCount(int index){ db.beginTransaction(); String sql = "update vocabulary set is_known='false' where id between " + (index*100+1) + " and " + (index*100+100); db.execSQL(sql); db.setTransactionSuccessful(); db.endTransaction(); } /** * ��ݴ���Ŀγ̺ţ������Ҫ��ʾ����� * @param lesson �γ̺� * @return */ public List<Map<String, String>> getWordsListByLesson(int lesson){ Cursor result = null; List<Map<String,String>> wordsList = null; try{ db.beginTransaction(); db.setTransactionSuccessful(); wordsList = new ArrayList<Map<String,String>>(); String sql = QUERY_WORDS_BY_INDEX + (lesson * 100 - 99) + " AND " + lesson * 100; result = db.rawQuery(sql, null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ Map<String, String> mWord = new HashMap<String, String>(); mWord.put("id", result.getString(result.getColumnIndex("id"))); mWord.put("symbols", result.getString(result.getColumnIndex("symbols"))); mWord.put("word", result.getString(result.getColumnIndex("word"))); mWord.put("content", result.getString(result.getColumnIndex("content"))); mWord.put("example", result.getString(result.getColumnIndex("example"))); mWord.put("note", result.getString(result.getColumnIndex("note"))); wordsList.add(mWord); } }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); db.endTransaction(); } } return wordsList; } /** * ���id���ҵ��� * @return ���� */ public WordInfo getWordById(int index){ WordInfo mWordInfo = null; Cursor result = null; try{ db.beginTransaction(); String sql = QUERY_ALL_WORDS + " where id=" + index; result = db.rawQuery(sql, null); if(!result.isAfterLast()){ result.moveToFirst(); mWordInfo = new WordInfo(); mWordInfo.setId(result.getInt(result.getColumnIndex("id"))); mWordInfo.setSymbols(result.getString(result.getColumnIndex("symbols"))); mWordInfo.setWord(result.getString(result.getColumnIndex("word"))); mWordInfo.setContent(result.getString(result.getColumnIndex("content"))); mWordInfo.setExample(result.getString(result.getColumnIndex("example"))); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return mWordInfo; } /** * ��ݿγ̺Ų�����γ��е�����Ϣ * @param lesson�γ̺� * @return */ public List<WordInfo> getWordsByLesson(int lesson){ List<WordInfo> lessonWords = null; Cursor result = null; try{ db.beginTransaction(); lessonWords = new ArrayList<WordInfo>(); String sql = QUERY_ALL_WORDS + " WHERE ID BETWEEN " + (lesson*100+1) + " AND " + (lesson*100+100); result = db.rawQuery(sql, null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ WordInfo mWordInfo = new WordInfo(); mWordInfo.setId(result.getInt(result.getColumnIndex("id"))); mWordInfo.setSymbols(result.getString(result.getColumnIndex("symbols"))); mWordInfo.setWord(result.getString(result.getColumnIndex("word"))); mWordInfo.setContent(result.getString(result.getColumnIndex("content"))); mWordInfo.setExample(result.getString(result.getColumnIndex("example"))); lessonWords.add(mWordInfo); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); db.endTransaction(); } } return lessonWords; } /** * ���µ����Ƿ�Ϊ���״̬ * @param id id�� */ public void updateWordIsStrangerById(boolean isStranger, int index){ db.beginTransaction(); try{ int id = index + 1; String sql = UPDATE_WORDS + " is_stranger='" + isStranger + "' WHERE ID=" + id; db.execSQL(sql); db.setTransactionSuccessful(); }catch(Exception e){ Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show(); }finally{ db.endTransaction(); } } /** * ���µ����Ƿ�Ϊ���״̬ * @param index lessonWords�е���� */ public void updateWordIsKnownByIndex(boolean isKnown, int index){ db.beginTransaction(); try{ int id = index + 1; //lessonWords��index��ʼλ��Ϊ0�� ��ݿ���id��ʼλ��Ϊ1��������Ҫ+1 String sql = UPDATE_WORDS + " is_known='" + isKnown + "' WHERE ID=" + id; db.execSQL(sql); db.setTransactionSuccessful(); }catch(Exception e){ Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show(); }finally{ db.endTransaction(); } } public void updateWordIsKnownById(boolean isKnown, int id){ db.beginTransaction(); try{ String sql = UPDATE_WORDS + " is_known='" + isKnown + "' WHERE ID=" + id; db.execSQL(sql); db.setTransactionSuccessful(); }catch(Exception e){ Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show(); }finally{ db.endTransaction(); } } /** * ���id���µ���������ʱ�� * @param date ������ʱ�� * @param id ����id */ public void updateLastVisitDateById(String date, int id){ db.beginTransaction(); try{ String sql = UPDATE_WORDS + " last_visit='" + date + "' WHERE ID=" + id; db.execSQL(sql); db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); Toast.makeText(context, "Sorry,����ʧ�ܣ����Ժ�����...", Toast.LENGTH_SHORT).show(); }finally{ db.endTransaction(); } } /** * ��ݿγ̺Ų�ѯ������������ʱ�� * @param lesson �γ̺� * @return ���пγ�����ʱ�伯�� */ public List<String> getLastVisitDateListByLesson(int lesson){ List<String> dateList = null; String sql = ""; Cursor result = null; db.beginTransaction(); try{ dateList = new ArrayList<String>(); for(int i=0;i<lesson;i++){ sql = "select last_visit from vocabulary WHERE ID BETWEEN " + (i*100+1) + " AND " + (i*100+100) + " ORDER BY last_visit desc LIMIT 0,1"; result =db.rawQuery(sql,null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ dateList.add(result.getString(result.getColumnIndex("last_visit"))); } } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return dateList; } /** * ��ݿγ̺Ų�ѯÿ���е�һ�����ʵĵ��ʣ������Լ����� */ public List<Map<String,String>> getAbstractListByLesson(int lesson){ List<Map<String,String>> abList = null; String sql = ""; Cursor result = null; try{ abList = new ArrayList<Map<String,String>>(); db.beginTransaction(); for(int i=0; i<lesson; i++){ // sql = "select word,symbols,content,example from vocabulary WHERE ID=" + (i*100+1); // sql = "select word,symbols from vocabulary WHERE ID=" + (i*100+1); sql = "select word,symbols,content,example from vocabulary WHERE ID=1"; result =db.rawQuery(sql,null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ Map<String,String> mapWordInfo = new HashMap<String,String>(); mapWordInfo.put("word", result.getString(result.getColumnIndex("word"))); mapWordInfo.put("symbols", result.getString(result.getColumnIndex("symbols"))); mapWordInfo.put("content", result.getString(result.getColumnIndex("content"))); mapWordInfo.put("example", result.getString(result.getColumnIndex("example"))); abList.add(mapWordInfo); } } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return abList; } /** * * @param lesson �γ̺� * @return ÿ���лش���ȷ�ĵ����� */ public List<Integer> getAccuracyCountByListen(int lesson){ List<Integer> acList = null; String sql = ""; Cursor result = null; try{ acList = new ArrayList<Integer>(); db.beginTransaction(); for(int i=0;i<1;i++){ sql = "select count(id) as total from vocabulary where id between " + (i*100+1) + " and " + (i*100+100) + " and is_known='true'"; result = db.rawQuery(sql, null); for(result.moveToFirst();!result.isAfterLast();result.moveToNext()){ acList.add(result.getInt(result.getColumnIndex("total"))); } } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return acList; } /** * * @return ����������� */ public List<WordInfo> getAllUnknownWords(){ List<WordInfo> uWordsList = null; String sql = null; Cursor result = null; try{ uWordsList = new ArrayList<WordInfo>(); db.beginTransaction(); sql = "select * from vocabulary where is_known='false'"; result = db.rawQuery(sql, null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ WordInfo uWord = new WordInfo(); System.out.println("uWord-->" + uWord); uWord.setId(Integer.parseInt(result.getString(result.getColumnIndex("id")))); uWord.setSymbols(result.getString(result.getColumnIndex("symbols"))); uWord.setContent(result.getString(result.getColumnIndex("content"))); uWord.setWord(result.getString(result.getColumnIndex("word"))); uWord.setExample(result.getString(result.getColumnIndex("example"))); uWordsList.add(uWord); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ db.endTransaction(); if(result != null){ result.close(); } db.close(); } return uWordsList; } /** * ���idֵ�������״̬ */ public void updateUnknownWordStatusById(int id){ String sql = ""; try{ db.beginTransaction(); sql = UPDATE_WORDS + " is_known='true' where id=" + id; db.execSQL(sql); db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ db.endTransaction(); db.close(); } } /** * * @return */ public List<ReadingInfo> getAllReadingInfoByDate(int date){ List<ReadingInfo> readInfoList = null; String sql = ""; Cursor result = null; try{ db.beginTransaction(); sql = "select * from reading where date=" + date; result = db.rawQuery(sql,null); readInfoList = new ArrayList<ReadingInfo>(); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ ReadingInfo readingInfo = new ReadingInfo(); readingInfo.setId(Integer.parseInt(result.getString(result.getColumnIndex("id")))); readingInfo.setTitle(result.getString(result.getColumnIndex("title"))); readingInfo.setDate(Integer.parseInt(result.getString(result.getColumnIndex("date")))); readingInfo.setContent(result.getString(result.getColumnIndex("content"))); readingInfo.setAnswer(result.getString(result.getColumnIndex("answer"))); readInfoList.add(readingInfo); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return readInfoList; } /** * * ����д����Ϣ * @return */ public List<WrittingInfo> getAllWrittingInfoByDate(){ List<WrittingInfo> writtingInfoList = null; String sql = ""; Cursor result = null; try{ db.beginTransaction(); sql = "select * from writting"; result = db.rawQuery(sql,null); writtingInfoList = new ArrayList<WrittingInfo>(); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ WrittingInfo writtingInfo = new WrittingInfo(); writtingInfo.setId(Integer.parseInt(result.getString(result.getColumnIndex("id")))); writtingInfo.setQuestion(result.getString(result.getColumnIndex("question"))); writtingInfo.setDate(result.getString(result.getColumnIndex("date"))); writtingInfo.setHaveImage(result.getString(result.getColumnIndex("have_image"))); writtingInfo.setAnswer(result.getString(result.getColumnIndex("answer"))); writtingInfo.setImagePath(result.getString(result.getColumnIndex("image_path"))); writtingInfo.setTitle(result.getString(result.getColumnIndex("title"))); writtingInfoList.add(writtingInfo); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return writtingInfoList; } public List<WordInfo> getSearchResult(String keyWord) { List<WordInfo> wordInfos = null; String sql = ""; Cursor result1 = null; Cursor result2 = null; Cursor result3 = null; boolean isFoundInWord = true; boolean isFoundInContent = true; try{ wordInfos = new ArrayList<WordInfo>(); db.beginTransaction(); sql = "select * from vocabulary where word='" + keyWord + "'"; result1 = db.rawQuery(sql, null); for(result1.moveToFirst();!result1.isAfterLast();result1.moveToNext()){ WordInfo wordInfo = new WordInfo(); wordInfo.setId(result1.getInt(result1.getColumnIndex("id"))); wordInfo.setWord(result1.getString(result1.getColumnIndex("word"))); wordInfo.setSymbols(result1.getString(result1.getColumnIndex("symbols"))); wordInfo.setContent(result1.getString(result1.getColumnIndex("content"))); wordInfo.setExample(Html.fromHtml(result1.getString(result1.getColumnIndex("example"))).toString()); wordInfos.add(wordInfo); isFoundInWord = false; isFoundInContent = false; } if(isFoundInWord){//����ģ���ѯ sql = "select * from vocabulary where word like '" + keyWord + "%'"; result2 = db.rawQuery(sql, null); for(result2.moveToFirst(); !result2.isAfterLast(); result2.moveToNext()){ WordInfo wordInfo = new WordInfo(); wordInfo.setId(result2.getInt(result2.getColumnIndex("id"))); wordInfo.setWord(result2.getString(result2.getColumnIndex("word"))); wordInfo.setSymbols(result2.getString(result2.getColumnIndex("symbols"))); wordInfo.setContent(result2.getString(result2.getColumnIndex("content"))); wordInfo.setExample(result2.getString(result2.getColumnIndex("example"))); wordInfos.add(wordInfo); isFoundInContent = false; } } if(isFoundInContent){//���ҵ����������� sql = "select * from vocabulary where content like '%" + keyWord + "%'"; result3 = db.rawQuery(sql, null); for(result3.moveToFirst(); !result3.isAfterLast(); result3.moveToNext()){ WordInfo wordInfo = new WordInfo(); wordInfo.setId(result3.getInt(result3.getColumnIndex("id"))); wordInfo.setWord(result3.getString(result3.getColumnIndex("word"))); wordInfo.setSymbols(result3.getString(result3.getColumnIndex("symbols"))); wordInfo.setContent(result3.getString(result3.getColumnIndex("content"))); wordInfo.setExample(result3.getString(result3.getColumnIndex("example"))); wordInfos.add(wordInfo); } } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result1 != null){ result1.close(); result1 = null; } if(result2 != null){ result2.close(); result2 = null; } if(result3 != null){ result3.close(); result3 = null; } db.endTransaction(); } return wordInfos; } public List<Map<String,String>> test(int index){ List<Map<String,String>> abList = null; String sql = ""; Cursor result = null; try{ abList = new ArrayList<Map<String,String>>(); db.beginTransaction(); sql = "select word,symbols,content,example from vocabulary WHERE ID=" + (index*100+1); result =db.rawQuery(sql,null); for(result.moveToFirst(); !result.isAfterLast(); result.moveToNext()){ Map<String,String> mapWordInfo = new HashMap<String,String>(); mapWordInfo.put("word", result.getString(result.getColumnIndex("word"))); mapWordInfo.put("symbols", result.getString(result.getColumnIndex("symbols"))); mapWordInfo.put("content", result.getString(result.getColumnIndex("content"))); mapWordInfo.put("example", result.getString(result.getColumnIndex("example"))); abList.add(mapWordInfo); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return abList; } public Integer test2(int index){ String sql = ""; Cursor result = null; int acCount = 0; try{ db.beginTransaction(); sql = "select count(id) as total from vocabulary where id between " + (index*100+1) + " and " + (index*100+100) + " and is_known='true'"; result = db.rawQuery(sql, null); result.moveToFirst(); if(!result.isAfterLast()){ acCount = result.getInt(result.getColumnIndex("total")); result.moveToNext(); } db.setTransactionSuccessful(); }catch(Exception e){ e.printStackTrace(); }finally{ if(result != null){ result.close(); } db.endTransaction(); } return acCount; } }
[ "190223629@qq.com" ]
190223629@qq.com
a9a4a060abf3e9b3ffd1c4cb861fea01c4bc7d77
dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9
/data_defect4j/preprossed_method_corpus/Math/40/org/apache/commons/math/dfp/BracketingNthOrderBrentSolverDFP_getMaximalOrder_89.java
806ada00c334d637913bc3baa09e63488db2392e
[]
no_license
hvdthong/NetML
dca6cf4d34c5799b400d718e0a6cd2e0b167297d
9bb103da21327912e5a29cbf9be9ff4d058731a5
refs/heads/master
2021-06-30T15:03:52.618255
2020-10-07T01:58:48
2020-10-07T01:58:48
150,383,588
1
1
null
2018-09-26T07:08:45
2018-09-26T07:08:44
null
UTF-8
Java
false
false
854
java
org apach common math dfp modif href http mathworld wolfram brent method brentsmethod html brent algorithm respect origin brent algorithm return chosen current interv user link allow solut allowedsolut maxim order invert polynomi root search user invert quadrat interv bracket root version bracket nth order brent solver dfp bracketingnthorderbrentsolverdfp maxim order maxim order maxim order getmaximalord maxim order maximalord
[ "hvdthong@gmail.com" ]
hvdthong@gmail.com
2c743039a5bd0c49842e02ef2fd26264857305d8
f7a2b5789fa1b517bf071f237ce9639961cb2cb7
/src/model/Voiture.java
428a6b77c3812eab65bc1957813c65b98f14712d
[]
no_license
amostin/ProjetJava
cb537445e399e3216ac8faa65baf2bfa36de6bf0
9e4219cdfec8b80c0dbecbd87b4c7c5859c02aae
refs/heads/master
2022-11-30T04:59:43.549396
2020-08-19T10:33:02
2020-08-19T10:33:02
275,386,141
0
0
null
2020-08-05T12:37:24
2020-06-27T14:12:51
Java
ISO-8859-1
Java
false
false
9,053
java
/** * */ package model; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; /** * Cette classe permet de créer des voitures * @author Ambroise Mostin * */ public class Voiture implements Comparable<Voiture>{ private String marque; private String type; private String puissance; private String bva; private String gps; private String porte; private String clim; private String etat; private String prix; private String prixKm; private String amende; private static int i = 0; /** * Ce constructeur permet de créer une voiture automatiquement * @param variete le numero correspond à un type de voiture */ public Voiture(int variete) { switch (variete) { case 0: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "2000"; this.bva = "oui"; this.gps = "oui"; this.porte = "3"; this.clim = "oui"; this.prix = "100"; this.prixKm = "5.0"; this.amende = "50.0"; this.etat = "disponible"; i++; break; case 1: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1800"; this.bva = "non"; this.gps = "oui"; this.porte = "3"; this.clim = "oui"; this.prix = "90"; this.prixKm = "4.5"; this.amende = "45.0"; this.etat = "disponible"; i++; break; case 2: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1600"; this.bva = "oui"; this.gps = "non"; this.porte = "3"; this.clim = "non"; this.prix = "80"; this.prixKm = "4.0"; this.amende = "40.0"; this.etat = "disponible"; i++; break; case 3: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1500"; this.bva = "non"; this.gps = "oui"; this.porte = "5"; this.clim = "oui"; this.prix = "70"; this.prixKm = "3.5"; this.amende = "35.0"; this.etat = "disponible"; i++; break; case 4: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1400"; this.bva = "oui"; this.gps = "non"; this.porte = "5"; this.clim = "non"; this.prix = "60"; this.prixKm = "3.0"; this.amende = "30.0"; this.etat = "disponible"; i++; break; case 5: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1300"; this.bva = "non"; this.gps = "non"; this.porte = "3"; this.clim = "non"; this.prix = "50"; this.prixKm = "2.5"; this.amende = "25.0"; this.etat = "disponible"; i++; break; case 6: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1200"; this.bva = "non"; this.gps = "non"; this.porte = "5"; this.clim = "oui"; this.prix = "40"; this.prixKm = "2.0"; this.amende = "20.0"; this.etat = "disponible"; i++; break; case 7: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1100"; this.bva = "oui"; this.gps = "oui"; this.porte = "5"; this.clim = "non"; this.prix = "30"; this.prixKm = "1.5"; this.amende = "15.0"; this.etat = "disponible"; i++; break; case 8: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "1000"; this.bva = "non"; this.gps = "oui"; this.porte = "5"; this.clim = "non"; this.prix = "20"; this.prixKm = "1.0"; this.amende = "10.0"; this.etat = "disponible"; i++; break; case 9: this.marque = "marque_"+i; this.type = "type_"+i; this.puissance = "800"; this.bva = "oui"; this.gps = "non"; this.porte = "5"; this.clim = "oui"; this.prix = "15"; this.prixKm = "0.75"; this.amende = "7.5"; this.etat = "disponible"; i++; break; default: break; } } /** * Ce constructeur permet de créer une voiture selon les caractéristiques choisies * @param marque marque de la voiture * @param type type de la voiture * @param puissance puissance de la voiture * @param bva boite de vitesse de la voiture * @param gps gps de la voiture * @param porte porte de la voiture * @param clim clim de la voiture * @param prix prix de la voiture * @param prixKm prixKm de la voiture * @param amende amende de la voiture */ public Voiture(String marque, String type, String puissance, String bva, String gps, String porte, String clim, String prix, String prixKm, String amende) { this.marque = marque + '_' + i; this.type = type + '_' + i; this.puissance = puissance; this.bva = bva; this.gps = gps; this.porte = porte; this.clim = clim; this.prix = prix; this.prixKm = prixKm; this.amende = amende; this.etat = "disponible"; i++; } @Override /** * Cette méthode permet d'afficher les caractéristiques de la voiture */ public String toString() { return "marque=" + marque + ", type=" + type + ", puissance=" + puissance + ", bva=" + bva + ", gps=" + gps + ", porte=" + porte + ", clim=" + clim + ", etat=" + etat + ", prix=" + prix + ", prixKm=" + prixKm + ", amende=" + amende; } /** * Cette méthode permet d'obtenir un identifant unique */ public static int getI() { return i; } /** * Cette méthode permet de modifier l'identifant unique */ public static void setI(int i) { Voiture.i = i; } /** * Cette méthode permet d'obtenir la marque */ public String getMarque() { return marque; } /** * Cette méthode permet de modifier la marque * @param marque la marque */ public void setMarque(String marque) { this.marque = marque; } /** * Cette méthode permet d'obtenir le type */ public String getType() { return type; } /** * Cette méthode permet de modifier le type * @param type le type */ public void setType(String type) { this.type = type; } /** * Cette méthode permet d'obtenir la puissance */ public String getPuissance() { return puissance; } /** * Cette méthode permet de modifier la puissance * @param puissance la puissance */ public void setPuissance(String puissance) { this.puissance = puissance; } /** * Cette méthode permet d'obtenir la boite de vitesse */ public String getBva() { return bva; } /** * Cette méthode permet de modifier la boite de vitesse * @param bva la boite de vitesse */ public void setBva(String bva) { this.bva = bva; } /** * Cette méthode permet d'obtenir le gps */ public String getGps() { return gps; } /** * Cette méthode permet de modifier le gps * @param gps le gps */ public void setGps(String gps) { this.gps = gps; } /** * Cette méthode permet d'obtenir le nombre de porte */ public String getPorte() { return porte; } /** * Cette méthode permet de modifier le nombre de porte * @param porte le nombre de porte */ public void setPorte(String porte) { this.porte = porte; } /** * Cette méthode permet d'obtenir la clim */ public String getClim() { return clim; } /** * Cette méthode permet de modifier la clim * @param clim la clim */ public void setClim(String clim) { this.clim = clim; } /** * Cette méthode permet d'obtenir l'état */ public String getEtat() { return etat; } /** * Cette méthode permet de modifier l'état * @param etat l'état de la voiture */ public void setEtat(String etat) { this.etat = etat; } /** * Cette méthode permet d'obtenir le prix */ public String getPrix() { return prix; } /** * Cette méthode permet de modifier le prix * @param prix le prix */ public void setPrix(String prix) { this.prix = prix; } /** * Cette méthode permet d'obtenir le prix au km */ public String getPrixKm() { return prixKm; } /** * Cette méthode permet de modifier le prix au km * @param prixKm le prix au km */ public void setPrixKm(String prixKm) { this.prixKm = prixKm; } /** * Cette méthode permet d'obtenir l'amende */ public String getAmende() { return amende; } /** * Cette méthode permet de modifier l'amende * @param amende le montant de l'amende */ public void setAmende(String amende) { this.amende = amende; } @Override /** * Cette méthode permet de comparer chaque voiture en fonction du prix * @param voiture la voiture avec laquelle comparer */ public int compareTo(Voiture voiture) { return (int)(Integer.parseInt(this.prix) - Integer.parseInt(voiture.getPrix())); } /** * Cette méthode permet de trier chaque voiture en fonction du prix * @param voitureParPrix la liste des voitures par prix */ public static ArrayList<Voiture> tri(ArrayList<Voiture> voitureParPrix){ Collections.sort(voitureParPrix); return voitureParPrix; } }
[ "a.mostin@students.ephec.be" ]
a.mostin@students.ephec.be
fcc36eeb81cf33017044bbf5ccf242b33f7a7140
7e892591a22018cebc2a9df5613cd8a462502c21
/z-common/src/main/java/logan/common/base/utils/xml/XmlJaxbUtils.java
5fced50d907856d3c5f821206df7c5ab36232ca5
[]
no_license
lengqiufeifeng/cloud
b6314f1a7d27549c95117a2e39fb23b16986fc51
f2761160625d983f49d696ca7962b8fd15b1deff
refs/heads/master
2021-10-11T07:20:46.209140
2019-01-23T07:02:43
2019-01-23T07:02:48
111,528,337
5
0
null
null
null
null
UTF-8
Java
false
false
2,433
java
package logan.common.base.utils.xml; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import java.io.File; import java.io.StringReader; import java.io.StringWriter; @SuppressWarnings("restriction" ) public class XmlJaxbUtils { @SuppressWarnings("unchecked" ) public static <E> E fromXML(String xml, Class<E> clazz) throws Exception { JAXBContext context = JAXBContext.newInstance(new Class[]{clazz}); Unmarshaller unmarshaller = context.createUnmarshaller(); try { return (E) unmarshaller.unmarshal(new StringReader(xml)); } catch (Exception e) { throw new Exception("解析xml出错! [" + xml + "]", e); } } @SuppressWarnings("unchecked" ) public static <E> E fromXML(File xmlFile, Class<E> clazz) throws Exception { JAXBContext context = JAXBContext.newInstance(new Class[]{clazz}); Unmarshaller unmarshaller = context.createUnmarshaller(); try { return (E) unmarshaller.unmarshal(xmlFile); } catch (Exception e) { throw new Exception("解析xml出错! ! " + xmlFile, e); } } public static String toXML(Object pojo) throws Exception { return toXML(pojo, "UTF-8" ); } public static String toXML(Object pojo, String encoding) throws Exception { JAXBContext context = JAXBContext.newInstance(new Class[]{pojo.getClass()}); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty("jaxb.encoding", encoding); marshaller.setProperty("jaxb.formatted.output", Boolean.valueOf(true)); StringWriter writer = new StringWriter(); marshaller.marshal(pojo, writer); String xml = writer.toString(); return xml; } public static void toXML(Object pojo, File xmlFile) throws Exception { toXML(pojo, "UTF-8", xmlFile); } public static void toXML(Object pojo, String encoding, File xmlFile) throws Exception { JAXBContext context = JAXBContext.newInstance(new Class[]{pojo.getClass()}); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty("jaxb.encoding", encoding); marshaller.setProperty("jaxb.formatted.output", Boolean.valueOf(true)); marshaller.marshal(pojo, xmlFile); } }
[ "xulongjun@jimoyo.com" ]
xulongjun@jimoyo.com
0575ada4e394ebd855b712c008994cd9c7c1c99a
6068c9ec095d23608e8484fb9d48e3fff759b13a
/src/test/java/katas/foliva/AlternatingCaseTest.java
c656cae60b01521d1e1b9169e22ba3713a3c1bb2
[ "Unlicense" ]
permissive
CFHLopez/bootcamp-2021-5
6cb6b2eefaf6d46e85d6153503efdfd7dc3b1fc9
89d1c511ed3e6fd2afd83d9d7e48b321ae3acf02
refs/heads/main
2023-09-04T17:27:22.401261
2021-11-22T16:47:36
2021-11-22T16:47:36
419,761,613
0
0
Unlicense
2021-10-21T14:42:05
2021-10-21T14:42:05
null
UTF-8
Java
false
false
1,673
java
package katas.foliva; import org.junit.Test; import static org.junit.Assert.assertEquals; public class AlternatingCaseTest { @Test public void allLowerCase(){ assertEquals("HELLO WORLD", StringUtils.toAlternativeString("hello world")); } @Test public void allUpperCase(){ assertEquals("hello world", StringUtils.toAlternativeString("HELLO WORLD")); } @Test public void oneLowerOneUpper(){ assertEquals("HELLO world", StringUtils.toAlternativeString("hello WORLD")); } @Test public void allNumbers(){ assertEquals("12345", StringUtils.toAlternativeString("12345")); } @Test public void twoConvertions(){ assertEquals("Hello World", StringUtils.toAlternativeString(StringUtils.toAlternativeString("Hello World"))); } @Test public void otherCases() { assertEquals("hEllO wOrld", StringUtils.toAlternativeString("HeLLo WoRLD")); assertEquals("1A2B3C4D5E", StringUtils.toAlternativeString("1a2b3c4d5e")); assertEquals("sTRINGuTILS.TOaLTERNATINGcASE", StringUtils.toAlternativeString("StringUtils.toAlternatingCase")); } @Test public void kataTitleTests() { assertEquals("ALTerNAtiNG CaSe", StringUtils.toAlternativeString("altERnaTIng cAsE")); assertEquals("altERnaTIng cAsE", StringUtils.toAlternativeString("ALTerNAtiNG CaSe")); assertEquals("ALTerNAtiNG CaSe <=> altERnaTIng cAsE", StringUtils.toAlternativeString("altERnaTIng cAsE <=> ALTerNAtiNG CaSe")); assertEquals("altERnaTIng cAsE <=> ALTerNAtiNG CaSe", StringUtils.toAlternativeString("ALTerNAtiNG CaSe <=> altERnaTIng cAsE")); } }
[ "Federico.Oliva@tsoftglobal.com" ]
Federico.Oliva@tsoftglobal.com
d50bed9bcdeb30e2e853df5d1327dfb2dd7c5317
63e0779a511f1af30d72bd8ec27f27d5814d6f76
/Tshogyen/app/src/main/java/edu/gcit/tshogyen/BoyCulC.java
79141a38dfa43b9d3f9c1379536a0bee0666fc7d
[]
no_license
Sonamdema123/Project2021
609baad24b44a10ce3d78bd88fc2b7e51935f706
0b2eaed2d66f994bdd0acd2a5dccfedbb08f0d40
refs/heads/main
2023-07-17T20:41:07.436882
2021-08-26T14:36:13
2021-08-26T14:36:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,516
java
package edu.gcit.tshogyen; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.Task; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.firestore.DocumentSnapshot; import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.QuerySnapshot; import com.google.firebase.storage.FirebaseStorage; import com.google.firebase.storage.StorageReference; import java.util.ArrayList; import java.util.List; public class BoyCulC extends AppCompatActivity { RecyclerView mRecyclerView; List<Candidates> candidateList; FirebaseFirestore fStore; ProgressDialog pd; VoteListAdapter mAdapter; FirebaseStorage firebaseStorage; StorageReference storageReference; FirebaseAuth fAuth; ImageView imageView; EditText candidateRole; FloatingActionButton gotonext; // CollectionReference collectionReference; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_boy_cul_c); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); int gridColumnCount = getResources().getInteger(R.integer.grid_column_count); fAuth = FirebaseAuth.getInstance(); pd = new ProgressDialog(this); candidateRole = findViewById(R.id.candidate_role); imageView = findViewById(R.id.image_resultView); firebaseStorage = FirebaseStorage.getInstance(); storageReference = firebaseStorage.getReference("Candidate_Images"); mRecyclerView = findViewById(R.id.voterecyclerView); //Set the Layout Manager mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); //Initialize the ArrayList that will contain the data candidateList = new ArrayList<>(); //Initialize the adapter and set it ot the RecyclerView mAdapter = new VoteListAdapter(this, candidateList); mRecyclerView.setAdapter(mAdapter); //for the different orientation and device sizes mRecyclerView.setLayoutManager(new GridLayoutManager(this, gridColumnCount)); fStore = FirebaseFirestore.getInstance(); // collectionReference = fStore.collection("Candidates"); gotonext = findViewById(R.id.gotoGirlCulC); gotonext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getApplicationContext(), GirlCulC.class)); finish(); } }); //show data in recyclerview showBoyCulturalCoordinator(); } @Override public void onBackPressed() { moveTaskToBack(true); } private void showBoyCulturalCoordinator() { //set title of progress dialog pd.setTitle("Loading Candidates..."); //show progress dialog pd.show(); fStore.collection("Boy Cultural Coordinator") .get() .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { // candidatesList.clear(); //called when data is retrieved pd.dismiss(); //show candidate for (DocumentSnapshot can: task.getResult()){ Candidates candidates = new Candidates( can.getString("id"), can.getString("FullName"), can.getString("CandidateEmail"), can.getString("CandidateID"), can.getString("CandidateRole"), can.getString("Uri"), can.getLong("Votes").intValue()); candidateList.add(candidates); } //adapter mAdapter = new VoteListAdapter(getApplicationContext(), candidateList); //set adapter to recyclerview mRecyclerView.setAdapter(mAdapter); } }) .addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { //called when there is any error while retrieving pd.dismiss(); Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater=getMenuInflater(); inflater.inflate(R.menu.menu, menu); return true; } @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: this.finish(); return true; } if(item.getItemId() == R.id.logout){ FirebaseAuth.getInstance().signOut(); startActivity(new Intent(getApplicationContext(), LoginActivity.class)); finish(); } if(item.getItemId() == R.id.user_profile){ startActivity(new Intent(getApplicationContext(), UserProfile.class)); } if(item.getItemId() == R.id.about){ startActivity(new Intent(getApplicationContext(), AboutPage.class)); } return super.onOptionsItemSelected(item); } }
[ "sdema1684@gmail.com" ]
sdema1684@gmail.com
49a6dda50f928ccce33bf541f4692b4a40dcc335
53ca207904e6c7ab573d9e81b61b593cbe076ef1
/veterinaria/src/trasveterinaria/dao/ComprobantesDAO.java
6fcc958562b46662455348c529c355c86d6e4fee
[]
no_license
aknarf/veterinaria-upc-201401
96cfa45f8f240bc7a4bda0e35da771e2e82b97a2
c4cadf0e2dc416490125c688e15c488f965f7866
refs/heads/master
2021-01-02T09:15:11.137258
2014-08-09T17:30:41
2014-08-09T17:30:41
38,780,375
0
0
null
null
null
null
UTF-8
Java
false
false
1,492
java
package trasveterinaria.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import trasveterinaria.excepcion.DAOExcepcion; import trasveterinaria.modelo.Citas; import trasveterinaria.modelo.Comprobantes; import trasveterinaria.util.ConexionBD; public class ComprobantesDAO extends BaseDAO { public void insertar (Comprobantes vo) throws DAOExcepcion { String query = "insert into comprobantes " + "(NroComprobante,serie,Correlativo,Tipo,direccion,fechaRegistro,Citas_nroCita)" + "values (?,?,?,?,?,?,?)"; Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; try { con = ConexionBD.obtenerConexion(); stmt = con.prepareStatement(query); stmt.setInt(1, vo.getNroComprobante()); stmt.setString(2, vo.getSerie()); stmt.setString(3, vo.getCorrelativo()); stmt.setString(4, vo.getTipo()); stmt.setString(5, vo.getDireccion()); stmt.setString(6, vo.getFechaRegistro()); stmt.setInt(7, vo.getNroCita()); //stmt.setString(2, vo.getNombre()); int i = stmt.executeUpdate(); if (i != 1) { throw new SQLException("No se pudo insertar"); } } catch (SQLException e) { System.err.println(e.getMessage()); throw new DAOExcepcion(e.getMessage()); } finally { this.cerrarResultSet(rs); this.cerrarStatement(stmt); this.cerrarConexion(con); } } }
[ "horuz0308@gmail.com" ]
horuz0308@gmail.com
94e300d887c7747d8961e2ecb5d32fc141e95369
3a47d7d1d6968daea4f2154de479ac18b17ad7db
/com.sg.vim/src/com/sg/vim/service/fuellabel/HelloWorld.java
e500f9a35db62297210c7c21714572f720c65f65
[]
no_license
sgewuhan/vim
ef64fce49f9ab481521a21901157c81910e57e5e
d7d193f5be3b357bace4e0f7b703281ade15ae7f
refs/heads/master
2021-01-19T03:12:56.079503
2013-06-26T00:51:24
2013-06-26T00:51:24
9,443,167
0
1
null
null
null
null
UTF-8
Java
false
false
762
java
package com.sg.vim.service.fuellabel; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "HelloWorld") public class HelloWorld { }
[ "ghuazh@gmail.com" ]
ghuazh@gmail.com
1bc08f81c35591378d537396b53d877f196f8b0f
cecc61169b2949b9ad1cfc91d24690595cc897ce
/src/main/java/com/china/mybootstrap/dao/UsrMapper.java
7516394795cffef9261795f1f8fe31eab65de978
[]
no_license
li1xiang/mybootstrap
c83804818e5b98e9d7b28c7f86dd70605ccc84f7
3eb3c97a0075c2a45d097e700f9ebcd6724e7a66
refs/heads/master
2022-10-27T13:21:01.499961
2019-07-31T15:11:07
2019-07-31T15:11:07
199,878,590
0
0
null
null
null
null
UTF-8
Java
false
false
807
java
package com.china.mybootstrap.dao; import com.china.mybootstrap.entity.Usr; import com.china.mybootstrap.entity.UsrExample; import java.util.List; import org.apache.ibatis.annotations.Param; public interface UsrMapper { long countByExample(UsrExample example); int deleteByExample(UsrExample example); int deleteByPrimaryKey(Integer usrId); int insert(Usr record); int insertSelective(Usr record); List<Usr> selectByExample(UsrExample example); Usr selectByPrimaryKey(Integer usrId); int updateByExampleSelective(@Param("record") Usr record, @Param("example") UsrExample example); int updateByExample(@Param("record") Usr record, @Param("example") UsrExample example); int updateByPrimaryKeySelective(Usr record); int updateByPrimaryKey(Usr record); }
[ "1614624236@qq.com" ]
1614624236@qq.com
bcbbbeda4917fda1ca2c530690603444728f9137
694fda5049cb91d8f3631a4832e714d18152cf8c
/Slumber Time/src/edu/northwestern/cbits/intellicare/slumbertime/SettingsActivity.java
213a0a9e5dfeb34bd730f14c625ad4058b32c58e
[]
no_license
cbitstech/Intellicare-Template
c3a5d0f34a6690f0629f24dec517f829b1baab97
d2fdf3171bf6558c88a9111096c6f353e92149c0
refs/heads/master
2016-09-07T10:37:53.505475
2014-07-23T17:22:58
2014-07-23T17:22:58
12,496,363
1
3
null
null
null
null
UTF-8
Java
false
false
2,850
java
package edu.northwestern.cbits.intellicare.slumbertime; import java.util.HashMap; import android.app.TimePickerDialog; import android.app.TimePickerDialog.OnTimeSetListener; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.text.format.DateFormat; import android.widget.TimePicker; import edu.northwestern.cbits.intellicare.ConsentedActivity; import edu.northwestern.cbits.intellicare.logging.LogManager; public class SettingsActivity extends PreferenceActivity { @SuppressWarnings("deprecation") public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setTitle(R.string.title_settings); this.addPreferencesFromResource(R.layout.activity_settings); } public void onResume() { super.onResume(); HashMap<String, Object> payload = new HashMap<String, Object>(); LogManager.getInstance(this).log("opened_settings", payload); } public void onPause() { HashMap<String, Object> payload = new HashMap<String, Object>(); LogManager.getInstance(this).log("closed_settings", payload); super.onPause(); } @SuppressWarnings("deprecation") public boolean onPreferenceTreeClick (PreferenceScreen screen, Preference preference) { String key = preference.getKey(); if (key == null) { } else if (key.equals("settings_reminder_time")) { final SettingsActivity me = this; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); TimePickerDialog dialog = new TimePickerDialog(this, new OnTimeSetListener() { public void onTimeSet(TimePicker arg0, int hour, int minute) { Editor editor = prefs.edit(); editor.putInt(AlarmService.REMINDER_HOUR, hour); editor.putInt(AlarmService.REMINDER_MINUTE, minute); editor.commit(); HashMap<String, Object> payload = new HashMap<String, Object>(); payload.put("hour", hour); payload.put("minute", minute); payload.put("source", "settings"); payload.put("full_mode", prefs.getBoolean("settings_full_mode", true)); LogManager.getInstance(me).log("set_reminder_time", payload); } }, prefs.getInt(AlarmService.REMINDER_HOUR, 9), prefs.getInt(AlarmService.REMINDER_MINUTE, 0), DateFormat.is24HourFormat(this)); dialog.show(); return true; } else if (key.equals("copyright_statement")) ConsentedActivity.showCopyrightDialog(this); return super.onPreferenceTreeClick(screen, preference); } }
[ "github@audacious-software.com" ]
github@audacious-software.com
42ea77e41c4f311dd84c2d6c8e721e2460485c4b
18cbd04c5e84a478e3d809027864a0de39581c7a
/cloud-consumer-feign-order80/src/main/java/com/atguigu/springcloud/controller/OrderFeignController.java
2df19da110801c3d18cb265c67195ef59f860076
[]
no_license
guohangbk/2020springcloud-atguigu
f559436ac9cf0fd97becc42d810f20e7e9b7aac3
1d93ca35cac3e88ad439529f0babb585893bd148
refs/heads/master
2023-02-19T12:07:01.854905
2021-01-09T08:59:04
2021-01-09T08:59:04
328,108,864
0
0
null
null
null
null
UTF-8
Java
false
false
1,034
java
package com.atguigu.springcloud.controller; import com.atguigu.springcloud.entities.CommonResult; import com.atguigu.springcloud.entities.Payment; import com.atguigu.springcloud.service.PaymentFeignService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; /** * @Author guohang * @Description * @Date 2020/4/19 15:45 */ @RestController @Slf4j public class OrderFeignController { @Autowired private PaymentFeignService paymentFeignService; @GetMapping("/consumer/payment/get/{id}") public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){ return paymentFeignService.getPaymentById(id); } @GetMapping("/comsumer/payment/feign/timeout") public String paymentFeignTimeout(){ return paymentFeignService.paymentFeignTimeout(); } }
[ "guohangbk@163.com" ]
guohangbk@163.com
bc3217ccf5ff49b8de8ff99d7d0c15d192138b4e
a348e363cf746bd77c2e6a3e48b7f04ad2fae959
/src/PenTest.java
b117996c904369f31d5cf647a31e395b974b7460
[]
no_license
nik-rusak/qaacademy
00a9f68fba19b240d259aff55f33ad65a790bbc8
9b7a30f87c35804d81e927a03b5dcda7d38a0809
refs/heads/master
2021-01-10T06:27:37.891183
2015-11-25T07:28:29
2015-11-25T09:47:12
46,844,880
0
0
null
null
null
null
UTF-8
Java
false
false
4,214
java
import org.testng.Assert; import org.testng.annotations.Test; import static org.testng.Assert.*; /** * Created by n.rusak on 24.11.2015. */ public class PenTest { @Test public void testGetColorBlack() throws Exception { Assert.assertEquals(new Pen(1000,1,"BLACK").getColor(), "BLACK"); } @Test public void testGetColorBlue() throws Exception { Assert.assertEquals(new Pen(1000, 1, "BLUE").getColor(),"BLUE"); } @Test public void testGetColorNull() throws Exception { Assert.assertEquals(new Pen(1000, 1, "").getColor(), ""); } @Test public void testIsWorkPositive() throws Exception { assertTrue(new Pen(1000, 1, "GREEN").isWork()); } @Test public void testIsWorkNegative() throws Exception { assertFalse(new Pen(-1000, 1, "GREEN").isWork()); } @Test public void testIsWorkNull() throws Exception { assertFalse(new Pen(0, 1, "GREEN").isWork()); } @Test public void testWriteEmptyPen() throws Exception { Assert.assertEquals(new Pen(0, 1, "BLACK").write("Something"), ""); } @Test public void testWriteNull() throws Exception { Assert.assertEquals(new Pen(1000,1,"BLACK").write(""), ""); } @Test public void testWriteUsual() throws Exception { Assert.assertEquals(new Pen(200,1,"BLACK").write("Something"), "Something"); } @Test public void testWriteNotEnough() throws Exception { Assert.assertEquals(new Pen(2,1,"BLACK").write("Something"), "So"); } @Test public void testWriteNotEnoughBigLetters() throws Exception { Assert.assertEquals(new Pen(6,3,"BLACK").write("Something"), "So"); } @Test public void testWriteEnoughBigLetters() throws Exception { Assert.assertEquals(new Pen(1000,2,"BLACK").write("Something"), "Something"); } @Test public void testWriteNegativeInk() throws Exception { Assert.assertEquals(new Pen(-1,1,"BLACK").write("Something"), ""); } @Test public void testWriteNegativeSize() throws Exception { Assert.assertEquals(new Pen(10,-1,"BLACK").write("Something"), ""); } @Test public void testWriteNullSize() throws Exception { Assert.assertEquals(new Pen(10,0,"BLACK").write("Something"), ""); } @Test public void testWriteSecondWord() throws Exception { Pen pen = new Pen(100,1,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), "world"); } @Test public void testWriteSecondWordNotEnough() throws Exception { Pen pen = new Pen(6,1,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), "w"); } @Test public void testWriteSecondWordNotEnoughBigLetters() throws Exception { Pen pen = new Pen(12,2,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), "w"); } @Test public void testWriteSecondWordEmpty() throws Exception { Pen pen = new Pen(5,1,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), ""); } @Test public void testWriteSecondWordNegativeInk() throws Exception { Pen pen = new Pen(-1,1,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), ""); } @Test public void testWriteSecondWordNegativeSize() throws Exception { Pen pen = new Pen(1,-1,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), ""); } @Test public void testWriteSecondWordNullSize() throws Exception { Pen pen = new Pen(1,0,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), ""); } @Test public void testWriteSecondWordEnoughBigLetters() throws Exception { Pen pen = new Pen(20,2,"BLACK"); pen.write("Hello"); Assert.assertEquals(pen.write("world"), "world"); } @Test public void testWriteSecondWordEnoughSmallLetters() throws Exception { Pen pen = new Pen(1,0.2,"BLACK"); pen.write("Test"); Assert.assertEquals(pen.write("Test1"), "T"); } }
[ "allknown@yandex.ru" ]
allknown@yandex.ru
e4a9659db543a8e0e547694c15ded2ab5f3cc082
cc8d194313b9c99c86b62b421abe77bd329dba67
/test/cellsTest2.java
b7a76289a25ae310f1beb78616b1973ba4cc3269
[]
no_license
RogerTorra/SpreadsheetA
2e69c2ba9d7ca377b9b35b0a5975a0f9cb7f95bb
3a897522bb82be908dcc46d972828a22dba9af51
refs/heads/master
2021-01-19T06:32:51.308351
2014-05-01T16:23:12
2014-05-01T16:23:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
900
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. */ import spreadsheet.SomeValue; import org.junit.Test; import static org.junit.Assert.*; import org.junit.Before; import spreadsheet.Expression; import static spreadsheet.Spreadsheet.*; /** * * @author rtv1 */ public class cellsTest2 { @Before public void setup(){ //put("a3",plus(1.0,1.0)); put("a2",plus("a0","a1")); } @Test public void cell_has_no_value_if_depends_on_empty_cells(){ assertFalse(get("a2").hasValue()); } @Test public void value_test(){ put("a0",1.0); put("a1",1.0); //assertEquals(new SomeValue(2.0), get("a3")); assertEquals(new SomeValue(4.0), get("a2")); } public cellsTest2() { } }
[ "elrogertorra@gmail.com" ]
elrogertorra@gmail.com
231a73387fcb6d34959c2a9c371c33922ccb4263
cd6e8f2f067f69b17f1050f793ffdfe0906efafb
/MeuPrograma/src/meuprograma/MeuPrograma.java
dee25fde558743fe07f4292a7082688faf2e0857
[]
no_license
eudavidavi/Faculdade-UVA
65ceb69a8f9b4eea02559c19d47309f3eb5e0d30
13df7829dd4239e9700e4467bea1fcbe3ca08812
refs/heads/main
2023-03-18T11:22:03.738662
2021-03-06T23:46:09
2021-03-06T23:46:09
null
0
0
null
null
null
null
UTF-8
Java
false
false
825
java
package meuprograma; public class MeuPrograma { public static void main(String[] args) { Computador pc1 = new Computador(); Computador pc2 = new Computador(); Computador pc3 = new Computador("", "", 0, 0, false); Computador pc4 = new Computador("", "", 0, 0, false); System.out.println("Pc 1"); pc1.pegarDados(); System.out.println("Pc 2"); pc2.pegarDados(); System.out.println("Pc 3"); pc3.pegarDados(); System.out.println("Pc 4"); pc4.pegarDados(); System.out.println("Pc 1"); pc1.imprimir(); System.out.println("Pc 2"); pc2.imprimir(); System.out.println("Pc 3"); pc3.imprimir(); System.out.println("Pc 4"); pc4.imprimir(); } }
[ "54958760+monteirodavi@users.noreply.github.com" ]
54958760+monteirodavi@users.noreply.github.com
9fa5670b26eeb6f84762e3764d27d001cfda9586
75c4712ae3f946db0c9196ee8307748231487e4b
/src/main/java/com/alipay/api/response/AlipayCommerceDataResultSendResponse.java
285dc2a1043abda5d342f1efb77aab1f17b0ef35
[ "Apache-2.0" ]
permissive
yuanbaoMarvin/alipay-sdk-java-all
70a72a969f464d79c79d09af8b6b01fa177ac1be
25f3003d820dbd0b73739d8e32a6093468d9ed92
refs/heads/master
2023-06-03T16:54:25.138471
2021-06-25T14:48:21
2021-06-25T14:48:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
375
java
package com.alipay.api.response; import com.alipay.api.AlipayResponse; /** * ALIPAY API: alipay.commerce.data.result.send response. * * @author auto create * @since 1.0, 2019-01-07 20:51:15 */ public class AlipayCommerceDataResultSendResponse extends AlipayResponse { private static final long serialVersionUID = 7489223471598993392L; }
[ "ben.zy@antfin.com" ]
ben.zy@antfin.com
5456ae30aeb7d9ae8d7f5ea8767d0ca08ea81287
bddaae4327543483799fc6be3010e1f95f7b02cd
/src/main/java/com/hillel/bugtracker/BugTrackerApplication.java
eb61598bbfef5f181eb00fe13a1cf46815b1bdc2
[]
no_license
AbidSaleh/Spring-Boot-BugTracker
20acc0509f03b818d384ea21ac0d28d6a219a6a1
1d018c0f83c5f31e9526984e5298b3d36ec8b047
refs/heads/master
2022-04-09T20:50:19.430968
2020-03-18T07:50:59
2020-03-18T07:50:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
723
java
package com.hillel.bugtracker; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.transaction.annotation.EnableTransactionManagement; @SpringBootApplication @EnableTransactionManagement @EnableJpaRepositories @EnableAutoConfiguration public class BugTrackerApplication { public static void main(String[] args) { SpringApplication.run(BugTrackerApplication.class, args); } }
[ "alexzhuravlov13@gmail.com" ]
alexzhuravlov13@gmail.com
d6e3a95e31689869b7ab2e713b0975e3d9c5c442
fc7e53847869e06c99a2a844c78eeb71dabf2cad
/practise/src/_28_OverloadedConstructors/Pizza.java
3dfd3b62589f540dc967b5ca5e2a0eff7568ac08
[]
no_license
loquy/java-core
ca670eb6661ebeadb46bc82b802c58b5beb20d42
223ed928dd48e210f4071e52287b7b5b2b25246a
refs/heads/main
2023-08-05T02:30:14.243286
2021-09-19T02:35:02
2021-09-19T02:35:02
407,595,887
0
0
null
null
null
null
UTF-8
Java
false
false
480
java
package _28_OverloadedConstructors; public class Pizza { String bread; String sauce; String cheese; String topping; Pizza(String bread, String sauce, String cheese) { this.bread = bread; this.sauce = sauce; this.cheese = cheese; } Pizza(String bread, String sauce, String cheese, String topping) { this.bread = bread; this.sauce = sauce; this.cheese = cheese; this.topping = topping; } }
[ "laiqingyin@lwops.cn" ]
laiqingyin@lwops.cn
c866edb9f784f8856f4e3ed69a1c0563cb1e1380
5b9b654e77c1562a367254461c0b6e5933be31c5
/src/LeetCode226.java
9aef96f2a0eddbe7e5a33b7d4a92200be8181762
[]
no_license
sparkfengbo/LeetcodeSourceJava
865d7328899d09b5e1b7164edb2a6a91b4a48e4a
26b6e5f827822a18a0482623acb24fe363cd9374
refs/heads/master
2022-05-30T15:10:42.561864
2022-05-18T04:56:57
2022-05-18T04:56:57
146,726,852
0
0
null
null
null
null
UTF-8
Java
false
false
1,808
java
import datastruct.TreeNode; /** * 翻转二叉树 * * 翻转一棵二叉树。 * * 示例: * * 输入: * * 4 * / \ * 2 7 * / \ / \ * 1 3 6 9 * 输出: * * 4 * / \ * 7 2 * / \ / \ * 9 6 3 1 * 备注: * 这个问题是受到 Max Howell 的 原问题 启发的 : * * 谷歌:我们90%的工程师使用您编写的软件(Homebrew),但是您却无法在面试时在白板上写出翻转二叉树这道题,这太糟糕了。 */ public class LeetCode226 { public static void main(String[] args) { TreeNode root = new TreeNode(4); TreeNode node1 = new TreeNode(2); TreeNode node2 = new TreeNode(7); root.left = node1; root.right = node2; TreeNode node3 = new TreeNode(1); TreeNode node4 = new TreeNode(3); node1.left = node3; node1.right = node4; TreeNode node5 = new TreeNode(6); TreeNode node6 = new TreeNode(9); node2.left = node5; node2.right = node6; TreeNode result = invertTree(root); System.out.println(); } public static TreeNode invertTree(TreeNode root) { if (root == null) { return null; } if (root.left != null && root.right != null) { TreeNode tmp = root.left; root.left = root.right; root.right = tmp; invertTree(root.left); invertTree(root.right); } else if (root.left == null) { root.left = root.right; root.right = null; invertTree(root.left); } else if (root.right == null) { root.right = root.left; root.left = null; invertTree(root.right); } return root; } }
[ "fengbo04@baidu.com" ]
fengbo04@baidu.com
f4e8e0de5d8484dab93e1dc90ac6588c07e3c3da
beb2fbdd8e5343fe76c998824c7228a546884c5e
/com.kabam.marvelbattle/src/com/google/android/gms/tagmanager/cq.java
ed97f8eb36e5406b0013cad58b12427b609cd1c5
[]
no_license
alamom/mcoc_11.2.1_store_apk
4a988ab22d6c7ad0ca5740866045083ec396841b
b43c41d3e8a43f63863d710dad812774cd14ace0
refs/heads/master
2021-01-11T17:13:02.358134
2017-01-22T19:51:35
2017-01-22T19:51:35
79,740,812
0
0
null
null
null
null
UTF-8
Java
false
false
13,613
java
package com.google.android.gms.tagmanager; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import com.google.android.gms.internal.c.f; import com.google.android.gms.internal.ol.a; import com.google.android.gms.internal.pm; import com.google.android.gms.internal.pn; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.json.JSONException; class cq implements o.f { private final String aoc; private final ExecutorService aqA; private bg<ol.a> aqt; private final Context mContext; cq(Context paramContext, String paramString) { this.mContext = paramContext; this.aoc = paramString; this.aqA = Executors.newSingleThreadExecutor(); } private cr.c a(ByteArrayOutputStream paramByteArrayOutputStream) { Object localObject = null; try { paramByteArrayOutputStream = ba.cG(paramByteArrayOutputStream.toString("UTF-8")); return paramByteArrayOutputStream; } catch (UnsupportedEncodingException paramByteArrayOutputStream) { for (;;) { bh.S("Failed to convert binary resource to string for JSON parsing; the file format is not UTF-8 format."); paramByteArrayOutputStream = (ByteArrayOutputStream)localObject; } } catch (JSONException paramByteArrayOutputStream) { for (;;) { bh.W("Failed to extract the container from the resource file. Resource is a UTF-8 encoded string but doesn't contain a JSON container"); paramByteArrayOutputStream = (ByteArrayOutputStream)localObject; } } } private void d(ol.a parama) throws IllegalArgumentException { if ((parama.gs == null) && (parama.ass == null)) { throw new IllegalArgumentException("Resource and SupplementedResource are NULL."); } } private cr.c k(byte[] paramArrayOfByte) { try { cr.c localc = cr.b(c.f.a(paramArrayOfByte)); paramArrayOfByte = localc; if (localc != null) { bh.V("The container was successfully loaded from the resource (using binary file)"); paramArrayOfByte = localc; } } catch (pm paramArrayOfByte) { for (;;) { bh.T("The resource file is corrupted. The container cannot be extracted from the binary file"); paramArrayOfByte = null; } } catch (cr.g paramArrayOfByte) { for (;;) { bh.W("The resource file is invalid. The container from the binary file is invalid"); paramArrayOfByte = null; } } return paramArrayOfByte; } public void a(bg<ol.a> parambg) { this.aqt = parambg; } public void b(final ol.a parama) { this.aqA.execute(new Runnable() { public void run() { cq.this.c(parama); } }); } boolean c(ol.a parama) { boolean bool = false; localFile = oS(); try { FileOutputStream localFileOutputStream = new java/io/FileOutputStream; localFileOutputStream.<init>(localFile); try { localFileOutputStream.close(); throw parama; } catch (IOException localIOException) { for (;;) { bh.W("error closing stream for writing resource to disk"); } } } catch (FileNotFoundException parama) { for (;;) { try { localFileOutputStream.write(pn.f(parama)); bool = true; } catch (IOException parama) { parama = parama; bh.W("Error writing resource to disk. Removing resource from disk."); localFile.delete(); try { localFileOutputStream.close(); } catch (IOException parama) { bh.W("error closing stream for writing resource to disk"); } continue; } finally {} try { localFileOutputStream.close(); return bool; parama = parama; bh.T("Error opening resource file for writing"); } catch (IOException parama) { bh.W("error closing stream for writing resource to disk"); } } } } public cr.c ff(int paramInt) { for (;;) { try { localObject1 = this.mContext.getResources().openRawResource(paramInt); bh.V("Attempting to load a container from the resource ID " + paramInt + " (" + this.mContext.getResources().getResourceName(paramInt) + ")"); } catch (Resources.NotFoundException localNotFoundException) { Object localObject1; ByteArrayOutputStream localByteArrayOutputStream; bh.W("Failed to load the container. No default container resource found with the resource ID " + paramInt); cr.c localc = null; continue; localc = k(localByteArrayOutputStream.toByteArray()); continue; } try { localByteArrayOutputStream = new java/io/ByteArrayOutputStream; localByteArrayOutputStream.<init>(); cr.b((InputStream)localObject1, localByteArrayOutputStream); localObject1 = a(localByteArrayOutputStream); if (localObject1 == null) { continue; } bh.V("The container was successfully loaded from the resource (using JSON file format)"); } catch (IOException localIOException) { bh.W("Error reading the default container with resource ID " + paramInt + " (" + this.mContext.getResources().getResourceName(paramInt) + ")"); Object localObject2 = null; } } return (cr.c)localObject1; } /* Error */ void oR() { // Byte code: // 0: aload_0 // 1: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 4: ifnonnull +13 -> 17 // 7: new 232 java/lang/IllegalStateException // 10: dup // 11: ldc -22 // 13: invokespecial 235 java/lang/IllegalStateException:<init> (Ljava/lang/String;)V // 16: athrow // 17: aload_0 // 18: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 21: invokeinterface 240 1 0 // 26: ldc -14 // 28: invokestatic 111 com/google/android/gms/tagmanager/bh:V (Ljava/lang/String;)V // 31: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce; // 34: invokevirtual 252 com/google/android/gms/tagmanager/ce:oK ()Lcom/google/android/gms/tagmanager/ce$a; // 37: getstatic 258 com/google/android/gms/tagmanager/ce$a:aqi Lcom/google/android/gms/tagmanager/ce$a; // 40: if_acmpeq +15 -> 55 // 43: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce; // 46: invokevirtual 252 com/google/android/gms/tagmanager/ce:oK ()Lcom/google/android/gms/tagmanager/ce$a; // 49: getstatic 261 com/google/android/gms/tagmanager/ce$a:aqj Lcom/google/android/gms/tagmanager/ce$a; // 52: if_acmpne +32 -> 84 // 55: aload_0 // 56: getfield 28 com/google/android/gms/tagmanager/cq:aoc Ljava/lang/String; // 59: invokestatic 248 com/google/android/gms/tagmanager/ce:oJ ()Lcom/google/android/gms/tagmanager/ce; // 62: invokevirtual 264 com/google/android/gms/tagmanager/ce:getContainerId ()Ljava/lang/String; // 65: invokevirtual 270 java/lang/String:equals (Ljava/lang/Object;)Z // 68: ifeq +16 -> 84 // 71: aload_0 // 72: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 75: getstatic 276 com/google/android/gms/tagmanager/bg$a:apM Lcom/google/android/gms/tagmanager/bg$a; // 78: invokeinterface 279 2 0 // 83: return // 84: new 281 java/io/FileInputStream // 87: astore_1 // 88: aload_1 // 89: aload_0 // 90: invokevirtual 142 com/google/android/gms/tagmanager/cq:oS ()Ljava/io/File; // 93: invokespecial 282 java/io/FileInputStream:<init> (Ljava/io/File;)V // 96: new 47 java/io/ByteArrayOutputStream // 99: astore_2 // 100: aload_2 // 101: invokespecial 212 java/io/ByteArrayOutputStream:<init> ()V // 104: aload_1 // 105: aload_2 // 106: invokestatic 215 com/google/android/gms/tagmanager/cr:b (Ljava/io/InputStream;Ljava/io/OutputStream;)V // 109: aload_2 // 110: invokevirtual 225 java/io/ByteArrayOutputStream:toByteArray ()[B // 113: invokestatic 286 com/google/android/gms/internal/ol$a:l ([B)Lcom/google/android/gms/internal/ol$a; // 116: astore_2 // 117: aload_0 // 118: aload_2 // 119: invokespecial 288 com/google/android/gms/tagmanager/cq:d (Lcom/google/android/gms/internal/ol$a;)V // 122: aload_0 // 123: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 126: aload_2 // 127: invokeinterface 291 2 0 // 132: aload_1 // 133: invokevirtual 292 java/io/FileInputStream:close ()V // 136: ldc_w 294 // 139: invokestatic 111 com/google/android/gms/tagmanager/bh:V (Ljava/lang/String;)V // 142: goto -59 -> 83 // 145: astore_1 // 146: ldc_w 296 // 149: invokestatic 65 com/google/android/gms/tagmanager/bh:S (Ljava/lang/String;)V // 152: aload_0 // 153: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 156: getstatic 276 com/google/android/gms/tagmanager/bg$a:apM Lcom/google/android/gms/tagmanager/bg$a; // 159: invokeinterface 279 2 0 // 164: goto -81 -> 83 // 167: astore_1 // 168: ldc_w 298 // 171: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 174: goto -38 -> 136 // 177: astore_2 // 178: aload_0 // 179: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 182: getstatic 301 com/google/android/gms/tagmanager/bg$a:apN Lcom/google/android/gms/tagmanager/bg$a; // 185: invokeinterface 279 2 0 // 190: ldc_w 303 // 193: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 196: aload_1 // 197: invokevirtual 292 java/io/FileInputStream:close ()V // 200: goto -64 -> 136 // 203: astore_1 // 204: ldc_w 298 // 207: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 210: goto -74 -> 136 // 213: astore_2 // 214: aload_0 // 215: getfield 121 com/google/android/gms/tagmanager/cq:aqt Lcom/google/android/gms/tagmanager/bg; // 218: getstatic 301 com/google/android/gms/tagmanager/bg$a:apN Lcom/google/android/gms/tagmanager/bg$a; // 221: invokeinterface 279 2 0 // 226: ldc_w 305 // 229: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 232: aload_1 // 233: invokevirtual 292 java/io/FileInputStream:close ()V // 236: goto -100 -> 136 // 239: astore_1 // 240: ldc_w 298 // 243: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 246: goto -110 -> 136 // 249: astore_2 // 250: aload_1 // 251: invokevirtual 292 java/io/FileInputStream:close ()V // 254: aload_2 // 255: athrow // 256: astore_1 // 257: ldc_w 298 // 260: invokestatic 70 com/google/android/gms/tagmanager/bh:W (Ljava/lang/String;)V // 263: goto -9 -> 254 // Local variable table: // start length slot name signature // 0 266 0 this cq // 87 46 1 localFileInputStream java.io.FileInputStream // 145 1 1 localFileNotFoundException FileNotFoundException // 167 30 1 localIOException1 IOException // 203 30 1 localIOException2 IOException // 239 12 1 localIOException3 IOException // 256 1 1 localIOException4 IOException // 99 28 2 localObject1 Object // 177 1 2 localIOException5 IOException // 213 1 2 localIllegalArgumentException IllegalArgumentException // 249 6 2 localObject2 Object // Exception table: // from to target type // 84 96 145 java/io/FileNotFoundException // 132 136 167 java/io/IOException // 96 132 177 java/io/IOException // 196 200 203 java/io/IOException // 96 132 213 java/lang/IllegalArgumentException // 232 236 239 java/io/IOException // 96 132 249 finally // 178 196 249 finally // 214 232 249 finally // 250 254 256 java/io/IOException } File oS() { String str = "resource_" + this.aoc; return new File(this.mContext.getDir("google_tagmanager", 0), str); } public void oc() { this.aqA.execute(new Runnable() { public void run() { cq.this.oR(); } }); } public void release() { try { this.aqA.shutdown(); return; } finally { localObject = finally; throw ((Throwable)localObject); } } } /* Location: C:\tools\androidhack\com.kabam.marvelbattle\classes.jar!\com\google\android\gms\tagmanager\cq.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
[ "eduard.martini@gmail.com" ]
eduard.martini@gmail.com
4571be5a5e34e2c787c9e6987df2856f106746f2
b5cc497b581f0775dedde5ebd5ed2a7c82d17c5b
/src/main/java/com/cctv/peoplay/admin/goods/model/dto/GoodsCategoryDTO.java
de7a674640eae2c5921920af4e7a3b6f21557a8d
[]
no_license
clzlckzkch1509/peoPlay
dd131b482adbf5f560b0c06d9f37287ecae2ce8f
6d2131bb1167d502d7375428aa5f19fdaaf12bf1
refs/heads/master
2023-06-07T01:07:19.592413
2021-07-06T02:31:37
2021-07-06T02:31:37
373,686,005
0
0
null
null
null
null
UTF-8
Java
false
false
896
java
package com.cctv.peoplay.admin.goods.model.dto; public class GoodsCategoryDTO { private int goodsCategoryNum; private String goodsCategoryName; public int getGoodsCategoryNum() { return goodsCategoryNum; } public void setGoodsCategoryNum(int goodsCategoryNum) { this.goodsCategoryNum = goodsCategoryNum; } public String getGoodsCategoryName() { return goodsCategoryName; } public void setGoodsCategoryName(String goodsCategoryName) { this.goodsCategoryName = goodsCategoryName; } @Override public String toString() { return "GoodsCategoryDTO [goodsCategoryNum=" + goodsCategoryNum + ", goodsCategoryName=" + goodsCategoryName + "]"; } public GoodsCategoryDTO() { } public GoodsCategoryDTO(int goodsCategoryNum, String goodsCategoryName) { this.goodsCategoryNum = goodsCategoryNum; this.goodsCategoryName = goodsCategoryName; } }
[ "dongr52@naver.com" ]
dongr52@naver.com
31328daeed2a80ef49a2cc984553be82669ed508
5a66b6809a3cddced0e84b56a8cf3a612a78989f
/TestNg_DataDriven_Framework/src/main/java/User_Login/Login.java
2b13dc0ab0daa96d0671e4fbe3f977289f982ba8
[]
no_license
Vampire010/DDF
338d3252f9c1dd7131f0ef80ea67ba337594217b
c0b395a58c8f9f7f070c64b07f40fa27b71c547a
refs/heads/master
2023-08-25T01:45:14.147783
2021-10-22T16:15:34
2021-10-22T16:15:34
419,163,600
0
0
null
null
null
null
UTF-8
Java
false
false
700
java
package User_Login; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import Browser_Configuration.Launch_Browsers; import Browser_Configuration.Page_Assertions; public class Login extends Launch_Browsers { public void login_page(String Username , String Password) { WebElement Usrname = driver.findElement(By.id("username")); Usrname.sendKeys(Username); WebElement Usrpassword = driver.findElement(By.id("password")); Usrpassword.sendKeys(Password); WebElement Location_session = driver.findElement(By.id("Registration Desk")); Location_session.click(); WebElement Lobin_btn = driver.findElement(By.id("loginButton")); Lobin_btn.click(); } }
[ "44545166+Vampire010@users.noreply.github.com" ]
44545166+Vampire010@users.noreply.github.com
fc59cb6bf35c06dee0fc33052d21faa7cced88f5
b653c6d0bbe1094a65474aa0524226808cf39184
/src/main/java/com/dotaciones/service/model/Dispositivo.java
32fe8bb53393a85f9eff246e9a10fffbb9a60103
[]
no_license
nikodius/ApiRestDotaciones
388b7d8d312c2d7f0f01c4e96d82637cbe70db92
61db87ca2662070e1a8285a99a2f051b3fb1ea70
refs/heads/main
2023-07-23T18:26:10.827546
2021-08-24T16:43:32
2021-08-24T16:43:32
399,537,125
0
0
null
null
null
null
UTF-8
Java
false
false
1,853
java
package com.dotaciones.service.model; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import javax.persistence.Table; @Entity @Table(name = "dispositivos") public class Dispositivo { @Id private String serial; @Column(name = "nombre") private String nombre; @Column(name = "so") private String so; @OneToOne(mappedBy = "dispositivo", cascade = CascadeType.ALL) private Asignacion asignacion; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "fk_tipo") private TipoDispositivo tipoDispositivo; @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "fk_propietario") private Propietario propietario; public Dispositivo(String serial, String nombre, TipoDispositivo tipoDispositivo, Propietario propietario) { super(); this.serial = serial; this.nombre = nombre; this.tipoDispositivo = tipoDispositivo; this.propietario = propietario; } public Dispositivo() { super(); } public String getSerial() { return serial; } public void setSerial(String serial) { this.serial = serial; } public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public Asignacion getAsignacion() { return asignacion; } public void setAsignacion(Asignacion asignacion) { this.asignacion = asignacion; } public TipoDispositivo getTipoDispositivo() { return tipoDispositivo; } public void setTipoDispositivo(TipoDispositivo tipoDispositivo) { this.tipoDispositivo = tipoDispositivo; } public Propietario getPropietario() { return propietario; } public void setPropietario(Propietario propietario) { this.propietario = propietario; } }
[ "nicolasrg2502@gmail.com" ]
nicolasrg2502@gmail.com
9783b4e457067d5be9f67759313083927966790b
7a75c899fc8eaf97d195f8e05063d5f835bcf893
/src/test/java/com/example/demo/LjhApplicationTests.java
b105e75dbdafdb852d1d9c5b964841d4fcb53ade
[]
no_license
silverljh/ljhdemo
13f1c90840824c7fb8c6a5c9442fd5e368804c2f
935b7b8c788fcf63a88c38f5ed346d7602cecbeb
refs/heads/master
2021-05-23T10:23:33.741985
2020-04-05T13:29:11
2020-04-05T13:29:11
253,241,656
0
0
null
null
null
null
UTF-8
Java
false
false
214
java
package com.example.demo; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class LjhApplicationTests { @Test void contextLoads() { } }
[ "1056200293@qq.com" ]
1056200293@qq.com
9a242bfa9af3086363d0ee99bebbfb5d52c35058
6fdb33408e81beb11cdcbd5db20c3bd0d1fb44c2
/Lesson2/Lab3/Task1to4/app/src/main/java/com/kat2n/practice_android/lesson2/lab3/task1to4/MainActivity.java
9ab5a5c08a3ab23c69c2fe925f8bb06f4ed523b5
[]
no_license
daisu8e/practice-android
f2b8e0a99598645434bc137bdb4db71ff2bcb6dc
5e29532a6a39f93a7df173d0f19d43295f724371
refs/heads/master
2020-04-09T21:08:13.482022
2019-06-19T05:45:55
2019-06-19T05:45:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,887
java
package com.kat2n.practice_android.lesson2.lab3.task1to4; import android.content.Intent; import android.net.Uri; import android.support.v4.app.ShareCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; public class MainActivity extends AppCompatActivity { private EditText mWebsiteEditText; private EditText mLocationEditText; private EditText mShareTextEditText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebsiteEditText = findViewById(R.id.website_edittext); mLocationEditText = findViewById(R.id.location_edittext); mShareTextEditText = findViewById(R.id.share_edittext); } public void openWebsite(View view) { String url = mWebsiteEditText.getText().toString(); Uri webpage = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, webpage); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d("ImplicitIntents", "Can't handle this!"); } } public void openLocation(View view) { String loc = mLocationEditText.getText().toString(); Uri addressUri = Uri.parse("geo:0,0?q=" + loc); Intent intent = new Intent(Intent.ACTION_VIEW, addressUri); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Log.d("ImplicitIntents", "Can't handle this intent!"); } } public void shareText(View view) { String txt = mShareTextEditText.getText().toString(); String mimeType = "text/plain"; ShareCompat.IntentBuilder .from(this) .setType(mimeType) .setChooserTitle("Share this text with: ") .setText(txt) .startChooser(); } }
[ "katsumata.coffee.150yen@gmail.com" ]
katsumata.coffee.150yen@gmail.com
cb80c6332140df7e2489b94e7573c99979d96cff
3ec81e2880f7abb468de5a9b832ee495242678d2
/app/src/androidTest/java/com/example/invoicetextdetector/ExampleInstrumentedTest.java
86d2a2264b4820d52498a16f1d6235ab69b877f5
[]
no_license
NEETI9952/TextRecognizer
6ae3ee792acbdfebf159640b050162c86583ab9f
afd85bee379861aa3b099526fbdf00ab7a587993
refs/heads/master
2023-03-16T18:46:25.649993
2021-03-06T07:27:41
2021-03-06T07:27:41
343,415,715
0
0
null
null
null
null
UTF-8
Java
false
false
776
java
package com.example.invoicetextdetector; import android.content.Context; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.example.invoicetextdetector", appContext.getPackageName()); } }
[ "neetibisht919@gmail.com" ]
neetibisht919@gmail.com
1438bb67d7ebb5c8cb161f4f2659912dd2137169
544861597d2e8bb8eae50e411e0bbda47543a4ae
/app/src/main/java/cn/mark/frame/ui/fragment/ImageFragment.java
df21cdb89fe7d9017b94d9cc1f3b701279f6be61
[]
no_license
ahkkfh/MyFrame
0a199d351b46470fac0f9498cb431c1f02c9b7cd
f20b4dea833c3468fb6e9bcdb78c2653d6a0d510
refs/heads/master
2021-01-21T14:44:35.228065
2017-09-01T05:46:46
2017-09-01T05:46:46
59,712,251
5
2
null
2017-06-16T02:52:30
2016-05-26T02:11:06
Java
UTF-8
Java
false
false
627
java
package cn.mark.frame.ui.fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import cn.mark.frame.R; /*** * @author marks.luo * @Description: TODO() * @date:2017-04-07 14:06 */ public class ImageFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_image,container,false); } }
[ "995250016@qq.com" ]
995250016@qq.com
1384ceb1ba965cc48d9cccf110148c67be915264
c178a5e7564f53f9aa5fa0376c8e32f3d8563fb9
/src/com/duanxr/yith/midium/MaximizeDistanceToClosestPerson.java
4fcd81e664d03b8842fae974ce0d254f68538360
[]
no_license
duanxr/Great-Algorithm-of-Yith
d775283648809a6f15bf4d7fa2f28c31551f0779
76110f9ce8e914f8deae8c18eba1cbf00b0d6e8a
refs/heads/master
2021-12-01T10:20:29.155610
2021-11-23T02:56:24
2021-11-23T02:56:24
165,953,707
0
2
null
null
null
null
UTF-8
Java
false
false
3,582
java
package com.duanxr.yith.midium; /** * @author 段然 2021/3/8 */ public class MaximizeDistanceToClosestPerson { /** * You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed). * * There is at least one empty seat, and at least one person sitting. * * Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.  * * Return that maximum distance to the closest person. * *   * * Example 1: * * * Input: seats = [1,0,0,0,1,0,1] * Output: 2 * Explanation: * If Alex sits in the second open seat (i.e. seats[2]), then the closest person has distance 2. * If Alex sits in any other open seat, the closest person has distance 1. * Thus, the maximum distance to the closest person is 2. * Example 2: * * Input: seats = [1,0,0,0] * Output: 3 * Explanation: * If Alex sits in the last seat (i.e. seats[3]), the closest person is 3 seats away. * This is the maximum distance possible, so the answer is 3. * Example 3: * * Input: seats = [0,1] * Output: 1 *   * * Constraints: * * 2 <= seats.length <= 2 * 104 * seats[i] is 0 or 1. * At least one seat is empty. * At least one seat is occupied. * * 给你一个数组 seats 表示一排座位,其中 seats[i] = 1 代表有人坐在第 i 个座位上,seats[i] = 0 代表座位 i 上是空的(下标从 0 开始)。 * * 至少有一个空座位,且至少有一人已经坐在座位上。 * * 亚历克斯希望坐在一个能够使他与离他最近的人之间的距离达到最大化的座位上。 * * 返回他到离他最近的人的最大距离。 * *   * * 示例 1: * * * 输入:seats = [1,0,0,0,1,0,1] * 输出:2 * 解释: * 如果亚历克斯坐在第二个空位(seats[2])上,他到离他最近的人的距离为 2 。 * 如果亚历克斯坐在其它任何一个空位上,他到离他最近的人的距离为 1 。 * 因此,他到离他最近的人的最大距离是 2 。 * 示例 2: * * 输入:seats = [1,0,0,0] * 输出:3 * 解释: * 如果亚历克斯坐在最后一个座位上,他离最近的人有 3 个座位远。 * 这是可能的最大距离,所以答案是 3 。 * 示例 3: * * 输入:seats = [0,1] * 输出:1 *   * * 提示: * * 2 <= seats.length <= 2 * 104 * seats[i] 为 0 或 1 * 至少有一个 空座位 * 至少有一个 座位上有人 * */ class Solution { public int maxDistToClosest(int[] seats) { return Math.max(Math.max(lDis(seats), mDis(seats)), rDis(seats)); } private int mDis(int[] seats) { int count = 0; int max = Integer.MIN_VALUE; for (int seat : seats) { if (seat == 0) { count++; } else { if (count > max) { max = count; } count = 0; } } return (max + 1) / 2; } private int lDis(int[] seats) { int count = 0; for (int seat : seats) { if (seat != 0) { return count; } count++; } return count; } private int rDis(int[] seats) { int count = 0; for (int i = seats.length - 1; i >= 0; i--) { if (seats[i] != 0) { return count; } count++; } return count; } } }
[ "admin@duanxr.com" ]
admin@duanxr.com
9fae828c0a42d665c103bff3c807572bfe046594
5598faaaaa6b3d1d8502cbdaca903f9037d99600
/code_changes/Apache_projects/HDFS-142/f0d8a5db10a28484ad3fcd66601475ebceee3c84/TestNameNodeMXBean.java
ec52d558b3e028e6aa7171cfcb81b294d1b17b93
[]
no_license
SPEAR-SE/LogInBugReportsEmpirical_Data
94d1178346b4624ebe90cf515702fac86f8e2672
ab9603c66899b48b0b86bdf63ae7f7a604212b29
refs/heads/master
2022-12-18T02:07:18.084659
2020-09-09T16:49:34
2020-09-09T16:49:34
286,338,252
0
2
null
null
null
null
UTF-8
Java
false
false
3,894
java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.hdfs.server.namenode; import java.lang.management.ManagementFactory; import javax.management.MBeanServer; import javax.management.ObjectName; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.server.namenode.FSNamesystem; import org.junit.Test; import junit.framework.Assert; /** * Class for testing {@link NameNodeMXBean} implementation */ public class TestNameNodeMXBean { @Test public void testNameNodeMXBeanInfo() throws Exception { Configuration conf = new Configuration(); MiniDFSCluster cluster = null; try { cluster = new MiniDFSCluster(conf, 1, true, null); cluster.waitActive(); FSNamesystem fsn = cluster.getNameNode().namesystem; MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName("HadoopInfo:type=NameNodeInfo"); // get attribute "ClusterId" String clusterId = (String) mbs.getAttribute(mxbeanName, "ClusterId"); Assert.assertEquals(fsn.getClusterId(), clusterId); // get attribute "BlockpoolId" String blockpoolId = (String) mbs.getAttribute(mxbeanName, "BlockpoolId"); Assert.assertEquals(fsn.getBlockpoolId(), blockpoolId); // get attribute "Version" String version = (String) mbs.getAttribute(mxbeanName, "Version"); Assert.assertEquals(fsn.getVersion(), version); // get attribute "Used" Long used = (Long) mbs.getAttribute(mxbeanName, "Used"); Assert.assertEquals(fsn.getUsed(), used.longValue()); // get attribute "Total" Long total = (Long) mbs.getAttribute(mxbeanName, "Total"); Assert.assertEquals(fsn.getTotal(), total.longValue()); // get attribute "safemode" String safemode = (String) mbs.getAttribute(mxbeanName, "Safemode"); Assert.assertEquals(fsn.getSafemode(), safemode); // get attribute nondfs Long nondfs = (Long) (mbs.getAttribute(mxbeanName, "NonDfsUsedSpace")); Assert.assertEquals(fsn.getNonDfsUsedSpace(), nondfs.longValue()); // get attribute percentremaining Float percentremaining = (Float) (mbs.getAttribute(mxbeanName, "PercentRemaining")); Assert.assertEquals(fsn.getPercentRemaining(), percentremaining .floatValue()); // get attribute Totalblocks Long totalblocks = (Long) (mbs.getAttribute(mxbeanName, "TotalBlocks")); Assert.assertEquals(fsn.getTotalBlocks(), totalblocks.longValue()); // get attribute alivenodeinfo String alivenodeinfo = (String) (mbs.getAttribute(mxbeanName, "LiveNodes")); Assert.assertEquals(fsn.getLiveNodes(), alivenodeinfo); // get attribute deadnodeinfo String deadnodeinfo = (String) (mbs.getAttribute(mxbeanName, "DeadNodes")); Assert.assertEquals(fsn.getDeadNodes(), deadnodeinfo); } finally { if (cluster != null) { cluster.shutdown(); } } } }
[ "archen94@gmail.com" ]
archen94@gmail.com
1b0dbfa649579987a04bed2487f987f0f01884c4
b7bfc55d03983231e13737cc7ab53909172fa95f
/86.分隔链表.java
b87896c6ee23d9e5dbe7502860ad995f90d9a186
[]
no_license
tunye/leetcode
5d7dc6c943cc1ee0dd561469f8656f07baabe336
bdb9c06b31f742494238b5408f49b71e96c25306
refs/heads/master
2022-11-22T13:17:36.427866
2020-07-27T05:54:14
2020-07-27T05:54:14
279,529,083
1
0
null
null
null
null
UTF-8
Java
false
false
1,824
java
// https://leetcode-cn.com/problems/partition-list public class Solution { public static class ListNode { int val; ListNode next; ListNode(int x) { val = x; } } public ListNode partition(ListNode head, int x) { ListNode small = new ListNode(-1); ListNode smallList = small; ListNode big = new ListNode(-1); ListNode bigList = big; while (head != null) { if (head.val < x) { smallList.next = head; smallList = smallList.next; } else { bigList.next = head; bigList = bigList.next; } head = head.next; } bigList.next = null; smallList.next = big.next; return small.next; } private void toString(ListNode listNode, StringBuilder stringBuilder) { stringBuilder.append(listNode.val); if (listNode.next != null) { stringBuilder.append(" -> "); toString(listNode.next, stringBuilder); } } public static void main(String[] args) { Solution solution = new Solution(); ListNode param = new ListNode(-1); ListNode tmp = param; tmp.next = new ListNode(9); tmp = tmp.next; tmp.next = new ListNode(3); tmp = tmp.next; tmp.next = new ListNode(4); tmp = tmp.next; tmp.next = new ListNode(1); tmp = tmp.next; tmp.next = new ListNode(15); tmp = tmp.next; tmp.next = new ListNode(7); ListNode result = solution.partition(param.next, 6); StringBuilder resultString = new StringBuilder(); solution.toString(result, resultString); System.err.println("result " + resultString.toString()); } }
[ "chentong1@staff.weibo.com" ]
chentong1@staff.weibo.com
001fe34b688e35fd2aa8eb4a064373aeb3455ad6
bc98d806362fe82f5a235134bbde911e517a29fe
/src/grapher/ui/Main.java
de2b9a8f1ca66542216289ee74bed48c4eb24055
[]
no_license
monthebrice2000/ihm
9dcdd650a8f3f4375ce539d2019374af49613d6f
5e4c2c73aabafb0403ab97c36879c1d546dbc6ed
refs/heads/main
2023-08-31T09:12:06.661372
2021-10-25T14:37:44
2021-10-25T14:37:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,428
java
/* grapher.ui.Main * (c) blanch@imag.fr 2021– */ package grapher.ui; import grapher.fc.Function; import grapher.fc.FunctionFactory; import javax.swing.*; import javax.swing.JSplitPane; import javax.swing.border.Border; import javax.swing.event.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.Arrays; // main that launch a grapher.ui.Grapher public class Main extends JFrame { Main(String title, String[] expressions) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); Grapher grapher = new Grapher(); String[] ex = {"sin(x)", "cos(x)", "tan(x)"}; for(String expression: ex) { grapher.add(expression); } Interaction i = new Interaction( grapher ); grapher.addMouseListener( i ); grapher.addMouseMotionListener( i ); add(grapher); javax.swing.JSplitPane splitPane = new javax.swing.JSplitPane( javax.swing.JSplitPane.HORIZONTAL_SPLIT ); DefaultListModel<String> model = new DefaultListModel<>(); JList<String> myList = new JList<String>( model ); model.addAll(Arrays.asList(ex)); splitPane.setRightComponent( grapher ); JButton button1 = new JButton("+"); JButton button2 = new JButton("-"); JPanel panel = new JPanel(); JPanel buttonsPanel = new JPanel(); splitPane.setLeftComponent( panel ); panel.setLayout( new GridLayout( 2,1)); panel.add( myList); panel.add( buttonsPanel ); buttonsPanel.setLayout( new GridLayout(1,2)); buttonsPanel.add( button1 ); buttonsPanel.add( button2 ); splitPane.setDividerSize( 10 ); splitPane.setDividerLocation( 100 ); splitPane.setOneTouchExpandable( true ); splitPane.addMouseListener( i ); add( splitPane ); myList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if( myList.getSelectionModel().getMinSelectionIndex( ) >= 0 ){ System.out.println( "+++++"+model.get( myList.getSelectionModel().getMinSelectionIndex() ) ); String selectedItem = myList.getSelectedValue().toString(); Function f = FunctionFactory.createFunction( selectedItem ); grapher.setSelectedFunctions( f ); } } } }); //ToolbarClass toolbar = new ToolbarClass(); //toolbar.createAndShowGUI(); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); if( action.equals( "+" ) ){ System.out.println( "J'ajoute une fonction"); } } }); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); ListSelectionModel selmodel = myList.getSelectionModel(); int index = selmodel.getMinSelectionIndex(); if (index >= 0) System.out.println( index ); System.out.println( model ); model.removeElementAt( index ); grapher.removeFunctionByClicked(); myList.setSelectedIndex( model.getSize() - 1 ); } }); pack(); } public static void main(String[] argv) { final String[] expressions = argv; SwingUtilities.invokeLater(new Runnable() { public void run() { new Main("grapher", expressions).setVisible(true); } }); } }
[ "monthedjeumoubrice2000@gmail.com" ]
monthedjeumoubrice2000@gmail.com
a31574fdefec824ca42c05a5db326fa2954982e3
16da1aec4387b149d77d26e15d8dde9d1f1bb0a5
/src/main/java/com/karthikbashetty/leetcodepractice/MaximumDepthofBinaryTree.java
33b92705581a8195ffd5de03c1b7a2bd741d7bb3
[]
no_license
krats/leetcodepractice
ee93c549fa8027602e5c87262e2c4d66ccef38c2
68086281de4de9e23355d72ffe3f7dfd26f33bc0
refs/heads/master
2020-03-15T19:31:17.092626
2018-05-13T05:34:40
2018-05-13T05:34:40
132,310,804
0
0
null
null
null
null
UTF-8
Java
false
false
1,153
java
package com.karthikbashetty.leetcodepractice; import java.util.Stack; public class MaximumDepthofBinaryTree { public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } public int maxDepthRecursive(TreeNode root) { if(root == null) { return 0; } else return Math.max(maxDepthRecursive(root.left), maxDepthRecursive(root.right)) + 1; } public int maxDepth(TreeNode root) { if(root == null) { return 0; } int ans = 0; Stack<TreeNode> stack = new Stack<TreeNode>(); stack.push(root); while (stack.size() != 0) { Stack<TreeNode> newStack = new Stack<TreeNode>(); ans += 1; while (stack.size() != 0) { TreeNode current = stack.pop(); if(current.left != null) newStack.push(current.left); if(current.right != null) newStack.push(current.right); } stack = newStack; } return ans; } }
[ "karthiksathy@gmail.com" ]
karthiksathy@gmail.com