blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1802b7b2619561c5e308835628ae6024c0f030dc | 4ecca46e3221b29c28fddaf2b71cecdcdbfe6bb1 | /src/main/java/com/liquor/offer/no61to68/No63.java | c2aecbf210630d794ccfbb389cad668f4638b9a3 | [] | no_license | xiaowen1993/JianZhiOffer | 8430aa8d30dbf9821483b83932f58dd5b906715c | a1fbe096e07a30658d294190153a007333ae248f | refs/heads/master | 2022-04-23T05:01:00.688548 | 2020-03-24T14:46:08 | 2020-03-24T14:46:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,265 | java | package com.liquor.offer.no61to68;
/**
* 给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4。
*
* 做这道题,只需要记住一句话, 二叉搜索树的中序遍历顺序就是从小到大的排序顺序x`
*
*
* @author zzc on 2020.1.31
*/
public class No63 {
int index = 0;
TreeNode KthNode(TreeNode pRoot, int k) {
if (pRoot!=null){
//先找到最左侧,也就是最小的节点
TreeNode node = KthNode(pRoot.left,k);
if (node!=null){
//这里实际上是把最左侧的节点返回给了第一层调用
return node;
}
//从最小的开始寻找
index++;
if (k==index){
//注意返回的是当前节点
node = pRoot;
return node;
}
node = KthNode(pRoot.right,k);
return node;
}
return null;
}
public class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
}
| [
"[email protected]"
] | |
5bf0da80f104973903f3acb67138932435867082 | 6f44db937970bd94e4e4018903062232c3e2e6a6 | /day16/src/oop/inherit/multi2/Zerg.java | 57cedd74de83f26e5ca23acf7800a7aac47d5b01 | [] | no_license | roh-dh/device | 6735dc8f690d2c82d114746951f245bc60784a0e | 3ce6ed4b9563c570c9095ad11e585fc2f58682e7 | refs/heads/master | 2022-12-03T01:41:59.299296 | 2020-08-14T02:54:37 | 2020-08-14T02:54:37 | 256,438,682 | 0 | 0 | null | 2020-06-09T21:26:44 | 2020-04-17T07:55:26 | Java | UTF-8 | Java | false | false | 78 | java | package oop.inherit.multi2;
public abstract class Zerg extends Unit{
}
| [
"[email protected]"
] | |
6770cf3368f80d170f237d8cf85e632402d9e9a6 | 491212fabdb38193be449c6908fc9745e654a72c | /settlement/branches/tk-collate-rkylin-settle-web/src/main/java/com/rkylin/settle/manager/SettleRuleManager.java | 5521c7749d72907b7e4c58db080a8d52a0c394ec | [] | no_license | yangjava/kylin-settlement | 2bb849c01219fe6e0ab49055189a7341a1ab7aa3 | cc6fa6d8cdaac1c380275849017aeeb2b0c63f30 | refs/heads/master | 2020-12-02T22:09:17.798167 | 2017-07-03T08:24:39 | 2017-07-03T08:24:39 | 96,088,185 | 1 | 10 | null | null | null | null | UTF-8 | Java | false | false | 753 | java | /*
* Powered By chanjetpay-code-generator
* Web Site: http://www.chanjetpay.com
* Since 2014 - 2015
*/
package com.rkylin.settle.manager;
import java.util.List;
import com.rkylin.settle.pojo.SettleRule;
import com.rkylin.settle.pojo.SettleRuleQuery;
public interface SettleRuleManager {
int saveSettleRule(SettleRule settleRule);
int updateSettleRule(SettleRule settleRule);
SettleRule findSettleRuleById(Long id);
List<SettleRule> queryList(SettleRuleQuery query);
public List<SettleRule> queryListByStart2EndTime(SettleRuleQuery query);
int deleteSettleRuleById(Long id);
int deleteSettleRule(SettleRuleQuery query);
List<SettleRule> queryPage(SettleRuleQuery query);
int countByExample(SettleRuleQuery query);
}
| [
"[email protected]"
] | |
21f7fd94c569a7cff206174a8ae2e4260cc16f01 | b79a0a3e714cb09958f0b4607eb8751acb786304 | /cloud-order-service2001/src/main/java/com/gx/wuzhou/order/service/AccountService.java | e0fe559627d493b5e90bfbe0c1d5e68d7d1c7f96 | [] | no_license | Ljx888/cloud2020 | cdd9ccc47f145363e25d51328751488fb2c687a5 | 1a6c33be75c75d5a4cdc2494017d9ff664630f7a | refs/heads/master | 2022-12-20T00:49:35.680669 | 2020-09-22T01:10:24 | 2020-09-22T01:10:24 | 297,497,153 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 963 | java | /**
* Copyright (C), 2019-2020, XXX有限公司
* FileName: AccountService
* Author: Administrator
* Date: 2020/9/20 0020 21:34
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.gx.wuzhou.order.service;
import com.gx.wuzhou.order.domain.CommonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
/**
* 〈一句话功能简述〉<br>
* 〈〉
*
* @author Administrator
* @create 2020/9/20 0020
* @since 1.0.0
*/
@FeignClient(value = "seata-account-service")
public interface AccountService {
@PostMapping(value = "/account/decrease")
CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money);
}
| [
"1473990960"
] | 1473990960 |
4e0caf90042d5f4befecf19d4da5c5f83c0ed3f5 | dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9 | /data_defect4j/preprossed_method_corpus/Chart/5/org/jfree/chart/annotations/CategoryLineAnnotation_writeObject_407.java | 93fd6588d994374097a5ca52f08eab3e02976ee2 | [] | 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 | 861 | java |
org jfree chart annot
line annot link categori plot categoryplot
categori line annot categorylineannot categori annot categoryannot
serial support
param stream output stream
except ioexcept error
write object writeobject object output stream objectoutputstream stream except ioexcept
stream write object defaultwriteobject
serial util serialutil write paint writepaint paint stream
serial util serialutil write stroke writestrok stroke stream
| [
"[email protected]"
] | |
a60befe0a70f6d5a29dda6657ed51b14a03f6d3c | 64053470213ffa18e91a023c9d831e2a83ee3f72 | /library/src/main/java/com/zk/library/binding/command/ViewAdapter/CircleImageView/ViewAdapter.java | e02dc12d73243abc0894703541e9efb0006fc961 | [] | no_license | a18608407391/Android | e7ac15376df94168ab05df1d79422b1a380da227 | 6d64ca82213e269ada50b00afe342d6597178f29 | refs/heads/master | 2020-07-19T19:41:32.231386 | 2020-05-07T01:45:49 | 2020-05-07T01:45:49 | 206,502,674 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 943 | java | package com.zk.library.binding.command.ViewAdapter.CircleImageView;
import android.databinding.BindingAdapter;
import android.text.TextUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.zk.library.R;
import de.hdodenhof.circleimageview.CircleImageView;
/**
* Created by goldze on 2017/6/18.
*/
public final class ViewAdapter {
@BindingAdapter("android:imgUrlCircle")
public static void setImageUri(final CircleImageView imageView, String url) {
if (!TextUtils.isEmpty(url)) {
//使用Glide框架加载图片
RequestOptions options =new RequestOptions().placeholder(R.drawable.icon_default).error(R.drawable.icon_default).diskCacheStrategy(DiskCacheStrategy.ALL).override(50,50);
Glide.with(imageView.getContext()).load(url).apply(options).into(imageView);
}
}
}
| [
"[email protected]"
] | |
f2baa5186be0ffec462ad9cf5f5e97def52b465e | 27e01a045d648305176e4a3a3b3ffef6c4888705 | /nio/src/main/java/tk/yuqibit/nio/protocol/netty/server/NettyServer.java | 59f49295f9c5364eb1ed8cbb76f4f99a6b478ba0 | [] | no_license | CharlieYuQi/java-learn | bf1b39a15f6f8405c3380ef6ce1f4c371e924e5e | e46835437abb896a55732b95f5e9a44a161d6471 | refs/heads/master | 2022-09-29T05:20:45.814852 | 2022-09-20T12:08:53 | 2022-09-20T12:08:53 | 89,459,227 | 19 | 21 | null | null | null | null | UTF-8 | Java | false | false | 2,623 | java | /*
* Copyright 2013-2018 Lilinfeng.
*
* 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 tk.yuqibit.nio.protocol.netty.server;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.timeout.ReadTimeoutHandler;
import tk.yuqibit.nio.protocol.netty.NettyConstant;
import tk.yuqibit.nio.protocol.netty.codec.NettyMessageDecoder;
import tk.yuqibit.nio.protocol.netty.codec.NettyMessageEncoder;
import java.io.IOException;
/**
* @author Lilinfeng
* @date 2014年3月15日
* @version 1.0
*/
public class NettyServer {
public void bind() throws Exception {
// 配置服务端的NIO线程组
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
.option(ChannelOption.SO_BACKLOG, 100)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch)
throws IOException {
ch.pipeline().addLast(
new NettyMessageDecoder(1024 * 1024, 4, 4));
ch.pipeline().addLast(new NettyMessageEncoder());
ch.pipeline().addLast("readTimeoutHandler",
new ReadTimeoutHandler(50));
ch.pipeline().addLast(new LoginAuthRespHandler());
ch.pipeline().addLast("HeartBeatHandler",
new HeartBeatRespHandler());
}
});
// 绑定端口,同步等待成功
b.bind(NettyConstant.REMOTEIP, NettyConstant.PORT).sync();
System.out.println("Netty server start ok : "
+ (NettyConstant.REMOTEIP + " : " + NettyConstant.PORT));
}
public static void main(String[] args) throws Exception {
new NettyServer().bind();
}
}
| [
"[email protected]"
] | |
8a99c472d1a6eb89f2ee62cc317269992742a5c9 | 7c46a44f1930b7817fb6d26223a78785e1b4d779 | /soap/src/java/com/zimbra/soap/admin/message/PurgeAccountCalendarCacheResponse.java | a212dab8bbc6665af3a1347eb15a2274fdf553ae | [] | no_license | Zimbra/zm-mailbox | 20355a191c7174b1eb74461a6400b0329907fb02 | 8ef6538e789391813b65d3420097f43fbd2e2bf3 | refs/heads/develop | 2023-07-20T15:07:30.305312 | 2023-07-03T06:44:00 | 2023-07-06T10:09:53 | 85,609,847 | 67 | 128 | null | 2023-09-14T10:12:10 | 2017-03-20T18:07:01 | Java | UTF-8 | Java | false | false | 1,031 | java | /*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2011, 2012, 2013, 2014, 2016 Synacor, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* ***** END LICENSE BLOCK *****
*/
package com.zimbra.soap.admin.message;
import javax.xml.bind.annotation.XmlRootElement;
import com.zimbra.common.soap.AdminConstants;
@XmlRootElement(name=AdminConstants.E_PURGE_ACCOUNT_CALENDAR_CACHE_RESPONSE)
public class PurgeAccountCalendarCacheResponse {
}
| [
"[email protected]"
] | |
e917142d6fb4c5fa0db9ed33b18a57db978308e2 | 9fe18266c3cafb35b5717836714d255c40f0bf5d | /hossi-server/src/main/java/org/somen440/hossi/domain/application/fruit/FruitListInteractor.java | 1eb7245e6684fb2a8f307c6594684dedcaa9d6b7 | [
"Apache-2.0"
] | permissive | somen440/hossi | 27947a8d1acf788aebd1e01f8b528a91a57ad71b | 2b41498e980ca8993c1dd65883bdd68ace16ec72 | refs/heads/main | 2023-04-03T10:11:45.258286 | 2021-04-11T08:35:35 | 2021-04-11T08:35:35 | 351,281,822 | 0 | 0 | Apache-2.0 | 2021-04-11T08:31:07 | 2021-03-25T02:11:50 | Java | UTF-8 | Java | false | false | 1,104 | java | package org.somen440.hossi.domain.application.fruit;
import java.util.HashSet;
import java.util.stream.Collectors;
import javax.enterprise.context.ApplicationScoped;
import org.somen440.hossi.domain.model.fruit.FruitRepository;
import org.somen440.hossi.usecases.fruits.FruitData;
import org.somen440.hossi.usecases.fruits.list.FruitListInputData;
import org.somen440.hossi.usecases.fruits.list.FruitListOutputData;
import org.somen440.hossi.usecases.fruits.list.FruitListUseCase;
@ApplicationScoped
public class FruitListInteractor implements FruitListUseCase {
FruitRepository fruitRepository;
public FruitListInteractor() {}
public FruitListInteractor(FruitRepository fruitRepository) {
this.fruitRepository = fruitRepository;
}
@Override
public FruitListOutputData handle(FruitListInputData inputData) throws Exception {
final var fruits =
fruitRepository.findAll().stream()
.map(fruit -> new FruitData(fruit.id, fruit.name, fruit.description))
.collect(Collectors.toList());
return new FruitListOutputData(new HashSet<>(fruits));
}
}
| [
"[email protected]"
] | |
8486e3411e66626f11b8a810fe4abbe97e883f88 | 16579c0d31122a7e318d3de8a7597e17d5878799 | /SYSD_TP2/src/systemeDistribuer/m1/miage/heritageClass.java | 9a68781590a9d106a5555126ecb8550a9b5e5e4c | [] | no_license | miage2017/TAMZALI-Selma | 09c725e056a41a0c7f64d0aeecee529f8f32fcf8 | 968048aba27b0e351f291ff4d3472a752ca748aa | refs/heads/master | 2021-08-26T09:47:13.884441 | 2017-11-23T07:05:36 | 2017-11-23T07:05:36 | 111,636,214 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 788 | java | package systemeDistribuer.m1.miage;
public class heritageClass extends Thread {
String nom = "Toto";
int maxv = 10;
public heritageClass(String nom) {
this.nom = nom;
}
public void run() {
System.out.format("Ici le thread %s, je debute!\n", nom);
for (int i = 0; i < maxv; i++) {
System.out.format("[%s] dit je suis la %d\n", nom, i);
}
}
public static void main(String[] args) throws Exception {
String jobname = String.format("1");
String jobname2 = String.format("2");
heritageClass objet_executable = new heritageClass(jobname);
heritageClass objet_executable2 = new heritageClass(jobname2);
System.out.format("Creating thread %s\n", jobname);
objet_executable.start();
objet_executable2.start();
System.out.format("Main :Fini ici !\n");
}
}
| [
"[email protected]"
] | |
f0dc27129ae9fae5d0c02e0d36fff58c66d28abc | e9affefd4e89b3c7e2064fee8833d7838c0e0abc | /aws-java-sdk-cloudfront/src/main/java/com/amazonaws/services/cloudfront/model/transform/PublicKeyConfigStaxUnmarshaller.java | 0b520ac2f0001b04c0ef96bace0ffb23f0692950 | [
"Apache-2.0"
] | permissive | aws/aws-sdk-java | 2c6199b12b47345b5d3c50e425dabba56e279190 | bab987ab604575f41a76864f755f49386e3264b4 | refs/heads/master | 2023-08-29T10:49:07.379135 | 2023-08-28T21:05:55 | 2023-08-28T21:05:55 | 574,877 | 3,695 | 3,092 | Apache-2.0 | 2023-09-13T23:35:28 | 2010-03-22T23:34:58 | null | UTF-8 | Java | false | false | 3,084 | java | /*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.cloudfront.model.transform;
import javax.xml.stream.events.XMLEvent;
import javax.annotation.Generated;
import com.amazonaws.services.cloudfront.model.*;
import com.amazonaws.transform.Unmarshaller;
import com.amazonaws.transform.StaxUnmarshallerContext;
import com.amazonaws.transform.SimpleTypeStaxUnmarshallers.*;
/**
* PublicKeyConfig StAX Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class PublicKeyConfigStaxUnmarshaller implements Unmarshaller<PublicKeyConfig, StaxUnmarshallerContext> {
public PublicKeyConfig unmarshall(StaxUnmarshallerContext context) throws Exception {
PublicKeyConfig publicKeyConfig = new PublicKeyConfig();
int originalDepth = context.getCurrentDepth();
int targetDepth = originalDepth + 1;
if (context.isStartOfDocument())
targetDepth += 1;
while (true) {
XMLEvent xmlEvent = context.nextEvent();
if (xmlEvent.isEndDocument())
return publicKeyConfig;
if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
if (context.testExpression("CallerReference", targetDepth)) {
publicKeyConfig.setCallerReference(StringStaxUnmarshaller.getInstance().unmarshall(context));
continue;
}
if (context.testExpression("Name", targetDepth)) {
publicKeyConfig.setName(StringStaxUnmarshaller.getInstance().unmarshall(context));
continue;
}
if (context.testExpression("EncodedKey", targetDepth)) {
publicKeyConfig.setEncodedKey(StringStaxUnmarshaller.getInstance().unmarshall(context));
continue;
}
if (context.testExpression("Comment", targetDepth)) {
publicKeyConfig.setComment(StringStaxUnmarshaller.getInstance().unmarshall(context));
continue;
}
} else if (xmlEvent.isEndElement()) {
if (context.getCurrentDepth() < originalDepth) {
return publicKeyConfig;
}
}
}
}
private static PublicKeyConfigStaxUnmarshaller instance;
public static PublicKeyConfigStaxUnmarshaller getInstance() {
if (instance == null)
instance = new PublicKeyConfigStaxUnmarshaller();
return instance;
}
}
| [
""
] | |
68a828cea88d161101e3dbf5c139a76fbd0c88cd | e828f2c87d3093faf2eb9e211e7b73e27567d937 | /app/src/androidTest/java/com/laulee/idcardnumber/ExampleInstrumentedTest.java | 34b4c4dadd107ce96ef0d9e11f8b741aace9ee9b | [] | no_license | laulee/opencvface | 6446b2aeb156f2d3b5161b4107edd2fe89844ee0 | 95164c7ced7f1df0dfca87340bc8b00af8e249aa | refs/heads/master | 2021-03-18T04:25:17.094235 | 2020-03-13T10:31:34 | 2020-03-13T10:31:34 | 247,045,547 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 717 | java | package com.laulee.idcardnumber;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.laulee.idcardnumber", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
f07aa86e820b51d2d08e71d90f8f45fed288fe58 | 1f41ee1a72a829cd6145df64509fc8433850c21a | /de/MineBug/schematics/jnbt/NBTOutputStream.java | 2ed175fe57711b1a2cb31d9779ab57f00a89f70a | [] | no_license | Buggy-Development/Schematic-Paster | 43c140d0466d8a888affabc237f2e4096c28f73b | f5cbacb2831b14795144d94056fac0bf83f7a845 | refs/heads/master | 2022-04-18T16:29:38.043889 | 2020-04-18T23:41:46 | 2020-04-18T23:41:46 | 256,875,283 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,738 | java | package de.MineBug.schematics.jnbt;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.GZIPOutputStream;
/*
* JNBT License
*
* Copyright (c) 2010 Graham Edgecombe
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the JNBT team nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* <p>This class writes <strong>NBT</strong>, or
* <strong>Named Binary Tag</strong> <code>Tag</code> objects to an underlying
* <code>OutputStream</code>.</p>
*
* <p>The NBT format was created by Markus Persson, and the specification may
* be found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p>
* @author Graham Edgecombe
*
*/
public final class NBTOutputStream implements Closeable {
/**
* The output stream.
*/
private final DataOutputStream os;
/**
* Creates a new <code>NBTOutputStream</code>, which will write data to the
* specified underlying output stream.
* @param os The output stream.
* @throws IOException if an I/O error occurs.
*/
public NBTOutputStream(OutputStream os) throws IOException {
this.os = new DataOutputStream(new GZIPOutputStream(os));
}
/**
* Writes a tag.
* @param tag The tag to write.
* @throws IOException if an I/O error occurs.
*/
public void writeTag(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
String name = tag.getName();
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
if(type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
writeTagPayload(tag);
}
/**
* Writes tag payload.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch(type) {
case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag);
break;
case NBTConstants.TYPE_BYTE:
writeByteTagPayload((ByteTag) tag);
break;
case NBTConstants.TYPE_SHORT:
writeShortTagPayload((ShortTag) tag);
break;
case NBTConstants.TYPE_INT:
writeIntTagPayload((IntTag) tag);
break;
case NBTConstants.TYPE_LONG:
writeLongTagPayload((LongTag) tag);
break;
case NBTConstants.TYPE_FLOAT:
writeFloatTagPayload((FloatTag) tag);
break;
case NBTConstants.TYPE_DOUBLE:
writeDoubleTagPayload((DoubleTag) tag);
break;
case NBTConstants.TYPE_BYTE_ARRAY:
writeByteArrayTagPayload((ByteArrayTag) tag);
break;
case NBTConstants.TYPE_STRING:
writeStringTagPayload((StringTag) tag);
break;
case NBTConstants.TYPE_LIST:
writeListTagPayload((ListTag) tag);
break;
case NBTConstants.TYPE_COMPOUND:
writeCompoundTagPayload((CompoundTag) tag);
break;
default:
throw new IOException("Invalid tag type: " + type + ".");
}
}
/**
* Writes a <code>TAG_Byte</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteTagPayload(ByteTag tag) throws IOException {
os.writeByte(tag.getValue());
}
/**
* Writes a <code>TAG_Byte_Array</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
byte[] bytes = tag.getValue();
os.writeInt(bytes.length);
os.write(bytes);
}
/**
* Writes a <code>TAG_Compound</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for(Tag childTag : tag.getValue().values()) {
writeTag(childTag);
}
os.writeByte((byte) 0); // end tag - better way?
}
/**
* Writes a <code>TAG_List</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeListTagPayload(ListTag tag) throws IOException {
Class<? extends Tag> clazz = tag.getType();
List<Tag> tags = tag.getValue();
int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for(int i = 0; i < size; i++) {
writeTagPayload(tags.get(i));
}
}
/**
* Writes a <code>TAG_String</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeStringTagPayload(StringTag tag) throws IOException {
byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length);
os.write(bytes);
}
/**
* Writes a <code>TAG_Double</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue());
}
/**
* Writes a <code>TAG_Float</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeFloatTagPayload(FloatTag tag) throws IOException {
os.writeFloat(tag.getValue());
}
/**
* Writes a <code>TAG_Long</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeLongTagPayload(LongTag tag) throws IOException {
os.writeLong(tag.getValue());
}
/**
* Writes a <code>TAG_Int</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeIntTagPayload(IntTag tag) throws IOException {
os.writeInt(tag.getValue());
}
/**
* Writes a <code>TAG_Short</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeShortTagPayload(ShortTag tag) throws IOException {
os.writeShort(tag.getValue());
}
/**
* Writes a <code>TAG_Empty</code> tag.
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
@Override
public void close() throws IOException {
os.close();
}
}
| [
"[email protected]"
] | |
ed2a42d18c862b9320c7288d3f7624e823528d87 | cc9387b528114b9cfe8da6b3d63f540b31b57c21 | /Clic/src/categories/Categories.java | 8c19476fc0217580564aa39bc3f259fe05f85700 | [] | no_license | hillel91/Exercises | 601449063611dfe9b0f81f628ccf7b83c2c1f637 | 73c6812415fae4a142eeea6ad8d7009f7fd7fbd6 | refs/heads/master | 2020-05-13T19:47:25.125136 | 2019-04-16T09:44:04 | 2019-04-16T09:44:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 141 | java | package categories;
public enum Categories {
Computers,
Cars,
Design,
Electricity,
Food,
Restaurant,
Vacation,
}
| [
"[email protected]"
] | |
046db7c0bc470b9aae97e40fad687a1c7bd48451 | cb9cccf855b68d556a7001295e0e2dcb948811a1 | /src/main/java/com/zelu/authorizecode/confige/TemplateConfige.java | 455b3cf978bbee2f37b29909b4957d287ce1a319 | [] | no_license | wangqiang6071/authorizecode | ae5abff57781c9550938ba0ac98cda74c33bfadf | 4c948c6564a2f9f13454d78cf8a314443b2f70cc | refs/heads/master | 2023-08-25T15:01:55.335447 | 2021-10-19T06:29:10 | 2021-10-19T06:29:10 | 418,798,278 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,061 | java | package com.zelu.authorizecode.confige;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
* @author wangqiang
* @Date: 2021/9/16 09:43
*/
@Configuration
public class TemplateConfige {
//RestTemplate的3种REST-Client的封装
@Bean("urlConnection")
public RestTemplate urlConnectionRestTemplate(){
RestTemplate restTemplate = new RestTemplate(new SimpleClientHttpRequestFactory());
return restTemplate;
}
// @Bean("httpClient")
// public RestTemplate httpClientRestTemplate(){
// RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
// return restTemplate;
// }
// @Bean("OKHttp3")
// public RestTemplate OKHttp3RestTemplate(){
// RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
// return restTemplate;
// }
}
| [
"[email protected]"
] | |
36ce23aa4e5c878c242d6cb0021b70e273f4fb90 | 4ce317de6a7f44249be4c12a77d5332d27d92523 | /gmall-api/src/main/java/com/dilen/gmall/bean/PmsBaseAttrInfo.java | 1fe5fe7eb39c36b8648ac8e2bfe29f3e7b755bbe | [] | no_license | wucong0205/wumall | 3c9605ed2e637b2572cc61ed9550635787c314c6 | 61cb62ee32c16f32cbeb514dd3cae90d0d9eb7be | refs/heads/master | 2022-09-17T03:37:39.454949 | 2020-04-14T14:45:01 | 2020-04-14T14:45:01 | 226,133,608 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java | package com.dilen.gmall.bean;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
/**
* @param
* @return
*/
public class PmsBaseAttrInfo implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column
private String id;
@Column
private String attrName; //平台属性名称
@Column
private String catalog3Id; //三级分类编号ID
@Column
private String isEnabled; //是否启用 启用:1 停用:0
@Transient
List<PmsBaseAttrValue> attrValueList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAttrName() {
return attrName;
}
public void setAttrName(String attrName) {
this.attrName = attrName;
}
public String getCatalog3Id() {
return catalog3Id;
}
public void setCatalog3Id(String catalog3Id) {
this.catalog3Id = catalog3Id;
}
public String getIsEnabled() {
return isEnabled;
}
public void setIsEnabled(String isEnabled) {
this.isEnabled = isEnabled;
}
public List<PmsBaseAttrValue> getAttrValueList() {
return attrValueList;
}
public void setAttrValueList(List<PmsBaseAttrValue> attrValueList) {
this.attrValueList = attrValueList;
}
}
| [
"[email protected]"
] | |
a2b40c9b0330e480d2aa421a8c69e6c4032c2172 | 16b0e7a4ebb9ddced57cc3bad9fbfda76ca57a51 | /src/main/java/com/nc/dao/CustomerMapper.java | 5c2f1e20a99a83b30bef8496082e091cc1f1f818 | [] | no_license | NiiCi/Mybatis | 705308e0db31d0d3b5de082e0722f5a20b3d542a | b5552633bd75ac51c79e4ee53892907711d0e492 | refs/heads/master | 2020-04-08T07:18:30.762179 | 2018-11-26T08:25:35 | 2018-11-26T08:25:35 | 159,134,263 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 267 | java | package com.nc.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.nc.entity.Customers;
/*@Repository("customerDao")*/
public interface CustomerMapper {
public List<Customers> queryCus();
public int checkCus(String name);
}
| [
"[email protected]"
] | |
12dd021706131dafbb22015def020cc978167865 | 8b61fa8f6c7d64fb4cf2133573af4fb894aea94c | /src/pers/caijx/corejava/chapter14/sync2/Test.java | ec105fede9969e99dccf03ee33881d48285189ce | [] | no_license | SmileCJX/corejava | e681439d922ca1e5e4e77b977796f669d6ce9968 | 2ad7d0cd4c4d1d3af90aaea5bf00428e19b73238 | refs/heads/master | 2022-03-29T02:36:55.772290 | 2019-11-02T15:55:55 | 2019-11-02T15:55:55 | 109,553,996 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 252 | java | package pers.caijx.corejava.chapter14.sync2;
/**
* Created by Administrator on 2017/11/15/015.
*/
public class Test {
public static void main(String[] args) {
double result = 0.0;
System.out.println(2.5 * Math.sqrt(2));
}
}
| [
"[email protected]"
] | |
40fecbc7e7e329ef5f13655d20179e8b840da9bd | f2497f7c5dd0de11b63e0beff552fe24ba6eff83 | /TileEntities/Transmission/TileEntityGearbox.java | 43efdcdd898d63d002f10d13c253f08d280f4875 | [] | no_license | riking/RotaryCraft | b851011fdd3bd80ee4c5e8eaff2004b641c629fe | fe1716b65a13577ed7342287babf9e29d82844e1 | refs/heads/master | 2021-01-19T07:20:01.698369 | 2015-01-06T09:16:58 | 2015-01-06T09:16:58 | 28,856,270 | 0 | 1 | null | 2015-01-06T09:30:45 | 2015-01-06T09:30:44 | null | UTF-8 | Java | false | false | 16,921 | java | /*******************************************************************************
* @author Reika Kalseki
*
* Copyright 2015
*
* All rights reserved.
* Distribution of the software in any form is only allowed with
* explicit, prior permission from the owner.
******************************************************************************/
package Reika.RotaryCraft.TileEntities.Transmission;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import Reika.ChromatiCraft.API.WorldRift;
import Reika.DragonAPI.Instantiable.HybridTank;
import Reika.DragonAPI.Instantiable.StepTimer;
import Reika.DragonAPI.Instantiable.Data.WorldLocation;
import Reika.DragonAPI.Libraries.MathSci.ReikaEngLibrary;
import Reika.DragonAPI.Libraries.MathSci.ReikaMathLibrary;
import Reika.DragonAPI.Libraries.Registry.ReikaItemHelper;
import Reika.DragonAPI.Libraries.World.ReikaRedstoneHelper;
import Reika.DragonAPI.Libraries.World.ReikaWorldHelper;
import Reika.RotaryCraft.RotaryConfig;
import Reika.RotaryCraft.API.Power.ShaftPowerEmitter;
import Reika.RotaryCraft.Auxiliary.ItemStacks;
import Reika.RotaryCraft.Auxiliary.RotaryAux;
import Reika.RotaryCraft.Auxiliary.Interfaces.PipeConnector;
import Reika.RotaryCraft.Auxiliary.Interfaces.SimpleProvider;
import Reika.RotaryCraft.Auxiliary.Interfaces.TemperatureTE;
import Reika.RotaryCraft.Base.TileEntity.TileEntity1DTransmitter;
import Reika.RotaryCraft.Base.TileEntity.TileEntityPiping.Flow;
import Reika.RotaryCraft.Registry.DifficultyEffects;
import Reika.RotaryCraft.Registry.MachineRegistry;
import Reika.RotaryCraft.Registry.MaterialRegistry;
import Reika.RotaryCraft.Registry.RotaryAchievements;
public class TileEntityGearbox extends TileEntity1DTransmitter implements PipeConnector, IFluidHandler, TemperatureTE {
public boolean reduction = true; // Reduction gear if true, accelerator if false
private int damage = 0;
private MaterialRegistry type;
private HybridTank tank = new HybridTank("gear", 24000);
private boolean failed;
private int temperature;
private StepTimer tempTimer = new StepTimer(20);
private static final int MAX_DAMAGE = 480;
private boolean lastPower;
public TileEntityGearbox(MaterialRegistry type) {
if (type == null)
type = MaterialRegistry.WOOD;
this.type = type;
}
public TileEntityGearbox() {
this(MaterialRegistry.WOOD);
}
public MaterialRegistry getGearboxType() {
return type != null ? type : MaterialRegistry.WOOD;
}
public int getMaxLubricant() {
switch(type) {
case BEDROCK:
return 0;
case DIAMOND:
return 1000;
case STEEL:
return 24000;
case STONE:
return 8000;
case WOOD:
return 0;//3000;
default:
return 0;
}
}
public int getDamage() {
return damage;
}
public double getDamagedPowerFactor() {
return Math.pow(0.99, damage);
}
public int getDamagePercent() {
return this.getDamagePercent(damage);
}
@Override
protected void readFromSplitter(TileEntitySplitter spl) { //Complex enough to deserve its own function
int sratio = spl.getRatioFromMode();
if (sratio == 0)
return;
boolean favorbent = false;
if (sratio < 0) {
favorbent = true;
sratio = -sratio;
}
if (reduction) {
if (xCoord == spl.writeinline[0] && zCoord == spl.writeinline[1]) { //We are the inline
omega = spl.omega/ratio; //omega always constant
if (sratio == 1) { //Even split, favorbent irrelevant
torque = spl.torque/2*ratio;
return;
}
if (favorbent) {
torque = spl.torque/sratio*ratio;
}
else {
torque = ratio*(int)(spl.torque*((sratio-1D)/(sratio)));
}
}
else if (xCoord == spl.writebend[0] && zCoord == spl.writebend[1]) { //We are the bend
omega = spl.omega/ratio; //omega always constant
if (sratio == 1) { //Even split, favorbent irrelevant
torque = spl.torque/2*ratio;
return;
}
if (favorbent) {
torque = ratio*(int)(spl.torque*((sratio-1D)/(sratio)));
}
else {
torque = spl.torque/sratio*ratio;
}
}
else { //We are not one of its write-to blocks
torque = 0;
omega = 0;
power = 0;
return;
}
}
else {
if (xCoord == spl.writeinline[0] && zCoord == spl.writeinline[1]) { //We are the inline
omega = spl.omega*ratio; //omega always constant
if (sratio == 1) { //Even split, favorbent irrelevant
torque = spl.torque/2/ratio;
return;
}
if (favorbent) {
torque = spl.torque/sratio/ratio;
}
else {
torque = (int)(spl.torque*((sratio-1D))/sratio)/(ratio);
}
}
else if (xCoord == spl.writebend[0] && zCoord == spl.writebend[1]) { //We are the bend
omega = spl.omega*ratio; //omega always constant
if (sratio == 1) { //Even split, favorbent irrelevant
torque = spl.torque/2/ratio;
return;
}
if (favorbent) {
torque = (int)(spl.torque*((sratio-1D)/(sratio)))/ratio;
}
else {
torque = spl.torque/sratio/ratio;
}
}
else { //We are not one of its write-to blocks
torque = 0;
omega = 0;
power = 0;
return;
}
}
}
@Override
public void updateEntity(World world, int x, int y, int z, int meta) {
super.updateTileEntity();
tickcount++;
this.getIOSides(world, x, y, z, meta);
if ((world.getWorldTime()&31) == 0)
ReikaWorldHelper.causeAdjacentUpdates(world, x, y, z);
if (ReikaRedstoneHelper.isPositiveEdge(world, x, y, z, lastPower))
ratio = -ratio;
this.transferPower(world, x, y, z, meta);
power = (long)omega*(long)torque;
this.getLube(world, x, y, z, meta);
tempTimer.update();
if (tempTimer.checkCap()) {
this.updateTemperature(world, x, y, z, meta);
}
this.basicPowerReceiver();
lastPower = world.isBlockIndirectlyGettingPowered(x, y, z);
}
public void getLube(World world, int x, int y, int z, int metadata) {
int oldlube = 0;
if (type.needsLubricant() && omegain > 0) {
if (tank.isEmpty()) {
if (!world.isRemote && damage < MAX_DAMAGE && rand.nextInt(40) == 0 && this.getTicksExisted() >= 100) {
damage++;
RotaryAchievements.DAMAGEGEARS.triggerAchievement(this.getPlacer());
}
if (rand.nextDouble()*rand.nextDouble() > this.getDamagedPowerFactor()) {
if (type.isFlammable())
ReikaWorldHelper.ignite(world, x, y, z);
world.spawnParticle("crit", xCoord+rand.nextFloat(), yCoord+rand.nextFloat(), zCoord+rand.nextFloat(), -0.5+rand.nextFloat(), rand.nextFloat(), -0.5+rand.nextFloat());
if (rand.nextInt(5) == 0) {
world.playSoundEffect(x+0.5, y+0.5, z+0.5, type.getDamageNoise(), 1F, 1F);
}
}
}
else if (!world.isRemote && type.consumesLubricant()) {
if (tickcount >= 80) {
tank.removeLiquid(Math.max(1, (int)(DifficultyEffects.LUBEUSAGE.getChance()*ReikaMathLibrary.logbase(omegain, 2)/4)));
tickcount = 0;
}
}
}
}
public void getIOSides(World world, int x, int y, int z, int metadata) {
while (metadata > 3)
metadata -= 4;
super.getIOSides(world, x, y, z, metadata, false);
}
private void calculateRatio() {
int tratio = 1+this.getBlockMetadata()/4;
ratio = (int)ReikaMathLibrary.intpow(2, tratio);
}
@Override
protected void readFromCross(TileEntityShaft cross) {
if (cross.isWritingTo(this)) {
if (reduction) {
omega = cross.readomega[0]/ratio;
torque = cross.readtorque[0]*ratio;
}
else {
omega = cross.readomega[0]*ratio;
torque = cross.readtorque[0]/ratio;
}
}
else if (cross.isWritingTo2(this)) {
if (reduction) {
omega = cross.readomega[1]/ratio;
torque = cross.readtorque[1]*ratio;
}
else {
omega = cross.readomega[1]*ratio;
torque = cross.readtorque[1]/ratio;
}
}
else {
omega = torque = 0;
return; //not its output
}
}
@Override
protected void transferPower(World world, int x, int y, int z, int meta) {
this.calculateRatio();
if (worldObj.isRemote && !RotaryAux.getPowerOnClient)
return;
boolean flag = true;
omegain = torquein = 0;
boolean isCentered = x == xCoord && y == yCoord && z == zCoord;
int dx = x+read.offsetX;
int dy = y+read.offsetY;
int dz = z+read.offsetZ;
MachineRegistry m = isCentered ? this.getMachine(read) : MachineRegistry.getMachine(world, dx, dy, dz);
TileEntity te = isCentered ? this.getAdjacentTileEntity(read) : world.getTileEntity(dx, dy, dz);
if (this.isProvider(te)) {
if (m == MachineRegistry.SHAFT) {
TileEntityShaft devicein = (TileEntityShaft)te;
if (devicein.isCross()) {
this.readFromCross(devicein);
}
else if (devicein.isWritingTo(this)) {
torquein = devicein.torque;
omegain = devicein.omega;
}
}
else if (te instanceof SimpleProvider) {
this.copyStandardPower(te);
}
else if (m == MachineRegistry.POWERBUS) {
TileEntityPowerBus pwr = (TileEntityPowerBus)te;
ForgeDirection dir = this.getInputForgeDirection().getOpposite();
omegain = pwr.getSpeedToSide(dir);
torquein = pwr.getTorqueToSide(dir);
}
else if (te instanceof ShaftPowerEmitter) {
ShaftPowerEmitter sp = (ShaftPowerEmitter)te;
if (sp.isEmitting() && sp.canWriteTo(read.getOpposite())) {
torquein = sp.getTorque();
omegain = sp.getOmega();
}
}
else if (m == MachineRegistry.SPLITTER) {
TileEntitySplitter devicein = (TileEntitySplitter)te;
if (devicein.isSplitting()) {
this.readFromSplitter(devicein);
flag = false;
}
else if (devicein.isWritingTo(this)) {
torquein = devicein.torque;
omegain = devicein.omega;
}
}
}
else if (te instanceof WorldRift) {
WorldRift sr = (WorldRift)te;
WorldLocation loc = sr.getLinkTarget();
if (loc != null)
this.transferPower(loc.getWorld(), loc.xCoord, loc.yCoord, loc.zCoord, meta);
}
else {
omega = 0;
torque = 0;
power = 0;
return;
}
if (flag) {
if (reduction) {
omega = omegain / ratio;
if (torquein <= RotaryConfig.torquelimit/ratio)
torque = torquein * ratio;
else {
torque = RotaryConfig.torquelimit;
world.spawnParticle("crit", x+rand.nextFloat(), y+rand.nextFloat(), z+rand.nextFloat(), -0.5+rand.nextFloat(), rand.nextFloat(), -0.5+rand.nextFloat());
world.playSoundEffect(x+0.5, y+0.5, z+0.5, type.getDamageNoise(), 0.1F, 1F);
}
}
else {
if (omegain <= RotaryConfig.omegalimit/ratio)
omega = omegain * ratio;
else {
omega = RotaryConfig.omegalimit;
world.spawnParticle("crit", x+rand.nextFloat(), y+rand.nextFloat(), z+rand.nextFloat(), -0.5+rand.nextFloat(), rand.nextFloat(), -0.5+rand.nextFloat());
world.playSoundEffect(x+0.5, y+0.5, z+0.5, type.getDamageNoise(), 0.1F, 1F);
}
torque = torquein / ratio;
}
}
torque *= this.getDamagedPowerFactor();
if (torque <= 0)
omega = 0;
if (!type.isInfiniteStrength())
this.testFailure();
}
public void fail(World world, int x, int y, int z) {
failed = true;
world.createExplosion(null, x+0.5, y+0.5, z+0.5, 1F, true);
ItemStack item = null;
switch(type) {
case WOOD:
item = ItemStacks.sawdust.copy();
break;
case STONE:
item = new ItemStack(Blocks.gravel, 1, 0);
break;
case STEEL:
item = ItemStacks.scrap.copy();
break;
case DIAMOND:
item = new ItemStack(Items.diamond, 1, 0);
break;
case BEDROCK:
item = ItemStacks.bedrockdust.copy();
break;
}
for (int i = 0; i < this.getRatio(); i++) {
ReikaItemHelper.dropItem(world, x+0.5, y+1.25, z+0.5, item);
}
world.setBlockToAir(x, y, z);
}
public void repair(int dmg) {
damage -= dmg;
if (damage < 0)
damage = 0;
failed = false;
}
public void setDamage(int dmg) {
damage = dmg;
}
public void testFailure() {
if (ReikaEngLibrary.mat_rotfailure(type.getDensity(), 0.0625, ReikaMathLibrary.doubpow(Math.max(omega, omegain), 1-(0.11D*type.ordinal())), type.getTensileStrength())) {
this.fail(worldObj, xCoord, yCoord, zCoord);
}
else if (ReikaEngLibrary.mat_twistfailure(Math.max(torque, torquein), 0.0625, type.getShearStrength()/16D)) {
this.fail(worldObj, xCoord, yCoord, zCoord);
}
}
public int getLubricantScaled(int par1)
{
if (this.getMaxLubricant() == 0)
return 0;
return tank.getLevel()*par1/this.getMaxLubricant();
}
@Override
protected void writeSyncTag(NBTTagCompound NBT)
{
super.writeSyncTag(NBT);
NBT.setBoolean("reduction", reduction);
NBT.setInteger("damage", damage);
NBT.setBoolean("fail", failed);
NBT.setInteger("temp", temperature);
tank.writeToNBT(NBT);
}
@Override
public void writeToNBT(NBTTagCompound NBT) {
NBT.setInteger("type", type.ordinal());
super.writeToNBT(NBT);
}
@Override
public void readFromNBT(NBTTagCompound NBT) {
type = MaterialRegistry.setType(NBT.getInteger("type"));
super.readFromNBT(NBT);
}
@Override
protected void readSyncTag(NBTTagCompound NBT)
{
super.readSyncTag(NBT);
reduction = NBT.getBoolean("reduction");
damage = NBT.getInteger("damage");
failed = NBT.getBoolean("fail");
temperature = NBT.getInteger("temp");
tank.readFromNBT(NBT);
}
@Override
public boolean hasModelTransparency() {
return false;
}
@Override
protected void animateWithTick(World world, int x, int y, int z) {
if (!this.isInWorld()) {
phi = 0;
return;
}
phi += ReikaMathLibrary.doubpow(ReikaMathLibrary.logbase(omega+1, 2), 1.05);
}
@Override
public int getRedstoneOverride() {
return 15*tank.getLevel()/this.getMaxLubricant();
}
@Override
public boolean canConnectToPipe(MachineRegistry m) {
return m == MachineRegistry.HOSE;
}
@Override
public boolean canConnectToPipeOnSide(MachineRegistry p, ForgeDirection side) {
return side != ForgeDirection.DOWN;
}
@Override
public void onEMP() {}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if (this.canFill(from, resource.getFluid())) {
int space = this.getMaxLubricant()-this.getLubricant();
if (space > 0) {
if (resource.amount > space)
resource = new FluidStack(resource.getFluid(), space);
return tank.fill(resource, doFill);
}
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return from != ForgeDirection.UP && fluid.equals(FluidRegistry.getFluid("lubricant"));
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[]{tank.getInfo()};
}
public int getLubricant() {
return tank.getLevel();
}
public void setLubricant(int amt) {
tank.setContents(amt, FluidRegistry.getFluid("lubricant"));
}
public void fillWithLubricant() {
this.setLubricant(this.getMaxLubricant());
}
public boolean canTakeLubricant(int amt) {
return tank.getLevel()+amt <= this.getMaxLubricant();
}
public void addLubricant(int amt) {
tank.addLiquid(amt, FluidRegistry.getFluid("lubricant"));
}
@Override
public Flow getFlowForSide(ForgeDirection side) {
return side != ForgeDirection.UP ? Flow.INPUT : Flow.NONE;
}
@Override
public MachineRegistry getMachine() {
return MachineRegistry.GEARBOX;
}
@Override
public void updateTemperature(World world, int x, int y, int z, int meta) {
int Tamb = ReikaWorldHelper.getAmbientTemperatureAt(world, x, y, z);
if (type == MaterialRegistry.WOOD) {
if (omega > 0) {
temperature++;
world.playSound(x+0.5, y+0.5, z+0.5, type.getDamageNoise(), 1, 1, true);
}
}
else if (type == MaterialRegistry.STONE) {
if (omega > 8192) {
temperature++;
world.playSound(x+0.5, y+0.5, z+0.5, type.getDamageNoise(), 1, 1, true);
}
}
else {
temperature = Tamb;
}
if (temperature > 90 && rand.nextBoolean() && (type == MaterialRegistry.STONE || type == MaterialRegistry.WOOD)) {
damage++;
}
if (temperature > 120) {
this.overheat(world, x, y, z);
}
}
@Override
public void addTemperature(int temp) {
temperature += temp;
}
@Override
public int getTemperature() {
return temperature;
}
@Override
public int getThermalDamage() {
return 0;
}
@Override
public void overheat(World world, int x, int y, int z) {
if (type.isFlammable())
ReikaWorldHelper.ignite(world, x, y, z);
}
public static int getDamagePercent(int val) {
return (int)(100*(1-Math.pow(0.99, val)));
}
}
| [
"[email protected]"
] | |
99a4342adc28293d1d30249c9b3f6ead6fef6964 | 4e8d52f594b89fa356e8278265b5c17f22db1210 | /WebServiceArtifacts/XigniteReleases/com/xignite/services/GetTodaysSecurityHeadlinesResponse.java | d61ed2de6aac0ec5c32153b96e25523d3bade05b | [] | no_license | ouniali/WSantipatterns | dc2e5b653d943199872ea0e34bcc3be6ed74c82e | d406c67efd0baa95990d5ee6a6a9d48ef93c7d32 | refs/heads/master | 2021-01-10T05:22:19.631231 | 2015-05-26T06:27:52 | 2015-05-26T06:27:52 | 36,153,404 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,833 | java |
package com.xignite.services;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
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>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="GetTodaysSecurityHeadlinesResult" type="{http://www.xignite.com/services/}SecurityHeadlines" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"getTodaysSecurityHeadlinesResult"
})
@XmlRootElement(name = "GetTodaysSecurityHeadlinesResponse")
public class GetTodaysSecurityHeadlinesResponse {
@XmlElement(name = "GetTodaysSecurityHeadlinesResult")
protected SecurityHeadlines getTodaysSecurityHeadlinesResult;
/**
* Gets the value of the getTodaysSecurityHeadlinesResult property.
*
* @return
* possible object is
* {@link SecurityHeadlines }
*
*/
public SecurityHeadlines getGetTodaysSecurityHeadlinesResult() {
return getTodaysSecurityHeadlinesResult;
}
/**
* Sets the value of the getTodaysSecurityHeadlinesResult property.
*
* @param value
* allowed object is
* {@link SecurityHeadlines }
*
*/
public void setGetTodaysSecurityHeadlinesResult(SecurityHeadlines value) {
this.getTodaysSecurityHeadlinesResult = value;
}
}
| [
"[email protected]"
] | |
1321f2bafe581a50ff3f3483272d9306a9b6474a | 0e3b7a702869f4c2fac0565ed11498f3643de3ee | /RxAsync/app/src/main/java/scionoftech/rxasync/CustomObservableActivity.java | e956ead859cd42263979ef917c24e06d275b13e7 | [] | no_license | scionoftech/RxJava-RxAndroid-Samples | 6748897fe0f4a54f02359d9772b0a5d0382ce8c7 | ee32a471a8cf4d11c931404555f766707d551ecd | refs/heads/master | 2021-01-20T06:19:34.621122 | 2017-04-30T17:00:42 | 2017-04-30T17:00:42 | 89,864,360 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,645 | java | package scionoftech.rxasync;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.Callable;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
import static android.content.ContentValues.TAG;
public class CustomObservableActivity extends AppCompatActivity {
CompositeDisposable compositeDisposable = new CompositeDisposable();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_observable);
Run();
}
public void Run() {
compositeDisposable.add(getobservable().subscribeOn(Schedulers.newThread()) // Create a new Thread
.observeOn(AndroidSchedulers.mainThread()) // Use the UI thread
.subscribeWith(new DisposableObserver<Integer>() {
@Override
public void onNext(Integer value) {
Log.d("output", String.valueOf(value));
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
Log.d("onComplete", "On Complete");
}
}));
}
public Observable<Integer> getobservable() {
return Observable.defer(new Callable<ObservableSource<? extends Integer>>() {
@Override
public ObservableSource<? extends Integer> call() throws Exception {
return Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
if (!e.isDisposed()) {
for (int i = 0; i < 100000; i++) {
e.onNext(i);
}
e.onComplete();
}
}
});
}
});
}
@Override
protected void onDestroy() {
compositeDisposable.clear(); // do not send event after activity has been destroyed
super.onDestroy();
}
}
| [
"[email protected]"
] | |
f038823e9cf856a3a815000b8d81b18a09e6035b | ce68783ff3bd2cc196c1041b7901eadbe360face | /NJU_EAS_Client/src/presentation/jteacherui/combine.java | 1ea5ffa1be4f979fde6324bbf26baaaecc8f16b4 | [] | no_license | kesperado/EAS | 57e1063d464243b25f6f09cda45ef179a43f7164 | eca43041ddfc6779f3916e52b1443cc7dcea1944 | refs/heads/master | 2020-06-01T05:51:38.698091 | 2015-06-17T05:40:23 | 2015-06-17T05:40:23 | 37,574,506 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,246 | java | //整合整体框架和教学计划
package presentation.jteacherui;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
import businesslogiccontroller.jteachercontroller.jTeacherController;
@SuppressWarnings("serial")
public class combine extends JPanel{
private jTeacherController jTeacherController;
JTabbedPane jtp;
JPanel jp1,jp2;
public combine(jTeacherController jTeacherController){
this.jTeacherController=jTeacherController;
jtp=new JTabbedPane();
jp1=new Outline(this.jTeacherController);
jp2=new TeaPlans(this.jTeacherController);
jtp.add("整体框架",jp1);
jtp.add("院系教学计划",jp2);
jtp.setOpaque(false);
jp1.setOpaque(false);
jp2.setOpaque(false);
this.setOpaque(false);
this.setLayout(new BorderLayout());
this.add(jtp,BorderLayout.CENTER);
}
public void paintComponent(Graphics g){
Image im = null;
try {
im = ImageIO.read(new File("Images/back.jpg"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
super.paintComponent(g);
g.drawImage(im,0,0,this.getWidth(),this.getHeight(),this);
}
}
| [
"[email protected]"
] | |
a4db86584f06feb5e89293d0b7192294ebdf7273 | 8d23e59659b3fc0f46a269879eb6d5b5086a796c | /chapter_002/src/main/java/ru.job4j/tracker/Tracker4StaticFinalClass.java | 99e5d7f27ec58a25962100ab6b45a627d9380548 | [
"Apache-2.0"
] | permissive | Tasolcheg/job4j_learning | 70bcab597f02f2a6179bc0d8c8d7ad9f6f3adf18 | 5542065217143a8ed180cd487d58c2e5ced4b31b | refs/heads/master | 2021-07-04T14:42:41.901562 | 2019-02-06T15:07:48 | 2019-02-06T15:07:48 | 135,817,462 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,027 | java | package ru.job4j.tracker;
import java.util.Arrays;
import java.util.Random;
public class Tracker4StaticFinalClass {
private Tracker4StaticFinalClass() {
}
public static Tracker4StaticFinalClass getInstance() {
return Holder.INSTANCE;
}
private static final class Holder {
private static final Tracker4StaticFinalClass INSTANCE = new Tracker4StaticFinalClass();
}
public static void main(String[] args) {
Tracker4StaticFinalClass tracker = Tracker4StaticFinalClass.getInstance();
}
/**
* Массив для хранение заявок.
*/
private Item[] items = new Item[100];
/**
* Указатель ячейки для новой заявки.
*/
private int position = 0;
/**
* Рандомогенератор)
*/
private static final Random RN = new Random();
public Item[] getItems() {
return items;
}
/**
* Метод реализаущий добавление заявки в хранилище
*
* @param item новая заявка
*/
public Item add(Item item) {
item.setId(this.generateId());
this.items[position++] = item;
return item;
}
/**
* Метод генерирует уникальный ключ для заявки.
* Так как у заявки нет уникальности полей, имени и описание. Для идентификации нам нужен уникальный ключ.
*
* @return Уникальный ключ.
*/
private String generateId() {
return String.valueOf(System.currentTimeMillis() + RN.nextInt(100));
}
/**
* Метод возвращает весь массив без null
*
* @return
*/
public Item[] findAll() {
return Arrays.copyOf(items, position);
}
/**
* Заменяет заявку сохраняя id
*
* @param id
* @param item
*/
public boolean replace(String id, Item item) {
boolean result = false;
int inde = this.getIndex(id);
if (inde != -1) {
item.setId(this.items[inde].getId());
this.items[inde] = item;
result = true;
}
return result;
}
/**
* Удаление Item из массива по id
*
* @param id
*/
public boolean delete(String id) {
boolean result = false;
int ind = this.getIndex(id);
if (ind != -1) {
System.arraycopy(items, ind + 1, items, ind, this.items.length - ind - 1);
position--;
result = true;
}
return result;
}
/**
* Метод создает массив с совпадениями по указанному имени
*
* @param name
* @return Itemss массив совпадающих Item
*/
public Item[] findByName(String name) {
int ind = 0;
Item[] itemTemp = new Item[100];
for (Item a : items) {
if (a != null && a.getName().equals(name)) {
itemTemp[ind++] = a;
}
}
Item[] itemss = Arrays.copyOf(itemTemp, ind);
return itemss;
}
/**
* Найти Item в массиве по id
*
* @param id
* @return Возвращает Item
*/
public Item findById(String id) {
int index = getIndex(id);
Item result = null;
if (index != -1) {
result = this.items[index];
}
return result;
}
/**
* Узнать index по id
*
* @param id
* @return index
*/
public int getIndex(String id) {
int result = -1;
for (int i = 0; i < this.items.length; i++) {
if (this.items[i] != null && this.items[i].getId().equals(id)) {
result = i;
break;
}
}
return result;
}
}
| [
"[email protected]"
] | |
c520a61420e2d90c841fbbfed1693de5505bbf42 | 24aa1f592f2c5bf5723734022a6f6906191446eb | /src/org/marker/mushroom/servlet/DispatcherServlet.java | d7e941cb07eff5b011e795f1a5cab9f09d5386c0 | [] | no_license | UniqueJoker11/GeekCMS | 97b278fb137cbc953952e4a6cfd35dfdd81a48d8 | d2767e31d18cf64f2b7b5e8c89d969a025035f10 | refs/heads/master | 2020-06-03T14:47:24.174211 | 2015-06-26T06:12:24 | 2015-06-26T06:12:24 | 37,991,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,120 | java | package org.marker.mushroom.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.marker.mushroom.context.ActionContext;
import org.marker.mushroom.core.AppStatic;
import org.marker.mushroom.core.WebAPP;
import org.marker.mushroom.holder.SpringContextHolder;
import org.marker.mushroom.statistic.StatisticUtil;
/**
* 前台界面的Servlet 这个Servlet主要用来将请求转到WebAPP对象中,有核心处理类来处理前台的请求信息
*
* @author marker
* */
public class DispatcherServlet extends HttpServlet {
private static final long serialVersionUID = 6700091564520406775L;
/** 请求字符编码 */
private static final String ENCODING = "utf-8";
/** 响应内容类型 */
private static final String CONTENT_TYPE = "text/html;charset=utf-8";
/**
* 处理请求/cms?参数=值&
* @throws IOException
* */
public void progress(HttpServletRequest request,
HttpServletResponse response) throws IOException {
request.setCharacterEncoding(ENCODING);// 设置请求字符编码
response.setContentType(CONTENT_TYPE);// 设置响应字符编码
// 线程绑定请求对象和响应对象
ActionContext.currentThreadBindRequestAndResponse(request, response);
StatisticUtil s = SpringContextHolder.getBean("statisticUtil");
String ip = (String) request.getAttribute(AppStatic.REAL_IP); // 搭建了niginx request.getRemoteHost();
s.visited(ip);
// 创建应用实例(多线程模式)
WebAPP app = WebAPP.newInstance();
app.start();// 启动实例
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.progress(request, response);
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.progress(request, response);
}
/**
* 销毁
*/
@Override
public void destroy() {
super.destroy();
}
}
| [
"xiaochou913"
] | xiaochou913 |
3a9f59e7695f56bceff9a08a2706b3976c4fb062 | 291e22fd08f9a18871ba3be5b3da1e584cb2a3e0 | /src/edu/cmu/tartan/item/ItemDiamond.java | ad7867832a55bfd3a449a4545f6593cbde9f4b59 | [] | no_license | hyosangs/TartanAdventure-master-2team | 5c670f5b8aff4824b42e8ccdb5712f3c88cb2a24 | 5cd925a886bbdee89219ad7e92cd8aeec8c2ef06 | refs/heads/master | 2020-03-20T23:54:15.609035 | 2018-08-03T03:37:49 | 2018-08-03T03:37:49 | 137,868,946 | 1 | 0 | null | 2018-08-03T03:37:50 | 2018-06-19T09:21:36 | HTML | UTF-8 | Java | false | false | 640 | java | package edu.cmu.tartan.item;
import edu.cmu.tartan.properties.Holdable;
import edu.cmu.tartan.properties.Installable;
/**
* This class for a diam, which can be held and placed in something.
* <p>
* Project: LG Exec Ed SDET Program
* 2018 Jeffrey S. Gennari
* Versions:
* 1.0 March 2018 - initial version
*/
public class ItemDiamond extends Item implements Holdable, Installable {
/**
* Constructor for a diamond
* @param s description
* @param sd long description
* @param a aliases
*/
public ItemDiamond(String s, String sd, String[] a) {
super(s, sd, a);
setValue(1000);
}
} | [
"[email protected]"
] | |
0e99121314e90a306c318f17b50e3609dce86a92 | 02f3845a3cddaafcdc25b6b74f5424ed06beb4ec | /app/controllers/IndexFacesController.java | ae4f720266cf35441403bffdef3ba2304f9593e0 | [
"CC0-1.0"
] | permissive | abhinavsinha1991/cc-Image-Detection-DL | a14bb52666595d2a3cade19978f8a8ed87900341 | 6eb1ba4c3d72fe7d53d82b6fc5682265223a78ad | refs/heads/master | 2020-12-02T19:49:28.122782 | 2017-07-05T12:27:40 | 2017-07-05T12:27:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,161 | java | package controllers;
/**
* Created by abhinav on 10/6/17.
*/
import com.amazonaws.AmazonClientException;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.rekognition.AmazonRekognition;
import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder;
import com.amazonaws.services.rekognition.model.FaceRecord;
import com.amazonaws.services.rekognition.model.Image;
import com.amazonaws.services.rekognition.model.IndexFacesRequest;
import com.amazonaws.services.rekognition.model.IndexFacesResult;
import com.amazonaws.util.IOUtils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import play.libs.Json;
import play.mvc.Controller;
import play.mvc.Result;
import javax.inject.Singleton;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.List;
@Singleton
public class IndexFacesController extends Controller {
public Result index(String photoId, String collectionId) {
if(request().body() == null){
return badRequest("Expecting Json data");
}else {
File photo = request().body().asRaw().asFile();
// String photoId = json.findPath("photoId").textValue();
// String collectionId = json.findPath("collectionId").textValue();
AWSCredentials credentials;
try {
System.out.println(" CollectionID: " + collectionId);
credentials = new ProfileCredentialsProvider().getCredentials();
} catch (Exception e) {
throw new AmazonClientException(
"Cannot load the credentials from the credential profiles file. " +
"Please make sure that your credentials file is at the correct " +
"location (/Users/userid/.aws/credentials), and is in valid format.",
e);
}
ByteBuffer imageBytes = null; // Capture image from webcam
try {
InputStream inputStream = new FileInputStream(photo);
imageBytes = ByteBuffer.wrap(IOUtils.toByteArray(inputStream));
} catch (Exception e) {
System.out.println("Failed to load source image " + photo);
return badRequest("Failed to load source image");
}
AmazonRekognition amazonRekognition = AmazonRekognitionClientBuilder
.standard()
.withRegion(Regions.US_WEST_2)
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.build();
List<FaceRecord> faceRecords;
ObjectNode result = Json.newObject();
try {
Image source = new Image()
.withBytes(imageBytes);
IndexFacesResult indexFacesResult = callIndexFaces(collectionId,
photoId, "ALL", source, amazonRekognition);
faceRecords = indexFacesResult.getFaceRecords();
for (FaceRecord faceRecord : faceRecords) {
System.out.println("Face detected: Faceid is " +
faceRecord.getFace().getFaceId());
}
} catch (Exception e) {
System.out.println("Error in adding image."+ e.getMessage());
result.put("status","FAIL");
result.put("statusMessage", "Image addition failed."+e.getMessage().substring(0,e.getMessage().indexOf('(')));
return ok(result);
}
if(!faceRecords.isEmpty()) {
result.put("status", "OK");
result.put("statusMessage", "Image " + photoId + " added successfully!!");
result.put("agerange", faceRecords.get(0).getFaceDetail().getAgeRange().toString());
result.put("hasbeard", faceRecords.get(0).getFaceDetail().getBeard().toString());
result.put("gender", faceRecords.get(0).getFaceDetail().getGender().toString());
result.put("specs", faceRecords.get(0).getFaceDetail().getEyeglasses().toString());
return ok(result);
} else {
result.put("status","FAIL");
result.put("statusMessage", "No face found in image to add.");
return ok(result);
}
}
}
private static IndexFacesResult callIndexFaces(String collectionId, String externalImageId,
String attributes, Image image, AmazonRekognition amazonRekognition) {
IndexFacesRequest indexFacesRequest = new IndexFacesRequest()
.withImage(image)
.withCollectionId(collectionId)
.withExternalImageId(externalImageId)
.withDetectionAttributes(attributes);
return amazonRekognition.indexFaces(indexFacesRequest);
}
}
| [
"[email protected]"
] | |
50fab09c063e3271ac2951dc88bc3efaa9056379 | 198b020a82e4c75365c6aec9aa4a4cac53e5aaa8 | /DriverService3.0/src/com/cy/driver/assess/action/AddNewDriverUserAssessAction.java | 32e4ab77b21f8b886a62c07c2c0a7245d98ef0f6 | [] | no_license | kenjs/Java | 8cc2a6c4a13bddc12f15d62350f3181acccc48ec | 8cb9c7c93bc0cfa57d77cf3805044e5fe18778f2 | refs/heads/master | 2020-12-14T09:46:07.493930 | 2015-08-19T08:11:59 | 2015-08-19T08:11:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,567 | java | package com.cy.driver.assess.action;
import java.io.IOException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cy.common.action.BaseJsonAction;
import com.cy.common.bo.DriverUserAssessInfoBo;
import com.cy.common.bo.OperationLogInfoBo;
import com.cy.driver.assess.service.DriverUserAssessInfoService;
import com.cy.driver.operationLog.service.OperationLogService;
/**
* 新增货源评价
* @date 2014-6-9
* @author haoyong
*
*/
public class AddNewDriverUserAssessAction extends BaseJsonAction{
/**
*
*/
private static final long serialVersionUID = -5288383312711696270L;
private Logger log = LoggerFactory.getLogger(getClass());
private DriverUserAssessInfoService driverUserAssessInfoService;
public void setDriverUserAssessInfoService(
DriverUserAssessInfoService driverUserAssessInfoService) {
this.driverUserAssessInfoService = driverUserAssessInfoService;
}
protected void execMethod() throws Exception {
}
public String exec() {
try {
String driverId = request.getParameter("driverId");
if(StringUtils.isBlank(driverId)){
log.info("司机不存在");
sendResponseToJson("-9","司机不存在");
return ERROR;
}
int accFlag = operationLogService.checkUser(driverId);
if(accFlag == 1) {
log.info("该用户不存在或已被删除");
sendResponseToJson("-9","该用户不存在或已被删除");
return ERROR;
} else if(accFlag == 11) {
log.info("该用户已被冻结");
sendResponseToJson("-9","该用户已被冻结");
return ERROR;
}
log2Db(driverId);
DriverUserAssessInfoBo bo = new DriverUserAssessInfoBo();
if(StringUtils.isBlank(request.getParameter("assessEvaluateScore"))){
sendResponseToJson("-8", "请选择评分");
return ERROR;
} else {
bo.setAssessEvaluateScore(Integer.parseInt(request.getParameter("assessEvaluateScore")));
if((Integer.parseInt(request.getParameter("assessEvaluateScore")) == 9)
&& StringUtils.isBlank(request.getParameter("assess"))) {
sendResponseToJson("-8", "请说明差评原因");
return ERROR;
}
}
if(StringUtils.isBlank(request.getParameter("cargoId"))){
sendResponseToJson("-8", "货物不存在");
return ERROR;
} else {
bo.setCargoId(Integer.parseInt(request.getParameter("cargoId")));
}
if(StringUtils.isBlank(request.getParameter("userId"))){
sendResponseToJson("-8", "用户不存在");
return ERROR;
} else {
bo.setUserId(Integer.parseInt(request.getParameter("userId")));
}
if(StringUtils.isBlank(request.getParameter("transactionId"))){
sendResponseToJson("-8", "交易订单不存在");
return ERROR;
} else {
bo.setTransactionId(Integer.parseInt(request.getParameter("transactionId")));
}
bo.setDriverId(Integer.parseInt(driverId));
bo.setAssess(request.getParameter("assess"));
int key = driverUserAssessInfoService.selectAssessNum(bo);
if(key == 0) {
int i = driverUserAssessInfoService.addNewDriverUserAssessInfo(bo);
if(i == 0){
log.info("评价货源失败");
sendResponseToJson("-8", "评价货源失败");
}else{
log.info("评价货源成功");
sendResponseToJson("1", "评价货源成功");
}
} else {
bo.setId(key);
int j = driverUserAssessInfoService.updateDriverUserAssessInfo(bo);
if(j == 0){
log.info("修改货源评价失败");
sendResponseToJson("0", "修改货源评价失败");
}else{
log.info("修改货源评价成功");
sendResponseToJson("1", "修改货源评价成功");
}
}
} catch (IOException e) {
log.error(e.getMessage());
try {
sendResponseToJson("-8", e.getMessage());
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
return SUCCESS;
}
private OperationLogService operationLogService;
private void log2Db(String driverId) {
OperationLogInfoBo bo = new OperationLogInfoBo();
bo.setOperationName("addNewDriverUserAssessAction");
bo.setOperationType(42);
bo.setRemark("新增货源评价");
if(StringUtils.isNotBlank(driverId)) {
bo.setUserDriverId(Integer.parseInt(driverId));
}
operationLogService.insertOperationLog(bo);
}
public void setOperationLogService(OperationLogService operationLogService) {
this.operationLogService = operationLogService;
}
}
| [
"[email protected]"
] | |
2d08182a18926498885c7b0880c2c90be14d1260 | 1fcf55744b63123df0d297082d431ff30caa5910 | /Spring_practice/src/com/zdz/springmvc/controller/DataBinderTestController.java | a1ac45f76e2d8ddbf91d01d4a8f3eae436d87ab3 | [] | no_license | zdz-java/MyEclipse_Practice | 1a81ec8c2cf5e9e3fb4f1d08ebbbf8cc1d563436 | 9b12bb500565345607cff468f648c8ccb2c9147c | refs/heads/master | 2021-01-10T01:42:35.460059 | 2016-02-23T15:25:45 | 2016-02-23T15:25:45 | 44,595,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,921 | java | package com.zdz.springmvc.controller;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import com.zdz.bean.DataBinderTestModel;
import com.zdz.bean.PhoneNumberModel;
import com.zdz.springmvc.editor.PhoneNumberEditor;
public class DataBinderTestController extends AbstractCommandController {
public DataBinderTestController() {
setCommandClass(DataBinderTestModel.class); // 设置命令对象
setCommandName("dataBinderTest");// 设置命令对象的名字
}
@Override
protected ModelAndView handle(HttpServletRequest req,
HttpServletResponse resp, Object command, BindException errors)
throws Exception {
// 输出command对象看看是否绑定正确
System.out.println(command);
return new ModelAndView("bindAndValidate/success").addObject(
"dataBinderTest", command);
}
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
super.initBinder(request, binder);
//注册自定义的属性编辑器
//1、日期
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
CustomDateEditor dateEditor = new CustomDateEditor(df, true);
//表示如果命令对象有Date类型的属性,将使用该属性编辑器进行类型转换
binder.registerCustomEditor(Date.class, dateEditor);
//自定义的电话号码编辑器
binder.registerCustomEditor(PhoneNumberModel.class, new PhoneNumberEditor());
}
}
| [
"[email protected]"
] | |
7a8eff05214a2942b74ef48e634581fc857f7ab8 | f3a4a9028338630f5e2f30654dea92ea5acda01b | /Inliner/src/inliner/syntaxtree/VarDeclaration.java | 5fac1ee05d32570369e83dd4bacd7423fc998057 | [] | no_license | pradeep90/POPL | c71ceb0fc9c9ed4a002c95b76e3dbdd7fe911951 | 2716cc3cbf6242fd073ef8147594f7afc387c96b | refs/heads/master | 2021-10-28T06:27:28.639694 | 2016-10-10T21:24:25 | 2016-10-10T21:24:25 | 7,853,403 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 879 | java | //
// Generated by JTB 1.3.2
//
package inliner.syntaxtree;
/**
* Grammar production:
* f0 -> Type()
* f1 -> Identifier()
* f2 -> ";"
*/
public class VarDeclaration implements Node {
public Type f0;
public Identifier f1;
public NodeToken f2;
public VarDeclaration(Type n0, Identifier n1, NodeToken n2) {
f0 = n0;
f1 = n1;
f2 = n2;
}
public VarDeclaration(Type n0, Identifier n1) {
f0 = n0;
f1 = n1;
f2 = new NodeToken(";");
}
public void accept(inliner.visitor.Visitor v) {
v.visit(this);
}
public <R,A> R accept(inliner.visitor.GJVisitor<R,A> v, A argu) {
return v.visit(this,argu);
}
public <R> R accept(inliner.visitor.GJNoArguVisitor<R> v) {
return v.visit(this);
}
public <A> void accept(inliner.visitor.GJVoidVisitor<A> v, A argu) {
v.visit(this,argu);
}
}
| [
"[email protected]"
] | |
354ffc2e1ee9e2496b2101d81fa0981b6bd7df9c | e73d0aad2e66f83391519228e16b3165babc1e1a | /src/main/java/ua/dovhopoliuk/controller/command/page/pages/ReportRequestsPageCommand.java | 76e92648e3c55bd9a97bec55df5cbecbdcf5f6b3 | [] | no_license | CodeGangsta44/ServletTask | 3d25f09484657ebcdfcc0a9c4b6f490afdeb3d07 | 368687bae4749204a9efb1963f4329733fe60bd4 | refs/heads/master | 2022-07-25T19:30:36.953421 | 2019-08-15T02:26:29 | 2019-08-15T02:26:29 | 201,058,874 | 0 | 2 | null | 2022-07-06T20:46:45 | 2019-08-07T13:43:45 | Java | UTF-8 | Java | false | false | 330 | java | package ua.dovhopoliuk.controller.command.page.pages;
import ua.dovhopoliuk.controller.command.Command;
import javax.servlet.http.HttpServletRequest;
public class ReportRequestsPageCommand implements Command {
@Override
public String execute(HttpServletRequest request) {
return "/report_requests.jsp";
}
}
| [
"[email protected]"
] | |
a53c8a6e63a2e38d3db6979df6f46adb27d79561 | b300a884653f34dafa8596f6569d208676a20e2f | /app/src/main/java/beangate/datta/mapapp/MapsActivity.java | 326fb62cf8487cf707c03ab81f90b2ae4e0fb2ba | [] | no_license | sandeep56712/map | 040c420d40d19261e55d68343e9551064898469e | fea899c18ba1e8b6b8e4e498aababc47020f4bd6 | refs/heads/master | 2020-04-21T23:26:21.281468 | 2019-02-10T05:42:46 | 2019-02-10T05:42:46 | 169,946,933 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,088 | java | package beangate.datta.mapapp;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng TutorialsPoint = new LatLng(21, 57);
mMap.addMarker(new
MarkerOptions().position(TutorialsPoint).title("Tutorialspoint.com"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(TutorialsPoint));
// googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
// googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
googleMap.getUiSettings().setZoomGesturesEnabled(true);
}
}
| [
"[email protected]"
] | |
a2643af64067d2ecdf9a55e04c59c8093ebf4aa7 | d4dbb0571226af5809cc953e73924d505094e211 | /Hibernate/07.BestPracticesAndArchitecture/BestPracticesExercises/src/main/java/onlineshop/serviceImpls/OrderServiceImpl.java | f825e14522c3590c667b074ae4bb72ef68bb2229 | [] | no_license | vasilgramov/database-fundamentals | 45e258e965e85514e60b849d9049737ae25e81c0 | 0ebe74ab4bffef0d29d6ee2e200f07bdc24fe6bf | refs/heads/master | 2021-06-18T17:54:36.238976 | 2017-07-10T14:49:44 | 2017-07-10T14:49:44 | 89,739,950 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,026 | java | package onlineshop.serviceImpls;
import onlineshop.domains.factories.OrderFactory;
import onlineshop.domains.models.Location;
import onlineshop.domains.models.Order;
import onlineshop.repositories.OrderRepository;
import onlineshop.services.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class OrderServiceImpl implements OrderService {
private final OrderFactory orderFactory;
private final OrderRepository orderRepository;
@Autowired
public OrderServiceImpl(OrderFactory orderFactory, OrderRepository orderRepository) {
this.orderFactory = orderFactory;
this.orderRepository = orderRepository;
}
@Override
public Order create(Date date, Location location) {
return this.orderFactory.create(date, location);
}
@Override
public Order persist(Order order) {
this.orderRepository.saveAndFlush(order);
return order;
}
}
| [
"[email protected]"
] | |
7e2865b1798af4553b96cd81dbc7734f54ac0f80 | 73f3f968cb16cf468cdd85f20851d6bbf8fc8605 | /app/src/androidTest/java/com/example/formulatioalumnos/ExampleInstrumentedTest.java | c50b8a243e7385cbebe3f3655d8ddbff03ef432b | [] | no_license | Rogelio02/FormularioConBD | 7717411388a044cd7baa7b2feac711f2ccdb1549 | d1542662c073d0031f1bee50e1b98aadf26c4ccb | refs/heads/master | 2020-05-16T10:01:16.637494 | 2019-04-23T09:29:20 | 2019-04-23T09:29:20 | 182,966,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 742 | java | package com.example.formulatioalumnos;
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.formulatioalumnos", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
8a1c99533839e0111c61a50af456c48add52808d | 53d1b32dd3e4c44f01bee9bb8f28fc6ab3509851 | /src/main/java/com/epam/training/parser/SAXCarBuilder.java | b37cfb0883ba2e30918f25158d5b17ee342406a2 | [] | no_license | selfdenied/xml-task | b81aab2343215734733744f9ba79f648da10704b | 63bf0febec3330e02eb1e62a6bce0adb665418a2 | refs/heads/master | 2021-01-20T11:43:44.671433 | 2015-06-09T15:16:38 | 2015-06-09T15:16:38 | 37,027,948 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,382 | java | package com.epam.training.parser;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import com.epam.training.parser.handler.CarHandler;
/*
* The class builds a list of taxi cars. The data is stored
* in the XML file. SAX parser is used to extract the data.
*/
public class SAXCarBuilder extends AbstractCarBuilder {
/* getting the logger reference */
private static final Logger LOG = Logger.getLogger(SAXCarBuilder.class);
private CarHandler carHandler;
private XMLReader xmlReader;
/* creating XML reader and setting the ContentHandler */
public SAXCarBuilder() {
super();
this.carHandler = new CarHandler();
try {
this.xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(carHandler);
} catch (SAXException exception) {
LOG.error("Error. No default XMLReader class was identified!",
exception);
}
}
@Override
public void buildTaxiFleet(String filePath) {
try {
/* parsing the XML file */
xmlReader.parse(filePath);
} catch (SAXException exception) {
LOG.error("SAX parser error!", exception);
} catch (IOException exception) {
LOG.error("I/O stream error!", exception);
}
/* getting the taxi fleet from a CarHandler */
this.taxiFleet = carHandler.getTaxiFleet();
}
}
| [
"[email protected]"
] | |
a0eee65b34c76c2a583700b7aaf62ce07fd16ffe | b34654bd96750be62556ed368ef4db1043521ff2 | /review_process_improvements_updates_pack_2/trunk/project_management_1.1.0_dev_submission/src/java/tests/com/topcoder/management/project/ApplicationsManagerExceptionUnitTests.java | c5a0feb7aa82f1a95f7af4a70def047d9e2e6d0f | [] | no_license | topcoder-platform/tcs-cronos | 81fed1e4f19ef60cdc5e5632084695d67275c415 | c4ad087bb56bdaa19f9890e6580fcc5a3121b6c6 | refs/heads/master | 2023-08-03T22:21:52.216762 | 2019-03-19T08:53:31 | 2019-03-19T08:53:31 | 89,589,444 | 0 | 1 | null | 2019-03-19T08:53:32 | 2017-04-27T11:19:01 | null | UTF-8 | Java | false | false | 1,577 | java | /*
* Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.management.project;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* <p>
* Unit test for ApplicationsManagerException class.
* </p>
*
* @author pvmagacho
* @version 1.1
*/
public class ApplicationsManagerExceptionUnitTests extends TestCase {
/**
* Aggregates all tests in this class.
*
* @return Test suite aggregating all tests.
*/
public static Test suite() {
return new TestSuite(ApplicationsManagerExceptionUnitTests.class);
}
/**
* Accuracy test of <code>ApplicationsManagerException(String message)</code> constructor.
*
* @throws Exception throw exception to JUnit.
*/
public void testApplicationsManagerExceptionAccuracy1() throws Exception {
ApplicationsManagerException ce = new ApplicationsManagerException("test");
assertEquals("message is incorrect.", "test", ce.getMessage());
}
/**
* Accuracy test of <code>ApplicationsManagerException(String message, Throwable cause)</code> constructor.
*
* @throws Exception throw exception to JUnit.
*/
public void testApplicationsManagerExceptionAccuracy2() throws Exception {
Exception e = new Exception("error1");
ApplicationsManagerException ce = new ApplicationsManagerException("error2", e);
assertEquals("message is incorrect.", "error2", ce.getMessage());
assertEquals("cause is incorrect.", e, ce.getCause());
}
}
| [
"gjw99@fb370eea-3af6-4597-97f7-f7400a59c12a"
] | gjw99@fb370eea-3af6-4597-97f7-f7400a59c12a |
f5201432e3fa73d442e73562bd69df31598365e7 | d6397782d975fc9e27bdc079b9d085159b064ff7 | /src/main/java/co/laomag/es_spider/service/UserService.java | 0b936f799d1be83a285e47644e477530da17924c | [] | no_license | ma2695212419/es_spider | c9883ec8bc9215cd19d6beb7d121bfb4beeea60f | c330079c10bccbd8cc1973a4a87126b75c3b6eeb | refs/heads/master | 2023-05-06T22:56:45.618343 | 2021-05-25T15:33:17 | 2021-05-25T15:33:17 | 362,094,183 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 254 | java | package co.laomag.es_spider.service;
import co.laomag.es_spider.models.RequestMessages;
import co.laomag.es_spider.models.Userinfo;
import com.github.pagehelper.PageInfo;
public interface UserService {
RequestMessages AddUser(Userinfo userinfo);
}
| [
"[email protected]"
] | |
52290e2e9839195aa90cc0c429ac64b69821952a | d2a63ceca83d07ce6509d1d44d667b6953258bb1 | /src/zig/zak/media/tor/search/soundcloud/SoundcloundUser.java | 4ef2cfc6b96cbee11b6cfd63476af590ca9da64d | [] | no_license | alpha97/MediaTor | 626a3addaa0f580c9d69e7400b7cfac6ab1f0510 | 6eb03c0333bb74a36968d88b535ad01196da6fcc | refs/heads/master | 2020-09-03T03:53:34.374638 | 2019-09-08T15:54:21 | 2019-09-08T15:54:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,031 | java | /*
* Created by Angel Leon (@gubatron), Alden Torres (aldenml)
* Copyright (c) 2011-2016, FrostWire(R). All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package zig.zak.media.tor.search.soundcloud;
/**
* @author gubatron
* @author aldenml
*/
final class SoundcloundUser {
public int id;
public String kind;
public String username;
public String uri;
public String avatar_url;
}
| [
"[email protected]"
] | |
cd6ea945aea609f28fe978fa118bfe828dce5878 | 932807243a7911f8843ad9a19b4ab5e62402062d | /spring-framework-5.1.3.RELEASE/spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java | b8f692c82b1c27e62489a64b4430d860b8959b7b | [
"Apache-2.0"
] | permissive | hu396448218/spring-source-study | daad67e55674b6dfe7c39adcb873819b03ab1004 | 8059d6d846eae11ad86225356c101caef6e6c1db | refs/heads/main | 2023-03-31T12:06:58.015401 | 2021-04-05T10:19:30 | 2021-04-05T10:19:30 | 354,787,051 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,589 | java | /*
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context.annotation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ConfigurationCondition.ConfigurationPhase;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Internal class used to evaluate {@link Conditional} annotations.
*
* @author Phillip Webb
* @author Juergen Hoeller
* @since 4.0
*/
class ConditionEvaluator {
private final ConditionContextImpl context;
/**
* Create a new {@link ConditionEvaluator} instance.
*/
public ConditionEvaluator(@Nullable BeanDefinitionRegistry registry,
@Nullable Environment environment, @Nullable ResourceLoader resourceLoader) {
this.context = new ConditionContextImpl(registry, environment, resourceLoader);
}
/**
* Determine if an item should be skipped based on {@code @Conditional} annotations.
* The {@link ConfigurationPhase} will be deduced from the type of item (i.e. a
* {@code @Configuration} class will be {@link ConfigurationPhase#PARSE_CONFIGURATION})
* @param metadata the meta data
* @return if the item should be skipped
*/
public boolean shouldSkip(AnnotatedTypeMetadata metadata) {
return shouldSkip(metadata, null);
}
/**
* Determine if an item should be skipped based on {@code @Conditional} annotations.
* @param metadata the meta data
* @param phase the phase of the call
* @return if the item should be skipped
*/
public boolean shouldSkip(@Nullable AnnotatedTypeMetadata metadata, @Nullable ConfigurationPhase phase) {
if (metadata == null || !metadata.isAnnotated(Conditional.class.getName())) {
return false;
}
if (phase == null) {
if (metadata instanceof AnnotationMetadata &&
ConfigurationClassUtils.isConfigurationCandidate((AnnotationMetadata) metadata)) {
return shouldSkip(metadata, ConfigurationPhase.PARSE_CONFIGURATION);
}
return shouldSkip(metadata, ConfigurationPhase.REGISTER_BEAN);
}
List<Condition> conditions = new ArrayList<>();
for (String[] conditionClasses : getConditionClasses(metadata)) {
for (String conditionClass : conditionClasses) {
Condition condition = getCondition(conditionClass, this.context.getClassLoader());
conditions.add(condition);
}
}
AnnotationAwareOrderComparator.sort(conditions);
for (Condition condition : conditions) {
ConfigurationPhase requiredPhase = null;
if (condition instanceof ConfigurationCondition) {
requiredPhase = ((ConfigurationCondition) condition).getConfigurationPhase();
}
if ((requiredPhase == null || requiredPhase == phase) && !condition.matches(this.context, metadata)) {
return true;
}
}
return false;
}
@SuppressWarnings("unchecked")
private List<String[]> getConditionClasses(AnnotatedTypeMetadata metadata) {
MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(Conditional.class.getName(), true);
Object values = (attributes != null ? attributes.get("value") : null);
return (List<String[]>) (values != null ? values : Collections.emptyList());
}
private Condition getCondition(String conditionClassName, @Nullable ClassLoader classloader) {
Class<?> conditionClass = ClassUtils.resolveClassName(conditionClassName, classloader);
return (Condition) BeanUtils.instantiateClass(conditionClass);
}
/**
* Implementation of a {@link ConditionContext}.
*/
private static class ConditionContextImpl implements ConditionContext {
@Nullable
private final BeanDefinitionRegistry registry;
@Nullable
private final ConfigurableListableBeanFactory beanFactory;
private final Environment environment;
private final ResourceLoader resourceLoader;
@Nullable
private final ClassLoader classLoader;
public ConditionContextImpl(@Nullable BeanDefinitionRegistry registry,
@Nullable Environment environment, @Nullable ResourceLoader resourceLoader) {
this.registry = registry;
this.beanFactory = deduceBeanFactory(registry);
this.environment = (environment != null ? environment : deduceEnvironment(registry));
this.resourceLoader = (resourceLoader != null ? resourceLoader : deduceResourceLoader(registry));
this.classLoader = deduceClassLoader(resourceLoader, this.beanFactory);
}
@Nullable
private ConfigurableListableBeanFactory deduceBeanFactory(@Nullable BeanDefinitionRegistry source) {
if (source instanceof ConfigurableListableBeanFactory) {
return (ConfigurableListableBeanFactory) source;
}
if (source instanceof ConfigurableApplicationContext) {
return (((ConfigurableApplicationContext) source).getBeanFactory());
}
return null;
}
private Environment deduceEnvironment(@Nullable BeanDefinitionRegistry source) {
if (source instanceof EnvironmentCapable) {
return ((EnvironmentCapable) source).getEnvironment();
}
return new StandardEnvironment();
}
private ResourceLoader deduceResourceLoader(@Nullable BeanDefinitionRegistry source) {
if (source instanceof ResourceLoader) {
return (ResourceLoader) source;
}
return new DefaultResourceLoader();
}
@Nullable
private ClassLoader deduceClassLoader(@Nullable ResourceLoader resourceLoader,
@Nullable ConfigurableListableBeanFactory beanFactory) {
if (resourceLoader != null) {
ClassLoader classLoader = resourceLoader.getClassLoader();
if (classLoader != null) {
return classLoader;
}
}
if (beanFactory != null) {
return beanFactory.getBeanClassLoader();
}
return ClassUtils.getDefaultClassLoader();
}
@Override
public BeanDefinitionRegistry getRegistry() {
Assert.state(this.registry != null, "No BeanDefinitionRegistry available");
return this.registry;
}
@Override
@Nullable
public ConfigurableListableBeanFactory getBeanFactory() {
return this.beanFactory;
}
@Override
public Environment getEnvironment() {
return this.environment;
}
@Override
public ResourceLoader getResourceLoader() {
return this.resourceLoader;
}
@Override
@Nullable
public ClassLoader getClassLoader() {
return this.classLoader;
}
}
}
| [
"[email protected]"
] | |
d2c3539a9d53702bb869cc473749e2600cdd7ba8 | 18bbebbed1235c04c3a7c4318c9a29af15e812e2 | /java-client/src/main/java/io/fluxcapacitor/javaclient/tracking/client/TrackingClient.java | affeeb8deed14ac8fcd90767f6292e68f489bc2b | [
"Apache-2.0"
] | permissive | donders/flux-capacitor-client | 9f7e29f2fb61656a551fb73d714ec88a265a47e4 | dce07713baa327bcc89c0edea91b2ba37e160079 | refs/heads/master | 2020-04-01T23:46:52.214648 | 2018-10-19T11:33:03 | 2018-10-19T11:33:03 | 153,772,961 | 0 | 0 | null | 2018-10-19T11:30:37 | 2018-10-19T11:30:37 | null | UTF-8 | Java | false | false | 1,012 | java | /*
* Copyright (c) 2016-2017 Flux Capacitor.
*
* 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 io.fluxcapacitor.javaclient.tracking.client;
import io.fluxcapacitor.common.api.tracking.MessageBatch;
import java.time.Duration;
public interface TrackingClient {
MessageBatch read(String consumer, int channel, int maxSize, Duration maxTimeout, String typeFilter,
boolean ignoreMessageTarget);
void storePosition(String consumer, int[] segment, long lastIndex);
}
| [
"[email protected]"
] | |
0ad1b78d28f4fab2a77ee7066098dea46cedc8ed | e8203f16499e2d5566175d836906d405934a2ea9 | /src/com/suyin/utils/zxing/BufferedImageLuminanceSource.java | 18458eeb9b89795b87ca6573654cb7332a07d194 | [] | no_license | lizheng64677/wxService | 0109a411c83fd81309922e0d90cf257fedacf203 | 3e88a7362188785e7a5b51346676d45afeffebdf | refs/heads/master | 2020-03-11T07:56:32.245389 | 2018-06-02T10:56:20 | 2018-06-02T10:56:20 | 129,870,578 | 0 | 1 | null | 2018-04-21T10:47:50 | 2018-04-17T08:17:32 | JavaScript | UTF-8 | Java | false | false | 2,870 | java | package com.suyin.utils.zxing;
import com.google.zxing.LuminanceSource;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
public final class BufferedImageLuminanceSource extends LuminanceSource {
private final BufferedImage image;
private final int left;
private final int top;
public BufferedImageLuminanceSource(BufferedImage image) {
this(image, 0, 0, image.getWidth(), image.getHeight());
}
public BufferedImageLuminanceSource(BufferedImage image, int left, int top, int width, int height) {
super(width, height);
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
if (left + width > sourceWidth || top + height > sourceHeight) {
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
}
for (int y = top; y < top + height; y++) {
for (int x = left; x < left + width; x++) {
if ((image.getRGB(x, y) & 0xFF000000) == 0) {
image.setRGB(x, y, 0xFFFFFFFF); // = white
}
}
}
this.image = new BufferedImage(sourceWidth, sourceHeight, BufferedImage.TYPE_BYTE_GRAY);
this.image.getGraphics().drawImage(image, 0, 0, null);
this.left = left;
this.top = top;
}
@Override
public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == null || row.length < width) {
row = new byte[width];
}
image.getRaster().getDataElements(left, top + y, width, 1, row);
return row;
}
@Override
public byte[] getMatrix() {
int width = getWidth();
int height = getHeight();
int area = width * height;
byte[] matrix = new byte[area];
image.getRaster().getDataElements(left, top, width, height, matrix);
return matrix;
}
@Override
public boolean isCropSupported() {
return true;
}
@Override
public LuminanceSource crop(int left, int top, int width, int height) {
return new BufferedImageLuminanceSource(image, this.left + left, this.top + top, width, height);
}
@Override
public boolean isRotateSupported() {
return true;
}
@Override
public LuminanceSource rotateCounterClockwise() {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
AffineTransform transform = new AffineTransform(0.0, -1.0, 1.0, 0.0, 0.0, sourceWidth);
BufferedImage rotatedImage = new BufferedImage(sourceHeight, sourceWidth, BufferedImage.TYPE_BYTE_GRAY);
Graphics2D g = rotatedImage.createGraphics();
g.drawImage(image, transform, null);
g.dispose();
int width = getWidth();
return new BufferedImageLuminanceSource(rotatedImage, top, sourceWidth - (left + width), getHeight(), width);
}
} | [
"qq329009099"
] | qq329009099 |
a2b56fb8c56e61f8a6a80eeec165fbbe5d688b18 | 0418cf2c79a27ffb1712788d89ff4db3fb06be0b | /src/main/java/com/roroldo/principles/dependencyInversion/improve/way_setter/Client.java | f9d809a0dc6ee7d2a8cf6f06c7aabc5be76c6057 | [] | no_license | Roroldo/DesignPatterns | 1cbfd40cc749e9593872f59553da7a085dfd0046 | 00777ccb44922423ef61e3f5eb53ef14f6c4df40 | refs/heads/master | 2023-04-28T08:30:53.269447 | 2021-05-16T15:36:49 | 2021-05-16T15:36:49 | 332,967,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,157 | java | package com.roroldo.principles.dependencyInversion.improve.way_setter;
/**
* setter方法实现
* @author 落霞不孤
*/
public class Client {
public static void main(String[] args) {
MobilePhone mobilePhone = new MobilePhone();
Email email = new Email();
Qq qq = new Qq();
mobilePhone.setReceiver(email);
mobilePhone.receive();
mobilePhone.setReceiver(qq);
mobilePhone.receive();
}
}
/**
* 手机类 接受消息
*/
class MobilePhone {
private IReceiver receiver;
public void setReceiver(IReceiver receiver) {
this.receiver = receiver;
}
public void receive() {
System.out.println(this.receiver.getInfo());
}
}
/**
* 接受消息抽象接口
*/
interface IReceiver {
String getInfo();
}
/**
* 邮件
*/
class Email implements IReceiver {
@Override
public String getInfo() {
return "谷歌邮件:ding~ 您收到一封新的邮件..";
}
}
/**
* QQ
*/
class Qq implements IReceiver {
@Override
public String getInfo() {
return "QQ:您的特殊关心发表了新的空间,点击查看~";
}
} | [
"[email protected]"
] | |
11738d17aee338da4399fd3863dde2d8fa07629a | bf1b1206c4f29e57d494acc1edbe2f807ce236d2 | /src/main/java/com/grokonez/jwtauthentication/message/response/JwtResponse.java | b410eff530f87ac339c9c09d408281ad6aba3ee1 | [] | no_license | elyadmanii/coproline1 | 9633e2dc8b5492645eb9f9f778eb1c42f738304d | 0b22ae0c97bc4cf3d44414b7c7d0d81f10d34d2b | refs/heads/master | 2020-04-22T07:30:26.417421 | 2019-09-27T20:05:46 | 2019-09-27T20:05:46 | 170,218,592 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,224 | java | package com.grokonez.jwtauthentication.message.response;
import java.util.Collection;
import org.springframework.security.core.GrantedAuthority;
import com.grokonez.jwtauthentication.model.User;
public class JwtResponse {
private String token;
private String type = "Bearer";
private String username;
private User user;
private Collection<? extends GrantedAuthority> authorities;
public JwtResponse(String accessToken, String username,User user, Collection<? extends GrantedAuthority> authorities) {
this.token = accessToken;
this.username = username;
this.user = user;
this.authorities = authorities;
}
public String getAccessToken() {
return token;
}
public void setAccessToken(String accessToken) {
this.token = accessToken;
}
public String getTokenType() {
return type;
}
public void setTokenType(String tokenType) {
this.type = tokenType;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
}
} | [
"[email protected]"
] | |
fb079daf8b35b1b8cdd1bb7d525887f44d5b6a64 | f2f0cbb20f53eae0e336121eebb8afbfe20b6220 | /spring-datajpa-postgresql/src/main/java/com/haydikodlayalim/DatajpaApplication.java | a483f5134be2dae0b0deba89dad81ba6092bc048 | [] | no_license | klonesa/spring-boot-examples | 91c36295068f2af27271e56c8230685f3fbf370d | c370bc6c8e23fc67d2e25695dd07aae8ed9fa377 | refs/heads/main | 2023-08-23T22:59:28.442823 | 2021-09-29T22:15:53 | 2021-09-29T22:15:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package com.haydikodlayalim;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EnableJpaRepositories //bu paket altindaki tum jpa repositorylerini initialize et
public class DatajpaApplication {
public static void main(String[] args) {
SpringApplication.run(DatajpaApplication.class, args);
}
}
| [
"[email protected]"
] | |
33763dcd8185cc4f1d5d4080ea8f2db986d2c8c1 | 9d864f5a053b29d931b4c2b4f773e13291189d27 | /src/postem/postem-api/src/java/org/sakaiproject/api/app/postem/data/GradebookManager.java | 8753b2d68cf0669869f8f307eb0cd58b85017fb9 | [] | no_license | kyeddlapalli/sakai-cle | b1bd1e4431d8d96b6b650bfe9454eacd3e7042b2 | 1f06c7ac69c7cbe731c8d175d557313d0fb34900 | refs/heads/master | 2021-01-18T10:57:25.449065 | 2014-01-12T21:18:15 | 2014-01-12T21:18:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,419 | java | /**********************************************************************************
* $URL: https://source.sakaiproject.org/svn/postem/trunk/postem-api/src/java/org/sakaiproject/api/app/postem/data/GradebookManager.java $
* $Id: GradebookManager.java 125618 2013-06-11 16:41:26Z [email protected] $
***********************************************************************************
*
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 The Sakai Foundation
*
* Licensed under the Educational Community 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.opensource.org/licenses/ECL-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.sakaiproject.api.app.postem.data;
import java.util.List;
import java.util.SortedSet;
public interface GradebookManager {
public Gradebook createGradebook(String title, String creator,
String context, List headings, SortedSet students, Template template, String fileReference);
public Gradebook createEmptyGradebook(String creator, String context);
public StudentGrades createStudentGradesInGradebook(String username,
List grades, Gradebook gradebook);
public StudentGrades createStudentGrades(String username, List grades);
public Template createTemplate(String template);
public Gradebook getGradebookByTitleAndContext(final String title,
final String context);
public SortedSet getGradebooksByContext(final String context, final String sortBy, final boolean ascending);
public SortedSet getReleasedGradebooksByContext(final String context, final String sortBy, final boolean ascending);
public SortedSet getStudentGradesForGradebook(final Gradebook gradebook);
public void saveGradebook(Gradebook gradebook);
public void updateGrades(Gradebook gradebook, List headings,
SortedSet students);
public void updateTemplate(Gradebook gradebook, String template, String fileReference);
public void deleteGradebook(final Gradebook gradebook);
public void deleteStudentGrades(final StudentGrades student);
/**
*
* @param gradebookId
* @return gradebook object with the headings and student data populated
*/
public Gradebook getGradebookByIdWithHeadingsAndStudents(final Long gradebookId);
/**
*
* @param gradebookId
* @return gradebook object with headings populated, not students
*/
public Gradebook getGradebookByIdWithHeadings(final Long gradebookId);
/**
* Return the StudentGrades object associated with the given gradebook and
* username
* @param gradebook
* @param username
* @return
*/
public StudentGrades getStudentByGBAndUsername(final Gradebook gradebook, final String username);
/**
* Update an individual StudentGrades object
* @param student
*/
public void updateStudent(StudentGrades student);
/**
*
* @param gradebook
* @return a list of all of the usernames associated with the given gradebook
*/
public List getUsernamesInGradebook(Gradebook gradebook);
}
| [
"[email protected]"
] | |
fb67efde7593fd6d320cbea5823dd340a6418aa2 | f734a18f8d05c709b0f5e1ed7d5c39fd45aed680 | /feature-test/src/main/java/demo/helloworld/GH260.java | 2cc34b5b4275943b4bde12a55048eb8709cea59a | [
"Apache-2.0"
] | permissive | luketn/act-demo-apps | dffdc9c2ebfe3048e33f595c7c22aebca6f849ae | e1b753e3824df09a48d66258fadc08520e2ea6c2 | refs/heads/master | 2021-08-20T03:16:20.726854 | 2017-11-28T03:42:03 | 2017-11-28T03:42:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 378 | java | package demo.helloworld;
import act.controller.annotation.UrlContext;
import act.util.DisableFastJsonCircularReferenceDetect;
import demo.helloworld.gh251.Foo;
import org.osgl.mvc.annotation.GetAction;
@UrlContext("260")
public class GH260 extends GHTest {
@DisableFastJsonCircularReferenceDetect
@GetAction
public Foo foo() {
return new Foo();
}
}
| [
"[email protected]"
] | |
7cc5cc186508669e969fe822dc2449e1e0ac5f86 | f1b844dc2f5307c6a7847d45330a24f35e11ffa8 | /app/src/main/java/com/example/carapp/SplashScreenActivity.java | fdda94eacc57480a7fa943395db191439c386cc7 | [] | no_license | NithyaYamsinghe/RentACar | 43341d8615091b0b5b1d135f669deb27df1e5b6d | b2df268f22d0918caa74490db27f297daeeca2ca | refs/heads/master | 2022-04-10T09:10:30.286153 | 2020-03-17T18:13:27 | 2020-03-17T18:13:27 | 248,040,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,734 | java | package com.example.carapp;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
public class SplashScreenActivity extends AppCompatActivity {
private static int SPLASH_TIMER = 5000;
// Initializing variables
ImageView backgroundImage;
TextView sloganText;
// Animation variables
Animation sideAnim, sideBottomAnim;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash_screen);
// Hooks
backgroundImage = findViewById(R.id.splash_background_image);
sloganText = findViewById(R.id.slogan);
// Animation
sideAnim = AnimationUtils.loadAnimation(this, R.anim.side_animation);
sideBottomAnim = AnimationUtils.loadAnimation(this, R.anim.side_bottom_animation);
// Set animations on elements
backgroundImage.setAnimation(sideAnim);
sloganText.setAnimation(sideBottomAnim);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreenActivity.this, DashboardActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_TIMER);
}
}
| [
"[email protected]"
] | |
5d6a3cd9ca727d05f86bab20a113d23b7ccd1629 | 52f25aed45024d888f7eb48a81ddbea712eeb621 | /exercise/HortonExercises/Ch05/Rectangles/TestRectangle.java | f94f7e983b6fac920efc4ab5cda9e68243052c0b | [] | no_license | asszem/JavaLearning | 7ef8e9fb0ec605340254ac604520a2b6484da299 | 1c0aae2e1f19e0f5f84315aafc9afd13c2b9a98d | refs/heads/master | 2021-01-23T01:55:41.428926 | 2017-07-09T10:42:02 | 2017-07-09T10:42:02 | 85,943,287 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,560 | java | package HortonExercises.Ch05.Rectangles;
//Chapter 5, Exercise 1
/*
Define a class for rectangle objects defined by two points,
the top-left and bottom-right corners of the rectangle.
Include a constructor to copy a rectangle, a method to return a rectangle object
that encloses the current object and the rectangle passed as an argument,
and a method to display the defining points of a rectangle.
Test the class by creating four rectangles and combining these cumulatively
to end up with a rectangle enclosing them all.
Output the defining points of all the rectangles you create.
*/
// This tests the Rectangle class that appears in the same directory as this.
public class TestRectangle {
public static void main(String args[]) {
Rectangle[] rects = new Rectangle[4];
Rectangle enclosing;
// Initialize the rectangles as arbitrary sizes and at arbitrary positions:
for(int i = 0 ; i < rects.length ; ++i) {
rects[i] = new Rectangle(Math.random()*100, Math.random()*100, Math.random()*100, Math.random()*100);
System.out.print("Coords of rectangle " + i + " are: ");
System.out.println(rects[i]);
}
// Initialize the enclosing rectangle to be first rectangle
enclosing = rects[0];
// Combine it with each the other rectangles in turn.
// This will result in the rectangle that encloses them all.
for(Rectangle rect : rects) {
enclosing = enclosing.encloses(rect);
}
System.out.println("\nCoords of Enclosing rectangle are ");
System.out.println(enclosing);
}
} | [
"[email protected]"
] | |
dc1b2ec807edf763a676603caa8eb18a7ce0c5e7 | 0863f174b7dee7d77c4b42793ff6f4ddda855227 | /src/com/example/sudokusolver/android/SudokuView.java | 16caeb37c815d69a732f88f00e1ea9942b0ca9ec | [] | no_license | oliveross/SudokuSolver | 8cd08e4fd9c3a7a3dd97ac8db4982fd3e7bf92fb | 78c5e3226c9b8a17bc01f7a94b6aaf6d3ec34abb | refs/heads/master | 2021-05-28T22:54:17.123189 | 2015-05-26T00:37:44 | 2015-05-26T00:37:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,122 | java | package com.example.sudokusolver.android;
import com.example.sudokusolver.R;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.Paint.FontMetrics;
import android.graphics.Rect;
import android.util.Log;
import android.view.View;
public class SudokuView extends View {
public static final int BOLD_WIDTH = 5;
public static final int BORDER_WIDTH = 2;
private Paint mBorderLine;
private Paint mBoldLine;
private Paint mGreyLine;
private Paint mTextBold;
private Paint mTextNormal;
private float top, bottom, left, right;
private float rectDimens;
private float width, height;
private int[][] mSolved;
private int[][] mUnsolved;
public SudokuView(Context context, int[][] unsolved, int[][] solved) {
super(context);
mSolved = solved;
mUnsolved = unsolved;
mBorderLine = new Paint();
mBorderLine.setColor(getResources().getColor(R.color.black));
mBorderLine.setStrokeWidth(BORDER_WIDTH);
mBoldLine = new Paint();
mBoldLine.setColor(getResources().getColor(R.color.black));
mBoldLine.setStrokeWidth(BOLD_WIDTH);
mGreyLine = new Paint();
mGreyLine.setColor(getResources().getColor(R.color.grey));
mTextBold = new Paint();
mTextNormal = new Paint();
}
@Override
protected void onDraw(Canvas canvas) {
// get dimensions for sudoku grid
rectDimens = (float) (this.getWidth() * 0.9);
top = this.getHeight() / 2 - rectDimens / 2;
bottom = top + rectDimens;
left = (float) (this.getWidth() * 0.05);
right = left + rectDimens;
width = right - left;
height = bottom - top;
// draw lines
drawGreyLines(canvas);
drawBoldLines(canvas);
drawBorderLines(canvas);
// set up paint for text
mTextBold.setTextAlign(Paint.Align.CENTER);
mTextBold.setTextSize(width / 9 * 0.75f);
mTextBold.setTypeface(Typeface.DEFAULT_BOLD);
mTextNormal.setTextAlign(Paint.Align.CENTER);
mTextNormal.setTextSize(width / 9 * 0.75f);
mTextNormal.setColor(Color.GRAY);
// find offset to center line
FontMetrics fm = mTextBold.getFontMetrics();
float offset = (fm.ascent + fm.descent) / 2;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
Log.d("array: " + i + "," + j, mSolved[i][j] + ","
+ mUnsolved[i][j]);
}
}
drawDigits(canvas, offset);
}
/**
* draws the digits to the sudoku grid
*
* @param canvas
* @param offset
*/
private void drawDigits(Canvas canvas, float offset) {
float tileWidth = width / 9;
float tileHeight = height / 9;
for (int i = 0; i < mSolved.length; i++) {
for (int j = 0; j < mSolved[0].length; j++) {
float x = left + tileWidth * i + tileWidth / 2;
float y = top + tileHeight * j + tileHeight / 2 - offset;
// if it an original number, then draw with bold font
if (mUnsolved[i][j] != 0) {
canvas.drawText(Integer.toString(mSolved[i][j]), x, y,
mTextBold);
// if it is part of solution, then draw with regular grey
// font
} else {
canvas.drawText(Integer.toString(mSolved[i][j]), x, y,
mTextNormal);
}
}
}
}
private void drawGreyLines(Canvas canvas) {
// inner grey lines
for (int i = (int) left; i < (int) right; i += width / 9) {
canvas.drawLine(i, top, i, bottom, mGreyLine);
}
for (int i = (int) top; i < (int) bottom; i += height / 9) {
canvas.drawLine(left, i, right, i, mGreyLine);
}
}
private void drawBoldLines(Canvas canvas) {
// major bold lines
for (int i = (int) (left + (right - left) / 3); i < right; i += width / 3) {
canvas.drawLine(i, top, i, bottom, mBoldLine);
}
for (int i = (int) (top + (bottom - top) / 3); i < bottom; i += height / 3) {
canvas.drawLine(left, i, right, i, mBoldLine);
}
}
private void drawBorderLines(Canvas canvas) {
// border
canvas.drawLine(left, top, left, bottom, mBorderLine); // left
canvas.drawLine(left, top, right, top, mBorderLine); // top
canvas.drawLine(right, top, right, bottom, mBorderLine); // right
canvas.drawLine(left, bottom, right, bottom, mBorderLine); // bottom
}
}
| [
"[email protected]"
] | |
6e8a77e14a799d3976cf77338062d487b0178639 | e58d3e45aa687bef0261c52af1e0a765ec330180 | /src/org/swiftgantt/ui/LogoViewUI.java | b637a02d3a3996e5535015acd0ce40bc48c4196c | [] | no_license | Kihansi95/FlexibleJobShop | f4976d1f86fce767b38792ca6998c20c04306a68 | 9251eb441fd51cdea7071260fb733546c8b96fa0 | refs/heads/master | 2020-03-15T11:12:49.549300 | 2018-06-10T11:19:18 | 2018-06-10T11:19:18 | 132,115,996 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,979 | java | package org.swiftgantt.ui;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.LabelUI;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.swiftgantt.LogoView;
import org.swiftgantt.common.LogHelper;
/**
* paint logo and version for <code>LogoView.java</code>
* @author Yuxing Wang
*
*/
public class LogoViewUI extends LabelUI {
protected LogoView logoView = null;
protected Logger logger = null;
private int fontSize = 28;
public LogoViewUI() {
logger = LogManager.getLogger(LogoViewUI.class);
}
public static ComponentUI createUI(JComponent c) {
return new LogoViewUI();
}
@Override
public void installUI(JComponent c) {
logoView = (LogoView) c;
super.installUI(c);
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
LogHelper.title(logger, "Start to Paint Logo View UI");
int width = c.getSize().width;
int height = c.getSize().height;
logger.debug(width);
logger.debug(height);
// Rectangle rec = new Rectangle(0, 0, width, height);
// g.setColor(this.logoView.getGanttChart().getConfig().getGanttChartBackColor());
// g.fillRect(0, 0, width, height);
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
// Draw Brand "SwiftGantt"
g.setFont(new Font("Colonna MT", Font.BOLD, fontSize));
String brand = logoView.getText();
if (brand != null) {
logger.debug("Text: " + brand);
g.setColor(new Color(109, 135, 75));
g.drawChars(brand.toCharArray(), 0, 5, 20, 32);
g.setColor(new Color(19, 128, 168));
g.drawChars(brand.toCharArray(), 5, brand.length() - 5, width / 2, 32);
}
//
g.setColor(Color.black);
g.drawRect(0, 0, width, height);
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
}
}
| [
"[email protected]"
] | |
f3c9acd25d38be7366daf193b4ffa706e2417682 | a632e7fd28cb5eeeff3a1f6524c68f2c95348106 | /src/main/java/com/gbabler/controller/PaymentController.java | 905bfdfff05a3dffad247d41f55cf600a2018382 | [] | no_license | MarcosVMoreira/patch-demo | 654e8f81cca6d464ef90471e5bbdd97245518696 | 5bc567ee547ebfa93044e00bd702429070fbf6b3 | refs/heads/master | 2023-03-03T02:26:00.387642 | 2021-02-12T13:32:26 | 2021-02-12T13:32:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 966 | java | package com.gbabler.controller;
import com.gbabler.model.dto.PaymentRequest;
import com.gbabler.service.PaymentService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/payments")
@RequiredArgsConstructor
public class PaymentController {
private final PaymentService paymentService;
@PatchMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void partialUpdate(@RequestBody PaymentRequest paymentRequest, @PathVariable String id) {
paymentService.partialUpdate(paymentRequest, id);
}
} | [
"[email protected]"
] | |
1cfdaf63b70ccaa5a7ab234b5cda5bdc7c349558 | 248abd2b312d9a1584477e22a3430e9f29d9c6d9 | /Phonebook/src/phonebook06/db/PhonebookModel.java | 399994a45ad0e3e9fa4feadd039a112ef2f34281 | [] | no_license | JangYunSung/JavaWork1 | 337093f9d084130e8e1a91a699d90f312e666d13 | c48f1076281a7391d4e5ebe909e345262e9972e3 | refs/heads/master | 2022-04-26T16:30:07.810689 | 2020-04-27T01:27:35 | 2020-04-27T01:27:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,814 | java | package phonebook06.db;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
// MODEL 객체
// 데이터 표현 객체
public class PhonebookModel implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7457878413286439105L;
// 멤버변수
private int uid; // unique id
private String name; // 이름
private String phoneNum; // 전화번호
private String memo; // 메모
private Date regDate; // 등록일시
// 기본생성자
public PhonebookModel() {
this.name = "";
this.phoneNum = "";
this.memo = "";
this.regDate = new Date(); // 생성되는 현재시간.
}
// 매개변수 생성자
public PhonebookModel(String name, String phoneNum, String email) {
this();
this.name = name;
this.phoneNum = phoneNum;
this.memo = email;
}
public PhonebookModel(int uid, String name, String phoneNum, String email, Date regDate) {
super();
this.uid = uid;
this.name = name;
this.phoneNum = phoneNum;
this.memo = email;
this.regDate = regDate;
}
// getter & setter
public int getUid() {return uid;}
public void setUid(int uid) {this.uid = uid;}
public String getName() {return name;}
public void setName(String name) {this.name = name;}
public String getPhoneNum() {return phoneNum;}
public void setPhoneNum(String phoneNum) {this.phoneNum = phoneNum;}
public String getMemo() {return memo;}
public void setMemo(String memo) {this.memo = memo;}
public Date getRegDate() {return regDate;}
public void setRegDate(Date regDate) {this.regDate = regDate;}
@Override
public String toString() {
String str = String.format("%3d|%s|%s|%s|%20s",
uid, name, phoneNum, memo,
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(regDate));
return str;
}
}
| [
"ahsku45@naver,com"
] | ahsku45@naver,com |
99adebfe6eb949b80096c71f33fdbaa5d2e5b96f | 0ee472ab3655833b23101e8678b1aaffc89a4f48 | /app/src/test/java/com/example/demonav/ExampleUnitTest.java | fbd8634aa873fba17ec57990057a07e0ef97a9f8 | [] | no_license | shubhangidk/Demonav | 8fbe5566386f63618f8ca9f05d95910229b21edf | 0a4bf86338ccbbc99ab846953c42fcc367843cc1 | refs/heads/master | 2020-07-28T03:14:00.548193 | 2019-09-18T11:21:25 | 2019-09-18T11:21:25 | 209,290,360 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 380 | java | package com.example.demonav;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
4ec8fa77efcecaded58f34abc87ae957ee27b289 | 64310de24414f486a4167f40950441db369c007f | /src/com/xiao/util/CheckUtil.java | cb54eed8614f0d4c7946598901235828ad547187 | [] | no_license | LongwuXiao/weixin | dba238398cf7af5bebaa2e351ff12b28b59dfc9d | fd52d28ad04f67626b2976854b7971bc5dbeced9 | refs/heads/master | 2016-09-06T15:59:47.406608 | 2015-04-17T06:14:26 | 2015-04-17T06:14:26 | 34,099,409 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,204 | java | package com.xiao.util;
import java.security.MessageDigest;
import java.util.Arrays;
public class CheckUtil {
private static final String token = "xiaolongwu";
public static boolean checkSignature(String signature,String timestamp,String nonce){
String[] arr = new String[]{token,timestamp,nonce};
//排序
Arrays.sort(arr);
//生成字符串
StringBuffer content = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
content.append(arr[i]);
}
//sha1加密
String temp = getSha1(content.toString());
return temp.equals(signature);
}
public static String getSha1(String str){
if(str == null || str.length() == 0){
return null;
}
char hexDigits[] = {'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f'};
try {
MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
mdTemp.update(str.getBytes("UTF-8"));
byte[] md = mdTemp.digest();
int j = md.length;
char buf[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
buf[k++] = hexDigits[byte0 & 0xf];
}
return new String(buf);
} catch (Exception e) {
return null;
}
}
}
| [
"[email protected]"
] | |
29784905ec01b6ded666c8dbf766f3d02ea48c61 | f8434073dc71fb3fc61813595d6e5437b483f567 | /src/minecraft/net/minecraft/src/J_JsonNodeSelector.java | 7052b3724cde2f18f326e4b11b2052882b6bd02d | [] | no_license | FrozenHF/LavaBukkit | 9fe9d7fb93603f659ea08b53d9269502273d0ede | 0ea93a62e840ef498cee988222e47cc09d20e08a | refs/heads/master | 2021-01-16T23:01:38.903417 | 2011-10-31T17:14:25 | 2011-10-31T17:14:25 | 2,682,589 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 976 | java | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
// Referenced classes of package net.minecraft.src:
// J_Functor, J_ChainedFunctor
public final class J_JsonNodeSelector
{
J_JsonNodeSelector(J_Functor j_functor)
{
valueGetter = j_functor;
}
public boolean matchs(Object obj)
{
return valueGetter.matchsNode(obj);
}
public Object getValue(Object obj)
{
return valueGetter.applyTo(obj);
}
public J_JsonNodeSelector with(J_JsonNodeSelector j_jsonnodeselector)
{
return new J_JsonNodeSelector(new J_ChainedFunctor(this, j_jsonnodeselector));
}
String shortForm()
{
return valueGetter.shortForm();
}
public String toString()
{
return valueGetter.toString();
}
final J_Functor valueGetter;
}
| [
"[email protected]"
] | |
9e50f2f4fa82fb4e56a32692fe3f9df348f9b78c | 689cdf772da9f871beee7099ab21cd244005bfb2 | /classes/com/iflytek/cloud/IdentityResult.java | 6c20cd7b3fd6db296aa4610988e97220f50efd12 | [] | no_license | waterwitness/dazhihui | 9353fd5e22821cb5026921ce22d02ca53af381dc | ad1f5a966ddd92bc2ac8c886eb2060d20cf610b3 | refs/heads/master | 2020-05-29T08:54:50.751842 | 2016-10-08T08:09:46 | 2016-10-08T08:09:46 | 70,314,359 | 2 | 4 | null | null | null | null | UTF-8 | Java | false | false | 916 | java | package com.iflytek.cloud;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
public class IdentityResult
implements Parcelable
{
public static final Parcelable.Creator<IdentityResult> CREATOR = new IdentityResult.1();
private String a = "";
private IdentityResult(Parcel paramParcel)
{
this.a = paramParcel.readString();
}
public IdentityResult(String paramString)
{
if (paramString != null) {
this.a = paramString;
}
}
public int describeContents()
{
return 0;
}
public String getResultString()
{
return this.a;
}
public void writeToParcel(Parcel paramParcel, int paramInt)
{
paramParcel.writeString(this.a);
}
}
/* Location: E:\apk\dazhihui2\classes-dex2jar.jar!\com\iflytek\cloud\IdentityResult.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
31db879275cdedbebe31dec0ccfc1f674dcdd911 | 27462843e67824a750092cdd824b05fe5e144de2 | /src/test/java/utils/Hooks.java | 9e350473d40c0bac426626ed3e45e4af767cc168 | [] | no_license | AlexanderDark/FinalWork | 07bf6f4b427ec5b09917b56bf7fa695cb9084b74 | 3fdedd3e18bb225f1159dadbc362262d855aa7a7 | refs/heads/master | 2023-04-22T14:46:27.720248 | 2021-05-15T12:25:17 | 2021-05-15T12:25:17 | 361,274,538 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,392 | java | package utils;
import Parameters.GetBrowserName;
import com.codeborne.selenide.Selenide;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import pages.EventsPage;
import pages.MainPage;
import pages.TalksLibraryPage;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class Hooks {
protected MainPage mainPage = new MainPage();
protected EventsPage eventsPage = new EventsPage();
protected TalksLibraryPage talksLibraryPage = new TalksLibraryPage();
private Logger logger = LogManager.getLogger(Hooks.class);
@Execution(ExecutionMode.CONCURRENT)
@BeforeAll
public void setUp() {
GetBrowserName.initBrowser();
logger.info("Открыт браузер");
}
@Execution(ExecutionMode.CONCURRENT)
@AfterEach
public void setDownTest() {
Selenide.clearBrowserLocalStorage();
logger.info("Чистим браузер");
Selenide.closeWebDriver();
logger.info("Закрыт браузер");
}
@Execution(ExecutionMode.CONCURRENT)
@AfterAll
public void closeSelenide() {
Selenide.closeWebDriver();
logger.info("Закрыт браузер");
}
}
| [
"[email protected]"
] | |
e28a51f3b2f98df1bfc63437e2bcd46a0f49eaee | eb29772b0b2401fa0c75b7bb31700e9543f75fdf | /Aplicatie/Vehicul.java | 196ca4aaf3e4229552de8c8ca3e978542ac156af | [] | no_license | leeanaa/Java1Associate | 305eb3bb2a908e9ddf31e768d38178e6dd6d3df2 | 77fb4c56d31a6678664133d3f99421ef6ec3f746 | refs/heads/master | 2020-06-11T12:58:58.800616 | 2019-06-26T20:36:36 | 2019-06-26T20:36:36 | 193,972,331 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 173 | java | public class Vehicul {
String marca;
String culoare;
public Vehicul(String marca,String culoare){
this.marca=marca;
this.culoare=culoare;
}
} | [
"[email protected]"
] | |
3daedcb928c5de59868a900b93e751136499a6f0 | 099c242bce833a0dd1177dc20cea8979ef83992e | /Java Codes/HeapSort.java | 363f950448abd79c6e12c76ccdd40ccd3cd49c30 | [
"MIT"
] | permissive | sonika-shah/Hacktoberfest_2021 | bc85695390efef2e0d805570412923c024bc9bfd | a4bf2ced93457337aa4b91569d6060d163771348 | refs/heads/main | 2023-08-22T05:52:57.302969 | 2021-10-25T05:29:33 | 2021-10-25T05:29:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,623 | java | /*
Java implementation of heap sort
Input format:
Enter number of elements in the array: 5
Enter 5 elements
5 4 7 3 1
Output:
Elements in array:
5 4 7 3 1
Elements after sorting:
1 3 4 5 7
*/
import java.util.Scanner;
public class HeapSort {
public static void heapify(int a[], int i, int n) {
int l = 2 * i + 1;
int r = 2 * i + 2;
int temp, largest;
if (l < n && a[l] > a[i])
largest = l;
else
largest = i;
if (r < n && a[r] > a[largest])
largest = r;
if (largest != i) {
temp = a[largest];
a[largest] = a[i];
a[i] = temp;
heapify(a, largest, n);
}
}
public static void bheap(int a[]) {
for (int i = (a.length / 2) - 1; i >= 0; i--) {
heapify(a, i, a.length);
}
}
public static void Sort(int a[]) {
int temp, j, i;
bheap(a);
for (i = (a.length) - 1; i > 0;) {
temp = a[0];
a[0] = a[i];
a[i] = temp;
heapify(a, 0, i--);
}
}
public static void printarray(int a[]) {
for (int i = 0; i < a.length; i++) {
System.out.print(a[i] + " ");
}
}
public static void main(String[] args) {
int n, res, i;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of elements in the array: ");
n = s.nextInt();
int a[] = new int[n];
System.out.println("Enter " + n + " elements ");
for (i = 0; i < n; i++) {
a[i] = s.nextInt();
}
System.out.println("Elements in array: ");
printarray(a);
Sort(a);
System.out.println("\nElements after sorting:");
printarray(a);
}
}
| [
"[email protected]"
] | |
e2fa5a7e1686198af4aa87408c2b3cbabd3a746f | 1e8272f2a6191fc840d7d2dd69dc12cb1b157552 | /src/main/java/docpreview/config/audit/package-info.java | e62585be7ec80ce140310e3c692a73511df729b5 | [] | no_license | contribution-jhipster-uga/sample-jhipster-docpreview | a6f9338ce89e73353d4417f188a0df91976e4059 | 6a3b2d496f223dc721d5d0c2d5ac5fe835342ec2 | refs/heads/master | 2023-05-14T10:59:36.295697 | 2020-03-22T17:53:42 | 2020-03-22T17:53:42 | 249,178,948 | 0 | 0 | null | 2023-05-09T03:22:27 | 2020-03-22T12:30:47 | Java | UTF-8 | Java | false | false | 65 | java | /**
* Audit specific code.
*/
package docpreview.config.audit;
| [
"[email protected]"
] | |
d46cb874828ef219dc18450e22c33621721a1963 | 1c40d2e445d5165ca1007589dd9891b933eea2b4 | /PraticaOffline7/src/ufersa/sd/threads/SocketMulticast/UDPCliente2.java | ef6db4fe98cc597ccc2d707a2f7776532e347e96 | [
"MIT"
] | permissive | fcd007/ExclusaoMutuaConcorrencia | 5e3b3b14edee228b94b18a4b0d3ae9ca6a288f2e | 8187f8888552bfb1ef1265ff6dacc06bdf11f043 | refs/heads/master | 2022-11-24T06:58:58.523226 | 2020-07-28T01:58:58 | 2020-07-28T01:58:58 | 283,067,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 624 | java | package ufersa.sd.threads.SocketMulticast;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class UDPCliente2 {
public static void main(String[] args) throws Exception {
try(DatagramSocket socket = new DatagramSocket()) {
String mensagem = "Mensagem2";
byte[] buffer = mensagem.getBytes();
InetAddress addr = InetAddress.getByName("228.0.0.1");
DatagramPacket pacote = new DatagramPacket(buffer, buffer.length, addr, 34001);
socket.send(pacote);
System.out.println("Cliente: enviando mensagem para o servidor " + mensagem);
}
}
}
| [
"[email protected]"
] | |
51430652c4d7c2c835b0bff325ae7b9096275185 | ff8896046b874b8e446f12b4f1beb9e243807950 | /sub-server/src/test/java/com/rukevwe/subserver/SubServerApplicationTests.java | 3be67a4ca0f29a898b62da2a4f7416dd3bd73858 | [] | no_license | ahwinemman/png-take-home | fcbf29a28714373108dfcff306feb716c4c824aa | 1dee3152a5ac40cd0e27f6034700c6cd82960449 | refs/heads/master | 2023-07-14T09:45:37.700796 | 2021-08-27T07:00:37 | 2021-08-27T07:00:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 216 | java | package com.rukevwe.subserver;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SubServerApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
3964fbb0281896adddbe03bdfb0d355b775c6659 | e49ddf6e23535806c59ea175b2f7aa4f1fb7b585 | /tags/release-5.4.2/mipav/src/gov/nih/mipav/model/algorithms/t2mapping/cj/fileformats/BFFBase.java | f8b8f68bf8df2454c4d32a3247678fd75e7cb24a | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | svn2github/mipav | ebf07acb6096dff8c7eb4714cdfb7ba1dcace76f | eb76cf7dc633d10f92a62a595e4ba12a5023d922 | refs/heads/master | 2023-09-03T12:21:28.568695 | 2019-01-18T23:13:53 | 2019-01-18T23:13:53 | 130,295,718 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,442 | java | package gov.nih.mipav.model.algorithms.t2mapping.cj.fileformats;
import java.io.*;
import java.lang.*;
import java.lang.Float;
import java.util.*;
import java.nio.ByteOrder;
import java.net.*;
import java.util.zip.*;
import javax.imageio.stream.*;
import gov.nih.mipav.model.algorithms.t2mapping.cj.appkit.AppKit;
import gov.nih.mipav.model.algorithms.t2mapping.cj.volume.*;
import gov.nih.mipav.model.algorithms.t2mapping.cj.utilities.*;
/** BFFBase class is used as the super class of all BFF file types.
*/
public abstract class BFFBase extends MRIFile {
protected Vector header;
protected boolean bigEndian_f;
protected int nimages;
/** Default constructor.
*/
public BFFBase()
{
initialize();
}
/** Constructor that takes a file.
*/
public BFFBase(String filename)
{
initialize();
}
/** Initializer
*/
public void initialize()
{
data = null;
header = null;
datatype = MRIFile.DATATYPE_SHORT;
endian = ByteOrder.LITTLE_ENDIAN;
}
/** Abstract readHeader method that must be defined elsewhere.
*/
public abstract void readHeader( ImageInputStream ldis );
/** Abstract readData method that must be defined elsewhere.
*/
public abstract void readData( ImageInputStream ldis );
/** Abstract write Header that must be defined in the subclass.
*/
public abstract void writeHeader( ImageOutputStream ldos );
/** Abstract write Data that must be defined in the subclass.
*/
public abstract void writeData( ImageOutputStream ldos );
/** Abstract parseheader that must be defined in the subclass.
*/
abstract void parseHeader();
/** Read header from a file.
*
*/
public void readHeader( String filename )
{
ImageInputStream ldis = null;
String line;
//
// Read header first.
//
header = new Vector(0);
ldis = AppKit.openRead(filename);
if(ldis == null) {
System.out.println("BFF: Could not open " + filename + " to read.");
System.exit(0);
}
readHeader( ldis );
}
/** Read method that reads from a file.
*/
public void read( String filename )
{
ImageInputStream ldis = null;
String line;
//
// Read header first.
//
header = new Vector(0);
ldis = AppKit.openRead(filename);
if( ldis == null ) {
System.out.println("BFF: Could not open " + filename + " to read.");
System.exit(0);
}
readHeader( ldis );
readData( ldis );
try
{
ldis.close();
}
catch( IOException e )
{
System.out.println("BFF: Could not close " + filename );
System.exit(0);
}
}
/** Get a copy of the header.
*/
public Vector getHeader()
{
return (Vector)header.clone();
}
/** Write method that writes to the specified file and writes
* the data in the specified type.
*/
public void write( String filename, int datatype )
{
System.out.println("Entering BFFBase::write with " + filename);
ImageOutputStream ldos = null;
GZIPOutputStream gzos = null;
String line;
OutputStream fos = null;
try
{
fos = new FileOutputStream(new File(filename));
if( filename.endsWith(".gz") )
{
gzos = new GZIPOutputStream( fos );
}
fos = new BufferedOutputStream( gzos );
}
catch (IOException e)
{
System.out.println(e);
System.exit(-1);
}
ldos = new MemoryCacheImageOutputStream(fos);
setDataType( datatype );
parseForString("type:", true);
header.insertElementAt("type: " + MRIFile.dataTypeToString(datatype), 3);
// ldos = AppKit.openWrite(filename);
// if( ldos == null ) {
// System.out.println("BFF: Could not open " + filename + " to write.");
// System.exit(0);
// }
writeHeader( ldos );
writeData( ldos );
try {
ldos.close();
gzos.finish();
}
catch( IOException e ) {
System.out.println("BFF: Could not close " + filename );
System.exit(0);
}
System.out.println("Leaving BFFBase::write");
}
/** Write method that writes the data in an unsigned short format.
*/
public void write( String filename )
{
write( filename, datatype );
}
/** Show the header.
*/
public void show()
{
for(int ii=0; ii<header.size(); ii++) {
System.out.println(header.elementAt(ii));
}
}
/** Retrieve the specified slice.
*/
public Slice getSlice( int slice_num, int channel )
{
return data.getSlice( slice_num, channel );
}
/** Get the channels in a float format.
*
*/
public float[] getChannels( int row, int col, int slice )
{
return data.getChannel(row,col,slice);
}
/** Get the channels in a double format.
*
*/
public double[] getChannelsDouble( int row, int col, int slice )
{
return data.getChannelDouble(row,col,slice);
}
/** Add a comment to the header.
*/
public void addComment(String comment)
{
String computer = AppKit.getHostName();
if (computer != null)
{
computer = " on " + computer;
}
else
{
System.out.println("ge2bff: Could not determine the name of the host, continuing...");
computer = "";
}
header.add("comment: " + comment +
" (Processed on " + (new Date()).toString() +
computer + " by " + System.getProperty("user.name") + ")");
}
protected int parseForInt( String keyword, boolean remove )
{
int toreturn = -1;
String temp;
Integer tempInt;
for(int ii=0; ii<header.size(); ii++) {
temp = (String)header.elementAt(ii);
if( temp.indexOf(keyword) != -1 ) {
tempInt = new Integer(temp.substring( temp.indexOf(":")+1 ,
temp.length() ).trim());
toreturn = tempInt.intValue();
if( remove ) {
header.removeElementAt(ii);
ii++;
}
}
}
return toreturn;
}
protected int parseForInt( String keyword )
{
return parseForInt( keyword, false );
}
protected String parseForString( String keyword )
{
return parseForString( keyword, false );
}
protected String parseForString( String keyword, boolean remove )
{
String toreturn = "";
String temp;
for(int ii=0; ii<header.size(); ii++) {
temp = (String)header.elementAt(ii);
if( temp.indexOf(keyword) != -1 ) {
toreturn = temp.substring( temp.indexOf(":")+1 ,
temp.length() ).trim();
if( remove ) {
header.removeElementAt(ii);
ii++;
}
}
}
return toreturn;
}
protected Vector parseForDoubleVec( String keyword )
{
return parseForDoubleVec(keyword, false);
}
protected Vector parseForStringVec( String keyword, boolean remove )
{
int toreturn = -1;
String temp;
int index;
boolean found = false;
Vector tempvector = new Vector();
for(int ii=0; ii<header.size(); ii++)
{
temp = (String)header.elementAt(ii);
if( temp.indexOf(keyword) == 0 )
{
//
// Found the right line, now we need to parse it.
//
index = temp.indexOf(":")+1;
boolean done = false;
while( !done ) {
//
// Look for the commas.
//
if( temp.indexOf(",", index+1 ) > 0 ) {
tempvector.add( temp.substring(index+1, temp.indexOf(",", index+1) ).trim() );
index = temp.indexOf(",", index+1);
found = true;
}
else {
tempvector.add( temp.substring(temp.lastIndexOf(",")+1).trim() );
done = true;
}
}
if( remove )
{
header.removeElementAt(ii);
ii++;
}
}
}
return tempvector;
}
protected Vector parseForDoubleVec( String keyword, boolean remove )
{
int toreturn = -1;
String temp;
int index;
boolean found = false;
Vector tempvector = new Vector();
for(int ii=0; ii<header.size(); ii++)
{
temp = (String)header.elementAt(ii);
if( temp.indexOf(keyword) == 0 )
{
//
// Found the right line, now we need to parse it.
//
index = temp.indexOf(":")+1;
boolean done = false;
while( !done ) {
//
// Look for the commas.
//
if( temp.indexOf(",", index+1 ) > 0 ) {
tempvector.add( new Float( temp.substring(index+1, temp.indexOf(",", index+1) ).trim() ));
index = temp.indexOf(",", index+1);
found = true;
}
else {
tempvector.add( new Float( temp.substring(temp.lastIndexOf(",")+1).trim() ) );
done = true;
}
}
if( remove )
{
header.removeElementAt(ii);
ii++;
}
}
}
return tempvector;
}
// protected double[] parseForDoubleVec( String keyword )
// {
// int toreturn = -1;
// String temp;
// int index;
// boolean found = false;
// Vector tempvector = new Vector();
//
// for(int ii=0; ii<header.size(); ii++) {
// temp = (String)header.elementAt(ii);
//
// if( temp.indexOf(keyword) == 0 ) {
// //
// // Found the right line, now we need to parse it.
// //
// index = temp.indexOf(":")+1;
// boolean done = false;
// while( !done ) {
// //
// // Look for the commas.
// //
// if( temp.indexOf(",", index+1 ) > 0 ) {
// tempvector.add( new Float( temp.substring(index+1, temp.indexOf(",", index+1) ).trim() ));
// index = temp.indexOf(",", index+1);
// found = true;
// }
// else {
// tempvector.add( new Float( temp.substring(temp.lastIndexOf(",")+1).trim() ) );
// done = true;
// }
// }
// }
// }
//
// //
// // Copy vector info to a double array and return that.
// //
// double[] doubleReturn = new double[tempvector.size()];
// for(int ii=0; ii<tempvector.size(); ii++) {
// doubleReturn[ii] = ((Float)tempvector.elementAt(ii)).doubleValue();
// }
//
// return doubleReturn;
// }
//
}
| [
"[email protected]@ba61647d-9d00-f842-95cd-605cb4296b96"
] | [email protected]@ba61647d-9d00-f842-95cd-605cb4296b96 |
3a285c14099ed3c3baeddcdca4cb55309e1fa998 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipseswt_cluster/5149/tar_1.java | 8aa114b227c77dbc2c5ac699ab64b660d9ea5a39 | [] | 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 | 51,965 | java | /*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* 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://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import java.util.Vector;
/**
* Instances of this class represent a selectable user interface object
* that represents an item in a table.
* <dl>
* <dt><b>Styles:</b></dt>
* <dd>(none)</dd>
* <dt><b>Events:</b></dt>
* <dd>(none)</dd>
* </dl>
* <p>
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
public class TableItem extends SelectableItem {
private static final int FIRST_COLUMN_IMAGE_INDENT = 2; // Space in front of image - first column only
private static final int FIRST_COLUMN_TEXT_INDENT = 4; // Space in front of text - first column only
private static final int TEXT_INDENT_NO_IMAGE = 2; // Space in front of item text when no item in the column has an image - first column only
private static final int TEXT_INDENT = 6; // Space in front of item text - all other columns
private static final int SELECTION_PADDING = 6; // Space behind text in a selected item
private Vector dataLabels = new Vector(); // Original text set by the user. Items that don't
// have a label are represented by a null slot
private String[] trimmedLabels; // Text that is actually displayed, may be trimmed
// to fit the column
private Vector images = new Vector(); // Item images. Items that don't have an image
// are represented by a null slot
private Point selectionExtent; // Size of the rectangle drawn to indicate a
// selected item.
private int imageIndent = 0; // the factor by which the item image and check box, if any,
// are indented. The multiplier is the image width.
private int index; // index of the item in the parent widget
Color background = null;
Color foreground = null;
Font font = null;
Color [] cellBackground, cellForeground;
Font [] cellFont;
int [] textWidths;
boolean cached;
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>) and a style value
* describing its behavior and appearance. The item is added
* to the end of the items maintained by its parent.
* <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
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
public TableItem(Table parent, int style) {
this(parent, style, checkNull(parent).getItemCount());
}
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>), a style value
* describing its behavior and appearance, and the index
* at which to place it in the items maintained by its parent.
* <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
* @param index the index to store the receiver in its parent
*
* @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
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
public TableItem(Table parent, int style, int index) {
super(parent, style);
trimmedLabels = new String[parent.internalGetColumnCount()];
parent.addItem(this, index);
}
/**
* Calculate the size of the rectangle drawn to indicate a selected
* item. This is also used to draw the selection focus rectangle.
* The selection extent is calculated for the first column only (the
* only column the selection is drawn in).
*/
void calculateSelectionExtent() {
Table parent = getParent();
TableColumn column = parent.internalGetColumn(TableColumn.FIRST);
GC gc = new GC(parent);
gc.setFont(getFont());
String trimmedText = getText(gc, column);
int gridLineWidth = parent.getGridLineWidth();
if (trimmedText != null) {
selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());
selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;
selectionExtent.x = Math.min(
selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);
if (parent.getLinesVisible() == true) {
selectionExtent.y -= gridLineWidth;
}
}
gc.dispose();
}
/**
* Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
* Otherwise return 'table'
*/
static Table checkNull(Table table) {
if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
return table;
}
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
void clear() {
super.clear();
dataLabels = new Vector();
trimmedLabels = new String[getParent().internalGetColumnCount()];
images = new Vector();
selectionExtent = null;
background = foreground = null;
font = null;
cellBackground = cellForeground = null;
cellFont = null;
textWidths = null;
cached = false;
}
void clearTextWidths() {
textWidths = null;
}
void clearTextWidths(int columnIndex) {
if (textWidths != null) {
textWidths [columnIndex] = 0;
}
}
public void dispose() {
if (isDisposed()) return;
Table parent = getParent();
parent.removeItem(this);
super.dispose();
}
void doDispose() {
dataLabels = null;
trimmedLabels = null;
images = null;
selectionExtent = null;
foreground = background = null;
font = null;
cellForeground = cellBackground = null;
cellFont = null;
textWidths = null;
super.doDispose();
}
/**
* Draw the image of the receiver for column 'index' at
* 'destinationPosition' using 'gc'.
* Stretch/shrink the image to the fixed image size of the receiver's
* parent.
* @param gc - GC to draw on.
* @param destinationPosition - position on the GC to draw at.
* @param index - index of the image to draw
* @return Answer the position where drawing stopped.
*/
Point drawImage(GC gc, Point destinationPosition, int index) {
Table parent = getParent();
Image image = getImage(index);
Rectangle sourceImageBounds;
Point destinationImageExtent = parent.getImageExtent();
int imageOffset;
int itemHeight = parent.getItemHeight();
if (image != null) {
sourceImageBounds = image.getBounds();
if (index == TableColumn.FIRST){
gc.setBackground(getBackground(index));
gc.fillRectangle(
destinationPosition.x, destinationPosition.y,
destinationImageExtent.x, itemHeight);
} else {
// full row select would obscure transparent images in all but the first column
// so always clear the image area in this case. Fixes 1FYNITC
if ((parent.getStyle() & SWT.FULL_SELECTION) != 0) {
gc.fillRectangle(
destinationPosition.x, destinationPosition.y,
destinationImageExtent.x, destinationImageExtent.y);
}
}
imageOffset = (itemHeight - destinationImageExtent.y) / 2;
gc.drawImage(
image, 0, 0, // source x, y
sourceImageBounds.width, sourceImageBounds.height, // source width, height
destinationPosition.x, destinationPosition.y + imageOffset, // destination x, y
destinationImageExtent.x, destinationImageExtent.y); // destination width, height
}
if (((index == TableColumn.FIRST && // always add the image width for the first column
parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
(index != TableColumn.FIRST && // add the image width if it's not the first column
image != null)) && // only when the item actually has an image
destinationImageExtent != null) {
destinationPosition.x += destinationImageExtent.x;
}
return destinationPosition;
}
/**
* Draw the label of the receiver for column 'index' at 'position'
* using 'gc'.
* The background color is set to the selection background color if
* the item is selected and the text is drawn for the first column.
* @param gc - GC to draw on.
* @param position - position on the GC to draw at.
* @param index - specifies which subitem text to draw
*/
void drawText(String label, GC gc, Point position, int index) {
Table parent = getParent();
int textOffset, alignmentOffset;
if (label != null) {
gc.setFont(getFont(index));
boolean drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0) &&
((parent.style & SWT.HIDE_SELECTION) == 0 || parent.isFocusControl());
if (isSelected() == true && drawSelection == true) {
gc.setForeground(getSelectionForegroundColor());
} else {
gc.setForeground(getForeground(index));
}
alignmentOffset = getAlignmentOffset (index, getBounds(index).width, gc);
textOffset = (parent.getItemHeight() - parent.getFontHeight()) / 2; // vertically center the text
gc.drawString(label, position.x + alignmentOffset, position.y + textOffset, true);
}
}
int getAlignmentOffset(int columnIndex, int columnWidth, GC gc) {
Table parent = getParent();
TableColumn column = parent.internalGetColumn (columnIndex);
Image image = getImage(columnIndex);
int alignmentOffset = 0;
int alignment = column.getAlignment();
String label = getText(gc, column);
int imageWidth = 0;
int textWidth = gc.stringExtent (label).x;
Point imageExtent = parent.getImageExtent();
if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column
parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
(columnIndex != TableColumn.FIRST && // add the image width if it's not the first column
image != null)) && // only when the item actually has an image
imageExtent != null) {
textWidth += imageExtent.x;
}
if ((alignment & SWT.RIGHT) != 0) {
alignmentOffset = columnWidth - textWidth - imageWidth - TEXT_INDENT - TEXT_INDENT;
}
if ((alignment & SWT.CENTER) != 0) {
alignmentOffset = ((columnWidth - textWidth) / 2) - imageWidth - TEXT_INDENT;
}
if (alignmentOffset < 0) alignmentOffset = 0;
return alignmentOffset;
}
/**
* Returns the receiver's background color.
*
* @return the background color
*
* @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 Color getBackground(){
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if (background != null) return background;
return parent.getBackground ();
}
/**
* Returns the background color at the given column index in the receiver.
*
* @param index the column index
* @return the background color
*
* @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 Color getBackground (int index) {
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return getBackground ();
if (cellBackground == null || cellBackground [index] == null) return getBackground ();
return cellBackground [index];
}
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent at a column in the table.
*
* @param index the index that specifies the column
* @return the receiver's bounding column rectangle
*
* @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 Rectangle getBounds(int index) {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
Rectangle itemBounds;
Rectangle columnBounds;
Rectangle checkboxBounds;
TableColumn column;
int itemIndex = parent.indexOf(this);
int itemHeight = parent.getItemHeight();
int gridLineWidth = parent.getLinesVisible() ? parent.getGridLineWidth() : 0;
int itemYPos;
if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {
itemBounds = new Rectangle(0, 0, 0, 0);
}
else {
column = parent.internalGetColumn(index);
columnBounds = column.getBounds();
itemYPos = columnBounds.y + itemHeight * itemIndex;
itemBounds = new Rectangle(
columnBounds.x, itemYPos,
columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);
if (index == TableColumn.FIRST) {
if (isCheckable() == true) {
checkboxBounds = getCheckboxBounds();
itemBounds.x = checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; // add checkbox start, width and space behind checkbox
itemBounds.width -= itemBounds.x;
}
else {
int imageIndent = getImageIndentPixel();
itemBounds.x += imageIndent;
itemBounds.width -= imageIndent;
}
}
}
return itemBounds;
}
/**
* Returns <code>true</code> if the receiver is checked,
* and false otherwise. When the parent does not have
* the <code>CHECK</code> style, return false.
*
* @return the checked state of the checkbox
*
* @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 getChecked() {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return super.getChecked();
}
/**
* Answer the x position of the item check box
*/
int getCheckboxXPosition() {
return getImageIndentPixel();
}
/**
* Answer the item labels set by the user.
* These may not be the same as those drawn on the screen. The latter
* may be trimmed to fit the column. Items that don't have a label are
* represented by a null slot in the vector.
* @return Vector - the item labels set by the user.
*/
Vector getDataLabels() {
return dataLabels;
}
/**
* Return the position at which the string starts that is used
* to indicate a truncated item text.
* @param columnIndex - index of the column for which the position of
* the truncation replacement should be calculated
* @param columnWidth - width of the column for which the position of
* the truncation replacement should be calculated
* @return -1 when the item text is not truncated
*/
int getDotStartX(int columnIndex, int columnWidth) {
GC gc;
Table parent = getParent();
String label = getText(columnIndex);
int alignment = parent.internalGetColumn (columnIndex).getAlignment();
int dotStartX = -1;
int maxWidth;
if (label != null) {
gc = new GC(parent);
gc.setFont (getFont());
dotStartX = getAlignmentOffset(columnIndex, columnWidth, gc);
if ((alignment & SWT.LEFT) != 0) {
maxWidth = getMaxTextWidth(columnIndex, columnWidth);
label = parent.trimItemText(label, maxWidth, gc);
if (label.endsWith(Table.DOT_STRING)) {
int dotsWidth = gc.stringExtent(Table.DOT_STRING).x;
dotStartX = gc.stringExtent(label).x - dotsWidth;
// add indents, margins and image width
dotStartX += getImageStopX(columnIndex);
dotStartX += getTextIndent(columnIndex);
}
}
gc.dispose();
}
return dotStartX;
}
/**
* Returns the font that the receiver will use to paint textual information for this item.
*
* @return the receiver's font
*
* @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 Font getFont () {
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if (font != null) return font;
return parent.getFont ();
}
/**
* Returns the font that the receiver will use to paint textual information
* for the specified cell in this item.
*
* @param index the column index
* @return the receiver's font
*
* @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 Font getFont (int index) {
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return getFont ();
if (cellFont == null || cellFont [index] == null) return getFont ();
return cellFont [index];
}
/**
* Returns the foreground color that the receiver will use to draw.
*
* @return the receiver's foreground color
*
* @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 Color getForeground(){
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
if (foreground != null) return foreground;
return parent.getForeground ();
}
/**
*
* Returns the foreground color at the given column index in the receiver.
*
* @param index the column index
* @return the foreground color
*
* @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 Color getForeground (int index) {
checkWidget ();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return getForeground ();
if (cellForeground == null || cellForeground [index] == null) return getForeground ();
return cellForeground [index];
}
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
* the <code>CHECK</code> style, return false.
*
* @return the grayed state of the checkbox
*
* @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 getGrayed() {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return super.getGrayed();
}
public Image getImage() {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return getImage(0);
}
/**
* Returns the image stored at the given column index in the receiver,
* or null if the image has not been set or if the column does not exist.
*
* @param index the column index
* @return the image stored at the given column index 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 Image getImage(int columnIndex) {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
Image image = null;
Vector images = getImages();
int itemIndex = getIndex();
if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {
image = (Image) images.elementAt(columnIndex);
}
return image;
}
/**
* Returns a rectangle describing the size and location
* relative to its parent of an image at a column in the
* table.
*
* @param index the index that specifies the column
* @return the receiver's bounding image rectangle
*
* @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 Rectangle getImageBounds(int index) {
checkWidget();
Table parent = getParent();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf (this);
int imageWidth = 0;
Point imageExtent = parent.getImageExtent();
Rectangle imageBounds = getBounds(index);
if (itemIndex == -1) {
imageBounds = new Rectangle(0, 0, 0, 0);
}
else
if (imageExtent != null) {
if (index == TableColumn.FIRST || getImage(index) != null) {
imageWidth = imageExtent.x;
}
}
imageBounds.width = imageWidth;
return imageBounds;
}
/**
* Gets the image indent.
*
* @return the indent
*
* @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 getImageIndent() {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int index = parent.indexOf(this);
if (index == -1) return 0;
return imageIndent;
}
/**
* Answer the number of pixels the image in the first column is
* indented. Calculation starts at the column start and counts
* all pixels except the check box.
*/
int getImageIndentPixel() {
int indentPixel = FIRST_COLUMN_IMAGE_INDENT;
Point imageExtent = getParent().getImageExtent();
if (imageExtent != null) {
indentPixel += imageExtent.x * getImageIndent();
}
return indentPixel;
}
/**
* Answer the item images set by the user. Items that don't have an
* image are represented by a null slot in the vector.
*/
Vector getImages() {
return images;
}
/**
* Calculate the x coordinate where the item image of column
* 'columnIndex' stops.
* @param columnIndex - the column for which the stop position of the
* image should be calculated.
*/
int getImageStopX(int columnIndex) {
int imageStopX = 0;
Table parent = getParent();
Rectangle checkboxBounds;
if (columnIndex == TableColumn.FIRST) {
if (isCheckable() == true) {
checkboxBounds = getCheckboxBounds();
imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;
}
else {
imageStopX = getImageIndentPixel();
}
}
if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column
parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
(columnIndex != TableColumn.FIRST && // add the image width if it's not the first column
getImage(columnIndex) != null)) && // only when the item actually has an image
parent.getImageExtent() != null) {
imageStopX += parent.getImageExtent().x;
}
return imageStopX;
}
/**
* Return the index of the item in its parent widget.
*/
int getIndex() {
return index;
}
/**
* Return the item extent in the specified column
* The extent includes the actual width of the item including checkbox,
* image and text.
*/
Point getItemExtent(TableColumn column) {
Table parent = getParent();
int columnIndex = column.getIndex();
Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());
GC gc = new GC(parent);
gc.setFont(getFont());
String trimmedText = getText(gc, column);
if (trimmedText != null && trimmedText.length() > 0) {
extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);
}
if (columnIndex == TableColumn.FIRST) {
extent.x += SELECTION_PADDING;
}
gc.dispose();
return extent;
}
/**
* Answer the maximum width in pixel of the text that fits in the
* column identified by 'columnIndex' without trimming the text.
* @param columnIndex - the column for which the maximum text width
* should be calculated.
* @param columnWidth - width of the column 'columnIndex'
*/
int getMaxTextWidth(int columnIndex, int columnWidth) {
int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
return columnWidth - itemWidth;
}
/**
* Returns the receiver's parent, which must be a <code>Table</code>.
*
* @return the receiver's parent
*
* @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 Table getParent() {
checkWidget();
return (Table) super.getSelectableParent();
}
/**
* Answer the width of the item required to display the complete contents.
*/
int getPreferredWidth(int index) {
int size = getImageStopX(index);
String text = (String) getDataLabels().elementAt (index);
if (text != null) {
size += getTextWidth (index) + getTextIndent (index) * 2 + 1;
}
return size;
}
/**
* Return the size of the rectangle drawn to indicate a selected item.
* This is also used to draw the selection focus rectangle and drop
* insert marker.
* Implements SelectableItem#getSelectionExtent
*/
Point getSelectionExtent() {
Table parent = getParent();
Point extent;
if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) { // regular, first column, selection?
if (selectionExtent == null) {
calculateSelectionExtent();
}
extent = selectionExtent;
}
else {
extent = parent.getFullSelectionExtent(this);
}
return extent;
}
/**
* Return the x position of the selection rectangle
* Implements SelectableItem#getSelectionX
*/
int getSelectionX() {
return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
}
public String getText() {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
return getText(0);
}
/**
* Returns the text stored at the given column index in the receiver,
* or empty string if the text has not been set.
*
* @param index the column index
* @return the text stored at the given column index 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>
* @exception SWTError <ul>
* <li>ERROR_CANNOT_GET_TEXT - if the column at index does not exist</li>
* </ul>
*/
public String getText(int columnIndex) {
checkWidget();
Table parent = getParent ();
if (!parent.checkData (this, true)) error (SWT.ERROR_WIDGET_DISPOSED);
int itemIndex = parent.indexOf(this);
Vector labels = getDataLabels();
String label = null;
if (itemIndex == -1) {
error(SWT.ERROR_CANNOT_GET_TEXT);
}
if (columnIndex >= 0 && columnIndex < labels.size()) {
label = (String) labels.elementAt(columnIndex);
}
if (label == null) {
label = ""; // label vector is initialized with null instead of empty Strings
}
return label;
}
/**
* Answer the text that is going to be drawn in 'column'. This
* text may be a trimmed copy of the original text set by the
* user if it doesn't fit into the column. In that case the last
* characters are replaced with Table.DOT_STRING.
* A cached copy of the trimmed text is returned if available.
* @param gc - GC to use for measuring the text extent
* @param column - TableColumn for which the text should be returned
*/
String getText(GC gc, TableColumn column) {
int columnIndex = column.getIndex();
String label = getTrimmedText(columnIndex);
int maxWidth;
if (label == null) {
gc.setFont(getFont());
maxWidth = getMaxTextWidth(columnIndex, column.getWidth());
label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);
}
return label;
}
/**
* Answer the indent of the text in column 'columnIndex' in pixel.
* This indent is used in front of and behind the item text.
* @param columnIndex - specifies the column for which the indent
* should be calculated.
*/
int getTextIndent(int columnIndex) {
int textIndent;
if (columnIndex == TableColumn.FIRST) {
if (getParent().hasFirstColumnImage() == false) {
textIndent = TEXT_INDENT_NO_IMAGE;
}
else {
textIndent = FIRST_COLUMN_TEXT_INDENT;
}
}
else {
textIndent = TEXT_INDENT;
}
return textIndent;
}
int getTextWidth (int columnIndex) {
if (textWidths == null) {
int count = Math.max (1, getParent ().getColumnCount ());
textWidths = new int [count];
}
String text = (String) getDataLabels().elementAt (columnIndex);
if (text != null && textWidths [columnIndex] == 0 && text.length () > 0) {
GC gc = new GC (getParent ());
gc.setFont (getFont (columnIndex));
textWidths [columnIndex] = gc.stringExtent (text).x;
gc.dispose ();
}
return textWidths [columnIndex];
}
/**
* Answer the cached trimmed text for column 'columnIndex'.
* Answer null if it hasn't been calculated yet.
* @param columnIndex - specifies the column for which the
* trimmed text should be answered.
*/
String getTrimmedText(int columnIndex) {
String label = null;
String labels[] = getTrimmedTexts();
if (columnIndex < labels.length) {
label = labels[columnIndex];
}
return label;
}
/**
* Answer an array of cached trimmed labels.
*/
String [] getTrimmedTexts() {
return trimmedLabels;
}
/**
* Ensure that the image and label vectors have at least
* 'newSize' number of elements.
*/
void growVectors(int newSize) {
Vector images = getImages();
Vector labels = getDataLabels();
if (newSize > images.size()){
images.setSize(newSize);
}
if (newSize > labels.size()){
labels.setSize(newSize);
}
}
/**
* Insert 'column' into the receiver.
*/
void insertColumn(TableColumn column) {
Vector data = getDataLabels();
Vector images = getImages();
String stringData[];
Image imageData[];
int index = column.getIndex();
if (index < data.size()) {
data.insertElementAt(null, index);
}
else {
data.addElement(null);
}
stringData = new String[data.size()];
data.copyInto(stringData);
setText(stringData);
if (index < images.size()) {
images.insertElementAt(null, index);
}
else {
images.addElement(null);
}
imageData = new Image[images.size()];
images.copyInto(imageData);
setImage(imageData);
String[] tempTrimmed = new String[trimmedLabels.length + 1];
System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
System.arraycopy(trimmedLabels, index, tempTrimmed, index + 1, trimmedLabels.length - index);
trimmedLabels = tempTrimmed;
}
/**
* Sets the image at an index.
*
* @param image the new image (or null)
*
* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
* when called from the wrong thread
* @exception SWTError(ERROR_WIDGET_DISPOSED)
* when the widget has been disposed
*/
void internalSetImage(int columnIndex, Image image) {
Vector images = getImages();
boolean imageWasNull = false;
Table parent = getParent();
if (columnIndex >= 0 &&
columnIndex < parent.internalGetColumnCount()) {
if (columnIndex >= images.size()) {
growVectors(columnIndex + 1);
}
Image oldImage = (Image) images.elementAt(columnIndex);
if (oldImage == null && image != null) {
imageWasNull = true;
}
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
if (image != null && image.type == SWT.ICON && image.equals (oldImage)) return;
images.setElementAt(image, columnIndex);
reset(columnIndex); // new image may cause text to no longer fit in the column
notifyImageChanged(columnIndex, imageWasNull);
}
}
/**
* Sets the widget text.
*
* The widget text for an item is the label of the
* item or the label of the text specified by a column
* number.
*
* @param index the column number
* @param text the new text
*
*/
void internalSetText(int columnIndex, String string) {
Vector labels = getDataLabels();
Table parent = getParent();
String oldText;
if (columnIndex >= 0 &&
columnIndex < parent.internalGetColumnCount()) {
if (columnIndex >= labels.size()) {
growVectors(columnIndex + 1);
}
oldText = (String) labels.elementAt(columnIndex);
if (string.equals(oldText) == false) {
labels.setElementAt(string, columnIndex);
clearTextWidths(columnIndex);
reset(columnIndex);
notifyTextChanged(columnIndex, oldText == null);
}
}
}
/**
* Answer whether the click at 'xPosition' on the receiver is a
* selection click.
* A selection click occurred when the click was behind the image
* and before the end of the item text.
* @return
* true - 'xPosition' is a selection click.
* false - otherwise
*/
boolean isSelectionHit(int xPosition) {
int itemStopX = getImageStopX(TableColumn.FIRST);
Point selectionExtent = getSelectionExtent();
if (selectionExtent != null) {
itemStopX += selectionExtent.x;
}
return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);
}
/**
* The image for the column identified by 'columnIndex' has changed.
* Notify the parent widget and supply redraw coordinates, if possible.
* @param columnIndex - index of the column that has a new image.
*/
void notifyImageChanged(int columnIndex, boolean imageWasNull) {
Table parent = getParent();
Rectangle changedColumnBounds;
Image currentImage;
int redrawStartX = 0;
int redrawWidth = 0;
int columnCount = parent.internalGetColumnCount();
if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
currentImage = getImage(columnIndex);
redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
if (parent.getImageExtent() != null && imageWasNull == false && currentImage != null) {
redrawWidth = getImageStopX(columnIndex);
}
else {
redrawWidth = changedColumnBounds.width;
}
redrawWidth += changedColumnBounds.x - redrawStartX;
}
cached = true;
parent.itemChanged(this, redrawStartX, redrawWidth);
}
/**
* The label for the column identified by 'columnIndex' has changed.
* Notify the parent widget and supply redraw coordinates, if possible.
* @param columnIndex - index of the column that has a new label.
*/
void notifyTextChanged(int columnIndex, boolean textWasNull) {
Table parent = getParent();
String text;
Rectangle columnBounds;
int redrawStartX = 0;
int redrawWidth = 0;
int columnCount = parent.internalGetColumnCount();
if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
text = (String) getDataLabels().elementAt(columnIndex);
columnBounds = parent.internalGetColumn(columnIndex).getBounds();
redrawStartX = columnBounds.x;
if (getImage(columnIndex) != null) {
redrawStartX += getImageStopX(columnIndex);
}
redrawStartX = Math.max(0, redrawStartX);
// don't redraw if text changed from null to empty string
if (textWasNull == false || text.length() > 0) {
redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;
}
}
cached = true;
parent.itemChanged(this, redrawStartX, redrawWidth);
}
/**
* Draw the receiver at 'paintPosition' in the column identified by
* 'columnIndex' using 'gc'.
* @param gc - GC to use for drawing
* @param paintPosition - position where the receiver should be drawing.
* @param column - the column to draw in
*/
void paint(GC gc, Point paintPosition, TableColumn column) {
int columnIndex = column.getIndex();
String label = getText(gc, column);
String oldLabel = getTrimmedText(columnIndex);
Table parent = getParent ();
int itemHeight = parent.getItemHeight ();
if (label != null && label.equals(oldLabel) == false) {
setTrimmedText(label, columnIndex);
selectionExtent = null; // force a recalculation next time the selection extent is needed
}
Color background = gc.getBackground();
if (!isSelected() || ((parent.getStyle() & SWT.HIDE_SELECTION) != 0 && !parent.isFocusControl())) {
int width = column.getBounds().width;
int height = itemHeight;
gc.setBackground(getBackground(columnIndex));
gc.fillRectangle(paintPosition.x, paintPosition.y, width, height);
} else {
if (columnIndex == TableColumn.FIRST) {
int width = getImageIndentPixel();
int height = itemHeight;
gc.setBackground(getBackground (columnIndex));
gc.fillRectangle(paintPosition.x, paintPosition.y, width, height);
} else {
if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) {
int width = column.getBounds ().width;
int height = itemHeight;
gc.setBackground(getBackground (columnIndex));
gc.fillRectangle(paintPosition.x, paintPosition.y, width, height);
}
}
}
if (columnIndex == TableColumn.FIRST) {
paintPosition.x += getImageIndentPixel();
if (isCheckable() == true) {
paintPosition = drawCheckbox(gc, paintPosition);
}
}
paintPosition = drawImage(gc, paintPosition, columnIndex);
paintPosition.x += getTextIndent(columnIndex);
drawText(label, gc, paintPosition, columnIndex);
gc.setBackground(background);
}
/**
* Remove 'column' from the receiver.
*/
void removeColumn(TableColumn column) {
Vector data = getDataLabels();
Vector images = getImages();
String stringData[];
Image imageData[];
int index = column.getIndex();
if (index < data.size()) {
data.removeElementAt(index);
stringData = new String[data.size()];
data.copyInto(stringData);
setText(stringData);
}
if (index < images.size()) {
images.removeElementAt(index);
imageData = new Image[images.size()];
images.copyInto(imageData);
setImage(imageData);
}
if (trimmedLabels.length == 1) {
trimmedLabels = new String[0];
} else {
String[] tempTrimmed = new String[trimmedLabels.length - 1];
System.arraycopy(trimmedLabels, 0, tempTrimmed, 0, index);
System.arraycopy(trimmedLabels, index +1, tempTrimmed, index, trimmedLabels.length - index -1);
trimmedLabels = tempTrimmed;
}
}
/**
* Reset the cached trimmed label for the sub item identified by
* 'index'.
* @param index - index of the label that should be reset.
*/
void reset(int index) {
String trimmedLabels[] = getTrimmedTexts();
if (index >= 0 && index < trimmedLabels.length) {
trimmedLabels[index] = null;
}
if (index == TableColumn.FIRST) {
selectionExtent = null;
}
}
void redraw(){
cached = true;
Table parent = getParent();
int y = parent.getRedrawY(this);
parent.redraw(0, y, parent.getClientArea().width, parent.getItemHeight(), false);
}
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the item
* if the argument is null.
*
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 2.0
*
*/
public void setBackground (Color color) {
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
if (background == color) return;
if (background != null && background.equals (color)) return;
background = color;
redraw();
}
/**
* Sets the background color at the given column index in the receiver
* to the color specified by the argument, or to the default system color for the item
* if the argument is null.
*
* @param index the column index
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 setBackground (int index, Color color) {
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
Table parent = getParent ();
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return;
if (cellBackground == null) {
cellBackground = new Color [count];
}
if (cellBackground [index] == color) return;
if (cellBackground [index] != null && cellBackground [index].equals (color)) return;
cellBackground [index] = color;
redraw ();
}
/**
* Sets the font that the receiver will use to paint textual information
* for this item to the font specified by the argument, or to the default font
* for that kind of control if the argument is null.
*
* @param font the new font (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 setFont (Font font) {
checkWidget ();
if (font != null && font.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
if (this.font == font) return;
if (this.font != null && this.font.equals (font)) return;
this.font = font;
clearTextWidths ();
redraw ();
}
/**
* Sets the font that the receiver will use to paint textual information
* for the specified cell in this item to the font specified by the
* argument, or to the default font for that kind of control if the
* argument is null.
*
* @param index the column index
* @param font the new font (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 setFont (int index, Font font) {
checkWidget ();
if (font != null && font.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
Table parent = getParent ();
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count - 1) return;
if (cellFont == null) {
cellFont = new Font [count];
}
if (cellFont [index] == font) return;
if (cellFont [index] != null && cellFont [index].equals (font)) return;
cellFont [index] = font;
clearTextWidths (index);
redraw ();
}
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the item
* if the argument is null.
*
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 2.0
*
*/
public void setForeground (Color color){
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
if (foreground == color) return;
if (foreground != null && foreground.equals (color)) return;
foreground = color;
redraw();
}
/**
* Sets the foreground color at the given column index in the receiver
* to the color specified by the argument, or to the default system color for the item
* if the argument is null.
*
* @param index the column index
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument 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 setForeground (int index, Color color){
checkWidget ();
if (color != null && color.isDisposed ()) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
Table parent = getParent ();
int count = Math.max (1, parent.getColumnCount ());
if (0 > index || index > count -1) return;
if (cellForeground == null) {
cellForeground = new Color [count];
}
if (cellForeground [index] == color) return;
if (cellForeground [index] != null && cellForeground [index].equals (color)) return;
cellForeground [index] = color;
redraw ();
}
/**
* Sets the image for multiple columns in the Table.
*
* @param images the array of new images
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
* <li>ERROR_INVALID_ARGUMENT - if one of the images 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>
*/
public void setImage(Image [] images) {
checkWidget();
if (images == null) {
error(SWT.ERROR_NULL_ARGUMENT);
}
if (getParent().indexOf(this) == -1) {
return;
}
for (int i = 0; i < images.length; i++) {
internalSetImage(i, images[i]);
}
}
/**
* Sets the receiver's image at a column.
*
* @param index the column index
* @param image the new image
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the image 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>
*/
public void setImage(int index, Image image) {
checkWidget();
if (getParent().indexOf(this) != -1) {
internalSetImage(index, image);
}
}
public void setImage(Image image) {
checkWidget();
setImage(0, image);
}
/**
* Sets the indent of the first column's image, expressed in terms of the image's width.
*
* @param indent the new indent
*
* </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 setImageIndent(int indent) {
checkWidget();
Table parent = getParent();
TableColumn column;
int index = parent.indexOf(this);
if (index != -1 && indent >= 0 && indent != imageIndent) {
imageIndent = indent;
column = parent.internalGetColumn(TableColumn.FIRST);
parent.redraw(
0, parent.getRedrawY(this),
column.getWidth(), parent.getItemHeight(), false);
cached = true;
}
}
/**
* Sets the text for multiple columns in the table.
*
* @param strings the array of new strings
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the text 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 setText(String [] strings) {
checkWidget();
if (strings == null) {
error(SWT.ERROR_NULL_ARGUMENT);
}
if (getParent().indexOf(this) == -1) {
return;
}
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
if (string != null) {
internalSetText(i, string);
}
}
}
/**
* Sets the receiver's text at a column
*
* @param index the column index
* @param string the new text
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the text 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 setText (int index, String string) {
checkWidget();
if (string == null) {
error(SWT.ERROR_NULL_ARGUMENT);
}
if (getParent().indexOf(this) != -1) {
internalSetText(index, string);
}
}
public void setText(String text) {
checkWidget();
if (text == null) {
error(SWT.ERROR_NULL_ARGUMENT);
}
setText(0, text);
}
/**
* Set the trimmed text of column 'columnIndex' to label. The trimmed
* text is the one that is displayed in a column. It may be shorter than
* the text originally set by the user via setText(...) to fit the
* column.
* @param label - the text label of column 'columnIndex'. May be trimmed
* to fit the column.
* @param columnIndex - specifies the column whose text label should be
* set.
*/
void setTrimmedText(String label, int columnIndex) {
String labels[] = getTrimmedTexts();
if (columnIndex < labels.length) {
labels[columnIndex] = label;
}
}
/**
* Sets the checked state of the checkbox for this item. This state change
* only applies if the Table was created with the SWT.CHECK style.
*
* @param checked the new checked state of the checkbox
*
* @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 setChecked(boolean checked) {
checkWidget();
super.setChecked(checked);
}
/**
* Sets the grayed state of the checkbox for this item. This state change
* only applies if the Table was created with the SWT.CHECK style.
*
* @param grayed the new grayed state of the checkbox;
*
* @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 setGrayed (boolean grayed) {
checkWidget();
super.setGrayed(grayed);
}
/**
* Set the index of this item in its parent widget to 'newIndex'.
*/
void setIndex(int newIndex) {
index = newIndex;
}
}
| [
"[email protected]"
] | |
bdc3831bb361d8b7ad66762ff77bbf388e446248 | 470b59a3845ffce3e917cecdfec276e997317ebd | /数据结构/niuniu/src/Main.java | 10295ce8eee565548cd65f05e57043229cedadbb | [] | no_license | RichardW911/RichardW911 | 3996576ca413d76a43a9dcdb3fdd65ef03f0e683 | 2e0b42e3d30bbd247df8b086e49189d5fde671c6 | refs/heads/master | 2023-06-20T05:06:28.520935 | 2021-07-21T05:35:52 | 2021-07-21T05:35:52 | 372,862,327 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,322 | java | import com.sun.deploy.uitoolkit.impl.text.TextPluginUIToolkit;
import com.sun.org.apache.xerces.internal.xinclude.XInclude11TextReader;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLFault;
import sun.net.httpserver.HttpServerImpl;
import javax.net.ssl.SSLServerSocket;
import java.net.ServerSocket;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;
import java.util.Scanner;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) throws InterruptedException {
Stack<String> stack = new Stack<>();
Scanner sc = new Scanner(System.in);
int max = 0;
int n = sc.nextInt();
while(sc.hasNext()) {
for(int i = 0; i < n; i++) {
String[] str = sc.nextLine().split(" ");
if(str[1].equals("connect")) {
stack.push(str[0]);
if(stack.size() > max) {
max = stack.size();
}
}else if(str[1].equals("disconnect")) {
stack.pop();
}
}
System.out.println(max);
}
TimeUnit.SECONDS.sleep(100);
}
Semaphore semaphore = new Semaphore(2,true);
}
class Main99
{
public static void main(String[] args)throws Exception
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String str="";
while((str=br.readLine())!=null)
{
String[] strs= str.split(" ");
int m= Integer.parseInt(strs[0]);
int n= Integer.parseInt(strs[1]);
int[][] nums=new int[m][n];
for(int i=0;i<m;i++){
String strr = br.readLine();
String[] b = strr.split(" ");
for(int j=0;j<n;j++){
nums[i][j] = Integer.parseInt(b[j]);
}
}
String[] res={""};
peocess(nums,0,0,"(0,0)\n",res);
if(res[0].length()==0)
System.out.println("(0,0)");
else System.out.println(res[0].substring(0,res[0].length()-1));
}
}
public static void peocess(int[][]arr,int x,int y,String path,String[]res)
{
if ((x==arr.length-1)&&(y==arr[x].length-1))
{
if (arr[x][y]==0)
res[0]=path;
return;
}
if (x>arr.length-1||y>arr[x].length-1)
return;
if (x+1<arr.length&&arr[x+1][y]==0)
peocess(arr,x+1,y,path+"("+(x+1)+","+y+")\n",res);
if (y+1<arr[x].length&&arr[x][y+1]==0)
peocess(arr,x,y+1,path+"("+x+","+(y+1)+")\n",res);
}
}
/*
public class Main {
private int n;
private int m;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[][] nums = new int[n][m];
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
nums[i][j] = sc.nextInt();
}
}
}
public void backTrack(int[][] nums,int n, int m, int i, int j) {
if(i == n - 1 && j == m - 1 ) {
return;
}
for(; j < m; j++) {
if(nums[i][j] == 1 || j + 1 >= m) {
backTrack(nums,n,m,i + 1, j);
}
}
backTrack(nums,n,m,i,j - 1);
}
}
*/
class Main10 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int res = findFib(n);
if(res == -1) System.out.println("null");
else System.out.println(res);
/*Scanner in = new Scanner(System.in);
HashMap<Character,Integer> map = new HashMap<>();
while (in.hasNext()) {
String str = in.nextLine();
char[] ch = str.toCharArray();
for (char c : ch) {
if(map.containsKey(c)) {
map.put(c,map.get(c) + 1);
} else {
map.put(c,1);
}
}
int i;
for(i = 0; i < ch.length; i++) {
if(map.get(ch[i]) == 1) {
System.out.println(ch[i]);
break;
}
}
if(i == ch.length) {
System.out.println("-1");
}
}*/
}
public static int Fib1(int n) {
if(n == 0 || n == 1) return 0;
if(n == 2) return 1;
return Fib1(n - 1) + Fib1(n - 2);
}
public static int Fib2(int n) {
if(n == 0 || n == 1) return 0;
if(n == 2) return 1;
int a = 0;
int b = 1;
for(int i = n - 2; i > 0; i--) {
int c = a + b;
a = b;
b = c;
}
return b;
}
public static int findFib(int n) {
if(n == 0) return 1;
if(n == 1) return 2;
int a = 0;
int b = 1;
int count = 2;
while(b < n) {
int c = a + b;
a = b;
b = c;
count++;
}
if(b != n) {
return -1;
}else {
return count;
}
}
}
/*
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int n = in.nextInt();//怪物数量
int a = in.nextInt();//小易的初始能力值
int[] num = new int[n];//每个怪物的防御力
for(int i = 0; i < n; i++) {
num[i] = in.nextInt();
}
for(int i = 0; i < n; i++) {
if(a >= num[i]) {
a = a + num[i];
} else {
a = a + GCD(a,num[i]);
}
}
System.out.println(a);
}
}
//求最大公约数
public static int GCD(int m,int n) {
if(m<n) {
int k=m;
m=n;
n=k;
}
//if(m%n!=0) {
// m=m%n;
// return gcd(m,n);
//}
//return n;
return m%n == 0?n:GCD(n,m%n);
}
}*/
| [
"[email protected]"
] | |
bf51c7d22117a9a55159755a990d74af01656dbf | d531fc55b08a0cd0f71ff9b831cfcc50d26d4e15 | /gen/main/java/org/hl7/fhir/ImmunizationEvaluationStatusCodes.java | c14634f808e3804d6aba1d93fd4db6a83d3fdf65 | [] | no_license | threadedblue/fhir.emf | f2abc3d0ccce6dcd5372874bf1664113d77d3fad | 82231e9ce9ec559013b9dc242766b0f5b4efde13 | refs/heads/master | 2021-12-04T08:42:31.542708 | 2021-08-31T14:55:13 | 2021-08-31T14:55:13 | 104,352,691 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,699 | java | /**
*/
package org.hl7.fhir;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Immunization Evaluation Status Codes</b></em>'.
* <!-- end-user-doc -->
*
* <!-- begin-model-doc -->
* The status of the evaluation being done.
* If the element is present, it must have either a @value, an @id, or extensions
* <!-- end-model-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.hl7.fhir.ImmunizationEvaluationStatusCodes#getValue <em>Value</em>}</li>
* </ul>
*
* @see org.hl7.fhir.FhirPackage#getImmunizationEvaluationStatusCodes()
* @model extendedMetaData="name='ImmunizationEvaluationStatusCodes' kind='elementOnly'"
* @generated
*/
public interface ImmunizationEvaluationStatusCodes extends Element {
/**
* Returns the value of the '<em><b>Value</b></em>' attribute.
* The literals are from the enumeration {@link org.hl7.fhir.ImmunizationEvaluationStatusCodesList}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Value</em>' attribute.
* @see org.hl7.fhir.ImmunizationEvaluationStatusCodesList
* @see #isSetValue()
* @see #unsetValue()
* @see #setValue(ImmunizationEvaluationStatusCodesList)
* @see org.hl7.fhir.FhirPackage#getImmunizationEvaluationStatusCodes_Value()
* @model unsettable="true"
* extendedMetaData="kind='attribute' name='value'"
* @generated
*/
ImmunizationEvaluationStatusCodesList getValue();
/**
* Sets the value of the '{@link org.hl7.fhir.ImmunizationEvaluationStatusCodes#getValue <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Value</em>' attribute.
* @see org.hl7.fhir.ImmunizationEvaluationStatusCodesList
* @see #isSetValue()
* @see #unsetValue()
* @see #getValue()
* @generated
*/
void setValue(ImmunizationEvaluationStatusCodesList value);
/**
* Unsets the value of the '{@link org.hl7.fhir.ImmunizationEvaluationStatusCodes#getValue <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isSetValue()
* @see #getValue()
* @see #setValue(ImmunizationEvaluationStatusCodesList)
* @generated
*/
void unsetValue();
/**
* Returns whether the value of the '{@link org.hl7.fhir.ImmunizationEvaluationStatusCodes#getValue <em>Value</em>}' attribute is set.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return whether the value of the '<em>Value</em>' attribute is set.
* @see #unsetValue()
* @see #getValue()
* @see #setValue(ImmunizationEvaluationStatusCodesList)
* @generated
*/
boolean isSetValue();
} // ImmunizationEvaluationStatusCodes
| [
"[email protected]"
] | |
174f736d463859481b7c1a6758a14ca8354167dc | a7ba4d78dbdba146c5b7452141111c9d2a60216a | /app/src/main/java/com/example/chat_boot/MessageAdapter.java | 94e692394191c0412b0ac9fd19bb1f0237bd64f9 | [] | no_license | Ariful0007/Chat_Boot | 17017cbc96c245e38ebf3abc63a2dc2a00976870 | 34694593535efe568f51652c6e27617678c6c45d | refs/heads/master | 2022-12-28T07:53:15.816701 | 2020-10-20T06:30:30 | 2020-10-20T06:30:30 | 305,611,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,541 | java | package com.example.chat_boot;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.CustomViewHolder> {
List<ResponseMessage> responseMessages;
Context context;
class CustomViewHolder extends RecyclerView.ViewHolder{
TextView textView;
public CustomViewHolder(View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.textMessage);
}
}
public MessageAdapter(List<ResponseMessage> responseMessages, Context context) {
this.responseMessages = responseMessages;
this.context = context;
}
@Override
public int getItemViewType(int position) {
if(responseMessages.get(position).isMe()){
return R.layout.me_buble;
}
return R.layout.boot_buble;
}
@Override
public int getItemCount() {
return responseMessages.size();
}
@Override
public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new CustomViewHolder(LayoutInflater.from(parent.getContext())
.inflate(viewType, parent, false));
}
@Override
public void onBindViewHolder(CustomViewHolder holder, int position) {
holder.textView.setText(responseMessages.get(position).getText());
}
} | [
"[email protected]"
] | |
191c56bda4aa320a84adfa8ce6eb52a9a5c9e9ff | 83597086cd4f6864def1a4e5662077b8f60d390f | /src/controller/editEventServlet.java | 33544d7b05bcb1192e7dcacf23b8aa886a28cc1b | [] | no_license | zjhayes/EventManager | 647d4ec020128fff939f78674bb980c60d655e73 | 40f6d33531d5eb22097a9d906fe49f50bbe62ed7 | refs/heads/master | 2022-07-09T18:01:01.596059 | 2020-03-06T16:49:48 | 2020-03-06T16:49:48 | 243,430,705 | 0 | 1 | null | 2022-06-21T02:52:21 | 2020-02-27T04:30:19 | Java | UTF-8 | Java | false | false | 2,275 | java | package controller;
import java.io.IOException;
import java.time.LocalDate;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Event;
import model.Person;
/**
* Servlet implementation class editEventServlet
*/
@WebServlet("/editEventServlet")
public class editEventServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public editEventServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
EventHelper eh = new EventHelper();
PersonHelper ph = new PersonHelper();
Integer tempId = Integer.parseInt(request.getParameter("id"));
Event toUpdate = eh.searchForEventById(tempId);
String eventName = request.getParameter("Ename");
String month = request.getParameter("month");
String day = request.getParameter("day");
String year = request.getParameter("year");
LocalDate ld;
try
{
ld = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
}
catch (NumberFormatException ex)
{
ld = LocalDate.now();
}
Person hostToAdd = null;
String selectedHost = request.getParameter("hostToAdd");
if(selectedHost != null)
{
hostToAdd = ph.searchForPersonById(Integer.parseInt(selectedHost));
}
toUpdate.setName(eventName);
toUpdate.setEventDate(ld);
if(hostToAdd != null)
{
toUpdate.setHost(hostToAdd);
}
eh.updateEvent(toUpdate);
getServletContext().getRequestDispatcher("/viewEventServlet").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
] | |
d66c7e0896d3179f20c23ba2eddb1b989ba250ab | c77252c03a0c52b32ad04f9e6fdbdc7d383b3859 | /src/main/java/cn/garyt/cast/gstreamer/player/event/PositionChangedEvent.java | c39cadd71db953a54b36e5b7fc1ce43453d81540 | [] | no_license | GaryT9527/cling-cast | a0022ef51672c2d790ef46feb7784ab7487d0015 | daa5b3ebe4b1b9d718f110bfdb5ac67ee603ebfc | refs/heads/master | 2022-04-16T08:09:39.935306 | 2020-04-15T01:44:55 | 2020-04-15T01:44:55 | 255,774,398 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 740 | java | package cn.garyt.cast.gstreamer.player.event;
import cn.garyt.cast.gstreamer.player.MediaPlayer;
public class PositionChangedEvent extends MediaEvent {
private static final long serialVersionUID = 269889318281659313L;
public final long position;
public final int percent;
public PositionChangedEvent(MediaPlayer player, long position, int percent) {
super(player);
this.position = position;
this.percent = percent;
}
public int getPercent() {
return percent;
}
public long getPosition() {
return position;
}
@Override
public String toString() {
return getClass().getName() + "[source=" + getSource() + ",position=" + position + "]";
}
} | [
"[email protected]"
] | |
6f8d0b01407b7e3ae4b52c56732250229823ab8d | 16ae9299ebc2ec33ef5baf8a3dacc2270ad023ba | /net.loginbuddy.service/src/main/java/net/loginbuddy/service/management/ConfigurationMaster.java | 9facf5898227ece27d2ce579a6bcc67043385a7f | [
"Apache-2.0"
] | permissive | SaschaZeGerman/loginbuddy | 4b005a5bbaa25327de7aba3458ebb73db20b8990 | 6d21d56df974b1f5f365376e63224f6718dd78f3 | refs/heads/master | 2023-05-26T09:37:23.166270 | 2023-02-02T06:16:32 | 2023-02-02T06:16:32 | 158,331,158 | 17 | 7 | Apache-2.0 | 2023-05-22T19:59:53 | 2018-11-20T04:32:27 | Java | UTF-8 | Java | false | false | 8,447 | java | package net.loginbuddy.service.management;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import net.loginbuddy.common.api.HttpHelper;
import net.loginbuddy.config.discovery.DiscoveryUtil;
import net.loginbuddy.config.management.AccessToken;
import net.loginbuddy.config.management.AccessTokenLocation;
import net.loginbuddy.config.management.ConfigurationTypes;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public abstract class ConfigurationMaster extends Management {
public static boolean isConfigManagementEnabled() {
return isManagementEnabled() && DiscoveryUtil.UTIL.getManagement().getConfigurationEndpoint() != null;
}
// TODO update group(2) when a JSON schema gets introduced that validates values such as permitted provider name length
private static Pattern pEntities = Pattern.compile(
String.format("^/(%s|%s|%s|%s)(?:/([a-zA-Z0-9-_]{1,64}))?$",
ConfigurationTypes.CLIENTS.toString(),
ConfigurationTypes.PROVIDERS.toString(),
ConfigurationTypes.DISCOVERY.toString(),
ConfigurationTypes.PROPERTIES.toString()));
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
if(!isConfigManagementEnabled()) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration management is not enabled").toJSONString());
return;
}
Matcher matcher = pEntities.matcher(request.getPathInfo() == null ? "unknown" : request.getPathInfo());
if (matcher.find()) {
try {
doGetProtected(request, response, ConfigurationTypes.valueOf(matcher.group(1).toUpperCase()), matcher.group(2), new AccessToken(request, AccessTokenLocation.HEADER));
} catch (IllegalArgumentException e) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", e.getMessage()).toJSONString());
}
} else {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration type was not given or is not supported").toJSONString());
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
if(!isConfigManagementEnabled()) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration management is not enabled").toJSONString());
return;
}
Matcher matcher = pEntities.matcher(request.getPathInfo() == null ? "unknown" : request.getPathInfo());
if (matcher.find()) {
try {
String httpBody = HttpHelper.readMessageBody(request.getReader());
if (request.getContentType().startsWith("application/json")) {
response.setStatus(200);
response.getWriter().println(
doPostProtected(
httpBody,
ConfigurationTypes.valueOf(matcher.group(1).toUpperCase()),
matcher.group(2),
new AccessToken(request, AccessTokenLocation.HEADER)));
} else {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "the given content-type is not supported!"));
}
} catch (Exception e) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", e.getMessage()).toJSONString());
}
} else {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration type was not given or is not supported").toJSONString());
}
}
@Override
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/json");
if(!isConfigManagementEnabled()) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration management is not enabled").toJSONString());
return;
}
Matcher matcher = pEntities.matcher(request.getPathInfo() == null ? "unknown" : request.getPathInfo());
if (matcher.find()) {
try {
String httpBody = HttpHelper.readMessageBody(request.getReader());
if (request.getContentType().startsWith("application/json")) {
response.setStatus(200);
response.getWriter().println(
doPutProtected(
httpBody,
ConfigurationTypes.valueOf(matcher.group(1).toUpperCase()),
matcher.group(2),
new AccessToken(request, AccessTokenLocation.HEADER)));
} else {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "the given content-type is not supported!"));
}
} catch (Exception e) {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", e.getMessage()).toJSONString());
}
} else {
response.setStatus(400);
response.getWriter().println(HttpHelper.getErrorAsJson("invalid_request", "configuration type was not given or is not supported").toJSONString());
}
}
/**
* This method retrieves requested configuration.
*
* @param request the request
* @param response the response
* @param configType the requested configuration type. Values must match a valid of ConfigurationTypes
* @param selector depending on the type this value must identify a specific configuration. For example, client configurations this would require a valid client_id
* @param token the access_token for this request/ It must have been granted for required scope and resource
* @throws ServletException
* @throws IOException
*/
protected abstract void doGetProtected(HttpServletRequest request, HttpServletResponse response, ConfigurationTypes configType, String selector, AccessToken token) throws ServletException, IOException;
/**
* This method replaces the given configuration.
*
* @param configType the requested configuration type. Values must match a valid of ConfigurationTypes
* @param selector depending on the type this value must identify a specific configuration. For example, client configurations this would require a valid client_id
* @param token the access_token for this request/ It must have been granted for required scope and resource
* @throws ServletException
* @throws IOException
*/
protected abstract String doPostProtected(String httpBody, ConfigurationTypes configType, String selector, AccessToken token) throws Exception;
/**
* This method updates the given configuration.
*
* @param configType the requested configuration type. Values must match a valid of ConfigurationTypes
* @param selector depending on the type this value must identify a specific configuration. For example, client configurations this would require a valid client_id
* @param token the access_token for this request/ It must have been granted for required scope and resource
* @throws ServletException
* @throws IOException
*/
protected abstract String doPutProtected(String httpBody, ConfigurationTypes configType, String selector, AccessToken token) throws Exception;
}
| [
"[email protected]"
] | |
fd2ad42d17ddd008a36aec1447806396a4402c8a | c7823dd5857604ebfdf62e04990f4c24ce4c34e6 | /Mobile-Dev-Analysis/android-analysis-(kachidoki-moiling-luoyy)/ViewAnalysis/app/src/main/java/com/example/administrator/viewanalysis/MainActivity.java | b1cb418d860df7988744491ffb5ff2b1d0f210e1 | [
"Apache-2.0"
] | permissive | MathiasLuo/Mobile-Dev-Analysis | 55c2bde1a67b9c614158d0f7e949167bc60193f9 | 8c7252bd036767fd9332326e443a506da73e560b | refs/heads/master | 2020-04-07T14:00:42.542255 | 2015-03-21T10:59:24 | 2015-03-21T10:59:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 408 | java | package com.example.administrator.viewanalysis;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
| [
"[email protected]"
] | |
4d43a8cd63d4c49681e83f0a7b77f22773e7d57e | 118cd90e9545bceaca9cf17a64d73bc5aaa7e056 | /src/main/java/com/zr/xinshenstatistics/service/impl/XinshenstatisticsServiceImpl.java | 60459b9e4073d77a24f2026205cbc182b45b1848 | [] | no_license | harry2048/operate-platform | e89ed59b036e1ef1da070b1a36845c49c7098cfa | 7d98ea13b454abfd48ded655d69c137d67b9c832 | refs/heads/master | 2022-12-10T17:20:12.506992 | 2019-07-10T02:40:19 | 2019-07-10T02:40:19 | 195,345,156 | 0 | 1 | null | 2022-12-06T00:32:22 | 2019-07-05T05:38:08 | HTML | UTF-8 | Java | false | false | 5,558 | java | package com.zr.xinshenstatistics.service.impl;
import antlr.collections.impl.LList;
import com.zr.xinshenstatistics.mapper.XinshenstatisticsMapper;
import com.zr.xinshenstatistics.pojo.Riskreserve_Capitalside;
import com.zr.xinshenstatistics.pojo.Xinshenstatistics;
import com.zr.xinshenstatistics.pojo.XinshenstatisticsVO;
import com.zr.xinshenstatistics.service.XinshenstatisticsService;
import com.zr.xinshenstatistics.util.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
/**
* Created by 86151 on 2019/6/14.
*/
@Service
@Slf4j
public class XinshenstatisticsServiceImpl implements XinshenstatisticsService {
@Autowired
private XinshenstatisticsMapper xinshenstatisticsMapper;
@Override
@Transactional
public ResultVo<AllRecords> queryPage(XinshenstatisticsVO xinshenstatisticsVO) {
//查询数据
List<Xinshenstatistics> xinshenstatisticsList = xinshenstatisticsMapper.queryPage(xinshenstatisticsVO);
//查询数量
int count = xinshenstatisticsMapper.queryCount(xinshenstatisticsVO);
//把当前页、每页大小、总页数、总条数、数据统一放入到AllRecords返回
AllRecords allRecords = new AllRecords();
allRecords.setPageIndex(xinshenstatisticsVO.getPageIndex());
allRecords.setPageSize(xinshenstatisticsVO.getPageSize());
allRecords.setTotalNumber(count);
allRecords.resetTotalNumber(count);
allRecords.setDataList(xinshenstatisticsList);
return ResultBuildVo.success(allRecords);
}
/**
* //1.定义一个导出模板
//2.从数据库中查询出将要导出的数据
//3.把从数据库中查询出的数据赋值给导出模板
//4.对需要转化的数据进行转化
//5.在浏览器生成一个文件
*/
@Override
public ResultVo exportExcel(HttpServletResponse response, XinshenstatisticsVO xinshenstatisticsVO) throws Exception {
List<Xinshenstatistics> xinshenstatisticsList = xinshenstatisticsMapper.queryBySelectVo(xinshenstatisticsVO);
System.out.println("长度"+xinshenstatisticsList.size());
//限制,导出10000数据
int totalNum = xinshenstatisticsMapper.queryCount(xinshenstatisticsVO);
if(totalNum>10000){
return ResultBuildVo.error("默认导出10000条数据","500");
}
//3.把从数据库中查询出的数据赋值给导出模
//获取响应输出流
ServletOutputStream out = response.getOutputStream();
//给输出文件设置名称
POIClass.toPackageOs(response, "提前结清导出");
//读取模板中的数据
InputStream in = ExportUtil.toPackageIn("templates/提前结清.xlsx");
//根据模板的数据、把查询出来的数据给摸版SHeet1组中的数据赋值、把excel输出到浏览器上
writeDataToExcel(in, "Sheet1", xinshenstatisticsList, out);
if (in != null) {
in.close();
out.close();
}
return null;
}
@Override
public ResultVo queryAll() {
List<Riskreserve_Capitalside> riskreserve_Capitalside = xinshenstatisticsMapper.queryAll();
if (riskreserve_Capitalside.size() == 0){
return ResultBuildVo.error("查看对象不存在!","500");
}
return ResultBuildVo.success(riskreserve_Capitalside);
}
// 由于此方法不能通用, 所以单独写在这里
private void writeDataToExcel(InputStream in, String sheetName,
List<Xinshenstatistics> resultList, ServletOutputStream out) throws Exception {
//POi读取模板
XSSFWorkbook wb = new XSSFWorkbook(in);
//读取sheet1中的数据
Sheet sheet = wb.getSheet(sheetName);
if (sheet != null) {
//向sheet1中赋值,设置样式
toResultListValueInfo( sheet, resultList);
}
//把数据写入到输出流中
wb.write(out);
//关闭poi方法
wb.close();
}
/**
* 插入excel表中项目信息
*
* @param sheet
*/
private void toResultListValueInfo(Sheet sheet, List<Xinshenstatistics> earliersettlementList) {
//从第五行开始赋值
int row_column = 4;
int i = 0;
//遍历数据集合
for (Xinshenstatistics obj : earliersettlementList) {
//创建一行的方法
Row row = sheet.createRow(row_column);
// 给第一列序号赋值赋值
POIClass.toCellValue(row, 0, i++ + "");
POIClass.toCellValue(row, 1, obj.getScopeOfBusiness() + "");
POIClass.toCellValue(row, 2, obj.getOrderNum() + "");
POIClass.toCellValue(row, 4, obj.getLoanTime() + "");
POIClass.toCellValue(row, 5, obj.getManagemen() + "");
POIClass.toCellValue(row, 6, obj.getChannel() + "");
POIClass.toCellValue(row, 7, obj.getCustomerName() + "");
POIClass.toCellValue(row, 8, obj.getIdCode() + "");
row_column++;
}
}
}
| [
"[email protected]"
] | |
aeeff636ace3b5a85abccba78144adc981724a96 | 785ae8bc513eae6873f335e79d12af3b415d0afc | /Check_the_vowel.java | 47afe08898d59236073cda7624ee80a91b9faac8 | [] | no_license | mandavajyothi/guvi | 744e4e8a5652cdbcc84ef85d05f853b97b9088f5 | 226b3b26ae57a420cb729b57a38dfe2e85bc08cf | refs/heads/master | 2020-03-24T06:26:21.775619 | 2018-09-20T10:43:59 | 2018-09-20T10:43:59 | 142,528,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 367 | java | import java.util.*;
class Check_the_vowel
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int count=0;
for(int i=0;i<s.length();i++)
{
if(s.charAt(i)=='a'||s.charAt(i)=='e'||s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)=='u')
count++;
}
if(count>0)
System.out.println("yes");
else
System.out.println("no");
}
}
| [
"[email protected]"
] | |
5a5ada71a833628ae9edaeeb102f6783a9accfec | 4c0926a98c8309da0c6900120bc4d7721c51f87a | /src/input/old/KeyPressed.java | 6ba565e852797f67e06ceda8e6629d85623929bc | [] | no_license | FireFlyForLife/TileGameV3 | 9498bb3032b851b4c78c337f80e92fc79de4cb2c | c1f03f2eb1d9503e6ff711cf89c25f4281cb462d | refs/heads/master | 2020-12-24T16:07:26.686574 | 2016-03-04T11:50:26 | 2016-03-04T11:50:26 | 42,243,024 | 0 | 0 | null | 2015-09-11T07:50:12 | 2015-09-10T12:27:19 | null | UTF-8 | Java | false | false | 141 | java | package input.old;
import java.awt.event.KeyEvent;
public interface KeyPressed extends EventMethod{
public void keyPressed(KeyEvent e);
}
| [
"[email protected]"
] | |
38a811fb2db9e5dd8a6e4dea037fc5cdaf182e8e | 261df9a087967ae857bf0221d5b0dbb901666dbb | /src/main/java/de/befrish/jqwik/vavr/arbitraries/collection/seq/VavrVectorArbitrary.java | bf876699114ac22dd5af1e39085491f313999d35 | [
"Apache-2.0"
] | permissive | davd33/jqwik-vavr | 527aa0527518cb14c50b2d94b1dda868438af88c | d1ea6172f26daf724697c0cd1fd766f8020364f6 | refs/heads/master | 2022-12-29T07:16:14.130614 | 2020-10-21T23:52:37 | 2020-10-21T23:52:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 612 | java | package de.befrish.jqwik.vavr.arbitraries.collection.seq;
import de.befrish.jqwik.vavr.arbitraries.base.AbstractListBasedVavrArbitrary;
import io.vavr.collection.Array;
import io.vavr.collection.Vector;
import net.jqwik.api.Arbitrary;
public class VavrVectorArbitrary<T> extends AbstractListBasedVavrArbitrary<T, Vector<T>> {
public VavrVectorArbitrary(final Arbitrary<T> elementArbitrary, final boolean elementsUnique) {
super(elementArbitrary, elementsUnique);
}
@Override
protected Vector<T> convertJavaListToVavrCollection(final java.util.List<T> javaList) {
return Vector.ofAll(javaList);
}
}
| [
"[email protected]"
] | |
5763fb897ddb81dc1e667f31abfdbab5f03bef28 | 9bb54d587b38cb505d86c75db96fc20986ae8416 | /ImageView/app/src/androidTest/java/com/example/dopcountry/imageview/ExampleInstrumentedTest.java | 783fa2bc68d71262c3f20eb290ac94051efbc57a | [] | no_license | arifromdon/LearningAndroid | 2e27e37e7f202ded3d68c92c1589b17ad3573212 | d70074fa14d43ac1465bdea1ac24aa6797216847 | refs/heads/master | 2020-03-16T00:26:07.000879 | 2018-05-17T02:29:42 | 2018-05-17T02:29:42 | 132,416,463 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 748 | java | package com.example.dopcountry.imageview;
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.dopcountry.imageview", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
3aaa1fc939e8e402f6d829e929cb8befa626c301 | 3640cc81f0acaf06712c9f25082e7117899e2a0e | /hw03/src/main/java/ru/dio/testframework/After.java | d486de365020a0564e86c72c2f0dc146b9f3a5ec | [] | no_license | S-Dionis/otus_hws | b9ac633c93ef137be90bf9ca5ecc2678381dc3dd | 60a16db07999de558360a4004aaa611b5cbbf2c0 | refs/heads/master | 2023-02-13T13:35:13.224114 | 2021-01-14T11:25:58 | 2021-01-14T11:25:58 | 285,256,278 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 180 | java | package ru.dio.testframework;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface After {
}
| [
"[email protected]"
] | |
5a4adbc870ad94349550930967795cad0603d0bb | 48e835e6f176a8ac9ae3ca718e8922891f1e5a18 | /benchmark/validation/hudson/scm/ChangeLogSetTest.java | aac341d1da66bd486b8ac8d39e83415359472d38 | [] | no_license | STAMP-project/dspot-experiments | f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5 | 121487e65cdce6988081b67f21bbc6731354a47f | refs/heads/master | 2023-02-07T14:40:12.919811 | 2019-11-06T07:17:09 | 2019-11-06T07:17:09 | 75,710,758 | 14 | 19 | null | 2023-01-26T23:57:41 | 2016-12-06T08:27:42 | null | UTF-8 | Java | false | false | 1,537 | java | package hudson.scm;
import hudson.Extension;
import hudson.MarkupText;
import hudson.model.AbstractBuild;
import hudson.scm.ChangeLogSet.Entry;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.FakeChangeLogSCM.EntryImpl;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
public class ChangeLogSetTest {
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
@Issue("JENKINS-17084")
public void catchingExceptionDuringAnnotation() {
EntryImpl change = new EntryImpl();
change.setParent(ChangeLogSet.createEmpty(null));// otherwise test would actually test only NPE thrown when accessing parent.build
boolean notCaught = false;
try {
change.getMsgAnnotated();
} catch (Throwable t) {
notCaught = true;
}
Assert.assertEquals(new EntryImpl().getMsg(), change.getMsg());
Assert.assertEquals(false, notCaught);
}
@Extension
public static final class ThrowExceptionChangeLogAnnotator extends ChangeLogAnnotator {
@Override
public void annotate(AbstractBuild<?, ?> build, Entry change, MarkupText text) {
throw new RuntimeException();
}
}
@Extension
public static final class ThrowErrorChangeLogAnnotator extends ChangeLogAnnotator {
@Override
public void annotate(AbstractBuild<?, ?> build, Entry change, MarkupText text) {
throw new Error();
}
}
}
| [
"[email protected]"
] | |
20c847c9af89633f7a7965f2904afee25591bc7a | d8030364f8259477e3c9816adf05ca11c100deec | /src/test/java/com/tescobank/judge/view/PreContractLoanView.java | edc202090a30eb65b50be802f9b991fd0229edb4 | [] | no_license | ajsin0508/Selenium-Framework | f20653cb86dd8030d13c9893774430cd8e767258 | bc7c507c206c72487d176552e36cf64d0dd39185 | refs/heads/master | 2021-01-21T06:59:52.947205 | 2017-02-27T11:28:22 | 2017-02-27T11:28:22 | 83,302,856 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,917 | java | package com.tescobank.judge.view;
import com.tescobank.judge.question.QuestionUtil;
import com.tescobank.judge.state.Actor;
import com.tescobank.judge.tbcukesupport.JudgeTescoBankInteractionBase;
import org.openqa.selenium.WebDriver;
import static com.tescobank.judge.state.StateKey.*;
import static com.tescobank.judge.state.StateKey.ANNUAL_INTEREST;
import static com.tescobank.judge.targets.PreContractLoanTarget.*;
import static org.junit.Assert.assertTrue;
/**
* Created by pabloarroyo on 13/07/16.
*/
public class PreContractLoanView extends JudgeTescoBankInteractionBase {
public PreContractLoanView(WebDriver driver) {
super(driver);
}
@Override
public boolean isRendered() {
return isElementDisplayed(VIEW_IDENTIFIER);
}
public void assertInView() {
assertTrue(isRendered());
}
public void assertLoanAmountParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("This means the amount of credit to be provided under the proposedcredit agreement or the credit limit " + QuestionUtil.formatCurrency((String) Actor.get(LOAN_AMOUNT))));
}
public void assertDurationParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("The duration of the credit agreement. " + Actor.get(LOAN_TERM) + " months"));
}
public void assertRepaymentsParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("Repayments " + Actor.get(LOAN_TERM)));
}
public void assertTotalAmountParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("This means the amount you have borrowed plus interest and other costs. " + QuestionUtil.formatCurrency((String) Actor.get(TOTAL_AMOUNT))));
}
public void assertMonthlyRepaymentParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("monthly repayments of " + QuestionUtil.formatCurrency((String) Actor.get(MONTHLY_REPAYMENT))));
}
public void assertAPRParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("The APR is there to help you compare different offers. " + Actor.get(LOAN_APR)));
}
public void assertAnnualInterestParameter() {
assertTrue(getTextForElement(DOCUMENT_WORDING).contains("Fixed rate of " + Actor.get(ANNUAL_INTEREST) + "% per annum (Nominal)"));
}
public void assertExplanationPresent() {
assertTrue(getPageSourceContent().contains("(Standard European Consumer Credit Information)"));
}
public void assertPdfLinkPresent() {
// assertTrue(getPageSourceContent().contains("Download a copy"));
assertTrue(isElementDisplayed(PDF_LINK));
}
public void assertPdfMatchesName(String pdfName) {
waitForDocumentReady();
String xPath = "//a[@class='download-doc ' and contains(.,'" + pdfName + "')]";
assertTrue(isElementPresentByXpath(xPath));
}
} | [
"[email protected]"
] | |
c224e33d678a8f9880da47b8b30715b312f2202f | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/4/4_2659570497f45c25a357d474c45673bbff1a66a4/Fe/4_2659570497f45c25a357d474c45673bbff1a66a4_Fe_t.java | 73f5fed611089fe9dbf6ac9549768bbc66e989a0 | [] | 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 | 7,579 | java | package org.melonbrew.fe;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.melonbrew.fe.Metrics.Graph;
import org.melonbrew.fe.database.Account;
import org.melonbrew.fe.database.Database;
import org.melonbrew.fe.database.databases.FlatFile;
import org.melonbrew.fe.database.databases.MySQLDB;
import org.melonbrew.fe.database.databases.SQLiteDB;
import org.melonbrew.fe.listeners.FePlayerListener;
public class Fe extends JavaPlugin {
private Logger log;
private API api;
private Database database;
private Set<Database> databases;
private String latestVersion;
public void onEnable(){
log = getServer().getLogger();
getDataFolder().mkdirs();
new FePlayerListener(this);
databases = new HashSet<Database>();
databases.add(new MySQLDB(this));
databases.add(new SQLiteDB(this));
getConfig().options().copyDefaults(true);
for (Database database : databases){
String name = database.getConfigName();
ConfigurationSection section = getConfig().getConfigurationSection(name);
if (section == null){
section = getConfig().createSection(name);
}
database.getConfigDefaults(section);
if (section.getKeys(false).isEmpty()){
getConfig().set(name, null);
}
}
getConfig().options().header("Fe Config - melonbrew.org\n" +
"holdings - The amount of money that the player will start out with\n" +
"prefix - The message prefix\n" +
"currency - The single and multiple names for the currency\n" +
"type - The type of database used (sqlite or mysql)\n");
saveConfig();
api = new API(this);
if (!setupDatabase()){
return;
}
setupVault();
setLatestVersion(getDescription().getVersion());
getCommand("fe").setExecutor(new FeCommand(this));
getServer().getScheduler().scheduleAsyncDelayedTask(this, new UpdateCheck(this));
loadMetrics();
}
private void loadMetrics(){
try {
Metrics metrics = new Metrics(this);
Graph graph = metrics.createGraph("Database Engine");
graph.addPlotter(new Metrics.Plotter(database.getName()){
public int getValue(){
return 1;
}
});
metrics.start();
} catch (IOException e){
}
}
protected void setLatestVersion(String latestVersion){
this.latestVersion = latestVersion;
}
public String getLatestVersion(){
return latestVersion;
}
public boolean isUpdated(){
String version = getDescription().getVersion();
return latestVersion.equalsIgnoreCase(version) || version.endsWith("-SNAPSHOT");
}
private void setupVault(){
Plugin vault = getServer().getPluginManager().getPlugin("Vault");
if (vault == null){
return;
}
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null){
getServer().getServicesManager().unregister(economyProvider.getProvider());
}
getServer().getServicesManager().register(Economy.class, new Economy_Fe(this), this, ServicePriority.Highest);
}
public void onDisable(){
getServer().getServicesManager().unregisterAll(this);
getFeDatabase().close();
}
public void log(String message){
log.info("[Fe] " + message);
}
public void log(Phrase phrase, String... args){
log(phrase.parse(args));
}
public Database getFeDatabase(){
return database;
}
public API getAPI(){
return api;
}
private boolean setupDatabase(){
return setupDatabase(null);
}
private boolean setupDatabase(List<Account> accounts){
String type = getConfig().getString("type");
database = null;
if (type.equalsIgnoreCase("flatfile")){
database = new FlatFile(this);
boolean convert = false;
if (database.init()){
log("Converting flat file into SQLite...");
convert = true;
}
getConfig().set("type", "sqlite");
saveConfig();
if (convert){
return setupDatabase(database.getTopAccounts());
}
}
for (Database database : databases){
System.out.println(type + "," + database.getConfigName());
if (type.equalsIgnoreCase(database.getConfigName())){
try {
this.database = database;
break;
} catch (Exception e){
}
}
}
if (database == null){
log(Phrase.DATABASE_TYPE_DOES_NOT_EXIST);
return false;
}
if (!database.init()){
log(Phrase.DATABASE_FAILURE_DISABLE);
getServer().getPluginManager().disablePlugin(this);
return false;
}
if (accounts != null){
for (Account account : accounts){
database.createAccount(account.getName()).setMoney(account.getMoney());
}
log("Finished conversion.");
}
return true;
}
private void setupPhrases(){
File phrasesFile = new File(getDataFolder(), "phrases.yml");
for (Phrase phrase : Phrase.values()){
phrase.reset();
}
if (!phrasesFile.exists()){
return;
}
YamlConfiguration phrasesConfig = YamlConfiguration.loadConfiguration(phrasesFile);
Set<String> keys = phrasesConfig.getKeys(false);
for (Phrase phrase : Phrase.values()){
String phraseConfigName = phrase.getConfigName();
if (keys.contains(phraseConfigName)){
phrase.setMessage(phrasesConfig.getString(phraseConfigName));
}
}
}
public void reloadConfig(){
super.reloadConfig();
setupPhrases();
}
public ConfigurationSection getMySQLConfig(){
return getConfig().getConfigurationSection("mysql");
}
public String getReadName(Account account){
return getReadName(account.getName());
}
public String getReadName(String name){
name = name.toLowerCase();
OfflinePlayer player = getServer().getOfflinePlayer(name);
if (player != null){
name = player.getName();
}
return name;
}
public String getMessagePrefix(){
return ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + getConfig().getString("prefix") + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY;
}
public String getCurrencySingle(){
return getConfig().getString("currency.single");
}
public String getCurrencyMultiple(){
return getConfig().getString("currency.multiple");
}
public String getEqualMessage(String inBetween, int length){
return getEqualMessage(inBetween, length, length);
}
public String getEqualMessage(String inBetween, int length, int length2){
String equals = getEndEqualMessage(length);
String end = getEndEqualMessage(length2);
return equals + ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + inBetween + ChatColor.DARK_GRAY + "]" + end;
}
public String getEndEqualMessage(int length){
String message = ChatColor.GRAY + "";
for (int i = 0; i < length; i++){
message += "=";
}
return message;
}
}
| [
"[email protected]"
] | |
91682eaf9a6a33755b1cf6faee74c392bf3ff6dd | de3c2d89f623527b35cc5dd936773f32946025d2 | /src/main/java/com/airbnb/lottie/LottieAnimationView.java | 89a755b7f77cb71427fce42966e8296112e7294b | [] | no_license | ren19890419/lvxing | 5f89f7b118df59fd1da06aaba43bd9b41b5da1e6 | 239875461cb39e58183ac54e93565ec5f7f28ddb | refs/heads/master | 2023-04-15T08:56:25.048806 | 2020-06-05T10:46:05 | 2020-06-05T10:46:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,017 | java | package com.airbnb.lottie;
import android.animation.Animator.AnimatorListener;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.JsonReader;
import android.util.Log;
import android.view.View.BaseSavedState;
import androidx.appcompat.widget.AppCompatImageView;
import com.airbnb.lottie.model.KeyPath;
import com.airbnb.lottie.model.LottieCompositionCache;
import com.airbnb.lottie.p014e.LottieValueCallback;
import java.io.StringReader;
import org.json.JSONObject;
public class LottieAnimationView extends AppCompatImageView {
/* renamed from: a */
public static final CacheStrategy f1213a = CacheStrategy.Weak;
/* renamed from: b */
private static final String f1214b = LottieAnimationView.class.getSimpleName();
/* renamed from: c */
private final LottieListener<LottieComposition> f1215c = new LottieListener<LottieComposition>() {
/* renamed from: a */
public void mo9777a(LottieComposition dVar) {
LottieAnimationView.this.setComposition(dVar);
}
};
/* renamed from: d */
private final LottieListener<Throwable> f1216d = new LottieListener<Throwable>() {
/* renamed from: a */
public void mo9777a(Throwable th) {
throw new IllegalStateException("Unable to parse composition", th);
}
};
/* renamed from: e */
private final LottieDrawable f1217e = new LottieDrawable();
/* renamed from: f */
private CacheStrategy f1218f;
/* renamed from: g */
private String f1219g;
/* renamed from: h */
private int f1220h;
/* renamed from: i */
private boolean f1221i = false;
/* renamed from: j */
private boolean f1222j = false;
/* renamed from: k */
private boolean f1223k = false;
/* renamed from: l */
private LottieTask f1224l;
/* renamed from: m */
private LottieComposition f1225m;
@Deprecated
/* renamed from: com.airbnb.lottie.LottieAnimationView$CacheStrategy */
public enum CacheStrategy {
None,
Weak,
Strong
}
/* renamed from: com.airbnb.lottie.LottieAnimationView$SavedState */
private static class SavedState extends BaseSavedState {
public static final Creator<SavedState> CREATOR = new Creator<SavedState>() {
/* renamed from: a */
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel);
}
/* renamed from: a */
public SavedState[] newArray(int i) {
return new SavedState[i];
}
};
/* renamed from: a */
String f1232a;
/* renamed from: b */
int f1233b;
/* renamed from: c */
float f1234c;
/* renamed from: d */
boolean f1235d;
/* renamed from: e */
String f1236e;
/* renamed from: f */
int f1237f;
/* renamed from: g */
int f1238g;
SavedState(Parcelable parcelable) {
super(parcelable);
}
private SavedState(Parcel parcel) {
super(parcel);
this.f1232a = parcel.readString();
this.f1234c = parcel.readFloat();
boolean z = true;
if (parcel.readInt() != 1) {
z = false;
}
this.f1235d = z;
this.f1236e = parcel.readString();
this.f1237f = parcel.readInt();
this.f1238g = parcel.readInt();
}
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeString(this.f1232a);
parcel.writeFloat(this.f1234c);
parcel.writeInt(this.f1235d);
parcel.writeString(this.f1236e);
parcel.writeInt(this.f1237f);
parcel.writeInt(this.f1238g);
}
}
public LottieAnimationView(Context context) {
super(context);
m1060a((AttributeSet) null);
}
public LottieAnimationView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m1060a(attributeSet);
}
public LottieAnimationView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
m1060a(attributeSet);
}
/* renamed from: a */
private void m1060a(AttributeSet attributeSet) {
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.LottieAnimationView);
this.f1218f = CacheStrategy.values()[obtainStyledAttributes.getInt(R.styleable.LottieAnimationView_lottie_cacheStrategy, f1213a.ordinal())];
if (!isInEditMode()) {
boolean hasValue = obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_rawRes);
boolean hasValue2 = obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_fileName);
boolean hasValue3 = obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_url);
if (hasValue && hasValue2) {
throw new IllegalArgumentException("lottie_rawRes and lottie_fileName cannot be used at the same time. Please use use only one at once.");
} else if (hasValue) {
int resourceId = obtainStyledAttributes.getResourceId(R.styleable.LottieAnimationView_lottie_rawRes, 0);
if (resourceId != 0) {
setAnimation(resourceId);
}
} else if (hasValue2) {
String string = obtainStyledAttributes.getString(R.styleable.LottieAnimationView_lottie_fileName);
if (string != null) {
setAnimation(string);
}
} else if (hasValue3) {
String string2 = obtainStyledAttributes.getString(R.styleable.LottieAnimationView_lottie_url);
if (string2 != null) {
setAnimationFromUrl(string2);
}
}
}
if (obtainStyledAttributes.getBoolean(R.styleable.LottieAnimationView_lottie_autoPlay, false)) {
this.f1221i = true;
this.f1222j = true;
}
if (obtainStyledAttributes.getBoolean(R.styleable.LottieAnimationView_lottie_loop, false)) {
this.f1217e.mo9813e(-1);
}
if (obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_repeatMode)) {
setRepeatMode(obtainStyledAttributes.getInt(R.styleable.LottieAnimationView_lottie_repeatMode, 1));
}
if (obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_repeatCount)) {
setRepeatCount(obtainStyledAttributes.getInt(R.styleable.LottieAnimationView_lottie_repeatCount, -1));
}
setImageAssetsFolder(obtainStyledAttributes.getString(R.styleable.LottieAnimationView_lottie_imageAssetsFolder));
setProgress(obtainStyledAttributes.getFloat(R.styleable.LottieAnimationView_lottie_progress, 0.0f));
mo9731a(obtainStyledAttributes.getBoolean(R.styleable.LottieAnimationView_lottie_enableMergePathsForKitKatAndAbove, false));
if (obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_colorFilter)) {
SimpleColorFilter lVar = new SimpleColorFilter(obtainStyledAttributes.getColor(R.styleable.LottieAnimationView_lottie_colorFilter, 0));
mo9729a(new KeyPath("**"), LottieProperty.f1547x, new LottieValueCallback(lVar));
}
if (obtainStyledAttributes.hasValue(R.styleable.LottieAnimationView_lottie_scale)) {
this.f1217e.mo9812e(obtainStyledAttributes.getFloat(R.styleable.LottieAnimationView_lottie_scale, 1.0f));
}
obtainStyledAttributes.recycle();
m1063g();
}
public void setImageResource(int i) {
mo9726a();
m1061e();
super.setImageResource(i);
}
public void setImageDrawable(Drawable drawable) {
m1059a(drawable, true);
}
/* renamed from: a */
private void m1059a(Drawable drawable, boolean z) {
if (z && drawable != this.f1217e) {
mo9726a();
}
m1061e();
super.setImageDrawable(drawable);
}
public void setImageBitmap(Bitmap bitmap) {
mo9726a();
m1061e();
super.setImageBitmap(bitmap);
}
public void invalidateDrawable(Drawable drawable) {
Drawable drawable2 = getDrawable();
LottieDrawable lottieDrawable = this.f1217e;
if (drawable2 == lottieDrawable) {
super.invalidateDrawable(lottieDrawable);
} else {
super.invalidateDrawable(drawable);
}
}
/* access modifiers changed from: protected */
public Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.f1232a = this.f1219g;
savedState.f1233b = this.f1220h;
savedState.f1234c = this.f1217e.mo9840t();
savedState.f1235d = this.f1217e.mo9829n();
savedState.f1236e = this.f1217e.mo9800b();
savedState.f1237f = this.f1217e.mo9827l();
savedState.f1238g = this.f1217e.mo9828m();
return savedState;
}
/* access modifiers changed from: protected */
public void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
this.f1219g = savedState.f1232a;
if (!TextUtils.isEmpty(this.f1219g)) {
setAnimation(this.f1219g);
}
this.f1220h = savedState.f1233b;
int i = this.f1220h;
if (i != 0) {
setAnimation(i);
}
setProgress(savedState.f1234c);
if (savedState.f1235d) {
mo9732b();
}
this.f1217e.mo9795a(savedState.f1236e);
setRepeatMode(savedState.f1237f);
setRepeatCount(savedState.f1238g);
}
/* access modifiers changed from: protected */
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (this.f1222j && this.f1221i) {
mo9732b();
}
}
/* access modifiers changed from: protected */
public void onDetachedFromWindow() {
if (mo9734c()) {
mo9735d();
this.f1221i = true;
}
mo9726a();
super.onDetachedFromWindow();
}
/* access modifiers changed from: 0000 */
/* renamed from: a */
public void mo9726a() {
LottieDrawable lottieDrawable = this.f1217e;
if (lottieDrawable != null) {
lottieDrawable.mo9804c();
}
}
/* renamed from: a */
public void mo9731a(boolean z) {
this.f1217e.mo9796a(z);
}
/* renamed from: b */
public void mo9733b(boolean z) {
if (this.f1223k != z) {
this.f1223k = z;
m1063g();
}
}
public boolean getUseHardwareAcceleration() {
return this.f1223k;
}
public void setAnimation(final int i) {
this.f1220h = i;
this.f1219g = null;
LottieComposition a = LottieCompositionCache.m1654a().mo10128a(i);
if (a != null) {
setComposition(a);
return;
}
m1062f();
m1061e();
this.f1224l = LottieCompositionFactory.m1463a(getContext(), i).mo9999a((LottieListener<T>) new LottieListener<LottieComposition>() {
/* renamed from: a */
public void mo9777a(LottieComposition dVar) {
LottieCompositionCache.m1654a().mo10130a(i, dVar);
}
}).mo9999a(this.f1215c).mo10001c(this.f1216d);
}
public void setAnimation(final String str) {
this.f1219g = str;
this.f1220h = 0;
LottieComposition a = LottieCompositionCache.m1654a().mo10129a(str);
if (a != null) {
setComposition(a);
return;
}
m1062f();
m1061e();
this.f1224l = LottieCompositionFactory.m1472b(getContext(), str).mo9999a((LottieListener<T>) new LottieListener<LottieComposition>() {
/* renamed from: a */
public void mo9777a(LottieComposition dVar) {
LottieCompositionCache.m1654a().mo10131a(str, dVar);
}
}).mo9999a(this.f1215c).mo10001c(this.f1216d);
}
@Deprecated
public void setAnimation(JSONObject jSONObject) {
setAnimation(new JsonReader(new StringReader(jSONObject.toString())));
}
@Deprecated
public void setAnimationFromJson(String str) {
mo9730a(str, (String) null);
}
/* renamed from: a */
public void mo9730a(String str, String str2) {
mo9728a(new JsonReader(new StringReader(str)), str2);
}
@Deprecated
public void setAnimation(JsonReader jsonReader) {
mo9728a(jsonReader, (String) null);
}
/* renamed from: a */
public void mo9728a(JsonReader jsonReader, String str) {
m1062f();
m1061e();
this.f1224l = LottieCompositionFactory.m1465a(jsonReader, str).mo9999a(this.f1215c).mo10001c(this.f1216d);
}
public void setAnimationFromUrl(String str) {
m1062f();
m1061e();
this.f1224l = LottieCompositionFactory.m1464a(getContext(), str).mo9999a(this.f1215c).mo10001c(this.f1216d);
}
/* renamed from: e */
private void m1061e() {
LottieTask jVar = this.f1224l;
if (jVar != null) {
jVar.mo10000b(this.f1215c);
this.f1224l.mo10002d(this.f1216d);
}
}
public void setComposition(LottieComposition dVar) {
if (L.f1437a) {
String str = f1214b;
StringBuilder sb = new StringBuilder();
sb.append("Set Composition \n");
sb.append(dVar);
Log.v(str, sb.toString());
}
this.f1217e.setCallback(this);
this.f1225m = dVar;
boolean a = this.f1217e.mo9798a(dVar);
m1063g();
if (getDrawable() != this.f1217e || a) {
setImageDrawable(null);
setImageDrawable(this.f1217e);
requestLayout();
}
}
public LottieComposition getComposition() {
return this.f1225m;
}
/* renamed from: b */
public void mo9732b() {
this.f1217e.mo9814f();
m1063g();
}
public void setMinFrame(int i) {
this.f1217e.mo9789a(i);
}
public float getMinFrame() {
return this.f1217e.mo9820h();
}
public void setMinProgress(float f) {
this.f1217e.mo9788a(f);
}
public void setMaxFrame(int i) {
this.f1217e.mo9802b(i);
}
public float getMaxFrame() {
return this.f1217e.mo9821i();
}
public void setMaxProgress(float f) {
this.f1217e.mo9801b(f);
}
public void setSpeed(float f) {
this.f1217e.mo9805c(f);
}
public float getSpeed() {
return this.f1217e.mo9825j();
}
/* renamed from: a */
public void mo9727a(AnimatorListener animatorListener) {
this.f1217e.mo9790a(animatorListener);
}
public void setRepeatMode(int i) {
this.f1217e.mo9809d(i);
}
public int getRepeatMode() {
return this.f1217e.mo9827l();
}
public void setRepeatCount(int i) {
this.f1217e.mo9813e(i);
}
public int getRepeatCount() {
return this.f1217e.mo9828m();
}
/* renamed from: c */
public boolean mo9734c() {
return this.f1217e.mo9829n();
}
public void setImageAssetsFolder(String str) {
this.f1217e.mo9795a(str);
}
public String getImageAssetsFolder() {
return this.f1217e.mo9800b();
}
public void setImageAssetDelegate(ImageAssetDelegate bVar) {
this.f1217e.mo9792a(bVar);
}
public void setFontAssetDelegate(FontAssetDelegate aVar) {
this.f1217e.mo9791a(aVar);
}
public void setTextDelegate(TextDelegate mVar) {
this.f1217e.mo9793a(mVar);
}
/* renamed from: a */
public <T> void mo9729a(KeyPath eVar, T t, LottieValueCallback<T> cVar) {
this.f1217e.mo9794a(eVar, t, cVar);
}
public void setScale(float f) {
this.f1217e.mo9812e(f);
if (getDrawable() == this.f1217e) {
m1059a((Drawable) null, false);
m1059a((Drawable) this.f1217e, false);
}
}
public float getScale() {
return this.f1217e.mo9832q();
}
/* renamed from: d */
public void mo9735d() {
this.f1217e.mo9834s();
m1063g();
}
public void setFrame(int i) {
this.f1217e.mo9806c(i);
}
public int getFrame() {
return this.f1217e.mo9826k();
}
public void setProgress(float f) {
this.f1217e.mo9808d(f);
}
public float getProgress() {
return this.f1217e.mo9840t();
}
public long getDuration() {
LottieComposition dVar = this.f1225m;
if (dVar != null) {
return (long) dVar.mo9920c();
}
return 0;
}
public void setPerformanceTrackingEnabled(boolean z) {
this.f1217e.mo9803b(z);
}
public PerformanceTracker getPerformanceTracker() {
return this.f1217e.mo9807d();
}
/* renamed from: f */
private void m1062f() {
this.f1225m = null;
this.f1217e.mo9811e();
}
/* renamed from: g */
private void m1063g() {
int i = 1;
boolean z = this.f1223k && this.f1217e.mo9829n();
if (z) {
i = 2;
}
setLayerType(i, null);
}
}
| [
"[email protected]"
] | |
a8dc56af1129d418a726cbc3c397cdbe32abb6a3 | 07c25bf46a9967c88c3089685d6acd32c8fc49c7 | /trunk/Sources/Java/InterfaceGraphique/src/ca/polymtl/inf2990/SelectionneurFichier/SelectionneurFichier.java | ab56235bc28e944169be47eddf169069582b794d | [] | no_license | mathieumg/hockedu | 6d91a032034f143d5430fbcba894312e948433d9 | 34a0bad42dac55b71cf7d02c3cb5807ad6351014 | refs/heads/master | 2021-07-09T07:06:03.973469 | 2016-12-07T07:58:44 | 2016-12-07T07:58:44 | 9,439,670 | 1 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 1,427 | java | package ca.polymtl.inf2990.SelectionneurFichier;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import ca.polymtl.inf2990.Fenetre;
/**
* Classe pour encapsuler le JFileChooser.
*
* @author Charles Etienne Lalonde
*/
public class SelectionneurFichier extends JFileChooser
{
private static final long serialVersionUID = 1L;
/**
* Constructeur pour le selectionneur de fichier.
*/
public SelectionneurFichier()
{
super("./");
setAcceptAllFileFilterUsed(false);
addChoosableFileFilter(new FiltreFichiersXML());
}
@Override
public void approveSelection()
{
if (getDialogType() == SAVE_DIALOG)
{
final File fichierSelectionne = getSelectedFile();
if (fichierSelectionne != null && fichierSelectionne.exists())
{
final int valeurRetour = JOptionPane.showOptionDialog(Fenetre.obtenirInstance(), "Ce fichier existe déjà. Voulez-vous vraiment l'écraser?", "Écraser?", JOptionPane.INFORMATION_MESSAGE, JOptionPane.YES_NO_OPTION, null, new String[] { "Oui", "Non" }, "Non");
if (valeurRetour == 1)
{
return;
}
}
final String extensionFichierSelectionne = FiltreFichiersXML.obtenirExtension(fichierSelectionne);
if (extensionFichierSelectionne == null || !extensionFichierSelectionne.equals("xml"))
{
setSelectedFile(new File(fichierSelectionne.getAbsolutePath() + ".xml"));
}
}
super.approveSelection();
}
}
| [
"[email protected]"
] | |
b1b25f4bde6f8b7f39786ae63f6308c2c624623b | b755a269f733bc56f511bac6feb20992a1626d70 | /qiyun-lottery/lottery-model/src/main/java/com/qiyun/model2/LotteryTerm2.java | 160c6bf253d41b2cfaa6157ef403282b3c262bef | [] | no_license | yysStar/dubbo-zookeeper-SSM | 55df313b58c78ab2eaa3d021e5bb201f3eee6235 | e3f85dea824159fb4c29207cc5c9ccaecf381516 | refs/heads/master | 2022-12-21T22:50:33.405116 | 2020-05-09T09:20:41 | 2020-05-09T09:20:41 | 125,301,362 | 2 | 0 | null | 2022-12-16T10:51:09 | 2018-03-15T02:27:17 | Java | UTF-8 | Java | false | false | 5,439 | java | package com.qiyun.model2;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class LotteryTerm2 implements Serializable {
private Integer id;
private Integer lotteryType;
private String term;
private String outTerm;
private Date openDateTime;
private Date startDateTime;
private Date endDateTime;
private Date terminalEndDateTime;
private Integer isAble;
private Integer lotMgrIsAble;
private Integer isCurrentTerm;
private Integer isBooking;
private Integer status;
private String result;
private String totalAmount;
private String awardPool;
private String testMachineCode;
private String resultDetail;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getLotteryType() {
return lotteryType;
}
public void setLotteryType(Integer lotteryType) {
this.lotteryType = lotteryType;
}
public String getTerm() {
return term;
}
public void setTerm(String term) {
this.term = term == null ? null : term.trim();
}
public String getOutTerm() {
return outTerm;
}
public void setOutTerm(String outTerm) {
this.outTerm = outTerm == null ? null : outTerm.trim();
}
public Date getOpenDateTime() {
return openDateTime;
}
public void setOpenDateTime(Date openDateTime) {
this.openDateTime = openDateTime;
}
public Date getStartDateTime() {
return startDateTime;
}
public void setStartDateTime(Date startDateTime) {
this.startDateTime = startDateTime;
}
public Date getEndDateTime() {
return endDateTime;
}
public void setEndDateTime(Date endDateTime) {
this.endDateTime = endDateTime;
}
public Date getTerminalEndDateTime() {
return terminalEndDateTime;
}
public void setTerminalEndDateTime(Date terminalEndDateTime) {
this.terminalEndDateTime = terminalEndDateTime;
}
public Integer getIsAble() {
return isAble;
}
public void setIsAble(Integer isAble) {
this.isAble = isAble;
}
public Integer getLotMgrIsAble() {
return lotMgrIsAble;
}
public void setLotMgrIsAble(Integer lotMgrIsAble) {
this.lotMgrIsAble = lotMgrIsAble;
}
public Integer getIsCurrentTerm() {
return isCurrentTerm;
}
public void setIsCurrentTerm(Integer isCurrentTerm) {
this.isCurrentTerm = isCurrentTerm;
}
public Integer getIsBooking() {
return isBooking;
}
public void setIsBooking(Integer isBooking) {
this.isBooking = isBooking;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result == null ? null : result.trim();
}
public String getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(String totalAmount) {
this.totalAmount = totalAmount == null ? null : totalAmount.trim();
}
public String getAwardPool() {
return awardPool;
}
public void setAwardPool(String awardPool) {
this.awardPool = awardPool == null ? null : awardPool.trim();
}
public String getTestMachineCode() {
return testMachineCode;
}
public void setTestMachineCode(String testMachineCode) {
this.testMachineCode = testMachineCode == null ? null : testMachineCode.trim();
}
public String getResultDetail() {
return resultDetail;
}
public void setResultDetail(String resultDetail) {
this.resultDetail = resultDetail == null ? null : resultDetail.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", lotteryType=").append(lotteryType);
sb.append(", term=").append(term);
sb.append(", outTerm=").append(outTerm);
sb.append(", openDateTime=").append(openDateTime);
sb.append(", startDateTime=").append(startDateTime);
sb.append(", endDateTime=").append(endDateTime);
sb.append(", terminalEndDateTime=").append(terminalEndDateTime);
sb.append(", isAble=").append(isAble);
sb.append(", lotMgrIsAble=").append(lotMgrIsAble);
sb.append(", isCurrentTerm=").append(isCurrentTerm);
sb.append(", isBooking=").append(isBooking);
sb.append(", status=").append(status);
sb.append(", result=").append(result);
sb.append(", totalAmount=").append(totalAmount);
sb.append(", awardPool=").append(awardPool);
sb.append(", testMachineCode=").append(testMachineCode);
sb.append(", resultDetail=").append(resultDetail);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
} | [
"[email protected]"
] | |
a4f66abfcd44d2e2f95d023110cfc368a9361509 | e0d5c57a4f5e8a8bd9ef6a0e1fabc863562f5dc5 | /app/src/androidTest/java/com/example/oracle/powerreceiver/ExampleInstrumentedTest.java | 283ac4f2eaa6cd3c940425bdd77151adfa46631a | [] | no_license | RickyRenardi/PowerReceiver | 13f65e93cc794f2b0a385b418ad09dca288b473d | 12c682caaf013ae4489136c94a7a784f824fef17 | refs/heads/master | 2020-05-04T21:12:05.084381 | 2019-04-04T09:38:57 | 2019-04-04T09:38:57 | 179,467,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 748 | java | package com.example.oracle.powerreceiver;
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.oracle.powerreceiver", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
cbbbfa50706293ffbb53f3074fe34b22ceeefa99 | d6e14aba59ee895286e50a6684f8d9ef170b8f29 | /zplugins/src/main/java/com/zchaos/zplugins/update/UpdateStatus.java | 7df9e543006276545b3dbc02ed918d1143e120d1 | [] | no_license | zchaos/zrepo | cce2d425e69c180cebee96b7b285ccab75721a85 | 458c70554431693ea05965b2958ac24ec200539a | refs/heads/master | 2021-01-10T19:24:53.470974 | 2014-08-13T03:42:09 | 2014-08-13T03:42:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 480 | java | package com.zchaos.zplugins.update;
/**
* 更新配置的状态
* <p>Copyright: Copyright (c) 2012<p>
* <p>succez<p>
* @author menghsh
* @createdate 2012-3-28
*/
public enum UpdateStatus {
/**
* 正常
*/
NORMAL,
/**
* 接收到请求
*/
REQUESTED,
/**
* 正在检查更新
*/
CHECKUPDATE,
/**
* 检查更新完毕
*/
CHECKEDUPDATE,
/**
* 正在更新
*/
UPDATE,
/**
* 更新完毕
*/
UPDATED,
/**
* 出现异常
*/
ERROR
}
| [
"[email protected]"
] | |
0fd84d1b8d078a9fb68dfe2a4246e186131f0238 | 8f24e30f8d18d6e59d426d7ecd9b9297bafb2642 | /app/src/main/java/com/example/tiku2/MyTouchListener.java | fd1f2107455c7c42c5c9c114e4350a6bb56a7818 | [] | no_license | shazongqain/tk2 | c31079a857c489ef591948db1bd6483e9339ef94 | f372faafe61611af6bd2c16c14c079a5a1476e56 | refs/heads/master | 2020-09-21T01:00:23.843633 | 2019-12-02T09:39:38 | 2019-12-02T09:39:38 | 224,634,704 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,664 | java | package com.example.tiku2;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
public class MyTouchListener implements View.OnTouchListener {
private PointF startPoint= new PointF();
private Matrix matrix=new Matrix();
private Matrix currentMatrix=new Matrix();
private int mode=0;
private static final int DRAG=1;
private static final int ZOOM=2;
private float startDis;
private PointF midPoint;
private ImageView imageView;
private GestureDetector detector;
public MyTouchListener(ImageView image) {
this.imageView = image;
detector=new GestureDetector(new GestureDetector.SimpleOnGestureListener());
detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return false;
}
@Override
public boolean onDoubleTap(MotionEvent e) {
if (imageView.getScaleX()!=1){
imageView.setScaleX(1);
imageView.setScaleY(1);
}else {
imageView.setScaleX(3);
imageView.setScaleY(3);
}
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
return false;
}
});
}
public boolean onTouch(View v, MotionEvent event) {
imageView.setScaleType(ImageView.ScaleType.MATRIX);
detector.onTouchEvent(event);
switch (event.getAction()&MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
mode=DRAG;
matrix.set(imageView.getImageMatrix());
currentMatrix.set(imageView.getImageMatrix());
startPoint.set(event.getX(), event.getY());
break;
case MotionEvent.ACTION_MOVE:
if(mode==DRAG){
float dx=event.getX()-startPoint.x;
float dy=event.getY()-startPoint.y;
matrix.set(currentMatrix);
matrix.postTranslate(dx, dy);
}else if(mode==ZOOM){
float endDis=distance(event);
if(endDis>10f){
float scale=endDis/startDis;
matrix.set(currentMatrix);
matrix.postScale(scale,scale,midPoint.x,midPoint.y);
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode=0;
break;
case MotionEvent.ACTION_POINTER_DOWN:
mode=ZOOM;
startDis=distance(event);
if(startDis>10f){
midPoint=mid(event);
currentMatrix.set(imageView.getImageMatrix());
}
break;
default:
break;
}
imageView.setImageMatrix(matrix);
return true;
}
public float distance(MotionEvent event) {
float dx=event.getX(1)-event.getX(0);
float dy=event.getY(1)-event.getY(0);
return (float) Math.sqrt(dx*dx+dy*dy);
}
public static PointF mid(MotionEvent event){
float midx=(event.getX(1)+event.getX(0))/2;
float midy=(event.getY(1)+event.getY(0))/2;
return new PointF(midx,midy);
}
}
| [
"[email protected]"
] | |
cda3b7e7a0a6ee6a1fa5ee24741f4c64f0f3bf4b | bb2e4aba2f6d69fdb973e2f85c5e394b91631113 | /src/test/java/gov/usgs/cida/qw/codes/webservices/ProviderRestControllerIT.java | 21fb52316b7d0bcbc760473c66d385488da9af02 | [] | no_license | ssoper-usgs/qw_portal_services | a5bb01825c8ebd3234b2913c66d9f972c1f6aa23 | ace59c83337496f21aa80911722de39d0ff65527 | refs/heads/master | 2021-06-20T01:25:47.988236 | 2019-06-27T19:11:33 | 2019-06-27T19:11:33 | 162,303,231 | 0 | 0 | null | 2018-12-18T14:49:09 | 2018-12-18T14:49:08 | null | UTF-8 | Java | false | false | 2,078 | java | package gov.usgs.cida.qw.codes.webservices;
import org.junit.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import gov.usgs.cida.qw.CustomStringToArrayConverter;
import gov.usgs.cida.qw.LastUpdateDao;
import gov.usgs.cida.qw.codes.dao.CodeDao;
import gov.usgs.cida.qw.springinit.DBTestConfig;
import gov.usgs.cida.qw.springinit.SpringConfig;
@EnableWebMvc
@AutoConfigureMockMvc(secure=false)
@SpringBootTest(webEnvironment=WebEnvironment.MOCK,
classes={DBTestConfig.class, SpringConfig.class, CustomStringToArrayConverter.class,
ProviderRestController.class, LastUpdateDao.class, CodeDao.class})
public class ProviderRestControllerIT extends BaseCodesRestControllerTest {
public static String TEST_ENDPOINT = "/codes/providers";
public static String CODE_VALUE = "STEWARDS";
public static String CODE_JSON = "{\"value\":\"STEWARDS\"}";
public static String CODE_XML = XML_HEADER +"<Code value=\"STEWARDS\"/>";
public static String SEARCH_TEXT = "st";
public static String SEARCH_JSON = "{\"codes\":[{\"value\":\"STORET\"}],\"recordCount\":2}";
public static String SEARCH_XML = XML_HEADER + "<Codes><Code value=\"STORET\"/><recordCount>2</recordCount></Codes>";
public static String COMPARE_FILE_JSON = "provider.json";
public static String COMPARE_FILE_XML = "provider.xml";
@Test
public void getListAsJsonTest() throws Exception {
runGetListAsJsonTest(TEST_ENDPOINT, SEARCH_TEXT, COMPARE_FILE_JSON, SEARCH_JSON);
}
@Test
public void getListAsXmlTest() throws Exception {
runGetListAsXmlTest(TEST_ENDPOINT, SEARCH_TEXT, COMPARE_FILE_XML, SEARCH_XML);
}
@Test
public void getCodeAsJsonTest() throws Exception {
runGetCodeAsJson(TEST_ENDPOINT, CODE_VALUE, CODE_JSON);
}
@Test
public void getCodeAsXmlTest() throws Exception {
runGetCodeAsXml(TEST_ENDPOINT, CODE_VALUE, CODE_XML);
}
}
| [
"[email protected]"
] | |
66f75809ecf906a96e000144edf1b8e0784a1b14 | 4dc0f0e0d0cc6ac5f2da9f5534d6bcd109d89bef | /springboot-redis-message/src/main/java/org/jeedevframework/springboot/message/BlockingQueueQueueService.java | b122b45de5c9d5e851c6aed3074d73d1370327f5 | [] | no_license | huligong1234/springboot-learning | 70a0f37de7aaef246671d9578323161fba23a7d7 | 2e832330a816afdb8b37d9def4997f6341f81955 | refs/heads/master | 2022-06-28T20:43:12.467279 | 2019-10-03T03:52:01 | 2019-10-03T03:52:01 | 137,196,057 | 4 | 1 | null | 2022-06-17T03:29:04 | 2018-06-13T09:49:39 | Java | UTF-8 | Java | false | false | 2,223 | java | package org.jeedevframework.springboot.message;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
/**
* 基于jdk BlockingQueue 实现队列示例
*
* */
@Component
public class BlockingQueueQueueService {
Logger logger = LoggerFactory.getLogger(BlockingQueueQueueService.class);
private final static Map<String,LinkedBlockingQueue<String>> BBLOCKING_QUEUE = new ConcurrentHashMap<>();
public synchronized void put(String queueName, String value){
if(StringUtils.isBlank(queueName) || StringUtils.isBlank(value)) {
return;
}
if(!BBLOCKING_QUEUE.containsKey(queueName)) {
BBLOCKING_QUEUE.put(queueName, new LinkedBlockingQueue<>());
}
try {
BBLOCKING_QUEUE.get(queueName).put(value);
} catch (InterruptedException e) {
logger.error("BlockingQueueQueueService.put,",e.getMessage());
}
}
public synchronized String get(String queueName){
if(StringUtils.isBlank(queueName)) {
return null;
}
if(BBLOCKING_QUEUE.containsKey(queueName)) {
return BBLOCKING_QUEUE.get(queueName).poll();
}
return null;
}
public static void main(String[] args) {
BlockingQueueQueueService blockingQueueQueueService = new BlockingQueueQueueService();
blockingQueueQueueService.put("d1","1111");
blockingQueueQueueService.put("d1","2222");
blockingQueueQueueService.put("d1","3333");
blockingQueueQueueService.put("d1","4444");
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
System.out.println(blockingQueueQueueService.get("d1"));
}
}
| [
"[email protected]"
] | |
7218e95e134afe7efd20df3832a1c5f0d27734e5 | ce44d0e3cde20c7d4a3b849a87120808a6d462e9 | /app/src/main/java/com/example/teerayutk/tsr_demo/utils/ExtactCartItem.java | a5f591bb1ba8cb9077b5590f2287cab53c6e88c6 | [] | no_license | tsrmobile/TSR_Demo | 183cc5eb655aca23b237dde098be9091071ffee7 | e4cadc4d8a4995bf6884ec1095a930bd93b010a2 | refs/heads/master | 2021-04-12T07:43:38.455340 | 2017-06-28T08:59:00 | 2017-06-28T08:59:00 | 94,508,678 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 906 | java | package com.example.teerayutk.tsr_demo.utils;
import com.android.tonyvu.sc.model.Cart;
import com.android.tonyvu.sc.model.Saleable;
import com.example.teerayutk.tsr_demo.model.catalog.Product;
import com.example.teerayutk.tsr_demo.model.cart.CartItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Created by teera-s on 11/4/2016 AD.
*/
public class ExtactCartItem {
public List<CartItem> getCartItems(Cart cart) {
List<CartItem> cartItems = new ArrayList<CartItem>();
Map<Saleable, Integer> itemMap = cart.getItemWithQuantity();
for (Map.Entry<Saleable, Integer> entry : itemMap.entrySet()) {
CartItem cartItem = new CartItem();
cartItem.setProduct((Product) entry.getKey());
cartItem.setQuantity(entry.getValue());
cartItems.add(cartItem);
}
return cartItems;
}
}
| [
"[email protected]"
] | |
5a5ca336adaae26d28ea486aa0271d2bb76f7c43 | 4a131266045b03f3d5bb708573592ce474450d12 | /third_party/bazel/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | 812d1fa89b6259e0c0d036d11d9770b9a70bab70 | [] | no_license | leolorenzoluis/goose | 4b216c69d9d5f27e18ab5e8d2fabf80a32cf7764 | e4d07ae11ab0fdde9f64c3ee51826d15d0fc8058 | refs/heads/master | 2020-06-25T08:35:38.070464 | 2015-08-04T04:00:22 | 2015-08-04T04:00:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,471 | java | // Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionCacheChecker.Token;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionException;
import com.google.devtools.build.lib.actions.AlreadyReportedActionExecutionException;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MissingInputFileException;
import com.google.devtools.build.lib.actions.NotifyOnActionCacheHit;
import com.google.devtools.build.lib.actions.PackageRootResolver;
import com.google.devtools.build.lib.actions.Root;
import com.google.devtools.build.lib.actions.cache.MetadataHandler;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.packages.PackageIdentifier;
import com.google.devtools.build.lib.syntax.Label;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionException;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
import com.google.devtools.build.skyframe.ValueOrException2;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* A builder for {@link ActionExecutionValue}s.
*/
public class ActionExecutionFunction implements SkyFunction {
private static final Predicate<Artifact> IS_SOURCE_ARTIFACT = new Predicate<Artifact>() {
@Override
public boolean apply(Artifact input) {
return input.isSourceArtifact();
}
};
private final SkyframeActionExecutor skyframeActionExecutor;
private final TimestampGranularityMonitor tsgm;
public ActionExecutionFunction(SkyframeActionExecutor skyframeActionExecutor,
TimestampGranularityMonitor tsgm) {
this.skyframeActionExecutor = skyframeActionExecutor;
this.tsgm = tsgm;
}
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws ActionExecutionFunctionException,
InterruptedException {
Action action = (Action) skyKey.argument();
Map<Artifact, FileArtifactValue> inputArtifactData = null;
Map<Artifact, Collection<Artifact>> expandedMiddlemen = null;
boolean alreadyRan = skyframeActionExecutor.probeActionExecution(action);
try {
Pair<Map<Artifact, FileArtifactValue>, Map<Artifact, Collection<Artifact>>> checkedInputs =
checkInputs(env, action, alreadyRan); // Declare deps on known inputs to action.
if (checkedInputs != null) {
inputArtifactData = checkedInputs.first;
expandedMiddlemen = checkedInputs.second;
}
} catch (ActionExecutionException e) {
throw new ActionExecutionFunctionException(e);
}
// TODO(bazel-team): Non-volatile NotifyOnActionCacheHit actions perform worse in Skyframe than
// legacy when they are not at the top of the action graph. In legacy, they are stored
// separately, so notifying non-dirty actions is cheap. In Skyframe, they depend on the
// BUILD_ID, forcing invalidation of upward transitive closure on each build.
if (action.isVolatile() || action instanceof NotifyOnActionCacheHit) {
// Volatile build actions may need to execute even if none of their known inputs have changed.
// Depending on the buildID ensure that these actions have a chance to execute.
PrecomputedValue.BUILD_ID.get(env);
}
if (env.valuesMissing()) {
return null;
}
ActionExecutionValue result;
try {
result = checkCacheAndExecuteIfNeeded(action, inputArtifactData, expandedMiddlemen, env);
} catch (ActionExecutionException e) {
// In this case we do not report the error to the action reporter because we have already
// done it in SkyframeExecutor.reportErrorIfNotAbortingMode() method. That method
// prints the error in the top-level reporter and also dumps the recorded StdErr for the
// action. Label can be null in the case of, e.g., the SystemActionOwner (for build-info.txt).
throw new ActionExecutionFunctionException(new AlreadyReportedActionExecutionException(e));
} finally {
declareAdditionalDependencies(env, action);
}
if (env.valuesMissing()) {
return null;
}
return result;
}
/**
* Skyframe implementation of {@link PackageRootResolver}. Should be used only from SkyFunctions,
* because it uses SkyFunction.Environment for evaluation of ContainingPackageLookupValue.
*/
private static class PackageRootResolverWithEnvironment implements PackageRootResolver {
private final Environment env;
public PackageRootResolverWithEnvironment(Environment env) {
this.env = env;
}
@Override
public Map<PathFragment, Root> findPackageRoots(Iterable<PathFragment> execPaths) {
Map<PathFragment, SkyKey> depKeys = new HashMap<>();
// Create SkyKeys list based on execPaths.
for (PathFragment path : execPaths) {
depKeys.put(path,
ContainingPackageLookupValue.key(PackageIdentifier.createInDefaultRepo(path)));
}
Map<SkyKey, SkyValue> values = env.getValues(depKeys.values());
if (env.valuesMissing()) {
// Some values are not computed yet.
return null;
}
Map<PathFragment, Root> result = new HashMap<>();
for (PathFragment path : execPaths) {
// TODO(bazel-team): Add check for errors here, when loading phase will be removed.
// For now all possible errors that ContainingPackageLookupFunction can generate
// are caught in previous phases.
ContainingPackageLookupValue value =
(ContainingPackageLookupValue) values.get(depKeys.get(path));
if (value.hasContainingPackage()) {
// We have found corresponding root for current execPath.
result.put(path, Root.asSourceRoot(value.getContainingPackageRoot()));
} else {
// We haven't found corresponding root for current execPath.
result.put(path, null);
}
}
return result;
}
}
private ActionExecutionValue checkCacheAndExecuteIfNeeded(
Action action,
Map<Artifact, FileArtifactValue> inputArtifactData,
Map<Artifact, Collection<Artifact>> expandedMiddlemen,
Environment env) throws ActionExecutionException, InterruptedException {
// Don't initialize the cache if the result has already been computed and this is just a
// rerun.
FileAndMetadataCache fileAndMetadataCache = null;
MetadataHandler metadataHandler = null;
Token token = null;
long actionStartTime = System.nanoTime();
// inputArtifactData is null exactly when we know that the execution result was already
// computed on a prior run of this SkyFunction. If it is null we don't need to initialize
// anything -- we will get the result directly from SkyframeActionExecutor's cache.
if (inputArtifactData != null) {
// Check action cache to see if we need to execute anything. Checking the action cache only
// needs to happen on the first run, since a cache hit means we'll return immediately, and
// there'll be no second run.
fileAndMetadataCache = new FileAndMetadataCache(
inputArtifactData,
expandedMiddlemen,
skyframeActionExecutor.getExecRoot(),
action.getOutputs(),
// Only give the metadata cache the ability to look up Skyframe values if the action
// might have undeclared inputs. If those undeclared inputs are generated, they are
// present in Skyframe, so we can save a stat by looking them up directly.
action.discoversInputs() ? env : null,
tsgm);
metadataHandler =
skyframeActionExecutor.constructMetadataHandler(fileAndMetadataCache);
token = skyframeActionExecutor.checkActionCache(action, metadataHandler,
new PackageRootResolverWithEnvironment(env), actionStartTime);
if (token == Token.NEED_TO_RERUN) {
return null;
}
}
if (token == null && inputArtifactData != null) {
// We got a hit from the action cache -- no need to execute.
return new ActionExecutionValue(
fileAndMetadataCache.getOutputData(),
fileAndMetadataCache.getAdditionalOutputData());
}
ActionExecutionContext actionExecutionContext = null;
try {
if (inputArtifactData != null) {
actionExecutionContext = skyframeActionExecutor.constructActionExecutionContext(
fileAndMetadataCache, metadataHandler);
if (action.discoversInputs()) {
skyframeActionExecutor.discoverInputs(action, actionExecutionContext);
}
}
// If this is the second time we are here (because the action discovers inputs, and we had
// to restart the value builder after declaring our dependence on newly discovered inputs),
// the result returned here is the already-computed result from the first run.
// Similarly, if this is a shared action and the other action is the one that executed, we
// must use that other action's value, provided here, since it is populated with metadata
// for the outputs.
// If this action was not shared and this is the first run of the action, this returned
// result was computed during the call.
return skyframeActionExecutor.executeAction(action, fileAndMetadataCache, token,
actionStartTime, actionExecutionContext);
} finally {
try {
if (actionExecutionContext != null) {
actionExecutionContext.getFileOutErr().close();
}
} catch (IOException e) {
// Nothing we can do here.
}
}
}
private static Iterable<SkyKey> toKeys(Iterable<Artifact> inputs,
Iterable<Artifact> mandatoryInputs) {
if (mandatoryInputs == null) {
// This is a non inputs-discovering action, so no need to distinguish mandatory from regular
// inputs.
return Iterables.transform(inputs, new Function<Artifact, SkyKey>() {
@Override
public SkyKey apply(Artifact artifact) {
return ArtifactValue.key(artifact, true);
}
});
} else {
Collection<SkyKey> discoveredArtifacts = new HashSet<>();
Set<Artifact> mandatory = Sets.newHashSet(mandatoryInputs);
for (Artifact artifact : inputs) {
discoveredArtifacts.add(ArtifactValue.key(artifact, mandatory.contains(artifact)));
}
// In case the action violates the invariant that getInputs() is a superset of
// getMandatoryInputs(), explicitly add the mandatory inputs. See bug about an
// "action not in canonical form" error message. Also note that we may add Skyframe edges on
// these potentially stale deps due to the way loading inputs from the action cache functions.
// In practice, this is safe since C++ actions (the only ones which discover inputs) only add
// possibly stale inputs on source artifacts, which we treat as non-mandatory.
for (Artifact artifact : mandatory) {
discoveredArtifacts.add(ArtifactValue.key(artifact, true));
}
return discoveredArtifacts;
}
}
/**
* Declare dependency on all known inputs of action. Throws exception if any are known to be
* missing. Some inputs may not yet be in the graph, in which case the builder should abort.
*/
private Pair<Map<Artifact, FileArtifactValue>, Map<Artifact, Collection<Artifact>>> checkInputs(
Environment env, Action action, boolean alreadyRan) throws ActionExecutionException {
Map<SkyKey, ValueOrException2<MissingInputFileException, ActionExecutionException>> inputDeps =
env.getValuesOrThrow(toKeys(action.getInputs(), action.discoversInputs()
? action.getMandatoryInputs() : null), MissingInputFileException.class,
ActionExecutionException.class);
// If the action was already run, then break out early. This avoids the cost of constructing the
// input map and expanded middlemen if they're not going to be used.
if (alreadyRan) {
return null;
}
int missingCount = 0;
int actionFailures = 0;
boolean catastrophe = false;
// Only populate input data if we have the input values, otherwise they'll just go unused.
// We still want to loop through the inputs to collect missing deps errors. During the
// evaluator "error bubbling", we may get one last chance at reporting errors even though
// some deps are stilling missing.
boolean populateInputData = !env.valuesMissing();
NestedSetBuilder<Label> rootCauses = NestedSetBuilder.stableOrder();
Map<Artifact, FileArtifactValue> inputArtifactData =
new HashMap<>(populateInputData ? inputDeps.size() : 0);
Map<Artifact, Collection<Artifact>> expandedMiddlemen =
new HashMap<>(populateInputData ? 128 : 0);
ActionExecutionException firstActionExecutionException = null;
for (Map.Entry<SkyKey, ValueOrException2<MissingInputFileException,
ActionExecutionException>> depsEntry : inputDeps.entrySet()) {
Artifact input = ArtifactValue.artifact(depsEntry.getKey());
try {
ArtifactValue value = (ArtifactValue) depsEntry.getValue().get();
if (populateInputData && value instanceof AggregatingArtifactValue) {
AggregatingArtifactValue aggregatingValue = (AggregatingArtifactValue) value;
for (Pair<Artifact, FileArtifactValue> entry : aggregatingValue.getInputs()) {
inputArtifactData.put(entry.first, entry.second);
}
// We have to cache the "digest" of the aggregating value itself, because the action cache
// checker may want it.
inputArtifactData.put(input, aggregatingValue.getSelfData());
expandedMiddlemen.put(input,
Collections2.transform(aggregatingValue.getInputs(),
Pair.<Artifact, FileArtifactValue>firstFunction()));
} else if (populateInputData && value instanceof FileArtifactValue) {
// TODO(bazel-team): Make sure middleman "virtual" artifact data is properly processed.
inputArtifactData.put(input, (FileArtifactValue) value);
}
} catch (MissingInputFileException e) {
missingCount++;
if (input.getOwner() != null) {
rootCauses.add(input.getOwner());
}
} catch (ActionExecutionException e) {
actionFailures++;
if (firstActionExecutionException == null) {
firstActionExecutionException = e;
}
catastrophe = catastrophe || e.isCatastrophe();
rootCauses.addTransitive(e.getRootCauses());
}
}
// We need to rethrow first exception because it can contain useful error message
if (firstActionExecutionException != null) {
if (missingCount == 0 && actionFailures == 1) {
// In the case a single action failed, just propagate the exception upward. This avoids
// having to copy the root causes to the upwards transitive closure.
throw firstActionExecutionException;
}
throw new ActionExecutionException(firstActionExecutionException.getMessage(),
firstActionExecutionException.getCause(), action, rootCauses.build(), catastrophe);
}
if (missingCount > 0) {
for (Label missingInput : rootCauses.build()) {
env.getListener().handle(Event.error(action.getOwner().getLocation(), String.format(
"%s: missing input file '%s'", action.getOwner().getLabel(), missingInput)));
}
throw new ActionExecutionException(missingCount + " input file(s) do not exist", action,
rootCauses.build(), /*catastrophe=*/false);
}
return Pair.of(
Collections.unmodifiableMap(inputArtifactData),
Collections.unmodifiableMap(expandedMiddlemen));
}
private static void declareAdditionalDependencies(Environment env, Action action) {
if (action.discoversInputs()) {
// TODO(bazel-team): Should this be all inputs, or just source files?
env.getValues(toKeys(Iterables.filter(action.getInputs(), IS_SOURCE_ARTIFACT),
action.getMandatoryInputs()));
}
}
/**
* All info/warning messages associated with actions should be always displayed.
*/
@Override
public String extractTag(SkyKey skyKey) {
return null;
}
/**
* Used to declare all the exception types that can be wrapped in the exception thrown by
* {@link ActionExecutionFunction#compute}.
*/
private static final class ActionExecutionFunctionException extends SkyFunctionException {
private final ActionExecutionException actionException;
public ActionExecutionFunctionException(ActionExecutionException e) {
// We conservatively assume that the error is transient. We don't have enough information to
// distinguish non-transient errors (e.g. compilation error from a deterministic compiler)
// from transient ones (e.g. IO error).
// TODO(bazel-team): Have ActionExecutionExceptions declare their transience.
super(e, Transience.TRANSIENT);
this.actionException = e;
}
@Override
public boolean isCatastrophic() {
return actionException.isCatastrophe();
}
}
}
| [
"[email protected]"
] | |
f42628b6ec27e352276149a75eb25f1c0fd4b63e | 7c0d4bbeb65a58e2ae80191258c76960de691390 | /poc/SpaceWeatherSWD/SpaceWeatherSWD/SpaceWeatherSWD-Application/src/main/java/br/inpe/climaespacial/swd/home/validators/IntervalValidator.java | 8b60ec4213052d1bc22725578b2becdb7418100c | [] | no_license | guilhermebotossi/upmexmples | 92d53f2a04d4fe53cc0bf8ead0788983d7c28a0a | 77d90477c85456b223c21e4e9a77f761be4fa861 | refs/heads/master | 2022-12-07T12:25:32.599139 | 2019-11-26T23:45:48 | 2019-11-26T23:45:48 | 35,224,927 | 0 | 0 | null | 2022-11-24T09:17:43 | 2015-05-07T14:31:30 | Java | UTF-8 | Java | false | false | 231 | java |
package br.inpe.climaespacial.swd.home.validators;
import java.time.ZonedDateTime;
public interface IntervalValidator {
void validate(ZonedDateTime farthestFromNow, ZonedDateTime nearestFromNow, int periodSize);
}
| [
"[email protected]"
] | |
5793395716323bfd0b3fa8b81c4f2bf2ec4dcb10 | 97c2cfd517cdf2a348a3fcb73e9687003f472201 | /workspace/fftw-pomsfa/tags/fftw-pomsfa-1.4.3/src/main/java/com/fftw/fix/quickfixj/LogReader.java | 302f07d961d88b639aeac7952dcb59f55785f510 | [] | no_license | rsheftel/ratel | b1179fcc1ca55255d7b511a870a2b0b05b04b1a0 | e1876f976c3e26012a5f39707275d52d77f329b8 | refs/heads/master | 2016-09-05T21:34:45.510667 | 2015-05-12T03:51:05 | 2015-05-12T03:51:05 | 32,461,975 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,377 | java | package com.fftw.fix.quickfixj;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import quickfix.DefaultMessageFactory;
import quickfix.FileStore;
import quickfix.FileStoreFactory;
import quickfix.InvalidMessage;
import quickfix.Message;
import quickfix.MessageUtils;
import quickfix.SessionID;
import quickfix.SessionSettings;
import com.fftw.task.AbstractObservableTask;
/**
* Read in a QuickFix/J log.
*
*/
public class LogReader extends AbstractObservableTask
{
private DefaultMessageFactory dmf = new DefaultMessageFactory();
private static final String[] EXTENSIONS =
{
".body", ".header", ".seqnums", ".session"
};
public List<Message> readFixStore (File fixLogFile) throws FileNotFoundException, IOException
{
// Determine the log files from the selected file
FileStore fs = createFileStore(fixLogFile);
long lastSeqNum = fs.getNextSenderMsgSeqNum();
setDone(false);
setCancelled(false);
List<String> messageStr = new ArrayList<String>(1);
List<Message> messages = new ArrayList<Message>((int)lastSeqNum);
for (int i = 1; i < lastSeqNum && !isCancelRequested() && !isCancelled(); i++)
{
fs.get(i, i, messageStr);
String message = messageStr.get(0);
Message fixMessage = message == null ? null : convertStr2Message(message);
if (fixMessage != null)
{
messages.add(fixMessage);
}
messageStr.clear();
setProgress(i, lastSeqNum);
setChanged();
notifyObservers();
}
if (isCancelRequested() && !isDone())
{
setCancelled(true);
setCancelled(false);
}
setProgress(100);
setChanged();
notifyObservers();
return messages;
}
private Message convertStr2Message (String message)
{
try
{
return MessageUtils.parse(dmf, null, message);
}
catch (InvalidMessage e)
{
}
return null;
}
public List<Message> readFixLog (File fixLogFile) throws FileNotFoundException, IOException
{
long expectedSize = fixLogFile.length();
long bytesRead = 0;
setDone(false);
setCancelled(false);
List<Message> messages = new LinkedList<Message>();
FileReader fr = new FileReader(fixLogFile);
BufferedReader br = new BufferedReader(fr);
while (!isDone() && !isCancelRequested() && !isCancelled())
{
String fileLine = br.readLine();
if (fileLine == null)
{
setDone(true);
}
else
{
bytesRead += fileLine.length();
String[] messageParts = fileLine.split(" - ");
Message fixMessage = convertStr2Message(messageParts[1]);
messages.add(fixMessage);
setProgress(bytesRead, expectedSize);
setChanged();
notifyObservers();
}
}
br.close();
if (isCancelRequested() && !isDone())
{
setCancelled(true);
setCancelled(false);
}
setProgress(100);
setChanged();
notifyObservers();
return messages;
}
private FileStore createFileStore (File fixLogFile)
{
SessionID fileSessionID = extractSessionFileName(fixLogFile);
if (fileSessionID != null)
{
File dir = fixLogFile.getParentFile();
SessionSettings ss = new SessionSettings();
ss.setString(FileStoreFactory.SETTING_FILE_STORE_PATH, dir.getAbsolutePath());
FileStoreFactory fsf = new FileStoreFactory(ss);
return (FileStore)fsf.create(fileSessionID);
}
return null;
}
/**
* return everything before the last 'dot'
*
* The extension should be one of:
* <ul>
* <li>body</li>
* <li>header</li>
* <li>seqnums</li>
* <li>session</li>
* </ul>
*
* @param fixLogFile
* @return
*/
private SessionID extractSessionFileName (File fixLogFile)
{
String fileName = fixLogFile.getName();
String sessionStr = null;
for (String ext : EXTENSIONS)
{
String[] tmp = fileName.split(ext);
if (tmp != null && tmp[0].length() < fileName.length())
{
// Found a match
sessionStr = tmp[0];
break;
}
}
if (sessionStr != null)
{
String[] sessionParts = sessionStr.split("-");
return new SessionID(sessionParts[0], sessionParts[1], sessionParts[2]);
}
return null;
}
private void setProgress (long bytesRead, long expectedSize)
{
int progress = (int)((float)bytesRead / (float)expectedSize * 100.0);
setProgress(progress);
}
public String getDescription ()
{
return "Reading FIX Log File";
}
}
| [
"[email protected]"
] | |
da061e67a7221a1e0bbcfd4bbd639c06e7fe0cc1 | 26fa263aed5ad64f47a43100f9c1f8829cff6973 | /android-framework/src/main/java/io/blushine/android/Fragment.java | 46e998e97b53604981449fd4103ece40e301880f | [
"MIT"
] | permissive | Senth/android-framework | 9111669db69812e2a813accd169654e56537ed77 | 7280575b4989a3fc5cc22a958c2a9d69d44550ce | refs/heads/master | 2021-10-10T21:09:48.427478 | 2019-01-17T13:01:07 | 2019-01-17T13:01:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,951 | java | package io.blushine.android;
import android.os.Bundle;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.HashMap;
import java.util.Map;
/**
* Base class for all fragments. If you want to make a fullscreen fragment, use {@link AppFragment
* instead}. This class is mostly used for fragments inside fragments.
*/
public abstract class Fragment extends androidx.fragment.app.Fragment {
protected View mView;
private Map<String, Object> mArguments = new HashMap<>();
private Map<String, AppFragment.ArgumentRequired> mArgumentRequired = new HashMap<>();
private boolean mCreatedNewView = false;
public Fragment() {
onDeclareArguments();
}
/**
* Called when argument should be declared
*/
protected void onDeclareArguments() {
// Does nothing
}
/**
* Declare arguments. If an argument is set as required and it's not available it will
* generate an error.
* @param argumentName name of the argument
* @param required true if required, false if optional.
*/
protected void declareArgument(String argumentName, AppFragment.ArgumentRequired required) {
mArgumentRequired.put(argumentName, required);
}
/**
* Add arguments to the class
* @param arguments add all the arguments to an existing argument list, or set this bundle as the argument
* list.
*/
protected void addArguments(Bundle arguments) {
Bundle existingArguments = getArguments();
if (existingArguments != null) {
existingArguments.putAll(arguments);
} else {
setArguments(arguments);
}
}
@Nullable
@Override
public final View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
fetchArguments();
onArgumentsSet();
if (mView == null) {
mView = onCreateViewImpl(inflater, container, savedInstanceState);
mCreatedNewView = true;
} else {
mCreatedNewView = false;
}
return mView;
}
@Override
public final void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mCreatedNewView) {
onViewCreatedImpl(view, savedInstanceState);
}
}
/**
* Called immediately after {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}
* has returned, but before any saved state has been restored in to the view.
* This gives subclasses a chance to initialize themselves once
* they know their view hierarchy has been completely created. The fragment's
* view hierarchy is not however attached to its parent at this point.
* @param view The View returned by {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}.
* @param savedInstanceState If non-null, this fragment is being re-constructed from a previous
* saved state as given here.
*/
public void onViewCreatedImpl(View view, @Nullable Bundle savedInstanceState) {
}
/**
* Set Arguments
*/
private void fetchArguments() {
Bundle arguments = getArguments();
for (Map.Entry<String, AppFragment.ArgumentRequired> entry : mArgumentRequired.entrySet()) {
String name = entry.getKey();
AppFragment.ArgumentRequired required = entry.getValue();
Object value = null;
if (arguments != null) {
value = arguments.get(name);
}
if (value != null) {
mArguments.put(name, value);
} else if (required == AppFragment.ArgumentRequired.REQUIRED) {
throw new IllegalStateException("Required argument " + name + " not set!");
}
}
}
/**
* Called when the arguments have been set
*/
protected void onArgumentsSet() {
// Does nothing
}
/**
* Called to have the fragment instantiate its user interface view.
* This is optional, and non-graphical fragments can return null (which
* is the default implementation). This will be called between
* {@link #onCreate(Bundle)} and {@link #onActivityCreated(Bundle)}.
* <p>
* <p>If you return a View from here, you will later be called in
* {@link #onDestroyView} when the view is being released.
* @param inflater The LayoutInflater object that can be used to inflate any views in the fragment,
* @param container If non-null, this is the parent view that the fragment's UI should be attached
* to. The fragment should not add the view itself, but this can be used to generate the
* LayoutParams of the view.
* @param savedInstanceState If non-null, this fragment is being re-constructed from a previous
* saved state as given here.
* @return Return the View for the fragment's UI, or null.
*/
public abstract View onCreateViewImpl(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState);
/**
* Get the argument value
* @param argumentName the name of the argument
* @return argument value in the specified format
*/
@SuppressWarnings("unchecked")
protected <ReturnType> ReturnType getArgument(String argumentName) {
return (ReturnType) mArguments.get(argumentName);
}
/**
* If an argument is required or not
*/
protected enum ArgumentRequired {
REQUIRED,
OPTIONAL,
}
}
| [
"[email protected]"
] | |
e3cb64bcdc4c4835c8d6c3f77e5861a5d85ced05 | 06a961732f946cf3dd609868e28522fca94f0b04 | /src/main/java/com/eho/fhir/pixm/RestControllers/IHEpixmController.java | 028d39254f0d39a6d776e4acb71f2f0b2c8b1d69 | [
"Apache-2.0"
] | permissive | bornajafarpour/FHIR-Test-Server | f00704287e2032e4efb43749aadede622fbfb19f | e69fc4aad0ef0506bff012ae056a089a84e6b707 | refs/heads/master | 2020-06-11T15:08:35.518736 | 2017-03-30T20:24:01 | 2017-03-30T20:24:01 | 75,642,652 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,558 | 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.eho.fhir.pixm.RestControllers;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
import ca.uhn.fhir.model.dstu2.composite.AgeDt;
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu2.resource.Parameters;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum;
import ca.uhn.fhir.model.primitive.BooleanDt;
import ca.uhn.fhir.model.primitive.IdDt;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
import com.amazonaws.services.dynamodbv2.model.ScanRequest;
import com.amazonaws.services.dynamodbv2.model.ScanResult;
import com.eho.dynamodb.DynamoDBConnection;
import com.eho.validation.PIXmValidator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import sun.awt.image.ImageCache;
/**
*
* @author borna.jafarpour
*/
@RestController
@RequestMapping(value="/Patient/$ihe-pix")
public class IHEpixmController {
//
// @RequestMapping(method=RequestMethod.GET, produces = "application/json;charset=UTF-8")
// public ResponseEntity<String> patient_search(@RequestParam(required = false) String given, @RequestParam(required = false) String family, @RequestParam(required = false) String identifier) throws Exception
// {
// return new ResponseEntity("test ihe-pixm goooz",HttpStatus.OK);
// }
@RequestMapping(method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public @ResponseBody ResponseEntity<String> ihe_pixm_post( @RequestBody final String parameters) throws Exception{
//Parameters posted_parameters = DynamoDBConnection.fCtx.newJsonParser().parseResource(Parameters.class, parameters);
JSONObject params = new JSONObject(parameters);
try {
JSONArray parameter = params.optJSONArray("parameter");
if (parameter == null)
throw new Exception("No parameter was provided");
if (parameter.length() > 1)
throw new Exception("Too many paramaters");
if (!"sourceIdentifier".equals(parameter.getJSONObject(0).optString("name")))
throw new Exception("Incorrect parameter type. SourceIdentifier is expected");
String system = parameter.optJSONObject(0).optJSONObject("valueIdentifier").optString("system").toLowerCase();
String value = parameter.optJSONObject(0).optJSONObject("valueIdentifier").optString("value");
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
String filter_expression = DynamoDBConnection.create_search_exp(system+"|"+value,"identifiers",expressionAttributeValues);
AmazonDynamoDB client = DynamoDBConnection.getDynamoDBClient();
ScanRequest scanRequest = new ScanRequest()
.withTableName(DynamoDBConnection.PATIENT_TABLE)
.withFilterExpression(filter_expression)
//.withExpressionAttributeNames(expressionAttributeNames)
.withExpressionAttributeValues(expressionAttributeValues);
ScanResult result = client.scan(scanRequest);
Parameters pm = new Parameters();
ResourceMetadataMap rmm = new ResourceMetadataMap();//.put(ResourceMetadataKeyEnum.PROFILES,"salaam" );
rmm.put(ResourceMetadataKeyEnum.PROFILES, new IdDt("http://ehealthontario.ca/API/FHIR/StructureDefinition/pcr-parameters-pixm-out|1.0"));
pm.setResourceMetadata(rmm);
HashSet<String> identifiers_so_far = new HashSet<>();
for (Map<String, AttributeValue> item : result.getItems()) {//add all the items to a bundle to be returned
int latest_version = Integer.valueOf(item.get("version").getN());
String item_id = item.get("dynamodb-id").getS();
pm.addParameter(new Parameters.Parameter().setName("targetId").setValue(new IdDt(item_id)));
String latest_text = item.get("text"+latest_version).getS();
HashSet<String> identifiers = DynamoDBConnection.get_patient_identifiers(latest_text);
for (String thisid : identifiers)
{
system =thisid.substring(0, thisid.indexOf("|"));
value = thisid.substring(thisid.indexOf("|")+1);
if (!identifiers_so_far.contains(system + "|" + value))//avoiding duplicate identifiers
{
identifiers_so_far.add(system + "|" + value);
pm.addParameter(new Parameters.Parameter().setName("targetIdentifier").setValue( new IdentifierDt(system, value)));
}
}
}
return new ResponseEntity(DynamoDBConnection.fCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(pm),HttpStatus.OK);
} catch (Exception e) {
OperationOutcome oo = new OperationOutcome().addIssue(new OperationOutcome.Issue().setSeverity(IssueSeverityEnum.ERROR).setDiagnostics(e.getMessage()));
PIXmValidator.validate_json(parameters, "Parameters", oo);
return new ResponseEntity(DynamoDBConnection.fCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo),HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
| [
"[email protected]"
] | |
3c36115a161588ad131a099191e36966803814f8 | db2a36a97263797268779f2c7b6739dfd07efc67 | /kodilla-testing/src/main/java/com/kodilla/testing/library/BookLibrary.java | d0b06e2530170d7fd25a225fcc50ede37a015f16 | [] | no_license | Luke1024/rodo-kodilla-java | 85c635eed4beb24d59282bb0bd9bca71432bbd99 | e7544e57efdc59ced6bd3c0170351374bb6bb97d | refs/heads/master | 2020-04-08T23:09:19.059034 | 2019-08-08T10:11:20 | 2019-08-08T10:11:20 | 159,707,253 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 850 | java | package com.kodilla.testing.library;
import java.util.ArrayList;
import java.util.List;
public class BookLibrary {
LibraryDatabase libraryDatabase;
public BookLibrary(LibraryDatabase libraryDatabase)
{
this.libraryDatabase = libraryDatabase;
}
public List<Book> listBooksWithCondition(String titleFragment) {
List<Book> bookList = new ArrayList<Book>();
if (titleFragment.length() < 3) return bookList;
List<Book> resultList = libraryDatabase.listBooksWithCondition(titleFragment);
if (resultList.size() > 20) return bookList;
bookList = resultList;
return bookList;
}
public List<Book> listBooksInHandsOf(LibraryUser libraryUser){
List<Book> books = libraryDatabase.listBooksInHandsOf(libraryUser);
return books;
}
} | [
"[email protected]"
] | |
0a85b69788fa48feed4d7e29dab54b518c227c0e | fae83a7a4b1f0e4bc3e28b8aaef5ca8998918183 | /src/org/daisy/util/fileset/validation/message/ValidatorErrorMessage.java | eb8bd4afdca622695abe7f2911b7f2ca25e7aa8c | [] | no_license | techmilano/pipeline1 | 2bd3c64edf9773c868bbe23123b80b2302212ca5 | f4b7c92ef9d84bf9caeebc4e17870059d044d83c | refs/heads/master | 2020-04-10T14:27:46.762074 | 2018-03-09T14:35:31 | 2018-03-13T13:48:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,325 | java | /*
* org.daisy.util (C) 2005-2008 Daisy Consortium
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.daisy.util.fileset.validation.message;
import java.net.URI;
/**
* Message issued when a Validator encounters an invalid state in the input fileset
* that is flagged to have a severity level of <em>error</em>.
* @author Markus Gylling
*/
public class ValidatorErrorMessage extends ValidatorMessage {
public ValidatorErrorMessage(URI file, String message, int line, int column) {
super(file, message, line, column);
}
public ValidatorErrorMessage(URI file, String message) {
super(file, message);
}
}
| [
"[email protected]"
] | |
e6542140fca35b4f37b5f0465f201f3be7429cd7 | 726b6d9f5bd965b8047662cdf3c7f2796139e69c | /InteraxTelephonyAMI/src/com/interax/telephony/service/ami/pickdialing/PickDialingCallManager.java | bf5db2572aeef8d3d1bc86d0ca116ae0a08b8d2e | [] | no_license | adiquintero/interaxtelephony | 794e8311d3f61e3fdec233c055c0e5df4db3274a | 14dcd109fa3dd5ed74797f681dd87ec793ded703 | refs/heads/master | 2020-08-23T09:24:31.158545 | 2019-10-21T14:21:34 | 2019-10-21T14:21:34 | 216,584,831 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,289 | java | package com.interax.telephony.service.ami.pickdialing;
import java.util.Calendar;
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.ChannelState;
import org.asteriskjava.live.ManagerCommunicationException;
import org.asteriskjava.live.NoSuchChannelException;
import org.asteriskjava.manager.action.StreamAction;
import com.interax.telephony.service.ami.InteraxTelephonyCallManager;
import com.interax.telephony.service.data.ServiceReservation;
import com.interax.telephony.service.exception.InteraxTelephonyException;
import com.interax.telephony.service.exception.pickdialing.PickDialingNotEnoughBalanceException;
import com.interax.telephony.util.PersistenceManager;
import com.interax.telephony.util.StackTrace;
public class PickDialingCallManager extends InteraxTelephonyCallManager {
private PickDialingAmi pickDialingAmi;
private PickDialingCallManagerLogger managerLogger;
private int currentSleepTime;
private Calendar nextWakeUpDate;
private String backupFileName;
protected PickDialingManagedCall managedCall;
private String childrenCdrId;
public PickDialingCallManager(PickDialingAmi pickDialingAmi, PickDialingManagedCall managedCall, AsteriskChannel incomingChannel, AsteriskChannel outgoingChannel){
super(incomingChannel, outgoingChannel, pickDialingAmi.getPickDialingAmiConfig().SLEEP_TIME, pickDialingAmi.getPickDialingAmiConfig().SAFETY_SECONDS_TO_HANGUP, pickDialingAmi.getGenericEjbCaller());
this.managedCall = managedCall;
this.pickDialingAmi = pickDialingAmi;
this.managerLogger = new PickDialingCallManagerLogger(this,this.pickDialingAmi.getConfigPath());
}
public void run(){
this.childrenCdrId = this.managedCall.getChildrenCdrId();
this.managerLogger.info("Monitoring Call");
this.managerLogger.info("/******/Call data/******/");
this.managerLogger.info("ANI:" + this.managedCall.getAni());
this.managerLogger.info("DNI:" + this.managedCall.getDni());
this.managerLogger.info("Service Family:" + this.managedCall.getServiceFamily());
this.managerLogger.info("AccessType:" + this.managedCall.getAccessType());
this.managerLogger.info("/******/Call data/******/");
this.backupFileName =PickDialingAmi.BACKUP_FILE_PREFIX + this.managedCall.getIncomingCdrId();
this.nextWakeUpDate = this.managedCall.getNextWakeupDate();
this.currentSleepTime = this.sleepTime/2;
this.toHangup = this.managedCall.isToHangupCall();
if(this.nextWakeUpDate.compareTo(this.managedCall.getStartDate())==0){
this.managerLogger.info("New Call. Sleeping:" + this.currentSleepTime);
this.nextWakeUpDate.add(Calendar.SECOND, this.currentSleepTime);
}
else
{
this.managerLogger.info("Recovering from persistent data.");
if(this.toHangup){
forceHangup();
}
int minutes = 0;
Calendar now = Calendar.getInstance();
while(this.nextWakeUpDate.before(now)){
minutes++;
this.nextWakeUpDate.add(Calendar.SECOND, this.sleepTime);
}
if(minutes != 0){
minutes--;
this.managerLogger.info("Make a new reservation that should be made in the past.");
getNewBlock(false);
}
this.managerLogger.info("To charge: " + minutes + " minutes.");
try {
if(getBlock(this.managedCall.getReservationId(), minutes)){
this.managerLogger.info(minutes + " minutes charged successfully.");
}
else{
this.managerLogger.info(minutes + " couldn't be charged.");
}
//TODO: Decidir si se tranca la llamada, o que medida se toma.
} catch (InteraxTelephonyException e) {
this.managerLogger.warn("There was a problem reservating a minute for this call.");
this.managerLogger.warn("Detail: " + e.getMessage());
}
}
while(this.alive){
this.managedCall.setNextWakeupDate(this.nextWakeUpDate);
this.managedCall.setToHangupCall(this.toHangup);
PersistenceManager.saveObject(this.managedCall, this.backupFileName);
Calendar now = Calendar.getInstance();
long realSleepTime = this.nextWakeUpDate.getTimeInMillis() - now.getTimeInMillis();
try{
this.managerLogger.debug("Is alive!");
this.managerLogger.debug("To sleep: " + realSleepTime);
if(realSleepTime > 0){
this.managerLogger.debug("Sleeping " + realSleepTime / 1000 + " seconds.");
Thread.sleep(realSleepTime);
}
else{
this.managerLogger.error("FATAL ERROR. THIS SHOULD NEVER HAPPEN!!! SLEEPTIME NEGATIVE.");
this.managerLogger.debug("Error sleepTime is negative. Sleep 5 seg");
Thread.sleep(5000);
}
ChannelState channelState = outgoingChannel.getState();
this.managerLogger.debug("Channels: (IN/OUT) " + this.incomingChannel.getName() + " -- " + this.outgoingChannel.getName());
this.managerLogger.debug("OutgoingChannel state: " + channelState.name());
switch (channelState) {
case UP:
if(this.toHangup){
forceHangup();
}else{
this.managerLogger.info("Make a new reservation.");
getNewBlock();
}
break;
case HUNGUP:
managerLogger.info("The channel hungup.");
this.alive = false;
break;
default:
this.managerLogger.info("The channel is not up.");
this.alive = false;
break;
}
}
catch(InterruptedException ie){
}
}
}
private void getNewBlock(){
getNewBlock(true);
}
private void getNewBlock(boolean calculateNextWakeUpDate){
this.managerLogger.info("Channel still up, trying to reserve 1 more minute.");
try {
int secondsLeft = getBlock(this.managedCall.getReservationId());
if(calculateNextWakeUpDate){
this.managerLogger.info("Calculating nextWakeUpDate.");
if(secondsLeft < ServiceReservation.BASE_TIME_IN_SECONDS){
// No more money for this call
this.managerLogger.warn("There is no more money available for this call.");
this.managerLogger.info("There is no more minutes available, only " + secondsLeft + " seconds, sending a warning beep.");
this.toHangup = true;
try {
StreamAction streamAction = new StreamAction();
streamAction.setChannel(incomingChannel.getName());
streamAction.setFile("beep");
this.pickDialingAmi.managerConnection.sendAction(streamAction,0);
} catch (Exception e1) {
this.managerLogger.error("Problem Streaming file.");
}
secondsLeft = this.sleepTime/2 + secondsLeft - this.safetySecondsToHangup;
}
else{
this.managerLogger.info("There is one more minute available.");
secondsLeft = ServiceReservation.BASE_TIME_IN_SECONDS;// Se pone 60 seg por seguridad.
}
this.currentSleepTime = secondsLeft;
this.nextWakeUpDate.add(Calendar.SECOND, this.currentSleepTime);
}
} catch (PickDialingNotEnoughBalanceException e) {
// No more money for this call
this.toHangup = true;
this.managerLogger.warn("There is no more money available for this call.");
this.managerLogger.warn("Detail: " + e.getMessage());
this.managerLogger.warn("This is the last minute, send a warning.");
StreamAction streamAction = new StreamAction();
streamAction.setChannel(incomingChannel.getName());
streamAction.setFile("beep");
try {
this.pickDialingAmi.managerConnection.sendAction(streamAction,0);
} catch (Exception e1) {
this.managerLogger.error("Problem Streaming file.");
}
if(calculateNextWakeUpDate){
this.managerLogger.info("Calculating nextWakeUpDate.");
this.currentSleepTime = this.sleepTime/2 - this.safetySecondsToHangup;
this.nextWakeUpDate.add(Calendar.SECOND, this.currentSleepTime);
}
} catch (InteraxTelephonyException e) {
// Other error
this.managerLogger.warn("There was a problem reservating a minute for this call.");
this.managerLogger.warn("Detail: " + e.getMessage());
this.managerLogger.warn("Forcing Hangup.");
this.toHangup = true;
}
}
private void forceHangup(){
this.managerLogger.info("Going to force Hangup.");
this.managerLogger.debug("Channels: (IN/OUT) " + this.incomingChannel.getName() + " -- " + this.outgoingChannel.getName());
try{
this.outgoingChannel.hangup();
this.managerLogger.info("Hangup successfull.");
this.alive = false;
}
catch(NoSuchChannelException nsce){
this.managerLogger.error("Problem with the Hangup. No such channel");
this.managerLogger.debug("Deatil: " + nsce.getMessage());
this.managerLogger.debug("Trace: " + StackTrace.ToString(nsce));
this.alive = false;
}
catch(ManagerCommunicationException mce){
this.managerLogger.error("Problem with the Hangup. Error in comunication.");
this.managerLogger.debug("Deatil: " + mce.getMessage());
this.managerLogger.debug("Trace: " + StackTrace.ToString(mce));
this.alive = false;
}
}
private Integer getBlock(long reservationId) throws InteraxTelephonyException {
if (this.managedCall.isRaterTestMode()){
this.managerLogger.info("In test mode.");
int availableSeconds = this.managedCall.getRaterTestAvailablesSeconds();
this.managerLogger.debug(availableSeconds + " available test seconds.");
if(availableSeconds < ServiceReservation.BASE_TIME_IN_SECONDS){
this.managedCall.setRaterTestAvailablesSeconds(0);
return availableSeconds;
}
else
{
this.managedCall.setRaterTestAvailablesSeconds(availableSeconds - ServiceReservation.BASE_TIME_IN_SECONDS);
return ServiceReservation.BASE_TIME_IN_SECONDS;
}
}
return getBlock(reservationId, this.pickDialingAmi.getPickDialingAmiConfig().RATER_EJB_SERVER, this.pickDialingAmi.getPickDialingAmiConfig().RATER_EJB_PORT);
}
private boolean getBlock(long reservationId, long blocks) throws InteraxTelephonyException {
if (this.managedCall.isRaterTestMode()){
this.managerLogger.info("In test mode.");
this.managerLogger.debug("Consuming minutes in system.");
return true;
}
return getBlock(reservationId, blocks, this.pickDialingAmi.getPickDialingAmiConfig().RATER_EJB_SERVER, this.pickDialingAmi.getPickDialingAmiConfig().RATER_EJB_PORT);
}
public String getChildrenCdrId() {
return childrenCdrId;
}
} | [
"[email protected]"
] | |
7fcb72fcfa91c943515feee2210677b310f988e3 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_af02b3b4358981f299bcf02d031870e94348bb25/StartupListener/2_af02b3b4358981f299bcf02d031870e94348bb25_StartupListener_s.java | fc995472852789027111f60accaa6ae060fb228e | [] | 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,391 | java | package gov.nih.nci.camod.webapp.listener;
import gov.nih.nci.camod.Constants;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.ContextLoaderListener;
/**
* StartupListener class used to initialize and database settings and populate
* any application-wide drop-downs.
*
* @author <a href="mailto:[email protected]">Matt Raible</a>
*
* @web.listener
*/
public class StartupListener extends ContextLoaderListener implements ServletContextListener {
private static final long serialVersionUID = 3257135453799404851L;
private static final Log log = LogFactory.getLog(StartupListener.class);
public void contextInitialized(ServletContextEvent event) {
if (log.isDebugEnabled()) {
log.debug("initializing context...");
}
// call Spring's context ContextLoaderListener to initialize
// all the context files specified in web.xml
super.contextInitialized(event);
ServletContext context = event.getServletContext();
String daoType = context.getInitParameter(Constants.DAO_TYPE);
// if daoType is not specified, use DAO as default
if (daoType == null) {
log.warn("No 'daoType' context carameter, using hibernate");
daoType = Constants.DAO_TYPE_HIBERNATE;
}
// Orion starts Servlets before Listeners, so check if the config
// object already exists
Map config = (HashMap) context.getAttribute(Constants.CONFIG);
if (config == null) {
config = new HashMap();
}
// Create a config object to hold all the app config values
config.put(Constants.DAO_TYPE, daoType);
context.setAttribute(Constants.CONFIG, config);
// output the retrieved values for the Init and Context Parameters
if (log.isDebugEnabled()) {
log.debug("daoType: " + daoType);
log.debug("populating drop-downs...");
}
setupContext(context);
}
public static void setupContext(ServletContext context) {
if (log.isDebugEnabled()) {
log.debug("drop-down initialization complete [OK]");
}
}
}
| [
"[email protected]"
] | |
3b93e322bb022b23626e0707a2a9b5cc0b28c33e | dde803892d3c34fdad44e87f47a4bfd5c867185d | /Indexing/src/cs/uwindsor/ir/index/search/Search.java | dd11624286401f46c39de31fc3c7a11af876a95c | [] | no_license | rajbhatta/Java_search_engine | 41f930a993a74d59f27e045f583129255f251bf0 | 603943d06f6bf69831326aca63c1aae89da1dee2 | refs/heads/master | 2022-06-03T15:11:00.195932 | 2019-06-14T02:09:48 | 2019-06-14T02:09:48 | 191,859,915 | 5 | 0 | null | 2020-06-15T21:53:39 | 2019-06-14T02:01:00 | Java | UTF-8 | Java | false | false | 1,546 | java | package cs.uwindsor.ir.index.search;
import java.nio.file.Paths;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
public class Search {
public static void main(String[] args) throws Exception {
String index = "E://ir notes//project/index";
String searchValue="information"; //provide search parameter
IndexReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(index)));
IndexSearcher searcher = new IndexSearcher(reader);
Analyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser("contents", analyzer);
Query query = parser.parse(searchValue);
TopDocs results = searcher.search(query, 10000);
System.out.println(results.totalHits + "TOTAL DOCUMENTS");
for (int i = 0; i < results.totalHits; i++)
{
Document doc = searcher.doc(results.scoreDocs[i].doc);
String filePath = doc.get("path");
System.out.println((i + 1) + ". " + filePath);
String title = doc.get("title");
if (title != null)
{
System.out.println("Title:" + title);
}
}
reader.close();
}
} | [
"[email protected]"
] | |
be2bb74dc70b28de46da9011facddac5e472e582 | 9e23148ed736707f9d7a147edce463171b24b398 | /playlist/Playlist.java | 6bda695a17515f1835bee6bf277fc57f30e70c43 | [] | no_license | Dishakumra/Playlist | b74fe2cff779d5845c8fa679b2093d39c608f0e6 | 57754ae173f3031be1ff243954544658d8a303c1 | refs/heads/master | 2020-12-26T09:50:42.988119 | 2020-01-31T16:40:47 | 2020-01-31T16:40:47 | 237,471,961 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,643 | java | import java.util.*;
import java.io.*;
import structure.*;
public class Playlist{
public static void main(String args[])
{
MediaPlayer m=new MediaPlayer();
do{
System.out.println("Welcome to mymediaplayer");
int choice;
int inter;
System.out.println("1 :- Create a new playlist");
System.out.println("2 :- Print All the PlayLists ");
System.out.println("3 :- print the active PlayList ");
System.out.println("4 :- Enter the Playlist no. to start it ");
System.out.println("5:- add Song to The Playlist");
System.out.println("6 :- See songs in active Playlist");
System.out.println("7:- delete the Playlist");
System.out.println("8:- set modes out of (1 for normal 2 for repeat playlist 3 for shuffle play)");
Scanner sc=new Scanner(System.in);
choice=sc.nextInt();
switch(choice){
case 1:
m.createNewPlayList();
break;
case 2:
m.printPlayList();
break;
case 3:
m.printActivePlayList();
break;
case 4:
inter=sc.nextInt();
m.setActive(inter);
break;
case 5:
m.addSongs();
break;
case 6:
m.peekPlayList();
break;
case 7:
m.deleteActivePlayList();
break;
case 8:
inter=sc.nextInt();
m.playSongs(inter);
break;
}
if(choice==0)
break;
}while(true);
}
}
| [
"[email protected]"
] | |
a8681063b9d6976d7625b88de8ee298add4c492b | 114bf61984d0059a9c0b55faa51867181f6df966 | /sb-config/src/test/java/cn/mh/config/yml/PersonTest.java | 0d6a2c39a1afce4effd5c2cc500f8f97dc6e4084 | [] | no_license | mashenghao/springboot-learn | c30bfd3a46ba91c232fdf93f6b98fc9793e95936 | 265604459da397002355df2074c72ee4f1ea4fae | refs/heads/master | 2020-09-15T23:56:27.285096 | 2019-11-25T12:57:18 | 2019-11-25T12:57:18 | 223,589,657 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | package cn.mh.config.yml;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
/**
* @program: springboot-learn
* @Date: 2019/11/13 16:58
* @Author: mahao
* @Description:
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class PersonTest {
} | [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.