blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1438b25e349b0cb7800e89102979ba630225dc9a | 7b2d2f0fef11fc22572135ff613777779da8c9c0 | /graphql/webmvc/src/main/java/com/example/UserController.java | 499a5a882ec2e8efeb070a3ffd6155a41d8bda2a | []
| no_license | hirakida/spring-boot-demo | 70895a13181e6c10e7bca1c70f060b18204a0a97 | aba101fd4fd9a65c0b72a226e386c549713cebd7 | refs/heads/master | 2023-07-18T21:00:46.657049 | 2023-07-17T16:03:29 | 2023-07-17T16:03:29 | 77,306,006 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,899 | java | package com.example;
import java.util.List;
import java.util.Optional;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.server.ResponseStatusException;
import com.example.model.User;
import com.example.repository.UserRepository;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class UserController {
private final UserRepository userRepository;
@QueryMapping
public Optional<User> user(@Argument int id) {
return userRepository.findById(id);
}
@QueryMapping
public List<User> users() {
return userRepository.findAll();
}
@QueryMapping
public List<User> usersByName(@Argument String name) {
return userRepository.findByName(name);
}
@MutationMapping
public User createUser(@Argument UserInput input) {
User user = new User();
user.setName(input.getName());
user.setRoleId(input.getRoleId());
return userRepository.save(user);
}
@MutationMapping
public User updateUser(@Argument int id, @Argument UserInput input) {
User user = userRepository.findById(id)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
user.setName(input.getName());
user.setRoleId(input.getRoleId());
return userRepository.save(user);
}
@MutationMapping
public void deleteUser(@Argument int id) {
userRepository.deleteById(id);
}
@Data
public static class UserInput {
private String name;
private Integer roleId;
}
}
| [
"[email protected]"
]
| |
29f11f5057ab625867f5a85c98625d0a9095e919 | 66a9f92f90682846a2dc0322811b9afd7c9626b8 | /src/main/java/org/javacs/FixImports.java | 751c7565bba21d0655b547cdbd8d1fb722fafee8 | [
"MIT"
]
| permissive | acr31/java-language-server | c48bcff7ef44c1de24d0684b67e39e2edc08c776 | 58c484f7dac0a61a0843c7cde98906a4eac9033d | refs/heads/master | 2020-04-05T04:44:19.698194 | 2018-11-07T15:11:22 | 2018-11-07T15:11:22 | 156,564,599 | 0 | 0 | MIT | 2018-11-07T15:10:04 | 2018-11-07T15:10:03 | null | UTF-8 | Java | false | false | 505 | java | package org.javacs;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.util.SourcePositions;
import java.util.Set;
class FixImports {
final CompilationUnitTree parsed;
final SourcePositions sourcePositions;
final Set<String> fixedImports;
FixImports(CompilationUnitTree parsed, SourcePositions sourcePositions, Set<String> fixedImports) {
this.parsed = parsed;
this.sourcePositions = sourcePositions;
this.fixedImports = fixedImports;
}
}
| [
"[email protected]"
]
| |
ca139c3c63d1ab532b6d6bb72b446140f8abbd17 | 6650eed44e794c82f71c8cfe3aec0868ffcbf0b7 | /src/rocks/actions/Action.java | f98281aaf8cb6fa17f84bd3c11408b324f52e8b0 | []
| no_license | LaughingLlama/treerocks | f6370a8b4033b5cde3722db854bd4e813f7ceb06 | 5fce2549a7c4608818ba9ee4267830f7b45862e5 | refs/heads/master | 2021-07-01T09:54:44.498891 | 2017-09-19T01:40:41 | 2017-09-19T01:40:41 | 103,336,939 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 495 | java | package rocks.actions;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import rocks.actions.requirements.Requirement;
public abstract class Action implements EventHandler<ActionEvent> {
final private String name;
final private Requirement req;
public Action( String action, Requirement requirement ) {
this.name = action;
this.req = requirement;
}
public String name() {
return name;
}
public Requirement requirement() {
return req;
}
}
| [
"[email protected]"
]
| |
ea2c1174878bffe1b62251f85d596d3e5cb077d3 | 7a4066d462e6569806f84430348b3338e06bbe63 | /project/src/main/java/com/dlf/project/adapter/Rec_Adapter_copy.java | b92543ff955aa3d2260860d5c78f859d045b9e37 | []
| no_license | DF-du/7_30_Work | e69a0e2dc56f4429aa6dc89ff8d437c964acbd0a | fc4d7c4e9bf75b91d20b20aaba5e041f25014d3b | refs/heads/master | 2022-11-27T03:29:26.210640 | 2020-08-01T19:22:21 | 2020-08-01T19:22:21 | 283,773,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,837 | java | package com.dlf.project.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.dlf.project.R;
import com.dlf.project.bean.FuliBean;
import com.dlf.project.sql.MySQLite;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Rec_Adapter_copy extends RecyclerView.Adapter<Rec_Adapter_copy.ViewHolder> {
private Context context;
private ArrayList<FuliBean.ResultsBean> resultsBeans;
public Rec_Adapter_copy(Context context, ArrayList<FuliBean.ResultsBean> resultsBeans) {
this.context = context;
this.resultsBeans = resultsBeans;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
FuliBean.ResultsBean bean = resultsBeans.get(position);
holder.title.setText(bean.getDesc());
Glide.with(context).load(bean.getUrl()).into(holder.url);
}
@Override
public int getItemCount() {
return resultsBeans.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.url)
ImageView url;
@BindView(R.id.title)
TextView title;
public ViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
}
| [
"[email protected]"
]
| |
211a9537c40377b0b723368ecc7942990662a9bc | 6bed1a50d054f5ce099692502407c420e3eb21c4 | /src/Threads/Thrd4_Boolean.java | e7a778631f5c85effa77ad6895a86f488797a2c3 | []
| no_license | shubhrajps/JavaCode | 0ff7800774c5e3b44285c9794744fdce607b6ad3 | 8016258d6199d84a507e77b69a90840f41c733c9 | refs/heads/master | 2023-06-01T04:44:05.191309 | 2017-04-18T05:21:07 | 2017-04-18T05:21:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 988 | java | package Threads;
//Java Program to use a Boolean variable to manage the Thread
import java.util.Scanner;
class Processor extends Thread
{
private volatile boolean running=true; //Boolean variable converts to false after shutdown() function is called. Thus Terminating the Thread.
@Override
public void run()
{
while(running)
{
System.out.println("HELLO");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public void shutdown()
{
running=false;
}
}
public class Thrd4_Boolean
{
public static void main(String args[])
{
Processor p=new Processor();
p.start();
System.out.println("PRESS RETURN TO STOP...");
Scanner sc=new Scanner(System.in);
sc.nextLine();
p.shutdown();
}
}
/*
1. This method helps in synchronising a Thread in low-level.
*/ | [
"SHUBHRAJ PRASAD SINGH"
]
| SHUBHRAJ PRASAD SINGH |
d0d9c2ef7faec8b81b8eef743b5b46c23d31aef6 | 23e89f83067344bcfc8807124a05353749c707e5 | /app/src/main/java/com/sjk/signdemo/BaseActivity.java | 42eeccc099698cc646337404e51f5a6cb8ac5901 | []
| no_license | 1045290202/AndroidNativeLoginAndLogout | 8a4d0adccef63c78d03331ff7878ba3414e72e4a | 4bedba4a2001c5fd6f083f1565fadbfcaffb5af3 | refs/heads/master | 2020-03-21T07:30:02.955219 | 2018-06-22T09:30:01 | 2018-06-22T09:30:01 | 138,283,447 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package com.sjk.signdemo;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCollector.addActivity(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
ActivityCollector.removeActivity(this);
}
}
| [
"[email protected]"
]
| |
c2674a9ca1deb60e2594d2abab3cdc0fa5c552a1 | 16146accaf27ce9d52b9ead31368beb1c7b09565 | /src/main/java/transitSystem/TransitLine.java | e8dd185bfd2588fc1853555dfb06fd56172b5e0d | []
| no_license | cllorca1/transit | 19d16bc74e61d490e76dc853e20485a33f70a0dc | 6baacdd1cba4afaad3c8db8fe9c3609f930e05b8 | refs/heads/master | 2021-01-12T09:49:49.575642 | 2018-04-11T06:30:42 | 2018-04-11T06:30:42 | 73,492,557 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,001 | java | package transitSystem;
import javax.sound.sampled.Line;
import java.util.Map;
/**
* Created by carlloga on 21/11/16.
*/
public class TransitLine {
private long lineId;
private String fromStop;
private String toStop;
private boolean bus;
private boolean subway;
private boolean tram;
private String lineName;
private double headway;
private Map<Integer,TransitStop> stopList;
private Map<Integer, Long> linkList;
private LineType lineType;
private boolean validity;
public TransitLine(long lineId, String fromStop, String toStop, boolean bus, boolean subway, boolean tram, String lineName, Map<Integer, TransitStop> stopList, boolean validity) {
this.lineId = lineId;
this.fromStop = fromStop;
this.toStop = toStop;
this.bus = bus;
this.subway = subway;
this.tram = tram;
this.lineName = lineName;
this.stopList = stopList;
this.validity = validity;
}
public TransitLine(long lineId, String fromStop, String toStop, boolean bus, boolean subway, boolean tram, String lineName, Map<Integer, TransitStop> stopList, Map<Integer, Long> linkList) {
this.lineId = lineId;
this.fromStop = fromStop;
this.toStop = toStop;
this.bus = bus;
this.subway = subway;
this.tram = tram;
this.lineName = lineName;
this.stopList = stopList;
this.linkList = linkList;
}
public long getLineId() {
return lineId;
}
public String getFromStop() {
if (fromStop!=null) {
return fromStop.replace(";", "-");
} else{
return null;
}
}
public String getToStop() {
if (toStop!=null) {
return toStop.replace(";", "-");
} else{
return null;
}
}
public boolean isBus() {
return bus;
}
public boolean isSubway() {
return subway;
}
public boolean isTram() {
return tram;
}
public String getLineName() {
if (lineName!=null) {
return lineName.replace(";", "-");
} else{
return null;
}
}
public Map<Integer, TransitStop> getStopList() {
return stopList;
}
public Map<Integer, Long> getLinkList() {
return linkList;
}
public void setLinkList(Map<Integer, Long> linkList) {
this.linkList = linkList;
}
public void setLineId(long lineId) {
this.lineId = lineId;
}
public double getHeadway() {
return headway;
}
public void setHeadway(double headway) {
this.headway = headway;
}
public LineType getLineType() {
return lineType;
}
public void setLineType(LineType lineType) {
this.lineType = lineType;
}
public boolean isValidity() {
return validity;
}
public void setValidity(boolean validity) {
this.validity = validity;
}
}
| [
"[email protected]"
]
| |
0c4db9e3b07824dcc9056b552a0ca882e6b95851 | 68f7d2d7258bfe0aad96cd98a59cb9ed443576c6 | /rabbitmq/src/main/java/com/jerry/rabbitmq/config/RabbitMQConfig.java | 4d7f95f84258bc5791083daf4b1c3f5b1fbe9315 | []
| no_license | luoyefeiwu/learn_springcloud | 9c325e3ad96774ebca80c1f56af27d116b23bae5 | 4028ab568644bde1744f1a4fc8ff07c5cbd025af | refs/heads/master | 2020-03-27T17:41:06.420525 | 2019-04-08T10:33:01 | 2019-04-08T10:33:01 | 146,866,573 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,411 | java | package com.jerry.rabbitmq.config;
import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
@Configuration
public class RabbitMQConfig {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Value("${spring.rabbitmq.host}")
private String host;
@Value("${spring.rabbitmq.port}")
private int port;
@Value("${spring.rabbitmq.username}")
private String username;
@Value("${spring.rabbitmq.password}")
private String password;
public static final String EXCHANGE_A = "my-mq-exchange_A";
public static final String EXCHANGE_B = "my-mq-exchange_B";
public static final String EXCHANGE_C = "my-mq-exchange_C";
public static final String QUEUE_A = "QUEUE_A";
public static final String QUEUE_B = "QUEUE_B";
public static final String QUEUE_C = "QUEUE_C";
public static final String ROUTINGKEY_A = "spring-boot-routingKey_A";
public static final String ROUTINGKEY_B = "spring-boot-routingKey_B";
public static final String ROUTINGKEY_C = "spring-boot-routingKey_C";
@Bean
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
connectionFactory.setVirtualHost("/");
connectionFactory.setPublisherConfirms(true);
return connectionFactory;
}
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
return template;
}
/**
* 针对消费者配置
* 1. 设置交换机类型
* 2. 将队列绑定到交换机
* FanoutExchange: 将消息分发到所有的绑定队列,无routingkey的概念
* HeadersExchange :通过添加属性key-value匹配
* DirectExchange:按照routingkey分发到指定队列
* TopicExchange:多关键字匹配
*/
@Bean
public DirectExchange defaultExchange() {
return new DirectExchange(EXCHANGE_A);
}
/**
* 获取队列A
*
* @return
*/
@Bean
public Queue queueA() {
return new Queue(QUEUE_A, true); //队列持久
}
/**
* 获取队列A
*
* @return
*/
@Bean
public Queue queueB() {
return new Queue(QUEUE_B, true); //队列持久
}
@Bean
public Binding binding() {
return BindingBuilder.bind(queueA()).to(defaultExchange()).with(RabbitMQConfig.ROUTINGKEY_A);
}
@Bean
public Binding bindingB() {
return BindingBuilder.bind(queueB()).to(defaultExchange()).with(RabbitMQConfig.ROUTINGKEY_B);
}
// @Bean
// public SimpleMessageListenerContainer messageContainer() {
// //加载处理消息A的队列
// SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory());
// //设置接收多个队列里面的消息,这里设置接收队列A
// //假如想一个消费者处理多个队列里面的信息可以如下设置:
// //container.setQueues(queueA(),queueB(),queueC());
// container.setQueues(queueA());
// container.setExposeListenerChannel(true);
// //设置最大的并发的消费者数量
// container.setMaxConcurrentConsumers(10);
// //最小的并发消费者的数量
// container.setConcurrentConsumers(1);
// //设置确认模式手工确认
// container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
// container.setMessageListener(new ChannelAwareMessageListener() {
// @Override
// public void onMessage(Message message, Channel channel) throws Exception {
// /**通过basic.qos方法设置prefetch_count=1,这样RabbitMQ就会使得每个Consumer在同一个时间点最多处理一个Message,
// 换句话说,在接收到该Consumer的ack前,它不会将新的Message分发给它 */
// channel.basicQos(1);
// byte[] body = message.getBody();
// logger.info("接收处理队列A当中的消息:" + new String(body));
// /**为了保证永远不会丢失消息,RabbitMQ支持消息应答机制。
// 当消费者接收到消息并完成任务后会往RabbitMQ服务器发送一条确认的命令,然后RabbitMQ才会将消息删除。*/
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
// }
// });
// return container;
//
// }
}
| [
"[email protected]"
]
| |
80c22b393cd71474c76b3ea5cbb7e64512c6c094 | 35f210c14fceffd8a96bba0219979375fd958b68 | /src/main/java/advanced/collections/composition/Room.java | b0ec9d77be1a87c2421d7c56497679532fb736a7 | []
| no_license | Kiminiute/JavaKlaipeda4 | 513b806ada02c76322374e6a4fea179b90eb2877 | f8977f2508a2c17fbc66dea5ac36208db1564c74 | refs/heads/master | 2023-02-23T21:08:34.279993 | 2021-01-04T17:33:58 | 2021-01-04T17:33:58 | 319,025,146 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 193 | java | package advanced.collections.composition;
public class Room {
private Bed bed;
private Tv tv;
public Room(Bed bed, Tv tv){
this.bed = bed;
this.tv = tv;
}
}
| [
"[email protected]"
]
| |
4d59c581b357d11ab545f5a00192829068423203 | 48589a0dc2bab74cb2005060f860bf51946b1bc2 | /src/test/java/eu/bitwalker/jhreactdemo/web/rest/AccountResourceIT.java | 218a24e74820233d7717fd4121a3c4829328a3f1 | []
| no_license | HaraldWalker/jhreactdemo | f21265aa2f76e32f772721f9d1564c438fca7dcc | 967eb7f3ed273139d6e29b686588bb2c7396d098 | refs/heads/master | 2023-05-26T22:43:23.956167 | 2021-06-12T12:57:50 | 2021-06-12T12:57:50 | 376,283,797 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 32,826 | java | package eu.bitwalker.jhreactdemo.web.rest;
import static eu.bitwalker.jhreactdemo.web.rest.AccountResourceIT.TEST_USER_LOGIN;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import eu.bitwalker.jhreactdemo.IntegrationTest;
import eu.bitwalker.jhreactdemo.config.Constants;
import eu.bitwalker.jhreactdemo.domain.User;
import eu.bitwalker.jhreactdemo.repository.AuthorityRepository;
import eu.bitwalker.jhreactdemo.repository.UserRepository;
import eu.bitwalker.jhreactdemo.security.AuthoritiesConstants;
import eu.bitwalker.jhreactdemo.service.UserService;
import eu.bitwalker.jhreactdemo.service.dto.AdminUserDTO;
import eu.bitwalker.jhreactdemo.service.dto.PasswordChangeDTO;
import eu.bitwalker.jhreactdemo.service.dto.UserDTO;
import eu.bitwalker.jhreactdemo.web.rest.vm.KeyAndPasswordVM;
import eu.bitwalker.jhreactdemo.web.rest.vm.ManagedUserVM;
import java.time.Instant;
import java.util.*;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
/**
* Integration tests for the {@link AccountResource} REST controller.
*/
@AutoConfigureMockMvc
@WithMockUser(value = TEST_USER_LOGIN)
@IntegrationTest
class AccountResourceIT {
static final String TEST_USER_LOGIN = "test";
@Autowired
private UserRepository userRepository;
@Autowired
private AuthorityRepository authorityRepository;
@Autowired
private UserService userService;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private MockMvc restAccountMockMvc;
@Test
@WithUnauthenticatedMockUser
void testNonAuthenticatedUser() throws Exception {
restAccountMockMvc
.perform(get("/api/authenticate").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(""));
}
@Test
void testAuthenticatedUser() throws Exception {
restAccountMockMvc
.perform(
get("/api/authenticate")
.with(
request -> {
request.setRemoteUser(TEST_USER_LOGIN);
return request;
}
)
.accept(MediaType.APPLICATION_JSON)
)
.andExpect(status().isOk())
.andExpect(content().string(TEST_USER_LOGIN));
}
@Test
void testGetExistingAccount() throws Exception {
Set<String> authorities = new HashSet<>();
authorities.add(AuthoritiesConstants.ADMIN);
AdminUserDTO user = new AdminUserDTO();
user.setLogin(TEST_USER_LOGIN);
user.setFirstName("john");
user.setLastName("doe");
user.setEmail("[email protected]");
user.setImageUrl("http://placehold.it/50x50");
user.setLangKey("en");
user.setAuthorities(authorities);
userService.createUser(user);
restAccountMockMvc
.perform(get("/api/account").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.login").value(TEST_USER_LOGIN))
.andExpect(jsonPath("$.firstName").value("john"))
.andExpect(jsonPath("$.lastName").value("doe"))
.andExpect(jsonPath("$.email").value("[email protected]"))
.andExpect(jsonPath("$.imageUrl").value("http://placehold.it/50x50"))
.andExpect(jsonPath("$.langKey").value("en"))
.andExpect(jsonPath("$.authorities").value(AuthoritiesConstants.ADMIN));
}
@Test
void testGetUnknownAccount() throws Exception {
restAccountMockMvc
.perform(get("/api/account").accept(MediaType.APPLICATION_PROBLEM_JSON))
.andExpect(status().isInternalServerError());
}
@Test
@Transactional
void testRegisterValid() throws Exception {
ManagedUserVM validUser = new ManagedUserVM();
validUser.setLogin("test-register-valid");
validUser.setPassword("password");
validUser.setFirstName("Alice");
validUser.setLastName("Test");
validUser.setEmail("[email protected]");
validUser.setImageUrl("http://placehold.it/50x50");
validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
assertThat(userRepository.findOneByLogin("test-register-valid")).isEmpty();
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(validUser)))
.andExpect(status().isCreated());
assertThat(userRepository.findOneByLogin("test-register-valid")).isPresent();
}
@Test
@Transactional
void testRegisterInvalidLogin() throws Exception {
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin("funky-log(n"); // <-- invalid
invalidUser.setPassword("password");
invalidUser.setFirstName("Funky");
invalidUser.setLastName("One");
invalidUser.setEmail("[email protected]");
invalidUser.setActivated(true);
invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(invalidUser)))
.andExpect(status().isBadRequest());
Optional<User> user = userRepository.findOneByEmailIgnoreCase("[email protected]");
assertThat(user).isEmpty();
}
@Test
@Transactional
void testRegisterInvalidEmail() throws Exception {
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin("bob");
invalidUser.setPassword("password");
invalidUser.setFirstName("Bob");
invalidUser.setLastName("Green");
invalidUser.setEmail("invalid"); // <-- invalid
invalidUser.setActivated(true);
invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(invalidUser)))
.andExpect(status().isBadRequest());
Optional<User> user = userRepository.findOneByLogin("bob");
assertThat(user).isEmpty();
}
@Test
@Transactional
void testRegisterInvalidPassword() throws Exception {
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin("bob");
invalidUser.setPassword("123"); // password with only 3 digits
invalidUser.setFirstName("Bob");
invalidUser.setLastName("Green");
invalidUser.setEmail("[email protected]");
invalidUser.setActivated(true);
invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(invalidUser)))
.andExpect(status().isBadRequest());
Optional<User> user = userRepository.findOneByLogin("bob");
assertThat(user).isEmpty();
}
@Test
@Transactional
void testRegisterNullPassword() throws Exception {
ManagedUserVM invalidUser = new ManagedUserVM();
invalidUser.setLogin("bob");
invalidUser.setPassword(null); // invalid null password
invalidUser.setFirstName("Bob");
invalidUser.setLastName("Green");
invalidUser.setEmail("[email protected]");
invalidUser.setActivated(true);
invalidUser.setImageUrl("http://placehold.it/50x50");
invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(invalidUser)))
.andExpect(status().isBadRequest());
Optional<User> user = userRepository.findOneByLogin("bob");
assertThat(user).isEmpty();
}
@Test
@Transactional
void testRegisterDuplicateLogin() throws Exception {
// First registration
ManagedUserVM firstUser = new ManagedUserVM();
firstUser.setLogin("alice");
firstUser.setPassword("password");
firstUser.setFirstName("Alice");
firstUser.setLastName("Something");
firstUser.setEmail("[email protected]");
firstUser.setImageUrl("http://placehold.it/50x50");
firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
// Duplicate login, different email
ManagedUserVM secondUser = new ManagedUserVM();
secondUser.setLogin(firstUser.getLogin());
secondUser.setPassword(firstUser.getPassword());
secondUser.setFirstName(firstUser.getFirstName());
secondUser.setLastName(firstUser.getLastName());
secondUser.setEmail("[email protected]");
secondUser.setImageUrl(firstUser.getImageUrl());
secondUser.setLangKey(firstUser.getLangKey());
secondUser.setCreatedBy(firstUser.getCreatedBy());
secondUser.setCreatedDate(firstUser.getCreatedDate());
secondUser.setLastModifiedBy(firstUser.getLastModifiedBy());
secondUser.setLastModifiedDate(firstUser.getLastModifiedDate());
secondUser.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
// First user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(firstUser)))
.andExpect(status().isCreated());
// Second (non activated) user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(secondUser)))
.andExpect(status().isCreated());
Optional<User> testUser = userRepository.findOneByEmailIgnoreCase("[email protected]");
assertThat(testUser).isPresent();
testUser.get().setActivated(true);
userRepository.save(testUser.get());
// Second (already activated) user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(secondUser)))
.andExpect(status().is4xxClientError());
}
@Test
@Transactional
void testRegisterDuplicateEmail() throws Exception {
// First user
ManagedUserVM firstUser = new ManagedUserVM();
firstUser.setLogin("test-register-duplicate-email");
firstUser.setPassword("password");
firstUser.setFirstName("Alice");
firstUser.setLastName("Test");
firstUser.setEmail("[email protected]");
firstUser.setImageUrl("http://placehold.it/50x50");
firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
// Register first user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(firstUser)))
.andExpect(status().isCreated());
Optional<User> testUser1 = userRepository.findOneByLogin("test-register-duplicate-email");
assertThat(testUser1).isPresent();
// Duplicate email, different login
ManagedUserVM secondUser = new ManagedUserVM();
secondUser.setLogin("test-register-duplicate-email-2");
secondUser.setPassword(firstUser.getPassword());
secondUser.setFirstName(firstUser.getFirstName());
secondUser.setLastName(firstUser.getLastName());
secondUser.setEmail(firstUser.getEmail());
secondUser.setImageUrl(firstUser.getImageUrl());
secondUser.setLangKey(firstUser.getLangKey());
secondUser.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
// Register second (non activated) user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(secondUser)))
.andExpect(status().isCreated());
Optional<User> testUser2 = userRepository.findOneByLogin("test-register-duplicate-email");
assertThat(testUser2).isEmpty();
Optional<User> testUser3 = userRepository.findOneByLogin("test-register-duplicate-email-2");
assertThat(testUser3).isPresent();
// Duplicate email - with uppercase email address
ManagedUserVM userWithUpperCaseEmail = new ManagedUserVM();
userWithUpperCaseEmail.setId(firstUser.getId());
userWithUpperCaseEmail.setLogin("test-register-duplicate-email-3");
userWithUpperCaseEmail.setPassword(firstUser.getPassword());
userWithUpperCaseEmail.setFirstName(firstUser.getFirstName());
userWithUpperCaseEmail.setLastName(firstUser.getLastName());
userWithUpperCaseEmail.setEmail("[email protected]");
userWithUpperCaseEmail.setImageUrl(firstUser.getImageUrl());
userWithUpperCaseEmail.setLangKey(firstUser.getLangKey());
userWithUpperCaseEmail.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
// Register third (not activated) user
restAccountMockMvc
.perform(
post("/api/register")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(userWithUpperCaseEmail))
)
.andExpect(status().isCreated());
Optional<User> testUser4 = userRepository.findOneByLogin("test-register-duplicate-email-3");
assertThat(testUser4).isPresent();
assertThat(testUser4.get().getEmail()).isEqualTo("[email protected]");
testUser4.get().setActivated(true);
userService.updateUser((new AdminUserDTO(testUser4.get())));
// Register 4th (already activated) user
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(secondUser)))
.andExpect(status().is4xxClientError());
}
@Test
@Transactional
void testRegisterAdminIsIgnored() throws Exception {
ManagedUserVM validUser = new ManagedUserVM();
validUser.setLogin("badguy");
validUser.setPassword("password");
validUser.setFirstName("Bad");
validUser.setLastName("Guy");
validUser.setEmail("[email protected]");
validUser.setActivated(true);
validUser.setImageUrl("http://placehold.it/50x50");
validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
restAccountMockMvc
.perform(post("/api/register").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(validUser)))
.andExpect(status().isCreated());
Optional<User> userDup = userRepository.findOneWithAuthoritiesByLogin("badguy");
assertThat(userDup).isPresent();
assertThat(userDup.get().getAuthorities())
.hasSize(1)
.containsExactly(authorityRepository.findById(AuthoritiesConstants.USER).get());
}
@Test
@Transactional
void testActivateAccount() throws Exception {
final String activationKey = "some activation key";
User user = new User();
user.setLogin("activate-account");
user.setEmail("[email protected]");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(false);
user.setActivationKey(activationKey);
userRepository.saveAndFlush(user);
restAccountMockMvc.perform(get("/api/activate?key={activationKey}", activationKey)).andExpect(status().isOk());
user = userRepository.findOneByLogin(user.getLogin()).orElse(null);
assertThat(user.isActivated()).isTrue();
}
@Test
@Transactional
void testActivateAccountWithWrongKey() throws Exception {
restAccountMockMvc.perform(get("/api/activate?key=wrongActivationKey")).andExpect(status().isInternalServerError());
}
@Test
@Transactional
@WithMockUser("save-account")
void testSaveAccount() throws Exception {
User user = new User();
user.setLogin("save-account");
user.setEmail("[email protected]");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
userRepository.saveAndFlush(user);
AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
userDTO.setFirstName("firstname");
userDTO.setLastName("lastname");
userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
userDTO.setImageUrl("http://placehold.it/50x50");
userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
restAccountMockMvc
.perform(post("/api/account").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(userDTO)))
.andExpect(status().isOk());
User updatedUser = userRepository.findOneWithAuthoritiesByLogin(user.getLogin()).orElse(null);
assertThat(updatedUser.getFirstName()).isEqualTo(userDTO.getFirstName());
assertThat(updatedUser.getLastName()).isEqualTo(userDTO.getLastName());
assertThat(updatedUser.getEmail()).isEqualTo(userDTO.getEmail());
assertThat(updatedUser.getLangKey()).isEqualTo(userDTO.getLangKey());
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
assertThat(updatedUser.getImageUrl()).isEqualTo(userDTO.getImageUrl());
assertThat(updatedUser.isActivated()).isTrue();
assertThat(updatedUser.getAuthorities()).isEmpty();
}
@Test
@Transactional
@WithMockUser("save-invalid-email")
void testSaveInvalidEmail() throws Exception {
User user = new User();
user.setLogin("save-invalid-email");
user.setEmail("[email protected]");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
userRepository.saveAndFlush(user);
AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
userDTO.setFirstName("firstname");
userDTO.setLastName("lastname");
userDTO.setEmail("invalid email");
userDTO.setActivated(false);
userDTO.setImageUrl("http://placehold.it/50x50");
userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
restAccountMockMvc
.perform(post("/api/account").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(userDTO)))
.andExpect(status().isBadRequest());
assertThat(userRepository.findOneByEmailIgnoreCase("invalid email")).isNotPresent();
}
@Test
@Transactional
@WithMockUser("save-existing-email")
void testSaveExistingEmail() throws Exception {
User user = new User();
user.setLogin("save-existing-email");
user.setEmail("[email protected]");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
userRepository.saveAndFlush(user);
User anotherUser = new User();
anotherUser.setLogin("save-existing-email2");
anotherUser.setEmail("[email protected]");
anotherUser.setPassword(RandomStringUtils.random(60));
anotherUser.setActivated(true);
userRepository.saveAndFlush(anotherUser);
AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
userDTO.setFirstName("firstname");
userDTO.setLastName("lastname");
userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
userDTO.setImageUrl("http://placehold.it/50x50");
userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
restAccountMockMvc
.perform(post("/api/account").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(userDTO)))
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("save-existing-email").orElse(null);
assertThat(updatedUser.getEmail()).isEqualTo("[email protected]");
}
@Test
@Transactional
@WithMockUser("save-existing-email-and-login")
void testSaveExistingEmailAndLogin() throws Exception {
User user = new User();
user.setLogin("save-existing-email-and-login");
user.setEmail("[email protected]");
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
userRepository.saveAndFlush(user);
AdminUserDTO userDTO = new AdminUserDTO();
userDTO.setLogin("not-used");
userDTO.setFirstName("firstname");
userDTO.setLastName("lastname");
userDTO.setEmail("[email protected]");
userDTO.setActivated(false);
userDTO.setImageUrl("http://placehold.it/50x50");
userDTO.setLangKey(Constants.DEFAULT_LANGUAGE);
userDTO.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
restAccountMockMvc
.perform(post("/api/account").contentType(MediaType.APPLICATION_JSON).content(TestUtil.convertObjectToJsonBytes(userDTO)))
.andExpect(status().isOk());
User updatedUser = userRepository.findOneByLogin("save-existing-email-and-login").orElse(null);
assertThat(updatedUser.getEmail()).isEqualTo("[email protected]");
}
@Test
@Transactional
@WithMockUser("change-password-wrong-existing-password")
void testChangePasswordWrongExistingPassword() throws Exception {
User user = new User();
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password-wrong-existing-password");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
restAccountMockMvc
.perform(
post("/api/account/change-password")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO("1" + currentPassword, "new password")))
)
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("change-password-wrong-existing-password").orElse(null);
assertThat(passwordEncoder.matches("new password", updatedUser.getPassword())).isFalse();
assertThat(passwordEncoder.matches(currentPassword, updatedUser.getPassword())).isTrue();
}
@Test
@Transactional
@WithMockUser("change-password")
void testChangePassword() throws Exception {
User user = new User();
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
restAccountMockMvc
.perform(
post("/api/account/change-password")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO(currentPassword, "new password")))
)
.andExpect(status().isOk());
User updatedUser = userRepository.findOneByLogin("change-password").orElse(null);
assertThat(passwordEncoder.matches("new password", updatedUser.getPassword())).isTrue();
}
@Test
@Transactional
@WithMockUser("change-password-too-small")
void testChangePasswordTooSmall() throws Exception {
User user = new User();
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password-too-small");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
String newPassword = RandomStringUtils.random(ManagedUserVM.PASSWORD_MIN_LENGTH - 1);
restAccountMockMvc
.perform(
post("/api/account/change-password")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO(currentPassword, newPassword)))
)
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("change-password-too-small").orElse(null);
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
}
@Test
@Transactional
@WithMockUser("change-password-too-long")
void testChangePasswordTooLong() throws Exception {
User user = new User();
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password-too-long");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
String newPassword = RandomStringUtils.random(ManagedUserVM.PASSWORD_MAX_LENGTH + 1);
restAccountMockMvc
.perform(
post("/api/account/change-password")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO(currentPassword, newPassword)))
)
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("change-password-too-long").orElse(null);
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
}
@Test
@Transactional
@WithMockUser("change-password-empty")
void testChangePasswordEmpty() throws Exception {
User user = new User();
String currentPassword = RandomStringUtils.random(60);
user.setPassword(passwordEncoder.encode(currentPassword));
user.setLogin("change-password-empty");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
restAccountMockMvc
.perform(
post("/api/account/change-password")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(new PasswordChangeDTO(currentPassword, "")))
)
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin("change-password-empty").orElse(null);
assertThat(updatedUser.getPassword()).isEqualTo(user.getPassword());
}
@Test
@Transactional
void testRequestPasswordReset() throws Exception {
User user = new User();
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
user.setLogin("password-reset");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
restAccountMockMvc
.perform(post("/api/account/reset-password/init").content("[email protected]"))
.andExpect(status().isOk());
}
@Test
@Transactional
void testRequestPasswordResetUpperCaseEmail() throws Exception {
User user = new User();
user.setPassword(RandomStringUtils.random(60));
user.setActivated(true);
user.setLogin("password-reset-upper-case");
user.setEmail("[email protected]");
userRepository.saveAndFlush(user);
restAccountMockMvc
.perform(post("/api/account/reset-password/init").content("[email protected]"))
.andExpect(status().isOk());
}
@Test
void testRequestPasswordResetWrongEmail() throws Exception {
restAccountMockMvc
.perform(post("/api/account/reset-password/init").content("[email protected]"))
.andExpect(status().isOk());
}
@Test
@Transactional
void testFinishPasswordReset() throws Exception {
User user = new User();
user.setPassword(RandomStringUtils.random(60));
user.setLogin("finish-password-reset");
user.setEmail("[email protected]");
user.setResetDate(Instant.now().plusSeconds(60));
user.setResetKey("reset key");
userRepository.saveAndFlush(user);
KeyAndPasswordVM keyAndPassword = new KeyAndPasswordVM();
keyAndPassword.setKey(user.getResetKey());
keyAndPassword.setNewPassword("new password");
restAccountMockMvc
.perform(
post("/api/account/reset-password/finish")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(keyAndPassword))
)
.andExpect(status().isOk());
User updatedUser = userRepository.findOneByLogin(user.getLogin()).orElse(null);
assertThat(passwordEncoder.matches(keyAndPassword.getNewPassword(), updatedUser.getPassword())).isTrue();
}
@Test
@Transactional
void testFinishPasswordResetTooSmall() throws Exception {
User user = new User();
user.setPassword(RandomStringUtils.random(60));
user.setLogin("finish-password-reset-too-small");
user.setEmail("[email protected]");
user.setResetDate(Instant.now().plusSeconds(60));
user.setResetKey("reset key too small");
userRepository.saveAndFlush(user);
KeyAndPasswordVM keyAndPassword = new KeyAndPasswordVM();
keyAndPassword.setKey(user.getResetKey());
keyAndPassword.setNewPassword("foo");
restAccountMockMvc
.perform(
post("/api/account/reset-password/finish")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(keyAndPassword))
)
.andExpect(status().isBadRequest());
User updatedUser = userRepository.findOneByLogin(user.getLogin()).orElse(null);
assertThat(passwordEncoder.matches(keyAndPassword.getNewPassword(), updatedUser.getPassword())).isFalse();
}
@Test
@Transactional
void testFinishPasswordResetWrongKey() throws Exception {
KeyAndPasswordVM keyAndPassword = new KeyAndPasswordVM();
keyAndPassword.setKey("wrong reset key");
keyAndPassword.setNewPassword("new password");
restAccountMockMvc
.perform(
post("/api/account/reset-password/finish")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(keyAndPassword))
)
.andExpect(status().isInternalServerError());
}
}
| [
"[email protected]"
]
| |
d599aefdaf08d039f81e80100e09ad398a333b78 | f7203a7d877e552e31ba2837dcad60d63d082c67 | /src/main/java/vn/locdt/jquestion/util/OsUtils.java | fec9a0bd5c777554a7bd2c4c00a73728794ed6ef | [
"Apache-2.0"
]
| permissive | dinhtienloc/jquestion | 824b6bd2e029fd3eb67215ff1286b1aa3026a170 | 672e8e34f2408dd423a7c5766bb7e2e2f5483318 | refs/heads/master | 2021-05-06T01:41:37.148676 | 2019-12-18T18:50:41 | 2019-12-18T18:50:41 | 114,452,330 | 1 | 0 | Apache-2.0 | 2020-10-13T18:16:35 | 2017-12-16T10:31:11 | Java | UTF-8 | Java | false | false | 419 | java | package vn.locdt.jquestion.util;
public class OsUtils {
private final static String OS = System.getProperty("os.name");
public static boolean isWindowOS() {
return OS.startsWith("Windows");
}
public static boolean isMac() {
return OS.contains("mac");
}
public static boolean isUnix() {
return (OS.contains("nix") || OS.contains("nux") || OS.contains("aix"));
}
}
| [
"Hakiem09"
]
| Hakiem09 |
61c73b4c7e5e951eb3776197ce03d64f45ff3c15 | 9d1fc985da1131009cd752d68062783c2e29e60e | /app/src/main/java/com/example/motoheal/MainActivity.java | 2d63bc7112ef9a912a3a53b1bc5e7a5c5d06f854 | []
| no_license | sushant192/My-Service-app | f343c2a02d541f7565523c6df1b541af5e14ea6f | 8826fceb2710509c18f3a075ae7ffab6486e64d4 | refs/heads/master | 2023-06-26T17:32:37.750311 | 2021-07-21T15:08:21 | 2021-07-21T15:08:21 | 388,156,059 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 705 | java | package com.example.motoheal;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class MainActivity extends AppCompatActivity {
private static final int time=3300;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i=new Intent(MainActivity.this,MainActivity3.class);
startActivity(i);
finish();
}
},time);
}
} | [
"[email protected]"
]
| |
ff117b2a83665a871a03c4f3c60980cfd677c915 | 261e6bbe8da52787b06cd79b4990d9c4c5cfa77e | /app/src/main/java/com/example/educor_app/Authentications/SendOTP.java | e56a6e8ab51c7c3773d342e5d2860e1e9b94b95d | []
| no_license | johnsolomon1610/Educor_app | 43ad391793b1c3cb2fb7345fbf2c12dcd0b9eee5 | e3f37b59802c0e3a1e8f39868c661c2b0ff5ba57 | refs/heads/master | 2023-08-18T20:53:37.294003 | 2021-10-06T09:49:23 | 2021-10-06T09:49:23 | 414,104,599 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,128 | java | package com.example.educor_app.Authentications;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.airbnb.lottie.LottieAnimationView;
import com.example.educor_app.R;
import com.google.firebase.FirebaseException;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.PhoneAuthCredential;
import com.google.firebase.auth.PhoneAuthProvider;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import static java.util.Objects.*;
public class SendOTP extends AppCompatActivity {
EditText editTextPhone;
Button buttonContinue;
FirebaseAuth mAuth;
FirebaseDatabase database;
DatabaseReference databaseReference;
public static String Phone;
public ImageView send;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_send_o_t_p);
editTextPhone = findViewById(R.id.inputMobile);
buttonContinue = findViewById(R.id.getOTP);
send=findViewById(R.id.send);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
databaseReference = FirebaseDatabase.getInstance().getReference().child("signup").child(user.getUid());
databaseReference.addValueEventListener(new ValueEventListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
// Phone = (Objects.<Object>requireNonNull(dataSnapshot.child("MobileNumber").getValue()).toString());
if(dataSnapshot.exists()) {
Phone = (Objects.requireNonNull(dataSnapshot.child("MobileNumber").getValue()).toString());
}else {
Toast.makeText(SendOTP.this,"Data doesnt exists",Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
buttonContinue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkConnection();
/* */
}
});
}
public void checkConnection(){
ConnectivityManager manager=(ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork= manager.getActiveNetworkInfo();
if (null==activeNetwork){
Intent intent=new Intent(SendOTP.this,network_indicator.class);
intent.putExtra("from","SendOTP");
startActivity(intent);
finish();
}else{
String code = "+91";
String number = editTextPhone.getText().toString().trim();
if (number.isEmpty() || number.length() < 10) {
editTextPhone.setError("Valid number is required");
editTextPhone.requestFocus();
return;
}
String phoneNumber = code + number;
if (Phone.equals(number)){
final LottieAnimationView lottiePreloader=findViewById(R.id.lottie_send);
send.setVisibility(View.INVISIBLE);
lottiePreloader.setVisibility(View.VISIBLE);
lottiePreloader.setSpeed(1);
lottiePreloader.playAnimation();
Thread timer = new Thread() {
public void run() {
try {
sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent intent = new Intent(SendOTP.this, VerifyOTP.class);
intent.putExtra("phoneNumber", phoneNumber);
startActivity(intent);
finish();
}
}
};
timer.start();
/* */
}else{
Toast.makeText(SendOTP.this,"Mobile number you have entered currently doesn't match with your registered mobile number!",Toast.LENGTH_LONG).show();
}
}
}
} | [
"[email protected]"
]
| |
cc0a536720e80ca89fee4a585131fb2258fbb61e | f52d89e3adb2b7f5dc84337362e4f8930b3fe1c2 | /com.fudanmed.platform.core.web/src/main/java/com/fudanmed/platform/core/web/client/project/FaultTypeListViewRenderTemplate.java | 13d77361bf220220d12f61f5de273ebdffd9920a | []
| no_license | rockguo2015/med | a4442d195e04f77c6c82c4b82b9942b6c5272892 | b3db5a4943e190370a20cc4fac8faf38053ae6ae | refs/heads/master | 2016-09-08T01:30:54.179514 | 2015-05-18T10:23:02 | 2015-05-18T10:23:02 | 34,060,096 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 710 | java | package com.fudanmed.platform.core.web.client.project;
import com.fudanmed.platform.core.web.shared.project.UIFaultType;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.XTemplates.XTemplate;
public interface FaultTypeListViewRenderTemplate extends XTemplates {
@XTemplate("<div><div style=\'float:left\'><span style=\'font-size:120%;font-weight:bold;\'>{ft.name}</span><BR>\u5DE5\u65F6:{ft.standardCostTime},\u7EE9\u6548:{ft.performanceWeight},\u98CE\u9669\u7B49\u7EA7:{ft.faultRiskLevel.name}</div> <div style=\'width:100px;float:right\'>{ft.teamName}</div></div>")
public abstract SafeHtml render(final UIFaultType ft);
}
| [
"[email protected]"
]
| |
b434b703bf8cdf2f4f09ec104bf95a1fba04e8ed | 50c937c8a203a5ca3a26f70980173a5a898da9e3 | /l2gw-core/highfive/gameserver/java/ru/l2gw/gameserver/taskmanager/AutoSaveManager.java | 2cea7d83e966cba58ae6932a8df49c4f3a88cc53 | []
| no_license | gokusgit/hi5 | b336cc8bf96b74cbd9419253444cf0a7df71a2fb | 0345266a3cb3059b3e4e5ec31b59690af36e07fd | refs/heads/master | 2020-07-10T23:33:14.500298 | 2019-08-26T07:41:18 | 2019-08-26T07:41:18 | 204,398,114 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,793 | java | package ru.l2gw.gameserver.taskmanager;
import org.apache.commons.logging.LogFactory;
import ru.l2gw.gameserver.Config;
import ru.l2gw.gameserver.controllers.ThreadPoolManager;
import ru.l2gw.gameserver.model.L2ObjectsStorage;
import ru.l2gw.gameserver.model.L2Player;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
public class AutoSaveManager
{
protected static org.apache.commons.logging.Log _log = LogFactory.getLog("autoSaveManager");
private static String _logFile = "autoSaveManager";
private static AutoSaveManager _instance;
private static ScheduledFuture<AutoSaveTask> _autoSaveTask = null;
private class SaveInfo
{
public int _objectId;
public long _lastSaveTime;
public String _HWID = "";
public SaveInfo(final int objectId, final String HWID)
{
_objectId = objectId;
_lastSaveTime = System.currentTimeMillis();
_HWID = HWID;
}
}
private static ConcurrentHashMap<Integer, SaveInfo> _objects = new ConcurrentHashMap<Integer, SaveInfo>();
class AutoSaveTask implements Runnable
{
public void run()
{
long time = System.currentTimeMillis();
for(final SaveInfo object : _objects.values())
if(time - object._lastSaveTime >= Config.CHAR_SAVE_INTERVAL)
{
try
{
L2Player pl = L2ObjectsStorage.getPlayer(object._objectId);
if(!pl.isLogoutStarted() || !pl.isEntering())
pl.saveCharToDisk();
object._lastSaveTime = time;
}
catch(final Exception e)
{
try
{
_objects.remove(object._objectId);
_log.info(object + " remove from task");
}
catch(final Exception e2)
{
_log.warn(object + " can't remove", e2);
}
}
}
time = System.currentTimeMillis() - time;
if(time > Config.TASK_SAVE_INTERVAL)
_log.info("ALERT! TASK_SAVE_INTERVAL is too small, time to save characters in Queue = " + time);
}
}
public void addPlayer(final L2Player player, final String HWID)
{
if(_objects.contains(player.getObjectId()))
_log.warn(player + " already added!");
else
_objects.put(player.getObjectId(), new SaveInfo(player.getObjectId(), HWID));
_log.info(player + " add hwid: " + HWID);
}
public void removePlayer(final L2Player player)
{
if(_objects.contains(player.getObjectId()))
_log.info(player + " no exists");
else
{
_objects.remove(player.getObjectId());
player.saveCharToDisk();
_log.info(player + " removed");
}
}
public AutoSaveManager()
{
startAutoSaveTask();
}
public static void Shutdown()
{
stopAutoSaveTask(false);
}
public static AutoSaveManager getInstance()
{
if(_instance == null)
{
_log.info("Initializing AutoSaveManager");
_instance = new AutoSaveManager();
}
return _instance;
}
public void startAutoSaveTask()
{
stopAutoSaveTask(true);
_autoSaveTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoSaveTask(), Config.TASK_SAVE_INTERVAL, Config.TASK_SAVE_INTERVAL);
}
public static void stopAutoSaveTask(final boolean mayInterruptIfRunning)
{
if(_autoSaveTask != null)
{
_autoSaveTask.cancel(mayInterruptIfRunning);
_autoSaveTask = null;
}
}
public int getCountByHWID(final String HWID)
{
int result = 0;
for(final SaveInfo object : _objects.values())
{
if(object._HWID.equals(HWID))
result++;
}
return result;
}
public ArrayList<String> getNamesByHWID(final String HWID)
{
final ArrayList<String> names = new ArrayList<String>();
for(final SaveInfo object : _objects.values())
{
if(object._HWID.equals(HWID))
{
final L2Player player = L2ObjectsStorage.getPlayer(object._objectId);
if(player != null)
names.add(player.getName());
}
}
return names;
}
}
| [
"[email protected]"
]
| |
64895fe0e0fc83c0b551afb5f49d989ca90d4141 | 17be833988fef16b819878fe624d8750f5ad1a6d | /hystrix-client-consum/src/main/java/com/zhouhc/hystrixclientconsum/consum/command/UserToObservableCommand.java | 9845ea55a22605c6db00f21b2c4199a1462347fe | []
| no_license | XZTJJ/spring-cloud-action | 20a42ecda2b64b9e91c3c0566e339c859f01588d | 924ea626ed67423ff0260b180842bcc274439f1a | refs/heads/master | 2021-03-20T12:16:40.603841 | 2020-05-16T03:39:42 | 2020-05-16T03:39:42 | 247,205,208 | 0 | 0 | null | 2020-10-13T21:45:44 | 2020-03-14T03:34:50 | Java | UTF-8 | Java | false | false | 3,490 | java | package com.zhouhc.hystrixclientconsum.consum.command;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixObservableCommand;
import com.netflix.hystrix.HystrixRequestCache;
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategyDefault;
import com.zhouhc.hystrixclientconsum.consum.pojo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
import rx.Observable;
import rx.Subscriber;
import java.util.concurrent.TimeUnit;
//使用响应式的开发,一次性返回多条数据
public class UserToObservableCommand extends HystrixObservableCommand<User> {
private Logger logger = LoggerFactory.getLogger(getClass());
//缓存命令
private static final HystrixCommandKey GETTER_KEY = HystrixCommandKey.Factory.asKey("UserObservableCommand");
private RestTemplate restTemplate;
private String[] ids;
public UserToObservableCommand(RestTemplate restTemplate, String[] ids) {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("UserCommandGroup")).andCommandKey(GETTER_KEY));
this.restTemplate = restTemplate;
this.ids = ids;
}
@Override
protected Observable<User> construct() {
return Observable.create(new Observable.OnSubscribe<User>() {
@Override
public void call(Subscriber<? super User> subscriber) {
try {
//表示没有取消
if (!subscriber.isUnsubscribed()) {
for (String id : ids) {
User userObject = restTemplate.getForObject("http://HYSTRIX-CLIENT-PROVIDE/hystrix/findUser?id={1}", User.class, id);
//模拟网络故障
//TimeUnit.MILLISECONDS.sleep(3000);
//表示进行下一个的操作
subscriber.onNext(userObject);
}
subscriber.onCompleted();
}
} catch (Exception e) {
logger.error("聚合时发生错误");
}
}
});
}
//降级服务
@Override
protected Observable<User> resumeWithFallback() {
return Observable.create(new Observable.OnSubscribe<User>() {
@Override
public void call(Subscriber<? super User> subscriber) {
try {
//表示没有取消
if (!subscriber.isUnsubscribed()) {
User userObject = new User("UserToObservableCommand","UserToObservableCommand","UserToObservableCommand");
//表示进行下一个的操作
subscriber.onNext(userObject);
subscriber.onCompleted();
}
} catch (Exception e) {
logger.error("聚合时发生错误");
}
}
});
}
//使用缓存
@Override
protected String getCacheKey() {
String idsKey = "";
for (String id : ids)
idsKey += id;
return String.valueOf(idsKey);
}
//缓存清除
public static void flushCache(String id){
HystrixRequestCache.getInstance(GETTER_KEY, HystrixConcurrencyStrategyDefault.getInstance()).clear(id);
}
}
| [
"[email protected]"
]
| |
73dc9b0252b5464e771556a853d219945e4c0ab1 | 51cfe3fd3339f5ec5abae8610da98b53c3855b5b | /java assessment2/src/com/dev/gmail/MessageInterface.java | 7bca10c400c61e7bcb893b66870e781c60068f14 | []
| no_license | mithunshaiva7/assessment2 | 0d974b2af9d7ad68a7603e585112e841dc0e137f | 12b8b7e4f3dad9745c3e291eb59b9100e02bf6d6 | refs/heads/master | 2020-07-30T17:35:21.260308 | 2019-09-23T08:43:54 | 2019-09-23T08:43:54 | 210,305,075 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 167 | java | package com.dev.gmail;
public interface MessageInterface {
public boolean storeMessage(String emailId, Message message);
public boolean display(String emailId);
}
| [
"[email protected]"
]
| |
61aaca7dee4021fc087d25e6c57bd578d1715fad | 515cfd343b72a7839c9d9e5497960e279fa792c4 | /app/src/main/java/com/fiek/regionalsnowforecast/FavResortsDBValues.java | 34d14fde02710b86a380c83f4bb5b1aa7e9004c6 | []
| no_license | lorentmustafa/RegionalSnowForecast-MP | aebf3dd5f16de2422512c47b45e5032174a7f4c1 | 4980f41e76b86c4cbc1a343d71761e5a24c7a3ef | refs/heads/master | 2022-11-09T09:45:55.258252 | 2020-06-28T15:29:01 | 2020-06-28T15:29:01 | 263,760,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package com.fiek.regionalsnowforecast;
public class FavResortsDBValues {
public static final String userId = "uid";
public static final String resort1 = "resort1";
public static final String resort2 = "resort2";
public static final String resort3 = "resort3";
public static final String resort4 = "resort4";
public static final String resort5 = "resort5";
}
| [
"[email protected]"
]
| |
0694d971ee88f604e08a6eb46f8c3e2a2872af6f | d07a288ec285c188279f166725e6d9b52e2be66e | /src/com/clowd/ld37/level/Level1.java | ae901079c3cb1186e4f365896f3852f82bc467c2 | []
| no_license | Jasyuid/MazeFrenzy | 83bb75dd047bab265de3d6e4360d29df1961d803 | d3964406cb3d348e3b92a2a9d27af2871efb6c99 | refs/heads/master | 2021-01-12T08:18:08.282687 | 2020-07-28T06:02:06 | 2020-07-28T06:02:06 | 76,532,410 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,705 | java | package com.clowd.ld37.level;
import java.awt.event.KeyEvent;
import com.clowd.ld37.StateManager;
import com.clowd.ld37.entity.item.Item;
import com.clowd.ld37.entity.mob.Player;
import com.clowd.ld37.entity.mob.Walker;
import com.clowd.ld37.entity.trap.Trap;
import com.clowd.ld37.gfx.Screen;
import com.clowd.ld37.gfx.StringObject;
import com.clowd.ld37.input.Keyboard;
import com.clowd.ld37.level.tile.Tile;
import com.clowd.ld37.sound.Sound;
public class Level1 extends Level{
public Level1(String path, StateManager manager){
super(path, manager);
}
public void generateLevel(){
levelNum = 1;
startTimer = 20;
spawnX = levelX + 30*12+5;
spawnY = levelY + 30*11+5;
entities.add(new Player(this, spawnX, spawnY));
/*
entities.add(new Item(this, levelX + 30*10+7, levelY + 30*11+7, 1));
entities.add(new Walker(this, levelX+30*15+3, levelY+30*6+3, 0, 2, 30*4));
entities.add(new Walker(this, levelX+30*19+3, levelY+30*11+3, 1, 0, 30*5));
entities.add(new Trap(this, levelX+30*16, levelY+30*12, 0));
*/
}
public void update2(){
if(start){
if(Keyboard.keyTyped(KeyEvent.VK_ENTER)){
start = false;
Sound.enter.play(false);
Sound.music.play(true);
}
}else if(end){
if(Keyboard.keyTyped(KeyEvent.VK_ENTER)){
nextLevel = true;
Sound.enter.play(false);
}
if(endY <= -1200){
manager.setLevel(new Level2("/levels/level2.png", manager));
}
}else{
updateEntities();
if(tiles[((int)(playerX-levelX+10)/30)+((int)(playerY-levelY+10)/30)*width] == 0xff0000ff){
end = true;
Sound.finish.play(false);
Sound.music.stop();
}
}
}
public void render2(Screen screen){
if(start || startX < 1000){
screen.renderRect(40+startY, 140+startX, 1020, 420, Tile.walltile.getColor());
screen.renderRect(50+startY, 150+startX, 1000, 400, 0x333333);
screen.addText(new StringObject("Controls: ", 70+startY, 210+startX, 50, Tile.walltile.getColor()));
screen.addText(new StringObject("Movement: Up/Down/Left/Right or WASD", 80+startY, 260+startX, 30, 0xffffff));
screen.addText(new StringObject("Pause: Escape", 80+startY, 300+startX, 30, 0xffffff));
screen.addText(new StringObject("Goal: ", 70+startY, 380+startX, 50, Tile.walltile.getColor()));
screen.addText(new StringObject("Reach the white tile as fast as posible:", 80+startY, 430+startX, 30, 0xffffff));
screen.renderRect(750+startY, 395+startX, 50, 50, 0xffffff);
screen.addText(new StringObject("Press Enter to Begin", 240+startY, 520+startX, 50, 0xffffff));
}
if(end){
screen.renderRect(40+endY, 140+endX, 1020, 420, Tile.walltile.getColor());
screen.renderRect(50+endY, 150+endX, 1000, 400, 0x333333);
screen.addText(new StringObject("Final Time: " + timeS + "." + timeMS, 310+endY, 210+endX, 50, Tile.walltile.getColor()));
screen.addText(new StringObject("Rank: ", 320+endY, 380+endX, 100, 0xffffff));
if(timeS < 10){
screen.addText(new StringObject("A", 650+endY, 380+endX, 100, 0x00dd00));
Level.ratings[levelNum] = "A";
}else if(timeS < 15){
screen.addText(new StringObject("B", 650+endY, 380+endX, 100, 0x2222dd));
Level.ratings[levelNum] = "B";
}else if(timeS < 20){
screen.addText(new StringObject("C", 650+endY, 380+endX, 100, 0xdddd00));
Level.ratings[levelNum] = "C";
}else if(timeS < 25){
screen.addText(new StringObject("D", 650+endY, 380+endX, 100, 0xdd8800));
Level.ratings[levelNum] = "D";
}else{
screen.addText(new StringObject("F", 650+endY, 380+endX, 100, 0xdd0000));
Level.ratings[levelNum] = "F";
}
screen.addText(new StringObject("Press Enter to Continue", 200+endY, 520+endX, 50, 0xffffff));
}
}
}
| [
"[email protected]"
]
| |
feb4db6194f32fbe13b95c165097adb34bec7fbb | 37019e78e8fba64c919fed206df09d5239d7186d | /src/com/algorithm/thread/interuptingThread/DownloadingFileTask.java | d54db075524e0172956f745ee4f123b00cca1d27 | []
| no_license | MithileshRavindiran/Algorithm | aad3b57aa4cba47cbda0d1ee684e43bc1536d233 | 56bdbeafb80eb39d43b3dd27c6ba614a27064c61 | refs/heads/master | 2022-07-03T05:31:08.857043 | 2020-05-13T13:56:42 | 2020-05-13T13:56:42 | 256,473,922 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 589 | java | package com.algorithm.thread.interuptingThread;
/**
* Created by mravindran on 16/04/20.
*/
public class DownloadingFileTask implements Runnable {
@Override
public void run() {
System.out.println("Downloading the File Started: "+ Thread.currentThread().getName());
for (int i =0; i < Integer.MAX_VALUE; i++) {
if (Thread.currentThread().isInterrupted()) return;
System.out.println("Downloading Byte "+ i);
}
System.out.println("Downloading the File Completed after wait: "+ Thread.currentThread().getName());
}
}
| [
"[email protected]"
]
| |
8c3d62ed347f61d9b031212bf079b0d08b7b9186 | e0e12b424d92f4625f0f5d010ace56623093fb15 | /app/src/main/java/com/gqq/leetcode/offer/Offer32.java | 53f119772bd04ce51063a7ace0c0f393963921bb | []
| no_license | gqq519/LeetCode | 9a05993f41b4e753641efe00aab78f5e502a9304 | 89a04c187614718306d852042a2bc072f67d15de | refs/heads/master | 2021-07-05T22:26:41.050289 | 2020-11-16T15:01:39 | 2020-11-16T15:01:39 | 193,846,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,329 | java | package com.gqq.leetcode.offer;
import com.gqq.leetcode.TreeNode;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
/**
* 从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印。
*
*
*
* 例如:
* 给定二叉树: [3,9,20,null,null,15,7],
*
* 3
* / \
* 9 20
* / \
* 15 7
* 返回:
*
* [3,9,20,15,7]
*
* 来源:力扣(LeetCode)
* 链接:https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof
*
* 解题思路:
* 利用队列先进先出的特点,将节点和左右子树分别add到队列中,再poll出来
*/
public class Offer32 {
public int[] levelOrder(TreeNode root) {
if (root == null) return new int[]{};
Queue<TreeNode> queue = new ArrayDeque<>();
List<Integer> list = new ArrayList<>();
queue.add(root);
while (!queue.isEmpty()) {
TreeNode node = queue.poll();
list.add(node.val);
if (node.left != null) queue.add(node.left);
if (node.right != null) queue.add(node.right);
}
int res[] = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
res[i] = list.get(i);
}
return res;
}
}
| [
"[email protected]"
]
| |
a43e676281d3a1eb4b5ed7f33e892ea6460de953 | 91ac0f6ea7999b4d26ced1c7772d221ce81a83c6 | /src/main/java/cn/chenxun/common/utils/ObjectSerializer.java | 1e6441de00cfd8d4a355e2c847a95abbd5bb3a91 | []
| no_license | Ranhang/seed-end | feed50f0d7c44c624e5266c70d12dd590577b12f | 13b467df098966b8f57c910befd0e70ee44b5863 | refs/heads/master | 2020-12-08T09:29:38.945321 | 2020-01-10T01:32:16 | 2020-01-10T01:32:16 | 232,946,514 | 1 | 0 | null | 2020-01-10T02:13:36 | 2020-01-10T02:13:35 | null | UTF-8 | Java | false | false | 1,888 | java | package cn.chenxun.common.utils;
import org.apache.shiro.io.SerializationException;
import java.io.*;
public class ObjectSerializer implements RedisSerializer<Object> {
public static final int BYTE_ARRAY_OUTPUT_STREAM_SIZE = 128;
@Override
public byte[] serialize(Object object) throws SerializationException {
byte[] result = new byte[0];
if (object == null) {
return result;
}
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(BYTE_ARRAY_OUTPUT_STREAM_SIZE);
if (!(object instanceof Serializable)) {
throw new SerializationException("requires a Serializable payload "
+ "but received an object of type [" + object.getClass().getName() + "]");
}
try {
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteStream);
objectOutputStream.writeObject(object);
objectOutputStream.flush();
result = byteStream.toByteArray();
} catch (IOException e) {
throw new SerializationException("serialize error, object=" + object, e);
}
return result;
}
@Override
public Object deserialize(byte[] bytes) throws SerializationException {
Object result = null;
if (bytes == null || bytes.length == 0) {
return result;
}
try {
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream = new MultiClassLoaderObjectInputStream(byteStream);
result = objectInputStream.readObject();
} catch (IOException e) {
throw new SerializationException("deserialize error", e);
} catch (ClassNotFoundException e) {
throw new SerializationException("deserialize error", e);
}
return result;
}
}
| [
"[email protected]"
]
| |
ba713cfa84b7ad9cb850b933c419f5d0067d55aa | 702e33c652394e5bab6febcc99ad6cfd701597ca | /DBSHK/src/GTMDP34.java | 7f2a41c5ddd80a5bdb855d330e1a7cfc3a262221 | []
| no_license | cuongtm2012/Utinity | e342613aabde0d3cf613ff47b947126576e5671c | 4d3428263b4b80019c9fe30395cb97b1a7a38e75 | refs/heads/master | 2021-05-04T11:21:10.584142 | 2016-04-12T09:08:46 | 2016-04-12T09:08:46 | 55,790,631 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,423 | java | import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Statement;
import java.util.Properties;
/**
*
*/
/**
* @author e1067720
*
*/
public class GTMDP34 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Statement statement = null;
Properties prop = new Properties();
InputStream inputPath = null;
String line = "";
String accNo = null;
long accNum = 0;
String configFile = "DBSHK.properties";
String fileName = "GTMDP34";
try {
inputPath = new FileInputStream(configFile);
prop.load(inputPath);
FileInputStream fis = new FileInputStream(prop.getProperty(fileName));
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
while ((line = br.readLine()) != null) {
if (line.length() > 9) {
accNo = line.substring(33, 50).trim();
try {
accNum = Long.parseLong(accNo);
if (accNum >= 0) {
analysis(statement, line);
}
} catch (NumberFormatException ex) {
accNum = -1;
}
}
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Insert DB successfull");
}
public static void analysis(Statement statement, String line) {
String ourdate = "";
String ourtime = "";
String ourSeqNo = "";
String jetcoSeqNo = "";
String accNo = "";
String cardNumber = "";
String tranCode = "";
String tranDesc = "";
String feeamount = "";
String feeaccNo = "";
String errorCode = "";
String sqlInsert = "";
try {
ourdate = line.substring(1, 10).trim();
ourtime = line.substring(10, 19).trim();
ourSeqNo = line.substring(19, 25).trim();
jetcoSeqNo = line.substring(26, 32).trim();
accNo = line.substring(33, 50).trim();
cardNumber = line.substring(51, 68).trim();
tranCode = line.substring(69, 72).trim();
tranDesc = line.substring(74, 85).trim();
feeamount = line.substring(87, 100).trim();
feeaccNo = line.substring(100, 117).trim();
errorCode = line.substring(117, 125).trim();
sqlInsert = insertDB(ourdate, ourtime, ourSeqNo, jetcoSeqNo, accNo,
cardNumber, tranCode, tranDesc, feeamount, feeaccNo,
errorCode);
statement.executeUpdate(sqlInsert);
} catch (Exception ex) {
System.out.println("Error CardNo : " + ourdate + " - " + ourtime
+ ourSeqNo + jetcoSeqNo + accNo + cardNumber + tranCode
+ tranDesc + feeamount + feeaccNo + errorCode);
System.out.println(ex.getMessage());
}
}
public static String insertDB(String ourdate, String ourtime,
String ourSeqNo, String jetcoSeqNo, String accNo,
String cardNumber, String tranCode, String tranDesc,
String feeamount, String feeaccNo, String errorCode) {
String sqlInsert = "";
try {
sqlInsert = "Insert into GTMDP34(OURDATE,OURTIME,OURSEQNO,JETCOSEQNO,ACCNO,CARDNUMBER,TRANCODE,TRANDESC,AMOUNT,TRANFEEACCNO,ERRORCODE) "
+ "values ('"
+ ourdate
+ "','"
+ ourtime
+ "','"
+ ourSeqNo
+ "','"
+ jetcoSeqNo
+ "','"
+ accNo
+ "','"
+ cardNumber
+ "','"
+ tranCode
+ "','"
+ tranDesc
+ "','"
+ feeamount
+ "','"
+ feeaccNo + "','" + errorCode + "')";
System.out.println(sqlInsert);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
return sqlInsert;
}
}
| [
"[email protected]"
]
| |
81999d444014b262b2c8264de63d1b50bae0d6ce | fac5d6126ab147e3197448d283f9a675733f3c34 | /src/main/java/android/support/v13/app/FragmentStatePagerAdapter.java | 2cce53da41d83016bb58fc2ccc947fbc97c7b602 | []
| no_license | KnzHz/fpv_live | 412e1dc8ab511b1a5889c8714352e3a373cdae2f | 7902f1a4834d581ee6afd0d17d87dc90424d3097 | refs/heads/master | 2022-12-18T18:15:39.101486 | 2020-09-24T19:42:03 | 2020-09-24T19:42:03 | 294,176,898 | 0 | 0 | null | 2020-09-09T17:03:58 | 2020-09-09T17:03:57 | null | UTF-8 | Java | false | false | 6,068 | java | package android.support.v13.app;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
@Deprecated
public abstract class FragmentStatePagerAdapter extends PagerAdapter {
private static final boolean DEBUG = false;
private static final String TAG = "FragStatePagerAdapter";
private FragmentTransaction mCurTransaction = null;
private Fragment mCurrentPrimaryItem = null;
private final FragmentManager mFragmentManager;
private ArrayList<Fragment> mFragments = new ArrayList<>();
private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<>();
@Deprecated
public abstract Fragment getItem(int i);
@Deprecated
public FragmentStatePagerAdapter(FragmentManager fm) {
this.mFragmentManager = fm;
}
@Deprecated
public void startUpdate(ViewGroup container) {
if (container.getId() == -1) {
throw new IllegalStateException("ViewPager with adapter " + this + " requires a view id");
}
}
@Deprecated
public Object instantiateItem(ViewGroup container, int position) {
Fragment.SavedState fss;
Fragment f;
if (this.mFragments.size() > position && (f = this.mFragments.get(position)) != null) {
return f;
}
if (this.mCurTransaction == null) {
this.mCurTransaction = this.mFragmentManager.beginTransaction();
}
Fragment fragment = getItem(position);
if (this.mSavedState.size() > position && (fss = this.mSavedState.get(position)) != null) {
fragment.setInitialSavedState(fss);
}
while (this.mFragments.size() <= position) {
this.mFragments.add(null);
}
fragment.setMenuVisibility(false);
FragmentCompat.setUserVisibleHint(fragment, false);
this.mFragments.set(position, fragment);
this.mCurTransaction.add(container.getId(), fragment);
return fragment;
}
@Deprecated
public void destroyItem(ViewGroup container, int position, Object object) {
Fragment.SavedState savedState;
Fragment fragment = (Fragment) object;
if (this.mCurTransaction == null) {
this.mCurTransaction = this.mFragmentManager.beginTransaction();
}
while (this.mSavedState.size() <= position) {
this.mSavedState.add(null);
}
ArrayList<Fragment.SavedState> arrayList = this.mSavedState;
if (fragment.isAdded()) {
savedState = this.mFragmentManager.saveFragmentInstanceState(fragment);
} else {
savedState = null;
}
arrayList.set(position, savedState);
this.mFragments.set(position, null);
this.mCurTransaction.remove(fragment);
}
@Deprecated
public void setPrimaryItem(ViewGroup container, int position, Object object) {
Fragment fragment = (Fragment) object;
if (fragment != this.mCurrentPrimaryItem) {
if (this.mCurrentPrimaryItem != null) {
this.mCurrentPrimaryItem.setMenuVisibility(false);
FragmentCompat.setUserVisibleHint(this.mCurrentPrimaryItem, false);
}
if (fragment != null) {
fragment.setMenuVisibility(true);
FragmentCompat.setUserVisibleHint(fragment, true);
}
this.mCurrentPrimaryItem = fragment;
}
}
@Deprecated
public void finishUpdate(ViewGroup container) {
if (this.mCurTransaction != null) {
this.mCurTransaction.commitAllowingStateLoss();
this.mCurTransaction = null;
this.mFragmentManager.executePendingTransactions();
}
}
@Deprecated
public boolean isViewFromObject(View view, Object object) {
return ((Fragment) object).getView() == view;
}
@Deprecated
public Parcelable saveState() {
Bundle state = null;
if (this.mSavedState.size() > 0) {
state = new Bundle();
Fragment.SavedState[] fss = new Fragment.SavedState[this.mSavedState.size()];
this.mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i = 0; i < this.mFragments.size(); i++) {
Fragment f = this.mFragments.get(i);
if (f != null && f.isAdded()) {
if (state == null) {
state = new Bundle();
}
this.mFragmentManager.putFragment(state, "f" + i, f);
}
}
return state;
}
@Deprecated
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
this.mSavedState.clear();
this.mFragments.clear();
if (fss != null) {
for (Parcelable parcelable : fss) {
this.mSavedState.add((Fragment.SavedState) parcelable);
}
}
for (String key : bundle.keySet()) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = this.mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (this.mFragments.size() <= index) {
this.mFragments.add(null);
}
FragmentCompat.setMenuVisibility(f, false);
this.mFragments.set(index, f);
} else {
Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
}
| [
"[email protected]"
]
| |
94544696b6708311789697ef5b719cc602266065 | 714fae00250d3fe9fc35d6c1c62968b703df0495 | /zhaohg-other/src/main/java/com/zhaohg/lucene/searcher/IndexSearchDemo.java | fcbc1f2c5f53e8682ad1a8bc970787b927f75e8e | []
| no_license | zhaohg/dev | c378e94a83ac256ff9e4b99bbdb3cce8da74a29c | 6b8248a3c7824ff10fa05e814d9658be273c7bbb | refs/heads/master | 2022-12-21T20:31:19.464451 | 2019-07-01T15:25:39 | 2019-07-01T15:25:39 | 189,548,628 | 1 | 1 | null | 2022-12-16T06:47:15 | 2019-05-31T07:28:23 | Java | UTF-8 | Java | false | false | 11,632 | java | package com.zhaohg.lucene.searcher;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.BytesRef;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.io.StringReader;
public class IndexSearchDemo {
private Directory directory = new RAMDirectory();
private String[] ids = {"1", "2"};
private String[] countries = {"Netherlands", "Italy"};
private String[] contents = {"Amsterdam has lots of bridges", "Venice has lots of canals, not bridges"};
private String[] cities = {"Amsterdam", "Venice"};
private IndexWriterConfig indexWriterConfig = new IndexWriterConfig(new WhitespaceAnalyzer());
private IndexWriter indexWriter;
@Before
public void createIndex() {
try {
indexWriter = new IndexWriter(directory, indexWriterConfig);
for (int i = 0; i < 2; i++) {
Document document = new Document();
Field idField = new StringField("id", ids[i], Field.Store.YES);
Field countryField = new StringField("country", countries[i], Field.Store.YES);
Field contentField = new TextField("content", contents[i], Field.Store.NO);
Field cityField = new StringField("city", cities[i], Field.Store.YES);
document.add(idField);
document.add(countryField);
document.add(contentField);
document.add(cityField);
indexWriter.addDocument(document);
}
indexWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void testTermQuery() throws IOException {
Term term = new Term("id", "2");
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(new TermQuery(term), 10);
Assert.assertEquals(1, search.totalHits);
}
@Test
public void testMatchNoDocsQuery() throws IOException {
Query query = new MatchNoDocsQuery();
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(0, search.totalHits);
}
@Test
public void testTermRangeQuery() throws IOException {
//搜索起始字母范围从A到Z的city
Query query = new TermRangeQuery("city", new BytesRef("A"), new BytesRef("Z"), true, true);
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(2, search.totalHits);
}
@Test
public void testQueryParser() throws ParseException, IOException {
//使用WhitespaceAnalyzer分析器不会忽略大小写,也就是说大小写敏感
QueryParser queryParser = new QueryParser("content", new WhitespaceAnalyzer());
Query query = queryParser.parse("+lots +has");
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 1);
Assert.assertEquals(2, search.totalHits);
query = queryParser.parse("lots OR bridges");
search = indexSearcher.search(query, 10);
Assert.assertEquals(2, search.totalHits);
//有点需要注意,在QueryParser解析通配符表达式的时候,一定要用引号包起来,然后作为字符串传递给parse函数
query = new QueryParser("field", new StandardAnalyzer()).parse("\"This is some phrase*\"");
Assert.assertEquals("analyzed", "\"? ? some phrase\"", query.toString("field"));
//语法参考:http://lucene.apache.org/core/6_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description
//使用QueryParser解析"~",~代表编辑距离,~后面参数的取值在0-2之间,默认值是2,不要使用浮点数
QueryParser parser = new QueryParser("city", new WhitespaceAnalyzer());
//例如,roam~,该查询会匹配foam和roams,如果~后不跟参数,则默认值是2
//QueryParser在解析的时候不区分大小写(会全部转成小写字母),所以虽少了一个字母,但是首字母被解析为小写的v,依然不匹配,所以编辑距离是2
query = parser.parse("Venic~2");
search = indexSearcher.search(query, 10);
Assert.assertEquals(1, search.totalHits);
}
@Test
public void testBooleanQuery() throws IOException {
Query termQuery = new TermQuery(new Term("country", "Beijing"));
Query termQuery1 = new TermQuery(new Term("city", "Venice"));
//测试OR查询,或者出现Beijing或者出现Venice
BooleanQuery build = new BooleanQuery.Builder().add(termQuery, BooleanClause.Occur.SHOULD).add(termQuery1, BooleanClause.Occur.SHOULD).build();
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(build, 10);
Assert.assertEquals(1, search.totalHits);
//使用BooleanQuery实现 国家是(Italy OR Netherlands) AND contents中包含(Amsterdam)操作
BooleanQuery build1 = new BooleanQuery.Builder().add(new TermQuery(new Term("country", "Italy")), BooleanClause.Occur.SHOULD).add(new TermQuery
(new Term("country",
"Netherlands")), BooleanClause.Occur.SHOULD).build();
BooleanQuery build2 = new BooleanQuery.Builder().add(build1, BooleanClause.Occur.MUST).add(new TermQuery(new Term("content", "Amsterdam")), BooleanClause.Occur
.MUST).build();
search = indexSearcher.search(build2, 10);
Assert.assertEquals(1, search.totalHits);
}
@Test
public void testPhraseQuery() throws IOException {
//设置两个短语之间的跨度为2,也就是说has和bridges之间的短语小于等于均可检索到
PhraseQuery build = new PhraseQuery.Builder().setSlop(2).add(new Term("content", "has")).add(new Term("content", "bridges")).build();
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(build, 10);
Assert.assertEquals(1, search.totalHits);
build = new PhraseQuery.Builder().setSlop(1).add(new Term("content", "Venice")).add(new Term("content", "lots")).add(new Term("content",
"canals")).build();
search = indexSearcher.search(build, 10);
Assert.assertNotEquals(1, search.totalHits);
}
@Test
public void testMatchAllDocsQuery() throws IOException {
Query query = new MatchAllDocsQuery();
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(2, search.totalHits);
}
@Test
public void testFuzzyQuery() throws IOException, ParseException {
//注意是区分大小写的,同时默认的编辑距离的值是2
//注意两个Term之间的编辑距离必须小于两者中最小者的长度:the edit distance between the terms must be less than the minimum length term
Query query = new FuzzyQuery(new Term("city", "Veni"));
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(1, search.totalHits);
}
@Test
public void testWildcardQuery() throws IOException {
//*代表0个或者多个字母
Query query = new WildcardQuery(new Term("content", "*dam"));
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(1, search.totalHits);
//?代表0个或者1个字母
query = new WildcardQuery(new Term("content", "?ridges"));
search = indexSearcher.search(query, 10);
Assert.assertEquals(2, search.totalHits);
query = new WildcardQuery(new Term("content", "b*s"));
search = indexSearcher.search(query, 10);
Assert.assertEquals(2, search.totalHits);
}
@Test
public void testPrefixQuery() throws IOException {
//使用前缀搜索以It打头的国家名,显然只有Italy符合
PrefixQuery query = new PrefixQuery(new Term("country", "It"));
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(query, 10);
Assert.assertEquals(1, search.totalHits);
}
private IndexSearcher getIndexSearcher() throws IOException {
return new IndexSearcher(DirectoryReader.open(directory));
}
@Test
public void testToken() throws IOException {
Analyzer analyzer = new StandardAnalyzer();
TokenStream
tokenStream = analyzer.tokenStream("myfield", new StringReader("Some text content for my test!"));
OffsetAttribute offsetAttribute = tokenStream.addAttribute(OffsetAttribute.class);
tokenStream.reset();
while (tokenStream.incrementToken()) {
System.out.println("token: " + tokenStream.reflectAsString(true).toString());
System.out.println("token start offset: " + offsetAttribute.startOffset());
System.out.println("token end offset: " + offsetAttribute.endOffset());
}
}
@Test
public void testMultiPhraseQuery() throws IOException {
Term[] terms = new Term[]{new Term("content", "has"), new Term("content", "lots")};
Term term2 = new Term("content", "bridges");
//多个add之间认为是OR操作,即(has lots)和bridges之间的slop不大于3,不计算标点
MultiPhraseQuery multiPhraseQuery = new MultiPhraseQuery.Builder().add(terms).add(term2).setSlop(3).build();
IndexSearcher indexSearcher = new IndexSearcher(DirectoryReader.open(directory));
TopDocs search = indexSearcher.search(multiPhraseQuery, 10);
Assert.assertEquals(2, search.totalHits);
}
//使用BooleanQuery类模拟MultiPhraseQuery类的功能
@Test
public void testBooleanQueryImitateMultiPhraseQuery() throws IOException {
PhraseQuery first = new PhraseQuery.Builder().setSlop(3).add(new Term("content", "Amsterdam")).add(new Term("content", "bridges"))
.build();
PhraseQuery second = new PhraseQuery.Builder().setSlop(1).add(new Term("content", "Venice")).add(new Term("content", "lots")).build();
BooleanQuery booleanQuery = new BooleanQuery.Builder().add(first, BooleanClause.Occur.SHOULD).add(second, BooleanClause.Occur.SHOULD).build();
IndexSearcher indexSearcher = getIndexSearcher();
TopDocs search = indexSearcher.search(booleanQuery, 10);
Assert.assertEquals(2, search.totalHits);
}
} | [
"[email protected]"
]
| |
f7fbe33a6fe78c17457ff17fe8f761ed4917d242 | 471a1d9598d792c18392ca1485bbb3b29d1165c5 | /jadx-MFP/src/main/java/android/support/v7/widget/ChildHelper.java | e0c95b3bed4183da0635d766daeb5a3ef8c58318 | []
| no_license | reed07/MyPreferencePal | 84db3a93c114868dd3691217cc175a8675e5544f | 365b42fcc5670844187ae61b8cbc02c542aa348e | refs/heads/master | 2020-03-10T23:10:43.112303 | 2019-07-08T00:39:32 | 2019-07-08T00:39:32 | 129,635,379 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,649 | java | package android.support.v7.widget;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import java.util.ArrayList;
import java.util.List;
class ChildHelper {
private static final boolean DEBUG = false;
private static final String TAG = "ChildrenHelper";
final Bucket mBucket = new Bucket();
final Callback mCallback;
final List<View> mHiddenViews = new ArrayList();
static class Bucket {
static final int BITS_PER_WORD = 64;
static final long LAST_BIT = Long.MIN_VALUE;
long mData = 0;
Bucket mNext;
Bucket() {
}
/* access modifiers changed from: 0000 */
public void set(int i) {
if (i >= 64) {
ensureNext();
this.mNext.set(i - 64);
return;
}
this.mData |= 1 << i;
}
private void ensureNext() {
if (this.mNext == null) {
this.mNext = new Bucket();
}
}
/* access modifiers changed from: 0000 */
public void clear(int i) {
if (i >= 64) {
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.clear(i - 64);
return;
}
return;
}
this.mData &= ~(1 << i);
}
/* access modifiers changed from: 0000 */
public boolean get(int i) {
if (i >= 64) {
ensureNext();
return this.mNext.get(i - 64);
}
return (this.mData & (1 << i)) != 0;
}
/* access modifiers changed from: 0000 */
public void reset() {
this.mData = 0;
Bucket bucket = this.mNext;
if (bucket != null) {
bucket.reset();
}
}
/* access modifiers changed from: 0000 */
public void insert(int i, boolean z) {
if (i >= 64) {
ensureNext();
this.mNext.insert(i - 64, z);
return;
}
boolean z2 = (this.mData & Long.MIN_VALUE) != 0;
long j = (1 << i) - 1;
long j2 = this.mData;
this.mData = ((j2 & (~j)) << 1) | (j2 & j);
if (z) {
set(i);
} else {
clear(i);
}
if (z2 || this.mNext != null) {
ensureNext();
this.mNext.insert(0, z2);
}
}
/* access modifiers changed from: 0000 */
public boolean remove(int i) {
if (i >= 64) {
ensureNext();
return this.mNext.remove(i - 64);
}
long j = 1 << i;
boolean z = (this.mData & j) != 0;
this.mData &= ~j;
long j2 = j - 1;
long j3 = this.mData;
this.mData = Long.rotateRight(j3 & (~j2), 1) | (j3 & j2);
Bucket bucket = this.mNext;
if (bucket != null) {
if (bucket.get(0)) {
set(63);
}
this.mNext.remove(0);
}
return z;
}
/* access modifiers changed from: 0000 */
public int countOnesBefore(int i) {
Bucket bucket = this.mNext;
if (bucket == null) {
if (i >= 64) {
return Long.bitCount(this.mData);
}
return Long.bitCount(this.mData & ((1 << i) - 1));
} else if (i < 64) {
return Long.bitCount(this.mData & ((1 << i) - 1));
} else {
return bucket.countOnesBefore(i - 64) + Long.bitCount(this.mData);
}
}
public String toString() {
if (this.mNext == null) {
return Long.toBinaryString(this.mData);
}
StringBuilder sb = new StringBuilder();
sb.append(this.mNext.toString());
sb.append("xx");
sb.append(Long.toBinaryString(this.mData));
return sb.toString();
}
}
interface Callback {
void addView(View view, int i);
void attachViewToParent(View view, int i, LayoutParams layoutParams);
void detachViewFromParent(int i);
View getChildAt(int i);
int getChildCount();
ViewHolder getChildViewHolder(View view);
int indexOfChild(View view);
void onEnteredHiddenState(View view);
void onLeftHiddenState(View view);
void removeAllViews();
void removeViewAt(int i);
}
ChildHelper(Callback callback) {
this.mCallback = callback;
}
private void hideViewInternal(View view) {
this.mHiddenViews.add(view);
this.mCallback.onEnteredHiddenState(view);
}
private boolean unhideViewInternal(View view) {
if (!this.mHiddenViews.remove(view)) {
return false;
}
this.mCallback.onLeftHiddenState(view);
return true;
}
/* access modifiers changed from: 0000 */
public void addView(View view, boolean z) {
addView(view, -1, z);
}
/* access modifiers changed from: 0000 */
public void addView(View view, int i, boolean z) {
int i2;
if (i < 0) {
i2 = this.mCallback.getChildCount();
} else {
i2 = getOffset(i);
}
this.mBucket.insert(i2, z);
if (z) {
hideViewInternal(view);
}
this.mCallback.addView(view, i2);
}
private int getOffset(int i) {
if (i < 0) {
return -1;
}
int childCount = this.mCallback.getChildCount();
int i2 = i;
while (i2 < childCount) {
int countOnesBefore = i - (i2 - this.mBucket.countOnesBefore(i2));
if (countOnesBefore == 0) {
while (this.mBucket.get(i2)) {
i2++;
}
return i2;
}
i2 += countOnesBefore;
}
return -1;
}
/* access modifiers changed from: 0000 */
public void removeView(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild >= 0) {
if (this.mBucket.remove(indexOfChild)) {
unhideViewInternal(view);
}
this.mCallback.removeViewAt(indexOfChild);
}
}
/* access modifiers changed from: 0000 */
public void removeViewAt(int i) {
int offset = getOffset(i);
View childAt = this.mCallback.getChildAt(offset);
if (childAt != null) {
if (this.mBucket.remove(offset)) {
unhideViewInternal(childAt);
}
this.mCallback.removeViewAt(offset);
}
}
/* access modifiers changed from: 0000 */
public View getChildAt(int i) {
return this.mCallback.getChildAt(getOffset(i));
}
/* access modifiers changed from: 0000 */
public void removeAllViewsUnfiltered() {
this.mBucket.reset();
for (int size = this.mHiddenViews.size() - 1; size >= 0; size--) {
this.mCallback.onLeftHiddenState((View) this.mHiddenViews.get(size));
this.mHiddenViews.remove(size);
}
this.mCallback.removeAllViews();
}
/* access modifiers changed from: 0000 */
public View findHiddenNonRemovedView(int i) {
int size = this.mHiddenViews.size();
for (int i2 = 0; i2 < size; i2++) {
View view = (View) this.mHiddenViews.get(i2);
ViewHolder childViewHolder = this.mCallback.getChildViewHolder(view);
if (childViewHolder.getLayoutPosition() == i && !childViewHolder.isInvalid() && !childViewHolder.isRemoved()) {
return view;
}
}
return null;
}
/* access modifiers changed from: 0000 */
public void attachViewToParent(View view, int i, LayoutParams layoutParams, boolean z) {
int i2;
if (i < 0) {
i2 = this.mCallback.getChildCount();
} else {
i2 = getOffset(i);
}
this.mBucket.insert(i2, z);
if (z) {
hideViewInternal(view);
}
this.mCallback.attachViewToParent(view, i2, layoutParams);
}
/* access modifiers changed from: 0000 */
public int getChildCount() {
return this.mCallback.getChildCount() - this.mHiddenViews.size();
}
/* access modifiers changed from: 0000 */
public int getUnfilteredChildCount() {
return this.mCallback.getChildCount();
}
/* access modifiers changed from: 0000 */
public View getUnfilteredChildAt(int i) {
return this.mCallback.getChildAt(i);
}
/* access modifiers changed from: 0000 */
public void detachViewFromParent(int i) {
int offset = getOffset(i);
this.mBucket.remove(offset);
this.mCallback.detachViewFromParent(offset);
}
/* access modifiers changed from: 0000 */
public int indexOfChild(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild != -1 && !this.mBucket.get(indexOfChild)) {
return indexOfChild - this.mBucket.countOnesBefore(indexOfChild);
}
return -1;
}
/* access modifiers changed from: 0000 */
public boolean isHidden(View view) {
return this.mHiddenViews.contains(view);
}
/* access modifiers changed from: 0000 */
public void hide(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild >= 0) {
this.mBucket.set(indexOfChild);
hideViewInternal(view);
return;
}
StringBuilder sb = new StringBuilder();
sb.append("view is not a child, cannot hide ");
sb.append(view);
throw new IllegalArgumentException(sb.toString());
}
/* access modifiers changed from: 0000 */
public void unhide(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild < 0) {
StringBuilder sb = new StringBuilder();
sb.append("view is not a child, cannot hide ");
sb.append(view);
throw new IllegalArgumentException(sb.toString());
} else if (this.mBucket.get(indexOfChild)) {
this.mBucket.clear(indexOfChild);
unhideViewInternal(view);
} else {
StringBuilder sb2 = new StringBuilder();
sb2.append("trying to unhide a view that was not hidden");
sb2.append(view);
throw new RuntimeException(sb2.toString());
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.mBucket.toString());
sb.append(", hidden list:");
sb.append(this.mHiddenViews.size());
return sb.toString();
}
/* access modifiers changed from: 0000 */
public boolean removeViewIfHidden(View view) {
int indexOfChild = this.mCallback.indexOfChild(view);
if (indexOfChild == -1) {
unhideViewInternal(view);
return true;
} else if (!this.mBucket.get(indexOfChild)) {
return false;
} else {
this.mBucket.remove(indexOfChild);
unhideViewInternal(view);
this.mCallback.removeViewAt(indexOfChild);
return true;
}
}
}
| [
"[email protected]"
]
| |
03c9c2f9690aeb0fcd3d12d2975f15cb96ed9371 | 42a2454fc1b336fd7e00c3583f379f03516d50e0 | /java/debugger/impl/src/com/intellij/debugger/impl/attach/JavaAttachDebuggerProvider.java | f3fad9e5b195481eadf7775303eed4503ebb0562 | [
"Apache-2.0"
]
| permissive | meanmail/intellij-community | f65893f148b2913b18ec4787a82567c8b41c2e2b | edeb845e7c483d852d807eb0015d28ee8a813f87 | refs/heads/master | 2021-01-11T02:53:33.903981 | 2019-03-01T18:42:10 | 2019-03-01T18:42:10 | 70,822,840 | 1 | 1 | Apache-2.0 | 2019-03-01T18:42:11 | 2016-10-13T15:49:45 | Java | UTF-8 | Java | false | false | 16,808 | java | // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.debugger.impl.attach;
import com.intellij.debugger.engine.RemoteStateState;
import com.intellij.debugger.impl.DebuggerManagerImpl;
import com.intellij.debugger.impl.GenericDebuggerRunner;
import com.intellij.execution.*;
import com.intellij.execution.configurations.*;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.process.OSProcessUtil;
import com.intellij.execution.process.ProcessInfo;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolder;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.rt.execution.application.AppMainV2;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PathUtil;
import com.intellij.util.execution.ParametersListUtil;
import com.intellij.xdebugger.attach.XDefaultLocalAttachGroup;
import com.intellij.xdebugger.attach.XLocalAttachDebugger;
import com.intellij.xdebugger.attach.XLocalAttachDebuggerProvider;
import com.intellij.xdebugger.attach.XLocalAttachGroup;
import com.jetbrains.sa.SaJdwp;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
* @author egor
*/
public class JavaAttachDebuggerProvider implements XLocalAttachDebuggerProvider {
private static final Logger LOG = Logger.getInstance(JavaAttachDebuggerProvider.class);
private static class JavaLocalAttachDebugger implements XLocalAttachDebugger {
private final Project myProject;
private final LocalAttachInfo myInfo;
JavaLocalAttachDebugger(@NotNull Project project, @NotNull LocalAttachInfo info) {
myProject = project;
myInfo = info;
}
@NotNull
@Override
public String getDebuggerDisplayName() {
return myInfo.getDebuggerName();
}
@Override
public void attachDebugSession(@NotNull Project project, @NotNull ProcessInfo processInfo) {
attach(myInfo, myProject);
}
}
private static final Key<Map<String, LocalAttachInfo>> ADDRESS_MAP_KEY = Key.create("ADDRESS_MAP");
private static final XLocalAttachGroup ourAttachGroup = new JavaDebuggerAttachGroup("Java", -20);
static class JavaDebuggerAttachGroup extends XDefaultLocalAttachGroup {
private final String myName;
private final int myOrder;
JavaDebuggerAttachGroup(String name, int order) {
myName = name;
myOrder = order;
}
@Override
public int getOrder() {
return myOrder;
}
@NotNull
@Override
public String getGroupName() {
return myName;
}
@NotNull
@Override
public String getProcessDisplayText(@NotNull Project project, @NotNull ProcessInfo info, @NotNull UserDataHolder dataHolder) {
LocalAttachInfo attachInfo = getAttachInfo(project, info, dataHolder.getUserData(ADDRESS_MAP_KEY));
assert attachInfo != null;
String res;
String executable = info.getExecutableDisplayName();
if ("java".equals(executable)) {
if (!StringUtil.isEmpty(attachInfo.myClass)) {
res = attachInfo.myClass;
}
else {
res = StringUtil.notNullize(ArrayUtil.getLastElement(info.getCommandLine().split(" "))); // should be class name
}
}
else {
res = executable;
}
return attachInfo.getProcessDisplayText(res);
}
}
@NotNull
@Override
public XLocalAttachGroup getAttachGroup() {
return ourAttachGroup;
}
@NotNull
@Override
public List<XLocalAttachDebugger> getAvailableDebuggers(@NotNull Project project,
@NotNull ProcessInfo processInfo,
@NotNull UserDataHolder contextHolder) {
Map<String, LocalAttachInfo> addressMap = contextHolder.getUserData(ADDRESS_MAP_KEY);
if (addressMap == null) {
addressMap = new HashMap<>();
contextHolder.putUserData(ADDRESS_MAP_KEY, addressMap);
final Map<String, LocalAttachInfo> map = addressMap;
Set<String> attachedPids = JavaDebuggerAttachUtil.getAttachedPids(project);
VirtualMachine.list().forEach(desc -> {
String pid = desc.id();
LocalAttachInfo address = getProcessAttachInfo(pid, attachedPids);
if (address != null) {
map.put(pid, address);
}
});
}
LocalAttachInfo info = getAttachInfo(project, processInfo, addressMap);
if (info != null && isDebuggerAttach(info)) {
return Collections.singletonList(new JavaLocalAttachDebugger(project, info));
}
return Collections.emptyList();
}
boolean isDebuggerAttach(LocalAttachInfo info) {
return info instanceof DebuggerLocalAttachInfo;
}
@Nullable
private static LocalAttachInfo getAttachInfo(Project project,
ProcessInfo processInfo,
@Nullable Map<String, LocalAttachInfo> addressMap) {
LocalAttachInfo res;
String pidString = String.valueOf(processInfo.getPid());
if (addressMap != null) {
res = addressMap.get(pidString);
}
else {
res = getProcessAttachInfo(pidString, project);
}
if (res == null) {
res = getProcessAttachInfo(ParametersListUtil.parse(processInfo.getCommandLine()), pidString);
}
return res;
}
@Nullable
static LocalAttachInfo getProcessAttachInfo(List<String> arguments, String pid) {
String address;
boolean socket;
for (String argument : arguments) {
if (argument.startsWith("-agentlib:jdwp") &&
argument.contains("server=y") &&
(argument.contains("transport=dt_shmem") || argument.contains("transport=dt_socket"))) {
socket = argument.contains("transport=dt_socket");
String[] params = argument.split(",");
for (String param : params) {
if (param.startsWith("address")) {
try {
address = param.split("=")[1];
address = StringUtil.trimStart(address, "*:"); // handle java 9 format: *:5005
return new DebuggerLocalAttachInfo(socket, address, null, pid, false);
}
catch (Exception e) {
LOG.error(e);
return null;
}
}
}
break;
}
}
return null;
}
private static LocalAttachInfo getProcessAttachInfo(String pid, @NotNull Set<String> attachedPids) {
if (!attachedPids.contains(pid)) {
Future<LocalAttachInfo> future = ApplicationManager.getApplication().executeOnPooledThread(() -> getProcessAttachInfoInt(pid));
try {
// attaching ang getting info may hang in some cases
return future.get(5, TimeUnit.SECONDS);
}
catch (Exception e) {
LOG.info("Timeout while getting attach info", e);
}
finally {
future.cancel(true);
}
}
return null;
}
@Nullable
private static LocalAttachInfo getProcessAttachInfo(@NotNull String pid, @NotNull Project project) {
return getProcessAttachInfo(pid, JavaDebuggerAttachUtil.getAttachedPids(project));
}
@Nullable
static LocalAttachInfo getProcessAttachInfo(@NotNull String pid) {
return getProcessAttachInfo(pid, Collections.emptySet());
}
@Nullable
private static LocalAttachInfo getProcessAttachInfoInt(String pid) {
VirtualMachine vm = null;
try {
vm = JavaDebuggerAttachUtil.attachVirtualMachine(pid);
Properties agentProperties = vm.getAgentProperties();
String command = agentProperties.getProperty("sun.java.command");
if (!StringUtil.isEmpty(command)) {
command = StringUtil.replace(command, AppMainV2.class.getName(), "").trim();
command = StringUtil.notNullize(StringUtil.substringBefore(command, " "), command);
}
String property = agentProperties.getProperty("sun.jdwp.listenerAddress");
if (property != null && property.indexOf(':') != -1) {
boolean autoAddress = false;
String args = agentProperties.getProperty("sun.jvm.args");
if (!StringUtil.isEmpty(args)) {
for (String arg : args.split(" ")) {
if (arg.startsWith("-agentlib:jdwp")) {
autoAddress = !arg.contains("address=");
break;
}
}
}
return new DebuggerLocalAttachInfo(!"dt_shmem".equals(StringUtil.substringBefore(property, ":")),
StringUtil.substringAfter(property, ":"),
command, pid, autoAddress);
}
//do not allow further for idea process
if (!pid.equals(OSProcessUtil.getApplicationPid())) {
Properties systemProperties = vm.getSystemProperties();
// prefer sa-jdwp attach if available
// sa pid attach if sa-jdi.jar is available
LocalAttachInfo info = SAJDWPLocalAttachInfo.create(systemProperties, command, pid);
if (info != null) {
return info;
}
// sa pid attach if sa-jdi.jar is available
info = SAPIDLocalAttachInfo.create(systemProperties, command, pid);
if (info != null) {
return info;
}
}
}
catch (InternalError e) {
LOG.warn(e);
}
catch (AttachNotSupportedException | IOException ignored) {
}
finally {
if (vm != null) {
try {
vm.detach();
}
catch (IOException ignored) {
}
}
}
return null;
}
private static class DebuggerLocalAttachInfo extends LocalAttachInfo {
private final boolean myUseSocket;
private final String myAddress;
private final boolean myAutoAddress;
DebuggerLocalAttachInfo(boolean socket, @NotNull String address, String aClass, String pid, boolean autoAddress) {
super(aClass, pid);
myUseSocket = socket;
myAddress = address;
myAutoAddress = autoAddress;
}
@Override
RemoteConnection createConnection() {
return myAutoAddress
? new PidRemoteConnection(myPid)
: new PidRemoteConnection(myPid, myUseSocket, DebuggerManagerImpl.LOCALHOST_ADDRESS_FALLBACK, myAddress, false);
}
@Override
String getSessionName() {
return myAutoAddress ? super.getSessionName() : "localhost:" + myAddress;
}
@Override
String getDebuggerName() {
return "Java Debugger";
}
@Override
String getProcessDisplayText(String text) {
return text + " (" + myAddress + ")";
}
}
static class SAPIDLocalAttachInfo extends LocalAttachInfo {
final String mySAJarPath;
SAPIDLocalAttachInfo(String aClass, String pid, String SAJarPath) {
super(aClass, pid);
mySAJarPath = SAJarPath;
}
@Nullable
static SAPIDLocalAttachInfo create(Properties systemProperties, String aClass, String pid) throws IOException {
File saJdiJar = new File(systemProperties.getProperty("java.home"), "../lib/sa-jdi.jar"); // java 8 only for now
if (saJdiJar.exists()) {
return new SAPIDLocalAttachInfo(aClass, pid, saJdiJar.getCanonicalPath());
}
return null;
}
@Override
RemoteConnection createConnection() {
return new SAPidRemoteConnection(myPid, mySAJarPath);
}
@Override
String getDebuggerName() {
return "Read Only Java Debugger";
}
}
static class SAJDWPLocalAttachInfo extends LocalAttachInfo {
private final List<String> myCommands;
SAJDWPLocalAttachInfo(String aClass, String pid, List<String> commands) {
super(aClass, pid);
myCommands = commands;
}
@Nullable
static LocalAttachInfo create(Properties systemProperties, String aClass, String pid) {
try {
List<String> commands = SaJdwp.getServerProcessCommand(systemProperties, pid, "0", false, PathUtil.getJarPathForClass(SaJdwp.class));
return new SAJDWPLocalAttachInfo(aClass, pid, commands);
}
catch (Exception ignored) {
}
return null;
}
@Override
RemoteConnection createConnection() {
return new SAJDWPRemoteConnection(myPid, myCommands);
}
@Override
String getDebuggerName() {
return "Read Only Java Debugger";
}
}
static abstract class LocalAttachInfo {
final String myClass;
final String myPid;
LocalAttachInfo(String aClass, String pid) {
myClass = aClass;
myPid = pid;
}
abstract RemoteConnection createConnection();
String getSessionName() {
return "pid " + myPid;
}
abstract String getDebuggerName();
String getProcessDisplayText(String text) {
return text;
}
}
private static class ProcessAttachDebugExecutor extends DefaultDebugExecutor {
static ProcessAttachDebugExecutor INSTANCE = new ProcessAttachDebugExecutor();
private ProcessAttachDebugExecutor() {
}
@NotNull
@Override
public String getId() {
return "ProcessAttachDebug";
}
}
public static class ProcessAttachDebuggerRunner extends GenericDebuggerRunner {
@NotNull
@Override
public String getRunnerId() {
return "ProcessAttachDebuggerRunner";
}
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment)
throws ExecutionException {
return attachVirtualMachine(state, environment, ((RemoteState)state).getRemoteConnection(), false);
}
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
return executorId.equals(ProcessAttachDebugExecutor.INSTANCE.getId());
}
}
private static class ProcessAttachRunConfiguration extends RunConfigurationBase {
private LocalAttachInfo myAttachInfo;
protected ProcessAttachRunConfiguration(@NotNull Project project) {
super(project, ProcessAttachRunConfigurationType.FACTORY, "ProcessAttachRunConfiguration");
}
@NotNull
@Override
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
throw new IllegalStateException("Editing is not supported");
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
return new RemoteStateState(getProject(), myAttachInfo.createConnection());
}
}
private static final class ProcessAttachRunConfigurationType implements ConfigurationType {
static final ProcessAttachRunConfigurationType INSTANCE = new ProcessAttachRunConfigurationType();
static final ConfigurationFactory FACTORY = new ConfigurationFactory(INSTANCE) {
@NotNull
@Override
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
return new ProcessAttachRunConfiguration(project);
}
};
@NotNull
@Nls
@Override
public String getDisplayName() {
return getId();
}
@Nls
@Override
public String getConfigurationTypeDescription() {
return getId();
}
@Override
public Icon getIcon() {
return null;
}
@NotNull
@Override
public String getId() {
return "ProcessAttachRunConfigurationType";
}
@Override
public ConfigurationFactory[] getConfigurationFactories() {
return new ConfigurationFactory[]{FACTORY};
}
@Override
public String getHelpTopic() {
return "reference.dialogs.rundebug.ProcessAttachRunConfigurationType";
}
}
static void attach(JavaAttachDebuggerProvider.LocalAttachInfo info, Project project) {
RunnerAndConfigurationSettings runSettings =
RunManager
.getInstance(project).createConfiguration(info.getSessionName(), JavaAttachDebuggerProvider.ProcessAttachRunConfigurationType.FACTORY);
((JavaAttachDebuggerProvider.ProcessAttachRunConfiguration)runSettings.getConfiguration()).myAttachInfo = info;
ProgramRunnerUtil.executeConfiguration(runSettings, JavaAttachDebuggerProvider.ProcessAttachDebugExecutor.INSTANCE);
}
}
| [
"[email protected]"
]
| |
d6394a9106554f74647a6fe7e3f58cad67ea4551 | 4f614758d596a0919d8e00a62fdd7290870f01ac | /Tvtime2/app/src/main/java/pt/tvtime/app/model/Temporada.java | e46179450e9e1a87e371a6e2c40a3379316c8731 | []
| no_license | Carlos2641/TV-Checker- | 8dfaded3ddcaad449d27df5cca611ae247b328f7 | 8667767427e785d10c9c3ae8ff4575f141abc6e4 | refs/heads/master | 2022-12-18T13:54:26.080486 | 2020-02-03T16:23:49 | 2020-02-03T16:23:49 | 209,286,408 | 0 | 0 | null | 2022-11-23T04:21:27 | 2019-09-18T10:58:05 | HTML | UTF-8 | Java | false | false | 888 | java | package pt.tvtime.app.model;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity
public class Temporada {
@PrimaryKey()
private long idTemporada;
private int idSerie;
private int idEpisodio;
public Temporada(long idTemporada, int idSerie, int idEpisodio) {
this.idTemporada = idTemporada;
this.idSerie = idSerie;
this.idEpisodio = idEpisodio;
}
public long getIdTemporada() {
return idTemporada;
}
public int getIdSerie() {
return idSerie;
}
public int getIdEpisodio() {
return idEpisodio;
}
public void setIdTemporada(long idTemporada) {
this.idTemporada = idTemporada;
}
public void setIdSerie(int idSerie) {
this.idSerie = idSerie;
}
public void setIdEpisodio(int idEpisodio) {
this.idEpisodio = idEpisodio;
}
}
| [
"[email protected]"
]
| |
06a5dac2cd17aaead6324aca94457762ce9fd145 | cee53b391e5f83c0fcc554a784701e444fc57c52 | /app/src/main/java/com/timetson/theheartofegypt/SahidicMenuActivity.java | 64fd4b14a507c022d8c7c5a0814fc2499b1fbd88 | []
| no_license | rafeek-awney/pheat-n-keami | 683e96a942bd59bde257420c78fa0c4d4355e5a4 | 83e1505a1142ae34ceca1332cca65bd56c1fbeaa | refs/heads/master | 2023-03-09T00:31:13.908976 | 2021-02-26T17:29:37 | 2021-02-26T17:29:37 | 342,649,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,593 | java | package com.timetson.theheartofegypt;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.timetson.theheartofegypt.helpers.localeHelper;
import com.timetson.theheartofegypt.modules.DataContainer;
public class SahidicMenuActivity extends AppCompatActivity {
////////// assign views ////////
private Button buttonAbout;
private Button buttonAlphabet;
private TextView title;
////////////////////////////////
////////////for Language Setting///////////////////
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
}
private void updateLanguage(Context context, String language) {
Resources resources = localeHelper.getLocalizedResources(context, language);
title.setText(resources.getString(R.string.dialect_menu_sahidic));
buttonAbout.setText(resources.getString(R.string.dialect_menu_about));
buttonAlphabet.setText(resources.getString(R.string.dialect_menu_alphabet));
}
////////////////////////////////////////////////////
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialect_menu);
////////initialization///////////
final Context context = this;
buttonAlphabet = findViewById(R.id.dialect_menu_button_alphbet);
buttonAbout = findViewById(R.id.dialect_menu_button_about);
title = findViewById(R.id.head_title);
///////////////////////////////
///////set language///////////
updateLanguage(context, DataContainer.LanguageCode);
//////////////////////////
// Ads code
DataContainer.AdmobLoad(this, context, R.id.adView);
// end Ads code
buttonAbout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, SahidicAboutActivity.class);
startActivity(intent);
}
});
buttonAlphabet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, SahidicLettersListActivity.class);
startActivity(intent);
}
});
}
}
| [
"[email protected]"
]
| |
9ed810dac6a692ebf7e9bc8759bc9a8f0b14479c | 52ee06f507ca2bd26c6c4694f6a0ebcc21be24cb | /Game2d/src/unb/cic/poo/game2d/items/ItemGen.java | d72e73736a83dfb69afbd9896ec008a393c43ebd | []
| no_license | joseleite19/game | ab47994b53577eaab2ca46aa8b08be1aea2fff44 | b810d911740d54562957d56c45bbbe5936b44999 | refs/heads/master | 2020-05-30T11:54:19.438185 | 2016-09-11T22:25:39 | 2016-09-11T22:25:39 | 65,823,400 | 1 | 0 | null | 2016-08-16T13:39:15 | 2016-08-16T13:39:14 | null | UTF-8 | Java | false | false | 106 | java | package unb.cic.poo.game2d.items;
public interface ItemGen {
public Item getItem(float pX, float pY);
}
| [
"[email protected]"
]
| |
907da4bed96b53667092e94eaaa7cbb0b0654dc4 | e082e05ff825a74b2232b9dd6a519a9e106af8fa | /app/src/main/java/com/sec/health/health/http/RehaCallback.java | 7db9d395595561c36a07a2daba0004c40e6acb9f | []
| no_license | ChenxiuLion/LionLib | 0e3f43e3be5bb209d88b8685f608b9e34f283236 | 020d13c4029b868456acdffb1ec21ea9632f263e | refs/heads/master | 2021-01-02T03:15:24.725945 | 2017-08-01T02:47:13 | 2017-08-01T02:47:13 | 98,950,646 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,099 | java | package com.sec.health.health.http;
import android.os.Handler;
import android.os.Looper;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
/**
* Created by chenxiu on 2017/7/18.
* Success is getting what you want
* 爱生活,爱撸码,我为自己代言。
*/
public abstract class RehaCallback implements Callback {
private Handler mHandler = new Handler(Looper.getMainLooper());
@Override
public void onFailure(final Call call, IOException e) {
mHandler.post(new Runnable() {
@Override
public void run() {
onErro(call.toString());
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String json = response.body().string();
mHandler.post(new Runnable() {
@Override
public void run() {
onSucceed(json);
}
});
}
protected abstract void onSucceed(String json);
protected abstract void onErro(String erro);
}
| [
"aa.6236990"
]
| aa.6236990 |
824e8353312a0fb7f9ce286de69051ccacdd5eff | 12b9787a4fcaceed6e9829a74b078df9c7c1601d | /Selenium_Tuts/src/Selenium_Tuts1/HandleTable.java | 5c3fbb0fb37a58227ed7921a3c4ae5bbb052638f | []
| no_license | Mohana30/Frameworks | 0f018d13751c6d199ca9fe7257893c33d2e69f67 | 6e7db06754f90984a4d34d771e54f01ad67f249a | refs/heads/master | 2022-12-06T18:38:33.232018 | 2020-08-31T09:13:40 | 2020-08-31T09:13:40 | 291,659,501 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,393 | java | package Selenium_Tuts1;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
public class HandleTable {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.cricbuzz.com/live-cricket-scorecard/29079/2nd-test-pakistan-tour-of-england-2020");
WebElement ele = driver.findElement(By.xpath("//span[text()='Pakistan 1st Innings']/parent::div/parent::div"));
int sizeEle = ele.findElements(By.cssSelector(".cb-col.cb-col-100.cb-scrd-itms div:nth-child(3)")).size();
int sum=0;
for (int i = 0; i < sizeEle-2; i++) {
String rank = ele.findElements(By.cssSelector(".cb-col.cb-col-100.cb-scrd-itms div:nth-child(3)")).get(i).getText();
sum = sum+Integer.parseInt(rank);
}
String extras = driver.findElement(By.xpath("//span[text()='Pakistan 1st Innings']/parent::div/parent::div//div[text()='Extras']/following-sibling::div")).getText();
sum = sum+Integer.parseInt(extras);
String total = ele.findElement(By.xpath("//div[text()='Total']/following-sibling::div")).getText();
int Total = Integer.parseInt(total);
Assert.assertEquals(Total, sum);
}
}
| [
"[email protected]"
]
| |
0f6d49b2d226f7e281b995a093c4e83e80779279 | dbcb1692d9a0e6d28198cbc3597d6329c9207854 | /server/src/main/java/com/advertising/dashboard/config/SecurityWebApplicationInitializer.java | cb18421a6a52e1994c509219237ae1fe37f9f31a | []
| no_license | seltsamD/advertising | 0b2feda2bd5d777015921b300d566b836ec41e87 | 5107bf0f45deadfa6f9d243cbc74e02d805815ca | refs/heads/master | 2020-04-22T20:26:40.320962 | 2019-02-18T09:17:34 | 2019-02-18T09:17:34 | 170,641,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 236 | java | package com.advertising.dashboard.config;
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
} | [
"[email protected]"
]
| |
2ad6f2def76e53d8d7b1469a7c7c6f7165f6a1fa | b85d0ce8280cff639a80de8bf35e2ad110ac7e16 | /com/fossil/cef.java | 4873a5c963c948d82ba57ee9b91d1d102af0cf08 | []
| no_license | MathiasMonstrey/fosil_decompiled | 3d90433663db67efdc93775145afc0f4a3dd150c | 667c5eea80c829164220222e8fa64bf7185c9aae | refs/heads/master | 2020-03-19T12:18:30.615455 | 2018-06-07T17:26:09 | 2018-06-07T17:26:09 | 136,509,743 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,872 | java | package com.fossil;
import android.annotation.TargetApi;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class cef {
private static final List<String> bPe = Arrays.asList(new String[]{"com.google.firebase.auth.FirebaseAuth", "com.google.firebase.iid.FirebaseInstanceId"});
private static final List<String> bPf = Collections.singletonList("com.google.firebase.crash.FirebaseCrash");
private static final List<String> bPg = Arrays.asList(new String[]{"com.google.android.gms.measurement.AppMeasurement"});
private static final List<String> bPh = Arrays.asList(new String[0]);
private static final Set<String> bPi = Collections.emptySet();
private static final Object bhH = new Object();
static final Map<String, cef> bpM = new jl();
private final ceg bPj;
private final AtomicBoolean bPk = new AtomicBoolean(false);
private final AtomicBoolean bPl = new AtomicBoolean();
private final List<Object> bPm = new CopyOnWriteArrayList();
private final List<C2021b> bPn = new CopyOnWriteArrayList();
private final List<Object> bPo = new CopyOnWriteArrayList();
private C1918a bPp;
private final Context mApplicationContext;
private final String mName;
public interface C1918a {
}
public interface C2021b {
void ba(boolean z);
}
@TargetApi(24)
static class C2022c extends BroadcastReceiver {
private static AtomicReference<C2022c> bqe = new AtomicReference();
private final Context mApplicationContext;
private C2022c(Context context) {
this.mApplicationContext = context;
}
private static void aY(Context context) {
if (bqe.get() == null) {
BroadcastReceiver c2022c = new C2022c(context);
if (bqe.compareAndSet(null, c2022c)) {
context.registerReceiver(c2022c, new IntentFilter("android.intent.action.USER_UNLOCKED"));
}
}
}
public final void onReceive(Context context, Intent intent) {
synchronized (cef.bhH) {
for (cef b : cef.bpM.values()) {
b.VT();
}
}
this.mApplicationContext.unregisterReceiver(this);
}
}
private cef(Context context, String str, ceg com_fossil_ceg) {
this.mApplicationContext = (Context) awa.bO(context);
this.mName = awa.df(str);
this.bPj = (ceg) awa.bO(com_fossil_ceg);
this.bPp = new bcf();
}
public static cef VQ() {
cef com_fossil_cef;
synchronized (bhH) {
com_fossil_cef = (cef) bpM.get("[DEFAULT]");
if (com_fossil_cef == null) {
String valueOf = String.valueOf(axu.LL());
throw new IllegalStateException(new StringBuilder(String.valueOf(valueOf).length() + 116).append("Default FirebaseApp is not initialized in this process ").append(valueOf).append(". Make sure to call FirebaseApp.initializeApp(Context) first.").toString());
}
}
return com_fossil_cef;
}
private final void VR() {
awa.m4634a(!this.bPl.get(), "FirebaseApp was deleted");
}
private final void VT() {
m6097a(cef.class, (Object) this, bPe);
if (VS()) {
m6097a(cef.class, (Object) this, bPf);
m6097a(Context.class, this.mApplicationContext, bPg);
}
}
public static cef m6095a(Context context, ceg com_fossil_ceg) {
return m6096a(context, com_fossil_ceg, "[DEFAULT]");
}
public static cef m6096a(Context context, ceg com_fossil_ceg, String str) {
Object com_fossil_cef;
bcg.aL(context);
if (context.getApplicationContext() instanceof Application) {
bdq.m4909a((Application) context.getApplicationContext());
bdq.Nd().m4910a(new cff());
}
String trim = str.trim();
if (context.getApplicationContext() != null) {
context = context.getApplicationContext();
}
synchronized (bhH) {
awa.m4634a(!bpM.containsKey(trim), new StringBuilder(String.valueOf(trim).length() + 33).append("FirebaseApp name ").append(trim).append(" already exists!").toString());
awa.m4640p(context, "Application context cannot be null.");
com_fossil_cef = new cef(context, trim, com_fossil_ceg);
bpM.put(trim, com_fossil_cef);
}
bcg.m4833a(com_fossil_cef);
com_fossil_cef.m6097a(cef.class, com_fossil_cef, bPe);
if (com_fossil_cef.VS()) {
com_fossil_cef.m6097a(cef.class, com_fossil_cef, bPf);
com_fossil_cef.m6097a(Context.class, com_fossil_cef.getApplicationContext(), bPg);
}
return com_fossil_cef;
}
private final <T> void m6097a(Class<T> cls, T t, Iterable<String> iterable) {
boolean o = gn.m10636o(this.mApplicationContext);
if (o) {
C2022c.aY(this.mApplicationContext);
}
for (String str : iterable) {
String str2;
if (o) {
try {
if (!bPh.contains(str2)) {
}
} catch (ClassNotFoundException e) {
if (bPi.contains(str2)) {
throw new IllegalStateException(String.valueOf(str2).concat(" is missing, but is required. Check if it has been removed by Proguard."));
}
Log.d("FirebaseApp", String.valueOf(str2).concat(" is not linked. Skipping initialization."));
} catch (NoSuchMethodException e2) {
throw new IllegalStateException(String.valueOf(str2).concat("#getInstance has been removed by Proguard. Add keep rule to prevent it."));
} catch (Throwable e3) {
Log.wtf("FirebaseApp", "Firebase API initialization failure.", e3);
} catch (Throwable e4) {
String str3 = "FirebaseApp";
String str4 = "Failed to initialize ";
str2 = String.valueOf(str2);
Log.wtf(str3, str2.length() != 0 ? str4.concat(str2) : new String(str4), e4);
}
}
Method method = Class.forName(str2).getMethod("getInstance", new Class[]{cls});
int modifiers = method.getModifiers();
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) {
method.invoke(null, new Object[]{t});
}
}
}
public static cef aX(Context context) {
cef VQ;
synchronized (bhH) {
if (bpM.containsKey("[DEFAULT]")) {
VQ = VQ();
} else {
ceg ba = ceg.ba(context);
if (ba == null) {
VQ = null;
} else {
VQ = m6095a(context, ba);
}
}
}
return VQ;
}
private final void bD(boolean z) {
Log.d("FirebaseApp", "Notifying background state change listeners.");
for (C2021b ba : this.bPn) {
ba.ba(z);
}
}
public static void ba(boolean z) {
synchronized (bhH) {
ArrayList arrayList = new ArrayList(bpM.values());
int size = arrayList.size();
int i = 0;
while (i < size) {
Object obj = arrayList.get(i);
i++;
cef com_fossil_cef = (cef) obj;
if (com_fossil_cef.bPk.get()) {
com_fossil_cef.bD(z);
}
}
}
}
public ceg VP() {
VR();
return this.bPj;
}
public final boolean VS() {
return "[DEFAULT]".equals(getName());
}
public boolean equals(Object obj) {
return !(obj instanceof cef) ? false : this.mName.equals(((cef) obj).getName());
}
public Context getApplicationContext() {
VR();
return this.mApplicationContext;
}
public String getName() {
VR();
return this.mName;
}
public int hashCode() {
return this.mName.hashCode();
}
public String toString() {
return avx.bN(this).m4608b("name", this.mName).m4608b("options", this.bPj).toString();
}
}
| [
"[email protected]"
]
| |
b07ffa0c5cb4f94e48329b6c0bc0f13ee49a97ba | 54556275ca0ad0fb4850b92e5921725da73e3473 | /src/com/google/common/collect/LinkedHashMultimap.java | 3a20db8443ef74c1db5cdc8e8229eedcb569c3b2 | []
| no_license | xSke/CoreServer | f7ea539617c08e4bd2206f8fa3c13c58dfb76d30 | d3655412008da22b58f031f4e7f08a6f6940bf46 | refs/heads/master | 2020-03-19T02:33:15.256865 | 2018-05-31T22:00:17 | 2018-05-31T22:00:17 | 135,638,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,438 | java | /*
* Decompiled with CFR 0_129.
*
* Could not load the following classes:
* javax.annotation.Nullable
*/
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.collect.AbstractSetMultimap;
import com.google.common.collect.CollectPreconditions;
import com.google.common.collect.Hashing;
import com.google.common.collect.ImmutableEntry;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import javax.annotation.Nullable;
@GwtCompatible(serializable=true, emulated=true)
public final class LinkedHashMultimap<K, V>
extends AbstractSetMultimap<K, V> {
private static final int DEFAULT_KEY_CAPACITY = 16;
private static final int DEFAULT_VALUE_SET_CAPACITY = 2;
@VisibleForTesting
static final double VALUE_SET_LOAD_FACTOR = 1.0;
@VisibleForTesting
transient int valueSetCapacity = 2;
private transient ValueEntry<K, V> multimapHeaderEntry;
@GwtIncompatible(value="java serialization not supported")
private static final long serialVersionUID = 1L;
public static <K, V> LinkedHashMultimap<K, V> create() {
return new LinkedHashMultimap<K, V>(16, 2);
}
public static <K, V> LinkedHashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) {
return new LinkedHashMultimap<K, V>(Maps.capacity(expectedKeys), Maps.capacity(expectedValuesPerKey));
}
public static <K, V> LinkedHashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) {
LinkedHashMultimap<K, V> result = LinkedHashMultimap.create(multimap.keySet().size(), 2);
result.putAll(multimap);
return result;
}
private static <K, V> void succeedsInValueSet(ValueSetLink<K, V> pred, ValueSetLink<K, V> succ) {
pred.setSuccessorInValueSet(succ);
succ.setPredecessorInValueSet(pred);
}
private static <K, V> void succeedsInMultimap(ValueEntry<K, V> pred, ValueEntry<K, V> succ) {
pred.setSuccessorInMultimap(succ);
succ.setPredecessorInMultimap(pred);
}
private static <K, V> void deleteFromValueSet(ValueSetLink<K, V> entry) {
LinkedHashMultimap.succeedsInValueSet(entry.getPredecessorInValueSet(), entry.getSuccessorInValueSet());
}
private static <K, V> void deleteFromMultimap(ValueEntry<K, V> entry) {
LinkedHashMultimap.succeedsInMultimap(entry.getPredecessorInMultimap(), entry.getSuccessorInMultimap());
}
private LinkedHashMultimap(int keyCapacity, int valueSetCapacity) {
super(new LinkedHashMap(keyCapacity));
CollectPreconditions.checkNonnegative(valueSetCapacity, "expectedValuesPerKey");
this.valueSetCapacity = valueSetCapacity;
this.multimapHeaderEntry = new ValueEntry<Object, Object>(null, null, 0, null);
LinkedHashMultimap.succeedsInMultimap(this.multimapHeaderEntry, this.multimapHeaderEntry);
}
@Override
Set<V> createCollection() {
return new LinkedHashSet(this.valueSetCapacity);
}
@Override
Collection<V> createCollection(K key) {
return new ValueSet(key, this.valueSetCapacity);
}
@Override
public Set<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
return super.replaceValues((Object)key, (Iterable)values);
}
@Override
public Set<Map.Entry<K, V>> entries() {
return super.entries();
}
@Override
public Collection<V> values() {
return super.values();
}
@Override
Iterator<Map.Entry<K, V>> entryIterator() {
return new Iterator<Map.Entry<K, V>>(){
ValueEntry<K, V> nextEntry;
ValueEntry<K, V> toRemove;
{
this.nextEntry = LinkedHashMultimap.access$300((LinkedHashMultimap)LinkedHashMultimap.this).successorInMultimap;
}
@Override
public boolean hasNext() {
return this.nextEntry != LinkedHashMultimap.this.multimapHeaderEntry;
}
@Override
public Map.Entry<K, V> next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
ValueEntry<K, V> result = this.nextEntry;
this.toRemove = result;
this.nextEntry = this.nextEntry.successorInMultimap;
return result;
}
@Override
public void remove() {
CollectPreconditions.checkRemove(this.toRemove != null);
LinkedHashMultimap.this.remove(this.toRemove.getKey(), this.toRemove.getValue());
this.toRemove = null;
}
};
}
@Override
Iterator<V> valueIterator() {
return Maps.valueIterator(this.entryIterator());
}
@Override
public void clear() {
super.clear();
LinkedHashMultimap.succeedsInMultimap(this.multimapHeaderEntry, this.multimapHeaderEntry);
}
@GwtIncompatible(value="java.io.ObjectOutputStream")
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
stream.writeInt(this.valueSetCapacity);
stream.writeInt(this.keySet().size());
for (Object key : this.keySet()) {
stream.writeObject(key);
}
stream.writeInt(this.size());
for (Map.Entry entry : this.entries()) {
stream.writeObject(entry.getKey());
stream.writeObject(entry.getValue());
}
}
@GwtIncompatible(value="java.io.ObjectInputStream")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.multimapHeaderEntry = new ValueEntry<Object, Object>(null, null, 0, null);
LinkedHashMultimap.succeedsInMultimap(this.multimapHeaderEntry, this.multimapHeaderEntry);
this.valueSetCapacity = stream.readInt();
int distinctKeys = stream.readInt();
LinkedHashMap<Object, Collection<V>> map = new LinkedHashMap<Object, Collection<V>>(Maps.capacity(distinctKeys));
for (int i = 0; i < distinctKeys; ++i) {
Object key = stream.readObject();
map.put(key, this.createCollection(key));
}
int entries = stream.readInt();
for (int i = 0; i < entries; ++i) {
Object key = stream.readObject();
Object value = stream.readObject();
((Collection)map.get(key)).add(value);
}
this.setMap(map);
}
@VisibleForTesting
final class ValueSet
extends Sets.ImprovedAbstractSet<V>
implements ValueSetLink<K, V> {
private final K key;
@VisibleForTesting
ValueEntry<K, V>[] hashTable;
private int size = 0;
private int modCount = 0;
private ValueSetLink<K, V> firstEntry;
private ValueSetLink<K, V> lastEntry;
ValueSet(K key, int expectedValues) {
this.key = key;
this.firstEntry = this;
this.lastEntry = this;
int tableSize = Hashing.closedTableSize(expectedValues, 1.0);
ValueEntry[] hashTable = new ValueEntry[tableSize];
this.hashTable = hashTable;
}
private int mask() {
return this.hashTable.length - 1;
}
@Override
public ValueSetLink<K, V> getPredecessorInValueSet() {
return this.lastEntry;
}
@Override
public ValueSetLink<K, V> getSuccessorInValueSet() {
return this.firstEntry;
}
@Override
public void setPredecessorInValueSet(ValueSetLink<K, V> entry) {
this.lastEntry = entry;
}
@Override
public void setSuccessorInValueSet(ValueSetLink<K, V> entry) {
this.firstEntry = entry;
}
@Override
public Iterator<V> iterator() {
return new Iterator<V>(){
ValueSetLink<K, V> nextEntry;
ValueEntry<K, V> toRemove;
int expectedModCount;
{
this.nextEntry = ValueSet.this.firstEntry;
this.expectedModCount = ValueSet.this.modCount;
}
private void checkForComodification() {
if (ValueSet.this.modCount != this.expectedModCount) {
throw new ConcurrentModificationException();
}
}
@Override
public boolean hasNext() {
this.checkForComodification();
return this.nextEntry != ValueSet.this;
}
@Override
public V next() {
if (!this.hasNext()) {
throw new NoSuchElementException();
}
ValueEntry entry = (ValueEntry)this.nextEntry;
Object result = entry.getValue();
this.toRemove = entry;
this.nextEntry = entry.getSuccessorInValueSet();
return result;
}
@Override
public void remove() {
this.checkForComodification();
CollectPreconditions.checkRemove(this.toRemove != null);
ValueSet.this.remove(this.toRemove.getValue());
this.expectedModCount = ValueSet.this.modCount;
this.toRemove = null;
}
};
}
@Override
public int size() {
return this.size;
}
@Override
public boolean contains(@Nullable Object o) {
int smearedHash = Hashing.smearedHash(o);
ValueEntry<K, V> entry = this.hashTable[smearedHash & this.mask()];
while (entry != null) {
if (entry.matchesValue(o, smearedHash)) {
return true;
}
entry = entry.nextInValueBucket;
}
return false;
}
@Override
public boolean add(@Nullable V value) {
ValueEntry<K, V> rowHead;
int smearedHash = Hashing.smearedHash(value);
int bucket = smearedHash & this.mask();
ValueEntry<K, V> entry = rowHead = this.hashTable[bucket];
while (entry != null) {
if (entry.matchesValue(value, smearedHash)) {
return false;
}
entry = entry.nextInValueBucket;
}
ValueEntry<K, V> newEntry = new ValueEntry<K, V>(this.key, value, smearedHash, rowHead);
LinkedHashMultimap.succeedsInValueSet(this.lastEntry, newEntry);
LinkedHashMultimap.succeedsInValueSet(newEntry, this);
LinkedHashMultimap.succeedsInMultimap(LinkedHashMultimap.this.multimapHeaderEntry.getPredecessorInMultimap(), newEntry);
LinkedHashMultimap.succeedsInMultimap(newEntry, LinkedHashMultimap.this.multimapHeaderEntry);
this.hashTable[bucket] = newEntry;
++this.size;
++this.modCount;
this.rehashIfNecessary();
return true;
}
private void rehashIfNecessary() {
if (Hashing.needsResizing(this.size, this.hashTable.length, 1.0)) {
ValueEntry[] hashTable = new ValueEntry[this.hashTable.length * 2];
this.hashTable = hashTable;
int mask = hashTable.length - 1;
for (ValueSetLink<K, V> entry = this.firstEntry; entry != this; entry = entry.getSuccessorInValueSet()) {
ValueEntry valueEntry = (ValueEntry)entry;
int bucket = valueEntry.smearedValueHash & mask;
valueEntry.nextInValueBucket = hashTable[bucket];
hashTable[bucket] = valueEntry;
}
}
}
@Override
public boolean remove(@Nullable Object o) {
int smearedHash = Hashing.smearedHash(o);
int bucket = smearedHash & this.mask();
ValueEntry<K, V> prev = null;
ValueEntry<K, V> entry = this.hashTable[bucket];
while (entry != null) {
if (entry.matchesValue(o, smearedHash)) {
if (prev == null) {
this.hashTable[bucket] = entry.nextInValueBucket;
} else {
prev.nextInValueBucket = entry.nextInValueBucket;
}
LinkedHashMultimap.deleteFromValueSet(entry);
LinkedHashMultimap.deleteFromMultimap(entry);
--this.size;
++this.modCount;
return true;
}
prev = entry;
entry = entry.nextInValueBucket;
}
return false;
}
@Override
public void clear() {
Arrays.fill(this.hashTable, null);
this.size = 0;
for (ValueSetLink<K, V> entry = this.firstEntry; entry != this; entry = entry.getSuccessorInValueSet()) {
ValueEntry valueEntry = (ValueEntry)entry;
LinkedHashMultimap.deleteFromMultimap(valueEntry);
}
LinkedHashMultimap.succeedsInValueSet(this, this);
++this.modCount;
}
}
@VisibleForTesting
static final class ValueEntry<K, V>
extends ImmutableEntry<K, V>
implements ValueSetLink<K, V> {
final int smearedValueHash;
@Nullable
ValueEntry<K, V> nextInValueBucket;
ValueSetLink<K, V> predecessorInValueSet;
ValueSetLink<K, V> successorInValueSet;
ValueEntry<K, V> predecessorInMultimap;
ValueEntry<K, V> successorInMultimap;
ValueEntry(@Nullable K key, @Nullable V value, int smearedValueHash, @Nullable ValueEntry<K, V> nextInValueBucket) {
super(key, value);
this.smearedValueHash = smearedValueHash;
this.nextInValueBucket = nextInValueBucket;
}
boolean matchesValue(@Nullable Object v, int smearedVHash) {
return this.smearedValueHash == smearedVHash && Objects.equal(this.getValue(), v);
}
@Override
public ValueSetLink<K, V> getPredecessorInValueSet() {
return this.predecessorInValueSet;
}
@Override
public ValueSetLink<K, V> getSuccessorInValueSet() {
return this.successorInValueSet;
}
@Override
public void setPredecessorInValueSet(ValueSetLink<K, V> entry) {
this.predecessorInValueSet = entry;
}
@Override
public void setSuccessorInValueSet(ValueSetLink<K, V> entry) {
this.successorInValueSet = entry;
}
public ValueEntry<K, V> getPredecessorInMultimap() {
return this.predecessorInMultimap;
}
public ValueEntry<K, V> getSuccessorInMultimap() {
return this.successorInMultimap;
}
public void setSuccessorInMultimap(ValueEntry<K, V> multimapSuccessor) {
this.successorInMultimap = multimapSuccessor;
}
public void setPredecessorInMultimap(ValueEntry<K, V> multimapPredecessor) {
this.predecessorInMultimap = multimapPredecessor;
}
}
private static interface ValueSetLink<K, V> {
public ValueSetLink<K, V> getPredecessorInValueSet();
public ValueSetLink<K, V> getSuccessorInValueSet();
public void setPredecessorInValueSet(ValueSetLink<K, V> var1);
public void setSuccessorInValueSet(ValueSetLink<K, V> var1);
}
}
| [
"[email protected]"
]
| |
53ac649ad92f5a1bc7e259015ab4b938c26a9ab5 | 30031789491b9cc7ca8ab8662df23412642891c9 | /src/main/java/com/algortithms/sort/RadixSort.java | 4e11746ed3b28aac8ca44de33071eb2c26b876e4 | []
| no_license | rodrigomirazo/algorithms | 2529f6ce78b83af08c8f3928d7aead1f3a5a31e8 | cf3d686caec101682262e62880824f99635d12f4 | refs/heads/master | 2021-07-15T02:34:33.196165 | 2020-06-11T14:36:59 | 2020-06-11T14:36:59 | 167,308,643 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,995 | java | package com.algortithms.sort;
import java.io.*;
import java.util.*;
class RadixSort {
/*Driver function to check for above function*/
public static void main (String[] args)
{
int arr[] = {170, 45, 75, 90, 802, 24, 2, 66};
int n = arr.length;
radixsort(arr, n);
System.out.println("\n Result = " + print(arr));
}
// The main function to that sorts arr[] of size n using
// RadixSort Sort
static void radixsort(int arr[], int n)
{
// Find the maximum number to know number of digits
int m = getMax(arr, n);
// Do counting sort for every digit. Note that instead
// of passing digit number, exp is passed. exp is 10^i
// where i is current digit number
for (int exp = 1; m/exp > 0; exp *= 10) {
System.out.println("\n");
countSort(arr, n, exp);
System.out.println("\n");
}
}
// A function to do counting sort of arr[] according to
// the digit represented by exp.
static void countSort(int arr[], int n, int exp)
{
int output[] = new int[n]; // output array
int i;
int count[] = new int[10];
Arrays.fill(count,0);
System.out.println("1) Fill count = " + print(count));
// Store count of occurrences in count[]
for (i = 0; i < n; i++) {
int expCalc = (arr[i]/exp)%10;
count[ expCalc ]++;
}
System.out.println("2) Store count of occurrences in count[] = " + print(count));
// Change count[i] so that count[i] now contains
// actual position of this digit in output[]
for (i = 1; i < 10; i++)
count[i] += count[i - 1];
System.out.println("3) count[i]= += count[i - 1]; => " + print(count));
// Build the output array
for (i = n - 1; i >= 0; i--)
{
int expCalc = (arr[i]/exp)%10;
int countIndex = count[ expCalc ];
output[countIndex - 1] = arr[i];
count[ expCalc ]--;
}
System.out.println("4) output => " + print(count));
// Copy the output array to arr[], so that arr[] now
// contains sorted numbers according to curent digit
for (i = 0; i < n; i++)
arr[i] = output[i];
}
// A utility function to get maximum value in arr[]
static int getMax(int arr[], int n)
{
int mx = arr[0];
for (int i = 1; i < n; i++)
if (arr[i] > mx)
mx = arr[i];
return mx;
}
// A utility function to print an array
static void print(int arr[], int n)
{
for (int i=0; i<n; i++)
System.out.print(arr[i]+" ");
}
static String print(int arr[]) {
String arrString = "";
for (int i=0; i<arr.length; i++)
arrString = arrString.concat( arr[i] + " ");
return arrString;
}
}
/* This code is contributed by Devesh Agrawal */
| [
"[email protected]"
]
| |
4268655ac183dba3cda6726c8145675ea517922e | 565d6d61c8003d5a4aee122034817d44e55b00ff | /mailcasting/src/GetCon.java | 9750850e6ef58c42c203dc3698b96189e166d1b1 | []
| no_license | vinayv1208/Egiants_tasks | c56b3e8d38c75a594d3d094845e42b1bab983542 | 894e6cc0f95757e87218105c31926bd3cb1a74ab | refs/heads/master | 2023-01-09T21:10:09.690459 | 2019-09-22T13:11:39 | 2019-09-22T13:11:39 | 204,596,002 | 1 | 0 | null | 2022-12-31T02:49:54 | 2019-08-27T01:45:56 | Java | UTF-8 | Java | false | false | 516 | java | import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class GetCon {
private GetCon(){}
public static Connection con;
static{
try {
Class.forName(DBIntializer.DRIVER);
con=DriverManager.getConnection(DBIntializer.CON_STRING,DBIntializer.USERNAME,DBIntializer.PASSWORD);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
System.out.println("Exception in GetCon");
}
}
public static Connection getCon(){
return con;
}
}
| [
"[email protected]"
]
| |
66c5ba708116a6745c2e040870000d1f4b0931a1 | 6ef5e630d996943cb64d077941b29ea085e6a372 | /src/test/java/com/alanihre/chess/board/BoardTest.java | 14cb0964088501b06e3cfca05de69da5b1910422 | []
| no_license | alanihre/chess | 102a0f59cadc83ace6f9e9e7cf2a57f6cd69a8ef | f892493710d4f7d069fc0b386727d39fa76649f5 | refs/heads/master | 2021-01-22T12:17:06.729600 | 2016-09-27T11:28:14 | 2016-09-27T11:28:14 | 68,321,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,449 | java | package com.alanihre.chess.board;
import com.alanihre.chess.piece.Pawn;
import com.alanihre.chess.piece.Piece;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public class BoardTest {
private static int BOARD_SIZE_WIDTH = 8;
private static int BOARD_SIZE_HEIGHT = 9;
private Board board;
@Before
public void setUp() {
board = new StubBoard(BOARD_SIZE_WIDTH, BOARD_SIZE_HEIGHT);
}
@Test
public void testConstructor() {
assertEquals(BOARD_SIZE_WIDTH, board.getWidth());
assertEquals(BOARD_SIZE_HEIGHT, board.getHeight());
}
@Test
public void testCreateHorizontalLabels() {
char[] horizontalLabels = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
assertTrue(Arrays.equals(board.getHorizontalLabels(), horizontalLabels));
}
@Test
public void testCreateVerticalLabels() {
char[] verticalLabels = {'9', '8', '7', '6', '5', '4', '3', '2', '1'};
assertTrue(Arrays.equals(board.getVerticalLabels(), verticalLabels));
}
@Test
public void testPositionWithinBoardBounds() {
Position positionOutsideBoardBounds = new Position(BOARD_SIZE_WIDTH + 1, BOARD_SIZE_HEIGHT + 1);
assertFalse(board.positionWithinBoardBounds(positionOutsideBoardBounds));
Position positionInsideBoardBounds = new Position(BOARD_SIZE_WIDTH - 1, BOARD_SIZE_HEIGHT - 1);
assertTrue(board.positionWithinBoardBounds(positionInsideBoardBounds));
}
@Test
public void testPutPiece() {
Position position = new Position(0, 0);
Piece piece = new Pawn(Piece.PieceColor.BLACK);
board.putPiece(piece, position);
Piece actualPieceAtPosition = board.getSquareAtPosition(position).getPiece();
assertSame(piece, actualPieceAtPosition);
}
@Test
public void testBoardPointToLabeledPoint() {
Position position = new Position(1, 2);
String expectedLabeledPoint = "b7";
String actualLabeledPoint = board.boardPointToLabeledPoint(position);
assertEquals(expectedLabeledPoint, actualLabeledPoint);
}
@Test
public void testLabeledPointToBoardPoint() {
String labeledPoint = "b7";
Position expectedPosition = new Position(1, 2);
Position actualPosition = board.labeledPointToBoardPoint(labeledPoint);
assertEquals(expectedPosition, actualPosition);
}
}
| [
"[email protected]"
]
| |
c4619a25872a8f60a8fd51511ad7ede87ebcce5d | 02570607edea101396ff231025498056ece3df31 | /leanback-v17/src/main/java/com/open/leanback/widget/ListRow.java | 57fc02e18f1ae5c7c47a1694be502c2f6d9ae279 | []
| no_license | SKToukir/FileBrowser-TV | 978048f6d172224522d57b06a2282b2f9fd922ea | 25b6d2f19bd76d7933f143744d1b01a40958f2ef | refs/heads/master | 2023-03-05T15:12:25.861913 | 2021-02-18T04:41:21 | 2021-02-18T04:41:21 | 334,580,130 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,807 | java | /*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.open.leanback.widget;
/**
* A {@link Row} composed of a optional {@link HeaderItem}, and an {@link ObjectAdapter}
* describing the items in the list.
*/
public class ListRow extends Row {
private final ObjectAdapter mAdapter;
private CharSequence mContentDescription;
/**
* Returns the {@link ObjectAdapter} that represents a list of objects.
*/
public final ObjectAdapter getAdapter() {
return mAdapter;
}
public ListRow(HeaderItem header, ObjectAdapter adapter) {
super(header);
mAdapter = adapter;
verify();
}
public ListRow(long id, HeaderItem header, ObjectAdapter adapter) {
super(id, header);
mAdapter = adapter;
verify();
}
public ListRow(ObjectAdapter adapter) {
super();
mAdapter = adapter;
verify();
}
private void verify() {
if (mAdapter == null) {
throw new IllegalArgumentException("ObjectAdapter cannot be null");
}
}
/**
* Returns content description for the ListRow. By default it returns
* {@link HeaderItem#getContentDescription()} or {@link HeaderItem#getName()},
* unless {@link #setContentDescription(CharSequence)} was explicitly called.
*
* @return Content description for the ListRow.
*/
public CharSequence getContentDescription() {
if (mContentDescription != null) {
return mContentDescription;
}
final HeaderItem headerItem = getHeaderItem();
if (headerItem != null) {
CharSequence contentDescription = headerItem.getContentDescription();
if (contentDescription != null) {
return contentDescription;
}
return headerItem.getName();
}
return null;
}
/**
* Explicitly set content description for the ListRow, {@link #getContentDescription()} will
* ignore values from HeaderItem.
*
* @param contentDescription Content description sets on the ListRow.
*/
public void setContentDescription(CharSequence contentDescription) {
mContentDescription = contentDescription;
}
} | [
"[email protected]"
]
| |
2e87232c9b3086eb7e7b22d05be967d9ef7fce6d | fa9e4292ed04464239ffb2dfa6bd503581613a75 | /miniSpring-ioc/src/main/java/org/miniSpring/ioc/Bean/PropertyArg.java | a84f63bd7ccf102186894764b4717dfd18846e3c | []
| no_license | n040661/miniSpring | 5faa6c2954bc936317e40eab8ea658c40aed03e4 | 55389ddf8282007bfa6846b9db588dc02196c4e1 | refs/heads/master | 2020-03-26T17:43:56.006338 | 2018-04-20T03:06:20 | 2018-04-20T03:06:20 | 145,177,085 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 541 | java | package org.miniSpring.ioc.Bean;
/**
* 元素属性
* @author hongyang.jiang
*
*/
public class PropertyArg {
private String name;
private String value;
private String typeName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
} | [
"[email protected]"
]
| |
743e13e94d099ef0ec1abdbf82abe9659fea00a4 | 6c52bfc829eeb725207e1b9605f4bb9f35366b84 | /알쏭달쏭200/src/Ch06/ex06_14.java | 419d4da94d9986569be663c4ae07306867c96eb3 | []
| no_license | mylovejlj/200Qs | d9a6af0b6cc4ec39400c29a76256f8d0f5dd40df | ccf48cf054ea32962bc542a93a0fcf61e8a01377 | refs/heads/master | 2023-03-08T04:43:43.796501 | 2021-03-01T07:35:46 | 2021-03-01T07:35:46 | 343,328,047 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 892 | java | package Ch06;
import java.util.Random;
import java.util.Scanner;
//배열 a의 모든 요소를 역순으로 배열 b에 복사하는 프로그램을 만들자. 두 배열의 요소수는 동일하다해도 좋다.
public class ex06_14 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 요소 수 읽기
System.out.print("요소 수:");
int n = sc.nextInt();
int[] arr = new int[n];
int[] arr_copy = new int[n];
// 배열 생성
for (int i = 0; i < n; i++) {
System.out.println("arr[" + i + "]=");
arr[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
arr_copy[i] = arr[n-1-i];
}
// 출력
for (int i = 0; i < n; i++) {
System.out.println("요소를 역순으로 배열했습니다.");
System.out.println("arr_copy[" + i + "]=" + arr_copy[i]);
}
}
}
| [
"leenara@DESKTOP-D1N69LA"
]
| leenara@DESKTOP-D1N69LA |
097c87fa0527d0fc810f4f9a4b1f5462ca5bbc04 | 0f26ed96f91f52e17132428b815dc4807f7da28c | /jxsm/src/main/java/com/wl/jx/dao/impl/PackingListDaoImpl.java | 214ed23176f495c535bb3a3b4f97a2132756f8cc | []
| no_license | wanlin77/jxsm | 88d816fbe6e27f8fb3af65ce2e4b72de7ed402f5 | 9ff4a4c3ef41dd286be996658e9a1de5fd304066 | refs/heads/master | 2021-04-27T00:27:13.825270 | 2018-03-22T06:53:16 | 2018-03-22T06:53:16 | 123,817,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package com.wl.jx.dao.impl;
import org.springframework.stereotype.Repository;
import com.wl.jx.dao.PackingListDao;
import com.wl.jx.domain.PackingList;
@Repository
public class PackingListDaoImpl extends BaseDaoImpl<PackingList> implements PackingListDao{
public PackingListDaoImpl() {
this.setNs("com.wl.jx.mapper.PackingListMapper."); //设置命名空间
}
}
| [
"[email protected]"
]
| |
1f369595e19852b662774dc92fb2a5a787ce0d1b | 2e0c63c750acaa434818311f178c11dc4de0e004 | /src/controllers/login/LogoutServlet.java | b2d82ca0ffae575cb37fed905e34924860f6efcc | []
| no_license | pochi01/daily_report_system_mn | a81c04fa655a302ba060ebaefd00f0323063359a | b08a40dcdb7c34dae64fea04e8f02da90db4d848 | refs/heads/master | 2020-04-14T21:40:51.744370 | 2019-01-05T12:40:11 | 2019-01-05T12:40:11 | 164,136,554 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,025 | java | package controllers.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LogoutServlet
*/
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LogoutServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getSession().removeAttribute("login_employee");
request.getSession().setAttribute("flush", "ログアウトしました。");
response.sendRedirect(request.getContextPath() + "/login");
}
}
| [
"[email protected]"
]
| |
e663d02e3950145fb6634b984f7b1fbb2994958f | 3779eabe054707b9ccbce46d63136b6e7739b15d | /src/info/realjin/newsintime/service/DbManagerService.java | ddb03b2f83418c3dfc8fbdc5ab66a2406f5f9944 | []
| no_license | realjin/NewsInTime | 9b9283c10960b727938639fae6fd42894e6d66f2 | 8165d60d5dfe352f360e136394c572662d35ff7a | refs/heads/master | 2021-01-01T18:38:13.669584 | 2013-02-16T13:23:00 | 2013-02-16T13:23:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,044 | java | package info.realjin.newsintime.service;
import info.realjin.newsintime.dao.CollectionDao;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;
/*
* http://stackoverflow.com/questions/3684678/best-practices-of-working-with-multiple-sqlite-db-tables-in-android
*/
public class DbManagerService {
private static final String LOG_TAG = DbManagerService.class
.getSimpleName();
private SQLiteDatabase db;
private static MySQLiteOpenHelper helper;
private Context ctx;
private CollectionDao collectionDao;
public DbManagerService(Context c) {
ctx = c;
helper = new MySQLiteOpenHelper(c);
Log.e("HELPER+=======", "" + helper);
db = helper.getWritableDatabase();
collectionDao = new CollectionDao(this);
}
/**
* init database tables
*/
public void initDatabase() {
checkDbState();
Log.i("===DBM===", "** init db");
db.execSQL("CREATE TABLE IF NOT EXISTS " + Table_Collection.TNAME
+ " (" + Table_Collection.CNAME_ID + " INTEGER PRIMARY KEY,"
+ Table_Collection.CNAME_NAME + " TEXT,"
+ Table_Collection.CNAME_ENABLED + " INTEGER,"
+ Table_Collection.CNAME_UPDATETIME + " TEXT);");
db.execSQL("CREATE TABLE IF NOT EXISTS "
+ Table_CollectionCollectionItem.TNAME + " ("
+ Table_CollectionCollectionItem.CNAME_ID
+ " INTEGER PRIMARY KEY,"
+ Table_CollectionCollectionItem.CNAME_COLLID + " INTEGER,"
+ Table_CollectionCollectionItem.CNAME_COLLITEMID
+ " INTEGER);");
db.execSQL("CREATE TABLE IF NOT EXISTS " + Table_CollectionItem.TNAME
+ " (" + Table_CollectionItem.CNAME_ID
+ " INTEGER PRIMARY KEY," + Table_CollectionItem.CNAME_NAME
+ " TEXT," + Table_CollectionItem.CNAME_URL + " TEXT,"
+ Table_CollectionItem.CNAME_TYPE + " TEXT,"
+ Table_CollectionItem.CNAME_PREDEFINED + " TEXT,"
+ Table_CollectionItem.CNAME_UPDATETIME + " TEXT);");
}
public static final class Table_Collection implements BaseColumns {
public static final String TNAME = "NEWSINTIME_COLLECTION";
public static final String CNAME_ID = "id";
public static final String CNAME_NAME = "name";
public static final String CNAME_ENABLED = "enabled";
public static final String CNAME_UPDATETIME = "updatetime";
public static final int DEFAULTVALUE_ENABLED_FALSE = -1;
public static final int DEFAULTVALUE_ENABLED_TRUE = 0;
}
public static final class Table_CollectionCollectionItem implements
BaseColumns {
public static final String TNAME = "NEWSINTIME_COLLECTION_COLLECTIONITEM";
public static final String CNAME_ID = "id";
public static final String CNAME_COLLID = "collid";
public static final String CNAME_COLLITEMID = "collitemid";
}
public static final class Table_CollectionItem implements BaseColumns {
public static final String TNAME = "NEWSINTIME_COLLECTIONITEM";
public static final String CNAME_ID = "id";
public static final String CNAME_NAME = "name";
public static final String CNAME_URL = "url";
// public static final String CNAME_COLLID = "collid";
public static final String CNAME_TYPE = "type";
public static final String CNAME_PREDEFINED = "predefined";
public static final String CNAME_UPDATETIME = "updatetime";
public static final String CNAME_OWNER = "owner";
}
public boolean isOpen() {
return db != null && db.isOpen();
}
public void open() {
helper = new MySQLiteOpenHelper(ctx);
if (!isOpen()) {
db = helper.getWritableDatabase();
}
}
public void close() {
if (isOpen()) {
db.close();
db = null;
if (helper != null) {
helper.close();
helper = null;
}
}
}
private boolean checkDbState() {
if (db == null || !db.isOpen()) {
// throw new
// IllegalStateException("The database has not been opened");
return false;
}
return true;
}
/**
* return db that is opened!!
*/
public SQLiteDatabase getDb() {
if (checkDbState()) {
return db;
} else {
open();
if (!checkDbState()) {
throw new IllegalStateException(
"The database has not been opened");
}
return db;
}
}
private static class MySQLiteOpenHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "newsintime_test.db";
private static final int DATABASE_VERSION = 7;
private MySQLiteOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(LOG_TAG, "Upgrading database from version " + oldVersion
+ " to " + newVersion + "!");
}
private void dropDatabase(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + Table_Collection.TNAME);
db.execSQL("DROP TABLE IF EXISTS " + Table_CollectionItem.TNAME);
}
}
public CollectionDao getCollectionDao() {
return collectionDao;
}
public void setCollectionDao(CollectionDao collectionDao) {
this.collectionDao = collectionDao;
}
}
| [
"[email protected]"
]
| |
16d0cd30130858c4dca4dbf32e32bbd930a68c81 | b0d1dd5611bd6deb4cd5549dc778d7c6cd77477a | /sams-enquiry-0.0.8/src/com/narendra/sams/enquiry/domain/StudentPrevClass.java | 6336db7479e74f407ca72bfbe5643606e4a4aeb6 | []
| no_license | kajubaba/kamlesh | a28496e4bb8a277532ed01c9c9e0ced31b27b064 | 3419fd55afe8044660948cd6ed5342ed025b81e8 | refs/heads/master | 2021-07-06T16:22:47.738261 | 2017-10-02T06:59:23 | 2017-10-02T06:59:23 | 105,502,681 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,666 | java | package com.narendra.sams.enquiry.domain;
public class StudentPrevClass {
public static String STATUS_BLANK = "";
public static String STATUS_FAIL = "fail";
public static String STATUS_PURSUING = "pursuing";
public static String STATUS_RESULT_AWAITED = "result awaited";
public static String STATUS_RESULT_DECLARED = "result declared";
private String board;
private String city;
private String className;
private Long id;
private String instituteName;
private Float percentage;
private String studentStatus;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public String getClassName() {
return this.className;
}
public void setClassName(String className) {
this.className = className;
}
public String getInstituteName() {
return this.instituteName;
}
public void setInstituteName(String instituteName) {
this.instituteName = instituteName;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getBoard() {
return this.board;
}
public void setBoard(String board) {
this.board = board;
}
public String getStudentStatus() {
return this.studentStatus;
}
public void setStudentStatus(String studentStatus) {
this.studentStatus = studentStatus;
}
public Float getPercentage() {
return this.percentage;
}
public void setPercentage(Float percentage) {
this.percentage = percentage;
}
}
| [
"[email protected]"
]
| |
e0172e759e9a4641201a94e6c361e97d535a503a | 6e755a3fc1217c4620c6522cf01eb93d8329b3b5 | /app/src/main/java/com/uwaterloo/portfoliorebalancing/model/SimulationStrategy.java | 2fc79f9c87b070e1545948c90f3be8ed59d12bac | []
| no_license | portfoliorebalancing/portfolio-rebalancing-android | f9257a2005e2dab4afd99db037b05f7226390072 | 19a2abe70b5c4c4700ae276bf322a4eee2a4c273 | refs/heads/master | 2020-12-24T09:16:56.459604 | 2016-12-19T00:02:58 | 2016-12-19T00:02:58 | 73,300,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,091 | java | package com.uwaterloo.portfoliorebalancing.model;
import com.orm.SugarRecord;
/**
* Created by lucas on 16/11/16.
*/
public class SimulationStrategy extends SugarRecord<SimulationStrategy> {
private Simulation simulation;
private int strategy;
private double floor;
private double multiplier;
private double optionPrice;
private double strike;
public SimulationStrategy() {}
public SimulationStrategy(Simulation simulation, int strategy, double floor, double multiplier, double optionPrice, double strike) {
this.simulation = simulation;
this.strategy = strategy;
this.floor = floor;
this.multiplier = multiplier;
this.optionPrice = optionPrice;
this.strike = strike;
}
public double getFloor() {
return floor;
}
public double getMultiplier() {
return multiplier;
}
public double getOptionPrice() {
return optionPrice;
}
public double getStrike() {
return strike;
}
public int getStrategy() {
return strategy;
}
}
| [
"[email protected]"
]
| |
4b5b39757d3239aa4532a5681a60c2cc16a08246 | 683c818f66432f251aaa9940651098d2bfb73776 | /PersonalFolder/taewoo/src/member/command/LogoutHandler.java | 8495a09692b593926b47d14d81f6af5b4abe042c | []
| no_license | dbxodnsms/jusiktopia | 51f04b7af5e4a9b45c73ebf641d079fdf0a6d3e3 | a52db51f90e65603c3103a0281796ca2ba5e8487 | refs/heads/master | 2023-04-18T02:18:12.827918 | 2020-05-22T08:22:25 | 2020-05-22T08:22:25 | 255,502,804 | 1 | 1 | null | 2021-05-01T06:49:41 | 2020-04-14T03:40:05 | HTML | UTF-8 | Java | false | false | 698 | java | package member.command;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import controller.command.CommandHandler;
public class LogoutHandler implements CommandHandler{
private HttpSession session;
private String path;
@Override
public String process(HttpServletRequest request, HttpServletResponse response) throws Exception {
session = request.getSession();
session.invalidate();
path = request.getParameter("path");
System.out.println("path="+path);
System.out.println(request.getRequestURI());
request.setAttribute("path", path);
return "/member/logoutSuccess.jsp";
}
}
| [
"[email protected]"
]
| |
f867c388dc40726a99ce6a9966f9d1e68ed11e4c | d250057f6fae1ebf46a21380fc8b16809d2492f2 | /LeetCode/20210624LC/src/HJ40.java | 87338d4aaa23afdd5b2e515b8c154378f7e4ff60 | []
| no_license | BJT55/Code | 19a4c810fbe45d5140fcaf025f1c4bcbb335f90b | 2b26f8d825f8df129403e11c31f0da32d22c911b | refs/heads/master | 2023-08-22T21:29:49.665445 | 2021-10-13T15:12:20 | 2021-10-13T15:12:20 | 316,652,235 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 807 | java | import java.util.Scanner;
public class HJ40 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String s = in.nextLine();
int letter = 0, blank = 0, digit = 0, other = 0;
for(char c : s.toCharArray()){
if(Character.isLetter(c)){
letter++;
}else if(Character.isDigit(c)){
digit++;
}else if(c == ' '){
blank++;
}else{
other++;
}
}
System.out.println(letter);
System.out.println(blank);
System.out.println(digit);
System.out.println(other);
}
}
}
| [
"[email protected]"
]
| |
c138b3c2b359b81019bb150c126a81cc3799da91 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/4/4_186e0bf4cfd7f58d10115a17b66c7373fad0fbaf/CommunityService/4_186e0bf4cfd7f58d10115a17b66c7373fad0fbaf_CommunityService_s.java | 34a7d9d13f056e1705ce7960e08937592db73d8e | []
| 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 | 38,479 | java | /*
* Copyright IBM Corp. 2013
*
* 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.ibm.sbt.services.client.connections.communities;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.Header;
import com.ibm.commons.util.StringUtil;
import com.ibm.commons.util.io.StreamUtil;
import com.ibm.sbt.services.client.ClientServicesException;
import com.ibm.sbt.services.client.ClientService.ContentStream;
import com.ibm.sbt.services.client.base.BaseService;
import com.ibm.sbt.services.client.base.ConnectionsConstants;
import com.ibm.sbt.services.client.base.transformers.TransformerException;
import com.ibm.sbt.services.client.base.util.EntityUtil;
import com.ibm.sbt.services.client.connections.communities.feedhandler.BookmarkFeedHandler;
import com.ibm.sbt.services.client.connections.communities.feedhandler.CommunityFeedHandler;
import com.ibm.sbt.services.client.connections.files.AccessType;
import com.ibm.sbt.services.client.connections.files.File;
import com.ibm.sbt.services.client.connections.files.FileList;
import com.ibm.sbt.services.client.connections.files.FileService;
import com.ibm.sbt.services.client.connections.files.FileServiceException;
import com.ibm.sbt.services.client.connections.files.FileServiceURIBuilder;
import com.ibm.sbt.services.client.connections.files.ResultType;
import com.ibm.sbt.services.client.connections.files.SubFilters;
import com.ibm.sbt.services.client.connections.files.feedHandler.FileFeedHandler;
import com.ibm.sbt.services.client.connections.files.model.Headers;
import com.ibm.sbt.services.client.connections.forums.feedhandler.ForumsFeedHandler;
import com.ibm.sbt.services.client.connections.forums.feedhandler.TopicsFeedHandler;
import com.ibm.sbt.services.client.connections.communities.feedhandler.InviteFeedHandler;
import com.ibm.sbt.services.client.connections.communities.feedhandler.MemberFeedHandler;
import com.ibm.sbt.services.client.connections.communities.transformers.CommunityMemberTransformer;
import com.ibm.sbt.services.client.connections.communities.transformers.InviteTransformer;
import com.ibm.sbt.services.client.connections.communities.util.Messages;
import com.ibm.sbt.services.client.connections.forums.ForumList;
import com.ibm.sbt.services.client.connections.forums.ForumService;
import com.ibm.sbt.services.client.connections.forums.ForumServiceException;
import com.ibm.sbt.services.client.connections.forums.ForumTopic;
import com.ibm.sbt.services.client.connections.forums.TopicList;
import com.ibm.sbt.services.client.Response;
import com.ibm.sbt.services.client.ClientService;
import com.ibm.sbt.services.endpoints.Endpoint;
import com.ibm.sbt.services.util.AuthUtil;
/**
* CommunityService can be used to perform Community Related operations.
*
* @Represents Connections Community Service
* @author Swati Singh
* @author Manish Kataria
* @author Carlos Manias
* <pre>
* Sample Usage
* {@code
* CommunityService _service = new CommunityService();
* Collection<Community> communities = _service.getPublicCommunities();
* }
* </pre>
*/
public class CommunityService extends BaseService {
private static final String COMMUNITY_UNIQUE_IDENTIFIER = "communityUuid";
/**
* Used in constructing REST APIs
*/
public static final String CommunityBaseUrl = "{communities}/service/atom";
/**
* Constructor Creates CommunityService Object with default endpoint and default cache size
*/
public CommunityService() {
this(DEFAULT_ENDPOINT_NAME, DEFAULT_CACHE_SIZE);
}
/**
* Constructor - Creates CommunityService Object with a specified endpoint
*
* @param endpoint
* Creates CommunityService with specified endpoint and a default CacheSize
*/
public CommunityService(String endpoint) {
this(endpoint, DEFAULT_CACHE_SIZE);
}
/**
* Constructor - Creates CommunityService Object with specified endpoint and cache size
*
* @param endpoint
* @param cacheSize
* Creates CommunityService with specified endpoint and CacheSize
*/
public CommunityService(String endpoint, int cacheSize) {
super(endpoint, cacheSize);
}
/**
* Constructor - Creates CommunityService Object with a specified endpoint
*
* @param endpoint
* Creates CommunityService with specified endpoint and a default CacheSize
*/
public CommunityService(Endpoint endpoint) {
this(endpoint, DEFAULT_CACHE_SIZE);
}
/**
* Constructor - Creates CommunityService Object with specified endpoint and cache size
*
* @param endpoint
* @param cacheSize
* Creates CommunityService with specified endpoint and CacheSize
*/
public CommunityService(Endpoint endpoint, int cacheSize) {
super(endpoint, cacheSize);
}
/**
* This method returns the public communities
*
* @return
* @throws CommunityServiceException
*/
public CommunityList getPublicCommunities() throws CommunityServiceException {
return getPublicCommunities(null);
}
/**
* This method returns the public communities
*
* @param parameters
* @return
* @throws CommunityServiceException
*/
public CommunityList getPublicCommunities(Map<String, String> parameters) throws CommunityServiceException {
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITIES.getCommunityEntityType(),CommunityType.ALL.getCommunityType());
CommunityList communities = null;
if(null == parameters){
parameters = new HashMap<String, String>();
}
try {
communities = (CommunityList) getEntities(requestUrl, parameters, new CommunityFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.PublicCommunitiesException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.PublicCommunitiesException);
}
return communities;
}
/**
* Wrapper method to get a Community
* <p>
* fetches community content from server and populates the data member of {@link Community} with the fetched content
*
* @param communityUuid
* id of community
* @return A Community
* @throws CommunityServiceException
*/
public Community getCommunity(String communityUuid) throws CommunityServiceException {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String url = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.INSTANCE.getCommunityType());
Community community;
try {
community = (Community)getEntity(url, parameters, new CommunityFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CommunityException, communityUuid);
} catch (Exception e) {
throw new CommunityServiceException(e, Messages.CommunityException, communityUuid);
}
return community;
}
/**
* This method returns the Communities of which the user is a member or owner.
*
* @param communityUuid
* @return MemberList
* @throws CommunityServiceException
*/
public MemberList getMembers(String communityUuid) throws CommunityServiceException {
return getMembers(communityUuid, null);
}
/** Wrapper method to get list of the members of a community
*
* @param communityUuid
* @param query parameters
* @return MemberList
* @throws CommunityServiceException
*/
public MemberList getMembers(String communityUuid, Map<String, String> parameters) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
if(null == parameters){
parameters = new HashMap<String, String>();
}
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.MEMBERS.getCommunityType());
MemberList members = null;
try {
members = (MemberList) getEntities(requestUrl, parameters, new MemberFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CommunityMembersException, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CommunityMembersException, communityUuid);
}
return members;
}
/**
* This method returns the Communities of which the user is a member or owner.
*
* @return
* @throws CommunityServiceException
*/
public CommunityList getMyCommunities() throws CommunityServiceException {
return getMyCommunities(null);
}
/**
* Wrapper method to get Communities of which the user is a member or owner.
*
* @return A list of communities of which the user is a member or owner
* @throws CommunityServiceException
*/
public CommunityList getMyCommunities(Map<String, String> parameters) throws CommunityServiceException {
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITIES.getCommunityEntityType(), CommunityType.MY.getCommunityType());
CommunityList communities = null;
if(null == parameters){
parameters = new HashMap<String, String>();
}
try {
communities = (CommunityList) getEntities(requestUrl, parameters, new CommunityFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.MyCommunitiesException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.MyCommunitiesException);
}
return communities;
}
public CommunityList getSubCommunities(String communityUuid) throws CommunityServiceException {
return getSubCommunities(communityUuid, null);
}
/**
* Wrapper method to get SubCommunities of a community
*
* @param communityUuid
* community Id of which SubCommunities are to be fetched
* @return A list of communities
* @throws CommunityServiceException
*/
public CommunityList getSubCommunities(String communityUuid, Map<String, String> parameters) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
if(null == parameters){
parameters = new HashMap<String, String>();
}
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(), CommunityType.SUBCOMMUNITIES.getCommunityType());
CommunityList communities = null;
try {
communities = (CommunityList) getEntities(requestUrl, parameters, new CommunityFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.SubCommunitiesException, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.SubCommunitiesException, communityUuid);
}
return communities;
}
public BookmarkList getBookmarks(String communityUuid) throws CommunityServiceException {
return getBookmarks(communityUuid, null);
}
/**
* Wrapper method to get bookmarks for a community.
*
* @param communityUuid
* community Id of which bookmarks are to be fetched
* @return Bookmarks of the given Community
* @throws CommunityServiceException
*/
public BookmarkList getBookmarks(String communityUuid, Map<String, String> parameters) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
if(null == parameters){
parameters = new HashMap<String, String>();
}
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.BOOKMARKS.getCommunityType());
BookmarkList bookmarks = null;
try {
bookmarks = (BookmarkList) getEntities(requestUrl, parameters, new BookmarkFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CommunityBookmarksException, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CommunityBookmarksException, communityUuid);
}
return bookmarks;
}
public TopicList getForumTopics(String communityUuid) throws CommunityServiceException {
return getForumTopics(communityUuid, null);
}
/**
* Wrapper method to get forums of a community .
*
* @param communityUuid
* Uuid of Community for which forums are to be fetched
* @return ForumList
* @throws CommunityServiceException
*/
public ForumList getForums(String communityUuid) throws CommunityServiceException {
return getForums(communityUuid, null);
}
/**
* Wrapper method to get forums of a community .
*
* @param communityUuid
* Uuid of Community for which forums are to be fetched
* @param query parameters
* @return ForumList
* @throws CommunityServiceException
*/
public ForumList getForums(String communityUuid, Map<String, String> parameters) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
if(null == parameters){
parameters = new HashMap<String, String>();
}
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
ForumList forums;
try {
ForumService svc = new ForumService(this.endpoint);
forums = svc.getAllForums(parameters);
}catch (Exception e) {
throw new CommunityServiceException(e, Messages.CommunityForumTopicsException, communityUuid);
}
return forums;
}
/**
* Wrapper method to get forum topics of a community .
*
* @param communityUuid
* community Id of which forum topics are to be fetched
* @return Forum topics of the given Community
* @throws CommunityServiceException
*/
public TopicList getForumTopics(String communityUuid, Map<String, String> parameters) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
if(null == parameters){
parameters = new HashMap<String, String>();
}
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(), CommunityType.FORUMTOPICS.getCommunityType());
TopicList forumTopics;
try {
forumTopics = (TopicList) getEntities(requestUrl, parameters, new TopicsFeedHandler(new ForumService()));
}catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CommunityForumTopicsException, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CommunityForumTopicsException, communityUuid);
}
return forumTopics;
}
/**
* Wrapper method to create a Topic for default Forum of a Community
* <p>
* User should be authenticated to call this method
* @param ForumTopic
* @return Topic
* @throws ForumServiceException
*/
public ForumTopic createForumTopic(ForumTopic topic, String communityId)throws CommunityServiceException {
try {
ForumService svc = new ForumService(this.endpoint);
return svc.createCommunityForumTopic(topic, communityId);
}catch (Exception e) {
throw new CommunityServiceException(e, Messages.CreateCommunityForumTopicException, communityId);
}
}
/**
* Get a list of the outstanding community invitations of the currently authenticated
* user or provide parameters to search for a subset of those invitations.
*
* @method getMyInvites
* @return pending invites for the authenticated user
*/
public InviteList getMyInvites() throws CommunityServiceException {
return getMyInvites(null);
}
/**
* Get a list of the outstanding community invitations of the currently authenticated
* user or provide parameters to search for a subset of those invitations.
*
* @method getMyInvites
* @param parameters
* Various parameters that can be passed to get a feed of members of a community.
* The parameters must be exactly as they are supported by IBM Connections like ps, sortBy etc.
* @return pending invites for the authenticated user
*/
public InviteList getMyInvites(Map<String, String> parameters) throws CommunityServiceException {
if(null == parameters){
parameters = new HashMap<String, String>();
}
String requestUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(), CommunityType.MYINVITES.getCommunityType());
InviteList invites = null;
try {
invites = (InviteList) getEntities(requestUrl, parameters, new InviteFeedHandler(this));
}catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CommunityInvitationsException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CommunityInvitationsException);
}
return invites;
}
/**
* Method to create a community invitation, user should be authenticated to perform this operation
*
* @method createInvite
* @param communityUuid
* community Id for which invite is to be sent
* @param contributorId
* user id of contributor
* @return pending invites for the authenticated user
*/
public Invite createInvite(String communityUuid, String contributorId) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String inviteUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.INVITES.getCommunityType());
Object communityPayload;
Member member = new Member(this, contributorId);
try {
communityPayload = new InviteTransformer().transform(member.getFieldsMap());
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
Invite invite = null;
try {
Response result = super.createData(inviteUrl, parameters, communityPayload);
invite = (Invite) new InviteFeedHandler(this).createEntity(result);
} catch (Exception e) {
throw new CommunityServiceException(e, Messages.CreateInvitationException);
}
return invite;
}
/**
* Method to accept a outstanding community invitation, user should be authenticated to perform this operation
*
* @method acceptInvite
* @param communityUuid
* community Id for which invite is sent
* @param contributorId
* user id of contributor
* @return boolean
*/
public boolean acceptInvite(String communityUuid, String contributorId) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
boolean success = true;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String inviteUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.MEMBERS.getCommunityType());
Object communityPayload;
Member member = new Member(this, contributorId);
try {
communityPayload = new CommunityMemberTransformer().transform(member.getFieldsMap());
} catch (TransformerException e) {
success = false;
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
try {
super.createData(inviteUrl, parameters, communityPayload);
} catch (Exception e) {
success = false;
throw new CommunityServiceException(e, Messages.AcceptInvitationException);
}
return success;
}
/**
* Method to decline a outstanding community invitation, user should be authenticated to perform this operation
*
* @method declineInvite
* @param communityUuid
* community Id for which invite is sent
* @param contributorId
* user id of contributor
* @return boolean
*/
public boolean declineInvite(String communityUuid, String contributorId) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
boolean success = true;
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
if(EntityUtil.isEmail(contributorId)){
parameters.put("email", contributorId);
}
else{
parameters.put("userid", contributorId);
}
String inviteUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),CommunityType.INVITES.getCommunityType());
try {
super.deleteData(inviteUrl, parameters, communityUuid);
} catch (Exception e) {
success = false;
throw new CommunityServiceException(e, Messages.DeclineInvitationException);
}
return success;
}
/**
* Wrapper method to create a community
* <p>
* User should be authenticated to call this method
*
* In response to successful creation of a community server does not return the id in response payload.
* In headers Location has the id to newly created community, we use this to return the communityid.
* Location: https://server/communities/service/atom/community/instance?communityUuid=c93bfb43-0bf2-4125-a8a4-7acd4
*
* @param Community
* @return String
* communityid of newly created Community
* @throws CommunityServiceException
*/
public String createCommunity(Community community) throws CommunityServiceException {
if (null == community){
throw new CommunityServiceException(null, Messages.NullCommunityObjectException);
}
try {
Object communityPayload;
try {
communityPayload = community.constructCreateRequestBody();
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
String communityPostUrl = resolveCommunityUrl(CommunityEntity.COMMUNITIES.getCommunityEntityType(),CommunityType.MY.getCommunityType());
Response requestData = createData(communityPostUrl, null, communityPayload,ClientService.FORMAT_CONNECTIONS_OUTPUT);
community.clearFieldsMap();
return extractCommunityIdFromHeaders(requestData);
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityException);
}
}
private String extractCommunityIdFromHeaders(Response requestData){
Header[] headers = requestData.getResponse().getAllHeaders();
String urlLocation = "";
for (Header header: headers){
if (header.getName().equalsIgnoreCase("Location")) {
urlLocation = header.getValue();
}
}
return urlLocation.substring(urlLocation.indexOf(COMMUNITY_UNIQUE_IDENTIFIER+"=") + (COMMUNITY_UNIQUE_IDENTIFIER+"=").length());
}
/**
* Wrapper method to update a community
* <p>
* User should be logged in as a owner of the community to call this method.
*
* @param community
* community which is to be updated
* @throws CommunityServiceException
*/
public void updateCommunity(Community community) throws CommunityServiceException {
try {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, community.getCommunityUuid());
String updateUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(), CommunityType.INSTANCE.getCommunityType());
Object communityPayload;
try {
communityPayload = community.constructCreateRequestBody();
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
super.updateData(updateUrl, parameters,communityPayload, COMMUNITY_UNIQUE_IDENTIFIER);
community.clearFieldsMap();
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.UpdateCommunityException);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.UpdateCommunityException);
}
}
/**
* Wrapper method to update Community Logo, supported for connections
*
* @param File
* image to be uploaded as Community Logo
* @param communityId
* @throws CommunityServiceException
*/
public void updateCommunityLogo(java.io.File file, String communityId) throws CommunityServiceException{
try {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityId);
String name = file.getName();
int dot = StringUtil.lastIndexOfIgnoreCase(name, ".");
String ext = "";
if (dot > -1) {
ext = name.substring(dot + 1); // add one for the dot!
}
if (!StringUtil.isEmpty(ext)) {
Map<String, String> headers = new HashMap<String, String>();
if (StringUtil.equalsIgnoreCase(ext,"jpg")) {
headers.put("Content-Type", "image/jpeg"); // content-type should be image/jpeg for file extension - jpeg/jpg
} else {
headers.put("Content-Type", "image/" + ext);
}
// the url doesn't have atom in base
String url = "/communities/service/html/image";
getClientService().put(url, parameters, headers, file, ClientService.FORMAT_NULL);
}
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.UpdateCommunityLogoException);
}
}
/**
* Wrapper method to get member of a community.
* <p>
*
* @param communityUuid
* Id of Community
* @param memberId
* Id of Member
* @return Member
* @throws CommunityServiceException
*/
public Member getMember(String communityUuid, String memberId) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)||StringUtil.isEmpty(memberId)){
throw new CommunityServiceException(null, Messages.NullCommunityIdOrUserIdException);
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
if(memberId.contains("@")){
parameters.put("email", memberId);
}
else{
parameters.put("userid", memberId);
}
String url = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),
CommunityType.MEMBERS.getCommunityType());
Member member;
try {
member = (Member)getEntity(url, parameters, new MemberFeedHandler(this));
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.GetMemberException, memberId, communityUuid);
} catch (Exception e) {
throw new CommunityServiceException(e, Messages.GetMemberException, memberId, communityUuid);
}
return member;
}
/**
* Wrapper method to add member to a community.
* <p>
* User should be logged in as a owner of the community to call this method
*
* @param communityUuid
* Id of Community to which the member needs to be added
* @param memberId
* Id of Member which is to be added
* @throws CommunityServiceException
*/
public boolean addMember(String communityUuid, Member member) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdUserIdOrRoleException);
}
String memberId = member.getUserid();
if(StringUtil.isEmpty(memberId)){
if(StringUtil.isEmpty(member.getEmail()))
throw new CommunityServiceException(null, Messages.NullCommunityIdUserIdOrRoleException);
else
memberId = member.getEmail();
}
try {
if(StringUtil.isEmpty(member.getRole())){
member.setRole("member"); //default role is member
}
} catch (Exception e) {
member.setRole("member");
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
Object communityPayload;
try {
communityPayload = new CommunityMemberTransformer().transform(member.getFieldsMap());
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.CreateCommunityPayloadException);
}
String communityUpdateMembertUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),CommunityType.MEMBERS.getCommunityType());
try {
Response response = super.createData(communityUpdateMembertUrl, parameters, communityPayload);
int statusCode = response.getResponse().getStatusLine().getStatusCode();
return statusCode == HttpServletResponse.SC_CREATED;
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.AddMemberException, memberId, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.AddMemberException, memberId, communityUuid);
}
}
/**
* Wrapper method to update member of a community.
* <p>
* User should be logged in as a owner of the community to call this method
*
* @param community
* Id of Community
* @param memberId
* Id of Member
* @throws CommunityServiceException
*/
public void updateMember(String communityId, Member member)throws CommunityServiceException {
if (StringUtil.isEmpty(communityId)){
throw new CommunityServiceException(null, Messages.NullCommunityIdUserIdOrRoleException);
}
String memberId = "";
if(StringUtil.isEmpty(member.getUserid())){
memberId = member.getEmail();
}
if (StringUtil.isEmpty(memberId)){
throw new CommunityServiceException(null, Messages.NullCommunityIdUserIdOrRoleException);
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityId);
parameters.put("userid", member.getUserid());
Object memberPayload;
try {
member.setUserid(member.getUserid()); // to add this in fields map for update
memberPayload = new CommunityMemberTransformer().transform(member.getFieldsMap());
} catch (TransformerException e) {
throw new CommunityServiceException(e, Messages.UpdateMemberException);
}
String communityUpdateMembertUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),CommunityType.MEMBERS.getCommunityType());
try {
super.createData(communityUpdateMembertUrl, parameters, memberPayload);
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.UpdateMemberException, memberId, member.getRole(), communityId);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.UpdateMemberException, memberId, member.getRole(), communityId);
}
}
/**
* Wrapper method to remove member from a community.
* <p>
* User should be logged in as a owner of the community to call this method
*
* @param community
* Id of Community from which the member is to be removed
* @param memberId
* Id of Member who is to be removed
* @throws CommunityServiceException
*/
public void removeMember(String communityUuid, String memberId) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)||StringUtil.isEmpty(memberId)){
throw new CommunityServiceException(null, Messages.NullCommunityIdOrUserIdException);
}
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
if(EntityUtil.isEmail(memberId)){
parameters.put("email", memberId);
}else{
parameters.put("userid", memberId);
}
try {
String deleteCommunityUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(),CommunityType.MEMBERS.getCommunityType());
super.deleteData(deleteCommunityUrl, parameters, COMMUNITY_UNIQUE_IDENTIFIER);
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.RemoveMemberException, memberId, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.RemoveMemberException, memberId, communityUuid);
}
}
/**
* Wrapper method to delete a community
* <p>
* User should be logged in as a owner of the community to call this method.
*
* @param String
* communityUuid which is to be deleted
* @throws CommunityServiceException
*/
public void deleteCommunity(String communityUuid) throws CommunityServiceException {
if (StringUtil.isEmpty(communityUuid)){
throw new CommunityServiceException(null, Messages.NullCommunityIdException);
}
try {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(COMMUNITY_UNIQUE_IDENTIFIER, communityUuid);
String deleteCommunityUrl = resolveCommunityUrl(CommunityEntity.COMMUNITY.getCommunityEntityType(), CommunityType.INSTANCE.getCommunityType());
super.deleteData(deleteCommunityUrl, parameters, COMMUNITY_UNIQUE_IDENTIFIER);
} catch (ClientServicesException e) {
throw new CommunityServiceException(e, Messages.DeleteCommunityException, communityUuid);
} catch (IOException e) {
throw new CommunityServiceException(e, Messages.DeleteCommunityException, communityUuid);
}
}
/*
* Method to generate appropriate REST URLs
*
* @param communityEntity ( Ref Class : CommunityEntity )
* @param communityType ( Ref Class : CommunityType )
*/
protected String resolveCommunityUrl(String communityEntity, String communityType) {
return resolveCommunityUrl(communityEntity, communityType, null);
}
/*
* Method to generate appropriate REST URLs
*
* @param communityEntity ( Ref Class : CommunityEntity )
* @param communityType ( Ref Class : CommunityType )
* @param params : ( Ref Class : CommunityParams )
*/
protected String resolveCommunityUrl(String communityEntity, String communityType, Map<String, String> params) {
StringBuilder comBaseUrl = new StringBuilder(CommunityBaseUrl);
if (StringUtil.isEmpty(communityEntity)) {
communityEntity = CommunityEntity.COMMUNITIES.getCommunityEntityType(); // Default Entity Type
}
if (StringUtil.isEmpty(communityType)) {
communityType = CommunityType.ALL.getCommunityType(); // Default Community Type
}
if (AuthUtil.INSTANCE.getAuthValue(endpoint).equalsIgnoreCase(ConnectionsConstants.OAUTH)) {
comBaseUrl.append(ConnectionsConstants.SEPARATOR).append(ConnectionsConstants.OAUTH);
}
comBaseUrl.append(ConnectionsConstants.SEPARATOR).append(communityEntity).append(ConnectionsConstants.SEPARATOR).append(communityType);
// Add required parameters
if (null != params && params.size() > 0) {
comBaseUrl.append(ConnectionsConstants.INIT_URL_PARAM);
boolean setSeparator = false;
for (Map.Entry<String, String> param : params.entrySet()) {
String key = param.getKey();
if (StringUtil.isEmpty(key)) continue;
String value = EntityUtil.encodeURLParam(param.getValue());
if (StringUtil.isEmpty(value)) continue;
if (setSeparator) {
comBaseUrl.append(ConnectionsConstants.URL_PARAM);
} else {
setSeparator = true;
}
comBaseUrl.append(key).append(ConnectionsConstants.EQUALS).append(value);
}
}
return comBaseUrl.toString();
}
/**
* Method to get a list of Community Files
* @param communityId
* @param params
* @return
* @throws CommunityServiceException
*/
public FileList getCommunityFiles(String communityId, HashMap<String, String> params) throws CommunityServiceException {
FileService fileService = new FileService(this.endpoint);
try {
return fileService.getCommunityFiles(communityId, params);
} catch (FileServiceException e) {
throw new CommunityServiceException(e);
}
}
/**
* Method to download a community file
* @param ostream
* @param fileId
* @param communityId
* @param params
* @return long
* @throws CommunityServiceException
*/
public long downloadCommunityFile(OutputStream ostream, final String fileId, final String communityId, Map<String, String> params) throws CommunityServiceException {
FileService svc = new FileService(this.endpoint);
try {
return svc.downloadCommunityFile(ostream, fileId, communityId, params);
} catch (FileServiceException e) {
throw new CommunityServiceException(e, Messages.DownloadCommunitiesException);
}
}
/**
* Method to upload a File to Community
* @param iStream
* @param communityId
* @param title
* @param length
* @throws CommunityServiceException
*/
public File uploadFile(InputStream iStream, String communityId, final String title, long length) throws CommunityServiceException {
FileService svc = new FileService(this.endpoint);
try {
return svc.uploadCommunityFile(iStream, communityId, title, length);
} catch (FileServiceException e) {
throw new CommunityServiceException(e, Messages.UploadCommunitiesException);
}
}
}
| [
"[email protected]"
]
| |
c8bfb2bf841773b4b9f6b39ea1991b01e16071ff | 299d9f6459cf9906b8c80b37f00a9d011446c94e | /src/main/java/br/com/cupom/utils/notafiscal/TRetConsReciNFe.java | a02a8a03b7c91f7bf94fb682f0a59c39ff5a58c8 | []
| no_license | jeffersondlopes/cupom-entrada-nf | 9ac50aa9eda16095a8a025ada2358d0f4e2358dd | 30a93956e399a270981feb6eb4cce61c37d45739 | refs/heads/master | 2022-12-25T17:51:31.230096 | 2020-09-23T17:22:42 | 2020-09-23T17:22:42 | 293,175,660 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,092 | java | //
// Este arquivo foi gerado pela Arquitetura JavaTM para Implementação de Referência (JAXB) de Bind XML, v2.3.0.1
// Consulte <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas as modificações neste arquivo serão perdidas após a recompilação do esquema de origem.
// Gerado em: 2020.09.10 às 05:33:29 PM UTC
//
package br.com.cupom.utils.notafiscal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* Tipo Retorno do Pedido de Consulta do Recido do Lote de Notas Fiscais Eletrônicas
*
* <p>Classe Java de TRetConsReciNFe complex type.
*
* <p>O seguinte fragmento do esquema especifica o conteúdo esperado contido dentro desta classe.
*
* <pre>
* <complexType name="TRetConsReciNFe">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="tpAmb" type="{http://www.portalfiscal.inf.br/nfe}TAmb"/>
* <element name="verAplic" type="{http://www.portalfiscal.inf.br/nfe}TVerAplic"/>
* <element name="nRec" type="{http://www.portalfiscal.inf.br/nfe}TRec"/>
* <element name="cStat" type="{http://www.portalfiscal.inf.br/nfe}TStat"/>
* <element name="xMotivo" type="{http://www.portalfiscal.inf.br/nfe}TMotivo"/>
* <element name="cUF" type="{http://www.portalfiscal.inf.br/nfe}TCodUfIBGE"/>
* <element name="dhRecbto" type="{http://www.portalfiscal.inf.br/nfe}TDateTimeUTC"/>
* <sequence minOccurs="0">
* <element name="cMsg">
* <simpleType>
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <whiteSpace value="preserve"/>
* <pattern value="[0-9]{1,4}"/>
* </restriction>
* </simpleType>
* </element>
* <element name="xMsg">
* <simpleType>
* <restriction base="{http://www.portalfiscal.inf.br/nfe}TString">
* <minLength value="1"/>
* <maxLength value="200"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* <element name="protNFe" type="{http://www.portalfiscal.inf.br/nfe}TProtNFe" maxOccurs="50" minOccurs="0"/>
* </sequence>
* <attribute name="versao" use="required" type="{http://www.portalfiscal.inf.br/nfe}TVerNFe" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TRetConsReciNFe", propOrder = {
"tpAmb",
"verAplic",
"nRec",
"cStat",
"xMotivo",
"cuf",
"dhRecbto",
"cMsg",
"xMsg",
"protNFe"
})
public class TRetConsReciNFe {
@XmlElement(required = true)
protected String tpAmb;
@XmlElement(required = true)
protected String verAplic;
@XmlElement(required = true)
protected String nRec;
@XmlElement(required = true)
protected String cStat;
@XmlElement(required = true)
protected String xMotivo;
@XmlElement(name = "cUF", required = true)
protected String cuf;
@XmlElement(required = true)
protected String dhRecbto;
protected String cMsg;
protected String xMsg;
protected List<TProtNFe> protNFe;
@XmlAttribute(name = "versao", required = true)
protected String versao;
/**
* Obtém o valor da propriedade tpAmb.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTpAmb() {
return tpAmb;
}
/**
* Define o valor da propriedade tpAmb.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTpAmb(String value) {
this.tpAmb = value;
}
/**
* Obtém o valor da propriedade verAplic.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVerAplic() {
return verAplic;
}
/**
* Define o valor da propriedade verAplic.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVerAplic(String value) {
this.verAplic = value;
}
/**
* Obtém o valor da propriedade nRec.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNRec() {
return nRec;
}
/**
* Define o valor da propriedade nRec.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNRec(String value) {
this.nRec = value;
}
/**
* Obtém o valor da propriedade cStat.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCStat() {
return cStat;
}
/**
* Define o valor da propriedade cStat.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCStat(String value) {
this.cStat = value;
}
/**
* Obtém o valor da propriedade xMotivo.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXMotivo() {
return xMotivo;
}
/**
* Define o valor da propriedade xMotivo.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setXMotivo(String value) {
this.xMotivo = value;
}
/**
* Obtém o valor da propriedade cuf.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCUF() {
return cuf;
}
/**
* Define o valor da propriedade cuf.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCUF(String value) {
this.cuf = value;
}
/**
* Obtém o valor da propriedade dhRecbto.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDhRecbto() {
return dhRecbto;
}
/**
* Define o valor da propriedade dhRecbto.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDhRecbto(String value) {
this.dhRecbto = value;
}
/**
* Obtém o valor da propriedade cMsg.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCMsg() {
return cMsg;
}
/**
* Define o valor da propriedade cMsg.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCMsg(String value) {
this.cMsg = value;
}
/**
* Obtém o valor da propriedade xMsg.
*
* @return
* possible object is
* {@link String }
*
*/
public String getXMsg() {
return xMsg;
}
/**
* Define o valor da propriedade xMsg.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setXMsg(String value) {
this.xMsg = value;
}
/**
* Gets the value of the protNFe property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the protNFe property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getProtNFe().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link TProtNFe }
*
*
*/
public List<TProtNFe> getProtNFe() {
if (protNFe == null) {
protNFe = new ArrayList<TProtNFe>();
}
return this.protNFe;
}
/**
* Obtém o valor da propriedade versao.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersao() {
return versao;
}
/**
* Define o valor da propriedade versao.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersao(String value) {
this.versao = value;
}
}
| [
"[email protected]"
]
| |
ac143d1d1f10e968b0f17b06a3d298c9d1129fae | 797fbe8d4a5eedcf9b08d24b87a6c5db41ba4e13 | /app/src/main/java/com/example/cafeteriaappmuc/Activities/DisplayImageActivity.java | 338b12eecaf89f8677b7cc15171fa9f9b675fd8c | []
| no_license | elisebsm/Mobile | c5f44068c332b8446d64ba982739aa8d362ac314 | 602a1fc92f9adf281ca0cf5a6d628af591872311 | refs/heads/master | 2021-03-29T09:12:35.369693 | 2020-05-15T22:37:03 | 2020-05-15T22:37:03 | 247,940,742 | 0 | 0 | null | 2020-05-15T20:01:31 | 2020-03-17T10:27:11 | Java | UTF-8 | Java | false | false | 1,434 | java | package com.example.cafeteriaappmuc.Activities;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.example.cafeteriaappmuc.GlobalClass;
import com.example.cafeteriaappmuc.R;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
public class DisplayImageActivity extends AppCompatActivity {
private String imageName;
private String databasePath;
private StorageReference imagesRef;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.display_image);
Intent intent = getIntent();
imageName = intent.getStringExtra("imageName");
//getting image from firebase or cache
StorageReference storageReference = FirebaseStorage.getInstance().getReference();
String foodService= ((GlobalClass) this.getApplication()).getFoodService();
String dishName= ((GlobalClass) this.getApplication()).getDishName();
imagesRef = storageReference.child("images/"+foodService+"/"+dishName+"/"+imageName);
imageView = findViewById(R.id.FullImageView);
//Loading image from Glide library.
Glide.with(this).load(imagesRef).into(imageView);
}
}
| [
"[email protected]"
]
| |
a7396018336014e2bf8db2780cef71d2ca04bc9f | 8a009dd6fcc45530e40512630ccf511bf7e4794a | /Corrections/TP-07-Decorator-Bridge-Method-Factory-Composite-Abstract-Factory/src/soldier/core/Unit.java | f7fa02efe99af138a099ca7b2fb3c27c332dc466 | []
| no_license | maphdev/M1_Software_Architecture | c4a776518bace5dfce62c3e4cd03a96ce03fccb8 | 9b7b0a37bee9eb5cbb5015ba8aca2a3bb67d48b4 | refs/heads/master | 2021-01-24T02:29:50.187333 | 2018-08-21T14:47:31 | 2018-08-21T14:47:31 | 122,850,964 | 1 | 0 | null | null | null | null | WINDOWS-1250 | Java | false | false | 691 | java | /**
* D. Auber & P. Narbel
* Solution TD Architecture Logicielle 2016 Université Bordeaux.
*/
package soldier.core;
import java.util.Iterator;
public interface Unit {
/**
* Unit methods
*/
public String getName();
public float getHealthPoints();
public boolean alive();
public void heal();
public float parry(float force);
public float strike();
/**
* Behavior extensions
*/
public void addEquipment(Equipment w);
public void removeEquipment(Equipment w);
public Iterator<Equipment> getEquipments();
/**
* Composite methods
*/
public Iterator<Unit> subUnits();
public void addUnit(Unit au);
public void removeUnit(Unit au);
}
| [
"[email protected]"
]
| |
4170f29271a5b398b2f56c29cbed172cfdc7edcb | a822fbdcdbad3a156cfdbcf9e86e3bafb1519333 | /src/main/java/com/lyl/service/ActiveService.java | 44c7aa44ed01a5dede5d1822b473e0bfe18c0077 | []
| no_license | PanHuai/- | ab37563a9078515a831e22b0edacc6e88e8d954d | 4a5c6393ec4025f86cec9ff2f0c9df3a151708b3 | refs/heads/master | 2020-04-11T08:42:36.307725 | 2019-02-28T12:20:30 | 2019-02-28T12:20:30 | 144,217,871 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 277 | java | package com.lyl.service;
import com.lyl.model.Active;
/**
* Created by 潘淮 on 2018/12/31.<br>
*/
public interface ActiveService {
public Active get();
public Active getById(int id);
public int add(Active active);
public int update(Active active);
}
| [
"[email protected]"
]
| |
770303f9b58f86f3070926d97b8bbb0d6ea84051 | e13b0a6069e03d12a1cb0f905949460fb89ae969 | /Lab6/src/com/company/SurgicalTechnologist.java | 1523ae7c228c8d9ed093cf82e2d2c722fa10b4ed | []
| no_license | Tanyatsy/OOP | 0c2a511b0cd20d2454da163ac3f4467098f973d6 | 4eaf839329d1f6635b9c4554d330abe83949b900 | refs/heads/master | 2020-09-16T10:01:56.825929 | 2019-12-11T15:16:33 | 2019-12-11T15:16:33 | 223,736,662 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 81 | java | package com.company;
public class SurgicalTechnologist extends Technologist {
}
| [
"[email protected]"
]
| |
dc0a26fc1f45c38303d12169cf549612916ce85a | 3aa8d4702ada59bba21f65f92e997f1c150be969 | /ch22-testpyramid/Phase6/airport/src/test/java/com/manning/junitbook/testpyramid/airport/FlightBuilderUtil.java | 205009da69e67e3d3dbb3cae87e591654a3e375f | []
| no_license | kenshin579/books-junit-in-actions-3rd | b0e4de1345599c20545944b19531ef799f720b4b | c5d74bdf5429dc621961c85de330dbd20832355a | refs/heads/master | 2022-02-13T18:27:09.299647 | 2020-03-02T14:04:52 | 2020-03-02T14:04:52 | 244,385,110 | 0 | 0 | null | 2022-01-21T23:38:39 | 2020-03-02T14:01:14 | HTML | UTF-8 | Java | false | false | 1,255 | java | package com.manning.junitbook.testpyramid.airport;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class FlightBuilderUtil {
public static Flight buildFlightFromCsv(String flightNumber, int seats, String fileName) throws IOException {
Flight flight = new Flight(flightNumber, seats);
flight.setOrigin("London");
flight.setDestination("Bucharest");
flight.setDistance(2100);
try(BufferedReader reader = new BufferedReader(new FileReader(fileName))) {
String line = null;
do {
line = reader.readLine();
if (line != null) {
String[] passengerString = line.toString().split(";");
Passenger passenger = new Passenger(passengerString[0].trim(), passengerString[1].trim(), passengerString[2].trim());
if(passengerString.length == 4) {
if ("Y".equals(passengerString[3].trim())) {
passenger.setVip(true);
}
}
flight.addPassenger(passenger);
}
} while (line != null);
}
return flight;
}
}
| [
"[email protected]"
]
| |
34b58d590e2bc35ebb8df25b628a1a18a34aa7d2 | ec3badc26008554114dc7b0996d95bfc3bb24417 | /fibMaxNode.java | 1032274579ac1c27a0b0b2f11a0e845d3af86173 | []
| no_license | jayetri/Hashtag-counter-using-Fibonacci-Max-Heap | dd376c00eeb1c291ff1df1d00665650a26ade2e6 | bc1bf26c14428604804054f4c50b97e6f1d1343a | refs/heads/master | 2022-09-19T17:45:37.466488 | 2020-05-31T01:28:31 | 2020-05-31T01:28:31 | 268,147,396 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,216 | java |
/**
This class - fibMaxNode represents each of the nodes in the Max Fibonacci Heap.
*/
class fibMaxNode<T>
{ double Heap_Key; // This is the key of every node.
int NodeDegree; //This is the degree. Degree is basically the no. of children of every node.
boolean flag_for_cascading; //This shows if the childcut value is true or false. It is of type boolean. It is false initially. For every node, when one of its children is removed, it is marked true.
fibMaxNode<T> Parent_Node; //It points to the parent field.
fibMaxNode<T> Child_Node; //It points to the child node
fibMaxNode<T> sibling_right_node; //It points to the left sibling of this node since fibonacci heap has a doubly linked list.
fibMaxNode<T> sibling_left_node; //It points to the right sibling of this node since fibonacci heap has a doubly linked list.
T value; //It is used to represent the frequency of the hashtag and the value of node in the Fibonacci Heap.
public fibMaxNode(T value, double Heap_Key) //Constructor-THis initializes all the node attributes.
{
sibling_right_node = this;
sibling_left_node = this;
this.value = value;
this.Heap_Key = Heap_Key;
}
}
| [
"[email protected]"
]
| |
e2b35580c7f1dd1cda5b6886a4df1f0badc177c0 | e6df03bedce3a3d6b2edaafa82e5937f6a628a71 | /Stack/src/main/java/Using_LinkedList/Employee.java | c282f35816810415e80d5f4ab0796180fe9de590 | []
| no_license | Motahharul-Haque/Data_Structure_and_Algo | d8adbc1da7a7b136d0c3ab12689add608bcc51df | 421421798aa7fac86c0c636f68d0277ce072f95c | refs/heads/master | 2023-02-04T22:36:07.535464 | 2020-12-21T08:47:46 | 2020-12-21T08:47:46 | 302,120,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,436 | java | package Using_LinkedList;
import java.util.Objects;
public class Employee {
private String firstName;
private String lastName;
private int id;
public Employee(String firstName, String lastName, int id) {
this.firstName = firstName;
this.lastName = lastName;
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Employee employee = (Employee) o;
return id == employee.id &&
firstName.equals(employee.firstName) &&
lastName.equals(employee.lastName);
}
@Override
public int hashCode() {
return Objects.hash(firstName, lastName, id);
}
@Override
public String toString() {
return "Employee{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", id=" + id +
'}';
}
}
| [
"[email protected]"
]
| |
eebe552e690d6d05cd1190818f209fcff596b880 | c8789701018fcd777ba71455c7073e2503ec3229 | /app/src/main/java/com/yihuan/sharecalendar/ui/view/pickerview/data/WheelCalendar.java | 1700c26b0cc82eb2bb3579cc63b1085ad1ed6388 | []
| no_license | 1002311566/ShareCalender | 67744f1d413ad3df9fe780d34690e0a4df9437ee | 5faf2d91c40940db7c9d95f017dde1c528cb2c3b | refs/heads/master | 2020-04-01T20:12:02.146835 | 2018-10-18T10:02:55 | 2018-10-18T10:02:55 | 153,590,927 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 900 | java | package com.yihuan.sharecalendar.ui.view.pickerview.data;
import java.util.Calendar;
/**
* Created by jzxiang on 16/4/19.
*/
public class WheelCalendar {
public int year, month, day, hour, minute;
private boolean noRange;
public WheelCalendar(long millseconds) {
initData(millseconds);
}
private void initData(long millseconds) {
if (millseconds == 0) {
noRange = true;
return;
}
Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.setTimeInMillis(millseconds);
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH) + 1;
day = calendar.get(Calendar.DAY_OF_MONTH);
hour = calendar.get(Calendar.HOUR_OF_DAY);
minute = calendar.get(Calendar.MINUTE);
}
public boolean isNoRange() {
return noRange;
}
}
| [
"[email protected]"
]
| |
37974f51ab9f68f90e6f757fc597a703a8670ecf | 446a56b68c88df8057e85f424dbac90896f05602 | /support/cas-server-support-json-service-registry/src/main/java/org/apereo/cas/nativex/JsonServiceRegistryRuntimeHints.java | c85c4cc88b2b3d48c993be7c524264c9f8c25a8a | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-warranty-disclaimer"
]
| permissive | apereo/cas | c29deb0224c52997cbfcae0073a4eb65ebf41205 | 5dc06b010aa7fd1b854aa1ae683d1ab284c09367 | refs/heads/master | 2023-09-01T06:46:11.062065 | 2023-09-01T01:17:22 | 2023-09-01T01:17:22 | 2,352,744 | 9,879 | 3,935 | Apache-2.0 | 2023-09-14T14:06:17 | 2011-09-09T01:36:42 | Java | UTF-8 | Java | false | false | 445 | java | package org.apereo.cas.nativex;
import org.apereo.cas.util.nativex.CasRuntimeHintsRegistrar;
import org.springframework.aot.hint.RuntimeHints;
/**
* This is {@link JsonServiceRegistryRuntimeHints}.
*
* @author Misagh Moayyed
* @since 7.0.0
*/
public class JsonServiceRegistryRuntimeHints implements CasRuntimeHintsRegistrar {
@Override
public void registerHints(final RuntimeHints hints, final ClassLoader classLoader) {
}
}
| [
"[email protected]"
]
| |
b13f53f103f4fb01a47f5c6877440d351ceac677 | 47dc3463202a9c0fdf5563ac30758cb5da22a529 | /src/main/java/com/stackoverflow/weiping/util/TimeUtil.java | d5e14c920282c9098ac629a0b093f1e51f19dd23 | []
| no_license | dkuppitz/weiping | 07cfbf4b969534bcd6a2333385df58b321e4ec54 | a229ef3aa9f07469a0275e33f50968b030d988ff | refs/heads/master | 2020-04-18T20:55:53.234008 | 2019-01-27T19:39:20 | 2019-01-27T19:39:20 | 167,751,097 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 619 | java | package com.stackoverflow.weiping.util;
import java.time.DayOfWeek;
import java.time.LocalTime;
public class TimeUtil {
public static LocalTime toLocalTime(final int minutes) {
return LocalTime.of(minutes / 60, minutes % 60);
}
public static int toMinutes(final LocalTime time) {
return time.getHour() * 60 + time.getMinute();
}
public static int daysBetween(final DayOfWeek day1, final DayOfWeek day2) {
return day1.getValue() <= day2.getValue()
? (day2.getValue() - day1.getValue())
: (7 - (day1.getValue() - day2.getValue()));
}
}
| [
"[email protected]"
]
| |
0b0139095b9ca0781096958b45e4ad28f85dee83 | 4ce04d624fe87db3db61cabadd65efa404dd74cb | /app/src/main/java/com/vination/sunshine/MainActivity.java | 528f276afac4b265fba578c078999484cc47116b | []
| no_license | Vemon/Sunshine | 152505b14859d318d9a55742aa3673e1c116cbe2 | 60e439069f73d07144e1d27b2e20b8c8f34d27d8 | refs/heads/master | 2016-08-04T18:59:41.585176 | 2014-10-24T03:11:02 | 2014-10-24T03:11:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,328 | java | package com.vination.sunshine;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
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);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new ForecastFragment())
.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
]
| |
14de9098ef16e09501ae2738234c60a70731abb9 | 09cb8903da1a2b2b580866d13d5155a16b2ff7ee | /src/main/java/com/hr/domain/reportChart/ChartTemplate.java | 916cae3f7d99527a9a877f215f942e576edf156f | []
| no_license | tathanhxuan/hr | ce61da5e98853c064c92251f94c47c06df3682ba | d987bdd819bccc663eca0b208065243e8f53e200 | refs/heads/master | 2020-04-18T20:28:12.476034 | 2019-02-05T12:45:24 | 2019-02-05T12:45:24 | 167,738,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | java | package com.hr.domain.reportChart;
public abstract class ChartTemplate {
public abstract void getATStatistics();
public abstract void getOTStatistics();
public abstract void getLeaveStatistics();
public final void getReportChart() {
System.out.println("Report Statistics");
getATStatistics();
getOTStatistics();
getLeaveStatistics();
}
} | [
"[email protected]"
]
| |
5d6869e4f49d24160bb36f6c7c033f02bca317be | b34da302b2ec04c2b6fd90fc9d7fddaa7d9aacf0 | /pinyougou-shop-web/src/main/java/com/pinyougou/shop/controller/ItemController.java | 4b12a0518948df2febfbd6e96045e9d3f0e8bb3a | []
| no_license | CharleyLau/pinyougou | 57a0142d34141c7a3e11335bf024fd8eb2aefd94 | bf95b88c699838d6de506130c0ad598965fc3e34 | refs/heads/master | 2020-03-18T21:29:49.133056 | 2018-06-03T03:35:09 | 2018-06-03T03:35:12 | 135,283,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,252 | java | package com.pinyougou.shop.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.pinyougou.pojo.TbItem;
import com.pinyougou.sellergoods.service.ItemService;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* controller
* @author Administrator
*
*/
@RestController
@RequestMapping("/item")
public class ItemController {
@Reference
private ItemService itemService;
/**
* 返回全部列表
* @return
*/
@RequestMapping("/findAll")
public List<TbItem> findAll(){
return itemService.findAll();
}
/**
* 返回全部列表
* @return
*/
@RequestMapping("/findPage")
public PageResult findPage(int page,int rows){
return itemService.findPage(page, rows);
}
/**
* 增加
* @param item
* @return
*/
@RequestMapping("/add")
public Result add(@RequestBody TbItem item){
try {
itemService.add(item);
return new Result(true, "增加成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "增加失败");
}
}
/**
* 修改
* @param item
* @return
*/
@RequestMapping("/update")
public Result update(@RequestBody TbItem item){
try {
itemService.update(item);
return new Result(true, "修改成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "修改失败");
}
}
/**
* 获取实体
* @param id
* @return
*/
@RequestMapping("/findOne")
public TbItem findOne(Long id){
return itemService.findOne(id);
}
/**
* 批量删除
* @param ids
* @return
*/
@RequestMapping("/delete")
public Result delete(Long [] ids){
try {
itemService.delete(ids);
return new Result(true, "删除成功");
} catch (Exception e) {
e.printStackTrace();
return new Result(false, "删除失败");
}
}
/**
* 查询+分页
* @param
* @param page
* @param rows
* @return
*/
@RequestMapping("/search")
public PageResult search(@RequestBody TbItem item, int page, int rows ){
return itemService.findPage(item, page, rows);
}
}
| [
"[email protected]"
]
| |
f8b290e635d104d8de5faf6021a006cb7aa056ed | 383af3f62e01d58c36822b40a6fcde254ba1ccb8 | /src/test/java/com/compsis/security/SecurityUtilsUnitTest.java | c35d9234362a1f36e5030b495ff8f3792b65229d | []
| no_license | BulkSecurityGeneratorProject/coa | 1124f4b073d65842914759bf1e2473b3cf1916f7 | 5184b40842b28f5592676d020a23634822428221 | refs/heads/master | 2022-12-09T23:32:54.935790 | 2019-02-19T16:52:48 | 2019-02-19T16:52:48 | 296,580,751 | 0 | 0 | null | 2020-09-18T09:49:20 | 2020-09-18T09:49:19 | null | UTF-8 | Java | false | false | 3,198 | java | package com.compsis.security;
import org.junit.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Test class for the SecurityUtils utility class.
*
* @see SecurityUtils
*/
public class SecurityUtilsUnitTest {
@Test
public void testgetCurrentUserLogin() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
SecurityContextHolder.setContext(securityContext);
Optional<String> login = SecurityUtils.getCurrentUserLogin();
assertThat(login).contains("admin");
}
@Test
public void testgetCurrentUserJWT() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "token"));
SecurityContextHolder.setContext(securityContext);
Optional<String> jwt = SecurityUtils.getCurrentUserJWT();
assertThat(jwt).contains("token");
}
@Test
public void testIsAuthenticated() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
SecurityContextHolder.setContext(securityContext);
boolean isAuthenticated = SecurityUtils.isAuthenticated();
assertThat(isAuthenticated).isTrue();
}
@Test
public void testAnonymousIsNotAuthenticated() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(AuthoritiesConstants.ANONYMOUS));
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("anonymous", "anonymous", authorities));
SecurityContextHolder.setContext(securityContext);
boolean isAuthenticated = SecurityUtils.isAuthenticated();
assertThat(isAuthenticated).isFalse();
}
@Test
public void testIsCurrentUserInRole() {
SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
Collection<GrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(AuthoritiesConstants.USER));
securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("user", "user", authorities));
SecurityContextHolder.setContext(securityContext);
assertThat(SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.USER)).isTrue();
assertThat(SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN)).isFalse();
}
}
| [
"[email protected]"
]
| |
eae37c4a7bd8aa95470d74f621d8e22e01434642 | 01ebbc94cd4d2c63501c2ebd64b8f757ac4b9544 | /backend/gxqpt-pt/gxqpt-mt-api/src/main/java/com/hengyunsoft/platform/mt/api/punchstatics/dto/CompanyStaticsDTO.java | 9a866b3845a5c88493b9f02240d5b58bb725485e | []
| no_license | KevinAnYuan/gxq | 60529e527eadbbe63a8ecbbad6aaa0dea5a61168 | 9b59f4e82597332a70576f43e3f365c41d5cfbee | refs/heads/main | 2023-01-04T19:35:18.615146 | 2020-10-27T06:24:37 | 2020-10-27T06:24:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,807 | java | package com.hengyunsoft.platform.mt.api.punchstatics.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* com.hengyunsoft.platform.mt.api.punchclock.dto.clock
* 版权:中科恒运软件科技股份有限公司贵阳分公司
* 描述:企业统计首页
* 修改人:gbl
* 修改时间:2019/7/4
* 修改内容:
*/
@Data
@ApiModel(value = "CompanyStaticsDTO", description = "企业统计首页")
public class CompanyStaticsDTO {
@ApiModelProperty(value = "企业数量")
private int companyNum;
@ApiModelProperty(value = "本月新增")
private int monthNum;
@ApiModelProperty(value = "总资产")
private int property;
@ApiModelProperty(value = "在职人数")
private int personNum;
@ApiModelProperty(value = "申报数量")
private int projectDeclare;
@ApiModelProperty(value = "版权登记")
private int technical;
@ApiModelProperty(value = "软件著作权")
private int investment;
@ApiModelProperty(value = "IDC资质")
private int cultivate;
@ApiModelProperty(value = "历年项目申报数量统计 k:年份 v1:值")
private List<StaticsKVDTO> yearDeclare;
@ApiModelProperty(value = "项目申报类别统计 k:类别(0:其他 1.CMMI;2,发明专利;3,实用型专利;4,外观设计专利;5,版权登记;6,软件著作权;7,IDC资质) v1:数据")
private List<StaticsKVDTO> pDeclares;
@ApiModelProperty(value = "项目补助资金情况统计 k:年份 v1: 贷款贴息 v2:财政拨款")
private List<StaticsKVDTO> projectSubsidy;
@ApiModelProperty(value = "本年度企业项目申报排名 k:企业名称 v1:数量")
private List<StaticsKVDTO> companyDeclare;
}
| [
"[email protected]"
]
| |
c5c9c701446a65c7da6735c796afad3f53e6c426 | 0bd2a900824c05bd49fec3294a857567a7e4575c | /src/tests/org/jboss/test/remoting/stream/StreamingConnectorTestClient.java | 20117aaf59e86a255881ff8d12129face7779024 | []
| no_license | dcreado/jbossremoting2.5.3 | 769e0bf3cfb026e76999ad9fc8057132a52c7b0e | 74d0979a0b0f4e41e189f620bd1a3c9554c638a4 | refs/heads/master | 2021-01-01T06:04:42.540475 | 2013-04-25T17:23:13 | 2013-04-25T17:23:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,518 | java | package org.jboss.test.remoting.stream;
import junit.framework.TestCase;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.Connector;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Map;
/**
* @author <a href="mailto:[email protected]">Tom Elrod</a>
*/
public class StreamingConnectorTestClient extends TestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5400;
private String locatorURI;
private Client remotingClient = null;
private File testFile = null;
private FileInputStream fileInput = null;
private boolean error = false;
private Connector connector = null;
private String streamConnectorLocatorUri;
public void testStream() throws Throwable
{
for(int x = 0; x < 5; x++)
{
// new Thread(new Runnable() {
// public void run()
// {
// try
// {
sendStream();
// }
// catch (Throwable throwable)
// {
// throwable.printStackTrace();
// error = true;
// }
// }
// }).start();
}
// Thread.sleep(5000);
// assertFalse(error);
}
public void sendStream() throws Throwable
{
URL fileURL = this.getClass().getResource("test.txt");
if(fileURL == null)
{
throw new Exception("Can not find file test.txt");
}
testFile = new File(fileURL.getFile());
fileInput = new FileInputStream(testFile);
String param = "foobar";
long fileLength = testFile.length();
System.out.println("File size = " + fileLength);
Object ret = remotingClient.invoke(fileInput, param, connector);
Map responseMap = (Map)ret;
String subSys = (String)responseMap.get("subsystem");
String clientId = (String)responseMap.get("clientid");
String paramVal = (String)responseMap.get("paramval");
assertEquals("test_stream".toUpperCase(), subSys);
assertEquals(remotingClient.getSessionId(), clientId);
assertEquals("foobar", paramVal);
Object response = remotingClient.invoke("get_size");
int returnedFileLength = ((Integer) response).intValue();
System.out.println("Invocation response: " + response);
if(fileLength == returnedFileLength)
{
System.out.println("PASS");
}
else
{
System.out.println("FAILED - returned file length was " + returnedFileLength);
}
assertEquals(fileLength, returnedFileLength);
}
public void setUp() throws Exception
{
String bindAddr = System.getProperty("jrunit.bind_addr", host);
locatorURI = transport + "://" + bindAddr + ":" + port;
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
remotingClient = new Client(locator, "test_stream");
remotingClient.connect();
setupServer();
}
private void setupServer() throws Exception
{
String bindAddr = System.getProperty("jrunit.bind_addr", host);
streamConnectorLocatorUri = transport + "://" + bindAddr + ":" + 5410;
connector = new Connector(streamConnectorLocatorUri);
connector.create();
connector.start();
}
public void tearDown() throws Exception
{
if(remotingClient != null)
{
remotingClient.disconnect();
}
if(fileInput != null)
{
fileInput.close();
}
}
/**
* Can pass transport and port to be used as parameters.
* Valid transports are 'rmi' and 'socket'.
*
* @param args
*/
public static void main(String[] args)
{
if(args != null && args.length == 2)
{
StreamingConnectorTestClient.transport = args[0];
StreamingConnectorTestClient.port = Integer.parseInt(args[1]);
}
String locatorURI = StreamingConnectorTestClient.transport + "://" + StreamingConnectorTestClient.host + ":" + StreamingConnectorTestClient.port;
StreamingConnectorTestClient client = new StreamingConnectorTestClient();
try
{
client.setUp();
client.testStream();
client.tearDown();
}
catch(Throwable e)
{
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
1ce52dcb923083f8a0b30f61aa290763f19670cd | 5e3f90e83ae9588c0ffdcf22fa7ddb6cedc6dffb | /src/teal/core/BeanInfoAdapter.java | 883a14a04005664be7b9815f40897249d698a5e1 | [
"MIT",
"BSD-2-Clause"
]
| permissive | thosmos/TEALsim | c8704584dd4200f9db90142a50f377eafa7aba0e | bebb6ee90ba7e1e547f9ecb51b391aa742a784a8 | refs/heads/master | 2020-03-23T21:12:40.506442 | 2015-04-24T09:22:33 | 2015-04-24T09:22:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,117 | java | /*
* TEALsim - MIT TEAL Project
* Copyright (c) 2004 The Massachusetts Institute of Technology. All rights reserved.
* Please see license.txt in top level directory for full license.
*
* http://icampus.mit.edu/teal/TEALsim
*
* $Id: BeanInfoAdapter.java,v 1.9 2008/02/11 19:40:59 pbailey Exp $
*
*/
package teal.core;
import java.beans.*;
import teal.util.*;
/**
*
* @author Andrew McKinney
* @author Phil Bailey
* @author Michael Danziger
* @version $Revision: 1.9 $
*/
public class BeanInfoAdapter extends SimpleBeanInfo {
public static EventSetDescriptor[] sEventSetTemplate = new EventSetDescriptor[0];
public static PropertyDescriptor[] sPropertyTemplate = new PropertyDescriptor[0];
public int getDefaultEventIndex() {
TDebug.println(2,"BeanInfoAdapter: " + this.getClass().getName() + ": getDefaultEventIndex");
return -1;
}
public EventSetDescriptor[] getEventSetDescriptors() {
TDebug.println(2,"BeanInfoAdapter: " + this.getClass().getName() + ": getEventSet");
//return new EventSetDescriptor[0];
return null;
}
} | [
"[email protected]"
]
| |
1e463f4178c24282028121188c5b7089694d9a80 | ce6132b320ca0a55e8b122f25ad4987202a52afb | /src/controllers/employees/EmployeesCreateServlet.java | 73f0a909547010369e2bf104591efcfd3c4a90ff | []
| no_license | koutarouokutani/kadai-kakutyou | 4efa9b8746cee9c5a31d1e527525d86567ca7b37 | 50c28b532e9e0e58ea8c7987b576ac73e3ef1d0c | refs/heads/master | 2023-01-05T16:48:53.642732 | 2020-11-03T14:28:14 | 2020-11-03T14:28:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,943 | java | package controllers.employees;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;
import javax.persistence.EntityManager;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import models.Employee;
import models.validators.EmployeeValidator;
import utils.DBUtil;
import utils.EncryptUtil;
/**
* Servlet implementation class EmployeesCreateServlet
*/
@WebServlet("/employees/create")
public class EmployeesCreateServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public EmployeesCreateServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String _token = (String)request.getParameter("_token");
if(_token != null && _token.equals(request.getSession().getId())) {
EntityManager em = DBUtil.createEntityManager();
Employee e = new Employee();
e.setCode(request.getParameter("code"));
e.setName(request.getParameter("name"));
e.setPassword(
EncryptUtil.getPasswordEncrypt(
request.getParameter("password"),
(String)this.getServletContext().getAttribute("pepper")
)
);
e.setAdmin_flag(Integer.parseInt(request.getParameter("admin_flag")));
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
e.setCreated_at(currentTime);
e.setUpdated_at(currentTime);
e.setDelete_flag(0);
List<String> errors = EmployeeValidator.validate(e, true, true);
if(errors.size() > 0) {
em.close();
request.setAttribute("_token", request.getSession().getId());
request.setAttribute("employee", e);
request.setAttribute("errors", errors);
RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/views/employees/new.jsp");
rd.forward(request, response);
}else {
em.getTransaction().begin();
em.persist(e);
em.getTransaction().commit();
em.close();
request.getSession().setAttribute("flush", "登録が完了しました。");
response.sendRedirect(request.getContextPath() + "/employees/index");
}
}
}
}
| [
"[email protected]"
]
| |
008af406c90787aed9ce06a3c8bc5428216c4696 | 2a5c0c08e934177c35c5438522257ba50539ab6c | /aws/core/src/main/java/org/jclouds/aws/ec2/binders/BindBundleIdsToIndexedFormParams.java | cf64fa031206ec5f6e83a13f027bd5d7cfdb2a9a | [
"Apache-2.0"
]
| permissive | kohsuke/jclouds | 6258d76e94ad31cf51e1bf193e531ad301815b97 | 58f8a7eb1500f9574302b23d6382b379ebf187d9 | refs/heads/master | 2023-06-01T17:17:27.598644 | 2010-08-04T01:34:19 | 2010-08-04T01:34:19 | 816,000 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,336 | java | /**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <[email protected]>
*
* ====================================================================
* 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.jclouds.aws.ec2.binders;
import static org.jclouds.aws.ec2.util.EC2Utils.indexStringArrayToFormValuesWithPrefix;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
/**
* Binds the String [] to form parameters named with BundleId.index
*
* @author Adrian Cole
*/
@Singleton
public class BindBundleIdsToIndexedFormParams implements Binder {
public void bindToRequest(HttpRequest request, Object input) {
indexStringArrayToFormValuesWithPrefix(request, "BundleId", input);
}
} | [
"[email protected]"
]
| |
dc381658546819c1ec1fefd360a04028fbd9a868 | 809991a39dfc70caf54ede45d0d7e8970debd5fb | /src/Test/Arename.java | 97f74028ae24b66392ed0263931369def61c0cc1 | []
| no_license | s1nd/DesignPattern | f525f0bfc5e19c0a7ab4761200ba190eb26bf82e | 5513da5fbdcf8093096125aea9ac3a1f8d548f54 | refs/heads/master | 2021-01-05T01:31:42.557859 | 2020-04-28T05:42:37 | 2020-04-28T05:42:37 | 240,830,493 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 40 | java | package Test;
public class Arename {
}
| [
"[email protected]"
]
| |
638aa2d681852e93e12d54960b1573f366c2c83d | 9c1b583175e0c41e7541300fb5342d3149a53c21 | /sandeep-exercies/swbhavtech-linkedList/src/com/techlabs/generic/linklist/Node.java | 134df9cb6ce5f163d7adc1aeb912e465d58e3b0f | []
| no_license | mohan08p/java_students | 90c8da05f8ddd1834e1b4a23b3f1e0e2b0fd363f | edb069b962ceaf80c052336db36fc0bd8c3261dd | refs/heads/master | 2021-01-25T14:11:11.782720 | 2018-01-29T08:56:09 | 2018-01-29T08:56:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 538 | java | package com.techlabs.generic.linklist;
public class Node<T> {
T item;
Node<T> next;
Node<T> prev;
Node(Node<T> prev, T element, Node<T> next) {
this.item = element;
this.next = next;
this.prev = prev;
}
public T getItem() {
return item;
}
public void setItem(T item) {
this.item = item;
}
public Node<T> getNext() {
return next;
}
public void setNext(Node<T> next) {
this.next = next;
}
public Node<T> getPrev() {
return prev;
}
public void setPrev(Node<T> prev) {
this.prev = prev;
}
} | [
"[email protected]"
]
| |
0ddb8c8e50db3eba5462a48c4f4873c460f08111 | dcfb8393958359ad6efbedc032ad9fd28608ffb1 | /shoppingbackend/src/test/java/barcan/ro/shoppingbackend/AppTest.java | b60b685521c4d55278c869b9f34c562ea530feae | []
| no_license | Daniel11041990/online-shopping | 09e5c2b43bce22c1a24aef43bfe0e9706411eb53 | 09dea0ae86b771a44cf765919da89cd56c3c5769 | refs/heads/master | 2021-09-14T17:10:32.632084 | 2018-05-16T12:14:26 | 2018-05-16T12:14:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 691 | java | package barcan.ro.shoppingbackend;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| [
"[email protected]"
]
| |
df25f2ff72cf6fe5970531d06b8b89bc418514a3 | 0907c886f81331111e4e116ff0c274f47be71805 | /sources/com/mopub/mobileads/VastVideoViewControllerTwo.java | 234b71184864fadbee0bc1b383ddb6ea02da3824 | [
"MIT"
]
| permissive | Minionguyjpro/Ghostly-Skills | 18756dcdf351032c9af31ec08fdbd02db8f3f991 | d1a1fb2498aec461da09deb3ef8d98083542baaf | refs/heads/Android-OS | 2022-07-27T19:58:16.442419 | 2022-04-15T07:49:53 | 2022-04-15T07:49:53 | 415,272,874 | 2 | 0 | MIT | 2021-12-21T10:23:50 | 2021-10-09T10:12:36 | Java | UTF-8 | Java | false | false | 51,450 | java | package com.mopub.mobileads;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.core.content.ContextCompat;
import androidx.media.AudioAttributesCompat;
import androidx.media2.common.SessionPlayer;
import androidx.media2.common.UriMediaItem;
import androidx.media2.player.MediaPlayer;
import androidx.media2.player.PlaybackParams;
import androidx.media2.widget.VideoView;
import com.mopub.common.ExternalViewabilitySession;
import com.mopub.common.ExternalViewabilitySessionManager;
import com.mopub.common.IntentActions;
import com.mopub.common.VisibleForTesting;
import com.mopub.common.logging.MoPubLog;
import com.mopub.common.util.AsyncTasks;
import com.mopub.common.util.Dips;
import java.util.concurrent.Executor;
import kotlin.jvm.internal.Intrinsics;
@Mockable
/* compiled from: VastVideoViewControllerTwo.kt */
public class VastVideoViewControllerTwo extends BaseVideoViewController {
public static final String CURRENT_POSITION = "current_position";
public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
private static final int DEFAULT_VIDEO_DURATION_FOR_CLOSE_BUTTON = 5000;
public static final String RESUMED_VAST_CONFIG = "resumed_vast_config";
private static final int SEEKER_POSITION_NOT_INITIALIZED = -1;
public static final String VAST_VIDEO_CONFIG = "vast_video_config";
private static final long VIDEO_COUNTDOWN_UPDATE_INTERVAL = 250;
private static final long VIDEO_PROGRESS_TIMER_CHECKER_DELAY = 50;
private final Activity activity;
private VastVideoBlurLastVideoFrameTask blurLastVideoFrameTask;
private final ImageView blurredLastVideoFrameImageView;
public VastVideoGradientStripWidget bottomGradientStripWidget;
private final View.OnTouchListener clickThroughListener;
public VastVideoCloseButtonWidget closeButtonWidget;
private final VastVideoViewCountdownRunnableTwo countdownRunnable;
private final VastVideoCtaButtonWidget ctaButtonWidget;
/* access modifiers changed from: private */
public final ExternalViewabilitySessionManager externalViewabilitySessionManager = new ExternalViewabilitySessionManager(getActivity());
private final Bundle extras;
private final View iconView;
private boolean isCalibrationDone;
private boolean isClosing;
private boolean isComplete;
/* access modifiers changed from: private */
public boolean isInClickExperiment;
private final View landscapeCompanionAdView;
private MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
private final MediaPlayer mediaPlayer = new MediaPlayer(getContext());
private final View portraitCompanionAdView;
public VastVideoProgressBarWidget progressBarWidget;
private final VastVideoViewProgressRunnableTwo progressCheckerRunnable;
public VastVideoRadialCountdownWidget radialCountdownWidget;
private final Bundle savedInstanceState;
private int seekerPositionOnPause = -1;
private boolean shouldAllowClose;
private boolean shouldAllowSkip;
private int showCloseButtonDelay = DEFAULT_VIDEO_DURATION_FOR_CLOSE_BUTTON;
public VastVideoGradientStripWidget topGradientStripWidget;
/* access modifiers changed from: private */
public VastCompanionAdConfigTwo vastCompanionAdConfig;
private final VastIconConfigTwo vastIconConfig;
private final VastVideoConfigTwo vastVideoConfig;
private boolean videoError;
/* access modifiers changed from: private */
public final VideoView videoView;
@VisibleForTesting
public static /* synthetic */ void blurLastVideoFrameTask$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void blurredLastVideoFrameImageView$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void bottomGradientStripWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void closeButtonWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void ctaButtonWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void iconView$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void isCalibrationDone$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void isClosing$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void isComplete$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void landscapeCompanionAdView$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void mediaMetadataRetriever$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void portraitCompanionAdView$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void progressBarWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void radialCountdownWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void shouldAllowClose$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void showCloseButtonDelay$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void topGradientStripWidget$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void vastIconConfig$annotations() {
}
@VisibleForTesting
public static /* synthetic */ void vastVideoConfig$annotations() {
}
public Activity getActivity() {
return this.activity;
}
public Bundle getExtras() {
return this.extras;
}
public Bundle getSavedInstanceState() {
return this.savedInstanceState;
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
/* JADX WARNING: Code restructure failed: missing block: B:39:0x0273, code lost:
if (r0 != null) goto L_0x027f;
*/
/* JADX WARNING: Removed duplicated region for block: B:26:0x009c */
/* JADX WARNING: Removed duplicated region for block: B:62:0x0346 */
/* Code decompiled incorrectly, please refer to instructions dump. */
public VastVideoViewControllerTwo(android.app.Activity r8, android.os.Bundle r9, android.os.Bundle r10, long r11, com.mopub.mobileads.BaseVideoViewController.BaseVideoViewControllerListener r13) {
/*
r7 = this;
java.lang.String r0 = "activity"
kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull(r8, r0)
java.lang.String r0 = "extras"
kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull(r9, r0)
java.lang.String r0 = "baseListener"
kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull(r13, r0)
r0 = r8
android.content.Context r0 = (android.content.Context) r0
java.lang.Long r11 = java.lang.Long.valueOf(r11)
r7.<init>(r0, r11, r13)
r7.activity = r8
r7.extras = r9
r7.savedInstanceState = r10
androidx.media2.player.MediaPlayer r8 = new androidx.media2.player.MediaPlayer
android.content.Context r9 = r7.getContext()
r8.<init>(r9)
r7.mediaPlayer = r8
r8 = -1
r7.seekerPositionOnPause = r8
com.mopub.common.ExternalViewabilitySessionManager r9 = new com.mopub.common.ExternalViewabilitySessionManager
android.app.Activity r10 = r7.getActivity()
android.content.Context r10 = (android.content.Context) r10
r9.<init>(r10)
r7.externalViewabilitySessionManager = r9
android.media.MediaMetadataRetriever r9 = new android.media.MediaMetadataRetriever
r9.<init>()
r7.mediaMetadataRetriever = r9
r9 = 5000(0x1388, float:7.006E-42)
r7.showCloseButtonDelay = r9
android.os.Bundle r9 = r7.getSavedInstanceState()
r10 = 0
if (r9 == 0) goto L_0x0053
java.lang.String r11 = "resumed_vast_config"
java.io.Serializable r9 = r9.getSerializable(r11)
goto L_0x0054
L_0x0053:
r9 = r10
L_0x0054:
boolean r11 = r9 instanceof com.mopub.mobileads.VastVideoConfigTwo
if (r11 != 0) goto L_0x0059
r9 = r10
L_0x0059:
com.mopub.mobileads.VastVideoConfigTwo r9 = (com.mopub.mobileads.VastVideoConfigTwo) r9
if (r9 == 0) goto L_0x005f
r11 = r9
goto L_0x0072
L_0x005f:
android.os.Bundle r11 = r7.getExtras()
java.lang.String r12 = "vast_video_config"
java.io.Serializable r11 = r11.getSerializable(r12)
boolean r12 = r11 instanceof com.mopub.mobileads.VastVideoConfigTwo
if (r12 != 0) goto L_0x006e
r11 = r10
L_0x006e:
com.mopub.mobileads.VastVideoConfigTwo r11 = (com.mopub.mobileads.VastVideoConfigTwo) r11
if (r11 == 0) goto L_0x0354
L_0x0072:
r7.vastVideoConfig = r11
if (r9 == 0) goto L_0x008f
android.os.Bundle r9 = r7.getSavedInstanceState()
if (r9 == 0) goto L_0x0087
java.lang.String r11 = "current_position"
int r9 = r9.getInt(r11, r8)
java.lang.Integer r9 = java.lang.Integer.valueOf(r9)
goto L_0x0088
L_0x0087:
r9 = r10
L_0x0088:
if (r9 == 0) goto L_0x008f
int r9 = r9.intValue()
goto L_0x0090
L_0x008f:
r9 = -1
L_0x0090:
r7.seekerPositionOnPause = r9
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
java.lang.String r9 = r9.getDiskMediaFileUrl()
if (r9 == 0) goto L_0x0346
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
android.app.Activity r11 = r7.getActivity()
android.content.res.Resources r11 = r11.getResources()
java.lang.String r12 = "activity.resources"
kotlin.jvm.internal.Intrinsics.checkExpressionValueIsNotNull(r11, r12)
android.content.res.Configuration r11 = r11.getConfiguration()
int r11 = r11.orientation
com.mopub.mobileads.VastCompanionAdConfigTwo r9 = r9.getVastCompanionAd(r11)
r7.vastCompanionAdConfig = r9
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
com.mopub.mobileads.VastIconConfigTwo r9 = r9.getVastIconConfig()
r7.vastIconConfig = r9
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
boolean r9 = r9.getEnableClickExperiment()
r7.isInClickExperiment = r9
com.mopub.mobileads.VastVideoViewControllerTwo$4 r9 = new com.mopub.mobileads.VastVideoViewControllerTwo$4
r9.<init>(r7)
android.view.View$OnTouchListener r9 = (android.view.View.OnTouchListener) r9
r7.clickThroughListener = r9
android.view.ViewGroup r9 = r7.getLayout()
r11 = -16777216(0xffffffffff000000, float:-1.7014118E38)
r9.setBackgroundColor(r11)
android.widget.ImageView r9 = new android.widget.ImageView
android.content.Context r11 = r7.getContext()
r9.<init>(r11)
r11 = 4
r9.setVisibility(r11)
android.widget.RelativeLayout$LayoutParams r12 = new android.widget.RelativeLayout$LayoutParams
r12.<init>(r8, r8)
android.view.ViewGroup r8 = r7.getLayout()
r13 = r9
android.view.View r13 = (android.view.View) r13
android.view.ViewGroup$LayoutParams r12 = (android.view.ViewGroup.LayoutParams) r12
r8.addView(r13, r12)
android.view.View$OnTouchListener r8 = r7.clickThroughListener
r9.setOnTouchListener(r8)
kotlin.Unit r8 = kotlin.Unit.INSTANCE
r7.blurredLastVideoFrameImageView = r9
android.app.Activity r8 = r7.getActivity()
android.content.Context r8 = (android.content.Context) r8
r9 = 0
androidx.media2.widget.VideoView r8 = r7.createVideoView(r8, r9)
r7.videoView = r8
r8.requestFocus()
com.mopub.common.ExternalViewabilitySessionManager r8 = r7.externalViewabilitySessionManager
android.app.Activity r12 = r7.getActivity()
androidx.media2.widget.VideoView r13 = r7.videoView
android.view.View r13 = (android.view.View) r13
com.mopub.mobileads.VastVideoConfigTwo r0 = r7.getVastVideoConfig()
r8.createVideoSession((android.app.Activity) r12, (android.view.View) r13, (com.mopub.mobileads.VastVideoConfigTwo) r0)
com.mopub.common.ExternalViewabilitySessionManager r8 = r7.externalViewabilitySessionManager
android.widget.ImageView r12 = r7.getBlurredLastVideoFrameImageView()
android.view.View r12 = (android.view.View) r12
r8.registerVideoObstruction(r12)
com.mopub.mobileads.VastVideoConfigTwo r8 = r7.getVastVideoConfig()
r12 = 2
android.view.View r8 = r7.createCompanionAdView(r8, r12, r11)
r7.landscapeCompanionAdView = r8
com.mopub.mobileads.VastVideoConfigTwo r8 = r7.getVastVideoConfig()
r12 = 1
android.view.View r8 = r7.createCompanionAdView(r8, r12, r11)
r7.portraitCompanionAdView = r8
com.mopub.mobileads.VastCompanionAdConfigTwo r8 = r7.vastCompanionAdConfig
if (r8 == 0) goto L_0x014e
r8 = 1
goto L_0x014f
L_0x014e:
r8 = 0
L_0x014f:
com.mopub.mobileads.VastVideoGradientStripWidget r13 = new com.mopub.mobileads.VastVideoGradientStripWidget
android.content.Context r1 = r7.getContext()
android.graphics.drawable.GradientDrawable$Orientation r2 = android.graphics.drawable.GradientDrawable.Orientation.TOP_BOTTOM
r4 = 0
r5 = 6
android.view.ViewGroup r0 = r7.getLayout()
java.lang.String r3 = "layout"
kotlin.jvm.internal.Intrinsics.checkExpressionValueIsNotNull(r0, r3)
int r6 = r0.getId()
r0 = r13
r3 = r8
r0.<init>(r1, r2, r3, r4, r5, r6)
android.view.ViewGroup r0 = r7.getLayout()
r1 = r13
android.view.View r1 = (android.view.View) r1
r0.addView(r1)
com.mopub.common.ExternalViewabilitySessionManager r0 = r7.externalViewabilitySessionManager
r0.registerVideoObstruction(r1)
kotlin.Unit r0 = kotlin.Unit.INSTANCE
r7.setTopGradientStripWidget(r13)
com.mopub.mobileads.VastVideoProgressBarWidget r13 = new com.mopub.mobileads.VastVideoProgressBarWidget
android.content.Context r0 = r7.getContext()
r13.<init>(r0)
androidx.media2.widget.VideoView r0 = r7.videoView
int r0 = r0.getId()
r13.setAnchorId(r0)
r13.setVisibility(r11)
android.view.ViewGroup r0 = r7.getLayout()
r1 = r13
android.view.View r1 = (android.view.View) r1
r0.addView(r1)
com.mopub.common.ExternalViewabilitySessionManager r0 = r7.externalViewabilitySessionManager
r0.registerVideoObstruction(r1)
kotlin.Unit r0 = kotlin.Unit.INSTANCE
r7.setProgressBarWidget(r13)
com.mopub.mobileads.VastVideoGradientStripWidget r13 = new com.mopub.mobileads.VastVideoGradientStripWidget
android.content.Context r1 = r7.getContext()
android.graphics.drawable.GradientDrawable$Orientation r2 = android.graphics.drawable.GradientDrawable.Orientation.BOTTOM_TOP
r4 = 8
r5 = 2
com.mopub.mobileads.VastVideoProgressBarWidget r0 = r7.getProgressBarWidget()
int r6 = r0.getId()
r0 = r13
r0.<init>(r1, r2, r3, r4, r5, r6)
android.view.ViewGroup r0 = r7.getLayout()
r1 = r13
android.view.View r1 = (android.view.View) r1
r0.addView(r1)
com.mopub.common.ExternalViewabilitySessionManager r0 = r7.externalViewabilitySessionManager
r0.registerVideoObstruction(r1)
kotlin.Unit r0 = kotlin.Unit.INSTANCE
r7.setBottomGradientStripWidget(r13)
com.mopub.mobileads.VastVideoRadialCountdownWidget r13 = new com.mopub.mobileads.VastVideoRadialCountdownWidget
android.content.Context r0 = r7.getContext()
r13.<init>(r0)
r13.setVisibility(r11)
android.view.ViewGroup r0 = r7.getLayout()
r1 = r13
android.view.View r1 = (android.view.View) r1
r0.addView(r1)
com.mopub.common.ExternalViewabilitySessionManager r0 = r7.externalViewabilitySessionManager
r0.registerVideoObstruction(r1)
kotlin.Unit r0 = kotlin.Unit.INSTANCE
r7.setRadialCountdownWidget(r13)
com.mopub.mobileads.VastIconConfigTwo r13 = r7.getVastIconConfig()
if (r13 == 0) goto L_0x0276
android.content.Context r0 = r7.getContext()
com.mopub.mobileads.VastResourceTwo r1 = r13.getVastResource()
com.mopub.mobileads.VastWebView r0 = com.mopub.mobileads.VastWebView.createView((android.content.Context) r0, (com.mopub.mobileads.VastResourceTwo) r1)
java.lang.String r1 = "it"
kotlin.jvm.internal.Intrinsics.checkExpressionValueIsNotNull(r0, r1)
com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$let$lambda$1 r1 = new com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$let$lambda$1
r1.<init>(r13, r7)
com.mopub.mobileads.VastWebView$VastWebViewClickListener r1 = (com.mopub.mobileads.VastWebView.VastWebViewClickListener) r1
r0.setVastWebViewClickListener(r1)
com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$let$lambda$2 r1 = new com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$let$lambda$2
r1.<init>(r13, r7)
android.webkit.WebViewClient r1 = (android.webkit.WebViewClient) r1
r0.setWebViewClient(r1)
r0.setVisibility(r11)
com.mopub.mobileads.VastIconConfigTwo r11 = r7.getVastIconConfig()
if (r11 == 0) goto L_0x0246
android.widget.RelativeLayout$LayoutParams r10 = new android.widget.RelativeLayout$LayoutParams
int r11 = r13.getWidth()
float r11 = (float) r11
android.content.Context r1 = r7.getContext()
int r11 = com.mopub.common.util.Dips.asIntPixels(r11, r1)
int r13 = r13.getHeight()
float r13 = (float) r13
android.content.Context r1 = r7.getContext()
int r13 = com.mopub.common.util.Dips.asIntPixels(r13, r1)
r10.<init>(r11, r13)
L_0x0246:
r11 = 12
float r11 = (float) r11
android.content.Context r13 = r7.getContext()
int r13 = com.mopub.common.util.Dips.dipsToIntPixels(r11, r13)
android.content.Context r1 = r7.getContext()
int r11 = com.mopub.common.util.Dips.dipsToIntPixels(r11, r1)
if (r10 == 0) goto L_0x0260
r10.setMargins(r13, r11, r9, r9)
kotlin.Unit r11 = kotlin.Unit.INSTANCE
L_0x0260:
android.view.ViewGroup r11 = r7.getLayout()
r13 = r0
android.view.View r13 = (android.view.View) r13
android.view.ViewGroup$LayoutParams r10 = (android.view.ViewGroup.LayoutParams) r10
r11.addView(r13, r10)
com.mopub.common.ExternalViewabilitySessionManager r10 = r7.externalViewabilitySessionManager
r10.registerVideoObstruction(r13)
kotlin.Unit r10 = kotlin.Unit.INSTANCE
if (r0 == 0) goto L_0x0276
goto L_0x027f
L_0x0276:
android.view.View r13 = new android.view.View
android.content.Context r10 = r7.getContext()
r13.<init>(r10)
L_0x027f:
r7.iconView = r13
android.content.Context r10 = r7.getContext()
androidx.media2.widget.VideoView r11 = r7.videoView
int r11 = r11.getId()
com.mopub.mobileads.VastVideoConfigTwo r13 = r7.getVastVideoConfig()
java.lang.String r13 = r13.getClickThroughUrl()
java.lang.CharSequence r13 = (java.lang.CharSequence) r13
if (r13 == 0) goto L_0x029d
int r13 = r13.length()
if (r13 != 0) goto L_0x029e
L_0x029d:
r9 = 1
L_0x029e:
r9 = r9 ^ r12
com.mopub.mobileads.VastVideoCtaButtonWidget r12 = new com.mopub.mobileads.VastVideoCtaButtonWidget
r12.<init>(r10, r11, r8, r9)
android.view.ViewGroup r8 = r7.getLayout()
r9 = r12
android.view.View r9 = (android.view.View) r9
r8.addView(r9)
com.mopub.common.ExternalViewabilitySessionManager r8 = r7.externalViewabilitySessionManager
r8.registerVideoObstruction(r9)
com.mopub.mobileads.VastVideoConfigTwo r8 = r7.getVastVideoConfig()
java.lang.String r8 = r8.getCustomCtaText()
if (r8 == 0) goto L_0x02c2
r12.updateCtaText(r8)
kotlin.Unit r8 = kotlin.Unit.INSTANCE
L_0x02c2:
android.view.View$OnTouchListener r8 = r7.clickThroughListener
r12.setOnTouchListener(r8)
kotlin.Unit r8 = kotlin.Unit.INSTANCE
r7.ctaButtonWidget = r12
com.mopub.mobileads.VastVideoCloseButtonWidget r8 = new com.mopub.mobileads.VastVideoCloseButtonWidget
android.content.Context r9 = r7.getContext()
r8.<init>(r9)
r9 = 8
r8.setVisibility(r9)
android.view.ViewGroup r9 = r7.getLayout()
r10 = r8
android.view.View r10 = (android.view.View) r10
r9.addView(r10)
com.mopub.common.ExternalViewabilitySessionManager r9 = r7.externalViewabilitySessionManager
r9.registerVideoObstruction(r10)
com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$also$lambda$3 r9 = new com.mopub.mobileads.VastVideoViewControllerTwo$$special$$inlined$also$lambda$3
r9.<init>(r7)
android.view.View$OnTouchListener r9 = (android.view.View.OnTouchListener) r9
r8.setOnTouchListenerToContent(r9)
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
java.lang.String r9 = r9.getCustomSkipText()
if (r9 == 0) goto L_0x0301
r8.updateCloseButtonText(r9)
kotlin.Unit r9 = kotlin.Unit.INSTANCE
L_0x0301:
com.mopub.mobileads.VastVideoConfigTwo r9 = r7.getVastVideoConfig()
java.lang.String r9 = r9.getCustomCloseIconUrl()
if (r9 == 0) goto L_0x0310
r8.updateCloseButtonIcon(r9)
kotlin.Unit r9 = kotlin.Unit.INSTANCE
L_0x0310:
kotlin.Unit r9 = kotlin.Unit.INSTANCE
r7.setCloseButtonWidget(r8)
boolean r8 = r7.isInClickExperiment
if (r8 == 0) goto L_0x032a
com.mopub.mobileads.VastVideoConfigTwo r8 = r7.getVastVideoConfig()
boolean r8 = r8.isRewarded()
if (r8 != 0) goto L_0x032a
com.mopub.mobileads.VastVideoCtaButtonWidget r8 = r7.getCtaButtonWidget()
r8.notifyVideoSkippable()
L_0x032a:
android.os.Handler r8 = new android.os.Handler
android.os.Looper r9 = android.os.Looper.getMainLooper()
r8.<init>(r9)
com.mopub.mobileads.VastVideoViewProgressRunnableTwo r9 = new com.mopub.mobileads.VastVideoViewProgressRunnableTwo
com.mopub.mobileads.VastVideoConfigTwo r10 = r7.getVastVideoConfig()
r9.<init>(r7, r10, r8)
r7.progressCheckerRunnable = r9
com.mopub.mobileads.VastVideoViewCountdownRunnableTwo r9 = new com.mopub.mobileads.VastVideoViewCountdownRunnableTwo
r9.<init>(r7, r8)
r7.countdownRunnable = r9
return
L_0x0346:
java.lang.IllegalArgumentException r8 = new java.lang.IllegalArgumentException
java.lang.String r9 = "VastVideoConfigTwo does not have a video disk path"
java.lang.String r9 = r9.toString()
r8.<init>(r9)
java.lang.Throwable r8 = (java.lang.Throwable) r8
throw r8
L_0x0354:
java.lang.IllegalArgumentException r8 = new java.lang.IllegalArgumentException
java.lang.String r9 = "VastVideoConfigTwo is invalid"
java.lang.String r9 = r9.toString()
r8.<init>(r9)
java.lang.Throwable r8 = (java.lang.Throwable) r8
throw r8
*/
throw new UnsupportedOperationException("Method not decompiled: com.mopub.mobileads.VastVideoViewControllerTwo.<init>(android.app.Activity, android.os.Bundle, android.os.Bundle, long, com.mopub.mobileads.BaseVideoViewController$BaseVideoViewControllerListener):void");
}
/* compiled from: VastVideoViewControllerTwo.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public MediaPlayer getMediaPlayer() {
return this.mediaPlayer;
}
public VastVideoConfigTwo getVastVideoConfig() {
return this.vastVideoConfig;
}
public VastIconConfigTwo getVastIconConfig() {
return this.vastIconConfig;
}
public ImageView getBlurredLastVideoFrameImageView() {
return this.blurredLastVideoFrameImageView;
}
public View getLandscapeCompanionAdView() {
return this.landscapeCompanionAdView;
}
public View getPortraitCompanionAdView() {
return this.portraitCompanionAdView;
}
public View getIconView() {
return this.iconView;
}
public VastVideoGradientStripWidget getTopGradientStripWidget() {
VastVideoGradientStripWidget vastVideoGradientStripWidget = this.topGradientStripWidget;
if (vastVideoGradientStripWidget == null) {
Intrinsics.throwUninitializedPropertyAccessException("topGradientStripWidget");
}
return vastVideoGradientStripWidget;
}
public void setTopGradientStripWidget(VastVideoGradientStripWidget vastVideoGradientStripWidget) {
Intrinsics.checkParameterIsNotNull(vastVideoGradientStripWidget, "<set-?>");
this.topGradientStripWidget = vastVideoGradientStripWidget;
}
public VastVideoGradientStripWidget getBottomGradientStripWidget() {
VastVideoGradientStripWidget vastVideoGradientStripWidget = this.bottomGradientStripWidget;
if (vastVideoGradientStripWidget == null) {
Intrinsics.throwUninitializedPropertyAccessException("bottomGradientStripWidget");
}
return vastVideoGradientStripWidget;
}
public void setBottomGradientStripWidget(VastVideoGradientStripWidget vastVideoGradientStripWidget) {
Intrinsics.checkParameterIsNotNull(vastVideoGradientStripWidget, "<set-?>");
this.bottomGradientStripWidget = vastVideoGradientStripWidget;
}
public VastVideoProgressBarWidget getProgressBarWidget() {
VastVideoProgressBarWidget vastVideoProgressBarWidget = this.progressBarWidget;
if (vastVideoProgressBarWidget == null) {
Intrinsics.throwUninitializedPropertyAccessException("progressBarWidget");
}
return vastVideoProgressBarWidget;
}
public void setProgressBarWidget(VastVideoProgressBarWidget vastVideoProgressBarWidget) {
Intrinsics.checkParameterIsNotNull(vastVideoProgressBarWidget, "<set-?>");
this.progressBarWidget = vastVideoProgressBarWidget;
}
public VastVideoRadialCountdownWidget getRadialCountdownWidget() {
VastVideoRadialCountdownWidget vastVideoRadialCountdownWidget = this.radialCountdownWidget;
if (vastVideoRadialCountdownWidget == null) {
Intrinsics.throwUninitializedPropertyAccessException("radialCountdownWidget");
}
return vastVideoRadialCountdownWidget;
}
public void setRadialCountdownWidget(VastVideoRadialCountdownWidget vastVideoRadialCountdownWidget) {
Intrinsics.checkParameterIsNotNull(vastVideoRadialCountdownWidget, "<set-?>");
this.radialCountdownWidget = vastVideoRadialCountdownWidget;
}
public VastVideoCtaButtonWidget getCtaButtonWidget() {
return this.ctaButtonWidget;
}
public VastVideoCloseButtonWidget getCloseButtonWidget() {
VastVideoCloseButtonWidget vastVideoCloseButtonWidget = this.closeButtonWidget;
if (vastVideoCloseButtonWidget == null) {
Intrinsics.throwUninitializedPropertyAccessException("closeButtonWidget");
}
return vastVideoCloseButtonWidget;
}
public void setCloseButtonWidget(VastVideoCloseButtonWidget vastVideoCloseButtonWidget) {
Intrinsics.checkParameterIsNotNull(vastVideoCloseButtonWidget, "<set-?>");
this.closeButtonWidget = vastVideoCloseButtonWidget;
}
public VastVideoBlurLastVideoFrameTask getBlurLastVideoFrameTask() {
return this.blurLastVideoFrameTask;
}
public void setBlurLastVideoFrameTask(VastVideoBlurLastVideoFrameTask vastVideoBlurLastVideoFrameTask) {
this.blurLastVideoFrameTask = vastVideoBlurLastVideoFrameTask;
}
public MediaMetadataRetriever getMediaMetadataRetriever() {
return this.mediaMetadataRetriever;
}
public void setMediaMetadataRetriever(MediaMetadataRetriever mediaMetadataRetriever2) {
this.mediaMetadataRetriever = mediaMetadataRetriever2;
}
public boolean isComplete() {
return this.isComplete;
}
public void setComplete(boolean z) {
this.isComplete = z;
}
public boolean getShouldAllowClose() {
return this.shouldAllowClose;
}
public void setShouldAllowClose(boolean z) {
this.shouldAllowClose = z;
}
public int getShowCloseButtonDelay() {
return this.showCloseButtonDelay;
}
public void setShowCloseButtonDelay(int i) {
this.showCloseButtonDelay = i;
}
public boolean isCalibrationDone() {
return this.isCalibrationDone;
}
public void setCalibrationDone(boolean z) {
this.isCalibrationDone = z;
}
public boolean isClosing() {
return this.isClosing;
}
public void setClosing(boolean z) {
this.isClosing = z;
}
public boolean getVideoError() {
return this.videoError;
}
public void setVideoError(boolean z) {
this.videoError = z;
}
public String getNetworkMediaFileUrl() {
return getVastVideoConfig().getNetworkMediaFileUrl();
}
/* access modifiers changed from: private */
public void adjustSkipOffset() {
int duration = getDuration();
if (getVastVideoConfig().isRewarded()) {
setShowCloseButtonDelay(duration);
return;
}
if (duration < 16000) {
setShowCloseButtonDelay(duration);
}
try {
Integer skipOffsetMillis = getVastVideoConfig().getSkipOffsetMillis(duration);
if (skipOffsetMillis != null) {
setShowCloseButtonDelay(skipOffsetMillis.intValue());
}
} catch (NumberFormatException unused) {
MoPubLog.log(MoPubLog.SdkLogEvent.CUSTOM, "Failed to parse skipoffset " + getVastVideoConfig().getSkipOffset());
}
}
private VideoView createVideoView(Context context, int i) {
VideoView videoView2 = new VideoView(context);
Executor mainExecutor = ContextCompat.getMainExecutor(context);
PlaybackParams build = new PlaybackParams.Builder().setAudioFallbackMode(0).setSpeed(1.0f).build();
Intrinsics.checkExpressionValueIsNotNull(build, "PlaybackParams.Builder()….0f)\n .build()");
getMediaPlayer().setPlaybackParams(build);
getMediaPlayer().setAudioAttributes(new AudioAttributesCompat.Builder().setUsage(1).setContentType(3).build());
getMediaPlayer().registerPlayerCallback(mainExecutor, new PlayerCallback());
videoView2.removeView(videoView2.getMediaControlView());
videoView2.setId(View.generateViewId());
videoView2.setPlayer(getMediaPlayer());
videoView2.setOnTouchListener(this.clickThroughListener);
MediaPlayer mediaPlayer2 = getMediaPlayer();
mediaPlayer2.setMediaItem(new UriMediaItem.Builder(Uri.parse(getVastVideoConfig().getDiskMediaFileUrl())).build());
mediaPlayer2.prepare().addListener(new VastVideoViewControllerTwo$createVideoView$$inlined$run$lambda$1(mediaPlayer2, this, mainExecutor), mainExecutor);
return videoView2;
}
public View createCompanionAdView(VastVideoConfigTwo vastVideoConfigTwo, int i, int i2) {
Intrinsics.checkParameterIsNotNull(vastVideoConfigTwo, "$this$createCompanionAdView");
VastCompanionAdConfigTwo vastCompanionAd = vastVideoConfigTwo.getVastCompanionAd(i);
if (vastCompanionAd != null) {
RelativeLayout relativeLayout = new RelativeLayout(getContext());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
relativeLayout.setGravity(17);
View view = relativeLayout;
getLayout().addView(view, layoutParams);
this.externalViewabilitySessionManager.registerVideoObstruction(view);
VastWebView createWebView = createWebView(vastCompanionAd);
createWebView.setVisibility(i2);
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(Dips.dipsToIntPixels((float) (vastCompanionAd.getWidth() + 16), getContext()), Dips.dipsToIntPixels((float) (vastCompanionAd.getHeight() + 16), getContext()));
layoutParams2.addRule(13, -1);
View view2 = createWebView;
relativeLayout.addView(view2, layoutParams2);
this.externalViewabilitySessionManager.registerVideoObstruction(view2);
if (createWebView != null) {
return view2;
}
}
View view3 = new View(getContext());
view3.setVisibility(4);
return view3;
}
private VastWebView createWebView(VastCompanionAdConfigTwo vastCompanionAdConfigTwo) {
VastWebView createView = VastWebView.createView(getContext(), vastCompanionAdConfigTwo.getVastResource());
Intrinsics.checkExpressionValueIsNotNull(createView, "it");
createView.setVastWebViewClickListener(new VastVideoViewControllerTwo$createWebView$$inlined$also$lambda$1(this, vastCompanionAdConfigTwo));
createView.setWebViewClient(new VastVideoViewControllerTwo$createWebView$$inlined$also$lambda$2(this, vastCompanionAdConfigTwo));
Intrinsics.checkExpressionValueIsNotNull(createView, "VastWebView.createView(c…}\n }\n }");
return createView;
}
/* access modifiers changed from: protected */
public void onCreate() {
super.onCreate();
VastVideoConfigTwo vastVideoConfig2 = getVastVideoConfig();
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig2.handleImpression(context, getDuration());
broadcastAction(IntentActions.ACTION_INTERSTITIAL_SHOW);
}
/* access modifiers changed from: protected */
public void onResume() {
startRunnables();
if (this.seekerPositionOnPause > 0) {
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_PLAYING, this.seekerPositionOnPause);
Intrinsics.checkExpressionValueIsNotNull(getMediaPlayer().seekTo((long) this.seekerPositionOnPause, 3), "mediaPlayer.seekTo(seeke…MediaPlayer.SEEK_CLOSEST)");
} else {
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_LOADED, getDuration());
if (!isComplete()) {
getMediaPlayer().play();
}
}
if (this.seekerPositionOnPause != -1) {
VastVideoConfigTwo vastVideoConfig2 = getVastVideoConfig();
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig2.handleResume(context, this.seekerPositionOnPause);
}
}
/* access modifiers changed from: protected */
public void onPause() {
stopRunnables();
this.seekerPositionOnPause = getCurrentPosition();
getMediaPlayer().pause();
if (!isClosing()) {
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_PAUSED, getCurrentPosition());
VastVideoConfigTwo vastVideoConfig2 = getVastVideoConfig();
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig2.handlePause(context, this.seekerPositionOnPause);
}
}
/* access modifiers changed from: protected */
public void onDestroy() {
stopRunnables();
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_STOPPED, getCurrentPosition());
this.externalViewabilitySessionManager.endVideoSession();
broadcastAction(IntentActions.ACTION_INTERSTITIAL_DISMISS);
}
/* access modifiers changed from: protected */
public void onSaveInstanceState(Bundle bundle) {
Intrinsics.checkParameterIsNotNull(bundle, "outState");
bundle.putInt(CURRENT_POSITION, this.seekerPositionOnPause);
bundle.putSerializable(RESUMED_VAST_CONFIG, getVastVideoConfig());
}
/* access modifiers changed from: protected */
public void onConfigurationChanged(Configuration configuration) {
Intrinsics.checkParameterIsNotNull(configuration, "newConfig");
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
Resources resources = context.getResources();
Intrinsics.checkExpressionValueIsNotNull(resources, "context.resources");
int i = resources.getConfiguration().orientation;
if (getLandscapeCompanionAdView().getVisibility() == 0 || getPortraitCompanionAdView().getVisibility() == 0) {
if (i == 1) {
getLandscapeCompanionAdView().setVisibility(4);
getPortraitCompanionAdView().setVisibility(0);
} else {
getLandscapeCompanionAdView().setVisibility(0);
getPortraitCompanionAdView().setVisibility(4);
}
}
VastCompanionAdConfigTwo vastCompanionAd = getVastVideoConfig().getVastCompanionAd(i);
if (vastCompanionAd != null) {
Context context2 = getContext();
Intrinsics.checkExpressionValueIsNotNull(context2, "context");
vastCompanionAd.handleImpression(context2, getDuration());
} else {
vastCompanionAd = null;
}
this.vastCompanionAdConfig = vastCompanionAd;
}
/* access modifiers changed from: protected */
public View getVideoView() {
return this.videoView;
}
/* access modifiers changed from: protected */
public void onBackPressed() {
handleExitTrackers();
}
public boolean backButtonEnabled() {
return this.shouldAllowSkip || getShouldAllowClose();
}
/* access modifiers changed from: protected */
public void onActivityResult(int i, int i2, Intent intent) {
if (isClosing() && i == 1 && i2 == -1) {
getBaseVideoViewControllerListener().onFinish();
}
}
public void handleViewabilityQuartileEvent$mopub_sdk_base_release(String str) {
Intrinsics.checkParameterIsNotNull(str, "enumValue");
ExternalViewabilitySession.VideoEvent valueOf = ExternalViewabilitySession.VideoEvent.valueOf(str);
if (valueOf != null) {
this.externalViewabilitySessionManager.recordVideoEvent(valueOf, getCurrentPosition());
}
}
public int getDuration() {
return (int) getMediaPlayer().getDuration();
}
public int getCurrentPosition() {
return (int) getMediaPlayer().getCurrentPosition();
}
public static /* synthetic */ void updateCountdown$mopub_sdk_base_release$default(VastVideoViewControllerTwo vastVideoViewControllerTwo, boolean z, int i, Object obj) {
if (obj == null) {
if ((i & 1) != 0) {
z = false;
}
vastVideoViewControllerTwo.updateCountdown$mopub_sdk_base_release(z);
return;
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: updateCountdown");
}
public void updateCountdown$mopub_sdk_base_release(boolean z) {
if (isCalibrationDone()) {
getRadialCountdownWidget().updateCountdownProgress(getShowCloseButtonDelay(), getCurrentPosition());
}
if (z || getCurrentPosition() >= getShowCloseButtonDelay()) {
getRadialCountdownWidget().setVisibility(8);
getCloseButtonWidget().setVisibility(0);
setShouldAllowClose(true);
if (this.isInClickExperiment || !getVastVideoConfig().isRewarded()) {
getCtaButtonWidget().notifyVideoSkippable();
}
}
}
public void updateProgressBar() {
getProgressBarWidget().updateProgress(getCurrentPosition());
}
public void handleIconDisplay(int i) {
Integer durationMS;
VastIconConfigTwo vastIconConfig2;
VastIconConfigTwo vastIconConfig3 = getVastIconConfig();
if (vastIconConfig3 != null) {
int offsetMS = vastIconConfig3.getOffsetMS();
getIconView().setVisibility(0);
String networkMediaFileUrl = getNetworkMediaFileUrl();
if (!(networkMediaFileUrl == null || (vastIconConfig2 = getVastIconConfig()) == null)) {
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastIconConfig2.handleImpression(context, i, networkMediaFileUrl);
}
VastIconConfigTwo vastIconConfig4 = getVastIconConfig();
if (vastIconConfig4 != null && (durationMS = vastIconConfig4.getDurationMS()) != null && i >= offsetMS + durationMS.intValue()) {
getIconView().setVisibility(8);
}
}
}
public void prepareBlurredLastVideoFrame(ImageView imageView, String str) {
Intrinsics.checkParameterIsNotNull(imageView, "blurredLastVideoFrameImageView");
Intrinsics.checkParameterIsNotNull(str, "diskMediaFileUrl");
MediaMetadataRetriever mediaMetadataRetriever2 = getMediaMetadataRetriever();
if (mediaMetadataRetriever2 != null) {
VastVideoBlurLastVideoFrameTask vastVideoBlurLastVideoFrameTask = new VastVideoBlurLastVideoFrameTask(mediaMetadataRetriever2, imageView, getDuration());
AsyncTasks.safeExecuteOnExecutor(vastVideoBlurLastVideoFrameTask, str);
setBlurLastVideoFrameTask(vastVideoBlurLastVideoFrameTask);
}
}
/* access modifiers changed from: private */
public void handleExitTrackers() {
int currentPosition = getCurrentPosition();
if (isComplete()) {
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_COMPLETE, getDuration());
VastVideoConfigTwo vastVideoConfig2 = getVastVideoConfig();
Context context = getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig2.handleComplete(context, getDuration());
} else if (this.shouldAllowSkip) {
this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_COMPLETE, currentPosition);
VastVideoConfigTwo vastVideoConfig3 = getVastVideoConfig();
Context context2 = getContext();
Intrinsics.checkExpressionValueIsNotNull(context2, "context");
vastVideoConfig3.handleSkip(context2, currentPosition);
}
VastVideoConfigTwo vastVideoConfig4 = getVastVideoConfig();
Context context3 = getContext();
Intrinsics.checkExpressionValueIsNotNull(context3, "context");
vastVideoConfig4.handleClose(context3, getDuration());
}
private void startRunnables() {
this.progressCheckerRunnable.startRepeating(VIDEO_PROGRESS_TIMER_CHECKER_DELAY);
this.countdownRunnable.startRepeating(VIDEO_COUNTDOWN_UPDATE_INTERVAL);
}
/* access modifiers changed from: private */
public void stopRunnables() {
this.progressCheckerRunnable.stop();
this.countdownRunnable.stop();
}
/* compiled from: VastVideoViewControllerTwo.kt */
public final class PlayerCallback extends MediaPlayer.PlayerCallback {
private boolean complete;
private final String playerStateToString(int i) {
return i != 0 ? i != 1 ? i != 2 ? i != 3 ? "UNKNOWN" : "PLAYER_STATE_ERROR" : "PLAYER_STATE_PLAYING" : "PLAYER_STATE_PAUSED" : "PLAYER_STATE_IDLE";
}
public PlayerCallback() {
}
public final boolean getComplete() {
return this.complete;
}
public final void setComplete(boolean z) {
this.complete = z;
}
public void onPlayerStateChanged(SessionPlayer sessionPlayer, int i) {
Intrinsics.checkParameterIsNotNull(sessionPlayer, "player");
super.onPlayerStateChanged(sessionPlayer, i);
if (i != 3) {
MoPubLog.log(MoPubLog.SdkLogEvent.CUSTOM, "Player state changed to " + playerStateToString(i));
return;
}
VastVideoViewControllerTwo.this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.RECORD_AD_ERROR, VastVideoViewControllerTwo.this.getCurrentPosition());
VastVideoViewControllerTwo.this.stopRunnables();
VastVideoViewControllerTwo.this.updateCountdown$mopub_sdk_base_release(true);
VastVideoViewControllerTwo.this.videoError(false);
VastVideoViewControllerTwo.this.setVideoError(true);
VastVideoConfigTwo vastVideoConfig = VastVideoViewControllerTwo.this.getVastVideoConfig();
Context context = VastVideoViewControllerTwo.this.getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig.handleError(context, VastErrorCode.GENERAL_LINEAR_AD_ERROR, VastVideoViewControllerTwo.this.getCurrentPosition());
}
public void onPlaybackCompleted(SessionPlayer sessionPlayer) {
Intrinsics.checkParameterIsNotNull(sessionPlayer, "player");
VastVideoViewControllerTwo.this.stopRunnables();
VastVideoViewControllerTwo.updateCountdown$mopub_sdk_base_release$default(VastVideoViewControllerTwo.this, false, 1, (Object) null);
VastVideoViewControllerTwo.this.setComplete(true);
VastVideoViewControllerTwo.this.videoCompleted(false);
if (VastVideoViewControllerTwo.this.getVastVideoConfig().isRewarded()) {
VastVideoViewControllerTwo.this.broadcastAction(IntentActions.ACTION_REWARDED_VIDEO_COMPLETE);
}
if (VastVideoViewControllerTwo.this.getVideoError() && VastVideoViewControllerTwo.this.getVastVideoConfig().getRemainingProgressTrackerCount() == 0) {
VastVideoViewControllerTwo.this.externalViewabilitySessionManager.recordVideoEvent(ExternalViewabilitySession.VideoEvent.AD_COMPLETE, VastVideoViewControllerTwo.this.getCurrentPosition());
VastVideoConfigTwo vastVideoConfig = VastVideoViewControllerTwo.this.getVastVideoConfig();
Context context = VastVideoViewControllerTwo.this.getContext();
Intrinsics.checkExpressionValueIsNotNull(context, "context");
vastVideoConfig.handleComplete(context, VastVideoViewControllerTwo.this.getCurrentPosition());
}
VastVideoViewControllerTwo.this.videoView.setVisibility(4);
VastVideoViewControllerTwo.this.getProgressBarWidget().setVisibility(8);
VastVideoViewControllerTwo.this.getIconView().setVisibility(8);
VastVideoViewControllerTwo.this.getTopGradientStripWidget().notifyVideoComplete();
VastVideoViewControllerTwo.this.getBottomGradientStripWidget().notifyVideoComplete();
VastVideoViewControllerTwo.this.getCtaButtonWidget().notifyVideoComplete();
VastCompanionAdConfigTwo access$getVastCompanionAdConfig$p = VastVideoViewControllerTwo.this.vastCompanionAdConfig;
if (access$getVastCompanionAdConfig$p != null) {
Context context2 = VastVideoViewControllerTwo.this.getContext();
Intrinsics.checkExpressionValueIsNotNull(context2, "context");
Resources resources = context2.getResources();
Intrinsics.checkExpressionValueIsNotNull(resources, "context.resources");
if (resources.getConfiguration().orientation == 1) {
VastVideoViewControllerTwo.this.getPortraitCompanionAdView().setVisibility(0);
} else {
VastVideoViewControllerTwo.this.getLandscapeCompanionAdView().setVisibility(0);
}
Context context3 = VastVideoViewControllerTwo.this.getContext();
Intrinsics.checkExpressionValueIsNotNull(context3, "context");
access$getVastCompanionAdConfig$p.handleImpression(context3, VastVideoViewControllerTwo.this.getDuration());
} else if (VastVideoViewControllerTwo.this.getBlurredLastVideoFrameImageView().getDrawable() != null) {
VastVideoViewControllerTwo.this.getBlurredLastVideoFrameImageView().setVisibility(0);
}
}
public void onSeekCompleted(SessionPlayer sessionPlayer, long j) {
Intrinsics.checkParameterIsNotNull(sessionPlayer, "player");
VastVideoViewControllerTwo.this.getMediaPlayer().play();
}
}
}
| [
"[email protected]"
]
| |
6b8aac37f9d8d5aaea2aaf071308e23b5c6331f2 | fe22f2823c82191fbbd68a251a9ae8157fad1ff8 | /src/main/java/com/eniacdevelopment/EniacHome/DataModel/Configuration/Configuration.java | d1a1e7e99698b2644d4ea5f59a3716921a1bbb6f | []
| no_license | EniacHome/DataModel | 0a0f40b3f4ec30d27fd4a845ee96312174957cb0 | b45023f7db70df0d6d7bd15974c7a507e9bcc467 | refs/heads/master | 2021-05-04T07:27:01.355142 | 2017-01-17T15:08:11 | 2017-01-17T15:08:11 | 70,625,475 | 0 | 0 | null | 2016-11-17T14:53:35 | 2016-10-11T18:53:37 | Java | UTF-8 | Java | false | false | 247 | java | package com.eniacdevelopment.EniacHome.DataModel.Configuration;
import com.eniacdevelopment.EniacHome.DataModel.Entity;
/**
* Created by larsg on 11/18/2016.
*/
public abstract class Configuration extends Entity {
public boolean Active;
}
| [
"[email protected]"
]
| |
0171f23857372793ee9cf280555e91f8c9348d91 | 213ee351b4d379be9b1647e98b2fff66d6caf9f7 | /app/src/main/java/com/example/administrator/broadcastbestpractice/LoginActivity.java | 1b6ada259a109b7323886c18b60779ef8bf78889 | [
"Apache-2.0"
]
| permissive | fgl890317/BroadcastBestPractice | 0e8a57a0e1b1f2cad50848ba90879f37210a98bf | 4d0b7a76962a9cd1dd9335a8619afe8e44019e45 | refs/heads/master | 2021-01-10T11:27:50.044293 | 2015-09-23T10:23:15 | 2015-09-23T10:23:15 | 42,993,796 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,549 | java | package com.example.administrator.broadcastbestpractice;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
/**
* Created by Administrator on 2015/9/2.
*/
public class LoginActivity extends BaseActivity implements View.OnClickListener {
private EditText accountEdit;
private EditText passwordEdit;
private SharedPreferences pref;
private SharedPreferences.Editor editor;
private CheckBox rememberPass;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
pref= PreferenceManager.getDefaultSharedPreferences(this);
accountEdit= (EditText) findViewById(R.id.account);
passwordEdit= (EditText) findViewById(R.id.password);
rememberPass= (CheckBox) findViewById(R.id.remember_pass);
boolean isRemember=pref.getBoolean("remember_password",false);
if (isRemember){
String account=pref.getString("account","");
String password=pref.getString("password","");
accountEdit.setText(account);
passwordEdit.setText(password);
rememberPass.setChecked(true);
}
findViewById(R.id.login).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.login:
String account=accountEdit.getText().toString();
String password=passwordEdit.getText().toString();
if (account.equals("admin")&&password.equals("123456")){
editor=pref.edit();
if (rememberPass.isChecked()){
editor.putBoolean("remember_password",true);
editor.putString("account",account);
editor.putString("password",password);
}else {
editor.clear();
}
editor.commit();
Intent intent=new Intent(LoginActivity.this,MainActivity.class);
startActivity(intent);
finish();
}else {
Toast.makeText(LoginActivity.this,"account or password is invalid",Toast.LENGTH_SHORT).show();
}
break;
}
}
}
| [
"[email protected]"
]
| |
93bff964d4e05ecd029c55bf2d173c04c4408840 | f4ae4f3ec817d84ad246d780200091df224eb2aa | /src/main/java/org/pih/biometric/service/exception/ServiceNotEnabledException.java | ab199ca4feb18b9bc50970866da63f29738f2f1c | []
| no_license | PIH/pih-biometrics | 7962a04ea6f2f7bd615cb76bd0ca12b6ce789487 | 220e7274a33b38931df36adce925e415b191d3ef | refs/heads/master | 2023-05-11T03:17:39.802593 | 2023-05-05T20:59:25 | 2023-05-05T20:59:25 | 93,772,715 | 6 | 9 | null | null | null | null | UTF-8 | Java | false | false | 1,005 | java | /*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.pih.biometric.service.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
* Represents an Exception that is thrown if an aspect of the system is accessed that is not enabled
*/
@ResponseStatus(HttpStatus.FORBIDDEN)
public class ServiceNotEnabledException extends RuntimeException {
public ServiceNotEnabledException(String serviceName) {
super(serviceName + " is not enabled on this system. Please check your application.yml configuration.");
}
}
| [
"[email protected]"
]
| |
f5d02a4e5349ea01a631b5dfbab073c305a6b78a | ec73c20c3e6df508e63abf32e729d6caa60c523a | /MyApplication2/app/src/main/java/com/example/mi/myapplication2/Deletestu.java | 396a4864a5a468dfc03fa49ac480baefce9b396a | []
| no_license | cyxsf/Android | f1131032c207b94c13800dce1ce1697b976774e5 | 51c2b5345e3dd199956a3d9c50c2577120927851 | refs/heads/master | 2020-07-21T15:18:33.131837 | 2019-09-08T07:41:12 | 2019-09-08T07:41:12 | 206,906,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,196 | java | package com.example.mi.myapplication2;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Deletestu extends AppCompatActivity {
private EditText editid, editname, editsex, editage, editpro, editgrade;
private Button button_sure,button_cancel;
private StudentManager studentManager;
private myDatabaseHelper MyDatabaseHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.deletestu);
studentManager=new StudentManager(this);
MyDatabaseHelper=new myDatabaseHelper(this);
editid = findViewById(R.id.text_stuid);
editname = findViewById(R.id.text_name);
editsex = findViewById(R.id.text_sex);
editage = findViewById(R.id.text_age);
editpro = findViewById(R.id.text_pro);
editgrade = findViewById(R.id.text_grade);
button_sure = findViewById(R.id.button1);
button_cancel = findViewById(R.id.button2);
button_sure.setOnClickListener(delete_Listener);
button_cancel.setOnClickListener(delete_Listener);
Intent intent=getIntent();
String stuid=intent.getStringExtra("stu_id");
String stuname=intent.getStringExtra("stu_name");
SQLiteDatabase db=MyDatabaseHelper.getWritableDatabase();
String sql="SELECT * FROM student where stu_id=? and stu_name=?";
Cursor mCursor=db.rawQuery(sql,new String[]{stuid,stuname});
while(mCursor.moveToNext()){
String sex=mCursor.getString(mCursor.getColumnIndex("stu_sex"));
String age=mCursor.getString(mCursor.getColumnIndex("stu_age"));
String pro=mCursor.getString(mCursor.getColumnIndex("stu_pro"));
String grade=mCursor.getString(mCursor.getColumnIndex("stu_grade"));
editid.setText(stuid);
editname.setText(stuname);
editsex.setText(sex);
editage.setText(age);
editpro.setText(pro);
editgrade.setText(grade);
}
}
View.OnClickListener delete_Listener = new View.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
deletestu_check();
break;
case R.id.button2:
Intent intent = new Intent(Deletestu.this,Editstu.class);
startActivity(intent);
finish();
break;
}
}
};
public void deletestu_check() {
String stu_id=editid.getText().toString().trim();
studentManager.delete(stu_id);
Toast.makeText(Deletestu.this, "删除成功", Toast.LENGTH_SHORT).show();
Intent intent_D_E = new Intent(Deletestu.this,Editstu.class);
startActivity(intent_D_E);
finish();
}
}
| [
"[email protected]"
]
| |
f8733b9137677dd1504b21d5d41030219281d238 | fc9e81b9d134a20bcf2ae52c470d56b8b94a9730 | /src/selenium/Login.java | 3e7ecad8f1244dee06756c2bd6257ae191ec77d7 | []
| no_license | DeaneKane/Gamebattles-Match-Getter | fba89afa68dcee3888c0b85653715b4f396af458 | ec07dce5bc940942b8276f2b4090b67089b22e7d | refs/heads/master | 2022-04-06T13:12:35.133888 | 2020-03-12T16:38:38 | 2020-03-12T16:38:38 | 237,263,282 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,646 | java | package selenium;
import java.io.File;
import org.openqa.selenium.By;
import storage.LoginDecryption;
import storage.LoginEncryption;
public class Login extends StartFirefoxDriver
{
private String user;
private String password;
private File detailsFile = new File( "configurations.des" );
public Login()
{
// Start Firefox driver with saved settings
driver = startFirefox();
driver.navigate().to( "https://www.gamebattles.com" );
}
public void checkForPrivacyPrompt()
{
if( driver.findElement( By.xpath( "/html/body/div[6]/div[2]/div/gb-privacy-policy-updated-dialog/div/gb-card/div[2]/button" ) ) != null )
{
driver.findElement( By.xpath( "/html/body/div[6]/div[2]/div/gb-privacy-policy-updated-dialog/div/gb-card/div[2]/button" ) )
.click();
}
}
public boolean checkIfAlreadyLoggedIn()
{
return driver.findElement( By.xpath( "/html/body/gb-root/gb-main-layout/div/div/sh-header-container/sh-header/div/div/div[2]/button[1]" ) ) == null;
}
public void loginUser() throws Exception
{
// checkForPrivacyPrompt();
if( !checkIfAlreadyLoggedIn() )
{
driver.findElement( By.xpath( "/html/body/gb-root/gb-main-layout/div/div/sh-header-container/sh-header/div/div/div[2]/button[1]" ) )
.click();
if(!checkIfDetailsStored()) {
LoginEncryption le = new LoginEncryption();
le.deletePlainTextFile();
}
LoginDecryption ld = new LoginDecryption();
user = ld.extractUsername();
password = ld.extractPassword();
ld.deletePlainTextFile();
driver.findElement( By.xpath( "//*[@id=\"login\"]" ) ).sendKeys( user );
driver.findElement( By.xpath( "//*[@id=\"login_password\"]" ) ).sendKeys( password );
driver.findElement( By.xpath( "//*[@id=\"login_button\"]" ) ).click();
scrapeUsername();
}
}
public String scrapeUsername() {
String userScraped = driver.findElement( By.xpath( "/html/body/gb-root/gb-main-layout/div/div/sh-header-container/sh-header/div/div/div[2]/sh-submenu-trigger[2]/div/button" ) ).getText();
user = userScraped.substring( 0 , (userScraped.length() -2 )) ;
return user;
}
public String getUser()
{
return user;
}
public boolean checkIfDetailsStored()
{
return detailsFile.exists();
}
}
| [
"[email protected]"
]
| |
8ca186c0a1d8c0698e86b531cfcfad14c2b2c22a | c772070d75357c5213d354520755ff664efa657a | /src/main/java/com/archsystemsinc/ipms/sec/persistence/dao/IMeetingMinutesJpaDAO.java | daeb9498fd46f651dd0a158e40850f0a46756853 | []
| no_license | Archsystemsllc/ipms | ad2d1e592c082c95917dae82713ca01111a95b10 | 593be17e0dcab5e93f14d451c42032fe7bcdaea3 | refs/heads/master | 2021-01-20T07:02:12.337149 | 2017-09-10T15:20:46 | 2017-09-10T15:20:46 | 101,255,447 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 503 | java | package com.archsystemsinc.ipms.sec.persistence.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.archsystemsinc.ipms.sec.model.MeetingAgendaItem;
import com.archsystemsinc.ipms.sec.model.MeetingMinutes;
public interface IMeetingMinutesJpaDAO extends
JpaRepository<MeetingMinutes, Long>,
JpaSpecificationExecutor<MeetingMinutes> {
MeetingMinutes findByName(final String name);
}
| [
"[email protected]"
]
| |
4214f51839c63d589fc4a075c392fd5947ea70cf | 2733a49a6b5404857787802ef90c1db351523a23 | /src/main/java/org/virtue/network/event/context/impl/in/VarcTransmitEventContext.java | c5c99ef726f8ddfd3fe3fb9eef46e75e64b395f3 | [
"MIT"
]
| permissive | Sundays211/VirtueRS3 | 2500c9bbc0f2adf9b8036be2e398388ee8be1c97 | b630bd3add4e849ac6c457b3f158a731f10ff502 | refs/heads/develop | 2021-01-18T21:35:39.166859 | 2018-07-29T07:14:17 | 2018-07-29T07:14:17 | 49,179,329 | 14 | 26 | MIT | 2022-11-03T10:32:36 | 2016-01-07T03:45:43 | Java | UTF-8 | Java | false | false | 1,889 | java | /**
* Copyright (c) 2014 Virtue Studios
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions\:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.virtue.network.event.context.impl.in;
import java.util.Map;
import org.virtue.network.event.context.GameEventContext;
/**
* @author Im Frizzy <skype:kfriz1998>
* @author Frosty Teh Snowman <skype:travis.mccorkle>
* @author Arthur <skype:arthur.behesnilian>
* @author Kayla <skype:ashbysmith1996>
* @author Sundays211
* @since 7/01/2015
*/
public class VarcTransmitEventContext implements GameEventContext {
private boolean finished;
private Map<Integer, Integer> values;
public VarcTransmitEventContext (boolean finished, Map<Integer, Integer> values) {
this.finished = finished;
this.values = values;
}
public boolean isFinished () {
return finished;
}
public Map<Integer, Integer> getValues () {
return values;
}
}
| [
"[email protected]"
]
| |
b7212c6b45a9df785fe6aab962372b79b02d2e78 | 1b17dba5d16ff0d34353f7de86afe94367e30144 | /app/src/test/java/com/cain/zhufengfm1/ExampleUnitTest.java | ef5a79a483053bab2fffb0948150eaf24a1e6b3e | []
| no_license | Dan-Yue/ZhuFengFM1 | 4796c227c5cfcc663e0c178807404efb77fd5573 | 05e39d8059ff94d1cf0489872326f1c54d798a6f | refs/heads/master | 2021-01-10T18:01:16.780743 | 2017-07-19T10:07:09 | 2017-07-19T10:07:09 | 55,499,851 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | package com.cain.zhufengfm1;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
34635622319b21f23001e6aafcd434d3f96dbcc1 | 738b972fe2190473b68f1c14d69d2ee24f8356bb | /app/src/androidTest/java/com/kcode/appupdate/ExampleInstrumentedTest.java | 55d075e8c6dcd9522fe1acdf499268b2df17a113 | []
| no_license | git930/AppUpdate | 3d1844bd0d11073a2a6a6235df0617d5d8ca67e2 | e881c923abf6afd300414ca3fc3766d11a34633c | refs/heads/master | 2020-05-22T21:29:38.752945 | 2017-03-12T06:35:42 | 2017-03-12T06:35:42 | 84,726,212 | 1 | 0 | null | 2017-03-12T13:06:55 | 2017-03-12T13:06:55 | null | UTF-8 | Java | false | false | 742 | java | package com.kcode.appupdate;
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.*;
/**
* Instrumentation 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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.kcode.appupdate", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
088bdddcc2d94431fe9b04956481ee6b4abb9dec | 5f280dd9f3e463362ac3967283d5bb156089ed4c | /src/main/java/easy/Pascal_Triangle.java | ded9356b2b5a6e90ef14cb444509f7909f38454a | []
| no_license | lingnanlu/leetcode_new | 8115799516701a95d84b9696abb9e35f3786f924 | 238ed8444032038fdd4e99c37da4cb574387748b | refs/heads/master | 2021-06-09T23:08:48.922993 | 2019-11-16T14:54:08 | 2019-11-16T14:54:08 | 146,698,043 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,007 | java | package easy;
import java.util.ArrayList;
import java.util.List;
public class Pascal_Triangle {
public static void main(String[] args) {
Pascal_Triangle test = new Pascal_Triangle();
test.generate(5);
}
public List<List<Integer>> generate(int numRows) {
if(numRows == 0) return new ArrayList<List<Integer>>();
List<List<Integer>> result = new ArrayList<List<Integer>>();
List<Integer> firstRow = new ArrayList<Integer>();
firstRow.add(1);
result.add(firstRow);
//从第二行到最后一行
for (int i = 1; i < numRows; i++) {
List<Integer> lastRow = result.get(i - 1);
List<Integer> currentRow = new ArrayList<Integer>();
currentRow.add(1);
for (int j = 1; j < i; j++) {
currentRow.add(lastRow.get(j - 1) + lastRow.get(j));
}
currentRow.add(1);
result.add(currentRow);
}
return result;
}
}
| [
"[email protected]"
]
| |
0a20592cd0bf694d2c73079accb4c438b138b14c | 58798868141971ccbabae4376ff515380befd07e | /DataStructures/src/main/java/com/vee/datastructures/sort/BaseSort.java | fc7e61c67d8fcd0f0bb10628f404a6d2792c4deb | []
| no_license | ti-cortex-m4/Algorithms | a27190b24e8fb070542de1eef1b195cf4008e929 | 900d9d3f38a42136861850da6aa2d05dc8afe559 | refs/heads/master | 2021-06-22T23:53:04.886595 | 2017-07-30T18:33:55 | 2017-07-30T18:33:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 205 | java | package com.vee.datastructures.sort;
public abstract class BaseSort<M> {
protected void exchange(M[] array, int i, int j) {
M temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
| [
"[email protected]"
]
| |
51117f204d2dae11d5867342d57ffceb0a176094 | 0bf8c8d9a8959d5fcdd207cf758970a9c76b035f | /src/DominionCardsHTMLReader/DominionCardsHTMLReader.java | c186608c2ec6ec6efda35aa8c8118c92cab2e2be | []
| no_license | TGAPMuraki/DominionCardManager | 54c7045502c43009b2f7fd25c05dd7a0ee7063c4 | e4a850ccc7caacf55435f79d264372e795ca76c0 | refs/heads/master | 2021-01-01T04:17:47.994831 | 2017-08-18T22:42:39 | 2017-08-18T22:42:39 | 97,159,035 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,100 | java | package DominionCardsHTMLReader;
import DominionCard.DominionCard;
import DominionCard.DominionExpansions.DominionExpansion;
import DominionCards.DominionCards;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.swing.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.URL;
/**
* Created by Muraki on 7/16/2017.
*/
public class DominionCardsHTMLReader extends DominionCards {
public String getInnerHTML(String htmlString) throws Exception {
while (htmlString.indexOf("<") == 0) htmlString = htmlString.substring(htmlString.indexOf(">") + 1);
while (htmlString.lastIndexOf(">") == htmlString.length() - 1)
htmlString = htmlString.substring(0, htmlString.lastIndexOf("<"));
htmlString = htmlString.replace("\n", "").replace("<br />", "\n");
return htmlString;
}
private String readNextHTMLCardElement(BufferedReader reader) throws Exception {
String htmlElement = "";
while (!htmlElement.contains("</td>")) {
htmlElement += reader.readLine();
}
return htmlElement;
}
private DominionCard readHTMLCardBlock(BufferedReader reader) throws Exception {
DominionCard newCard = new DominionCard();
newCard.setName(getInnerHTML(readNextHTMLCardElement(reader)));
newCard.setTypes(getInnerHTML(readNextHTMLCardElement(reader)));
newCard.setCost(getInnerHTML(readNextHTMLCardElement(reader)));
newCard.setDescription(getInnerHTML(readNextHTMLCardElement(reader)));
reader.readLine();
return newCard;
}
private void readToFirstCard(BufferedReader reader) throws Exception {
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("<tbody>")) {
return;
}
}
}
private void loadExpansionFromWeb(String urlExpansionPart, DominionExpansion expansion) {
try {
URL url = new URL("https://dominionstrategy.com/card-lists/" + urlExpansionPart + "-card-list/");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
readToFirstCard(reader);
while ((line = reader.readLine()) != null) {
if (line.contains("</tbody>")) break;
add(readHTMLCardBlock(reader));
}
reader.close();
} catch (Exception e) {
}
}
public void loadFromWeb() {
loadExpansionFromWeb(DominionExpansion.DOMINION.toString(), DominionExpansion.DOMINION);
loadExpansionFromWeb(DominionExpansion.INTRIGUE.toString(), DominionExpansion.INTRIGUE);
loadExpansionFromWeb(DominionExpansion.SEASIDE.toString(), DominionExpansion.SEASIDE);
loadExpansionFromWeb(DominionExpansion.ALCHEMY.toString(), DominionExpansion.ALCHEMY);
loadExpansionFromWeb(DominionExpansion.PROSPERITY.toString(), DominionExpansion.PROSPERITY);
loadExpansionFromWeb(DominionExpansion.CORNUCOPIA.toString(), DominionExpansion.CORNUCOPIA);
loadExpansionFromWeb(DominionExpansion.HINTERLANDS.toString(), DominionExpansion.HINTERLANDS);
loadExpansionFromWeb(DominionExpansion.DARK_AGES.toString(), DominionExpansion.DARK_AGES);
loadExpansionFromWeb(DominionExpansion.GUILDS.toString(), DominionExpansion.GUILDS);
}
private void AddCardElement(Element rootElement, DominionCard dominionCard) {
Document document = rootElement.getOwnerDocument();
String cardElementName = "DominionCard";
Element cardElement = document.createElement(cardElementName);
Attr nameAttribute = document.createAttribute("name");
nameAttribute.setValue(dominionCard.getName());
cardElement.appendChild(nameAttribute);
rootElement.appendChild(cardElement);
}
public void saveToXML(String xmlFile) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
String rootName = "DominionCards";
Element rootElement = document.createElement(rootName);
document.appendChild(rootElement);
for(int i = 0; i < size(); i++){
AddCardElement(rootElement, get(i));
}
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(new File(xmlFile));
Source input = new DOMSource(document);
transformer.transform(input, output);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Error:", JOptionPane.ERROR_MESSAGE);
}
}
}
| [
"[email protected]"
]
| |
90feb2c257b65051e823ade6a524ea1859a6c1a0 | 82e95ad9dc60de61333965b83f1775f37092c078 | /app/src/main/java/org/bitxbit/beaconranger/ui/BeaconScannerActivity.java | eca6acbc3f1fe34a6214c0fea6de3976d72415fc | []
| no_license | tymiles003/BeaconRanger | c433b2ff5b3621222ffdc48b8ca857963929f074 | c10f3383bf99771e4b35ba15be7bb90fbc13102b | refs/heads/master | 2021-01-18T14:54:21.161466 | 2015-02-09T14:39:45 | 2015-02-09T14:39:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,070 | java | package org.bitxbit.beaconranger.ui;
import android.app.Activity;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.Identifier;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.RangeNotifier;
import org.altbeacon.beacon.Region;
import org.bitxbit.beaconranger.R;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class BeaconScannerActivity extends Activity implements BeaconConsumer {
private static final String TAG = BeaconScannerActivity.class.getSimpleName();
private static final Set<Beacon> knownBeacons = new HashSet<Beacon>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_beacon_scanner);
BeaconManager.getInstanceForApplication(getApplicationContext()).bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
BeaconManager.getInstanceForApplication(getApplicationContext()).unbind(this);
}
@Override
public void onBeaconServiceConnect() {
BeaconManager mgr = BeaconManager.getInstanceForApplication(getApplicationContext());
monitor(mgr);
// range(mgr);
}
private void range(BeaconManager mgr) {
mgr.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
for (Beacon b : beacons) {
if (!knownBeacons.contains(b)) {
knownBeacons.add(b);
Log.d(TAG, "Saw new beacon: " + b.getIdentifiers());
}
}
}
});
try {
mgr.startRangingBeaconsInRegion(new Region("home", null, null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
private void monitor(BeaconManager mgr) {
mgr.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.d(TAG, "entered " + region.getId1() + " :: " + region.getId2() + " :: " + region.getId3());
}
@Override
public void didExitRegion(Region region) {
Log.d(TAG, "exited " + region.getId1() + " :: " + region.getId2() + " :: " + region.getId3());
}
@Override
public void didDetermineStateForRegion(int i, Region region) {
}
});
try {
BeaconManager.getInstanceForApplication(getApplicationContext()).startMonitoringBeaconsInRegion(
new Region("home", Identifier.parse("e2154275-f952-44f4-add2-2b1cf9febec7"), null, null));
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
daa0d3d7c045f76fc58483dfa3a29bd717c1247b | 6402b537e480a5674a3609e993fd11bf45f022f3 | /src/main/java/com/carddex/sims2/security/MyCustomLoginAuthenticationSuccessHandler.java | 3347d7b9f59d0c5cc36506a2cb3549fd22d55173 | []
| no_license | uskovvm/sims-2 | 3604c849786ec7a7ebfe07703a46cddc8ebc70e3 | ad67a2e19941140eb7d79e855c81b5b696704762 | refs/heads/master | 2020-03-25T11:19:16.862032 | 2018-08-08T05:42:28 | 2018-08-08T05:42:28 | 143,727,536 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,780 | java | package com.carddex.sims2.security;
import java.io.IOException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.DefaultRedirectStrategy;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.WebAttributes;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import com.carddex.sims2.persistence.model.User;
//@Component("myAuthenticationSuccessHandler")
public class MyCustomLoginAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@Autowired
ActiveUserStore activeUserStore;
@Override
public void onAuthenticationSuccess(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) throws IOException {
addWelcomeCookie(gerUserName(authentication), response);
redirectStrategy.sendRedirect(request, response, "/homepage.html?user=" + authentication.getName());
final HttpSession session = request.getSession(false);
if (session != null) {
session.setMaxInactiveInterval(30 * 60);
LoggedUser user = new LoggedUser(authentication.getName(), activeUserStore);
session.setAttribute("user", user);
}
clearAuthenticationAttributes(request);
}
private String gerUserName(final Authentication authentication) {
return ((User) authentication.getPrincipal()).getFirstName();
}
private void addWelcomeCookie(final String user, final HttpServletResponse response) {
Cookie welcomeCookie = getWelcomeCookie(user);
response.addCookie(welcomeCookie);
}
private Cookie getWelcomeCookie(final String user) {
Cookie welcomeCookie = new Cookie("welcome", user);
welcomeCookie.setMaxAge(60 * 60 * 24 * 30); // 30 days
return welcomeCookie;
}
protected void clearAuthenticationAttributes(final HttpServletRequest request) {
final HttpSession session = request.getSession(false);
if (session == null) {
return;
}
session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
}
public void setRedirectStrategy(final RedirectStrategy redirectStrategy) {
this.redirectStrategy = redirectStrategy;
}
protected RedirectStrategy getRedirectStrategy() {
return redirectStrategy;
}
} | [
"[email protected]"
]
| |
0060c3a3597e11cc6ef7bab08cd800aff892ef6c | 41a1f13bdf66de06d5bce313922b174bb63227c2 | /RedPlus/src/com/i5le/back/web/RedPlusDealerInfoController.java | 4858b76582500dd6db513a0987f1d99daa3652a5 | []
| no_license | zhangdengjie/weshop | 0428269bc5010ee790ede795a12abf178b768d49 | 116c59db25d7b3f0ff97830830c02043c86dc837 | refs/heads/master | 2020-12-25T21:56:24.842248 | 2015-01-28T12:54:36 | 2015-01-28T12:54:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,287 | java | package com.i5le.back.web;
import javax.servlet.ServletRequest;
import javax.validation.Valid;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.i5le.framwork.core.service.BaseService;
import com.i5le.framwork.core.web.BaseCRUDController;
import com.i5le.framwork.sys.entity.User;
import com.i5le.redplus.entity.DealerInfo;
import com.i5le.redplus.entity.UserInfo;
import com.i5le.redplus.service.DealerInfoService;
import com.i5le.redplus.service.UserInfoService;
@Controller
@RequestMapping("/back/dealerInfo")
public class RedPlusDealerInfoController extends
BaseCRUDController<DealerInfo, String> {
@Autowired
DealerInfoService dealerInfoService;
@RequestMapping(value = "")
public String index(ServletRequest request) {
return "/admin/redplus/dealerInfo/index";
}
@RequiresPermissions("/back/dealerInfo:list")
@ResponseBody
@RequestMapping(value = "list")
public String list(ServletRequest request) {
return super.list(request);
}
@RequiresPermissions("/back/dealerInfo:distributor")
@ResponseBody
@RequestMapping(value = "distributor")
public String distributor(ServletRequest request) {
Subject currentUser = SecurityUtils.getSubject();//获取当前用户
User user=(User) currentUser.getSession(true).getAttribute("current_login");
if(user!=null){
}
//dealerInfoService.
return super.list(request);
}
@RequiresPermissions("/back/dealerInfo:add")
@ResponseBody
@RequestMapping(value = "add")
public String add(@Valid DealerInfo userInfo) {
try {
this.dealerInfoService.save(userInfo);
return RESULT_OK;
} catch (Exception e) {
return RESULT_ERROR;
// TODO: handle exception
}
}
@RequiresPermissions("/back/dealerInfo:del")
@RequestMapping(value = "del")
@ResponseBody
public String del(@RequestParam(value = "ids[]") String[] ids) {
try {
this.dealerInfoService.delete(ids);
return RESULT_OK;
} catch (Exception e) {
return RESULT_ERROR;
// TODO: handle exception
}
}
@RequiresPermissions("/back/dealerInfo:update")
@ResponseBody
@RequestMapping(value = "update")
public String edit(@Valid @ModelAttribute("entity") DealerInfo userInfo) {
try {
this.dealerInfoService.save(userInfo);
return RESULT_OK;
} catch (Exception e) {
return RESULT_ERROR;
// TODO: handle exception
}
}
@ModelAttribute
public void getUser(
@RequestParam(value = "id", defaultValue = "-1") String id,
Model model) {
if (id != null) {
model.addAttribute("entity", this.dealerInfoService.findOne(id));
}
}
@Override
protected BaseService<DealerInfo, String> getServcie() {
// TODO Auto-generated method stub
return dealerInfoService;
}
}
| [
"[email protected]"
]
| |
693016e490eec09f3c5a33310aa64658cdfb2df7 | 5b8f0cbd2076b07481bd62f26f5916d09a050127 | /src/LC374.java | f78eb412d77301edf773e0c970a9e460a08d9218 | []
| no_license | micgogi/micgogi_algo | b45664de40ef59962c87fc2a1ee81f86c5d7c7ba | 7cffe8122c04059f241270bf45e033b1b91ba5df | refs/heads/master | 2022-07-13T00:00:56.090834 | 2022-06-15T14:02:51 | 2022-06-15T14:02:51 | 209,986,655 | 7 | 3 | null | 2020-10-20T07:41:03 | 2019-09-21T13:06:43 | Java | UTF-8 | Java | false | false | 2,062 | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* @author Micgogi
* on 7/13/2020 11:03 AM
* Rahul Gogyani
*/
public class LC374 {
public static void main(String args[]) {
FastReader sc = new FastReader();
}
/**
* Forward declaration of guess API.
* @param n your guess
* @return -1 if num is lower than the guess number
* 1 if num is higher than the guess number
* otherwise return 0
* int guess(int num);
*/
public static int guessNumber(int n) {
int left = 1, right = n;
while(left < right) {
int mid = left + (right - left) / 2;
if(guess(mid) == 0) {
return mid;
} else if(guess(mid) == 1) {
left = mid + 1;
} else {
right = mid;
}
}
return left;
}
public static int guess(int num){
return 0;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in), 32768);
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| [
"[email protected]"
]
| |
c03e2ff4d9714f3234c2bdc21db769dfc3fe27d6 | ab2cb37bfafb7ca5821d4fecd4cc60bd669565ee | /src/main/java/com/ubb935/halfway/repository/JobApplicationRepository.java | e4b0579d7297bc3bdc2f6d1f0e57fcddd94cfa52 | []
| no_license | maiertudor/halfwayApi | 38fa61847e844f026df991d0e07af7bb369dac2b | 889d7f840630232bf5516684c6e10259c757cd68 | refs/heads/master | 2020-05-27T17:05:06.078055 | 2019-05-26T17:55:48 | 2019-05-26T17:55:48 | 188,714,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 597 | java | package com.ubb935.halfway.repository;
import com.ubb935.halfway.model.Account;
import com.ubb935.halfway.model.Job;
import com.ubb935.halfway.model.JobApplication;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by Laura on 1/12/2018.
*/
@Repository
public interface JobApplicationRepository extends BaseRepository<JobApplication> {
List<JobApplication> findApplicationByProvider(Account provider);
List<JobApplication> findApplicationByJob(Job job);
JobApplication findOneByJob_IdAndProvider_Username(String jobId, String username);
}
| [
"[email protected]"
]
| |
c38ff128a017ec398841285ada332dcd8ed134bb | 5177176d110e0afe77c857229d2e4a717e7e0940 | /AnShengApplication/zatgov/src/main/java/com/safetys/zatgov/adapter/WgyMakeCheckListAdapter.java | 37f04312db5e4949562852984439f5bb44075a82 | []
| no_license | RickyYu/CommonAndroid | 12bf6793d3b814f0bcb694605a7cf49cf0ed93db | 25fe2535d39ece61715355eed0d330e94f294039 | refs/heads/master | 2021-08-30T13:39:47.750892 | 2017-12-18T05:46:40 | 2017-12-18T05:46:40 | 106,800,196 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,875 | java | package com.safetys.zatgov.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.safetys.zatgov.R;
import com.safetys.zatgov.bean.SafetyMatter;
import com.safetys.zatgov.ui.activity.WgyMakeCheckListActivity;
import com.safetys.zatgov.utils.DialogUtil;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Author:Created by Ricky on 2017/11/15.
* Description:
*/
public class WgyMakeCheckListAdapter extends BaseAdapter {
private WgyMakeCheckListActivity mContext;
private LayoutInflater mInflater;
private ArrayList<SafetyMatter> mdatas;
public WgyMakeCheckListAdapter(WgyMakeCheckListActivity context,
ArrayList<SafetyMatter> mdatas) {
this.mContext = context;
this.mInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mdatas = mdatas;
}
@Override
public int getCount() {
return mdatas.size();
}
@Override
public Object getItem(int position) {
return mdatas.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
ViewHolder mHodler;
if (convertView == null) {
convertView = mInflater.inflate(
R.layout.list_view_string_and_remark_item, null);
mHodler = new ViewHolder(convertView);
convertView.setTag(mHodler);
} else {
mHodler = (ViewHolder) convertView.getTag();
}
mHodler.text1.setText(mdatas.get(position).getContent());
mHodler.ivRemark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String msg = mdatas.get(position).getRemark();
DialogUtil.showMsgDialog(mContext,
msg, false, null);
}
});
mHodler.btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mdatas.remove(position);
notifyDataSetChanged();
}
});
return convertView;
}
static class ViewHolder {
@BindView(R.id.btn_delete)
LinearLayout btnDelete;
@BindView(R.id.text1)
TextView text1;
@BindView(R.id.iv_remark)
ImageView ivRemark;
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
}
| [
"[email protected]"
]
| |
0ae3df3549a84bb5ebfdb2093567ae29f269e293 | 9d7484b256426bcdfff85615946c826ceb626fd1 | /imageio-openjpeg/src/main/java/de/digitalcollections/openjpeg/lib/structs/opj_poc.java | 26239d8f277a3ad1ccc28641725990cd12519144 | [
"Apache-2.0"
]
| permissive | renevanderark/imageio-jnr | 3de81a92adc228472b5185b1e5cb28b991baa84f | a9b9c53638bff8cc8ca05f3a182a3ce8aff02cc9 | refs/heads/master | 2020-08-07T22:50:12.695733 | 2019-10-10T13:33:40 | 2019-10-10T13:33:40 | 213,611,918 | 0 | 0 | Apache-2.0 | 2019-10-08T10:21:34 | 2019-10-08T10:20:26 | null | UTF-8 | Java | false | false | 2,289 | java | package de.digitalcollections.openjpeg.lib.structs;
import de.digitalcollections.openjpeg.lib.enums.PROG_ORDER;
import jnr.ffi.Runtime;
import jnr.ffi.Struct;
public class opj_poc extends Struct {
/** Resolution num start, Component num start, given by POC */
Unsigned32 resno0 = new Unsigned32();
Unsigned32 compno0 = new Unsigned32();
/** Layer num end,Resolution num end, Component num end, given by POC */
Unsigned32 layno1 = new Unsigned32();
Unsigned32 resno1 = new Unsigned32();
Unsigned32 compno1 = new Unsigned32();
/** Layer num start,Precinct num start, Precinct num end */
Unsigned32 layno0 = new Unsigned32();
Unsigned32 precno0 = new Unsigned32();
Unsigned32 precno1 = new Unsigned32();
/** Progression order enum*/
Enum<PROG_ORDER> prg1 = new Enum<>(PROG_ORDER.class);
Enum<PROG_ORDER> prg = new Enum<>(PROG_ORDER.class);
/** Progression order string*/
String progorder = new AsciiString(5);
/** Tile number */
Unsigned32 tile = new Unsigned32();
/** Start and end values for Tile width and height*/
Signed32 tx0 = new Signed32();
Signed32 tx1 = new Signed32();
Signed32 ty0 = new Signed32();
Signed32 ty1 = new Signed32();
/** Start value, initialised in pi_initialise_encode*/
Unsigned32 layS = new Unsigned32();
Unsigned32 resS = new Unsigned32();
Unsigned32 compS = new Unsigned32();
Unsigned32 prcS = new Unsigned32();
/** End value, initialised in pi_initialise_encode */
Unsigned32 layE = new Unsigned32();
Unsigned32 resE = new Unsigned32();
Unsigned32 compE = new Unsigned32();
Unsigned32 prcE = new Unsigned32();
/** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
Unsigned32 txS = new Unsigned32();
Unsigned32 txE = new Unsigned32();
Unsigned32 tyS = new Unsigned32();
Unsigned32 tyE = new Unsigned32();
Unsigned32 dx = new Unsigned32();
Unsigned32 dy = new Unsigned32();
/** Temporary values for Tile parts, initialised in pi_create_encode */
Unsigned32 lay_t = new Unsigned32();
Unsigned32 res_t = new Unsigned32();
Unsigned32 comp_t = new Unsigned32();
Unsigned32 prc_t = new Unsigned32();
Unsigned32 tx0_t = new Unsigned32();
Unsigned32 ty0_t = new Unsigned32();
public opj_poc(Runtime runtime) {
super(runtime);
}
}
| [
"[email protected]"
]
| |
06b2abfd3f6c1e5deee8063571c72fd6718a4583 | ac94ac4e2dca6cbb698043cef6759e328c2fe620 | /providers/aws-s3/src/test/java/org/jclouds/aws/s3/blobstore/integration/AWSS3BlobIntegrationLiveTest.java | 73b1e042fd9c178e0fc8b69a0ff42f45079f4d01 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | andreisavu/jclouds | 25c528426c8144d330b07f4b646aa3b47d0b3d17 | 34d9d05eca1ed9ea86a6977c132665d092835364 | refs/heads/master | 2021-01-21T00:04:41.914525 | 2012-11-13T18:11:04 | 2012-11-13T18:11:04 | 2,503,585 | 2 | 0 | null | 2012-10-16T21:03:12 | 2011-10-03T09:11:27 | Java | UTF-8 | Java | false | false | 1,207 | java | /**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.aws.s3.blobstore.integration;
import org.jclouds.s3.blobstore.integration.S3BlobIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "AWSS3BlobIntegrationLiveTest")
public class AWSS3BlobIntegrationLiveTest extends S3BlobIntegrationLiveTest {
public AWSS3BlobIntegrationLiveTest() {
provider = "aws-s3";
}
}
| [
"[email protected]"
]
| |
2d287fb6accc3856e467399dbe2192370e47cacb | c610eaab3534d2ba9df62e09a69a99fe7089f7f9 | /limits-service/src/main/java/com/yash/microservices/LimitsServiceApplication.java | 470a948a683b1f27d53dbbebd17b3aea582a0b4f | []
| no_license | yashtiwari68/microservices | 8246427bbb940a9d625cd1e344678193b81f2587 | 1b2283511b972d9f0546b00dc1b639bbc369a53c | refs/heads/master | 2022-12-10T15:56:52.314087 | 2020-09-10T04:50:02 | 2020-09-10T04:50:02 | 294,006,077 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 408 | java | package com.yash.microservices;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
@SpringBootApplication
@EnableHystrix
public class LimitsServiceApplication {
public static void main(String[] args) {
SpringApplication.run(LimitsServiceApplication.class, args);
}
}
| [
"[email protected]"
]
| |
6683ffd869433ae0aea1b40f7e728922cb5b98d0 | b13396f9d3d809a7d1dee2fc6612bd0e95b1ceb9 | /app/src/main/java/com/ooooim/enums/PlatformEnum.java | a772f988980e7927e057069089f0c8d009a8d6be | [
"Apache-2.0"
]
| permissive | tengbinlive/ooooim_android | d85eb39e467b075b567d846e4cef196972d5f6ec | 23d9822138c486a879e0764c7dcf217c4d20afb4 | refs/heads/master | 2021-01-10T02:59:00.414135 | 2016-04-11T10:56:51 | 2016-04-11T10:56:51 | 55,757,976 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,606 | java | package com.ooooim.enums;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;
/**
* 第三方类型枚举.
*
* @author bin.teng
*/
public enum PlatformEnum {
/**
* 微信
*/
WEIXIN(Wechat.NAME, "微信"),
/**
* 朋友圈
*/
WEIXIN_TIMELINE(WechatMoments.NAME, "朋友圈"),
/**
* QQ
*/
QQ_TENCENT(QQ.NAME, "QQ"),
/**
* 新浪
*/
SINA(SinaWeibo.NAME, "新浪微博");
private String code;
private String desc;
private PlatformEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
/**
* 根据编号值获得对应枚举对象.
*
* @param code 编号值
* @return 对应枚举对象
*/
public static PlatformEnum getEnumByCode(String code) {
for (PlatformEnum item : values()) {
if (item.code.equals(code))
return item;
}
return null;
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(super.toString());
buf.append(",code=").append(this.getCode());
buf.append(",desc=").append(this.getDesc());
return buf.toString();
}
}
| [
"[email protected]"
]
| |
ee5d243ccf1ddde9e152f06f60c7736bf90048f4 | 7fdc5f6b956a63c1d96ac4962999054f2b9258df | /src/uygulama/FormMusteriDuzenle.java | b4800d284cfbb5c399b768b0a4158573cc38efaa | [
"MIT"
]
| permissive | eneskizilkaya1070/Satis_Otomasyonu | 58bf3f405d3e79d428bedbfa46d3c10086185f94 | 575c715e6e34d9e2551f6ca575c11d08709655b4 | refs/heads/master | 2022-11-04T23:50:34.132426 | 2020-06-15T18:17:21 | 2020-06-15T18:17:21 | 272,512,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,640 | java | package uygulama;
import java.awt.event.KeyEvent;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class FormMusteriDuzenle extends javax.swing.JFrame {
static String mid = "";
static boolean durum = false;
DB db = new DB();
public FormMusteriDuzenle() {
initComponents();
this.setIconImage(new ImageIcon(getClass().getResource("/img/musteri_duzenle.png")).getImage());
durum = true;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
panelDuzenle = new javax.swing.JPanel();
txtAdi = new javax.swing.JTextField();
txtSoyadi = new javax.swing.JTextField();
txtTelefon = new javax.swing.JTextField();
txtAdres = new javax.swing.JTextField();
btnEkle = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Müşteri Düzenleme");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
});
panelDuzenle.setBorder(javax.swing.BorderFactory.createTitledBorder("Müşteri Güncelleme"));
txtAdres.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
txtAdresKeyPressed(evt);
}
});
btnEkle.setText("Müşteri Güncelle");
btnEkle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEkleActionPerformed(evt);
}
});
jLabel1.setText("Müşteri Adı:");
jLabel2.setText("Müşteri Soyadı:");
jLabel3.setText("Müşteri Telefon:");
jLabel4.setText("Müşteri Adres:");
javax.swing.GroupLayout panelDuzenleLayout = new javax.swing.GroupLayout(panelDuzenle);
panelDuzenle.setLayout(panelDuzenleLayout);
panelDuzenleLayout.setHorizontalGroup(
panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDuzenleLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE)
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtAdres, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
.addComponent(txtTelefon, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtSoyadi, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnEkle, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtAdi, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
panelDuzenleLayout.setVerticalGroup(
panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDuzenleLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtAdi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtSoyadi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTelefon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18, 18, 18)
.addGroup(panelDuzenleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtAdres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addGap(18, 18, 18)
.addComponent(btnEkle)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(panelDuzenle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(panelDuzenle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void btnEkleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEkleActionPerformed
String adi = txtAdi.getText().trim();
String soyadi = txtSoyadi.getText().trim();
String telefon = txtTelefon.getText().trim();
String adres = txtAdres.getText().trim();
if (adi.equals("")) {
JOptionPane.showMessageDialog(rootPane, "Lütfen müşteri adını giriniz!");
txtAdi.requestFocus();
} else if (soyadi.equals("")) {
JOptionPane.showMessageDialog(rootPane, "Lütfen müşteri soyadını giriniz!");
txtSoyadi.requestFocus();
} else if (telefon.equals("")) {
JOptionPane.showMessageDialog(rootPane, "Lütfen müşteri telefonunu giriniz!");
txtTelefon.requestFocus();
} else if (adres.equals("")) {
JOptionPane.showMessageDialog(rootPane, "Lütfen müşteri adresini giriniz!");
txtAdres.requestFocus();
} else {
try {
String yazQuery = "UPDATE musteriler SET mAdi = '" + adi + "', mSoyadi = '" + soyadi + "', mTelefon = '" + telefon + "', mAdres = '" + adres + "' WHERE mID = '" + mid + "' ";
int yazSonuc = db.baglan().executeUpdate(yazQuery);
if (yazSonuc > 0) {
AnaForm.musteriVerileri();
JOptionPane.showMessageDialog(rootPane, "Müşteri başarı ile güncellendi.");
txtAdi.setText("");
txtSoyadi.setText("");
txtTelefon.setText("");
txtAdres.setText("");
txtAdi.requestFocus();
} else {
JOptionPane.showMessageDialog(rootPane, "Müşteri güncelleme işlemi başarısız oldu!");
}
} catch (SQLException ex) {
System.err.println("Müşteri güncelleme işlemi hatası : " + ex);
if (ex.toString().contains("SQLITE_CONSTRAINT_UNIQUE")) {
JOptionPane.showMessageDialog(rootPane, "Aynı telefon numarası ile birden fazla kayıt yapılamaz!");
}
} finally {
db.kapat();
dispose();
}
}
}//GEN-LAST:event_btnEkleActionPerformed
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
durum = false;
}//GEN-LAST:event_formWindowClosed
private void txtAdresKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAdresKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
btnEkleActionPerformed(null);
}
}//GEN-LAST:event_txtAdresKeyPressed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FormMusteriDuzenle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FormMusteriDuzenle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FormMusteriDuzenle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FormMusteriDuzenle.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormMusteriDuzenle().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnEkle;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel panelDuzenle;
public javax.swing.JTextField txtAdi;
public javax.swing.JTextField txtAdres;
public javax.swing.JTextField txtSoyadi;
public javax.swing.JTextField txtTelefon;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
]
| |
0a073bc47942f417f3864bfdd236fffa483c9f7f | da6c2b33da03886d25ed1a4f8e5556ddb3cbc2d6 | /src/com/pinplanet/pintact/contact/ContactAddActivity.java | 2f73412c89d77b78f5b4d518314710098e4ca68a | []
| no_license | rahulyhg/PintactContactManagement-Android | 84ffb88beb636c4eb54ccbf1d61e22bf7ba26af0 | edfaeca67463008ca30b63a6abe019ebf21fcc0c | refs/heads/master | 2020-05-09T18:00:25.568435 | 2015-09-15T08:14:40 | 2015-09-15T08:14:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,049 | java | package com.pinplanet.pintact.contact;
import android.app.FragmentManager;
import android.os.Bundle;
import android.view.Window;
import com.pinplanet.pintact.R;
import com.pinplanet.pintact.utility.MyActivity;
public class ContactAddActivity extends MyActivity {
FragmentConnectContact fragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_contact);
hideBoth();
// View.OnClickListener finClkLn = new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// finish();
// }
// };
//showRightImage(R.drawable.actionbar_x);
//addRightImageClickListener(finClkLn);
fragment = new FragmentConnectContact();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
fragmentManager.executePendingTransactions();
}
}
| [
"[email protected]"
]
| |
b26ae779c754c230094726a7e91148f88e308de1 | ee0493d3b53a6cbaa38c42346480e03892b5487f | /cloud-providerconsul-payment8006/src/main/java/com/edu/springcloud/controller/PaymentController.java | bc26d32aae54fde894e0d83cbb49e4d9169e121e | []
| no_license | XiaZhuXi/2020cloud | bef35b8f7dc7fa08b575384a35445090b519c7fc | 663d0d5ffbd56268eaa4e82c19ce5c064e05fa1c | refs/heads/master | 2023-07-11T00:49:26.214109 | 2021-08-07T03:10:39 | 2021-08-07T03:10:39 | 393,549,377 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package com.edu.springcloud.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.UUID;
@RestController
@Slf4j
public class PaymentController {
@Value("${server.port}")
private String serverPort;
@RequestMapping("/payment/consul")
public String paymentCon(){
return "springcloud with consul: "+serverPort+"\t"+ UUID.randomUUID().toString();
}
}
| [
"[email protected]"
]
| |
e6cecc96b27bf4395b2693946a2833eef3a38db3 | bb101b5c329609afedf4e0c07d2e4b64d1c3f135 | /Android Security Source Code/Android_Security-master/app/src/androidTest/java/com/example/androidsecurity/ExampleInstrumentedTest.java | c1a87b5a5c57068715af86a5494992d69b21af0c | []
| no_license | vaginessa/Android-Spyware-Detection-System | 3cdf8643648dc6f5f427a06041c1a8468693247a | 15d3ca66e906e577bd6521d3b2597e5fb65a1734 | refs/heads/main | 2023-07-13T19:06:44.504243 | 2021-08-28T14:26:04 | 2021-08-28T14:26:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 770 | java | package com.example.androidsecurity;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.androidsecurity", appContext.getPackageName());
}
}
| [
"[email protected]"
]
| |
a8a62a9ddf979516e3edbe5f54c64f2c9a7ed2af | 863acb02a064a0fc66811688a67ce3511f1b81af | /sources/com/google/android/gms/internal/ads/zzccw.java | c1c91956ecc8c1c84ad7dd9706519c7d29d7ece4 | [
"MIT"
]
| permissive | Game-Designing/Custom-Football-Game | 98d33eb0c04ca2c48620aa4a763b91bc9c1b7915 | 47283462b2066ad5c53b3c901182e7ae62a34fc8 | refs/heads/master | 2020-08-04T00:02:04.876780 | 2019-10-06T06:55:08 | 2019-10-06T06:55:08 | 211,914,568 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,524 | java | package com.google.android.gms.internal.ads;
import android.os.RemoteException;
import com.google.android.gms.ads.VideoController.VideoLifecycleCallbacks;
public final class zzccw extends VideoLifecycleCallbacks {
/* renamed from: a */
private final zzbyt f26395a;
public zzccw(zzbyt zzbyt) {
this.f26395a = zzbyt;
}
public final void onVideoStart() {
zzaau a = m28283a(this.f26395a);
if (a != null) {
try {
a.onVideoStart();
} catch (RemoteException e) {
zzbad.m26358c("Unable to call onVideoEnd()", e);
}
}
}
public final void onVideoPause() {
zzaau a = m28283a(this.f26395a);
if (a != null) {
try {
a.onVideoPause();
} catch (RemoteException e) {
zzbad.m26358c("Unable to call onVideoEnd()", e);
}
}
}
public final void onVideoEnd() {
zzaau a = m28283a(this.f26395a);
if (a != null) {
try {
a.mo29375M();
} catch (RemoteException e) {
zzbad.m26358c("Unable to call onVideoEnd()", e);
}
}
}
/* renamed from: a */
private static zzaau m28283a(zzbyt zzbyt) {
zzaar m = zzbyt.mo31015m();
if (m == null) {
return null;
}
try {
return m.mo29370ma();
} catch (RemoteException e) {
return null;
}
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.