blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
995729b18fa08f413544fc2f9fe1789934f1eaaf | d7cb8ab8cc0b1406f86016e69ef9b9334b7551c6 | /android/src/main/java/com/raulh82vlc/MoviesFinder/MoviesFinderApp.java | a7bc4f9804b671bfc5368d28558fa331de8cb8c1 | [
"Apache-2.0"
] | permissive | josedlpozo/Movies-Finder | 5cd856cd6128c09df2464255bd57798a9558013b | 409d04a7a0b43be426969753a999b2250f940bb1 | refs/heads/master | 2021-01-23T23:30:05.752967 | 2016-07-02T22:54:39 | 2016-07-03T12:40:11 | 62,503,115 | 0 | 0 | null | 2016-07-03T15:35:34 | 2016-07-03T15:35:33 | null | UTF-8 | Java | false | false | 1,542 | java | /*
* Copyright (C) 2016 Raul Hernandez Lopez
*
* 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.raulh82vlc.MoviesFinder;
import android.app.Application;
import com.raulh82vlc.MoviesFinder.di.components.ApplicationComponent;
import com.raulh82vlc.MoviesFinder.di.modules.ApplicationModule;
import com.raulh82vlc.MoviesFinder.di.components.DaggerApplicationComponent;
/**
* {@link ApplicationComponent} could be used to provide dependencies needed by the whole app
* execution. Application context linked dependencies would be exposed by it too.
*
* @author Raul Hernandez Lopez
*/
public class MoviesFinderApp extends Application {
private ApplicationComponent applicationComponent;
@Override
public void onCreate() {
super.onCreate();
applicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
.build();
}
public ApplicationComponent component() {
return applicationComponent;
}
}
| [
"[email protected]"
] | |
a1311895f2745d2076928c4489d51e2704c7c35e | a6362ee54921aa8db7a526b5a2a5b39e202558a1 | /gmall-pms/src/main/java/com/atguigu/gmall/pms/dao/SkuInfoDao.java | 9035617c0d16cc85595c552ab23329e966d3a348 | [
"Apache-2.0"
] | permissive | qgh123456/gmall | 4971f15ecca074b9a361bfc1ad3784bb1b48bc14 | 5e557c3c26c3dd77089410dc2272b71705d3b9dd | refs/heads/master | 2022-07-09T15:26:01.048557 | 2020-01-09T04:09:45 | 2020-01-09T04:09:45 | 232,533,804 | 0 | 0 | Apache-2.0 | 2022-06-21T02:36:05 | 2020-01-08T10:04:59 | JavaScript | UTF-8 | Java | false | false | 367 | java | package com.atguigu.gmall.pms.dao;
import com.atguigu.gmall.pms.entity.SkuInfoEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* sku信息
*
* @author qiguohui
* @email [email protected]
* @date 2020-01-08 22:46:32
*/
@Mapper
public interface SkuInfoDao extends BaseMapper<SkuInfoEntity> {
}
| [
"[email protected]"
] | |
7f4d47881c8ec5820625fddd6a9869b1c21ebd01 | 5b1cd07fd6803342c65ce0ec7b6a812cc747349c | /api/src/main/java/com/datapath/kg/risks/api/dao/repository/ComponentImpactRepository.java | ef9984c9a6c1b8262f1aaa94a8303712468719f7 | [
"Apache-2.0"
] | permissive | DataPathAnalytics/KR_Developing-a-New-Audit-Methodology-for-Electronic-Public-Tenders-back | b077379e9a96aaaf21404d37814564ce295d5059 | 0e3d4dc16b51869806f74f0b3ef31cc193ad372f | refs/heads/master | 2023-04-07T19:05:54.042053 | 2019-12-17T15:34:27 | 2019-12-17T15:34:27 | 228,623,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 282 | java | package com.datapath.kg.risks.api.dao.repository;
import com.datapath.kg.risks.api.dao.entity.ComponentImpactEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ComponentImpactRepository extends JpaRepository<ComponentImpactEntity, Integer> {
}
| [
"[email protected]"
] | |
59d85525381fb66eba11e8264015d8ff7b2a48e5 | ee0cd437c134535a5c028dd2818af15a96941ce2 | /src/main/java/br/com/martins/edson/spring/marvel/game/mapper/ArenaMapper.java | 3724c28dcc851131a795bc4c99c9cb746362216d | [] | no_license | edson-martins/spring-boot-marvel-game | c0958861cd1712cd64651c755dd76739c669f449 | 6a37f5c9cc68086dd09b12232df06bc0d432dd83 | refs/heads/main | 2023-06-16T06:09:20.055921 | 2021-07-15T21:42:22 | 2021-07-15T21:42:22 | 362,203,846 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 609 | java | package br.com.martins.edson.spring.marvel.game.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;
import br.com.martins.edson.spring.marvel.game.dto.ArenaDTO;
import br.com.martins.edson.spring.marvel.game.model.Game;
/**
* Interface : ArenaMapper
* Description: MapStruct mapper from ArenaDTO to Game model.
*
* @author Edson Martins
*/
@Mapper(componentModel = "spring")
@Component
public interface ArenaMapper {
public static final ArenaMapper INSTANCE = Mappers.getMapper(ArenaMapper.class);
Game toGame(ArenaDTO arena);
}
| [
"[email protected]"
] | |
70dc33f7a1b2ff918ab8c6041420f745442291df | 5a0e9e009b6b97b9f4f16b43fda5be39f934c979 | /1-03-mockito/src/test/java/houseware/learn/testing/mockito/model/TestMockitoUserServices2.java | b7dc21e3d90e647f460fb6e05e2c2e3b1ff61a0f | [] | no_license | chandanws/testing-1 | 0aad71708ef2c96e88ff082c1d04f1882ae2aa36 | 0560118fe047768358ee99aa067ab39fd8b400d4 | refs/heads/master | 2021-06-11T08:55:59.630732 | 2016-09-06T10:25:49 | 2016-09-06T10:25:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,623 | java | package houseware.learn.testing.mockito.model;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import javax.persistence.EntityManager;
import static org.mockito.Mockito.when;
import static org.junit.Assert.*;
/**
* @author [email protected]
*/
@RunWith(MockitoJUnitRunner.class)
public class TestMockitoUserServices2 {
@Mock
EntityManager entityManager;
@Before
public void setUp() {
when(entityManager.find(User.class, 1L)).thenReturn(new User(1L, "juanito", "lopez"));
when(entityManager.find(User.class, 18L)).thenReturn(new User(18L, "alvarito", "perez"));
when(entityManager.find(User.class, 0L)).thenReturn(null);
when(entityManager.find(User.class, -10L)).thenReturn(null);
when(entityManager.find(User.class, null)).thenReturn(null);
}
@Test
public void validar_findAndUpper_with_1() {
User u = new UserServices(new UserDAO(entityManager)).findAndUpper(1L);
assertNotNull("user is null",u);
assertEquals("juanito", u.getFirstName());
assertEquals("LOPEZ", u.getLastName());
}
@Test
public void validar_findAndUpper_with_18() {
User u = new UserServices(new UserDAO(entityManager)).findAndUpper(18L);
assertNotNull("user is null",u);
assertEquals("ALVARITO", u.getFirstName());
}
@Test
public void validar_findAndUpper_with_null() {
User u = new UserServices(new UserDAO(entityManager)).findAndUpper(null);
assertNull(u);
}
}
| [
"[email protected]"
] | |
1ef12cd6a731f4df405bc4ffd6107b362ec82df5 | 2e7dcd12ad488b8b443b16c4beffc5c17d2fd000 | /6 kuy/DecodetheMorsecode/src/test/java/MorseCodeDecoderTest.java | be977700c8d53a0f69c93b02879e681036f88d7f | [] | no_license | OleksandrChekalenko/codewars | a12ddcc851ae221e90fd67598ab10915e124e385 | 22114e6dcc997cb705a44eaa6b53e35d68c06368 | refs/heads/master | 2023-08-17T16:35:32.199682 | 2023-08-11T13:28:15 | 2023-08-11T13:28:15 | 157,531,287 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | import org.junit.Test;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
public class MorseCodeDecoderTest {
@Test
public void testExampleFromDescription() {
assertThat(MorseCodeDecoder.decode(".... . -.-- .--- ..- -.. ."), is("HEY JUDE"));
}
} | [
"[email protected]"
] | |
fe6731f5be3827cc037096c511f6a5a4b9280f0e | 28df46f33feb507577e41f1140334d27f14f510c | /xacml3/trunk/xacml-core/src/main/java/org/forgerock/xacml/core/v3/Functions/AccessPermitted.java | 746309433daeed2cf1f86645e6ad893f3ff922a4 | [] | no_license | deepakchanalia/forgerock-commons | 3dc5c0ac6c541ac2f5fbbe8fdf79b21e90bc8a5e | dd83127c17428e9397a568b3eaac46a72d1aa087 | refs/heads/master | 2021-01-11T21:00:12.193770 | 2015-07-23T22:46:14 | 2015-07-23T22:46:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,440 | java | /**
*
~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
~
~ Copyright (c) 2011-2013 ForgeRock AS. All Rights Reserved
~
~ The contents of this file are subject to the terms
~ of the Common Development and Distribution License
~ (the License). You may not use this file except in
~ compliance with the License.
~
~ You can obtain a copy of the License at
~ http://forgerock.org/license/CDDLv1.0.html
~ See the License for the specific language governing
~ permission and limitations under the License.
~
~ When distributing Covered Code, include this CDDL
~ Header Notice in each file and include the License file
~ at http://forgerock.org/license/CDDLv1.0.html
~ If applicable, add the following below the CDDL Header,
~ with the fields enclosed by brackets [] replaced by
~ your own identifying information:
~ "Portions Copyrighted [year] [name of copyright owner]"
*
*/
package org.forgerock.xacml.core.v3.Functions;
/**
* A.3.16 Other functions
urn:oasis:names:tc:xacml:3.0:function:access-permitted
This function SHALL take an “http://www.w3.org/2001/XMLSchema#anyURI” and an
"http://www.w3.org/2001/XMLSchema#string" as arguments.
The first argument SHALL be interpreted as an attribute category.
The second argument SHALL be interpreted as the XML content of an <Attributes> element with Category
equal to the first argument. The function evaluates to an "http://www.w3.org/2001/XMLSchema#boolean".
This function SHALL return "True" if and only if the policy evaluation described below returns the value of "Permit".
The following evaluation is described as if the context is actually instantiated,
but it is only required that an equivalent result be obtained.
The function SHALL construct a new context, by copying all the information from the current context,
omitting any <Attributes> element with Category equal to the first argument.
The second function argument SHALL be added to the context as the content of an <Attributes> element
with Category equal to the first argument.
The function SHALL invoke a complete policy evaluation using the newly constructed context.
This evaluation SHALL be completely isolated from the evaluation which invoked the function,
but shall use all current policies and combining algorithms, including any per request policies.
The PDP SHALL detect any loop which may occur if successive evaluations invoke
this function by counting the number of total invocations of any instance of this function during
any single initial invocation of the PDP. If the total number of invocations exceeds the bound for such
invocations, the initial invocation of this function evaluates to Indeterminate with a
“urn:oasis:names:tc:xacml:1.0:status:processing-error” status code.
Also, see the security considerations in section 9.1.8.
*/
import org.forgerock.xacml.core.v3.engine.XACML3EntitlementException;
import org.forgerock.xacml.core.v3.engine.XACMLEvalContext;
import org.forgerock.xacml.core.v3.model.FunctionArgument;
import org.forgerock.xacml.core.v3.model.XACMLFunction;
/**
* urn:oasis:names:tc:xacml:3.0:function:access-permitted
*/
public class AccessPermitted extends XACMLFunction {
public AccessPermitted() {
}
public FunctionArgument evaluate( XACMLEvalContext pip) throws XACML3EntitlementException {
FunctionArgument retVal = FunctionArgument.falseObject;
return retVal;
}
}
| [
"GuruAllan@ca16bcf9-9eb2-46e4-97b8-9b07c30c95dc"
] | GuruAllan@ca16bcf9-9eb2-46e4-97b8-9b07c30c95dc |
4f3a9a08ffda0cdb6ed7e4571ecddb410b06e9da | 717da6319951933ef3c0da11bff96a25991e15da | /src/main/java/Control/PaymentController.java | af5497893071dfd60794921c46927b70ce7f7c08 | [] | no_license | sunta1204/hopeassurance | 066dd4433718d44a6e5bbe272ec0621f8d706509 | bdda8e3b99b740e16be6b36f71a40698b405ac4f | refs/heads/master | 2020-04-11T19:05:58.387974 | 2018-12-16T17:48:52 | 2018-12-16T17:48:52 | 162,022,250 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,387 | java | package Control;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.sql.SQLException;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
@Controller
public class PaymentController {
PaymentDAO paymentDAO;
MemberDAO memberDAO;
public PaymentController()throws ClassNotFoundException, SQLException{
paymentDAO = new PaymentDAO();
memberDAO = new MemberDAO();
}
//For admin login
@PostMapping("/insertPaymentA" )
public String insertPaymentAmin(HttpSession session,@RequestParam("payment_cartype") String payment_cartype,@RequestParam("payment_plate") String payment_plate,@RequestParam("payment_username") String payment_username
,@RequestParam("payment_name") String payment_name,@RequestParam("payment_email") String payment_email
,@RequestParam("payment_phone") String payment_phone,@RequestParam("payment_address") String payment_address
,@RequestParam("payment_city")String payment_city,@RequestParam("payment_country")String payment_country
,@RequestParam("payment_zipcode") int payment_zipcode,@RequestParam("payment_picName")String payment_picName
,@RequestParam("payment_pic") MultipartFile payment_pic, Model model) throws SQLException {
String user = (String)session.getAttribute("member_username");
String userStatus = (String)session.getAttribute("member_status");
if(user != null && userStatus.equals("A")) { //ถ้า user ไม่มีค่า และ userStatus มีค่าเท่ากับ A
Payment payment = new Payment(0, payment_cartype,payment_plate,payment_username, payment_name, payment_email, payment_phone, payment_address, payment_city, payment_country, payment_zipcode, payment_picName,"", "","","");
paymentDAO.createPayment(payment);
String name1 = payment.getPayment_picName();
String name2 = payment.getPayment_cartype();
String name3 = payment.getPayment_plate();
if (!payment_pic.isEmpty()) {
try {
byte[] bytes = payment_pic.getBytes();
// Creating the directory to store file
//String rootPath = System.getProperty("user.dir");
//File dir = new File(rootPath +File.separator+ "tmpFiles");
File dir = new File("src/main/resources/static/payment");
if (!dir.exists())
dir.mkdirs();
// Create the file on server
File serverFile = new File(dir.getAbsolutePath()+ File.separator + name1+"_"+name2+"_"+name3+".jpg");
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();
//logger.info("Server File Location="+ serverFile.getAbsolutePath());
//System.out.println(serverFile.getAbsolutePath());
model.addAttribute("uploadStatus", "You successfully uploaded file= " + name1+name2+name3+"<br>"+serverFile.getAbsolutePath());
//return "You successfully uploaded file= " + name+"<br>"+serverFile.getAbsolutePath();
} catch (Exception e) {
model.addAttribute("uploadStatus","You failed to upload " +name1+name2+name3+ " => " + e.getMessage());
}
} else {
model.addAttribute("uploadStatus", "You failed to upload " + name1 +name2+name3+" because the file was empty.");
}
return"redirect:/admin/index_admin";
}else {
return "redirect:/pleaseLogin";
}
}
//For User login
@PostMapping("/insertPaymentU" )
public String insertPaymentUser(HttpSession session,@RequestParam("payment_cartype") String payment_cartype,@RequestParam("payment_plate")String payment_plate,@RequestParam("payment_username") String payment_username
,@RequestParam("payment_name") String payment_name,@RequestParam("payment_email") String payment_email
,@RequestParam("payment_phone") String payment_phone,@RequestParam("payment_address") String payment_address
,@RequestParam("payment_city")String payment_city,@RequestParam("payment_country")String payment_country
,@RequestParam("payment_zipcode") int payment_zipcode,@RequestParam("payment_picName")String payment_picName
,@RequestParam("payment_pic") MultipartFile payment_pic, Model model) throws SQLException {
String user = (String)session.getAttribute("member_username");
String userStatus = (String)session.getAttribute("member_status");
if(user != null && userStatus.equals("U")) { //ถ้า user ไม่มีค่า และ userStatus มีค่าเท่ากับ U
Payment payment = new Payment(0, payment_cartype,payment_plate,payment_username, payment_name, payment_email, payment_phone, payment_address, payment_city, payment_country, payment_zipcode, payment_picName,"", "","","");
paymentDAO.createPayment(payment);
String name1 = payment.getPayment_picName();
String name2 = payment.getPayment_cartype();
String name3 = payment.getPayment_plate();
if (!payment_pic.isEmpty()) {
try {
byte[] bytes = payment_pic.getBytes();
// Creating the directory to store file
//String rootPath = System.getProperty("user.dir");
//File dir = new File(rootPath +File.separator+ "tmpFiles");
File dir = new File("src/main/resources/static/payment");
if (!dir.exists())
dir.mkdirs();
// Create the file on server
File serverFile = new File(dir.getAbsolutePath()+ File.separator + name1+"_"+name2+"_"+name3+".jpg");
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();
//logger.info("Server File Location="+ serverFile.getAbsolutePath());
//System.out.println(serverFile.getAbsolutePath());
model.addAttribute("uploadStatus", "You successfully uploaded file= " + name1+name2+name3+"<br>"+serverFile.getAbsolutePath());
//return "You successfully uploaded file= " + name+"<br>"+serverFile.getAbsolutePath();
} catch (Exception e) {
model.addAttribute("uploadStatus","You failed to upload " +name1+name2+name3+ " => " + e.getMessage());
}
} else {
model.addAttribute("uploadStatus", "You failed to upload " + name1 +name2+name3+" because the file was empty.");
}
return"redirect:/User/index_user";
}
else {
return "redirect:/pleaseLogin";
}
}
}
| [
"[email protected]"
] | |
d94ee5a0065a9a4a03ad908d8e226fedad9d0ad7 | c6992ce8db7e5aab6fd959c0c448659ab91b16ce | /sdk/apimanagement/azure-resourcemanager-apimanagement/src/main/java/com/azure/resourcemanager/apimanagement/models/ApiManagementSkuCapacity.java | e1c04c94b923cb90dcd1c040c8c48a6235921737 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause",
"CC0-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.1-or-later"
] | permissive | g2vinay/azure-sdk-for-java | ae6d94d583cc2983a5088ec8f6146744ee82cb55 | b88918a2ba0c3b3e88a36c985e6f83fc2bae2af2 | refs/heads/master | 2023-09-01T17:46:08.256214 | 2021-09-23T22:20:20 | 2021-09-23T22:20:20 | 161,234,198 | 3 | 1 | MIT | 2020-01-16T20:22:43 | 2018-12-10T20:44:41 | Java | UTF-8 | Java | false | false | 2,281 | java | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.apimanagement.models;
import com.azure.core.annotation.Immutable;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Describes scaling information of a SKU. */
@Immutable
public final class ApiManagementSkuCapacity {
@JsonIgnore private final ClientLogger logger = new ClientLogger(ApiManagementSkuCapacity.class);
/*
* The minimum capacity.
*/
@JsonProperty(value = "minimum", access = JsonProperty.Access.WRITE_ONLY)
private Integer minimum;
/*
* The maximum capacity that can be set.
*/
@JsonProperty(value = "maximum", access = JsonProperty.Access.WRITE_ONLY)
private Integer maximum;
/*
* The default capacity.
*/
@JsonProperty(value = "default", access = JsonProperty.Access.WRITE_ONLY)
private Integer defaultProperty;
/*
* The scale type applicable to the sku.
*/
@JsonProperty(value = "scaleType", access = JsonProperty.Access.WRITE_ONLY)
private ApiManagementSkuCapacityScaleType scaleType;
/**
* Get the minimum property: The minimum capacity.
*
* @return the minimum value.
*/
public Integer minimum() {
return this.minimum;
}
/**
* Get the maximum property: The maximum capacity that can be set.
*
* @return the maximum value.
*/
public Integer maximum() {
return this.maximum;
}
/**
* Get the defaultProperty property: The default capacity.
*
* @return the defaultProperty value.
*/
public Integer defaultProperty() {
return this.defaultProperty;
}
/**
* Get the scaleType property: The scale type applicable to the sku.
*
* @return the scaleType value.
*/
public ApiManagementSkuCapacityScaleType scaleType() {
return this.scaleType;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}
}
| [
"[email protected]"
] | |
8421aa42f80769370f240e905fb669c221cc3626 | 3047a81b16c42f0538f56e771962aa41f238e268 | /jik/src/day2/ScannerEx1.java | 2cd5515cee358f4bbe48f47e9f43d246c4b91449 | [] | no_license | hansujini/java_jik | b37eede0f00fcee79c6a2994b2d43eba748ec53f | 04a4bbc74de0fce4c33693bea6906183db959ddc | refs/heads/main | 2023-08-25T19:36:51.329834 | 2021-10-28T08:40:35 | 2021-10-28T08:40:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,283 | java | package day2;
import java.util.Scanner;
public class ScannerEx1 {
public static void main(String[] args) {
//콘솔에서 입력 받을 수 있게 Scanner를 생성. 생성된 Scanner의 이름은 scan
Scanner scan = new Scanner(System.in);
System.out.print("정수를 입력하세요 : ");
int num1 = scan.nextInt();
System.out.println("입력된 정수는 " + num1 + " 입니다.");
System.out.print("실수를 입력하세요 : ");
double num2 = scan.nextDouble();
System.out.println("입력된 실수는 " + num2 + " 입니다.");
System.out.print("문자를 입력하세요 : ");
char ch1 = scan.next().charAt(0);
System.out.println("입력된 문자는 " + ch1 + " 입니다.");
//next() : 공백을 제외한 한 단어를 읽어옴.
System.out.print("단어를 입력하세요 : ");
String str1 = scan.next();
System.out.println("입력된 단어는 " + str1 + " 입니다.");
scan.nextLine();
//nextLine() : 공백을 포함한 한 라인을 읽어옴.
System.out.print("문장을 입력하세요 : ");
String str2 = scan.nextLine();
System.out.println("입력된 문장은 " + str2 + " 입니다.");
//더이상 콘솔에서 입력 받을 내용이 없으면 Scanner 사용을 종료
scan.close();
}
}
| [
"[email protected]"
] | |
a8f788ae84a7b43d67396ccab6bbe89f6978ce70 | 3405b4edb0ca04aa6c68ebccfba1a02301eceee7 | /src/main/java/com/ma/entity/Article.java | fa6b4a132ebcb6919b8d0faec26516c121284506 | [] | no_license | maxiaojieX/SSM-Template | 831e4daec3352d50e6d261abe3ea9d10bfd0b3a8 | 905d709b4d96912d2d2cb50d07177690528f2807 | refs/heads/master | 2021-07-25T22:54:57.829221 | 2017-11-03T05:49:31 | 2017-11-03T05:49:31 | 109,357,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,515 | java | package com.ma.entity;
import java.util.Date;
public class Article {
private Integer id;
private String title;
private Integer nodeid;
private Integer scannum;
private Integer replynum;
private Date lastreplytime;
private Date createtime;
private String simplepic;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getNodeid() {
return nodeid;
}
public void setNodeid(Integer nodeid) {
this.nodeid = nodeid;
}
public Integer getScannum() {
return scannum;
}
public void setScannum(Integer scannum) {
this.scannum = scannum;
}
public Integer getReplynum() {
return replynum;
}
public void setReplynum(Integer replynum) {
this.replynum = replynum;
}
public Date getLastreplytime() {
return lastreplytime;
}
public void setLastreplytime(Date lastreplytime) {
this.lastreplytime = lastreplytime;
}
public Date getCreatetime() {
return createtime;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public String getSimplepic() {
return simplepic;
}
public void setSimplepic(String simplepic) {
this.simplepic = simplepic;
}
} | [
"[email protected]"
] | |
7ddf258c1751c0b6799bf092fa7ad84213cc0d1e | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/neo4j--neo4j/7d5af5798b4986a17ddbd97018329b7ed788d507/after/CoreEdgeClusterSettings.java | ee53e6652cf34a7e4765b66647af4fa77787a563 | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,710 | java | /*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.coreedge.server;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.function.Function;
import org.neo4j.graphdb.config.Setting;
import org.neo4j.graphdb.factory.Description;
import org.neo4j.kernel.configuration.Internal;
import static org.neo4j.kernel.configuration.Settings.ANY;
import static org.neo4j.kernel.configuration.Settings.BOOLEAN;
import static org.neo4j.kernel.configuration.Settings.BYTES;
import static org.neo4j.kernel.configuration.Settings.DURATION;
import static org.neo4j.kernel.configuration.Settings.INTEGER;
import static org.neo4j.kernel.configuration.Settings.MANDATORY;
import static org.neo4j.kernel.configuration.Settings.STRING;
import static org.neo4j.kernel.configuration.Settings.TRUE;
import static org.neo4j.kernel.configuration.Settings.illegalValueMessage;
import static org.neo4j.kernel.configuration.Settings.list;
import static org.neo4j.kernel.configuration.Settings.matches;
import static org.neo4j.kernel.configuration.Settings.min;
import static org.neo4j.kernel.configuration.Settings.setting;
@Description("Settings for Core-Edge Clusters")
public class CoreEdgeClusterSettings
{
public static final Function<String, ListenSocketAddress> LISTEN_SOCKET_ADDRESS = new Function<String,
ListenSocketAddress>()
{
@Override
public ListenSocketAddress apply( String value )
{
String[] split = value.split( ":" );
return new ListenSocketAddress( new InetSocketAddress( split[0], Integer.valueOf( split[1] ) ) );
}
@Override
public String toString()
{
return "a socket address";
}
};
public static final Function<String, AdvertisedSocketAddress> ADVERTISED_SOCKET_ADDRESS = new Function<String,
AdvertisedSocketAddress>()
{
@Override
public AdvertisedSocketAddress apply( String value )
{
return new AdvertisedSocketAddress( value );
}
@Override
public String toString()
{
return "a socket address";
}
};
@Description("Time out for a new member to catch up")
public static final Setting<Long> join_catch_up_timeout =
setting( "core_edge.join_catch_up_timeout", DURATION, "10m" );
@Description("Leader election timeout")
public static final Setting<Long> leader_election_timeout =
setting( "core_edge.leader_election_timeout", DURATION, "500ms" );
@Description("The maximum batch size when catching up (in unit of entries)")
public static final Setting<Integer> catchup_batch_size =
setting( "core_edge.catchup_batch_size", INTEGER, "64" );
@Description("The maximum lag allowed before log shipping pauses (in unit of entries)")
public static final Setting<Integer> log_shipping_max_lag =
setting( "core_edge.log_shipping_max_lag", INTEGER, "256" );
@Description("Size of the RAFT in queue")
public static final Setting<Integer> raft_in_queue_size =
setting( "core_edge.raft_in_queue_size", INTEGER, "64" );
@Description("Largest batch processed by RAFT")
public static final Setting<Integer> raft_in_queue_max_batch =
setting( "core_edge.raft_in_queue_max_batch", INTEGER, "16" );
@Description("Time out for a token to be replicated")
public static final Setting<Long> token_creation_timeout =
setting( "core_edge.token_creation_timeout", DURATION, "1s" );
@Description("Time out waiting for the leader locking token")
public static final Setting<Long> leader_lock_token_timeout =
setting( "core_edge.leader_lock_token_timeout", DURATION, "1s" );
@Description("Expected size of core cluster")
public static final Setting<Integer> expected_core_cluster_size =
setting( "core_edge.expected_core_cluster_size", INTEGER, "3" );
@Description("Timeout for taking remote (write) locks on slaves.")
public static final Setting<Long> lock_read_timeout =
setting( "core_edge.lock_read_timeout", DURATION, "20s" );
@Description("Network interface and port for the RAFT server to listen on.")
public static final Setting<ListenSocketAddress> transaction_listen_address =
setting( "core_edge.transaction_listen_address", LISTEN_SOCKET_ADDRESS, "0.0.0.0:6001" );
@Description("Hostname/IP address and port that other RAFT servers can use to communicate with us.")
public static final Setting<AdvertisedSocketAddress> transaction_advertised_address =
setting( "core_edge.transaction_advertised_address", ADVERTISED_SOCKET_ADDRESS, "localhost:6001" );
@Description("Network interface and port for the RAFT server to listen on.")
public static final Setting<ListenSocketAddress> raft_listen_address =
setting( "core_edge.raft_listen_address", LISTEN_SOCKET_ADDRESS, "0.0.0.0:7400" );
@Description("Hostname/IP address and port that other RAFT servers can use to communicate with us.")
public static final Setting<AdvertisedSocketAddress> raft_advertised_address =
setting( "core_edge.raft_advertised_address", ADVERTISED_SOCKET_ADDRESS, "localhost:7400" );
@Description("Hostname/IP address and port that we can be connected to be the driver.")
public static final Setting<AdvertisedSocketAddress> bolt_advertised_address =
setting( "core_edge.bolt_advertised_address", ADVERTISED_SOCKET_ADDRESS, "localhost:7687" );
@Description("Host and port to bind the cluster management communication.")
public static final Setting<ListenSocketAddress> cluster_listen_address =
setting( "core_edge.cluster_listen_address", LISTEN_SOCKET_ADDRESS, "0.0.0.0:5001" );
@Description("A comma-separated list of other members of the cluster to join.")
public static final Setting<List<AdvertisedSocketAddress>> initial_core_cluster_members =
setting( "core_edge.initial_core_cluster_members", list( ",", ADVERTISED_SOCKET_ADDRESS ), MANDATORY );
@Description("Prevents the network middleware from dumping its own logs. Defaults to true.")
public static final Setting<Boolean> disable_middleware_logging =
setting( "core_edge.disable_middleware_logging", BOOLEAN, TRUE );
@Description("The maximum file size before the storage file is rotated (in unit of entries)")
public static final Setting<Integer> last_flushed_state_size =
setting( "core_edge.last_applied_state_size", INTEGER, "1000" );
@Description("The maximum file size before the id allocation file is rotated (in unit of entries)")
public static final Setting<Integer> id_alloc_state_size =
setting( "core_edge.id_alloc_state_size", INTEGER, "1000" );
@Description("The maximum file size before the membership state file is rotated (in unit of entries)")
public static final Setting<Integer> raft_membership_state_size =
setting( "core_edge.raft_membership_state_size", INTEGER, "1000" );
@Description("The maximum file size before the vote state file is rotated (in unit of entries)")
public static final Setting<Integer> vote_state_size = setting( "core_edge.raft_vote_state_size", INTEGER, "1000" );
@Description("The maximum file size before the term state file is rotated (in unit of entries)")
public static final Setting<Integer> term_state_size = setting( "core_edge.raft_term_state_size", INTEGER, "1000" );
@Description("The maximum file size before the global session tracker state file is rotated (in unit of entries)")
public static final Setting<Integer> global_session_tracker_state_size =
setting( "core_edge.global_session_tracker_state_size", INTEGER, "1000" );
@Description("The maximum file size before the replicated lock token state file is rotated (in unit of entries)")
public static final Setting<Integer> replicated_lock_token_state_size =
setting( "core_edge.replicated_lock_token_state_size", INTEGER, "1000" );
@Description("The number of messages waiting to be sent to other servers in the cluster")
public static final Setting<Integer> outgoing_queue_size =
setting( "core_edge.outgoing_queue_size", INTEGER, "64" );
@Description("The number of operations to be processed before the state machines flush to disk")
public static final Setting<Integer> state_machine_flush_window_size =
setting( "core_edge.state_machine_flush_window_size", INTEGER, "100" );
@Description( "RAFT log pruning strategy" )
public static final Setting<String> raft_log_pruning_strategy =
setting( "core_edge.raft_log_prune_strategy", STRING, "keep_all" );
@Description( "RAFT log implementation" )
public static final Setting<String> raft_log_implementation =
setting( "core_edge.raft_log_implementation", STRING, "SEGMENTED" );
@Description( "RAFT log rotation size" )
public static final Setting<Long> raft_log_rotation_size =
setting( "core_edge.raft_log_rotation_size", BYTES, "1M", min( 1024L ) );
@Description( "RAFT log pruning frequency" )
public static final Setting<Long> raft_log_pruning_frequency =
setting( "core_edge.raft_log_pruning_frequency", DURATION, "10m" );
@Description("RAFT meta data cache size (in unit of entries)")
public static final Setting<Integer> raft_log_meta_data_cache_size =
setting( "core_edge.raft_log_meta_data_cache_size", INTEGER, "100000" );
@Description("RAFT entry cache size (in unit of entries)")
public static final Setting<Integer> raft_log_entry_cache_size =
setting( "core_edge.raft_log_entry_cache_size", INTEGER, "32" );
@Description("RAFT header cache size (in unit of file headers)")
public static final Setting<Integer> raft_log_header_cache_size =
setting( "core_edge.raft_log_header_cache_size", INTEGER, "10" );
@Description("Enable or disable the dump of all network messages pertaining to the RAFT protocol")
public static final Setting<Boolean> raft_messages_log_enable =
setting( "core_edge.raft_messages_log_enable", BOOLEAN, "true");
@Description( "Interval of pulling updates from cores." )
public static final Setting<Long> pull_interval = setting( "core_edge.pull_interval", DURATION, "1s" );
@Description( "Id for a cluster instance. Must be unique within the cluster." )
public static final Setting<Integer> server_id = setting( "core_edge.server_id", INTEGER, MANDATORY );
@Description( "The name of the core cluster." )
@Internal
public static final Setting<String> cluster_name = setting( "core_edge.cluster_name", STRING, "core-cluster",
illegalValueMessage( "must be a valid cluster name", matches( ANY ) ) );
} | [
"[email protected]"
] | |
bf72d4379ada145d53e55569c38a25a320ee70ab | 3032edbc7a7077418cc4e43d15971ff993613284 | /com-xyf-pojo/src/main/java/com/xyf/pojo/Admin.java | c0f53c1d81edbdff0cb269a5bacb266156baa32a | [] | no_license | RAOE/RunnerManager | 13bdf7a933fa6746a919cf892d66f970f9201819 | 2e5777ad89f55501e3e43a67d2054664909196a6 | refs/heads/master | 2022-12-26T04:45:15.154704 | 2021-12-13T05:20:32 | 2021-12-13T05:20:32 | 127,129,249 | 294 | 34 | null | 2022-12-16T09:45:08 | 2018-03-28T11:20:12 | Java | UTF-8 | Java | false | false | 1,762 | java | package com.xyf.pojo;
public class Admin {
private Long id;
private String name;
private String phone;
private String password;
private String description;
private Boolean isDeleted;
private Boolean roleid;//当前为权限控制 是否为裁判长 1是 0否
private String realname;
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Boolean getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(Boolean isDeleted) {
this.isDeleted = isDeleted;
}
public Boolean getRoleid() {
return roleid;
}
public void setRoleid(Boolean roleid) {
this.roleid = roleid;
}
@Override
public String toString() {
return "Admin [id=" + id + ", name=" + name + ", phone=" + phone + ", password=" + password + ", description="
+ description + ", isDeleted=" + isDeleted + ", roleid=" + roleid + "]";
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Admin other = (Admin) obj;
if (id != other.id)
return false;
return true;
}
}
| [
"[email protected]"
] | |
28313da04bf1b1e91149712f7297c2146df7dbd0 | 43f0024ddb5337f44659aa1e1c09e7d6665d77b4 | /src/main/scala/org/apache/flink/formats/parquet/utils/RowConverter.java | 1fc49bbab131704582bc415f000b7980d640d403 | [] | no_license | lvhuyen/sdc | c741b49bbaaded5f0ca40eb198a48f5728043547 | b8cdac767a571a93fb16a0d9fd469ad9e921eeb5 | refs/heads/master | 2020-04-24T01:36:29.705496 | 2019-06-13T12:26:41 | 2019-06-13T12:26:41 | 171,604,782 | 1 | 0 | null | 2019-06-13T12:03:22 | 2019-02-20T05:07:18 | Scala | UTF-8 | Java | false | false | 13,259 | 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.flink.formats.parquet.utils;
import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
import org.apache.flink.api.common.typeinfo.SqlTimeTypeInfo;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeutils.CompositeType;
import org.apache.flink.api.java.typeutils.MapTypeInfo;
import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.types.Row;
import org.apache.parquet.io.api.Binary;
import org.apache.parquet.io.api.Converter;
import org.apache.parquet.io.api.GroupConverter;
import org.apache.parquet.io.api.PrimitiveConverter;
import org.apache.parquet.schema.GroupType;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.OriginalType;
import org.apache.parquet.schema.PrimitiveType;
import org.apache.parquet.schema.Type;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Extends from {@link GroupConverter} to convert an nested Parquet Record into Row.
*/
public class RowConverter extends GroupConverter implements ParentDataHolder {
private final Converter[] converters;
private final ParentDataHolder parentDataHolder;
private final TypeInformation<?> typeInfo;
private Row currentRow;
private int posInParentRow;
public RowConverter(MessageType messageType, TypeInformation<?> typeInfo) {
this(messageType, typeInfo, null, 0);
}
public RowConverter(GroupType schema, TypeInformation<?> typeInfo, ParentDataHolder parent, int pos) {
this.typeInfo = typeInfo;
this.parentDataHolder = parent;
this.posInParentRow = pos;
this.converters = new Converter[schema.getFieldCount()];
int i = 0;
if (typeInfo.getArity() >= 1 && (typeInfo instanceof CompositeType)) {
for (Type field : schema.getFields()) {
converters[i] = createConverter(field, i, ((CompositeType<?>) typeInfo).getTypeAt(i), this);
i++;
}
}
}
private static Converter createConverter(
Type field,
int fieldPos,
TypeInformation<?> typeInformation,
ParentDataHolder parentDataHolder) {
if (field.isPrimitive()) {
return new RowConverter.RowPrimitiveConverter(field, parentDataHolder, fieldPos);
} else if (typeInformation instanceof MapTypeInfo) {
return new RowConverter.MapConverter((GroupType) field, (MapTypeInfo) typeInformation,
parentDataHolder, fieldPos);
} else if (typeInformation instanceof BasicArrayTypeInfo) {
Type elementType = field.asGroupType().getFields().get(0);
Class typeClass = ((BasicArrayTypeInfo) typeInformation).getComponentInfo().getTypeClass();
if (typeClass.equals(Character.class)) {
return new RowConverter.ArrayConverter<Character>(elementType,
Character.class, BasicTypeInfo.CHAR_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Boolean.class)) {
return new RowConverter.ArrayConverter<Boolean>(elementType,
Boolean.class, BasicTypeInfo.BOOLEAN_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Short.class)) {
return new RowConverter.ArrayConverter<Short>(elementType,
Short.class, BasicTypeInfo.SHORT_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Integer.class)) {
return new RowConverter.ArrayConverter<Integer>(elementType,
Integer.class, BasicTypeInfo.INSTANT_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Long.class)) {
return new RowConverter.ArrayConverter<Long>(elementType,
Long.class, BasicTypeInfo.LONG_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Double.class)) {
return new RowConverter.ArrayConverter<Double>(elementType,
Double.class, BasicTypeInfo.DOUBLE_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(String.class)) {
return new RowConverter.ArrayConverter<String>(elementType,
String.class, BasicTypeInfo.STRING_TYPE_INFO, parentDataHolder, fieldPos);
} else if (typeClass.equals(Date.class)) {
return new RowConverter.ArrayConverter<Date>(elementType,
Date.class, SqlTimeTypeInfo.DATE, parentDataHolder, fieldPos);
} else if (typeClass.equals(Time.class)) {
return new RowConverter.ArrayConverter<Time>(elementType,
Time.class, SqlTimeTypeInfo.TIME, parentDataHolder, fieldPos);
} else if (typeClass.equals(Timestamp.class)) {
return new RowConverter.ArrayConverter<Timestamp>(elementType,
Timestamp.class, SqlTimeTypeInfo.TIMESTAMP, parentDataHolder, fieldPos);
} else if (typeClass.equals(BigDecimal.class)) {
return new RowConverter.ArrayConverter<BigDecimal>(elementType,
BigDecimal.class, BasicTypeInfo.BIG_DEC_TYPE_INFO, parentDataHolder, fieldPos);
}
throw new IllegalArgumentException(
String.format("Can't create converter unsupported primitive array type for %s", typeClass.toString()));
} else if (typeInformation instanceof ObjectArrayTypeInfo) {
GroupType parquetGroupType = field.asGroupType();
Type elementType = parquetGroupType.getType(0);
return new RowConverter.ArrayConverter<Row>(elementType, Row.class,
((ObjectArrayTypeInfo) typeInformation).getComponentInfo(), parentDataHolder, fieldPos);
} else if (typeInformation instanceof RowTypeInfo) {
return new RowConverter((GroupType) field, typeInformation, parentDataHolder, fieldPos);
}
throw new IllegalArgumentException(
String.format("Can't create converter for field %s with type %s ", field.getName(), typeInformation.toString()));
}
@Override
public Converter getConverter(int i) {
return converters[i];
}
@Override
public void start() {
this.currentRow = new Row(typeInfo.getArity());
}
public Row getCurrentRow() {
return currentRow;
}
@Override
public void end() {
if (parentDataHolder != null) {
parentDataHolder.add(posInParentRow, currentRow);
}
}
@Override
public void add(int fieldIndex, Object object) {
currentRow.setField(fieldIndex, object);
}
static class RowPrimitiveConverter extends PrimitiveConverter {
private OriginalType originalType;
private PrimitiveType.PrimitiveTypeName primitiveTypeName;
private ParentDataHolder parentDataHolder;
private int pos;
RowPrimitiveConverter(Type dataType, ParentDataHolder parentDataHolder, int pos) {
this.parentDataHolder = parentDataHolder;
this.pos = pos;
if (dataType.isPrimitive()) {
this.originalType = dataType.getOriginalType();
this.primitiveTypeName = dataType.asPrimitiveType().getPrimitiveTypeName();
} else {
// Backward-compatibility It can be a group type middle layer
Type primitiveType = dataType.asGroupType().getType(0);
this.originalType = primitiveType.getOriginalType();
this.primitiveTypeName = primitiveType.asPrimitiveType().getPrimitiveTypeName();
}
}
@Override
public void addBinary(Binary value) {
// in case it is a timestamp type stored as INT96
if (primitiveTypeName.equals(PrimitiveType.PrimitiveTypeName.INT96)) {
parentDataHolder.add(pos, new Timestamp(ParquetTimestampUtils.getTimestampMillis(value)));
return;
}
if (originalType != null) {
switch (originalType) {
case DECIMAL:
parentDataHolder.add(pos, new BigDecimal(value.toStringUsingUTF8().toCharArray()));
break;
case UTF8:
case ENUM:
case JSON:
case BSON:
parentDataHolder.add(pos, value.toStringUsingUTF8());
break;
default:
throw new UnsupportedOperationException("Unsupported original type : " + originalType.name()
+ " for primitive type BINARY");
}
} else {
parentDataHolder.add(pos, value.toStringUsingUTF8());
}
}
@Override
public void addBoolean(boolean value) {
parentDataHolder.add(pos, value);
}
@Override
public void addDouble(double value) {
parentDataHolder.add(pos, value);
}
@Override
public void addFloat(float value) {
parentDataHolder.add(pos, value);
}
@Override
public void addInt(int value) {
if (originalType != null) {
switch (originalType) {
case TIME_MICROS:
case TIME_MILLIS:
parentDataHolder.add(pos, new Time(value));
break;
case TIMESTAMP_MICROS:
case TIMESTAMP_MILLIS:
parentDataHolder.add(pos, new Timestamp(value));
break;
case DATE:
parentDataHolder.add(pos, new Date(value));
break;
case UINT_8:
case UINT_16:
case UINT_32:
case INT_8:
case INT_16:
case INT_32:
parentDataHolder.add(pos, value);
break;
default:
throw new UnsupportedOperationException("Unsupported original type : " + originalType.name()
+ " for primitive type INT32");
}
} else {
parentDataHolder.add(pos, value);
}
}
@Override
public void addLong(long value) {
if (originalType != null) {
switch (originalType) {
case TIME_MICROS:
parentDataHolder.add(pos, new Time(value));
break;
case TIMESTAMP_MICROS:
case TIMESTAMP_MILLIS:
parentDataHolder.add(pos, new Timestamp(value));
break;
case INT_64:
case DECIMAL:
// long is more efficient then BigDecimal in terms of memory.
parentDataHolder.add(pos, value);
break;
default:
throw new UnsupportedOperationException("Unsupported original type : " + originalType.name()
+ " for primitive type INT64");
}
} else {
parentDataHolder.add(pos, value);
}
}
}
@SuppressWarnings("unchecked")
static class ArrayConverter<T> extends GroupConverter implements ParentDataHolder {
private final ParentDataHolder parentDataHolder;
private final Class elementClass;
private final int pos;
private List<T> list;
private Converter elementConverter;
ArrayConverter(Type elementType, Class elementClass, TypeInformation elementTypeInfo,
ParentDataHolder parentDataHolder, int pos) {
this.elementClass = elementClass;
this.parentDataHolder = parentDataHolder;
this.pos = pos;
if (elementClass.equals(Row.class)) {
this.elementConverter = createConverter(elementType, 0, elementTypeInfo, this);
} else {
this.elementConverter = new RowConverter.RowPrimitiveConverter(elementType, this, 0);
}
}
@Override
public Converter getConverter(int fieldIndex) {
return elementConverter;
}
@Override
public void start() {
list = new ArrayList<>();
}
@Override
public void end() {
parentDataHolder.add(pos, list.toArray((T[]) Array.newInstance(elementClass, list.size())));
}
@Override
public void add(int fieldIndex, Object object) {
list.add((T) object);
}
}
static class MapConverter extends GroupConverter {
private final ParentDataHolder parentDataHolder;
private final Converter keyValueConverter;
private final int pos;
private Map<Object, Object> map;
MapConverter(GroupType type, MapTypeInfo typeInfo, ParentDataHolder parentDataHolder, int pos) {
this.parentDataHolder = parentDataHolder;
this.pos = pos;
this.keyValueConverter = new MapKeyValueConverter((GroupType) type.getType(0), typeInfo);
}
@Override
public Converter getConverter(int fieldIndex) {
return keyValueConverter;
}
@Override
public void start() {
map = new HashMap<>();
}
@Override
public void end() {
parentDataHolder.add(pos, map);
}
final class MapKeyValueConverter extends GroupConverter {
private final Converter keyConverter;
private final Converter valueConverter;
private Object key;
private Object value;
MapKeyValueConverter(GroupType groupType, MapTypeInfo typeInfo) {
this.keyConverter = createConverter(
groupType.getType(0), 0, typeInfo.getKeyTypeInfo(),
(fieldIndex, object) -> key = object);
this.valueConverter = createConverter(
groupType.getType(1), 1, typeInfo.getValueTypeInfo(),
(fieldIndex, object) -> value = object);
}
@Override
public Converter getConverter(int fieldIndex) {
if (fieldIndex == 0) {
return keyConverter;
} else {
return valueConverter;
}
}
@Override
public void start() {
key = null;
value = null;
}
@Override
public void end() {
map.put(this.key, this.value);
}
}
}
} | [
"[email protected]"
] | |
c3e653296d529b51950528fb46807b7c973a0bb3 | fe5d1e3cbc8324c1e1a9d8748e8949fb661c8bcc | /JSP/한빛/src/appB/MyApplicationAttributeListener.java | 1ba67ef5bfd3cfe1dbfa890576a54ead850697a2 | [] | no_license | zhaojc/web | 6aafbc8a72856443c1ee1161c707f044a9ce974a | fe5f8b1feb97b4a6ce95427af7c7c3be7f88f1b8 | refs/heads/master | 2021-01-18T20:23:03.773660 | 2013-09-09T12:03:26 | 2013-09-09T12:03:26 | null | 0 | 0 | null | null | null | null | UHC | Java | false | false | 1,110 | java | package mylistener;
import javax.servlet.*;
import java.util.*;
public class MyApplicationAttributeListener implements ServletContextAttributeListener {
public void attributeAdded(ServletContextAttributeEvent event) {
String name = event.getName();
String value = (String) event.getValue();
System.out.printf("[%TT] application 애트리뷰트 입력 %s=%s %n",
new GregorianCalendar(), name, value);
}
public void attributeReplaced(ServletContextAttributeEvent event) {
String name = event.getName();
String value = (String) event.getValue();
System.out.printf("[%TT] application 애트리뷰트 수정 %s=%s %n",
new GregorianCalendar(), name, value);
}
public void attributeRemoved(ServletContextAttributeEvent event) {
String name = event.getName();
String value = (String) event.getValue();
System.out.printf("[%TT] application 애트리뷰트 삭제 %s=%s %n",
new GregorianCalendar(), name, value);
}
}
| [
"[email protected]"
] | |
5c7376395911c0d6886f991ff2920fde1f4351c2 | eda1e9355b7f57b0fe7d499dcd5b803e7738b44f | /com/mongodb/ServerVersion.java | e0038eeca9254613e207e0d1ea00a29af2c9cee5 | [] | no_license | TheS7W/HCTeams | 55190c7101bbd2ebbb9d7670e9d7a7d14e2f1afe | 0a69b9be1909828be3916eef329fd9f4a8e96216 | refs/heads/master | 2020-12-27T20:39:37.989216 | 2014-12-19T19:24:37 | 2014-12-19T19:24:37 | 34,543,926 | 0 | 1 | null | 2015-04-24T21:58:17 | 2015-04-24T21:58:15 | null | UTF-8 | Java | false | false | 1,762 | java | package com.mongodb;
import org.bson.util.*;
import java.util.*;
class ServerVersion implements Comparable<ServerVersion>
{
private final List<Integer> versionList;
public ServerVersion() {
super();
this.versionList = Collections.unmodifiableList((List<? extends Integer>)Arrays.asList(0, 0, 0));
}
public ServerVersion(final List<Integer> versionList) {
super();
Assertions.notNull("versionList", versionList);
Assertions.isTrue("version array has three elements", versionList.size() == 3);
this.versionList = Collections.unmodifiableList((List<? extends Integer>)new ArrayList<Integer>(versionList));
}
public ServerVersion(final int majorVersion, final int minorVersion) {
this(Arrays.asList(majorVersion, minorVersion, 0));
}
public List<Integer> getVersionList() {
return this.versionList;
}
public int compareTo(final ServerVersion o) {
int retVal = 0;
for (int i = 0; i < this.versionList.size(); ++i) {
retVal = this.versionList.get(i).compareTo(o.versionList.get(i));
if (retVal != 0) {
break;
}
}
return retVal;
}
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
final ServerVersion that = (ServerVersion)o;
return this.versionList.equals(that.versionList);
}
public int hashCode() {
return this.versionList.hashCode();
}
public String toString() {
return "ServerVersion{versionList=" + this.versionList + '}';
}
}
| [
"[email protected]"
] | |
b01d50a8416797b3e7db171fb6694d2486293b45 | c58c1930622be7e4b597836ec5083d75ad1e54f6 | /src/main/java/pe/edu/upeu/sysventas_blue/dao/ProductoDao.java | 75e652d4a97facb1256ca7c220af043f3fdc982d | [] | no_license | JoseCV09/BackEnd-Productos | b8fddf71d8ec6140145473c16e5da86d0d853c0f | 80db4c8b6eeb804ceb4e517707a069e98914a687 | refs/heads/master | 2023-01-29T10:49:55.100964 | 2020-12-01T14:00:09 | 2020-12-01T14:00:09 | 317,556,612 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java | package pe.edu.upeu.sysventas_blue.dao;
import java.util.List;
import java.util.Map;
import pe.edu.upeu.sysventas_blue.entity.Producto;
public interface ProductoDao {
int create(Producto producto);
int update(Producto producto);
int delete(int id);
Map<String, Object> read(int id);
List<Map<String, Object>> readAll();
}
| [
"[email protected]"
] | |
b63e51ce94d481d43fd1774ed8fa20de9570a5dd | b8f4bda82c721fafe7cd008eb1af46e8118cbc3f | /src/main/java/pl/pollub/cs/pentalearn/service/exception/InvalidRequestException.java | 3ac0f0171f9e46f34e706a6f04dc54b752729823 | [] | no_license | Jarek0/PentaLearnStart | 8850cfdea84f8edd79b1d57a993f647d4c8d2c9a | e5c3d4e0d162cb3d70eda7bd5a5cc6ec1d268395 | refs/heads/master | 2020-12-24T06:03:35.044551 | 2016-11-30T19:18:22 | 2016-11-30T19:18:22 | 73,233,681 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package pl.pollub.cs.pentalearn.service.exception;
import org.springframework.validation.Errors;
@SuppressWarnings("serial")
public class InvalidRequestException extends RuntimeException {
private Errors errors;
public InvalidRequestException(String message, Errors errors) {
super(message);
this.errors = errors;
}
public Errors getErrors() {
return errors;
}
}
| [
"[email protected]"
] | |
4997b4ecd3574db52c2b03c0135cd9080974ba0e | cd0b565ac4c5db2d8068027b320131b069b04091 | /Command/command/MacroCommand.java | a01435d1696748144e5586a12eef59f7cfcd6fd5 | [] | no_license | cobachie/design-pattern | c254ee8953501e84d6e74f62b7d9939e197f964d | c68189cbe6783801ebf0c63273ae1cd8f42530aa | refs/heads/main | 2023-03-18T07:20:47.890109 | 2021-03-13T05:44:40 | 2021-03-14T23:52:27 | 347,783,416 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 532 | java | package command;
import java.util.Stack;
import java.util.Iterator;
public class MacroCommand implements Command {
private Stack commands = new Stack();
public void execute() {
Iterator it = commands.iterator();
while (it.hasNext()) {
((Command) it.next()).execute();
}
}
public void append(Command cmd) {
if (cmd != this) {
commands.push(cmd);
}
}
public void undo() {
if (!commands.empty()) {
commands.pop();
}
}
public void clear() {
commands.clear();
}
} | [
"[email protected]"
] | |
5edc6205023d941b7d1259a3744da285c249fd88 | 5d37e3508e758c495d0d2b4c2f75076dacdf6535 | /abase/baselib/src/main/java/com/garfield/baselib/fragmentation/anim/DefaultNoAnimator.java | 7bb6ae5693f04cddfc7eb6017dc1cf97faa2a686 | [
"Apache-2.0"
] | permissive | weigao123/MyAndroid | a7bd6f47e7088c508a311d50de80223c92db027c | 3d3be297e14cbba4f0200d6daa41aa79775f2f46 | refs/heads/master | 2021-06-22T04:09:54.559883 | 2020-11-26T13:57:12 | 2020-11-26T13:57:12 | 63,529,458 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,033 | java | package com.garfield.baselib.fragmentation.anim;
import android.os.Parcel;
import android.os.Parcelable;
import com.garfield.baselib.R;
public class DefaultNoAnimator extends FragmentAnimator implements Parcelable {
public DefaultNoAnimator() {
enter = R.anim.no_anim;
exit = R.anim.no_anim;
popEnter = R.anim.no_anim;
popExit = R.anim.no_anim;
}
protected DefaultNoAnimator(Parcel in) {
super(in);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<DefaultNoAnimator> CREATOR = new Creator<DefaultNoAnimator>() {
@Override
public DefaultNoAnimator createFromParcel(Parcel in) {
return new DefaultNoAnimator(in);
}
@Override
public DefaultNoAnimator[] newArray(int size) {
return new DefaultNoAnimator[size];
}
};
}
| [
"[email protected]"
] | |
711d3b172d3a6c8eca963edfcc4ba94b24c6558e | b1c7d854d6a2257330b0ea137c5b4e24b2e5078d | /com/google/android/gms/internal/zzasv.java | 02c3132206614c83eabf62f1466dc78d59c3d0e1 | [] | no_license | nayebare/mshiriki_android_app | 45fd0061332f5253584b351b31b8ede2f9b56387 | 7b6b729b5cbc47f109acd503b57574d48511ee70 | refs/heads/master | 2020-06-21T20:01:59.725854 | 2017-06-12T13:55:51 | 2017-06-12T13:55:51 | 94,205,275 | 1 | 1 | null | 2017-06-13T11:22:51 | 2017-06-13T11:22:51 | null | UTF-8 | Java | false | false | 2,127 | java | package com.google.android.gms.internal;
import android.os.Handler;
import android.os.Looper;
import com.google.android.gms.common.internal.zzac;
abstract class zzasv {
private static volatile Handler zzaec;
private volatile long zzaed;
private final zzatp zzbpw;
private boolean zzbqB;
private final Runnable zzv;
/* renamed from: com.google.android.gms.internal.zzasv.1 */
class C10211 implements Runnable {
final /* synthetic */ zzasv zzbqC;
C10211(zzasv com_google_android_gms_internal_zzasv) {
this.zzbqC = com_google_android_gms_internal_zzasv;
}
public void run() {
if (Looper.myLooper() == Looper.getMainLooper()) {
this.zzbqC.zzbpw.zzJs().zzm(this);
return;
}
boolean zzcv = this.zzbqC.zzcv();
this.zzbqC.zzaed = 0;
if (zzcv && this.zzbqC.zzbqB) {
this.zzbqC.run();
}
}
}
zzasv(zzatp com_google_android_gms_internal_zzatp) {
zzac.zzw(com_google_android_gms_internal_zzatp);
this.zzbpw = com_google_android_gms_internal_zzatp;
this.zzbqB = true;
this.zzv = new C10211(this);
}
private Handler getHandler() {
if (zzaec != null) {
return zzaec;
}
Handler handler;
synchronized (zzasv.class) {
if (zzaec == null) {
zzaec = new Handler(this.zzbpw.getContext().getMainLooper());
}
handler = zzaec;
}
return handler;
}
public void cancel() {
this.zzaed = 0;
getHandler().removeCallbacks(this.zzv);
}
public abstract void run();
public boolean zzcv() {
return this.zzaed != 0;
}
public void zzx(long j) {
cancel();
if (j >= 0) {
this.zzaed = this.zzbpw.zznq().currentTimeMillis();
if (!getHandler().postDelayed(this.zzv, j)) {
this.zzbpw.zzJt().zzLa().zzj("Failed to schedule delayed post. time", Long.valueOf(j));
}
}
}
}
| [
"[email protected]"
] | |
c05122f0cb5b8005819e7cf55c85f683ac27dac3 | b3c19ad007296c0fa2fdaead9e0e915331c58d21 | /src/bos/consoar/ninebynine/support/Common.java | 9c60ece194ca421fb88a57f8a346370864f6f56c | [
"Apache-2.0"
] | permissive | Consoar/9X9 | a5931007f921ccfd3a04357946f799320d527fe5 | a181659125eab6c7e8f78be3928304bea79bda3f | refs/heads/master | 2016-09-05T17:42:41.518880 | 2014-05-21T15:02:30 | 2014-05-21T15:02:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 354 | java | package bos.consoar.ninebynine.support;
import bos.consoar.ninebynine.support.entity.Block;
public class Common {
public static final int width = 9;
public static final int height = 9;
public static Block[] BlocksCopy(Block[]src ,int length){
Block[] dst=new Block[length];
for (int i=0;i<length;++i){
dst[i]=src[i];
}
return dst;
}
}
| [
"[email protected]"
] | |
37ef5eb85de29bd97d6883ead1ef052ad540c428 | dd624d0f66d552a26b5fc3200a9990f5ae3b0680 | /utils_library/src/main/java/com/utils/common/backup/zip/ZipImpl.java | c22ecedcac3e86d2957a6bc2e83a9207c6e5e219 | [] | no_license | androidKy/Tit_tok_tool | 6952a01f3bc305c9632f5a7663100567dce68e29 | 8068a076357991c319086ba893775616277eea72 | refs/heads/master | 2020-11-23T19:02:38.646702 | 2019-12-13T10:32:34 | 2019-12-13T10:32:34 | 227,781,085 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,730 | java | package com.utils.common.backup.zip;
import android.content.Context;
import android.provider.Settings;
import com.safframework.log.L;
import com.utils.common.ThreadUtils;
import com.utils.common.backup.BackupConstant;
import com.utils.common.backup.utils.ZipUtils;
import java.io.File;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* description:压缩实现类
* author: kyXiao
* created date: 2018/9/17
*/
public class ZipImpl implements IZip {
private static final String TAG = "ZipImpl";
private static volatile ZipImpl mInstance;
private WeakReference<Context> mContextWeakReference;
private IZipListener mZipListener;
private boolean mIsZipping;
private String uid;
private String aid;
private ZipImpl(Context context) {
mContextWeakReference = new WeakReference<Context>(context);
}
public static ZipImpl getInstance(Context context) {
if (mInstance == null) {
synchronized (ZipImpl.class) {
if (mInstance == null) {
mInstance = new ZipImpl(context);
}
}
}
return mInstance;
}
@Override
public void startZip(final String filePath) {
if (mIsZipping) {
/* if (mZipListener != null)
mZipListener.onZipFailed("正在压缩,请等待完成再执行压缩");*/
onFailed("正在压缩,请等待完成再执行压缩");
return;
}
ThreadUtils.executeByCached(new ThreadUtils.Task<Boolean>() {
@Override
public Boolean doInBackground() throws Throwable {
final File sdcardFileList = new File(filePath);
if (sdcardFileList.exists() && sdcardFileList.isDirectory()) {
backupData(sdcardFileList);
}
return null;
}
@Override
public void onSuccess(Boolean result) {
}
@Override
public void onCancel() {
}
@Override
public void onFail(Throwable t) {
}
});
}
@Override
public void setFileNameParams(String uid, String aid) {
this.uid = uid;
this.aid = aid;
}
/**
* 备份指定的数据
*
* @param fileDir
*/
private void backupData(File fileDir) {
File zipFilePath = new File(BackupConstant.ZIP_FILE_PATH);
//判断之前是否有压缩过,如果有则删除重新创建,无则直接创建
if (zipFilePath.exists()) {
//zipFile.mkdir();
ZipUtils.deleteFile(zipFilePath);
zipFilePath.mkdirs();
} else zipFilePath.mkdirs();
mIsZipping = true;
File zipFile = zipFile(fileDir);
mIsZipping = false;
if (zipFile == null) {
onFailed("压缩文件过程出现异常");
return;
}
L.i(TAG, "压缩文件成功》》》》》");
onSucceed(zipFile.getName());
}
private File zipFile(File fileDir) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String tempFileName = String.format("%s%s_%s_%s.%s", BackupConstant.ZIP_FILE_PATH, uid, aid,
dateFormat.format(new Date()), "zip.tmp");
// tempFileName = BackupConstant.ZIP_FILE_PATH + "uid_aid_20181234567890" + ".zip.tmp";
L.i(TAG, "zipFile 新文件名字:" + tempFileName);
try {
ZipUtils.zip(fileDir, tempFileName);
File zipedFile;
new File(tempFileName).renameTo(zipedFile = new File(tempFileName.replace(".tmp", "")));
return zipedFile;
} catch (Exception e) {
e.printStackTrace();
L.e(TAG, "压缩出错:" + e.getMessage());
}
return null;
}
private String getAndroidId() {
String androidId = "";
if (mContextWeakReference != null) {
Context context = mContextWeakReference.get();
androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
return androidId;
}
@Override
public boolean isZipping() {
return mIsZipping;
}
@Override
public void addZipListener(IZipListener zipListener) {
mZipListener = zipListener;
}
private void onFailed(String message) {
if (mZipListener != null)
mZipListener.onZipFailed(message);
}
private void onSucceed(String zipFileName) {
if (mZipListener != null)
mZipListener.onZipSuccess(zipFileName);
}
}
| [
"[email protected]"
] | |
c2ec5629e87bd2000f18e56a8b92a85287a34c2b | 70fc4b0dab77c3b841dfbb0649887fbf68a2791f | /Lab4/SpringBoot-Application/src/main/java/Lab4/Demo/SpringBootApplication/repository/PostRepository.java | 8c76733bce34d4f432c912bfe224b65b4cf751cf | [] | no_license | sirakGh/WAA | 5a759b8e6902db87c1287ab0610b954fd327bff1 | b63a9f20723af92c772d717508255c2601173400 | refs/heads/main | 2023-08-01T16:08:16.343808 | 2021-09-26T07:47:29 | 2021-09-26T07:47:29 | 406,551,445 | 0 | 0 | null | 2021-09-15T00:02:57 | 2021-09-14T23:36:10 | Java | UTF-8 | Java | false | false | 325 | java | package Lab4.Demo.SpringBootApplication.repository;
import Lab4.Demo.SpringBootApplication.model.Post;
import java.util.List;
import java.util.Optional;
public interface PostRepository {
List<Post> getAllPost();
void addPost(Post post);
Optional<Post> getPostById(long id );
void removePost(long id );
}
| [
"[email protected]"
] | |
cb29d0e7a92c4432f6980664c85c1b2122d59324 | 106ad7cc822821dc0dedf6dd42d984a05f9a3335 | /Akshay/practice/AbstactDemo.java | 8dc02553a0dc9931349758f3b4bd11dd294abf1d | [] | no_license | sakthisgit/javaex | abc705bd989f54fcf97ad74cc432652494a0928a | dc248a54e39168895fd94b323553c0de091f935c | refs/heads/master | 2021-08-25T10:37:28.658468 | 2021-08-12T15:43:18 | 2021-08-12T15:43:18 | 252,906,785 | 3 | 6 | null | null | null | null | UTF-8 | Java | false | false | 309 | java | package corejava;
abstract class Animal2
{
abstract void sound();
}
class Dog2 extends Animal2{
@Override
void sound() {
// TODO Auto-generated method stub
System.out.println("Wooooooff");
}
}
public class AbstactDemo {
public static void main(String[] args) {
Dog2 d=new Dog2();
d.sound();
}
}
| [
"[email protected]"
] | |
750aa811791644d0e47f79f748b8cb099dc39de4 | c285fbde311a2d379c67ad32048ffa8d81273361 | /javastudy-search-parent/javastudy-search-elasticsearch/src/main/java/org/javastudy/search/elasticsearch/App.java | 6a2dd9e2c3ad8594317ec9462af6f99e7d4a8efc | [] | no_license | coolkingzhang/javastudy | 42b4a29f76325d77a8adb2813f51a02b5b89511e | e385666fe194b7c2b8f83ac89569d1a8a9e083fd | refs/heads/master | 2020-12-22T00:04:57.339994 | 2016-08-13T10:26:14 | 2016-08-13T10:26:14 | 59,395,349 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 197 | java | package org.javastudy.search.elasticsearch;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
| [
"[email protected]"
] | |
79348d80aabc1444665fe29094634ac79d1de1fd | a280aa9ac69d3834dc00219e9a4ba07996dfb4dd | /regularexpress/home/weilaidb/work/app/hadoop-2.7.3-src/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/pipes/OutputHandler.java | b6c766aa69958dbe5ebc6d08bfd43677167e2488 | [] | no_license | weilaidb/PythonExample | b2cc6c514816a0e1bfb7c0cbd5045cf87bd28466 | 798bf1bdfdf7594f528788c4df02f79f0f7827ce | refs/heads/master | 2021-01-12T13:56:19.346041 | 2017-07-22T16:30:33 | 2017-07-22T16:30:33 | 68,925,741 | 4 | 2 | null | null | null | null | UTF-8 | Java | false | false | 568 | java | package org.apache.hadoop.mapred.pipes;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.mapred.Counters;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
class OutputHandler<K extends WritableComparable,
V extends Writable>
implements UpwardProtocol<K, V>
| [
"[email protected]"
] | |
79a826fa6aa3fe0425836c95945d6adc6912cfcd | 637ab648d011ebb3f157754909d15e0198880f9e | /dojosurvey/src/test/java/com/mattr/dojosurvey/DojosurveyApplicationTests.java | 2e99a1440af13853491a882806649227f1fdb415 | [] | no_license | mateogolf/SpringProjects | bfb954e84c875c91cc3111c786e34b86a6f4bdab | 8f84f20cc5eeafc051dd0d325b5f34dc432832c1 | refs/heads/master | 2021-03-12T19:32:31.563588 | 2017-09-28T15:26:37 | 2017-09-28T15:26:37 | 102,882,036 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 341 | java | package com.mattr.dojosurvey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DojosurveyApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
7cd74c4dcec44140d48f35d277ac5d9b5c75b658 | f420d514af2a7ba62bd28c3dbe3230888451efa5 | /src/test/java/com/mrmodise/test/impl/OrderBOImplTest.java | 76f802f6c190d60b73794d6ba11069b9107a74d4 | [
"MIT"
] | permissive | mrmodise/Order-Processing-Java-Unit-Testing | 99c5168871308277d55d136552eccdc285985330 | 7fb072b76efcaf6d97318f9d175b514814621413 | refs/heads/master | 2021-01-01T04:21:40.312582 | 2017-07-16T18:10:35 | 2017-07-16T18:10:35 | 97,159,845 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,464 | java | package com.mrmodise.test.impl;
import com.mrmodise.service.impl.OrderBOImpl;
import com.mrmodise.service.OrderDAO;
import com.mrmodise.domain.Order;
import com.mrmodise.exception.BOException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.sql.SQLException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Created by mrmodise on 2017/07/13.
*/
public class OrderBOImplTest {
@Mock
OrderDAO orderDAO;
OrderBOImpl orderBO;
Order order;
@Before
public void setup(){
MockitoAnnotations.initMocks(this);
orderBO = new OrderBOImpl();
orderBO.setOrderDAO(orderDAO);
order = new Order();
}
@Test
public void placeOrder_Should_Create_An_Order() throws SQLException, BOException {
// setup expectation
when(orderDAO.createOrder(order)).thenReturn(new Integer(1));
boolean result = orderBO.placeOrder(order);
// verify the results
assertTrue(result);
verify(orderDAO).createOrder(order);
}
@Test
public void placeOrder_Should_Not_Create_An_Order() throws SQLException, BOException {
// setup expectation
when(orderDAO.createOrder(order)).thenReturn(new Integer(0));
boolean result = orderBO.placeOrder(order);
// verify the results
assertFalse(result);
verify(orderDAO).createOrder(order);
}
@Test(expected = BOException.class)
public void placeOrder_Should_Throw_BOException() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.createOrder(order)).thenThrow(SQLException.class);
// place an order
orderBO.placeOrder(order);
}
@Test
public void cancelOrder_Should_Cancel_Order() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.readOrder(123)).thenReturn(order);
when(orderDAO.updateOrder(order)).thenReturn(1);
boolean result = orderBO.cancelOrder(123);
assertTrue(result);
verify(orderDAO).readOrder(123);
verify(orderDAO).updateOrder(order);
}
@Test
public void cancelOrder_Should_Not_Cancel_Order() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.readOrder(123)).thenReturn(order);
when(orderDAO.updateOrder(order)).thenReturn(0);
boolean result = orderBO.cancelOrder(123);
assertFalse(result);
verify(orderDAO).readOrder(123);
verify(orderDAO).updateOrder(order);
}
@Test(expected = BOException.class)
public void cancelOrder_Should_Throw_SQL_Exception_On_Read() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.readOrder(123)).thenThrow(SQLException.class);
orderBO.cancelOrder(123);
}
@Test(expected = BOException.class)
public void cancelOrder_Should_Throw_SQLException_On_Update() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.readOrder(123)).thenReturn(order);
when(orderDAO.updateOrder(order)).thenThrow(SQLException.class);
orderBO.cancelOrder(123);
}
@Test
public void deleteOrder_Should_Delete_An_Order() throws SQLException, BOException {
// setup expectation
when(orderDAO.deleteOrder(123)).thenReturn(new Integer(1));
boolean result = orderBO.deleteOrder(123);
// verify the results
assertTrue(result);
verify(orderDAO).deleteOrder(123);
}
@Test
public void deleteOrder_Should_Not_Delete_An_Order() throws SQLException, BOException {
// setup expectation
when(orderDAO.deleteOrder(123)).thenReturn(new Integer(0));
boolean result = orderBO.deleteOrder(123);
// verify the results
assertFalse(result);
verify(orderDAO).deleteOrder(123);
}
@Test(expected = BOException.class)
public void deleteOrder_Should_Throw_SQLException() throws SQLException, BOException {
// setup expectation to throw BO exception
when(orderDAO.deleteOrder(123)).thenThrow(SQLException.class);
// place an order
orderBO.deleteOrder(123);
}
}
| [
"[email protected]"
] | |
2182b9217893928314cf0001a71c0230400ff839 | c141b78ca31a9ac518a7180e1ba289ab16f8f31a | /app/src/main/java/com/zgf/modelapplication/weight/view/PickerItem.java | 67202e470c1b1507a4b63936eff019905688ee6c | [] | no_license | ZGaoFei/ModelApplication | 8d21b2bafbbe2a3ac1eef33fa42c255928342927 | cda70e6f4eee038560920480a1d67abf1fe29cc1 | refs/heads/master | 2020-06-10T16:58:27.038220 | 2017-04-18T04:39:16 | 2017-04-18T04:39:16 | 75,928,698 | 1 | 0 | null | 2017-04-18T06:57:58 | 2016-12-08T10:42:40 | Java | UTF-8 | Java | false | false | 198 | java | package com.zgf.modelapplication.weight.view;
/**
* PickerView item接口类
*/
public interface PickerItem {
/**
* 获取item要显示的文本
*
* @return
*/
String getText();
}
| [
"[email protected]"
] | |
573a77c04c6505d7c37d2566defe46bb0f23957f | 4c147cfb77773d2a1de7a5b1f6f630e906d4a2c2 | /audiovideo/src/main/java/com/applozic/audiovideo/activity/VideoActivity.java | d3140bdfd96ba0d556701bd05af7740ed6294a68 | [] | no_license | aamirtams/AndroidChatApp | a064e042fa9834569cb809042cfcba8804f6fc9d | 7dece8aeeade98f77f32eebf37c2760ca06d7ef4 | refs/heads/master | 2021-09-22T11:19:26.748933 | 2018-09-09T09:53:57 | 2018-09-09T09:53:57 | 126,000,934 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,036 | java | package com.applozic.audiovideo.activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.twilio.video.CameraCapturer;
import com.twilio.video.VideoView;
import applozic.com.audiovideo.R;
public class VideoActivity extends AudioCallActivityV2 {
private static final String TAG = VideoActivity.class.getName();
LinearLayout videoOptionlayout;
public VideoActivity() {
super(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conversation);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
init();
contactName = (TextView) findViewById(R.id.contact_name);
//profileImage = (ImageView) findViewById(R.id.applozic_audio_profile_image);
txtCount = (TextView) findViewById(R.id.applozic_audio_timer);
contactName.setText(contactToCall.getDisplayName());
pauseVideo = true;
primaryVideoView = (VideoView) findViewById(R.id.primary_video_view);
thumbnailVideoView = (VideoView) findViewById(R.id.thumbnail_video_view);
videoStatusTextView = (TextView) findViewById(R.id.video_status_textview);
videoStatusTextView.setVisibility(View.GONE);
connectActionFab = (FloatingActionButton) findViewById(R.id.call_action_fab);
switchCameraActionFab = (FloatingActionButton) findViewById(R.id.switch_camera_action_fab);
localVideoActionFab = (FloatingActionButton) findViewById(R.id.local_video_action_fab);
muteActionFab = (FloatingActionButton) findViewById(R.id.mute_action_fab);
speakerActionFab = (FloatingActionButton) findViewById(R.id.speaker_action_fab);
videoOptionlayout = (LinearLayout) findViewById(R.id.video_call_option);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.video_container);
frameLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
hideShowWithAnimation();
return false;
}
});
/*
* Enable changing the volume using the up/down keys during a conversation
*/
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
/*
* Needed for setting/abandoning audio focus during call
*/
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
/*
* Check camera and microphone permissions. Needed in Android M.
*/
if (!checkPermissionForCameraAndMicrophone()) {
requestPermissionForCameraAndMicrophone();
} else {
createAudioAndVideoTracks();
intializeUI();
initializeApplozic();
}
}
private void hideShowWithAnimation() {
//Camera Actions
if (switchCameraActionFab.isShown()) {
switchCameraActionFab.hide();
} else {
switchCameraActionFab.show();
}
//Mute Actions
if (muteActionFab.isShown()) {
muteActionFab.hide();
} else {
muteActionFab.show();
}
if (localVideoActionFab.isShown()) {
localVideoActionFab.hide();
} else {
localVideoActionFab.show();
}
if (speakerActionFab.isShown()) {
speakerActionFab.hide();
} else {
speakerActionFab.show();
}
}
@Override
public void initializeApplozic() {
super.initializeApplozic();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
/*
* The initial state when there is no active conversation.
*/
@Override
protected void setDisconnectAction() {
super.setDisconnectAction();
if (isFrontCamAvailable(getBaseContext())) {
switchCameraActionFab.show();
switchCameraActionFab.setOnClickListener(switchCameraClickListener());
} else {
switchCameraActionFab.hide();
}
localVideoActionFab.show();
localVideoActionFab.setOnClickListener(localVideoClickListener());
}
private View.OnClickListener switchCameraClickListener() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
if (cameraCapturer != null) {
CameraCapturer.CameraSource cameraSource = cameraCapturer.getCameraSource();
cameraCapturer.switchCamera();
if (thumbnailVideoView.getVisibility() == View.VISIBLE) {
thumbnailVideoView.setMirror(cameraSource == CameraCapturer.CameraSource.BACK_CAMERA);
} else {
primaryVideoView.setMirror(cameraSource == CameraCapturer.CameraSource.BACK_CAMERA);
}
}
}
};
}
private View.OnClickListener localVideoClickListener() {
return new View.OnClickListener() {
@Override
public void onClick(View v) {
/*
* Enable/disable the local video track
*/
if (localVideoTrack != null) {
boolean enable = !localVideoTrack.isEnabled();
localVideoTrack.enable(enable);
int icon;
if (enable) {
icon = R.drawable.ic_videocam_green_24px;
switchCameraActionFab.show();
} else {
icon = R.drawable.ic_videocam_off_red_24px;
switchCameraActionFab.hide();
}
localVideoActionFab.setImageDrawable(
ContextCompat.getDrawable(VideoActivity.this, icon));
}
}
};
}
public boolean isFrontCamAvailable(Context context) {
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
return true;
} else {
return false;
}
}
}
| [
"[email protected]"
] | |
f7b013727ce17feceddc83c1de251b8df20eef2d | 67d3b5a4c6bd59c93e0428276f6f62eee95c6175 | /src/main/java/leetcode/p477/Solution477_2.java | 4fc9a7dd092bec629076bb65e48e715bffa8cc94 | [
"MIT"
] | permissive | beloshabskiy/leetcode | 4e03304161e9b801c6615f6bf18e2215af6cead9 | 440e87ac8046cba1cce153123680ed14912fbe1e | refs/heads/master | 2020-12-06T06:02:00.322041 | 2020-06-29T14:13:36 | 2020-06-29T14:13:36 | 232,366,356 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 745 | java | package leetcode.p477;
/**
* 477. Total Hamming Distance
* The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
* Now your job is to find the total Hamming distance between all pairs of the given numbers.
*/
public class Solution477_2 {
public int totalHammingDistance(int[] nums) {
int result = 0;
for (int i = 0; i < 32; i++) {
int zeros = 0;
int ones = 0;
for (int num : nums) {
if (((num >> i) & 1) == 0) {
++zeros;
} else {
++ones;
}
}
result += (zeros * ones);
}
return result;
}
}
| [
"[email protected]"
] | |
58f62e7890843e87fe3b997bf65e0f7367659503 | 10127b97f97d388a9c43f50bc53dfa610d7652f0 | /benz/benz-core/src/test/java/com/sxx/ioc/ann/bean/Person.java | 9a9f43aaef1d8160dd39f02c5c298d7b18a5a33a | [] | no_license | suxiaoxu/Benz | fac2043bf23e45e8d7fa92e81f8f899f3dd90b92 | b416646b3ea84b4e884eaab112305c49e438bc23 | refs/heads/master | 2021-01-20T07:34:57.421540 | 2017-06-20T14:59:55 | 2017-06-20T14:59:55 | 50,226,599 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 543 | java | package com.sxx.ioc.ann.bean;
@MyClassAnnotation(uri ="asdf",desc="asdf")
public class Person {
private int age;
private String name;
private int heghit;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getHeghit() {
return heghit;
}
public void setHeghit(int heghit) {
this.heghit = heghit;
}
public int sub(int a,int b){
System.out.println(a+b);
return a+b;
}
}
| [
"[email protected]"
] | |
55dae168ce3e3ee53040ca8c1cf8d906cc048e30 | 1ae9b3a3734923363f5efbd7fc273248b71ad10a | /app/src/main/java/com/example/ins/Fragment/SearchFragment.java | 0cae475c2f291aab3110251e1c491ae43e7197e6 | [] | no_license | violetddd/Group27_test | c2630907937c5991a643a69c2d665b45e9be4e5a | ff003fbf8e980d74fd62aaa27f5e351fcbb1e905 | refs/heads/master | 2023-06-17T01:42:01.430444 | 2021-07-13T13:40:47 | 2021-07-13T13:40:47 | 384,592,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,070 | java | package com.example.ins.Fragment;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.ins.R;
/**
* A simple {@link Fragment} subclass.
* Use the {@link SearchFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class SearchFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public SearchFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment SearchFragment.
*/
// TODO: Rename and change types and number of parameters
public static SearchFragment newInstance(String param1, String param2) {
SearchFragment fragment = new SearchFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_search, container, false);
}
} | [
"[email protected]"
] | |
27f89f0ae36fcf31733608bcdd6e38b44e2c5982 | 0b161fdb4427b96e636e76346042266e6aae8059 | /Latest APIs code JAVA/dev server/src/main/java/com/etl/base/CompanyServices.java | 59a273f4b9e3b76730733568409553200bc45fc1 | [] | no_license | ishuzontec/https---github.com-falconloop-Falconloop-APIs | 7c3d1d3c782e38d44e1d90c85fc35d86ea0c6287 | f3df3c6fcf893c12d46fd38c540ebf8cdb8ad1d3 | refs/heads/master | 2020-03-29T01:58:21.385070 | 2018-09-19T08:10:36 | 2018-09-19T08:10:36 | 149,415,745 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,266 | java | package com.etl.base;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.etl.util.MYSQLConnection;
import com.etl.util.MYSQLHelper;
public class CompanyServices {
public int CompanyServicesId;
public int CompanyId;
public String CompanyServices;
public String CreatedDate;
public String Result;
public String Error;
private void setcompanyServicesId(int companyServicesId) {
this.CompanyServicesId = companyServicesId;
}
private int getcompanyServicesId() {
return CompanyServicesId;
}
private void setcompanyId(int companyId) {
this.CompanyId = companyId;
}
private int getcompanyId() {
return CompanyId;
}
private void setcompanyServices(String companyServices) {
this.CompanyServices = companyServices;
}
private String getcompanyServices() {
return CompanyServices;
}
private void setCreatedDate(String CreatedDate) {
this.CreatedDate = CreatedDate;
}
private String getCreatedDate() {
return CreatedDate;
}
private void setResult(String Result) {
this.Result = Result;
}
private String getResult() {
return Result;
}
private void setError(String Error) {
this.Error = Error;
}
private String getError() {
return Error;
}
public CompanyServices addCompanyServices(int CompanyId, String CompanyServices) {
CompanyServices _CompanyServices = new CompanyServices();
Connection _Connection = MYSQLConnection.GetConnection();
PreparedStatement _PreparedStatement = null;
MYSQLHelper _MYSQLHelper = new MYSQLHelper();
if (_Connection != null) {
try {
String _queryRole = "SELECT * FROM company where Company_Id='" + CompanyId + "'";
ResultSet _ResultSetRole = _MYSQLHelper.GetResultSet(_queryRole, _Connection);
if (_ResultSetRole.next()) {
String _querycompanyservices = "SELECT * FROM companyservices where companyId='" + CompanyId + "'";
ResultSet _ResultSetServices = _MYSQLHelper.GetResultSet(_querycompanyservices, _Connection);
if (!_ResultSetServices.next()) {
String[] arrOfStrCompanyServices = CompanyServices.split(",");
boolean ictr = true;
for (int i = 0; i < arrOfStrCompanyServices.length; i++) {
String _queryRoleService = "SELECT * FROM services where servicesId='"
+ arrOfStrCompanyServices[i] + "'";
ResultSet _ResultSetService = _MYSQLHelper.GetResultSet(_queryRoleService, _Connection);
if (!_ResultSetService.next()) {
ictr = false;
}
}
if (ictr) {
int _lResultId = _addCompanyService(CompanyId, CompanyServices);
_CompanyServices.setcompanyServicesId(_lResultId);
_CompanyServices.setResult("Success");
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Invalid Service Id, Please sent correct Service Ids!");
}
} else {
int _lResultId = _updateCompanyService(CompanyId, CompanyServices);
if (_lResultId > 0) {
_CompanyServices.setcompanyId(CompanyId);
_CompanyServices.setResult("Success");
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("an error occured, please contact to system administrator!");
}
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Invalid Company Id!");
}
} catch (Exception e) {
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Error in api backend connectivity !");
}
return _CompanyServices;
}
public CompanyServices updateCompanyServices(int CompanyId, String CompanyServices) {
CompanyServices _CompanyServices = new CompanyServices();
Connection _Connection = MYSQLConnection.GetConnection();
PreparedStatement _PreparedStatement = null;
MYSQLHelper _MYSQLHelper = new MYSQLHelper();
if (_Connection != null) {
try {
String _queryRole = "SELECT * FROM company where Company_Id='" + CompanyId + "'";
ResultSet _ResultSetRole = _MYSQLHelper.GetResultSet(_queryRole, _Connection);
if (_ResultSetRole.next()) {
String[] arrOfStrCompanyServices = CompanyServices.split(",");
boolean ictr = true;
for (int i = 0; i < arrOfStrCompanyServices.length; i++) {
String _queryRoleService = "SELECT * FROM services where servicesId='"
+ arrOfStrCompanyServices[i] + "'";
ResultSet _ResultSetService = _MYSQLHelper.GetResultSet(_queryRoleService, _Connection);
if (!_ResultSetService.next()) {
ictr = false;
}
}
if (ictr) {
int _lResultId = _updateCompanyService(CompanyId, CompanyServices);
if (_lResultId > 0) {
_CompanyServices.setcompanyId(CompanyId);
_CompanyServices.setResult("Success");
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("an error occured, please contact to system administrator!");
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Invalid Service Id, Please sent correct Service Ids!");
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Invalid Company Id!");
}
} catch (Exception e) {
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Error in api backend connectivity !");
}
return _CompanyServices;
}
public int _addCompanyService(int CompanyId, String CompanyServices) {
int _result = 0;
Connection _Connection = MYSQLConnection.GetConnection();
PreparedStatement _PreparedStatement = null;
MYSQLHelper _MYSQLHelper = new MYSQLHelper();
if (_Connection != null) {
try {
String _queryRole = "SELECT * FROM company where Company_Id='" + CompanyId + "'";
ResultSet _ResultSetRole = _MYSQLHelper.GetResultSet(_queryRole, _Connection);
if (_ResultSetRole.next()) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
String date = format.format(cal.getTime());
String sInsertStatement = "INSERT INTO companyservices(companyId,companyServices,createdDate)";
sInsertStatement = sInsertStatement + " VALUES(?, ?, ?)";
_PreparedStatement = _Connection.prepareStatement(sInsertStatement);
_PreparedStatement.setInt(1, CompanyId);
_PreparedStatement.setString(2, CompanyServices);
_PreparedStatement.setString(3, date);
_PreparedStatement.executeUpdate();
ResultSet _ResultSetld = _MYSQLHelper.GetResultSet(
"SELECT MAX(companyServicesId) AS companyServicesId FROM companyservices", _Connection);
if (_ResultSetld.next()) {
int lastid = _ResultSetld.getInt("companyServicesId");
_result = lastid;
}
}
} catch (Exception e) {
}
}
return _result;
}
public int _updateCompanyService(int CompanyId, String CompanyServices) {
int _result = 0;
CompanyServices _CompanyServices = new CompanyServices();
Connection _Connection = MYSQLConnection.GetConnection();
PreparedStatement _PreparedStatement = null;
MYSQLHelper _MYSQLHelper = new MYSQLHelper();
try {
String _queryRole = "SELECT * FROM company where Company_Id='" + CompanyId + "'";
ResultSet _ResultSetRole = _MYSQLHelper.GetResultSet(_queryRole, _Connection);
if (_ResultSetRole.next()) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
String date = format.format(cal.getTime());
String sInsertStatement = "UPDATE companyservices SET companyservices = ?,createdDate = ? "
+ " WHERE companyId = ?";
_PreparedStatement = _Connection.prepareStatement(sInsertStatement);
_PreparedStatement.setString(1, CompanyServices);
_PreparedStatement.setString(2, date);
_PreparedStatement.setInt(3, CompanyId);
_PreparedStatement.executeUpdate();
_result = 1;
}
} catch (Exception e) {
_result = 0;
}
return _result;
}
public CompanyServices _getCompanyServicedetails(int CompanyId) {
CompanyServices _CompanyServices = new CompanyServices();
Connection _Connection = MYSQLConnection.GetConnection();
MYSQLHelper _MYSQLHelper = new MYSQLHelper();
if (_Connection != null) {
try {
ResultSet _ResultSet = _MYSQLHelper
.GetResultSet("SELECT * FROM companyservices where CompanyId='" + CompanyId + "'", _Connection);
if (_ResultSet.next()) {
_CompanyServices.setcompanyServicesId(_ResultSet.getInt("companyServicesId"));
_CompanyServices.setcompanyId(_ResultSet.getInt("companyId"));
_CompanyServices.setcompanyServices(_ResultSet.getString("companyServices"));
_CompanyServices.setCreatedDate(_ResultSet.getString("createdDate"));
_CompanyServices.setResult("Success");
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Invalid Company Id!");
}
}
catch (Exception e) {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("an error occured, please contact to system administrator!");
}
} else {
_CompanyServices.setResult("Failed");
_CompanyServices.setError("Error in api backend connectivity !");
}
return _CompanyServices;
}
}
| [
"[email protected]"
] | |
399c1de64012ad75f3f25005501a6d2f6eb38dfa | 0c1acfa5f3514340d73a1b074a23e3620583d27a | /zsdev-ac/src/main/java/com/sdzs/zsdev/ac/task/TaskResponse.java | bb6218729c97b95b3eeceb2753eded2bf36cf24d | [] | no_license | zhangxiaodang-zs/zsdev | e7881472b10f4d4aa1c9f7df1e18316f3ffb6d2f | 24c740338e0a92b629d0546dd63dca375e943150 | refs/heads/master | 2022-12-15T04:59:18.827836 | 2020-04-13T13:25:42 | 2020-04-13T13:25:42 | 247,853,771 | 0 | 0 | null | 2022-12-06T00:44:20 | 2020-03-17T01:39:34 | Java | UTF-8 | Java | false | false | 6,684 | java | package com.sdzs.zsdev.ac.task;
/**
* Copyright(C) ShanDongYinFang 2019.
* <p>
* WEB端机构信息返回报文.
*
* @author 门海峰 2020/03/17.
* @version V0.0.1.
* <p>
* 更新履历: V0.0.1 2020/03/17 门海峰 创建.
*/
public class TaskResponse {
// 请求次数
private String draw;
// 总条数(不是本页的条数,是总条数)
private String totalcount;
//返回角色信息集合
private Object tasklist;
public String getDraw() {
return draw;
}
public void setDraw(String draw) {
this.draw = draw;
}
public String getTotalcount() {
return totalcount;
}
public void setTotalcount(String totalcount) {
this.totalcount = totalcount;
}
public Object getTasklist() {
return tasklist;
}
public void setTasklist(Object tasklist) {
this.tasklist = tasklist;
}
// 主机构树
public static class ProjectTree{
// 任务id
private String id;
// 关联需求id
private String demandid;
// 任务名称
private String taskname;
// 预计开始时间
private String expectedsttime;
// 预计结束时间
private String expectedentime;
// 实际开始时间
private String actualsttime;
// 实际结束时间
private String actualentime;
// 任务介绍
private String taskcontent;
// 所属项目
private String projectname;
// 用户名称
private String username;
// 工时
private String workhours;
// 任务负责人
private String principal;
// 任务进度
private String schedule;
// 添加时间
private String addtime;
// 更新时间
private String updtime;
// 关联需求名称
private String demandname;
//返回集合
private Object tasklist;
// 状态
private String status;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDemandid() {
return demandid;
}
public void setDemandid(String demandid) {
this.demandid = demandid;
}
public String getTaskname() {
return taskname;
}
public void setTaskname(String taskname) {
this.taskname = taskname;
}
public String getExpectedsttime() {
return expectedsttime;
}
public void setExpectedsttime(String expectedsttime) {
this.expectedsttime = expectedsttime;
}
public String getExpectedentime() {
return expectedentime;
}
public void setExpectedentime(String expectedentime) {
this.expectedentime = expectedentime;
}
public String getActualsttime() {
return actualsttime;
}
public void setActualsttime(String actualsttime) {
this.actualsttime = actualsttime;
}
public String getActualentime() {
return actualentime;
}
public void setActualentime(String actualentime) {
this.actualentime = actualentime;
}
public String getTaskcontent() {
return taskcontent;
}
public void setTaskcontent(String taskcontent) {
this.taskcontent = taskcontent;
}
public String getPrincipal() {
return principal;
}
public void setPrincipal(String principal) {
this.principal = principal;
}
public String getSchedule() {
return schedule;
}
public void setSchedule(String schedule) {
this.schedule = schedule;
}
public String getAddtime() {
return addtime;
}
public void setAddtime(String addtime) {
this.addtime = addtime;
}
public String getUpdtime() {
return updtime;
}
public void setUpdtime(String updtime) {
this.updtime = updtime;
}
public Object getTasklist() {
return tasklist;
}
public void setTasklist(Object tasklist) {
this.tasklist = tasklist;
}
public String getWorkhours() {
return workhours;
}
public void setWorkhours(String workhours) {
this.workhours = workhours;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getDemandname() {
return demandname;
}
public void setDemandname(String demandname) {
this.demandname = demandname;
}
public String getProjectname() {
return projectname;
}
public void setProjectname(String projectname) {
this.projectname = projectname;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
@Override
public String toString() {
return "TaskListResponse{" +
"taskid='" + id + '\'' +
", taskname='" + taskname + '\'' +
", projectname='" + projectname + '\'' +
", demandname='" + demandname + '\'' +
", expectedsttime='" + expectedsttime + '\'' +
", expectedentime='" + expectedentime + '\'' +
", actualsttime='" + actualsttime + '\'' +
", actualentime='" + actualentime + '\'' +
", taskcontent='" + taskcontent + '\'' +
", workhours='" + workhours + '\'' +
", principal='" + principal + '\'' +
", username='" + username + '\'' +
", schedule='" + schedule + '\'' +
", addtime='" + addtime + '\'' +
", updtime='" + updtime + '\'' +
", status='" + status + '\'' +
'}';
}
}
@Override
public String toString() {
return "TaskResponse{" +
"draw='" + draw + '\'' +
", totalcount='" + totalcount + '\'' +
", tasklist=" + tasklist +
'}';
}
}
| [
"[email protected]"
] | |
e845704cb0bf770131074b07a3b3678e42bc4bf3 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mobileqqi/classes.jar/AndroidClientInterface/stVerifyBlackListRsp.java | 6fde9cd0b5d04d359f85cc9480821348c889f1db | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 837 | java | package AndroidClientInterface;
import com.qq.taf.jce.JceInputStream;
import com.qq.taf.jce.JceOutputStream;
import com.qq.taf.jce.JceStruct;
public final class stVerifyBlackListRsp
extends JceStruct
{
public int iValue = 0;
public stVerifyBlackListRsp() {}
public stVerifyBlackListRsp(int paramInt)
{
this.iValue = paramInt;
}
public void readFrom(JceInputStream paramJceInputStream)
{
this.iValue = paramJceInputStream.read(this.iValue, 0, true);
}
public void writeTo(JceOutputStream paramJceOutputStream)
{
paramJceOutputStream.write(this.iValue, 0);
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mobileqqi\classes2.jar
* Qualified Name: AndroidClientInterface.stVerifyBlackListRsp
* JD-Core Version: 0.7.0.1
*/ | [
"[email protected]"
] | |
82f9be469b268ccd3dafa0ded8e7c540fc80dbc7 | e498ea268e52a7683597375c6f2cfe8ff2c0b949 | /spring-multi-datasource/src/main/java/com/baoli/multidatasource/entity/User.java | 83713eed355e63bbae129ec0eac7d6a8352de82d | [] | no_license | lilybao/common-demo | e2ee53d36af65d3130ddae83262bc9bdd5f900de | 00f3a5f008c7111ffbf3f98bc38035b6fa814e4a | refs/heads/master | 2022-06-22T17:13:39.584178 | 2020-05-29T09:57:28 | 2020-05-29T09:57:28 | 230,351,579 | 1 | 0 | null | 2022-06-21T04:03:39 | 2019-12-27T01:28:44 | Java | UTF-8 | Java | false | false | 250 | java | package com.baoli.multidatasource.entity;
import lombok.Data;
/**
* @program: common-demo
* @description: 用户
* @author: li baojian
* @create: 2020-03-23 18:40
*/
@Data
public class User {
private String name;
private String age;
}
| [
"[email protected]"
] | |
30385b838379faa02ef56f60e7accc093f3e5d6e | 6013879985cb21f6e55dba1ab51e6a3c6f78d66b | /StreetApp_AS/streetApp/src/main/java/com/juxun/business/street/bean/UserBean.java | 8aac4d9905ff0cfcc91bbbc684d5efd9780c1aca | [] | no_license | 15307388990/street | 6ed4e9b72feb9bfd2c346c6b7cd46960ba695c84 | 77cfc79bb1f8c7e20e18f87a20bfe5272d05b66b | refs/heads/master | 2020-04-09T18:21:56.098493 | 2018-12-05T11:52:33 | 2018-12-05T11:52:33 | 160,509,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,515 | java | /**
*
*/
package com.juxun.business.street.bean;
import java.io.Serializable;
/**
*
* 项目名称:Street 类名称:UserBean 类描述: 创建人:WuJianhua 创建时间:2015年6月2日 下午4:25:59
* 修改人:WuJianhua 修改时间:2015年6月2日 下午4:25:59 修改备注:
*
* @version
*
*/
@SuppressWarnings("serial")
public class UserBean implements Serializable {
// private int userId;// 用户ID
// private String userName;// 用户名
// private String userNickname;// 用户昵称
// private int storeId;// 商铺ID
private String authToken;// 授权令牌
private int userid;// 商户id
private int oper_id;// 操作员id
private int out_id;// 门店id
private int storeId;// 商铺ID
private String storename;// 商户名称
public String getStorename() {
return storename;
}
public void setStorename(String storename) {
this.storename = storename;
}
public String getAuthToken() {
return authToken;
}
public void setAuthToken(String authToken) {
this.authToken = authToken;
}
public int getOut_id() {
return out_id;
}
public void setOut_id(int out_id) {
this.out_id = out_id;
}
public int getStoreId() {
return storeId;
}
public void setStoreId(int storeId) {
this.storeId = storeId;
}
public int getUserId() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public int getOper_id() {
return oper_id;
}
public void setOper_id(int oper_id) {
this.oper_id = oper_id;
}
}
| [
"[email protected]"
] | |
21e13e5d43a19e0ee95e4cc4868f1d4a820077e3 | c9c3cebcb981aef73f69d37ad28ee4c4df7f2eaf | /src/main/java/dev/paie/web/WebAppInitializer.java | 3a27754d35bf5cc12dc8bf89b947365d51b27d4b | [] | no_license | warso/sirh-gestion-paie | af6e9873fc0eb2d0fe857fd6c7c5eb3c39b77b2a | b841d5b6615e7059e5a586e3e0cb1ec170aa2333 | refs/heads/master | 2020-12-24T05:13:27.785471 | 2017-06-06T15:44:09 | 2017-06-06T15:44:09 | 92,925,939 | 0 | 0 | null | 2017-05-31T08:55:16 | 2017-05-31T08:55:16 | null | UTF-8 | Java | false | false | 1,664 | java | package dev.paie.web;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import dev.paie.config.WebAppConfig;
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
// Initialisation du contexte Spring
AnnotationConfigWebApplicationContext webContext = new
AnnotationConfigWebApplicationContext();
webContext.register(WebAppConfig.class);
/*
*
* <servlet>
*
* <servlet-name>dispatcher</servlet-name> <servlet-
* class>org.springframework.web.servlet.DispatcherServlet</servlet-
* class>
*
* <load-on-startup>1</load-on-startup>
*
* </servlet>
*
*/
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",new DispatcherServlet(webContext));
dispatcher.setLoadOnStartup(1);
/*
*
* <servlet-mapping>
*
* <servlet-name>dispatcher</servlet-name>
*
* <url-pattern>/mvc/*</url-pattern>
*
* </servlet-mapping>
*
*/
dispatcher.addMapping("/mvc/*");
/*
*
* <listener>
*
* <listener-
* class>org.springframework.web.context.ContextLoaderListener</listener
* -class>
*
* </listener>
*
*/
servletContext.addListener(new ContextLoaderListener(webContext));
}
} | [
"[email protected]"
] | |
657bbc97e3afe74bb5ed07f4ca3999bf6b2d54c1 | 69b7af0eefdb58fe5418e291f36b77dd66b95d6b | /TuanLuongIoofexercise/src/Robot.java | 76d31efc5011a2dd5e122e176a39b4b65729edc3 | [] | no_license | tuanmission/TuanLuongIOOFRobotChallenge | ae83db14db729812d4f33971747a2337e29d73fd | bc3d77dfcce2941c4c2e92d83aaa8dfed8e56692 | refs/heads/master | 2023-08-28T14:49:03.034947 | 2021-10-03T06:33:02 | 2021-10-03T06:33:02 | 412,988,249 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,160 | java |
public class Robot {
private int x; //Instance Variables
private int y;
private Direction direction;
public Robot(int xin, int yin, Direction dir) {
this.x=xin;
this.y=yin;
this.direction=dir;
}
//Method to move robot left
public void left() {
switch(this.direction) { //Switch statement to determine the direction robot faces after turning
case EAST:
this.direction =Direction.NORTH;
break;
case NORTH:
this.direction = Direction.WEST;
break;
case WEST:
this.direction = Direction.SOUTH;
break;
case SOUTH:
this.direction = Direction.EAST;
break;
}
}
//Method to move right
public void right() {
switch(this.direction) { //Switch statement to determine the direction robot faces after turning
case EAST:
this.direction =Direction.SOUTH;
break;
case NORTH:
this.direction = Direction.EAST;
break;
case WEST:
this.direction = Direction.NORTH;
break;
case SOUTH:
this.direction = Direction.WEST;
break;
}
}
public void move() { //Method to move robot
int x=this.x; //Temporary Variables to check if the movement is in range.
int y = this.y;
switch(this.direction) { //Switch statement to determine the position the robot changes.
case EAST:
x++; //Moves robot facing east based on origin of SW of (0,0)
if(inRange(x)==true) { //Check is move is in range, if it is reassigns instance variable
this.x=x;
}
break;
case NORTH:
y++; // Moves robot facing north.
if(inRange(y)==true) {
this.y=y;
}
break;
case WEST:
x--; //Moves robot facing West
if(inRange(x)==true) {
this.x=x;
}
break;
case SOUTH:
y--; //Moves robot facing south
if(inRange(y)==true) {
this.y=y;
}
break;
}
}
//Method to report direction.
public String Report() {
return this.x +","+this.y+","+this.direction;
}
//Determines if the variable is within the range of the table
private boolean inRange(int var) {
if (var<0 || var>4 ) {
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
f6b4e1dc306192bb5d7e223a101edd5351de45c2 | 08ec7f5aaada2592a95fac333f66321410fd1135 | /Anagram/src/SemPalavraException.java | fc3306e345245411864b5c835e8e84240fd3cda6 | [] | no_license | PedroSantos42/algorithms | 759a34d2e1f0fed4847fdac5cb6f655b484c65e7 | fff22af1c1711c2fe92bb523cdb37c8a08f5412f | refs/heads/master | 2023-03-23T15:43:55.076244 | 2021-03-07T15:45:25 | 2021-03-07T15:45:25 | 147,710,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 140 | java |
public class SemPalavraException extends Exception {
public SemPalavraException()
{
super("Sem nenhuma palavra nos parâmetros");
}
}
| [
"[email protected]"
] | |
62bf5f0c4eafe385864838bd47cb3f02c9a0ab51 | 5dae254e98b68cbbc747f64677e555f4b8da3447 | /core/src/com/apptogo/runalien/plugin/AbstractPlugin.java | 0d202d491ce80ab5ec428ab010cdf4883bb3c292 | [] | no_license | mantkowicz/runalien | 8a7764989a5e80130101752ea52024256c0d0dcc | 2ebc5f21fbaf3f46892afd8f9573ea7ed67119a7 | refs/heads/master | 2020-12-25T16:58:47.627186 | 2017-03-16T21:45:16 | 2017-03-16T21:45:16 | 53,248,435 | 0 | 1 | null | 2019-11-03T11:47:20 | 2016-03-06T10:05:13 | Java | UTF-8 | Java | false | false | 549 | java | package com.apptogo.runalien.plugin;
import com.apptogo.runalien.game.GameActor;
import com.badlogic.gdx.physics.box2d.Body;
public abstract class AbstractPlugin {
protected GameActor actor;
protected Body body;
abstract public void setUpDependencies();
abstract public void run();
public void postSetActor() {
}
public GameActor getActor() {
return actor;
}
public void setActor(GameActor actor) {
this.actor = actor;
this.body = actor.getBody();
setUpDependencies();
postSetActor();
}
}
| [
"[email protected]"
] | |
d120f2f73e5eedc8dd66d1e6385d3c24e77407da | c8a6fb1aed83cf3c8d2ce7095971cc1622282952 | /microservicecloud-config-client-3355/src/main/java/com/atguigu/springcloud/rest/ConfigClientRest.java | 6ac9ad170f6f97c82317580a7c8476684362348f | [] | no_license | qiyejialaodu/microservicecloud | 0e376d350c819dc6feb38ba293113c39c989dcbc | 8d270053ef8fc950136278e94dc7f53c50bd9f24 | refs/heads/master | 2022-11-29T11:50:30.905399 | 2020-08-13T13:22:07 | 2020-08-13T13:33:00 | 287,283,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 813 | java | package com.atguigu.springcloud.rest;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ConfigClientRest {
@Value("${spring.application.name}")
private String applicationName;
@Value("${eureka.client.service-url.defaultZone}")
private String eurekaServers;
@Value("${server.port}")
private String port;
@RequestMapping("/config")
public String getConfig(){
String str = "applicationName:"+applicationName+"\n"+"eurekaServers:"+"\n"+eurekaServers+"port:"+port;
System.out.println("******str: "+str);
return "applicationName:"+applicationName+"\n"+"eurekaServers:"+"\n"+eurekaServers+"port:"+port;
}
}
| [
"[email protected]"
] | |
61247ad5ef3ddee6855beb96d5b7119f127f4a92 | e4aad1c64bc06e924694ff2210dab5edef0ec831 | /app/src/main/java/com/example/tctctc/easylook/ganhuojizhongying/DetailActivity.java | b58dc77f31ef3cc38856509c674d92b07b6c7124 | [] | no_license | ziktang/EasyLook | 0640ac1c3bba6551b55d0bb751741100d7088005 | 38de28b98bcd89d13d61da2cf968b5aad385a0ed | refs/heads/master | 2020-05-27T21:13:15.028486 | 2017-03-02T00:49:58 | 2017-03-02T00:49:58 | 83,617,148 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,576 | java | package com.example.tctctc.easylook.ganhuojizhongying;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.Target;
import com.example.tctctc.easylook.Base.BaseActivity;
import com.example.tctctc.easylook.R;
import com.example.tctctc.easylook.Utils.NetUtil;
import com.example.tctctc.easylook.ganhuojizhongying.Model.CateGanHuo;
import com.umeng.analytics.MobclickAgent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class DetailActivity extends BaseActivity {
private static final String GH_CACAHE_DIRNAME = "ghCache";
@BindView(R.id.gh_detail)
WebView mGhDetail;
private CateGanHuo.CateBean cateBean;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ButterKnife.bind(this);
cateBean = (CateGanHuo.CateBean) getIntent().getSerializableExtra("bean");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(cateBean.getWho());
setWebView(mGhDetail);
mGhDetail.loadUrl(cateBean.getUrl());
}
private void setWebView(WebView webView) {
WebSettings webSettings = mGhDetail.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setDefaultTextEncodingName("utf-8");
if (NetUtil.isNetworkAvailable(getApplicationContext())) {
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);//根据cache-control决定是否从网络上取数据。
} else {
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);//没网,则从本地获取,即离线加载
}
webSettings.setAppCacheEnabled(true);//开启 Application Caches 功能
String cacheDirPath = getFilesDir().getAbsolutePath() + GH_CACAHE_DIRNAME;
webSettings.setAppCachePath(cacheDirPath); //设置 Application Caches 缓存目录
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.share:
share();
return true;
case R.id.use_browser:
Uri uri = Uri.parse(cateBean.getUrl());
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void share() {
Intent share_intent = new Intent();
share_intent.setAction(Intent.ACTION_SEND);//设置分享行为
share_intent.setType("text/plain");//设置分享内容的类型
share_intent.putExtra(Intent.EXTRA_SUBJECT, cateBean.getDesc());//添加分享内容标题
share_intent.putExtra(Intent.EXTRA_TEXT, cateBean.getDesc()+"(分享自氢读)"+cateBean.getUrl());//添加分享内容
//创建分享的Dialog
share_intent = Intent.createChooser(share_intent, "分享到");
startActivity(share_intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.detail_menu,menu);
return true;
}
public void onResume() {
super.onResume();
MobclickAgent.onPageStart("DetailActivity"); //统计页面,"MainScreen"为页面名称,可自定义
}
public void onPause() {
super.onPause();
MobclickAgent.onPageEnd("DetailActivity");
}
}
| [
"[email protected]"
] | |
80db5f1448dd161ad784e7d62f7a218797742df8 | a6ee43db1ecf659c47967d3334ba15e504947a5e | /src/main/java/com/leetcode/pascals_triangle_ii/Solution1.java | f637b472fd9740656b1d5af0d05250403f7ca7ea | [
"MIT"
] | permissive | magnetic1/leetcode | fa3d640b640b4626705272bbcafc31c082fa6138 | 4577439aac13f095bc1f20adec5521520b3bef70 | refs/heads/master | 2023-04-21T10:28:10.320263 | 2021-05-06T12:22:57 | 2021-05-06T12:22:57 | 230,269,263 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 806 | java | /**
* Leetcode - pascals_triangle_ii
*/
package com.leetcode.pascals_triangle_ii;
import java.util.*;
import com.ciaoshen.leetcode.util.*;
/**
* log instance is defined in Solution interface
* this is how slf4j will work in this class:
* =============================================
* if (log.isDebugEnabled()) {
* log.debug("a + b = {}", sum);
* }
* =============================================
*/
class Solution1 implements Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> list = new ArrayList<>();
for(int size = 0; size <= rowIndex; size++) {
for(int i = size - 1; i > 0; i--) {
list.set(i, list.get(i - 1) + list.get(i));
}
list.add(1);
}
return list;
}
}
| [
"[email protected]"
] | |
0c9e477cc64658f14e2215c4b78a9adb0988b158 | 3d30d35c6383d1a16430560db69416e924f21177 | /src/main/java/com/net/demo/service/PublisherService.java | 03040da10fc15444c9d32334df646bfdfb7bfa62 | [] | no_license | lucyVan/net3.14 | a06fe5eae13dd5bccc4b797c61a079aa9a4cce86 | a6d746723e7d0db30a9eb9aada28300272e3b393 | refs/heads/master | 2022-06-22T20:39:38.136112 | 2020-01-10T06:45:04 | 2020-01-10T06:45:04 | 232,980,021 | 0 | 0 | null | 2022-06-21T02:36:46 | 2020-01-10T06:21:50 | Java | UTF-8 | Java | false | false | 126 | java | package com.net.demo.service;
import org.springframework.stereotype.Service;
@Service
public interface PublisherService {
}
| [
"[email protected]"
] | |
d3e30704d697256971bcfd752f3c8c3f32a2336d | 696637bc44b2d4f9a1213447db922928b2d7f010 | /src/webserver/WebServer.java | f856cddacbb88a57433ec439a5a6ec01d9b070a3 | [] | no_license | del42/WebServer | 0fa2ba92ceaa977c88e847dc852c4b061bc5d5c2 | c91d346c7277020512764b83212c814188f62b58 | refs/heads/master | 2020-04-05T23:02:11.237601 | 2012-11-20T20:49:27 | 2012-11-20T20:49:27 | 6,784,919 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,314 | java | package webserver;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import webserver.configuration.ConfigVars;
import webserver.configuration.HttpdConf;
import webserver.configuration.MIME;
import webserver.request.BufferedInputStreamReader;
import webserver.request.HttpReqMsg;
import webserver.request.Request;
import webserver.response.HttpRespMsg;
import webserver.response.Response;
/**
* This class is the entry point of the web server application. It reads the
* configuration files and sets the configuration parameters. Then, it opens a
* server socket and starts receiving the requests from the browser and
* assigning them to the threads. Each thread is responsible for parsing the
* request, preparing the response and sending the response back to the browser
* through different objects and methods.
*/
public class WebServer {
private ServerSocket serverSocket;
private Socket socket = null;
private static int tID = 0;
private ExecutorService threadPoolExecutor;
/**
* This is the web server constructor. As soon as a web server object is
* instantiated, it instantiates two other objects which read the
* configuration files and set the configuration parameters for the web
* server. Now, the web server is ready to receive the requests.
*/
public WebServer() {
// parse httpd.conf and mime.types files as the web server starts
String userDir = System.getProperty("user.dir");
String sep = System.getProperty("file.separator");
System.out.println("Configuring the web server ..." + "\n");
new HttpdConf(userDir + sep + "conf" + sep + "httpd.conf").processConfigFile();
new MIME(userDir + sep + "conf" + sep + "mime.types").processMIMEFile();
}
/**
* This method opens a server socket to receive the requests from the
* browser. Then, it creates a thread pool with a capacity defined in
* configuration parameters and starts accepting the incoming requests and
* assigning them to the threads in the thread pool.
*
* @throws InterruptedException
*/
public void webServerRun() throws InterruptedException {
try {
serverSocket = new ServerSocket(Integer.parseInt(ConfigVars.getListen()));
System.out.println("Socket Opened on Port "
+ ConfigVars.getListen() + ".");
} catch (IOException e) {
System.out.println("Failed to open socket on port "
+ ConfigVars.getListen() + ".");
System.exit(1);
}
int maxThread = Integer.parseInt(ConfigVars.getMaxThread());
// thread pool with maxThread number
threadPoolExecutor = Executors.newFixedThreadPool(maxThread);
while (true) {
try {
socket = serverSocket.accept();
threadPoolExecutor.execute(new ReqThread(socket, tID));
if (tID == maxThread) {
tID = 0;
} else {
tID++;
}
} catch (IOException e) {
System.out.println("Accept Failed on: "
+ ConfigVars.getListen());
System.exit(1);
}
}
}
public static void main(String[] args) throws IOException,
InterruptedException {
WebServer ws = new WebServer();
ws.webServerRun();
}
}
/**
* This class defines the functionalities of each thread. Each thread receives
* the request assigned by the WebServer. It instantiates a Request object,
* which parses the request and stores the extracted information in an
* HttpReqMsg object. Then, it instantiates the Response object which prepares
* the response in an HttpRespMsg object. Finally,the thread sends the respond
* back to the server. The request and response information is saved on a log
* file.
*/
class ReqThread implements Runnable {
private Socket socket;
private Request request;
private Response response;
private HttpReqMsg reqMsg;
private HttpRespMsg respMsg;
private FileWriter logFile;
private BufferedInputStreamReader req;
BufferedOutputStream out;
private int tID;
public ReqThread(Socket clientSocket, int id) {
this.socket = clientSocket;
this.tID = id;
try {
req = new BufferedInputStreamReader(new BufferedInputStream(socket.getInputStream()));
out = new BufferedOutputStream(socket.getOutputStream());
} catch (IOException e) {
System.out.println(e);
}
}
/**
* This method is responsible for writing to the log file. For each request
* and its response, the following information is saved: 1. the client's
* name and IP address. 2. the request's type and resource 3. the HTTP
* version 4. the response's status code, description, and body size (if
* any) 5. the date and time of the response
*
* @throws IOException
*/
synchronized public void writeLog() throws IOException {
char quotation = '"';
long currentTime = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss z");
logFile = new FileWriter(ConfigVars.getLogFile(), true);
PrintWriter lwrite = new PrintWriter(logFile, true);
lwrite.print(socket.getLocalAddress().getHostAddress() + " -"
+ socket.getLocalAddress().getCanonicalHostName() + " "
+ quotation + reqMsg.getMethodName() + " " + reqMsg.getURI()
+ " " + respMsg.getVersion() + quotation + " "
+ respMsg.getStatusCode() + " " + respMsg.getDescription()
+ " ");
if (respMsg.getBody() != null) {
lwrite.print(Long.toString(respMsg.getBody().length()) + " Bytes");
} else {
lwrite.print("0 Bytes");
}
lwrite.println(" " + sdf.format(new Date(currentTime)));
}
/**
* This method is invoked when each thread starts running. It instantiates
* the objects and call the methods that perform the web server's main
* functionalities.
*/
public void run() {
request = new Request(req);
reqMsg = request.parseRequest();
response = new Response(reqMsg, socket);
try {
respMsg = response.buildResponse();
} catch (InternalServerErrorException e) {
System.out.println("Internal Server Error");
respMsg = e.getRespMsg();
}
try {
writeLog();
} catch (IOException e) {
System.out.println(e.getMessage());
}
if (respMsg != null) {
sendResponse();
}
}
/**
* This method sends the response back to the client. It sends the
* response's first line which contains the status code, description and
* HTTP version. Then, it send the headers and the reponse's body (if any).
*/
public void sendResponse() {
try {
BufferedOutputStream out = new BufferedOutputStream(
socket.getOutputStream());
PrintWriter writer = new PrintWriter(out, true);
// writes the response's first line
writer.println(respMsg.getVersion() + " " + respMsg.getStatusCode()
+ " " + respMsg.getDescription());
System.out.println(respMsg.getVersion() + " "
+ respMsg.getStatusCode() + " " + respMsg.getDescription());
// writes the headers
Iterator<Entry<String, String>> it = respMsg.getHeaders().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next();
writer.println(pairs.getKey() + ": " + pairs.getValue());
it.remove();
}
// inserts a blank line if the response is not a cgi result
if (!reqMsg.getCgiScript()) {
writer.println("");
}
// write the response body if it contains one
if (respMsg.getBody() != null) {
byte[] body = new byte[(int) respMsg.getBody().length()];
FileInputStream in = new FileInputStream(respMsg.getBody());
BufferedInputStream bufferedIn = new BufferedInputStream(in);
bufferedIn.read(body, 0, body.length);
System.out.println(tID + " is sending..." + "\n");
out.write(body, 0, body.length);
out.flush();
}
out.close();
socket.close();
} catch (IOException ex) {
System.out.println("Access Failed: " + ConfigVars.getListen()
+ ex.getMessage());
}
}
}
| [
"[email protected]"
] | |
6f2f79f8231024196db2844031dc9348041b7b89 | 010af329f73332ff36476c38f749fd6805086acc | /app/src/main/java/com/ruanjie/donkey/bean/UnReadBean.java | 5673a55dc4e6a8f2a006ffce8f0691a4c4dc2ef4 | [] | no_license | Superingxz/YellowDonkey | f577feed32485b49ccab06660121af6a43a37320 | a47691c815d4f25d1298f2f3b68f17f8961d4ad5 | refs/heads/master | 2023-02-01T10:03:38.011876 | 2020-12-18T09:07:53 | 2020-12-18T09:07:53 | 322,543,723 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 202 | java | package com.ruanjie.donkey.bean;
public class UnReadBean {
private int num;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
| [
"[email protected]"
] | |
037b03cac7ba00cf7d613e7609c9c92338743518 | 2a8f4be775f0e46ef665aa0a8a7b5670c6f02344 | /Chapter8/AudioVideoTest/app/src/main/java/com/lingsh/audiovideotest/PlayAudioActivity.java | 54d159670286895356d94b60ca006937c2929211 | [
"Apache-2.0"
] | permissive | lance-ling/TheFirstCodeAndroid | 72ef4937fe7bd5df6b1fc58db4b63c681087c47d | a815713b17f6bed17d99fc47b801082be4625bc7 | refs/heads/master | 2020-09-29T08:44:54.701978 | 2019-12-31T06:26:16 | 2019-12-31T06:26:16 | 227,002,739 | 0 | 1 | Apache-2.0 | 2019-12-18T01:15:34 | 2019-12-10T01:31:21 | Java | UTF-8 | Java | false | false | 4,339 | java | package com.lingsh.audiovideotest;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.File;
import java.io.IOException;
public class PlayAudioActivity extends AppCompatActivity implements View.OnClickListener {
private static final int REQUEST_CODE_WRITE = 1;
private MediaPlayer mMediaPlayer;
public static void startForActivity(Context context) {
Intent intent = new Intent(context, PlayAudioActivity.class);
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_audio);
Button start = (Button) findViewById(R.id.start);
Button pause = (Button) findViewById(R.id.pause);
Button reset = (Button) findViewById(R.id.reset);
start.setOnClickListener(this);
pause.setOnClickListener(this);
reset.setOnClickListener(this);
// 1. 创建MediaPlayer实例
mMediaPlayer = new MediaPlayer();
// 2. 在onCreate() 进行运行时权限处理 动态申请WRITE_EXTRANAL_STORAGE权限
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE_WRITE);
} else {
initMediaPalyer();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == REQUEST_CODE_WRITE) {
// 3. 判断用户是否授权
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 1. 同意,初始化MediaPlayer对象
Toast.makeText(this, "Thx for you grant", Toast.LENGTH_SHORT).show();
initMediaPalyer();
} else {
// 2. 拒绝,直接退出finish()
Toast.makeText(this, "Sorry, you deny", Toast.LENGTH_SHORT).show();
finish();
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
private void initMediaPalyer() {
// 4. 创建File对象指定音频文件的路径
// getExternalStorageDirectory Android 10.0(Q) 被遗弃
File file = new File(Environment.getExternalStorageDirectory(), "music.mp3");
// 5. 调用MediaPlayer对象的setDataSource()和prepare()方法,为播放前做好准备
try {
mMediaPlayer.setDataSource(file.getPath());
mMediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
// 6. 判断是否正在播放 调用MediaPlayer对象的isPlaying()方法
switch (v.getId()) {
case R.id.start:
// 1. 开始播放 在没有播放时
if (!mMediaPlayer.isPlaying()) {
mMediaPlayer.start();
}
break;
case R.id.pause:
// 2. 暂停播放 在播放时
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
}
break;
case R.id.reset:
// 3. 停止播放并初始化 在播放时
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.reset();
}
break;
default:
break;
}
}
@Override
protected void onDestroy() {
// 7. 在onDestroy() 停止播放并释放MediaPlayer对象
if (mMediaPlayer != null) {
mMediaPlayer.release();
}
super.onDestroy();
}
}
| [
"[email protected]"
] | |
89cfe50dbc4e1420dfb8cfe93035150351e7db8b | 88c80ffa37f0d5bd6b5b626cba99418d90aa6d29 | /springbootbymyself/src/main/java/com/whyme/springboot/_05freemarker/AppConfig.java | 5fb2f0609486c1578306517cc4bfa7cbe4f04089 | [] | no_license | zhiwuwy/SpringBoot | 82f24b30425731aabb9ce9271ec096b9f39b5650 | 1257b498dcfe2e774940508d4c9e34d02ef68d9c | refs/heads/master | 2022-05-30T06:18:45.336659 | 2019-03-02T09:49:51 | 2019-03-02T09:49:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 321 | java | package com.whyme.springboot._05freemarker;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AppConfig {
public static void main(String[] args) {
SpringApplication.run(AppConfig.class, args);
}
}
| [
"[email protected]"
] | |
9f18e181de89903f5a455eaaf8988e0278c32141 | 57b169b2cb830b4d0584fa999ac2986396ae1815 | /src/main/java/com/peiyuzhen/pms/domain/PayType.java | 223a7e2dfcde210d74ffea7c3f9556b40f22414c | [] | no_license | Shadow404/pms | b56cc743ffe274fa5a9a25f0a965a73200193a48 | 1d644f574018b28381e33da45aec312d03dd0fde | refs/heads/master | 2022-07-03T10:32:34.881434 | 2020-04-09T01:59:00 | 2020-04-09T01:59:00 | 253,986,778 | 7 | 0 | null | null | null | null | UTF-8 | Java | false | false | 441 | java | package com.peiyuzhen.pms.domain;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.math.BigDecimal;
@Data
@Entity
@NoArgsConstructor
public class PayType {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer PayTypeId;
@Column(nullable = false,scale = 2,precision = 10)
private BigDecimal unitPrice;//单价
@Column
private String PayTypeName;
}
| [
"[email protected]"
] | |
5b09ccd5e657b91628801d2c77cd07478e5c89ee | 53baed6918217d19466c15045e68104af5977167 | /chargingStation-web-master/chargingStation-web-master-53da1fd1aa027ac37a2b78f649e16b6906eb3332/src/main/java/com/jopool/chargingStation/www/controller/api/ApiOrderController.java | 464831835bf17e36151d6d9448e402aa78923022 | [] | no_license | jinguangyang/chargeStation | 6f0892de382c62446076b20959c66b4a20180311 | 9923d976205cbdb66b3d796f44794707ba66c8b8 | refs/heads/master | 2021-09-25T15:16:06.380827 | 2018-10-23T14:10:54 | 2018-10-23T14:10:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,854 | java | package com.jopool.chargingStation.www.controller.api;
import com.jopool.chargingStation.www.controller.BaseController;
import com.jopool.chargingStation.www.response.OrderListResp;
import com.jopool.chargingStation.www.service.OrderService;
import com.jopool.jweb.entity.BaseParam;
import com.jopool.jweb.entity.PageResult;
import com.jopool.jweb.entity.Result;
import com.jopool.jweb.enums.Code;
import com.jopool.jweb.mybatis.page.Pagination;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Project : chargingStation
* @Package Name : com.jopool.chargingStation.www.controller.api
* @Author : soupcat
* @Creation Date : 2017年08月25日 下午2:38
*/
@RestController
@RequestMapping("/api/order")
public class ApiOrderController extends BaseController {
@Resource
private OrderService orderService;
/**
* HYD0101充电记录列表
* http://wiki.jopool.net/pages/viewpage.action?pageId=7864564
*
* @param baseParam
* @return
*/
@RequestMapping("getOrders.htm")
public Result getOrders(BaseParam baseParam, String stationId, String status, Pagination page) {
List<OrderListResp> resps = orderService.getOrders(baseParam.getPassportId(), stationId, status, page.page());
return new PageResult(resps, page.getPaginator());
}
/**
* HYD0102充电记录详情
* http://wiki.jopool.net/pages/viewpage.action?pageId=7864566
*
* @param orderId
* @return
*/
@RequestMapping("getOrderDetail.htm")
public Result getOrderDetail(String orderId) {
validateParam(orderId);
OrderListResp resp = orderService.getOrderDetail(orderId);
return new Result(Code.SUCCESS, resp);
}
}
| [
"[email protected]"
] | |
a15eeabd2b7a7288578ff9db371432d23d3684b1 | 18b8174aeaa1a5ac324a3e32bed29b23b5a085c6 | /modules/flowable5-engine/src/main/java/org/activiti/engine/impl/juel/Bindings.java | 4f1c987bc90df954c4f2f3beb168e5dbae4853ad | [
"Apache-2.0"
] | permissive | vineetasharma/Flowable-Engine-6.3.1 | a7d3f39d1e68109bddc69b4c96af6e4200cd6144 | 442a107bcf4c6165640987a2717a996dbab00364 | refs/heads/master | 2020-04-09T11:31:42.359414 | 2018-12-04T08:55:42 | 2018-12-04T08:55:42 | 160,313,282 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,084 | java | /*
* Based on JUEL 2.2.1 code, 2006-2009 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.juel;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.activiti.engine.impl.javax.el.ELException;
import org.activiti.engine.impl.javax.el.ValueExpression;
/**
* Bindings, usually created by a {@link org.activiti.engine.impl.juel.Tree}.
*
* @author Christoph Beck
*/
public class Bindings implements TypeConverter {
private static final long serialVersionUID = 1L;
private static final Method[] NO_FUNCTIONS = new Method[0];
private static final ValueExpression[] NO_VARIABLES = new ValueExpression[0];
/**
* Wrap a {@link Method} for serialization.
*/
private static class MethodWrapper implements Serializable {
private static final long serialVersionUID = 1L;
private transient Method method;
private MethodWrapper(Method method) {
this.method = method;
}
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException {
out.defaultWriteObject();
out.writeObject(method.getDeclaringClass());
out.writeObject(method.getName());
out.writeObject(method.getParameterTypes());
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
Class<?> type = (Class<?>) in.readObject();
String name = (String) in.readObject();
Class<?>[] args = (Class<?>[]) in.readObject();
try {
method = type.getDeclaredMethod(name, args);
} catch (NoSuchMethodException e) {
throw new IOException(e.getMessage());
}
}
}
private transient Method[] functions;
private final ValueExpression[] variables;
private final TypeConverter converter;
/**
* Constructor.
*/
public Bindings(Method[] functions, ValueExpression[] variables) {
this(functions, variables, TypeConverter.DEFAULT);
}
/**
* Constructor.
*/
public Bindings(Method[] functions, ValueExpression[] variables, TypeConverter converter) {
super();
this.functions = functions == null || functions.length == 0 ? NO_FUNCTIONS : functions;
this.variables = variables == null || variables.length == 0 ? NO_VARIABLES : variables;
this.converter = converter == null ? TypeConverter.DEFAULT : converter;
}
/**
* Get function by index.
*
* @param index
* function index
* @return method
*/
public Method getFunction(int index) {
return functions[index];
}
/**
* Test if given index is bound to a function. This method performs an index check.
*
* @param index
* identifier index
* @return <code>true</code> if the given index is bound to a function
*/
public boolean isFunctionBound(int index) {
return index >= 0 && index < functions.length;
}
/**
* Get variable by index.
*
* @param index
* identifier index
* @return value expression
*/
public ValueExpression getVariable(int index) {
return variables[index];
}
/**
* Test if given index is bound to a variable. This method performs an index check.
*
* @param index
* identifier index
* @return <code>true</code> if the given index is bound to a variable
*/
public boolean isVariableBound(int index) {
return index >= 0 && index < variables.length && variables[index] != null;
}
/**
* Apply type conversion.
*
* @param value
* value to convert
* @param type
* target type
* @return converted value
* @throws ELException
*/
@Override
public <T> T convert(Object value, Class<T> type) {
return converter.convert(value, type);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Bindings) {
Bindings other = (Bindings) obj;
return Arrays.equals(functions, other.functions)
&& Arrays.equals(variables, other.variables)
&& converter.equals(other.converter);
}
return false;
}
@Override
public int hashCode() {
return Arrays.hashCode(functions) ^ Arrays.hashCode(variables) ^ converter.hashCode();
}
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException {
out.defaultWriteObject();
MethodWrapper[] wrappers = new MethodWrapper[functions.length];
for (int i = 0; i < wrappers.length; i++) {
wrappers[i] = new MethodWrapper(functions[i]);
}
out.writeObject(wrappers);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
MethodWrapper[] wrappers = (MethodWrapper[]) in.readObject();
if (wrappers.length == 0) {
functions = NO_FUNCTIONS;
} else {
functions = new Method[wrappers.length];
for (int i = 0; i < functions.length; i++) {
functions[i] = wrappers[i].method;
}
}
}
}
| [
"[email protected]"
] | |
ff981bb889c3957385c8362fb3456382dd2469ff | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/23/23_d0104b47f5812a2d8cf21de7c68f32a67f7b0637/Localizations/23_d0104b47f5812a2d8cf21de7c68f32a67f7b0637_Localizations_s.java | 7b634b24e9266d1384a069042569714bc7fdeca6 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 2,924 | java | package net.mcft.copy.betterstorage.misc;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class Localizations {
private Localizations() { }
public static void load() {
Pattern pattern = Pattern.compile(".*(assets/" + Constants.modId + "/lang/(.+)\\.(.+))");
for (String file : getResources(pattern)) {
Matcher matcher = pattern.matcher(file);
matcher.find();
String resource = "/" + matcher.group(1);
String lang = matcher.group(2);
boolean isXML = matcher.group(3).equalsIgnoreCase("xml");
LanguageRegistry.instance().loadLocalization(resource, lang, isXML);
}
}
private static Collection<String> getResources(Pattern pattern) {
ArrayList<String> retval = new ArrayList<String>();
String classPath = System.getProperty("java.class.path", ".");
String[] classPathElements = classPath.split(File.pathSeparator);
for (String element : classPathElements)
retval.addAll(getResources(element, pattern));
return retval;
}
private static Collection<String> getResources(String element, Pattern pattern) {
ArrayList<String> retval = new ArrayList<String>();
File file = new File(element);
if (file.isDirectory())
retval.addAll(getResourcesFromDirectory(file, pattern));
else retval.addAll(getResourcesFromJarFile(file, pattern));
return retval;
}
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern) {
ArrayList<String> retval = new ArrayList<String>();
ZipFile zf;
try { zf = new ZipFile(file); }
catch (ZipException e) { throw new Error(e); }
catch (IOException e) { throw new Error(e); }
Enumeration<? extends ZipEntry> entries = zf.entries();
while (entries.hasMoreElements()) {
ZipEntry ze = entries.nextElement();
String fileName = ze.getName();
boolean accept = pattern.matcher(fileName).matches();
if (accept) retval.add(fileName);
}
try { zf.close(); }
catch (IOException e) { throw new Error(e); }
return retval;
}
private static Collection<String> getResourcesFromDirectory(File directory, Pattern pattern) {
ArrayList<String> retval = new ArrayList<String>();
File[] fileList = directory.listFiles();
for (File file : fileList) {
if (file.isDirectory()) {
retval.addAll(getResourcesFromDirectory(file, pattern));
} else try {
String fileName = file.getCanonicalPath().replace('\\', '/');
boolean accept = pattern.matcher(fileName).matches();
if (accept) retval.add(fileName);
} catch (final IOException e) { throw new Error(e); }
}
return retval;
}
}
| [
"[email protected]"
] | |
51a710dfb56b4145f90bc30751266641b3318fc3 | 2be50b6df19578b547f405530ea58671b2c7de3b | /app/src/main/java/com/cstz/cunguan/activity/InvestRecord.java | 4aa3deacbf07393c48a0eea77cc3383b5feb3701 | [] | no_license | androiddeveloper007/zzp-wx-demo | 0e54c4f3f66b5ad366184b4d965fc376840bd853 | 53fffaefb05636c08d32003ff00d07dd1851b008 | refs/heads/master | 2021-09-06T01:14:35.046538 | 2018-02-01T07:20:49 | 2018-02-01T07:20:49 | 119,797,787 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 34,034 | java | package com.cstz.cunguan.activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.Window;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.cstz.adapter.MyPagerAdapterCg;
import com.cstz.common.App;
import com.cstz.common.MyActivity;
import com.cstz.common.SharedPreferencesData;
import com.cstz.common.view.MySliderCg;
import com.cstz.cstz_android.R;
import com.cstz.cunguan.fragment.ViewPagerItemView;
import com.cstz.tab.MainActivity;
import com.lzy.widget.HeaderViewPager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xutils.common.util.DensityUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import library.widget.xlistview.XListView;
/**
* 投资记录
*/
public class InvestRecord extends MyActivity implements OnClickListener {
@BindView(R.id.title_tv)
TextView titleTv;
@BindView(R.id.title_back)
ImageView titleBack;
@BindView(R.id.iv_navigation_right)
ImageView ivNavigationRight;
MySliderCg slider_invest_record;
ViewPager pager_invest_record;
List<ViewPagerItemView> viewlist;
ViewPagerItemView page1, page2, page3;
private XListView lv0, lv1, lv2;
private Context context;
private List<Map<String, String>> listGet0, listGetTotal0, listGet1, listGetTotal1, listGet2, listGetTotal2;
private MyAdapter adapter, adapter1, adapter2;
private int pageNum = 1, pageNum1 = 1, pageNum2 = 1;
private final static int pageSize = 15;
private int status = 0;//0:全部,1:收益中,-1:已兑付
private int mScreenHeight; // 屏幕高度
private HeaderViewPager scrollableLayout;
private int currentYTemp = 0;
private String uCenter = "1";//1:原账户 2:存管账户 3:借款人
private TextView tvInvesting, tvForPay, tvHasRepay;
boolean isPage1First = true, isPage2First = true;
private ViewStub stub0;
private ViewStub stub1;
private SharedPreferencesData sp;
private String oldAccountCloseDay;
private Handler mHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.aa_activity_invest_record);
setTransparentStatusBar(this,true);
ButterKnife.bind(this);
titleTv.setText("投资记录");
titleBack.setVisibility(View.VISIBLE);
ivNavigationRight.setImageResource(R.mipmap.invest_record_old);
context = this;
sp = new SharedPreferencesData(context);
mHandler = new Handler();
mScreenHeight = DensityUtil.getScreenHeight();
if (getIntent() != null && getIntent().hasExtra("uCenter"))
uCenter = getIntent().getStringExtra("uCenter");
if (getIntent() != null && getIntent().hasExtra("oldAccountCloseDay"))
oldAccountCloseDay = getIntent().getStringExtra("oldAccountCloseDay");
if (TextUtils.equals("-1", oldAccountCloseDay) && !TextUtils.equals("1", App.regAsDeposit))
ivNavigationRight.setVisibility(View.VISIBLE);
else
ivNavigationRight.setVisibility(View.GONE);
loadData(0, pageNum);//初始化数据
initViewStub(false);
initViewStub(true);
}
private void initViewStub(boolean noData) {
if (noData) {
stub0 = (ViewStub) findViewById(R.id.view_invest_record0);
stub0.inflate();
LinearLayout ll_btn_invest = (LinearLayout) findViewById(R.id.ll_btn_invest);
ll_btn_invest.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, MainActivity.class);
intent.putExtra("product", "");
startActivity(intent);
finish();
}
});
} else {
stub1 = (ViewStub) findViewById(R.id.view_invest_record1);
stub1.inflate();
slider_invest_record = (MySliderCg) findViewById(R.id.slider_invest_record);
pager_invest_record = (ViewPager) findViewById(R.id.pager_invest_record);
scrollableLayout = (HeaderViewPager) findViewById(R.id.header_viewPager);
tvInvesting = (TextView) findViewById(R.id.tv_invest_record1);
tvForPay = (TextView) findViewById(R.id.tv_invest_record4);
tvHasRepay = (TextView) findViewById(R.id.tv_invest_record5);
initView();
}
}
private void loadData(int status, int index) {
Map<String, Object> map = new HashMap<>();
map.put("status", status);
map.put("pageNum", index);
map.put("pageSize", pageSize);
map.put("deposit", TextUtils.equals("1", uCenter) ? "0" : "1");
map.put("token", sp.getValue("token"));
postData(map, "/user/investRecord", null, App.PostType.LOAD);
}
private void initView() {
slider_invest_record.setOnClickSlider(new MySliderCg.OnClickSlider() {
@Override
public void getIndex(int index) {
pager_invest_record.setCurrentItem(index);
}
});
viewlist = new ArrayList<>();
page1 = (ViewPagerItemView) View.inflate(this, R.layout.funddetail_tab1, null);
page1.setScrollableView((XListView) page1.findViewById(R.id.lv_funddetail_tab0));
page2 = (ViewPagerItemView) View.inflate(this, R.layout.funddetail_tab1, null);
page2.setScrollableView((XListView) page2.findViewById(R.id.lv_funddetail_tab0));
page3 = (ViewPagerItemView) View.inflate(this, R.layout.funddetail_tab1, null);
page3.setScrollableView((XListView) page3.findViewById(R.id.lv_funddetail_tab0));
viewlist.add(page1);
viewlist.add(page2);
viewlist.add(page3);
initPage0();
initPage1();
initPage2();
pager_invest_record.setAdapter(new MyPagerAdapterCg(viewlist));
scrollableLayout.setCurrentScrollableContainer(page1);
pager_invest_record.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
@Override
public void onPageSelected(int position) {
slider_invest_record.setSelectIndex(position);
scrollableLayout.setCurrentScrollableContainer(viewlist.get(position));
if (position == 0) {
status = 0;
} else if (position == 1) {
status = 1;
if (isPage1First) {
isPage1First = false;
loadData(status, pageNum1);
}
} else if (position == 2) {
status = -1;
if (isPage2First) {
isPage2First = false;
loadData(status, pageNum2);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {}
});
scrollableLayout.setOnScrollListener(new HeaderViewPager.OnScrollListener() {
@Override
public void onScroll(int currentY, int maxY) {
if (currentY == 0) {
lv0.setPullRefreshEnable(true);
lv1.setPullRefreshEnable(true);
lv2.setPullRefreshEnable(true);
} else {
showLog("currentY:"+currentY+" currentYTemp:"+currentYTemp);
if (!lv0.getIsPullRefreshing() && currentY < currentYTemp)
lv0.setPullRefreshEnable(false);
if (!lv1.getIsPullRefreshing() && currentY < currentYTemp)
lv1.setPullRefreshEnable(false);
if (!lv2.getIsPullRefreshing() && currentY < currentYTemp)
lv2.setPullRefreshEnable(false);
}
currentYTemp = currentY;
}
});
pager_invest_record.setCurrentItem(0);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (scrollableLayout != null) {
scrollableLayout.setTopOffset(0);
scrollableLayout.setCurrentScrollableContainer(viewlist.get(pager_invest_record.getCurrentItem()));
}
}
private void initPage0() {
if (lv0 == null) {
lv0 = (XListView) page1.findViewById(R.id.lv_funddetail_tab0);
lv0.setPullRefreshEnable(true);
lv0.setPullLoadEnable(true);
lv0.setAutoLoadEnable(true);
lv0.setXListViewListener(new XListView.IXListViewListener() {
@Override
public void onRefresh() {
lv0.setPullLoadEnable(false);
lv0.setAutoLoadEnable(true);
pageNum = 1;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
listGet0.clear();
listGetTotal0.clear();
loadData(0, pageNum);
}
}, 300);
}
@Override
public void onLoadMore() {
pageNum++;
loadData(0, pageNum);
}
});
listGetTotal0 = new ArrayList<>();
listGet0 = new ArrayList<>();
Map<String, String> map = new HashMap<>();
listGet0.add(map);
adapter = new MyAdapter(listGet0, 0);
lv0.setAdapter(adapter);
int height = mScreenHeight - getResources().getDimensionPixelOffset(R.dimen.dimen_340);
adapter.getNoDataEntity(height);
}
}
private void initPage1() {
if (lv1 == null) {
lv1 = (XListView) page2.findViewById(R.id.lv_funddetail_tab0);
lv1.setPullRefreshEnable(true);
lv1.setPullLoadEnable(false);
lv1.setAutoLoadEnable(false);
lv1.setXListViewListener(new XListView.IXListViewListener() {
@Override
public void onRefresh() {
lv1.setPullLoadEnable(false);
lv1.setAutoLoadEnable(true);
pageNum1 = 1;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
listGet1.clear();
listGetTotal1.clear();
loadData(1, pageNum1);
}
}, 300);
}
@Override
public void onLoadMore() {
pageNum1++;
loadData(1, pageNum1);
}
});
listGetTotal1 = new ArrayList<>();
Map<String, String> map = new HashMap<>();
listGet1 = new ArrayList<>();
listGet1.add(map);
adapter1 = new MyAdapter(listGet1, 1);
lv1.setAdapter(adapter1);
int height = mScreenHeight - getResources().getDimensionPixelOffset(R.dimen.dimen_340);
adapter1.getNoDataEntity(height);
}
}
private void initPage2() {
if (lv2 == null) {
lv2 = (XListView) page3.findViewById(R.id.lv_funddetail_tab0);
lv2.setPullRefreshEnable(true);
lv2.setPullLoadEnable(false);
lv2.setAutoLoadEnable(false);
lv2.setXListViewListener(new XListView.IXListViewListener() {
@Override
public void onRefresh() {
lv2.setPullLoadEnable(false);
lv2.setAutoLoadEnable(true);
pageNum2 = 1;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
listGet2.clear();
listGetTotal2.clear();
loadData(-1, pageNum2);
}
}, 300);
}
@Override
public void onLoadMore() {
pageNum2++;
loadData(-1, pageNum2);
}
});
listGetTotal2 = new ArrayList<>();
Map<String, String> map = new HashMap<>();
listGet2 = new ArrayList<>();
listGet2.add(map);
adapter2 = new MyAdapter(listGet2, 2);
lv2.setAdapter(adapter2);
int height = mScreenHeight - getResources().getDimensionPixelOffset(R.dimen.dimen_340);
adapter2.getNoDataEntity(height);
}
}
@Override
public void requestSuccess(JSONObject object, App.PostType postType) {
super.requestSuccess(object, postType);
if (object != null) {
try {
JSONObject data = object.getJSONObject("data");
JSONObject data2 = object.getJSONObject("data2");
JSONArray array;
if (data.has("page") && data.getJSONArray("page") != null) {
array = data.getJSONArray("page");
if (array != null) {
int length = array.length();
switch (status) {
case 0:
if (data2 != null && status == 0) {
if (data2.has("forPayInterest"))
tvForPay.setText(data2.getString("forPayInterest"));
if (data2.has("forPayPrincipal"))
tvInvesting.setText(data2.getString("forPayPrincipal"));
if (data2.has("hasRePayInterest"))
tvHasRepay.setText(data2.getString("hasRePayInterest"));
}
if (length == 0 && pageNum == 1) {
stub0.setVisibility(View.VISIBLE);
stub1.setVisibility(View.GONE);
return;
} else if(length == 0 && pageNum > 1){
lv0.setNoMoreData();
} else {
stub0.setVisibility(View.GONE);
stub1.setVisibility(View.VISIBLE);
}
listGet0 = new ArrayList<>(array.length());
for (int i = 0; i < array.length(); i++) {
JSONObject product = array.getJSONObject(i);
Map<String, String> map = new HashMap<>();
map.put("productTitle", product.getString("productTitle"));
map.put("repayTime", product.getString("repayTime"));
map.put("interest", product.getString("interest"));
map.put("pDeadline", product.getString("pDeadline"));
map.put("investAmount", product.getString("investAmount"));
map.put("investTime", product.getString("investTime"));
map.put("annualRate", product.getString("annualRate"));
map.put("award", product.getString("award"));
map.put("deadline", product.getString("deadline"));
map.put("status", product.getString("status"));//状态 2:投资中,3 已募满 4:兑付中 5:已完成
if(product.has("keybd_code"))
map.put("keybd_code", product.getString("keybd_code"));
if(product.has("price_amount"))
map.put("price_amount", product.getString("price_amount"));
if(product.has("keybd_state"))
map.put("keybd_state", product.getString("keybd_state"));
listGet0.add(map);
}
if (length < pageSize){
// lv0.setPullLoadEnable(false);
lv0.setNoMoreData();
}else{
lv0.setPullLoadEnable(true);
}
if (adapter.isNoData) {
adapter = new MyAdapter(listGet0, 0);
lv0.setAdapter(adapter);
listGetTotal0.addAll(listGet0);
} else {
listGetTotal0.addAll(listGet0);
adapter.update(listGetTotal0);
}
break;
case 1:
if (length == 0) {
lv1.setPullLoadEnable(false);
return;
}
listGet1 = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
JSONObject product = array.getJSONObject(i);
Map<String, String> map = new HashMap<>();
map.put("productTitle", product.getString("productTitle"));
map.put("repayTime", product.getString("repayTime"));
map.put("interest", product.getString("interest"));
map.put("pDeadline", product.getString("pDeadline"));
map.put("investAmount", product.getString("investAmount"));
map.put("investTime", product.getString("investTime"));
map.put("annualRate", product.getString("annualRate"));
map.put("award", product.getString("award"));
map.put("deadline", product.getString("deadline"));
map.put("status", product.getString("status"));
if(product.has("keybd_code"))
map.put("keybd_code", product.getString("keybd_code"));
if(product.has("price_amount"))
map.put("price_amount", product.getString("price_amount"));
if(product.has("keybd_state"))
map.put("keybd_state", product.getString("keybd_state"));
listGet1.add(map);
}
if (length < pageSize) {
// lv1.setPullLoadEnable(false);
lv1.setNoMoreData();
} else {
lv1.setPullLoadEnable(true);
}
if (adapter1.isNoData) {
adapter1 = new MyAdapter(listGet1, 1);
lv1.setAdapter(adapter1);
listGetTotal1.addAll(listGet1);
} else {
listGetTotal1.addAll(listGet1);
adapter1.update(listGetTotal1);
}
break;
case -1:
if (length == 0) {
lv2.setPullLoadEnable(false);
return;
}
listGet2 = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
JSONObject product = array.getJSONObject(i);
Map<String, String> map = new HashMap<>();
map.put("productTitle", product.getString("productTitle"));
map.put("repayTime", product.getString("repayTime"));
map.put("interest", product.getString("interest"));
map.put("pDeadline", product.getString("pDeadline"));
map.put("investAmount", product.getString("investAmount"));
map.put("investTime", product.getString("investTime"));
map.put("annualRate", product.getString("annualRate"));
map.put("award", product.getString("award"));
map.put("deadline", product.getString("deadline"));
map.put("status", product.getString("status"));
if(product.has("keybd_code"))
map.put("keybd_code", product.getString("keybd_code"));
if(product.has("price_amount"))
map.put("price_amount", product.getString("price_amount"));
if(product.has("keybd_state"))
map.put("keybd_state", product.getString("keybd_state"));
listGet2.add(map);
}
if (length < pageSize) {
lv2.setPullLoadEnable(false);
lv2.setNoMoreData();
} else {
lv2.setPullLoadEnable(true);
}
if (adapter2.isNoData) {
adapter2 = new MyAdapter(listGet2, 2);
lv2.setAdapter(adapter2);
listGetTotal2.addAll(listGet2);
} else {
listGetTotal2.addAll(listGet2);
adapter2.update(listGetTotal2);
}
break;
}
} else {
switch (status) {
case 0:
lv0.setPullLoadEnable(false);
break;
case 1:
lv1.setPullLoadEnable(false);
break;
case -1:
lv2.setPullLoadEnable(false);
break;
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
public void requestFinished() {
super.requestFinished();
switch (status) {
case 0:
lv0.stopRefresh();
lv0.stopLoadMore();
break;
case 1:
lv1.stopRefresh();
lv1.stopLoadMore();
break;
case -1:
lv2.stopRefresh();
lv2.stopLoadMore();
break;
}
}
@Override
public void requestFail(String msg, JSONObject obj, App.PostType postType) {
super.requestFail(msg, obj, postType);
}
@OnClick({R.id.title_back, R.id.iv_navigation_right})
public void onClick(View view) {
switch (view.getId()) {
case R.id.title_back:
finish();
break;
case R.id.iv_navigation_right:
startActivity(new Intent(this, InvestRecordOld.class));
break;
default:break;
}
}
class MyAdapter extends BaseAdapter {
private List<Map<String, String>> list = new ArrayList<>();
private boolean isNoData;
private int height;
private int type;
protected LayoutInflater mInflater;
public MyAdapter(List<Map<String, String>> listget, int type) {
this.list = listget;
this.type = type;
mInflater = LayoutInflater.from(context);
}
public void getNoDataEntity(int height) {
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> entity = new HashMap<>();
this.isNoData = true;
this.height = height;
list.add(entity);
update(list);
}
public void update(List<Map<String, String>> list) {
this.list = list;
notifyDataSetChanged();
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (isNoData) {
convertView = mInflater.inflate(R.layout.item_no_data_layout, null);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
RelativeLayout rootView = ButterKnife.findById(convertView, R.id.rl_root_view);
// ImageView iv = ButterKnife.findById(convertView, R.id.iv_placeholder_image);
// iv.setImageResource(R.mipmap.invest_record_nodata);
TextView tv = ButterKnife.findById(convertView, R.id.tv_nodata);
switch (type) {
case 0:
tv.setText("暂无数据");
break;
case 1:
tv.setText("暂无收益中数据");
break;
case 2:
tv.setText("暂无已兑付数据");
break;
}
rootView.setLayoutParams(params);
return convertView;
}
Holder holder;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.lv_item_invest_record, parent, false);
holder = new Holder(convertView);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
switch (list.get(position).get("pDeadline")) {
case "33":
holder.tvInvestRecordTitle.setText("五星月享(33天)");
break;
case "93":
holder.tvInvestRecordTitle.setText("五星季享(93天)");
break;
case "183":
holder.tvInvestRecordTitle.setText("五星双季享(183天)");
break;
default:
break;
}
String title = "";
String subTitle = "";
String title0 = list.get(position).get("productTitle");
String[] arr = title0.split("\\s+");
if (arr != null && arr.length > 1) {
title = arr[0];
for (int i = 0; i < arr.length; i++) {
if (i > 0) {
subTitle += arr[i];
}
}
holder.tvInvestRecordTitle.setText(title);
holder.tvInvestRecordTitleSub.setText(subTitle);
} else {
holder.tvInvestRecordTitleSub.setText(title0);
}
holder.tvInvestRecordMoney.setText("投资金额 (元):" + list.get(position).get("investAmount"));
holder.tvInvestRecordTime.setText("投资时间:" + list.get(position).get("investTime"));
holder.tvInvestRecordEarning.setText("预计收益 (元):" + list.get(position).get("interest"));
holder.tvInvestRecordEndTime.setText("兑付日期:" + list.get(position).get("repayTime"));
holder.tvInvestRecordDays.setText("投资" + list.get(position).get("deadline") + "天");
double annualRate = Double.parseDouble(list.get(position).get("annualRate"));
double award = Double.parseDouble(list.get(position).get("award"));
double realRate = annualRate + award;
holder.tvInvestRecordStyle.setText("年化" + realRate + "%");
switch (list.get(position).get("status")) {
case "2":
holder.tvInvestRecordStatus.setText("收益中");
holder.tvInvestRecordStatus.setBackgroundResource(R.drawable.tv_status_bg_cg);
break;
case "3":
holder.tvInvestRecordStatus.setText("收益中");
holder.tvInvestRecordStatus.setBackgroundResource(R.drawable.tv_status_bg_cg);
break;
case "4":
holder.tvInvestRecordStatus.setText("收益中");
holder.tvInvestRecordStatus.setBackgroundResource(R.drawable.tv_status_bg_cg);
break;
case "5":
holder.tvInvestRecordStatus.setText("已兑付");
holder.tvInvestRecordStatus.setBackgroundResource(R.drawable.tv_status_bg_cg1);
break;
default:
break;
}
if(list.get(position).get("keybd_code")==null || TextUtils.isEmpty(list.get(position).get("keybd_code").toString())){//没有Kcode字段,就隐藏那块布局
holder.rl_keyboard_invest_record.setVisibility(View.GONE);
}else{
holder.rl_keyboard_invest_record.setVisibility(View.VISIBLE);
holder.tv_code_used.setText(list.get(position).get("keybd_code").toString());
holder.tv_code_fanxian.setText("+"+list.get(position).get("price_amount").toString());
String keybd_state = list.get(position).get("keybd_state").toString();
switch (keybd_state){
case "2":holder.tv_code_result_tip.setText("项目兑付时返现");break;
case "3":holder.tv_code_result_tip.setText("已返现");break;
case "4":holder.tv_code_result_tip.setText("键盘已退货,K码已失效");break;
default:break;
}
}
return convertView;
}
@Override
public boolean isEnabled(int position) {
return false;
}
class Holder {
@BindView(R.id.tv_invest_record_title)
TextView tvInvestRecordTitle;
@BindView(R.id.tv_invest_record_title_sub)
TextView tvInvestRecordTitleSub;
@BindView(R.id.tv_invest_record_style)
TextView tvInvestRecordStyle;
@BindView(R.id.tv_invest_record_days)
TextView tvInvestRecordDays;
@BindView(R.id.tv_invest_record_money)
TextView tvInvestRecordMoney;
@BindView(R.id.tv_invest_record_time)
TextView tvInvestRecordTime;
@BindView(R.id.tv_invest_record_earning)
TextView tvInvestRecordEarning;
@BindView(R.id.tv_invest_record_endTime)
TextView tvInvestRecordEndTime;
@BindView(R.id.tv_invest_record_status)
TextView tvInvestRecordStatus;
@BindView(R.id.tv_code_used)
TextView tv_code_used; //已使用K码
@BindView(R.id.tv_code_fanxian)
TextView tv_code_fanxian; //返现
@BindView(R.id.tv_code_result_tip)
TextView tv_code_result_tip; //结果提示
@BindView(R.id.rl_keyboard_invest_record)
RelativeLayout rl_keyboard_invest_record; //布局块
Holder(View view) {
ButterKnife.bind(this, view);
}
}
}
@Override
protected void onDestroy() {
sp=null;
mHandler=null;
super.onDestroy();
}
} | [
"[email protected]"
] | |
079bda303edb50c23d265a4a9b46edf6b3704d9d | 366aec26c921e77c211905b93e1f04743199684e | /src/com/igomall/dao/ConsultationDao.java | e173e618b9a3d355ef9b50e709115fc2a35a6931 | [] | no_license | cloudgoon/mall-1 | 492dbdb6b8b71f40cad66e325c5e55218e11db54 | 3340c8cc16418ee8f986c8f181f634e3abcf90ab | refs/heads/master | 2021-05-16T19:59:24.613232 | 2019-10-12T07:52:27 | 2019-10-12T07:52:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,589 | java |
package com.igomall.dao;
import java.util.List;
import com.igomall.Filter;
import com.igomall.Order;
import com.igomall.Page;
import com.igomall.Pageable;
import com.igomall.entity.Consultation;
import com.igomall.entity.Member;
import com.igomall.entity.Product;
import com.igomall.entity.Store;
/**
* Dao - 咨询
*
* @author IGOMALL Team
* @version 1.0
*/
public interface ConsultationDao extends BaseDao<Consultation, Long> {
/**
* 查找咨询
*
* @param member
* 会员
* @param product
* 商品
* @param isShow
* 是否显示
* @param count
* 数量
* @param filters
* 筛选
* @param orders
* 排序
* @return 咨询,不包含咨询回复
*/
List<Consultation> findList(Member member, Product product, Boolean isShow, Integer count, List<Filter> filters, List<Order> orders);
/**
* 查找咨询分页
*
* @param member
* 会员
* @param product
* 商品
* @param store
* 店铺
* @param isShow
* 是否显示
* @param pageable
* 分页信息
* @return 咨询分页,不包含咨询回复
*/
Page<Consultation> findPage(Member member, Product product, Store store, Boolean isShow, Pageable pageable);
/**
* 查找咨询数量
*
* @param member
* 会员
* @param product
* 商品
* @param isShow
* 是否显示
* @return 咨询数量,不包含咨询回复
*/
Long count(Member member, Product product, Boolean isShow);
} | [
"[email protected]"
] | |
aeac1b2e007aa8f5b538be3ef463388f2d2cb1a9 | 0ad86348124cd9724444972b3668b5f1b86aeb83 | /src/org/usfirst/frc/team5137/robot/commands/UnrollWinch.java | f6844c652f112e99bfe16a9f1a8670aa5ab36469 | [] | no_license | trevormcclellan/2016JavaCode | 52a70b9280049f2156cee0700649cf4329671814 | d66669943985c98597400be0cacff4f6c751e3ab | refs/heads/master | 2021-01-23T20:45:53.161771 | 2017-02-04T23:25:37 | 2017-02-04T23:25:37 | 49,752,355 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,004 | java | package org.usfirst.frc.team5137.robot.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc.team5137.robot.*;
/**
*
*/
public class UnrollWinch extends Command {
public UnrollWinch() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
requires (Robot.winch);
}
// Called just before this Command runs the first time
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
Robot.winch.unroll();
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
protected void end() {
Robot.winch.stop();
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}
}
| [
"[email protected]"
] | |
df001d30f6e5fcc1939d2112a019e52ec57c51b3 | 982c6b06d72d646c809d5a12866359f720305067 | /subprojects/platform-native/src/main/java/dev/nokee/platform/nativebase/internal/dependencies/ModelBackedNativeComponentDependencies.java | 601a7fe5a7b98071f54a53159e6de9701afcbeff | [
"Apache-2.0"
] | permissive | nokeedev/gradle-native | e46709a904e20183ca09ff64b92d222d3c888df2 | 6e6ee42cefa69d81fd026b2cfcb7e710dd62d569 | refs/heads/master | 2023-05-30T02:27:59.371101 | 2023-05-18T15:36:49 | 2023-05-23T14:43:18 | 243,841,556 | 52 | 9 | Apache-2.0 | 2023-05-23T14:58:33 | 2020-02-28T19:42:28 | Java | UTF-8 | Java | false | false | 2,231 | java | /*
* Copyright 2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.nokee.platform.nativebase.internal.dependencies;
import dev.nokee.model.internal.core.GradlePropertyComponent;
import dev.nokee.model.internal.core.ModelNode;
import dev.nokee.model.internal.core.ModelNodeAware;
import dev.nokee.model.internal.core.ModelNodeContext;
import dev.nokee.model.internal.core.ModelProperties;
import dev.nokee.platform.base.DependencyBucket;
import dev.nokee.platform.nativebase.NativeComponentDependencies;
import org.gradle.api.provider.MapProperty;
public final class ModelBackedNativeComponentDependencies implements NativeComponentDependencies, ModelNodeAware {
private final ModelNode node = ModelNodeContext.getCurrentModelNode();
@Override
@SuppressWarnings("unchecked")
public DependencyBucket getCompileOnly() {
return ((MapProperty<String, DependencyBucket>) node.get(GradlePropertyComponent.class).get()).getting("compileOnly").get();
}
@Override
@SuppressWarnings("unchecked")
public DependencyBucket getImplementation() {
return ((MapProperty<String, DependencyBucket>) node.get(GradlePropertyComponent.class).get()).getting("implementation").get();
}
@Override
@SuppressWarnings("unchecked")
public DependencyBucket getRuntimeOnly() {
return ((MapProperty<String, DependencyBucket>) node.get(GradlePropertyComponent.class).get()).getting("runtimeOnly").get();
}
@Override
@SuppressWarnings("unchecked")
public DependencyBucket getLinkOnly() {
return ((MapProperty<String, DependencyBucket>) node.get(GradlePropertyComponent.class).get()).getting("linkOnly").get();
}
@Override
public ModelNode getNode() {
return node;
}
}
| [
"[email protected]"
] | |
f488d636ceb07ab13d0eb6f9d56f02159a7f01e3 | 5a2553c91e319f5a9eb8216fcaf58ce99603cf68 | /src/main/java/com/aktar/alumni/model/Skill.java | 5da017f6d37e32addabd932936cb1841c80ce23d | [] | no_license | aktarulahsan/alumni-association | 086773a72c5ba2875bb223d503f3433eef7fcd19 | d6626b6543c2d9bdaeb29ef7bba909a854b708f8 | refs/heads/master | 2023-02-26T08:16:45.947055 | 2023-02-14T05:32:20 | 2023-02-14T05:32:20 | 169,536,106 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,044 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.aktar.alumni.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
/**
*
* @author C8
*/
@Entity
public class Skill {
@Id
@GeneratedValue
private int skillid;
@Column
private String emailid;
@Column
private String skill;
public int getSkillid() {
return skillid;
}
public void setSkillid(int skillid) {
this.skillid = skillid;
}
public String getEmailid() {
return emailid;
}
public void setEmailid(String emailid) {
this.emailid = emailid;
}
public String getSkill() {
return skill;
}
public void setSkill(String skill) {
this.skill = skill;
}
}
| [
"aktar@aktar-PC"
] | aktar@aktar-PC |
e0efa1d7e57db27d42db84f9ebcf6fe27af79537 | f2f70d728c5ab120da397d067d82b9631d5d2853 | /IJ/JavaRushHomeWork/src/com/javarush/test/level16/lesson13/bonus01/common/JpgReader.java | 2adebc158993883ed1fd1a49571d35b39acd5877 | [] | no_license | paliydmn/JavaRushHomeWork | 561cb8faf6871f58d387eaa4c3dc343e1192c8ba | 9b9cba8b41392737499bad8e629d758241768e12 | refs/heads/JavaRushHome | 2021-01-22T10:50:49.648474 | 2017-06-06T12:11:50 | 2017-06-06T12:11:50 | 92,656,080 | 0 | 0 | null | 2017-06-06T12:11:51 | 2017-05-28T11:05:27 | null | UTF-8 | Java | false | false | 152 | java | package com.javarush.test.level16.lesson13.bonus01.common;
/**
* Created by Dima on 11.03.2016.
*/
public class JpgReader implements ImageReader
{
}
| [
"[email protected]"
] | |
198ec90c357edafed85ab5b6532fb0012077f85b | aff66a1613358d4afd18fd7fce6fadf357ba4e2e | /src/Data_Structures_and_Algorithms_Made_Easy/Doubly_Linked_List_Client.java | 4cf9898f4b611484904d5d41b82b7960b0ee271a | [] | no_license | Leo-Adlakha/Java-Codes | 5af4258640aa480946c336e525ab9cebb803935c | d83b8c1e5af5d6bbb8d3364998169b597fdae579 | refs/heads/master | 2020-07-06T13:48:24.775508 | 2019-11-11T08:07:37 | 2019-11-11T08:07:37 | 203,037,347 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 578 | java | package Data_Structures_and_Algorithms_Made_Easy;
public class Doubly_Linked_List_Client {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Doubly_Linked_List list = new Doubly_Linked_List() ;
list.addFirst(10);
list.addLast(20);
list.addLast(40);
list.addLast(50);
list.addLast(60);
list.display();
list.addLast(70);
list.display();
list.addAt(30, 2);
list.display() ;
System.out.println(list.size());
list.deleteAt(0);
list.deleteAt(list.size()-1);
list.deleteAt(3);
list.display();
}
}
| [
"[email protected]"
] | |
d8a5c642c6088a473bbfbc7c676dfa7151ffa65c | 8acb32e24ceb51f74fdcf94b579cfb5f02d73606 | /newx/src/com/entity/Ban.java | fd1c5eb9458a378d7327ee0f6f034dc511cbd070 | [] | no_license | tech-lic/C-Tech | 912930e2fcb15af985d4aa57dbd21e0af8ae7cd2 | 6fc6939690e01e71ec7c998aadf405f13926f935 | refs/heads/master | 2020-12-30T12:36:46.746734 | 2017-06-12T06:00:54 | 2017-06-12T06:00:54 | 91,401,718 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 724 | java | package com.entity;
/**
* Ban entity. @author MyEclipse Persistence Tools
*/
public class Ban implements java.io.Serializable {
// Fields
private Integer id;
private String ban;
private String tech;
// Constructors
/** default constructor */
public Ban() {
}
/** full constructor */
public Ban(String ban, String tech) {
this.ban = ban;
this.tech = tech;
}
// Property accessors
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBan() {
return this.ban;
}
public void setBan(String ban) {
this.ban = ban;
}
public String getTech() {
return this.tech;
}
public void setTech(String tech) {
this.tech = tech;
}
} | [
"[email protected]"
] | |
2b48da0898e3256d23d5bb2846caf04e65a63276 | 15ebc42d3d97cc813f5ad664a20813214576ff93 | /alohandes_df.perezc_s.abadia/src/main/java/uniandes/isis2304/parranderos/persistencia/SQLOfertaVivienda.java | e3637c81071a31cf8ab0af21d28bd400f57f7377 | [] | no_license | dfperezc/it3 | a835909ff7b938907b55f7ffce78c00dd058a00e | 8b8c4031735f6e03cf0ad42ef80fdcd68d079886 | refs/heads/master | 2022-05-28T09:34:27.373782 | 2020-04-30T23:40:11 | 2020-04-30T23:40:11 | 260,306,369 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,725 | java | package uniandes.isis2304.parranderos.persistencia;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
public class SQLOfertaVivienda
{
/* ****************************************************************
* Constantes
*****************************************************************/
/**
* Cadena que representa el tipo de consulta que se va a realizar en las sentencias de acceso a la base de datos
* Se renombra acá para facilitar la escritura de las sentencias
*/
private final static String SQL = PersistenciaAlohAndes.SQL;
/* ****************************************************************
* Atributos
*****************************************************************/
/**
* El manejador de persistencia general de la aplicación
*/
private PersistenciaAlohAndes pp;
/* ****************************************************************
* Métodos
*****************************************************************/
/**
* Constructor
* @param pp - El Manejador de persistencia de la aplicación
*/
public SQLOfertaVivienda (PersistenciaAlohAndes pp)
{
this.pp = pp;
}
public long adicionarOfertaVivienda (PersistenceManager pm, long ido, String idv)
{
Query q = pm.newQuery(SQL, "INSERT INTO " + pp.darTablaOfertaVivienda () + "(idoferta, idvivienda) values (?, ?)");
q.setParameters(ido, idv);
return (long) q.executeUnique();
}
public long eliminarOfertaVivienda (PersistenceManager pm, long ido, String idv)
{
Query q = pm.newQuery(SQL, "DELETE FROM " + pp.darTablaOfertaVivienda () + " WHERE idoferta = ? AND idvivienda = ?");
q.setParameters(ido, idv);
return (long) q.executeUnique();
}
}
| [
"[email protected]"
] | |
309b04d25f0def02ce2665dcd0b83b1728976a45 | e559610360e51c4c994233873ae764ab3b5d043f | /app/src/main/java/com/seminariodetesis/MainActivity.java | 016451849c5d74900b9d5c8acb10e2c567ca1777 | [] | no_license | Cristian123AT/SeminariodeTesis | 569cf6daadac07ed459bf0c700b57e1438d8d242 | 16e6a8f17fbafed5d0e72c4035aecc8ffed9be3c | refs/heads/master | 2023-02-08T09:26:31.385190 | 2020-12-28T01:42:14 | 2020-12-28T01:42:14 | 323,092,933 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,770 | java | package com.seminariodetesis;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.seminariodetesis.Vista.Completar;
import com.seminariodetesis.Vista.LetraInvertida;
import com.seminariodetesis.Vista.Login;
import com.seminariodetesis.Vista.Sonido;
import com.seminariodetesis.Vista.VelocidadLectora;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
public class MainActivity extends AppCompatActivity implements IComunicaFragments {
FirebaseAuth firebaseAuth;
protected String usuario = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("user");
firebaseAuth = FirebaseAuth.getInstance();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.tesis_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.salir:
System.exit(0);
return (true);
case R.id.logout:
firebaseAuth.signOut();
startActivity(new Intent(this, Login.class));
return (true);
}
return (super.onOptionsItemSelected(item));
}
@Override
public void velocidadLectora() {
Intent intent = new Intent(this, VelocidadLectora.class);
intent.putExtra("Tipo","VELOCIDAD LECTORA");
startActivity(intent);
}
@Override
public void Actividades() {
Intent intent = new Intent(this, LetraInvertida.class);
startActivity(intent);
}
@Override
public void CompletarPalabras() {
Intent intent = new Intent(this, Completar.class);
startActivity(intent);
}
@Override
public void RelacionarPalabras() {
}
@Override
public void RelacionarSonidos() {
Intent intent = new Intent(this, Sonido.class);
startActivity(intent);
}
@Override
public void Otros() {
}
} | [
"[email protected]"
] | |
434b4e369468e825e7edd319f5d7440a07f972c5 | 80c0141c67d148eaeac1bbf3935aa73f8021b222 | /xtext.cool/src-gen/xtext/cool/cool/BasicExpression.java | e6b561c5f48811556b0e57e6160c3d77cd1b6435 | [] | no_license | OpenUniversity/AOP-Awesome-Legacy | 2487e26a070b8e0a4788f897517b27f24e89105b | 8131d2382be05e589fb3a12a0ffb9178a922f86a | refs/heads/master | 2021-01-01T19:48:10.409410 | 2017-07-29T07:43:22 | 2017-07-29T07:43:22 | 98,688,611 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,220 | java | /**
* <copyright>
* </copyright>
*
*/
package xtext.cool.cool;
import org.eclipse.emf.ecore.EObject;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Basic Expression</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link xtext.cool.cool.BasicExpression#isNegated <em>Negated</em>}</li>
* <li>{@link xtext.cool.cool.BasicExpression#getExpr <em>Expr</em>}</li>
* </ul>
* </p>
*
* @see xtext.cool.cool.CoolPackage#getBasicExpression()
* @model
* @generated
*/
public interface BasicExpression extends EObject
{
/**
* Returns the value of the '<em><b>Negated</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Negated</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Negated</em>' attribute.
* @see #setNegated(boolean)
* @see xtext.cool.cool.CoolPackage#getBasicExpression_Negated()
* @model
* @generated
*/
boolean isNegated();
/**
* Sets the value of the '{@link xtext.cool.cool.BasicExpression#isNegated <em>Negated</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Negated</em>' attribute.
* @see #isNegated()
* @generated
*/
void setNegated(boolean value);
/**
* Returns the value of the '<em><b>Expr</b></em>' reference.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Expr</em>' reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Expr</em>' reference.
* @see #setExpr(CondVar)
* @see xtext.cool.cool.CoolPackage#getBasicExpression_Expr()
* @model
* @generated
*/
CondVar getExpr();
/**
* Sets the value of the '{@link xtext.cool.cool.BasicExpression#getExpr <em>Expr</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Expr</em>' reference.
* @see #getExpr()
* @generated
*/
void setExpr(CondVar value);
} // BasicExpression
| [
"[email protected]"
] | |
9cfffb7f3283ea13f309b350dfdfab99aee50221 | 739ad8d1cd249b473ad9d42620c1595040fe5b04 | /Øving 1/src/com/trygve/oving1/Resturant.java | c8cfea9aa354637c1e013b505ccdc80da9ce3bfd | [] | no_license | trygve55/Videreg-ende-Programmering | b35afcb9d14bc84cb8ce2bf8dd78c7b7baeb8d1a | 49b2b88c160620a8803f6cdf1eebef618bdc4202 | refs/heads/master | 2021-04-30T16:20:37.512796 | 2017-03-17T11:40:01 | 2017-03-17T11:40:01 | 80,006,230 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,862 | java | package com.trygve.oving1;
import java.util.Calendar;
class Resturant {
private String navnResturant;
private int etableringsar;
Bord bord;
public Resturant(String navnResturant, int etableringsar, int antallBord) {
if (navnResturant != null) navnResturant = navnResturant.trim();
if (navnResturant == null || navnResturant.length() <= 0|| antallBord <= 0) throw new IllegalArgumentException();//exception
this.navnResturant = navnResturant;
this.etableringsar = etableringsar;
this.bord = new Bord(antallBord);
}
public String getNavnResturant() {
return navnResturant;
}
public void setNavnResturant(String navnResturant) {
if (navnResturant != null) navnResturant = navnResturant.trim();
if (navnResturant == null || navnResturant.length() <= 0) ;//exception
this.navnResturant = navnResturant;
}
public int getEtableringsar() {
return etableringsar;
}
public int getAlder() {
return Calendar.getInstance().get(Calendar.YEAR) - etableringsar;
}
public int getLedigeBord() {
int antall = 0;
for (int i = 1; i <= bord.getAntallBord();i++) if (!bord.getRestervert(i)) antall++;
return antall;
}
public int getOpptatteBord() {
int antall = 0;
for (int i = 1; i <= bord.getAntallBord();i++) if (bord.getRestervert(i)) antall++;
return antall;
}
public int getTotaleBord() {
return bord.getAntallBord();
}
public boolean reserverBord(String navn) {
return reserverBord(navn, 1);
}
public boolean reserverBord(String navn, int antallBordSkalReserveres) {
if (getLedigeBord() < antallBordSkalReserveres) return false;
int antallReservert = 0;
for (int i = 1; antallBordSkalReserveres > antallReservert && bord.getAntallBord() >= i;i++ ) {
if (bord.reserverBord(i, navn)) antallReservert++;
}
return true;
}
public int[] finnReserverteBordNavn(String navn) {
int[] bordNr = new int[0];
for (int i = 1; i <= getTotaleBord(); i++ ) {
if (bord.getRestervertNavn(i) != null && bord.getRestervertNavn(i).equals(navn)) {
bordNr = expandArray(bordNr);
bordNr[bordNr.length - 1] = i;
}
}
return bordNr;
}
public String finnReserverteBordNummer(int bordNr) {
return bord.getRestervertNavn(bordNr);
}
public void frigiBord(int[] bordNr) {
for (int i = 0; i < bordNr.length;i++) bord.frigiBord(bordNr[i]);
}
private int[] expandArray(int[] oldArray) {
int[] newArray = new int[oldArray.length + 1];
for (int i = 0; i < oldArray.length; i++) newArray[i] = oldArray[i];
return newArray;
}
} | [
"[email protected]"
] | |
9ed8fe34cd3fd37c3e437ff2f653fbe186025bea | 6bb184d3f007fa3d21584cedab2afb2061411bce | /src/main/java/tpfinal/tp/controller/ArbolController.java | 1dfdcfed776ceb3ea98d95cf358fe8784fce7cf5 | [] | no_license | JaquelinaAcosta/TP-final-DIED | 5f070fd648407fa422363491f51f9fad26c7305e | ff3f405fe99c3a3f0ea5a0d3b4b92100125ec312 | refs/heads/master | 2021-01-01T15:26:10.358723 | 2017-08-24T02:34:26 | 2017-08-24T02:34:26 | 97,615,714 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,569 | 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 tpfinal.tp.controller;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.WindowConstants;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import tpfinal.tp.estructuraArbolNario.Nodo;
import tpfinal.tp.estructuraArbolNario.TipoNodo;
import tpfinal.tp.estructuraArbolNario.ArbolNario;
import tpfinal.tp.guardarADisco.ArbolDao;
import tpfinal.tp.windows.PanelAgregarAArbol;
import tpfinal.tp.windows.PanelBusquedaArbol;
/**
*Esta clase va a controlar las relaciones entre las pantallas de ingresar
* datos del Arbol y la de buscar los datos
*
*/
public class ArbolController {
private ArbolNario<TipoNodo> arbolN;
private PanelAgregarAArbol panelAgregar;
private PanelBusquedaArbol panelBusqueda;
private Map<TipoNodo,String> nodoMetadatos;
private Nodo nodo;
private Nodo raiz;
private List<Nodo<TipoNodo>> listaNodo;
private List<Nodo<TipoNodo>> listaNodoHijosCapitulo;
private List<Nodo<TipoNodo>> listaNodoHijosResumen;
private List<Nodo<TipoNodo>> listaNodoHijosMetadato;
private List<Nodo<TipoNodo>> listaNodoHijosHijos;
private TipoNodo tipo;
private ArbolDao arbolDao = new ArbolDao();
public ArbolController(PanelAgregarAArbol panelA,PanelBusquedaArbol panelB)
{
this.panelAgregar=panelA;
this.panelBusqueda=panelB;
this.arbolN= new ArbolNario<>();
this.nodo= new Nodo();
this.nodoMetadatos= new LinkedHashMap<>();
this.listaNodo= new ArrayList<>();
this.listaNodoHijosCapitulo= new ArrayList<>();
this.listaNodoHijosResumen= new ArrayList<>();
this.listaNodoHijosMetadato= new ArrayList<>();
this.listaNodoHijosHijos= new ArrayList<>();
}
public ArbolController(PanelBusquedaArbol panelb)
{
this.panelBusqueda=panelb;
this.arbolN= new ArbolNario<>();
this.nodo= new Nodo();
this.nodoMetadatos= new LinkedHashMap<>();
this.listaNodo= new ArrayList<>();
this.listaNodoHijosCapitulo= new ArrayList<>();
this.listaNodoHijosResumen= new ArrayList<>();
this.listaNodoHijosMetadato= new ArrayList<>();
this.listaNodoHijosHijos= new ArrayList<>();
}
public ArbolController(PanelAgregarAArbol panelb)
{
this.panelAgregar=panelb;
this.arbolN= new ArbolNario<>();
this.nodo= new Nodo();
this.nodoMetadatos= new LinkedHashMap<>();
this.listaNodo= new ArrayList<>();
this.listaNodoHijosCapitulo= new ArrayList<>();
this.listaNodoHijosResumen= new ArrayList<>();
this.listaNodoHijosMetadato= new ArrayList<>();
this.listaNodoHijosHijos= new ArrayList<>();
}
//cargamos la raiz al arbol
public void cargarRaizArbol(String material,TipoNodo tipo)
{
this.raiz= new Nodo(tipo,material);
this.arbolN.setRaiz(raiz);
}
public List<Nodo<TipoNodo>> cargarNodoDeRaiz(String material,TipoNodo tipo)
{
Nodo<TipoNodo> n= new Nodo(tipo,material);
listaNodo.add(n);
System.out.println("listaNodo"+listaNodo);
return listaNodo;
}
public void unirNodosRaiz()
{
this.raiz.setHijos(listaNodo);
this.cargarNodosHijos();
}
public void cargarNodosHijos()
{
for(int i=0;i <listaNodo.size();i++)
{
if(listaNodo.get(0).getData().equals(tipo.CAPITULO))
{
listaNodo.get(0).setHijos(listaNodoHijosCapitulo);
System.out.println("Agregue el hijo correctamente");
}
if(listaNodo.get(1).getData().equals(tipo.METADATO))
{
listaNodo.get(1).setHijos(listaNodoHijosMetadato);
System.out.println("Agregue el hijo correctamente");
}
if(listaNodo.get(2).getData().equals(tipo.RESUMEN))
{
listaNodo.get(2).setHijos(listaNodoHijosResumen);
System.out.println("Agregue el hijo correctamente");
}
}
}
public List<Nodo<TipoNodo>> agregarHijosCapitulo(String material,TipoNodo tipo)
{
Nodo<TipoNodo> n= new Nodo(tipo,material);
this.listaNodoHijosCapitulo.add(n);
return listaNodoHijosCapitulo;
}
public List<Nodo<TipoNodo>> agregarHijosMetadato(String material,TipoNodo tipo)
{
Nodo<TipoNodo> n= new Nodo(tipo,material);
this.listaNodoHijosMetadato.add(n);
return listaNodoHijosMetadato;
}
public List<Nodo<TipoNodo>> agregarHijosResumen(String material,TipoNodo tipo)
{
Nodo<TipoNodo> n= new Nodo(tipo,material);
this.listaNodoHijosResumen.add(n);
return listaNodoHijosResumen;
}
public void cargarArbol()
{
this.unirNodosRaiz();
System.out.println("c argue el arbol"+arbolN.toString());
arbolDao.agregar(arbolN);
}
public void dibujarArbol()
{
DefaultMutableTreeNode abuelo = new DefaultMutableTreeNode(this.raiz.dato());
DefaultTreeModel modelo = new DefaultTreeModel(abuelo);
JTree tree = new JTree(modelo);
// Construccion de los datos del arbol
DefaultMutableTreeNode padre = new DefaultMutableTreeNode(this.listaNodo.get(0).dato());
DefaultMutableTreeNode tio1 = new DefaultMutableTreeNode(this.listaNodo.get(1).dato());
DefaultMutableTreeNode tio2 = new DefaultMutableTreeNode(this.listaNodo.get(2).dato());
modelo.insertNodeInto(padre, abuelo, 0);
modelo.insertNodeInto(tio1, abuelo, 1);
modelo.insertNodeInto(tio2, abuelo, 2);
for(int i=0;i<this.listaNodoHijosCapitulo.size();i++)
{
DefaultMutableTreeNode hijo = new DefaultMutableTreeNode(this.listaNodoHijosCapitulo.get(i).dato());
modelo.insertNodeInto(hijo, padre, i);
}
for(int k=0;k<this.listaNodoHijosMetadato.size();k++)
{
DefaultMutableTreeNode hijo1 = new DefaultMutableTreeNode(this.listaNodoHijosMetadato.get(k).dato());
modelo.insertNodeInto(hijo1,tio1, k);
}
for(int j=0;j<this.listaNodoHijosResumen.size();j++)
{
DefaultMutableTreeNode hijo2 = new DefaultMutableTreeNode(this.listaNodoHijosResumen.get(j).dato());
modelo.insertNodeInto(hijo2, tio2, j);
}
// Construccion y visualizacion de la ventana
JFrame v = new JFrame();
JScrollPane scroll = new JScrollPane(tree);
v.getContentPane().add(scroll);
v.pack();
v.setVisible(true);
v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void buscarNodo(String titulo,TipoNodo tipoViene)
{
System.out.println("Hola entreeeeee");
List<ArbolNario> listaArbol= new ArrayList<ArbolNario>();
listaArbol= arbolDao.cargarLista();
// System.out.println("esta es mi lista "+listaArbol);
for(int i=0;i<listaArbol.size();i++)
{
Nodo<TipoNodo> n= listaArbol.get(i).getRaiz();
System.out.println("este es mi nodo "+n);
List<Nodo<TipoNodo>> listaHijo= n.getHijos();
if((n.dato().equals(titulo))&&(n.getData().equals(tipoViene)))//si hay coincidencia en la raiz
{
System.out.println("HUBO COINCIDENCIA del padre");
/*creo el arbol*/
DefaultMutableTreeNode abuelo = new DefaultMutableTreeNode(n.dato());
DefaultTreeModel modelo = new DefaultTreeModel(abuelo);
JTree tree = new JTree(modelo);
//si tiene mas de un hijo exploro tdo el arbol
for(int z=0;z< listaHijo.size();z++)
{
DefaultMutableTreeNode padre = new DefaultMutableTreeNode(listaHijo.get(z).dato());
modelo.insertNodeInto(padre, abuelo, z);
}
JFrame v = new JFrame();
JScrollPane scroll = new JScrollPane(tree);
v.getContentPane().add(scroll);
v.pack();
v.setVisible(true);
v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
for(int k=0;k< listaHijo.size();k++)
{
// Nodo<TipoNodo> nHijo= listaArbol.get(k).getRaiz();
// System.out.println("este es mi nodo de mi hijo "+nHijo);
// List<Nodo<TipoNodo>> listaSubHijo= nHijo.getHijos();
if((listaHijo.get(k).dato().equals(titulo))&&(listaHijo.get(k).getData().equals(tipoViene)))
{
DefaultMutableTreeNode abuelo = new DefaultMutableTreeNode(listaHijo.get(k).dato());
DefaultTreeModel modelo = new DefaultTreeModel(abuelo);
JTree tree = new JTree(modelo);
// for(int w=0;w< listaSubHijo.size();w++)
// {
// DefaultMutableTreeNode padre = new DefaultMutableTreeNode(listaSubHijo.get(w).dato());
// modelo.insertNodeInto(padre, abuelo, w);
// }
JFrame v = new JFrame();
JScrollPane scroll = new JScrollPane(tree);
v.getContentPane().add(scroll);
v.pack();
v.setVisible(true);
v.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
System.out.println("HUBO COINCIDENCIAaaaaaaaaaaaaa del hijo ");
}
}
}
}
}
| [
"[email protected]"
] | |
01c0b50e105d083a7bfde27b695e1734fc7e8306 | 90b9114d607b0c4b6194e1f7b712fa2251a07794 | /mapnavigator/src/main/java/biking/mapnavigator/Navigator.java | 5daba99a00d9e44158a1cf5f039af03aa011418d | [] | no_license | amolmate/BikingDiaries2 | 48759669a24efc66ec71f9e0d1380a466164ae3d | 7abe0af6e305f6e0961bbccebefd8fdbf37cf473 | refs/heads/master | 2021-01-17T01:09:13.855803 | 2016-06-06T07:08:56 | 2016-06-06T07:08:56 | 60,506,284 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,838 | java | package biking.mapnavigator;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import android.content.Context;
import android.graphics.Color;
import android.os.AsyncTask;
import android.util.Log;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
public class Navigator {
@SuppressWarnings("unused")
private Context context;
private LatLng startPosition, endPosition;
private String mode;
private GoogleMap map;
private Directions directions;
private int pathColor = Color.BLUE;
private int secondPath = Color.CYAN;
private int thirdPath = Color.RED;
private float pathWidth = 5;
private OnPathSetListener listener;
private boolean alternatives = false;
private long arrivalTime;
private String avoid;
private ArrayList<Polyline> lines = new ArrayList<Polyline>();
String distance="",duration="";
Context ctx;
IGetDistTime iGetDistTime;
public Navigator(GoogleMap map, LatLng startLocation, LatLng endLocation,Context context){
this.startPosition = startLocation;
this.endPosition = endLocation;
this.map = map;
this.ctx=context;
iGetDistTime=(IGetDistTime)ctx;
}
public interface OnPathSetListener{
public void onPathSetListener(Directions directions);
}
public void setOnPathSetListener(OnPathSetListener listener){
this.listener = listener;
}
/**
* Gets the starting location for the directions
*
*/
public LatLng getStartPoint(){
return startPosition;
}
/**
* Gets the end location for the directions
*
*/
public LatLng getEndPoint(){
return endPosition;
}
/**
* Get's driving directions from the starting location to the ending location
*
* @param showDialog
* Set to true if you want to show a ProgressDialog while retrieving directions
* @param findAlternatives
* give alternative routes to the destination
*
*/
public void findDirections(boolean findAlternatives){
this.alternatives = findAlternatives;
new PathCreator().execute();
}
/**
* Sets the type of direction you want (driving,walking,biking or mass transit). This MUST be called before getting the directions
* If using "transit" mode you must provide an arrival time
*
* @param mode
* The type of directions you want (driving,walking,biking or mass transit)
* @param arrivalTime
* If selected mode it "transit" you must provide and arrival time (milliseconds since January 1, 1970 UTC). If arrival time is not given
* the current time is given and may return unexpected results.
*/
public void setMode(int mode, long arrivalTime,int avoid){
switch(mode){
case 0:
this.mode = "driving";
break;
case 1:
this.mode = "transit";
this.arrivalTime = arrivalTime;
break;
case 2:
this.mode = "bicycling";
break;
case 3:
this.mode = "walking";
break;
default:
this.mode = "driving";
break;
}
switch(avoid){
case 0:
this.avoid = "tolls";
break;
case 1:
this.avoid = "highways";
break;
default:
break;
}
}
/**
* Get all direction information
* @return
*/
public Directions getDirections(){
return directions;
}
/**
* Change the color of the path line, must be called before calling findDirections().
* @param firstPath
* Color of the first line, default color is blue.
* @param secondPath
* Color of the second line, default color is cyan
* @param thirdPath
* Color of the third line, default color is red
*
*/
public void setPathColor(int firstPath,int secondPath, int thirdPath){
pathColor = firstPath;
}
/**
* Change the width of the path line
* @param width
* Width of the line, default width is 3
*/
public void setPathLineWidth(float width){
pathWidth = width;
}
private Polyline showPath(Route route,int color){
return map.addPolyline(new PolylineOptions().addAll(route.getPath()).color(color).width(pathWidth));
}
public ArrayList<Polyline> getPathLines(){
return lines;
}
private class PathCreator extends AsyncTask<Void,Void,Directions>{
@Override
protected Directions doInBackground(Void... params) {
if(mode == null){
mode = "driving";
}
String url = "http://maps.googleapis.com/maps/api/directions/json?"
+ "origin=" + startPosition.latitude + "," + startPosition.longitude
+ "&destination=" + endPosition.latitude + "," + endPosition.longitude
+ "&sensor=false&units=metric&mode="+mode+"&alternatives="+String.valueOf(alternatives);
if(mode.equals("transit")){
if(arrivalTime > 0){
url += url + "&arrival_time="+arrivalTime;
}else{
url += url + "&departure_time="+System.currentTimeMillis();
}
}
if(avoid != null){
url += url+"&avoid="+avoid;
}
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(url);
HttpResponse response = httpClient.execute(httpPost, localContext);
if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
Log.d("URL ","is"+url);
String s = EntityUtils.toString(response.getEntity());
Log.d("Direction","is"+s);
return new Directions(s);
}
return null;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Directions directions){
if(directions != null){
Navigator.this.directions = directions;
for(int i=0; i<directions.getRoutes().size(); i++){
Route r = directions.getRoutes().get(i);
if(i == 0){
lines.add(showPath(r,pathColor));
}else if(i == 1){
lines.add(showPath(r,secondPath));
}else if(i == 3){
lines.add(showPath(r,thirdPath));
}
}
iGetDistTime.getDistTime(directions.getDuration(), directions.getDistance());
if(listener != null){
listener.onPathSetListener(directions);
}
}
}
}
public String getDistance(){
return Navigator.this.directions.getDistance();
}
public String getDuration(){
return Navigator.this.directions.getDuration();
}
}
| [
"[email protected]"
] | |
9c251c4e9bbf40ff23a6b5abb22e1690dc38444a | 6e5503118457714b108d6fa1d16466c11e5c0719 | /app/src/main/java/com/logic/client/mvp/model/NewsTabTagModel.java | 2e49827887fdc9b66ee5842f4953f43967dbc40e | [] | no_license | Peter6666/client | bacd97b5a61136dfeec4afaa35cf24cda1fecc86 | 0cd78aec3c414573b141efe771ef8301db0a1e5c | refs/heads/master | 2020-03-10T12:44:45.772014 | 2018-05-29T07:20:38 | 2018-05-29T07:20:38 | 129,384,581 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,327 | java | package com.logic.client.mvp.model;
import android.util.Log;
import com.logic.client.R;
import com.logic.client.bean.NewsChannelTabs;
import com.logic.client.rx.RxSchedulers;
import com.logic.client.rx.base.BaseApplication;
import com.logic.client.rx.base.mvp.BaseModel;
import com.logic.client.utils.CacheUtils;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.FlowableEmitter;
import io.reactivex.FlowableOnSubscribe;
import io.reactivex.annotations.NonNull;
/**
* @author logic. Email:[email protected]
* @data 2018/5/2
* @desc
*/
public class NewsTabTagModel extends BaseModel {
public Flowable<List<NewsChannelTabs>> getSelectChannel() {
return Flowable.create(new FlowableOnSubscribe<List<NewsChannelTabs>>() {
@Override
public void subscribe(@NonNull FlowableEmitter<List<NewsChannelTabs>> e) throws Exception {
ArrayList<NewsChannelTabs> tabs = (ArrayList<NewsChannelTabs>) CacheUtils.getInstance().getSerializable("CURRENT_CHANNEL");
if (tabs == null) {
tabs = loadTabs(R.array.static_news_channel_name, true, true, NewsChannelTabs.CURRENT_CHANNEL);//加载固定频道
CacheUtils.getInstance().put("CURRENT_CHANNEL", tabs);
}
e.onNext(tabs);
e.onComplete();
}
}, BackpressureStrategy.BUFFER).compose(RxSchedulers.<List<NewsChannelTabs>>FlowableToMain());
}
public Flowable<List<NewsChannelTabs>> getUnSelectChannel() {
return Flowable.create(new FlowableOnSubscribe<List<NewsChannelTabs>>() {
@Override
public void subscribe(@NonNull FlowableEmitter<List<NewsChannelTabs>> e) throws Exception {
ArrayList<NewsChannelTabs> tabs = (ArrayList<NewsChannelTabs>) CacheUtils.getInstance().getSerializable("ADD_CHANNEL");
if (tabs == null) {
tabs = loadTabs(R.array.news_channel_name, false, false, NewsChannelTabs.ADD_CHANNEL);//加载频道
CacheUtils.getInstance().put("ADD_CHANNEL", tabs);
}
e.onNext(tabs);
e.onComplete();
}
}, BackpressureStrategy.BUFFER).compose(RxSchedulers.<List<NewsChannelTabs>>FlowableToMain());
}
/**
* 加载频道
*
* @return
*/
public ArrayList<NewsChannelTabs> loadTabs(int id, boolean isSelect, boolean isFixed, int type) {
String[] stringArray = BaseApplication.getAppContext().getResources().getStringArray(id);
ArrayList<NewsChannelTabs> tabs = new ArrayList<>();
for (int i = 0; i < stringArray.length; i++) {
NewsChannelTabs newsChannelTabs = new NewsChannelTabs(stringArray[i], isSelect, i, isFixed, type);
tabs.add(newsChannelTabs);
}
return tabs;
}
/**
* @param current
* @param add
*/
public void saveChannel(final ArrayList<NewsChannelTabs> current, final ArrayList<NewsChannelTabs> add) {
if (current != null)
CacheUtils.getInstance().put("CURRENT_CHANNEL", current);
if (add != null)
CacheUtils.getInstance().put("ADD_CHANNEL", add);
}
}
| [
"[email protected]"
] | |
7bd8951585d42ecf3cb69ff09268152035f6f74d | f3403b6442d626caea1957004ebe1ee994adb2f9 | /IssuerBanks/src/main/java/com/IssuerBanks/IssuerBanks/IssuerBankRoutes/AuthenticationForTransaction.java | 60ed0e2a07d7014b07e60084e4af2ca713e1f747 | [] | no_license | 2893348004/BankingApplication | 2e3a48759ed416210451f37cd85d75d116d4b34d | 83a01db6b6b864972845fc4ceff482a02c7e4258 | refs/heads/master | 2023-08-16T06:38:42.729812 | 2021-09-10T16:46:23 | 2021-09-10T16:46:23 | 405,135,207 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,056 | java | package com.IssuerBanks.IssuerBanks.IssuerBankRoutes;
import com.IssuerBanks.IssuerBanks.Factories.BankAbstractFactory;
import com.IssuerBanks.IssuerBanks.Factories.BankFactoryProvider;
import com.IssuerBanks.IssuerBanks.Factories.CardFactory;
import org.apache.camel.Exchange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class AuthenticationForTransaction {
@Autowired
private BankFactoryProvider abstractFactory;
private CardFactory cardFactory;
public String isThisCorrectPerson(Exchange exchange){
var custom = exchange.getIn().getBody(String.class);
List<String> elementList = Arrays.asList(custom.split(","));
String id = elementList.get(0);
String cardNumber = elementList.get(1);
String firstName = elementList.get(2);
String lastName = elementList.get(3);
String expiry = elementList.get(4);
int pin = Integer.parseInt( elementList.get(5) ) ;
int bin = Integer.parseInt( elementList.get(6) ) ;
int ccv = Integer.parseInt( elementList.get(7) ) ;
String validityofnumber = elementList.get(9);
String bankname = elementList.get(10);
CardFactory cardFactory = getFactory(bankname);
boolean isThisGuyLegit = cardFactory.authenticateTransaction(id,cardNumber,firstName,lastName,expiry,pin,bin,ccv);
if(isThisGuyLegit == true)
{
var authenticated = custom + "LEGITIMATE CREDENTIALS" + ",";
exchange.getIn().setBody(authenticated);
}
else if (isThisGuyLegit == false)
{
var notAuthenticated = custom + "NOT VALID CREDENTIALS" + ",";
exchange.getIn().setBody(notAuthenticated);
}
return exchange.getIn().getBody(String.class);
}
public CardFactory getFactory(String bankname){
return abstractFactory.createCardService(bankname);
}
}
| [
"[email protected]"
] | |
dc577fe526a1daac14e1f51b86d4f84243f15cf3 | 0865ce2c48c12b0ad804d5b40ae1418539d5beb3 | /spring-mvc-client-three/src/main/java/com/hhcf/system/listner/MQMsgListener.java | 429173b05e4d2e1afd48c33391f4985445903a77 | [] | no_license | radtek/full-cluster | 73cc0f330983f8cd38315fed4f5f57bebacafa02 | fa24ed300f5b15ab8c89fd5d9bbcce776ddc1e95 | refs/heads/master | 2020-06-15T23:43:19.807143 | 2018-11-21T09:56:28 | 2018-11-21T09:56:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,503 | java | package com.hhcf.system.listner;
import java.util.Map;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import com.rabbitmq.client.Channel;
/**
* @Title: MQMsgListener
* @Description:
* @Author: zhaotf
* @Since:2018年5月16日 下午2:41:59
* @see {@linkplain https://www.cnblogs.com/piaolingzxh/p/5448927.html}
*/
public class MQMsgListener implements ChannelAwareMessageListener {
public void receiveMsg(Map<String, Object> message) {
}
@Override
public void onMessage(Message message, Channel channel) throws Exception {
System.out.println("MQMsgListener.receiveMsg侦听mq消息代码:" + message);
try {
System.out.println("MQMsgListener.onMessage--监听端:" + message.getMessageProperties() + ":"
+ new String(message.getBody(), "UTF-8"));
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
e.printStackTrace();// TODO 业务处理
if (message.getMessageProperties().getRedelivered()) {
System.out.println("消息已重复处理失败,拒绝再次接收...");
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true); // 拒绝消息,单条
} else {
System.out.println("消息即将再次返回队列处理...");
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true); // 拒绝消息,可多条,
// requeue为是否重新回到队列
}
}
}
}
| [
"[email protected]"
] | |
409025cb982f2a11b80048a09c74803fe7aa8db8 | 3264ec2bd7d4256dc52eac5fbe807adaca51d8f4 | /src/Algorithms/Implementation/easy/SockMerchant.java | ea0e5d85aca3d13310cb49d0a70cbf6fa9d77435 | [] | no_license | asuvorkov/HackerRank | 221fef9afd7724538dbf0972b90cb293fe1c0a7a | f74bd4735405139fa49440425577c6c60d0de08e | refs/heads/master | 2021-01-22T11:20:15.801417 | 2018-04-14T08:51:41 | 2018-04-14T08:51:41 | 92,682,042 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 799 | java | package Algorithms.Implementation.easy;
import java.util.*;
/**
* Created by Andrei on 13.08.2017.
*/
public class SockMerchant {
static int sockMerchant(int n, int[] ar) {
// Complete this function
int numberOfPairs = 0;
Arrays.sort( ar );
for (int i = 1; i < ar.length; i++){
if (ar[i] == ar[i - 1]){
numberOfPairs++;
i++;
}
}
return numberOfPairs;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] ar = new int[n];
for(int ar_i = 0; ar_i < n; ar_i++){
ar[ar_i] = in.nextInt();
}
int result = sockMerchant(n, ar);
System.out.println(result);
}
}
| [
"[email protected]"
] | |
a23cd051d53a56c381048fa24e7ace12d5cd8825 | 367a5ea5c129f5205f5f507b775ea6762e9d3b2b | /Pen.java | 1f4acff8eb35294ceaa4711a4310effd9080bca6 | [] | no_license | davidgarciaj/SnakeGame | e42ae0f45563402a72ddf157dfe9767a91db1b73 | a6b342d8831576358304f68d6ec110e1e67a19ef | refs/heads/master | 2021-01-10T11:53:27.388533 | 2016-04-08T10:11:10 | 2016-04-08T10:11:10 | 55,497,236 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,031 | java | import java.awt.Color;
import java.util.Random;
/**
* A pen can be used to draw on a canvas. The pen maintains a position, direction, color,
* and an up/down state. The pen can be moved across the canvas. If the pen is down, it
* leaves a line on the canvas when moved. (If it is up, it will not draw a line.)
*
* @author Michael Kölling & David J. Barnes
* @version 2011.07.31
*/
public class Pen
{
// constants for randomSquiggle method
private static final int SQIGGLE_SIZE = 40;
private static final int SQIGGLE_COUNT = 30;
private int xPosition;
private int yPosition;
private int rotation;
private Color color;
private boolean penDown;
private Canvas canvas;
private Random random;
/**
* Create a new Pen with its own canvas. The pen will create a new canvas for
* itself to draw on, and start in the default state (centre of canvas, direction
* right, color black, pen down).
*/
public Pen()
{
this (280, 220, new Canvas("My Canvas", 560, 440));
}
/**
* Create a new Pen for a given canvas. The direction is initially 0 (to the right),
* the color is black, and the pen is down.
*
* @param xPos the initial horizontal coordinate of the pen
* @param yPos the initial vertical coordinate of the pen
* @param drawingCanvas the canvas to draw on
*/
public Pen(int xPos, int yPos, Canvas drawingCanvas)
{
xPosition = xPos;
yPosition = yPos;
rotation = 0;
penDown = true;
color = Color.BLACK;
canvas = drawingCanvas;
random = new Random();
}
/**
* Move the specified distance in the current direction. If the pen is down,
* leave a line on the canvas.
*
* @param distance The distance to move forward from the current location.
*/
public void move(int distance)
{
double angle = Math.toRadians(rotation);
int newX = (int) Math.round(xPosition + Math.cos(angle) * distance);
int newY = (int) Math.round(yPosition + Math.sin(angle) * distance);
moveTo(newX, newY);
}
/**
* Move to the specified location. If the pen is down, leave a line on the canvas.
*
* @param x The x-coordinate to move to.
* @param y The y-coordinate to move to.
*/
public void moveTo(int x, int y)
{
if (penDown) {
canvas.setForegroundColor(color);
canvas.drawLine(xPosition, yPosition, x, y);
}
xPosition = x;
yPosition = y;
}
/**
* Turn the specified amount (out of a 360 degree circle) clockwise from the current
* rotation.
*
* @param degrees The amount of degrees to turn. (360 is a full circle.)
*/
public void turn(int degrees)
{
rotation = rotation + degrees;
}
/**
* Turn to the specified direction. 0 is right, 90 is down, 180 is left, 270 is up.
*
* @param angle The angle to turn to.
*/
public void turnTo(int angle)
{
rotation = angle;
}
/**
* Set the drawing color.
*
* @param newColor The color to use for subsequent drawing operations.
*/
public void setColor(Color newColor)
{
color = newColor;
}
/**
* Lift the pen up. Moving afterwards will not leave a line on the canvas.
*/
public void penUp()
{
penDown = false;
}
/**
* Put the pen down. Moving afterwards will leave a line on the canvas.
*/
public void penDown()
{
penDown = true;
}
/**
* Scribble on the canvas in the current color. The size and complexity of the
* squiggle produced is defined by the constants SQIGGLE_SIZE and SQIGGLE_COUNT.
*/
public void randomSquiggle()
{
for (int i=0; i<SQIGGLE_COUNT; i++) {
move(random.nextInt(SQIGGLE_SIZE));
turn(160 + random.nextInt(40));
}
}
} | [
"[email protected]"
] | |
b85f5556364678b01f184d08a4719bca18295e58 | 77a74278b89b59ccd9ca9b78c80987a5591a6859 | /src/gameobj/Boss/BossAttack.java | 2fefdac77aa53997b51b493ff4536761f150c039 | [] | no_license | wolke1007/cmoney_project_shootinggame | c9ef5c8bae7d8dcbb3280df6f9286998e6c787cb | 9411c58395e962e6b131a438ff6bbe7585ae41fe | refs/heads/master | 2022-11-27T16:45:22.157796 | 2020-08-04T17:38:29 | 2020-08-04T17:38:29 | 284,514,799 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,510 | 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 gameobj.Boss;
import controllers.AudioPath;
import controllers.AudioResourceController;
import controllers.ImagePath;
import controllers.MusicResourceController;
import gameobj.GameObject;
import java.awt.Graphics;
import java.util.ArrayList;
import renderer.Renderer;
import renderer.RendererToRotate;
import util.Angle;
import util.AverageSpeed;
import util.Delay;
import util.Global;
import util.VectorCollision;
/**
*
* @author F-NB
*/
public class BossAttack extends GameObject {
private float startX;//已設定
private float startY;//已設定
private GameObject target;//已設定
private ArrayList<GameObject> allObjects;//已設定
private RendererToRotate renderer;//繪製移動中 的 旋轉圖 //已設定
private int trigCount;//旋轉特效的切換
private Renderer effect;//繪製 移動 前/後 的效果 //已設定
private boolean isMove;//是否移動 false //已設定
private Delay effectDelay;//換圖的 Delay //已設定
private int effectCount;//一般特效的切圖切換
private int attackRange;//攻擊範圍
private AverageSpeed averageSpeed;
private VectorCollision vectorMove;
private Angle angle;
//自己對目標的移動控制
private Delay moveDelay;//已設定
private float moveSpeed;//已設定
private float actMoveSpeed;//已設定
private float moveMultiple;//移動倍數
//自己對目標的移動控制end
public BossAttack(String colliderType, float x, float y, GameObject target, float moveSpeed, String[] path, int width, int height) {
super(colliderType, x, y, width, height, width, height);
this.startX = x;//開始的位置
this.startY = y;//開始的位置
this.target = target;//目標
setIsMove(false);
setAverageSpeed();
setVectorMove();
setMoveMultiple(4);
this.renderer = new RendererToRotate(path, this, 0);//一開始在0度
this.effect = new Renderer();
this.effect.setImage(ImagePath.BOSS_BOOM_CONTINUE);//特效 圖片路徑
this.trigCount = 0;
setMoveSpeedDetail(moveSpeed);
setEffectDelay();
setAttackRange(width);
setType("BossAttack");
}
public RendererToRotate getRenderer() {
return this.renderer;
}
public void setIsMove(boolean isMove) {
this.isMove = isMove;
}//已設定
public boolean getIsMove() {
return this.isMove;
}
private void setAttackRange(int attackRange) {
this.attackRange = attackRange;
}//設定攻擊範圍 //已設定
private void setAverageSpeed() {
if (this.averageSpeed == null) {
this.averageSpeed = new AverageSpeed(this.getCenterX(), this.getCenterY(), this.target.getCenterX(), this.target.getCenterY(), 50, true);
}
this.averageSpeed.setCenterX(this.getCenterX());
this.averageSpeed.setCenterY(this.getCenterY());
this.averageSpeed.setGoalCenterX(this.target.getCenterX());
this.averageSpeed.setGoalCenterY(this.target.getCenterY());
}//已設定
private void setVectorMove() {
this.vectorMove = new VectorCollision(this, 0, 0, new String[]{"Map", "Ammo", "Enemy", "Boss", "Barrier", "BossAttack"}, Global.INNER);
this.vectorMove.setIsBackMove(false);
this.vectorMove.setDivisor(5f);
}//已設定
public void setAngle() {
if (this.angle == null) {
this.angle = new Angle(this.getCenterX(), this.getCenterY(), this.target.getCenterX(), this.target.getCenterY());
return;
}
this.angle.setCenterX(this.getCenterX());
this.angle.setCenterY(this.getCenterY());
this.angle.setGoalCenterX(this.target.getCenterX());
this.angle.setGoalCenterY(this.target.getCenterY());
}//已設定
public double getAngle() {
return this.angle.getAngle();
}//已設定
private void setMoveSpeedDetail(float moveSpeed) {
this.moveSpeed = limitRange(moveSpeed);
this.actMoveSpeed = 60 - this.moveSpeed;
this.moveDelay = new Delay(this.actMoveSpeed);
this.moveDelay.start();
}
private float limitRange(float range) {
if (range < 0) {
return 0;
} else if (range > 60) {
return 60;
}
return range;
}
public void setMoveSpeed(float moveSpeed) {
this.moveSpeed = limitRange(moveSpeed);
this.actMoveSpeed = this.moveSpeed;
this.moveDelay.setDelayFrame(this.actMoveSpeed);
}
public float getMoveSpeed() {
return this.moveSpeed;
}
private void setEffectDelay() {
if (this.effectDelay == null) {
this.effectDelay = new Delay(5);
} else {
this.effectDelay.setDelayFrame(5);
}
this.effectDelay.stop();
this.effectCount = 0;
}
public void setNewStart() {
this.setXY(this.startX, this.startY);//回到原點
setIsMove(false);
// setEffectDelay();
this.vectorMove.setIsCollision(false);
this.moveDelay.start();
}
public void setMoveMultiple(float moveMultiple) {
this.moveMultiple = moveMultiple;
}
public float getMoveMultiple() {
return this.moveMultiple;
}
public void setAllObject(ArrayList<GameObject> list) {
this.allObjects = list;
this.vectorMove.setAllObjects(list);
}
public ArrayList<GameObject> getAllObject() {
return this.allObjects;
}
public int getEffectCount() {
return this.effectCount;
}
@Override
public void update() {
if (this.moveDelay.isTrig()) {//自己本身的移動速度
if (!this.isMove) {//如果不能移動,隨時面對目標方向
setAngle();
setAverageSpeed();
this.renderer.setAngle(getAngle());//隨時面對目標方向
this.effectDelay.start();
if (this.effectDelay.isTrig()) {
this.renderer.setState(this.trigCount++ % 3); //特效 0 / 1 / 2 輪流放
}
} else {//可以移動的狀況下,就不再旋轉直接移動
if (!this.vectorMove.getIsCollision()) {//如果沒有撞到,持續移動
this.effectDelay.start();
float dx = this.averageSpeed.offsetDX();
float dy = this.averageSpeed.offsetDY();
this.vectorMove.newOffset(dx * this.getMoveMultiple(), dy * this.getMoveMultiple());
if (this.effectDelay.isTrig()) {//持續移動的同時也切換特效
this.renderer.setState(this.trigCount++ % 4 + 3);//特效 3 / 4 / 5 輪流放
}
} else {//如果有撞到,先扣血,再放特效
if (this.effectCount == 0) {
MusicResourceController.getInstance().tryGetMusic(AudioPath.BOSS_ATTACK_BOMB).play();
// AudioResourceController.getInstance().play(AudioPath.BOSS_ATTACK_BOMB);
this.effectDelay.click();
for (int i = 0; i < this.allObjects.size(); i++) {//扣血
if (Math.sqrt(Math.pow(this.allObjects.get(i).getCenterX() - this.getCenterX(), 2)
+ Math.pow(this.allObjects.get(i).getCenterY() - this.getCenterY(), 2)) < this.attackRange) {
if (!this.allObjects.get(i).getType().equals("Actor")) {
continue;
}
for (int j = 0; j < 5; j++) {
this.allObjects.get(i).subtractHp();
}
}
}//扣血end
this.effectDelay.setDelayFrame(1);
}
if (this.effectDelay.isTrig()) {
this.effectCount++;
this.effectCount++;
}
if (this.effectCount > 63) {
this.setXY(-10000, -10000);
// this.effectDelay.stop();
this.moveDelay.stop();
setIsMove(false);
setEffectDelay();
}
}
}
}
}
@Override
public void paintComponent(Graphics g) {
if (!this.vectorMove.getIsCollision()) {//如果沒有撞到
this.renderer.paint(g);
} else {//如果有撞到
this.effect.paint(g,
(int) this.getCenterX() - this.attackRange,
(int) this.getCenterY() - this.attackRange,
(int) this.getCenterX() + this.attackRange,
(int) this.getCenterY() + this.attackRange,
(this.effectCount % 9) * 71,
(this.effectCount / 9) * 71,
(this.effectCount % 9) * 71 + 71,
(this.effectCount / 9) * 71 + 71);
}
}
@Override
public void setDir(int dir) {
}//用不到
}
| [
"[email protected]"
] | |
e2ef4dd6d1eea19963aa77d23c72e67481db7061 | 7636e33a07a38002296475be03bf02ccb4ee3ceb | /v17-web/v17-order/src/main/java/com/hgz/v17order/config/RabbitConfig.java | dba8c714fe11d628c51341c695257570f08b3997 | [] | no_license | DialogD/v17 | 3777b220acbe875a9dd19df8c2ac2f84901cfc93 | edd86444dc4595e7fdea2b0adc9ca7d08431286a | refs/heads/master | 2023-03-03T19:37:06.118354 | 2021-02-20T09:02:06 | 2021-02-20T09:06:29 | 340,552,708 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,085 | java | package com.hgz.v17order.config;
import com.hgz.commons.constant.MQConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: DJA
* @Date: 2019/11/21
*/
@Configuration
public class RabbitConfig {
@Bean
public TopicExchange initOrderTopicExchange(){
TopicExchange topicExchange = new TopicExchange(MQConstant.EXCHANGE.ORDER_EXCHANGE,true,false);
return topicExchange;
}
@Bean
public Queue initOrderQueue(){
Queue queue = new Queue(MQConstant.QUEUE.ORDER_QUEUE,true,false,false);
return queue;
}
@Bean
public Binding bindOrderExchange(Queue initOrderQueue,
TopicExchange initOrderTopicExchange){
return BindingBuilder.bind(initOrderQueue).to(initOrderTopicExchange).with("order.create");
}
}
| [
"[email protected]"
] | |
26f840e9f86f90e233268c15d8539a003e192071 | cd892d377017f1ce50e6a92aa19c4bf64cdc31af | /src/test/java/com/gdufe/exercise_app/service/CoinDetailServiceTest.java | 1ce854b7910a5f1758cc3d2222ceaa9fac4b527f | [] | no_license | gdufexzq/exercise_app | bc90c2a2f810d8f1713527007cebdb40acdafca0 | a2a235600726671bea7601b2fa0a9c1316f38bf2 | refs/heads/master | 2021-11-03T18:12:28.440708 | 2019-04-26T09:42:09 | 2019-04-26T09:42:09 | 182,353,422 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 927 | java | package com.gdufe.exercise_app.service;
import com.gdufe.exercise_app.ExerciseAppApplicationTests;
import com.gdufe.exercise_app.entity.CoinDetail;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import static org.junit.Assert.*;
public class CoinDetailServiceTest extends ExerciseAppApplicationTests {
@Autowired
private CoinDetailService coinDetailService;
@Test
public void testSave(){
String openId = "ooVES0RPqnsd1MVza4rwcWyKUAfs";
long qiandaoTime = new Date().getTime();
CoinDetail coinDetail = new CoinDetail();
coinDetail.setCoin(10L);
coinDetail.setBeizhu("签到");
coinDetail.setCreateTime(qiandaoTime);
coinDetail.setModifyTime(qiandaoTime);
coinDetail.setOpenId(openId);
coinDetail.setUserName(" ");
coinDetailService.save(coinDetail);
}
} | [
"[email protected]"
] | |
5424d97cb828adf219fb6dd1204030786754c1ba | b8ce556ee3c6cebcfb51b0959ea4f7935fba0a80 | /src/main/java/com/emart/user/service/userservice/jwtsecurity/JwtAuthenticationEntryPoint.java | 1079431bfdb92d630ae69d3678cb176003047a72 | [] | no_license | NathalieSong/FSD-Stackathon-Backend-User-Service | 9e322a3c196b83a7148e074cee167224f4c03b3e | b65ed221033643b9387642a220f80410c5217a3e | refs/heads/master | 2022-11-05T21:10:54.651496 | 2020-06-11T13:35:25 | 2020-06-11T13:35:25 | 262,735,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 869 | java | package com.emart.user.service.userservice.jwtsecurity;
import java.io.IOException;
import java.io.Serializable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = 1L;
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException, ServletException {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
} | [
"[email protected]"
] | |
029e30cdfac631e53a87f155d9c21d2ca3ec7c27 | a89792ab19fc2c13c03b5df6994ea89bdf441846 | /DVDLibrary/src/main/java/com/sg/dvdlibrary/dao/DVDLibraryDao.java | a93efbce2149165d53e6b0301550a579e4ac1e7a | [] | no_license | croyfish/SoftwareGuild | 8bc360eb0356423e074070a9f12bfe79800fba02 | 35d4fafc4dcb801c54706a76d29674081de8b8c6 | refs/heads/master | 2021-05-12T17:23:52.243392 | 2017-11-17T19:41:51 | 2017-11-17T19:41:51 | 117,042,729 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,136 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.sg.dvdlibrary.dao;
import com.sg.dvdlibrary.dto.DVD;
import java.util.List;
import java.util.Map;
/**
*
* @author jeffc
*/
public interface DVDLibraryDao {
public void loadLibrary();
public DVD addDVD(String SKU, DVD dvd)
throws DVDLibraryPersistenceException;
public DVD editDVD(String SKU, DVD dvd)
throws DVDLibraryPersistenceException;
public List<DVD> getAllDVDs()
throws DVDLibraryPersistenceException;
public DVD getDVD(String SKU)
throws DVDLibraryPersistenceException;
public DVD removeDVD(String SKU)
throws DVDLibraryPersistenceException;
public List<DVD> getDVDsByTitle(String title)
throws DVDLibraryPersistenceException;
public boolean verifySKU(String SKU)
throws DVDLibraryPersistenceException;
public String getNewSKU()
throws DVDLibraryPersistenceException;
public void saveOnExit()
throws DVDLibraryPersistenceException;
public List<DVD> getAllMoviesReleasedInLastNYears(int N)
throws DVDLibraryPersistenceException;
public List<DVD> getAllMoviesWithGivenMPAARating(String MPAARating)
throws DVDLibraryPersistenceException;
public Map<String, List<DVD>> getAllMoviesByGivenDirectorSortedByMPAARating(String Director)
throws DVDLibraryPersistenceException;
public List<DVD> getAllMoviesReleasedByStudio(String Studio)
throws DVDLibraryPersistenceException;
public double getAverageAgeOfAllMovies()
throws DVDLibraryPersistenceException;
public List<DVD> getNewestMovie()
throws DVDLibraryPersistenceException;;
public List<DVD> getOldestMovie()
throws DVDLibraryPersistenceException;
public double getAverageNumberOfNotesPerMovie()
throws DVDLibraryPersistenceException;
public List<DVD> getListOfDVDs ()
throws DVDLibraryPersistenceException;
}
| [
"[email protected]"
] | |
a3b8a75bca59bbb7f6b46ac9a7826d5c07fad4c2 | 33b16f265b765663f677bb77e15163f245e1221d | /src/main/java/com/revature/teamManager/util/exceptions/ResourcePersistenceException.java | 4f96a5b33f6084e832e8816bbe55c454a6500d30 | [] | no_license | ColbyDub/CLMW_api_p2 | 7172d3ae5f820b94e6b6a034dfc93cf1c7268334 | 3a4c5eca721323ded1e90606f3150a79b43eab19 | refs/heads/main | 2023-08-12T20:34:59.007349 | 2021-09-21T02:22:36 | 2021-09-21T02:22:36 | 401,490,833 | 0 | 2 | null | 2021-09-22T14:03:27 | 2021-08-30T21:28:20 | Java | UTF-8 | Java | false | false | 212 | java | package com.revature.teamManager.util.exceptions;
public class ResourcePersistenceException extends RuntimeException {
public ResourcePersistenceException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
b35670d03ab5f61fd3833a29a1f7fe37fd71323b | 9f79a9d773d27d6bb2bfe9c88e48066042225505 | /src/test/java/kr/ac/kaist/salab/SALabWebsiteApplicationTests.java | f91f170e9444a8ac155e802198fa53a7af4adee5 | [] | no_license | gkm2164/salab-web | a24855607877f6560a16dddd5bd924bf8e7c6abd | eb21bd2f4649dfb0780b0b34ac89987a8dc67785 | refs/heads/master | 2021-01-10T10:50:34.140087 | 2016-08-12T12:41:56 | 2016-08-12T12:41:56 | 52,427,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package kr.ac.kaist.salab;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SALabWebsiteApplication.class)
@WebAppConfiguration
public class SALabWebsiteApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
4c87fcc22cbe4ef590a6367cbb8d6d7ddc724458 | 119765610e20b77e1d81a6bbfef99f49e382aef8 | /qq-spring/src/main/java/com/github/rygh/qq/spring/QQSpringLifecycleBean.java | af97b78da39cce155289363efe46b2b9392410ce | [] | no_license | rygh/qq | 809ad4a3072e3af71c3e4a42ba9a123cfa34fbc9 | 28e9a72c0f932e62bfdda17e9b5144ccdee96f68 | refs/heads/master | 2022-08-10T12:21:12.133727 | 2022-07-30T17:49:56 | 2022-07-30T17:49:56 | 134,170,019 | 0 | 0 | null | 2022-07-30T17:49:57 | 2018-05-20T17:04:50 | Java | UTF-8 | Java | false | false | 760 | java | package com.github.rygh.qq.spring;
import org.springframework.context.SmartLifecycle;
import com.github.rygh.qq.QQServer;
public class QQSpringLifecycleBean implements SmartLifecycle {
private QQServer runtime;
private boolean running = false;
public QQSpringLifecycleBean(QQServer runtime) {
this.runtime = runtime;
}
@Override
public void start() {
runtime.start();
running = true;
}
@Override
public void stop() {
runtime.stop();
running = false;
}
@Override
public boolean isRunning() {
return running;
}
@Override
public int getPhase() {
return Integer.MAX_VALUE;
}
@Override
public boolean isAutoStartup() {
return true;
}
@Override
public void stop(Runnable callback) {
stop();
callback.run();
}
}
| [
"[email protected]"
] | |
42c93d4884ab3a8f770d0aaebb0a40dac2ab48d7 | 6a44dd09339a8867b36191e95e8721a2d2f92a4d | /AI Chess Game/src/game/impl/moves/PawnCapturePromotion.java | 3e7bb0ab47e4710026f5f4231cc49777efbce183 | [] | no_license | ankurkhetan2015/Java | 61855a1bf7a9bdac9bd52a56d83c1787b740df17 | 5d0407715284ea3f8d043cd72d91aa164a8697b0 | refs/heads/master | 2020-07-17T05:24:12.301429 | 2020-05-03T18:02:09 | 2020-05-03T18:02:09 | 205,955,090 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 467 | java | package game.impl.moves;
import game.ILocation;
import game.IPromotionMove;
import pieces.IPiece;
public class PawnCapturePromotion extends CaptureMove implements IPromotionMove {
private IPiece promotion;
public PawnCapturePromotion(IPiece piece, ILocation from, ILocation to, IPiece promotion) {
super(piece, from, to);
this.promotion = promotion;
}
@Override
public IPiece getPromotion() {
return promotion;
}
}
| [
"[email protected]"
] | |
5f74112cd67c9a1a181386be83d13d8ed612640a | 1c12da9c1e39b9b79c717725b5f0fbd8a1d5bb40 | /src/test/java/com/nimbusds/openid/connect/sdk/validators/IDTokenValidatorWithHTTPTest.java | d9d059e4b825955c9366f3eb8dbdeca9b8b32456 | [
"Apache-2.0"
] | permissive | kuaizionly11/OAuth-2.0 | 612ce41910e397ec45e4394a88bca34566d5d8ca | 812516088bd97751604627a0dfd47c832074a245 | refs/heads/master | 2021-01-17T07:32:07.546477 | 2017-02-27T07:44:44 | 2017-02-27T07:44:44 | 83,744,970 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,462 | java | /*
* oauth2-oidc-sdk
*
* Copyright 2012-2016, Connect2id Ltd and contributors.
*
* 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.nimbusds.openid.connect.sdk.validators;
import java.net.URI;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import static net.jadler.Jadler.*;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jose.crypto.RSASSASigner;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
import com.nimbusds.jose.jwk.source.ImmutableJWKSet;
import com.nimbusds.jose.proc.BadJOSEException;
import com.nimbusds.jose.proc.BadJWSException;
import com.nimbusds.jwt.SignedJWT;
import com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod;
import com.nimbusds.oauth2.sdk.auth.Secret;
import com.nimbusds.oauth2.sdk.id.Audience;
import com.nimbusds.oauth2.sdk.id.ClientID;
import com.nimbusds.oauth2.sdk.id.Issuer;
import com.nimbusds.oauth2.sdk.id.Subject;
import com.nimbusds.openid.connect.sdk.SubjectType;
import com.nimbusds.openid.connect.sdk.claims.IDTokenClaimsSet;
import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientInformation;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
import junit.framework.TestCase;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.After;
import org.junit.Before;
/**
* Tests the static factory method with HTTP retrieval of remote OP JWK set to
* complete ID token validation.
*/
public class IDTokenValidatorWithHTTPTest extends TestCase {
@Before
public void setUp() {
initJadler();
}
@After
public void tearDown() {
closeJadler();
}
private Pair<OIDCProviderMetadata,List<RSAKey>> createOPMetadata()
throws Exception {
// Generate 2 RSA keys for the OP
KeyPairGenerator pairGen = KeyPairGenerator.getInstance("RSA");
pairGen.initialize(1024);
KeyPair keyPair = pairGen.generateKeyPair();
final RSAKey rsaJWK1 = new RSAKey.Builder((RSAPublicKey) keyPair.getPublic())
.privateKey((RSAPrivateKey) keyPair.getPrivate())
.keyID("1")
.build();
keyPair = pairGen.generateKeyPair();
final RSAKey rsaJWK2 = new RSAKey.Builder((RSAPublicKey) keyPair.getPublic())
.privateKey((RSAPrivateKey) keyPair.getPrivate())
.keyID("2")
.build();
OIDCProviderMetadata opMetadata = new OIDCProviderMetadata(
new Issuer("https://c2id.com"),
Collections.singletonList(SubjectType.PUBLIC),
URI.create("http://localhost:" + port() + "/jwks.json"));
opMetadata.setIDTokenJWSAlgs(Arrays.asList(JWSAlgorithm.RS256, JWSAlgorithm.HS256));
opMetadata.setIDTokenJWEAlgs(Collections.singletonList(JWEAlgorithm.RSA1_5));
opMetadata.setIDTokenJWEEncs(Arrays.asList(EncryptionMethod.A128CBC_HS256, EncryptionMethod.A128GCM));
opMetadata.setTokenEndpointAuthMethods(Collections.singletonList(ClientAuthenticationMethod.CLIENT_SECRET_BASIC));
opMetadata.applyDefaults();
onRequest()
.havingMethodEqualTo("GET")
.havingPathEqualTo("/jwks.json")
.respond()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody(new JWKSet(Arrays.asList((JWK)rsaJWK1, (JWK)rsaJWK2)).toJSONObject().toJSONString());
return new ImmutablePair<>(opMetadata, Arrays.asList(rsaJWK1, rsaJWK2));
}
public void testStaticFactoryMethod_RS256()
throws Exception {
// Create OP metadata
Pair<OIDCProviderMetadata,List<RSAKey>> opInfo = createOPMetadata();
OIDCProviderMetadata opMetadata = opInfo.getLeft();
RSAKey rsaKey1 = opInfo.getRight().get(0);
RSAKey rsaKey2 = opInfo.getRight().get(1);
// Create client registration
OIDCClientMetadata metadata = new OIDCClientMetadata();
metadata.setRedirectionURI(URI.create("https://example.com/cb"));
metadata.applyDefaults();
OIDCClientInformation clientInfo = new OIDCClientInformation(new ClientID("123"), new Date(), metadata, new Secret());
// Create validator
IDTokenValidator v = IDTokenValidator.create(opMetadata, clientInfo, null);
assertEquals(opMetadata.getIssuer(), v.getExpectedIssuer());
assertEquals(clientInfo.getID(), v.getClientID());
assertNotNull(v.getJWSKeySelector());
assertNull(v.getJWEKeySelector());
// Check JWS key selector
List<Key> matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), null);
assertEquals(1, matches.size());
matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey2.getKeyID()).build(), null);
assertEquals(1, matches.size());
matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).build(), null);
assertEquals(2, matches.size());
// Create ID token
final Date now = new Date();
final Date inOneHour = new Date(now.getTime() + 3600*1000L);
IDTokenClaimsSet claimsSet = new IDTokenClaimsSet(
opMetadata.getIssuer(),
new Subject("alice"),
new Audience(clientInfo.getID()).toSingleAudienceList(),
inOneHour, // exp
now); // iat
SignedJWT idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
// Validate
IDTokenClaimsSet validated = v.validate(idToken, null);
assertEquals(claimsSet.getIssuer(), validated.getIssuer());
assertEquals(claimsSet.getSubject(), validated.getSubject());
assertEquals(claimsSet.getAudience().get(0), validated.getAudience().get(0));
assertEquals(1, validated.getAudience().size());
assertEquals(claimsSet.getExpirationTime(), validated.getExpirationTime());
assertEquals(claimsSet.getIssueTime(), validated.getIssueTime());
// Create an ID token with unspecified key ID
idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
// Validate again
validated = v.validate(idToken, null);
assertEquals(claimsSet.getIssuer(), validated.getIssuer());
assertEquals(claimsSet.getSubject(), validated.getSubject());
assertEquals(claimsSet.getAudience().get(0), validated.getAudience().get(0));
assertEquals(1, validated.getAudience().size());
assertEquals(claimsSet.getExpirationTime(), validated.getExpirationTime());
assertEquals(claimsSet.getIssueTime(), validated.getIssueTime());
// Sign ID token with invalid RSA key
KeyPairGenerator pairGen = KeyPairGenerator.getInstance("RSA");
pairGen.initialize(1024);
KeyPair keyPair = pairGen.generateKeyPair();
final RSAKey badKey = new RSAKey.Builder((RSAPublicKey) keyPair.getPublic())
.privateKey((RSAPrivateKey) keyPair.getPrivate())
.keyID("1")
.build();
idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(badKey));
try {
v.validate(idToken, null);
fail();
} catch (BadJWSException e) {
assertEquals("Signed JWT rejected: Invalid signature", e.getMessage());
}
// Sign ID token with RSA key with unexpected key ID
idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID("XXXXXXX").build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
try {
v.validate(idToken, null);
fail();
} catch (BadJOSEException e) {
assertEquals("Signed JWT rejected: No matching key(s) found", e.getMessage());
}
}
public void testStaticFactoryMethod_nested_JWS_JWE()
throws Exception {
// Create OP metadata
Pair<OIDCProviderMetadata,List<RSAKey>> opInfo = createOPMetadata();
OIDCProviderMetadata opMetadata = opInfo.getLeft();
RSAKey rsaKey1 = opInfo.getRight().get(0);
RSAKey rsaKey2 = opInfo.getRight().get(1);
// Create client registration
KeyPairGenerator pairGen = KeyPairGenerator.getInstance("RSA");
pairGen.initialize(1024);
KeyPair clientKeyPair = pairGen.generateKeyPair();
final RSAKey clientJWK = new RSAKey.Builder((RSAPublicKey) clientKeyPair.getPublic())
.privateKey((RSAPrivateKey) clientKeyPair.getPrivate())
.keyID("e1")
.build();
OIDCClientMetadata metadata = new OIDCClientMetadata();
metadata.setRedirectionURI(URI.create("https://example.com/cb"));
metadata.setIDTokenJWSAlg(JWSAlgorithm.RS256);
metadata.setIDTokenJWEAlg(JWEAlgorithm.RSA1_5);
metadata.setIDTokenJWEEnc(EncryptionMethod.A128CBC_HS256);
metadata.applyDefaults();
OIDCClientInformation clientInfo = new OIDCClientInformation(new ClientID("123"), new Date(), metadata, new Secret());
// Create validator
IDTokenValidator v = IDTokenValidator.create(opMetadata, clientInfo, new ImmutableJWKSet(new JWKSet(clientJWK)));
assertEquals(opMetadata.getIssuer(), v.getExpectedIssuer());
assertEquals(clientInfo.getID(), v.getClientID());
assertNotNull(v.getJWSKeySelector());
assertNotNull(v.getJWEKeySelector());
// Check JWS key selector
List<Key> matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), null);
assertEquals(1, matches.size());
matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey2.getKeyID()).build(), null);
assertEquals(1, matches.size());
matches = v.getJWSKeySelector().selectJWSKeys(new JWSHeader.Builder(JWSAlgorithm.RS256).build(), null);
assertEquals(2, matches.size());
// Check JWE key selector
matches = v.getJWEKeySelector().selectJWEKeys(new JWEHeader.Builder(JWEAlgorithm.RSA1_5, EncryptionMethod.A128CBC_HS256).keyID("e1").build(), null);
assertEquals(1, matches.size());
// Create ID token
final Date now = new Date();
final Date inOneHour = new Date(now.getTime() + 3600*1000L);
IDTokenClaimsSet claimsSet = new IDTokenClaimsSet(
opMetadata.getIssuer(),
new Subject("alice"),
new Audience(clientInfo.getID()).toSingleAudienceList(),
inOneHour, // exp
now); // iat
SignedJWT idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
// Encrypt with client public RSA key
JWEObject encrypted = new JWEObject(new JWEHeader.Builder(JWEAlgorithm.RSA1_5, EncryptionMethod.A128CBC_HS256).keyID("e1").build(), new Payload(idToken));
encrypted.encrypt(new RSAEncrypter(clientJWK));
// Validate
IDTokenClaimsSet validated = v.validate(idToken, null);
assertEquals(claimsSet.getIssuer(), validated.getIssuer());
assertEquals(claimsSet.getSubject(), validated.getSubject());
assertEquals(claimsSet.getAudience().get(0), validated.getAudience().get(0));
assertEquals(1, validated.getAudience().size());
assertEquals(claimsSet.getExpirationTime(), validated.getExpirationTime());
assertEquals(claimsSet.getIssueTime(), validated.getIssueTime());
// Create an ID token with unspecified key ID
idToken = new SignedJWT(new JWSHeader(JWSAlgorithm.RS256), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
encrypted = new JWEObject(new JWEHeader(JWEAlgorithm.RSA1_5, EncryptionMethod.A128CBC_HS256), new Payload(idToken));
encrypted.encrypt(new RSAEncrypter(clientJWK));
// Validate again
validated = v.validate(idToken, null);
assertEquals(claimsSet.getIssuer(), validated.getIssuer());
assertEquals(claimsSet.getSubject(), validated.getSubject());
assertEquals(claimsSet.getAudience().get(0), validated.getAudience().get(0));
assertEquals(1, validated.getAudience().size());
assertEquals(claimsSet.getExpirationTime(), validated.getExpirationTime());
assertEquals(claimsSet.getIssueTime(), validated.getIssueTime());
// Sign ID token with invalid RSA key
KeyPair keyPair = pairGen.generateKeyPair();
final RSAKey badKey = new RSAKey.Builder((RSAPublicKey) keyPair.getPublic())
.privateKey((RSAPrivateKey) keyPair.getPrivate())
.keyID("1")
.build();
idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey1.getKeyID()).build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(badKey));
try {
v.validate(idToken, null);
fail();
} catch (BadJWSException e) {
assertEquals("Signed JWT rejected: Invalid signature", e.getMessage());
}
// Sign ID token with RSA key with unexpected key ID
idToken = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).keyID("XXXXXXX").build(), claimsSet.toJWTClaimsSet());
idToken.sign(new RSASSASigner(rsaKey1));
try {
v.validate(idToken, null);
fail();
} catch (BadJOSEException e) {
assertEquals("Signed JWT rejected: No matching key(s) found", e.getMessage());
}
}
}
| [
"[email protected]"
] | |
39f46f7688493817f1219272002f1642f214e922 | 5de4f2b06230348e574792dac1bc1e9eb96949ad | /volley/src/main/java/com/android/volley/Request.java | 06ab75edb560c18a5228c2227f5a433d7129dfe2 | [] | no_license | explaraTech/ExplaraAndroidSDK | d3f9dd14028559fdf34cbc73995b0617ab3ea8ac | b9e7f832e7bb98e7bce4b3694e3a1db8e14f8582 | refs/heads/master | 2020-04-06T03:38:45.296205 | 2016-07-04T14:14:00 | 2016-07-04T14:14:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,223 | java | /*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.volley;
import android.content.Context;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import com.android.volley.VolleyLog.MarkerLog;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Map;
/**
* Base class for all network requests.
*
* @param <T> The type of parsed response this request expects.
*/
public abstract class Request<T> implements Comparable<Request<T>> {
/**
* Default encoding for POST or PUT parameters. See {@link #getParamsEncoding()}.
*/
private static final String DEFAULT_PARAMS_ENCODING = "UTF-8";
/**
* Supported request methods.
*/
public interface Method {
int DEPRECATED_GET_OR_POST = -1;
int GET = 0;
int POST = 1;
int PUT = 2;
int DELETE = 3;
int HEAD = 4;
int OPTIONS = 5;
int TRACE = 6;
int PATCH = 7;
}
/** An event log tracing the lifetime of this request; for debugging. */
private final MarkerLog mEventLog = MarkerLog.ENABLED ? new MarkerLog() : null;
/**
* Request method of this request. Currently supports GET, POST, PUT, DELETE, HEAD, OPTIONS,
* TRACE, and PATCH.
*/
private final int mMethod;
/** URL of this request. */
private final String mUrl;
/** Default tag for {@link TrafficStats}. */
private final int mDefaultTrafficStatsTag;
/** Listener interface for errors. */
private final Response.ErrorListener mErrorListener;
/** Sequence number of this request, used to enforce FIFO ordering. */
private Integer mSequence;
/** The request queue this request is associated with. */
private RequestQueue mRequestQueue;
/** Whether or not responses to this request should be cached. */
private boolean mShouldCache = true;
/** Whether or not this request has been canceled. */
private boolean mCanceled = false;
/** Whether or not a response has been delivered for this request yet. */
private boolean mResponseDelivered = false;
/** The retry policy for this request. */
private RetryPolicy mRetryPolicy;
public Context applicationCtx;
/**
* When a request can be retrieved from cache but must be refreshed from
* the network, the cache entry will be stored here so that in the event of
* a "Not Modified" response, we can be sure it hasn't been evicted from cache.
*/
private Cache.Entry mCacheEntry = null;
/** An opaque token tagging this request; used for bulk cancellation. */
private Object mTag;
/**
* Creates a new request with the given URL and error listener. Note that
* the normal response listener is not provided here as delivery of responses
* is provided by subclasses, who have a better idea of how to deliver an
* already-parsed response.
*
* @deprecated Use {@link #Request(int, String, com.android.volley.Response.ErrorListener)}.
*/
@Deprecated
public Request(String url, Response.ErrorListener listener) {
this(Method.DEPRECATED_GET_OR_POST, url, listener);
}
/**
* Creates a new request with the given method (one of the values from {@link Method}),
* URL, and error listener. Note that the normal response listener is not provided here as
* delivery of responses is provided by subclasses, who have a better idea of how to deliver
* an already-parsed response.
*/
public Request(int method, String url, Response.ErrorListener listener) {
mMethod = method;
mUrl = url;
mErrorListener = listener;
setRetryPolicy(new DefaultRetryPolicy());
mDefaultTrafficStatsTag = findDefaultTrafficStatsTag(url);
}
/**
* Return the method for this request. Can be one of the values in {@link Method}.
*/
public int getMethod() {
return mMethod;
}
/**
* Set a tag on this request. Can be used to cancel all requests with this
* tag by {@link RequestQueue#cancelAll(Object)}.
*
* @return This Request object to allow for chaining.
*/
public Request<?> setTag(Object tag) {
mTag = tag;
return this;
}
/**
* Returns this request's tag.
* @see Request#setTag(Object)
*/
public Object getTag() {
return mTag;
}
/**
* @return this request's {@link com.android.volley.Response.ErrorListener}.
*/
public Response.ErrorListener getErrorListener() {
return mErrorListener;
}
/**
* @return A tag for use with {@link TrafficStats#setThreadStatsTag(int)}
*/
public int getTrafficStatsTag() {
return mDefaultTrafficStatsTag;
}
/**
* @return The hashcode of the URL's host component, or 0 if there is none.
*/
private static int findDefaultTrafficStatsTag(String url) {
if (!TextUtils.isEmpty(url)) {
Uri uri = Uri.parse(url);
if (uri != null) {
String host = uri.getHost();
if (host != null) {
return host.hashCode();
}
}
}
return 0;
}
/**
* Sets the retry policy for this request.
*
* @return This Request object to allow for chaining.
*/
public Request<?> setRetryPolicy(RetryPolicy retryPolicy) {
mRetryPolicy = retryPolicy;
return this;
}
/**
* Adds an event to this request's event log; for debugging.
*/
public void addMarker(String tag) {
if (MarkerLog.ENABLED) {
mEventLog.add(tag, Thread.currentThread().getId());
}
}
/**
* Notifies the request queue that this request has finished (successfully or with error).
*
* <p>Also dumps all events from this request's event log; for debugging.</p>
*/
void finish(final String tag) {
if (mRequestQueue != null) {
mRequestQueue.finish(this);
}
if (MarkerLog.ENABLED) {
final long threadId = Thread.currentThread().getId();
if (Looper.myLooper() != Looper.getMainLooper()) {
// If we finish marking off of the main thread, we need to
// actually do it on the main thread to ensure correct ordering.
Handler mainThread = new Handler(Looper.getMainLooper());
mainThread.post(new Runnable() {
@Override
public void run() {
mEventLog.add(tag, threadId);
mEventLog.finish(this.toString());
}
});
return;
}
mEventLog.add(tag, threadId);
mEventLog.finish(this.toString());
}
}
/**
* Associates this request with the given queue. The request queue will be notified when this
* request has finished.
*
* @return This Request object to allow for chaining.
*/
public Request<?> setRequestQueue(RequestQueue requestQueue) {
mRequestQueue = requestQueue;
return this;
}
/**
* Sets the sequence number of this request. Used by {@link RequestQueue}.
*
* @return This Request object to allow for chaining.
*/
public final Request<?> setSequence(int sequence) {
mSequence = sequence;
return this;
}
/**
* Returns the sequence number of this request.
*/
public final int getSequence() {
if (mSequence == null) {
throw new IllegalStateException("getSequence called before setSequence");
}
return mSequence;
}
/**
* Returns the URL of this request.
*/
public String getUrl() {
return mUrl;
}
/**
* Returns the cache key for this request. By default, this is the URL.
*/
public String getCacheKey() {
return getUrl();
}
/**
* Annotates this request with an entry retrieved for it from cache.
* Used for cache coherency support.
*
* @return This Request object to allow for chaining.
*/
public Request<?> setCacheEntry(Cache.Entry entry) {
mCacheEntry = entry;
return this;
}
/**
* Returns the annotated cache entry, or null if there isn't one.
*/
public Cache.Entry getCacheEntry() {
return mCacheEntry;
}
/**
* Mark this request as canceled. No callback will be delivered.
*/
public void cancel() {
mCanceled = true;
}
/**
* Returns true if this request has been canceled.
*/
public boolean isCanceled() {
return mCanceled;
}
/**
* Returns a list of extra HTTP headers to go along with this request. Can
* throw {@link AuthFailureError} as authentication may be required to
* provide these values.
* @throws AuthFailureError In the event of auth failure
*/
public Map<String, String> getHeaders() throws AuthFailureError {
return Collections.emptyMap();
}
/**
* Returns a Map of POST parameters to be used for this request, or null if
* a simple GET should be used. Can throw {@link AuthFailureError} as
* authentication may be required to provide these values.
*
* <p>Note that only one of getPostParams() and getPostBody() can return a non-null
* value.</p>
* @throws AuthFailureError In the event of auth failure
*
* @deprecated Use {@link #getParams()} instead.
*/
@Deprecated
protected Map<String, String> getPostParams() throws AuthFailureError {
return getParams();
}
/**
* Returns which encoding should be used when converting POST parameters returned by
* {@link #getPostParams()} into a raw POST body.
*
* <p>This controls both encodings:
* <ol>
* <li>The string encoding used when converting parameter names and values into bytes prior
* to URL encoding them.</li>
* <li>The string encoding used when converting the URL encoded parameters into a raw
* byte array.</li>
* </ol>
*
* @deprecated Use {@link #getParamsEncoding()} instead.
*/
@Deprecated
protected String getPostParamsEncoding() {
return getParamsEncoding();
}
/**
* @deprecated Use {@link #getBodyContentType()} instead.
*/
@Deprecated
public String getPostBodyContentType() {
return getBodyContentType();
}
/**
* Returns the raw POST body to be sent.
*
* @throws AuthFailureError In the event of auth failure
*
* @deprecated Use {@link #getBody()} instead.
*/
@Deprecated
public byte[] getPostBody() throws AuthFailureError {
// Note: For compatibility with legacy clients of volley, this implementation must remain
// here instead of simply calling the getBody() function because this function must
// call getPostParams() and getPostParamsEncoding() since legacy clients would have
// overridden these two member functions for POST requests.
Map<String, String> postParams = getPostParams();
if (postParams != null && postParams.size() > 0) {
return encodeParameters(postParams, getPostParamsEncoding());
}
return null;
}
/**
* Returns a Map of parameters to be used for a POST or PUT request. Can throw
* {@link AuthFailureError} as authentication may be required to provide these values.
*
* <p>Note that you can directly override {@link #getBody()} for custom data.</p>
*
* @throws AuthFailureError in the event of auth failure
*/
protected Map<String, String> getParams() throws AuthFailureError {
return null;
}
/**
* Returns which encoding should be used when converting POST or PUT parameters returned by
* {@link #getParams()} into a raw POST or PUT body.
*
* <p>This controls both encodings:
* <ol>
* <li>The string encoding used when converting parameter names and values into bytes prior
* to URL encoding them.</li>
* <li>The string encoding used when converting the URL encoded parameters into a raw
* byte array.</li>
* </ol>
*/
protected String getParamsEncoding() {
return DEFAULT_PARAMS_ENCODING;
}
/**
* Returns the content type of the POST or PUT body.
*/
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
}
/**
* Returns the raw POST or PUT body to be sent.
*
* <p>By default, the body consists of the request parameters in
* application/x-www-form-urlencoded format. When overriding this method, consider overriding
* {@link #getBodyContentType()} as well to match the new body format.
*
* @throws AuthFailureError in the event of auth failure
*/
public byte[] getBody() throws AuthFailureError {
Map<String, String> params = getParams();
if (params != null && params.size() > 0) {
return encodeParameters(params, getParamsEncoding());
}
return null;
}
/**
* Converts <code>params</code> into an application/x-www-form-urlencoded encoded string.
*/
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
StringBuilder encodedParams = new StringBuilder();
try {
for (Map.Entry<String, String> entry : params.entrySet()) {
encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding));
encodedParams.append('=');
encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding));
encodedParams.append('&');
}
return encodedParams.toString().getBytes(paramsEncoding);
} catch (UnsupportedEncodingException uee) {
throw new RuntimeException("Encoding not supported: " + paramsEncoding, uee);
}
}
/**
* Set whether or not responses to this request should be cached.
*
* @return This Request object to allow for chaining.
*/
public final Request<?> setShouldCache(boolean shouldCache) {
mShouldCache = shouldCache;
return this;
}
/**
* Returns true if responses to this request should be cached.
*/
public final boolean shouldCache() {
return mShouldCache;
}
/**
* Priority values. Requests will be processed from higher priorities to
* lower priorities, in FIFO order.
*/
public enum Priority {
LOW,
NORMAL,
HIGH,
IMMEDIATE
}
/**
* Returns the {@link Priority} of this request; {@link Priority#NORMAL} by default.
*/
public Priority getPriority() {
return Priority.NORMAL;
}
/**
* Returns the socket timeout in milliseconds per retry attempt. (This value can be changed
* per retry attempt if a backoff is specified via backoffTimeout()). If there are no retry
* attempts remaining, this will cause delivery of a {@link TimeoutError} error.
*/
public final int getTimeoutMs() {
return mRetryPolicy.getCurrentTimeout();
}
/**
* Returns the retry policy that should be used for this request.
*/
public RetryPolicy getRetryPolicy() {
return mRetryPolicy;
}
/**
* Mark this request as having a response delivered on it. This can be used
* later in the request's lifetime for suppressing identical responses.
*/
public void markDelivered() {
mResponseDelivered = true;
}
/**
* Returns true if this request has had a response delivered for it.
*/
public boolean hasHadResponseDelivered() {
return mResponseDelivered;
}
/**
* Subclasses must implement this to parse the raw network response
* and return an appropriate response type. This method will be
* called from a worker thread. The response will not be delivered
* if you return null.
* @param response Response from the network
* @return The parsed response, or null in the case of an error
*/
abstract protected Response<T> parseNetworkResponse(NetworkResponse response);
/**
* Subclasses can override this method to parse 'networkError' and return a more specific error.
*
* <p>The default implementation just returns the passed 'networkError'.</p>
*
* @param volleyError the error retrieved from the network
* @return an NetworkError augmented with additional information
*/
protected VolleyError parseNetworkError(VolleyError volleyError) {
return volleyError;
}
/**
* Subclasses must implement this to perform delivery of the parsed
* response to their listeners. The given response is guaranteed to
* be non-null; responses that fail to parse are not delivered.
* @param response The parsed response returned by
* {@link #parseNetworkResponse(NetworkResponse)}
*/
abstract protected void deliverResponse(T response);
/**
* Delivers error message to the ErrorListener that the Request was
* initialized with.
*
* @param error Error details
*/
public void deliverError(VolleyError error) {
if (mErrorListener != null) {
mErrorListener.onErrorResponse(error);
}
}
/**
* Our comparator sorts from high to low priority, and secondarily by
* sequence number to provide FIFO ordering.
*/
@Override
public int compareTo(Request<T> other) {
Priority left = this.getPriority();
Priority right = other.getPriority();
// High-priority requests are "lesser" so they are sorted to the front.
// Equal priorities are sorted by sequence number to provide FIFO ordering.
return left == right ?
this.mSequence - other.mSequence :
right.ordinal() - left.ordinal();
}
@Override
public String toString() {
String trafficStatsTag = "0x" + Integer.toHexString(getTrafficStatsTag());
return (mCanceled ? "[X] " : "[ ] ") + getUrl() + " " + trafficStatsTag + " "
+ getPriority() + " " + mSequence;
}
}
| [
"[email protected]"
] | |
70071fc381ae6a67c1ab400a0aa0449ffeebb327 | 1c9371ffe72e6c3edabce10d34598d821239da56 | /src/main/java/lab1/AnyaSuperIntegerList.java | 4180138eabc11ddb161e8e73f7989526ba5e3f7b | [] | no_license | anna-gor/JavaSchool | 04987ec5f73fc389d46da45fcc7bf93f3904306e | f1e11154b08db80223e6df53794a0f22cb39d4b1 | refs/heads/master | 2023-07-16T12:20:34.643849 | 2021-08-24T17:06:57 | 2021-08-24T17:06:57 | 396,861,572 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,941 | java | package lab1;
import java.util.Arrays;
public class AnyaSuperIntegerList implements SuperIntegerList {
int[] intArray;
int size;
public AnyaSuperIntegerList(int[] someIntegers) {
this.intArray = someIntegers;
this.size = intArray.length;
}
@Override
public void add(int number) {
intArray = Arrays.copyOf(intArray, size + 1);
size++;
intArray[size - 1] = number;
}
@Override
public void removeByIndex(int index) {
int j;
if (index >= size) {
System.out.println("Error: Index greater than length of array");
return;
}
if (index < 0) {
throw new IllegalArgumentException();
} else {
for (j = 0; j < size; j++) {
if (j == index) {
size--;
break;
}
}
for (int k = j; k < size; k++) {
intArray[k] = intArray[k + 1];
}
}
}
@Override
public void removeByValue(int value) {
int j;
for (j = 0; j < size; j++) {
if (intArray[j] == value) {
size--;
break;
}
}
for (int k = j; k < size; k++) {
intArray[k] = intArray[k + 1];
}
}
@Override
public int get(int index) {
if (index < 0) {
throw new IllegalArgumentException();
}
if (index >= size) {
System.out.println("Error: Index greater than length of array");
throw new ArrayIndexOutOfBoundsException();
} else {
return intArray[index];
}
}
@Override
public void printAll() {
for (int j = 0; j < size; j++) {
int i = intArray[j];
System.out.print(i);
System.out.print(' ');
}
System.out.println();
}
}
| [
"[email protected]"
] | |
49ff785910b1d0ec1fd96d4cc04a05b02d81a6ee | 45d83924e31d31a2693edee179909021cc43aaa3 | /src/main/java/com/gazfood/client/gazfoodspringbootclient/service/CafeteriaAndMenuServiceImpl.java | 36c9b4c80fa50c27e2828fff85540b9ab36faddd | [] | no_license | yam86rus/gazFoodSpringBootClient | a01c7b5ed5335981e3706665c766f8bd823156b0 | 2120e58c64a471aceffe2c406272022a8b78d3d5 | refs/heads/main | 2023-05-09T05:42:06.403995 | 2021-06-03T11:09:20 | 2021-06-03T11:09:20 | 373,478,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,502 | java | package com.gazfood.client.gazfoodspringbootclient.service;
import com.gazfood.client.gazfoodspringbootclient.dao.CafeteriaAndMenuRepository;
import com.gazfood.client.gazfoodspringbootclient.entity.CafeteriaAndMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class CafeteriaAndMenuServiceImpl implements CafeteriaAndMenuService {
@Autowired
private CafeteriaAndMenuRepository cafeteriaAndMenuRepository;
@Override
public List<CafeteriaAndMenu> getAllCafeteriaAndMenu() {
List<CafeteriaAndMenu> getAllCafeteriaAndMenu = cafeteriaAndMenuRepository.findAll();
return getAllCafeteriaAndMenu;
}
@Override
public void savaCafeteriaAndMenu(CafeteriaAndMenu cafeteriaAndMenu) {
cafeteriaAndMenuRepository.save(cafeteriaAndMenu);
}
@Override
public CafeteriaAndMenu getCafeteriaAndMenu(int id) {
CafeteriaAndMenu cafeteriaAndMenu = null;
Optional<CafeteriaAndMenu> optional = cafeteriaAndMenuRepository.findById(id);
if (optional.isPresent()) {
cafeteriaAndMenu = optional.get();
}
return cafeteriaAndMenu;
}
@Override
public void deleteCafeteriaAndMenu(int id) {
cafeteriaAndMenuRepository.deleteById(id);
}
@Override
public long getCountCafeteriaAndMenu() {
return cafeteriaAndMenuRepository.count();
}
}
| [
"[email protected]"
] | |
b33108f19ba798c7fde76a99ab26b78a57ebdfe3 | 409d0444d230ac4f3dcfc7dfd8b30770d11f6191 | /auth-service/src/main/java/com/rifkiansyah/authservice/Config/MongoDB/MongoBeeConfig.java | a97498e2185a06af9640bfd9edab1ac64547b128 | [] | no_license | rifkiansyahmc/spring-boot-cloud-oauth | 2ac646dd7e9de47275a538e5b64721fbcc94cfbd | 7cd2bf8bff474517830d7721b0ce591e0dc52de7 | refs/heads/master | 2020-07-30T00:10:25.522208 | 2019-09-21T19:29:52 | 2019-09-21T19:29:52 | 210,012,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,399 | java | package com.rifkiansyah.authservice.Config.MongoDB;
import com.github.mongobee.Mongobee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.data.mongodb.core.MongoTemplate;
@Configuration
@DependsOn("mongoTemplate")
public class MongoBeeConfig {
private static final String MONGODB_URL_FORMAT = "mongodb://%s:%s@%s:%d/%s";
private static final String MONGODB_CHANGELOGS_PACKAGE = "com.marcusdacoregio.authservice.config.mongodb.changelogs";
@Autowired
private MongoProperties mongoProperties;
@Autowired
private MongoTemplate mongoTemplate;
@Bean
public Mongobee mongobee() {
Mongobee runner = new Mongobee(String.format(MONGODB_URL_FORMAT,
mongoProperties.getUsername(),
mongoProperties.getPassword(),
mongoProperties.getHost(),
mongoProperties.getPort(),
mongoProperties.getDatabase()));
runner.setMongoTemplate(mongoTemplate);
runner.setDbName(mongoProperties.getDatabase());
runner.setChangeLogsScanPackage(MONGODB_CHANGELOGS_PACKAGE);
return runner;
}
} | [
"adfx-02morgan"
] | adfx-02morgan |
45d024fc4e4faf1ba3f759b101584b46936e3814 | 10605c0f2e8f40169bf372c0d7c14d8886ca15de | /src/com/iiordanov/domain/UserMsg.java | 5783a39400aea315916e986845239a2cbb797732 | [] | no_license | yangchuyingt/trunkeydesk | be5759c6796e7879984fff549a11af2fed61fd2f | 4222920a3d2be9301eeee94d8d661f109d839022 | refs/heads/master | 2021-08-16T15:33:14.155085 | 2017-11-20T02:57:38 | 2017-11-20T02:57:38 | 111,353,299 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 963 | java | package com.iiordanov.domain;
public class UserMsg {
private String username;
private String password;
private String hostip;
private String managerip;
private String port;
private String updatetime;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getHostip() {
return hostip;
}
public void setHostip(String hostip) {
this.hostip = hostip;
}
public String getManagerip() {
return managerip;
}
public void setManagerip(String managerip) {
this.managerip = managerip;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getUpdatetime() {
return updatetime;
}
public void setUpdatetime(String updatetime) {
this.updatetime = updatetime;
}
}
| [
"[email protected]"
] | |
4347341c21632aec1eab71daa1ac9c2b136df568 | ab8bafb139fff8cdb50a3d2d78c03eb9211d28ef | /src/org/apache/fop/fo/FObj.java | 5f6c56310909d77dc1bc20479001a8352b0f1357 | [
"Apache-1.1",
"Apache-2.0"
] | permissive | tanvir-ahmed-m4/fop-0.20.5 | 540f6386ce7a1a8102d652b13834207a0d0f11cc | 61290f6667d57ae483a58991c417dce91673386f | refs/heads/master | 2021-01-21T10:26:14.336631 | 2017-02-28T12:41:38 | 2017-02-28T12:41:38 | 83,430,905 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 8,728 | java | /*
* $Id: FObj.java,v 1.20.2.9 2003/04/11 00:24:37 pietsch Exp $
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, 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. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "FOP" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* [email protected].
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, 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.
* ============================================================================
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation and was originally created by
* James Tauber <[email protected]>. For more information on the Apache
* Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.fop.fo;
// FOP
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.IDReferences;
// Java
import java.util.HashSet;
/**
* base class for representation of formatting objects and their processing
*/
public abstract class FObj extends FONode {
public abstract static class Maker {
public abstract FObj make(FObj parent, PropertyList propertyList,
String systemId, int line, int column)
throws FOPException;
}
// protected PropertyList properties;
public PropertyList properties;
protected PropertyManager propMgr;
protected String systemId;
protected int line;
protected int column;
// markers
private HashSet markerClassNames;
protected FObj(FObj parent, PropertyList propertyList,
String systemId, int line, int column) {
super(parent);
this.properties = propertyList; // TO BE REMOVED!!!
propertyList.setFObj(this);
this.propMgr = makePropertyManager(propertyList);
this.systemId = systemId;
this.line = line;
this.column = column;
setWritingMode();
}
protected PropertyManager makePropertyManager(PropertyList propertyList) {
return new PropertyManager(propertyList);
}
/**
* adds characters (does nothing here)
* @param data text
* @param start start position
* @param length length of the text
*/
protected void addCharacters(char data[], int start, int length) {
// ignore
}
/**
* generates the area or areas for this formatting object
* and adds these to the area. This method should always be
* overridden by all sub classes
*
* @param area
*/
public int layout(Area area) throws FOPException {
// should always be overridden
return Status.OK;
}
/**
* returns the name of the formatting object
* @return the name of this formatting objects
*/
public abstract String getName();
/**
*
*/
// protected void start() {
// // do nothing by default
// }
/**
*
*/
protected void end() {
// do nothing by default
}
/**
* lets outside sources access the property list
* first used by PageNumberCitation to find the "id" property
* @param name - the name of the desired property to obtain
* @return the property
*/
public Property getProperty(String name) {
return (properties.get(name));
}
/**
* Return the "content width" of the areas generated by this FO.
* This is used by percent-based properties to get the dimension of
* the containing block.
* If an FO has a property with a percentage value, that value
* is usually calculated on the basis of the corresponding dimension
* of the area which contains areas generated by the FO.
* NOTE: subclasses of FObj should implement this to return a reasonable
* value!
*/
public int getContentWidth() {
return 0;
}
/**
* removes property id
* @param idReferences the id to remove
*/
public void removeID(IDReferences idReferences) {
if (((FObj)this).properties.get("id") == null
|| ((FObj)this).properties.get("id").getString() == null)
return;
idReferences.removeID(((FObj)this).properties.get("id").getString());
int numChildren = this.children.size();
for (int i = 0; i < numChildren; i++) {
FONode child = (FONode)children.get(i);
if ((child instanceof FObj)) {
((FObj)child).removeID(idReferences);
}
}
}
public boolean generatesReferenceAreas() {
return false;
}
/**
* Set writing mode for this FO.
* Find nearest ancestor, including self, which generates
* reference areas and use the value of its writing-mode property.
* If no such ancestor is found, use the value on the root FO.
*/
protected void setWritingMode() {
FObj p;
FObj parent;
for (p = this;
!p.generatesReferenceAreas() && (parent = p.getParent()) != null;
p = parent);
this.properties.setWritingMode(p.getProperty("writing-mode").getEnum());
}
public void addMarker(String markerClassName) throws FOPException {
// String mcname = marker.getMarkerClassName();
if (children != null) {
for (int i = 0; i < children.size(); i++) {
FONode child = (FONode)children.get(i);
if (!child.mayPrecedeMarker()) {
throw new FOPException("A fo:marker must be an initial child of '"
+ getName()+"'", systemId, line, column);
}
}
}
if (markerClassNames==null) {
markerClassNames = new HashSet();
markerClassNames.add(markerClassName);
} else if (!markerClassNames.contains(markerClassName) ) {
markerClassNames.add(markerClassName);
} else {
throw new FOPException("marker-class-name '"
+ markerClassName
+ "' already exists for this parent",
systemId, line, column);
}
}
// public boolean hasMarkers() {
// return markers!=null;
// }
// public ArrayList getMarkers() {
// if (markers==null) {
// log.debug("GetMarkers failed (no markers). Should not happen.");
// return null;
// } else {
// return new ArrayList(markers.values());
// }
// }
}
| [
"[email protected]"
] | |
e72058e87aeeaa6e0a0465ff6fda720547d47d9d | 162c09b60b9c85f01c8419891c7feac6806527b0 | /src/main/java/cn/unicom/met/mapper/PlaceMapper.java | f9dd633cf8ecc743e089b610e964e54ca6ba3c17 | [] | no_license | zhangruijie-star/met | 4dcce70f8ca0209ddec042d70061ac139a15cd94 | 4cf207f8d3528add306ce5047988763fa4aa7ea6 | refs/heads/master | 2022-06-22T22:46:18.086944 | 2019-11-26T07:10:54 | 2019-11-26T07:10:54 | 224,123,283 | 0 | 0 | null | 2022-06-17T02:41:27 | 2019-11-26T06:55:53 | JavaScript | UTF-8 | Java | false | false | 1,134 | java | package cn.unicom.met.mapper;
import cn.unicom.met.entity.Place;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
//public interface PlaceMapper extends BaseMapper<Place> {
//
//}
public interface PlaceMapper {
//查询所有
public List<Place> getList(@Param("startRecord") int startRecord, @Param("pageSize") int pageSize);
//查询数量
public int getCount();
//条件查询-page/rows
public List<Place> place_page(@Param("startRecord") int startRecord, @Param("pageSize") int pageSize);
//删除
public void del_place(@Param("uuid") String uuid);
//查询单个
public Place get_place(@Param("uuid") String uuid);
//新增
public void add_place(@Param("place") Place place);
//修改
public void update_place(@Param("place") Place place);
//搜索查询数量
public int findCount(@Param("address") String address );
//搜索查询place
public List<Place> find_place(@Param("address") String address, @Param("startRecord") int startRecord, @Param("pageSize") int pageSize);
}
| [
"[email protected]"
] | |
50096405d86e7b98a8e8408658aac843554564c0 | 15938d025827a01d74c0bcd0fc097b82ee270bd7 | /src/main/java/pe/joedayz/easyfact/exception/ComprobanteElectronicoNotFoundException.java | 090a4ea0800f7b973fac51c234bea0ac19dded34 | [
"Apache-2.0"
] | permissive | joedayz/easyfactapi | 1756dd05886818ecba8cb9ae93997ac0b64a6a74 | 43b6ffc86cf49eb6a92449cd49a4d2f5439f0137 | refs/heads/master | 2021-01-01T05:58:11.944890 | 2019-04-06T15:59:05 | 2019-04-06T15:59:05 | 97,321,391 | 3 | 11 | null | null | null | null | UTF-8 | Java | false | false | 276 | java | package pe.joedayz.easyfact.exception;
public class ComprobanteElectronicoNotFoundException extends RuntimeException{
public ComprobanteElectronicoNotFoundException(String numeroYSerie) {
super("could not find comprobante electronico '" + numeroYSerie + "'.");
}
}
| [
"[email protected]"
] | |
540a8a8129a6ac8caf2595a7a050ffde8908a79f | 1cf766185e82f634d654f423127f11d02a15a785 | /src/main/java/com/parallax/server/blocklyprop/utils/DateConversion.java | a582445348a8a463a57398101c1fd53ea1334301 | [
"MIT",
"Apache-2.0"
] | permissive | parallaxinc/BlocklyProp | e236c0550d1cd5d9db31f1bf43af4004d99b1bc3 | b735c82020097e9a028b8ab0e161927c76ce9650 | refs/heads/develop | 2023-08-09T13:09:34.312524 | 2022-02-22T18:32:04 | 2022-02-22T18:32:04 | 18,612,856 | 44 | 31 | MIT | 2023-07-25T14:00:44 | 2014-04-09T20:51:31 | Java | UTF-8 | Java | false | false | 1,065 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.parallax.server.blocklyprop.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
*
* @author Michel
*/
public class DateConversion {
private static final DateFormat DF = new SimpleDateFormat("yyyy/MM/dd");
private static final DateFormat DTF = new SimpleDateFormat("yyyy/MM/dd HH:mm");
private static final DateFormat TF = new SimpleDateFormat("HH:mm");
public static String toDateString(Date date) {
return toString(DF, date);
}
public static String toDateTimeString(Date date) {
return toString(DTF, date);
}
public static String toTimeString(Date date) {
return toString(TF, date);
}
public static String toString(DateFormat df, Date date) {
if (date == null) {
return null;
}
return df.format(date);
}
}
| [
"[email protected]"
] | |
b8211824c50f66e3ea4928c599d02282b228ecbe | 5629c87e297622b6d092d4083c05abc5fb23eb38 | /app/src/main/java/com/example/dell/wasalny_last/Data_entry.java | a1054aeb13f4dd0bc245465ed7f20c693142e676 | [] | no_license | ashraf1sayed/GraduationProject | beab9d475af799d32918baccce7008566bc41646 | f08c6cf29c6c6fc56a21592417b830f7beccd064 | refs/heads/master | 2020-07-25T03:41:11.448645 | 2019-09-12T22:13:20 | 2019-09-12T22:13:20 | 208,154,189 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,018 | java | package com.example.dell.wasalny_last;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.iid.FirebaseInstanceId;
import java.util.ArrayList;
public class Data_entry extends Fragment {
private View mMainView;
TextView emailview;
TextView phoneview;
EditText seats_numView;
Button go;
String id;
String key_user;
String key_book;
String bus_id, date, monthly_id, num_of_seats, user_id;
DatabaseReference dref_unreg_users;
DatabaseReference book_ref;
DatabaseReference dref_booking;
DatabaseReference dref_discount;
//go bus
ArrayList<String> allseats = new ArrayList<>();
ArrayList<Integer> allseatsInt = new ArrayList<>();
//return bus
ArrayList<String> allseats_ret = new ArrayList<>();
ArrayList<Integer> allseatsInt_ret = new ArrayList<>();
String bus_id_ret, date_ret, monthly_id_ret, num_of_seats_ret,reservation_id_go,reservation_id_ret;
Temp temp;
public Data_entry() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mMainView = inflater.inflate(R.layout.activity_data_entry, container, false);
emailview = mMainView.findViewById(R.id.email_id);
phoneview = (TextView) mMainView.findViewById(R.id.phone_id);
seats_numView = (EditText) mMainView.findViewById(R.id.seats_count);
go = mMainView.findViewById(R.id.go_btn);
temp = new Temp();
dref_unreg_users = FirebaseDatabase.getInstance().getReference().child("UnRegisterUser");
dref_booking = FirebaseDatabase.getInstance().getReference().child("Booking");
dref_discount = FirebaseDatabase.getInstance().getReference().child("Discount");
bus_id=temp.getGo_bus_round_id();
bus_id_ret=temp.getRet_bus_round_id();
Log.i("ddd", "id=" +bus_id );
go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createUser();
booking();
booking_ret();
Ticket_rounded data = new Ticket_rounded();
getFragmentManager()
.beginTransaction()
.replace(R.id.content, data)
.commit();
// move_to_payment();
// update_user_id_in_booking(key_user);
}
});
return mMainView;
}
public void createUser() {
// pr.setMessage("loading....");
// pr.show();
DatabaseReference newPost = dref_unreg_users.push();
String device_token = FirebaseInstanceId.getInstance().getToken();
key_user = newPost.getKey();
final String email = emailview.getText().toString().toLowerCase().trim();
final String phone = phoneview.getText().toString().toLowerCase().trim();
//create childs
newPost.child("email").setValue(email);
newPost.child("phone").setValue(phone);
// pr.dismiss();
}
//get seats for the bus that go
public void getSeats() {
Query query = dref_booking.orderByChild("busId").equalTo(bus_id);
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
// Log.e(TAG + "out", String.valueOf(snapshot.child("job")) + "" + String.valueOf(snapshot.child("name").getValue()));
String res_seats = (String) snapshot.child("numberOfSeats").getValue();
allseats.add(res_seats);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
//get seats for the returned bus
public void getSeats_ret() {
Query query = dref_booking.orderByChild("busId").equalTo(bus_id_ret);
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
// Log.e(TAG + "out", String.valueOf(snapshot.child("job")) + "" + String.valueOf(snapshot.child("name").getValue()));
String res_seats = (String) snapshot.child("numberOfSeats").getValue();
allseats_ret.add(res_seats);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
//random seats for go bus
public void choosing_random_seats() {
int r;
String str;
boolean state ;
int n= Integer.parseInt(seats_numView.getText().toString().toLowerCase().trim());
for (int i = 1; i <= n; i++) {
state=false;
while (state == false) {
r = getRandomIntegerBetweenRange(1, 40);
if (!allseatsInt.contains(r)) {
state = true;
if (i != n) {
num_of_seats = num_of_seats + String.valueOf(r) + "-";
} else {
num_of_seats = num_of_seats + String.valueOf(r);
}
} else {
state=false;
}
}
}
}
//return bus
public void choosing_random_seats_ret() {
int r;
String str;
boolean state ;
int n= Integer.parseInt(seats_numView.getText().toString().toLowerCase().trim());
for (int i = 1; i <= n; i++) {
state=false;
while (state == false) {
r = getRandomIntegerBetweenRange(1, 40);
if (!allseatsInt_ret.contains(r)) {
state = true;
if (i != n) {
num_of_seats_ret = num_of_seats_ret + String.valueOf(r) + "-";
} else {
num_of_seats_ret = num_of_seats_ret + String.valueOf(r);
}
} else {
state=false;
}
}
}
}
//get random numbers
public static int getRandomIntegerBetweenRange(int min, int max) {
int x = (int) ((Math.random() * ((max - min) + 1)) + min);
return x;
}
public void split_array() {
String str;
for (int i = 0; i < allseats.size(); i++) {
str = allseats.get(i);
String[] arr = str.split("-");
for (String w : arr) {
allseatsInt.add(Integer.valueOf(w));
}
}
}
//split the array for returned buses
public void split_array_ret() {
String str;
for (int i = 0; i < allseats_ret.size(); i++) {
str = allseats_ret.get(i);
String[] arr = str.split("-");
for (String w : arr) {
allseatsInt_ret.add(Integer.valueOf(w));
}
}
}
//booking go bus
public void booking() {
// pr.setMessage("loading....");
// pr.show();
DatabaseReference newPost = dref_booking.push();
String device_token = FirebaseInstanceId.getInstance().getToken();
String key = newPost.getKey();
Log.i("fbb", "the date" + key);
date = temp.getDigital_date_for_go();
temp.setReservation_id_go(key);
monthly_id = "daily";
num_of_seats = "";
discount(key);
temp.setBooking_id(key);
// functions to choose seat
getSeats();
split_array();
choosing_random_seats();
//create childs
newPost.child("busId").setValue(bus_id);
newPost.child("date").setValue(date);
newPost.child("monthlyId").setValue(monthly_id);
newPost.child("numberOfSeats").setValue(num_of_seats);
newPost.child("userId").setValue(key_user);
// pr.dismiss();
}
//booking returned bus
public void booking_ret() {
// pr.setMessage("loading....");
// pr.show();
DatabaseReference newPost = dref_booking.push();
String device_token = FirebaseInstanceId.getInstance().getToken();
String key = newPost.getKey();
Log.i("fbb", "the date" + key);
date = temp.getDigital_date_for_ret();
temp.setReservation_id_ret(key);
monthly_id_ret = "daily";
num_of_seats_ret = "";
discount(key);
//temp.setBooking_id(key);
// functions to choose seat
getSeats_ret();
split_array_ret();
choosing_random_seats_ret();
//create childs
newPost.child("busId").setValue(bus_id_ret);
newPost.child("date").setValue(date);
newPost.child("monthlyId").setValue(monthly_id);
newPost.child("numberOfSeats").setValue(num_of_seats_ret);
newPost.child("userId").setValue(key_user);
// pr.dismiss();
}
public void discount(String id)
{
DatabaseReference newPost = dref_discount.push();
newPost.child("bookId").setValue(id);
newPost.child("percentage").setValue("5%");
newPost.child("state").setValue("unpaid");
}
}
| [
"[email protected]"
] | |
efecb53b5f27fd4cca4ccc976b3a2658c3f1e1b6 | 7a0029548ee61693a6eb40cadae0111335c73fec | /debezium-core/src/main/java/io/debezium/text/XmlCharacters.java | 1939a8d5b986931ac5fad3ccc1f7df69ddf2791f | [
"Apache-2.0"
] | permissive | RedVentures/debezium | 2f3585e39b42a25e6ababdfbcb7874ed786f25b3 | e86fb83459c2b328a186072ff2500f3d6f590d3c | refs/heads/master | 2021-09-08T11:28:30.485315 | 2016-08-16T14:56:47 | 2016-08-16T14:56:47 | 65,745,620 | 0 | 0 | NOASSERTION | 2021-08-19T02:57:59 | 2016-08-15T16:04:36 | Java | UTF-8 | Java | false | false | 11,968 | java | /*
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.text;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import io.debezium.annotation.Immutable;
/**
* A utility class for determining the validity of various XML names, per the <a href="http://www.w3.org/TR/REC-xml/">XML 1.0
* Specification</a>.
*
* @author Randall Hauch
*/
@Immutable
public class XmlCharacters {
private static final int NUMBER_OF_CHARACTERS = 1 << 16; // 65536 or 0x10000
/**
* This implementation uses an array that captures for each character the XML classifications. An array is used because it is
* a fast way of looking up each character.
*/
private static final char[] MASKS = new char[NUMBER_OF_CHARACTERS];
private static final int VALID_CHARACTER = 1;
private static final int CONTENT_CHARACTER = 1 << 1;
private static final int SPACE_CHARACTER = 1 << 2;
private static final int NAME_START_CHARACTER = 1 << 3;
private static final int NAME_CHARACTER = 1 << 4;
private static final int NCNAME_START_CHARACTER = 1 << 5;
private static final int NCNAME_CHARACTER = 1 << 6;
private static final int PUBID_CHARACTER = 1 << 7;
static {
// ----------------
// Valid Characters
// ----------------
// [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
// See http://www.w3.org/TR/REC-xml/#charsets
MASKS[0x9] |= VALID_CHARACTER | CONTENT_CHARACTER;
MASKS[0xA] |= VALID_CHARACTER | CONTENT_CHARACTER;
MASKS[0xD] |= VALID_CHARACTER | CONTENT_CHARACTER;
for (int i = 0x20; i <= 0xD7FF; ++i)
MASKS[i] |= VALID_CHARACTER | CONTENT_CHARACTER;
for (int i = 0xE000; i <= 0xFFFD; ++i)
MASKS[i] |= VALID_CHARACTER | CONTENT_CHARACTER;
// Last range is bigger than our character array, so we'll handle in the 'isValid' method ...
// for ( int i=0x10000; i<=0x10FFFF; ++i ) MASKS[i] = VALID_CHARACTER_MASK | CONTENT_CHARACTER;
// Remove the other characters that are not allowed in XML content:
// '<', '&', '\n', '\r', ']'
MASKS['<'] &= ~(CONTENT_CHARACTER);
MASKS['&'] &= ~(CONTENT_CHARACTER);
MASKS['\n'] &= ~(CONTENT_CHARACTER);
MASKS['\r'] &= ~(CONTENT_CHARACTER);
MASKS[']'] &= ~(CONTENT_CHARACTER);
// ---------------------
// Whitespace Characters
// ---------------------
// [3] S ::= (#x20 | #x9 | #xD | #xA)+
// See http://www.w3.org/TR/REC-xml/#sec-common-syn
MASKS[0x20] |= SPACE_CHARACTER;
MASKS[0x9] |= SPACE_CHARACTER;
MASKS[0xA] |= SPACE_CHARACTER;
MASKS[0xD] |= SPACE_CHARACTER;
// ---------------------
// Name Start Characters
// ---------------------
// [4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
// [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
// [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
// [#x10000-#xEFFFF]
// See http://www.w3.org/TR/REC-xml/#sec-common-syn
//
// Note that all these start characters AND characters are valid for NAME and NCNAME
int nameStartMask = NAME_START_CHARACTER | NCNAME_START_CHARACTER | NAME_CHARACTER | NCNAME_CHARACTER;
MASKS[':'] |= nameStartMask;
MASKS['_'] |= nameStartMask;
for (int i = 'A'; i <= 'Z'; ++i)
MASKS[i] |= nameStartMask;
for (int i = 'a'; i <= 'z'; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0xC0; i <= 0xD6; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0xD8; i <= 0xF6; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0xF8; i <= 0x2FF; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x370; i <= 0x37D; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x37F; i <= 0x1FFF; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x200C; i <= 0x200D; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x2070; i <= 0x218F; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x2C00; i <= 0x2FEF; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x3001; i <= 0xD7FF; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0xF900; i <= 0xFDCF; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0xFDF0; i <= 0xFFFD; ++i)
MASKS[i] |= nameStartMask;
// Last range is bigger than our character array ...
// for (int i = 0x10000; i <= 0xEFFFF; ++i) MASKS[i] |= nameStartMask;
// ---------------
// Name Characters
// ---------------
// [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
// See http://www.w3.org/TR/REC-xml/#sec-common-syn
//
// Note that all these characters are valid for NAME and NCNAME
int nameMask = NAME_CHARACTER | NCNAME_CHARACTER;
MASKS['-'] |= nameMask;
MASKS['.'] |= nameMask;
MASKS[0xB7] |= nameMask;
for (int i = '0'; i <= '9'; ++i)
MASKS[i] |= nameMask;
for (int i = 0x0300; i <= 0x036F; ++i)
MASKS[i] |= nameStartMask;
for (int i = 0x203F; i <= 0x2040; ++i)
MASKS[i] |= nameStartMask;
// --------
// NC Names
// --------
// [4] NCName ::= NCNameStartChar NCNameChar*
// which is just an XML Name, minus the ":"
// See http://www.w3.org/TR/REC-xml-names/#ns-decl
// So, remove the NCNAME_CHARACTER and NCNAME_START_CHARACTER masks from ':' ...
MASKS[':'] &= ~(NCNAME_START_CHARACTER | NCNAME_CHARACTER);
// --------------------
// Public ID characters
// --------------------
// [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
MASKS[0x20] |= PUBID_CHARACTER;
MASKS[0xA] |= PUBID_CHARACTER;
MASKS[0xD] |= PUBID_CHARACTER;
for (int i = 'A'; i <= 'Z'; ++i)
MASKS[i] |= PUBID_CHARACTER;
for (int i = 'a'; i <= 'z'; ++i)
MASKS[i] |= PUBID_CHARACTER;
for (int i = '0'; i <= '9'; ++i)
MASKS[i] |= PUBID_CHARACTER;
MASKS['-'] |= PUBID_CHARACTER;
MASKS['\''] |= PUBID_CHARACTER;
MASKS['('] |= PUBID_CHARACTER;
MASKS[')'] |= PUBID_CHARACTER;
MASKS['+'] |= PUBID_CHARACTER;
MASKS[','] |= PUBID_CHARACTER;
MASKS['.'] |= PUBID_CHARACTER;
MASKS['/'] |= PUBID_CHARACTER;
MASKS[':'] |= PUBID_CHARACTER;
MASKS['='] |= PUBID_CHARACTER;
MASKS['?'] |= PUBID_CHARACTER;
MASKS[';'] |= PUBID_CHARACTER;
MASKS['!'] |= PUBID_CHARACTER;
MASKS['*'] |= PUBID_CHARACTER;
MASKS['#'] |= PUBID_CHARACTER;
MASKS['@'] |= PUBID_CHARACTER;
MASKS['$'] |= PUBID_CHARACTER;
MASKS['_'] |= PUBID_CHARACTER;
MASKS['%'] |= PUBID_CHARACTER;
}
private XmlCharacters() {
}
/**
* Determine whether the supplied character is a valid first character in an XML Name. The first character in an XML name is
* more restrictive than the {@link #isValidName(int) remaining characters}.
*
* @param c the character
* @return true if the character is valid for an XML Name's first character
*/
public static boolean isValidNameStart( int c ) {
return c < NUMBER_OF_CHARACTERS && (MASKS[c] & NAME_START_CHARACTER) != 0;
}
/**
* Determine whether the supplied character is a valid first character in an XML NCName. The first character in an XML NCName
* is more restrictive than the {@link #isValidName(int) remaining characters}.
*
* @param c the character
* @return true if the character is valid for an XML NCName's first character
*/
public static boolean isValidNcNameStart( int c ) {
return c < NUMBER_OF_CHARACTERS && (MASKS[c] & NCNAME_START_CHARACTER) != 0;
}
/**
* Determine whether the supplied character is a valid non-first character in an XML Name. The {@link #isValidNameStart(int)
* first character} in an XML name is more restrictive than the remaining characters.
*
* @param c the character
* @return true if the character is valid character in an XML Name
*/
public static boolean isValidName( int c ) {
return c < NUMBER_OF_CHARACTERS && (MASKS[c] & NAME_CHARACTER) != 0;
}
/**
* Determine whether the supplied character is a valid non-first character in an XML NCName. The
* {@link #isValidNcNameStart(int) first character} in an XML NCName is more restrictive than the remaining characters.
*
* @param c the character
* @return true if the character is valid character in an XML NCName
*/
public static boolean isValidNcName( int c ) {
return c < NUMBER_OF_CHARACTERS && (MASKS[c] & NCNAME_CHARACTER) != 0;
}
/**
* Determine whether the supplied character is a valid character in an XML Pubid.
*
* @param c the character
* @return true if the character is valid character in an XML Pubid
*/
public static boolean isValidPubid( int c ) {
return c < NUMBER_OF_CHARACTERS && (MASKS[c] & PUBID_CHARACTER) != 0;
}
/**
* Determine whether the supplied character is a valid character in XML.
*
* @param c the character
* @return true if the character is valid character in XML
*/
public static boolean isValid( int c ) {
return (c < NUMBER_OF_CHARACTERS && (MASKS[c] & VALID_CHARACTER) != 0) || (0x10000 <= c && c <= 0x10FFFF);
}
/**
* Determine whether the supplied character is a valid character in XML content
*
* @param c the character
* @return true if the character is valid character in XML content
*/
public static boolean isValidContent( int c ) {
return (c < NUMBER_OF_CHARACTERS && (MASKS[c] & CONTENT_CHARACTER) != 0) || (0x10000 <= c && c <= 0x10FFFF);
}
/**
* Determine whether the supplied character is a valid whitespace character in XML
*
* @param c the character
* @return true if the character is valid whitespace character in XML
*/
public static boolean isValidSpace( int c ) {
return c <= 0x20 && (MASKS[c] & SPACE_CHARACTER) != 0;
}
/**
* Determine if the supplied name is a valid XML Name.
*
* @param name the string being checked
* @return true if the supplied name is indeed a valid XML Name, or false otherwise
*/
public static boolean isValidName( String name ) {
if (name == null || name.length() == 0) return false;
CharacterIterator iter = new StringCharacterIterator(name);
char c = iter.first();
if (!isValidNameStart(c)) return false;
while (c != CharacterIterator.DONE) {
if (!isValidName(c)) return false;
c = iter.next();
}
return true;
}
/**
* Determine if the supplied name is a valid XML NCName.
*
* @param name the string being checked
* @return true if the supplied name is indeed a valid XML NCName, or false otherwise
*/
public static boolean isValidNcName( String name ) {
if (name == null || name.length() == 0) return false;
CharacterIterator iter = new StringCharacterIterator(name);
char c = iter.first();
if (!isValidNcNameStart(c)) return false;
while (c != CharacterIterator.DONE) {
if (!isValidNcName(c)) return false;
c = iter.next();
}
return true;
}
} | [
"[email protected]"
] | |
6c3afe0aa2941dddad2a754105657345876eaffe | e5bbf1f8a8fd289ac7fa8f0817e3f23ca40e806c | /src/main/java/com/example/design/command/Broker.java | 93d0341c41e4adac35b583daf7721578559ba4d5 | [] | no_license | adolph58/design-pattern | 0d7e19dec0b4ae22863d83dd88aa1fe04dcdb995 | acc265f1ed523128c39f5d60758cc3fd0b10c4b9 | refs/heads/master | 2023-02-20T23:14:01.173358 | 2021-01-15T02:24:15 | 2021-01-15T02:24:15 | 324,922,923 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | package com.example.design.command;
import java.util.ArrayList;
import java.util.List;
/**
* @author Arte
* @create 21-1-6
*/
public class Broker {
private List<Order> orderList = new ArrayList<>();
public void takeOrder(Order order) {
orderList.add(order);
}
public void placeOrders() {
for(Order order : orderList) {
order.execute();
}
orderList.clear();
}
}
| [
"[email protected]"
] | |
cdf9d1b201759e5a5d6c7ee7b3f9d6dbe87c8b41 | 543bcdacff145c2b0872005325b0566e5ad3ab4c | /occurrence-cube/trunk/src/test/java/org/gbif/cube/gmap/GoogleTileUtilTest.java | 1154c319e6c09667c32515cdb876440881f0dcf9 | [] | no_license | caozhenhuamail/gbif-labs | 1211cc5528b9c8b40f636fa57344fdc27dd5f598 | d8511ca4524913872a4539db96f574fd9ec49fc3 | refs/heads/master | 2023-01-03T19:32:48.522033 | 2014-05-22T07:58:47 | 2014-05-22T07:58:47 | 49,181,072 | 0 | 1 | null | 2023-01-02T22:02:51 | 2016-01-07T04:29:53 | Java | UTF-8 | Java | false | false | 989 | java | package org.gbif.cube.gmap;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GoogleTileUtilTest {
@Test
public void testGetOffset() {
assertEquals(92, GoogleTileUtil.getOffsetY(45d, -90d, 0));
assertEquals(128, GoogleTileUtil.getOffsetX(0d, 0d, 0));
assertEquals(128, GoogleTileUtil.getOffsetY(0d, 0d, 0));
assertEquals(0, GoogleTileUtil.getOffsetX(0d, 0d, 1));
assertEquals(0, GoogleTileUtil.getOffsetY(0d, 0d, 1));
assertEquals(0, GoogleTileUtil.getOffsetX(0d, 0d, 2));
assertEquals(0, GoogleTileUtil.getOffsetY(0d, 0d, 2));
// Canberra, AU
double lng = 149.1;
double lat = -35.2;
assertEquals(0, GoogleTileUtil.toTileX(lng, 0));
assertEquals(1, GoogleTileUtil.toTileX(lng, 1));
assertEquals(3, GoogleTileUtil.toTileX(lng, 2));
assertEquals(0, GoogleTileUtil.toTileY(lat, 0));
assertEquals(1, GoogleTileUtil.toTileY(lat, 1));
assertEquals(2, GoogleTileUtil.toTileY(lat, 2));
}
}
| [
"[email protected]"
] | |
c74e3e7eef43acbc66611101054317b0ba737a5e | 6fecab7e537f4dc544c1cc1b9583fe38388d6a87 | /sercice-order/src/main/java/com/example/demo/SerciceOrderApplication.java | cc7609f4fc8af70e70dcd15ced1bab0d5a174b51 | [] | no_license | fafi09/springclouddemo1 | 4cbcf0f02ebd43985df975725a8cf98f55527317 | c8955f8a924354f739be4024672a98d33f4ab1be | refs/heads/master | 2020-05-04T14:25:24.990725 | 2019-04-03T07:18:18 | 2019-04-03T07:18:18 | 179,195,917 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 981 | java | package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@ComponentScan(basePackages= {"com.example.controller","com.example.service"})
@EnableAutoConfiguration
@EnableEurekaClient
@EnableHystrix
public class SerciceOrderApplication {
public static void main(String[] args) {
SpringApplication.run(SerciceOrderApplication.class, args);
}
@Bean
@LoadBalanced
RestTemplate restTemplate() {
return new RestTemplate();
}
}
| [
"[email protected]"
] | |
32bff716a430f3922ac26858651ee56dc0503968 | 5253dcf5b8c35f8ea1ff632f87d61d009879d8a7 | /uikit/src/com/netease/nim/uikit/business/session/fragment/MessageFragment.java | 2d13d829c6315681e7a5aa1a67e00001002390e7 | [
"MIT"
] | permissive | lufeisong1988/changcai | 7e682ed2de796ecfd5204c9abf9485567714a477 | cd578f8de84c8ce2e71c5537c90d808ef398e2b3 | refs/heads/master | 2021-09-10T23:14:23.028466 | 2018-04-04T01:53:46 | 2018-04-04T01:53:46 | 116,357,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,583 | java | package com.netease.nim.uikit.business.session.fragment;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.juggist.commonlibrary.rx.RxBus;
import com.netease.nim.uikit.R;
import com.netease.nim.uikit.api.UIKitOptions;
import com.netease.nim.uikit.api.model.main.CustomPushContentProvider;
import com.netease.nim.uikit.api.model.session.SessionCustomization;
import com.netease.nim.uikit.business.ait.AitManager;
import com.netease.nim.uikit.business.session.actions.BaseAction;
import com.netease.nim.uikit.business.session.actions.ImageAction;
import com.netease.nim.uikit.business.session.actions.LocationAction;
import com.netease.nim.uikit.business.session.actions.VideoAction;
import com.netease.nim.uikit.business.session.constant.Extras;
import com.netease.nim.uikit.business.session.module.Container;
import com.netease.nim.uikit.business.session.module.ModuleProxy;
import com.netease.nim.uikit.business.session.module.input.InputPanel;
import com.netease.nim.uikit.business.session.module.list.MessageListPanelEx;
import com.netease.nim.uikit.common.fragment.TFragment;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.netease.nim.uikit.impl.NimUIKitImpl;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.Observer;
import com.netease.nimlib.sdk.RequestCallback;
import com.netease.nimlib.sdk.ResponseCode;
import com.netease.nimlib.sdk.msg.MessageBuilder;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.MsgServiceObserve;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.CustomMessageConfig;
import com.netease.nimlib.sdk.msg.model.IMMessage;
import com.netease.nimlib.sdk.msg.model.MemberPushOption;
import com.netease.nimlib.sdk.msg.model.MessageReceipt;
import com.netease.nimlib.sdk.robot.model.NimRobotInfo;
import com.netease.nimlib.sdk.robot.model.RobotAttachment;
import com.netease.nimlib.sdk.robot.model.RobotMsgType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
/**
* 聊天界面基类
* <p/>
* Created by huangjun on 2015/2/1.
*/
public class MessageFragment extends TFragment implements ModuleProxy {
private View rootView;
private SessionCustomization customization;
protected static final String TAG = "MessageActivity";
// 聊天对象
protected String sessionId; // p2p对方Account或者群id
protected SessionTypeEnum sessionType;
// modules
protected InputPanel inputPanel;//底部输入框view
protected MessageListPanelEx messageListPanel;
protected AitManager aitManager;
private Observable<Boolean> foregroundToBackgroundEvent;//从后台回到前台
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
foregroundToBackgroundEvent = RxBus.get().register("foregroundToBackground", Boolean.class);
foregroundToBackgroundEvent.observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
LogUtil.i("CommonApplication","event = " + aBoolean);
if(aBoolean && messageListPanel != null){
messageListPanel.onPause();
}
}
});
parseIntent();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.nim_message_fragment, container, false);
return rootView;
}
/**
* ***************************** life cycle *******************************
*/
@Override
public void onPause() {
super.onPause();
NIMClient.getService(MsgService.class).setChattingAccount(MsgService.MSG_CHATTING_ACCOUNT_NONE,
SessionTypeEnum.None);
inputPanel.onPause();
// messageListPanel.onPause();
}
@Override
public void onResume() {
super.onResume();
messageListPanel.onResume();
NIMClient.getService(MsgService.class).setChattingAccount(sessionId, sessionType);
getActivity().setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); // 默认使用听筒播放
}
@Override
public void onDestroy() {
super.onDestroy();
messageListPanel.onDestroy();
registerObservers(false);
if (inputPanel != null) {
inputPanel.onDestroy();
}
if (aitManager != null) {
aitManager.reset();
}
RxBus.get().unregister("foregroundToBackground",foregroundToBackgroundEvent);
}
public boolean onBackPressed() {
LogUtil.d("inputPanel","onBackPressed");
if (inputPanel.collapse(true)) {
return true;
}
if (messageListPanel.onBackPressed()) {
return true;
}
return false;
}
public void refreshMessageList() {
messageListPanel.refreshMessageList();
}
private void parseIntent() {
sessionId = getArguments().getString(Extras.EXTRA_ACCOUNT);
sessionType = (SessionTypeEnum) getArguments().getSerializable(Extras.EXTRA_TYPE);
Boolean onlineAble = getArguments().getBoolean(Extras.EXTRA_ONLINE,true);
IMMessage anchor = (IMMessage) getArguments().getSerializable(Extras.EXTRA_ANCHOR);
customization = (SessionCustomization) getArguments().getSerializable(Extras.EXTRA_CUSTOMIZATION);
Container container = new Container(getActivity(), sessionId, sessionType, this);
if (messageListPanel == null) {
messageListPanel = new MessageListPanelEx(container, rootView, anchor, false, false);
} else {
messageListPanel.reload(container, anchor);
}
if (inputPanel == null) {
inputPanel = new InputPanel(container, rootView, getActionList());
inputPanel.setCustomization(customization);
} else {
inputPanel.reload(container, customization);
}
initAitManager();
//设置底部inputPanel是否可见
if(onlineAble){
inputPanel.setVisiable(true);
}else{
inputPanel.setVisiable(false);
}
inputPanel.switchRobotMode(NimUIKitImpl.getRobotInfoProvider().getRobotByAccount(sessionId) != null);
registerObservers(true);
if (customization != null) {
messageListPanel.setChattingBackground(customization.backgroundUri, customization.backgroundColor);
}
}
public void showInputPanel(){
if(inputPanel != null){
inputPanel.setVisiable(true);
}
}
public void hideInputPanel(){
if(inputPanel != null){
inputPanel.setVisiable(false);
}
}
private void initAitManager() {
UIKitOptions options = NimUIKitImpl.getOptions();
if (options.aitEnable) {
aitManager = new AitManager(getContext(), options.aitTeamMember && sessionType == SessionTypeEnum.Team ? sessionId : null, options.aitIMRobot);
inputPanel.addAitTextWatcher(aitManager);
aitManager.setTextChangeListener(inputPanel);
}
}
/**
* ************************* 消息收发 **********************************
*/
// 是否允许发送消息
protected boolean isAllowSendMessage(final IMMessage message) {
return true;
}
/**
* ****************** 观察者 **********************
*/
private void registerObservers(boolean register) {
MsgServiceObserve service = NIMClient.getService(MsgServiceObserve.class);
service.observeReceiveMessage(incomingMessageObserver, register);
// 已读回执监听
if (NimUIKitImpl.getOptions().shouldHandleReceipt) {
service.observeMessageReceipt(messageReceiptObserver, register);
}
}
/**
* 消息接收观察者
*/
Observer<List<IMMessage>> incomingMessageObserver = new Observer<List<IMMessage>>() {
@Override
public void onEvent(List<IMMessage> messages) {
if (messages == null || messages.isEmpty()) {
return;
}
messageListPanel.onIncomingMessage(messages);
sendMsgReceipt(); // 发送已读回执
}
};
private Observer<List<MessageReceipt>> messageReceiptObserver = new Observer<List<MessageReceipt>>() {
@Override
public void onEvent(List<MessageReceipt> messageReceipts) {
receiveReceipt();
}
};
/**
* ********************** implements ModuleProxy *********************
*/
@Override
public boolean sendMessage(IMMessage message) {
if (!isAllowSendMessage(message)) {
return false;
}
appendTeamMemberPush(message);
message = changeToRobotMsg(message);
final IMMessage msg = message;
appendPushConfig(message);
// send message to server and save to db
NIMClient.getService(MsgService.class).sendMessage(message, false).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
}
@Override
public void onFailed(int code) {
sendFailWithBlackList(code, msg);
}
@Override
public void onException(Throwable exception) {
}
});
messageListPanel.onMsgSend(message);
if (aitManager != null) {
aitManager.reset();
}
return true;
}
// 被对方拉入黑名单后,发消息失败的交互处理
private void sendFailWithBlackList(int code, IMMessage msg) {
if (code == ResponseCode.RES_IN_BLACK_LIST) {
// 如果被对方拉入黑名单,发送的消息前不显示重发红点
msg.setStatus(MsgStatusEnum.success);
NIMClient.getService(MsgService.class).updateIMMessageStatus(msg);
messageListPanel.refreshMessageList();
// 同时,本地插入被对方拒收的tip消息
IMMessage tip = MessageBuilder.createTipMessage(msg.getSessionId(), msg.getSessionType());
tip.setContent(getActivity().getString(R.string.black_list_send_tip));
tip.setStatus(MsgStatusEnum.success);
CustomMessageConfig config = new CustomMessageConfig();
config.enableUnreadCount = false;
tip.setConfig(config);
NIMClient.getService(MsgService.class).saveMessageToLocal(tip, true);
}
}
private void appendTeamMemberPush(IMMessage message) {
if (aitManager == null) {
return;
}
if (sessionType == SessionTypeEnum.Team) {
List<String> pushList = aitManager.getAitTeamMember();
if (pushList == null || pushList.isEmpty()) {
return;
}
MemberPushOption memberPushOption = new MemberPushOption();
memberPushOption.setForcePush(true);
memberPushOption.setForcePushContent(message.getContent());
memberPushOption.setForcePushList(pushList);
message.setMemberPushOption(memberPushOption);
}
}
private IMMessage changeToRobotMsg(IMMessage message) {
if (aitManager == null) {
return message;
}
if (message.getMsgType() == MsgTypeEnum.robot) {
return message;
}
if (isChatWithRobot()) {
if (message.getMsgType() == MsgTypeEnum.text && message.getContent() != null) {
String content = message.getContent().equals("") ? " " : message.getContent();
message = MessageBuilder.createRobotMessage(message.getSessionId(), message.getSessionType(), message.getSessionId(), content, RobotMsgType.TEXT, content, null, null);
}
} else {
String robotAccount = aitManager.getAitRobot();
if (TextUtils.isEmpty(robotAccount)) {
return message;
}
String text = message.getContent();
String content = aitManager.removeRobotAitString(text, robotAccount);
content = content.equals("") ? " " : content;
message = MessageBuilder.createRobotMessage(message.getSessionId(), message.getSessionType(), robotAccount, text, RobotMsgType.TEXT, content, null, null);
}
return message;
}
private boolean isChatWithRobot() {
return NimUIKitImpl.getRobotInfoProvider().getRobotByAccount(sessionId) != null;
}
private void appendPushConfig(IMMessage message) {
CustomPushContentProvider customConfig = NimUIKitImpl.getCustomPushContentProvider();
if (customConfig != null) {
String content = customConfig.getPushContent(message);
Map<String, Object> payload = customConfig.getPushPayload(message);
message.setPushContent(content);
message.setPushPayload(payload);
}
}
@Override
public void onInputPanelExpand() {
messageListPanel.scrollToBottom();
}
@Override
public void shouldCollapseInputPanel() {
inputPanel.collapse(false);
}
@Override
public boolean isLongClickEnabled() {
return !inputPanel.isRecording();
}
@Override
public void onItemFooterClick(IMMessage message) {
if (aitManager == null) {
return;
}
if (messageListPanel.isSessionMode()) {
RobotAttachment attachment = (RobotAttachment) message.getAttachment();
NimRobotInfo robot = NimUIKitImpl.getRobotInfoProvider().getRobotByAccount(attachment.getFromRobotAccount());
aitManager.insertAitRobot(robot.getAccount(), robot.getName(), inputPanel.getEditSelectionStart());
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (aitManager != null) {
aitManager.onActivityResult(requestCode, resultCode, data);
}
inputPanel.onActivityResult(requestCode, resultCode, data);
messageListPanel.onActivityResult(requestCode, resultCode, data);
}
// 操作面板集合
protected List<BaseAction> getActionList() {
List<BaseAction> actions = new ArrayList<>();
actions.add(new ImageAction());
actions.add(new VideoAction());
actions.add(new LocationAction());
if (customization != null && customization.actions != null) {
actions.addAll(customization.actions);
}
return actions;
}
/**
* 发送已读回执
*/
private void sendMsgReceipt() {
messageListPanel.sendReceipt();
}
/**
* 收到已读回执
*/
public void receiveReceipt() {
messageListPanel.receiveReceipt();
}
public void insertAitTeamMemberInner(String account,String name){
aitManager.insertAitTeamMemberInner(account,name);
}
}
| [
"[email protected]"
] | |
c4229fdf94983b9483e4d64cb51e85a0862802d0 | 6f99b9f74e6afffaa5eb391b8aa9fddf37601e60 | /uppgift5_2.java | 6c849dab25cea12d3938304873504daf0296cbb8 | [] | no_license | SimonVestman/uppgiftkap5 | 48596a9e6c25c051d81da0dc93e27d3909fba7c0 | dbd2915a0c1185d19ce0c2d67e7a27c250233760 | refs/heads/master | 2020-08-09T18:00:57.176228 | 2019-10-11T09:14:39 | 2019-10-11T09:14:39 | 214,138,691 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 383 | java | import javax.swing.*;
public class uppgift5_2{
public static void main(String[] args){
double studsar = 0;
String Height = double.parseDouble (JOptionPane.showInputDialog(null,"skriv bollens höjd i meter"));
double.parseDouble(hojd)
while (hojd > 0.01) {
studsar = Height *0.70;
studsar ++;
}
JOptionPane.showMessageDialog(null,"bollen studsade" + studsar);
}
} | [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.