blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2 values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 9.45M | extension stringclasses 28 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1e9ee54f987e5b23688479ebad8681eabfbf56b1 | 886aa6b456554321aec45983633720a6fa9b8d09 | /(GamersPvP) Eventos/src/dev/gamerspvp/gladiador/eventochat/EventoChat.java | 8da1a34b708c51f9dc33f9d61ac6b287ce82e034 | [] | no_license | yMaatheus/GamersPvP | ea77ba2513163a85ca28a8254bcb1caebd7cbda8 | 03918a4d5fd47699768f3e5c96d91c2946173b82 | refs/heads/main | 2022-12-29T23:36:05.334993 | 2022-10-15T13:50:26 | 2022-10-15T13:50:26 | 551,941,217 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 599 | java | package dev.gamerspvp.gladiador.eventochat;
public class EventoChat {
private int resultado;
private boolean acontecendo;
public EventoChat() {
this.resultado = 0;
this.acontecendo = false;
}
public void reset() {
this.resultado = 0;
this.acontecendo = false;
}
public int getResultado() {
return resultado;
}
public void setResultado(int resultado) {
this.resultado = resultado;
}
public boolean isAcontecendo() {
return acontecendo;
}
public void setAcontecendo(boolean acontecendo) {
this.acontecendo = acontecendo;
}
} | [
"stvgamer74@gmail.com"
] | stvgamer74@gmail.com |
b8c2b53186b4d7fa56c553530216ca3efcd73352 | 671e0fc1999463e8e7a64fdc80b87ffd1425b401 | /src/main/java/com/octaspring/controller/ViewController.java | 4d27012c956356bff3d1e922665b5a6cd241238b | [] | no_license | adairvega/octaspring | 30f6a146dd890b306d7f3ede6e453ad77b0c1eef | 682a6497aea22a2351f0873075e7efcb71161aab | refs/heads/main | 2023-02-22T02:22:08.662674 | 2021-01-28T23:05:02 | 2021-01-28T23:10:11 | 331,775,985 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | java | package com.octaspring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class ViewController {
@GetMapping("/")
public String index() {
return "index";
}
}
| [
"adairgonzalez@utez.edu.mx"
] | adairgonzalez@utez.edu.mx |
52e8c42538b18d305a152c6639d8cd294c51db4e | 1cde1f7a900bdb189b39c649639691c8dd9f0537 | /order_service_impl/src/main/java/com/zufar/order_service_impl/controller/CategoryController.java | cafe4235b024c2b4b6bf7f0d4287339bdcf854c5 | [] | no_license | Sunagatov/Order_Service | e3e105a2efc34a34d20c3558e694bf0213a991e1 | 2ec71aab4b5b5cb8361ddf74d840075151aa538f | refs/heads/master | 2022-09-10T06:49:40.145518 | 2019-11-10T13:56:57 | 2019-11-10T13:56:57 | 217,142,299 | 1 | 0 | null | 2022-02-16T01:02:44 | 2019-10-23T19:57:23 | Java | UTF-8 | Java | false | false | 987 | java | package com.zufar.order_service_impl.controller;
import com.zufar.order_management_system_common.dto.Category;
import com.zufar.order_service_api.endpoint.CategoryServiceEndPoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "Category api")
@RestController
@RequestMapping(value = "categories")
public class CategoryController implements CategoryServiceEndPoint<Category> {
@Override
@GetMapping
@ApiOperation(value = "View a list of order categories.", response = Category[].class, responseContainer = "List")
public ResponseEntity<Category[]> getCategories() {
return new ResponseEntity<>(Category.values(), HttpStatus.OK);
}
}
| [
"sunagatovzr@vdcom.ru"
] | sunagatovzr@vdcom.ru |
6ebaf54edab76bc4797797fc0df3c2b5dd0edc3a | 308b25c93597c7f2b54225e02e42b6970e7ce193 | /12/AOneToManyTest/src/org/fkit/domain/Student.java | b263b2959e98f81adea3de514e8e04a84a1293c6 | [] | no_license | johnnywong233/crazy_ssm | a6ab33a49d7cf3113912d232fba22f5d6eda264c | 4c8e56676f0a7d65dd459b3f09f0a8b57317715b | refs/heads/master | 2020-03-08T17:57:51.538890 | 2018-04-06T13:25:52 | 2018-04-06T13:25:52 | 128,282,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,963 | java | package org.fkit.domain;
import java.io.Serializable;
/**
* CREATE TABLE tb_clazz(
* id INT PRIMARY KEY AUTO_INCREMENT,
* CODE VARCHAR(18),
* NAME VARCHAR(18)
* );
* <p>
* INSERT INTO tb_clazz(CODE,NAME) VALUES('j1601','Java就业班');
* <p>
* CREATE TABLE tb_student(
* id INT PRIMARY KEY AUTO_INCREMENT,
* NAME VARCHAR(18),
* sex VARCHAR(18),
* age INT,
* clazz_id INT,
* FOREIGN KEY (clazz_id) REFERENCES tb_clazz(id)
* );
* <p>
* INSERT INTO tb_student(NAME,sex,age,clazz_id) VALUES('jack','男',23,1);
* INSERT INTO tb_student(NAME,sex,age,clazz_id) VALUES('rose','女',18,1);
* INSERT INTO tb_student(NAME,sex,age,clazz_id) VALUES('tom','男',21,1);
* INSERT INTO tb_student(NAME,sex,age,clazz_id) VALUES('alice','女',20,1);
*/
public class Student implements Serializable {
private Integer id; // 学生id,主键
private String name; // 姓名
private String sex; // 性别
private Integer age; // 年龄
// 学生和班级是多对一的关系,即一个学生只属于一个班级
private Clazz clazz;
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Clazz getClazz() {
return clazz;
}
public void setClazz(Clazz clazz) {
this.clazz = clazz;
}
@Override
public String toString() {
return "Student [id=" + id + ", name=" + name + ", sex=" + sex
+ ", age=" + age + "]";
}
}
| [
"wangjian@lattebank.com"
] | wangjian@lattebank.com |
4cbc1e2bb8b743cd08aabb1a0fb4323eaf83fa54 | fa255d697d9a173b55c2c0ef76930e0a25ac067d | /src/main/java/org/cryptocoinpartners/schema/dao/HoldingJpaDao.java | 788cda567c5956c54dae6a76bd0bc0b79c37566f | [
"Apache-2.0"
] | permissive | timolson/cointrader | 0eb84719b0ac6c380bcd728b6c9155923cfeb0b4 | 48d4b6cd8a6097a1c4c8773a2ec4004df2fbbfba | refs/heads/master | 2023-06-25T17:40:43.506897 | 2022-06-21T01:03:49 | 2022-06-21T01:03:49 | 20,368,549 | 443 | 168 | NOASSERTION | 2023-06-14T22:34:08 | 2014-06-01T01:14:12 | Java | UTF-8 | Java | false | false | 210 | java | package org.cryptocoinpartners.schema.dao;
public class HoldingJpaDao extends DaoJpa implements HoldingDao {
/**
*
*/
private static final long serialVersionUID = -6595431729819638158L;
}
| [
"douggie@melvilleclarke.com"
] | douggie@melvilleclarke.com |
7cdafa4a96d3622c4e4e9a3b8ffa0641f316de86 | ccc833aaa5fcd374e53df48272e8452201db4c9a | /blogs/src/main/java/com/blog/security/core/service/UserService.java | 8f28cf1ffb2585751009c57aaa5dc50fbbd0a39d | [] | no_license | RJKKK/awesome_blogs | b1f98d81df1b6647fdba145a1fbdc238b71c6b01 | 3a80a4a4ecf18ef2921a35437179221621ccff45 | refs/heads/main | 2023-03-10T16:24:01.842991 | 2021-03-01T15:55:46 | 2021-03-01T15:55:46 | 307,855,361 | 3 | 1 | null | 2021-03-03T13:14:13 | 2020-10-27T23:40:24 | TypeScript | UTF-8 | Java | false | false | 463 | java | package com.blog.security.core.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.blog.security.core.entity.UserEntity;
import java.util.List;
/**
* @Description 系统用户业务接口
*/
public interface UserService extends IService<UserEntity> {
/**
* 根据用户名查询实体
* @Param username 用户名
* @Return UserEntity 用户实体
*/
UserEntity selectUserByName(String username);
} | [
"996489871@qq.com"
] | 996489871@qq.com |
4fe81f2b49bbb6e6f298c6a935e4c8e887bd0b68 | 7ee57de8501e64f94727b71847de63ecd6c0f7a8 | /Sece dining/Main.java | c7381d09d16e61f92a814d296e4d2d6a737e119e | [] | no_license | pree1999/Playground | e4696ac3acebee1ceb370fa281c2d8df2a350824 | acbf6d8cce0f4775ac670888f467d3d447c0f91f | refs/heads/master | 2022-07-15T21:29:02.433787 | 2020-05-14T07:20:01 | 2020-05-14T07:20:01 | 255,085,599 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 286 | java | #include<iostream>
using namespace std;
int main()
{
string door;
int n;
cin>>door>>n;
if(door=="front")
{
if(n==1)
cout<<"Left Handed";
else
cout<<"Right Handed";}
else{
if(n==1)
cout<<"Right Handed";
else
cout<<"Left Handed";
}
} | [
"63546241+pree1999@users.noreply.github.com"
] | 63546241+pree1999@users.noreply.github.com |
ed0b51bb239c19d27c49e947b4b28b1c0ea26fea | c01a80acd844e93106f694d396bcfc9b5d12dd35 | /Candy/Solution.java | e02d7d09611f5398629410e60e8999c1c4888e02 | [] | no_license | shaowei-su/MySubLC | c8ccc25ffc552b297eb69ff7b2f888f7aa45fa33 | 1a8048c16f782e025f0da85ac79dcb6a02e9166d | refs/heads/master | 2020-06-02T10:20:36.557147 | 2015-09-22T21:00:34 | 2015-09-22T21:00:34 | 37,701,847 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | public class Solution {
public int candy(int[] ratings) {
if (ratings == null || ratings.length == 0) {
return 0;
}
int res = 0;
int[] candies = new int[ratings.length];
candies[0] = 1;
for (int i = 1; i < ratings.length; i++) {
if (ratings[i] > ratings[i - 1]) {
candies[i] = candies[i - 1] + 1;
} else {
candies[i] = 1;
}
}
res = candies[candies.length - 1];
for (int i = candies.length - 2; i >= 0; i--) {
int crt = 1;
if (ratings[i] > ratings[i + 1]) {
crt = candies[i + 1] + 1;
}
res += Math.max(crt, candies[i]);
candies[i] = crt;
}
return res;
}
} | [
"shaow.su@gmail.com"
] | shaow.su@gmail.com |
435f490f2c01c66a2e44b60cf2f66c4f881486e1 | cc6ebd1214a2a33bbb5de97449bd30b986c38f61 | /subsystem/src/test/java/test/org/picketlink/as/subsystem/util/TestModule.java | db8e71f3b35a1cf011a5181a38db46967f5e4d0f | [] | no_license | picketlink/picketlink-tests | aacdf967b85798f0897122094bf878e28e748e79 | 153ae9ad2771f671b3986976f0afc7d45b353bf0 | refs/heads/master | 2020-05-28T13:29:16.505241 | 2015-12-17T04:13:05 | 2015-12-17T04:13:05 | 16,284,113 | 0 | 1 | null | 2014-07-24T07:00:12 | 2014-01-27T16:05:21 | Java | UTF-8 | Java | false | false | 7,774 | java | /*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package test.org.picketlink.as.subsystem.util;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexWriter;
import org.jboss.jandex.Indexer;
import org.jboss.shrinkwrap.api.Node;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* <p>Utility class with some convenience methods to create and remove modules.</p>
*
* @author Pedro Igor
*/
public class TestModule {
private final String moduleName;
private final File moduleXml;
private final List<JavaArchive> resources = new ArrayList<JavaArchive>();
/**
* <p>Creates a new module with the given name and module definition.</p>
*
* @param moduleName The name of the module.
* @param moduleXml The module definition file..
*/
public TestModule(String moduleName, File moduleXml) {
if (!moduleXml.exists()) {
throw new IllegalArgumentException("The module definition must exists.");
}
this.moduleName = moduleName;
this.moduleXml = moduleXml;
}
/**
* <p>Creates the module directory. If the module already exists, it will deleted first.</p>
*
* @throws java.io.IOException If any error occurs during the module creation.
*/
public void create() throws IOException {
create(true);
}
/**
* <p>Creates the module directory.</p>
*
* @param deleteFirst If the module already exists, this argument specifies if it should be deleted before continuing.
*
* @throws java.io.IOException
*/
public void create(boolean deleteFirst) throws IOException {
File moduleDirectory = getModuleDirectory();
if (moduleDirectory.exists()) {
if (!deleteFirst) {
throw new IllegalArgumentException(moduleDirectory + " already exists.");
}
remove();
}
File mainDirectory = new File(moduleDirectory, "main");
if (!mainDirectory.mkdirs()) {
throw new IllegalArgumentException("Could not create " + mainDirectory);
}
try {
copyFile(new File(mainDirectory, "module.xml"), new FileInputStream(this.moduleXml));
} catch (IOException e) {
throw new RuntimeException("Could not create module definition.", e);
}
for (JavaArchive resourceRoot : this.resources) {
FileOutputStream jarFile = null;
try {
Indexer indexer = new Indexer();
for (Node content : resourceRoot.getContent().values()) {
if (content.getPath().get().endsWith(".class")) {
indexer.index(content.getAsset().openStream());
}
}
Index index = indexer.complete();
ByteArrayOutputStream data = new ByteArrayOutputStream();
IndexWriter writer = new IndexWriter(data);
writer.write(index);
resourceRoot.addAsManifestResource(new ByteArrayAsset(data.toByteArray()), "jandex.idx");
jarFile = new FileOutputStream(new File(mainDirectory, resourceRoot.getName()));
resourceRoot.as(ZipExporter.class).exportTo(jarFile);
} catch (Exception e) {
throw new RuntimeException("Could not create module resource [" + resourceRoot.getName() + ".", e);
} finally {
if (jarFile != null) {
jarFile.flush();
jarFile.close();
}
}
}
}
/**
* <p>Removes the module from the modules directory. This operation can not be reverted.</p>
*/
public void remove() {
remove(getModuleDirectory());
}
/**
* <p>Creates a {@link org.jboss.shrinkwrap.api.spec.JavaArchive} instance that will be used to create a jar file inside the
* module's directory.</p>
*
* <p>The name of the archive must match one of the <code>resource-root</code> definitions defined in the module
* definition.</p>
*
* @param fileName The name of the archive.
*
* @return
*/
public JavaArchive addResource(String fileName) {
JavaArchive resource = ShrinkWrap.create(JavaArchive.class, fileName);
this.resources.add(resource);
return resource;
}
private void remove(File file) {
if (file.exists()) {
if (file.isDirectory()) {
for (String name : file.list()) {
remove(new File(file, name));
}
}
if (!file.delete()) {
throw new RuntimeException("Could not delete [" + file.getPath() + ".");
}
} else {
throw new IllegalStateException("Module [" + this.moduleName + "] does not exists.");
}
}
private File getModuleDirectory() {
return new File(getModulesDirectory(), this.moduleName.replace('.', File.separatorChar));
}
private File getModulesDirectory() {
String modulePath = System.getProperty("module.path", null);
if (modulePath == null) {
String jbossHome = System.getProperty("jboss.home", null);
if (jbossHome == null) {
throw new IllegalStateException("Neither -Dmodule.path nor -Djboss.home were set");
}
modulePath = jbossHome + File.separatorChar + "modules";
} else {
modulePath = modulePath.split(File.pathSeparator)[0];
}
File moduleDir = new File(modulePath);
if (!moduleDir.exists()) {
throw new IllegalStateException("Determined module path does not exist");
}
if (!moduleDir.isDirectory()) {
throw new IllegalStateException("Determined module path is not a dir");
}
return moduleDir;
}
private static void copyFile(File target, InputStream src) throws IOException {
final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(target));
try {
int i = src.read();
while (i != -1) {
out.write(i);
i = src.read();
}
} finally {
out.close();
}
}
public String getName() {
return moduleName;
}
}
| [
"pigor.craveiro@gmail.com"
] | pigor.craveiro@gmail.com |
2e284d37109c97cc82632e4e597ff014950ce2af | 521ebac515781cf9446076277293a1d0f4c6d5c3 | /qos-war/src/main/java/com/viettelperu/qos/model/dto/CustomerDTO.java | f407037062ae27e49c17bda53e9ad7ec577d2efe | [
"MIT"
] | permissive | caf3sua/qos | ea9d535c7d4691f2cc3738c0aed4f2572a46176f | 2a04b3a692acb2da293a4fcfc4cf9e69b1e083fd | refs/heads/master | 2020-04-12T02:32:51.780836 | 2016-07-26T14:35:52 | 2016-07-26T14:35:52 | 64,227,746 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,489 | java | package com.viettelperu.qos.model.dto;
import java.util.Date;
/**
* @author Nam, Nguyen Hoai <namnh@itsol.vn>
*/
public class CustomerDTO {
String code;
Long custId;
String firstName;
String lastName;
Long serviceType;
Date startDatetime;
Long Status;
String message;
String telecomService;
String isdn;
/**
* @return the isdn
*/
public String getIsdn() {
return isdn;
}
/**
* @param isdn the isdn to set
*/
public void setIsdn(String isdn) {
this.isdn = isdn;
}
/**
* @return the telecomService
*/
public String getTelecomService() {
return telecomService;
}
/**
* @param telecomService the telecomService to set
*/
public void setTelecomService(String telecomService) {
this.telecomService = telecomService;
}
/**
* @return the code
*/
public String getCode() {
return code;
}
/**
* @param code the code to set
*/
public void setCode(String code) {
this.code = code;
}
/**
* @return the custId
*/
public Long getCustId() {
return custId;
}
/**
* @param custId the custId to set
*/
public void setCustId(Long custId) {
this.custId = custId;
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
* @return the serviceType
*/
public Long getServiceType() {
return serviceType;
}
/**
* @param serviceType the serviceType to set
*/
public void setServiceType(Long serviceType) {
this.serviceType = serviceType;
}
/**
* @return the startDatetime
*/
public Date getStartDatetime() {
return startDatetime;
}
/**
* @param startDatetime the startDatetime to set
*/
public void setStartDatetime(Date startDatetime) {
this.startDatetime = startDatetime;
}
/**
* @return the status
*/
public Long getStatus() {
return Status;
}
/**
* @param status the status to set
*/
public void setStatus(Long status) {
Status = status;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}
}
| [
"hoainamtin2@gmail.com"
] | hoainamtin2@gmail.com |
4a5466f0b10c0b7445db7c3ccbfa62a121d63602 | 3fe1dca3d9f6a8b3561e00f48a1922336b0970b1 | /Assignment 8/Chapter_5_CityGuide/app/src/main/java/demoproject/caleb/umbc/chapter_5_cityguide/MainActivity.java | 39c982e18b3344c861e79272a97922075e609639 | [] | no_license | calebamassey/Java-JavaFX-AndroidStudios | 974bb1cca4d2f538f74a3bacde01b0c892e414ef | c09d9ed11e6a4f09fcd1cfb57e6936305599565b | refs/heads/master | 2020-04-06T20:37:16.426249 | 2019-12-16T23:32:18 | 2019-12-16T23:32:18 | 157,774,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,432 | java | package demoproject.caleb.umbc.chapter_5_cityguide;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[ ] attraction = {"Art Institute of Chicago", "Magnificent Mile", "Willis Tower", "Navy Pier", "Water Tower"};
setListAdapter(new ArrayAdapter<String>(this, R.layout.activity_main, R.id.travel, attraction));
}
protected void onListItemClick(ListView l, View v, int position, long id){
switch(position){
case 0:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse ("http://artic.edu ")));
break;
case 1:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse ("http://themagnificentmile.com" )));
break;
case 2:
startActivity(new Intent(MainActivity.this, Willis.class));
break;
case 3:
startActivity(new Intent(MainActivity.this, Pier.class));
break;
case 4:
startActivity(new Intent(MainActivity.this, Water.class));
break;
}
}
}
| [
"43453784+calebamassey@users.noreply.github.com"
] | 43453784+calebamassey@users.noreply.github.com |
02478b333b884d997f11f4edc6d2dc767ec9a8bb | 4a8defe6b16ed957c10c574f53220ffec87d272e | /src/main/java/com/example/demo/service/UserAndBanjiService.java | 61d86f960a61642b9df62bff00ea402630143657 | [] | no_license | 19941229xz/pageDemo | 02381898d69d3d2dea13626bedaee000db18e2f7 | 5b5c8153c5e066ed404cf80828c284cf3c82fedd | refs/heads/master | 2020-04-14T23:24:45.283238 | 2019-04-28T01:50:00 | 2019-04-28T01:50:00 | 164,201,360 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 207 | java | package com.example.demo.service;
import com.example.demo.common.base.BaseService;
import com.example.demo.model.UserAndBanji;
public interface UserAndBanjiService extends BaseService<UserAndBanji>{
}
| [
"kumashou@10.0.1.172"
] | kumashou@10.0.1.172 |
94758adf80460be3d2dbc038565a29e87da107c2 | 68b7462c32372b81251da5a989967e3a762bc79d | /src/main/java/com/keksovmen/Pinger/Handlers/FileHandler.java | 0e61bc3049e87c6f7715f7632fa1e33263314ad7 | [] | no_license | keksovmen/SiteChecker | 6dd999307e268770dacb622e2253b559131ffc35 | 91d9de9b9d4a995e850531b14b9fb224fb363707 | refs/heads/master | 2023-03-11T01:23:25.296293 | 2021-02-25T05:53:53 | 2021-02-25T05:53:53 | 340,368,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,899 | java | package com.keksovmen.Pinger.Handlers;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
public class FileHandler extends AbstractHandler {
public static final String DIRECTORY_NAME = "Pinger_Files_Storage";
public static final String FILE_NAME = "Data.txt";
public static final Path DESTINATION_PATH =
Paths.get(System.getProperty("user.home"), DIRECTORY_NAME, FILE_NAME);
private boolean fileCreated = false;
public FileHandler(Handler successor) {
super(successor);
}
@Override
public boolean addSite(String site) {
if (!fileCreated) {
return false;
}
if (site.endsWith("\n")) {
site = site.trim();
}
try {
Files.writeString(DESTINATION_PATH, site + "\n", StandardOpenOption.APPEND);
} catch (IOException e) {
e.printStackTrace();
updateError(ErrorCode.FILE_OPEN);
return false;
}
return super.addSite(site);
}
@Override
public boolean removeSite(String site) {
if (!fileCreated) {
return false;
}
List<String> allSites = readAllLines();
allSites.remove(site);
try {
Files.write(
DESTINATION_PATH,
allSites,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING
);
} catch (IOException e) {
e.printStackTrace();
updateError(ErrorCode.FILE_OPEN);
return false;
}
return super.removeSite(site);
}
@Override
public boolean changeDelay(int delay) {
//save to property map
return super.changeDelay(delay);
}
public boolean init() {
Path storagePath = Paths.get(System.getProperty("user.home"), DIRECTORY_NAME);
if (!Files.exists(storagePath)) {
try {
Files.createDirectory(storagePath);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
if (!Files.exists(DESTINATION_PATH)) {
try {
Files.createFile(DESTINATION_PATH);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
fileCreated = true;
return true;
}
public List<String> readAllLines() {
if (!fileCreated) {
return new ArrayList<>();
}
try {
return Files.readAllLines(DESTINATION_PATH);
} catch (IOException e) {
e.printStackTrace();
}
return new ArrayList<>();
}
}
| [
"keksovmen@yandex.ru"
] | keksovmen@yandex.ru |
182b06a57d6a4141261ecf0afb0de60fbc7fb272 | eae1771a055d3d1796f87e7491a405ac5d030d26 | /test/com/facebook/buck/rules/coercer/SourceSetTest.java | ba781240148d9fff658f80075c722f40ea44e563 | [
"Apache-2.0"
] | permissive | auserj/buck | 0015bf14dfdf1125923e295ff8c0bc227916cac4 | 046feaa1eb9b1dd2c31ce6c364995fb3207e627d | refs/heads/master | 2021-09-20T17:20:19.845804 | 2018-08-12T21:39:25 | 2018-08-12T22:39:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,261 | java | /*
* Copyright 2016-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.buck.rules.coercer;
import static org.junit.Assert.assertThat;
import com.facebook.buck.core.cell.TestCellPathResolver;
import com.facebook.buck.core.cell.resolver.CellPathResolver;
import com.facebook.buck.core.model.BuildTarget;
import com.facebook.buck.core.model.BuildTargetFactory;
import com.facebook.buck.core.sourcepath.DefaultBuildTargetSourcePath;
import com.facebook.buck.parser.BuildTargetPattern;
import com.facebook.buck.parser.BuildTargetPatternParser;
import com.facebook.buck.testutil.FakeProjectFilesystem;
import com.facebook.buck.versions.FixedTargetNodeTranslator;
import com.facebook.buck.versions.TargetNodeTranslator;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Optional;
import org.hamcrest.Matchers;
import org.junit.Test;
public class SourceSetTest {
private static final CellPathResolver CELL_PATH_RESOLVER =
TestCellPathResolver.get(new FakeProjectFilesystem());
private static final BuildTargetPatternParser<BuildTargetPattern> PATTERN =
BuildTargetPatternParser.fullyQualified();
@Test
public void translatedNamedSourcesTargets() {
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
TargetNodeTranslator translator =
new FixedTargetNodeTranslator(
new DefaultTypeCoercerFactory(), ImmutableMap.of(target, newTarget));
assertThat(
translator.translate(
CELL_PATH_RESOLVER,
PATTERN,
SourceSet.ofNamedSources(
ImmutableMap.of("name", DefaultBuildTargetSourcePath.of(target)))),
Matchers.equalTo(
Optional.of(
SourceSet.ofNamedSources(
ImmutableMap.of("name", DefaultBuildTargetSourcePath.of(newTarget))))));
}
@Test
public void untranslatedNamedSourcesTargets() {
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
TargetNodeTranslator translator =
new FixedTargetNodeTranslator(new DefaultTypeCoercerFactory(), ImmutableMap.of());
SourceSet list =
SourceSet.ofNamedSources(ImmutableMap.of("name", DefaultBuildTargetSourcePath.of(target)));
assertThat(
translator.translate(CELL_PATH_RESOLVER, PATTERN, list),
Matchers.equalTo(Optional.empty()));
}
@Test
public void translatedUnnamedSourcesTargets() {
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
BuildTarget newTarget = BuildTargetFactory.newInstance("//something:else");
TargetNodeTranslator translator =
new FixedTargetNodeTranslator(
new DefaultTypeCoercerFactory(), ImmutableMap.of(target, newTarget));
assertThat(
translator.translate(
CELL_PATH_RESOLVER,
PATTERN,
SourceSet.ofUnnamedSources(ImmutableSet.of(DefaultBuildTargetSourcePath.of(target)))),
Matchers.equalTo(
Optional.of(
SourceSet.ofUnnamedSources(
ImmutableSet.of(DefaultBuildTargetSourcePath.of(newTarget))))));
}
@Test
public void untranslatedUnnamedSourcesTargets() {
BuildTarget target = BuildTargetFactory.newInstance("//:rule");
TargetNodeTranslator translator =
new FixedTargetNodeTranslator(new DefaultTypeCoercerFactory(), ImmutableMap.of());
SourceSet list =
SourceSet.ofUnnamedSources(ImmutableSet.of(DefaultBuildTargetSourcePath.of(target)));
assertThat(
translator.translate(CELL_PATH_RESOLVER, PATTERN, list),
Matchers.equalTo(Optional.empty()));
}
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
782285093630a78ce81c89f9fa51003bad898db7 | 2f792ffd19eb1cce1391249a8f235d05fc5b0998 | /app/src/androidTest/java/com/example/ano/daily/ExampleInstrumentedTest.java | b57917a6684b2e7e91fc4748247c6a5f24246965 | [] | no_license | stupidboy666/Daily | ed584474ad2bbed1f15c8cb972503452c5797a01 | cd9b48643bc882677d3c9955aaf86a5956260478 | refs/heads/master | 2020-03-30T07:59:57.309799 | 2018-10-01T15:28:30 | 2018-10-01T15:28:30 | 150,980,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | package com.example.ano.daily;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.ano.daily", appContext.getPackageName());
}
}
| [
"1300833021@qq.com"
] | 1300833021@qq.com |
126de6afc85bc8580c896e2a440581a320075fae | 9f5a354cdea6ebf0133c6e793f020609d837d900 | /Alumini/src/com/alumni/db/DbConnection.java | 7020663b4b05b76c38f14323695c68474a9c2106 | [] | no_license | rhts76448/Studentsapp | 2af40ce3c86efa514e5e384fc4bc14941e422c04 | d5461a5b0599b4eda3a3af032d388ee26d5f29c8 | refs/heads/master | 2020-03-21T02:42:44.360106 | 2018-05-14T02:25:15 | 2018-05-14T02:25:15 | 138,013,762 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package com.alumni.db;
import java.sql.Connection;
public class DbConnection {
private static Connection connection;
public static void setConnection(Connection connection) {
DbConnection.connection = connection;
}
public static Connection getConnection()
{
return DbConnection.connection;
}
}
| [
"rohitpatel76448@gmail.com"
] | rohitpatel76448@gmail.com |
984dc8805821677d1f47723ce24df1027aba9282 | f75be7e48f6b2c8cd79bdb5d268e08db631d3363 | /src/GUI/TimeTableController.java | 042327bf47afd445a4410a424e0552befab50855 | [] | no_license | hamadhassan3/TimeTableManager | 89abbfbfc95e6533ddf553710b3a890837635317 | 44a9561b6b52b2eb9380f41031f0053b5f6565af | refs/heads/master | 2023-05-15T06:01:11.162324 | 2021-06-08T19:48:25 | 2021-06-08T19:48:25 | 375,083,925 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 51,263 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;
import admtimetable.*;
import com.sun.javafx.scene.control.skin.TableColumnHeader;
import com.sun.javaws.Main;
import java.awt.Color;
import java.awt.Font;
import static java.awt.SystemColor.menu;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Point2D;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceDialog;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.control.TextInputDialog;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.ScrollEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Shape;
import javafx.stage.FileChooser;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.util.Callback;
import javafx.util.Pair;
/**
* FXML Controller class
*
* @author hamad
*/
public class TimeTableController extends Application implements Initializable {
double x;
double y;
TimeTableController var = this;
public int BlocksUsed = 0;
public int TransitionCount = 0;
int b1Used = 0;
int b2Used = 0;
int b3Used = 0;
int b4Used = 0;
int b5Used = 0;
int b6Used = 0;
int b7Used = 0;
int b8Used = 0;
//private Pane ButtonsAnchor;
public Button button1 = new Button();
Button button2 = new Button();
Button button3 = new Button();
Button button4 = new Button();
Button button5 = new Button();
Button button6 = new Button();
Button buttonOFF = new Button();
Button buttonAllStar = new Button();
final int minSize = 30;
@FXML
private Pane ButtonsAnchor;
Date lastClickTime;
int counter = -1;
int prevButt = -1;
/**
* Initializes the controller class.
*/
String color[] = {"Red", "Yellow", "Green", "Orange", "Purple", "Brown", "Blue", "No Color"};
String butColors[] = {"Red", "Blue", "Grey", "Yellow", "Orange", "Purple", "black", "gold"};
double boundsInParentX = -1;
double boundsInParentY = -1;
public ListView<String> tablefortime;
@FXML
private TableView<Slot> table;
@FXML
private TableColumn<Slot, String> colNo;
@FXML
private TableColumn<Slot, String> colDate;
@FXML
private TableColumn<Slot, String> colDay;
private TableColumn<Slot, Button> colSlot;
Stage s;
List<String> listofrows = new ArrayList<>();
@FXML
private TableView<SlotButton> tableSlot;
@FXML
private TableColumn<SlotButton, Button> colSlotT2;
@FXML
private Label blockUsed;
@FXML
private Label trCount;
@FXML
private Button exp;
@FXML
private Button delButton;
@FXML
private Label l1;
@FXML
private Label l2;
@FXML
private Label l3;
@FXML
private Label l4;
@FXML
private Label l5;
@FXML
private Label l6;
@FXML
private Label l7;
@FXML
private Label l8;
TableView<Slot> gettable() {
return table;
}
TableView<SlotButton> getslottable() {
return tableSlot;
}
Slot click = null;
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
this.BlocksUsed = TimeTable.tb.blocksUsed;
this.TransitionCount = TimeTable.tb.transitionCount;
this.b1Used = TimeTable.tb.l1;
this.b2Used = TimeTable.tb.l2;
this.b3Used = TimeTable.tb.l3;
this.b4Used = TimeTable.tb.l4;
this.b5Used = TimeTable.tb.l5;
this.b6Used = TimeTable.tb.l6;
this.b7Used = TimeTable.tb.l7;
this.b8Used = TimeTable.tb.l8;
l1.setText("1 Used: " + Integer.toString(b1Used));
l2.setText("2 Used: " + Integer.toString(b2Used));
l3.setText("3 Used: " + Integer.toString(b3Used));
l4.setText("4 Used: " + Integer.toString(b4Used));
l5.setText("5 Used: " + Integer.toString(b5Used));
l6.setText("6 Used: " + Integer.toString(b6Used));
l7.setText("OFF Used: " + Integer.toString(b7Used));
l8.setText("All Star Used: " + Integer.toString(b8Used));
this.blockUsed.setText("Blocks Used: " + BlocksUsed);
//this.blockUsed.setText("Blocks Used: " + TransitionCount);
this.trCount.setText("Tranisition Count: " + TransitionCount);
colNo.setCellValueFactory(new PropertyValueFactory<Slot, String>("num"));
colDate.setCellValueFactory(new PropertyValueFactory<Slot, String>("date"));
colDay.setCellValueFactory(new PropertyValueFactory<Slot, String>("day"));
colSlotT2.setCellValueFactory(new PropertyValueFactory<SlotButton, Button>("but"));
table.setItems(getSlots());
delButton.setStyle("fx-background-color: transparent;-fx-background-image: url('/GUI/del.png')");
tableSlot.setRowFactory(tv -> new TableRow<SlotButton>() {
@Override
public void updateItem(SlotButton item, boolean empty) {
if (item == null) {
setStyle("");
} else if (item.getColor() == null) {
setStyle("");
item.getBut().setStyle("");
item.getBut().setText("");
} else {
if (item.getColor().equalsIgnoreCase("Off Day")) {
setStyle("-fx-background-color: black");
item.getBut().setStyle("-fx-background-color: black; -fx-text-fill: white;");
item.getBut().setText("Off Day");
} else {
boolean found = false;
for (int i = 0; i < butColors.length; i++) {
if (item.getColor().equals(butColors[i])) {
if (item.getNum() == 1) {
//Add up down left and right border
setStyle("-fx-border-width: 5 5 5 5;-fx-border-color: " + "black" + ";");
} else if (item.getNumInsideBut() == 0) {
//For up left right
setStyle("-fx-border-width: 5 5 0 5;-fx-border-color: " + "black" + ";");
} else if (item.getNumInsideBut() == item.getNum() - 1) {
//Add left right and down border
setStyle("-fx-border-width: 0 5 5 5;-fx-border-color: " + "black" + ";");
} else {
setStyle("-fx-border-width: 0 5 0 5;-fx-border-color: " + "black" + ";");
}
item.getBut().setText(Integer.toString(item.getNum()));
setStyle(getStyle() + "-fx-background-color: " + item.getColor() + ";");
if (i == 6) {
item.getBut().setText("OFF");
item.getBut().setTextFill(Paint.valueOf("white"));
} else if (i == 7) {
item.getBut().setText("All Star");
item.getBut().setTextFill(Paint.valueOf("white"));
} else {
item.getBut().setTextFill(Paint.valueOf("black"));
}
item.getBut().setStyle("-fx-background-color: " + item.getColor() + ";");
found = true;
break;
}
}
if (!found) {
setStyle("");
item.getBut().setStyle("");
}
}
}
}
});
table.setRowFactory(tv -> new TableRow<Slot>() {
@Override
public void updateItem(Slot item, boolean empty) {
super.updateItem(item, empty);
if (item == null) {
setStyle("");
} else {
if (item.getColor().equals("No Color")) {
setStyle("");
} else {
boolean found = false;
for (int i = 0; i < color.length; i++) {
if (item.getColor().equals(color[i])) {
setStyle("-fx-background-color: " + color[i] + ";");
found = true;
break;
}
}
if (!found) {
setStyle("");
}
}
}
}
});
table.addEventFilter(MouseEvent.MOUSE_ENTERED, event -> {
if ((event.getTarget() instanceof TableColumnHeader) | event.isDragDetect()) {
// PerformYourActionHere
ScrollBar scrollBarOne;
ScrollBar scrollBarTwo;
scrollBarOne = (ScrollBar) table.lookup(".scroll-bar:vertical");
scrollBarTwo = (ScrollBar) tableSlot.lookup(".scroll-bar:vertical");
if (scrollBarOne != null && scrollBarTwo != null) {
//scrollBarTwo.setBlockIncrement(34);
scrollBarOne.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
scrollBarTwo.setValue(scrollBarOne.getValue());
}
});
}
}
});
tableSlot.addEventFilter(MouseEvent.MOUSE_ENTERED, event -> {
if ((event.getTarget() instanceof TableColumnHeader) | event.isDragDetect()) {
// PerformYourActionHere
ScrollBar scrollBarOne;
ScrollBar scrollBarTwo;
scrollBarOne = (ScrollBar) table.lookup(".scroll-bar:vertical");
scrollBarTwo = (ScrollBar) tableSlot.lookup(".scroll-bar:vertical");
if (scrollBarOne != null && scrollBarTwo != null) {
//scrollBarTwo.setBlockIncrement(34);
scrollBarTwo.valueProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
scrollBarOne.setValue(scrollBarTwo.getValue());
}
});
}
}
});
exp.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open File");
File file = fileChooser.showOpenDialog(s);
FileWriter csvWriter = null;
try {
csvWriter = new FileWriter(file);
csvWriter.append(Boolean.toString(TimeTable.tb.satTCheck));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.sunTCheck));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.mon));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.tue));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.wed));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.thur));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.fri));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.sat));
csvWriter.append(",");
csvWriter.append(Boolean.toString(TimeTable.tb.sun));
csvWriter.append(",");
csvWriter.append(Integer.toString(BlocksUsed));
csvWriter.append(",");
csvWriter.append(Integer.toString(TransitionCount));
csvWriter.append(",");
csvWriter.append(Integer.toString(b1Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b2Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b3Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b4Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b5Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b6Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b7Used));
csvWriter.append(",");
csvWriter.append(Integer.toString(b8Used));
csvWriter.append("\n");
for (int i = 0; i < table.getItems().size(); i++) {
String i2 = Integer.toString(i);
try {
csvWriter.append(i2);
csvWriter.append(",");
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
csvWriter.append(table.getItems().get(i).getDate());
csvWriter.append(",");
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
csvWriter.append(table.getItems().get(i).getDay());
csvWriter.append(",");
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
String temp = Integer.toString(tableSlot.getItems().get(i).getNum());
try {
csvWriter.append(temp);
csvWriter.append(",");
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
csvWriter.append(tableSlot.getItems().get(i).getColor());
csvWriter.append(",");
csvWriter.append(Integer.toString(tableSlot.getItems().get(i).getNumInsideBut()));
csvWriter.append(",");
String strEv = table.getItems().get(i).getEvent();
if (strEv.isEmpty()) {
strEv = null;
}
csvWriter.append(strEv);
csvWriter.append(",");
String strCol = table.getItems().get(i).getColor();
if (strCol.isEmpty()) {
strCol = null;
}
csvWriter.append(strCol);
csvWriter.append(",");
csvWriter.append("\n");
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
}
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
csvWriter.flush();
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
try {
csvWriter.close();
} catch (IOException ex) {
Logger.getLogger(TimeTableController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
table.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
Slot row = table.getSelectionModel().getSelectedItem();
if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
Object object = table.getSelectionModel().selectedItemProperty().get();
int index = table.getSelectionModel().selectedIndexProperty().get();
// create a choice dialog
ChoiceDialog<String> d = new ChoiceDialog<>("Color", color);
//ChoiceDialog d = new ChoiceDialog(days[1], days);
d.setHeaderText("Add Color");
d.setContentText("Select the color!");
String color2;
Optional<String> result = d.showAndWait();
if (result.isPresent()) {
//System.out.println("Your name: " + result.get());
color2 = result.get();
//Setting the color inside the slot
if (!color2.equals("Color")) {
row.setColor(color2);
}
}
} else if (mouseEvent.getButton().equals(MouseButton.SECONDARY)) {
System.out.println("Double Click");
Object object = table.getSelectionModel().selectedItemProperty().get();
int index = table.getSelectionModel().selectedIndexProperty().get();
TextInputDialog dialog = new TextInputDialog("walter");
dialog.setTitle("EVENT BOX");
dialog.setHeaderText(row.getEvent());
dialog.setContentText("Enter the event:");
String s;
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
s = result.get();
row.setEvent(s);
}
}
table.refresh();
}
});
//Initialize with add event
button1.setText("6");
button1.setStyle("-fx-background-color: " + butColors[0] + ";");
button2.setText("5");
button2.setStyle("-fx-background-color: " + butColors[1] + ";");
button3.setText("4");
button3.setStyle("-fx-background-color: " + butColors[2] + ";");
button4.setText("3");
button4.setStyle("-fx-background-color: " + butColors[3] + ";");
button5.setText("2");
button5.setStyle("-fx-background-color: " + butColors[4] + ";");
button6.setText("1");
button6.setStyle("-fx-background-color: " + butColors[5] + ";");
buttonOFF.setText("OFF");
buttonOFF.setStyle("-fx-background-color: " + butColors[6] + ";");
buttonAllStar.setText("All Star");
buttonAllStar.setStyle("-fx-background-color: " + butColors[7] + ";");
buttonOFF.setTextFill(Paint.valueOf("white"));
buttonAllStar.setTextFill(Paint.valueOf("white"));
buttonAllStar.setMinSize(200, minSize * 8);
buttonAllStar.setPrefSize(200, minSize * 8);
buttonAllStar.setMaxSize(200, minSize * 8);
buttonOFF.setMinSize(200, minSize * 7);
buttonOFF.setPrefSize(200, minSize * 7);
buttonOFF.setMaxSize(200, minSize * 7);
button1.setMinSize(200, minSize * 6);
button1.setPrefSize(200, minSize * 6);
button1.setMaxSize(200, minSize * 6);
button2.setPrefSize(200, minSize * 5);
button2.setMinSize(200, minSize * 5);
button2.setMaxSize(200, minSize * 5);
button3.setMinSize(200, minSize * 4);
button3.setPrefSize(200, minSize * 4);
button3.setMaxSize(200, minSize * 4);
button4.setPrefSize(200, minSize * 3);
button4.setMaxSize(200, minSize * 3);
button4.setMinSize(200, minSize * 3);
button5.setPrefSize(200, minSize * 2);
button5.setMinSize(200, minSize * 2);
button5.setMaxSize(200, minSize * 2);
button6.setMinSize(200, minSize);
button6.setPrefSize(200, minSize);
button6.setMaxSize(200, minSize);
buttonAllStar.setAlignment(Pos.BOTTOM_CENTER);
buttonOFF.setAlignment(Pos.BOTTOM_CENTER);
button1.setAlignment(Pos.BOTTOM_CENTER);
button2.setAlignment(Pos.BOTTOM_CENTER);
button3.setAlignment(Pos.BOTTOM_CENTER);
button4.setAlignment(Pos.BOTTOM_CENTER);
button5.setAlignment(Pos.BOTTOM_CENTER);
button6.setAlignment(Pos.BOTTOM_CENTER);
setListenerOnButton(buttonAllStar);
setListenerOnButton(buttonOFF);
setListenerOnButton(button1);
setListenerOnButton(button2);
setListenerOnButton(button3);
setListenerOnButton(button4);
setListenerOnButton(button5);
setListenerOnButton(button6);
/*Draggable.Nature drag1 = new Draggable.Nature(button1);
Draggable.Nature drag2 = new Draggable.Nature(button2);
Draggable.Nature drag3 = new Draggable.Nature(button3);
Draggable.Nature drag4 = new Draggable.Nature(button4);
Draggable.Nature drag5 = new Draggable.Nature(button5);
Draggable.Nature drag6 = new Draggable.Nature(button6);*/
ButtonsAnchor.getChildren().add(buttonAllStar);
ButtonsAnchor.getChildren().add(buttonOFF);
ButtonsAnchor.getChildren().add(button1);
ButtonsAnchor.getChildren().add(button2);
ButtonsAnchor.getChildren().add(button3);
ButtonsAnchor.getChildren().add(button4);
ButtonsAnchor.getChildren().add(button5);
ButtonsAnchor.getChildren().add(button6);
setDeleteDropOnButton(delButton);
}
public void setDeleteDropOnButton(Button source) {
source.setOnDragOver(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (event.getGestureSource() != source && event.getDragboard().hasString()) {
Button sourceB = (Button) event.getGestureSource();
if (!sourceB.equals(button1) && !sourceB.equals(button2) && !sourceB.equals(button3)
&& !sourceB.equals(button4) && !sourceB.equals(button5) && !sourceB.equals(button6)
&& !sourceB.equals(buttonOFF) && !sourceB.equals(buttonAllStar)) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
}
event.consume();
}
});
source.setOnDragEntered(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (event.getGestureSource() != source
&& event.getDragboard().hasString()) {
Button sourceB = (Button) event.getGestureSource();
if (!sourceB.equals(button1) && !sourceB.equals(button2) && !sourceB.equals(button3)
&& !sourceB.equals(button4) && !sourceB.equals(button5) && !sourceB.equals(button6)
&& !sourceB.equals(buttonOFF) && !sourceB.equals(buttonAllStar)) {
source.setStyle("fx-background-color: transparent;-fx-background-image: url('/GUI/delOpen.png')");
}
}
event.consume();
}
});
source.setOnDragExited(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
source.setStyle("fx-background-color: transparent;-fx-background-image: url('/GUI/del.png')");
event.consume();
}
});
source.setOnDragDropped(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasString()) {
Button sourceB = (Button) event.getGestureSource();
//String txt = sourceB.getText();
if (sourceB.getText().equalsIgnoreCase("All Star")) {
b8Used--;
} else if (sourceB.getText().equalsIgnoreCase("OFF")) {
b7Used--;
} else if (sourceB.getText().equalsIgnoreCase("1")) {
b1Used--;
} else if (sourceB.getText().equalsIgnoreCase("2")) {
b2Used--;
} else if (sourceB.getText().equalsIgnoreCase("3")) {
b3Used--;
} else if (sourceB.getText().equalsIgnoreCase("4")) {
b4Used--;
} else if (sourceB.getText().equalsIgnoreCase("5")) {
b5Used--;
} else if (sourceB.getText().equalsIgnoreCase("6")) {
b6Used--;
}
l1.setText("1 Used: " + Integer.toString(b1Used));
l2.setText("2 Used: " + Integer.toString(b2Used));
l3.setText("3 Used: " + Integer.toString(b3Used));
l4.setText("4 Used: " + Integer.toString(b4Used));
l5.setText("5 Used: " + Integer.toString(b5Used));
l6.setText("6 Used: " + Integer.toString(b6Used));
l7.setText("OFF Used: " + Integer.toString(b7Used));
l8.setText("All Star Used: " + Integer.toString(b8Used));
for (int i = 0; i < table.getItems().size(); i++) {
if (tableSlot.getItems().get(i).getBut().equals(sourceB)) {
for (int j = 0; j < tableSlot.getItems().get(i).getNum(); j++) {
tableSlot.getItems().get(i + j).setColor(null);
tableSlot.getItems().get(i + j).setNumInsideBut(-1);
tableSlot.getItems().get(i + j).getBut().setText("");
deleterboy(tableSlot.getItems().get(i + j).getBut());
}
}
}
int transCount = 0;
for (int i = 0; i < table.getItems().size(); i++) {
if (table.getItems().get(i).getDay().equalsIgnoreCase("Friday")) {
if (i + 1 < table.getItems().size()) {
if (tableSlot.getItems().get(i).getNumInsideBut() != -1 && tableSlot.getItems().get(i + 1).getNumInsideBut() != -1 && tableSlot.getItems().get(i).getColor() != null && tableSlot.getItems().get(i + 1).getColor() != null) {
if (!tableSlot.getItems().get(i).getColor().equals(tableSlot.getItems().get(i + 1).getColor())) {
transCount++;
} else if (tableSlot.getItems().get(i).getNumInsideBut() != tableSlot.getItems().get(i + 1).getNumInsideBut() - 1) {
transCount++;
}
}
}
}
}
TransitionCount = transCount;
trCount.setText("Transitions Count: " + TransitionCount);
//BlockUsed
BlocksUsed--;
blockUsed.setText("Blocks: " + Integer.toString(BlocksUsed));
success = true;
}
event.setDropCompleted(success);
event.consume();
}
});
}
public ObservableList<Slot> getSlots() {
ObservableList<Slot> ls = FXCollections.observableArrayList();
ObservableList<SlotButton> lsb = FXCollections.observableArrayList();
for (int i = 0; i < DateList.L.size(); i++) {
String num = Integer.toString(i + 1);
String[] str = DateList.L.get(i).split(" ");
String date = str[0];
String day = str[1];
Button target = new Button();
//tableSlot.setStyle("-fx-padding: 0 0 0 0;");
target.setPrefSize(200, 30);
target.setMaxSize(200, 30);
target.setMinSize(200, 30);
deleterboy(target);
SlotButton sb = new SlotButton(target);
/*if (isValidDay(day) == false) {
sb.setIsOff(true);
sb.setColor("Off Day");
}*/
lsb.add(sb);
ls.add(new Slot(num, date, day));
}
for (int i = 0; i < TimeTable.tb.lsb.size() - 1; i++) {
ls.get(i).setColor(TimeTable.tb.ls.get(i).getColor());
ls.get(i).setDate(TimeTable.tb.ls.get(i).getDate());
ls.get(i).setDay(TimeTable.tb.ls.get(i).getDay());
ls.get(i).setEvent(TimeTable.tb.ls.get(i).getEvent());
ls.get(i).setNum(TimeTable.tb.ls.get(i).getNum());
String str = TimeTable.tb.lsb.get(i).getColor();
if (str.equals("null")) {
str = null;
}
lsb.get(i).setColor(str);
lsb.get(i).setNum(TimeTable.tb.lsb.get(i).getNum());
lsb.get(i).setNumInsideBut(TimeTable.tb.lsb.get(i).getNumInsideBut());
}
this.tableSlot.setItems(lsb);
return ls;
}
public void deleterboy(Button target) {
target.setOnDragOver(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (event.getGestureSource() != target && event.getDragboard().hasString()) {
int counter = 0;
boolean flag = true;
double buttonNumber = 0;
for (int i = 0; i < tableSlot.getItems().size(); i++) {
if (tableSlot.getItems().get(i).getBut().equals(target)) {
Button dumba = (Button) event.getGestureSource();
double l = dumba.getHeight();
buttonNumber = l / minSize;
if (dumba.getText().equalsIgnoreCase("All Star") || dumba.getText().equals("OFF")) {
buttonNumber = 1;
}
if (i + buttonNumber > tableSlot.getItems().size()) {
flag = false;
}
for (int lun = i; lun < i + buttonNumber && lun < tableSlot.getItems().size(); lun++) {
if (tableSlot.getItems().get(lun).getColor() != null) {
flag = false;
}
}
for (int lun = 0; lun < tableSlot.getItems().size(); lun++) {
if (tableSlot.getItems().get(lun).getBut().equals(event.getGestureSource())) {
l = tableSlot.getItems().get(lun).getNum();
buttonNumber = l;
if (i + buttonNumber > tableSlot.getItems().size()) {
flag = false;
}
for (int lun2 = i; lun2 < i + buttonNumber && lun2 < tableSlot.getItems().size(); lun2++) {
if (tableSlot.getItems().get(lun2).getColor() != null) {
flag = false;
}
}
}
}
}
}
if (TimeTable.tb.satTCheck == false) {
for (int i = 0; i < tableSlot.getItems().size(); i++) {
if (tableSlot.getItems().get(i).getBut().equals(target)) {
Button number = (Button) event.getGestureSource();
int number2 = (int) (number.getHeight() / minSize);
if (table.getItems().get(i).getDay().equalsIgnoreCase("Sunday")) {
if (i - 1 >= 0 && tableSlot.getItems().get(i - 1).getColor() != null) {
flag = false;
break;
}
} else if (number2 + i - 1 < tableSlot.getItems().size()) {
if (table.getItems().get(i + number2 - 1).getDay().equalsIgnoreCase("saturday")) {
if (i + 1 < tableSlot.getItems().size() && tableSlot.getItems().get(i + number2).getColor() != null) {
flag = false;
break;
}
}
}
}
}
}
Button number = (Button) event.getGestureSource();
int number2 = (int) (number.getHeight() / minSize);
if (number2 == 7) {
for (int i = 0; i < tableSlot.getItems().size(); i++) {
if (tableSlot.getItems().get(i).getBut().equals(target)) {
if (table.getItems().get(i).getDay().equalsIgnoreCase("monday")) {
if (TimeTable.tb.mon == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("tuesday")) {
if (TimeTable.tb.tue == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("wednesday")) {
if (TimeTable.tb.wed == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("thursday")) {
if (TimeTable.tb.thur == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("friday")) {
if (TimeTable.tb.fri == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("Saturday")) {
if (TimeTable.tb.sat == false) {
flag = false;
}
} else if (table.getItems().get(i).getDay().equalsIgnoreCase("Sunday")) {
if (TimeTable.tb.sun == false) {
flag = false;
}
}
}
}
}
if (flag == true) {
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
}
event.consume();
}
});
target.setOnDragEntered(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (event.getGestureSource() != target
&& event.getDragboard().hasString()) {
if (target.getStyle().equals("")) {
target.setStyle("-fx-background-color: grey;");
}
}
event.consume();
}
});
target.setOnDragExited(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (target.getStyle().equals("-fx-background-color: grey;")) {
target.setStyle("");
}
event.consume();
}
});
target.setOnDragDropped(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
Dragboard db = event.getDragboard();
boolean success = false;
if (db.hasString()) {
Button sourceB = (Button) event.getGestureSource();
setListenerOnButton2(target);
for (int i = 0; i < tableSlot.getItems().size(); i++) {
if (tableSlot.getItems().get(i).getBut().equals(target)) {
if (sourceB.getText().equalsIgnoreCase("OFF")) {
String st = sourceB.getStyle();
for (String color : butColors) {
String s = st.toLowerCase();
String ss = color.toLowerCase();
if (s.contains(ss)) {
tableSlot.getItems().get(i).setColor("Off Day");
tableSlot.getItems().get(i).setNumInsideBut(0);
break;
}
}
tableSlot.getItems().get(i).setNum(1);
}
else if (sourceB.getText().equalsIgnoreCase("All Star")) {
String st = sourceB.getStyle();
for (String color : butColors) {
String s = st.toLowerCase();
String ss = color.toLowerCase();
if (s.contains(ss)) {
tableSlot.getItems().get(i).setColor(color);
tableSlot.getItems().get(i).setNumInsideBut(0);
break;
}
}
tableSlot.getItems().get(i).setNum(1);
} else {
for (int j = 0; j < Integer.parseInt(sourceB.getText()); j++) {
Button b = new Button();
b.setMinSize(target.getWidth(), target.getHeight());
b.setPrefSize(target.getWidth(), target.getHeight());
String st = sourceB.getStyle();
for (String color : butColors) {
String s = st.toLowerCase();
String ss = color.toLowerCase();
if (s.contains(ss)) {
tableSlot.getItems().get(i + j).setColor(color);
tableSlot.getItems().get(i + j).setNumInsideBut(j);
if (j != 0) {
tableSlot.getItems().get(i + j).setBut(b);
}
break;
}
}
tableSlot.getItems().get(i + j).setNum(Integer.parseInt(sourceB.getText()));
}
}
break;
}
}
int height = 0;
for (int i = 0; i < tableSlot.getItems().size(); i++) {
if (sourceB.equals(tableSlot.getItems().get(i).getBut())) {
height = tableSlot.getItems().get(i).getNum();
for (int j = i; j < i + height; j++) {
tableSlot.getItems().get(j).setNumInsideBut(-1);
tableSlot.getItems().get(j).setColor(null);
tableSlot.getItems().get(j).getBut().setText("");
//setListenerOnButton2(tableSlot.getItems().get(j).getBut());
deleterboy(tableSlot.getItems().get(j).getBut());
}
break;
}
}
int transCount = 0;
for (int i = 0; i < table.getItems().size(); i++) {
if (table.getItems().get(i).getDay().equalsIgnoreCase("Friday")) {
if (i + 1 < table.getItems().size()) {
if (tableSlot.getItems().get(i).getNumInsideBut() != -1 && tableSlot.getItems().get(i + 1).getNumInsideBut() != -1 && tableSlot.getItems().get(i).getColor() != null && tableSlot.getItems().get(i + 1).getColor() != null) {
if (!tableSlot.getItems().get(i).getColor().equals(tableSlot.getItems().get(i + 1).getColor())) {
transCount++;
} else if (tableSlot.getItems().get(i).getNumInsideBut() != tableSlot.getItems().get(i + 1).getNumInsideBut() - 1) {
transCount++;
}
}
}
}
}
TransitionCount = transCount;
trCount.setText("Transitions Count: " + TransitionCount);
success = true;
tableSlot.refresh();
}
event.setDropCompleted(success);
event.consume();
}
});
}
public boolean isValidDay(String day) {
boolean toRet = true;
String[] days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
TimeTable tb = TimeTable.tb;
if (day.equals(days[0])) {
if (tb.mon) {
toRet = false;
}
} else if (day.equals(days[1])) {
if (tb.tue) {
toRet = false;
}
} else if (day.equals(days[2])) {
if (tb.wed) {
toRet = false;
}
} else if (day.equals(days[3])) {
if (tb.thur) {
toRet = false;
}
} else if (day.equals(days[4])) {
if (tb.fri) {
toRet = false;
}
} else if (day.equals(days[5])) {
if (tb.sat) {
toRet = false;
}
} else if (day.equals(days[6])) {
if (tb.sun) {
toRet = false;
}
}
return toRet;
}
public void setListenerOnButton(Button source) {
source.setOnDragDetected(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
Dragboard db = source.startDragAndDrop(TransferMode.ANY);
/* Put a string on a dragboard */
ClipboardContent content = new ClipboardContent();
String txt = "" + source.getText().toString();
content.putString(txt);
db.setContent(content);
event.consume();
}
});
source.setOnDragDone(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
if (event.getTransferMode() == TransferMode.MOVE) {
//source.setText("");
BlocksUsed++;
blockUsed.setText("Blocks Used: " + BlocksUsed);
if (source.getText().equalsIgnoreCase("All Star")) {
b8Used++;
} else if (source.getText().equalsIgnoreCase("OFF")) {
b7Used++;
} else if (source.getText().equalsIgnoreCase("1")) {
b1Used++;
} else if (source.getText().equalsIgnoreCase("2")) {
b2Used++;
} else if (source.getText().equalsIgnoreCase("3")) {
b3Used++;
} else if (source.getText().equalsIgnoreCase("4")) {
b4Used++;
} else if (source.getText().equalsIgnoreCase("5")) {
b5Used++;
} else if (source.getText().equalsIgnoreCase("6")) {
b6Used++;
}
l1.setText("1 Used: " + Integer.toString(b1Used));
l2.setText("2 Used: " + Integer.toString(b2Used));
l3.setText("3 Used: " + Integer.toString(b3Used));
l4.setText("4 Used: " + Integer.toString(b4Used));
l5.setText("5 Used: " + Integer.toString(b5Used));
l6.setText("6 Used: " + Integer.toString(b6Used));
l7.setText("OFF Used: " + Integer.toString(b7Used));
l8.setText("All Star Used: " + Integer.toString(b8Used));
} else {
//*********************************THE BEEEP**********************************
java.awt.Toolkit.getDefaultToolkit().beep();
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Error");
alert.setHeaderText("Error in placing the block");
alert.setContentText("Please Place the block in correct slot!");
alert.showAndWait();
}
event.consume();
}
});
}
public void setListenerOnButton2(Button source) {
source.setOnDragDetected(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
Dragboard db = source.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
content.putString(source.getText());
db.setContent(content);
event.consume();
}
});
source.setOnDragDone(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
/* the drag and drop gesture ended */
/* if the data was successfully moved, clear it */
if (event.getTransferMode() == TransferMode.MOVE) {
source.setText("");
source.setText("");
} else {
//*********************************THE BEEEP**********************************
java.awt.Toolkit.getDefaultToolkit().beep();
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Error");
alert.setHeaderText("Error in placing the block");
alert.setContentText("Please Place the block in correct slot!");
alert.showAndWait();
}
event.consume();
}
});
}
@Override
public void start(Stage primaryStage) throws Exception {
s = new Stage();
}
@FXML
private void onScroll(ScrollEvent event) {
}
@FXML
private void onScrollFn(ScrollEvent event) {
}
@FXML
private void onScrollSt(ScrollEvent event) {
}
}
| [
"hamadhassan3@gmail.com"
] | hamadhassan3@gmail.com |
2a850a1799e7f3be8452ba9886e97a8dfc6be9dd | 98d14a8d01c22b473c14ed61323c6a30c1081088 | /src/main/java/com/mashibing/juc/c_028_interview/A1B2C3/T04_00_lock_condition.java | d11e758f78089741c86d8d53e54f62c7a1c3626f | [] | no_license | lintianneng/JUC | 4d489686df95679ee88b34c2d4dfc1ffea20bc25 | 1bc8ae127947c402ce032aaee4fd9f24e54fb112 | refs/heads/master | 2020-08-08T23:09:25.807066 | 2019-09-29T03:24:03 | 2019-09-29T03:24:03 | 213,942,502 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,372 | java | package com.mashibing.juc.c_028_interview.A1B2C3;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class T04_00_lock_condition {
public static void main(String[] args) {
char[] aI = "1234567".toCharArray();
char[] aC = "ABCDEFG".toCharArray();
Lock lock = new ReentrantLock();
Condition condition = lock.newCondition();
new Thread(()->{
try {
lock.lock();
for(char c : aI) {
System.out.print(c);
condition.signal();
condition.await();
}
condition.signal();
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock();
}
}, "t1").start();
new Thread(()->{
try {
lock.lock();
for(char c : aC) {
System.out.print(c);
condition.signal();
condition.await();
}
condition.signal();
} catch (Exception e) {
e.printStackTrace();
} finally {
lock.unlock();
}
}, "t2").start();
}
}
| [
"alanpppbox@gmail.com"
] | alanpppbox@gmail.com |
77495d62a617d6bacf3c89146ccf72a7a5f80dc1 | f03931d05413f0d29d8e27944a6c5400ab52575e | /ViewController/src/view/SearchBean.java | ea13c70149c69e4b50aab6e3b9b01cdc37aedb92 | [] | no_license | pavansinghk/Ticketing_Tool | e82b0795d79df48f4f0f35d716168b7758945a6e | 622bff701628fdbad23a463b10baa4c6a6e74d38 | refs/heads/master | 2021-04-26T22:15:48.271182 | 2018-03-06T09:33:39 | 2018-03-06T09:33:39 | 124,056,508 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,111 | java | package view;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.RichPopup;
import oracle.adf.view.rich.component.rich.input.RichInputFile;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;
import oracle.adf.view.rich.component.rich.nav.RichCommandLink;
import oracle.binding.OperationBinding;
import oracle.jbo.ViewObject;
import oracle.jbo.domain.BlobDomain;
import org.apache.myfaces.trinidad.model.UploadedFile;
import weblogic.servlet.security.ServletAuthentication;
public class SearchBean {
private RichCommandLink onClick;
private RichPopup formUpdate;
private UploadedFile file;
private String fileName;
private String contentType;
private BlobDomain blob;
private RichInputText commentName;
private RichSelectOneChoice defaultInProgress;
private RichInputText stepsToReproduce;
private RichInputText additionalInformation;
private RichInputFile attachFile;
public SearchBean() {
}
public static String toLogout() throws IOException {
// Add event code here...
ExternalContext ectx =
FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
HttpSession session = (HttpSession)ectx.getSession(false);
session.invalidate();
response.sendRedirect("Login.html");
return null;
}
public void setOnClick(RichCommandLink onClick) {
this.onClick = onClick;
}
public RichCommandLink getOnClick() {
return onClick;
}
public void onLink(ActionEvent actionEvent) {
System.out.println(" on Ticket Number ");
BindingContext ctx = BindingContext.getCurrent();
DCBindingContainer bc = (DCBindingContainer)ctx.getCurrentBindingsEntry();
DCIteratorBinding iterator = bc.findIteratorBinding("TicketingtoolVO1Iterator");
ViewObject vo = iterator.getViewObject();
System.out.println("ticket id.. "+evaluateEL("#{pageFlowScope.ticketId}"));
vo.setWhereClause(" TicketingtoolEO.TICKETID = "+evaluateEL("#{pageFlowScope.ticketId}"));
if( defaultInProgress.getValue().equals("Open") || defaultInProgress.getValue().equals("New") || defaultInProgress.getValue().equals("InProgress")){
defaultInProgress.setValue("InProgress");
}
else{
defaultInProgress.setReadOnly(true);
}
vo.executeQuery();
iterator = bc.findIteratorBinding("AttachmentsRVO1Iterator");
ViewObject vo1 = iterator.getViewObject();
vo1.setWhereClause(" TICKETID = "+evaluateEL("#{pageFlowScope.ticketId}"));
vo1.executeQuery();
System.out.println(" attach count .. "+vo1.getRowCount());
iterator = bc.findIteratorBinding("CommentsVO1Iterator");
System.out.println("entering Iterator");
ViewObject vo2 = iterator.getViewObject();
vo2.setWhereClause(" CommentsEO.TICKETID =" +evaluateEL("#{pageFlowScope.ticketId}"));
System.out.println("in commentsvo1 iterator "+vo2.getQuery());
vo2.executeQuery();
System.out.println(" -=-=-=-=-=-=- ");
RichPopup.PopupHints hints = new RichPopup.PopupHints();
this.getFormUpdate().show(hints);
}
public static Object evaluateEL(String el)
{
System.out.println(" el string "+el);
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
return exp.getValue(elContext);
}
public void onPopupSubmit(ActionEvent actionEvent) {
// Add event code here...
String s1 = "Close";
DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding ob = (OperationBinding)bindings.getOperationBinding("searchSubmit");
if(defaultInProgress.getValue().equals(s1)) {
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
dateFormat.format(date);
System.out.println("date is "+date);
ob.getParamsMap().put("closeddate",date);
defaultInProgress.setReadOnly(true);
}
ob.execute();
}
public static void setEL(String el, Object val)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
exp.setValue(elContext, val);
}
public void setFormUpdate(RichPopup formUpdate) {
this.formUpdate = formUpdate;
}
public RichPopup getFormUpdate() {
return formUpdate;
}
private BlobDomain createBlobDomain(UploadedFile file) {
InputStream in = null;
BlobDomain blobDomain = null;
OutputStream out = null;
try
{
in = file.getInputStream();
blobDomain = new BlobDomain();
out = blobDomain.getBinaryOutputStream();
org.apache.commons.io.IOUtils.copy(in, out);
}
catch (IOException e)
{
e.printStackTrace();
}
catch (SQLException e)
{
e.fillInStackTrace();
}
return blobDomain;
}
public void onUpload(ValueChangeEvent valueChangeEvent) {
// Add event code here...
file = (UploadedFile)valueChangeEvent.getNewValue();
// Get the file name
fileName = file.getFilename();
System.out.println(" file name..."+fileName);
// get the mime type
contentType = file.getContentType();
System.out.println(" content type.. "+contentType);
// get blob
blob=createBlobDomain(file);
System.out.println(" blob type .."+blob);
DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding ob = (OperationBinding)bindings.getOperationBinding("updateAttachment");
ob.getParamsMap().put("ticId", evaluateEL("#{pageFlowScope.ticketId}"));
ob.getParamsMap().put("fileName", fileName);
ob.getParamsMap().put("contentType", contentType);
ob.getParamsMap().put("blob", blob);
ob.execute();
}
public void onComment(ValueChangeEvent valueChangeEvent) {
// Add event code here...
DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding ob = (OperationBinding)bindings.getOperationBinding("onPopupComments");
ob.getParamsMap().put("ticId", evaluateEL("#{pageFlowScope.ticketId}"));
ob.getParamsMap().put("comments",commentName.getValue());
ob.execute();
}
public void setCommentName(RichInputText commentName) {
this.commentName = commentName;
}
public RichInputText getCommentName() {
return commentName;
}
public void setFile(UploadedFile file) {
this.file = file;
}
public UploadedFile getFile() {
return file;
}
public void onDelete(ActionEvent actionEvent) {
// Add event code here...
BindingContext ctx = BindingContext.getCurrent();
DCBindingContainer bc = (DCBindingContainer)ctx.getCurrentBindingsEntry();
DCIteratorBinding iterator = bc.findIteratorBinding("AttachmentsRVO1Iterator");
String attid =iterator.getCurrentRow().getAttribute("AttachmentId").toString();
System.out.println(" delete attachment "+attid);
DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding ob = (OperationBinding)bindings.getOperationBinding("forDelete");
ob.getParamsMap().put("AttachId", attid);
ob.getParamsMap().put("ticId", evaluateEL("#{pageFlowScope.ticketId}"));
ob.execute();
}
public void setDefaultInProgress(RichSelectOneChoice defaultInProgress) {
this.defaultInProgress = defaultInProgress;
}
public RichSelectOneChoice getDefaultInProgress() {
return defaultInProgress;
}
public void onSearch(ActionEvent actionEvent) {
// Add event code here...
DCBindingContainer bindings =(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding ob = (OperationBinding)bindings.getOperationBinding("onSearch");
ob.execute();
}
public void setStepsToReproduce(RichInputText stepsToReproduce) {
this.stepsToReproduce = stepsToReproduce;
}
public RichInputText getStepsToReproduce() {
return stepsToReproduce;
}
public void setAdditionalInformation(RichInputText additionalInformation) {
this.additionalInformation = additionalInformation;
}
public RichInputText getAdditionalInformation() {
return additionalInformation;
}
public void setAttachFile(RichInputFile attachFile) {
this.attachFile = attachFile;
}
public RichInputFile getAttachFile() {
return attachFile;
}
public void onLogout(ActionEvent actionEvent) throws IOException {
// Add event code here...
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ectx = fc.getExternalContext();
HttpSession session = (HttpSession)ectx.getSession(false);
try {
session.invalidate();
ectx.redirect("login.html");
fc.responseComplete();
} catch (Exception exp) {
ectx.redirect("login.html");
fc.responseComplete();
}
}
public void onReset(ActionEvent actionEvent) {
// Add event code here...
System.out.println("inside reset");
BindingContext ctx = BindingContext.getCurrent();
DCBindingContainer bc = (DCBindingContainer)ctx.getCurrentBindingsEntry();
DCIteratorBinding iterator = bc.findIteratorBinding("TicketingToolTransVO1Iterator");
iterator.getViewObject().executeQuery();
}
}
| [
"36985671+pavansinghk@users.noreply.github.com"
] | 36985671+pavansinghk@users.noreply.github.com |
6caf914db4f82c6cea80ec15269250a26e9e1e6b | d490742b8eda06820ff86335b495fa22d6d05614 | /gmall-manage-service/src/main/java/com/example/service/impl/AttrServiceImpl.java | 59be687be59804b624ba42f6719a4429e39cb958 | [] | no_license | Loners451/gmall | f6c4371741bd2d924421a2eaa4f07b9e870a2ac9 | c2876684bcda93001c0700cd6daf059228855ab9 | refs/heads/master | 2022-09-17T19:01:01.164870 | 2019-11-07T12:58:30 | 2019-11-07T12:58:40 | 213,836,756 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,224 | java | package com.example.service.impl;
import com.alibaba.dubbo.config.annotation.Service;
import com.example.mapper.PmsBaseAttrInfoMapper;
import com.example.mapper.PmsBaseAttrValueMapper;
import com.example.mapper.PmsBaseSaleAttrMapper;
import com.gmall.bean.PmsBaseAttrInfo;
import com.gmall.bean.PmsBaseAttrValue;
import com.gmall.bean.PmsBaseSaleAttr;
import com.gmall.service.AttrService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author Moses
* @version 1.0
* @date 2019/10/12 10:25
*/
@Service
public class AttrServiceImpl implements AttrService {
@Autowired
PmsBaseAttrInfoMapper pmsBaseAttrInfoMapper;
@Autowired
PmsBaseAttrValueMapper pmsBaseAttrValueMapper;
@Autowired
PmsBaseSaleAttrMapper pmsBaseSaleAttrMapper;
@Override
public List<PmsBaseAttrInfo> attrInfosList(String catalog3Id) {
PmsBaseAttrInfo pmsBaseAttrInfo = new PmsBaseAttrInfo();
pmsBaseAttrInfo.setCatalog3Id(catalog3Id);
List<PmsBaseAttrInfo> pmsBaseAttrInfos = pmsBaseAttrInfoMapper.select(pmsBaseAttrInfo);
for (PmsBaseAttrInfo baseAttrInfo : pmsBaseAttrInfos) {
List<PmsBaseAttrValue> pmsBaseAttrValues = new ArrayList<>();
PmsBaseAttrValue pmsBaseAttrValue = new PmsBaseAttrValue();
pmsBaseAttrValue.setAttrId(baseAttrInfo.getId());
pmsBaseAttrValues = pmsBaseAttrValueMapper.select(pmsBaseAttrValue);
baseAttrInfo.setAttrValueList(pmsBaseAttrValues);
}
return pmsBaseAttrInfos;
}
@Override
public String saveAttrInfo(PmsBaseAttrInfo pmsBaseAttrInfo) {
String id = pmsBaseAttrInfo.getId();
if(StringUtils.isBlank(id)){
// id为空,保存
// 保存属性
pmsBaseAttrInfoMapper.insertSelective(pmsBaseAttrInfo);//insert insertSelective 是否将null插入数据库
// 保存属性值
List<PmsBaseAttrValue> attrValueList = pmsBaseAttrInfo.getAttrValueList();
for (PmsBaseAttrValue pmsBaseAttrValue : attrValueList) {
pmsBaseAttrValue.setAttrId(pmsBaseAttrInfo.getId());
pmsBaseAttrValueMapper.insertSelective(pmsBaseAttrValue);
}
}else{
// id不空,修改
// 属性修改
Example example = new Example(PmsBaseAttrInfo.class);
example.createCriteria().andEqualTo("id",pmsBaseAttrInfo.getId());
pmsBaseAttrInfoMapper.updateByExampleSelective(pmsBaseAttrInfo,example);
// 属性值修改
// 按照属性id删除所有属性值
PmsBaseAttrValue pmsBaseAttrValueDel = new PmsBaseAttrValue();
pmsBaseAttrValueDel.setAttrId(pmsBaseAttrInfo.getId());
pmsBaseAttrValueMapper.delete(pmsBaseAttrValueDel);
// 删除后,将新的属性值插入
List<PmsBaseAttrValue> attrValueList = pmsBaseAttrInfo.getAttrValueList();
for (PmsBaseAttrValue pmsBaseAttrValue : attrValueList) {
pmsBaseAttrValue.setAttrId(id);
pmsBaseAttrValueMapper.insertSelective(pmsBaseAttrValue);
}
}
return "success";
}
@Override
public List<PmsBaseAttrValue> getAttrValueList(String attrId) {
PmsBaseAttrValue pmsBaseAttrValue = new PmsBaseAttrValue();
pmsBaseAttrValue.setAttrId(attrId);
List<PmsBaseAttrValue> pmsBaseAttrValues = pmsBaseAttrValueMapper.select(pmsBaseAttrValue);
return pmsBaseAttrValues;
}
@Override
public List<PmsBaseSaleAttr> baseSaleAttrList() {
return pmsBaseSaleAttrMapper.selectAll();
}
@Override
public List<PmsBaseAttrInfo> getAttrValueListByValueId(Set<String> valueIdSet) {
String valueIdStr = StringUtils.join(valueIdSet, ",");//41,45,46
System.out.println("----->"+valueIdStr);
List<PmsBaseAttrInfo> pmsBaseAttrInfos = pmsBaseAttrInfoMapper.selectAttrValueListByValueId(valueIdStr);
return pmsBaseAttrInfos;
}
}
| [
"977036451@qq.com"
] | 977036451@qq.com |
1fab259b739f49091660af133f6e5b37e2bbb36a | 99ee3811eba3b00c8cbd18eb26fdb9baecd42eb3 | /ScrablleWordsFinder/src/pa4/ScoreTable.java | e7d342ff3177846d8c5f4ccadcaa1a483c5a52cf | [] | no_license | kavishjadwani/Scrabble-Words-Finder | 76b888426f7caf64dae01b462ad9e627a9d7f5cc | 674106293bda440932dcf14ad2b3ff3466841bb6 | refs/heads/master | 2021-05-14T14:52:43.517945 | 2018-01-02T07:54:48 | 2018-01-02T07:54:48 | 115,980,855 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,199 | java | package pa4;
public class ScoreTable {
private static final int scoreLevel1 = 1;
private static final char[] level1Chars = {'A', 'E', 'I', 'O', 'U', 'L', 'N', 'S', 'T', 'R', 'a', 'e', 'i', 'o', 'u', 'l', 'n', 's', 't', 'r'};
private static final int scoreLevel2 = 2;
private static final char[] level2Chars = {'D', 'G', 'd', 'g'};
private static final int scoreLevel3 = 3;
private static final char[] level3Chars = {'B', 'C', 'M', 'P', 'b', 'c', 'm', 'p'};
private static final int scoreLevel4 = 4;
private static final char[] level4Chars = {'F', 'H', 'V', 'W', 'Y', 'f', 'h', 'v', 'w', 'y'};
private static final int scoreLevel5 = 5;
private static final char[] level5Chars = {'K', 'k'};
private static final int scoreLevel6 = 8;
private static final char[] level6Chars = {'J', 'X', 'j', 'x'};
private static final int scoreLevel7 = 10;
private static final char[] level7Chars = {'Q', 'Z', 'q', 'z'};
private static int[] SCORE_BOARD = new int[128];
public ScoreTable() {
generateScoreTable();
}
private static void generateScoreTable() {
for (char chars : level1Chars) {
SCORE_BOARD[chars] = scoreLevel1;
}
for (char chars : level2Chars) {
SCORE_BOARD[chars] = scoreLevel2;
}
for (char chars : level3Chars) {
SCORE_BOARD[chars] = scoreLevel3;
}
for (char chars : level4Chars) {
SCORE_BOARD[chars] = scoreLevel4;
}
for (char chars : level5Chars) {
SCORE_BOARD[chars] = scoreLevel5;
}
for (char chars : level6Chars) {
SCORE_BOARD[chars] = scoreLevel6;
}
for (char chars : level7Chars) {
SCORE_BOARD[chars] = scoreLevel7;
}
}
/**
* This method calculates the score of the string and returns the score
*
* @param s the string whose score is to be calculated
* @return the score of the string
*/
public int findScoreOf(String s) {
int sum = 0;
for (int i = 0; i < s.length(); i++) {
sum += SCORE_BOARD[s.charAt(i)];
}
return sum;
}
}
| [
"33188687+kavishjadwani@users.noreply.github.com"
] | 33188687+kavishjadwani@users.noreply.github.com |
69a71cf4d27ec48997adaaf69e81d6f591d6d07a | f9ac69c35e44c4e6d46c490931484c26213e8ee0 | /src/my/gfg/doubly/linkedList/crud/DoublyLinkedList.java | e19ab753883125d6fcb84bce439b2487985a59f2 | [] | no_license | shanumnnit/DS | d12cf9baf5ca9e10292c722dc05de417ea9bfe66 | b54761cec3493da7ad3479a3b0ba5776ff3c46dc | refs/heads/master | 2020-03-22T08:41:29.246267 | 2020-01-19T06:07:14 | 2020-01-19T06:07:14 | 139,784,164 | 0 | 2 | null | 2018-07-06T21:39:29 | 2018-07-05T02:16:39 | Java | UTF-8 | Java | false | false | 2,033 | java | package my.gfg.doubly.linkedList.crud;
class Node {
int data;
Node prev;
Node next;
public Node(int data) {
super();
this.data = data;
}
}
class DoublyLinkedList {
Node head;
public void insertAtBeggining(int data) {
Node newNode = new Node(data);
if (head == null) {
head = newNode;
return;
}
newNode.next = head;
head.prev = newNode;
head = newNode;
}
public void insertAtEnd(int data) {
Node newNode = new Node(data);
if (head == null) {
head = newNode;
return;
}
Node temp = head;
while (temp.next != null) {
temp = temp.next;
}
newNode.prev = temp;
temp.next = newNode;
}
public void insertAt(int data, int offset) {
if (offset <= 0) {
insertAtBeggining(data);
return;
} else if (offset >= getLength()) {
insertAtEnd(data);
return;
}
Node newNode = new Node(data);
if (head == null) {
head = newNode;
return;
}
Node temp = head;
for (int i = 0; i < offset - 1 && temp != null; i++) {
temp = temp.next;
}
Node prev = temp.prev;
prev.next = newNode;
newNode.prev = prev;
newNode.next = temp;
temp.prev = newNode;
}
public void deleteAt(int offset) {
if (head == null)
return;
if (offset <= 0) {
Node temp = head;
head = head.next;
temp = null;
return;
}
Node temp = head;
for (int i = 0; i < offset - 1 && temp != null; i++) {
temp = temp.next;
}
temp.prev.next = temp.next;
temp.next.prev = temp.prev;
temp = null;
}
public void printList() {
if (head == null)
return;
Node temp = head;
System.out.print("Forward : ");
Node cur = temp;
while (temp != null) {
System.out.print(temp.data + " ");
cur = temp;
temp = temp.next;
}
System.out.println();
System.out.print("Backward : ");
while (cur != null) {
System.out.print(cur.data + " ");
cur = cur.prev;
}
System.out.println();
}
public int getLength() {
int length = 0;
Node temp = head;
while (temp != null) {
length++;
temp = temp.next;
}
return length;
}
}
| [
"shanu.gupta@kronos.com"
] | shanu.gupta@kronos.com |
5b9346fad82a4190fed4753e0ae490440622801b | 87404213803a1199a2382e6e883517de10e55849 | /src/MainServer/Client_interface.java | c2461f4c8256594eeee0160eb4f867d0b8598b74 | [] | no_license | sharmalakshay/fileSystem | 0fd3b5e962dc62ef8da861964f0b21b734f3319a | 9e9432993f837c1894cd5e27cbda17cfdf02572c | refs/heads/master | 2021-05-06T09:56:00.910216 | 2017-12-15T23:19:26 | 2017-12-15T23:19:26 | 114,111,468 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MainServer;
import java.rmi.*;
/**
*
* @author LSHARMA
*/
public interface Client_interface extends Remote{
/**
* Update Server IP in case of failure
* @param ip The secondary server IP
* @param port The secondary server port
* @throws RemoteException
*/
void updateServerIP(String ip,int port) throws RemoteException;
/**
* Setting authentication token for each user to identify them
* @param auth_token The the generated authentication token generated by the server
* @throws RemoteException
* */
void setAuthenticationToken(String auth_token) throws RemoteException;
/**
* Getting the authentication token that has been given before by the server
* @return String as the authentication token
* */
String getAuthenticationToken() throws RemoteException;
}
| [
"lsharma@tcd.ie"
] | lsharma@tcd.ie |
256a5cb09fd0b5f549c46ff113da40852922e870 | bfbfdb87807191e08f40a3853b000cd5d8da47d8 | /common/service/facade/src/main/java/com/xianglin/appserv/common/service/facade/model/Response.java | bf15a37caa21f9bb3acef0af2c5c5295db9a9766 | [] | no_license | 1amfine2333/appserv | df73926f5e70b8c265cc32277d8bf76af06444cc | ca33ff0f9bc3b5daf0ee32f405a2272cc4673ffa | refs/heads/master | 2021-10-10T09:59:03.114589 | 2019-01-09T05:39:20 | 2019-01-09T05:40:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,324 | java | /**
*
*/
package com.xianglin.appserv.common.service.facade.model;
import com.google.common.base.Optional;
import com.xianglin.appserv.common.service.facade.model.enums.FacadeEnums;
import com.xianglin.appserv.common.service.facade.model.enums.ResponseEnum;
import org.apache.commons.lang3.StringUtils;
import static com.xianglin.appserv.common.service.facade.model.enums.FacadeEnums.RETURN_EMPTY;
/**
* 通用服务响应结果
*
* @author pengpeng 2016年2月18日下午4:04:56
*/
public class Response<T> extends com.xianglin.gateway.common.service.facade.model.Response<T> {
public Response() {
super(null);
}
public Response(T t) {
super(t);
}
/**
* 检查响应,静态导入后可用于检查响应结果并返回响应结果
*
* @param response
* @param <T>
* @return
* @throws IllegalArgumentException 响应失败
*/
public static <T> Optional<T> checkResponse(Response<T> response) {
if (response == null) {
return Optional.absent();
}
if (!response.isSuccess()) {
throw new IllegalArgumentException(response.getTips());
}
T result = response.getResult();
return Optional.fromNullable(result);
}
/**
* 成功响应
*
* @param data
* @return
*/
public static <T> Response<T> ofSuccess(T data) {
Response<T> response = new Response<>(data);
response.setCode(1000);
return response;
}
/**
* 失败响应的工厂方法(带提示)
*
* @param message
* @return
*/
public static <T> Response<T> ofFail(String message) {
Response response = new Response<>(RETURN_EMPTY);
if (!StringUtils.isBlank(message)) {
response.setTips(message);
}
return response;
}
/**
* 失败响应的工厂方法
*
* @return
*/
public static <T> Response<T> ofFail() {
return ofFail(null);
}
public void setFacade(FacadeEnums facadeEnums) {
setResonpse(facadeEnums.code, facadeEnums.msg, facadeEnums.tip);
}
@Deprecated
public void setResonpse(ResponseEnum response) {
setResonpse(response.getCode(), response.getMemo(), response.getTips());
}
}
| [
"wangleitom@126.com"
] | wangleitom@126.com |
7842ea43dc772106a67475b86a5dd4f39285a37b | 6a6912a3b8aafb4dc7459f80cad19e1a531a180d | /src/test/java/stepdefinitions/ChoucairAcademyStepDefinitions.java | e823d22d60e323932e2829a8261a60b475967ce1 | [] | no_license | airportPickup/GuiaTecnica | c5c52e845651aedc0ff585a555ee5ce4e644b269 | 9869c9f00a6ff39597055fd0a0247f73c68b05dc | refs/heads/master | 2023-08-09T11:13:19.948314 | 2021-09-21T05:48:06 | 2021-09-21T05:48:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,563 | java | package stepdefinitions;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import model.AcademyChoucairData;
import net.serenitybdd.screenplay.GivenWhenThen;
import net.serenitybdd.screenplay.actors.OnStage;
import net.serenitybdd.screenplay.actors.OnlineCast;
import questions.Answer;
import tasks.Login;
import tasks.OpenUp;
import tasks.Search;
import java.util.List;
public class ChoucairAcademyStepDefinitions {
@Before
public void setStage(){
OnStage.setTheStage(new OnlineCast());
}
@Given("^that Rose wants to learn automation at the academy Choucair$")
public void thatRoseWantsToLearnAutomationAtTheAcademyChoucair(List<AcademyChoucairData> academyChoucairData) {
OnStage.theActorCalled("Rose").wasAbleTo(OpenUp.thePage(),(Login.onThePage(academyChoucairData.get(0).getStrUser(),academyChoucairData.get(0).getStrPassword())));
}
@When("^she search for the course on the Choucair academy platform$")
public void sheSearchForTheCourseOnTheChoucairAcademyPlatform(List<AcademyChoucairData> academyChoucairData) {
OnStage.theActorInTheSpotlight().attemptsTo(Search.the(academyChoucairData.get(0).getStrCourse()));
}
@Then("^she finds the course called$")
public void sheFindsTheCourseCalled(List<AcademyChoucairData> academyChoucairData)throws Exception {
OnStage.theActorInTheSpotlight().should(GivenWhenThen.seeThat(Answer.toThe(academyChoucairData.get(0).getStrCourse())));
}
}
| [
"dianamilena1699@gmail.com"
] | dianamilena1699@gmail.com |
bbbdcaa2a9ac93bd4b94f77d9106d15349f5c6ad | dab8a140d34cecf19b79da22b80181b44304189b | /Android引导页/CircleIndicator/app/src/androidTest/java/com/example/li/circleindicator/ApplicationTest.java | b072d9a1019db9ad6c66eabcc60a03560b1901b6 | [] | no_license | lichengxin/AndroidLocalDemo | 29d5a38b911f057e390997e8dfc86a293f99c187 | 4422d593c7488654c568700a1c2ef3e5b679d796 | refs/heads/master | 2021-01-19T02:23:37.675790 | 2016-07-14T09:39:35 | 2016-07-14T09:39:35 | 63,297,404 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package com.example.li.circleindicator;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"lichengxin@renqidai.cc"
] | lichengxin@renqidai.cc |
0dee03af038be9a85c69388fa44c2ab9b0d8b9d1 | 46639889543315094ad36e493f014f3641eb31f6 | /JstxCore/src/main/java/co/q64/jstx/compression/lzma/LZMACompressor.java | acf2317939cd084137fb4aec5b55fcc51a700f79 | [] | no_license | richax/Jstx | b7809c680a6e5490ee8739867fa95d1356826ba0 | 699e45c9b30ecd1190bee3bbcdc0899669c54748 | refs/heads/master | 2023-03-15T16:45:38.709196 | 2018-04-12T03:42:44 | 2018-04-12T03:42:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,349 | java |
package co.q64.jstx.compression.lzma;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import co.q64.jstx.compression.lzma.impl.lzm.Chunker;
import co.q64.jstx.compression.lzma.impl.lzm.Encoder;
/**
* LZMA compressor.
*/
public class LZMACompressor {
/**
* The default compression mode ({@code 3}).
*/
public static final CompressionMode DEFAULT_COMPRESSION_MODE = CompressionMode.MODE_3;
private Chunker chunker;
private long length;
private IOException exception;
/**
* Construct an encoder with unknown input length and using the {@link #DEFAULT_COMPRESSION_MODE default compression mode}.
*
* <p>
* This is a convenience constructor, equivalent to:
* <blockquote>
* <code>LZMACompressor(input, output, -1, DEFAULT_COMPRESSION_MODE)</code>
* </blockquote>
*/
public LZMACompressor(InputStream input, OutputStream output) throws IOException {
this(input, output, -1, DEFAULT_COMPRESSION_MODE);
}
/**
* Construct an encoder with unknown using the {@link #DEFAULT_COMPRESSION_MODE default compression mode}.
*
* <p>
* This is a convenience constructor, equivalent to:
* <blockquote>
* <code>LZMACompressor(input, output, length, DEFAULT_COMPRESSION_MODE)</code>
* </blockquote>
*/
public LZMACompressor(InputStream input, OutputStream output, long length) throws IOException {
this(input, output, -1, DEFAULT_COMPRESSION_MODE);
}
/**
* Primary constructor.
*
* <p>
* The given {@code length} limits how much data will be read from the input and
* will be encoded at the beginning of the compressed output. This allows decompressors
* to determine the uncompressed length without having to decompress the entire content,
* and causes the decompressor to stop decompressing at that point. If the length is not
* known, {@code -1} should be used.
*
* <p>
* The input and output streams will <em>not</em> be closed when the operation completes.
*
* @param input uncompressed input
* @param output compressed output
* @param length length of the input data if known, otherwise {@code -1}
* @param mode compression mode
* @throws IllegalArgumentException if {@code length} is less than {@code -1}
* @throws IllegalArgumentException if {@code mode} is null
* @throws IOException if {@code input} or {@code output} does
*/
protected LZMACompressor(InputStream input, OutputStream output, long length, CompressionMode mode) throws IOException {
init(input, output, length, mode);
}
LZMACompressor() {}
void init(InputStream input, OutputStream output, long length, CompressionMode mode) throws IOException {
if (mode == null)
throw new IllegalArgumentException("null mode");
if (length < -1)
throw new IllegalArgumentException("invalid length " + length);
this.length = length;
Encoder encoder = new Encoder();
mode.configure(encoder);
encoder.SetEndMarkerMode(true);
encoder.WriteCoderProperties(output);
for (int i = 0; i < 64; i += 8)
output.write((int) (length >> i) & 0xff);
this.chunker = encoder.CodeInChunks(input, output, length, -1);
while (execute()) {}
}
/**
* Process the next chunk of data. If an {@link IOException} is thrown during processing,
* this returns {@code false} and {@link #getException} will return the caught exception.
*
* @return {@code true} if there is more work to do, otherwise {@code false}
* @throws IllegalStateException if this compression operation has already completed
*/
public boolean execute() {
try {
return this.chunker.processChunk();
} catch (IOException e) {
this.exception = e;
return false;
}
}
/**
* Determine how much of the input data has been compressed so far.
* If a length of {@code -1} was given to the constructor, then this always returns zero.
*
* @return a value from 0.0 to 1.0
*/
public double getProgress() {
if (this.length == -1)
return 0.0;
return (double) this.chunker.getInBytesProcessed() / (double) this.length;
}
/**
* Get the exception thrown during the previous execution round, if any.
* <b>Note:</b> this method must be checked after compression is complete to determine
* if there was an error.
*
* @return thrown exception, or {@code null} if none was ever thrown
*/
public IOException getException() {
return this.exception;
}
}
| [
"Quantum64Development@gmail.com"
] | Quantum64Development@gmail.com |
3cb36f771ffaeecf7059a12a68774de8db355a59 | f9a5c9a6d9c92bfedbf5bf16492711952bcf60cc | /bundles/csvdir/tags/org.connid.bundles.csvdir-0.4/src/test/java/org/connid/bundles/csvdir/CSVDirConnectorCreateTests.java | 8a2048d8d29921d6c0069bfbf68ecaad603cba68 | [] | no_license | ilgrosso/oldConnId | 0caf26b32c84e0a053bc4087f46610c7ff9317fb | cabaf3590663eadab8f2bca361e8c07b929d357c | refs/heads/master | 2021-01-25T03:48:22.903438 | 2015-03-16T07:51:48 | 2015-03-16T07:51:48 | 32,308,774 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,567 | java | /*
* ====================
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 Tirasa. All rights reserved.
*
* The contents of this file are subject to the terms of the Common Development
* and Distribution License("CDDL") (the "License"). You may not use this file
* except in compliance with the License.
*
* You can obtain a copy of the License at
* https://connid.googlecode.com/svn/base/trunk/legal/license.txt
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing the Covered Code, include this
* CDDL Header Notice in each file
* and include the License file at identityconnectors/legal/license.txt.
* If applicable, add the following below this CDDL Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
* ====================
*/
package org.connid.bundles.csvdir;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.identityconnectors.common.security.GuardedString;
import org.identityconnectors.framework.api.APIConfiguration;
import org.identityconnectors.framework.api.ConnectorFacade;
import org.identityconnectors.framework.api.ConnectorFacadeFactory;
import org.identityconnectors.framework.common.exceptions.ConnectorException;
import org.identityconnectors.framework.common.objects.Attribute;
import org.identityconnectors.framework.common.objects.AttributeBuilder;
import org.identityconnectors.framework.common.objects.AttributeUtil;
import org.identityconnectors.framework.common.objects.ConnectorObject;
import org.identityconnectors.framework.common.objects.Name;
import org.identityconnectors.framework.common.objects.ObjectClass;
import org.identityconnectors.framework.common.objects.OperationalAttributes;
import org.identityconnectors.framework.common.objects.Uid;
import org.identityconnectors.test.common.TestHelpers;
import org.junit.Assert;
import org.junit.Test;
public class CSVDirConnectorCreateTests extends AbstractTest {
@Test
public final void createTest()
throws IOException {
createFile("createAccountTest", Collections.EMPTY_SET);
final CSVDirConnector connector = new CSVDirConnector();
connector.init(createConfiguration("createAccountTest.*\\.csv"));
Name name = new Name("___mperro123;pmassi");
Uid newAccount = connector.create(
ObjectClass.ACCOUNT, createSetOfAttributes(name), null);
Assert.assertEquals(name.getNameValue(), newAccount.getUidValue());
// --------------------------------
// check creation result
// --------------------------------
final ConnectorFacadeFactory factory =
ConnectorFacadeFactory.getInstance();
final APIConfiguration impl = TestHelpers.createTestConfiguration(
CSVDirConnector.class,
createConfiguration("createAccountTest.*\\.csv"));
final ConnectorFacade facade = factory.newInstance(impl);
final ConnectorObject object =
facade.getObject(ObjectClass.ACCOUNT, newAccount, null);
Assert.assertNotNull(object);
final Attribute password = AttributeUtil.find(
OperationalAttributes.PASSWORD_NAME, object.getAttributes());
Assert.assertNotNull(password.getValue().get(0));
((GuardedString) password.getValue().get(0)).access(
new GuardedString.Accessor() {
@Override
public void access(char[] clearChars) {
Assert.assertEquals("password", new String(clearChars));
}
});
// --------------------------------
final Uid uid = connector.authenticate(
ObjectClass.ACCOUNT,
"___mperro123;pmassi",
new GuardedString("password".toCharArray()),
null);
Assert.assertNotNull(uid);
connector.dispose();
}
private Set<Attribute> createSetOfAttributes(Name name) {
Set<Attribute> attributes = new HashSet<Attribute>();
attributes.add(name);
attributes.add(AttributeBuilder.build(TestAccountsValue.ACCOUNTID,
"___mperro123"));
attributes.add(AttributeBuilder.build(TestAccountsValue.FIRSTNAME,
"pmassi"));
attributes.add(AttributeBuilder.build(TestAccountsValue.LASTNAME,
"mperrone"));
attributes.add(AttributeBuilder.build(TestAccountsValue.EMAIL,
"massimiliano.perrone@test.it"));
attributes.add(AttributeBuilder.build(TestAccountsValue.CHANGE_NUMBER,
"0"));
attributes.add(AttributeBuilder.build(TestAccountsValue.PASSWORD,
"password"));
attributes.add(AttributeBuilder.build(TestAccountsValue.DELETED, "no"));
return attributes;
}
@Test(expected = ConnectorException.class)
public final void createExistingUserTest()
throws IOException {
createFile("sample", TestAccountsValue.TEST_ACCOUNTS);
final CSVDirConnector connector = new CSVDirConnector();
connector.init(createConfiguration("sample.*\\.csv"));
Name name = new Name("____jpc4323435;jPenelope");
connector.create(
ObjectClass.ACCOUNT, createSetOfAttributes(name), null);
connector.dispose();
}
}
| [
"chicchiricco@gmail.com@22724a10-ea78-6fbf-fdf7-017d9d74b811"
] | chicchiricco@gmail.com@22724a10-ea78-6fbf-fdf7-017d9d74b811 |
999c52c52fa73e910603d589d1e4049568daa448 | 954c85a2b12118d924ca7c4ec63dadc90cd89402 | /src/ru/fizteh/fivt/students/pavel_voropaev/multifilehashmap/commands/Get.java | 69f08c7f50d1e0069a501cb18587a579a17bea92 | [
"BSD-2-Clause"
] | permissive | ValentineLebedeva/fizteh-java-2014 | 6c5195070e29620f360c84a8f7a18c5ca32a5277 | 0b7d833e7161ab64baf13fbf92e5e3f254cbecf3 | refs/heads/master | 2021-01-18T01:05:32.938575 | 2014-12-23T18:23:33 | 2014-12-23T18:23:33 | 27,333,917 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 868 | java | package ru.fizteh.fivt.students.pavel_voropaev.multifilehashmap.commands;
import ru.fizteh.fivt.students.pavel_voropaev.multifilehashmap.*;
public final class Get {
private static int argNum = 2;
private static String name = "get";
private static String usage = "Usage: get <key>";
public static void exec(MultiFileTable db, String[] param) throws IllegalArgumentException, IllegalStateException {
if (param.length > argNum) {
ThrowExc.tooManyArg(name, usage);
}
if (param.length < argNum) {
ThrowExc.notEnoughArg(name, usage);
}
if (db == null) {
ThrowExc.noTable();
}
String tmp = db.get(param[1]);
if (tmp == null) {
System.out.println("not found");
} else {
System.out.println(tmp);
}
}
}
| [
"viavia@ro.ru"
] | viavia@ro.ru |
b398dc1473abae8e3ee85b8aedd8a8afcbffeab6 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /drjava_cluster/11612/src_1.java | 23e9502b473372112ea57c2a1a308a90ef1be607 | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 28,412 | java | /*BEGIN_COPYRIGHT_BLOCK
*
* This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
* or http://sourceforge.net/projects/drjava/
*
* DrJava Open Source License
*
* Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
*
* Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal with 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:
*
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimers.
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimers in the documentation and/or other materials provided with the distribution.
* - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
* endorse or promote products derived from this Software without specific prior written permission.
* - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
* names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
*
* 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
* CONTRIBUTORS 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
* WITH THE SOFTWARE.
*
END_COPYRIGHT_BLOCK*/
package edu.rice.cs.drjava.model;
import javax.swing.text.BadLocationException;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import javax.swing.SwingUtilities;
import edu.rice.cs.util.ClassPathVector;
import edu.rice.cs.util.FileOpenSelector;
import edu.rice.cs.drjava.model.FileSaveSelector;
import edu.rice.cs.util.FileOps;
import edu.rice.cs.util.OperationCanceledException;
import edu.rice.cs.util.UnexpectedException;
import edu.rice.cs.util.newjvm.AbstractMasterJVM;
import edu.rice.cs.util.text.EditDocumentException;
import edu.rice.cs.util.swing.Utilities;
import edu.rice.cs.drjava.DrJava;
import edu.rice.cs.drjava.config.OptionConstants;
import edu.rice.cs.drjava.config.OptionEvent;
import edu.rice.cs.drjava.config.OptionListener;
import edu.rice.cs.drjava.model.definitions.ClassNameNotFoundException;
import edu.rice.cs.drjava.model.definitions.DefinitionsDocument;
import edu.rice.cs.drjava.model.definitions.InvalidPackageException;
import edu.rice.cs.drjava.model.debug.Breakpoint;
import edu.rice.cs.drjava.model.debug.Debugger;
import edu.rice.cs.drjava.model.debug.DebugException;
import edu.rice.cs.drjava.model.debug.JPDADebugger;
import edu.rice.cs.drjava.model.debug.NoDebuggerAvailable;
import edu.rice.cs.drjava.model.debug.DebugListener;
import edu.rice.cs.drjava.model.debug.DebugWatchData;
import edu.rice.cs.drjava.model.debug.DebugThreadData;
import edu.rice.cs.drjava.model.repl.DefaultInteractionsModel;
import edu.rice.cs.drjava.model.repl.DummyInteractionsListener;
import edu.rice.cs.drjava.model.repl.InteractionsDocument;
import edu.rice.cs.drjava.model.repl.InteractionsDJDocument;
import edu.rice.cs.drjava.model.repl.InteractionsListener;
import edu.rice.cs.drjava.model.repl.InteractionsScriptModel;
import edu.rice.cs.drjava.model.repl.newjvm.MainJVM;
import edu.rice.cs.drjava.model.compiler.CompilerListener;
import edu.rice.cs.drjava.model.compiler.CompilerModel;
import edu.rice.cs.drjava.model.compiler.DefaultCompilerModel;
import edu.rice.cs.drjava.model.junit.DefaultJUnitModel;
import edu.rice.cs.drjava.model.junit.JUnitModel;
import java.io.*;
/** Handles the bulk of DrJava's program logic. The UI components interface with the GlobalModel through its public
* methods, and teh GlobalModel responds via the GlobalModelListener interface. This removes the dependency on the
* UI for the logical flow of the program's features. With the current implementation, we can finally test the compile
* functionality of DrJava, along with many other things. <p>
* @version $Id$
*/
public class DefaultGlobalModel extends AbstractGlobalModel {
/* FIELDS */
/* Interpreter fields */
/** The document used in the Interactions model. */
protected final InteractionsDJDocument _interactionsDocument;
/** RMI interface to the Interactions JVM. */
final MainJVM _jvm;
/** Interface between the InteractionsDocument and the JavaInterpreter, which runs in a separate JVM. */
protected final DefaultInteractionsModel _interactionsModel;
/** Core listener attached to interactions model */
protected InteractionsListener _interactionsListener = new InteractionsListener() {
public void interactionStarted() { }
public void interactionEnded() { }
public void interactionErrorOccurred(int offset, int length) { }
public void interpreterResetting() { }
public void interpreterReady(File wd) {
File buildDir = _state.getBuildDirectory();
if (buildDir != null) {
// System.out.println("adding for reset: " + _state.getBuildDirectory().getAbsolutePath());
try {
_jvm.addBuildDirectoryClassPath(new File(buildDir.getAbsolutePath()).toURL());
} catch(MalformedURLException murle) {
// edit this later! this is bad! we should handle this exception better!
throw new RuntimeException(murle);
}
}
}
public void interpreterResetFailed(Throwable t) { }
public void interpreterExited(int status) { }
public void interpreterChanged(boolean inProgress) { }
public void interactionIncomplete() { }
public void slaveJVMUsed() { }
};
private CompilerListener _clearInteractionsListener =
new CompilerListener() {
public void compileStarted() { }
public void compileEnded(File workDir, File[] excludedFiles) {
// Only clear interactions if there were no errors and unit testing is not in progress
if ( ((_compilerModel.getNumErrors() == 0) || (_compilerModel.getCompilerErrorModel().hasOnlyWarnings()))
&& ! _junitModel.isTestInProgress() && _resetAfterCompile) {
resetInteractions(workDir); // use same working directory as current interpreter
}
}
public void saveBeforeCompile() { }
public void saveUntitled() { }
};
// ---- Compiler Fields ----
/** CompilerModel manages all compiler functionality. */
private final CompilerModel _compilerModel;
/** Whether or not to reset the interactions JVM after compiling. Should only be false in test cases. */
private volatile boolean _resetAfterCompile = true;
/* JUnit Fields */
/** JUnitModel manages all JUnit functionality. */
private final DefaultJUnitModel _junitModel;
/* Javadoc Fields */
/** Manages all Javadoc functionality. */
protected final JavadocModel _javadocModel;
/* Debugger Fields */
/** Interface to the integrated debugger. If unavailable, set NoDebuggerAvailable.ONLY. */
private volatile Debugger _debugger = NoDebuggerAvailable.ONLY;
/* CONSTRUCTORS */
/** Constructs a new GlobalModel. Creates a new MainJVM and starts its Interpreter JVM. */
public DefaultGlobalModel() {
super();
AbstractMasterJVM._log.log(this + " has called contstructor for DefaultGlobal Model");
// Utilities.show("DefaultGlobalModel super call performed");
_jvm = new MainJVM(getWorkingDirectory());
AbstractMasterJVM._log.log(this + " has created a new MainJVM");
_compilerModel = new DefaultCompilerModel(this);
_junitModel = new DefaultJUnitModel(_jvm, _compilerModel, this);
_javadocModel = new DefaultJavadocModel(this);
_interactionsDocument = new InteractionsDJDocument();
_interactionsModel = new DefaultInteractionsModel(this, _jvm, _interactionsDocument, getWorkingDirectory());
_interactionsModel.addListener(_interactionsListener);
_jvm.setInteractionsModel(_interactionsModel);
_jvm.setJUnitModel(_junitModel);
_jvm.setOptionArgs(DrJava.getConfig().getSetting(SLAVE_JVM_ARGS));
DrJava.getConfig().addOptionListener(SLAVE_JVM_ARGS, new OptionListener<String>() {
public void optionChanged(OptionEvent<String> oe) { _jvm.setOptionArgs(oe.value); }
});
_createDebugger();
// Chain notifiers so that all events also go to GlobalModelListeners.
_interactionsModel.addListener(_notifier);
_compilerModel.addListener(_notifier);
_junitModel.addListener(_notifier);
_javadocModel.addListener(_notifier);
// Listen to compiler to clear interactions appropriately.
// XXX: The tests need this to be registered after _notifier, sadly.
// This is obnoxiously order-dependent, but it works for now.
_compilerModel.addListener(_clearInteractionsListener);
// Note: starting the JVM in another thread does not appear to improve performance
// AbstractMasterJVM._log.log("Starting the interpreter in " + this);
_jvm.startInterpreterJVM();
// Any lightweight parsing has been disabled until we have something that is beneficial and works better in the background.
// _parsingControl = new DefaultLightWeightParsingControl(this);
}
// public void compileAll() throws IOException{
//// ScrollableDialog sd = new ScrollableDialog(null, "DefaultGlobalModel.compileAll() called", "", "");
//// sd.show();
// _state.compileAll();
// }
// public void junitAll() { _state.junitAll(); }
/** Sets the build directory for a project. */
public void setBuildDirectory(File f) {
_state.setBuildDirectory(f);
if (f != null) {
// System.out.println("adding: " + f.getAbsolutePath());
try {
_jvm.addBuildDirectoryClassPath(new File(f.getAbsolutePath()).toURL());
}
catch(MalformedURLException murle) {
// TODO! change this! we should handle this exception better!
// show a popup like "invalide build directory" or something
throw new RuntimeException(murle);
}
}
_notifier.projectBuildDirChanged();
setProjectChanged(true);
setClassPathChanged(true);
}
// ----- METHODS -----
/** @return the interactions model. */
public DefaultInteractionsModel getInteractionsModel() { return _interactionsModel; }
/** @return InteractionsDJDocument in use by the InteractionsDocument. */
public InteractionsDJDocument getSwingInteractionsDocument() { return _interactionsDocument; }
public InteractionsDocument getInteractionsDocument() { return _interactionsModel.getDocument(); }
/** Gets the CompilerModel, which provides all methods relating to compilers. */
public CompilerModel getCompilerModel() { return _compilerModel; }
/** Gets the JUnitModel, which provides all methods relating to JUnit testing. */
public JUnitModel getJUnitModel() { return _junitModel; }
/** Gets the JavadocModel, which provides all methods relating to Javadoc. */
public JavadocModel getJavadocModel() { return _javadocModel; }
/** Prepares this model to be thrown away. Never called in practice outside of quit(), except in tests. */
public void dispose() {
// Kill the interpreter
_jvm.killInterpreter(null);
try { _jvm.dispose(); }
catch(RemoteException e) { /* ignore */ }
super.dispose();
}
/** Disposes of external resources. Kills the slave JVM. */
public void disposeExternalResources() {
// Kill the interpreter
_jvm.killInterpreter(null);
}
public void resetInteractions(File wd) { resetInteractions(wd, false); }
/** Clears and resets the slave JVM with working directory wd. Also clears the console if the option is
* indicated (on by default). The reset operation is suppressed if the existing slave JVM has not been
* used, {@code wd} matches its working directory, and forceResest is false.
*/
public void resetInteractions(File wd, boolean forceReset) {
// Utilities.show("resetInteractions called");
if (! forceReset && ! _jvm.slaveJVMUsed() && ! isClassPathChanged() &&
wd.equals(_interactionsModel.getWorkingDirectory())) {
// Eliminate resetting interpreter (slaveJVM) since it has already been reset appropriately.
// Utilities.show("Suppressing resetting of interactions pane");
_interactionsModel._notifyInterpreterReady(wd);
// Utilities.show("_notifyInterpreterReady called");
return;
}
// Utilities.show("Resetting interactions with working directory = " + wd);
// update the setting
DrJava.getConfig().setSetting(LAST_INTERACTIONS_DIRECTORY, wd);
_interactionsModel.resetInterpreter(wd);
}
/** Interprets the current given text at the prompt in the interactions pane. */
public void interpretCurrentInteraction() { _interactionsModel.interpretCurrentInteraction(); }
/** Interprets file selected in the FileOpenSelector. Assumes strings have no trailing whitespace. Interpretation is
* aborted after the first error.
*/
public void loadHistory(FileOpenSelector selector) throws IOException { _interactionsModel.loadHistory(selector); }
/** Loads the history/histories from the given selector. */
public InteractionsScriptModel loadHistoryAsScript(FileOpenSelector selector)
throws IOException, OperationCanceledException {
return _interactionsModel.loadHistoryAsScript(selector);
}
/** Clears the interactions history */
public void clearHistory() { _interactionsModel.getDocument().clearHistory(); }
/** Saves the unedited version of the current history to a file
* @param selector File to save to
*/
public void saveHistory(FileSaveSelector selector) throws IOException {
_interactionsModel.getDocument().saveHistory(selector);
}
/** Saves the edited version of the current history to a file
* @param selector File to save to
* @param editedVersion Edited verison of the history which will be saved to file instead of the lines saved in
* the history. The saved file will still include any tags needed to recognize it as a history file.
*/
public void saveHistory(FileSaveSelector selector, String editedVersion) throws IOException {
_interactionsModel.getDocument().saveHistory(selector, editedVersion);
}
/** Returns the entire history as a String with semicolons as needed. */
public String getHistoryAsStringWithSemicolons() {
return _interactionsModel.getDocument().getHistoryAsStringWithSemicolons();
}
/** Returns the entire history as a String. */
public String getHistoryAsString() {
return _interactionsModel.getDocument().getHistoryAsString();
}
/** Called when the debugger wants to print a message. Inserts a newline. */
public void printDebugMessage(String s) {
_interactionsModel.getDocument().
insertBeforeLastPrompt(s + "\n", InteractionsDocument.DEBUGGER_STYLE);
}
/** Blocks until the interpreter has registered. */
public void waitForInterpreter() { _jvm.ensureInterpreterConnected(); }
/** Returns the current classpath in use by the Interpreter JVM. */
public ClassPathVector getClassPath() { return _jvm.getClassPath(); }
/** Sets whether or not the Interactions JVM will be reset after a compilation succeeds. This should ONLY be used
* in tests! This method is not supported by AbstractGlobalModel.
* @param shouldReset Whether to reset after compiling
*/
void setResetAfterCompile(boolean shouldReset) { _resetAfterCompile = shouldReset; }
/** Gets the Debugger used by DrJava. */
public Debugger getDebugger() { return _debugger; }
/** Returns an available port number to use for debugging the interactions JVM.
* @throws IOException if unable to get a valid port number.
*/
public int getDebugPort() throws IOException { return _interactionsModel.getDebugPort(); }
// ---------- ConcreteOpenDefDoc inner class ----------
/** Inner class to handle operations on each of the open DefinitionsDocuments by the GlobalModel. <br><br>
* This was at one time called the <code>DefinitionsDocumentHandler</code>
* but was renamed (2004-Jun-8) to be more descriptive/intuitive.
*/
class ConcreteOpenDefDoc extends AbstractGlobalModel.ConcreteOpenDefDoc {
/** Standard constructor for a document read from a file. Initializes this ODD's DD.
* @param f file describing DefinitionsDocument to manage
*/
ConcreteOpenDefDoc(File f) throws IOException { super(f); }
/* Standard constructor for a new document (no associated file) */
ConcreteOpenDefDoc() { super(); }
/** Starting compiling this document. Used only for unit testing */
public void startCompile() throws IOException { _compilerModel.compile(ConcreteOpenDefDoc.this); }
private volatile InteractionsListener _runMain;
/** Runs the main method in this document in the interactions pane after resetting interactions with the source
* root for this document as the working directory. Warns the use if the class files for the doucment are not
* up to date. Fires an event to signal when execution is about to begin.
* NOTE: this code normally runs in the event thread; it cannot block waiting for an event that is triggered by
* event thread execution!
* @exception ClassNameNotFoundException propagated from getFirstTopLevelClass()
* @exception IOException propagated from GlobalModel.compileAll()
*/
public void runMain() throws ClassNameNotFoundException, IOException {
// Get the class name for this document, the first top level class in the document.
final String className = getDocument().getQualifiedClassName();
final InteractionsDocument iDoc = _interactionsModel.getDocument();
if (! checkIfClassFileInSync()) {
iDoc.insertBeforeLastPrompt(DOCUMENT_OUT_OF_SYNC_MSG, InteractionsDocument.ERROR_STYLE);
return;
}
final boolean wasDebuggerEnabled = getDebugger().isReady();
_runMain = new DummyInteractionsListener() {
public void interpreterReady(File wd) {
// Restart debugger if it was previously enabled and is now off
if (wasDebuggerEnabled && (! getDebugger().isReady())) {
try { getDebugger().startup(); } catch(DebugException de) { /* ignore, continue without debugger */ }
}
// Load the proper text into the interactions document
iDoc.clearCurrentInput();
iDoc.append("java " + className, null);
// Finally, execute the new interaction and record that event
_interactionsModel.interpretCurrentInteraction();
_notifier.runStarted(ConcreteOpenDefDoc.this);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
/* Remove _runMain listener AFTER this interpreterReady listener completes and DROPS it acquireReadLock on
* _interactionsModel._notifier. */
_interactionsModel.removeListener(_runMain);
}
});
}
};
_interactionsModel.addListener(_runMain);
File workDir;
if (isProjectActive()) workDir = getWorkingDirectory(); // use working directory for project
else workDir = getSourceRoot(); // use source root of current document
// Reset interactions to the soure root for this document; class will be executed when new interpreter is ready
resetInteractions(workDir);
}
/** Runs JUnit on the current document. Requires that all source documents are compiled before proceeding. */
public void startJUnit() throws ClassNotFoundException, IOException { _junitModel.junit(this); }
/** Generates Javadoc for this document, saving the output to a temporary
* directory. The location is provided to the javadocEnded event on
* the given listener.
* @param saver FileSaveSelector for saving the file if it needs to be saved
*/
public void generateJavadoc(FileSaveSelector saver) throws IOException {
// Use the model's classpath, and use the EventNotifier as the listener
_javadocModel.javadocDocument(this, saver, getClassPath().toString());
}
/** Called to indicate the document is being closed, so to remove all related state from the debug manager. */
public void removeFromDebugger() {
while (getBreakpointManager().getRegions().size() > 0) {
Breakpoint bp = getBreakpointManager().getRegions().get(0);
getBreakpointManager().removeRegion(bp);
}
}
} /* End of ConcreteOpenDefDoc */
/** Creates a ConcreteOpenDefDoc for a new DefinitionsDocument.
* @return OpenDefinitionsDocument object for a new document
*/
protected ConcreteOpenDefDoc _createOpenDefinitionsDocument() { return new ConcreteOpenDefDoc(); }
/** Creates a ConcreteOpenDefDoc for a given file f
* @return OpenDefinitionsDocument object for f
*/
protected ConcreteOpenDefDoc _createOpenDefinitionsDocument(File f) throws IOException { return new ConcreteOpenDefDoc(f); }
/** Adds the source root for doc to the interactions classpath; this function is a helper to _openFiles.
* @param doc the document to add to the classpath
*/
protected void addDocToClassPath(OpenDefinitionsDocument doc) {
try {
File classPath = doc.getSourceRoot();
try {
if (doc.isAuxiliaryFile())
_interactionsModel.addProjectFilesClassPath(classPath.toURL());
else _interactionsModel.addExternalFilesClassPath(classPath.toURL());
setClassPathChanged(true);
}
catch(MalformedURLException murle) { /* fail silently */ }
}
catch (InvalidPackageException e) {
// Invalid package-- don't add it to classpath
}
}
/** Instantiates the integrated debugger if the "debugger.enabled" config option is set to true. Leaves it
* at null if not.
*/
private void _createDebugger() {
try {
_debugger = new JPDADebugger(this);
_jvm.setDebugModel((JPDADebugger) _debugger);
// add listener to set the project file to "changed" when a breakpoint or watch is added, removed, or changed
getBreakpointManager().addListener(new RegionManagerListener<Breakpoint>() {
public void regionAdded(final Breakpoint bp, int index) { setProjectChanged(true); }
public void regionChanged(final Breakpoint bp, int index) { setProjectChanged(true); }
public void regionRemoved(final Breakpoint bp) {
try {
getDebugger().removeBreakpoint(bp);
} catch(DebugException de) { /* just ignore it */ }
setProjectChanged(true);
}
});
getBookmarkManager().addListener(new RegionManagerListener<DocumentRegion>() {
public void regionAdded(DocumentRegion r, int index) { setProjectChanged(true); }
public void regionChanged(DocumentRegion r, int index) { setProjectChanged(true); }
public void regionRemoved(DocumentRegion r) { setProjectChanged(true); }
});
_debugger.addListener(new DebugListener() {
public void watchSet(final DebugWatchData w) { setProjectChanged(true); }
public void watchRemoved(final DebugWatchData w) { setProjectChanged(true); }
public void regionAdded(final Breakpoint bp, int index) { }
public void regionChanged(final Breakpoint bp, int index) { }
public void regionRemoved(final Breakpoint bp) { }
public void debuggerStarted() { }
public void debuggerShutdown() { }
public void threadLocationUpdated(OpenDefinitionsDocument doc, int lineNumber, boolean shouldHighlight) { }
public void breakpointReached(final Breakpoint bp) { }
public void stepRequested() { }
public void currThreadSuspended() { }
public void currThreadResumed() { }
public void threadStarted() { }
public void currThreadDied() { }
public void nonCurrThreadDied() { }
public void currThreadSet(DebugThreadData thread) { }
});
}
catch( NoClassDefFoundError ncdfe ) {
// JPDA not available, so we won't use it.
_debugger = NoDebuggerAvailable.ONLY;
}
catch( UnsupportedClassVersionError ucve ) {
// Wrong version of JPDA, so we won't use it.
_debugger = NoDebuggerAvailable.ONLY;
}
catch( Throwable t ) {
// Something went wrong in initialization, don't use debugger
_debugger = NoDebuggerAvailable.ONLY;
}
}
/** Adds the project root (if a project is open), the source roots for other open documents, the paths in the
* "extra classpath" config option, as well as any project-specific classpaths to the interpreter's classpath.
* This method is called in DefaultInteractionsModel when the interpreter becomes ready.
*/
public void resetInteractionsClassPath() {
ClassPathVector projectExtras = getExtraClassPath();
//System.out.println("Adding project classpath vector to interactions classpath: " + projectExtras);
if (projectExtras != null) for (URL cpE : projectExtras) { _interactionsModel.addProjectClassPath(cpE); }
Vector<File> cp = DrJava.getConfig().getSetting(EXTRA_CLASSPATH);
if (cp != null) {
for (File f : cp) {
try { _interactionsModel.addExtraClassPath(f.toURL()); }
catch(MalformedURLException murle) {
System.out.println("File " + f + " in your extra classpath could not be parsed to a URL; " +
"it may contain un-URL-encodable characters.");
}
}
}
for (OpenDefinitionsDocument odd: getAuxiliaryDocuments()) {
// this forwards directly to InterpreterJVM.addClassPath(String)
try { _interactionsModel.addProjectFilesClassPath(odd.getSourceRoot().toURL()); }
catch(MalformedURLException murle) { /* fail silently */ }
catch(InvalidPackageException e) { /* ignore it */ }
}
for (OpenDefinitionsDocument odd: getNonProjectDocuments()) {
// this forwards directly to InterpreterJVM.addClassPath(String)
try {
File sourceRoot = odd.getSourceRoot();
if (sourceRoot != null) _interactionsModel.addExternalFilesClassPath(sourceRoot.toURL());
}
catch(MalformedURLException murle) { /* ignore it */ }
catch(InvalidPackageException e) { /* ignore it */ }
}
// add project source root to projectFilesClassPath. All files in project tree have this root.
try { _interactionsModel.addProjectFilesClassPath(getProjectRoot().toURL()); }
catch(MalformedURLException murle) { /* fail silently */ }
setClassPathChanged(false); // reset classPathChanged state
}
// private class ExtraClasspathOptionListener implements OptionListener<Vector<File>> {
// public void optionChanged (OptionEvent<Vector<File>> oce) {
// Vector<File> cp = oce.value;
// if (cp != null) {
// for (File f: cp) {
// // this forwards directly to InterpreterJVM.addClassPath(String)
// try { _interactionsModel.addExtraClassPath(f.toURL()); }
// catch(MalformedURLException murle) {
// /* do nothing; findbugs signals a bug unless this catch clause spans more than two lines */
// }
// }
// }
// }
// }
}
| [
"375833274@qq.com"
] | 375833274@qq.com |
d0cb5816445b6dc87f5ee30a86e6102d932a1b1e | 4f2bf6b54fbccafc1fa256c39982c6a673745489 | /flightreservation/src/main/java/com/pradeep/flightreservation/repos/FlightRepository.java | 39df9e3f1043b8ebf829fe45d097f92e25ef68d0 | [] | no_license | pradeep104203/FullStack-Development-using-SpringBoot-Angular-React | 536fafb0a883402a44f1a98646caf29401e3340e | fd7458c62c89656680b1cc238a7acb5da3b81486 | refs/heads/master | 2023-04-02T00:06:43.882344 | 2021-03-11T15:39:08 | 2021-03-11T15:39:08 | 346,749,440 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 667 | java | package com.pradeep.flightreservation.repos;
import java.util.Date;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.pradeep.flightreservation.entities.Flight;
public interface FlightRepository extends JpaRepository<Flight, Long> {
@Query("from Flight where departureCity=:departureCity and arrivalCity=:arrivalCity and dateOfDeparture=:dateOfDeparture")
List<Flight> findFlights(@Param("departureCity") String from, @Param("arrivalCity") String to,
@Param("dateOfDeparture") Date departureDate);
}
| [
"pradepreddy1993@gmail.com"
] | pradepreddy1993@gmail.com |
08713bf70ea832b12d5149a0225a6591afedc1bf | 14f7ba51772dab32b0c260cbd59987fe8c42d9ba | /src/main/java/梅花易数易学/六十四卦/风天小畜.java | 11035b50d66afd1fe3f1b329a050b17c6035f37a | [] | no_license | gaogushenling/suangua | 700d454c7f524e006a9dc61e2b9a47465b512982 | 605eee20f56cde2a3d217e5f0fcde32eefabdf79 | refs/heads/master | 2021-10-08T21:51:13.050496 | 2018-12-18T06:48:51 | 2018-12-18T06:48:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 868 | java | package 梅花易数易学.六十四卦;
import static Print.Print.println;
/**
* Created by zyf on 2016/9/15.
*/
public class 风天小畜 extends 六十四卦 {
@Override
public void 卦意() {
println("巽上乾下\n");
}
@Override
public void 卦辞() {
println("亨。密云不雨。自我西郊。\n");
}
@Override
public void 卦爻() {
println();
}
@Override
public void 六爻() {
println("初九,「复自道,何其咎?吉。\n" +
"九二,牵复,吉。\n" +
"九三,舆说辐。夫妻反目。\n" +
"六四,有孚,血去,惕出无咎。\n" +
"九五,有孚挛如,富以其邻。\n" +
"上九,既雨既处,尚德载。妇贞厉。月几望,君子征凶。 ");
}
}
| [
"BigBanan@169.254.188.139"
] | BigBanan@169.254.188.139 |
cb8ab7cb8b2223857d3ee4001cdd18c23d5d8ba2 | e425c13a0e62ede731b19e432471c0821b1dd098 | /bc/src/public/nc/uap/lfw/core/model/util/ElementObserver.java | b9cd135b2eb08078de6ea229f902e628a292099e | [] | no_license | thimda/rsd_web | 42c6ee54fcdd2fc699b74a1a48af2424fb5fd751 | 8c32851118eb98de1df2f0889a693258f10eab11 | refs/heads/master | 2020-05-17T18:58:22.839246 | 2012-04-01T22:24:41 | 2012-04-01T22:24:41 | 3,823,167 | 3 | 1 | null | null | null | null | GB18030 | Java | false | false | 12,384 | java | package nc.uap.lfw.core.model.util;
import nc.uap.lfw.core.combodata.ComboData;
import nc.uap.lfw.core.comp.ExcelColumn;
import nc.uap.lfw.core.comp.ExcelColumnGroup;
import nc.uap.lfw.core.comp.ExcelComp;
import nc.uap.lfw.core.comp.GridColumn;
import nc.uap.lfw.core.comp.GridComp;
import nc.uap.lfw.core.comp.IExcelColumn;
import nc.uap.lfw.core.comp.WebElement;
import nc.uap.lfw.core.ctx.AppLifeCycleContext;
import nc.uap.lfw.core.ctx.ApplicationContext;
import nc.uap.lfw.core.ctx.ViewContext;
import nc.uap.lfw.core.data.Dataset;
import nc.uap.lfw.core.data.Field;
import nc.uap.lfw.core.event.ctx.LfwPageContext;
import nc.uap.lfw.core.event.ctx.WidgetContext;
import nc.uap.lfw.core.page.LfwWidget;
import nc.uap.lfw.core.processor.EventRequestContext;
import nc.uap.lfw.core.tags.AppDynamicCompUtil;
import nc.uap.lfw.core.tags.DatasetMetaUtil;
import nc.uap.lfw.core.tags.DynamicCompUtil;
import nc.uap.lfw.core.tags.ExcelModelUtil;
import nc.uap.lfw.core.model.AppTypeUtil;
public final class ElementObserver {
public static final String OBS_IN = "OBS_IN";
private static final String GRIDCOLUMN_VISIBLE_SCRIPT = "gridcolumn_visible_script";
private static final String GRIDCOLUMN_VISIBLE_INDEX = "gridcolumn_visible_index";
private static final String GRIDCOLUMN_EDITABLE_SCRIPT = "gridcolumn_editable_script";
private static final String GRIDCOLUMN_EDITABLE_INDEX = "gridcolumn_editable_index";
private static final String GRIDCOLUMN_PRECISION_INDEX = "gridcolumn_precision_index";
public static void notifyChange(String type, WebElement ele){
notifyChange(type, ele, null);
}
public static void notifyChange(String type, WebElement ele, Object userObject){
// if(!LfwRuntimeEnvironment.isPageAction())
// return;
if(ele.getExtendAttributeValue(OBS_IN) != null)
return;
ele.setExtendAttribute(OBS_IN, "1");
if(ele instanceof ComboData){
processComboData(ele);
}
else if(ele instanceof GridColumn){
if(type != null && type.equals(GridColumn.COLUMN_VISIBLE)){
if(AppTypeUtil.getApplicationType().equals(AppTypeUtil.APP_TYPE))
appProcessColumnVisible((GridColumn) ele, (GridComp) userObject);
else
processColumnVisible((GridColumn) ele, (GridComp) userObject);
}
else if(type != null && type.equals(GridColumn.COLUMN_EDITABLE)){
// if(AppTypeUtil.getApplicationType().equals(AppTypeUtil.APP_TYPE))
// appProcessColumnEditable((GridColumn) ele, (GridComp) userObject);
// else
processColumnEditable((GridColumn) ele, (GridComp) userObject);
}
else if(type != null && type.equals(GridColumn.COLUMN_PRECISION)){
processColumnPrecision((GridColumn) ele, (GridComp) userObject);
}
}else if(ele instanceof Dataset){
processDataset(type, (Dataset)ele, userObject);
}
else if(ele instanceof LfwWidget){
LfwWidget widget = (LfwWidget) ele;
if(widget.isDialog())
processWidget(widget);
}
else if(ele instanceof ExcelComp){
processExcelComp(type,(ExcelComp)ele,userObject);
}
ele.removeExtendAttribute(OBS_IN);
}
private static void processWidget(LfwWidget widget) {
// TODO Auto-generated method stub
LfwPageContext pctx = EventRequestContext.getLfwPageContext();
pctx.addExecScript("pageUI.getDialog('" + widget.getId() + "').titleDiv.innerHTML='" + widget.getCaption() + "'");
}
public static void processDataset(String type,Dataset ds,Object userObject){
if("adjustField".equals(type)){
StringBuffer buf = new StringBuffer();
LfwWidget widget = ds.getWidget();
String varDs = "$c_"+ds.getId();
if(widget == null){
buf.append("var "+varDs).append(" = pageUI.getDataset('"+ds.getId()+"');\n");
}else{
buf.append("var "+varDs).append(" = pageUI.getWidget('"+widget.getId()+"').getDataset('"+ds.getId()+"');\n");
}
Field field = (Field)userObject;
String varField = "$c_"+field.getId();
buf.append("var "+varField).append(" = "+DatasetMetaUtil.generateField(field)+";\n");
buf.append(varDs).append(".addField("+varField+");\n");
addBeforeDynamicScript(buf.toString());
}
}
public static void processExcelComp(String type,ExcelComp ec,Object userObject){
if("addColumn".equals(type)){
StringBuffer buf = new StringBuffer();
LfwWidget widget = ec.getWidget();
String varEc = "$c_"+ec.getId();
String varModel = "model";
String varHeader = varEc+"_header";
if(widget != null){
buf.append("var "+varEc).append(" = pageUI.getWidget('"+widget.getId()+"').getComponent('"+ec.getId()+"');\n");
buf.append("var "+varModel+" = "+varEc+".model; \n");
IExcelColumn header = (IExcelColumn) userObject;
Dataset ds = widget.getViewModels().getDataset(ec.getDataset());
String varDs = "$c_"+ds.getId();
//buf.append("var "+varHeader).append(" = "+ExcelModelUtil.generalExcelHeader(ds, widget,header) + "; \n");
buf.append(" "+ExcelModelUtil.generalExcelHeader(ds, widget,header) + "; \n");
buf.append("var "+varDs).append(" = pageUI.getWidget('"+widget.getId()+"').getDataset('"+ds.getId()+"');\n");
buf.append(varModel).append(".setDataSet("+varDs+");\n");
buf.append(varEc).append(".setModel("+varModel+");\n");
addDynamicScript(buf.toString());
}
}
}
/**
* 设置grid列显示属性
*
* @param ele
* @param grid
*/
private static void processColumnVisible(GridColumn ele, GridComp grid) {
LfwPageContext pctx = EventRequestContext.getLfwPageContext();
Integer index = (Integer) pctx.getUserObject(GRIDCOLUMN_VISIBLE_INDEX + grid.getId());
if(index != null){
pctx.removeExecScript(index);
}
String script = null;
String visibleScript = (String) pctx.getUserObject(GRIDCOLUMN_VISIBLE_SCRIPT + grid.getId());
if (visibleScript == null || visibleScript.equals("")){
visibleScript = "[]";
}
//清空之前的对该列的设置
visibleScript = visibleScript.replace(",\"" + ele.getId() + ":" +"true\"", "");
visibleScript = visibleScript.replace(",\"" + ele.getId() + ":" +"false\"", "");
visibleScript = visibleScript.replace("\"" + ele.getId() + ":" +"true\"", "");
visibleScript = visibleScript.replace("\"" + ele.getId() + ":" +"false\"", "");
if(ele.isVisible()){
visibleScript = visibleScript.replace("]", ",\"" + ele.getId() + ":" +"true\"]");
}
else{
visibleScript = visibleScript.replace("]", ",\"" + ele.getId() + ":" +"false\"]");
}
visibleScript = visibleScript.replace("[,", "[");
script = "pageUI.getWidget('" + grid.getWidget().getId() + "').getComponent('" + grid.getId() + "').setColumnVisible(" + visibleScript + ")";
pctx.addUserObject(GRIDCOLUMN_VISIBLE_SCRIPT + grid.getId(), visibleScript);
index = pctx.addExecScript(script);
pctx.addUserObject(GRIDCOLUMN_VISIBLE_INDEX + grid.getId(), index);
}
/**
* app 设置grid列显示属性
*
* @param ele
* @param grid
*/
private static void appProcessColumnVisible(GridColumn ele, GridComp grid) {
ApplicationContext appCtx = AppLifeCycleContext.current().getApplicationContext();
Integer index = (Integer) appCtx.getAppAttribute(GRIDCOLUMN_VISIBLE_INDEX + grid.getId());
if(index != null){
appCtx.removeExecScript(index);
}
String script = null;
String visibleScript = (String) appCtx.getAppAttribute(GRIDCOLUMN_VISIBLE_SCRIPT + grid.getId());
if (visibleScript == null || visibleScript.equals("")){
visibleScript = "[]";
}
//清空之前的对该列的设置
visibleScript = visibleScript.replace(",\"" + ele.getId() + ":" +"true\"", "");
visibleScript = visibleScript.replace(",\"" + ele.getId() + ":" +"false\"", "");
visibleScript = visibleScript.replace("\"" + ele.getId() + ":" +"true\"", "");
visibleScript = visibleScript.replace("\"" + ele.getId() + ":" +"false\"", "");
if(ele.isVisible()){
visibleScript = visibleScript.replace("]", ",\"" + ele.getId() + ":" +"true\"]");
}
else{
visibleScript = visibleScript.replace("]", ",\"" + ele.getId() + ":" +"false\"]");
}
visibleScript = visibleScript.replace("[,", "[");
script = "pageUI.getWidget('" + grid.getWidget().getId() + "').getComponent('" + grid.getId() + "').setColumnVisible(" + visibleScript + ")";
appCtx.addAppAttribute(GRIDCOLUMN_VISIBLE_SCRIPT + grid.getId(), visibleScript);
index = appCtx.addExecScript(script);
appCtx.addAppAttribute(GRIDCOLUMN_VISIBLE_INDEX + grid.getId(), index);
}
/**
* 设置grid列可编辑属性
*
* @param ele
* @param grid
*/
private static void processColumnEditable(GridColumn ele, GridComp grid) {
LfwPageContext pctx = EventRequestContext.getLfwPageContext();
Integer index = (Integer) pctx.getUserObject(GRIDCOLUMN_EDITABLE_INDEX + grid.getId());
if(index != null){
pctx.removeExecScript(index);
}
String script = null;
String editableScript = (String) pctx.getUserObject(GRIDCOLUMN_EDITABLE_SCRIPT + grid.getId());
if (editableScript == null || editableScript.equals("")){
editableScript = "[]";
}
//清空之前的对该列的设置
editableScript = editableScript.replace(",\"" + ele.getId() + ":" +"true\"", "");
editableScript = editableScript.replace(",\"" + ele.getId() + ":" +"false\"", "");
editableScript = editableScript.replace("\"" + ele.getId() + ":" +"true\"", "");
editableScript = editableScript.replace("\"" + ele.getId() + ":" +"false\"", "");
if(ele.isEditable()){
editableScript = editableScript.replace("]", ",\"" + ele.getId() + ":" +"true\"]");
}
else{
editableScript = editableScript.replace("]", ",\"" + ele.getId() + ":" +"false\"]");
}
editableScript = editableScript.replace("[,", "[");
script = "pageUI.getWidget('" + grid.getWidget().getId() + "').getComponent('" + grid.getId() + "').setColumnEditable(" + editableScript + ")";
pctx.addUserObject(GRIDCOLUMN_EDITABLE_SCRIPT + grid.getId(), editableScript);
index = pctx.addExecScript(script);
pctx.addUserObject(GRIDCOLUMN_EDITABLE_INDEX + grid.getId(), index);
}
/**
* 设置grid列精度
*
* @param ele
* @param grid
*/
private static void processColumnPrecision(GridColumn ele, GridComp grid) {
LfwPageContext pctx = EventRequestContext.getLfwPageContext();
Integer index = (Integer) pctx.getUserObject(GRIDCOLUMN_PRECISION_INDEX + grid.getId() + "_" + ele.getId());
if(index != null){
pctx.removeExecScript(index);
}
String script = "try{ pageUI.getWidget('" + grid.getWidget().getId() + "').getComponent('" + grid.getId() + "').getBasicHeaderById('" + ele.getId() + "').setPrecision(" + ele.getPrecision() + ") }catch(e){};";
index = pctx.addExecScript(script);
pctx.addUserObject(GRIDCOLUMN_PRECISION_INDEX + grid.getId() + "_" + ele.getId(), index);
}
private static void processComboData(WebElement ele) {
if(((ComboData) ele).getWidget() == null)
return;
String widgetId = ((ComboData) ele).getWidget().getId();
if (AppTypeUtil.getApplicationType().equals(AppTypeUtil.APP_TYPE)){
ApplicationContext appCtx = AppLifeCycleContext.current().getApplicationContext();
ViewContext viewCtx = appCtx.getCurrentWindowContext().getViewContext(widgetId);
AppDynamicCompUtil util = new AppDynamicCompUtil(appCtx, viewCtx);
util.replaceComboData(ele.getId(), widgetId, (ComboData) ele.clone());
}
else {
LfwPageContext pc = EventRequestContext.getLfwPageContext();
WidgetContext wc = pc.getWidgetContext(widgetId);
if (wc == null && pc.getParentGlobalContext() != null)
wc = pc.getParentGlobalContext().getWidgetContext(widgetId);
DynamicCompUtil util = new DynamicCompUtil(pc, wc);
util.replaceComboData(ele.getId(), widgetId, (ComboData) ele.clone());
}
}
public static void addDynamicScript(String script){
if(script == null || script.equals(""))
return;
if(AppTypeUtil.getApplicationType().equals(AppTypeUtil.APP_TYPE)){
AppLifeCycleContext.current().getApplicationContext().addExecScript(script);
}
else{
LfwPageContext ctx = EventRequestContext.getLfwPageContext();
ctx.addExecScript(script);
}
}
public static void addBeforeDynamicScript(String script){
if(script == null || script.equals(""))
return;
if(AppTypeUtil.getApplicationType().equals(AppTypeUtil.APP_TYPE)){
AppLifeCycleContext.current().getApplicationContext().addBeforeExecScript(script);
}
else{
LfwPageContext ctx = EventRequestContext.getLfwPageContext();
ctx.addBeforeExecScript(script);
}
}
}
| [
"devin_2012@163.com"
] | devin_2012@163.com |
638d066ca2886fd93b4fa15fbd30ee04a247b034 | 3659875802aec87a3ab191c09388d59b63869380 | /javademo/src/java0705_basic_operator/prob/Prob0705_02.java | 51a1cfd83423a49d2d4a7c497051fc11780c8fb0 | [] | no_license | hongdaepyo/h1o1n1g1 | fab31dbd459dab78cb380acdec6563eb02cb2534 | 87896497a321440dff589e163cfa5a0644fad559 | refs/heads/master | 2021-06-06T17:38:46.362177 | 2016-12-20T10:47:39 | 2016-12-20T10:47:39 | 64,099,068 | 0 | 0 | null | 2021-05-07T06:13:59 | 2016-07-25T02:55:09 | Java | UTF-8 | Java | false | false | 549 | java | package java0705_basic_operator.prob;
/*
* data변수의 값이 대문자 이면 'A', 소문자이면 'a'을
* 출력하는 프로그램을 구현하시오.
* [실행결과]
* a
*/
/* char result = data >= 'A'&&data<='Z'?'A':'a';
System.out.println(result);
*/
public class Prob0705_02 {
public static void main(String[] args) {
char data = 'A'; // A ~ Z a~z
// 여기에 작성하시오
int asc = data;
asc = data < 97 ? 65 : 97;
char alpaUpper = (char) (asc);
System.out.println(alpaUpper);
}
}
| [
"h1o1n1g1@nate.com"
] | h1o1n1g1@nate.com |
3277711c318c35cf5082861bdaeb21e6176acb1b | 3abcf21616c2f8d3ac552cd4612fe6c287abd307 | /leetcode/src/com/bruce/leetcode/LinkedListCycle.java | 6dedbf9864d7217b1a1e9cabe272f9eb90dbf09f | [] | no_license | zj1111184556/javadesignpatter | 235c4aa6be56dc6db4d0ca624b2123ce5aea2d31 | ff6116039cd0f45bf24243fbacbb1d8f1dc4e626 | refs/heads/master | 2020-12-07T13:46:31.405208 | 2016-09-18T09:46:11 | 2016-09-18T09:46:11 | 68,512,022 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 538 | java | package com.bruce.leetcode;
class ListNode {
int val;
ListNode next;
ListNode(int x) {
val = x;
next = null;
}
}
public class LinkedListCycle {
public boolean hasCycle(ListNode head) {
if(head == null || head.next == null)
return false;
ListNode Faster = head, Slower = head;
while(Faster.next!=null && Faster.next.next!=null){
Slower = Slower.next;
Faster = Faster.next.next;
if(Faster == Slower)
return true;
}
return false;
}
}
| [
"bruce_zhou@asus.com"
] | bruce_zhou@asus.com |
37e51cf8e8722bc9051ecf9610e450e8a25514fa | b2db9c24d9d4b3a982e0d70b7042539cd63a26bc | /src/main/java/ru/dolinini/notebook/security/UserDetailsServiceImpl.java | 64d4a35d70099743c39f74eec8c67a8451d6beeb | [] | no_license | AlejandroWorkAcc/Notebook | a9a23d67fd5545c979ab257feb8d1e904f9abcbd | 3ab3e1b4aca41b8d36a3442a3d614e5257521e53 | refs/heads/main | 2023-03-15T16:48:27.458105 | 2021-03-08T13:26:33 | 2021-03-08T13:26:33 | 345,310,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 971 | java | package ru.dolinini.notebook.security;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import ru.dolinini.notebook.model.User;
import ru.dolinini.notebook.repos.UserRepo;
@Service("userdetailsserviceimpl")
public class UserDetailsServiceImpl implements UserDetailsService {
private final UserRepo userRepo;
public UserDetailsServiceImpl(UserRepo userRepo) {
this.userRepo = userRepo;
}
@Override
public UserDetails loadUserByUsername(String firstname) throws UsernameNotFoundException {
User user=userRepo.findByFirstname(firstname).orElseThrow(()->
new UsernameNotFoundException("User with such name doesn't exists")
);
return SecurityUser.getUserDetailsFromUser(user);
}
}
| [
"ljvghjlfnm@yandex.ru"
] | ljvghjlfnm@yandex.ru |
b0593188d97535a5f978a362424b53c2b54c8d61 | 8f3957062ea5e9f76b4153ff7d191d8a7f97c622 | /app/src/main/java/com/legend/ys8/utils/JsonUtil.java | 4cdd02381b9179eeaa69c48e636f9b93c2b3f6d7 | [] | no_license | liuzhushaonian/ys8-date-set | 0aec2a254fbae0f818ebabc1589e608f5fb9bab1 | fcbda0cd701fad8ceb9fb48f91ac1252c2c9a1ee | refs/heads/master | 2021-07-08T17:33:36.922408 | 2017-10-07T10:49:24 | 2017-10-07T10:49:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,332 | java | package com.legend.ys8.utils;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.legend.ys8.model.CharacterImpl;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* 解析json数据
* Created by legend on 2017/9/13.
*/
public class JsonUtil {
/**
* 将json转为相对应的对象数组并返回
* @param json
* @return
*/
public static List getJsonList(String json,Class<?> m){
List list=new ArrayList();
Gson gson=new GsonBuilder().create();
try {
JSONArray jsonArray=new JSONArray(json);
for (int i=0;i<jsonArray.length();i++){
Object object=gson.fromJson(String.valueOf(jsonArray.get(i)),m);
list.add(object);
}
} catch (JSONException e) {
e.printStackTrace();
}
return list;
}
//获取单个对象
public static Object getObject(String json,Class<?> t){
Gson gson=new GsonBuilder().create();
Object object=gson.fromJson(json,t);
return object;
}
public static String toJson(Object o){
String json=new Gson().toJson(o);
return json;
}
}
| [
"liuzhu234@gmail.com"
] | liuzhu234@gmail.com |
874185c18d41c25baff638bab3b1fe7dbc584814 | 3c9c52083decc2344dde318307a27bf21346447a | /src/baekjoon/solve/P01330___SumTwoNumbers.java | 3cc9db4a464fa98fd22e3f01745b74c0d11de39b | [] | no_license | YeonjungJo/baekjoon | 491e29b0a2aed6b8f1ebb64d775f00e903763f2a | aecb376b2b45ec5615ff597ca62fe723b27083e5 | refs/heads/master | 2022-03-15T12:06:49.126069 | 2022-03-13T17:36:53 | 2022-03-13T17:36:53 | 50,565,804 | 0 | 0 | null | 2022-02-15T14:39:33 | 2016-01-28T07:47:45 | Java | UTF-8 | Java | false | false | 409 | java | package baekjoon.solve;
import java.util.Scanner;
public class P01330___SumTwoNumbers {
private static final Scanner sc = new Scanner(System.in);
private void solve() {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a == b ? "==" : a > b ? ">" : "<");
}
public static void main(String[] args) {
new P01330___SumTwoNumbers().solve();
}
}
| [
"yeonjung.jo@gmail.com"
] | yeonjung.jo@gmail.com |
9af1f217e8d1bcdb45d7e1397d2740e49ff0c922 | 9b55a44aa8a2fd30e2c33f2baddeead9f992905e | /codegeneration/src/main/java/de/uniluebeck/sourcegen/c/CppFunComment.java | c1dd799006cdc5279064c1e192c3147244ade7bf | [
"BSD-3-Clause"
] | permissive | boldt/fabric | b158fd92705e27d869835ef822934a6e15b8d2eb | ee01ce6d8025b5116087635cb753341eac34eb60 | refs/heads/master | 2020-04-05T23:35:57.922202 | 2012-03-16T01:11:16 | 2012-03-16T01:11:16 | 1,858,723 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,807 | java | /**
* Copyright (c) 2010, Dennis Pfisterer, Marco Wegner, Institute of Telematics, University of Luebeck
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
* - Neither the name of the University of Luebeck nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
*
*/
package de.uniluebeck.sourcegen.c;
/**
* Method comment in Java.
*
* @author Marco Wegner
*/
public interface CppFunComment extends CppConstructorComment {
//
}
| [
"github@dennis-boldt.de"
] | github@dennis-boldt.de |
060624f9072eedab106e3297766412539f094cd2 | 90f75ddb200623f1e5332861e2c67d6059b56a46 | /factory-materials/src/servlet/DelEmpInfoServ.java | 7f8ebb32cb8eb9377af50d58e279dd23e3d243f0 | [] | no_license | ThanlonSmith/factory-material | 758f71c8fc92bc87835fb820054f3430a9ca360a | e3c988761273912b3592f579b083c0690dd5ad31 | refs/heads/master | 2020-11-24T12:09:04.473314 | 2020-06-05T05:55:15 | 2020-06-05T05:55:15 | 228,136,897 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,059 | java | package servlet;
import java.io.IOException;
import java.sql.SQLException;
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 dao.AdminDao;
/**
* Servlet 删除员工信息
*/
@WebServlet("/DelEmpInfoServ")
public class DelEmpInfoServ extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id = request.getParameter("id");
AdminDao aDao = new AdminDao();
try {
if (aDao.delEmpInfo(id)) {
request.getRequestDispatcher("/EmployeeInfoServ").forward(request, response);
}
} catch (SQLException | ServletException | IOException e) {
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
| [
"thanlon@163.com"
] | thanlon@163.com |
75a1871f020b9ca0b135f41d979d5cc096e2f2c7 | a602903c73834edbd6b1161dd202d1e36428a7ca | /Java/restassured.sandata.interop/src/test/java/AltEVV_generic/restassured/sandata/Indiana/Visit/SEVV277_TC100795_AltEVV_Visit_Modifier1field_validation_positive.java | 9c40aaaef13f143406eae8fc651ad65aa38ee2c8 | [] | no_license | PharahPhat/Selenium | e5e0ce5ca91708f63005fe205b061f23f1cd2c8e | 572fcf773c9e70b7ac168752d11c11b24837cab9 | refs/heads/master | 2022-12-08T12:59:52.010706 | 2020-04-01T04:49:04 | 2020-04-01T04:49:04 | 143,975,962 | 0 | 0 | null | 2022-12-06T00:44:30 | 2018-08-08T07:20:16 | Java | UTF-8 | Java | false | false | 3,189 | java | package AltEVV_generic.restassured.sandata.Indiana.Visit;
import java.io.IOException;
import java.sql.SQLException;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
import org.testng.annotations.Test;
import com.globalMethods.core.Assertion_DbVerifier;
import com.globalMethods.core.CommonMethods;
import com.globalMethods.core.GenerateUniqueParam;
import com.globalMethods.core.globalVariables;
import com.relevantcodes.extentreports.LogStatus;
import Utills_ExtentReport_Log4j.BaseTest;
public class SEVV277_TC100795_AltEVV_Visit_Modifier1field_validation_positive extends BaseTest{
GenerateUniqueParam GenerateUniqueParam=new GenerateUniqueParam();
Assertion_DbVerifier Assertion_DbVerifier= new Assertion_DbVerifier();
@Test(groups = {"All", "Regression"})
public void TC100795_AltEVV_Visit_Modifier1field_validation_positive() throws InterruptedException, java.text.ParseException, IOException, ParseException, SQLException, ClassNotFoundException, java.text.ParseException
{
// logger = extent.startTest("TC100795_AltEVV_Visit_Modifier1field_validation_positive");
logger.log(LogStatus.INFO, "TC100795_AltEVV_Visit_Modifier1field_validation_positive");
JSONArray jsonArrayVisit=GenerateUniqueParam.VisitParams_AltEVV();
JSONObject jsonObjectVisit = (JSONObject) jsonArrayVisit.get(0);
jsonObjectVisit.put(globalVariables.Modifier1, CommonMethods.generateRandomStringOfFixLength(2));
CommonMethods.validateResponse(jsonArrayVisit,
CommonMethods.propertyfileReader(globalVariables.altevv_visit));
}
@Test(groups = {"All", "Regression"})
public void TC100795_AltEVV_Visit_Modifier1field_alphanumeric() throws InterruptedException, java.text.ParseException, IOException, ParseException, SQLException, ClassNotFoundException, java.text.ParseException
{
// logger = extent.startTest("TC100795_AltEVV_Visit_Modifier1field_alphanumeric");
logger.log(LogStatus.INFO, "TC100795_AltEVV_Visit_Modifier1field_alphanumeric");
JSONArray jsonArrayVisit=GenerateUniqueParam.VisitParams_AltEVV();
JSONObject jsonObjectVisit = (JSONObject) jsonArrayVisit.get(0);
jsonObjectVisit.put(globalVariables.Modifier1, CommonMethods.generateRandomAlphaNumeric(2));
CommonMethods.validateResponse(jsonArrayVisit,
CommonMethods.propertyfileReader(globalVariables.altevv_visit));
}
@Test(groups = {"All", "Regression"})
public void TC100795_AltEVV_Visit_Modifier1field_singlechar() throws InterruptedException, java.text.ParseException, IOException, ParseException, SQLException, ClassNotFoundException, java.text.ParseException
{
// logger = extent.startTest("TC100795_AltEVV_Visit_Modifier1field_singlechar");
logger.log(LogStatus.INFO, "TC100795_AltEVV_Visit_Modifier1field_singlechar");
JSONArray jsonArrayVisit=GenerateUniqueParam.VisitParams_AltEVV();
JSONObject jsonObjectVisit = (JSONObject) jsonArrayVisit.get(0);
jsonObjectVisit.put(globalVariables.Modifier1, CommonMethods.generateRandomStringOfFixLength(1));
CommonMethods.validateResponse(jsonArrayVisit,
CommonMethods.propertyfileReader(globalVariables.altevv_visit));
}
}
| [
"phattnguyen@kms-technology.com"
] | phattnguyen@kms-technology.com |
076891fab3aa1c98dacac56a37bd7ead2b601353 | f84cdfcbf69944a0c553a7c75bc886cb048961a2 | /base/src/com/google/idea/blaze/base/projectview/section/sections/DirectoryEntry.java | 0744eea10ddd94880c2821a8f76628087d490df9 | [
"Apache-2.0"
] | permissive | ahirreddy/intellij | 737940df855c3c72f10f365c187cc076d1b7e96b | 369ec0911356207231bffee0995095159ae8c93d | refs/heads/master | 2021-01-19T21:19:48.543782 | 2018-08-17T22:10:54 | 2018-08-17T22:10:54 | 82,481,985 | 0 | 1 | Apache-2.0 | 2019-03-22T21:17:33 | 2017-02-19T18:59:05 | Java | UTF-8 | Java | false | false | 2,072 | java | /*
* Copyright 2016 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.base.projectview.section.sections;
import com.google.common.base.Objects;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import java.io.Serializable;
/** An entry in the directory section. */
public class DirectoryEntry implements Serializable {
private static final long serialVersionUID = 1L;
public final WorkspacePath directory;
public final boolean included;
public DirectoryEntry(WorkspacePath directory, boolean included) {
this.directory = directory;
this.included = included;
}
public static DirectoryEntry include(WorkspacePath directory) {
return new DirectoryEntry(directory, true);
}
public static DirectoryEntry exclude(WorkspacePath directory) {
return new DirectoryEntry(directory, false);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DirectoryEntry that = (DirectoryEntry) o;
return Objects.equal(included, that.included) && Objects.equal(directory, that.directory);
}
@Override
public int hashCode() {
return Objects.hashCode(directory, included);
}
@Override
public String toString() {
return (included ? "" : "-") + directoryString();
}
private String directoryString() {
if (directory.isWorkspaceRoot()) {
return ".";
}
return directory.relativePath();
}
}
| [
"brendandouglas@google.com"
] | brendandouglas@google.com |
5ddf629edfa5d2df7d16f1a5da27fb831ffc2b31 | 452a524e2faf3dd6cd356fe97c602d09d2ec35ca | /src/test/java/com/main/Page03.java | 670f0c796322924b0e0abc541ebee82c9bf93d6e | [] | no_license | svene/JPATips | 913a8ac09e44e7ec0c78dd837b7a03f856951f93 | cf51f796d16b3105b95e08c0439a22988f037284 | refs/heads/master | 2021-01-18T18:25:03.806606 | 2014-05-31T10:00:40 | 2014-05-31T10:00:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,101 | java | package com.main;
import javax.persistence.EntityManager;
import com.model.Address;
import com.model.Person;
public class Page03 {
public static void main(String[] args) {
CodeGenerator.startConnection();
CodeGenerator.generateData();
EntityManager em = CodeGenerator.getEntityManager();
Person person = em.find(Person.class, 1);
int addressId = 2;
// usually we send an id or a detached object from the view
setAddressToOtherPerson(em, person, addressId);
int personId = 4;
// usually we send an id or a detached object from the view
deletePerson(em, personId);
CodeGenerator.closeConnection();
}
private static void setAddressToOtherPerson(EntityManager em, Person person, int addressId) {
Address address = em.getReference(Address.class, addressId);
person.setAddress(address);
em.merge(person);
em.flush();
System.out.println("Merged");
}
private static void deletePerson(EntityManager em, int personId) {
Person savedPerson = em.getReference(Person.class, personId);
em.remove(savedPerson);
em.flush();
System.out.println("Deleted");
}
} | [
"sven.ehrke@canoo.com"
] | sven.ehrke@canoo.com |
d4d3f23f95a21c5bd58fb71e8d91b4c82472f475 | 16b16514066a96779a1c8440fc3ab4d70583f187 | /app/src/main/java/dnd/com/soupthatisthick/compendium/common/impls/ReadDaoImpl.java | 0fd2c707b9440310ef623ee286e29e672ab5f1db | [] | no_license | serskine/Compendium | d5104806c7296b40c331dae42ce598a23695540d | 4d2288bc179a95e6e7d85494f6e582a14380c32e | refs/heads/master | 2020-03-18T15:20:20.268793 | 2018-05-25T20:24:05 | 2018-05-25T20:24:05 | 134,901,355 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,660 | java | package dnd.com.soupthatisthick.compendium.common.impls;
import android.arch.persistence.room.RoomDatabase;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import dnd.com.soupthatisthick.compendium.common.ifaces.ReadDao;
public class ReadDaoImpl<Key, Record> extends AbstractDaoImpl<Key, Record> implements ReadDao<Key, Record> {
public ReadDaoImpl(final RoomDatabase roomDatabase, final String tableName) {
super(roomDatabase, tableName);
}
@Override
public Record load(Key key) {
throw new RuntimeException("load(Key) is not yet supported on table " + this.getDaoName() + " (" + this.getClass().getSimpleName() + ")");
}
@Override
public List<Record> searchFor(String[] includedTerms, String[] excludedTerms) {
throw new RuntimeException("searchFor(includedTerms[], excludedTerms[]) is not yet supported on table " + this.getDaoName() + " (" + this.getClass().getSimpleName() + ")");
}
@Override
public List<Record> findAll() {
throw new RuntimeException("findAll() is not yet supported on table " + this.getDaoName() + " (" + this.getClass().getSimpleName() + ")");
}
@Override
public Set<String> getSearchableColumns() {
throw new RuntimeException("getSearchableColumns() is not yet supported on table " + this.getDaoName() + " (" + this.getClass().getSimpleName() + ")");
}
@Override
public List<String> getOrderByColumns() {
throw new RuntimeException("getOrderByColumns() is not yet supported on table " + this.getDaoName() + " (" + this.getClass().getSimpleName() + ")");
}
}
| [
"stuart.marr.erskine@gmail.com"
] | stuart.marr.erskine@gmail.com |
a73cd86611b618ea20643cad5fa7dbe764889851 | b71739bd2a3cecaa9b6aef4ed583278297badc09 | /src/main/java/org/jboss/narayana/case02681833/RunnableTx.java | d426b3b1f6fba6fdba46b650f50d955ec483aa22 | [] | no_license | jhalliday/txjournaltest | a358ff69a65724a19a68ae1a7744eefd7dd6f3f6 | de814cfd1a20216e7c51606a3dea321927863bb5 | refs/heads/master | 2022-11-11T18:13:25.395245 | 2020-06-30T15:06:13 | 2020-06-30T15:06:13 | 275,842,745 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 963 | java | package org.jboss.narayana.case02681833;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
public class RunnableTx implements Runnable {
private final int numberOfTransactions;
public RunnableTx(int numberOfTransactions) {
this.numberOfTransactions = numberOfTransactions;
}
@Override
public void run() {
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
XAResource resource1 = new XAResourceImpl();
XAResource resource2 = new XAResourceImpl();
for (int i = 0; i < numberOfTransactions; i++) {
try {
tm.begin();
tm.getTransaction().enlistResource(resource1);
tm.getTransaction().enlistResource(resource2);
tm.commit();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
}
| [
"jonathan.halliday@redhat.com"
] | jonathan.halliday@redhat.com |
e8505e392dae78bc78af9c50ddd09b90a421e5ca | cecff85ccd080e23454ddfec4a8a34646cbce3b4 | /src/main/java/com/demo/webservice/domain/posts/Posts.java | 85c422fe39031c0b6096ef47f0ce2c069ddfc4b7 | [] | no_license | create-ko/SpringWebServiceMavenDemo | 885fdc721d4d4673ea42cf2b817b9c4d621946db | cf53850cfacc0b420b53a8bd79f06b4d9be7ba1e | refs/heads/master | 2020-05-18T16:12:13.376977 | 2019-05-02T08:37:52 | 2019-05-02T08:37:52 | 184,520,012 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,037 | java | package com.demo.webservice.domain.posts;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import com.demo.webservice.common.BaseTimeEntity;
/**
* Entity Class ( Table )
* @author create_ko
*
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
public class Posts extends BaseTimeEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(length = 500, nullable = false)
private String title;
@Column(columnDefinition = "TEXT", nullable = false)
private String content;
private String author;
@Builder
public Posts(String title, String content, String author) {
this.title = title;
this.content = content;
this.author = author;
}
} | [
"create_ko@createko.netand.co.kr"
] | create_ko@createko.netand.co.kr |
278ee40e7ac3ec37e9f7ddad6e5118a8aa8e79dc | 013056e44ecf131f5ff76f5280e05c95d443303a | /IDE Files/Phase2/src/main/controllers/SHPController/encog/app/analyst/csv/basic/BasicCachedFile.java | 8ab6c268ac5f29313ca6de2e07b02829026e6405 | [] | no_license | neguskay/CS5099-Dissertation | f1921b15d370e056a7d6d8e6aee26ef8224ed390 | 561d48318c720e3963775953bd67c75cb9ccd002 | refs/heads/master | 2020-04-10T09:46:32.247792 | 2018-12-08T15:20:47 | 2018-12-08T15:20:47 | 160,946,902 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,301 | java | /*
* Encog(tm) Core v3.4 - Java Version
* http://www.heatonresearch.com/encog/
* https://github.com/encog/encog-java-core
* Copyright 2008-2016 Heaton Research, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information on Heaton Research copyrights, licenses
* and trademarks visit:
* http://www.heatonresearch.com/copyright
*/
package org.encog.app.analyst.csv.basic;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.encog.app.quant.QuantError;
import org.encog.util.csv.CSVFormat;
import org.encog.util.csv.ReadCSV;
import org.encog.util.logging.EncogLogging;
/**
* Forms the foundation of all of the cached files in Encog Quant.
*/
public class BasicCachedFile extends BasicFile {
/**
* The column mapping.
*/
private final Map<String, BaseCachedColumn> columnMapping
= new HashMap<String, BaseCachedColumn>();
/**
* The columns.
*/
private final List<BaseCachedColumn> columns
= new ArrayList<BaseCachedColumn>();
/**
* Add a new column.
*
* @param column
* The column to add.
*/
public void addColumn(final BaseCachedColumn column) {
this.columns.add(column);
this.columnMapping.put(column.getName(), column);
}
/**
* Analyze the input file.
*
* @param input
* The input file.
* @param headers
* True, if there are headers.
* @param format
* The format of the CSV data.
*/
public void analyze(final File input, final boolean headers,
final CSVFormat format) {
resetStatus();
setInputFilename(input);
setExpectInputHeaders(headers);
setInputFormat(format);
this.columnMapping.clear();
this.columns.clear();
// first count the rows
BufferedReader reader = null;
try {
int recordCount = 0;
reader = new BufferedReader(new FileReader(getInputFilename()));
while (reader.readLine() != null) {
updateStatus(true);
recordCount++;
}
if (headers) {
recordCount--;
}
setRecordCount(recordCount);
} catch (final IOException ex) {
throw new QuantError(ex);
} finally {
reportDone(true);
if (reader != null) {
try {
reader.close();
} catch (final IOException e) {
throw new QuantError(e);
}
}
setInputFilename(input);
setExpectInputHeaders(headers);
setInputFormat(format);
}
// now analyze columns
ReadCSV csv = null;
try {
csv = new ReadCSV(input.toString(), headers, format);
if (!csv.next()) {
throw new QuantError("File is empty");
}
for (int i = 0; i < csv.getColumnCount(); i++) {
String name;
if (headers) {
name = attemptResolveName(csv.getColumnNames().get(i));
} else {
name = "Column-" + (i + 1);
}
// determine if it should be an input/output field
final String str = csv.get(i);
boolean io = false;
try {
Double.parseDouble(str);
io = true;
} catch (final NumberFormatException ex) {
EncogLogging.log(ex);
}
addColumn(new FileData(name, i, io, io));
}
} finally {
csv.close();
setAnalyzed(true);
}
}
/**
* Attempt to resolve a column name.
*
* @param name
* The unknown column name.
* @return The known column name.
*/
private String attemptResolveName(final String name) {
String name2 = name.toLowerCase();
if (name2.indexOf("open") != -1) {
return FileData.OPEN;
} else if (name2.indexOf("close") != -1) {
return FileData.CLOSE;
} else if (name2.indexOf("low") != -1) {
return FileData.LOW;
} else if (name2.indexOf("hi") != -1) {
return FileData.HIGH;
} else if (name2.indexOf("vol") != -1) {
return FileData.VOLUME;
} else if ((name2.indexOf("date") != -1)
|| (name.indexOf("yyyy") != -1)) {
return FileData.DATE;
} else if (name2.indexOf("time") != -1) {
return FileData.TIME;
}
return name;
}
/**
* Get the data for a specific column.
*
* @param name
* The column to read.
* @param csv
* The CSV file to read from.
* @return The column data.
*/
public String getColumnData(final String name, final ReadCSV csv) {
if (!this.columnMapping.containsKey(name)) {
return null;
}
final BaseCachedColumn column = this.columnMapping.get(name);
if (!(column instanceof FileData)) {
return null;
}
final FileData fd = (FileData) column;
return csv.get(fd.getIndex());
}
/**
* @return The column mappings.
*/
public Map<String, BaseCachedColumn> getColumnMapping() {
return this.columnMapping;
}
/**
* @return The columns.
*/
public List<BaseCachedColumn> getColumns() {
return this.columns;
}
}
| [
"neguskay93@gmail.com"
] | neguskay93@gmail.com |
2744682bbb1b2d7d01a64b51c1e8d650479fac22 | 3ca152dab98f405f74922ff4cab85c8535256e70 | /src/test/day0507/am/randomNumDemo.java | f2c9139fb2a6b2694fca1a0c3123a20d1df72a78 | [] | no_license | wenyuchen1994/yuchen | cf8f3cef85631a3eb22be70988789bd5cc338147 | fd3dc0b661d90bff0c94a0cfcf9b9b54a9a2bdbf | refs/heads/master | 2020-05-19T21:44:05.594908 | 2019-05-07T12:07:52 | 2019-05-07T12:07:52 | 185,230,988 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 408 | java | package test.day0507.am;
import java.util.Scanner;
public class randomNumDemo {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int sum=0;
System.out.println("请输入一个随机的数字");
int num=scan.nextInt();
for(int i=1;;i++) {
if (num%(10^i)/(10^(i-1))==num) {
break;
}
sum=sum+num%(10^i)/(10^(i-1));
}
System.out.println(sum);
}
}
| [
"soft01@localhost"
] | soft01@localhost |
d9b1c707706642e40d5a437a28f02dbc78f2e87b | 990a2e5e7f2894b3a0c5f2132d8f649cd94e1129 | /src/main/java/edu/uiowa/medline/investigatorAffiliation/InvestigatorAffiliationPmid.java | 5535b84601ed9b2ac1b373b589df4389b1e72fde | [] | no_license | eichmann/MEDLINETagLib | e821e983d2d904abc2ac8b7a9e80cc77c6c92198 | 676e425785f00b36bad9a846059087ae2e1e53b9 | refs/heads/master | 2020-03-18T20:20:42.683662 | 2019-04-05T15:56:31 | 2019-04-05T15:56:31 | 135,209,165 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,936 | java | package edu.uiowa.medline.investigatorAffiliation;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.uiowa.medline.MEDLINETagLibTagSupport;
@SuppressWarnings("serial")
public class InvestigatorAffiliationPmid extends MEDLINETagLibTagSupport {
private static final Log log = LogFactory.getLog(InvestigatorAffiliationPmid.class);
public int doStartTag() throws JspException {
try {
InvestigatorAffiliation theInvestigatorAffiliation = (InvestigatorAffiliation)findAncestorWithClass(this, InvestigatorAffiliation.class);
if (!theInvestigatorAffiliation.commitNeeded) {
pageContext.getOut().print(theInvestigatorAffiliation.getPmid());
}
} catch (Exception e) {
log.error("Can't find enclosing InvestigatorAffiliation for pmid tag ", e);
throw new JspTagException("Error: Can't find enclosing InvestigatorAffiliation for pmid tag ");
}
return SKIP_BODY;
}
public int getPmid() throws JspTagException {
try {
InvestigatorAffiliation theInvestigatorAffiliation = (InvestigatorAffiliation)findAncestorWithClass(this, InvestigatorAffiliation.class);
return theInvestigatorAffiliation.getPmid();
} catch (Exception e) {
log.error(" Can't find enclosing InvestigatorAffiliation for pmid tag ", e);
throw new JspTagException("Error: Can't find enclosing InvestigatorAffiliation for pmid tag ");
}
}
public void setPmid(int pmid) throws JspTagException {
try {
InvestigatorAffiliation theInvestigatorAffiliation = (InvestigatorAffiliation)findAncestorWithClass(this, InvestigatorAffiliation.class);
theInvestigatorAffiliation.setPmid(pmid);
} catch (Exception e) {
log.error("Can't find enclosing InvestigatorAffiliation for pmid tag ", e);
throw new JspTagException("Error: Can't find enclosing InvestigatorAffiliation for pmid tag ");
}
}
}
| [
"eichmann@deep-thought.info-science.uiowa.edu"
] | eichmann@deep-thought.info-science.uiowa.edu |
7449ca1d9d953acfe2fdb91bca4a03d9b1566a7f | ceac5c693257ea7af51ae7b0c775508ae13e0ff0 | /echo_master_service/modules/rest-server/src/main/java/in/dream_lab/echo/rest_server/EchoRestServerApplication.java | d19187a004769a0fdf7f0801dcfef2a937251175 | [
"Apache-2.0"
] | permissive | dream-lab/echo | 86a53e2a3149fbe7c6982250bd6f07870644840d | 3ba3e83068e733bc2330e0d1c9176d3fc2fb7e20 | refs/heads/master | 2020-04-05T13:41:22.066781 | 2019-04-05T04:07:12 | 2019-04-05T04:07:12 | 94,972,076 | 19 | 10 | Apache-2.0 | 2018-06-29T11:29:06 | 2017-06-21T06:45:57 | Java | UTF-8 | Java | false | false | 1,045 | java | package in.dream_lab.echo.rest_server;
import in.dream_lab.echo.rest_server.resources.EchoRestServerResource;
import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
/**
* Created by pushkar on 8/2/17.
*/
public class EchoRestServerApplication extends Application<EchoRestServerConfiguration> {
public static void main(String[] args) throws Exception {
new EchoRestServerApplication().run(args);
}
@Override
public String getName() {
return "hello-world";
}
@Override
public void initialize(Bootstrap<EchoRestServerConfiguration> bootstrap) {
// nothing to do yet
}
@Override
public void run(EchoRestServerConfiguration configuration,
Environment environment) {
final EchoRestServerResource resource = new EchoRestServerResource(
configuration.getTemplate(),
configuration.getDeaultName()
);
environment.jersey().register(resource);
}
}
| [
"pushkar1593@gmail.com"
] | pushkar1593@gmail.com |
c7fd6b1d73012448b4f2edf26eb24c65a3978fe7 | b63713f4087a10a9a32ffc5d5cbc5055fd254b86 | /Lab9/asynchronous/echo-ws-cli_async/target/generated-sources/wsimport/example/ws/EchoException.java | 945ce3bd4d8e394e0ebc157da2c3d654e78866bf | [] | no_license | PrimeAC/SDis-Labs | 5a5cbad062cf1e60e1b519555b45706d0b21a14f | 72564acf9b61a65c81cb1ba9d3b6f644d0b4f826 | refs/heads/master | 2021-04-30T18:44:46.114644 | 2016-05-12T01:39:10 | 2016-05-12T01:39:10 | 52,667,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,335 | java |
package example.ws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for EchoException complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="EchoException">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EchoException", propOrder = {
"message"
})
public class EchoException {
protected String message;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
| [
"afonso.caetano@outlook.com"
] | afonso.caetano@outlook.com |
437ca551d3de102f9f39e2b601ae73880c5001d8 | a8d19866f2fc047c5efc6f6a1eadc633838f2dcb | /fbcore/src/main/java/com/facebook/common/internal/Closeables.java | 3f82ef3f6a27cdb31d6293f494ef44db75ca4a28 | [
"BSD-3-Clause"
] | permissive | gavanx/l-fres | e3464f961cab7492f9fb455166376f217b73cdcb | b2de0f052f6074069bded3080bcce0b2a68bf11e | refs/heads/master | 2021-01-17T17:19:35.253905 | 2016-06-17T07:22:17 | 2016-06-17T07:22:17 | 61,353,580 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,882 | java | /*
* Copyright (C) 2007 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.common.internal;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/**
* Utility methods for working with {@link Closeable} objects.
*
* @author Michael Lancaster
* @since 1.0
*/
public final class Closeables {
@VisibleForTesting static final Logger logger = Logger.getLogger(Closeables.class.getName());
private Closeables() {
}
/**
* Closes a {@link Closeable}, with control over whether an {@code IOException} may be thrown.
* This is primarily useful in a finally block, where a thrown exception needs to be logged but
* not propagated (otherwise the original exception will be lost).
*
* <p>If {@code swallowIOException} is true then we never throw {@code IOException} but merely log
* it.
*
* <p>Example: <pre> {@code
*
* public void useStreamNicely() throws IOException {
* SomeStream stream = new SomeStream("foo");
* boolean threw = true;
* try {
* // ... code which does something with the stream ...
* threw = false;
* } finally {
* // If an exception occurs, rethrow it only if threw==false:
* Closeables.close(stream, threw);
* }
* }}</pre>
*
* @param closeable the {@code Closeable} object to be closed, or null, in which case this method
* does nothing
* @param swallowIOException if true, don't propagate IO exceptions thrown by the {@code close}
* methods
* @throws IOException if {@code swallowIOException} is false and {@code close} throws an
* {@code IOException}.
*/
public static void close(@Nullable Closeable closeable, boolean swallowIOException) throws IOException {
if (closeable == null) {
return;
}
try {
closeable.close();
} catch (IOException e) {
if (swallowIOException) {
logger.log(Level.WARNING, "IOException thrown while closing Closeable.", e);
} else {
throw e;
}
}
}
/**
* Closes the given {@link InputStream}, logging any {@code IOException} that's thrown rather
* than propagating it.
*
* <p>While it's not safe in the general case to ignore exceptions that are thrown when closing
* an I/O resource, it should generally be safe in the case of a resource that's being used only
* for reading, such as an {@code InputStream}. Unlike with writable resources, there's no
* chance that a failure that occurs when closing the stream indicates a meaningful problem such
* as a failure to flush all bytes to the underlying resource.
*
* @param inputStream the input stream to be closed, or {@code null} in which case this method
* does nothing
* @since 17.0
*/
public static void closeQuietly(@Nullable InputStream inputStream) {
try {
close(inputStream, true);
} catch (IOException impossible) {
throw new AssertionError(impossible);
}
}
/**
* Closes the given {@link Reader}, logging any {@code IOException} that's thrown rather than
* propagating it.
*
* <p>While it's not safe in the general case to ignore exceptions that are thrown when closing
* an I/O resource, it should generally be safe in the case of a resource that's being used only
* for reading, such as a {@code Reader}. Unlike with writable resources, there's no chance that
* a failure that occurs when closing the reader indicates a meaningful problem such as a failure
* to flush all bytes to the underlying resource.
*
* @param reader the reader to be closed, or {@code null} in which case this method does nothing
* @since 17.0
*/
public static void closeQuietly(@Nullable Reader reader) {
try {
close(reader, true);
} catch (IOException impossible) {
throw new AssertionError(impossible);
}
}
}
| [
"gavan@leoedu.cn"
] | gavan@leoedu.cn |
95d47d0102c52c39eeddd08f589e0a0700a7fedb | dd3eec242deb434f76d26b4dc0e3c9509c951ce7 | /2018-work/jiuy-biz/jiuy-biz-core/src/main/java/com/qianmi/open/api/response/ItemDetailUpdateResponse.java | 8644e427b79cc5712d9f7c5b0a16fb238c83e650 | [] | no_license | github4n/other_workplace | 1091e6368abc51153b4c7ebbb3742c35fb6a0f4a | 7c07e0d078518bb70399e50b35e9f9ca859ba2df | refs/heads/master | 2020-05-31T10:12:37.160922 | 2019-05-25T15:48:54 | 2019-05-25T15:48:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 587 | java | package com.qianmi.open.api.response;
import com.qianmi.open.api.tool.mapping.ApiField;
import com.qianmi.open.api.domain.cloudshop.Item;
import com.qianmi.open.api.QianmiResponse;
/**
* API: qianmi.cloudshop.item.detail.update response.
*
* @author auto
* @since 2.0
*/
public class ItemDetailUpdateResponse extends QianmiResponse {
private static final long serialVersionUID = 1L;
/**
* 返回是否成功is_success
*/
@ApiField("item")
private Item item;
public void setItem(Item item) {
this.item = item;
}
public Item getItem( ) {
return this.item;
}
}
| [
"nessary@foxmail.com"
] | nessary@foxmail.com |
de342bed09f06212b95c4d8901d11146992a79de | c34891675afa7b4b2e835ce04a8aca92640c0743 | /jet-inject/src/main/java/br/unicamp/ic/inject/parameters/metadata/MetadataParameter.java | b8fc1b56e461b3c1c9498b72acffd609da1fb5b5 | [
"AFL-2.1",
"AFL-3.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | buzzo/jet | 31739feabf268483734ac2abf3632922e380120a | cd97abc78aeb790b7895a671a3509819d64a4abb | refs/heads/master | 2020-12-24T13:21:57.508024 | 2011-04-10T21:18:21 | 2011-04-10T21:18:21 | 1,444,078 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 273 | java | package br.unicamp.ic.inject.parameters.metadata;
import java.lang.reflect.Method;
public interface MetadataParameter {
boolean isAnnotationPresent(final Method method);
int getPosition(final Method method);
Object getValue(final Method method);
}
| [
"andre@buzzo.com.br"
] | andre@buzzo.com.br |
850f7b70f2628cca7652a6ff0d3e59b69b295f0d | 00188ccc785a11214172460915ea048c1a4b4a1b | /A1/prog/Prog1bis/TD/correction/Maillon.java | 7c7d3abaed8ee446e4c401662fbdf773fe747d48 | [] | no_license | tom-sartori/FirstComputerScienceCourses | b67a2441e4b00731c5c7bf002cd70e3d3a29bcd5 | 8fbf4b2c33eefcb27578f3a617a1cfb366f76562 | refs/heads/master | 2023-03-30T07:40:44.429425 | 2021-04-07T09:46:34 | 2021-04-07T09:46:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 645 | java |
public class Maillon {
private int valeur;
private Maillon suivant;
/** Constructeur vide */
public Maillon () {
suivant = null;
}
/** Constructeur avec une valeur */
public Maillon (int n) {
valeur = n;
suivant = null;
}
public int getVal() {
return this.valeur;
}
public void setVal(int v) {
this.valeur = v;
}
public Maillon getSuiv () {
return this.suivant;
}
public void setSuiv (Maillon m) {
this.suivant = m;
}
public String toString () {
return Integer.toString(this.valeur);
}
/* -------------------------------------------------- */
}
| [
"tom.sartori-letourneau@etu.umontpellier.fr"
] | tom.sartori-letourneau@etu.umontpellier.fr |
3e40fb2aa6b04f38688c33a826add6a06b2bf9b6 | 1cee073f23b7269b54d79ee1cb1144ab09c15336 | /LibrarySuperToasts/src/com/extlibsupertoasts/SuperCardToast.java | 512e93012729fc25ccdf5fc32d6529ec8924aedc | [
"Apache-2.0"
] | permissive | wuyexiong/Supertoasts | 2f4c298da9558c8af80029f1289f65db204ef367 | b42554b942831419e05b3524f739b3bf3cf5be03 | refs/heads/master | 2020-12-01T03:03:25.698707 | 2013-06-24T04:07:21 | 2013-06-24T04:07:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36,905 | java | /**
* Copyright 2013 John Persano
*
* 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.extlibsupertoasts;
import com.extlibsupertoasts.styles.SuperCardToastStyle;
import com.extlibsupertoasts.utilities.OnDismissListener;
import com.extlibsupertoasts.utilities.SuperToastConstants;
import com.extlibsupertoasts.utilities.SwipeDismissListener;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
/**
* SuperCardToasts are designed to be used inside of Activities. SuperCardToasts
* are designed to be displayed at the top of an Activity to display non-essential
* non-intrusive messages.
*
*/
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public class SuperCardToast
{
private static final String TAG = "(SuperCardToast)";
private static final String ERROR_CONTEXTNOTACTIVITY = "Context must be an instance of Activity (SuperCardToast)";
private static final String ERROR_CONTAINERNULL = "You must have a LinearLayout with the id of card_container in your layout! (SuperCardToast)";
private static final String ERROR_TYPENULL = "You cannot supply null as a Type! (SuperCardToast)";
private static final String ERROR_NOCLICKLISTENER = "There was no OnClickListener set to the Button. Please call setButtonOnClickListener().";
private static final String ERROR_VIEWCONTAINERNULL = "Either the View or Container was null when trying to dismiss. Did you create and " +
"show a SuperCardToast before trying to dismiss it?";
/**
* This style implements a edit icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_EDITDARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_edit, "EDIT", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a exit icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_EXITDARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_exit, "EXIT", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a information icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_INFODARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_info, "INFO", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a redo icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_REDODARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_redo, "REDO", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a save icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_SAVEDARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_save, "SAVE", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a share icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_SHAREDARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_share, "SHARE", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a undo icon with a dark theme background.
*/
public static final SuperCardToastStyle STYLE_UNDODARK = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_dark_undo, "UNDO", (Color.WHITE), (Color.WHITE),
(com.extlibsupertoasts.R.drawable.background_greytranslucent), (Color.WHITE));
/**
* This style implements a edit icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_EDITLIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_edit, "EDIT", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a exit icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_EXITLIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_exit, "EXIT", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a information icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_INFOLIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_info, "INFO", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a redo icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_REDOLIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_redo, "REDO", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a save icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_SAVELIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_save, "SAVE", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a share icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_SHARELIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_share, "SHARE", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
/**
* This style implements a undo icon with a light theme background.
*/
public static final SuperCardToastStyle STYLE_UNDOLIGHT = new SuperCardToastStyle
(com.extlibsupertoasts.R.drawable.icon_light_undo, "UNDO", (Color.DKGRAY), (Color.DKGRAY),
(com.extlibsupertoasts.R.drawable.background_whitetranslucent), (Color.DKGRAY));
private Context mContext;
private LinearLayout mContainer;
private int sdkVersion = android.os.Build.VERSION.SDK_INT;
private Handler mHandler;
private View toastView;
private LayoutInflater mLayoutInflater;
private TextView mTextView;
private ProgressBar mProgressBar;
private Button mButton;
private View mDivider;
private LinearLayout mRootLayout;
private Type mType = Type.STANDARD;
private ProgressStyle mProgressStyle = ProgressStyle.CIRCLE;
private CharSequence textCharSequence;
private CharSequence buttonTextCharSequence;
private boolean touchDismiss;
private boolean touchImmediateDismiss;
private boolean swipeDismiss;
private int backgroundResource = (SuperToastConstants.BACKGROUND_BLACK);
private int dividerResource = (com.extlibsupertoasts.R.color.white);
private int textColor = (Color.WHITE);
private int buttonTextColor = (Color.WHITE);
private int buttonResource = (SuperToastConstants.BUTTON_DARK_UNDO);
private int duration = (SuperToastConstants.DURATION_LONG);
private Typeface typeface = (Typeface.DEFAULT);
private Typeface buttonTextTypeface = (Typeface.DEFAULT_BOLD);
private Drawable backgroundDrawable;
private Drawable dividerDrawable;
private Drawable buttonDrawable;
private boolean isIndeterminate;
private float textSize = (SuperToastConstants.TEXTSIZE_SMALL);
private float buttonTextSize = (SuperToastConstants.TEXTSIZE_MEDIUM);
private OnClickListener mOnClickListener;
private OnClickListener mButtonOnClickListener;
private boolean isProgressIndeterminate;
private OnDismissListener mOnDismissListener;
/**
* This is used to specify the type of SuperCardToast to
* be used.
*
*/
public enum Type {
/**
* Standard Toast type used for displaying messages.
*/
STANDARD,
/**
* Progress type used for showing progress.
*/
PROGRESS,
/**
* Button type used for user interaction.
*/
BUTTON;
}
/**
* This is used to specify the style of a progress SuperCardToast.
*
*/
public enum ProgressStyle {
/**
* Circle style with a rotating indicator.
*/
CIRCLE,
/**
* Horizontal style with a line indicator.
*/
HORIZONTAL;
}
/**
* Instantiates a new SuperCardToast. You <b>MUST</b> pass an Activity
* as a Context. The style of this SuperCardToast will be Standard.
*
* <br>
*
* @param mContext
*
* <br>
* This must be an Activity Context.
* <br>
*
*/
public SuperCardToast(Context mContext)
{
if(mContext instanceof Activity) {
this.mContext = mContext;
final Activity mActivity = (Activity) mContext;
mLayoutInflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(mActivity.findViewById(R.id.card_container) != null)
{
mContainer = (LinearLayout)
mActivity.findViewById(R.id.card_container);
} else {
throw new IllegalArgumentException(ERROR_CONTAINERNULL);
}
} else {
throw new IllegalArgumentException(ERROR_CONTEXTNOTACTIVITY);
}
}
/**
* Instantiates a new SuperActivityToast. You <b>MUST</b> pass an Activity
* as a Context.
*
* <br>
*
* @param mContext
*
* <br>
* This must be an Activity Context.
* <br>
*
* @param mType
* <br>
* Example: Type.STANDARD
* <br>
*
*/
public SuperCardToast(Context mContext, Type mType)
{
if (mContext instanceof Activity) {
this.mContext = mContext;
final Activity mActivity = (Activity) mContext;
mLayoutInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (mActivity.findViewById(R.id.card_container) != null) {
mContainer = (LinearLayout) mActivity
.findViewById(R.id.card_container);
} else {
throw new IllegalArgumentException(ERROR_CONTAINERNULL);
}
} else {
throw new IllegalArgumentException(ERROR_CONTEXTNOTACTIVITY);
}
if (mType != null) {
this.mType = mType;
} else {
throw new IllegalArgumentException(ERROR_TYPENULL);
}
}
/**
* This is used to show the SuperCardToast. You should
* do all of your modifications to the SuperCardToast before calling
* this method.
*/
public void show()
{
if(mType == Type.STANDARD)
{
toastView = mLayoutInflater
.inflate(R.layout.supercardtoast_toast, mContainer, false);
} else if(mType == Type.BUTTON) {
toastView = mLayoutInflater
.inflate(R.layout.supercardtoast_button, mContainer, false);
} else if(mType == Type.PROGRESS) {
if(mProgressStyle == ProgressStyle.CIRCLE) {
toastView = mLayoutInflater
.inflate(R.layout.supercardtoast_progresscircle, mContainer, false);
} else if(mProgressStyle == ProgressStyle.HORIZONTAL) {
toastView = mLayoutInflater
.inflate(R.layout.supercardtoast_progresshorizontal, mContainer, false);
}
}
if (touchDismiss || touchImmediateDismiss) {
if (touchDismiss) {
toastView.setOnTouchListener(mTouchDismissListener);
}
else if (touchImmediateDismiss) {
toastView.setOnTouchListener(mTouchImmediateDismissListener);
}
} else if (sdkVersion > android.os.Build.VERSION_CODES.HONEYCOMB_MR1
&& swipeDismiss) {
final SwipeDismissListener touchListener = new SwipeDismissListener(
toastView, new SwipeDismissListener.OnDismissCallback() {
@Override
public void onDismiss(View view) {
mContainer.removeView(toastView);
}
});
toastView.setOnTouchListener(touchListener);
}
if(!isIndeterminate) {
mHandler = new Handler();
mHandler.postDelayed(mHideRunnable, duration);
}
mTextView = (TextView)
toastView.findViewById(R.id.messageTextView);
mTextView.setTextColor(textColor);
mTextView.setText(textCharSequence);
mTextView.setTypeface(typeface);
mTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
if(mType == Type.BUTTON) {
mButton = (Button)
toastView.findViewById(R.id.actionButton);
if (buttonDrawable != null) {
mButton.setCompoundDrawablesWithIntrinsicBounds(null, null, buttonDrawable, null);
} else {
mButton.setCompoundDrawablesWithIntrinsicBounds(null, null, mContext.getResources()
.getDrawable(buttonResource), null);
}
if (mButtonOnClickListener != null) {
mButton.setOnClickListener(mButtonOnClickListener);
}
else {
Log.e(TAG, ERROR_NOCLICKLISTENER);
}
mButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, buttonTextSize);
mButton.setTextColor(buttonTextColor);
mButton.setText(buttonTextCharSequence);
mButton.setTypeface(buttonTextTypeface);
mDivider = (View)
toastView.findViewById(R.id.dividerView);
if (dividerDrawable != null) {
if (sdkVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
mDivider.setBackgroundDrawable(dividerDrawable);
} else {
mDivider.setBackground(dividerDrawable);
}
} else {
mDivider.setBackgroundResource(dividerResource);
}
}
if(mType == Type.PROGRESS) {
mProgressBar = (ProgressBar)
toastView.findViewById(R.id.progressBar);
mProgressBar.setIndeterminate(isProgressIndeterminate);
}
mRootLayout = (LinearLayout)
toastView.findViewById(R.id.root_layout);
if(backgroundDrawable != null) {
if (sdkVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
mRootLayout.setBackgroundDrawable(backgroundDrawable);
} else {
mRootLayout.setBackground(backgroundDrawable);
}
} else {
mRootLayout.setBackgroundResource(backgroundResource);
}
if(mOnClickListener != null) {
mRootLayout.setOnClickListener(mOnClickListener);
}
mContainer.setVisibility(View.VISIBLE);
mContainer.addView(toastView);
final Animation mAnimation = getCardAnimation();
mAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation arg0) {
/** Must use Handler to modify ViewGroup in onAnimationEnd() **/
Handler mHandler = new Handler();
mHandler.post(mInvalidateRunnable);
}
@Override
public void onAnimationRepeat(Animation arg0) {
// Do nothing
}
@Override
public void onAnimationStart(Animation arg0) {
// Do nothing
}
});
toastView.startAnimation(mAnimation);
}
//XXX: General methods.
/**
* This is used to set the message text of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* This method can be called again while the SuperCardToast is showing
* to modify the existing message. If your application might show two
* SuperCardToasts at one time you should try to reuse the same
* SuperCardToast by calling this method and {@link #resetDuration(int)}
* </p>
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* Toasts/SuperCardToast are designed to display short non-essential
* messages such as "Message sent!" after the user sends a SMS. Generally
* these messages should rarely display more than one line of text.
* </p>
*
* <br>
*
* @param textCharSequence
*
* <br>
*
*/
public void setText(CharSequence textCharSequence) {
this.textCharSequence = textCharSequence;
if (mTextView != null) {
mTextView.setText(textCharSequence);
}
}
/**
* This is used to set the message text color of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* The text color that you choose should contrast the color of the background.
* Generally the colors white and black are the only colors that should be used
* here.
* </p>
*
* <br>
* @param textColor
* <br>
* Example: (Color.WHITE)
* <br>
*
*/
public void setTextColor(int textColor) {
this.textColor = textColor;
if (mTextView != null) {
mTextView.setTextColor(textColor);
}
}
/**
* This is used to set the style of the SuperCardToast.
*
* <br>
*
* @param mSuperCardToastStyle
* <br>
* Example: (SuperCardToastStyle.STYLE_UNDODARK)
* <br>
*
*/
public void setStyle(SuperCardToastStyle mSuperCardToastStyle) {
this.buttonResource = mSuperCardToastStyle.undoButtonResource;
this.buttonTextCharSequence = mSuperCardToastStyle.buttonTextCharSequence;
this.textColor = mSuperCardToastStyle.messageTextColor;
this.buttonTextColor = mSuperCardToastStyle.buttonTextColor;
this.backgroundResource = mSuperCardToastStyle.backgroundResource;
this.dividerResource = mSuperCardToastStyle.dividerResource;
}
/**
* This is used to set the duration of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* Generally short durations are preferred.
* </p>
*
* <br>
* @param duration
* <br>
* Example: (SuperToastConstants.DURATION_SHORT)
* <br>
*
*/
public void setDuration(int duration) {
this.duration = duration;
}
/**
* This is used to reset the duration of the SuperCardToast
* while it is showing.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* Instead of having overlapping or sequential messages you
* should use this method to reuse an already showing SuperCardToast
* in instances where two or more messages can be showing at the same time.
* </p>
*
* <br>
* @param newDuration
* <br>
* Example: (SuperToastConstants.DURATION_SHORT)
* <br>
*
*/
public void resetDuration(int newDuration) {
if (mHandler != null) {
mHandler.removeCallbacks(mHideRunnable);
mHandler = null;
}
mHandler = new Handler();
mHandler.postDelayed(mHideRunnable, newDuration);
}
/**
* This is used to set an indeterminate duration of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This should be used in conjunction with the PROGRESS Type SuperCardToast.
* Any duration set via {@link #setDuration(int)} will be ignored.
* </p>
*
* <br>
* @param isIndeterminate
* <br>
*
*/
public void setIndeterminate(boolean isIndeterminate) {
this.isIndeterminate = isIndeterminate;
}
/**
* This is used to set a private OnTouchListener to the SuperCardToast
* that will dismiss the SuperCardToast with an Animation.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This method should be used with long running SuperCardToasts in case
* the SuperCardToast comes in between application content and the user.
* This method is not compatible with {@link #setOnClickListener(OnClickListener)}.
* </p>
*
* <br>
*
* @param touchDismiss
*
* <br>
*
*/
public void setTouchToDismiss(boolean touchDismiss) {
this.touchDismiss = touchDismiss;
}
/**
* This is used to set a private OnTouchListener to the SuperCardToast
* that will dismiss the SuperCardToast immediately without an Animation.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This method should be used with long running SuperActivityToasts in case
* the SuperActivityToast comes in between application content and the user.
* This method is not compatible with {@link #setOnClickListener(OnClickListener)}.
* </p>
*
* <br>
*
* @param touchImmediateDismiss
*
* <br>
*
*/
public void setTouchToImmediateDismiss(boolean touchImmediateDismiss) {
this.touchImmediateDismiss = touchImmediateDismiss;
}
/**
* This is used to set a private SwipeDismissListener to the SuperCardToast
* that will dismiss the SuperCardToast when the user swipes the SuperCardToast
* left or right.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This method should be used with long running SuperCardToasts in case
* the SuperCardToast comes in between application content and the user.
* This method is not compatible with {@link #setTouchToDismiss(boolean)}.
* </p>
*
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* This method does not work on pre-honeycomb devices.
* </p>
*
* <br>
*
* @param swipeDismiss
*
* <br>
*
*/
public void setSwipeToDismiss(boolean swipeDismiss) {
this.swipeDismiss = swipeDismiss;
}
/**
* This is used to set an OnClickListener to the SuperCardToast.
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* This method is not compatible with {@link #setTouchToDismiss(boolean)} or
* {@link #setTouchToImmediateDismiss(boolean)}.
* </p>
*
* <br>
* @param mOnClickListener
* <br>
*
*/
public void setOnClickListener(OnClickListener mOnClickListener) {
this.mOnClickListener = mOnClickListener;
}
/**
* This is used to set the background of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This library comes with backgrounds ready to use in your applications.
* If you would like to use your own backgrounds please make sure that
* the background is nine-patch or XML format.
* </p>
*
* <br>
* @param backgroundResource
* <br>
* Example: (SuperToastConstants.BACKGROUND_BLACK)
* <br>
*
*/
public void setBackgroundResource(int backgroundResource) {
this.backgroundResource = backgroundResource;
}
/**
* This is used to set the background of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This library comes with backgrounds ready to use in your applications.
* If you would like to use them please see {@link #setBackgroundResource(int)}.
* </p>
*
* <br>
* @param backgroundDrawable
* <br>
*
*/
public void setBackgroundDrawable(Drawable backgroundDrawable) {
this.backgroundDrawable = backgroundDrawable;
}
/**
* This is used to set the text size of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* Generally the text size should be around 14sp.
* </p>
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* You may specify an integer value as a parameter.
* This method will automatically convert the integer to
* scaled pixels.
* </p>
*
* <br>
* @param textSize
* <br>
* Example: (SuperToastConstants.TEXTSIZE_SMALL)
* <br>
*
*/
public void setTextSize(int textSize) {
this.textSize = textSize;
}
/**
* This is used to set the Typeface of the SuperCardToast text.
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* This library comes with a link to download the Roboto font. To use the
* fonts see {@link #loadRobotoTypeface(String)}.
* </p>
*
* <br>
* @param typeface
* <br>
* Example: (Typeface.DEFAULT) OR (mSuperCardToast.loadRobotoTypeface(SuperToastConstants.
* FONT_ROBOTO_THIN); *
* <br>
*
*/
public void setTypeface(Typeface typeface) {
this.typeface = typeface;
}
/**
* This is used to set an OnDismissListener to the SuperCardToast.
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* Make sure that the OnDismissListener is imported from this library.
* This method is not compatible with other OnDismissListeners.
* </p>
*
* <br>
* @param mOnDismissListener
* <br>
*
*/
public void setOnDismissListener(OnDismissListener mOnDismissListener) {
this.mOnDismissListener = mOnDismissListener;
}
/**
* This is used to dismiss the SuperCardToast.
*
* <br>
*
*/
public void dismiss() {
dismissWithAnimation();
}
/**
* This is used to dismiss the SuperActivityToast immediately without Animation.
*
* <br>
*
*/
public void dismissImmediately() {
if(mHandler != null) {
mHandler.removeCallbacks(mHideRunnable);
mHandler = null;
}
if (toastView != null && mContainer != null) {
mContainer.removeView(toastView);
toastView = null;
} else {
Log.e(TAG, ERROR_VIEWCONTAINERNULL);
}
if(mOnDismissListener != null) {
mOnDismissListener.onDismiss();
}
}
//XXX Progress specific methods.
/**
* This is used to set the ProgressStyle of a PROGRESS Type SuperCardToast.
*
* <br>
* @param mProgressStyle
* <br>
* Example: (ProgressStyle.CIRCLE)
* <br>
*
*/
public void setProgressStyle(ProgressStyle mProgressStyle) {
this.mProgressStyle = mProgressStyle;
}
/**
* This is used to set an indeterminate value to the ProgressBar
* in a PROGRESS Type SuperCardToast.
*
* <br>
* @param isProgressIndeterminate
* <br>
*
*/
public void setProgressIndeterminate(boolean isProgressIndeterminate) {
this.isProgressIndeterminate = isProgressIndeterminate;
}
/**
* This is used to set the progress of the ProgressBar in a
* Progress Type SuperCardToast.
*
* <br>
* @param progress
* <br>
*
*/
public void setProgress(int progress) {
if (mProgressBar != null) {
mProgressBar.setProgress(progress);
}
}
//XXX Button specific methods.
/**
* This is used to set the an OnClickListener to the Button in
* a BUTTON Type SuperCardToast.
*
* <br>
* @param mButtonOnClickListener
* <br>
*
*/
public void setButtonOnClickListener(OnClickListener mButtonOnClickListener) {
this.mButtonOnClickListener = mButtonOnClickListener;
}
/**
* This is used to set the text size of the Button in
* a BUTTON Type SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* Generally the text size should be around 14sp.
* </p>
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* You may specify an integer value as a parameter.
* This method will automatically convert the integer to
* scaled pixels.
* </p>
*
* <br>
* @param buttonTextSize
* <br>
* Example: (SuperToastConstants.TEXTSIZE_SMALL)
* <br>
*
*/
public void setButtonTextSize(int buttonTextSize) {
this.buttonTextSize = buttonTextSize;
}
/**
* This is used to set the Typeface of the Button in
* a BUTTON Type SuperCardToast.
*
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* This library comes with a link to download the Roboto font. To use the
* fonts see {@link #loadRobotoTypeface(String)}.
* </p>
*
* <br>
*
* @param buttonTextTypeface
*
* <br>
*
* Example: (Typeface.DEFAULT) OR (mSuperCardToast.loadRobotoTypeface(SuperToastConstants.
* FONT_ROBOTO_THIN);
*
*
* <br>
*
*/
public void setButtonTextTypeface(Typeface buttonTextTypeface)
{
this.buttonTextTypeface = buttonTextTypeface;
}
/**
* This is used to set the background of the Button in
* a BUTTON Type SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This library comes with backgrounds ready to use in your applications.
* </p>
*
* <br>
* @param buttonResource
* <br>
* Example: (SuperToastConstants.BUTTON_DARK_REDO)
* <br>
*
*/
public void setButtonResource(int buttonResource) {
this.buttonResource = buttonResource;
}
/**
* This is used to set the background Drawable of the Button in
* a BUTTON Type SuperCardToast.
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* This library comes with backgrounds ready to use in your applications.
* To use them please see {@link #setButtonResource(int)}.
* </p>
*
* <br>
* @param buttonDrawable
* <br>
*
*/
public void setButtonDrawable(Drawable buttonDrawable) {
this.buttonDrawable = buttonDrawable;
}
/**
* This is used to set the resource of the divider of the Button in
* a BUTTON Type SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* The resource can also be a color defined via XML. Choose a color that contrasts the
* background of the SuperButtonToast.
* </p>
*
* <br>
*
* @param dividerResource
*
* <br>
*
* Example: (R.color.white)
*
* <br>
*
*/
public void setDividerResource(int dividerResource) {
this.dividerResource = dividerResource;
}
/**
* This is used to set the Drawable of the divider of the Button in
* a BUTTON Type SuperCardToast.
*
* <br>
*
* <p>
* <b> Important note: </b>
* </p>
*
* <p>
* To use a Color instead see {@link #setDividerResource(int)}.
* </p>
*
* <br>
*
* @param dividerDrawable
*
* <br>
*
*/
public void setDividerDrawable(Drawable dividerDrawable) {
this.dividerDrawable = dividerDrawable;
}
/**
* This is used to set the Button text color of the SuperCardToast.
*
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* The text color that you choose should contrast the color of the background.
* Generally the colors white and black are the only colors that should be used
* here. This color should also match the color specified in {@link #setTextColor(int)}.
* </p>
*
* <br>
*
* @param buttonTextColor
*
* <br>
*
* Example: (Color.WHITE)
*
* <br>
*
*/
public void setButtonTextColor(final int buttonTextColor) {
this.buttonTextColor = buttonTextColor;
}
/**
* This is used to set the message text of the Button in the SuperCardToast.
* <br>
*
* <p>
* <b> Design guide: </b>
* </p>
*
* <p>
* The text of the SuperCardToast should be short, and all capital letters.
* </p>
*
* <br>
*
* @param buttonTextCharSequence
*
* <br>
*
*/
public void setButtonText(CharSequence buttonTextCharSequence) {
this.buttonTextCharSequence = buttonTextCharSequence;
if (mButton != null) {
mButton.setText(buttonTextCharSequence);
}
}
// XXX: Getter methods.
/**
* This is used to get the SuperCardToast message TextView.
*
* <br>
*
* @return TextView
*
* <br>
*
*/
public TextView getTextView() {
return mTextView;
}
/**
* This is used to get the SuperCardToast View.
*
* <br>
*
* @return View
*
* <br>
*
*/
public View getView() {
return toastView;
}
/**
* Returns true of the SuperCardToast is currently visible
* to the user.
*
* <br>
*
* @return boolean
*
* <br>
*
*/
public boolean isShowing() {
if (toastView != null) {
return toastView.isShown();
}
else {
return false;
}
}
/**
* This is used to get and load a Roboto font. You <b><i>MUST</i></b> put the
* desired font file in the assets folder of your project. The link to
* download the Roboto fonts is included in this library as a text file. Do
* not modify the names of these fonts.
*
* <br>
* @param typefaceString
* <br>
* Example: (SuperToastConstants.FONT_ROBOTO_THIN)
* <br>
*
* @return Typeface
*
* <br>
*
*/
public Typeface loadRobotoTypeface(String typefaceString) {
return Typeface.createFromAsset(mContext.getAssets(), typefaceString);
}
//XXX: Private methods.
private Animation getCardAnimation()
{
AnimationSet mAnimationSet = new AnimationSet(false);
TranslateAnimation mTranslateAnimation = new TranslateAnimation(0f, 0f, 1f, 0f);
mTranslateAnimation.setDuration(200);
mAnimationSet.addAnimation(mTranslateAnimation);
AlphaAnimation mAlphaAnimation = new AlphaAnimation(0f, 1f);
mAlphaAnimation.setDuration(400);
mAnimationSet.addAnimation(mAlphaAnimation);
RotateAnimation mRotationAnimation = new RotateAnimation(15f, 0f, 0f, 0f);
mRotationAnimation.setDuration(225);
mAnimationSet.addAnimation(mRotationAnimation);
return mAnimationSet;
}
private void dismissWithAnimation()
{
if(sdkVersion > android.os.Build.VERSION_CODES.HONEYCOMB_MR1)
{
int mViewWidth = toastView.getWidth();
toastView.animate()
.translationX(mViewWidth)
.alpha(0)
.setDuration(500)
.setListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
/** Must use Handler to modify ViewGroup in onAnimationEnd() **/
Handler mHandler = new Handler();
mHandler.post(mHideImmediateRunnable);
}
});
}
else
{
AnimationSet mAnimationSet = new AnimationSet(false);
final Activity mActivity = (Activity) mContext;
Display display = mActivity.getWindowManager().getDefaultDisplay();
int width = display.getWidth();
TranslateAnimation mTranslateAnimation = new TranslateAnimation(0f, width, 0f, 0f);
mTranslateAnimation.setDuration(500);
mAnimationSet.addAnimation(mTranslateAnimation);
AlphaAnimation mAlphaAnimation = new AlphaAnimation(1f, 0f);
mAlphaAnimation.setDuration(500);
mAnimationSet.addAnimation(mAlphaAnimation);
mAnimationSet.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
/** Must use Handler to modify ViewGroup in onAnimationEnd() **/
Handler mHandler = new Handler();
mHandler.post(mHideImmediateRunnable);
}
@Override
public void onAnimationRepeat(Animation animation)
{
// Not used
}
@Override
public void onAnimationStart(Animation animation)
{
// Not used
}
});
toastView.startAnimation(mAnimationSet);
}
}
private Runnable mHideRunnable = new Runnable()
{
public void run()
{
dismiss();
}
};
private Runnable mHideImmediateRunnable = new Runnable()
{
public void run()
{
dismissImmediately();
}
};
private Runnable mInvalidateRunnable = new Runnable()
{
public void run()
{
if(mContainer != null) {
mContainer.invalidate();
}
}
};
private OnTouchListener mTouchDismissListener = new OnTouchListener() {
int timesTouched;
@Override
public boolean onTouch(View view, MotionEvent event) {
/** This is a little hack to prevent the user from repeatedly
* touching the SuperCardToast causing erratic behavior **/
if (timesTouched == 0) {
dismiss();
}
timesTouched++;
return false;
}
};
private OnTouchListener mTouchImmediateDismissListener = new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
dismissImmediately();
return false;
}
};
} | [
"johnpersano@gmail.com"
] | johnpersano@gmail.com |
dc55414822f2ff7374fcf311e611d31b0f545c29 | 41b47d09eb3006f2565b1c334729322352943baa | /src/DISABLED-DEPRECEATED-ONLOL/disabled/onlol/fetcher/api/model/ApiMasteryDTO.java | 36b2acd41fa9ee566141700f79db7e163ce27393 | [] | no_license | d3sd1/rito-api | 5c8ef87751877fb3d171f56ca833ada91e3a3ff4 | 3f81a65573a730582a3c295b17c23f7502e92192 | refs/heads/dev | 2023-04-18T13:01:14.716310 | 2020-01-13T09:41:45 | 2020-01-13T09:41:45 | 233,258,460 | 0 | 0 | null | 2021-04-26T19:52:37 | 2020-01-11T16:06:43 | HTML | UTF-8 | Java | false | false | 664 | java | package status.disabled.onlol.fetcher.api.model;
/*
/lol/match/v4/matches/{matchId}
*/
public class ApiMasteryDTO {
private Integer masteryId = 0;
private Integer rank = 0;
public Integer getMasteryId() {
return masteryId;
}
public void setMasteryId(Integer masteryId) {
this.masteryId = masteryId;
}
public Integer getRank() {
return rank;
}
public void setRank(Integer rank) {
this.rank = rank;
}
@Override
public String toString() {
return "SampleMastery{" +
"masteryId=" + masteryId +
", rank=" + rank +
'}';
}
}
| [
"ag00631981@techmahindra.com"
] | ag00631981@techmahindra.com |
612392cda1de766d9b5cbe2540d0581787782976 | d0e6d6c290777d9f6917108a4189dcdf9fdcda3f | /qamservices/src/main/java/com/archsystems/patterns/cor/stage/SaveStage.java | 2674df70a7174bdc7a4360f9798f95d2feb21f97 | [] | no_license | Archsystemsllc/cmmiprototype | 964156e938318e5ab511c226ab040228114afe19 | e6df938ae831c9fd09fc98d9a747b0b8bba82c52 | refs/heads/master | 2021-03-27T20:53:47.203399 | 2018-01-26T19:16:23 | 2018-01-26T19:16:23 | 106,455,605 | 1 | 1 | null | 2017-10-17T16:37:20 | 2017-10-10T18:28:17 | CSS | UTF-8 | Java | false | false | 2,257 | java | package com.archsystems.patterns.cor.stage;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.archsystems.patterns.cor.FileUploadTO;
import com.archsystems.patterns.cor.Stage;
import com.archsystems.patterns.cor.TransferObject;
import com.archsystemsinc.exception.FileUploadException;
import com.archsystemsinc.logging.monitor.StageMonitor;
import com.archsystemsinc.qam.model.HealthCommunity;
import com.archsystemsinc.qam.repository.HealthCommunityRepository;
import com.archsystemsinc.qam.utils.PoiUtils;
@Component
public class SaveStage implements Stage{
private static final Logger log = Logger.getLogger(SaveStage.class);
@Autowired
private HealthCommunityRepository healthCommunityRepository;
private FileUploadTO payload;
@Override
public TransferObject getPayload() {
return payload;
}
public void setPayload(FileUploadTO payload) {
this.payload=payload;
}
@Override
public String getStageName() {
return"Save Stage";
}
@Override
public Stage execute(TransferObject payloadLocal, StageMonitor monitor) throws FileUploadException {
log.debug("--> execute");
try {
this.payload = (FileUploadTO) payloadLocal;
if(payload.getParsedData() != null && !payload.getParsedData().isEmpty()) {
List<HealthCommunity> savedData = healthCommunityRepository.save(payload.getParsedData());
PoiUtils.updateHealthDataWithMergedColData(savedData, this.payload.getConfigData());
payload.setSavedData(savedData);
monitor.appendMessage(this.getStageName(), "Saved data for file, count: "+
payload.getUploadedFile().getName()+"' "+payload.getParsedData().size());
}else {
monitor.appendMessage(this.getStageName(), "No data to save!!");
}
}catch(Exception e) {
e.printStackTrace();
monitor.appendMessage(this.getStageName(), ", Failed to save file data.");
this.payload.setMessage(this.getStageName()+", Failed to save file.");
this.payload.setStatus("ERROR");
throw new FileUploadException(e.getMessage());
}
log.debug("<-- execute");
return this;
}
}
| [
"ptotta@archsystemsinc.com"
] | ptotta@archsystemsinc.com |
b63e14c0499211d286771df956eeea5d726b7d51 | cf440f4e79d022e15a1da331d37e366261aad057 | /src/main/java/com/codecool/quest/logic/items/Armory.java | 3105687fa189930d73f63f043d10fffa89f32022 | [
"CC0-1.0",
"Apache-2.0"
] | permissive | CodecoolGlobal/quest-java-brb | 3c3ec8122644a81bf992d2642729b692e1f4196c | 867f11b409077328bd814de998a47a4c51dfaa4b | refs/heads/master | 2022-08-31T12:38:49.792522 | 2020-05-27T07:30:46 | 2020-05-27T07:30:46 | 225,324,229 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,113 | java | package com.codecool.quest.logic.items;
import com.codecool.quest.logic.Cell;
import com.codecool.quest.logic.actors.Player;
public abstract class Armory extends Item{
int durability;
int maxDurability;
Player player;
private int worth;
public Player getPlayer() {
return player;
}
public void setPlayer(Player player) {
this.player = player;
}
public int getDurability() {
return durability;
}
public void setDurability(int durability) {
this.durability = durability;
}
public Armory(Cell cell) {
super(cell);
}
public abstract void pickedUp(Player player);
public abstract void destroyArmory();
@Override
public String getTileName() {
return null;
}
public int getMaxDurability() {
return maxDurability;
}
public void setMaxDurability(int maxDurability) {
this.maxDurability = maxDurability;
}
public void loseDurability(){
this.setDurability(getDurability()-1);
if(this.getDurability() <= 0) this.destroyArmory();
}
}
| [
"szentkuti.adrian@gmail.com"
] | szentkuti.adrian@gmail.com |
239cfbf581f0c20052446eb54de6b5039992c65f | eb29c5f8459b52e4e65f299d0e47a60d3bbebd4a | /COMPILER/src/MoreJavaTest.java | cb161162f804963da6773c8c1c405135c450db42 | [] | no_license | mayankgandhi/453_PA4 | d907cd557e60455cfed5d2e3bdaba91718c27d0a | 70d10016c75172e959473ff13e2a58d117dbc2f0 | refs/heads/master | 2020-08-29T21:20:22.654610 | 2019-10-29T15:52:57 | 2019-10-29T15:52:57 | 218,177,038 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,727 | java | /*
* Programming Assignment 4 - Alexis Tinoco, Mayank Gandhi
*/
import java.io.*;
import java.util.*;
public class MoreJavaTest{
public static void TestThreeAddrGen(){
System.out.println("*******************************************");
System.out.println("Testing Three Address Generation");
String eval = "public class test {}";
MoreJava parser = new MoreJava();
String result = "";
assert(parser.getThreeAddr(eval).equals(result));
parser = new MoreJava();
eval = "public class test {int x; int y; void mainEntry() {} void blarg(){} }";
result = "";
assert(parser.getThreeAddr(eval).equals(result));
parser = new MoreJava();
eval = "public class test {int x; int y; void mainEntry(){ int x; x = 3; if(2 < 3 && 5 < 4){ x = 42; }}}";
result = "temp0 = 3\n"+
"x = temp0\n"+
"temp0 = 2\n"+
"temp1 = 3\n"+
"IF_LT: temp0, temp1, trueLabel1\n"+
"GOTO: falseLabel0\n"+
"trueLabel1\n"+
"temp2 = 5\n"+
"temp3 = 4\n"+
"IF_LT: temp2, temp3, trueLabel0\n"+
"GOTO: falseLabel0\n"+
"trueLabel0\n"+
"temp0 = 42\n"+
"x = temp0\n"+
"falseLabel0\n";
assert(parser.getThreeAddr(eval).equals(result));
System.out.println(parser.getThreeAddr(eval));
System.out.println("Congrats: three address generation tests passed! Now make your own test cases "+
"(this is only a subset of what we will test your code on)");
System.out.println("*******************************************");
}
public static void main(String[] args){
TestThreeAddrGen();
}
}
| [
"mayankgandhi50@gmail.com"
] | mayankgandhi50@gmail.com |
ab59de7808df195e57f24766af7261672e44db4b | 79648f9fc41b893ae9b0c8007a16fe15bbd87a61 | /src/com/flipkart/model/Notification.java | b66bf5a8ba55b1ee339ead5d5d24ea00d297871e | [] | no_license | anushkagarg13/StudentManagementSystem-Flipkart | e8753501eed00ffd54db7df2a2a393d3b40bdda3 | cf2bd8b4e44ef1d67dfe5f259fa6f79e9b56de9a | refs/heads/master | 2022-11-05T05:48:42.190248 | 2020-06-20T06:47:48 | 2020-06-20T06:47:48 | 273,314,660 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 901 | java | package com.flipkart.model;
public class Notification {
private int registrationId;
private int studentId;
private double payableAmount;
private int payModeId;
private String timeStamp;
public int getRegistrationId() {
return registrationId;
}
public void setRegistrationId(int registrationId) {
this.registrationId = registrationId;
}
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public double getPayableAmount() {
return payableAmount;
}
public void setPayableAmount(double payableAmount) {
this.payableAmount = payableAmount;
}
public int getPayModeId() {
return payModeId;
}
public void setPayModeId(int payModeId) {
this.payModeId = payModeId;
}
public String getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(String timeStamp) {
this.timeStamp = timeStamp;
}
}
| [
"anushkagarg1311@gmail.com"
] | anushkagarg1311@gmail.com |
e86fd9b07e6da59161ddc6e260e279ef286a7b7d | df4bc12c4759c42c1c667ddc3a673b07b15f8ec5 | /rating-date-service/src/main/java/com/micro/ratingdateservice/resources/RatingDataResource.java | 8d65e99e7745688cb7a43c72dda63594c1e60ce0 | [] | no_license | badr182/micro-services | 38ba5be14a3f1324b15350c0f2fd2fc9081bb497 | b028b6f6d62212480094b39080c73b4cb9324282 | refs/heads/master | 2023-09-01T09:14:54.078500 | 2021-10-19T19:46:09 | 2021-10-19T19:46:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 978 | java | package com.micro.ratingdateservice.resources;
import java.util.Arrays;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.micro.ratingdateservice.models.Rating;
import com.micro.ratingdateservice.models.UserRating;
@RestController
@RequestMapping("/ratingsdata")
public class RatingDataResource {
@GetMapping("/{movieId}")
public Rating getRating(@PathVariable("movieId") String movieId) {
return new Rating(movieId, 4);
}
@GetMapping("users/{userId}")
public UserRating getUserRating(@PathVariable("userId") String userId) {
List<Rating> rating = Arrays.asList(
new Rating("1234", 4),
new Rating("5678", 4)
);
UserRating userRating = new UserRating();
userRating.setUserRating(rating);
return userRating;
}
}
| [
"badrakkar182@gmail.com"
] | badrakkar182@gmail.com |
de72709a2f9358ec5c4fc6dd7768cacdbb5f3bfd | f123515744dd7d7ba4a70f88d435077d5407084a | /src/main/java/org/dvsa/testing/lib/Util.java | abd23931a3fea1eca2ea2b097c1d6c49e1433132 | [
"MIT"
] | permissive | dvsa/vol-page-objects | 91e8d6c96c5b015072ee99fae0a51b8234440972 | 45d723394325c3eaff703bc4834cf0b2f77b09b9 | refs/heads/master | 2023-07-21T15:20:20.347011 | 2018-09-25T10:56:45 | 2018-09-25T10:56:45 | 137,421,697 | 4 | 1 | NOASSERTION | 2023-09-01T17:01:39 | 2018-06-15T00:14:20 | Java | UTF-8 | Java | false | false | 144 | java | package org.dvsa.testing.lib;
public class Util {
public static int radioPosition(boolean option) {
return option ? 1 : 2;
}
}
| [
"rodney.ruswa@bjss.com"
] | rodney.ruswa@bjss.com |
d37e857d950c325cfd6fc6f59750dd5c253f948c | 257f5d9f3e3d6fadecd785a41b5504fe72a90fd7 | /src/day57_abstraction_polymorphism/abstract_class_vs_interface/AbstractB.java | 6d3fe3a07a240e6a23dc443ff7c768597ca1cd4d | [] | no_license | Dilnoz9140/StaticBlockDemo.java | c36fde2a3a47d080575fb83f67be4db028c244fb | 42f634d97b406d925ee04201e75a77c41779d011 | refs/heads/master | 2023-06-20T14:44:58.699643 | 2021-07-17T21:16:07 | 2021-07-17T21:16:07 | 385,745,238 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 156 | java | package day57_abstraction_polymorphism.abstract_class_vs_interface;
public abstract class AbstractB extends AbstractA implements InterfaceA,InterfaceB {
}
| [
"dilnoz8605@icloud.com"
] | dilnoz8605@icloud.com |
164fa3f2092117ba4a98e801f4745fd881f19b2f | 02d263f0e15f5448924b966568f986498234a9bd | /core/jreleaser-model/src/main/java/org/jreleaser/model/Twitter.java | 56bfdf910ac2dd2d239e45f9b1168ae084fcf752 | [
"Apache-2.0"
] | permissive | DennisRippinger/jreleaser | 3dd0692d88d60b3d9cc5165c80737d19700aab9c | 65b0e520d3bcc6c129e725ae42d65a1bfa6b55aa | refs/heads/main | 2023-05-04T02:38:30.269492 | 2021-05-21T20:31:43 | 2021-05-21T20:31:43 | 370,090,801 | 0 | 0 | Apache-2.0 | 2021-05-23T15:37:14 | 2021-05-23T15:37:14 | null | UTF-8 | Java | false | false | 4,083 | java | /*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2021 Andres Almiray.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jreleaser.model;
import org.jreleaser.util.Env;
import java.util.Map;
import static org.jreleaser.util.Constants.HIDE;
import static org.jreleaser.util.Constants.UNSET;
import static org.jreleaser.util.MustacheUtils.applyTemplate;
import static org.jreleaser.util.StringUtils.isNotBlank;
/**
* @author Andres Almiray
* @since 0.1.0
*/
public class Twitter extends AbstractAnnouncer {
public static final String NAME = "twitter";
public static final String TWITTER_CONSUMER_KEY = "TWITTER_CONSUMER_KEY";
public static final String TWITTER_CONSUMER_SECRET = "TWITTER_CONSUMER_SECRET";
public static final String TWITTER_ACCESS_TOKEN = "TWITTER_ACCESS_TOKEN";
public static final String TWITTER_ACCESS_TOKEN_SECRET = "TWITTER_ACCESS_TOKEN_SECRET";
private String consumerKey;
private String consumerSecret;
private String accessToken;
private String accessTokenSecret;
private String status;
public Twitter() {
super(NAME);
}
void setAll(Twitter twitter) {
super.setAll(twitter);
this.consumerKey = twitter.consumerKey;
this.consumerSecret = twitter.consumerSecret;
this.accessToken = twitter.accessToken;
this.accessTokenSecret = twitter.accessTokenSecret;
this.status = twitter.status;
}
public String getResolvedStatus(JReleaserContext context) {
Map<String, Object> props = context.props();
context.getModel().getRelease().getGitService().fillProps(props, context.getModel());
return applyTemplate(status, props);
}
public String getResolvedConsumerKey() {
return Env.resolve(TWITTER_CONSUMER_KEY, consumerKey);
}
public String getResolvedConsumerSecret() {
return Env.resolve(TWITTER_CONSUMER_SECRET, consumerSecret);
}
public String getResolvedAccessToken() {
return Env.resolve(TWITTER_ACCESS_TOKEN, accessToken);
}
public String getResolvedAccessTokenSecret() {
return Env.resolve(TWITTER_ACCESS_TOKEN_SECRET, accessTokenSecret);
}
public String getConsumerKey() {
return consumerKey;
}
public void setConsumerKey(String consumerKey) {
this.consumerKey = consumerKey;
}
public String getConsumerSecret() {
return consumerSecret;
}
public void setConsumerSecret(String consumerSecret) {
this.consumerSecret = consumerSecret;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getAccessTokenSecret() {
return accessTokenSecret;
}
public void setAccessTokenSecret(String accessTokenSecret) {
this.accessTokenSecret = accessTokenSecret;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
protected void asMap(Map<String, Object> props) {
props.put("consumerKey", isNotBlank(getResolvedConsumerKey()) ? HIDE : UNSET);
props.put("consumerSecret", isNotBlank(getResolvedConsumerSecret()) ? HIDE : UNSET);
props.put("accessToken", isNotBlank(getResolvedAccessToken()) ? HIDE : UNSET);
props.put("accessTokenSecret", isNotBlank(getResolvedAccessTokenSecret()) ? HIDE : UNSET);
props.put("status", status);
}
}
| [
"aalmiray@gmail.com"
] | aalmiray@gmail.com |
9e8abc725bba271d6ce76b739220a946b142128a | c2210171932755d752112f0591e26803cf05a758 | /src/main/java/cn/worldwalker/onecard/weixin/rpc/WeiXinRpcImpl.java | 539a0ae151ecadcf070797ea00d30b005ca118ba | [] | no_license | worldwalker77/onecard-weixin | 71fa2eb2aa91dbb901f6ca1be7085857992215e9 | dc4c2b24bb8e6bc193e5ba60e7857f22451e55fc | refs/heads/master | 2021-09-09T13:38:31.169072 | 2018-03-16T15:33:21 | 2018-03-16T15:33:21 | 103,874,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 796 | java | package cn.worldwalker.onecard.weixin.rpc;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import cn.worldwalker.onecard.weixin.common.utils.httpclient.HttpClientUtils;
import cn.worldwalker.onecard.weixin.constant.Constant;
@Service
public class WeiXinRpcImpl implements WeiXinRpc{
@Override
public String getOpenId(String code) {
String url = Constant.getOpenidAndAccessCode;
url = url.replace("CODE", code);
JSONObject obj = null;
try {
String str = HttpClientUtils.get(url);
obj = JSONObject.fromObject(str);
} catch (Exception e) {
e.printStackTrace();
}
if (obj != null && obj.containsKey("errcode"))
return null;
else{
String openid = obj.getString("openid");
return openid;
}
}
}
| [
"421269683@qq.com"
] | 421269683@qq.com |
2b57c5a186c611fa5de1f40cbdc2affc2f5acf37 | d60b12875a5b8195b56a0608c47bc17b77eeda4e | /src/test/AllTest.java | e835628e81a0dbdb61cad84d52fae936265c2120 | [] | no_license | teodorstrut/JavaFX-Interpreter | fbaff6b93b522c0dacbefd31b224a66fed8afd42 | e3adb851e2559c6364d72702a6b8fb140dbd0986 | refs/heads/master | 2020-05-04T15:49:43.517576 | 2019-04-03T09:54:11 | 2019-04-03T09:54:11 | 179,256,751 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,518 | java | //package test;
//
//import controller.MyController;
//import exception.MyException;
//import model.ADT.*;
//import model.Expression.ArithExp;
//import model.Expression.ConstExp;
//import model.Expression.Exp;
//import model.Expression.VarExp;
//import model.PrgState;
//import model.Statement.*;
//import org.junit.jupiter.api.Test;
//import repository.MyIRepository;
//import repository.MyRepository;
//
//import java.io.BufferedReader;
//import java.io.IOException;
//
//import static org.junit.jupiter.api.Assertions.assertEquals;
//
//public class AllTest {
// @Test
// void ConstExpTest() throws MyException {
// MyIDictionary<String, Integer> tbl = new MyDictionary<String, Integer>();
// MyIDictionary<Integer, Integer> hp = new MyDictionary<Integer, Integer>();
// Exp first=new ConstExp(5);
// assertEquals(5,first.eval(tbl,hp));
// Exp second=new ConstExp(19);
// assertEquals(19,second.eval(tbl,hp));
// Exp third=new ConstExp(1000);
// assertEquals(1000,third.eval(tbl,hp));
// }
// @Test
// void VarExpTest() throws MyException {
// MyDictionary<String, Integer> tbl = new MyDictionary<String, Integer>();
// MyIDictionary<Integer, Integer> hp = new MyDictionary<Integer, Integer>();
// tbl.getH_Map().put("i",5);
// tbl.getH_Map().put("j",19);
// tbl.getH_Map().put("k",1000);
// Exp first=new VarExp("i");
// assertEquals(5,first.eval(tbl,hp));
// Exp second=new VarExp("j");
// assertEquals(19,second.eval(tbl,hp));
// Exp third=new VarExp("k");
// assertEquals(1000,third.eval(tbl,hp));
// }
// @Test
// void ArithExpTest() throws MyException {
// MyIDictionary<String, Integer> tbl = new MyDictionary<String, Integer>();
// MyIDictionary<Integer, Integer> hp = new MyDictionary<Integer, Integer>();
// Exp expression1=new ArithExp('+',new ConstExp(5), new ConstExp(6));
// Exp expression2=new ArithExp('-',new ConstExp(5), new ConstExp(6));
// Exp expression3=new ArithExp('*',new ConstExp(5), new ConstExp(6));
// Exp expression4=new ArithExp('/',new ConstExp(5), new ConstExp(6));
//
// assertEquals(11,expression1.eval(tbl,hp));
// assertEquals(-1,expression2.eval(tbl,hp));
// assertEquals(30,expression3.eval(tbl,hp));
// assertEquals(0,expression4.eval(tbl,hp));
//
// }
// @Test
// void FileStmtTest() throws IOException, MyException {
// IStmt ex1 = new CompStmt(
// new CompStmt(new OpenRFile("fname","src/testfiles/test.in"),
// new ReadFile(new VarExp("fname"),"val")),
// new CompStmt(
// new PrintStmt(new VarExp("val")),
// new CompStmt(new IfStmt(new VarExp("val"),
// new CompStmt(new ReadFile(new VarExp("fname"),"val"),new PrintStmt(new VarExp("val"))),
// new PrintStmt(new ConstExp(0))),
// new CloseRFile(new VarExp("fname")))));
// PrgState program = new PrgState(50,new MyDictionary<String, Integer>(), new MyStack<IStmt>(), new MyList<Integer>(), new MyFileTable<Integer, MyPair<String, BufferedReader>>(), new MyDictionary<Integer, Integer>() , ex1);
// program = ex1.execute(program);
// MyIRepository repo = new MyRepository(program,"src/testfiles/testlog.txt");
// MyController ctr = new MyController(repo);
// ctr.allStep();
// }
// @Test
// void WhileStmtTest() throws IOException, MyException{
// IStmt ex1 = new CompStmt(new AssignStmt("v",new ConstExp(6)),
// new CompStmt(new WhileStmt(new ArithExp('-',new VarExp("v"),new ConstExp(4)),new CompStmt(new PrintStmt(new VarExp("v")),new AssignStmt("v",new ArithExp('-',new VarExp("v"),new ConstExp(1))))),
// new PrintStmt(new VarExp("v"))));
// PrgState program = new PrgState(99,new MyDictionary<String, Integer>(), new MyStack<IStmt>(), new MyList<Integer>(), new MyFileTable<Integer, MyPair<String, BufferedReader>>(), new MyDictionary<Integer, Integer>() , ex1);
// MyIRepository repo = new MyRepository(program,"src/testfiles/testlog.txt");
// MyController ctr = new MyController(repo);
// ctr.allStep();
// }
//}
| [
"teodorstrut@yahoo.com"
] | teodorstrut@yahoo.com |
f543fca7336cc735db25dde366f0ed23104aa8e5 | 4ec00c0c07bf1f7cff7e4166100653965e30e63a | /src/Latihan6/Cloneable.java | 97e0d91b321f35dfe840e23b148233fa0a5eabb6 | [] | no_license | mesati/jobsheet_5 | be34e2f180fc02fec57fedd9b82c0f6686c8276c | 3e0e2e250367bc8e83694036512a3392fdcfc26e | refs/heads/master | 2020-03-28T03:03:49.239706 | 2018-09-06T04:27:02 | 2018-09-06T04:27:02 | 147,616,897 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 646 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Latihan6;
/**
*
* @author WINDOWS 10
*/
public interface Cloneable {
public class Test implements Cloneable{
@Override
public Test clone() throws CloneNotSupportedException{
return (Test) super.clone();
}
public static void main(String[] args) {
try {
new Test().clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
}
| [
"WINDOWS 10@WINDOWS"
] | WINDOWS 10@WINDOWS |
74a6c391b25244100978aac9cddf01ebb87ff3c8 | c2be157026fc831d73246f2b107b4ab66dbe8248 | /app/src/main/java/com/bugke/demo/designdemo/fragment/WeathFragment.java | 3b210a9e11b9f5de5ba9bb31c2e83c63fc7bf988 | [] | no_license | sunO2/DesignDemo | 3b0ad8aa422f1bf7d427c655fc30c13ae86c1de3 | a5221b38ba4553d7dfa2e2dfd3c179c236ab1d15 | refs/heads/master | 2021-06-05T22:16:22.041334 | 2016-10-24T15:40:30 | 2016-10-24T15:40:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,170 | java | package com.bugke.demo.designdemo.fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.bugke.demo.designdemo.View.EmptyLayout;
import com.bugke.demo.designdemo.baidu.BaiDuLocationListener;
import com.bugke.demo.designdemo.baidu.MHLocationCaballck;
import com.bugke.demo.designdemo.bean.AndroidBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* "http://p.codekk.com/api/op/page/0?type=mix"
* Created by Hezhihu89 on 2016/10/20 0020.
*/
public class WeathFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener,BaseQuickAdapter.RequestLoadMoreListener,MHLocationCaballck{
private static final String KEY = "key=rel353ljdjfap5sc";
private String cityCode ="";
private OkHttpClient mOkHttpClient;
private BaseAdapter mAdapter;
private int mCurrentPage = 0;
private SwipeRefreshLayout swipeRefreshLayout;
private AndroidBean androidBean;
public static BaseFragment newInstance(String... egs) {
Bundle bundle = new Bundle();
bundle.putString(Pamans.TITLE,egs[0]);
bundle.putString(Pamans.URL,egs[1]);
WeathFragment fragmentPage = new WeathFragment();
fragmentPage.setArguments(bundle);
return fragmentPage;
}
@Nullable
@Override
public RootLayout getCreateView() {
EmptyLayout emptyLayout = new EmptyLayout(getContext());
swipeRefreshLayout = new SwipeRefreshLayout(getContext());
swipeRefreshLayout.setColorSchemeColors(Color.RED, Color.BLUE, Color.GREEN);
// RecyclerView recyclerView = new RecyclerView(getContext());
// swipeRefreshLayout.setOnRefreshListener(this);
// recyclerView.setItemAnimator(new DefaultItemAnimator());
// recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
// mAdapter = new BaseAdapter(null);
// mAdapter.isFirstOnly(false);
// mAdapter.setOnLoadMoreListener(this);
// mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
// recyclerView.setAdapter(mAdapter);
// swipeRefreshLayout.addView(recyclerView,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// emptyLayout.bindView(swipeRefreshLayout);
return emptyLayout;
}
public void getData(int mCurrentPage){
this.mCurrentPage = mCurrentPage;
getData();
}
@Override
protected void getData() {
if(cityCode.equals("")){
return;
}
mOkHttpClient =new OkHttpClient();
Request.Builder requestBuilder = new Request.Builder().url(URL+cityCode+"&"+KEY);
//可以省略,默认是GET请求
requestBuilder.method("GET",null);
Request request = requestBuilder.build();
Call mcall= mOkHttpClient.newCall(request);
mcall.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (null != response.cacheResponse()) {
String str = response.cacheResponse().toString();
} else {
String str = response.body().string();
Log.i("wangshu", "network---" + str);
if(null == androidBean){
// androidBean = new AndroidBean(str);
}else{
// androidBean.parsDatas(str);
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// mAdapter.setNewData(androidBean.mList);
swipeRefreshLayout.setRefreshing(false);
// mAdapter.hiedLoadingMore();
showSuccess();
}
});
}
}
});
}
@Override
public void onRefresh() {
getData(0);
swipeRefreshLayout.setRefreshing(true);
}
@Override
public void onLoadMoreRequested() {
getData(mCurrentPage+=1);
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if(cityCode.equals("")){
BaiDuLocationListener.getIns(getContext()).start(this);
}else{
getData();
}
}
@Override
public void locationCallBack(BDLocation location, LocationClient client) {
cityCode = location.getCityCode();
location.getCity();
getData();
client.stop();
}
}
| [
"354137379@qq.com"
] | 354137379@qq.com |
ccec96ac79f06a842d1c20d04374b5cd0be1d2e0 | e8e0834c96236cebd5e8251ba3c859e886058dc7 | /src/main/java/techguns/tileentities/ChemLabTileEnt.java | 846cad41ea1852db173c83080b6cad23c4687b7f | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | pWn3d1337/Techguns_1.14 | 13cf372b83809c257d12232e4b5e12915f41521d | c1fd43b702dcd57f492105cd575eae2c71b43aab | refs/heads/master | 2023-01-30T23:30:57.670708 | 2020-05-16T16:46:28 | 2020-05-16T16:46:28 | 264,366,792 | 0 | 1 | NOASSERTION | 2022-09-03T23:37:58 | 2020-05-16T05:32:56 | Java | UTF-8 | Java | false | false | 14,618 | java | package techguns.tileentities;
import java.util.Random;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidActionResult;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import techguns.TGItems;
import techguns.TGSounds;
import techguns.Techguns;
import techguns.gui.ButtonConstants;
import techguns.tileentities.operation.ChemLabRecipes;
import techguns.tileentities.operation.FluidTankPlus;
import techguns.tileentities.operation.ITileEntityFluidTanks;
import techguns.tileentities.operation.ItemStackHandlerPlus;
import techguns.tileentities.operation.MachineOperation;
import techguns.tileentities.operation.MachineSlotFluid;
import techguns.tileentities.operation.MachineSlotItem;
import techguns.util.ItemUtil;
public class ChemLabTileEnt extends BasicMachineTileEnt implements ITileEntityFluidTanks{
private Random rng = new Random();
protected static final float SOUND_VOLUME=0.65f;
public static final int BUTTON_ID_DUMP_INPUT = ButtonConstants.BUTTON_ID_REDSTONE+1;
public static final int BUTTON_ID_DUMP_OUTPUT = ButtonConstants.BUTTON_ID_REDSTONE+2;
public static final int BUTTON_ID_TOGGLE_DRAIN = ButtonConstants.BUTTON_ID_REDSTONE+3;
public ChemLabFluidHandler fluidHandler;
public FluidTank inputTank;
public FluidTank outputTank;
protected boolean drainInput=false;
public static final int SLOT_INPUT1=0;
public static final int SLOT_INPUT2=1;
public static final int SLOT_BOTTLE=2;
public static final int SLOT_OUTPUT=3;
public static final int SLOT_UPGRADE=4;
public MachineSlotItem input1;
public MachineSlotItem input2;
public MachineSlotItem input_bottle;
public MachineSlotFluid input_fluid;
public static final int CAPACITY_INPUT_TANK=8*Fluid.BUCKET_VOLUME;
public static final int CAPACITY_OUTPUT_TANK=16*Fluid.BUCKET_VOLUME;
public ChemLabTileEnt() {
super(5, true, 20000);
this.inputTank = new FluidTankPlus(this,CAPACITY_INPUT_TANK);
this.inputTank.setTileEntity(this);
this.outputTank = new FluidTankPlus(this,CAPACITY_OUTPUT_TANK);
this.outputTank.setTileEntity(this);
this.fluidHandler= new ChemLabFluidHandler(this);
input1 = new MachineSlotItem(this, SLOT_INPUT1);
input2 = new MachineSlotItem(this, SLOT_INPUT2);
input_bottle = new MachineSlotItem(this, SLOT_BOTTLE);
input_fluid = new MachineSlotFluid(inputTank);
this.inventory = new ItemStackHandlerPlus(5) {
@Override
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
setContentsChanged(true);
}
@Override
protected boolean allowItemInSlot(int slot, ItemStack stack) {
switch (slot) {
case SLOT_INPUT1:
case SLOT_INPUT2:
case SLOT_BOTTLE:
return isItemValidForSlot(slot, stack);
case SLOT_OUTPUT:
return false;
case SLOT_UPGRADE:
return TGItems.isMachineUpgrade(stack);
}
return false;
}
@Override
protected boolean allowExtractFromSlot(int slot, int amount) {
return slot == SLOT_OUTPUT;
}
};
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent(Techguns.MODID+".container.chemlab", new Object[0]);
}
@Override
public boolean hasCapability(Capability<?> capability, Direction facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Override
public <T> T getCapability(Capability<T> capability, Direction facing) {
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ? (T)fluidHandler : super.getCapability(capability, facing);
}
public boolean isItemValidForSlot(int slot, ItemStack item) {
if(slot==SLOT_BOTTLE){
return ChemLabRecipes.allowInFlaskSlot(item);
} else if(slot==SLOT_INPUT1 && this.input1.get().isEmpty() && this.input2.get().isEmpty()){
return !ChemLabRecipes.allowInFlaskSlot(item) && ChemLabRecipes.hasRecipeUsing(item);
} else if (slot==SLOT_INPUT1 && this.input1.get().isEmpty() && !this.input2.get().isEmpty()){
return !ChemLabRecipes.allowInFlaskSlot(item) && ChemLabRecipes.allowAsInput2(this.input2.get(), item);
} else if (slot==SLOT_INPUT1 && !this.input1.get().isEmpty()){
return ItemUtil.isItemEqual(this.input1.get(), item);
} else if (slot==SLOT_INPUT2 && !this.input1.get().isEmpty()){
return !ChemLabRecipes.allowInFlaskSlot(item) && ChemLabRecipes.allowAsInput2(this.input1.get(), item);
} else if (slot==SLOT_INPUT2 && !this.input2.get().isEmpty()){
return ItemUtil.isItemEqual(this.input2.get(), item);
}
return false;
}
@Override
public void readClientDataFromNBT(CompoundNBT tags) {
super.readClientDataFromNBT(tags);
drainInput=tags.getBoolean("drainInput");
CompoundNBT inputTankTags = tags.getCompoundTag("inputTank");
this.inputTank.readFromNBT(inputTankTags);
CompoundNBT outputTankTags = tags.getCompoundTag("outputTank");
this.outputTank.readFromNBT(outputTankTags);
}
@Override
public void writeClientDataToNBT(CompoundNBT tags) {
super.writeClientDataToNBT(tags);
tags.setBoolean("drainInput", this.drainInput);
CompoundNBT inputTankTags = new CompoundNBT();
this.inputTank.writeToNBT(inputTankTags);
tags.setTag("inputTank", inputTankTags);
CompoundNBT outputTankTags = new CompoundNBT();
this.outputTank.writeToNBT(outputTankTags);
tags.setTag("outputTank", outputTankTags);
}
@Override
protected int getNeededPower() {
if(this.currentOperation!=null) {
return this.currentOperation.getPowerPerTick();
}
return 0;
}
protected boolean canOutput(MachineOperation output) {
if (this.canOutput(output.getItemOutput0(),SLOT_OUTPUT)){
// check liquid output
FluidStack out = output.getFluidOutput0();
if (out==null) {
return true;
} else {
return this.outputTank.canFillFluidType(out) && this.outputTank.fill(out, false)==out.amount;
}
}
return false;
}
protected boolean canConsume(MachineOperation output) {
int multi = output.getStackMultiplier();
ItemStack in1 = output.getInputs().get(0);
ItemStack in2 = output.getInputs().get(1);
ItemStack bottle = output.getInputs().get(2);
FluidStack fluidIn =null;
int amount=0;
if (!output.getFluid_inputs().isEmpty()) {
fluidIn = output.getFluid_inputs().get(0);
if (fluidIn!=null) {
amount=fluidIn.amount;
}
}
return this.input1.canConsumeWithMultiplier(in1,multi) &&
this.input2.canConsumeWithMultiplier(in2,multi) &&
this.input_bottle.canConsumeWithMultiplier(bottle,multi) &&
this.input_fluid.canConsume(amount*multi);
}
protected void consume(MachineOperation output) {
this.input1.consume(output.getNeededAmountItem(SLOT_INPUT1));
this.input2.consume(output.getNeededAmountItem(SLOT_INPUT2));
this.input_bottle.consume(output.getNeededAmountItem(SLOT_BOTTLE));
this.input_fluid.consume(output.getNeededAmountFluid(0));
}
@Override
protected void checkAndStartOperation() {
this.setContentsChanged(false);
MachineOperation op = ChemLabRecipes.getOutputFor(this);
if (op != null && canOutput(op)) {
//check multiplier
int maxStack=this.getMaxMachineUpgradeMultiplier(SLOT_UPGRADE);
int multiplier=1;
//try higher stacksize
int i;
for (i=maxStack;i>1;--i){
op.setStackMultiplier(i);
if(this.canOutput(op) && canConsume(op)){
multiplier=i;
break;
}
}
op.setStackMultiplier(multiplier);
//drain
this.consume(op);
this.currentOperation = op;
this.progress = 0;
this.totaltime = 100;
if (!this.world.isRemote) {
this.needUpdate();
}
}
}
@Override
protected void finishedOperation() {
ItemStack itemOut = this.currentOperation.getItemOutput0();
if (!itemOut.isEmpty()) {
if (!this.inventory.getStackInSlot(SLOT_OUTPUT).isEmpty()) {
this.inventory.insertItemNoCheck(SLOT_OUTPUT, itemOut, false);
//this.inventory.getStackInSlot(SLOT_OUTPUT).grow(itemOut.getCount());
} else {
this.inventory.setStackInSlot(SLOT_OUTPUT, itemOut);
}
}
FluidStack fluidOut = this.currentOperation.getFluidOutput0();
if(fluidOut!=null) {
this.outputTank.fillInternal(fluidOut, true);
}
}
@Override
protected void playAmbientSound() {
int soundTick1 = 1;
int halfTime = (Math.round((float) totaltime * 0.5f));
if (this.progress == soundTick1 || this.progress == soundTick1 + halfTime) {
//worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "techguns:machines.chemlabWork", 1.0F, 1.0F, true);
world.playSound(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), TGSounds.CHEM_LAB_WORK,SoundCategory.BLOCKS, SOUND_VOLUME, 1.0F, true );
}
if ( this.world.isRemote) {
int delay = 10;
if (this.progress % delay == 0) {
world.spawnParticle(EnumParticleTypes.SPELL, this.getPos().getX()+0.5d + rng.nextFloat(), this.getPos().getY()+0.5d + rng.nextFloat(), this.getPos().getZ()+0.5d + rng.nextFloat(), 0, 1, 0);
}
}
}
public FluidStack getCurrentInputFluid() {
return this.inputTank.getFluid();
}
public FluidStack getCurrentOutputFluid() {
return this.outputTank.getFluid();
}
public int getValidSlotForItemInMachine(ItemStack item) {
if (ChemLabRecipes.allowInFlaskSlot(item)) {
if (this.input_bottle.get().isEmpty()) {
return SLOT_BOTTLE;
} else if (OreDictionary.itemMatches(this.input_bottle.get(), item, true)) {
return SLOT_BOTTLE;
}
} else if (!this.input1.get().isEmpty() && OreDictionary.itemMatches(this.input1.get(), item, true)) {
return SLOT_INPUT1;
} else if (!this.input2.get().isEmpty() && OreDictionary.itemMatches(this.input2.get(), item, true)) {
return SLOT_INPUT2;
} else if (this.input1.get().isEmpty() && ChemLabRecipes.hasRecipeUsing(item)) {
return SLOT_INPUT1;
} else if (!this.input1.get().isEmpty() && this.input2.get().isEmpty() && (ChemLabRecipes.allowAsInput2(this.input1.get(), item))) {
return SLOT_INPUT2;
} else if (TGItems.isMachineUpgrade(item)) {
return SLOT_UPGRADE;
}
return -1;
}
@Override
public void saveTanksToNBT(CompoundNBT tags) {
CompoundNBT inputTankTags = new CompoundNBT();
this.inputTank.writeToNBT(inputTankTags);
tags.setTag("inputTank", inputTankTags);
CompoundNBT outputTankTags = new CompoundNBT();
this.outputTank.writeToNBT(outputTankTags);
tags.setTag("outputTank", outputTankTags);
}
@Override
public void loadTanksFromNBT(CompoundNBT tags) {
CompoundNBT inputTank = tags.getCompoundTag("inputTank");
this.inputTank.readFromNBT(inputTank);
CompoundNBT outputTank = tags.getCompoundTag("outputTank");
this.outputTank.readFromNBT(outputTank);
}
public byte getDrainMode() {
return (byte) (this.drainInput?1:0);
}
@Override
public void buttonClicked(int id, PlayerEntity ply, String data) {
if(id<BUTTON_ID_DUMP_INPUT){
super.buttonClicked(id, ply, data);
} else {
if (this.isUseableByPlayer(ply)){
switch(id){
case BUTTON_ID_DUMP_INPUT: //drain input
this.inputTank.setFluid(null);
this.needUpdate();
break;
case BUTTON_ID_DUMP_OUTPUT: //drain output
this.outputTank.setFluid(null);
this.needUpdate();
break;
case BUTTON_ID_TOGGLE_DRAIN: //toogle drain
this.drainInput=!this.drainInput;
this.needUpdate();
break;
}
}
}
}
public static class ChemLabFluidHandler implements IFluidHandler {
private ChemLabTileEnt tile;
protected IFluidTankProperties[] tankProperties;
public ChemLabFluidHandler(ChemLabTileEnt tile) {
super();
this.tile = tile;
}
@Override
public IFluidTankProperties[] getTankProperties() {
if ( tankProperties == null) {
this.tankProperties = new IFluidTankProperties[]{new FluidTankPropertiesWrapper(tile.inputTank), new FluidTankPropertiesWrapper(tile.outputTank)};
}
return tankProperties;
}
@Override
public int fill(FluidStack resource, boolean doFill) {
return tile.inputTank.fill(resource, doFill);
}
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
if(!tile.drainInput) {
return tile.outputTank.drain(resource, doDrain);
} else {
return tile.inputTank.drain(resource, doDrain);
}
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
if(!tile.drainInput) {
return tile.outputTank.drain(maxDrain, doDrain);
} else {
return tile.inputTank.drain(maxDrain, doDrain);
}
}
}
@Override
public boolean onFluidContainerInteract(PlayerEntity player, Hand hand, IFluidHandlerItem fluidhandleritem, ItemStack stack) {
if(!this.isUseableByPlayer(player)) return false;
boolean interacted = false;
if(this.drainInput) {
interacted = FluidUtil.interactWithFluidHandler(player, hand, this.inputTank);
} else {
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (playerInventory != null)
{
FluidActionResult fluidActionResult = FluidUtil.tryFillContainerAndStow(stack, this.outputTank, playerInventory, Integer.MAX_VALUE, player,true);
if (!fluidActionResult.isSuccess())
{
fluidActionResult = FluidUtil.tryEmptyContainerAndStow(stack, this.inputTank, playerInventory, Integer.MAX_VALUE, player, true);
}
if (fluidActionResult.isSuccess())
{
player.setHeldItem(hand, fluidActionResult.getResult());
interacted=true;
}
}
}
return interacted;
}
}
| [
"teamolympuscaptain@gmail.com"
] | teamolympuscaptain@gmail.com |
fff7b927226c6860376224c5ff64071f466ba3cd | 8a2104dd23bfab0dbed4fe4c62adf84f8d546cf4 | /src/main/java/life/picacg/community/community/dto/CommentCreateDTO.java | 3d0ee119561d87c5d73b2819d1047bf2d2285280 | [] | no_license | zhenghaishan25672/picAcg | c89cbd5bc1955203f18e7b7203cbdfb328aa6b92 | 9ea5e15a5b9dd0284762387413a3c02562db601f | refs/heads/master | 2022-07-05T14:29:45.484404 | 2020-01-25T01:06:21 | 2020-01-25T01:06:21 | 225,827,942 | 5 | 0 | null | 2022-06-17T02:43:22 | 2019-12-04T09:24:30 | Java | UTF-8 | Java | false | false | 552 | java | package life.picacg.community.community.dto;
import lombok.Data;
/*数据传输对象(Data Transfer Object)*/
/*
1.依据现有的类代码,即可方便的构造出DTO对象,而无需重新进行分析。
2.减少请求次数,大大提高效率。
3.按需组织DTO对象,页面需要的字段我才组织,不需要的我不组织,可以避免传输整个表的字段,一定程度上提高了安全性。
*/
@Data
public class CommentCreateDTO {
private Long parentId;
private String content;
private Integer type;
}
| [
"997728584@qq.com"
] | 997728584@qq.com |
27f8f41c1da20c0446fe70dc89e0b6b92de9a323 | 939d01e43df980c33c02bcb375f0e35a48b5657a | /app/src/main/java/com/example/cs435projectjava/LocationView.java | 9ee15b2bde1f2aa4aa4512c690f2e0c5d40bcbc5 | [] | no_license | tpolderman22/CS445ProjectJava | f36a6550a58951bf349a694c6521b71240306bce | 5378c6db0eacca98c2b5a1e9d7386326dc2b84dc | refs/heads/master | 2023-05-03T19:05:01.373302 | 2021-05-08T02:38:50 | 2021-05-08T02:38:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,121 | java | package com.example.cs435projectjava;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import org.w3c.dom.Text;
/**
* show the time slots available at the location
*/
public class LocationView extends AppCompatActivity implements AsyncResponse{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_events_on_location);
//the calendar view and the submit button for picking dates
CalendarView appointmentCal = findViewById(R.id.appointmentCalendar);
Button submit = findViewById(R.id.submitDate);
//store this activity as an AsyncResponse and Context
Context context = this;
AsyncResponse ar = this;
String dateChosen = String.valueOf(appointmentCal.getDate()); //keep track of the date the user selects
//store the location name and description that are passed in from the previous activity. Also get the logged in user id
Bundle extras = getIntent().getExtras();
String userid = extras.getString("userid");
String locationName = extras.getString("locationName"); //the name of this location
String locationDescription = extras.getString("locationDescription"); //the name of this location
//set the text to the name and description so the user cna see what they have chosen
TextView title = findViewById(R.id.locationName);
title.setText(locationName);
TextView description = findViewById(R.id.locationDescription);
description.setText(locationDescription);
/**
* when the date is changed, save that value so that the user can submit it and add it to their selected times
*/
appointmentCal.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
String dateChosen = year + "/" + month + "/" + dayOfMonth;
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
description.setText(dateChosen);
//execute the database call and add the selected date to the appointments table.
BackgroundWorker worker = new BackgroundWorker(context, ar);
worker.execute("selectTime", locationName, userid, dateChosen);
finish();
startActivity(getIntent());
}
});
}
@Override
public void processFinish(String result, String additionalData) {
if(result.contains("Sign-up Complete")){
//TODO allow the user to see the sign up they successfully made
}
}
}
| [
"tpolderman0302@gmail.com"
] | tpolderman0302@gmail.com |
e8abb0366eb9bc47d693508cc85be89d90d00c2f | 900d3d4e311010f6d8619e358102c8e48cf40368 | /Graphs/Graph/BFS.java | 675ce12e899bb0727922af9ceeb88f3099b7cb58 | [] | no_license | Rranjan04/Problem-Solving-Using-DSA | d1dfb4af2f4dcee253847100305488adc25fba16 | c31d7e7c5ef63405f9c47e9487568c58d08c6c8e | refs/heads/main | 2023-06-12T13:48:55.655456 | 2021-07-07T07:44:47 | 2021-07-07T07:44:47 | 379,459,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,079 | java | package Graphs.Graph;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class BFS {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int v = s.nextInt();
int e = s.nextInt();
int[][] am = new int[v][v];
for(int i=0;i<e;i++){
int v1 = s.nextInt();
int v2 = s.nextInt();
am[v1][v2] = 1;
am[v2][v1] = 1;
}
s.close();
for(int i=0;i<v;i++){
for(int j=0;j<v;j++){
System.out.print(am[i][j]+" ");
}
System.out.println();
}
System.out.println();
bfs(am);
}
static void bfs(int[][] am){
boolean[] visited = new boolean[am.length];
for(int i=0;i<visited.length;i++){
if(!visited[i]){
bfsHelp(am, visited, i);
}
}
}
static void bfsHelp(int[][] am, boolean[] visited,int v){
Queue<Integer> q = new LinkedList<>();
q.add(v);
visited[v] =true;
while(!q.isEmpty()){
int node = q.poll();
System.out.print(node+" ");
for(int i=0;i<am.length;i++){
if(!visited[i] && am[node][i]==1){
visited[i] = true;
q.add(i);
}
}
}
}
}
| [
"rranjan1922@gmail.com"
] | rranjan1922@gmail.com |
ae8bb061249a5937ac528e2d473e5d0e31ce8a4e | 1ad530ee59490140c3e82a2d856ff3c36546acdd | /RotateOnOff/src/com/wind/RotateOnOff/RotateOnOffActivity.java | 6a9ea991563411f04a6be0b22587d34c8751a7d3 | [] | no_license | qianzui/nd-china | cf7cdcd4a32c0bc969b920b14515981770602a32 | 074aa22cc7369b343c4269b10123810553402d65 | refs/heads/master | 2016-09-06T16:09:25.498368 | 2013-04-16T05:44:28 | 2013-04-16T05:44:28 | 38,470,797 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,210 | java | package com.wind.RotateOnOff;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.widget.RemoteViews;
public class RotateOnOffActivity extends AppWidgetProvider {
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onDeleted(context, appWidgetIds);
Log.v("ooxx", "onDeleted");
}
@Override
public void onEnabled(Context context) {
// TODO Auto-generated method stub
super.onEnabled(context);
Log.v("ooxx", "onEnabled");
}
@Override
public void onDisabled(Context context) {
// TODO Auto-generated method stub
super.onDisabled(context);
Log.v("ooxx", "onDisabled");
}
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
super.onReceive(context, intent);
Log.v("ooxx", "onReceive");
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context,RotateOnOffActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.main);
views.setOnClickPendingIntent(R.id.rotate, pendingIntent);
int flag =Settings.System.getInt(context.getContentResolver(),Settings.System.ACCELEROMETER_ROTATION, 0);
if(flag == 1){
views.setImageViewResource(R.id.rotate, R.drawable.autorotate_off);
}
else {
views.setImageViewResource(R.id.rotate, R.drawable.autorotate_on);
}
Settings.System.putInt(context.getContentResolver(),Settings.System.ACCELEROMETER_ROTATION,flag==1?0:1);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
Log.v("ooxx", "onUpdate");
}
} | [
"hqxmail@gmail.com"
] | hqxmail@gmail.com |
3aba01ece31c9adbe9a39004d685107c309e83a8 | fe7198a98aeed92e221edd0ab112f0609b6db7c4 | /java/org/apache/catalina/valves/AbstractAccessLogValve.java | a55b2896bab14bab211c706583a35d4fc355898b | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"bzip2-1.0.6",
"CPL-1.0",
"CDDL-1.0",
"Zlib",
"EPL-1.0",
"LZMA-exception"
] | permissive | Shaoxubao/tomcat-study | 89ce196b33ebc6107b92382f429e9f88c4c91d69 | 932c87776f048cbd1da4b9cecd069361bb148ffb | refs/heads/master | 2022-02-05T14:58:55.429738 | 2020-02-24T07:32:22 | 2020-02-24T07:32:22 | 242,671,969 | 1 | 0 | Apache-2.0 | 2022-01-21T23:46:19 | 2020-02-24T07:23:29 | Java | UTF-8 | Java | false | false | 62,137 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.valves;
import java.io.CharArrayWriter;
import java.io.IOException;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.apache.catalina.AccessLog;
import org.apache.catalina.Globals;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Session;
import org.apache.catalina.connector.ClientAbortException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.TLSUtil;
import org.apache.coyote.ActionCode;
import org.apache.coyote.RequestInfo;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.collections.SynchronizedStack;
import org.apache.tomcat.util.net.IPv6Utils;
/**
* <p>Abstract implementation of the <b>Valve</b> interface that generates a web
* server access log with the detailed line contents matching a configurable
* pattern. The syntax of the available patterns is similar to that supported by
* the <a href="https://httpd.apache.org/">Apache HTTP Server</a>
* <code>mod_log_config</code> module.</p>
*
* <p>Patterns for the logged message may include constant text or any of the
* following replacement strings, for which the corresponding information
* from the specified Response is substituted:</p>
* <ul>
* <li><b>%a</b> - Remote IP address
* <li><b>%A</b> - Local IP address
* <li><b>%b</b> - Bytes sent, excluding HTTP headers, or '-' if no bytes
* were sent
* <li><b>%B</b> - Bytes sent, excluding HTTP headers
* <li><b>%h</b> - Remote host name (or IP address if
* <code>enableLookups</code> for the connector is false)
* <li><b>%H</b> - Request protocol
* <li><b>%l</b> - Remote logical username from identd (always returns '-')
* <li><b>%m</b> - Request method
* <li><b>%p</b> - Local port
* <li><b>%q</b> - Query string (prepended with a '?' if it exists, otherwise
* an empty string
* <li><b>%r</b> - First line of the request
* <li><b>%s</b> - HTTP status code of the response
* <li><b>%S</b> - User session ID
* <li><b>%t</b> - Date and time, in Common Log Format format
* <li><b>%u</b> - Remote user that was authenticated
* <li><b>%U</b> - Requested URL path
* <li><b>%v</b> - Local server name
* <li><b>%D</b> - Time taken to process the request, in millis
* <li><b>%T</b> - Time taken to process the request, in seconds
* <li><b>%F</b> - Time taken to commit the response, in millis
* <li><b>%I</b> - current Request thread name (can compare later with stacktraces)
* <li><b>%X</b> - Connection status when response is completed:
* <ul>
* <li><code>X</code> = Connection aborted before the response completed.</li>
* <li><code>+</code> = Connection may be kept alive after the response is sent.</li>
* <li><code>-</code> = Connection will be closed after the response is sent.</li>
* </ul>
* </ul>
* <p>In addition, the caller can specify one of the following aliases for
* commonly utilized patterns:</p>
* <ul>
* <li><b>common</b> - <code>%h %l %u %t "%r" %s %b</code>
* <li><b>combined</b> -
* <code>%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"</code>
* </ul>
*
* <p>
* There is also support to write information from the cookie, incoming
* header, the Session or something else in the ServletRequest.<br>
* It is modeled after the
* <a href="https://httpd.apache.org/">Apache HTTP Server</a> log configuration
* syntax:</p>
* <ul>
* <li><code>%{xxx}i</code> for incoming headers
* <li><code>%{xxx}o</code> for outgoing response headers
* <li><code>%{xxx}c</code> for a specific cookie
* <li><code>%{xxx}r</code> xxx is an attribute in the ServletRequest
* <li><code>%{xxx}s</code> xxx is an attribute in the HttpSession
* <li><code>%{xxx}t</code> xxx is an enhanced SimpleDateFormat pattern
* (see Configuration Reference document for details on supported time patterns)
* </ul>
*
* <p>
* Conditional logging is also supported. This can be done with the
* <code>conditionUnless</code> and <code>conditionIf</code> properties.
* If the value returned from ServletRequest.getAttribute(conditionUnless)
* yields a non-null value, the logging will be skipped.
* If the value returned from ServletRequest.getAttribute(conditionIf)
* yields the null value, the logging will be skipped.
* The <code>condition</code> attribute is synonym for
* <code>conditionUnless</code> and is provided for backwards compatibility.
* </p>
*
* <p>
* For extended attributes coming from a getAttribute() call,
* it is you responsibility to ensure there are no newline or
* control characters.
* </p>
*
* @author Craig R. McClanahan
* @author Jason Brittain
* @author Remy Maucherat
* @author Takayuki Kaneko
* @author Peter Rossbach
*/
public abstract class AbstractAccessLogValve extends ValveBase implements AccessLog {
private static final Log log = LogFactory.getLog(AbstractAccessLogValve.class);
/**
* The list of our time format types.
*/
private enum FormatType {
CLF, SEC, MSEC, MSEC_FRAC, SDF
}
/**
* The list of our port types.
*/
private enum PortType {
LOCAL, REMOTE
}
//------------------------------------------------------ Constructor
public AbstractAccessLogValve() {
super(true);
}
// ----------------------------------------------------- Instance Variables
/**
* enabled this component
*/
protected boolean enabled = true;
/**
* Use IPv6 canonical representation format as defined by RFC 5952.
*/
private boolean ipv6Canonical = false;
/**
* The pattern used to format our access log lines.
*/
protected String pattern = null;
/**
* The size of our global date format cache
*/
private static final int globalCacheSize = 300;
/**
* The size of our thread local date format cache
*/
private static final int localCacheSize = 60;
/**
* <p>Cache structure for formatted timestamps based on seconds.</p>
*
* <p>The cache consists of entries for a consecutive range of
* seconds. The length of the range is configurable. It is
* implemented based on a cyclic buffer. New entries shift the range.</p>
*
* <p>There is one cache for the CLF format (the access log standard
* format) and a HashMap of caches for additional formats used by
* SimpleDateFormat.</p>
*
* <p>Although the cache supports specifying a locale when retrieving a
* formatted timestamp, each format will always use the locale given
* when the format was first used. New locales can only be used for new formats.
* The CLF format will always be formatted using the locale
* <code>en_US</code>.</p>
*
* <p>The cache is not threadsafe. It can be used without synchronization
* via thread local instances, or with synchronization as a global cache.</p>
*
* <p>The cache can be created with a parent cache to build a cache hierarchy.
* Access to the parent cache is threadsafe.</p>
*
* <p>This class uses a small thread local first level cache and a bigger
* synchronized global second level cache.</p>
*/
protected static class DateFormatCache {
protected class Cache {
/* CLF log format */
private static final String cLFFormat = "dd/MMM/yyyy:HH:mm:ss Z";
/* Second used to retrieve CLF format in most recent invocation */
private long previousSeconds = Long.MIN_VALUE;
/* Value of CLF format retrieved in most recent invocation */
private String previousFormat = "";
/* First second contained in cache */
private long first = Long.MIN_VALUE;
/* Last second contained in cache */
private long last = Long.MIN_VALUE;
/* Index of "first" in the cyclic cache */
private int offset = 0;
/* Helper object to be able to call SimpleDateFormat.format(). */
private final Date currentDate = new Date();
protected final String cache[];
private SimpleDateFormat formatter;
private boolean isCLF = false;
private Cache parent = null;
private Cache(Cache parent) {
this(null, parent);
}
private Cache(String format, Cache parent) {
this(format, null, parent);
}
private Cache(String format, Locale loc, Cache parent) {
cache = new String[cacheSize];
for (int i = 0; i < cacheSize; i++) {
cache[i] = null;
}
if (loc == null) {
loc = cacheDefaultLocale;
}
if (format == null) {
isCLF = true;
format = cLFFormat;
formatter = new SimpleDateFormat(format, Locale.US);
} else {
formatter = new SimpleDateFormat(format, loc);
}
formatter.setTimeZone(TimeZone.getDefault());
this.parent = parent;
}
private String getFormatInternal(long time) {
long seconds = time / 1000;
/* First step: if we have seen this timestamp
during the previous call, and we need CLF, return the previous value. */
if (seconds == previousSeconds) {
return previousFormat;
}
/* Second step: Try to locate in cache */
previousSeconds = seconds;
int index = (offset + (int)(seconds - first)) % cacheSize;
if (index < 0) {
index += cacheSize;
}
if (seconds >= first && seconds <= last) {
if (cache[index] != null) {
/* Found, so remember for next call and return.*/
previousFormat = cache[index];
return previousFormat;
}
/* Third step: not found in cache, adjust cache and add item */
} else if (seconds >= last + cacheSize || seconds <= first - cacheSize) {
first = seconds;
last = first + cacheSize - 1;
index = 0;
offset = 0;
for (int i = 1; i < cacheSize; i++) {
cache[i] = null;
}
} else if (seconds > last) {
for (int i = 1; i < seconds - last; i++) {
cache[(index + cacheSize - i) % cacheSize] = null;
}
first = seconds - (cacheSize - 1);
last = seconds;
offset = (index + 1) % cacheSize;
} else if (seconds < first) {
for (int i = 1; i < first - seconds; i++) {
cache[(index + i) % cacheSize] = null;
}
first = seconds;
last = seconds + (cacheSize - 1);
offset = index;
}
/* Last step: format new timestamp either using
* parent cache or locally. */
if (parent != null) {
synchronized(parent) {
previousFormat = parent.getFormatInternal(time);
}
} else {
currentDate.setTime(time);
previousFormat = formatter.format(currentDate);
if (isCLF) {
StringBuilder current = new StringBuilder(32);
current.append('[');
current.append(previousFormat);
current.append(']');
previousFormat = current.toString();
}
}
cache[index] = previousFormat;
return previousFormat;
}
}
/* Number of cached entries */
private int cacheSize = 0;
private final Locale cacheDefaultLocale;
private final DateFormatCache parent;
protected final Cache cLFCache;
private final Map<String, Cache> formatCache = new HashMap<>();
protected DateFormatCache(int size, Locale loc, DateFormatCache parent) {
cacheSize = size;
cacheDefaultLocale = loc;
this.parent = parent;
Cache parentCache = null;
if (parent != null) {
synchronized(parent) {
parentCache = parent.getCache(null, null);
}
}
cLFCache = new Cache(parentCache);
}
private Cache getCache(String format, Locale loc) {
Cache cache;
if (format == null) {
cache = cLFCache;
} else {
cache = formatCache.get(format);
if (cache == null) {
Cache parentCache = null;
if (parent != null) {
synchronized(parent) {
parentCache = parent.getCache(format, loc);
}
}
cache = new Cache(format, loc, parentCache);
formatCache.put(format, cache);
}
}
return cache;
}
public String getFormat(long time) {
return cLFCache.getFormatInternal(time);
}
public String getFormat(String format, Locale loc, long time) {
return getCache(format, loc).getFormatInternal(time);
}
}
/**
* Global date format cache.
*/
private static final DateFormatCache globalDateCache =
new DateFormatCache(globalCacheSize, Locale.getDefault(), null);
/**
* Thread local date format cache.
*/
private static final ThreadLocal<DateFormatCache> localDateCache =
new ThreadLocal<DateFormatCache>() {
@Override
protected DateFormatCache initialValue() {
return new DateFormatCache(localCacheSize, Locale.getDefault(), globalDateCache);
}
};
/**
* The system time when we last updated the Date that this valve
* uses for log lines.
*/
private static final ThreadLocal<Date> localDate =
new ThreadLocal<Date>() {
@Override
protected Date initialValue() {
return new Date();
}
};
/**
* Are we doing conditional logging. default null.
* It is the value of <code>conditionUnless</code> property.
*/
protected String condition = null;
/**
* Are we doing conditional logging. default null.
* It is the value of <code>conditionIf</code> property.
*/
protected String conditionIf = null;
/**
* Name of locale used to format timestamps in log entries and in
* log file name suffix.
*/
protected String localeName = Locale.getDefault().toString();
/**
* Locale used to format timestamps in log entries and in
* log file name suffix.
*/
protected Locale locale = Locale.getDefault();
/**
* Array of AccessLogElement, they will be used to make log message.
*/
protected AccessLogElement[] logElements = null;
/**
* Array of elements where the value needs to be cached at the start of the
* request.
*/
protected CachedElement[] cachedElements = null;
/**
* Should this valve use request attributes for IP address, hostname,
* protocol and port used for the request.
* Default is <code>false</code>.
* @see #setRequestAttributesEnabled(boolean)
*/
protected boolean requestAttributesEnabled = false;
/**
* Buffer pool used for log message generation. Pool used to reduce garbage
* generation.
*/
private SynchronizedStack<CharArrayWriter> charArrayWriters =
new SynchronizedStack<>();
/**
* Log message buffers are usually recycled and re-used. To prevent
* excessive memory usage, if a buffer grows beyond this size it will be
* discarded. The default is 256 characters. This should be set to larger
* than the typical access log message size.
*/
private int maxLogMessageBufferSize = 256;
/**
* Does the configured log pattern include a known TLS attribute?
*/
private boolean tlsAttributeRequired = false;
// ------------------------------------------------------------- Properties
public int getMaxLogMessageBufferSize() {
return maxLogMessageBufferSize;
}
public void setMaxLogMessageBufferSize(int maxLogMessageBufferSize) {
this.maxLogMessageBufferSize = maxLogMessageBufferSize;
}
public boolean getIpv6Canonical() {
return ipv6Canonical;
}
public void setIpv6Canonical(boolean ipv6Canonical) {
this.ipv6Canonical = ipv6Canonical;
}
/**
* {@inheritDoc}
* Default is <code>false</code>.
*/
@Override
public void setRequestAttributesEnabled(boolean requestAttributesEnabled) {
this.requestAttributesEnabled = requestAttributesEnabled;
}
/**
* {@inheritDoc}
*/
@Override
public boolean getRequestAttributesEnabled() {
return requestAttributesEnabled;
}
/**
* @return the enabled flag.
*/
public boolean getEnabled() {
return enabled;
}
/**
* @param enabled
* The enabled to set.
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* @return the format pattern.
*/
public String getPattern() {
return this.pattern;
}
/**
* Set the format pattern, first translating any recognized alias.
*
* @param pattern The new pattern
*/
public void setPattern(String pattern) {
if (pattern == null) {
this.pattern = "";
} else if (pattern.equals(Constants.AccessLog.COMMON_ALIAS)) {
this.pattern = Constants.AccessLog.COMMON_PATTERN;
} else if (pattern.equals(Constants.AccessLog.COMBINED_ALIAS)) {
this.pattern = Constants.AccessLog.COMBINED_PATTERN;
} else {
this.pattern = pattern;
}
logElements = createLogElements();
cachedElements = createCachedElements(logElements);
}
/**
* Return whether the attribute name to look for when
* performing conditional logging. If null, every
* request is logged.
* @return the attribute name
*/
public String getCondition() {
return condition;
}
/**
* Set the ServletRequest.attribute to look for to perform
* conditional logging. Set to null to log everything.
*
* @param condition Set to null to log everything
*/
public void setCondition(String condition) {
this.condition = condition;
}
/**
* Return whether the attribute name to look for when
* performing conditional logging. If null, every
* request is logged.
* @return the attribute name
*/
public String getConditionUnless() {
return getCondition();
}
/**
* Set the ServletRequest.attribute to look for to perform
* conditional logging. Set to null to log everything.
*
* @param condition Set to null to log everything
*/
public void setConditionUnless(String condition) {
setCondition(condition);
}
/**
* Return whether the attribute name to look for when
* performing conditional logging. If null, every
* request is logged.
* @return the attribute name
*/
public String getConditionIf() {
return conditionIf;
}
/**
* Set the ServletRequest.attribute to look for to perform
* conditional logging. Set to null to log everything.
*
* @param condition Set to null to log everything
*/
public void setConditionIf(String condition) {
this.conditionIf = condition;
}
/**
* Return the locale used to format timestamps in log entries and in
* log file name suffix.
* @return the locale
*/
public String getLocale() {
return localeName;
}
/**
* Set the locale used to format timestamps in log entries and in
* log file name suffix. Changing the locale is only supported
* as long as the AccessLogValve has not logged anything. Changing
* the locale later can lead to inconsistent formatting.
*
* @param localeName The locale to use.
*/
public void setLocale(String localeName) {
this.localeName = localeName;
locale = findLocale(localeName, locale);
}
// --------------------------------------------------------- Public Methods
/**
* Log a message summarizing the specified request and response, according
* to the format specified by the <code>pattern</code> property.
*
* @param request Request being processed
* @param response Response being processed
*
* @exception IOException if an input/output error has occurred
* @exception ServletException if a servlet error has occurred
*/
@Override
public void invoke(Request request, Response response) throws IOException,
ServletException {
if (tlsAttributeRequired) {
// The log pattern uses TLS attributes. Ensure these are populated
// before the request is processed because with NIO2 it is possible
// for the connection to be closed (and the TLS info lost) before
// the access log requests the TLS info. Requesting it now causes it
// to be cached in the request.
request.getAttribute(Globals.CERTIFICATES_ATTR);
}
for (CachedElement element : cachedElements) {
element.cache(request);
}
getNext().invoke(request, response);
}
@Override
public void log(Request request, Response response, long time) {
if (!getState().isAvailable() || !getEnabled() || logElements == null
|| condition != null
&& null != request.getRequest().getAttribute(condition)
|| conditionIf != null
&& null == request.getRequest().getAttribute(conditionIf)) {
return;
}
/**
* XXX This is a bit silly, but we want to have start and stop time and
* duration consistent. It would be better to keep start and stop
* simply in the request and/or response object and remove time
* (duration) from the interface.
*/
long start = request.getCoyoteRequest().getStartTime();
Date date = getDate(start + time);
CharArrayWriter result = charArrayWriters.pop();
if (result == null) {
result = new CharArrayWriter(128);
}
for (int i = 0; i < logElements.length; i++) {
logElements[i].addElement(result, date, request, response, time);
}
log(result);
if (result.size() <= maxLogMessageBufferSize) {
result.reset();
charArrayWriters.push(result);
}
}
// -------------------------------------------------------- Protected Methods
/**
* Log the specified message.
*
* @param message Message to be logged. This object will be recycled by
* the calling method.
*/
protected abstract void log(CharArrayWriter message);
// -------------------------------------------------------- Private Methods
/**
* This method returns a Date object that is accurate to within one second.
* If a thread calls this method to get a Date and it's been less than 1
* second since a new Date was created, this method simply gives out the
* same Date again so that the system doesn't spend time creating Date
* objects unnecessarily.
* @param systime The time
* @return the date object
*/
private static Date getDate(long systime) {
Date date = localDate.get();
date.setTime(systime);
return date;
}
/**
* Find a locale by name.
* @param name The locale name
* @param fallback Fallback locale if the name is not found
* @return the locale object
*/
protected static Locale findLocale(String name, Locale fallback) {
if (name == null || name.isEmpty()) {
return Locale.getDefault();
} else {
for (Locale l: Locale.getAvailableLocales()) {
if (name.equals(l.toString())) {
return l;
}
}
}
log.error(sm.getString("accessLogValve.invalidLocale", name));
return fallback;
}
/**
* Start this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
setState(LifecycleState.STARTING);
}
/**
* Stop this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void stopInternal() throws LifecycleException {
setState(LifecycleState.STOPPING);
}
/**
* AccessLogElement writes the partial message into the buffer.
*/
protected interface AccessLogElement {
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time);
}
/**
* Marks an AccessLogElement as needing to be have the value cached at the
* start of the request rather than just recorded at the end as the source
* data for the element may not be available at the end of the request. This
* typically occurs for remote network information, such as ports, IP
* addresses etc. when the connection is closed unexpectedly. These elements
* take advantage of these values being cached elsewhere on first request
* and do not cache the value in the element since the elements are
* state-less.
*/
protected interface CachedElement {
public void cache(Request request);
}
/**
* write thread name - %I
*/
protected static class ThreadNameElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
RequestInfo info = request.getCoyoteRequest().getRequestProcessor();
if(info != null) {
buf.append(info.getWorkerThreadName());
} else {
buf.append("-");
}
}
}
/**
* write local IP address - %A
*/
protected static class LocalAddrElement implements AccessLogElement {
private final String localAddrValue;
public LocalAddrElement(boolean ipv6Canonical) {
String init;
try {
init = InetAddress.getLocalHost().getHostAddress();
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
init = "127.0.0.1";
}
if (ipv6Canonical) {
localAddrValue = IPv6Utils.canonize(init);
} else {
localAddrValue = init;
}
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
buf.append(localAddrValue);
}
}
/**
* write remote IP address - %a
*/
protected class RemoteAddrElement implements AccessLogElement, CachedElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
String value = null;
if (requestAttributesEnabled) {
Object addr = request.getAttribute(REMOTE_ADDR_ATTRIBUTE);
if (addr == null) {
value = request.getRemoteAddr();
} else {
value = addr.toString();
}
} else {
value = request.getRemoteAddr();
}
if (ipv6Canonical) {
value = IPv6Utils.canonize(value);
}
buf.append(value);
}
@Override
public void cache(Request request) {
if (!requestAttributesEnabled) {
request.getRemoteAddr();
}
}
}
/**
* write remote host name - %h
*/
protected class HostElement implements AccessLogElement, CachedElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
String value = null;
if (requestAttributesEnabled) {
Object host = request.getAttribute(REMOTE_HOST_ATTRIBUTE);
if (host != null) {
value = host.toString();
}
}
if (value == null || value.length() == 0) {
value = request.getRemoteHost();
}
if (value == null || value.length() == 0) {
value = "-";
}
if (ipv6Canonical) {
value = IPv6Utils.canonize(value);
}
buf.append(value);
}
@Override
public void cache(Request request) {
if (!requestAttributesEnabled) {
request.getRemoteHost();
}
}
}
/**
* write remote logical username from identd (always returns '-') - %l
*/
protected static class LogicalUserNameElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
buf.append('-');
}
}
/**
* write request protocol - %H
*/
protected class ProtocolElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (requestAttributesEnabled) {
Object proto = request.getAttribute(PROTOCOL_ATTRIBUTE);
if (proto == null) {
buf.append(request.getProtocol());
} else {
buf.append(proto.toString());
}
} else {
buf.append(request.getProtocol());
}
}
}
/**
* write remote user that was authenticated (if any), else '-' - %u
*/
protected static class UserElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (request != null) {
String value = request.getRemoteUser();
if (value != null) {
buf.append(value);
} else {
buf.append('-');
}
} else {
buf.append('-');
}
}
}
/**
* write date and time, in configurable format (default CLF) - %t or %{format}t
*/
protected class DateAndTimeElement implements AccessLogElement {
/**
* Format prefix specifying request start time
*/
private static final String requestStartPrefix = "begin";
/**
* Format prefix specifying response end time
*/
private static final String responseEndPrefix = "end";
/**
* Separator between optional prefix and rest of format
*/
private static final String prefixSeparator = ":";
/**
* Special format for seconds since epoch
*/
private static final String secFormat = "sec";
/**
* Special format for milliseconds since epoch
*/
private static final String msecFormat = "msec";
/**
* Special format for millisecond part of timestamp
*/
private static final String msecFractionFormat = "msec_frac";
/**
* The patterns we use to replace "S" and "SSS" millisecond
* formatting of SimpleDateFormat by our own handling
*/
private static final String msecPattern = "{#}";
private static final String trippleMsecPattern =
msecPattern + msecPattern + msecPattern;
/* Our format description string, null if CLF */
private final String format;
/* Whether to use begin of request or end of response as the timestamp */
private final boolean usesBegin;
/* The format type */
private final FormatType type;
/* Whether we need to postprocess by adding milliseconds */
private boolean usesMsecs = false;
protected DateAndTimeElement() {
this(null);
}
/**
* Replace the millisecond formatting character 'S' by
* some dummy characters in order to make the resulting
* formatted time stamps cacheable. We replace the dummy
* chars later with the actual milliseconds because that's
* relatively cheap.
*/
private String tidyFormat(String format) {
boolean escape = false;
StringBuilder result = new StringBuilder();
int len = format.length();
char x;
for (int i = 0; i < len; i++) {
x = format.charAt(i);
if (escape || x != 'S') {
result.append(x);
} else {
result.append(msecPattern);
usesMsecs = true;
}
if (x == '\'') {
escape = !escape;
}
}
return result.toString();
}
protected DateAndTimeElement(String header) {
String format = header;
boolean usesBegin = false;
FormatType type = FormatType.CLF;
if (format != null) {
if (format.equals(requestStartPrefix)) {
usesBegin = true;
format = "";
} else if (format.startsWith(requestStartPrefix + prefixSeparator)) {
usesBegin = true;
format = format.substring(6);
} else if (format.equals(responseEndPrefix)) {
usesBegin = false;
format = "";
} else if (format.startsWith(responseEndPrefix + prefixSeparator)) {
usesBegin = false;
format = format.substring(4);
}
if (format.length() == 0) {
type = FormatType.CLF;
} else if (format.equals(secFormat)) {
type = FormatType.SEC;
} else if (format.equals(msecFormat)) {
type = FormatType.MSEC;
} else if (format.equals(msecFractionFormat)) {
type = FormatType.MSEC_FRAC;
} else {
type = FormatType.SDF;
format = tidyFormat(format);
}
}
this.format = format;
this.usesBegin = usesBegin;
this.type = type;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
long timestamp = date.getTime();
long frac;
if (usesBegin) {
timestamp -= time;
}
/* Implementation note: This is deliberately not implemented using
* switch. If a switch is used the compiler (at least the Oracle
* one) will use a synthetic class to implement the switch. The
* problem is that this class needs to be pre-loaded when using a
* SecurityManager and the name of that class will depend on any
* anonymous inner classes and any other synthetic classes. As such
* the name is not constant and keeping the pre-loading up to date
* as the name changes is error prone.
*/
if (type == FormatType.CLF) {
buf.append(localDateCache.get().getFormat(timestamp));
} else if (type == FormatType.SEC) {
buf.append(Long.toString(timestamp / 1000));
} else if (type == FormatType.MSEC) {
buf.append(Long.toString(timestamp));
} else if (type == FormatType.MSEC_FRAC) {
frac = timestamp % 1000;
if (frac < 100) {
if (frac < 10) {
buf.append('0');
buf.append('0');
} else {
buf.append('0');
}
}
buf.append(Long.toString(frac));
} else {
// FormatType.SDF
String temp = localDateCache.get().getFormat(format, locale, timestamp);
if (usesMsecs) {
frac = timestamp % 1000;
StringBuilder trippleMsec = new StringBuilder(4);
if (frac < 100) {
if (frac < 10) {
trippleMsec.append('0');
trippleMsec.append('0');
} else {
trippleMsec.append('0');
}
}
trippleMsec.append(frac);
temp = temp.replace(trippleMsecPattern, trippleMsec);
temp = temp.replace(msecPattern, Long.toString(frac));
}
buf.append(temp);
}
}
}
/**
* write first line of the request (method and request URI) - %r
*/
protected static class RequestElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (request != null) {
String method = request.getMethod();
if (method == null) {
// No method means no request line
buf.append('-');
} else {
buf.append(request.getMethod());
buf.append(' ');
buf.append(request.getRequestURI());
if (request.getQueryString() != null) {
buf.append('?');
buf.append(request.getQueryString());
}
buf.append(' ');
buf.append(request.getProtocol());
}
} else {
buf.append('-');
}
}
}
/**
* write HTTP status code of the response - %s
*/
protected static class HttpStatusCodeElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (response != null) {
// This approach is used to reduce GC from toString conversion
int status = response.getStatus();
if (100 <= status && status < 1000) {
buf.append((char) ('0' + (status / 100)))
.append((char) ('0' + ((status / 10) % 10)))
.append((char) ('0' + (status % 10)));
} else {
buf.append(Integer.toString(status));
}
} else {
buf.append('-');
}
}
}
/**
* write local or remote port for request connection - %p and %{xxx}p
*/
protected class PortElement implements AccessLogElement, CachedElement {
/**
* Type of port to log
*/
private static final String localPort = "local";
private static final String remotePort = "remote";
private final PortType portType;
public PortElement() {
portType = PortType.LOCAL;
}
public PortElement(String type) {
switch (type) {
case remotePort:
portType = PortType.REMOTE;
break;
case localPort:
portType = PortType.LOCAL;
break;
default:
log.error(sm.getString("accessLogValve.invalidPortType", type));
portType = PortType.LOCAL;
break;
}
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (requestAttributesEnabled && portType == PortType.LOCAL) {
Object port = request.getAttribute(SERVER_PORT_ATTRIBUTE);
if (port == null) {
buf.append(Integer.toString(request.getServerPort()));
} else {
buf.append(port.toString());
}
} else {
if (portType == PortType.LOCAL) {
buf.append(Integer.toString(request.getServerPort()));
} else {
buf.append(Integer.toString(request.getRemotePort()));
}
}
}
@Override
public void cache(Request request) {
if (portType == PortType.REMOTE) {
request.getRemotePort();
}
}
}
/**
* write bytes sent, excluding HTTP headers - %b, %B
*/
protected static class ByteSentElement implements AccessLogElement {
private final boolean conversion;
/**
* @param conversion <code>true</code> to write '-' instead of 0 - %b.
*/
public ByteSentElement(boolean conversion) {
this.conversion = conversion;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
// Don't need to flush since trigger for log message is after the
// response has been committed
long length = response.getBytesWritten(false);
if (length <= 0) {
// Protect against nulls and unexpected types as these values
// may be set by untrusted applications
Object start = request.getAttribute(
Globals.SENDFILE_FILE_START_ATTR);
if (start instanceof Long) {
Object end = request.getAttribute(
Globals.SENDFILE_FILE_END_ATTR);
if (end instanceof Long) {
length = ((Long) end).longValue() -
((Long) start).longValue();
}
}
}
if (length <= 0 && conversion) {
buf.append('-');
} else {
buf.append(Long.toString(length));
}
}
}
/**
* write request method (GET, POST, etc.) - %m
*/
protected static class MethodElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (request != null) {
buf.append(request.getMethod());
}
}
}
/**
* write time taken to process the request - %D, %T
*/
protected static class ElapsedTimeElement implements AccessLogElement {
private final boolean millis;
/**
* @param millis <code>true</code>, write time in millis - %D,
* if <code>false</code>, write time in seconds - %T
*/
public ElapsedTimeElement(boolean millis) {
this.millis = millis;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (millis) {
buf.append(Long.toString(time));
} else {
// second
buf.append(Long.toString(time / 1000));
buf.append('.');
int remains = (int) (time % 1000);
buf.append(Long.toString(remains / 100));
remains = remains % 100;
buf.append(Long.toString(remains / 10));
buf.append(Long.toString(remains % 10));
}
}
}
/**
* write time until first byte is written (commit time) in millis - %F
*/
protected static class FirstByteTimeElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time) {
long commitTime = response.getCoyoteResponse().getCommitTime();
if (commitTime == -1) {
buf.append('-');
} else {
long delta = commitTime - request.getCoyoteRequest().getStartTime();
buf.append(Long.toString(delta));
}
}
}
/**
* write Query string (prepended with a '?' if it exists) - %q
*/
protected static class QueryElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
String query = null;
if (request != null) {
query = request.getQueryString();
}
if (query != null) {
buf.append('?');
buf.append(query);
}
}
}
/**
* write user session ID - %S
*/
protected static class SessionIdElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (request == null) {
buf.append('-');
} else {
Session session = request.getSessionInternal(false);
if (session == null) {
buf.append('-');
} else {
buf.append(session.getIdInternal());
}
}
}
}
/**
* write requested URL path - %U
*/
protected static class RequestURIElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (request != null) {
buf.append(request.getRequestURI());
} else {
buf.append('-');
}
}
}
/**
* write local server name - %v
*/
protected class LocalServerNameElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
String value = null;
if (requestAttributesEnabled) {
Object serverName = request.getAttribute(SERVER_NAME_ATTRIBUTE);
if (serverName != null) {
value = serverName.toString();
}
}
if (value == null || value.length() == 0) {
value = request.getServerName();
}
if (value == null || value.length() == 0) {
value = "-";
}
if (ipv6Canonical) {
value = IPv6Utils.canonize(value);
}
buf.append(value);
}
}
/**
* write any string
*/
protected static class StringElement implements AccessLogElement {
private final String str;
public StringElement(String str) {
this.str = str;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
buf.append(str);
}
}
/**
* write incoming headers - %{xxx}i
*/
protected static class HeaderElement implements AccessLogElement {
private final String header;
public HeaderElement(String header) {
this.header = header;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
Enumeration<String> iter = request.getHeaders(header);
if (iter.hasMoreElements()) {
buf.append(iter.nextElement());
while (iter.hasMoreElements()) {
buf.append(',').append(iter.nextElement());
}
return;
}
buf.append('-');
}
}
/**
* write a specific cookie - %{xxx}c
*/
protected static class CookieElement implements AccessLogElement {
private final String header;
public CookieElement(String header) {
this.header = header;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
String value = "-";
Cookie[] c = request.getCookies();
if (c != null) {
for (int i = 0; i < c.length; i++) {
if (header.equals(c[i].getName())) {
value = c[i].getValue();
break;
}
}
}
buf.append(value);
}
}
/**
* write a specific response header - %{xxx}o
*/
protected static class ResponseHeaderElement implements AccessLogElement {
private final String header;
public ResponseHeaderElement(String header) {
this.header = header;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
if (null != response) {
Iterator<String> iter = response.getHeaders(header).iterator();
if (iter.hasNext()) {
buf.append(iter.next());
while (iter.hasNext()) {
buf.append(',').append(iter.next());
}
return;
}
}
buf.append('-');
}
}
/**
* write an attribute in the ServletRequest - %{xxx}r
*/
protected static class RequestAttributeElement implements AccessLogElement {
private final String header;
public RequestAttributeElement(String header) {
this.header = header;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
Object value = null;
if (request != null) {
value = request.getAttribute(header);
} else {
value = "??";
}
if (value != null) {
if (value instanceof String) {
buf.append((String) value);
} else {
buf.append(value.toString());
}
} else {
buf.append('-');
}
}
}
/**
* write an attribute in the HttpSession - %{xxx}s
*/
protected static class SessionAttributeElement implements AccessLogElement {
private final String header;
public SessionAttributeElement(String header) {
this.header = header;
}
@Override
public void addElement(CharArrayWriter buf, Date date, Request request,
Response response, long time) {
Object value = null;
if (null != request) {
HttpSession sess = request.getSession(false);
if (null != sess) {
value = sess.getAttribute(header);
}
} else {
value = "??";
}
if (value != null) {
if (value instanceof String) {
buf.append((String) value);
} else {
buf.append(value.toString());
}
} else {
buf.append('-');
}
}
}
/**
* Write connection status when response is completed - %X
*/
protected static class ConnectionStatusElement implements AccessLogElement {
@Override
public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time) {
if (response != null && request != null) {
boolean statusFound = false;
// Check whether connection IO is in "not allowed" state
AtomicBoolean isIoAllowed = new AtomicBoolean(false);
request.getCoyoteRequest().action(ActionCode.IS_IO_ALLOWED, isIoAllowed);
if (!isIoAllowed.get()) {
buf.append('X');
statusFound = true;
} else {
// Check for connection aborted cond
if (response.isError()) {
Throwable ex = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
if (ex instanceof ClientAbortException) {
buf.append('X');
statusFound = true;
}
}
}
// If status is not found yet, cont to check whether connection is keep-alive or close
if (!statusFound) {
String connStatus = response.getHeader(org.apache.coyote.http11.Constants.CONNECTION);
if (org.apache.coyote.http11.Constants.CLOSE.equalsIgnoreCase(connStatus)) {
buf.append('-');
} else {
buf.append('+');
}
}
} else {
// Unknown connection status
buf.append('?');
}
}
}
/**
* Parse pattern string and create the array of AccessLogElement.
* @return the log elements array
*/
protected AccessLogElement[] createLogElements() {
List<AccessLogElement> list = new ArrayList<>();
boolean replace = false;
StringBuilder buf = new StringBuilder();
for (int i = 0; i < pattern.length(); i++) {
char ch = pattern.charAt(i);
if (replace) {
/*
* For code that processes {, the behavior will be ... if I do
* not encounter a closing } - then I ignore the {
*/
if ('{' == ch) {
StringBuilder name = new StringBuilder();
int j = i + 1;
for (; j < pattern.length() && '}' != pattern.charAt(j); j++) {
name.append(pattern.charAt(j));
}
if (j + 1 < pattern.length()) {
/* the +1 was to account for } which we increment now */
j++;
list.add(createAccessLogElement(name.toString(),
pattern.charAt(j)));
i = j; /* Since we walked more than one character */
} else {
// D'oh - end of string - pretend we never did this
// and do processing the "old way"
list.add(createAccessLogElement(ch));
}
} else {
list.add(createAccessLogElement(ch));
}
replace = false;
} else if (ch == '%') {
replace = true;
list.add(new StringElement(buf.toString()));
buf = new StringBuilder();
} else {
buf.append(ch);
}
}
if (buf.length() > 0) {
list.add(new StringElement(buf.toString()));
}
return list.toArray(new AccessLogElement[0]);
}
private CachedElement[] createCachedElements(AccessLogElement[] elements) {
List<CachedElement> list = new ArrayList<>();
for (AccessLogElement element : elements) {
if (element instanceof CachedElement) {
list.add((CachedElement) element);
}
}
return list.toArray(new CachedElement[0]);
}
/**
* Create an AccessLogElement implementation which needs an element name.
* @param name Header name
* @param pattern char in the log pattern
* @return the log element
*/
protected AccessLogElement createAccessLogElement(String name, char pattern) {
switch (pattern) {
case 'i':
return new HeaderElement(name);
case 'c':
return new CookieElement(name);
case 'o':
return new ResponseHeaderElement(name);
case 'p':
return new PortElement(name);
case 'r':
if (TLSUtil.isTLSRequestAttribute(name)) {
tlsAttributeRequired = true;
}
return new RequestAttributeElement(name);
case 's':
return new SessionAttributeElement(name);
case 't':
return new DateAndTimeElement(name);
default:
return new StringElement("???");
}
}
/**
* Create an AccessLogElement implementation.
* @param pattern char in the log pattern
* @return the log element
*/
protected AccessLogElement createAccessLogElement(char pattern) {
switch (pattern) {
case 'a':
return new RemoteAddrElement();
case 'A':
return new LocalAddrElement(ipv6Canonical);
case 'b':
return new ByteSentElement(true);
case 'B':
return new ByteSentElement(false);
case 'D':
return new ElapsedTimeElement(true);
case 'F':
return new FirstByteTimeElement();
case 'h':
return new HostElement();
case 'H':
return new ProtocolElement();
case 'l':
return new LogicalUserNameElement();
case 'm':
return new MethodElement();
case 'p':
return new PortElement();
case 'q':
return new QueryElement();
case 'r':
return new RequestElement();
case 's':
return new HttpStatusCodeElement();
case 'S':
return new SessionIdElement();
case 't':
return new DateAndTimeElement();
case 'T':
return new ElapsedTimeElement(false);
case 'u':
return new UserElement();
case 'U':
return new RequestURIElement();
case 'v':
return new LocalServerNameElement();
case 'I':
return new ThreadNameElement();
case 'X':
return new ConnectionStatusElement();
default:
return new StringElement("???" + pattern + "???");
}
}
}
| [
"shaoxb@yunjiglobal.com"
] | shaoxb@yunjiglobal.com |
7ae44a5070490b4a5b4968389dbeb6e85de26ea9 | 231d4498325b66c3a4467418698909707d4cca58 | /leetcode/editor/cn/[507]完美数.java | 5757f66200eb982aeeb65376f4f83d0a3288beb7 | [] | no_license | qdw497874677/MyLeetCode | 830d8a63f98c6691bdd6507a83f514d875ddaa01 | 36249c4177f5169da6f3dc2bfbf65a0ca7b0b486 | refs/heads/master | 2022-11-12T12:11:10.711071 | 2020-07-06T14:06:36 | 2020-07-06T14:06:36 | 277,555,108 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 632 | java | //对于一个 正整数,如果它和除了它自身以外的所有正因子之和相等,我们称它为“完美数”。
//
// 给定一个 整数 n, 如果他是完美数,返回 True,否则返回 False
//
//
//
// 示例:
//
// 输入: 28
//输出: True
//解释: 28 = 1 + 2 + 4 + 7 + 14
//
//
//
//
// 提示:
//
// 输入的数字 n 不会超过 100,000,000. (1e8)
// Related Topics 数学
import
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public boolean checkPerfectNumber(int num) {
}
}
//leetcode submit region end(Prohibit modification and deletion)
| [
"497874677@qq.com"
] | 497874677@qq.com |
ef93f6106e297c93f246d599ee40021ebdac0aa5 | b9d42a0e0c661ad9ef88a9bec263e6b4972b5e89 | /jsf-spring-project/src/main/java/tr/gov/tubitak/course/dao/UrunDao.java | 8d6d80016359534e2e0d9282fab763a1f0a6f41c | [] | no_license | omeryildiz/JavaWorkspace | 0fc2d668a2bccf14d3e0fa495550a46d68d0cadd | f596fca5227883dcd79ff3021b66edfbf5b4156d | refs/heads/master | 2020-04-22T16:43:26.900819 | 2015-10-13T08:48:30 | 2015-10-13T08:48:30 | 42,179,124 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package tr.gov.tubitak.course.dao;
import java.io.Serializable;
import org.springframework.stereotype.Repository;
import tr.gov.tubitak.course.entity.Urun;
import tr.gov.tubitak.course.util.GenericDAO;
@Repository
public class UrunDao extends GenericDAO<Urun>implements Serializable {
private static final long serialVersionUID = 6040967577021576269L;
}
| [
"nomeryildiz@gmail.com"
] | nomeryildiz@gmail.com |
36807794a2de275525c237834ffb211cfb39525c | 608cf243607bfa7a2f4c91298463f2f199ae0ec1 | /android/versioned-abis/expoview-abi40_0_0/src/main/java/abi40_0_0/expo/modules/camera/CameraModule.java | f50f8689aae4c08ec92777e13383a751e9165db8 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | kodeco835/symmetrical-happiness | ca79bd6c7cdd3f7258dec06ac306aae89692f62a | 4f91cb07abef56118c35f893d9f5cc637b9310ef | refs/heads/master | 2023-04-30T04:02:09.478971 | 2021-03-23T03:19:05 | 2021-03-23T03:19:05 | 350,565,410 | 0 | 1 | MIT | 2023-04-12T19:49:48 | 2021-03-23T03:18:02 | Objective-C | UTF-8 | Java | false | false | 10,687 | java | package abi40_0_0.expo.modules.camera;
import android.Manifest;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import com.google.android.cameraview.AspectRatio;
import com.google.android.cameraview.Constants;
import com.google.android.cameraview.Size;
import abi40_0_0.org.unimodules.core.ExportedModule;
import abi40_0_0.org.unimodules.core.ModuleRegistry;
import abi40_0_0.org.unimodules.core.Promise;
import abi40_0_0.org.unimodules.core.interfaces.ExpoMethod;
import abi40_0_0.org.unimodules.core.interfaces.services.UIManager;
import abi40_0_0.org.unimodules.interfaces.permissions.Permissions;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import abi40_0_0.expo.modules.camera.tasks.ResolveTakenPictureAsyncTask;
public class CameraModule extends ExportedModule {
private static final String TAG = "ExponentCameraModule";
private static final String ERROR_TAG = "E_CAMERA";
private ModuleRegistry mModuleRegistry;
static final int VIDEO_2160P = 0;
static final int VIDEO_1080P = 1;
static final int VIDEO_720P = 2;
static final int VIDEO_480P = 3;
static final int VIDEO_4x3 = 4;
public CameraModule(Context context) {
super(context);
}
@Override
public void onCreate(ModuleRegistry moduleRegistry) {
mModuleRegistry = moduleRegistry;
}
@Override
public String getName() {
return TAG;
}
@Override
public Map<String, Object> getConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("Type", getTypeConstants());
put("FlashMode", getFlashModeConstants());
put("AutoFocus", getAutoFocusConstants());
put("WhiteBalance", getWhiteBalanceConstants());
put("VideoQuality", getVideoQualityConstants());
put("FaceDetection", Collections.unmodifiableMap(new HashMap<>()));
}
private Map<String, Object> getTypeConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("front", Constants.FACING_FRONT);
put("back", Constants.FACING_BACK);
}
});
}
private Map<String, Object> getFlashModeConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("off", Constants.FLASH_OFF);
put("on", Constants.FLASH_ON);
put("auto", Constants.FLASH_AUTO);
put("torch", Constants.FLASH_TORCH);
}
});
}
private Map<String, Object> getAutoFocusConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("on", true);
put("off", false);
}
});
}
private Map<String, Object> getWhiteBalanceConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("auto", Constants.WB_AUTO);
put("cloudy", Constants.WB_CLOUDY);
put("sunny", Constants.WB_SUNNY);
put("shadow", Constants.WB_SHADOW);
put("fluorescent", Constants.WB_FLUORESCENT);
put("incandescent", Constants.WB_INCANDESCENT);
}
});
}
private Map<String, Object> getVideoQualityConstants() {
return Collections.unmodifiableMap(new HashMap<String, Object>() {
{
put("2160p", VIDEO_2160P);
put("1080p", VIDEO_1080P);
put("720p", VIDEO_720P);
put("480p", VIDEO_480P);
put("4:3", VIDEO_4x3);
}
});
}
});
}
@ExpoMethod
public void pausePreview(final int viewTag, final Promise promise) {
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
try {
if (view.isCameraOpened()) {
view.pausePreview();
}
} catch (Exception e) {
promise.reject(ERROR_TAG, "pausePreview -- exception occurred -- " + e.getMessage(), e);
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
@ExpoMethod
public void resumePreview(final int viewTag, final Promise promise) {
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
try {
if (view.isCameraOpened()) {
view.resumePreview();
}
} catch (Exception e) {
promise.reject(ERROR_TAG, "resumePreview -- exception occurred -- " + e.getMessage(), e);
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
@ExpoMethod
public void takePicture(final Map<String, Object> options, final int viewTag, final Promise promise) {
final File cacheDirectory = getContext().getCacheDir();
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
if (!Build.FINGERPRINT.contains("generic")) {
if (view.isCameraOpened()) {
view.takePicture(options, promise, cacheDirectory);
} else {
promise.reject("E_CAMERA_UNAVAILABLE", "Camera is not running");
}
} else {
Bitmap image = CameraViewHelper.generateSimulatorPhoto(view.getWidth(), view.getHeight());
new ResolveTakenPictureAsyncTask(image, promise, options, cacheDirectory, view).execute();
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
@ExpoMethod
public void record(final Map<String, Object> options, final int viewTag, final Promise promise) {
Permissions permissionsManager = mModuleRegistry.getModule(Permissions.class);
if (permissionsManager == null) {
promise.reject("E_NO_PERMISSIONS", "Permissions module is null. Are you sure all the installed Expo modules are properly linked?");
return;
}
if (permissionsManager.hasGrantedPermissions(Manifest.permission.RECORD_AUDIO)) {
final File cacheDirectory = getContext().getCacheDir();
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
if (view.isCameraOpened()) {
view.record(options, promise, cacheDirectory);
} else {
promise.reject("E_CAMERA_UNAVAILABLE", "Camera is not running");
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
} else {
promise.reject(new SecurityException("User rejected audio permissions"));
}
}
@ExpoMethod
public void stopRecording(final int viewTag, final Promise promise) {
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
if (view.isCameraOpened()) {
view.stopRecording();
promise.resolve(true);
} else {
promise.reject(ERROR_TAG, "Camera is not open");
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
@ExpoMethod
public void getSupportedRatios(final int viewTag, final Promise promise) {
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
if (view.isCameraOpened()) {
Set<AspectRatio> ratios = view.getSupportedAspectRatios();
List<String> supportedRatios = new ArrayList<>(ratios.size());
for (AspectRatio ratio : ratios) {
supportedRatios.add(ratio.toString());
}
promise.resolve(supportedRatios);
} else {
promise.reject(ERROR_TAG, "Camera is not running");
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
@ExpoMethod
public void getAvailablePictureSizes(final String ratio, final int viewTag, final Promise promise) {
addUIBlock(viewTag, new UIManager.UIBlock<ExpoCameraView>() {
@Override
public void resolve(ExpoCameraView view) {
if (view.isCameraOpened()) {
try {
SortedSet<Size> sizes = view.getAvailablePictureSizes(AspectRatio.parse(ratio));
List<String> result = new ArrayList<>(sizes.size());
for (Size size : sizes) {
result.add(size.toString());
}
promise.resolve(result);
} catch (Exception e) {
promise.reject(ERROR_TAG, "getAvailablePictureSizes -- unexpected error -- " + e.getMessage(), e);
}
} else {
promise.reject(ERROR_TAG, "Camera is not running");
}
}
@Override
public void reject(Throwable throwable) {
promise.reject(ERROR_TAG, throwable);
}
});
}
private void addUIBlock(int viewTag, UIManager.UIBlock<ExpoCameraView> block) {
UIManager manager = mModuleRegistry.getModule(UIManager.class);
if (manager == null) {
block.reject(new IllegalStateException("Implementation of " + UIManager.class.getName() + " is null. Are you sure you've included a proper Expo adapter for your platform?"));
} else {
manager.addUIBlock(viewTag, block, ExpoCameraView.class);
}
}
@ExpoMethod
public void requestPermissionsAsync(final Promise promise) {
Permissions permissionsManager = mModuleRegistry.getModule(Permissions.class);
if (permissionsManager == null) {
promise.reject("E_NO_PERMISSIONS", "Permissions module is null. Are you sure all the installed Expo modules are properly linked?");
return;
}
permissionsManager.askForPermissionsWithPromise(promise, Manifest.permission.CAMERA);
}
@ExpoMethod
public void getPermissionsAsync(final Promise promise) {
Permissions permissionsManager = mModuleRegistry.getModule(Permissions.class);
if (permissionsManager == null) {
promise.reject("E_NO_PERMISSIONS", "Permissions module is null. Are you sure all the installed Expo modules are properly linked?");
return;
}
permissionsManager.getPermissionsWithPromise(promise, Manifest.permission.CAMERA);
}
}
| [
"81201147+kodeco835@users.noreply.github.com"
] | 81201147+kodeco835@users.noreply.github.com |
3464564d4d464f772f6b92f36978196e6b84f658 | 37fe098837773666f8f6fd0622d60cf1170c5efa | /Life/Data-Structure/Queue/Queue.java | 1c1089ad81b0e06f253ec0d6f00d690dcab36f7b | [] | no_license | clementanto87/Life | df917c6a56a62f86f09e94f47c19a22eb483e9c0 | c78c05c073a998826262ec13e4298ce7f6de5e15 | refs/heads/master | 2021-10-07T08:12:39.824124 | 2021-10-04T05:39:27 | 2021-10-04T05:39:27 | 226,491,578 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,126 | java | package com.ds.Queue;
import java.util.Arrays;
public class Queue {
private int capacity = 5;
private int queue[] = new int[capacity];
private int front = 0;
private int rear = 0;
private int size = 0;
public void add(int data){
if(isFull()) increaseCapacity();
queue[rear] = data;
//rear = (rear + 1)%capacity;
rear++;
size++;
}
public void increaseCapacity(){
queue = Arrays.copyOf(queue, capacity*2);
}
public void show(){
for(int i=0;i<size;i++){
//System.out.println(queue[(i+front)%capacity]);
System.out.println(queue[(i+front)]);
}
}
public void peek(){
if(getSize() == 0){System.out.println("Queue Empty"); return; }
int data = 0;
data = queue[front];
System.out.println("Peek Data: "+ data);
}
public void pop(){
if(getSize() == 0){System.out.println("Queue Empty"); return; }
int data = 0;
data = queue[front];
//front = (front+1)%capacity;
front++;
size--;
System.out.println("Pop Data: "+data);
}
public int getSize(){
return size;
}
public boolean isFull(){
if(getSize() == capacity){
return true;
}
else return false;
}
}
| [
"clement.anto@gmail.com"
] | clement.anto@gmail.com |
4f05a8256cae091ded85b89cd7b5953e580f5b1c | 950d987a074b4ce76c2c22c6ac04499796610f8f | /src/main/java/com/gulecugurcan/soapwebservice/Country.java | 23f6b9774902aae92f30dff73ef415e14ab139ae | [] | no_license | UgurCanGulec/SoapWebServiceWithJaxb2-XSD-WSDL | ff83b60e6b127cd78bf24608159fd48ac3af3fc2 | 48de0ea71a19ca8ead9fb838a18503c6bf97018d | refs/heads/master | 2022-12-20T15:46:07.026747 | 2020-09-13T13:23:51 | 2020-09-13T13:23:51 | 295,155,759 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,040 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.09.08 at 07:24:11 PM EET
//
package com.gulecugurcan.soapwebservice;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for country complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="country">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="currency" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "country", propOrder = {
"id",
"name",
"population",
"capital",
"currency"
})
@Document
@Data
public class Country {
@Id
@XmlElement(required = true)
protected String id;
@XmlElement(required = true)
protected String name;
protected int population;
@XmlElement(required = true)
protected String capital;
@XmlElement(required = true)
protected String currency;
}
| [
"ugurcangulec@github.com"
] | ugurcangulec@github.com |
35403a3d8d37eb39205f8299f0ada721e4064641 | 5f5a5b0cd3324feded591d6986907746532374ba | /src/day33abstractclass/Civic.java | cc06efba3a29af06bc6e679154662e5e27717c32 | [] | no_license | gmz07dnz/gamze | 4f625aa95647542ebd583940449ed88ddd17e155 | a4662dccad1d84524dadbb71ab9978d6e67742ca | refs/heads/master | 2023-03-22T23:39:31.795050 | 2021-03-17T06:14:32 | 2021-03-17T06:14:32 | 344,900,564 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 144 | java | package day33abstractclass;
public class Civic extends Honda{
@Override
public void motor() {
System.out.println("1.6 eco");
}
}
| [
"gmzzdnzz07@gmail.com"
] | gmzzdnzz07@gmail.com |
4e2d89561b391e4f7e83fd3bb422c17598766213 | cf6966ed3fb122affb4ad03953b9728a387de596 | /src/com/spring/web/test/dao/OffersDAO.java | 5ccbbe3115984c956e8728874e4604ae7660715f | [] | no_license | paul-wr/spring-security-app | b57aa95c62868ba33e453ff5219633ace616c980 | b7ae77ac61a9ff2abce9e2eb0bd4301bb362639d | refs/heads/master | 2021-09-08T12:09:56.755122 | 2018-03-09T13:37:06 | 2018-03-09T13:37:06 | 105,781,878 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,010 | java | package com.spring.web.test.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component("offersDao")
public class OffersDAO {
private NamedParameterJdbcTemplate jdbc;
@Autowired
public void setDataSource(DataSource jdbc) {
this.jdbc = new NamedParameterJdbcTemplate(jdbc);
}
public List<Offer> getOffers() {
MapSqlParameterSource params = new MapSqlParameterSource();
// params.addValue("nameOne", "paul");
// params.addValue("nameTwo", "john");
return jdbc.query("select * from offers", params, new RowMapper<Offer>() {
public Offer mapRow(ResultSet rs, int rowNum) throws SQLException {
Offer offer = new Offer();
offer.setId(rs.getInt("id"));
offer.setName(rs.getString("name"));
offer.setText(rs.getString("text"));
offer.setEmail(rs.getString("email"));
return offer;
}
});
}
public Offer getOffer(int id) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("id", id);
return jdbc.queryForObject("select * from offers where id = :id", params, new RowMapper<Offer>() {
public Offer mapRow(ResultSet rs, int rowNum) throws SQLException {
Offer offer = new Offer();
offer.setId(rs.getInt("id"));
offer.setName(rs.getString("name"));
offer.setText(rs.getString("text"));
offer.setEmail(rs.getString("email"));
return offer;
}
});
}
public boolean create(Offer offer){
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(offer);
return jdbc.update("insert into offers (name, email, text) values (:name, :email, :text)", params) == 1;
}
@Transactional
public int[] create(List<Offer> offers){
SqlParameterSource[] params = SqlParameterSourceUtils.createBatch(offers.toArray());
return jdbc.batchUpdate("insert into offers (id, name, email, text) values (:id, :name, :email, :text)", params);
}
public boolean update(Offer offer){
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(offer);
return jdbc.update("update offers set name = :name, email = :email, text = :text where id =:id", params) == 1;
}
public boolean delete(int id){
MapSqlParameterSource params = new MapSqlParameterSource("id", id);
return jdbc.update("delete from offers where id = :id", params) == 1;
}
} | [
"mainaccount@Jupitors-iMac.local"
] | mainaccount@Jupitors-iMac.local |
924814930ffa39079c5251d64df62fe8f2721f94 | 8b1138629e7d22a9b6d33e43ae93cd1dd765b6e0 | /rpc/src/test/java/cc/lovezhy/raft/rpc/kryo/KryoTest.java | 6ff52d228f2a3ad3378dc894fe8289ba1fcfe374 | [
"Apache-2.0"
] | permissive | zhyzhyzhy/Rub-Raft | 4271fa8f972b28456cd943e1fb05efdd8217140d | cea1fb65a67e99c6bb5b59c0ce2f30159a5deeae | refs/heads/master | 2022-07-07T07:29:05.343491 | 2020-01-31T07:56:07 | 2020-01-31T07:56:50 | 156,950,281 | 7 | 1 | Apache-2.0 | 2022-06-17T02:03:50 | 2018-11-10T05:21:21 | Java | UTF-8 | Java | false | false | 1,558 | java | package cc.lovezhy.raft.rpc.kryo;
import cc.lovezhy.raft.rpc.kryo.model.School;
import cc.lovezhy.raft.rpc.kryo.model.Student;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.util.List;
public class KryoTest {
private static final Logger log = LoggerFactory.getLogger(KryoTest.class);
private Student student;
@Before
public void setUp() {
student = new Student();
student.setName("zhuyichen");
student.setAge(18);
List<School> schoolList = Lists.newArrayList();
schoolList.add(new School("江都中学"));
schoolList.add(new School("南京邮电大学"));
student.setSchoolList(schoolList);
log.info("origin student={}", student);
}
@Test
public void serializeTest() {
Kryo kryo = new Kryo();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Output output = new Output(byteArrayOutputStream);
kryo.writeObject(output, student);
output.close();
Input input = new Input(byteArrayOutputStream.toByteArray());
Student student = kryo.readObject(input, Student.class);
log.info("serialized student={}", student);
Assert.assertEquals(this.student, student);
}
}
| [
"1012146386@qq.com"
] | 1012146386@qq.com |
7be5c7ed0952943783493f6be16d535b1e640dbd | 13869b9ce75a91db14737e10ab6c3c4f1f32239e | /PlazoFijo_source_from_JADX/android/support/v4/view/ViewPager.java | 256dff5915e4bbb813e7500fc1d291588fb9debd | [] | no_license | garebon80/Ejemplos | 1c934a1673f094e4075e488c5f74f08f251abedd | c23380a1cdd874dd01309f2e3245f06184362e04 | refs/heads/master | 2021-08-26T09:13:21.151768 | 2017-11-22T20:13:41 | 2017-11-22T20:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 102,266 | java | package android.support.v4.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.os.SystemClock;
import android.support.v4.os.ParcelableCompat;
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v4.view.accessibility.AccessibilityRecordCompat;
import android.support.v4.widget.AutoScrollHelper;
import android.support.v4.widget.EdgeEffectCompat;
import android.support.v4.widget.ExploreByTouchHelper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SoundEffectConstants;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.BaseSavedState;
import android.view.View.MeasureSpec;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.Interpolator;
import android.widget.Scroller;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
public class ViewPager extends ViewGroup {
private static final int CLOSE_ENOUGH = 2;
private static final Comparator<ItemInfo> COMPARATOR;
private static final boolean DEBUG = false;
private static final int DEFAULT_GUTTER_SIZE = 16;
private static final int DEFAULT_OFFSCREEN_PAGES = 1;
private static final int DRAW_ORDER_DEFAULT = 0;
private static final int DRAW_ORDER_FORWARD = 1;
private static final int DRAW_ORDER_REVERSE = 2;
private static final int INVALID_POINTER = -1;
private static final int[] LAYOUT_ATTRS;
private static final int MAX_SETTLE_DURATION = 600;
private static final int MIN_DISTANCE_FOR_FLING = 25;
private static final int MIN_FLING_VELOCITY = 400;
public static final int SCROLL_STATE_DRAGGING = 1;
public static final int SCROLL_STATE_IDLE = 0;
public static final int SCROLL_STATE_SETTLING = 2;
private static final String TAG = "ViewPager";
private static final boolean USE_CACHE = false;
private static final Interpolator sInterpolator;
private static final ViewPositionComparator sPositionComparator;
private int mActivePointerId;
private PagerAdapter mAdapter;
private OnAdapterChangeListener mAdapterChangeListener;
private int mBottomPageBounds;
private boolean mCalledSuper;
private int mChildHeightMeasureSpec;
private int mChildWidthMeasureSpec;
private int mCloseEnough;
private int mCurItem;
private int mDecorChildCount;
private int mDefaultGutterSize;
private int mDrawingOrder;
private ArrayList<View> mDrawingOrderedChildren;
private final Runnable mEndScrollRunnable;
private int mExpectedAdapterCount;
private long mFakeDragBeginTime;
private boolean mFakeDragging;
private boolean mFirstLayout;
private float mFirstOffset;
private int mFlingDistance;
private int mGutterSize;
private boolean mIgnoreGutter;
private boolean mInLayout;
private float mInitialMotionX;
private float mInitialMotionY;
private OnPageChangeListener mInternalPageChangeListener;
private boolean mIsBeingDragged;
private boolean mIsUnableToDrag;
private final ArrayList<ItemInfo> mItems;
private float mLastMotionX;
private float mLastMotionY;
private float mLastOffset;
private EdgeEffectCompat mLeftEdge;
private Drawable mMarginDrawable;
private int mMaximumVelocity;
private int mMinimumVelocity;
private boolean mNeedCalculatePageOffsets;
private PagerObserver mObserver;
private int mOffscreenPageLimit;
private OnPageChangeListener mOnPageChangeListener;
private int mPageMargin;
private PageTransformer mPageTransformer;
private boolean mPopulatePending;
private Parcelable mRestoredAdapterState;
private ClassLoader mRestoredClassLoader;
private int mRestoredCurItem;
private EdgeEffectCompat mRightEdge;
private int mScrollState;
private Scroller mScroller;
private boolean mScrollingCacheEnabled;
private Method mSetChildrenDrawingOrderEnabled;
private final ItemInfo mTempItem;
private final Rect mTempRect;
private int mTopPageBounds;
private int mTouchSlop;
private VelocityTracker mVelocityTracker;
/* renamed from: android.support.v4.view.ViewPager.1 */
static class C00311 implements Comparator<ItemInfo> {
C00311() {
}
public int compare(ItemInfo lhs, ItemInfo rhs) {
return lhs.position - rhs.position;
}
}
/* renamed from: android.support.v4.view.ViewPager.2 */
static class C00322 implements Interpolator {
C00322() {
}
public float getInterpolation(float t) {
t -= 1.0f;
return ((((t * t) * t) * t) * t) + 1.0f;
}
}
/* renamed from: android.support.v4.view.ViewPager.3 */
class C00333 implements Runnable {
C00333() {
}
public void run() {
ViewPager.this.setScrollState(ViewPager.SCROLL_STATE_IDLE);
ViewPager.this.populate();
}
}
interface Decor {
}
static class ItemInfo {
Object object;
float offset;
int position;
boolean scrolling;
float widthFactor;
ItemInfo() {
}
}
public static class LayoutParams extends android.view.ViewGroup.LayoutParams {
int childIndex;
public int gravity;
public boolean isDecor;
boolean needsMeasure;
int position;
float widthFactor;
public LayoutParams() {
super(ViewPager.INVALID_POINTER, ViewPager.INVALID_POINTER);
this.widthFactor = 0.0f;
}
public LayoutParams(Context context, AttributeSet attrs) {
super(context, attrs);
this.widthFactor = 0.0f;
TypedArray a = context.obtainStyledAttributes(attrs, ViewPager.LAYOUT_ATTRS);
this.gravity = a.getInteger(ViewPager.SCROLL_STATE_IDLE, 48);
a.recycle();
}
}
interface OnAdapterChangeListener {
void onAdapterChanged(PagerAdapter pagerAdapter, PagerAdapter pagerAdapter2);
}
public interface OnPageChangeListener {
void onPageScrollStateChanged(int i);
void onPageScrolled(int i, float f, int i2);
void onPageSelected(int i);
}
public interface PageTransformer {
void transformPage(View view, float f);
}
private class PagerObserver extends DataSetObserver {
private PagerObserver() {
}
public void onChanged() {
ViewPager.this.dataSetChanged();
}
public void onInvalidated() {
ViewPager.this.dataSetChanged();
}
}
public static class SavedState extends BaseSavedState {
public static final Creator<SavedState> CREATOR;
Parcelable adapterState;
ClassLoader loader;
int position;
/* renamed from: android.support.v4.view.ViewPager.SavedState.1 */
static class C00951 implements ParcelableCompatCreatorCallbacks<SavedState> {
C00951() {
}
public SavedState createFromParcel(Parcel in, ClassLoader loader) {
return new SavedState(in, loader);
}
public SavedState[] newArray(int size) {
return new SavedState[size];
}
}
public SavedState(Parcelable superState) {
super(superState);
}
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeInt(this.position);
out.writeParcelable(this.adapterState, flags);
}
public String toString() {
return "FragmentPager.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " position=" + this.position + "}";
}
static {
CREATOR = ParcelableCompat.newCreator(new C00951());
}
SavedState(Parcel in, ClassLoader loader) {
super(in);
if (loader == null) {
loader = getClass().getClassLoader();
}
this.position = in.readInt();
this.adapterState = in.readParcelable(loader);
this.loader = loader;
}
}
static class ViewPositionComparator implements Comparator<View> {
ViewPositionComparator() {
}
public int compare(View lhs, View rhs) {
LayoutParams llp = (LayoutParams) lhs.getLayoutParams();
LayoutParams rlp = (LayoutParams) rhs.getLayoutParams();
if (llp.isDecor != rlp.isDecor) {
return llp.isDecor ? ViewPager.SCROLL_STATE_DRAGGING : ViewPager.INVALID_POINTER;
} else {
return llp.position - rlp.position;
}
}
}
class MyAccessibilityDelegate extends AccessibilityDelegateCompat {
MyAccessibilityDelegate() {
}
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setClassName(ViewPager.class.getName());
AccessibilityRecordCompat recordCompat = AccessibilityRecordCompat.obtain();
recordCompat.setScrollable(canScroll());
if (event.getEventType() == AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD && ViewPager.this.mAdapter != null) {
recordCompat.setItemCount(ViewPager.this.mAdapter.getCount());
recordCompat.setFromIndex(ViewPager.this.mCurItem);
recordCompat.setToIndex(ViewPager.this.mCurItem);
}
}
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
info.setClassName(ViewPager.class.getName());
info.setScrollable(canScroll());
if (ViewPager.this.canScrollHorizontally(ViewPager.SCROLL_STATE_DRAGGING)) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD);
}
if (ViewPager.this.canScrollHorizontally(ViewPager.INVALID_POINTER)) {
info.addAction(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD);
}
}
public boolean performAccessibilityAction(View host, int action, Bundle args) {
if (super.performAccessibilityAction(host, action, args)) {
return true;
}
switch (action) {
case AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD /*4096*/:
if (!ViewPager.this.canScrollHorizontally(ViewPager.SCROLL_STATE_DRAGGING)) {
return ViewPager.DEBUG;
}
ViewPager.this.setCurrentItem(ViewPager.this.mCurItem + ViewPager.SCROLL_STATE_DRAGGING);
return true;
case AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD /*8192*/:
if (!ViewPager.this.canScrollHorizontally(ViewPager.INVALID_POINTER)) {
return ViewPager.DEBUG;
}
ViewPager.this.setCurrentItem(ViewPager.this.mCurItem + ViewPager.INVALID_POINTER);
return true;
default:
return ViewPager.DEBUG;
}
}
private boolean canScroll() {
return (ViewPager.this.mAdapter == null || ViewPager.this.mAdapter.getCount() <= ViewPager.SCROLL_STATE_DRAGGING) ? ViewPager.DEBUG : true;
}
}
public static class SimpleOnPageChangeListener implements OnPageChangeListener {
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageSelected(int position) {
}
public void onPageScrollStateChanged(int state) {
}
}
static {
int[] iArr = new int[SCROLL_STATE_DRAGGING];
iArr[SCROLL_STATE_IDLE] = 16842931;
LAYOUT_ATTRS = iArr;
COMPARATOR = new C00311();
sInterpolator = new C00322();
sPositionComparator = new ViewPositionComparator();
}
public ViewPager(Context context) {
super(context);
this.mItems = new ArrayList();
this.mTempItem = new ItemInfo();
this.mTempRect = new Rect();
this.mRestoredCurItem = INVALID_POINTER;
this.mRestoredAdapterState = null;
this.mRestoredClassLoader = null;
this.mFirstOffset = -3.4028235E38f;
this.mLastOffset = AutoScrollHelper.NO_MAX;
this.mOffscreenPageLimit = SCROLL_STATE_DRAGGING;
this.mActivePointerId = INVALID_POINTER;
this.mFirstLayout = true;
this.mNeedCalculatePageOffsets = DEBUG;
this.mEndScrollRunnable = new C00333();
this.mScrollState = SCROLL_STATE_IDLE;
initViewPager();
}
public ViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.mItems = new ArrayList();
this.mTempItem = new ItemInfo();
this.mTempRect = new Rect();
this.mRestoredCurItem = INVALID_POINTER;
this.mRestoredAdapterState = null;
this.mRestoredClassLoader = null;
this.mFirstOffset = -3.4028235E38f;
this.mLastOffset = AutoScrollHelper.NO_MAX;
this.mOffscreenPageLimit = SCROLL_STATE_DRAGGING;
this.mActivePointerId = INVALID_POINTER;
this.mFirstLayout = true;
this.mNeedCalculatePageOffsets = DEBUG;
this.mEndScrollRunnable = new C00333();
this.mScrollState = SCROLL_STATE_IDLE;
initViewPager();
}
void initViewPager() {
setWillNotDraw(DEBUG);
setDescendantFocusability(AccessibilityEventCompat.TYPE_GESTURE_DETECTION_START);
setFocusable(true);
Context context = getContext();
this.mScroller = new Scroller(context, sInterpolator);
ViewConfiguration configuration = ViewConfiguration.get(context);
float density = context.getResources().getDisplayMetrics().density;
this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
this.mMinimumVelocity = (int) (400.0f * density);
this.mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
this.mLeftEdge = new EdgeEffectCompat(context);
this.mRightEdge = new EdgeEffectCompat(context);
this.mFlingDistance = (int) (25.0f * density);
this.mCloseEnough = (int) (2.0f * density);
this.mDefaultGutterSize = (int) (16.0f * density);
ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
if (ViewCompat.getImportantForAccessibility(this) == 0) {
ViewCompat.setImportantForAccessibility(this, SCROLL_STATE_DRAGGING);
}
}
protected void onDetachedFromWindow() {
removeCallbacks(this.mEndScrollRunnable);
super.onDetachedFromWindow();
}
private void setScrollState(int newState) {
if (this.mScrollState != newState) {
this.mScrollState = newState;
if (this.mPageTransformer != null) {
enableLayers(newState != 0 ? true : DEBUG);
}
if (this.mOnPageChangeListener != null) {
this.mOnPageChangeListener.onPageScrollStateChanged(newState);
}
}
}
public void setAdapter(PagerAdapter adapter) {
if (this.mAdapter != null) {
this.mAdapter.unregisterDataSetObserver(this.mObserver);
this.mAdapter.startUpdate((ViewGroup) this);
for (int i = SCROLL_STATE_IDLE; i < this.mItems.size(); i += SCROLL_STATE_DRAGGING) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
this.mAdapter.destroyItem((ViewGroup) this, ii.position, ii.object);
}
this.mAdapter.finishUpdate((ViewGroup) this);
this.mItems.clear();
removeNonDecorViews();
this.mCurItem = SCROLL_STATE_IDLE;
scrollTo(SCROLL_STATE_IDLE, SCROLL_STATE_IDLE);
}
PagerAdapter oldAdapter = this.mAdapter;
this.mAdapter = adapter;
this.mExpectedAdapterCount = SCROLL_STATE_IDLE;
if (this.mAdapter != null) {
if (this.mObserver == null) {
this.mObserver = new PagerObserver();
}
this.mAdapter.registerDataSetObserver(this.mObserver);
this.mPopulatePending = DEBUG;
boolean wasFirstLayout = this.mFirstLayout;
this.mFirstLayout = true;
this.mExpectedAdapterCount = this.mAdapter.getCount();
if (this.mRestoredCurItem >= 0) {
this.mAdapter.restoreState(this.mRestoredAdapterState, this.mRestoredClassLoader);
setCurrentItemInternal(this.mRestoredCurItem, DEBUG, true);
this.mRestoredCurItem = INVALID_POINTER;
this.mRestoredAdapterState = null;
this.mRestoredClassLoader = null;
} else if (wasFirstLayout) {
requestLayout();
} else {
populate();
}
}
if (this.mAdapterChangeListener != null && oldAdapter != adapter) {
this.mAdapterChangeListener.onAdapterChanged(oldAdapter, adapter);
}
}
private void removeNonDecorViews() {
int i = SCROLL_STATE_IDLE;
while (i < getChildCount()) {
if (!((LayoutParams) getChildAt(i).getLayoutParams()).isDecor) {
removeViewAt(i);
i += INVALID_POINTER;
}
i += SCROLL_STATE_DRAGGING;
}
}
public PagerAdapter getAdapter() {
return this.mAdapter;
}
void setOnAdapterChangeListener(OnAdapterChangeListener listener) {
this.mAdapterChangeListener = listener;
}
private int getClientWidth() {
return (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
}
public void setCurrentItem(int item) {
boolean z;
this.mPopulatePending = DEBUG;
if (this.mFirstLayout) {
z = DEBUG;
} else {
z = true;
}
setCurrentItemInternal(item, z, DEBUG);
}
public void setCurrentItem(int item, boolean smoothScroll) {
this.mPopulatePending = DEBUG;
setCurrentItemInternal(item, smoothScroll, DEBUG);
}
public int getCurrentItem() {
return this.mCurItem;
}
void setCurrentItemInternal(int item, boolean smoothScroll, boolean always) {
setCurrentItemInternal(item, smoothScroll, always, SCROLL_STATE_IDLE);
}
void setCurrentItemInternal(int item, boolean smoothScroll, boolean always, int velocity) {
boolean dispatchSelected = true;
if (this.mAdapter == null || this.mAdapter.getCount() <= 0) {
setScrollingCacheEnabled(DEBUG);
} else if (always || this.mCurItem != item || this.mItems.size() == 0) {
if (item < 0) {
item = SCROLL_STATE_IDLE;
} else if (item >= this.mAdapter.getCount()) {
item = this.mAdapter.getCount() + INVALID_POINTER;
}
int pageLimit = this.mOffscreenPageLimit;
if (item > this.mCurItem + pageLimit || item < this.mCurItem - pageLimit) {
for (int i = SCROLL_STATE_IDLE; i < this.mItems.size(); i += SCROLL_STATE_DRAGGING) {
((ItemInfo) this.mItems.get(i)).scrolling = true;
}
}
if (this.mCurItem == item) {
dispatchSelected = DEBUG;
}
if (this.mFirstLayout) {
this.mCurItem = item;
if (dispatchSelected && this.mOnPageChangeListener != null) {
this.mOnPageChangeListener.onPageSelected(item);
}
if (dispatchSelected && this.mInternalPageChangeListener != null) {
this.mInternalPageChangeListener.onPageSelected(item);
}
requestLayout();
return;
}
populate(item);
scrollToItem(item, smoothScroll, velocity, dispatchSelected);
} else {
setScrollingCacheEnabled(DEBUG);
}
}
private void scrollToItem(int item, boolean smoothScroll, int velocity, boolean dispatchSelected) {
ItemInfo curInfo = infoForPosition(item);
int destX = SCROLL_STATE_IDLE;
if (curInfo != null) {
destX = (int) (((float) getClientWidth()) * Math.max(this.mFirstOffset, Math.min(curInfo.offset, this.mLastOffset)));
}
if (smoothScroll) {
smoothScrollTo(destX, SCROLL_STATE_IDLE, velocity);
if (dispatchSelected && this.mOnPageChangeListener != null) {
this.mOnPageChangeListener.onPageSelected(item);
}
if (dispatchSelected && this.mInternalPageChangeListener != null) {
this.mInternalPageChangeListener.onPageSelected(item);
return;
}
return;
}
if (dispatchSelected && this.mOnPageChangeListener != null) {
this.mOnPageChangeListener.onPageSelected(item);
}
if (dispatchSelected && this.mInternalPageChangeListener != null) {
this.mInternalPageChangeListener.onPageSelected(item);
}
completeScroll(DEBUG);
scrollTo(destX, SCROLL_STATE_IDLE);
pageScrolled(destX);
}
public void setOnPageChangeListener(OnPageChangeListener listener) {
this.mOnPageChangeListener = listener;
}
public void setPageTransformer(boolean reverseDrawingOrder, PageTransformer transformer) {
int i = SCROLL_STATE_DRAGGING;
if (VERSION.SDK_INT >= 11) {
boolean z;
boolean hasTransformer = transformer != null ? true : DEBUG;
if (this.mPageTransformer != null) {
z = SCROLL_STATE_DRAGGING;
} else {
z = SCROLL_STATE_IDLE;
}
boolean needsPopulate = hasTransformer != z ? true : DEBUG;
this.mPageTransformer = transformer;
setChildrenDrawingOrderEnabledCompat(hasTransformer);
if (hasTransformer) {
if (reverseDrawingOrder) {
i = SCROLL_STATE_SETTLING;
}
this.mDrawingOrder = i;
} else {
this.mDrawingOrder = SCROLL_STATE_IDLE;
}
if (needsPopulate) {
populate();
}
}
}
void setChildrenDrawingOrderEnabledCompat(boolean enable) {
if (VERSION.SDK_INT >= 7) {
if (this.mSetChildrenDrawingOrderEnabled == null) {
try {
Class[] clsArr = new Class[SCROLL_STATE_DRAGGING];
clsArr[SCROLL_STATE_IDLE] = Boolean.TYPE;
this.mSetChildrenDrawingOrderEnabled = ViewGroup.class.getDeclaredMethod("setChildrenDrawingOrderEnabled", clsArr);
} catch (NoSuchMethodException e) {
Log.e(TAG, "Can't find setChildrenDrawingOrderEnabled", e);
}
}
try {
Method method = this.mSetChildrenDrawingOrderEnabled;
Object[] objArr = new Object[SCROLL_STATE_DRAGGING];
objArr[SCROLL_STATE_IDLE] = Boolean.valueOf(enable);
method.invoke(this, objArr);
} catch (Exception e2) {
Log.e(TAG, "Error changing children drawing order", e2);
}
}
}
protected int getChildDrawingOrder(int childCount, int i) {
int index;
if (this.mDrawingOrder == SCROLL_STATE_SETTLING) {
index = (childCount + INVALID_POINTER) - i;
} else {
index = i;
}
return ((LayoutParams) ((View) this.mDrawingOrderedChildren.get(index)).getLayoutParams()).childIndex;
}
OnPageChangeListener setInternalPageChangeListener(OnPageChangeListener listener) {
OnPageChangeListener oldListener = this.mInternalPageChangeListener;
this.mInternalPageChangeListener = listener;
return oldListener;
}
public int getOffscreenPageLimit() {
return this.mOffscreenPageLimit;
}
public void setOffscreenPageLimit(int limit) {
if (limit < SCROLL_STATE_DRAGGING) {
Log.w(TAG, "Requested offscreen page limit " + limit + " too small; defaulting to " + SCROLL_STATE_DRAGGING);
limit = SCROLL_STATE_DRAGGING;
}
if (limit != this.mOffscreenPageLimit) {
this.mOffscreenPageLimit = limit;
populate();
}
}
public void setPageMargin(int marginPixels) {
int oldMargin = this.mPageMargin;
this.mPageMargin = marginPixels;
int width = getWidth();
recomputeScrollPosition(width, width, marginPixels, oldMargin);
requestLayout();
}
public int getPageMargin() {
return this.mPageMargin;
}
public void setPageMarginDrawable(Drawable d) {
this.mMarginDrawable = d;
if (d != null) {
refreshDrawableState();
}
setWillNotDraw(d == null ? true : DEBUG);
invalidate();
}
public void setPageMarginDrawable(int resId) {
setPageMarginDrawable(getContext().getResources().getDrawable(resId));
}
protected boolean verifyDrawable(Drawable who) {
return (super.verifyDrawable(who) || who == this.mMarginDrawable) ? true : DEBUG;
}
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable d = this.mMarginDrawable;
if (d != null && d.isStateful()) {
d.setState(getDrawableState());
}
}
float distanceInfluenceForSnapDuration(float f) {
return (float) Math.sin((double) ((float) (((double) (f - 0.5f)) * 0.4712389167638204d)));
}
void smoothScrollTo(int x, int y) {
smoothScrollTo(x, y, SCROLL_STATE_IDLE);
}
void smoothScrollTo(int x, int y, int velocity) {
if (getChildCount() == 0) {
setScrollingCacheEnabled(DEBUG);
return;
}
int sx = getScrollX();
int sy = getScrollY();
int dx = x - sx;
int dy = y - sy;
if (dx == 0 && dy == 0) {
completeScroll(DEBUG);
populate();
setScrollState(SCROLL_STATE_IDLE);
return;
}
int duration;
setScrollingCacheEnabled(true);
setScrollState(SCROLL_STATE_SETTLING);
int width = getClientWidth();
int halfWidth = width / SCROLL_STATE_SETTLING;
float distance = ((float) halfWidth) + (((float) halfWidth) * distanceInfluenceForSnapDuration(Math.min(1.0f, (1.0f * ((float) Math.abs(dx))) / ((float) width))));
velocity = Math.abs(velocity);
if (velocity > 0) {
duration = Math.round(1000.0f * Math.abs(distance / ((float) velocity))) * 4;
} else {
duration = (int) ((1.0f + (((float) Math.abs(dx)) / (((float) this.mPageMargin) + (((float) width) * this.mAdapter.getPageWidth(this.mCurItem))))) * 100.0f);
}
this.mScroller.startScroll(sx, sy, dx, dy, Math.min(duration, MAX_SETTLE_DURATION));
ViewCompat.postInvalidateOnAnimation(this);
}
ItemInfo addNewItem(int position, int index) {
ItemInfo ii = new ItemInfo();
ii.position = position;
ii.object = this.mAdapter.instantiateItem((ViewGroup) this, position);
ii.widthFactor = this.mAdapter.getPageWidth(position);
if (index < 0 || index >= this.mItems.size()) {
this.mItems.add(ii);
} else {
this.mItems.add(index, ii);
}
return ii;
}
void dataSetChanged() {
boolean needPopulate;
int adapterCount = this.mAdapter.getCount();
this.mExpectedAdapterCount = adapterCount;
if (this.mItems.size() >= (this.mOffscreenPageLimit * SCROLL_STATE_SETTLING) + SCROLL_STATE_DRAGGING || this.mItems.size() >= adapterCount) {
needPopulate = DEBUG;
} else {
needPopulate = true;
}
int newCurrItem = this.mCurItem;
boolean isUpdating = DEBUG;
int i = SCROLL_STATE_IDLE;
while (i < this.mItems.size()) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
int newPos = this.mAdapter.getItemPosition(ii.object);
if (newPos != INVALID_POINTER) {
if (newPos == -2) {
this.mItems.remove(i);
i += INVALID_POINTER;
if (!isUpdating) {
this.mAdapter.startUpdate((ViewGroup) this);
isUpdating = true;
}
this.mAdapter.destroyItem((ViewGroup) this, ii.position, ii.object);
needPopulate = true;
if (this.mCurItem == ii.position) {
newCurrItem = Math.max(SCROLL_STATE_IDLE, Math.min(this.mCurItem, adapterCount + INVALID_POINTER));
needPopulate = true;
}
} else if (ii.position != newPos) {
if (ii.position == this.mCurItem) {
newCurrItem = newPos;
}
ii.position = newPos;
needPopulate = true;
}
}
i += SCROLL_STATE_DRAGGING;
}
if (isUpdating) {
this.mAdapter.finishUpdate((ViewGroup) this);
}
Collections.sort(this.mItems, COMPARATOR);
if (needPopulate) {
int childCount = getChildCount();
for (i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
LayoutParams lp = (LayoutParams) getChildAt(i).getLayoutParams();
if (!lp.isDecor) {
lp.widthFactor = 0.0f;
}
}
setCurrentItemInternal(newCurrItem, DEBUG, true);
requestLayout();
}
}
void populate() {
populate(this.mCurItem);
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
void populate(int r31) {
/*
r30 = this;
r21 = 0;
r15 = 2;
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r0 = r27;
r1 = r31;
if (r0 == r1) goto L_0x0031;
L_0x000f:
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r0 = r27;
r1 = r31;
if (r0 >= r1) goto L_0x003d;
L_0x001b:
r15 = 66;
L_0x001d:
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r0 = r30;
r1 = r27;
r21 = r0.infoForPosition(r1);
r0 = r31;
r1 = r30;
r1.mCurItem = r0;
L_0x0031:
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
if (r27 != 0) goto L_0x0040;
L_0x0039:
r30.sortChildDrawingOrder();
L_0x003c:
return;
L_0x003d:
r15 = 17;
goto L_0x001d;
L_0x0040:
r0 = r30;
r0 = r0.mPopulatePending;
r27 = r0;
if (r27 == 0) goto L_0x004c;
L_0x0048:
r30.sortChildDrawingOrder();
goto L_0x003c;
L_0x004c:
r27 = r30.getWindowToken();
if (r27 == 0) goto L_0x003c;
L_0x0052:
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
r0 = r27;
r1 = r30;
r0.startUpdate(r1);
r0 = r30;
r0 = r0.mOffscreenPageLimit;
r22 = r0;
r27 = 0;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r28 = r28 - r22;
r26 = java.lang.Math.max(r27, r28);
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
r4 = r27.getCount();
r27 = r4 + -1;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r28 = r28 + r22;
r12 = java.lang.Math.min(r27, r28);
r0 = r30;
r0 = r0.mExpectedAdapterCount;
r27 = r0;
r0 = r27;
if (r4 == r0) goto L_0x0106;
L_0x0095:
r27 = r30.getResources(); Catch:{ NotFoundException -> 0x00fc }
r28 = r30.getId(); Catch:{ NotFoundException -> 0x00fc }
r24 = r27.getResourceName(r28); Catch:{ NotFoundException -> 0x00fc }
L_0x00a1:
r27 = new java.lang.IllegalStateException;
r28 = new java.lang.StringBuilder;
r28.<init>();
r29 = "The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: ";
r28 = r28.append(r29);
r0 = r30;
r0 = r0.mExpectedAdapterCount;
r29 = r0;
r28 = r28.append(r29);
r29 = ", found: ";
r28 = r28.append(r29);
r0 = r28;
r28 = r0.append(r4);
r29 = " Pager id: ";
r28 = r28.append(r29);
r0 = r28;
r1 = r24;
r28 = r0.append(r1);
r29 = " Pager class: ";
r28 = r28.append(r29);
r29 = r30.getClass();
r28 = r28.append(r29);
r29 = " Problematic adapter: ";
r28 = r28.append(r29);
r0 = r30;
r0 = r0.mAdapter;
r29 = r0;
r29 = r29.getClass();
r28 = r28.append(r29);
r28 = r28.toString();
r27.<init>(r28);
throw r27;
L_0x00fc:
r11 = move-exception;
r27 = r30.getId();
r24 = java.lang.Integer.toHexString(r27);
goto L_0x00a1;
L_0x0106:
r8 = -1;
r9 = 0;
r8 = 0;
L_0x0109:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r27 = r27.size();
r0 = r27;
if (r8 >= r0) goto L_0x014b;
L_0x0117:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r17 = r0.get(r8);
r17 = (android.support.v4.view.ViewPager.ItemInfo) r17;
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r0 = r27;
r1 = r28;
if (r0 < r1) goto L_0x0260;
L_0x0137:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r0 = r27;
r1 = r28;
if (r0 != r1) goto L_0x014b;
L_0x0149:
r9 = r17;
L_0x014b:
if (r9 != 0) goto L_0x015d;
L_0x014d:
if (r4 <= 0) goto L_0x015d;
L_0x014f:
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r0 = r30;
r1 = r27;
r9 = r0.addNewItem(r1, r8);
L_0x015d:
if (r9 == 0) goto L_0x01e1;
L_0x015f:
r13 = 0;
r18 = r8 + -1;
if (r18 < 0) goto L_0x0264;
L_0x0164:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x0176:
r7 = r30.getClientWidth();
if (r7 > 0) goto L_0x0268;
L_0x017c:
r19 = 0;
L_0x017e:
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r23 = r27 + -1;
L_0x0186:
if (r23 < 0) goto L_0x0194;
L_0x0188:
r27 = (r13 > r19 ? 1 : (r13 == r19 ? 0 : -1));
if (r27 < 0) goto L_0x02d9;
L_0x018c:
r0 = r23;
r1 = r26;
if (r0 >= r1) goto L_0x02d9;
L_0x0192:
if (r17 != 0) goto L_0x0282;
L_0x0194:
r14 = r9.widthFactor;
r18 = r8 + 1;
r27 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
r27 = (r14 > r27 ? 1 : (r14 == r27 ? 0 : -1));
if (r27 >= 0) goto L_0x01da;
L_0x019e:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r27 = r27.size();
r0 = r18;
r1 = r27;
if (r0 >= r1) goto L_0x0337;
L_0x01ae:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x01c0:
if (r7 > 0) goto L_0x033b;
L_0x01c2:
r25 = 0;
L_0x01c4:
r0 = r30;
r0 = r0.mCurItem;
r27 = r0;
r23 = r27 + 1;
L_0x01cc:
r0 = r23;
if (r0 >= r4) goto L_0x01da;
L_0x01d0:
r27 = (r14 > r25 ? 1 : (r14 == r25 ? 0 : -1));
if (r27 < 0) goto L_0x03b0;
L_0x01d4:
r0 = r23;
if (r0 <= r12) goto L_0x03b0;
L_0x01d8:
if (r17 != 0) goto L_0x034f;
L_0x01da:
r0 = r30;
r1 = r21;
r0.calculatePageOffsets(r9, r8, r1);
L_0x01e1:
r0 = r30;
r0 = r0.mAdapter;
r28 = r0;
r0 = r30;
r0 = r0.mCurItem;
r29 = r0;
if (r9 == 0) goto L_0x0428;
L_0x01ef:
r0 = r9.object;
r27 = r0;
L_0x01f3:
r0 = r28;
r1 = r30;
r2 = r29;
r3 = r27;
r0.setPrimaryItem(r1, r2, r3);
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
r0 = r27;
r1 = r30;
r0.finishUpdate(r1);
r6 = r30.getChildCount();
r16 = 0;
L_0x0211:
r0 = r16;
if (r0 >= r6) goto L_0x042c;
L_0x0215:
r0 = r30;
r1 = r16;
r5 = r0.getChildAt(r1);
r20 = r5.getLayoutParams();
r20 = (android.support.v4.view.ViewPager.LayoutParams) r20;
r0 = r16;
r1 = r20;
r1.childIndex = r0;
r0 = r20;
r0 = r0.isDecor;
r27 = r0;
if (r27 != 0) goto L_0x025d;
L_0x0231:
r0 = r20;
r0 = r0.widthFactor;
r27 = r0;
r28 = 0;
r27 = (r27 > r28 ? 1 : (r27 == r28 ? 0 : -1));
if (r27 != 0) goto L_0x025d;
L_0x023d:
r0 = r30;
r17 = r0.infoForChild(r5);
if (r17 == 0) goto L_0x025d;
L_0x0245:
r0 = r17;
r0 = r0.widthFactor;
r27 = r0;
r0 = r27;
r1 = r20;
r1.widthFactor = r0;
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r27;
r1 = r20;
r1.position = r0;
L_0x025d:
r16 = r16 + 1;
goto L_0x0211;
L_0x0260:
r8 = r8 + 1;
goto L_0x0109;
L_0x0264:
r17 = 0;
goto L_0x0176;
L_0x0268:
r27 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
r0 = r9.widthFactor;
r28 = r0;
r27 = r27 - r28;
r28 = r30.getPaddingLeft();
r0 = r28;
r0 = (float) r0;
r28 = r0;
r0 = (float) r7;
r29 = r0;
r28 = r28 / r29;
r19 = r27 + r28;
goto L_0x017e;
L_0x0282:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r23;
r1 = r27;
if (r0 != r1) goto L_0x02d2;
L_0x028e:
r0 = r17;
r0 = r0.scrolling;
r27 = r0;
if (r27 != 0) goto L_0x02d2;
L_0x0296:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r0.remove(r1);
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
r0 = r17;
r0 = r0.object;
r28 = r0;
r0 = r27;
r1 = r30;
r2 = r23;
r3 = r28;
r0.destroyItem(r1, r2, r3);
r18 = r18 + -1;
r8 = r8 + -1;
if (r18 < 0) goto L_0x02d6;
L_0x02c0:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x02d2:
r23 = r23 + -1;
goto L_0x0186;
L_0x02d6:
r17 = 0;
goto L_0x02d2;
L_0x02d9:
if (r17 == 0) goto L_0x0309;
L_0x02db:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r23;
r1 = r27;
if (r0 != r1) goto L_0x0309;
L_0x02e7:
r0 = r17;
r0 = r0.widthFactor;
r27 = r0;
r13 = r13 + r27;
r18 = r18 + -1;
if (r18 < 0) goto L_0x0306;
L_0x02f3:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x0305:
goto L_0x02d2;
L_0x0306:
r17 = 0;
goto L_0x0305;
L_0x0309:
r27 = r18 + 1;
r0 = r30;
r1 = r23;
r2 = r27;
r17 = r0.addNewItem(r1, r2);
r0 = r17;
r0 = r0.widthFactor;
r27 = r0;
r13 = r13 + r27;
r8 = r8 + 1;
if (r18 < 0) goto L_0x0334;
L_0x0321:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x0333:
goto L_0x02d2;
L_0x0334:
r17 = 0;
goto L_0x0333;
L_0x0337:
r17 = 0;
goto L_0x01c0;
L_0x033b:
r27 = r30.getPaddingRight();
r0 = r27;
r0 = (float) r0;
r27 = r0;
r0 = (float) r7;
r28 = r0;
r27 = r27 / r28;
r28 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
r25 = r27 + r28;
goto L_0x01c4;
L_0x034f:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r23;
r1 = r27;
if (r0 != r1) goto L_0x03a9;
L_0x035b:
r0 = r17;
r0 = r0.scrolling;
r27 = r0;
if (r27 != 0) goto L_0x03a9;
L_0x0363:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r0.remove(r1);
r0 = r30;
r0 = r0.mAdapter;
r27 = r0;
r0 = r17;
r0 = r0.object;
r28 = r0;
r0 = r27;
r1 = r30;
r2 = r23;
r3 = r28;
r0.destroyItem(r1, r2, r3);
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r27 = r27.size();
r0 = r18;
r1 = r27;
if (r0 >= r1) goto L_0x03ad;
L_0x0397:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x03a9:
r23 = r23 + 1;
goto L_0x01cc;
L_0x03ad:
r17 = 0;
goto L_0x03a9;
L_0x03b0:
if (r17 == 0) goto L_0x03ee;
L_0x03b2:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r23;
r1 = r27;
if (r0 != r1) goto L_0x03ee;
L_0x03be:
r0 = r17;
r0 = r0.widthFactor;
r27 = r0;
r14 = r14 + r27;
r18 = r18 + 1;
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r27 = r27.size();
r0 = r18;
r1 = r27;
if (r0 >= r1) goto L_0x03eb;
L_0x03d8:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x03ea:
goto L_0x03a9;
L_0x03eb:
r17 = 0;
goto L_0x03ea;
L_0x03ee:
r0 = r30;
r1 = r23;
r2 = r18;
r17 = r0.addNewItem(r1, r2);
r18 = r18 + 1;
r0 = r17;
r0 = r0.widthFactor;
r27 = r0;
r14 = r14 + r27;
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r27 = r27.size();
r0 = r18;
r1 = r27;
if (r0 >= r1) goto L_0x0425;
L_0x0412:
r0 = r30;
r0 = r0.mItems;
r27 = r0;
r0 = r27;
r1 = r18;
r27 = r0.get(r1);
r27 = (android.support.v4.view.ViewPager.ItemInfo) r27;
r17 = r27;
L_0x0424:
goto L_0x03a9;
L_0x0425:
r17 = 0;
goto L_0x0424;
L_0x0428:
r27 = 0;
goto L_0x01f3;
L_0x042c:
r30.sortChildDrawingOrder();
r27 = r30.hasFocus();
if (r27 == 0) goto L_0x003c;
L_0x0435:
r10 = r30.findFocus();
if (r10 == 0) goto L_0x048c;
L_0x043b:
r0 = r30;
r17 = r0.infoForAnyChild(r10);
L_0x0441:
if (r17 == 0) goto L_0x0455;
L_0x0443:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r0 = r27;
r1 = r28;
if (r0 == r1) goto L_0x003c;
L_0x0455:
r16 = 0;
L_0x0457:
r27 = r30.getChildCount();
r0 = r16;
r1 = r27;
if (r0 >= r1) goto L_0x003c;
L_0x0461:
r0 = r30;
r1 = r16;
r5 = r0.getChildAt(r1);
r0 = r30;
r17 = r0.infoForChild(r5);
if (r17 == 0) goto L_0x0489;
L_0x0471:
r0 = r17;
r0 = r0.position;
r27 = r0;
r0 = r30;
r0 = r0.mCurItem;
r28 = r0;
r0 = r27;
r1 = r28;
if (r0 != r1) goto L_0x0489;
L_0x0483:
r27 = r5.requestFocus(r15);
if (r27 != 0) goto L_0x003c;
L_0x0489:
r16 = r16 + 1;
goto L_0x0457;
L_0x048c:
r17 = 0;
goto L_0x0441;
*/
throw new UnsupportedOperationException("Method not decompiled: android.support.v4.view.ViewPager.populate(int):void");
}
private void sortChildDrawingOrder() {
if (this.mDrawingOrder != 0) {
if (this.mDrawingOrderedChildren == null) {
this.mDrawingOrderedChildren = new ArrayList();
} else {
this.mDrawingOrderedChildren.clear();
}
int childCount = getChildCount();
for (int i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
this.mDrawingOrderedChildren.add(getChildAt(i));
}
Collections.sort(this.mDrawingOrderedChildren, sPositionComparator);
}
}
private void calculatePageOffsets(ItemInfo curItem, int curIndex, ItemInfo oldCurInfo) {
float offset;
int pos;
ItemInfo ii;
int N = this.mAdapter.getCount();
int width = getClientWidth();
float marginOffset = width > 0 ? ((float) this.mPageMargin) / ((float) width) : 0.0f;
if (oldCurInfo != null) {
int oldCurPosition = oldCurInfo.position;
int itemIndex;
if (oldCurPosition < curItem.position) {
itemIndex = SCROLL_STATE_IDLE;
offset = (oldCurInfo.offset + oldCurInfo.widthFactor) + marginOffset;
pos = oldCurPosition + SCROLL_STATE_DRAGGING;
while (pos <= curItem.position && itemIndex < this.mItems.size()) {
ii = (ItemInfo) this.mItems.get(itemIndex);
while (pos > ii.position && itemIndex < this.mItems.size() + INVALID_POINTER) {
itemIndex += SCROLL_STATE_DRAGGING;
ii = (ItemInfo) this.mItems.get(itemIndex);
}
while (pos < ii.position) {
offset += this.mAdapter.getPageWidth(pos) + marginOffset;
pos += SCROLL_STATE_DRAGGING;
}
ii.offset = offset;
offset += ii.widthFactor + marginOffset;
pos += SCROLL_STATE_DRAGGING;
}
} else if (oldCurPosition > curItem.position) {
itemIndex = this.mItems.size() + INVALID_POINTER;
offset = oldCurInfo.offset;
pos = oldCurPosition + INVALID_POINTER;
while (pos >= curItem.position && itemIndex >= 0) {
ii = (ItemInfo) this.mItems.get(itemIndex);
while (pos < ii.position && itemIndex > 0) {
itemIndex += INVALID_POINTER;
ii = (ItemInfo) this.mItems.get(itemIndex);
}
while (pos > ii.position) {
offset -= this.mAdapter.getPageWidth(pos) + marginOffset;
pos += INVALID_POINTER;
}
offset -= ii.widthFactor + marginOffset;
ii.offset = offset;
pos += INVALID_POINTER;
}
}
}
int itemCount = this.mItems.size();
offset = curItem.offset;
pos = curItem.position + INVALID_POINTER;
this.mFirstOffset = curItem.position == 0 ? curItem.offset : -3.4028235E38f;
this.mLastOffset = curItem.position == N + INVALID_POINTER ? (curItem.offset + curItem.widthFactor) - 1.0f : AutoScrollHelper.NO_MAX;
int i = curIndex + INVALID_POINTER;
while (i >= 0) {
ii = (ItemInfo) this.mItems.get(i);
while (pos > ii.position) {
offset -= this.mAdapter.getPageWidth(pos) + marginOffset;
pos += INVALID_POINTER;
}
offset -= ii.widthFactor + marginOffset;
ii.offset = offset;
if (ii.position == 0) {
this.mFirstOffset = offset;
}
i += INVALID_POINTER;
pos += INVALID_POINTER;
}
offset = (curItem.offset + curItem.widthFactor) + marginOffset;
pos = curItem.position + SCROLL_STATE_DRAGGING;
i = curIndex + SCROLL_STATE_DRAGGING;
while (i < itemCount) {
ii = (ItemInfo) this.mItems.get(i);
while (pos < ii.position) {
offset += this.mAdapter.getPageWidth(pos) + marginOffset;
pos += SCROLL_STATE_DRAGGING;
}
if (ii.position == N + INVALID_POINTER) {
this.mLastOffset = (ii.widthFactor + offset) - 1.0f;
}
ii.offset = offset;
offset += ii.widthFactor + marginOffset;
i += SCROLL_STATE_DRAGGING;
pos += SCROLL_STATE_DRAGGING;
}
this.mNeedCalculatePageOffsets = DEBUG;
}
public Parcelable onSaveInstanceState() {
SavedState ss = new SavedState(super.onSaveInstanceState());
ss.position = this.mCurItem;
if (this.mAdapter != null) {
ss.adapterState = this.mAdapter.saveState();
}
return ss;
}
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof SavedState) {
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
if (this.mAdapter != null) {
this.mAdapter.restoreState(ss.adapterState, ss.loader);
setCurrentItemInternal(ss.position, DEBUG, true);
return;
}
this.mRestoredCurItem = ss.position;
this.mRestoredAdapterState = ss.adapterState;
this.mRestoredClassLoader = ss.loader;
return;
}
super.onRestoreInstanceState(state);
}
public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) {
if (!checkLayoutParams(params)) {
params = generateLayoutParams(params);
}
LayoutParams lp = (LayoutParams) params;
lp.isDecor |= child instanceof Decor;
if (!this.mInLayout) {
super.addView(child, index, params);
} else if (lp == null || !lp.isDecor) {
lp.needsMeasure = true;
addViewInLayout(child, index, params);
} else {
throw new IllegalStateException("Cannot add pager decor view during layout");
}
}
public void removeView(View view) {
if (this.mInLayout) {
removeViewInLayout(view);
} else {
super.removeView(view);
}
}
ItemInfo infoForChild(View child) {
for (int i = SCROLL_STATE_IDLE; i < this.mItems.size(); i += SCROLL_STATE_DRAGGING) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
if (this.mAdapter.isViewFromObject(child, ii.object)) {
return ii;
}
}
return null;
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
android.support.v4.view.ViewPager.ItemInfo infoForAnyChild(android.view.View r3) {
/*
r2 = this;
L_0x0000:
r0 = r3.getParent();
if (r0 == r2) goto L_0x0012;
L_0x0006:
if (r0 == 0) goto L_0x000c;
L_0x0008:
r1 = r0 instanceof android.view.View;
if (r1 != 0) goto L_0x000e;
L_0x000c:
r1 = 0;
L_0x000d:
return r1;
L_0x000e:
r3 = r0;
r3 = (android.view.View) r3;
goto L_0x0000;
L_0x0012:
r1 = r2.infoForChild(r3);
goto L_0x000d;
*/
throw new UnsupportedOperationException("Method not decompiled: android.support.v4.view.ViewPager.infoForAnyChild(android.view.View):android.support.v4.view.ViewPager$ItemInfo");
}
ItemInfo infoForPosition(int position) {
for (int i = SCROLL_STATE_IDLE; i < this.mItems.size(); i += SCROLL_STATE_DRAGGING) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
if (ii.position == position) {
return ii;
}
}
return null;
}
protected void onAttachedToWindow() {
super.onAttachedToWindow();
this.mFirstLayout = true;
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int i;
setMeasuredDimension(getDefaultSize(SCROLL_STATE_IDLE, widthMeasureSpec), getDefaultSize(SCROLL_STATE_IDLE, heightMeasureSpec));
int measuredWidth = getMeasuredWidth();
this.mGutterSize = Math.min(measuredWidth / 10, this.mDefaultGutterSize);
int childWidthSize = (measuredWidth - getPaddingLeft()) - getPaddingRight();
int childHeightSize = (getMeasuredHeight() - getPaddingTop()) - getPaddingBottom();
int size = getChildCount();
for (i = SCROLL_STATE_IDLE; i < size; i += SCROLL_STATE_DRAGGING) {
LayoutParams lp;
View child = getChildAt(i);
if (child.getVisibility() != 8) {
lp = (LayoutParams) child.getLayoutParams();
if (lp != null && lp.isDecor) {
int hgrav = lp.gravity & 7;
int vgrav = lp.gravity & 112;
int widthMode = ExploreByTouchHelper.INVALID_ID;
int heightMode = ExploreByTouchHelper.INVALID_ID;
boolean consumeVertical = (vgrav == 48 || vgrav == 80) ? true : DEBUG;
boolean consumeHorizontal = (hgrav == 3 || hgrav == 5) ? true : DEBUG;
if (consumeVertical) {
widthMode = 1073741824;
} else if (consumeHorizontal) {
heightMode = 1073741824;
}
int widthSize = childWidthSize;
int heightSize = childHeightSize;
int i2 = lp.width;
if (r0 != -2) {
widthMode = 1073741824;
i2 = lp.width;
if (r0 != INVALID_POINTER) {
widthSize = lp.width;
}
}
i2 = lp.height;
if (r0 != -2) {
heightMode = 1073741824;
i2 = lp.height;
if (r0 != INVALID_POINTER) {
heightSize = lp.height;
}
}
child.measure(MeasureSpec.makeMeasureSpec(widthSize, widthMode), MeasureSpec.makeMeasureSpec(heightSize, heightMode));
if (consumeVertical) {
childHeightSize -= child.getMeasuredHeight();
} else if (consumeHorizontal) {
childWidthSize -= child.getMeasuredWidth();
}
}
}
}
this.mChildWidthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, 1073741824);
this.mChildHeightMeasureSpec = MeasureSpec.makeMeasureSpec(childHeightSize, 1073741824);
this.mInLayout = true;
populate();
this.mInLayout = DEBUG;
size = getChildCount();
for (i = SCROLL_STATE_IDLE; i < size; i += SCROLL_STATE_DRAGGING) {
child = getChildAt(i);
if (child.getVisibility() != 8) {
lp = (LayoutParams) child.getLayoutParams();
if (lp == null || !lp.isDecor) {
child.measure(MeasureSpec.makeMeasureSpec((int) (((float) childWidthSize) * lp.widthFactor), 1073741824), this.mChildHeightMeasureSpec);
}
}
}
}
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (w != oldw) {
recomputeScrollPosition(w, oldw, this.mPageMargin, this.mPageMargin);
}
}
private void recomputeScrollPosition(int width, int oldWidth, int margin, int oldMargin) {
if (oldWidth <= 0 || this.mItems.isEmpty()) {
ItemInfo ii = infoForPosition(this.mCurItem);
int scrollPos = (int) (((float) ((width - getPaddingLeft()) - getPaddingRight())) * (ii != null ? Math.min(ii.offset, this.mLastOffset) : 0.0f));
if (scrollPos != getScrollX()) {
completeScroll(DEBUG);
scrollTo(scrollPos, getScrollY());
return;
}
return;
}
int newOffsetPixels = (int) (((float) (((width - getPaddingLeft()) - getPaddingRight()) + margin)) * (((float) getScrollX()) / ((float) (((oldWidth - getPaddingLeft()) - getPaddingRight()) + oldMargin))));
scrollTo(newOffsetPixels, getScrollY());
if (!this.mScroller.isFinished()) {
this.mScroller.startScroll(newOffsetPixels, SCROLL_STATE_IDLE, (int) (infoForPosition(this.mCurItem).offset * ((float) width)), SCROLL_STATE_IDLE, this.mScroller.getDuration() - this.mScroller.timePassed());
}
}
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int i;
int count = getChildCount();
int width = r - l;
int height = b - t;
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int paddingRight = getPaddingRight();
int paddingBottom = getPaddingBottom();
int scrollX = getScrollX();
int decorCount = SCROLL_STATE_IDLE;
for (i = SCROLL_STATE_IDLE; i < count; i += SCROLL_STATE_DRAGGING) {
LayoutParams lp;
int childLeft;
int childTop;
View child = getChildAt(i);
if (child.getVisibility() != 8) {
lp = (LayoutParams) child.getLayoutParams();
if (lp.isDecor) {
int vgrav = lp.gravity & 112;
switch (lp.gravity & 7) {
case SCROLL_STATE_DRAGGING /*1*/:
childLeft = Math.max((width - child.getMeasuredWidth()) / SCROLL_STATE_SETTLING, paddingLeft);
break;
case FragmentManagerImpl.ANIM_STYLE_CLOSE_ENTER /*3*/:
childLeft = paddingLeft;
paddingLeft += child.getMeasuredWidth();
break;
case FragmentManagerImpl.ANIM_STYLE_FADE_ENTER /*5*/:
childLeft = (width - paddingRight) - child.getMeasuredWidth();
paddingRight += child.getMeasuredWidth();
break;
default:
childLeft = paddingLeft;
break;
}
switch (vgrav) {
case DEFAULT_GUTTER_SIZE /*16*/:
childTop = Math.max((height - child.getMeasuredHeight()) / SCROLL_STATE_SETTLING, paddingTop);
break;
case 48:
childTop = paddingTop;
paddingTop += child.getMeasuredHeight();
break;
case 80:
childTop = (height - paddingBottom) - child.getMeasuredHeight();
paddingBottom += child.getMeasuredHeight();
break;
default:
childTop = paddingTop;
break;
}
childLeft += scrollX;
child.layout(childLeft, childTop, child.getMeasuredWidth() + childLeft, child.getMeasuredHeight() + childTop);
decorCount += SCROLL_STATE_DRAGGING;
}
}
}
int childWidth = (width - paddingLeft) - paddingRight;
for (i = SCROLL_STATE_IDLE; i < count; i += SCROLL_STATE_DRAGGING) {
child = getChildAt(i);
if (child.getVisibility() != 8) {
lp = (LayoutParams) child.getLayoutParams();
if (!lp.isDecor) {
ItemInfo ii = infoForChild(child);
if (ii != null) {
childLeft = paddingLeft + ((int) (((float) childWidth) * ii.offset));
childTop = paddingTop;
if (lp.needsMeasure) {
lp.needsMeasure = DEBUG;
int makeMeasureSpec = MeasureSpec.makeMeasureSpec((int) (((float) childWidth) * lp.widthFactor), 1073741824);
child.measure(widthSpec, MeasureSpec.makeMeasureSpec((height - paddingTop) - paddingBottom, 1073741824));
}
child.layout(childLeft, childTop, child.getMeasuredWidth() + childLeft, child.getMeasuredHeight() + childTop);
}
}
}
}
this.mTopPageBounds = paddingTop;
this.mBottomPageBounds = height - paddingBottom;
this.mDecorChildCount = decorCount;
if (this.mFirstLayout) {
scrollToItem(this.mCurItem, DEBUG, SCROLL_STATE_IDLE, DEBUG);
}
this.mFirstLayout = DEBUG;
}
public void computeScroll() {
if (this.mScroller.isFinished() || !this.mScroller.computeScrollOffset()) {
completeScroll(true);
return;
}
int oldX = getScrollX();
int oldY = getScrollY();
int x = this.mScroller.getCurrX();
int y = this.mScroller.getCurrY();
if (!(oldX == x && oldY == y)) {
scrollTo(x, y);
if (!pageScrolled(x)) {
this.mScroller.abortAnimation();
scrollTo(SCROLL_STATE_IDLE, y);
}
}
ViewCompat.postInvalidateOnAnimation(this);
}
private boolean pageScrolled(int xpos) {
if (this.mItems.size() == 0) {
this.mCalledSuper = DEBUG;
onPageScrolled(SCROLL_STATE_IDLE, 0.0f, SCROLL_STATE_IDLE);
if (this.mCalledSuper) {
return DEBUG;
}
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
}
ItemInfo ii = infoForCurrentScrollPosition();
int width = getClientWidth();
int widthWithMargin = width + this.mPageMargin;
float marginOffset = ((float) this.mPageMargin) / ((float) width);
int currentPage = ii.position;
float pageOffset = ((((float) xpos) / ((float) width)) - ii.offset) / (ii.widthFactor + marginOffset);
int offsetPixels = (int) (((float) widthWithMargin) * pageOffset);
this.mCalledSuper = DEBUG;
onPageScrolled(currentPage, pageOffset, offsetPixels);
if (this.mCalledSuper) {
return true;
}
throw new IllegalStateException("onPageScrolled did not call superclass implementation");
}
protected void onPageScrolled(int position, float offset, int offsetPixels) {
int scrollX;
int childCount;
int i;
View child;
if (this.mDecorChildCount > 0) {
scrollX = getScrollX();
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
int width = getWidth();
childCount = getChildCount();
for (i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
child = getChildAt(i);
LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (lp.isDecor) {
int childLeft;
switch (lp.gravity & 7) {
case SCROLL_STATE_DRAGGING /*1*/:
childLeft = Math.max((width - child.getMeasuredWidth()) / SCROLL_STATE_SETTLING, paddingLeft);
break;
case FragmentManagerImpl.ANIM_STYLE_CLOSE_ENTER /*3*/:
childLeft = paddingLeft;
paddingLeft += child.getWidth();
break;
case FragmentManagerImpl.ANIM_STYLE_FADE_ENTER /*5*/:
childLeft = (width - paddingRight) - child.getMeasuredWidth();
paddingRight += child.getMeasuredWidth();
break;
default:
childLeft = paddingLeft;
break;
}
int childOffset = (childLeft + scrollX) - child.getLeft();
if (childOffset != 0) {
child.offsetLeftAndRight(childOffset);
}
}
}
}
if (this.mOnPageChangeListener != null) {
this.mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels);
}
if (this.mInternalPageChangeListener != null) {
this.mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels);
}
if (this.mPageTransformer != null) {
scrollX = getScrollX();
childCount = getChildCount();
for (i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
child = getChildAt(i);
if (!((LayoutParams) child.getLayoutParams()).isDecor) {
this.mPageTransformer.transformPage(child, ((float) (child.getLeft() - scrollX)) / ((float) getClientWidth()));
}
}
}
this.mCalledSuper = true;
}
private void completeScroll(boolean postEvents) {
boolean needPopulate;
if (this.mScrollState == SCROLL_STATE_SETTLING) {
needPopulate = true;
} else {
needPopulate = DEBUG;
}
if (needPopulate) {
setScrollingCacheEnabled(DEBUG);
this.mScroller.abortAnimation();
int oldX = getScrollX();
int oldY = getScrollY();
int x = this.mScroller.getCurrX();
int y = this.mScroller.getCurrY();
if (!(oldX == x && oldY == y)) {
scrollTo(x, y);
}
}
this.mPopulatePending = DEBUG;
for (int i = SCROLL_STATE_IDLE; i < this.mItems.size(); i += SCROLL_STATE_DRAGGING) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
if (ii.scrolling) {
needPopulate = true;
ii.scrolling = DEBUG;
}
}
if (!needPopulate) {
return;
}
if (postEvents) {
ViewCompat.postOnAnimation(this, this.mEndScrollRunnable);
} else {
this.mEndScrollRunnable.run();
}
}
private boolean isGutterDrag(float x, float dx) {
return ((x >= ((float) this.mGutterSize) || dx <= 0.0f) && (x <= ((float) (getWidth() - this.mGutterSize)) || dx >= 0.0f)) ? DEBUG : true;
}
private void enableLayers(boolean enable) {
int childCount = getChildCount();
for (int i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
ViewCompat.setLayerType(getChildAt(i), enable ? SCROLL_STATE_SETTLING : SCROLL_STATE_IDLE, null);
}
}
public boolean onInterceptTouchEvent(MotionEvent ev) {
int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
if (action == 3 || action == SCROLL_STATE_DRAGGING) {
this.mIsBeingDragged = DEBUG;
this.mIsUnableToDrag = DEBUG;
this.mActivePointerId = INVALID_POINTER;
if (this.mVelocityTracker != null) {
this.mVelocityTracker.recycle();
this.mVelocityTracker = null;
}
return DEBUG;
}
if (action != 0) {
if (this.mIsBeingDragged) {
return true;
}
if (this.mIsUnableToDrag) {
return DEBUG;
}
}
switch (action) {
case SCROLL_STATE_IDLE /*0*/:
float x = ev.getX();
this.mInitialMotionX = x;
this.mLastMotionX = x;
x = ev.getY();
this.mInitialMotionY = x;
this.mLastMotionY = x;
this.mActivePointerId = MotionEventCompat.getPointerId(ev, SCROLL_STATE_IDLE);
this.mIsUnableToDrag = DEBUG;
this.mScroller.computeScrollOffset();
if (this.mScrollState == SCROLL_STATE_SETTLING && Math.abs(this.mScroller.getFinalX() - this.mScroller.getCurrX()) > this.mCloseEnough) {
this.mScroller.abortAnimation();
this.mPopulatePending = DEBUG;
populate();
this.mIsBeingDragged = true;
requestParentDisallowInterceptTouchEvent(true);
setScrollState(SCROLL_STATE_DRAGGING);
break;
}
completeScroll(DEBUG);
this.mIsBeingDragged = DEBUG;
break;
break;
case SCROLL_STATE_SETTLING /*2*/:
int activePointerId = this.mActivePointerId;
if (activePointerId != INVALID_POINTER) {
int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId);
float x2 = MotionEventCompat.getX(ev, pointerIndex);
float dx = x2 - this.mLastMotionX;
float xDiff = Math.abs(dx);
float y = MotionEventCompat.getY(ev, pointerIndex);
float yDiff = Math.abs(y - this.mInitialMotionY);
if (dx == 0.0f || isGutterDrag(this.mLastMotionX, dx) || !canScroll(this, DEBUG, (int) dx, (int) x2, (int) y)) {
if (xDiff > ((float) this.mTouchSlop) && 0.5f * xDiff > yDiff) {
this.mIsBeingDragged = true;
requestParentDisallowInterceptTouchEvent(true);
setScrollState(SCROLL_STATE_DRAGGING);
this.mLastMotionX = dx > 0.0f ? this.mInitialMotionX + ((float) this.mTouchSlop) : this.mInitialMotionX - ((float) this.mTouchSlop);
this.mLastMotionY = y;
setScrollingCacheEnabled(true);
} else if (yDiff > ((float) this.mTouchSlop)) {
this.mIsUnableToDrag = true;
}
if (this.mIsBeingDragged && performDrag(x2)) {
ViewCompat.postInvalidateOnAnimation(this);
break;
}
}
this.mLastMotionX = x2;
this.mLastMotionY = y;
this.mIsUnableToDrag = true;
return DEBUG;
}
break;
case FragmentManagerImpl.ANIM_STYLE_FADE_EXIT /*6*/:
onSecondaryPointerUp(ev);
break;
}
if (this.mVelocityTracker == null) {
this.mVelocityTracker = VelocityTracker.obtain();
}
this.mVelocityTracker.addMovement(ev);
return this.mIsBeingDragged;
}
public boolean onTouchEvent(MotionEvent ev) {
if (this.mFakeDragging) {
return true;
}
if (ev.getAction() == 0 && ev.getEdgeFlags() != 0) {
return DEBUG;
}
if (this.mAdapter != null) {
if (this.mAdapter.getCount() != 0) {
if (this.mVelocityTracker == null) {
this.mVelocityTracker = VelocityTracker.obtain();
}
this.mVelocityTracker.addMovement(ev);
int action = ev.getAction();
boolean needsInvalidate = DEBUG;
float x;
switch (action & MotionEventCompat.ACTION_MASK) {
case SCROLL_STATE_IDLE /*0*/:
this.mScroller.abortAnimation();
this.mPopulatePending = DEBUG;
populate();
x = ev.getX();
this.mInitialMotionX = x;
this.mLastMotionX = x;
x = ev.getY();
this.mInitialMotionY = x;
this.mLastMotionY = x;
this.mActivePointerId = MotionEventCompat.getPointerId(ev, SCROLL_STATE_IDLE);
break;
case SCROLL_STATE_DRAGGING /*1*/:
if (this.mIsBeingDragged) {
VelocityTracker velocityTracker = this.mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, (float) this.mMaximumVelocity);
int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(velocityTracker, this.mActivePointerId);
this.mPopulatePending = true;
int width = getClientWidth();
int scrollX = getScrollX();
ItemInfo ii = infoForCurrentScrollPosition();
int currentPage = ii.position;
x = (float) scrollX;
float f = (float) width;
f = ii.offset;
float pageOffset = ((r0 / r0) - r0) / ii.widthFactor;
int activePointerIndex = MotionEventCompat.findPointerIndex(ev, this.mActivePointerId);
setCurrentItemInternal(determineTargetPage(currentPage, pageOffset, initialVelocity, (int) (MotionEventCompat.getX(ev, activePointerIndex) - this.mInitialMotionX)), true, true, initialVelocity);
this.mActivePointerId = INVALID_POINTER;
endDrag();
needsInvalidate = this.mLeftEdge.onRelease() | this.mRightEdge.onRelease();
break;
}
break;
case SCROLL_STATE_SETTLING /*2*/:
if (!this.mIsBeingDragged) {
int pointerIndex = MotionEventCompat.findPointerIndex(ev, this.mActivePointerId);
float x2 = MotionEventCompat.getX(ev, pointerIndex);
float xDiff = Math.abs(x2 - this.mLastMotionX);
float y = MotionEventCompat.getY(ev, pointerIndex);
float yDiff = Math.abs(y - this.mLastMotionY);
if (xDiff > ((float) this.mTouchSlop) && xDiff > yDiff) {
this.mIsBeingDragged = true;
requestParentDisallowInterceptTouchEvent(true);
if (x2 - this.mInitialMotionX > 0.0f) {
x = this.mInitialMotionX + ((float) this.mTouchSlop);
} else {
x = this.mInitialMotionX - ((float) this.mTouchSlop);
}
this.mLastMotionX = x;
this.mLastMotionY = y;
setScrollState(SCROLL_STATE_DRAGGING);
setScrollingCacheEnabled(true);
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
}
}
if (this.mIsBeingDragged) {
needsInvalidate = DEBUG | performDrag(MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, this.mActivePointerId)));
break;
}
break;
case FragmentManagerImpl.ANIM_STYLE_CLOSE_ENTER /*3*/:
if (this.mIsBeingDragged) {
scrollToItem(this.mCurItem, true, SCROLL_STATE_IDLE, DEBUG);
this.mActivePointerId = INVALID_POINTER;
endDrag();
needsInvalidate = this.mLeftEdge.onRelease() | this.mRightEdge.onRelease();
break;
}
break;
case FragmentManagerImpl.ANIM_STYLE_FADE_ENTER /*5*/:
int index = MotionEventCompat.getActionIndex(ev);
this.mLastMotionX = MotionEventCompat.getX(ev, index);
this.mActivePointerId = MotionEventCompat.getPointerId(ev, index);
break;
case FragmentManagerImpl.ANIM_STYLE_FADE_EXIT /*6*/:
onSecondaryPointerUp(ev);
this.mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, this.mActivePointerId));
break;
}
if (needsInvalidate) {
ViewCompat.postInvalidateOnAnimation(this);
}
return true;
}
}
return DEBUG;
}
private void requestParentDisallowInterceptTouchEvent(boolean disallowIntercept) {
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(disallowIntercept);
}
}
private boolean performDrag(float x) {
boolean needsInvalidate = DEBUG;
float deltaX = this.mLastMotionX - x;
this.mLastMotionX = x;
float scrollX = ((float) getScrollX()) + deltaX;
int width = getClientWidth();
float leftBound = ((float) width) * this.mFirstOffset;
float rightBound = ((float) width) * this.mLastOffset;
boolean leftAbsolute = true;
boolean rightAbsolute = true;
ItemInfo firstItem = (ItemInfo) this.mItems.get(SCROLL_STATE_IDLE);
ItemInfo lastItem = (ItemInfo) this.mItems.get(this.mItems.size() + INVALID_POINTER);
if (firstItem.position != 0) {
leftAbsolute = DEBUG;
leftBound = firstItem.offset * ((float) width);
}
if (lastItem.position != this.mAdapter.getCount() + INVALID_POINTER) {
rightAbsolute = DEBUG;
rightBound = lastItem.offset * ((float) width);
}
float f;
if (scrollX < leftBound) {
if (leftAbsolute) {
f = (float) width;
needsInvalidate = this.mLeftEdge.onPull(Math.abs(leftBound - scrollX) / r0);
}
scrollX = leftBound;
} else if (scrollX > rightBound) {
if (rightAbsolute) {
f = (float) width;
needsInvalidate = this.mRightEdge.onPull(Math.abs(scrollX - rightBound) / r0);
}
scrollX = rightBound;
}
this.mLastMotionX += scrollX - ((float) ((int) scrollX));
scrollTo((int) scrollX, getScrollY());
pageScrolled((int) scrollX);
return needsInvalidate;
}
private ItemInfo infoForCurrentScrollPosition() {
float scrollOffset;
float marginOffset = 0.0f;
int width = getClientWidth();
if (width > 0) {
scrollOffset = ((float) getScrollX()) / ((float) width);
} else {
scrollOffset = 0.0f;
}
if (width > 0) {
marginOffset = ((float) this.mPageMargin) / ((float) width);
}
int lastPos = INVALID_POINTER;
float lastOffset = 0.0f;
float lastWidth = 0.0f;
boolean first = true;
ItemInfo lastItem = null;
int i = SCROLL_STATE_IDLE;
while (i < this.mItems.size()) {
ItemInfo ii = (ItemInfo) this.mItems.get(i);
if (!(first || ii.position == lastPos + SCROLL_STATE_DRAGGING)) {
ii = this.mTempItem;
ii.offset = (lastOffset + lastWidth) + marginOffset;
ii.position = lastPos + SCROLL_STATE_DRAGGING;
ii.widthFactor = this.mAdapter.getPageWidth(ii.position);
i += INVALID_POINTER;
}
float offset = ii.offset;
float leftBound = offset;
float rightBound = (ii.widthFactor + offset) + marginOffset;
if (!first && scrollOffset < leftBound) {
return lastItem;
}
if (scrollOffset < rightBound || i == this.mItems.size() + INVALID_POINTER) {
return ii;
}
first = DEBUG;
lastPos = ii.position;
lastOffset = offset;
lastWidth = ii.widthFactor;
lastItem = ii;
i += SCROLL_STATE_DRAGGING;
}
return lastItem;
}
private int determineTargetPage(int currentPage, float pageOffset, int velocity, int deltaX) {
int targetPage;
if (Math.abs(deltaX) <= this.mFlingDistance || Math.abs(velocity) <= this.mMinimumVelocity) {
targetPage = (int) ((((float) currentPage) + pageOffset) + (currentPage >= this.mCurItem ? 0.4f : 0.6f));
} else {
targetPage = velocity > 0 ? currentPage : currentPage + SCROLL_STATE_DRAGGING;
}
if (this.mItems.size() <= 0) {
return targetPage;
}
return Math.max(((ItemInfo) this.mItems.get(SCROLL_STATE_IDLE)).position, Math.min(targetPage, ((ItemInfo) this.mItems.get(this.mItems.size() + INVALID_POINTER)).position));
}
public void draw(Canvas canvas) {
super.draw(canvas);
boolean needsInvalidate = DEBUG;
int overScrollMode = ViewCompat.getOverScrollMode(this);
if (overScrollMode == 0 || (overScrollMode == SCROLL_STATE_DRAGGING && this.mAdapter != null && this.mAdapter.getCount() > SCROLL_STATE_DRAGGING)) {
int restoreCount;
int height;
int width;
if (!this.mLeftEdge.isFinished()) {
restoreCount = canvas.save();
height = (getHeight() - getPaddingTop()) - getPaddingBottom();
width = getWidth();
canvas.rotate(270.0f);
canvas.translate((float) ((-height) + getPaddingTop()), this.mFirstOffset * ((float) width));
this.mLeftEdge.setSize(height, width);
needsInvalidate = DEBUG | this.mLeftEdge.draw(canvas);
canvas.restoreToCount(restoreCount);
}
if (!this.mRightEdge.isFinished()) {
restoreCount = canvas.save();
width = getWidth();
height = (getHeight() - getPaddingTop()) - getPaddingBottom();
canvas.rotate(90.0f);
canvas.translate((float) (-getPaddingTop()), (-(this.mLastOffset + 1.0f)) * ((float) width));
this.mRightEdge.setSize(height, width);
needsInvalidate |= this.mRightEdge.draw(canvas);
canvas.restoreToCount(restoreCount);
}
} else {
this.mLeftEdge.finish();
this.mRightEdge.finish();
}
if (needsInvalidate) {
ViewCompat.postInvalidateOnAnimation(this);
}
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (this.mPageMargin > 0 && this.mMarginDrawable != null && this.mItems.size() > 0 && this.mAdapter != null) {
int scrollX = getScrollX();
int width = getWidth();
float marginOffset = ((float) this.mPageMargin) / ((float) width);
int itemIndex = SCROLL_STATE_IDLE;
ItemInfo ii = (ItemInfo) this.mItems.get(SCROLL_STATE_IDLE);
float offset = ii.offset;
int itemCount = this.mItems.size();
int firstPos = ii.position;
int lastPos = ((ItemInfo) this.mItems.get(itemCount + INVALID_POINTER)).position;
int pos = firstPos;
while (pos < lastPos) {
float drawAt;
while (pos > ii.position && itemIndex < itemCount) {
itemIndex += SCROLL_STATE_DRAGGING;
ii = (ItemInfo) this.mItems.get(itemIndex);
}
if (pos == ii.position) {
drawAt = (ii.offset + ii.widthFactor) * ((float) width);
offset = (ii.offset + ii.widthFactor) + marginOffset;
} else {
float widthFactor = this.mAdapter.getPageWidth(pos);
drawAt = (offset + widthFactor) * ((float) width);
offset += widthFactor + marginOffset;
}
if (((float) this.mPageMargin) + drawAt > ((float) scrollX)) {
this.mMarginDrawable.setBounds((int) drawAt, this.mTopPageBounds, (int) ((((float) this.mPageMargin) + drawAt) + 0.5f), this.mBottomPageBounds);
this.mMarginDrawable.draw(canvas);
}
if (drawAt <= ((float) (scrollX + width))) {
pos += SCROLL_STATE_DRAGGING;
} else {
return;
}
}
}
}
public boolean beginFakeDrag() {
if (this.mIsBeingDragged) {
return DEBUG;
}
this.mFakeDragging = true;
setScrollState(SCROLL_STATE_DRAGGING);
this.mLastMotionX = 0.0f;
this.mInitialMotionX = 0.0f;
if (this.mVelocityTracker == null) {
this.mVelocityTracker = VelocityTracker.obtain();
} else {
this.mVelocityTracker.clear();
}
long time = SystemClock.uptimeMillis();
MotionEvent ev = MotionEvent.obtain(time, time, SCROLL_STATE_IDLE, 0.0f, 0.0f, SCROLL_STATE_IDLE);
this.mVelocityTracker.addMovement(ev);
ev.recycle();
this.mFakeDragBeginTime = time;
return true;
}
public void endFakeDrag() {
if (this.mFakeDragging) {
VelocityTracker velocityTracker = this.mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, (float) this.mMaximumVelocity);
int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(velocityTracker, this.mActivePointerId);
this.mPopulatePending = true;
int width = getClientWidth();
int scrollX = getScrollX();
ItemInfo ii = infoForCurrentScrollPosition();
setCurrentItemInternal(determineTargetPage(ii.position, ((((float) scrollX) / ((float) width)) - ii.offset) / ii.widthFactor, initialVelocity, (int) (this.mLastMotionX - this.mInitialMotionX)), true, true, initialVelocity);
endDrag();
this.mFakeDragging = DEBUG;
return;
}
throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
}
public void fakeDragBy(float xOffset) {
if (this.mFakeDragging) {
this.mLastMotionX += xOffset;
float scrollX = ((float) getScrollX()) - xOffset;
int width = getClientWidth();
float leftBound = ((float) width) * this.mFirstOffset;
float rightBound = ((float) width) * this.mLastOffset;
ItemInfo firstItem = (ItemInfo) this.mItems.get(SCROLL_STATE_IDLE);
ItemInfo lastItem = (ItemInfo) this.mItems.get(this.mItems.size() + INVALID_POINTER);
if (firstItem.position != 0) {
leftBound = firstItem.offset * ((float) width);
}
if (lastItem.position != this.mAdapter.getCount() + INVALID_POINTER) {
rightBound = lastItem.offset * ((float) width);
}
if (scrollX < leftBound) {
scrollX = leftBound;
} else if (scrollX > rightBound) {
scrollX = rightBound;
}
this.mLastMotionX += scrollX - ((float) ((int) scrollX));
scrollTo((int) scrollX, getScrollY());
pageScrolled((int) scrollX);
MotionEvent ev = MotionEvent.obtain(this.mFakeDragBeginTime, SystemClock.uptimeMillis(), SCROLL_STATE_SETTLING, this.mLastMotionX, 0.0f, SCROLL_STATE_IDLE);
this.mVelocityTracker.addMovement(ev);
ev.recycle();
return;
}
throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
}
public boolean isFakeDragging() {
return this.mFakeDragging;
}
private void onSecondaryPointerUp(MotionEvent ev) {
int pointerIndex = MotionEventCompat.getActionIndex(ev);
if (MotionEventCompat.getPointerId(ev, pointerIndex) == this.mActivePointerId) {
int newPointerIndex = pointerIndex == 0 ? SCROLL_STATE_DRAGGING : SCROLL_STATE_IDLE;
this.mLastMotionX = MotionEventCompat.getX(ev, newPointerIndex);
this.mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
if (this.mVelocityTracker != null) {
this.mVelocityTracker.clear();
}
}
}
private void endDrag() {
this.mIsBeingDragged = DEBUG;
this.mIsUnableToDrag = DEBUG;
if (this.mVelocityTracker != null) {
this.mVelocityTracker.recycle();
this.mVelocityTracker = null;
}
}
private void setScrollingCacheEnabled(boolean enabled) {
if (this.mScrollingCacheEnabled != enabled) {
this.mScrollingCacheEnabled = enabled;
}
}
public boolean canScrollHorizontally(int direction) {
boolean z = true;
if (this.mAdapter == null) {
return DEBUG;
}
int width = getClientWidth();
int scrollX = getScrollX();
if (direction < 0) {
if (scrollX <= ((int) (((float) width) * this.mFirstOffset))) {
z = DEBUG;
}
return z;
} else if (direction <= 0) {
return DEBUG;
} else {
if (scrollX >= ((int) (((float) width) * this.mLastOffset))) {
z = DEBUG;
}
return z;
}
}
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
if (v instanceof ViewGroup) {
ViewGroup group = (ViewGroup) v;
int scrollX = v.getScrollX();
int scrollY = v.getScrollY();
for (int i = group.getChildCount() + INVALID_POINTER; i >= 0; i += INVALID_POINTER) {
View child = group.getChildAt(i);
if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom()) {
if (canScroll(child, true, dx, (x + scrollX) - child.getLeft(), (y + scrollY) - child.getTop())) {
return true;
}
}
}
}
return (checkV && ViewCompat.canScrollHorizontally(v, -dx)) ? true : DEBUG;
}
public boolean dispatchKeyEvent(KeyEvent event) {
return (super.dispatchKeyEvent(event) || executeKeyEvent(event)) ? true : DEBUG;
}
public boolean executeKeyEvent(KeyEvent event) {
if (event.getAction() != 0) {
return DEBUG;
}
switch (event.getKeyCode()) {
case 21:
return arrowScroll(17);
case 22:
return arrowScroll(66);
case 61:
if (VERSION.SDK_INT < 11) {
return DEBUG;
}
if (KeyEventCompat.hasNoModifiers(event)) {
return arrowScroll(SCROLL_STATE_SETTLING);
}
if (KeyEventCompat.hasModifiers(event, SCROLL_STATE_DRAGGING)) {
return arrowScroll(SCROLL_STATE_DRAGGING);
}
return DEBUG;
default:
return DEBUG;
}
}
public boolean arrowScroll(int direction) {
View currentFocused = findFocus();
if (currentFocused == this) {
currentFocused = null;
} else if (currentFocused != null) {
boolean isChild = DEBUG;
for (ViewPager parent = currentFocused.getParent(); parent instanceof ViewGroup; parent = parent.getParent()) {
if (parent == this) {
isChild = true;
break;
}
}
if (!isChild) {
StringBuilder sb = new StringBuilder();
sb.append(currentFocused.getClass().getSimpleName());
for (ViewParent parent2 = currentFocused.getParent(); parent2 instanceof ViewGroup; parent2 = parent2.getParent()) {
sb.append(" => ").append(parent2.getClass().getSimpleName());
}
Log.e(TAG, "arrowScroll tried to find focus based on non-child current focused view " + sb.toString());
currentFocused = null;
}
}
boolean handled = DEBUG;
View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
if (nextFocused == null || nextFocused == currentFocused) {
if (direction == 17 || direction == SCROLL_STATE_DRAGGING) {
handled = pageLeft();
} else if (direction == 66 || direction == SCROLL_STATE_SETTLING) {
handled = pageRight();
}
} else if (direction == 17) {
handled = (currentFocused == null || getChildRectInPagerCoordinates(this.mTempRect, nextFocused).left < getChildRectInPagerCoordinates(this.mTempRect, currentFocused).left) ? nextFocused.requestFocus() : pageLeft();
} else if (direction == 66) {
handled = (currentFocused == null || getChildRectInPagerCoordinates(this.mTempRect, nextFocused).left > getChildRectInPagerCoordinates(this.mTempRect, currentFocused).left) ? nextFocused.requestFocus() : pageRight();
}
if (handled) {
playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
}
return handled;
}
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) {
if (outRect == null) {
outRect = new Rect();
}
if (child == null) {
outRect.set(SCROLL_STATE_IDLE, SCROLL_STATE_IDLE, SCROLL_STATE_IDLE, SCROLL_STATE_IDLE);
} else {
outRect.left = child.getLeft();
outRect.right = child.getRight();
outRect.top = child.getTop();
outRect.bottom = child.getBottom();
ViewGroup parent = child.getParent();
while ((parent instanceof ViewGroup) && parent != this) {
ViewGroup group = parent;
outRect.left += group.getLeft();
outRect.right += group.getRight();
outRect.top += group.getTop();
outRect.bottom += group.getBottom();
parent = group.getParent();
}
}
return outRect;
}
boolean pageLeft() {
if (this.mCurItem <= 0) {
return DEBUG;
}
setCurrentItem(this.mCurItem + INVALID_POINTER, true);
return true;
}
boolean pageRight() {
if (this.mAdapter == null || this.mCurItem >= this.mAdapter.getCount() + INVALID_POINTER) {
return DEBUG;
}
setCurrentItem(this.mCurItem + SCROLL_STATE_DRAGGING, true);
return true;
}
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
int focusableCount = views.size();
int descendantFocusability = getDescendantFocusability();
if (descendantFocusability != 393216) {
for (int i = SCROLL_STATE_IDLE; i < getChildCount(); i += SCROLL_STATE_DRAGGING) {
View child = getChildAt(i);
if (child.getVisibility() == 0) {
ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == this.mCurItem) {
child.addFocusables(views, direction, focusableMode);
}
}
}
}
if ((descendantFocusability == AccessibilityEventCompat.TYPE_GESTURE_DETECTION_START && focusableCount != views.size()) || !isFocusable()) {
return;
}
if (((focusableMode & SCROLL_STATE_DRAGGING) != SCROLL_STATE_DRAGGING || !isInTouchMode() || isFocusableInTouchMode()) && views != null) {
views.add(this);
}
}
public void addTouchables(ArrayList<View> views) {
for (int i = SCROLL_STATE_IDLE; i < getChildCount(); i += SCROLL_STATE_DRAGGING) {
View child = getChildAt(i);
if (child.getVisibility() == 0) {
ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == this.mCurItem) {
child.addTouchables(views);
}
}
}
}
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
int index;
int increment;
int end;
int count = getChildCount();
if ((direction & SCROLL_STATE_SETTLING) != 0) {
index = SCROLL_STATE_IDLE;
increment = SCROLL_STATE_DRAGGING;
end = count;
} else {
index = count + INVALID_POINTER;
increment = INVALID_POINTER;
end = INVALID_POINTER;
}
for (int i = index; i != end; i += increment) {
View child = getChildAt(i);
if (child.getVisibility() == 0) {
ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == this.mCurItem && child.requestFocus(direction, previouslyFocusedRect)) {
return true;
}
}
}
return DEBUG;
}
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) {
return super.dispatchPopulateAccessibilityEvent(event);
}
int childCount = getChildCount();
for (int i = SCROLL_STATE_IDLE; i < childCount; i += SCROLL_STATE_DRAGGING) {
View child = getChildAt(i);
if (child.getVisibility() == 0) {
ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == this.mCurItem && child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return DEBUG;
}
protected android.view.ViewGroup.LayoutParams generateDefaultLayoutParams() {
return new LayoutParams();
}
protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p) {
return generateDefaultLayoutParams();
}
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p) {
return ((p instanceof LayoutParams) && super.checkLayoutParams(p)) ? true : DEBUG;
}
public android.view.ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
return new LayoutParams(getContext(), attrs);
}
}
| [
"grebon@gmail.com"
] | grebon@gmail.com |
9a62a29df567f3cdb300ba428ee638bad2f916a8 | 3ca9698b73c5a6b4d1fd7b4710c55d1b740dfe38 | /app/src/main/java/com/example/zx1688/handler/MainActivity.java | 3dcf841f6359e740225aa867ecec91bb1a1029cb | [] | no_license | JAVASSR/Handler | db276ac449106b5892c30dcaac50302a0b070a52 | cb2086fe82d5c5e79bd7b2e687618947510ed6a3 | refs/heads/master | 2021-07-01T10:10:12.000794 | 2017-09-15T08:19:21 | 2017-09-15T08:19:21 | 103,632,625 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,767 | java | package com.example.zx1688.handler;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView textView=(TextView)findViewById(R.id.txtContent);
final Handler handler=new Handler(){
@Override
public void handleMessage(Message msg){
textView.setText(msg.arg1+"");
}
};
final Runnable myWorker=new Runnable() {
@Override
public void run() {
int progress=0;
while(progress<=100){
Message msg=new Message();
msg.arg1=progress;
handler.sendMessage(msg);
progress+=10;
try{
Thread.sleep(1000);
}catch (InterruptedException e){
e.printStackTrace();
}
}
Message msg=handler.obtainMessage();
msg.arg1=-1;
handler.sendMessage(msg);
}
};
Button button=(Button)findViewById(R.id.buttonStart);
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Thread workThread=new Thread(null,myWorker,"WorkThread");
workThread.start();
}
});
}
}
| [
"1713727885@qq.com"
] | 1713727885@qq.com |
dabd259c57c7e942e07d978b4a555ae06f228cf7 | 73639e3aab9dea503eaaca6f6d38f4ea40bd31f9 | /src/main/java/com/example/demo/mapper/Hr_nationMapper.java | 5196a66ed85ff0e84d0be3ae0fe6f32c8527f4ed | [] | no_license | hyh-h/LawOffices | 0306aae01dc070eeea07576999fc9b63d3b83480 | 1dc9b5ab72e374c88634d39ed9a76264b3156d06 | refs/heads/main | 2023-02-08T11:10:22.898340 | 2021-01-04T00:15:17 | 2021-01-04T00:15:17 | 325,746,012 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 281 | java | package com.example.demo.mapper;
import com.example.demo.entity.Hr_nation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hyh
* @since 2020-12-31
*/
public interface Hr_nationMapper extends BaseMapper<Hr_nation> {
}
| [
"3025305237@qq.com"
] | 3025305237@qq.com |
8815195c09627f5ade693301e19f56e6b89f2cc7 | 72e44ea0f8e48714d72d3ee4f17f731134161264 | /app/src/main/java/com/dmgremlins/nearby/LocationsListAdapter.java | 5363d1d8c91bce2dfd17420b58435eaa4b8384aa | [] | no_license | dkovachevikj/DAS2016_Nearby | ae0309c71f3d3f7062660a1bf0f491d68047d4a0 | 65b03d7b2e1bc82f63e4a19c78d205d414d4b0d0 | refs/heads/master | 2020-06-19T18:00:59.147335 | 2017-01-25T22:08:08 | 2017-01-25T22:08:08 | 74,841,732 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,307 | java | package com.dmgremlins.nearby;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.Random;
/*
takes care of filling the list that will contain
locations from a specific category with those locations
*/
public class LocationsListAdapter extends ArrayAdapter<String> {
Random random;
public LocationsListAdapter(Context context, String[] titles) {
super(context, R.layout.list_row, titles);
random = new Random();
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View customView = inflater.inflate(R.layout.list_row, parent, false);
String titleString = getItem(position);
TextView title = (TextView) customView.findViewById(R.id.listLocationTitle);
TextView distance = (TextView) customView.findViewById(R.id.listLocationDistance);
title.setText(titleString);
distance.setText(String.format("%.1f km", (random.nextInt(10000) + 100) / (float) 1000));
return customView;
}
}
| [
"dime15mk@gmail.com"
] | dime15mk@gmail.com |
b0aa0ddda30249aa52e0671285d46ed138746fb2 | 488f9036455d2a6035a1fffd5c46f9989781a315 | /wear/src/main/java/no/nordicsemi/android/nrftoolbox/uart/UARTConfigurationsAdapter.java | 8ea5ef45dece0006175fe0d731308ff229a9aef4 | [] | no_license | oneplaneteducation/My-nRF52-Toolbox | d068259a159897c38f4720a341a7cde1939fdb1f | a75f495ed08ade435b1b70b3799ceaf0b6a83561 | refs/heads/master | 2023-04-03T13:31:30.338178 | 2021-04-21T13:56:38 | 2021-04-21T13:56:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,525 | java | /*
* Copyright (c) 2015, Nordic Semiconductor
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package tk.giesecke.my_nrf52_tb.uart;
import android.content.Context;
import android.support.wearable.view.WearableListView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
import androidx.annotation.NonNull;
import tk.giesecke.my_nrf52_tb.R;
import tk.giesecke.my_nrf52_tb.uart.domain.UartConfiguration;
class UARTConfigurationsAdapter extends WearableListView.Adapter {
private final LayoutInflater inflater;
private List<UartConfiguration> configurations;
UARTConfigurationsAdapter(final Context context) {
inflater = LayoutInflater.from(context);
}
/**
* Populates the adapter with list of configurations.
*/
void setConfigurations(final List<UartConfiguration> configurations) {
this.configurations = configurations;
notifyDataSetChanged();
}
@NonNull
@Override
public WearableListView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup viewGroup, final int viewType) {
return new ConfigurationViewHolder(inflater.inflate(R.layout.configuration_item, viewGroup, false));
}
@Override
public void onBindViewHolder(@NonNull final WearableListView.ViewHolder holder, final int position) {
final ConfigurationViewHolder viewHolder = (ConfigurationViewHolder) holder;
viewHolder.setConfiguration(configurations.get(position));
}
@Override
public int getItemCount() {
return configurations != null ? configurations.size() : 0;
}
static class ConfigurationViewHolder extends WearableListView.ViewHolder {
private UartConfiguration configuration;
private TextView name;
ConfigurationViewHolder(final View itemView) {
super(itemView);
name = itemView.findViewById(R.id.name);
}
private void setConfiguration(final UartConfiguration configuration) {
this.configuration = configuration;
name.setText(configuration.getName());
}
UartConfiguration getConfiguration() {
return configuration;
}
}
}
| [
"bernd.giesecke@rakwireless.com"
] | bernd.giesecke@rakwireless.com |
a924e948185ae986d515cefb69604d7482e61e13 | 8e0e88e8fe2ef41003b7465e97392df77a06ae15 | /Athlete/src/tests/AllTests.java | 29ee5b050b384fe2e718f86ad079541f2ff7ab44 | [] | no_license | justinridout/Athlete | 37021a7918537319cf4c358723ddfbf71bdcd024 | 58ecd222c27f1f7a09fb739f0280f343e76e3919 | refs/heads/master | 2020-12-22T00:33:05.630177 | 2020-01-27T23:11:16 | 2020-01-27T23:11:16 | 236,615,864 | 0 | 0 | null | 2020-10-13T19:06:54 | 2020-01-27T23:10:40 | Java | UTF-8 | Java | false | false | 243 | java | package tests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ TestAthleteLogic.class, TestAthleteLogic2.class })
public class AllTests {
}
| [
"56090823+justinridout@users.noreply.github.com"
] | 56090823+justinridout@users.noreply.github.com |
28c7aae364e821a6e3f03e12d11a79746d35a4a6 | 4a65774fef1062b5b89c244b18a9474f7b7661b5 | /RitmeRecipe/src/be/apb/gfddpp/productfilter/RangesType.java | 7501ed2931cee362c612c9ac931f6eea812ab8e0 | [] | no_license | imec-int/ritme | 30c3c8eb7488a66f83a69527ee501b4b7889e568 | a004895d3b33d73156eaf113b7aeb85aa5bcf9d0 | refs/heads/master | 2022-01-15T04:58:12.436553 | 2019-07-29T14:12:05 | 2019-07-29T14:12:05 | 80,729,112 | 0 | 1 | null | 2019-07-29T14:12:06 | 2017-02-02T13:49:28 | Java | UTF-8 | Java | false | false | 2,225 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.08.08 at 04:15:31 PM CEST
//
package be.apb.gfddpp.productfilter;
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.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for rangesType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="rangesType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="range" type="{}range" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "rangesType", propOrder = {
"range"
})
@XmlSeeAlso({
MedicinesRanges.class,
PreparationsRanges.class
})
public class RangesType {
@XmlElement(required = true)
protected List<Range> range;
/**
* Gets the value of the range 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 range property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getRange().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Range }
*
*
*/
public List<Range> getRange() {
if (range == null) {
range = new ArrayList<Range>();
}
return this.range;
}
}
| [
"ritm-e@uzleuven.be"
] | ritm-e@uzleuven.be |
275f34b733b8ebdd78ee42a37ddf255b6fbbfb9f | 4aa0ec4a2dbf21838837dd7ff2ac0caedbdc40c1 | /ketab-admin/src/main/java/org/firstpartysystems/ketab/support/modelmapper/ModelMapper.java | 639acb3c4ac144d5c5db315bc03ab644a7672e07 | [] | no_license | aomargithub/ketab | a56782e9896a23f679714dcc88e3469d23147e21 | c8b5f2541d17e63488fe53bef9f088fad9ab8de4 | refs/heads/master | 2021-03-27T19:38:53.035210 | 2017-07-22T18:46:37 | 2017-07-22T18:46:37 | 89,778,545 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 719 | java | package org.firstpartysystems.ketab.support.modelmapper;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.firstpartysystems.ketab.domain.DomainModel;
import org.firstpartysystems.ketab.rest.dto.UserModel;
/**
*
* @author Ahmad Omar
*
*/
public interface ModelMapper<E extends DomainModel<?>, D extends UserModel<?>> extends Serializable{
D convertToDto(E entity);
List<D> convertToDto(List<E> entities);
Set<D> convertToDto(Set<E> entities);
E convertToEntity(D dto);
List<E> convertToEntity(List<D> dtos);
Set<E> convertToEntity(Set<D> dtos);
E convertToNewEntity(D dto);
List<E> convertToNewEntity(List<D> dtos);
Set<E> convertToNewEntity(Set<D> dtos);
}
| [
"aomar.github@gmail.com"
] | aomar.github@gmail.com |
2d192034ba441b15cf263b0e7c0f393443bf217a | a3afc35fa18aca579f5733b0b9b8deb97469c7b3 | /app/src/main/java/org/fwwb/convene/convenecode/BaseApplication.java | f2b6913724d7604d1c03be042dec2794518da1b2 | [] | no_license | Avinash208/convene_android | 0602e629e7246c84ecbb4548598073f8b8134b19 | f17e3939f8fe080ea599f8e3ac7057f004222c57 | refs/heads/master | 2020-03-28T21:12:33.558608 | 2018-09-17T14:31:53 | 2018-09-17T14:31:53 | 149,137,931 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,008 | java | package org.fwwb.convene.convenecode;
import android.app.Application;
import android.content.Context;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Build;
import android.support.multidex.MultiDex;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
import org.fwwb.convene.convenecode.receivers.ConnectivityReceiver;
public class BaseApplication extends Application {
@Override
public void onCreate()
{
super.onCreate();
Fabric.with(this, new Crashlytics());
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
ConnectivityReceiver connectionReceiver= new ConnectivityReceiver();
registerReceiver(connectionReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
}
}
| [
"avinash.r@mahiti.org"
] | avinash.r@mahiti.org |
026c7c447301d4c14207d1db7cf0a09e53f49f58 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XRENDERING-481-15-28-NSGA_II-LineCoverage:ExceptionType:StackTraceSimilarity/com/xpn/xwiki/api/Document_ESTest_scaffolding.java | 78c5db8567c24ac4db5fd22a5c0cf2378cb9c8c4 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 430 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Mon Apr 06 14:58:48 UTC 2020
*/
package com.xpn.xwiki.api;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class Document_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
d99c380b1db15597f091e7774638b73a012fcfe7 | 59b5e7e3a484edce9c2306ed4bb79f5cc0586f15 | /tbo/src/com/sosee/sys/base/service/TradeServiceImpl.java | 772ae46b81e4f3608691894e576429105611e658 | [] | no_license | Blusez/javaWeb-Dome | 415f62aac1134b6fbc7385a0d4a2cd612dad28df | af7f3b2226f529b8a2db4594e30ede39330cd535 | refs/heads/master | 2020-07-10T16:54:33.308991 | 2016-09-09T08:03:06 | 2016-09-09T08:03:06 | 67,776,939 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,250 | java | package com.sosee.sys.base.service;
import java.io.Serializable;
import java.util.List;
import com.sosee.base.dao.Page;
import com.sosee.sys.base.dao.TradeDao;
import com.sosee.sys.base.pojo.Items;
import com.sosee.sys.base.pojo.Trade;
public class TradeServiceImpl implements TradeService {
private TradeDao tradeDao;
public TradeDao getTradeDao() {
return tradeDao;
}
public void setTradeDao(TradeDao tradeDao) {
this.tradeDao = tradeDao;
}
@Override
public void delete(Trade trade) {
// TODO Auto-generated method stub
tradeDao.delete(trade);
}
@Override
public List<Trade> queryTradeByItem(Items items) {
// TODO Auto-generated method stub
return tradeDao.queryForList("from Trade where itemId=?", new Object[]{items});
}
@Override
public List<Trade> queryAllTrades() {
// TODO Auto-generated method stub
return tradeDao.queryAll("from Trade");
}
@Override
public void add(Trade trade) {
// TODO Auto-generated method stub
tradeDao.create(trade);
}
@Override
public Trade getTradeById(Serializable id) {
// TODO Auto-generated method stub
return tradeDao.queryById(id);
}
@Override
public void update(Trade trade) {
// TODO Auto-generated method stub
tradeDao.update(trade);
}
}
| [
"zhule007@qq.com"
] | zhule007@qq.com |
7fc444ff7e3692913c0e08133d51b03de6f4a19a | 5fd3d2d20539d4e160f8ac293e0d4f1566a98a2c | /hz-fine-master/src/main/java/com/hz/fine/master/core/service/impl/DidServiceImpl.java | edecf6a0b22cecc8a3611203d58f1af5887d5235 | [] | no_license | hzhuazhi/hz-fine | eeac8ba3b7eecebf1934abab5a4610d3f7e0cd6f | addc43d2fe849e01ebd5b78300aae6fdf2171719 | refs/heads/master | 2022-12-14T12:24:59.982673 | 2020-09-05T11:02:02 | 2020-09-05T11:02:02 | 262,562,132 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,278 | java | package com.hz.fine.master.core.service.impl;
import com.hz.fine.master.core.common.dao.BaseDao;
import com.hz.fine.master.core.common.service.impl.BaseServiceImpl;
import com.hz.fine.master.core.mapper.DidMapper;
import com.hz.fine.master.core.model.did.DidModel;
import com.hz.fine.master.core.service.DidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description 用户Service层的实现层
* @Author yoko
* @Date 2020/5/13 18:34
* @Version 1.0
*/
@Service
public class DidServiceImpl<T> extends BaseServiceImpl<T> implements DidService<T> {
/**
* 5分钟.
*/
public long FIVE_MIN = 300;
public long TWO_HOUR = 2;
@Autowired
private DidMapper didMapper;
public BaseDao<T> getDao() {
return didMapper;
}
@Override
public List<DidModel> getEffectiveDidList(DidModel model) {
return didMapper.getEffectiveDidList(model);
}
@Override
public int updateDidMoneyByOrder(DidModel model) {
return didMapper.updateDidMoneyByOrder(model);
}
@Override
public List<DidModel> getEffectiveDidByZfbList(DidModel model) {
return didMapper.getEffectiveDidByZfbList(model);
}
@Override
public int updateDidBalance(DidModel model) {
return didMapper.updateDidBalance(model);
}
@Override
public List<DidModel> getEffectiveDidByWxGroupList(DidModel model) {
return didMapper.getEffectiveDidByWxGroupList(model);
}
@Override
public int updateDidGroupNumOrSwitchType(DidModel model) {
return didMapper.updateDidGroupNumOrSwitchType(model);
}
@Override
public List<DidModel> getNewEffectiveDidByWxGroupList(DidModel model) {
return didMapper.getNewEffectiveDidByWxGroupList(model);
}
@Override
public List<DidModel> getDidByWxGroupList(DidModel model) {
return didMapper.getDidByWxGroupList(model);
}
@Override
public int updateDidOperateGroupNum(DidModel model) {
return didMapper.updateDidOperateGroupNum(model);
}
@Override
public List<DidModel> getDidByPoolList(DidModel model) {
return didMapper.getDidByPoolList(model);
}
}
| [
"duanfeng_1712@qq.com"
] | duanfeng_1712@qq.com |
14167638a6c74f98de7c72e6937d13a4d2ec01c3 | 6811fd178ae01659b5d207b59edbe32acfed45cc | /jira-project/jira-components/jira-tests-parent/jira-tests-unit/src/test/java/com/atlassian/jira/issue/statistics/TestJqlSelectStatisticsMapper.java | ee40a9b685dada8ef934f2fe34399f49ef932325 | [] | no_license | xiezhifeng/mysource | 540b09a1e3c62614fca819610841ddb73b12326e | 44f29e397a6a2da9340a79b8a3f61b3d51e331d1 | refs/heads/master | 2023-04-14T00:55:23.536578 | 2018-04-19T11:08:38 | 2018-04-19T11:08:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,645 | java | /*
* Copyright (c) 2002-2004
* All rights reserved.
*/
package com.atlassian.jira.issue.statistics;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.action.issue.customfields.option.MockOption;
import com.atlassian.jira.issue.customfields.converters.SelectConverterImpl;
import com.atlassian.jira.issue.customfields.option.Option;
import com.atlassian.jira.issue.customfields.searchers.transformer.CustomFieldInputHelper;
import com.atlassian.jira.issue.customfields.statistics.GroupPickerStatisticsMapper;
import com.atlassian.jira.issue.customfields.statistics.ProjectSelectStatisticsMapper;
import com.atlassian.jira.issue.customfields.statistics.SelectStatisticsMapper;
import com.atlassian.jira.issue.customfields.statistics.TextStatisticsMapper;
import com.atlassian.jira.issue.customfields.statistics.UserPickerStatisticsMapper;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.search.ClauseNames;
import com.atlassian.jira.issue.search.SearchRequest;
import com.atlassian.jira.local.MockControllerTestCase;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.MockUser;
import com.atlassian.query.QueryImpl;
import com.atlassian.query.clause.TerminalClauseImpl;
import com.atlassian.query.operand.EmptyOperand;
import com.atlassian.query.operator.Operator;
import com.mockobjects.dynamic.Mock;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class TestJqlSelectStatisticsMapper extends MockControllerTestCase
{
private ClauseNames clauseNames = new ClauseNames("cf[10001]");
private JiraAuthenticationContext authenticationContext;
private CustomFieldInputHelper customFieldInputHelper;
private User user;
@Before
public void setUp() throws Exception
{
authenticationContext = getMock(JiraAuthenticationContext.class);
user = new MockUser("fred");
expect(authenticationContext.getLoggedInUser()).andStubReturn(user);
customFieldInputHelper = EasyMock.createMock(CustomFieldInputHelper.class);
}
@Test
public void testGetSearchUrlSuffixNullSearchRequest() throws Exception
{
final CustomField customField = mockController.getMock(CustomField.class);
expect(customField.getClauseNames()).andReturn(new ClauseNames("customfield_10001"));
expect(customField.getName()).andReturn("Number CF");
expect(customFieldInputHelper.getUniqueClauseName(user, "customfield_10001", "Number CF")).andReturn("cf[10001]");
mockController.replay();
EasyMock.replay(customFieldInputHelper);
SelectStatisticsMapper mapper = new SelectStatisticsMapper(customField, new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
assertNull(mapper.getSearchUrlSuffix(null, null));
mockController.verify();
}
@Test
public void testGetSearchUrlSuffixNullValue() throws Exception
{
final CustomField customField = mockController.getMock(CustomField.class);
expect(customField.getClauseNames()).andReturn(new ClauseNames("cf[10001]"));
expect(customField.getName()).andReturn("Number CF");
final SearchRequest searchRequest = mockController.getMock(SearchRequest.class);
expect(customFieldInputHelper.getUniqueClauseName(user, "cf[10001]", "Number CF")).andReturn("cf[10001]");
searchRequest.getQuery();
mockController.setReturnValue(new QueryImpl());
mockController.replay();
EasyMock.replay(customFieldInputHelper);
SelectStatisticsMapper mapper = new SelectStatisticsMapper(customField, new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
final SearchRequest urlSuffix = mapper.getSearchUrlSuffix(null, searchRequest);
assertEquals(new TerminalClauseImpl(clauseNames.getPrimaryName(), Operator.IS, EmptyOperand.EMPTY), urlSuffix.getQuery().getWhereClause());
mockController.verify();
EasyMock.verify(customFieldInputHelper);
}
@Test
public void testGetSearchUrlSuffix() throws Exception
{
final CustomField customField = mockController.getMock(CustomField.class);
expect(customField.getClauseNames()).andReturn(new ClauseNames("cf[10001]"));
expect(customField.getName()).andReturn("Number CF");
final SearchRequest searchRequest = mockController.getMock(SearchRequest.class);
EasyMock.expect(customFieldInputHelper.getUniqueClauseName(user, "cf[10001]", "Number CF")).andReturn("cf[10001]");
searchRequest.getQuery();
mockController.setReturnValue(new QueryImpl());
mockController.replay();
EasyMock.replay(customFieldInputHelper);
SelectStatisticsMapper mapper = new SelectStatisticsMapper(customField, new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
Option option = new MockOption(null, null, 1L, "value", null, 1L);
final SearchRequest urlSuffix = mapper.getSearchUrlSuffix(option, searchRequest);
assertEquals(new TerminalClauseImpl(clauseNames.getPrimaryName(), Operator.EQUALS, "value"), urlSuffix.getQuery().getWhereClause());
mockController.verify();
EasyMock.verify(customFieldInputHelper);
}
@Test
public void testEquals()
{
mockController.replay();
Mock mockCustomField = new Mock(CustomField.class);
mockCustomField.setStrict(true);
String cfId = "customfield_10001";
mockCustomField.expectAndReturn("getId", cfId);
mockCustomField.expectAndReturn("getClauseNames", new ClauseNames("cf[10001]"));
SelectStatisticsMapper mapper = new SelectStatisticsMapper((CustomField) mockCustomField.proxy(), new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
// identity test
assertTrue(mapper.equals(mapper));
assertEquals(mapper.hashCode(), mapper.hashCode());
Mock mockCustomField2 = new Mock(CustomField.class);
mockCustomField2.setStrict(true);
mockCustomField2.expectAndReturn("getId", "customfield_10001");
mockCustomField2.expectAndReturn("getClauseNames", new ClauseNames("cf[10001]"));
SelectStatisticsMapper mapper2 = new SelectStatisticsMapper((CustomField) mockCustomField2.proxy(), new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
// As the mappers are using the same custom field they should be equal
assertTrue(mapper.equals(mapper2));
mockCustomField.verify();
mockCustomField2.verify();
assertEquals(mapper.hashCode(), mapper2.hashCode());
CustomField mockCustomField3 = EasyMock.createMock(CustomField.class);
final String cfId2 = "customfield_10002";
EasyMock.expect(mockCustomField3.getId()).andReturn(cfId2);
EasyMock.expect(mockCustomField3.getId()).andReturn(cfId2);
EasyMock.expect(mockCustomField3.getClauseNames()).andReturn(new ClauseNames("cf[10001]"));
EasyMock.replay(mockCustomField3);
SelectStatisticsMapper mapper3 = new SelectStatisticsMapper(mockCustomField3, new SelectConverterImpl(null), authenticationContext, customFieldInputHelper);
// As the mappers are using different custom field they should *not* be equal
assertFalse(mapper.equals(mapper3));
assertFalse(mapper.hashCode() == mapper3.hashCode());
assertFalse(mapper.equals(null));
assertFalse(mapper.equals(new Object()));
assertFalse(mapper.equals(new IssueKeyStatisticsMapper()));
assertFalse(mapper.equals(new IssueTypeStatisticsMapper(null)));
// ensure other implmentations of same base class are not equal even though they both extend
// they inherit the equals and hashCode implementations
assertFalse(mapper.equals(new UserPickerStatisticsMapper((CustomField) mockCustomField.proxy(), null, null)));
assertFalse(mapper.equals(new TextStatisticsMapper((CustomField) mockCustomField.proxy())));
assertFalse(mapper.equals(new ProjectSelectStatisticsMapper((CustomField) mockCustomField.proxy(), null)));
assertFalse(mapper.equals(new GroupPickerStatisticsMapper((CustomField) mockCustomField.proxy(), null, authenticationContext, customFieldInputHelper)));
EasyMock.verify(mockCustomField3);
mockCustomField.verify();
}
}
| [
"moink635@gmail.com"
] | moink635@gmail.com |
132bdb2cfb52e20eaa672c366b0cc1f00d76ad88 | 020922dc27fbb1e6a8f428842758fdc1498d46ff | /src/test/testhelpers/PetBinder.java | 97147d371ba3f774759356c49f2deb5bf6e8dfe5 | [
"Apache-2.0"
] | permissive | Prepaird/objectgraphdb | bce768293adff39c36975a41d266f356eb992662 | 883ca6c6e8e7de60ee127beba6e8bcb18a3cd575 | refs/heads/master | 2016-09-12T10:35:30.360558 | 2016-04-26T08:18:36 | 2016-04-26T08:18:36 | 57,057,473 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,920 | java | /*
* Copyright 2016 Prepaird AB (556983-5688).
*
* 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 testhelpers;
import com.google.common.base.Objects;
import com.prepaird.objectgraphdb.ObjectGraphDb;
import com.prepaird.objectgraphdb.queryrunners.OGBinder;
import com.prepaird.objectgraphdb.utils.Log;
import com.prepaird.objectgraphdb.utils.Utils;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import java.util.List;
import jpatest.edge.HasPet;
import jpatest.vertex.organisms.Pet;
/**
*
* @author Oliver Fleetwood
*/
public class PetBinder implements OGBinder {
@Override
public Object onLoad(ObjectGraphDb db, ODocument sourceVertex) {
String maleId = Utils.getRecordId(sourceVertex);
String q = "select expand(out('" + HasPet.class.getSimpleName() + "')[favourite=true]) from " + maleId;
// Log.debug(q);
List<Pet> res = db.query(new OSQLSynchQuery(q));
return res.isEmpty() ? null : res.get(0);
}
@Override
public Object onSave(ObjectGraphDb db, ODocument sourceVertex, Object newValue) {
if (newValue == null) {
return null;
}
//any existing pets are not favourites...
Pet p = db.save(newValue);
String maleId = Utils.getRecordId(sourceVertex), petId = p.getId(), ownerId = Utils.getRecordId(p.getOwnerId());
String q;
if (ownerId == null) {
q = "create Edge " + HasPet.class.getSimpleName() + " from " + maleId + " TO " + petId;
// Log.debug(q);
db.command(new OCommandSQL(q)).execute();
} else if (!Objects.equal(maleId, ownerId)) {
Log.error("this is not the owner of this pet!!!");
return null;
}
q = "update ("
+ "select expand(out('" + HasPet.class.getSimpleName() + "')) from " + maleId
+ ") set favourite = eval('@rid == " + petId + "')";
// Log.debug(q);
db.command(new OCommandSQL(q)).execute();
return db.reload(p);
}
@Override
public Object onDelete(ObjectGraphDb db, ODocument source, Object value) {
if (Utils.idNotNull(value)) {
//delete the pet/orphan removal
db.delete(value);
}
return null;
}
}
| [
"oliver.fleetwood@gmail.com"
] | oliver.fleetwood@gmail.com |
1c3be88418bbdf7da6c31eee10622b4028c6b038 | d20fda7153a4562e5272e2078ef00fb89dfcfe30 | /src/main/java/xyz/lomasz/springhelloworld/handler/JmsErrorHandler.java | 6bac62b5d76d2489752de8e0cce0a8131e95dc4e | [] | no_license | lomasz/spring-hello-world | 018ccb03bed78a570264d4b48923b8e9cae7282b | 2e01eb9c15fd2bbc0141834ebfd9f2c77f05f98b | refs/heads/master | 2021-09-07T23:43:20.339307 | 2018-03-03T12:07:47 | 2018-03-03T12:07:47 | 108,401,219 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 365 | java | package xyz.lomasz.springhelloworld.handler;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.stereotype.Service;
import org.springframework.util.ErrorHandler;
@CommonsLog
@Service
public class JmsErrorHandler implements ErrorHandler {
@Override
public void handleError(Throwable t) {
log.error(t.getMessage());
}
}
| [
"lukasz.tomaszewski89@gmail.com"
] | lukasz.tomaszewski89@gmail.com |
22eb9bd40c4b918d3ab7d84691e00fde2ff4329d | b76a223dc7205b8d0ff859b7a8bd56d3e74dfbd0 | /MyFlexibleFragment/app/src/main/java/com/example/myflexiblefragment/MainActivity.java | b5c548bb1582672eea8bc965cf4106c13a60f81f | [] | no_license | agustinartf13/dicoding-androidDasar | 939dfa7c72ae142b192cfe9faa9c4092ee65f78e | 35af6c310986cf83045176af30ffc655e2313a4a | refs/heads/master | 2022-12-15T05:14:58.925662 | 2020-09-11T16:50:13 | 2020-09-11T16:50:13 | 294,750,122 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,041 | java | package com.example.myflexiblefragment;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager mFragmentManager = getSupportFragmentManager();
HomeFragment mHomeFragment = new HomeFragment();
Fragment fragment = mFragmentManager.findFragmentByTag(HomeFragment.class.getSimpleName());
if (!(fragment instanceof HomeFragment)) {
Log.d("MyFlexibleFragment", "Fragment Name :" + HomeFragment.class.getSimpleName());
mFragmentManager
.beginTransaction()
.add(R.id.frame_container, mHomeFragment, HomeFragment.class.getSimpleName())
.commit();
}
}
}
| [
"agustina123379@gmail.com"
] | agustina123379@gmail.com |
49b4bff04a3d8a5735130ded4e54cb3b1e37326f | 6daf7349a304f2a55e85518258de42e0551adcea | /AbstractFactoryMethod/src/com/alliswell/factory/beans/PrawnPizza.java | 5dd24cd81ea8cef5f15272effcabded24b6b755d | [] | no_license | MyGitHub131/MyCoreJavaProject | ebcedb017bb642bd05290a94e862c428c256bd5a | f1c87cc9c486ed93baf03493f93c276c0de34a67 | refs/heads/master | 2022-11-20T06:29:53.953450 | 2020-07-22T06:47:39 | 2020-07-22T06:47:39 | 279,468,280 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 532 | java | package com.alliswell.factory.beans;
public class PrawnPizza implements IPizza {
@Override
public void prepare() {
System.out.println("Prawn Pizza Details");
System.out.println("===================");
System.out.println("Prawn pizza prepared...");
}
@Override
public void bake() {
System.out.println("Baking pizza...");
}
@Override
public void cut() {
System.out.println("Cutting pizza...");
}
@Override
public void box() {
System.out.println("Boxing pizza...");
}
}
| [
"DELL@ADMIN"
] | DELL@ADMIN |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.