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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11e2a2a7ced61da36b5347f6004f840722b2b4d7 | 5b1c4d465c104444297867003facee671d5bfb99 | /app/src/main/java/mmu/edu/my/shift/data/model/LoggedInUser.java | 0bb6176dca3d9e1aec2d3073449087b11efcf306 | [] | no_license | Spade497/ShiFT | ee259544bde88d13b3e7a87383f863a560c07600 | e302cdc0bed1b0fb33fc78955dd6a7c2c4fec42b | refs/heads/master | 2023-03-20T01:22:06.957370 | 2021-03-15T02:00:38 | 2021-03-15T02:00:38 | 332,679,567 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 503 | java | package mmu.edu.my.shift.data.model;
/**
* Data class that captures user information for logged in users retrieved from LoginRepository
*/
public class LoggedInUser {
private String userId;
private String displayName;
public LoggedInUser(String userId, String displayName) {
this.userId = userId;
this.displayName = displayName;
}
public String getUserId() {
return userId;
}
public String getDisplayName() {
return displayName;
}
} | [
"[email protected]"
] | |
6fa4abea9041dae53e2555580aa5e7c760c4f3f7 | 0e3e13b0577ef565c408783c82c43ada1217b08f | /StudentApi/src/main/java/com/student/soap/contract/scheduleservice/SoapCarRatingsAndCommentsRequest.java | 26909b6cfa799ef45f937d46908d679013f52c88 | [] | no_license | MarkoMesel/XIWS-TimProj | 13a9bb2aabc78a4b8fb54be613c22bd4c239ff62 | 5f9c8376a46fc9b7f9c8f6c6c8ea45d0d61611b1 | refs/heads/master | 2023-04-13T19:08:26.314610 | 2020-07-12T10:08:05 | 2020-07-12T10:08:05 | 265,536,586 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,574 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.07.06 at 07:41:59 PM BST
//
package com.student.soap.contract.scheduleservice;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"id"
})
@XmlRootElement(name = "soapCarRatingsAndCommentsRequest")
public class SoapCarRatingsAndCommentsRequest {
protected int id;
/**
* Gets the value of the id property.
*
*/
public int getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(int value) {
this.id = value;
}
}
| [
"[email protected]"
] | |
001fd74b20c6073083d2916c77677f2bc28c06af | 7cb46edb61ef13a7e14798b1bcc7244e72834ced | /src/main/java/com/example/testdemo/UsersController.java | 3de635a8fe038a22c3fab1d52072104ebdda09e6 | [] | no_license | ppolushkin/demo-test | 7f0ae4df726e917029bb2ea2323f5112f9c52141 | 3a2a85b52c97213e23219fb535b66604656570cf | refs/heads/master | 2021-06-26T10:09:50.402568 | 2017-09-14T02:27:20 | 2017-09-14T02:27:20 | 103,469,219 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 960 | java | package com.example.testdemo;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Created by Pavel Polushkin
* 14.09.2017.
*/
@RestController
@RequestMapping("/users")
public class UsersController {
private final UsersRepository usersRepository;
public UsersController(UsersRepository usersRepository) {
this.usersRepository = usersRepository;
}
@GetMapping
public List<User> getAll() {
return usersRepository.getAll();
}
@GetMapping("/{id}")
public User getOne(@PathVariable Long id) {
return usersRepository.getById(id);
}
@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) {
usersRepository.delete(id);
}
@PostMapping
public void add(@RequestBody User user) {
usersRepository.add(user);
}
@PutMapping
public void modify(@RequestBody User user) {
usersRepository.modify(user);
}
}
| [
"[email protected]"
] | |
5f330fe350b7cf34af3113c964ef857b61e88811 | bcfd9f294e1f20d7f03e4d80d4e8086dcea1613f | /app/src/androidTest/java/com/example/masters/mytest_iba/ExampleInstrumentedTest.java | 80d6b8db3da7432fc3d605d3dacef07bda8c1ec4 | [] | no_license | KimHyoungChul/MyTEST_IBA | e448603026f446677315b1de5b422ea95d119475 | e83c9f93838d6cb83e1aef0ea06ab6bad20500b6 | refs/heads/master | 2020-06-29T18:49:35.768332 | 2018-03-02T06:42:40 | 2018-03-02T06:42:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 761 | java | package com.example.masters.mytest_iba;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.masters.mytest_iba", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
9c2900172e00809442d7d0229c5eaf80a2d55dc2 | 889877dd2129c9717bafc77a84408f287fbbdbc3 | /src/main/java/bjl/core/enums/BankSegment.java | 776daaff655bffecb4b21eb9e4c24e5f8afa2b94 | [] | no_license | zhouxhhn/voto | 3cf1405045e81230398cb273cfeaf9ee95b86ac5 | 66fc84c1b6b536be51b84895aa2be316618d3d49 | refs/heads/master | 2020-03-26T23:08:11.746765 | 2018-08-21T05:54:02 | 2018-08-21T05:54:02 | 145,513,289 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,217 | java | package bjl.core.enums;
import org.apache.commons.lang3.StringUtils;
/**
* 银行代号枚举
* Created by zhangjin on 2017/9/7.
*/
public enum BankSegment {
ICBC("工商银行", 1001),
ABC("农业银行", 1002),
BOC("中国银行", 1003),
CCB("建设银行", 1004),
BCM("交通银行", 1005),
PSBC("邮政储蓄银行",1006),
CNCB("中信银行", 1007),
CEB("光大银行", 1008),
HXB("华夏银行", 1009),
CMSB("民生银行", 1010),
PAB("平安银行", 1011),
CMBC("招商银行", 1012),
CIB("兴业银行", 1013),
SPDB("浦发银行", 1014),
GDB("广发银行", 1017);
private String name;
private int value;
public String getName() {
return name;
}
public int getValue() {
return value;
}
BankSegment(String name, int value) {
this.name = name;
this.value = value;
}
public static String getByValue(Integer value){
for(BankSegment bankSegment : BankSegment.values()){
if(value == bankSegment.value){
return bankSegment.name();
}
}
return null;
}
}
| [
"[email protected]"
] | |
fc153a4d9da3d3ac069cbad8818a29f1c576f2d3 | 1f4fd7b4009cffae138f7466e3c32667d34c82b6 | /src/sga/gui/TelaClassApostadores.java | 02a1e8bbb4e3b26df6c7d7a152e9d597d26e10a7 | [] | no_license | demisgomes/bolao_da_copa | 5fb142fe998739d5f6f75ef0a738c86dfd54cbe1 | ebffcdb1373aef3a804b34891f74f8a42ed41630 | refs/heads/master | 2021-01-10T11:57:39.604233 | 2016-01-09T00:43:28 | 2016-01-09T00:43:28 | 49,304,662 | 3 | 1 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,315 | java | package sga.gui;
import java.awt.EventQueue;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import sga.dominio.aposta.Apostador;
import sga.dominio.aposta.GrupoApostadores;
/**
* Tela que mostra a classificação para os usuários
* @author Demis
*
*/
public class TelaClassApostadores extends JFrame {
private JPanel contentPane;
private JTable table;
private JTable table_1;
/**
* Create the frame.
*/
public TelaClassApostadores() {
setTitle("Classifica\u00E7\u00E3o dos Apostadores");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 245, 281);
contentPane = new JPanel();
contentPane.setForeground(SystemColor.activeCaption);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
//chama o método que gera a classificação
//na classe GrupoApostadores
GrupoApostadores.gerarClassificacaoApostadores();
JButton btnVoltar = new JButton("Voltar");
btnVoltar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
new TelaInicial().setVisible(true);
TelaClassApostadores.this.dispose();
}
});
btnVoltar.setBounds(77, 201, 89, 23);
contentPane.add(btnVoltar);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(35, 11, 183, 166);
contentPane.add(scrollPane);
//método que o professor Gabriel fez
ArrayList<Apostador> classificacao = GrupoApostadores.getClassificacao();
//cria um objeto chamado dados
Object[][] dados = new Object[classificacao.size()][2];
int idx = 0;
//para cada apostador na classificação
for (Apostador apostador : classificacao) {
//o primeiro dado será o nome
//o segundo será os pontos
dados[idx][0] = apostador.getNome();
dados[idx][1] = apostador.getPontos();
idx++;
}
//Os nomes das colunas serão Nome e pontos
Object[] colunas = {"Nome","Pontos"};
table_1 = new JTable(dados,colunas);
//adiciona a JTable no scrollpane
scrollPane.setViewportView(table_1);
}
}
| [
"Telascaviado24"
] | Telascaviado24 |
431725fc7592a39640ed7d13055c9c9f89fca7f3 | 32c2b65a40877e1090916b44f662d942f35cabec | /src/main/java/de/noriskclient/watermod/mixin/StructurePieceMixin.java | e8e279cc07c4545317e61af298f387c22cb4d32c | [
"CC0-1.0"
] | permissive | copyandexecute/EverythingIsWater | c8ced1412d4986d67a3a9c1663f3c49046db90f2 | a26891d2437c04c9497b16ff8632f7694d891afb | refs/heads/master | 2023-02-08T11:43:07.934527 | 2020-12-27T15:43:20 | 2020-12-27T15:43:20 | 324,560,288 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,636 | java | package de.noriskclient.watermod.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.structure.StructurePiece;
import net.minecraft.util.math.BlockBox;
import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(StructurePiece.class)
public class StructurePieceMixin {
@ModifyVariable(method = "fillWithOutline(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockBox;IIIIIILnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Z)V", at = @At("HEAD"), ordinal = 0)
private BlockState injected(BlockState blockState) {
return blockState.equals(Blocks.AIR.getDefaultState()) || blockState.equals(Blocks.CAVE_AIR.getDefaultState()) ? Blocks.WATER.getDefaultState() : blockState;
}
@ModifyVariable(method = "fillWithOutline(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockBox;IIIIIILnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Z)V", at = @At("HEAD"), ordinal = 1)
private BlockState injected2(BlockState blockState) {
return blockState.equals(Blocks.AIR.getDefaultState()) || blockState.equals(Blocks.CAVE_AIR.getDefaultState()) ? Blocks.WATER.getDefaultState() : blockState;
}
@ModifyVariable(method = "addBlock", at = @At("HEAD"), ordinal = 0)
private BlockState modifyaddBlock( BlockState block) {
return block.getMaterial().equals(Material.AIR) ? Blocks.WATER.getDefaultState() : block;
}
}
| [
"[email protected]"
] | |
c500a5fcae025d5da3735dba78006840d0f12e70 | 6e423ba9f9a28796344c611350678fba2cb93baf | /im-common/src/main/java/com/huzhihui/im/common/dto/msg/PlatformImMessage.java | fcdacad89929e68a9cee1c69843eae522f144f03 | [] | no_license | zhihuihu/IM | 1402040d866b2ff5f4332e22e7106805e4a221fd | 6fc8e6e9a0a9454495e16420a6bc5e69ee8a3932 | refs/heads/master | 2023-03-29T14:51:11.608020 | 2021-04-03T11:07:33 | 2021-04-03T11:07:33 | 351,090,120 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 651 | java | /**
* zhihuihu.github.io.
* Copyright (c) 2016-2019 All Rights Reserved.
*/
package com.huzhihui.im.common.dto.msg;
/**
* 平台通知消息
* @author huzhi
* @version $ v 0.1 2021/3/24 21:43 huzhi Exp $$
*/
public class PlatformImMessage extends BaseImMessage {
/** 接收者 */
private String toUserId;
/** 数据 */
private String data;
public String getToUserId() {
return toUserId;
}
public void setToUserId(String toUserId) {
this.toUserId = toUserId;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
| [
"[email protected]"
] | |
de2ac57aec0ba861a0edbfcc8494a4d25e566c2d | 1fadacc8af4519f825bb0ed99a61091572b8a3ed | /jdk8-features/src/com/msrm/jdk8/feature/ImprovedMapApp.java | 41edec74f50790061cb1887ff6afc0c9f1c04e25 | [] | no_license | srirambtechit/java-technology | aeb60240659e2cf6d932c8769dfc63bae9562912 | a6ad2530d8869b90f44dd6248df4aab0927d619d | refs/heads/master | 2020-12-29T02:37:30.081557 | 2016-12-24T16:37:08 | 2016-12-24T16:37:08 | 44,532,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,500 | java | package com.msrm.jdk8.feature;
import java.util.HashMap;
import java.util.Map;
public class ImprovedMapApp {
public static void main(String[] args) {
Map<String, String> oldMap = new HashMap<>();
oldMap.put("1", "one");
oldMap.put("2", "two");
oldMap.put("3", "three");
for (int i = 0; i < 10; i++) {
if (!oldMap.containsKey(String.valueOf(i)))
oldMap.put(String.valueOf(i), "val" + i);
}
System.out.println(oldMap);
System.out.println();
// 1. no need of checking key presents
Map<String, String> newMap = new HashMap<>();
newMap.put("1", "one");
newMap.put("2", "two");
newMap.put("3", "three");
for (int i = 0; i < 10; i++) {
newMap.putIfAbsent(String.valueOf(i), "val" + i);
}
System.out.println(newMap);
System.out.println();
// 2. compute logic on map based on presents of value
newMap.computeIfPresent("1", (k, v) -> v.concat(k));
// 3. compute logic on map if value not there
newMap.computeIfAbsent("10", v -> "ten");
// 4. always get value though value not there in map
// key "11" not in map
String foundValue = newMap.getOrDefault("11", "negative");
String defaultValue = newMap.getOrDefault("10", "negative");
System.out.println(foundValue);
System.out.println(defaultValue);
System.out.println();
// 5. merging values in map
newMap.merge("10", "_value", String::concat); // ten_value
// 4. printing map is so easy in lambda style
newMap.forEach((k, v) -> System.out.println(k + "=" + v));
}
}
| [
"[email protected]"
] | |
aff154ab2429d7a03fd22c5ff6066715003c8bf8 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/5/5_891741aebbe3d5a8d2426a499e93b00afb93ba10/QueryTranslatorXQueryImpl/5_891741aebbe3d5a8d2426a499e93b00afb93ba10_QueryTranslatorXQueryImpl_s.java | cb31e6bc49c8ba2eb9c6a030487e2f44a4f962fc | [] | 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 | 8,297 | java | /**
* Copyright (C) [2013] [The FURTHeR 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 edu.utah.further.ds.impl.service.query.logic;
import static edu.utah.further.core.api.constant.Constants.Scope.PROTOTYPE;
import static edu.utah.further.ds.api.util.AttributeName.META_DATA;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.ByteArrayInputStream;
import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBException;
import org.apache.commons.lang.Validate;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import edu.utah.further.core.api.chain.AttributeContainerImpl;
import edu.utah.further.core.api.chain.ChainRequest;
import edu.utah.further.core.api.collections.CollectionUtil;
import edu.utah.further.core.api.exception.ApplicationError;
import edu.utah.further.core.api.exception.ApplicationException;
import edu.utah.further.core.api.exception.WsException;
import edu.utah.further.core.api.lang.ReflectionUtil;
import edu.utah.further.core.api.xml.XmlService;
import edu.utah.further.core.chain.ChainRequestImpl;
import edu.utah.further.core.query.domain.SearchQueryTo;
import edu.utah.further.core.xml.xquery.XQueryService;
import edu.utah.further.ds.api.service.query.logic.QueryTranslator;
import edu.utah.further.ds.api.util.AttributeName;
import edu.utah.further.fqe.ds.api.domain.DsMetaData;
import edu.utah.further.fqe.ds.api.domain.QueryContext;
import edu.utah.further.fqe.ds.api.util.FqeDsQueryContextUtil;
import edu.utah.further.mdr.ws.api.service.rest.AssetServiceRest;
/**
* Query translator implementation that utilizes XQuery to translate queries. Use of this
* class requires setting the location of the XQuery artifact in the
* {@link AttributeName#QUERY_TRANSLATION}
* <p>
* -----------------------------------------------------------------------------------<br>
* (c) 2008-2012 FURTHeR Project, Health Sciences IT, University of Utah<br>
* Contact: {@code <[email protected]>}<br>
* Biomedical Informatics, 26 South 2000 East<br>
* Room 5775 HSEB, Salt Lake City, UT 84112<br>
* Day Phone: 1-801-581-4080<br>
* -----------------------------------------------------------------------------------
*
* @author N. Dustin Schultz {@code <[email protected]>}
* @version Jul 30, 2013
*/
@Service("queryTranslatorXquery")
@Qualifier("impl")
@Scope(PROTOTYPE)
public class QueryTranslatorXQueryImpl implements QueryTranslator
{
// ========================= CONSTANTS =================================
/**
* A logger that helps identify this class' printouts.
*/
private static final Logger log = getLogger(MethodHandles.lookup().lookupClass());
/**
* The byte encoding to use with Strings
*/
private static final Charset UTF_8 = Charset.forName("UTF-8");
// ========================= FIELDS =====================================
// ========================= DEPENDENCIES ===========================
/**
* XQuery Service
*/
@Autowired
@Qualifier("xqueryService")
private XQueryService xqueryService;
/**
* Service for marshalling and unmarshalling to XML
*/
@Autowired
private XmlService xmlService;
/**
* MDR web service client.
*/
@Autowired
@Qualifier("mdrAssetServiceRestClient")
private AssetServiceRest assetServiceRest;
// ================== IMPL: QueryTranslatorXQueryImpl ===================
@SuppressWarnings("unchecked")
/*
* (non-Javadoc)
*
* @see
* edu.utah.further.ds.api.service.query.logic.QueryTranslator#translate(edu.utah.
* further.fqe.ds.api.domain.QueryContext)
*/
@Override
public <T> T translate(final QueryContext queryContext,
final Map<String, Object> attributes)
{
if (log.isTraceEnabled())
{
log.trace("Translating query " + queryContext.getQuery() + " ... ");
}
final ChainRequest request = new ChainRequestImpl(new AttributeContainerImpl(
attributes));
final String query = FqeDsQueryContextUtil.marshalSearchQuery(xmlService,
queryContext.getQuery());
final String pathToXquery = request.getAttribute(AttributeName.QUERY_TRANSLATION);
if (pathToXquery == null)
{
throw new ApplicationException(
AttributeName.QUERY_TRANSLATION.getLabel()
+ " label was not set; don't know where to search for xquery translation");
}
String xQuery;
try
{
xQuery = assetServiceRest.getActiveResourceContentByPath(pathToXquery);
}
catch (final WsException e)
{
throw new ApplicationException("Unable to find XQuery for query translation",
e);
}
final DsMetaData dsMetaData = request.getAttribute(META_DATA);
@SuppressWarnings("serial")
final Map<String, String> parameters = new HashMap<String, String>()
{
{
put("tgNmspcId", dsMetaData.getNamespaceId().toString());
put("tgNmspcName", dsMetaData.getName());
}
};
final String result = xqueryService.executeIntoString(new ByteArrayInputStream(
xQuery.getBytes(UTF_8)), new ByteArrayInputStream(query.getBytes(UTF_8)),
parameters);
if (log.isTraceEnabled())
{
log.trace("XQuery Translation result: " + result);
}
final Object unmarshalResult;
try
{
unmarshalResult = xmlService.unmarshal(
new ByteArrayInputStream(result.getBytes()), xmlService
.options()
.addClass(SearchQueryTo.class)
.addClass(ApplicationError.class)
.buildContext()
.setRootNamespaceUris(CollectionUtil.<String> newSet()));
}
catch (final JAXBException e)
{
throw new ApplicationException(
"Unable to unmarshal SearchQuery after query translation", e);
}
if (ReflectionUtil.instanceOf(unmarshalResult, ApplicationError.class))
{
final ApplicationError error = (ApplicationError) unmarshalResult;
log.error("Query translation returned error, translation failed");
throw new ApplicationException(error.getCode(), error.getMessage());
}
// Sanity check
Validate.isTrue(ReflectionUtil.instanceOf(unmarshalResult, SearchQueryTo.class));
return (T) unmarshalResult;
}
// ========================= GET/SET ===========================
/**
* Return the xqueryService property.
*
* @return the xqueryService
*/
public XQueryService getXqueryService()
{
return xqueryService;
}
/**
* Set a new value for the xqueryService property.
*
* @param xqueryService
* the xqueryService to set
*/
public void setXqueryService(final XQueryService xqueryService)
{
this.xqueryService = xqueryService;
}
/**
* Return the xmlService property.
*
* @return the xmlService
*/
public XmlService getXmlService()
{
return xmlService;
}
/**
* Set a new value for the xmlService property.
*
* @param xmlService
* the xmlService to set
*/
public void setXmlService(final XmlService xmlService)
{
this.xmlService = xmlService;
}
/**
* Return the assetServiceRest property.
*
* @return the assetServiceRest
*/
public AssetServiceRest getAssetServiceRest()
{
return assetServiceRest;
}
/**
* Set a new value for the assetServiceRest property.
*
* @param assetServiceRest
* the assetServiceRest to set
*/
public void setAssetServiceRest(final AssetServiceRest assetServiceRest)
{
this.assetServiceRest = assetServiceRest;
}
}
| [
"[email protected]"
] | |
0398d36f94c3e5140611d5574da7dfaf83439518 | 71674f20bb75d1475f6b0c1dc1bead37be361c72 | /BankAccount.java | 62232f214e551ecf71cff808f2028ac26d3248b2 | [] | no_license | 2018deckerd/BankAccount_Optimized | 451a6c7481b0b88043dc1d5c1d1bd40e6d3ad0dc | ad7a0683d8ec307108f038c166de25c180328f14 | refs/heads/master | 2021-05-16T06:23:04.880420 | 2017-09-13T20:38:26 | 2017-09-13T20:38:26 | 103,447,913 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,346 | java | /**
* Account for keeping basic information for all types of bank account types
* @author Dylan Decker
*
*/
public class BankAccount {
static String name;
static int accountNumber = 1; // account number of bank account
static double amount; // amount of deposit or withdrawal
static double balance;
public BankAccount(String name, int accountNumber) {
this.name = name;
this.accountNumber = accountNumber;
}
/*
* Getter methods for the class
*/
public static String getName() {
return name;
}
public static int getAccountNumber() {
return accountNumber;
}
public static double getAmount() {
return amount;
}
public static double getBalance() {
return amount;
}
/*
* Setter methods for the class
*/
public static void setName(String n) {
name = n;
}
public static void setAccountNumber(int an) {
accountNumber = an;
}
public static void setAmount(double a) {
amount = a;
}
public static void setBalance(double b) {
balance = b;
}
/*
* This method prints out some general information about the bank account
*/
public static void printOut() {
System.out.println("Please select an option by entering the first letter of the choice. For instance,"
+ " to make a deposit, enter D.");
System.out.println("D)eposit\nW)ithdrawl\nM)onth end\nQ)uit");
}
}
| [
"[email protected]"
] | |
d8ea868e54d41cc6fa213acb12d6f5f0b2508bf3 | 7941d6ed6d1f87954de73876c6d70b2b4b9e8a8c | /src/PART_I_Core/Day16_Pbjects_and_Classes/copy/Dog.java | 9db30cfa64ea0efbf4c6389be72a02757929d5c7 | [] | no_license | Isso-Chan/Java-b13 | d91524f41788882b85b8fa7ba69b770cd0042a98 | a8d3697c7b8d77aba197077880b9657190da34a0 | refs/heads/master | 2022-11-14T05:47:48.062951 | 2020-07-02T11:23:43 | 2020-07-02T11:23:43 | 276,617,741 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 452 | java | package PART_I_Core.Day16_Pbjects_and_Classes.copy;
public class Dog {
// class is blueprint and has common properties and methods
String breed;
int age;
String color;
String name;
char veccination;
public void barking() {
System.out.println(name+ " is barking");
}
public void hungry() {
System.out.println(name+" is hungry");
}
public void speeping() {
System.out.println(name+" is sleeping");
}
}
| [
"[email protected]"
] | |
9955629a4891d91710abf87401c254cb3b3319cf | 7a26d59d5f8292cf0b3ea762960bf3dbd3b861ca | /tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionControllerTest.java | 8663d0bcbb5949418a3ad3819bf769075bb72c27 | [
"Apache-2.0"
] | permissive | ResurrectionRemix/Resurrection_packages_apps_Settings | bac0727c91db6d4d5d7f8f2b4ea01d8f4273853b | c65423981fe1f615b51dc534038110e6e86f88ad | refs/heads/Q | 2021-12-15T14:52:54.291575 | 2021-09-19T11:36:02 | 2021-09-19T11:36:02 | 17,210,708 | 228 | 1,613 | NOASSERTION | 2023-01-02T18:18:06 | 2014-02-26T13:00:14 | Java | UTF-8 | Java | false | false | 2,583 | java | /*
* Copyright (C) 2019 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.settings.homepage.contextualcards.conditional;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import com.android.settings.homepage.contextualcards.ContextualCard;
import com.android.settings.testutils.shadow.ShadowWifiManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowWifiManager.class})
public class HotspotConditionControllerTest {
private static final String WIFI_AP_SSID = "Test Hotspot";
@Mock
private ConditionManager mConditionManager;
private Context mContext;
private HotspotConditionController mController;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mController = new HotspotConditionController(mContext, mConditionManager);
}
@Test
public void buildContextualCard_hasWifiAp_shouldHaveWifiApSsid() {
setupWifiApConfiguration();
final ContextualCard card = mController.buildContextualCard();
assertThat(card.getSummaryText()).isEqualTo(WIFI_AP_SSID);
}
@Test
public void buildContextualCard_noWifiAp_shouldHaveDefaultSsid() {
final ContextualCard card = mController.buildContextualCard();
assertThat(card.getSummaryText()).isEqualTo(
mContext.getText(com.android.internal.R.string.wifi_tether_configure_ssid_default));
}
private void setupWifiApConfiguration() {
final WifiConfiguration wifiApConfig = new WifiConfiguration();
wifiApConfig.SSID = WIFI_AP_SSID;
mContext.getSystemService(WifiManager.class).setWifiApConfiguration(wifiApConfig);
}
}
| [
"[email protected]"
] | |
e6ae57318f4dc72b983d73737016c6ca7eb882b3 | 312ce2354c4616300b1b408868e04b78aa259207 | /Music/src/com/feebe/music/ArtistAlbumBrowserActivity.java | c1b9540e20462349e908bd1efd3075198d772ada | [] | no_license | jq/zhong | 473feff7043ff00355fe29097e9fc0b1e267ad4f | 8c088fdea923ca94eff51b0a3375595a69862ff8 | refs/heads/master | 2020-04-14T08:13:51.357206 | 2011-05-11T13:47:39 | 2011-05-11T13:47:39 | 1,487,089 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 35,003 | java | /*
* Copyright (C) 2007 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.feebe.music;
import com.feebe.music.QueryBrowserActivity.QueryListAdapter.QueryHandler;
import android.app.ExpandableListActivity;
import android.app.SearchManager;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.CursorAdapter;
import android.widget.CursorTreeAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.SectionIndexer;
import android.widget.SimpleCursorTreeAdapter;
import android.widget.TextView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import java.text.Collator;
public class ArtistAlbumBrowserActivity extends ExpandableListActivity
implements View.OnCreateContextMenuListener, MusicUtils.Defs
{
private String mCurrentArtistId;
private String mCurrentArtistName;
private String mCurrentAlbumId;
private String mCurrentAlbumName;
private String mCurrentArtistNameForAlbum;
private ArtistAlbumListAdapter mAdapter;
private boolean mAdapterSent;
private boolean mAdapterDestroyed = false;
private final static int SEARCH = CHILD_MENU_BASE;
public ArtistAlbumBrowserActivity()
{
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
if (icicle != null) {
mCurrentAlbumId = icicle.getString("selectedalbum");
mCurrentAlbumName = icicle.getString("selectedalbumname");
mCurrentArtistId = icicle.getString("selectedartist");
mCurrentArtistName = icicle.getString("selectedartistname");
}
MusicUtils.bindToService(this);
IntentFilter f = new IntentFilter();
f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
f.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
f.addDataScheme("file");
registerReceiver(mScanListener, f);
setContentView(R.layout.media_picker_activity_expanding);
ExpandableListView lv = getExpandableListView();
lv.setFastScrollEnabled(true);
lv.setOnCreateContextMenuListener(this);
lv.setTextFilterEnabled(true);
mAdapter = (ArtistAlbumListAdapter) getLastNonConfigurationInstance();
if (mAdapter == null) {
//Log.i("@@@", "starting query");
mAdapter = new ArtistAlbumListAdapter(
getApplication(),
this,
null, // cursor
R.layout.track_list_item_group,
new String[] {},
new int[] {},
R.layout.track_list_item_child,
new String[] {},
new int[] {});
setListAdapter(mAdapter);
setTitle(R.string.working_artists);
getArtistCursor(mAdapter.getQueryHandler(), null);
} else {
mAdapter.setActivity(this);
setListAdapter(mAdapter);
mArtistCursor = mAdapter.getCursor();
if (mArtistCursor != null) {
init(mArtistCursor);
} else {
getArtistCursor(mAdapter.getQueryHandler(), null);
}
}
}
@Override
public Object onRetainNonConfigurationInstance() {
mAdapterSent = true;
return mAdapter;
}
@Override
public void onSaveInstanceState(Bundle outcicle) {
// need to store the selected item so we don't lose it in case
// of an orientation switch. Otherwise we could lose it while
// in the middle of specifying a playlist to add the item to.
outcicle.putString("selectedalbum", mCurrentAlbumId);
outcicle.putString("selectedalbumname", mCurrentAlbumName);
outcicle.putString("selectedartist", mCurrentArtistId);
outcicle.putString("selectedartistname", mCurrentArtistName);
super.onSaveInstanceState(outcicle);
}
@Override
public void onDestroy() {
MusicUtils.unbindFromService(this);
if (!mAdapterSent) {
Cursor c = mAdapter.getCursor();
if (c != null) {
c.close();
}
}
if (mAdapter != null) {
mAdapter.getQueryHandler().removeCallbacksAndMessages(null);
}
mReScanHandler.removeCallbacksAndMessages(null);
// Because we pass the adapter to the next activity, we need to make
// sure it doesn't keep a reference to this activity. We can do this
// by clearing its DatasetObservers, which setListAdapter(null) does.
setListAdapter(null);
mAdapter = null;
mAdapterDestroyed = true;
unregisterReceiver(mScanListener);
super.onDestroy();
}
@Override
public void onResume() {
super.onResume();
IntentFilter f = new IntentFilter();
f.addAction(MediaPlaybackService.META_CHANGED);
f.addAction(MediaPlaybackService.QUEUE_CHANGED);
registerReceiver(mTrackListListener, f);
mTrackListListener.onReceive(null, null);
MusicUtils.setSpinnerState(this);
}
private BroadcastReceiver mTrackListListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
getExpandableListView().invalidateViews();
}
};
private BroadcastReceiver mScanListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MusicUtils.setSpinnerState(ArtistAlbumBrowserActivity.this);
mReScanHandler.sendEmptyMessage(0);
if (intent.getAction().equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
MusicUtils.clearAlbumArtCache();
}
}
};
private Handler mReScanHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
getArtistCursor(mAdapter.getQueryHandler(), null);
}
};
@Override
public void onPause() {
unregisterReceiver(mTrackListListener);
mReScanHandler.removeCallbacksAndMessages(null);
super.onPause();
}
public void init(Cursor c) {
if (mAdapterDestroyed)
return;
mAdapter.changeCursor(c); // also sets mArtistCursor
if (mArtistCursor == null) {
MusicUtils.displayDatabaseError(this);
closeContextMenu();
mReScanHandler.sendEmptyMessageDelayed(0, 1000);
return;
}
MusicUtils.hideDatabaseError(this);
setTitle();
}
private void setTitle() {
setTitle(R.string.artists_title);
}
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
mCurrentAlbumId = Long.valueOf(id).toString();
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
intent.putExtra("album", mCurrentAlbumId);
Cursor c = (Cursor) getExpandableListAdapter().getChild(groupPosition, childPosition);
String album = c.getString(c.getColumnIndex(MediaStore.Audio.Albums.ALBUM));
if (album == null || album.equals(MediaFile.UNKNOWN_STRING)) {
// unknown album, so we should include the artist ID to limit the songs to songs only by that artist
mArtistCursor.moveToPosition(groupPosition);
mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndex(MediaStore.Audio.Artists._ID));
intent.putExtra("artist", mCurrentArtistId);
}
startActivity(intent);
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, GOTO_START, 0, R.string.goto_start).setIcon(R.drawable.ic_menu_music_library);
menu.add(0, GOTO_PLAYBACK, 0, R.string.goto_playback).setIcon(R.drawable.ic_menu_playback);
menu.add(0, SHUFFLE_ALL, 0, R.string.shuffle_all).setIcon(R.drawable.ic_menu_shuffle);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(GOTO_PLAYBACK).setVisible(MusicUtils.isMusicLoaded());
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
Cursor cursor;
switch (item.getItemId()) {
case GOTO_START:
intent = new Intent();
intent.setClass(this, MusicBrowserActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
case GOTO_PLAYBACK:
intent = new Intent("com.android.music.PLAYBACK_VIEWER");
startActivity(intent);
return true;
case SHUFFLE_ALL:
cursor = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String [] { MediaStore.Audio.Media._ID},
MediaStore.Audio.Media.IS_MUSIC + "=1", null,
MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
if (cursor != null) {
MusicUtils.shuffleAll(this, cursor);
cursor.close();
}
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
MusicUtils.makePlaylistMenu(this, sub);
menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
menu.add(0, SEARCH, 0, R.string.search_title);
ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
if (gpos == -1) {
// this shouldn't happen
Log.d("Artist/Album", "no group");
return;
}
gpos = gpos - getExpandableListView().getHeaderViewsCount();
mArtistCursor.moveToPosition(gpos);
mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
mCurrentAlbumId = null;
if (mCurrentArtistName == null || mCurrentArtistName.equals(MediaFile.UNKNOWN_STRING)) {
menu.setHeaderTitle(getString(R.string.unknown_artist_name));
} else {
menu.setHeaderTitle(mCurrentArtistName);
}
return;
} else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
if (cpos == -1) {
// this shouldn't happen
Log.d("Artist/Album", "no child");
return;
}
Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
c.moveToPosition(cpos);
mCurrentArtistId = null;
mCurrentAlbumId = Long.valueOf(mi.id).toString();
mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
gpos = gpos - getExpandableListView().getHeaderViewsCount();
mArtistCursor.moveToPosition(gpos);
mCurrentArtistNameForAlbum = mArtistCursor.getString(
mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
if (mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaFile.UNKNOWN_STRING)) {
menu.setHeaderTitle(getString(R.string.unknown_album_name));
} else {
menu.setHeaderTitle(mCurrentAlbumName);
}
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION: {
// play everything by the selected artist
int [] list =
mCurrentArtistId != null ?
MusicUtils.getSongListForArtist(this, Integer.parseInt(mCurrentArtistId))
: MusicUtils.getSongListForAlbum(this, Integer.parseInt(mCurrentAlbumId));
MusicUtils.playAll(this, list, 0);
return true;
}
case QUEUE: {
int [] list =
mCurrentArtistId != null ?
MusicUtils.getSongListForArtist(this, Integer.parseInt(mCurrentArtistId))
: MusicUtils.getSongListForAlbum(this, Integer.parseInt(mCurrentAlbumId));
MusicUtils.addToCurrentPlaylist(this, list);
return true;
}
case NEW_PLAYLIST: {
Intent intent = new Intent();
intent.setClass(this, CreatePlaylist.class);
startActivityForResult(intent, NEW_PLAYLIST);
return true;
}
case PLAYLIST_SELECTED: {
int [] list =
mCurrentArtistId != null ?
MusicUtils.getSongListForArtist(this, Integer.parseInt(mCurrentArtistId))
: MusicUtils.getSongListForAlbum(this, Integer.parseInt(mCurrentAlbumId));
int playlist = item.getIntent().getIntExtra("playlist", 0);
MusicUtils.addToPlaylist(this, list, playlist);
return true;
}
case DELETE_ITEM: {
int [] list;
String desc;
if (mCurrentArtistId != null) {
list = MusicUtils.getSongListForArtist(this, Integer.parseInt(mCurrentArtistId));
String f = getString(R.string.delete_artist_desc);
desc = String.format(f, mCurrentArtistName);
} else {
list = MusicUtils.getSongListForAlbum(this, Integer.parseInt(mCurrentAlbumId));
String f = getString(R.string.delete_album_desc);
desc = String.format(f, mCurrentAlbumName);
}
Bundle b = new Bundle();
b.putString("description", desc);
b.putIntArray("items", list);
Intent intent = new Intent();
intent.setClass(this, DeleteItems.class);
intent.putExtras(b);
startActivityForResult(intent, -1);
return true;
}
case SEARCH:
doSearch();
return true;
}
return super.onContextItemSelected(item);
}
void doSearch() {
CharSequence title = null;
String query = null;
Intent i = new Intent();
i.setAction(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (mCurrentArtistId != null) {
title = mCurrentArtistName;
query = mCurrentArtistName;
i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistName);
i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE);
} else {
title = mCurrentAlbumName;
query = mCurrentArtistNameForAlbum + " " + mCurrentAlbumName;
i.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, mCurrentArtistNameForAlbum);
i.putExtra(MediaStore.EXTRA_MEDIA_ALBUM, mCurrentAlbumName);
i.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, MediaStore.Audio.Albums.ENTRY_CONTENT_TYPE);
}
title = getString(R.string.mediasearch, title);
i.putExtra(SearchManager.QUERY, query);
startActivity(Intent.createChooser(i, title));
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
switch (requestCode) {
case SCAN_DONE:
if (resultCode == RESULT_CANCELED) {
finish();
} else {
getArtistCursor(mAdapter.getQueryHandler(), null);
}
break;
case NEW_PLAYLIST:
if (resultCode == RESULT_OK) {
Uri uri = intent.getData();
if (uri != null) {
int [] list = null;
if (mCurrentArtistId != null) {
list = MusicUtils.getSongListForArtist(this, Integer.parseInt(mCurrentArtistId));
} else if (mCurrentAlbumId != null) {
list = MusicUtils.getSongListForAlbum(this, Integer.parseInt(mCurrentAlbumId));
}
MusicUtils.addToPlaylist(this, list, Integer.parseInt(uri.getLastPathSegment()));
}
}
break;
}
}
private Cursor getArtistCursor(AsyncQueryHandler async, String filter) {
StringBuilder where = new StringBuilder();
where.append(MediaStore.Audio.Artists.ARTIST + " != ''");
// Add in the filtering constraints
String [] keywords = null;
if (filter != null) {
String [] searchWords = filter.split(" ");
keywords = new String[searchWords.length];
Collator col = Collator.getInstance();
col.setStrength(Collator.PRIMARY);
for (int i = 0; i < searchWords.length; i++) {
keywords[i] = '%' + MediaStore.Audio.keyFor(searchWords[i]) + '%';
}
for (int i = 0; i < searchWords.length; i++) {
where.append(" AND ");
where.append(MediaStore.Audio.Media.ARTIST_KEY + " LIKE ?");
}
}
String whereclause = where.toString();
String[] cols = new String[] {
MediaStore.Audio.Artists._ID,
MediaStore.Audio.Artists.ARTIST,
MediaStore.Audio.Artists.NUMBER_OF_ALBUMS,
MediaStore.Audio.Artists.NUMBER_OF_TRACKS
};
Cursor ret = null;
if (async != null) {
async.startQuery(0, null, MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
cols, whereclause , keywords, MediaStore.Audio.Artists.ARTIST_KEY);
} else {
ret = MusicUtils.query(this, MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
cols, whereclause , keywords, MediaStore.Audio.Artists.ARTIST_KEY);
}
return ret;
}
static class ArtistAlbumListAdapter extends SimpleCursorTreeAdapter implements SectionIndexer {
private final Drawable mNowPlayingOverlay;
private final BitmapDrawable mDefaultAlbumIcon;
private int mGroupArtistIdIdx;
private int mGroupArtistIdx;
private int mGroupAlbumIdx;
private int mGroupSongIdx;
private final Context mContext;
private final Resources mResources;
private final String mAlbumSongSeparator;
private final String mUnknownAlbum;
private final String mUnknownArtist;
private final StringBuilder mBuffer = new StringBuilder();
private final Object[] mFormatArgs = new Object[1];
private final Object[] mFormatArgs3 = new Object[3];
private MusicAlphabetIndexer mIndexer;
private ArtistAlbumBrowserActivity mActivity;
private AsyncQueryHandler mQueryHandler;
private String mConstraint = null;
private boolean mConstraintIsValid = false;
private boolean mCursorInactive; // keep track of mCursor. Can be deactivated my mAdapter
static class ViewHolder {
TextView line1;
TextView line2;
ImageView play_indicator;
ImageView icon;
}
class QueryHandler extends AsyncQueryHandler {
QueryHandler(ContentResolver res) {
super(res);
}
@Override
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
//Log.i("@@@", "query complete");
mActivity.init(cursor);
}
}
ArtistAlbumListAdapter(Context context, ArtistAlbumBrowserActivity currentactivity,
Cursor cursor, int glayout, String[] gfrom, int[] gto,
int clayout, String[] cfrom, int[] cto) {
super(context, cursor, glayout, gfrom, gto, clayout, cfrom, cto);
mActivity = currentactivity;
mCursorInactive = false;
mQueryHandler = new QueryHandler(context.getContentResolver());
Resources r = context.getResources();
mNowPlayingOverlay = r.getDrawable(R.drawable.indicator_ic_mp_playing_list);
mDefaultAlbumIcon = (BitmapDrawable) r.getDrawable(R.drawable.albumart_mp_unknown_list);
// no filter or dither, it's a lot faster and we can't tell the difference
mDefaultAlbumIcon.setFilterBitmap(false);
mDefaultAlbumIcon.setDither(false);
mContext = context;
getColumnIndices(cursor);
mResources = context.getResources();
mAlbumSongSeparator = context.getString(R.string.albumsongseparator);
mUnknownAlbum = context.getString(R.string.unknown_album_name);
mUnknownArtist = context.getString(R.string.unknown_artist_name);
}
private void getColumnIndices(Cursor cursor) {
if (cursor != null) {
mGroupArtistIdIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID);
mGroupArtistIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST);
mGroupAlbumIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.NUMBER_OF_ALBUMS);
mGroupSongIdx = cursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.NUMBER_OF_TRACKS);
if (mIndexer != null) {
mIndexer.setCursor(cursor);
} else {
//mResources.getString(com.android.internal.R.string.fast_scroll_alphabet)
mIndexer = new MusicAlphabetIndexer(cursor, mGroupArtistIdx,"idx");
}
}
}
public void setActivity(ArtistAlbumBrowserActivity newactivity) {
mActivity = newactivity;
}
public AsyncQueryHandler getQueryHandler() {
return mQueryHandler;
}
@Override
public View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) {
View v = super.newGroupView(context, cursor, isExpanded, parent);
ImageView iv = (ImageView) v.findViewById(R.id.icon);
ViewGroup.LayoutParams p = iv.getLayoutParams();
p.width = ViewGroup.LayoutParams.WRAP_CONTENT;
p.height = ViewGroup.LayoutParams.WRAP_CONTENT;
ViewHolder vh = new ViewHolder();
vh.line1 = (TextView) v.findViewById(R.id.line1);
vh.line2 = (TextView) v.findViewById(R.id.line2);
vh.play_indicator = (ImageView) v.findViewById(R.id.play_indicator);
vh.icon = (ImageView) v.findViewById(R.id.icon);
vh.icon.setPadding(0, 0, 1, 0);
v.setTag(vh);
return v;
}
@Override
public View newChildView(Context context, Cursor cursor, boolean isLastChild,
ViewGroup parent) {
View v = super.newChildView(context, cursor, isLastChild, parent);
ViewHolder vh = new ViewHolder();
vh.line1 = (TextView) v.findViewById(R.id.line1);
vh.line2 = (TextView) v.findViewById(R.id.line2);
vh.play_indicator = (ImageView) v.findViewById(R.id.play_indicator);
vh.icon = (ImageView) v.findViewById(R.id.icon);
vh.icon.setBackgroundDrawable(mDefaultAlbumIcon);
vh.icon.setPadding(0, 0, 1, 0);
v.setTag(vh);
return v;
}
@Override
public void bindGroupView(View view, Context context, Cursor cursor, boolean isexpanded) {
ViewHolder vh = (ViewHolder) view.getTag();
String artist = cursor.getString(mGroupArtistIdx);
String displayartist = artist;
boolean unknown = artist == null || artist.equals(MediaFile.UNKNOWN_STRING);
if (unknown) {
displayartist = mUnknownArtist;
}
vh.line1.setText(displayartist);
int numalbums = cursor.getInt(mGroupAlbumIdx);
int numsongs = cursor.getInt(mGroupSongIdx);
String songs_albums = MusicUtils.makeAlbumsLabel(context,
numalbums, numsongs, unknown);
vh.line2.setText(songs_albums);
int currentartistid = MusicUtils.getCurrentArtistId();
int artistid = cursor.getInt(mGroupArtistIdIdx);
if (currentartistid == artistid && !isexpanded) {
vh.play_indicator.setImageDrawable(mNowPlayingOverlay);
} else {
vh.play_indicator.setImageDrawable(null);
}
}
@Override
public void bindChildView(View view, Context context, Cursor cursor, boolean islast) {
ViewHolder vh = (ViewHolder) view.getTag();
String name = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
String displayname = name;
boolean unknown = name == null || name.equals(MediaFile.UNKNOWN_STRING);
if (unknown) {
displayname = mUnknownAlbum;
}
vh.line1.setText(displayname);
int numsongs = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS));
int numartistsongs = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.NUMBER_OF_SONGS_FOR_ARTIST));
final StringBuilder builder = mBuffer;
builder.delete(0, builder.length());
if (unknown) {
numsongs = numartistsongs;
}
if (numsongs == 1) {
builder.append(context.getString(R.string.onesong));
} else {
if (numsongs == numartistsongs) {
final Object[] args = mFormatArgs;
args[0] = numsongs;
builder.append(mResources.getQuantityString(R.plurals.Nsongs, numsongs, args));
} else {
final Object[] args = mFormatArgs3;
args[0] = numsongs;
args[1] = numartistsongs;
args[2] = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
builder.append(mResources.getQuantityString(R.plurals.Nsongscomp, numsongs, args));
}
}
vh.line2.setText(builder.toString());
ImageView iv = vh.icon;
// We don't actually need the path to the thumbnail file,
// we just use it to see if there is album art or not
String art = cursor.getString(cursor.getColumnIndexOrThrow(
MediaStore.Audio.Albums.ALBUM_ART));
if (unknown || art == null || art.length() == 0) {
iv.setBackgroundDrawable(mDefaultAlbumIcon);
iv.setImageDrawable(null);
} else {
int artIndex = cursor.getInt(0);
Drawable d = MusicUtils.getCachedArtwork(context, artIndex, mDefaultAlbumIcon);
iv.setImageDrawable(d);
}
int currentalbumid = MusicUtils.getCurrentAlbumId();
int aid = cursor.getInt(0);
iv = vh.play_indicator;
if (currentalbumid == aid) {
iv.setImageDrawable(mNowPlayingOverlay);
} else {
iv.setImageDrawable(null);
}
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
int id = groupCursor.getInt(groupCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
String[] cols = new String[] {
MediaStore.Audio.Albums._ID,
MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.NUMBER_OF_SONGS,
MediaStore.Audio.Albums.NUMBER_OF_SONGS_FOR_ARTIST,
MediaStore.Audio.Albums.ALBUM_ART
};
Cursor c = MusicUtils.query(mActivity,
MediaStore.Audio.Artists.Albums.getContentUri("external", id),
cols, null, null, MediaStore.Audio.Albums.DEFAULT_SORT_ORDER);
class MyCursorWrapper extends CursorWrapper {
String mArtistName;
int mMagicColumnIdx;
MyCursorWrapper(Cursor c, String artist) {
super(c);
mArtistName = artist;
if (mArtistName == null || mArtistName.equals(MediaFile.UNKNOWN_STRING)) {
mArtistName = mUnknownArtist;
}
mMagicColumnIdx = c.getColumnCount();
}
@Override
public String getString(int columnIndex) {
if (columnIndex != mMagicColumnIdx) {
return super.getString(columnIndex);
}
return mArtistName;
}
@Override
public int getColumnIndexOrThrow(String name) {
if (MediaStore.Audio.Albums.ARTIST.equals(name)) {
return mMagicColumnIdx;
}
return super.getColumnIndexOrThrow(name);
}
@Override
public String getColumnName(int idx) {
if (idx != mMagicColumnIdx) {
return super.getColumnName(idx);
}
return MediaStore.Audio.Albums.ARTIST;
}
@Override
public int getColumnCount() {
return super.getColumnCount() + 1;
}
@Override
public void deactivate() {
synchronized (mActivity) {
mCursorInactive = true;
super.deactivate();
}
}
@Override
public boolean requery() {
synchronized (mActivity) {
mCursorInactive = !(super.requery()); // not ~ super()
return (mCursorInactive == false);
}
}
}
return new MyCursorWrapper(c, groupCursor.getString(mGroupArtistIdx));
}
@Override
public void changeCursor(Cursor cursor) {
if (cursor != null && cursor.isClosed()) {
return;
}
synchronized (mActivity) {
if ( mCursorInactive ) {
return;
}
if (cursor != mActivity.mArtistCursor) {
mActivity.mArtistCursor = cursor;
getColumnIndices(cursor);
super.changeCursor(cursor);
}
}
}
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
String s = constraint.toString();
if (mConstraintIsValid && (
(s == null && mConstraint == null) ||
(s != null && s.equals(mConstraint)))) {
return getCursor();
}
Cursor c = mActivity.getArtistCursor(null, s);
mConstraint = s;
mConstraintIsValid = true;
return c;
}
public Object[] getSections() {
return mIndexer.getSections();
}
public int getPositionForSection(int sectionIndex) {
return mIndexer.getPositionForSection(sectionIndex);
}
public int getSectionForPosition(int position) {
return 0;
}
}
private Cursor mArtistCursor;
}
| [
"[email protected]"
] | |
caa6a8fb4056edef34df480d4e117f7ce1ebfce0 | 5f48ad619a3bc9a37dc892db85f942a88efd4fca | /activity/src/main/java/org/itzheng/and/activity/ItSwipeBackActivity.java | ea7e6db921d930d168031115b9f7a1798d65520c | [] | no_license | itzheng/ActivityModule | 88c9606aa53f411b655b7cf9bbfede75fa435401 | 9b2e4daf589b12bef9becb54a346dc7180e9be2d | refs/heads/master | 2021-07-11T14:46:30.726772 | 2021-07-07T03:34:22 | 2021-07-07T03:34:22 | 124,034,771 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,689 | java | package org.itzheng.and.activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import cn.bingoogolapple.swipebacklayout.BGASwipeBackHelper;
/**
* Title:侧滑返回,主要用于需要侧滑返回的界面<br>
* Description: <br>
* https://github.com/bingoogolapple/BGASwipeBackLayout-Android
* <p>
* 需要在 build.gradle 添加依赖
* implementation 'cn.bingoogolapple:bga-swipebacklayout:1.2.0@aar'
* <p>
* 在 Application 的 oncreate 初始化
* BGASwipeBackHelper.init(this, null);
*
* @email [email protected]
* Created by itzheng on 2019-10-21.
*/
public class ItSwipeBackActivity extends ItActivity implements BGASwipeBackHelper.Delegate {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
if (isSupportSwipeBack()) {
initSwipeBackFinish();
}
super.onCreate(savedInstanceState);
}
protected BGASwipeBackHelper mSwipeBackHelper;
/**
* 初始化滑动返回。在 super.onCreate(savedInstanceState) 之前调用该方法
*/
protected void initSwipeBackFinish() {
mSwipeBackHelper = new BGASwipeBackHelper(this, this);
// 「必须在 Application 的 onCreate 方法中执行 BGASwipeBackHelper.init 来初始化滑动返回」
// 下面几项可以不配置,这里只是为了讲述接口用法。
// 设置滑动返回是否可用。默认值为 true
mSwipeBackHelper.setSwipeBackEnable(true);
// 设置是否仅仅跟踪左侧边缘的滑动返回。默认值为 true
mSwipeBackHelper.setIsOnlyTrackingLeftEdge(true);
// 设置是否是微信滑动返回样式。默认值为 true
mSwipeBackHelper.setIsWeChatStyle(true);
// 设置阴影资源 id。默认值为 R.drawable.bga_sbl_shadow
mSwipeBackHelper.setShadowResId(R.drawable.bga_sbl_shadow);
// 设置是否显示滑动返回的阴影效果。默认值为 true
mSwipeBackHelper.setIsNeedShowShadow(true);
// 设置阴影区域的透明度是否根据滑动的距离渐变。默认值为 true
mSwipeBackHelper.setIsShadowAlphaGradient(true);
// 设置触发释放后自动滑动返回的阈值,默认值为 0.3f
mSwipeBackHelper.setSwipeBackThreshold(0.3f);
// 设置底部导航条是否悬浮在内容上,默认值为 false
mSwipeBackHelper.setIsNavigationBarOverlap(false);
}
/**
* 是否支持侧滑关闭
*
* @return
*/
@Override
public boolean isSupportSwipeBack() {
return true;
}
@Override
public void onSwipeBackLayoutSlide(float slideOffset) {
}
@Override
public void onSwipeBackLayoutCancel() {
}
/**
* 滑动返回执行完毕,销毁当前 Activity
*/
@Override
public void onSwipeBackLayoutExecuted() {
mSwipeBackHelper.swipeBackward();
}
/**
* 设置滑动返回是否可用。
*
* @param swipeBackEnable
* @return
*/
public void setSwipeBackEnable(boolean swipeBackEnable) {
if (mSwipeBackHelper != null) {
mSwipeBackHelper.setSwipeBackEnable(swipeBackEnable);
}
}
@Override
public void onBackPressed() {
if (mSwipeBackHelper != null && mSwipeBackHelper.isSliding()) {
//正在滑动的时候取消返回事件
return;
}
if (isSupportSwipeBack()) {
//如果支持滑动关闭则使用插件回调
mSwipeBackHelper.backward();
} else {
//不支持滑动关闭使用系统返回
super.onBackPressed();
}
}
}
| [
"[email protected]"
] | |
2da35dc862ad7bfdd25bcee34aea7ce462119f9c | 47f7651d1c631b8ba11f5cfdf92a7d63c8e015b4 | /BWServer/dataService/initializeaccountdataService/InitializeAccountDataService_Stub.java | 740ec2e1a0f882815fe03e823d05cd5d53f4b251 | [] | no_license | gsyqwe/SoftEngineering2 | 416e75f455ef27de3d7aaadbf58e418b1e201a28 | 7b8e89ec13446f031e7dfb25f84ee503b7d410ff | refs/heads/master | 2020-04-06T15:31:55.513211 | 2018-11-15T17:53:54 | 2018-11-15T17:53:54 | 157,581,937 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 504 | java | //package initializeaccountdataService;
//
//
//import java.util.ArrayList;
//
//import PO.InitializeAccountPO;
//import enums.ResultMessage;
//
//public class InitializeAccountDataService_Stub implements InitializeAccountDataService {
// @Override
// public ArrayList<InitializeAccountPO> getList() {
// // TODO Auto-generated method stub
// return null;
// }
//
// @Override
// public ResultMessage insert(InitializeAccountPO po) {
// // TODO Auto-generated method stub
// return null;
// }
//
//}
| [
"[email protected]"
] | |
6e9e2d4a50861c21b6ae870f22ad0cf538913895 | f936a1c759e0ebcd4de9dc29857d8c6c25eae310 | /src/main/java/day0828/SpringMvcSample.java | bd3259f8ce9c0c46e43e5e42c79a704f1054b83e | [] | no_license | wwbaba/jtpStudy | 6c06df89f017f883e4905ef95e6b2f40ca46c695 | 8d1332f8aa4ae9d11106f9d930a3921d69fa0491 | refs/heads/master | 2020-03-29T03:56:53.328954 | 2018-09-21T01:36:06 | 2018-09-21T01:36:06 | 149,508,425 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 947 | java | package day0828;
/*
* springMvc开发总结:
* 1. 需要一个控制器,在web.xml中配置
* DispatcherServlet:
* 2. 需要一个spring的web配置文件
* [dispatch-servlet]-servlet.xml文件,在WEB-INF目录下,和web.xml同目录
* 3. 该spring配置文件中需要配置的选项:
* viewResolver:视图解析器
* 指定未来的jsp/html页面的解析方式/ jsp+model,构成需要返回的数据
* <mvc:default-servlet-handler />
* 针对非springmvc控制的内容,例如js/css/img等进行默认处理,配置适配器
*
* <context:component-scan base-package="day0827,day0828" />
* 指定了所有的controller类@Controller注解需要扫描的包路径,
* 扫描该包中的所有的类,如果有@Controller注解,则springMVC自动生成该类的实例并载入到springweb容器中
*
* src/applicationContext.xml配置
*
*
*/
public class SpringMvcSample {
}
| [
"[email protected]"
] | |
b8d249149bb77bc7ef4081af146c6e7b3461a640 | 56161c48587b273caa45c54802c8fb9215e6fae2 | /src/test/java/com/cheikh/invoice/security/DomainUserDetailsServiceIT.java | 445dbdd456f4f4fc0fb0f478b53cbc4f6caeeff8 | [] | no_license | chawki008/invoice_project | 528f55627e30f8aed678c8c5ed2b4ad1ad2d40c5 | dc1a02b7349864f8a976838d19077828d94c5d29 | refs/heads/master | 2022-04-04T02:09:21.710619 | 2019-12-29T20:21:53 | 2019-12-29T20:21:53 | 205,734,743 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,714 | java | package com.cheikh.invoice.security;
import com.cheikh.invoice.InvoiceProjectApp;
import com.cheikh.invoice.domain.User;
import com.cheikh.invoice.repository.UserRepository;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.transaction.annotation.Transactional;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* Integrations tests for {@link DomainUserDetailsService}.
*/
@SpringBootTest(classes = InvoiceProjectApp.class)
@Transactional
public class DomainUserDetailsServiceIT {
private static final String USER_ONE_LOGIN = "test-user-one";
private static final String USER_ONE_EMAIL = "test-user-one@localhost";
private static final String USER_TWO_LOGIN = "test-user-two";
private static final String USER_TWO_EMAIL = "test-user-two@localhost";
private static final String USER_THREE_LOGIN = "test-user-three";
private static final String USER_THREE_EMAIL = "test-user-three@localhost";
@Autowired
private UserRepository userRepository;
@Autowired
private UserDetailsService domainUserDetailsService;
private User userOne;
private User userTwo;
private User userThree;
@BeforeEach
public void init() {
userOne = new User();
userOne.setLogin(USER_ONE_LOGIN);
userOne.setPassword(RandomStringUtils.random(60));
userOne.setActivated(true);
userOne.setEmail(USER_ONE_EMAIL);
userOne.setFirstName("userOne");
userOne.setLastName("doe");
userOne.setLangKey("en");
userRepository.save(userOne);
userTwo = new User();
userTwo.setLogin(USER_TWO_LOGIN);
userTwo.setPassword(RandomStringUtils.random(60));
userTwo.setActivated(true);
userTwo.setEmail(USER_TWO_EMAIL);
userTwo.setFirstName("userTwo");
userTwo.setLastName("doe");
userTwo.setLangKey("en");
userRepository.save(userTwo);
userThree = new User();
userThree.setLogin(USER_THREE_LOGIN);
userThree.setPassword(RandomStringUtils.random(60));
userThree.setActivated(false);
userThree.setEmail(USER_THREE_EMAIL);
userThree.setFirstName("userThree");
userThree.setLastName("doe");
userThree.setLangKey("en");
userRepository.save(userThree);
}
@Test
@Transactional
public void assertThatUserCanBeFoundByLogin() {
UserDetails userDetails = domainUserDetailsService.loadUserByUsername(USER_ONE_LOGIN);
assertThat(userDetails).isNotNull();
assertThat(userDetails.getUsername()).isEqualTo(USER_ONE_LOGIN);
}
@Test
@Transactional
public void assertThatUserCanBeFoundByLoginIgnoreCase() {
UserDetails userDetails = domainUserDetailsService.loadUserByUsername(USER_ONE_LOGIN.toUpperCase(Locale.ENGLISH));
assertThat(userDetails).isNotNull();
assertThat(userDetails.getUsername()).isEqualTo(USER_ONE_LOGIN);
}
@Test
@Transactional
public void assertThatUserCanBeFoundByEmail() {
UserDetails userDetails = domainUserDetailsService.loadUserByUsername(USER_TWO_EMAIL);
assertThat(userDetails).isNotNull();
assertThat(userDetails.getUsername()).isEqualTo(USER_TWO_LOGIN);
}
@Test
@Transactional
public void assertThatUserCanBeFoundByEmailIgnoreCase() {
UserDetails userDetails = domainUserDetailsService.loadUserByUsername(USER_TWO_EMAIL.toUpperCase(Locale.ENGLISH));
assertThat(userDetails).isNotNull();
assertThat(userDetails.getUsername()).isEqualTo(USER_TWO_LOGIN);
}
@Test
@Transactional
public void assertThatEmailIsPrioritizedOverLogin() {
UserDetails userDetails = domainUserDetailsService.loadUserByUsername(USER_ONE_EMAIL);
assertThat(userDetails).isNotNull();
assertThat(userDetails.getUsername()).isEqualTo(USER_ONE_LOGIN);
}
@Test
@Transactional
public void assertThatUserNotActivatedExceptionIsThrownForNotActivatedUsers() {
assertThatExceptionOfType(UserNotActivatedException.class).isThrownBy(
() -> domainUserDetailsService.loadUserByUsername(USER_THREE_LOGIN));
}
}
| [
"[email protected]"
] | |
38945a40bd23c6f3d230ef2a7ef9cb9e893221d9 | decf86bcd14de7d105a33b8191dafc16a3e4580b | /10_Competition/src/competition/app/Runner.java | bfd29b5c9a02b2e9d2e304c8519b9d8451236ce6 | [] | no_license | MartinKonak/ALG2_online | 08a08b217bfcb6dc425acaea05f997a89af0c722 | fa0d4bfe10eb1263d987e936188aa7fe4a3ef85a | refs/heads/master | 2021-05-26T04:43:05.804791 | 2020-06-04T17:22:30 | 2020-06-04T17:22:30 | 254,057,155 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,192 | java | package competition.app;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/**
*
* @author Martin Koňák
*/
public class Runner implements Comparable<Runner> {
private int number;
private String firstname;
private String lastname;
private LocalTime startTime;
private LocalTime finishTime;
public static DateTimeFormatter dtfstart = DateTimeFormatter.ofPattern("HH:mm:ss");
public static DateTimeFormatter dtffinish = DateTimeFormatter.ofPattern("HH:mm:ss:SSS");
public Runner(int number, String firstname, String lastname) {
this.number = number;
this.firstname = firstname;
this.lastname = lastname;
}
public void setStartTime(String startTime) {
this.startTime = LocalTime.parse(startTime, dtfstart);
}
public void setFinishTime(String finishTime) {
this.finishTime = LocalTime.parse(finishTime, dtffinish);
}
public LocalTime getStartTime() {
return startTime;
}
public LocalTime getFinishTime() {
return finishTime;
}
public String getStartTimeString(){
return startTime.format(dtfstart);
}
public String getFinishTimeString(){
return finishTime.format(dtffinish);
}
public int getNumber() {
return number;
}
public LocalTime runningTime(){
return LocalTime.ofNanoOfDay(finishTime.toNanoOfDay() - startTime.toNanoOfDay());
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
@Override
public String toString() {
return String.format("%-4d%-10s%-10s%-15s%-15s%-15s", number, firstname, lastname, getStartTimeString(),
getFinishTimeString(), runningTime().format(dtffinish));
}
@Override
public int compareTo(Runner o) {
return this.runningTime().compareTo(o.runningTime());
}
/*public static void main(String[] args) {
Runner r = new Runner(101, "Alice", "Mala");
r.setStartTime("09:00:00");
r.setFinishTime("09:30:01:000");
System.out.println(r);
}*/
}
| [
"[email protected]"
] | |
9738621f35e02773ee7c4e19451124013503118d | 45673914cef5270318f85d438032187ec074260d | /TradeGame/src/tradegame/Guardian.java | 6ce2ccadbbc0747567759aa6fbf7bbdac2014d84 | [] | no_license | BluebirdLyrase/Tradegame | dace1b35194f83b4781db7db13eb246b02f40a85 | fc31144c48b86372ca654b8d5808dc6c0a1668ce | refs/heads/master | 2020-03-10T12:56:15.604319 | 2018-04-20T17:06:45 | 2018-04-20T17:06:45 | 128,940,271 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | package tradegame;
interface Guardian {
void Report();
}//4
| [
"[email protected]"
] | |
b39a25a6bf95bd38dbc8540d28130f92b0f54369 | 9efdb7d314e5dc90a2568ce1d613c0ff02ccfc4b | /app/src/main/java/com/yusong/community/ui/im/parse/UserProfileManager.java | 2290e87d857d66a48e2e4b3fdb789ae9b3e543ec | [] | no_license | feisher/community_huangshan2 | 1cdcb55e2b9c6394e7f0ac043b2d3c02fed04408 | aa3fc8103a0e6be8de89d0c7d81d2869724c4443 | refs/heads/master | 2021-07-14T18:15:52.164494 | 2017-10-19T03:25:01 | 2017-10-19T03:25:01 | 106,365,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,874 | java | package com.yusong.community.ui.im.parse;
import android.content.Context;
import com.hyphenate.EMValueCallBack;
import com.hyphenate.chat.EMClient;
import com.hyphenate.easeui.domain.EaseUser;
import com.yusong.community.ui.im.IMHelper;
import com.yusong.community.ui.im.IMHelper.DataSyncListener;
import com.yusong.community.ui.im.utils.PreferenceManager;
import java.util.ArrayList;
import java.util.List;
public class UserProfileManager {
/**
* application context
*/
protected Context appContext = null;
/**
* init flag: test if the sdk has been inited before, we don't need to init
* again
*/
private boolean sdkInited = false;
/**
* HuanXin sync contact nick and avatar listener
*/
private List<IMHelper.DataSyncListener> syncContactInfosListeners;
private boolean isSyncingContactInfosWithServer = false;
private EaseUser currentUser;
public UserProfileManager() {
}
public synchronized boolean init(Context context) {
if (sdkInited) {
return true;
}
ParseManager.getInstance().onInit(context);
syncContactInfosListeners = new ArrayList<DataSyncListener>();
sdkInited = true;
return true;
}
public void addSyncContactInfoListener(DataSyncListener listener) {
if (listener == null) {
return;
}
if (!syncContactInfosListeners.contains(listener)) {
syncContactInfosListeners.add(listener);
}
}
public void removeSyncContactInfoListener(DataSyncListener listener) {
if (listener == null) {
return;
}
if (syncContactInfosListeners.contains(listener)) {
syncContactInfosListeners.remove(listener);
}
}
public void asyncFetchContactInfosFromServer(List<String> usernames, final EMValueCallBack<List<EaseUser>> callback) {
if (isSyncingContactInfosWithServer) {
return;
}
isSyncingContactInfosWithServer = true;
// ParseManager.getInstance().getContactInfos(usernames, new EMValueCallBack<List<EaseUser>>() {
//
// @Override
// public void onSuccess(List<EaseUser> value) {
// isSyncingContactInfosWithServer = false;
// // in case that logout already before server returns,we should
// // return immediately
// if (!IMHelper.getInstance().isLoggedIn()) {
// return;
// }
// if (callback != null) {
// callback.onSuccess(value);
// }
// }
//
// @Override
// public void onError(int error, String errorMsg) {
// isSyncingContactInfosWithServer = false;
// if (callback != null) {
// callback.onError(error, errorMsg);
// }
// }
//
// });
}
public void notifyContactInfosSyncListener(boolean success) {
for (DataSyncListener listener : syncContactInfosListeners) {
listener.onSyncComplete(success);
}
}
public boolean isSyncingContactInfoWithServer() {
return isSyncingContactInfosWithServer;
}
public synchronized void reset() {
isSyncingContactInfosWithServer = false;
currentUser = null;
PreferenceManager.getInstance().removeCurrentUserInfo();
}
public synchronized EaseUser getCurrentUserInfo() {
if (currentUser == null) {
String username = EMClient.getInstance().getCurrentUser();
currentUser = new EaseUser(username);
String nick = getCurrentUserNick();
currentUser.setNick((nick != null) ? nick : username);
currentUser.setAvatar(getCurrentUserAvatar());
}
return currentUser;
}
public boolean updateCurrentUserNickName(final String nickname) {
boolean isSuccess = ParseManager.getInstance().updateParseNickName(nickname);
if (isSuccess) {
setCurrentUserNick(nickname);
}
return isSuccess;
}
public String uploadUserAvatar(byte[] data) {
String avatarUrl = ParseManager.getInstance().uploadParseAvatar(data);
if (avatarUrl != null) {
setCurrentUserAvatar(avatarUrl);
}
return avatarUrl;
}
//
// public void asyncGetCurrentUserInfo() {
// ParseManager.getInstance().asyncGetCurrentUserInfo(new EMValueCallBack<EaseUser>() {
//
// @Override
// public void onSuccess(EaseUser value) {
// if(value != null){
// setCurrentUserNick(value.getNick());
// setCurrentUserAvatar(value.getAvatar());
// }
// }
//
// @Override
// public void onError(int error, String errorMsg) {
//
// }
// });
//
// }
public void asyncGetUserInfo(final String username,final EMValueCallBack<EaseUser> callback){
ParseManager.getInstance().asyncGetUserInfo(username, callback);
}
private void setCurrentUserNick(String nickname) {
getCurrentUserInfo().setNick(nickname);
PreferenceManager.getInstance().setCurrentUserNick(nickname);
}
private void setCurrentUserAvatar(String avatar) {
getCurrentUserInfo().setAvatar(avatar);
PreferenceManager.getInstance().setCurrentUserAvatar(avatar);
}
private String getCurrentUserNick() {
return PreferenceManager.getInstance().getCurrentUserNick();
}
private String getCurrentUserAvatar() {
return PreferenceManager.getInstance().getCurrentUserAvatar();
}
}
| [
"[email protected]"
] | |
19534c505731b7b576c42867eace316490891d3e | f123c92704e5aa15dfd2e3ab0ecb3c7dfb8b87f2 | /LOTR/src/main/java/lotr/common/world/feature/LOTRWorldGenSimpleTrees.java | 8348f74f75e6ae79dc66aa8b6a964dfe948d78de | [] | no_license | Myrninvollo/LOTR-Minecraft-Mod | 2dcaabb659bfc10b41332f975209f2f8cd7e3f55 | 97843fd05ae9fc7a7f61021fbe288db0f0b4298b | refs/heads/master | 2020-12-30T22:58:22.274461 | 2014-10-12T19:06:55 | 2014-10-12T19:06:55 | 24,939,635 | 1 | 1 | null | 2014-10-12T19:06:55 | 2014-10-08T12:30:52 | null | UTF-8 | Java | false | false | 6,696 | java | package lotr.common.world.feature;
import java.util.Random;
import lotr.common.LOTRMod;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
public class LOTRWorldGenSimpleTrees extends WorldGenAbstractTree
{
private int minHeight;
private int maxHeight;
private Block woodID;
private int woodMeta;
private Block leafID;
private int leafMeta;
private int extraTrunkWidth;
private LOTRWorldGenSimpleTrees(boolean flag, int i, int j, Block k, int l, Block i1, int j1)
{
super(flag);
minHeight = i;
maxHeight = j;
woodID = k;
woodMeta = l;
leafID = i1;
leafMeta = j1;
}
public LOTRWorldGenSimpleTrees setTrunkWidth(int i)
{
extraTrunkWidth = i - 1;
return this;
}
public static LOTRWorldGenSimpleTrees newMallorn(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 9, 15, LOTRMod.wood, 1, LOTRMod.leaves, 1);
}
public static LOTRWorldGenSimpleTrees newApple(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 4, 7, LOTRMod.fruitWood, 0, LOTRMod.fruitLeaves, 0);
}
public static LOTRWorldGenSimpleTrees newPear(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 4, 5, LOTRMod.fruitWood, 1, LOTRMod.fruitLeaves, 1);
}
public static LOTRWorldGenSimpleTrees newCherry(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 4, 8, LOTRMod.fruitWood, 2, LOTRMod.fruitLeaves, 2);
}
public static LOTRWorldGenSimpleTrees newMango(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 4, 7, LOTRMod.fruitWood, 3, LOTRMod.fruitLeaves, 3);
}
public static LOTRWorldGenSimpleTrees newLebethron(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 5, 9, LOTRMod.wood2, 0, LOTRMod.leaves2, 0);
}
public static LOTRWorldGenSimpleTrees newLebethronLarge(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 11, 18, LOTRMod.wood2, 0, LOTRMod.leaves2, 0).setTrunkWidth(2);
}
public static LOTRWorldGenSimpleTrees newBeech(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 5, 9, LOTRMod.wood2, 1, LOTRMod.leaves2, 1);
}
public static LOTRWorldGenSimpleTrees newMaple(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 4, 8, LOTRMod.wood3, 0, LOTRMod.leaves3, 0);
}
public static LOTRWorldGenSimpleTrees newChestnut(boolean flag)
{
return new LOTRWorldGenSimpleTrees(flag, 5, 7, LOTRMod.wood4, 0, LOTRMod.leaves4, 0);
}
@Override
public boolean generate(World world, Random random, int i, int j, int k)
{
int height = MathHelper.getRandomIntegerInRange(random, minHeight, maxHeight);
boolean flag = true;
if (j >= 1 && j + height + 1 <= 256)
{
for (int j1 = j; j1 <= j + 1 + height; j1++)
{
int range = 1;
if (j1 == j)
{
range = 0;
}
if (j1 >= j + 1 + height - 2)
{
range = 2;
}
for (int i1 = i - range; i1 <= i + range + extraTrunkWidth && flag; i1++)
{
for (int k1 = k - range; k1 <= k + range + extraTrunkWidth && flag; k1++)
{
if (j1 >= 0 && j1 < 256)
{
Block block = world.getBlock(i1, j1, k1);
if (block.getMaterial() != Material.air && !block.isLeaves(world, i1, j1, k1) && block != Blocks.grass && block != Blocks.dirt && !block.isWood(world, i1, j1, k1))
{
flag = false;
}
}
else
{
flag = false;
}
}
}
}
if (!flag)
{
return false;
}
else
{
boolean flag1 = true;
for (int i1 = i; i1 <= i + extraTrunkWidth && flag1; i1++)
{
for (int k1 = k; k1 <= k + extraTrunkWidth && flag1; k1++)
{
Block block = world.getBlock(i1, j - 1, k1);
flag1 = ((block == Blocks.grass || block == Blocks.dirt) && j < 256 - height - 1);
}
}
if (flag1)
{
for (int i1 = i; i1 <= i + extraTrunkWidth; i1++)
{
for (int k1 = k; k1 <= k + extraTrunkWidth; k1++)
{
setBlockAndNotifyAdequately(world, i1, j - 1, k1, Blocks.dirt, 0);
}
}
byte leafStart = 3;
byte leafRangeMin = 0;
for (int j1 = j - leafStart + height; j1 <= j + height; j1++)
{
int j2 = j1 - (j + height);
int leafRange = leafRangeMin + 1 - j2 / 2;
for (int i1 = i - leafRange; i1 <= i + leafRange + extraTrunkWidth; i1++)
{
int i2 = i1 - i;
if (i2 > 0)
{
i2 -= extraTrunkWidth;
}
for (int k1 = k - leafRange; k1 <= k + leafRange + extraTrunkWidth; k1++)
{
int k2 = k1 - k;
if (k2 > 0)
{
k2 -= extraTrunkWidth;
}
Block block = world.getBlock(i1, j1, k1);
if ((Math.abs(i2) != leafRange || Math.abs(k2) != leafRange || random.nextInt(2) != 0 && j2 != 0) && block.canBeReplacedByLeaves(world, i1, j1, k1))
{
setBlockAndNotifyAdequately(world, i1, j1, k1, leafID, leafMeta);
}
}
}
}
for (int j1 = 0; j1 < height; j1++)
{
for (int i1 = i; i1 <= i + extraTrunkWidth; i1++)
{
for (int k1 = k; k1 <= k + extraTrunkWidth; k1++)
{
Block block = world.getBlock(i1, j + j1, k1);
if (block.getMaterial() == Material.air || block.isLeaves(world, i1, j + j1, k1))
{
setBlockAndNotifyAdequately(world, i1, j + j1, k1, woodID, woodMeta);
}
}
}
}
return true;
}
else
{
return false;
}
}
}
else
{
return false;
}
}
}
| [
"[email protected]"
] | |
61977c7b81f54b9113c7bb32bcf80d9e08c1d73a | 8d7a8184ad1bdcbc58b007ee93ae38614a01eec7 | /javaee/src/main/java/br/com/casadocodigo/loja/beans/Car.java | 8e049041074a3beff16b6b444eac0bce7e1bd087 | [] | no_license | levycandido/java-jee | e375e4ef0640e1c3dfc5efd3293e6fc96957cd9b | 3c9a12c9edf8d5a9cde9fed1395b499ab2682b8b | refs/heads/master | 2022-12-09T19:25:49.551903 | 2019-07-05T03:09:20 | 2019-07-05T03:09:20 | 195,330,084 | 0 | 0 | null | 2022-11-24T04:24:53 | 2019-07-05T03:06:13 | CSS | UTF-8 | Java | false | false | 2,629 | java | /*
* Copyright 2009-2014 PrimeTek.
*
* 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 br.com.casadocodigo.loja.beans;
import java.io.Serializable;
public class Car implements Serializable {
public String id;
public String brand;
public int year;
public String color;
public int price;
public boolean sold;
public Car() {}
public Car(String id, String brand, int year, String color) {
this.id = id;
this.brand = brand;
this.year = year;
this.color = color;
}
public Car(String id, String brand, int year, String color, int price, boolean sold) {
this.id = id;
this.brand = brand;
this.year = year;
this.color = color;
this.price = price;
this.sold = sold;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public boolean isSold() {
return sold;
}
public void setSold(boolean sold) {
this.sold = sold;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + (this.id != null ? this.id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Car other = (Car) obj;
if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
7b1a34f68715163099d06c7c0c24819b3ca88b21 | c143976e0f89ec73cad243e692abe3f78fd46aef | /springmvc/src/test/slowvic/shiro/realm/SimpleRealm.java | 907db64752cd629786f0b791ac9c086873a460c8 | [] | no_license | wusuoming/lyon | b746826780f719b1345acc29f6f331aa29ceef89 | 08d212447f65ca54846487f79c0d4d9dfefbfa1f | refs/heads/master | 2021-01-10T01:53:06.021647 | 2014-07-23T10:28:37 | 2014-07-23T10:28:37 | 44,794,729 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,306 | java | package test.slowvic.shiro.realm;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.realm.Realm;
public class SimpleRealm implements Realm {
@Override
public String getName() {
return "simpleRealm";
}
@Override
public boolean supports(AuthenticationToken token) {
return token instanceof UsernamePasswordToken;
}
@Override
public AuthenticationInfo getAuthenticationInfo(AuthenticationToken token)
throws AuthenticationException {
String userName = (String) token.getPrincipal();
String password = new String((char[]) (token.getCredentials()));
if (!"zhang".equals(userName)) {
throw new UnknownAccountException();
}
else if (!"123".equals(password)) {
throw new IncorrectCredentialsException();
}
return new SimpleAuthenticationInfo(token, userName, getName());
}
}
| [
"[email protected]"
] | |
62316dcfc54a73deedf00669ae8273e25beae89c | 7bdc34b26fb1a5ad9d88c13abf1d4a2c7ffc6d26 | /src/main/java/com/demo/supportportal/exceptions/UserNotFoundException.java | 57d7f8304772d91685d7952e61fd248878f50563 | [] | no_license | pks9862728888/support-portal | 46ee12728cfac3171a9f88aefc5cc371ae9fc972 | a2201b2f254ca08c700ff27c6dbe3d9f47a577c8 | refs/heads/master | 2023-04-27T18:06:56.738416 | 2021-05-17T08:31:48 | 2021-05-17T08:31:48 | 364,759,306 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 184 | java | package com.demo.supportportal.exceptions;
public class UserNotFoundException extends Exception {
public UserNotFoundException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
7a913f798a02bdbd841af8eb9ba8e9d796e38053 | 29a861c79f1f218211c8e2be07232a94c35da66f | /src/javaprograms/Pattern5.java | e91a3e5f42bf0738a70d85a92668594b179f3ed4 | [] | no_license | shivamsharma24/Java-programs | fe7a8586c04e2b1d26c95841211889654c744a0c | 6479f78070334d36f14fdcdc684a1e4260c8ac5d | refs/heads/master | 2020-03-21T09:05:35.418911 | 2018-06-23T07:57:09 | 2018-06-23T07:57:09 | 138,382,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 300 | java | package javaprograms;
public class Pattern5 {
/**
7 6 5 4 3 2 1
7 6 5 4 3 2
7 6 5 4 3
7 6 5 4
7 6 5
7 6
7
*/
public static void main(String[] args) {
for(int i=1;i<=7;i++)
{
for(int j=7;j>=i;j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
| [
"[email protected]"
] | |
2aae37eeb57dcd187402803be9aad57ed8000c15 | 358c4ceec836ff8de51e000f59031640ca9fbf8c | /作业10/Memento.java | 4b265ee65138f1d73af3bead38b4403d67645b36 | [] | no_license | lucky-alt/design-mode | 3c2a31e69864830faa4db2dd2afc27e1668a8564 | b7b335a9ec83c3bcf44530e0e1b40e61d7aea82f | refs/heads/master | 2023-05-12T09:16:56.833107 | 2021-06-06T06:55:18 | 2021-06-06T06:55:18 | 355,434,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 177 | java | public class Memento {
private State state;
public Memento(State state) {
this.state = state;
}
public State getState() {
return state;
}
} | [
"[email protected]"
] | |
ac6ab929ec6502a5415a34cc40fc6d4475d62ffd | b4da726763e4690a3f6eeaad58b71176fdbf0c4f | /src/com/akjava/gwt/clothhair/client/hair/HairDataUtils.java | 1916dcd195604e8db889a7be151a5c9fe5f15d09 | [] | no_license | akjava/GWTThreeClothHair | 350cecaddfba1165baba270f0ff5cfc2d9aef0c7 | b910e0605974e18f4ad3d1fe2e72ddb9dd02f0d9 | refs/heads/master | 2020-05-22T06:45:21.870888 | 2017-01-20T02:49:08 | 2017-01-20T02:49:08 | 60,046,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,187 | java | package com.akjava.gwt.clothhair.client.hair;
import java.util.List;
import com.akjava.gwt.clothhair.client.hair.HairData.HairPin;
import com.akjava.gwt.clothhair.client.hair.HairPinDataFunctions.HairPinToVertex;
import com.akjava.gwt.three.client.js.math.Vector3;
import com.akjava.gwt.three.client.js.objects.Mesh;
import com.google.common.collect.FluentIterable;
public class HairDataUtils {
public static double getTotalVDistance(double uDistance,int uSize,int vSize){
return (double)vSize/(double)uSize*uDistance;
}
public static double getTotalPinDistance(List<HairPin> pins,Mesh mesh,boolean applymatrix){
double distance=0;
HairPinToVertex hairPinToVertex= new HairPinToVertex(mesh,applymatrix);
List<Vector3> vecs=FluentIterable.from(pins).filter(HairPinPredicates.NoTargetOnly()).transform(hairPinToVertex).toList();
for(int i=0;i<vecs.size()-1;i++){
double d=vecs.get(i).distanceTo(vecs.get(i+1));
distance+=d;
}
return distance;
}
public static double getTotalPinDistance(HairData hairData,Mesh mesh,boolean applymatrix){
return getTotalPinDistance(hairData.getHairPins(),mesh,applymatrix);
}
}
| [
"[email protected]"
] | |
8da2bdd55c3f4087597a6fd8808cec58867f7ad6 | 067f6b1acfe42fc7ae782a9e569690a3297125f9 | /servlets-master/servlets/Servlet2/src/main/java/ru/javacourse/model/Address.java | 7ac483bebc1fc0a5efdcc845e26741593bba4c87 | [] | no_license | VitaliiMaltsev/Servlets | 7faaab5dbb0ba5afd0bad3f68ff3b5ce29c28ea8 | 5f4fab4c968bce22ea513b426af2f7fff66d1c02 | refs/heads/master | 2020-03-23T17:04:25.684052 | 2018-07-24T00:02:33 | 2018-07-24T00:02:33 | 141,841,378 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 918 | java | package ru.javacourse.model;
public class Address {
private String country;
private String city;
private String street;
private int zip;
public Address() {
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public int getZip() {
return zip;
}
public void setZip(int zip) {
this.zip = zip;
}
public Address(String country, String city, String street, int zip) {
this.country = country;
this.city = city;
this.street = street;
this.zip = zip;
}
}
| [
"[email protected]"
] | |
f2b4b4da92e31f02f53c410dc17d582ab8075340 | 8ba86df142e19635197a3fda9cb45845bb250de6 | /platforms/android/src/com/ionicframework/livefutsal400843/MainActivity.java | 393dd730a2b6921d8e1ab53cbd71de3a1999600a | [] | no_license | gallar12d/LiveFutsal | 7577b9c7228186bcac0a4f45e71db9275f062d76 | d1c337b4bc79046298df91e3f9bcfd983e046982 | refs/heads/master | 2020-04-06T07:06:59.542028 | 2016-08-31T17:04:58 | 2016-08-31T17:04:58 | 61,656,188 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | 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 com.ionicframework.livefutsal400843;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
| [
"hernanchelo1992@gmailcom"
] | hernanchelo1992@gmailcom |
cef80d70a88aa1c022784a124fe1186e1311f478 | 411da3bc03a68746067a1d6f7c34b0b084f462bc | /commons-springtools/src/main/scala/com/shengpay/commons/springtools/annotation/ParamName.java | 58a038d86874e4f23c944388dd6fe5f270ab03da | [] | no_license | wulliam/commons | 82d0da7d0835dc54ad7363edf84f9fb161b62b8a | c9e903b915eeb55d27b07252e49e67320212ed86 | refs/heads/master | 2021-01-15T11:13:44.312740 | 2014-07-02T02:40:19 | 2014-07-02T02:40:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 389 | java | package com.shengpay.commons.springtools.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.PARAMETER })
@Documented
public @interface ParamName {
String value();
}
| [
"[email protected]"
] | |
cc162a53420c14a8a17a3f8dfe76ab0fdd005b8d | 7b1c85010663863ea8289e97f558b66772b63d11 | /src/test/java/cn/hkxj/platform/service/GradeSearchServiceTest.java | e4526871488d509ac0beddfd937b9ad2d9e58969 | [
"MIT"
] | permissive | SyaEldon/hkxj | 96de5cb241e163a452524311adbd5e9e9ef95f17 | b924537447101a5fd761febd1f85f5dc22d5163c | refs/heads/master | 2020-04-29T01:31:34.627095 | 2019-02-26T09:07:28 | 2019-02-26T09:07:28 | 140,158,480 | 0 | 0 | MIT | 2018-07-08T10:36:19 | 2018-07-08T10:36:19 | null | UTF-8 | Java | false | false | 1,641 | java | package cn.hkxj.platform.service;
import cn.hkxj.platform.pojo.GradeAndCourse;
import cn.hkxj.platform.pojo.Student;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
/**
* @author junrong.chen
* @date 2018/9/22
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class GradeSearchServiceTest {
@Resource(name = "gradeSearchService")
private GradeSearchService gradeSearchService;
@Autowired
private WxMpService wxMpService;
@Test
public void getAccess_token() throws WxErrorException {
String accessToken = wxMpService.getAccessToken();
System.out.println(accessToken);
}
@Test
public void getCurrentTermGrade() {
Student student = new Student();
student.setAccount(2016023726);
student.setPassword("1");
long start = System.currentTimeMillis();
List<GradeAndCourse> currentTermGrade = gradeSearchService.getGradeFromSpiderAsync(student);
long end = System.currentTimeMillis();
long costtime = end - start;
System.out.println(CollectionUtils.isEmpty(currentTermGrade));
for (GradeAndCourse gradeAndCourse : currentTermGrade) {
log.info(gradeAndCourse.toString());
}
}
} | [
"[email protected]"
] | |
d1481c1517df1b4018118c2b74e0ecb3283a82da | eb4e0658523bfd36cc0758cfc1d8a0b305a97c50 | /src/java/com/bizosys/oneline/util/SqlValidator.java | d0ccab6251aa952b505a26e9b0d4c2a31ef1e781 | [] | no_license | bizosys/oneline-server | 050e95977c211b41b62e63a5d37c3801d66f0647 | ef8efca0e4f7dfa6a849858e2ae3f5e0fef67457 | refs/heads/master | 2021-01-10T14:09:38.473424 | 2015-11-05T10:37:30 | 2015-11-05T10:37:30 | 45,603,908 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,270 | java | /**
* Copyright 2010 Bizosys Technologies Limited
*
* Licensed to the Bizosys Technologies Limited (Bizosys) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The Bizosys 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 com.bizosys.oneline.util;
import com.bizosys.oneline.sql.QueryDefinationFactory;
import com.foundationdb.sql.StandardException;
import com.foundationdb.sql.parser.SQLParser;
public class SqlValidator {
static SQLParser parser = new SQLParser();
public static String validateSql( String sql ) {
String message = "OK";
try {
String parsedQuery = QueryDefinationFactory.getVariables(sql, null, null);
if( parsedQuery.indexOf("__where") > 0 )
parsedQuery = parsedQuery.replace("__where", "1=1");
if( parsedQuery.indexOf("__sort") > 0 ){
parsedQuery = parsedQuery.replace("order by __sort", "");
parsedQuery = parsedQuery.replace("ORDER BY __sort", "");
}
if( parsedQuery.indexOf("__offset") > 0 ){
parsedQuery = parsedQuery.replace("offset __offset", "");
parsedQuery = parsedQuery.replace("OFFSET __offset", "");
}
if( parsedQuery.indexOf("__limit") > 0 ){
parsedQuery = parsedQuery.replace("limit __limit", "");
parsedQuery = parsedQuery.replace("LIMIT __limit", "");
}
parser.parseStatement(parsedQuery);
} catch (StandardException e) {
message = "Syntax error : " + e.getMessage().split("\n")[0];
}
return message;
}
public static void main(String[] args) {
String sql = "select id,name,class from test where id = @id $mywhere";
String message = SqlValidator.validateSql(sql);
System.out.println( message );
}
}
| [
"[email protected]"
] | |
1c0b570faa33061d9707a0771b298e8582ef456e | 21765f2f6d0adc5798eac4798dca929a0f61b0d4 | /app/src/main/java/com/example/place_travel2021/Activity_chitietdiadiem.java | 840b20391f978c27548ebd461597f1f87d8fb885 | [] | no_license | Huang-Github20/demo2 | 209e38efb0146fbe32a4ab48a9068697fe31d2a0 | e594153f0fe022c06be5eba54280c1eb77e82155 | refs/heads/master | 2023-04-01T06:11:25.362696 | 2021-04-16T10:40:19 | 2021-04-16T10:40:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,401 | java | package com.example.place_travel2021;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.example.place_travel2021.fragment.Fragment_Home;
public class Activity_chitietdiadiem extends AppCompatActivity {
ImageView imagect;
Button btnbackct,btndattour;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chitietdiadiem);
btnbackct=(Button)findViewById(R.id.btn_back_ct);
btndattour=(Button)findViewById(R.id.btn_dattour);
btnbackct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Activity_chitietdiadiem.this,MainActivity.class));
}
});
btndattour.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Activity_chitietdiadiem.this,Activivty_Dattour.class));
}
});
}
} | [
"[email protected]"
] | |
7b7b5a96824084818bcf39f433747bc16c541709 | e254ed81382af531f05d69c3be5307b2d855196d | /src/net/aurore/datamanager/AuroreStatsJPAImpl.java | 378c2f3545603ed2a38e8806a8c55261ed6372ab | [] | no_license | Zeusu/Aurore-DOWN- | 73dd3a9790483d4287454be7021c13d30ccffe76 | 8ac7888ec5079801942409f47aa48d1a65e7df79 | refs/heads/master | 2022-03-26T08:27:06.059404 | 2018-05-27T08:14:53 | 2018-05-27T08:14:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,720 | java | package net.aurore.datamanager;
import org.hibernate.Session;
import org.hibernate.Query;
import net.aurore.entities.AuroreStats;
public class AuroreStatsJPAImpl implements AuroreStatsJPA {
private static final String PARAM_SUMMONER_ID = "summoner_id";
private static final String STATS_BY_SUMMONER_ID = "FROM AuroreStats WHERE " + PARAM_SUMMONER_ID + " = :" + PARAM_SUMMONER_ID;
private static final String GLOBAL_STATS = "FROM AuroreStats WHERE isGlobalStat = true AND " + PARAM_SUMMONER_ID + " IS NULL AND champion_focused IS NULL";
private Session sess;
private AuroreStats stats;
AuroreStatsJPAImpl(AuroreStats s, Session sess){
stats = s;
this.sess = sess;
}
@Override
public void save() {
try{
sess.beginTransaction();
AuroreStats s = null;
if(stats.getS() != null){
s = retrieve(stats.getS().getId());
}
if(s != null){
s.setAverageAssits(stats.getAverageAssits());
s.setAverageDeath(stats.getAverageDeath());
s.setAverageKill(stats.getAverageKill());
s.setKda(stats.getKda());
sess.update(s);
}else{
sess.save(stats);
}
sess.getTransaction().commit();
sess.clear();
}catch(Exception e){
e.printStackTrace();
}
}
@Override
public AuroreStats retrieve(long summonerId) {
Query query = sess.createQuery(STATS_BY_SUMMONER_ID);
query.setParameter(PARAM_SUMMONER_ID, summonerId);
Object o = query.uniqueResult();
if(o instanceof AuroreStats)
return (AuroreStats) o;
return null;
}
@Override
public AuroreStats retrieveGlobalStats() {
Query query = sess.createQuery(GLOBAL_STATS);
Object o = query.uniqueResult();
if(o instanceof AuroreStats) return (AuroreStats) o;
return null;
}
}
| [
"[email protected]"
] | |
2815f39b0a5f142559b1333575ca829a2a0c1c8a | 9e8f28c189f2b98916a34865044e794989aff314 | /6.PRO192x_Java/BeeGame_Assign 2/src/BeeGame/Main.java | a9e276729aa6527c0e3c5e25133cb73c38066cba | [] | no_license | quyetdong/Funix-Projects | 1831cf3006d24e707a9578d00cd68ff80cdd1470 | f3329f0e35e1b6ab1a377631f3566fa15ecc73a4 | refs/heads/master | 2020-06-10T15:59:12.017019 | 2019-06-25T08:36:45 | 2019-06-25T08:36:45 | 193,667,528 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 617 | java | package BeeGame;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Choose one of following options:");
System.out.println("1. Create a bee list: include 10 bees, each bee"
+ " is one of three types: Queen, Drone, Worker");
System.out.println("2. Attack bees in the list");
Scanner in = new Scanner(System.in);
Bee[] beeList = new Bee[10];
beeList = PlayBeeGame.startGame(in, beeList);
beeList = PlayBeeGame.attackBee(in, beeList);
System.out.println("You've won!");
PlayBeeGame.printBeeList(beeList);
in.close();
}
}
| [
"[email protected]"
] | |
e02809d87e60adeaaaecaa44b8ad8ac568f15191 | 37992a7083efea148c66381a2e7c988f59de712b | /cppk/app/src/main/java/ru/ppr/cppk/ui/activity/fineListManagement/FineListManagementPresenter.java | c04a814b540f994b0d7efcd358a093e74585be7f | [] | no_license | RVC3/PTK | 5ab897d6abee1f7f7be3ba49c893b97e719085e9 | 1052b2bfa8f565c96a85d5c5928ed6c938a20543 | refs/heads/master | 2022-12-22T22:11:40.231298 | 2020-07-01T09:45:38 | 2020-07-01T09:45:38 | 259,278,530 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,315 | java | package ru.ppr.cppk.ui.activity.fineListManagement;
import android.support.annotation.NonNull;
import com.google.common.primitives.Longs;
import java.util.ArrayList;
import java.util.List;
import ru.ppr.core.ui.mvp.presenter.BaseMvpPresenter;
import ru.ppr.cppk.db.LocalDaoSession;
import ru.ppr.cppk.di.Dagger;
import ru.ppr.cppk.entity.settings.PrivateSettings;
import ru.ppr.cppk.managers.NsiVersionManager;
import ru.ppr.nsi.NsiDaoSession;
import ru.ppr.nsi.entity.Fine;
import ru.ppr.nsi.repository.FineRepository;
/**
* @author Dmitry Nevolin
*/
public class FineListManagementPresenter extends BaseMvpPresenter<FineListManagementView> {
private InteractionListener interactionListener;
private boolean initialized = false;
private LocalDaoSession localDaoSession;
private NsiDaoSession nsiDaoSession;
private PrivateSettings privateSettings;
private NsiVersionManager nsiVersionManager;
private FineRepository fineRepository;
/**
* Список кодов разрешенных штрафов
*/
private List<Long> allowedFineCodeList;
void initialize(@NonNull LocalDaoSession localDaoSession,
@NonNull NsiDaoSession nsiDaoSession,
@NonNull PrivateSettings privateSettings,
@NonNull NsiVersionManager nsiVersionManager,
@NonNull FineRepository fineRepository) {
if (!initialized) {
this.initialized = true;
this.localDaoSession = localDaoSession;
this.nsiDaoSession = nsiDaoSession;
this.privateSettings = privateSettings;
this.nsiVersionManager = nsiVersionManager;
this.allowedFineCodeList = new ArrayList<>();
this.fineRepository = fineRepository;
onInitialize();
}
}
void bindInteractionListener(@NonNull InteractionListener interactionListener) {
this.interactionListener = interactionListener;
}
void onFineChecked(@NonNull Fine fine, boolean isChecked) {
if (isChecked && !allowedFineCodeList.contains(fine.getCode())) {
allowedFineCodeList.add(fine.getCode());
} else if (!isChecked && allowedFineCodeList.contains(fine.getCode())) {
allowedFineCodeList.remove(fine.getCode());
}
privateSettings.setAllowedFineCodes(Longs.toArray(allowedFineCodeList));
Dagger.appComponent().privateSettingsRepository().savePrivateSettings(privateSettings);
}
void onFineListIsEmptyDialogDismiss() {
interactionListener.returnToPreviousScreen();
}
private void onInitialize() {
long[] allowedFineCodes = privateSettings.getAllowedFineCodes();
int nsiVersion = nsiVersionManager.getCurrentNsiVersionId();
List<Fine> fineList = fineRepository.loadAll(nsiVersion);
if (allowedFineCodes != null) {
allowedFineCodeList.addAll(Longs.asList(allowedFineCodes));
}
view.setAllowedFineCodeList(allowedFineCodeList);
view.setFineList(fineList);
view.setFineListIsEmptyDialogVisible(fineList.isEmpty());
}
/**
* Интерфейс обработки событий.
*/
public interface InteractionListener {
void returnToPreviousScreen();
}
}
| [
"[email protected]"
] | |
f579af1743e1c9440f9e8dab7e476d63c1881efc | bd4dfb439ac79cd4138058a5ee3f6f3ebc4eefa3 | /src/main/java/io/atalisasowen/heartbeat/network/udp/HeartBeatUdpReceiver.java | 12ff610d9f99e6384ea114cf34d4c8f44dc40750 | [
"Apache-2.0"
] | permissive | AtalisasOwen/heartbeat-java | df6d933c5a69078288b28fd99b71b6817452cc09 | 3fb8f80ab1d24dfd1e7f31104e93beb1f381562d | refs/heads/master | 2022-12-20T11:40:12.057958 | 2020-10-10T06:43:21 | 2020-10-10T06:43:21 | 301,714,606 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,391 | java | package io.atalisasowen.heartbeat.network.udp;
import io.atalisasowen.heartbeat.command.HeartBeatHandler;
import io.atalisasowen.heartbeat.codec.HeartBeatUdpDecoder;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;
import java.net.InetSocketAddress;
public class HeartBeatUdpReceiver {
private final EventLoopGroup group;
private final Bootstrap bootstrap;
public HeartBeatUdpReceiver(InetSocketAddress address){
group = new NioEventLoopGroup();
bootstrap = new Bootstrap();
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.SO_BROADCAST, true)
.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new HeartBeatUdpDecoder());
pipeline.addLast(new HeartBeatHandler(address));
}
}).localAddress(address);
}
public Channel bind(){
return bootstrap.bind().syncUninterruptibly().channel();
}
public void stop(){
group.shutdownGracefully();
}
}
| [
"[email protected]"
] | |
f052ca6e98b7d7b6d4a6b40b976057267247aa2e | a2f6fa1bf2a45e9dbd1365f239bf833638ba83df | /项目练习/单机考试管理软件/老师的代码/step3/Exam/src/com/winstar/exam/test/Exam.java | bb87cf2061ed02fb45c8b98d656402485718d868 | [] | no_license | Follow-your-body/JavaLearnBasic | 4f8a070dad347686e06c3bd7a106f98ddfe2f31c | cbe24213f6621870b9ac9a970ff15ab37c7f1146 | refs/heads/master | 2021-01-18T16:53:13.730346 | 2017-04-16T05:29:45 | 2017-04-16T05:29:45 | 86,778,360 | 0 | 0 | null | null | null | null | ISO-8859-7 | Java | false | false | 673 | java | package com.winstar.exam.test;
import com.winstar.exam.domain.Item;
import com.winstar.exam.service.ItemService;
import com.winstar.exam.view.ExamView;
public class Exam {
public static void main(String[] args) {
ItemService service = new ItemService();
// Item item = service.getItem(5);
// if (item == null) {
// System.out.println("ΜβΊΕ²»ΆΤ");
// } else {
// System.out.println(item);
// }
// char[] chs={'a','1','b'};
// service.saveAnswer(chs);
// char[] result=service.readAnswer();
// System.out.println(result);
// int n2 = 3;
// int m = 2;
// System.out.println(m + n2);
ExamView ev = new ExamView();
ev.testExam();
}
}
| [
"[email protected]"
] | |
4d39ed743d0e2b08c1017371509022ff80992aca | 925d74b7caf5383aebb89739faa3868e28d3743e | /kodilla-good-patterns/src/main/java/com/kodilla/good/patterns/challenges/food/FoodRepository.java | 5de7b9aec4b303ccd50564afe5ac102031515e75 | [] | no_license | KrzysztofIT/6.1 | 9932d55ad6390dbeac601c4ed22b94aeb55fdf68 | cc3e16c856aca32781ff4c35f93ac332b599c221 | refs/heads/master | 2020-03-16T11:23:18.266193 | 2018-09-25T19:12:45 | 2018-09-25T19:12:45 | 132,647,295 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 129 | java | package com.kodilla.good.patterns.challenges.food;
public interface FoodRepository {
void createOrder(Provider provider);
}
| [
"“[email protected]"
] | |
d8614c0bb36b64a2afed86e255097a3d665fd09a | ba84bb6c0c8ea79d5f4810c1fc96ad364c511276 | /src/main/java/tools/tcpprint/TcpPrinter.java | 47faf651e3b888dff74b462dfd12637d30ed46c7 | [] | no_license | jmcabrera/tools | 977439ec3013aa59dedd20e684327910aeca0a4d | b6e9fa457dc0b459abe0edc54741db1fc1af8d58 | refs/heads/master | 2016-08-10T16:45:21.133815 | 2016-01-26T13:35:47 | 2016-01-26T13:35:47 | 50,430,143 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 923 | java | /**
*
*/
package tools.tcpprint;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.ServerSocket;
import java.net.Socket;
/**
* @author a208220 - Juan Manuel CABRERA
*
*/
public class TcpPrinter {
static final int DEFAULT_PORT = 12345;
public static void main(String[] args) throws IOException {
int port = args.length > 0 ? Integer.parseInt(args[0]) : DEFAULT_PORT;
try (ServerSocket seso = new ServerSocket(port)) {
while (true) {
try {
Socket so = seso.accept();
try (Reader r = new InputStreamReader(so.getInputStream())) {
char c;
while (-1 != (c = (char) r.read())) {
System.out.print(c);
}
}
System.out.println("<end of connection>");
}
catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
| [
"[email protected]"
] | |
6f48e19cdc96fdd62c1ac7584fce750a0f5ca5f2 | eb9c3dac0dca0ecd184df14b1fda62e61cc8c7d7 | /google/api/serviceusage/v1/google-cloud-api-serviceusage-v1-java/grpc-google-cloud-api-serviceusage-v1-java/src/main/java/com/google/api/serviceusage/v1/ServiceUsageGrpc.java | 39f9aeb1d527c13e1475269f32827cc399b78fed | [
"Apache-2.0"
] | permissive | Tryweirder/googleapis-gen | 2e5daf46574c3af3d448f1177eaebe809100c346 | 45d8e9377379f9d1d4e166e80415a8c1737f284d | refs/heads/master | 2023-04-05T06:30:04.726589 | 2021-04-13T23:35:20 | 2021-04-13T23:35:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 38,700 | java | package com.google.api.serviceusage.v1;
import static io.grpc.MethodDescriptor.generateFullMethodName;
/**
* <pre>
* [Service Usage API](/service-usage/docs/overview)
* </pre>
*/
@javax.annotation.Generated(
value = "by gRPC proto compiler",
comments = "Source: google/api/serviceusage/v1/serviceusage.proto")
public final class ServiceUsageGrpc {
private ServiceUsageGrpc() {}
public static final String SERVICE_NAME = "google.api.serviceusage.v1.ServiceUsage";
// Static method descriptors that strictly reflect the proto.
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.EnableServiceRequest,
com.google.longrunning.Operation> getEnableServiceMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "EnableService",
requestType = com.google.api.serviceusage.v1.EnableServiceRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.EnableServiceRequest,
com.google.longrunning.Operation> getEnableServiceMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.EnableServiceRequest, com.google.longrunning.Operation> getEnableServiceMethod;
if ((getEnableServiceMethod = ServiceUsageGrpc.getEnableServiceMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getEnableServiceMethod = ServiceUsageGrpc.getEnableServiceMethod) == null) {
ServiceUsageGrpc.getEnableServiceMethod = getEnableServiceMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.EnableServiceRequest, com.google.longrunning.Operation>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "EnableService"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.EnableServiceRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("EnableService"))
.build();
}
}
}
return getEnableServiceMethod;
}
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.DisableServiceRequest,
com.google.longrunning.Operation> getDisableServiceMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "DisableService",
requestType = com.google.api.serviceusage.v1.DisableServiceRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.DisableServiceRequest,
com.google.longrunning.Operation> getDisableServiceMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.DisableServiceRequest, com.google.longrunning.Operation> getDisableServiceMethod;
if ((getDisableServiceMethod = ServiceUsageGrpc.getDisableServiceMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getDisableServiceMethod = ServiceUsageGrpc.getDisableServiceMethod) == null) {
ServiceUsageGrpc.getDisableServiceMethod = getDisableServiceMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.DisableServiceRequest, com.google.longrunning.Operation>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "DisableService"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.DisableServiceRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("DisableService"))
.build();
}
}
}
return getDisableServiceMethod;
}
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.GetServiceRequest,
com.google.api.serviceusage.v1.Service> getGetServiceMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "GetService",
requestType = com.google.api.serviceusage.v1.GetServiceRequest.class,
responseType = com.google.api.serviceusage.v1.Service.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.GetServiceRequest,
com.google.api.serviceusage.v1.Service> getGetServiceMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.GetServiceRequest, com.google.api.serviceusage.v1.Service> getGetServiceMethod;
if ((getGetServiceMethod = ServiceUsageGrpc.getGetServiceMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getGetServiceMethod = ServiceUsageGrpc.getGetServiceMethod) == null) {
ServiceUsageGrpc.getGetServiceMethod = getGetServiceMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.GetServiceRequest, com.google.api.serviceusage.v1.Service>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetService"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.GetServiceRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.Service.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("GetService"))
.build();
}
}
}
return getGetServiceMethod;
}
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.ListServicesRequest,
com.google.api.serviceusage.v1.ListServicesResponse> getListServicesMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "ListServices",
requestType = com.google.api.serviceusage.v1.ListServicesRequest.class,
responseType = com.google.api.serviceusage.v1.ListServicesResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.ListServicesRequest,
com.google.api.serviceusage.v1.ListServicesResponse> getListServicesMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.ListServicesRequest, com.google.api.serviceusage.v1.ListServicesResponse> getListServicesMethod;
if ((getListServicesMethod = ServiceUsageGrpc.getListServicesMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getListServicesMethod = ServiceUsageGrpc.getListServicesMethod) == null) {
ServiceUsageGrpc.getListServicesMethod = getListServicesMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.ListServicesRequest, com.google.api.serviceusage.v1.ListServicesResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListServices"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.ListServicesRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.ListServicesResponse.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("ListServices"))
.build();
}
}
}
return getListServicesMethod;
}
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchEnableServicesRequest,
com.google.longrunning.Operation> getBatchEnableServicesMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "BatchEnableServices",
requestType = com.google.api.serviceusage.v1.BatchEnableServicesRequest.class,
responseType = com.google.longrunning.Operation.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchEnableServicesRequest,
com.google.longrunning.Operation> getBatchEnableServicesMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchEnableServicesRequest, com.google.longrunning.Operation> getBatchEnableServicesMethod;
if ((getBatchEnableServicesMethod = ServiceUsageGrpc.getBatchEnableServicesMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getBatchEnableServicesMethod = ServiceUsageGrpc.getBatchEnableServicesMethod) == null) {
ServiceUsageGrpc.getBatchEnableServicesMethod = getBatchEnableServicesMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.BatchEnableServicesRequest, com.google.longrunning.Operation>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "BatchEnableServices"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.BatchEnableServicesRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.longrunning.Operation.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("BatchEnableServices"))
.build();
}
}
}
return getBatchEnableServicesMethod;
}
private static volatile io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchGetServicesRequest,
com.google.api.serviceusage.v1.BatchGetServicesResponse> getBatchGetServicesMethod;
@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "BatchGetServices",
requestType = com.google.api.serviceusage.v1.BatchGetServicesRequest.class,
responseType = com.google.api.serviceusage.v1.BatchGetServicesResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchGetServicesRequest,
com.google.api.serviceusage.v1.BatchGetServicesResponse> getBatchGetServicesMethod() {
io.grpc.MethodDescriptor<com.google.api.serviceusage.v1.BatchGetServicesRequest, com.google.api.serviceusage.v1.BatchGetServicesResponse> getBatchGetServicesMethod;
if ((getBatchGetServicesMethod = ServiceUsageGrpc.getBatchGetServicesMethod) == null) {
synchronized (ServiceUsageGrpc.class) {
if ((getBatchGetServicesMethod = ServiceUsageGrpc.getBatchGetServicesMethod) == null) {
ServiceUsageGrpc.getBatchGetServicesMethod = getBatchGetServicesMethod =
io.grpc.MethodDescriptor.<com.google.api.serviceusage.v1.BatchGetServicesRequest, com.google.api.serviceusage.v1.BatchGetServicesResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "BatchGetServices"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.BatchGetServicesRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
com.google.api.serviceusage.v1.BatchGetServicesResponse.getDefaultInstance()))
.setSchemaDescriptor(new ServiceUsageMethodDescriptorSupplier("BatchGetServices"))
.build();
}
}
}
return getBatchGetServicesMethod;
}
/**
* Creates a new async stub that supports all call types for the service
*/
public static ServiceUsageStub newStub(io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<ServiceUsageStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<ServiceUsageStub>() {
@java.lang.Override
public ServiceUsageStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageStub(channel, callOptions);
}
};
return ServiceUsageStub.newStub(factory, channel);
}
/**
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
*/
public static ServiceUsageBlockingStub newBlockingStub(
io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<ServiceUsageBlockingStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<ServiceUsageBlockingStub>() {
@java.lang.Override
public ServiceUsageBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageBlockingStub(channel, callOptions);
}
};
return ServiceUsageBlockingStub.newStub(factory, channel);
}
/**
* Creates a new ListenableFuture-style stub that supports unary calls on the service
*/
public static ServiceUsageFutureStub newFutureStub(
io.grpc.Channel channel) {
io.grpc.stub.AbstractStub.StubFactory<ServiceUsageFutureStub> factory =
new io.grpc.stub.AbstractStub.StubFactory<ServiceUsageFutureStub>() {
@java.lang.Override
public ServiceUsageFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageFutureStub(channel, callOptions);
}
};
return ServiceUsageFutureStub.newStub(factory, channel);
}
/**
* <pre>
* [Service Usage API](/service-usage/docs/overview)
* </pre>
*/
public static abstract class ServiceUsageImplBase implements io.grpc.BindableService {
/**
* <pre>
* Enable a service so that it can be used with a project.
* </pre>
*/
public void enableService(com.google.api.serviceusage.v1.EnableServiceRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getEnableServiceMethod(), responseObserver);
}
/**
* <pre>
* Disable a service so that it can no longer be used with a project.
* This prevents unintended usage that may cause unexpected billing
* charges or security leaks.
* It is not valid to call the disable method on a service that is not
* currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
* the target service is not currently enabled.
* </pre>
*/
public void disableService(com.google.api.serviceusage.v1.DisableServiceRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getDisableServiceMethod(), responseObserver);
}
/**
* <pre>
* Returns the service configuration and enabled state for a given service.
* </pre>
*/
public void getService(com.google.api.serviceusage.v1.GetServiceRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.Service> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetServiceMethod(), responseObserver);
}
/**
* <pre>
* List all services available to the specified project, and the current
* state of those services with respect to the project. The list includes
* all public services, all services for which the calling user has the
* `servicemanagement.services.bind` permission, and all services that have
* already been enabled on the project. The list can be filtered to
* only include services in a specific state, for example to only include
* services enabled on the project.
* WARNING: If you need to query enabled services frequently or across
* an organization, you should use
* [Cloud Asset Inventory
* API](https://cloud.google.com/asset-inventory/docs/apis), which provides
* higher throughput and richer filtering capability.
* </pre>
*/
public void listServices(com.google.api.serviceusage.v1.ListServicesRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.ListServicesResponse> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListServicesMethod(), responseObserver);
}
/**
* <pre>
* Enable multiple services on a project. The operation is atomic: if enabling
* any service fails, then the entire batch fails, and no state changes occur.
* To enable a single service, use the `EnableService` method instead.
* </pre>
*/
public void batchEnableServices(com.google.api.serviceusage.v1.BatchEnableServicesRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getBatchEnableServicesMethod(), responseObserver);
}
/**
* <pre>
* Returns the service configurations and enabled states for a given list of
* services.
* </pre>
*/
public void batchGetServices(com.google.api.serviceusage.v1.BatchGetServicesRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.BatchGetServicesResponse> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getBatchGetServicesMethod(), responseObserver);
}
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
getEnableServiceMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.EnableServiceRequest,
com.google.longrunning.Operation>(
this, METHODID_ENABLE_SERVICE)))
.addMethod(
getDisableServiceMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.DisableServiceRequest,
com.google.longrunning.Operation>(
this, METHODID_DISABLE_SERVICE)))
.addMethod(
getGetServiceMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.GetServiceRequest,
com.google.api.serviceusage.v1.Service>(
this, METHODID_GET_SERVICE)))
.addMethod(
getListServicesMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.ListServicesRequest,
com.google.api.serviceusage.v1.ListServicesResponse>(
this, METHODID_LIST_SERVICES)))
.addMethod(
getBatchEnableServicesMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.BatchEnableServicesRequest,
com.google.longrunning.Operation>(
this, METHODID_BATCH_ENABLE_SERVICES)))
.addMethod(
getBatchGetServicesMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
com.google.api.serviceusage.v1.BatchGetServicesRequest,
com.google.api.serviceusage.v1.BatchGetServicesResponse>(
this, METHODID_BATCH_GET_SERVICES)))
.build();
}
}
/**
* <pre>
* [Service Usage API](/service-usage/docs/overview)
* </pre>
*/
public static final class ServiceUsageStub extends io.grpc.stub.AbstractAsyncStub<ServiceUsageStub> {
private ServiceUsageStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServiceUsageStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageStub(channel, callOptions);
}
/**
* <pre>
* Enable a service so that it can be used with a project.
* </pre>
*/
public void enableService(com.google.api.serviceusage.v1.EnableServiceRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getEnableServiceMethod(), getCallOptions()), request, responseObserver);
}
/**
* <pre>
* Disable a service so that it can no longer be used with a project.
* This prevents unintended usage that may cause unexpected billing
* charges or security leaks.
* It is not valid to call the disable method on a service that is not
* currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
* the target service is not currently enabled.
* </pre>
*/
public void disableService(com.google.api.serviceusage.v1.DisableServiceRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getDisableServiceMethod(), getCallOptions()), request, responseObserver);
}
/**
* <pre>
* Returns the service configuration and enabled state for a given service.
* </pre>
*/
public void getService(com.google.api.serviceusage.v1.GetServiceRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.Service> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getGetServiceMethod(), getCallOptions()), request, responseObserver);
}
/**
* <pre>
* List all services available to the specified project, and the current
* state of those services with respect to the project. The list includes
* all public services, all services for which the calling user has the
* `servicemanagement.services.bind` permission, and all services that have
* already been enabled on the project. The list can be filtered to
* only include services in a specific state, for example to only include
* services enabled on the project.
* WARNING: If you need to query enabled services frequently or across
* an organization, you should use
* [Cloud Asset Inventory
* API](https://cloud.google.com/asset-inventory/docs/apis), which provides
* higher throughput and richer filtering capability.
* </pre>
*/
public void listServices(com.google.api.serviceusage.v1.ListServicesRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.ListServicesResponse> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getListServicesMethod(), getCallOptions()), request, responseObserver);
}
/**
* <pre>
* Enable multiple services on a project. The operation is atomic: if enabling
* any service fails, then the entire batch fails, and no state changes occur.
* To enable a single service, use the `EnableService` method instead.
* </pre>
*/
public void batchEnableServices(com.google.api.serviceusage.v1.BatchEnableServicesRequest request,
io.grpc.stub.StreamObserver<com.google.longrunning.Operation> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getBatchEnableServicesMethod(), getCallOptions()), request, responseObserver);
}
/**
* <pre>
* Returns the service configurations and enabled states for a given list of
* services.
* </pre>
*/
public void batchGetServices(com.google.api.serviceusage.v1.BatchGetServicesRequest request,
io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.BatchGetServicesResponse> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getBatchGetServicesMethod(), getCallOptions()), request, responseObserver);
}
}
/**
* <pre>
* [Service Usage API](/service-usage/docs/overview)
* </pre>
*/
public static final class ServiceUsageBlockingStub extends io.grpc.stub.AbstractBlockingStub<ServiceUsageBlockingStub> {
private ServiceUsageBlockingStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServiceUsageBlockingStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageBlockingStub(channel, callOptions);
}
/**
* <pre>
* Enable a service so that it can be used with a project.
* </pre>
*/
public com.google.longrunning.Operation enableService(com.google.api.serviceusage.v1.EnableServiceRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getEnableServiceMethod(), getCallOptions(), request);
}
/**
* <pre>
* Disable a service so that it can no longer be used with a project.
* This prevents unintended usage that may cause unexpected billing
* charges or security leaks.
* It is not valid to call the disable method on a service that is not
* currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
* the target service is not currently enabled.
* </pre>
*/
public com.google.longrunning.Operation disableService(com.google.api.serviceusage.v1.DisableServiceRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getDisableServiceMethod(), getCallOptions(), request);
}
/**
* <pre>
* Returns the service configuration and enabled state for a given service.
* </pre>
*/
public com.google.api.serviceusage.v1.Service getService(com.google.api.serviceusage.v1.GetServiceRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetServiceMethod(), getCallOptions(), request);
}
/**
* <pre>
* List all services available to the specified project, and the current
* state of those services with respect to the project. The list includes
* all public services, all services for which the calling user has the
* `servicemanagement.services.bind` permission, and all services that have
* already been enabled on the project. The list can be filtered to
* only include services in a specific state, for example to only include
* services enabled on the project.
* WARNING: If you need to query enabled services frequently or across
* an organization, you should use
* [Cloud Asset Inventory
* API](https://cloud.google.com/asset-inventory/docs/apis), which provides
* higher throughput and richer filtering capability.
* </pre>
*/
public com.google.api.serviceusage.v1.ListServicesResponse listServices(com.google.api.serviceusage.v1.ListServicesRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getListServicesMethod(), getCallOptions(), request);
}
/**
* <pre>
* Enable multiple services on a project. The operation is atomic: if enabling
* any service fails, then the entire batch fails, and no state changes occur.
* To enable a single service, use the `EnableService` method instead.
* </pre>
*/
public com.google.longrunning.Operation batchEnableServices(com.google.api.serviceusage.v1.BatchEnableServicesRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getBatchEnableServicesMethod(), getCallOptions(), request);
}
/**
* <pre>
* Returns the service configurations and enabled states for a given list of
* services.
* </pre>
*/
public com.google.api.serviceusage.v1.BatchGetServicesResponse batchGetServices(com.google.api.serviceusage.v1.BatchGetServicesRequest request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getBatchGetServicesMethod(), getCallOptions(), request);
}
}
/**
* <pre>
* [Service Usage API](/service-usage/docs/overview)
* </pre>
*/
public static final class ServiceUsageFutureStub extends io.grpc.stub.AbstractFutureStub<ServiceUsageFutureStub> {
private ServiceUsageFutureStub(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
super(channel, callOptions);
}
@java.lang.Override
protected ServiceUsageFutureStub build(
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
return new ServiceUsageFutureStub(channel, callOptions);
}
/**
* <pre>
* Enable a service so that it can be used with a project.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation> enableService(
com.google.api.serviceusage.v1.EnableServiceRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getEnableServiceMethod(), getCallOptions()), request);
}
/**
* <pre>
* Disable a service so that it can no longer be used with a project.
* This prevents unintended usage that may cause unexpected billing
* charges or security leaks.
* It is not valid to call the disable method on a service that is not
* currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
* the target service is not currently enabled.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation> disableService(
com.google.api.serviceusage.v1.DisableServiceRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getDisableServiceMethod(), getCallOptions()), request);
}
/**
* <pre>
* Returns the service configuration and enabled state for a given service.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.api.serviceusage.v1.Service> getService(
com.google.api.serviceusage.v1.GetServiceRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getGetServiceMethod(), getCallOptions()), request);
}
/**
* <pre>
* List all services available to the specified project, and the current
* state of those services with respect to the project. The list includes
* all public services, all services for which the calling user has the
* `servicemanagement.services.bind` permission, and all services that have
* already been enabled on the project. The list can be filtered to
* only include services in a specific state, for example to only include
* services enabled on the project.
* WARNING: If you need to query enabled services frequently or across
* an organization, you should use
* [Cloud Asset Inventory
* API](https://cloud.google.com/asset-inventory/docs/apis), which provides
* higher throughput and richer filtering capability.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.api.serviceusage.v1.ListServicesResponse> listServices(
com.google.api.serviceusage.v1.ListServicesRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getListServicesMethod(), getCallOptions()), request);
}
/**
* <pre>
* Enable multiple services on a project. The operation is atomic: if enabling
* any service fails, then the entire batch fails, and no state changes occur.
* To enable a single service, use the `EnableService` method instead.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.longrunning.Operation> batchEnableServices(
com.google.api.serviceusage.v1.BatchEnableServicesRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getBatchEnableServicesMethod(), getCallOptions()), request);
}
/**
* <pre>
* Returns the service configurations and enabled states for a given list of
* services.
* </pre>
*/
public com.google.common.util.concurrent.ListenableFuture<com.google.api.serviceusage.v1.BatchGetServicesResponse> batchGetServices(
com.google.api.serviceusage.v1.BatchGetServicesRequest request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getBatchGetServicesMethod(), getCallOptions()), request);
}
}
private static final int METHODID_ENABLE_SERVICE = 0;
private static final int METHODID_DISABLE_SERVICE = 1;
private static final int METHODID_GET_SERVICE = 2;
private static final int METHODID_LIST_SERVICES = 3;
private static final int METHODID_BATCH_ENABLE_SERVICES = 4;
private static final int METHODID_BATCH_GET_SERVICES = 5;
private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
private final ServiceUsageImplBase serviceImpl;
private final int methodId;
MethodHandlers(ServiceUsageImplBase serviceImpl, int methodId) {
this.serviceImpl = serviceImpl;
this.methodId = methodId;
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
case METHODID_ENABLE_SERVICE:
serviceImpl.enableService((com.google.api.serviceusage.v1.EnableServiceRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
case METHODID_DISABLE_SERVICE:
serviceImpl.disableService((com.google.api.serviceusage.v1.DisableServiceRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
case METHODID_GET_SERVICE:
serviceImpl.getService((com.google.api.serviceusage.v1.GetServiceRequest) request,
(io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.Service>) responseObserver);
break;
case METHODID_LIST_SERVICES:
serviceImpl.listServices((com.google.api.serviceusage.v1.ListServicesRequest) request,
(io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.ListServicesResponse>) responseObserver);
break;
case METHODID_BATCH_ENABLE_SERVICES:
serviceImpl.batchEnableServices((com.google.api.serviceusage.v1.BatchEnableServicesRequest) request,
(io.grpc.stub.StreamObserver<com.google.longrunning.Operation>) responseObserver);
break;
case METHODID_BATCH_GET_SERVICES:
serviceImpl.batchGetServices((com.google.api.serviceusage.v1.BatchGetServicesRequest) request,
(io.grpc.stub.StreamObserver<com.google.api.serviceusage.v1.BatchGetServicesResponse>) responseObserver);
break;
default:
throw new AssertionError();
}
}
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
public io.grpc.stub.StreamObserver<Req> invoke(
io.grpc.stub.StreamObserver<Resp> responseObserver) {
switch (methodId) {
default:
throw new AssertionError();
}
}
}
private static abstract class ServiceUsageBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
ServiceUsageBaseDescriptorSupplier() {}
@java.lang.Override
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
return com.google.api.serviceusage.v1.ServiceUsageProto.getDescriptor();
}
@java.lang.Override
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
return getFileDescriptor().findServiceByName("ServiceUsage");
}
}
private static final class ServiceUsageFileDescriptorSupplier
extends ServiceUsageBaseDescriptorSupplier {
ServiceUsageFileDescriptorSupplier() {}
}
private static final class ServiceUsageMethodDescriptorSupplier
extends ServiceUsageBaseDescriptorSupplier
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
private final String methodName;
ServiceUsageMethodDescriptorSupplier(String methodName) {
this.methodName = methodName;
}
@java.lang.Override
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
return getServiceDescriptor().findMethodByName(methodName);
}
}
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
io.grpc.ServiceDescriptor result = serviceDescriptor;
if (result == null) {
synchronized (ServiceUsageGrpc.class) {
result = serviceDescriptor;
if (result == null) {
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
.setSchemaDescriptor(new ServiceUsageFileDescriptorSupplier())
.addMethod(getEnableServiceMethod())
.addMethod(getDisableServiceMethod())
.addMethod(getGetServiceMethod())
.addMethod(getListServicesMethod())
.addMethod(getBatchEnableServicesMethod())
.addMethod(getBatchGetServicesMethod())
.build();
}
}
}
return result;
}
}
| [
"bazel-bot-development[bot]@users.noreply.github.com"
] | bazel-bot-development[bot]@users.noreply.github.com |
dcf1de941c81106d3cc38739a80972b7979a21a4 | d0b2e7a5886252cbbaad9f44599eac7e3576e7a8 | /src/main/java/student_valerija_ionova/lesson_10/level_6/refactoring_methods_mot_more_than_3_strings/BookReaderImpl.java | 15aa942733a6aa685bdb6971a9555e9a4af54181 | [] | no_license | Dmitryyyyo/java_1_tuesday_2020_online | ac1b44822a2aed40a6e12e6909e9b8c699e57d4c | 7e3bba7ead444d0b2bf1b6715289b2fcc4d22c54 | refs/heads/master | 2023-01-02T11:21:40.223345 | 2020-10-21T18:02:55 | 2020-10-21T18:02:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,033 | java | package student_valerija_ionova.lesson_10.level_6.refactoring_methods_mot_more_than_3_strings;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class BookReaderImpl implements BookReader{
private List<Book> bookDatabase;
BookReaderImpl (Book...books){
this.bookDatabase = new ArrayList<>(Arrays.asList(books));
}
public List <Book> getBookDatabase (){
return bookDatabase;
}
public boolean addBook (Book book){
if (!bookDatabase.contains(book) && isValidBook(book)){
bookDatabase.add(book);
return true;
}
return false;
}
public boolean deleteBook (Book book){
if (bookDatabase.contains(book)){
bookDatabase.remove(book);
return true;
}
return false;
}
@Override
public String[] getArrayOfBooks() {
return bookDatabase.stream()
.map(book -> addBookToArray(book))
.toArray(String [] :: new);
}
private String addBookToArray (Book book){
return book.getTitle() + " [" + book.getAuthor() + "]";
}
@Override
public List<Book> findBookByAuthor(String author) {
return bookDatabase.stream()
.filter (book -> matchAuthor(book, author))
.collect(Collectors.toList());
}
@Override
public List<Book> findBookByTitle(String title) {
return bookDatabase.stream()
.filter (book -> matchTitle(book, title))
.collect(Collectors.toList());
}
@Override
public boolean markAsRead(Book book) {
if (bookDatabase.contains(book)){
bookDatabase.get(bookDatabase.indexOf(book)).setRead(true);
}
return bookDatabase.contains(book);
}
@Override
public boolean markAsNotRead(Book book) {
if (bookDatabase.contains(book)){
bookDatabase.get(bookDatabase.indexOf(book)).setRead(false);
}
return bookDatabase.contains(book);
}
@Override
public String[] getArrayOfReadBooks() {
return bookDatabase.stream()
.filter(book -> book.getIsRead())
.map(book -> addBookToArray(book))
.toArray(String[]::new);
}
@Override
public String[] getArrayOfNotReadBooks() {
return bookDatabase.stream()
.filter(book -> !book.getIsRead())
.map(book -> addBookToArray(book))
.toArray(String[]::new);
}
private boolean matchAuthor (Book book, String author){
return book.getAuthor().startsWith(author);
}
private boolean matchTitle (Book book, String title){
return book.getTitle().startsWith(title);
}
private boolean isValidBook (Book book){
return (book.getTitle() != null) && (book.getAuthor() != null) &&
(book.getTitle().length() > 0) && (book.getAuthor().length() > 0);
}
}
| [
"[email protected]"
] | |
8ec0aeb663fbacfc6c91416bc4c23548d3043273 | a73f191a93f479e0e406a300f9ccfddd2b135966 | /src/com/twu/biblioteca/User.java | 957d30a20173f557ebebda8a3546ea624b453966 | [
"Apache-2.0"
] | permissive | yi-jiayu/twu-biblioteca-jiayu | d1b782aa864659295617994fb49669415082113b | 845b3a6923778dfe32ac299e4694d26cedf9bdf4 | refs/heads/master | 2020-03-27T21:30:04.572609 | 2018-09-11T15:57:35 | 2018-09-11T15:57:35 | 147,149,625 | 0 | 0 | Apache-2.0 | 2018-09-11T03:02:23 | 2018-09-03T04:01:36 | Java | UTF-8 | Java | false | false | 1,008 | java | package com.twu.biblioteca;
public class User {
private LibraryNumber libraryNumber;
private PasswordHash passwordHash;
private String name;
private String email;
private String phone;
public User() {
}
// for creating new users internally without validation
User(String libraryNumber, String password, String name, String email, String phone) {
try {
this.libraryNumber = new LibraryNumber(libraryNumber);
} catch (InvalidLibraryNumberException ignored) {
}
this.passwordHash = new PasswordHash(password);
this.name = name;
this.email = email;
this.phone = phone;
}
LibraryNumber getLibraryNumber() {
return libraryNumber;
}
PasswordHash getPasswordHash() {
return passwordHash;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
public String getPhone() {
return phone;
}
}
| [
"[email protected]"
] | |
4c92944ad8b240069e99dc0595fc0213e4143335 | fb3f91fb6c18bb93c5d51b58d13e201203833994 | /Desarrollo/Tools/GeneradorModel/V3/Sources/MybatisModelGenerator/src/main/java/pe/com/jrtotem/app/generator/service/IInfoDbConnectionCrudService.java | 6b3b37ce5218739a87dc1e335f227f6fa21978ba | [] | no_license | cgb-extjs-gwt/avgust-extjs-generator | d24241e594078eb8af8e33e99be64e56113a1c0c | 30677d1fef4da73e2c72b6c6dfca85d492e1a385 | refs/heads/master | 2023-07-20T04:39:13.928605 | 2018-01-16T18:17:23 | 2018-01-16T18:17:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 614 | java | package pe.com.jrtotem.app.generator.service;
import java.util.List;
import pe.com.jrtotem.app.generator.mybatis.domain.InfoDbConnection;
import pe.com.jrtotem.app.generator.mybatis.domain.InfoDbConnectionExample;
import pe.com.jrtotem.app.generator.util.IMybatisRepositoryHelper;
public interface IInfoDbConnectionCrudService extends IMybatisRepositoryHelper {
Integer create(InfoDbConnection model) throws Exception;
void save(InfoDbConnection model) throws Exception;
void remove(InfoDbConnection model) throws Exception;
List<InfoDbConnection> list(InfoDbConnectionExample example) throws Exception;
}
| [
"[email protected]"
] | |
e16a0f699cbdb8301cc8ab910a1e0f848381c34a | e4d7cd74f4f04523a19b019e85569acb04100542 | /src/CHAPTER4/EdgeWeightedDirectedCycle.java | 1fc2b2c039ff75cd122b1efe7dbee0931b767d34 | [] | no_license | fengxiaohu/Algorithm-4th | 8f4377b04b0cd10de7f2343090323841fb9b760c | 73959623750fd9216708ba5563bfd50ed562643c | refs/heads/master | 2022-12-01T22:42:08.644276 | 2020-08-17T01:12:44 | 2020-08-17T01:12:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,409 | java | import edu.princeton.cs.algs4.DirectedEdge;
import edu.princeton.cs.algs4.*;
import edu.princeton.cs.algs4.Stack;
import edu.princeton.cs.algs4.EdgeWeightedDigraph;
public class EdgeWeightedDirectedCycle {
private boolean[] marked;
private DirectedEdge[] edgeTo;
private boolean[] onstack;
private Stack<DirectedEdge> cycle;
public EdgeWeightedDirectedCycle(EdgeWeightedDigraph G)
{
marked = new boolean[G.V()];
edgeTo = new DirectedEdge[G.V()];
onstack = new boolean[G.V()];
cycle = new Stack<DirectedEdge>();
for(int v=0;v<G.V();v++)
{
if(!marked[v])
{
dfs(G,v);
}
}
}
private void dfs(EdgeWeightedDigraph G,int v)
{
marked[v] = true;
onstack[v] = true;
for(DirectedEdge e: G.adj(v))
{
int w = e.to();
if(cycle != null)
{
return;
}
else if(!marked[w])
{
edgeTo[w] = e;
dfs(G,w);
}
else if(onstack[w])
{
for(DirectedEdge f = e;f.from()!=w;f=edgeTo[f.from()])
{
cycle.push(f);
}
cycle.push(e);
return;
}
}
onstack[v] =false;
}
public boolean hasCycle()
{
return cycle!=null;
}
public Iterable<DirectedCycle> cycle()
{
return cycle;
}
private boolean check()
{
DirectedEdge first = null, last = null;
for (DirectedEdge e : cycle()) {
if (first == null) first = e;
if (last != null) {
if (last.to() != e.from()) {
System.err.printf("cycle edges %s and %s not incident\n", last, e);
return false;
}
}
last = e;
}
if (last.to() != first.from()) {
System.err.printf("cycle edges %s and %s not incident\n", last, first);
return false;
}
}
return true;
}
public static void main(String[] args)
{
int V = Integer.parseInt(args[0]); // Vertices
int E = Integer.parseInt(args[1]); // Edges
int F = Integer.parseInt(args[2]); // extra F edges
EdgeWeightedDigraph G = new EdgeWeightedDigraph(V);
for(int i=0;i<G.V();i++)
{
int v = StdRandom.uniform(V);
int w = StdRandom.uniform(V);
double weight = StdRandom.uniform();
DirectedEdge e = new DirectedEdge(v, w, weight);
G.addEdge(e);
}
for(int i=0;i<F;i++)
{
int v = StdRandom.uniform(V);
int w = StdRandom.uniform(V);
double weight = StdRandom.uniform();
DirectedEdge e = new DirectedEdge(v, w, weight);
G.addEdge(e);
}
StdOut.println(G);
EdgeWeightedDirectedCycle finder = new EdgeWeightedDirectedCycle(G);
if(finder.hasCycle())
{
StdOut.print("Cycle: ");
for (DirectedEdge e : finder.cycle()) {
StdOut.print(e + " ");
}
}
else
{
StdOut.println("No directed cycle") ;
}
}
}
| [
"[email protected]"
] | |
2a46ebe8ed18723442d45cc50f31b829d8ed1ed9 | 6db99455b6ea0a6e1119a6cbb3d72e5e2f94f86b | /416repo/416SemesterProject/src/data/ClassListMap.java | c462887e225365ab274c7eea52d154c0f71d4289 | [] | no_license | softwarekitty/InvestigationEngine | c19292b852de7027e47bae7fc90c4fa957cc34a9 | 6b94f794b2f2e240492e3b0628495d4eecdf3a25 | refs/heads/master | 2016-08-07T03:38:58.621242 | 2012-11-19T01:37:37 | 2012-11-19T01:37:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,850 | java | package data;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@SuppressWarnings("serial")
public class ClassListMap extends
HashMap<String, Pentuple<File, Integer, String, String,String>> {
public static final String[][] supportedLanguages = {
{ "java 1.6",
"/Users/carlchapman/Desktop/SE_416/japiSets/japi6.txt",
".java", "import","Java" },
{ "java 1.7",
"/Users/carlchapman/Desktop/SE_416/japiSets/japi7.txt",
".java", "import","Java" } };
public ClassListMap() {
for (String[] sa : supportedLanguages) {
try {
File f = new File(sa[1]);
put(sa[0], new Pentuple<File, Integer, String, String,String>(f,
countLines(f), sa[2], sa[3],sa[4]));
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static String[] getLanguages() {
String[] toReturn = new String[supportedLanguages.length];
for (int i = 0; i < supportedLanguages.length; i++) {
toReturn[i] = supportedLanguages[i][0];
}
return toReturn;
}
private static int countLines(File f) {
InputStream is = null;
try {
is = new BufferedInputStream(new FileInputStream(f));
byte[] c = new byte[1024];
int count = 0;
int readChars = 0;
boolean empty = true;
while ((readChars = is.read(c)) != -1) {
empty = false;
for (int i = 0; i < readChars; ++i) {
if (c[i] == '\n')
++count;
}
}
is.close();
return (count == 0 && !empty) ? 1 : count;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return 0;
}
}
| [
"[email protected]"
] | |
ccf043ee686837ad2e98531f2e1aee2d2ff7d745 | 7c09956ab9be1d4aecc7e925051e3ea6aa2189ce | /payment-service/src/main/java/com/vinsguru/payment/config/PaymentConfig.java | 32e23c3569dde5ba679e418d5e9bb2b03e7a80f8 | [] | no_license | eliasmichalczuk/choreography-saga-spring-kafka | 65d0abba2e9f680df79c9356957c6ec21cf6883b | e0bfeed19cb68efbbb01eea474d91d277769da80 | refs/heads/main | 2023-06-11T03:49:16.497875 | 2021-07-03T23:45:40 | 2021-07-03T23:45:40 | 380,558,339 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,071 | java | package com.vinsguru.payment.config;
import com.vinsguru.events.inventory.InventoryEvent;
import com.vinsguru.events.order.OrderEvent;
import com.vinsguru.events.order.OrderStatus;
import com.vinsguru.events.payment.PaymentEvent;
import com.vinsguru.events.shipping.ShippingEvent;
import com.vinsguru.payment.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@Configuration
public class PaymentConfig {
@Autowired
private PaymentService service;
// payment service não consome mais diretamento o do order service,
// após o investario ser reservado, o inventory service envia o evento,
// e esse é consumido pelo payment service, que envia outro evento para o shipping service,
// em caso de rollback, faz o rollback inicialmente para o invetory service
// @Bean
// public Function<Flux<OrderEvent>, Flux<PaymentEvent>> paymentProcessor() {
// return flux -> flux.flatMap(this::processPayment);
// }
//
// private Mono<PaymentEvent> processPayment(OrderEvent event){
// if(event.getOrderStatus().equals(OrderStatus.CREATED)){
// return Mono.fromSupplier(() -> this.service.newOrderEvent(event));
// }else{
// return Mono.fromRunnable(() -> this.service.cancelOrderEvent(event));
// }
// }
@Bean
public Sinks.Many<PaymentEvent> paymentSink(){
return Sinks.many().unicast().onBackpressureBuffer();
}
@Bean
public Supplier<Flux<PaymentEvent>> paymentSupplier(Sinks.Many<PaymentEvent> sink){
return sink::asFlux;
}
@Bean
public Consumer<InventoryEvent> inventoryEventConsumer(){
return inventoryEvent -> service.newOrderEvent(inventoryEvent);
}
}
| [
"[email protected]"
] | |
a06bd3014cb936076b676ec5ce91c370eb6efc9a | f73b9e6b4b091a372ec8c6ddb341116556344608 | /app/src/main/java/com/first/anew/PlayersDataAdapter.java | 05b2e654444c59743d7d7571c518c83dcf7ff69d | [] | no_license | Ivangrischenko/shifu-project1 | 61df271451c6cac748834fd40552dda72083b378 | f54fd94222f0d353f36103b003d72c6025f96a42 | refs/heads/master | 2020-03-20T18:29:45.454079 | 2018-07-11T14:37:05 | 2018-07-11T14:37:05 | 137,590,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,786 | java | package com.first.anew;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.first.anew.Players.Player;
import java.util.ArrayList;
import java.util.List;
import io.realm.RealmList;
import pl.fanfatal.swipecontrollerdemo.R;
public class PlayersDataAdapter extends RecyclerView.Adapter<PlayersDataAdapter.MyViewHolder> {
public List<Player> playerList;
Context context;
public PlayersDataAdapter(List<Player> playerList, Context context) {
this.playerList = playerList;
this.context = context;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_view, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Player player = playerList.get(position);
holder.title.setText(player.getTitle());
holder.content.setText(player.getContent());
holder.link.setText(player.getLink());
}
@Override
public int getItemCount() {
return playerList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView title;
TextView content;
TextView link;
public MyViewHolder(View itemView) {
super(itemView);
title = itemView.findViewById(R.id.name);
content = itemView.findViewById(R.id.content);
link = itemView.findViewById(R.id.link);
}
}
}
| [
"Ivangrischenko"
] | Ivangrischenko |
723fcb2bd6cfa6de5759768aec87b538d1734ae4 | 401979212a3eadaf245b21a2e97cd97d87af96e0 | /java-in-action/mvnAction/src/main/java/model/uml/books.java | 8c125bd224aebf1ac3a578030231954c245faa50 | [] | no_license | zuston/code-library | 53f38979f8b43d7cee893ce77b5429da714ca4ec | 5c5cdc29f9b49be97e112017f268dcf913513e0d | refs/heads/master | 2021-05-04T09:28:29.827958 | 2016-12-23T04:53:27 | 2016-12-23T04:53:27 | 70,454,606 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,522 | java | package model.uml;
import tool.ORM;
/**
* Created by zuston on 16/11/7.
*/
public class books extends ORM {
public String type;
public String title;
public int price;
public String author;
public int number;
public int broken;
public books(String type, String title, int price, String author, int number, int broken) {
this.type = type;
this.title = title;
this.price = price;
this.author = author;
this.number = number;
this.broken = broken;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getBroken() {
return broken;
}
public void setBroken(int broken) {
this.broken = broken;
}
public static void main(String[] args) throws IllegalAccessException {
books bk = new books("文学","风雨张居正",200,"张文君",30,1);
bk.save();
}
}
| [
"[email protected]"
] | |
911b9392f0efbe8794c17869d50a3509d784a55c | f7503620250087ae9c8b064dd27e3253e4dbaf34 | /android/content/pm/ServiceInfo.java | 184789f3adf59ce6d0f0cf4ea439d9ba36f32f8f | [] | no_license | d-yacenko/ClassDump | a23d25c952c250c8b5c201c7a86aefe14ebabd39 | ccfbf8a187c1936c9aed0f3cefb869529ecb74d4 | refs/heads/master | 2021-01-19T02:19:16.615485 | 2017-04-05T09:09:10 | 2017-04-05T09:09:10 | 87,269,358 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,897 | java | package android.content.pm;
import android.__Result__;
/*===================================*/
/* ServiceInfo */
/*===================================*/
public class ServiceInfo extends android.content.pm.ComponentInfo implements android.os.Parcelable {
/*========fields=========*/
public static final android.os.Parcelable$Creator CREATOR=null;
public static final int FLAG_EXTERNAL_SERVICE=0;
public static final int FLAG_ISOLATED_PROCESS=0;
public static final int FLAG_SINGLE_USER=0;
public static final int FLAG_STOP_WITH_TASK=0;
public int flags;
public java.lang.String permission;
/*======constructors=====*/
public ServiceInfo (android.content.pm.ServiceInfo arg0) {__Result__.str+="|ServiceInfo|";}
public ServiceInfo () {__Result__.str+="|ServiceInfo|";}
/*========methods========*/
public void dump (android.util.Printer arg0,java.lang.String arg1) {__Result__.str+="|dump|"; return ;}
public void writeToParcel (android.os.Parcel arg0,int arg1) {__Result__.str+="|writeToParcel|"; return ;}
public int describeContents () {__Result__.str+="|describeContents|"; return 0;}
public java.lang.String toString () {__Result__.str+="|toString|"; return null;}
/*========inner classes========*/
import android.__Result__;
/*===================================*/
/* DisplayNameComparator */
/*===================================*/
public static class DisplayNameComparator implements java.util.Comparator<android.content.pm.PackageItemInfo> {
/*========fields=========*/
/*======constructors=====*/
public DisplayNameComparator (android.content.pm.PackageManager arg0) {__Result__.str+="|DisplayNameComparator|";}
/*========methods========*/
public final int compare (android.content.pm.PackageItemInfo arg0,android.content.pm.PackageItemInfo arg1) {__Result__.str+="|compare|"; return 0;}
/*========inner classes========*/
}
} | [
"[email protected]"
] | |
1351bf76dec63b6633a7020c1ad331cba5020864 | cc6af79efb2edbbdbdc8e1baf926ff67e02ff06f | /app/src/main/java/com/ase/aseapp/BusProvider.java | 90cbba079c027302438ff9ac688b090cf728fd57 | [] | no_license | anamariaradut/ASEApp | 0598935ada799443fce9ea30989caa19af919463 | bef148e9f5b7afcdd60b47994f674962183383f5 | refs/heads/master | 2021-01-09T06:34:03.125396 | 2017-02-05T15:34:48 | 2017-02-05T15:34:48 | 81,001,313 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 267 | java | package com.ase.aseapp;
/**
* Created by alex on 31.01.17.
*/
import com.squareup.otto.Bus;
public class BusProvider {
private static final Bus BUS = new Bus();
public static Bus getInstance(){
return BUS;
}
public BusProvider(){}
}
| [
"Ana-Maria Radut"
] | Ana-Maria Radut |
c93c833fd6c30b8e1afd1bdde818ddf440a505f8 | 17431c02b726f51f69a96b13e7769d72b2052134 | /app/src/main/java/autroid/business/adapter/ProfileProductStockAdapter.java | 8c091da8c8131b437faf513dcaa92104b05e3d7c | [] | no_license | bholaAutroid/Autroid | 53f56dc0114d5e2dbe3c624b461657e074c0b207 | d8bab8809b6b49d8f0c498b47ec961a05b942699 | refs/heads/master | 2023-06-26T10:12:31.062782 | 2021-07-30T05:03:04 | 2021-07-30T05:03:04 | 380,445,003 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,973 | java | package autroid.business.adapter;
import android.content.Context;
import android.content.res.Resources;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import autroid.business.R;
import autroid.business.model.bean.ProductDetailBE;
/**
* Created by pranav.mittal on 06/14/17.
*/
public class ProfileProductStockAdapter extends RecyclerView.Adapter<ProfileProductStockAdapter.ProfileProductStockHolder> {
Context context;
public ArrayList<ProductDetailBE> mList;
Boolean isFullWidth;
public ProfileProductStockAdapter(Context context,ArrayList<ProductDetailBE> mList,Boolean isFullWidth){
this.context=context;
this.mList=mList;
this.isFullWidth=isFullWidth;
}
@Override
public ProfileProductStockHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.
from(context).
inflate(R.layout.row_profile_product_stock, parent, false);
return new ProfileProductStockHolder(itemView);
}
@Override
public void onBindViewHolder(ProfileProductStockHolder holder, int position) {
holder.mProductName.setText(mList.get(position).getTitle());
holder.mProductPrice.setText("₹ "+mList.get(position).getPrice());
// holder.mProductCode.setText(mList.get(position).getCategory().getCategory());
if(mList.get(position).getThumbnails().size()>0)
Picasso.with(context).load(mList.get(position).getThumbnails().get(0).getFile_address()).placeholder(R.drawable.placeholder_big).into(holder.mProductImage);
else
Picasso.with(context).load(R.drawable.placeholder_big).fit().placeholder(R.drawable.placeholder_big).into(holder.mProductImage);
}
@Override
public int getItemCount() {
return mList.size();
}
public class ProfileProductStockHolder extends RecyclerView.ViewHolder{
TextView mProductPrice,mProductName,mProductCode;
LinearLayout mMainLayout;
ImageView mProductImage;
public ProfileProductStockHolder(View itemView) {
super(itemView);
mProductPrice= (TextView) itemView.findViewById(R.id.product_price);
mProductName= (TextView) itemView.findViewById(R.id.product_name);
mProductCode= (TextView) itemView.findViewById(R.id.product_code);
mMainLayout=itemView.findViewById(R.id.main_layout);
mProductImage= (ImageView) itemView.findViewById(R.id.product_image);
if(isFullWidth){
int width= Resources.getSystem().getDisplayMetrics().widthPixels;
mMainLayout.getLayoutParams().width=width;
}
}
}
}
| [
"[email protected]"
] | |
87a9faf8d59e6ed7cc1b2c197b1b0314fe0aeb93 | f18c96dbd335aebfacc6553b190e5e37a00f1fc8 | /java_project/MyProject/src/ch04/Member.java | aeb3a77fb028d0661ab3996c3e92bc7bb539bd00 | [] | no_license | flip1945/Java205 | 9f710156b344048faf3aaa925302c82e24fbb268 | ea34da4a411fe7ab2ac938a48caa203a29d54b12 | refs/heads/main | 2023-07-13T20:28:59.633857 | 2021-09-01T11:27:13 | 2021-09-01T11:27:13 | 370,222,260 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,873 | java | package ch04;
import java.util.Calendar;
import java.util.Scanner;
public class Member {
private int curYear = Calendar.getInstance().get(Calendar.YEAR);
public void checkFluVaccine(int birthYear) {
int age = curYear - birthYear + 1;
if (age < 15 || age >= 65) {
System.out.println("현재 나이 " + age + "살은");
System.out.println("무료예방접종이 가능합니다.");
} else {
System.out.println("현재 나이 " + age + "살은");
System.out.println("무료접종 대상이 아닙니다.");
}
}
public void checkMeicalCheck(int birthYear) {
int age = curYear - birthYear + 1;
if (age >= 20) {
if (curYear % 2 == birthYear % 2) {
System.out.println("현재 나이 " + age + "살은");
System.out.println("무료건강검진이 가능합니다.");
if (age >= 40) {
System.out.println("암 검사도 무료로 가능합니다.");
}
} else {
System.out.println("현재 나이 " + age + "살은");
System.out.println("무료건강검진 대상이 아닙니다.");
}
} else {
System.out.println("20세 이상만 무료로 건강검진이 가능합니다.");
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Member member = new Member();
while (true) {
System.out.print("태어난 연도를 입력해주세요(0 입력시 종료) : ");
int birthYear = scanner.nextInt();
if (birthYear == 0) {
break;
} else if (birthYear < 0) {
System.out.println("올바른 년도를 입력해주세요.");
continue;
}
System.out.println("---------독감예방 접종---------\n");
member.checkFluVaccine(birthYear);
System.out.println();
System.out.println("---------건강검진 대상---------\n");
member.checkMeicalCheck(birthYear);
System.out.println();
}
scanner.close();
}
}
| [
"[email protected]"
] | |
d14058092583e2249dd89a7e9cb21084302054f0 | cc8db277ffcf142e6a81fa8d3f7a240cd3a879b2 | /src/test/java/com/one/north/web/rest/JobHistoryResourceIT.java | 254742f3f48593a185bf95d104066d799414a036 | [] | no_license | uscbsitric/oneAngularTest | 3a75bb0c8cfcd431a2024199bf1e61d10679aa59 | 6e21bf445372de17254e7037ce4a19f0515e12b0 | refs/heads/master | 2021-07-06T20:51:12.222404 | 2019-05-19T09:49:51 | 2019-05-19T09:49:51 | 187,453,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,793 | java | package com.one.north.web.rest;
import com.one.north.OneangularApp;
import com.one.north.domain.JobHistory;
import com.one.north.repository.JobHistoryRepository;
import com.one.north.service.JobHistoryService;
import com.one.north.web.rest.errors.ExceptionTranslator;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.Validator;
import javax.persistence.EntityManager;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import static com.one.north.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import com.one.north.domain.enumeration.Language;
/**
* Integration tests for the {@Link JobHistoryResource} REST controller.
*/
@SpringBootTest(classes = OneangularApp.class)
public class JobHistoryResourceIT {
private static final Instant DEFAULT_START_DATE = Instant.ofEpochMilli(0L);
private static final Instant UPDATED_START_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS);
private static final Instant DEFAULT_END_DATE = Instant.ofEpochMilli(0L);
private static final Instant UPDATED_END_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS);
private static final Language DEFAULT_LANGUAGE = Language.FRENCH;
private static final Language UPDATED_LANGUAGE = Language.ENGLISH;
@Autowired
private JobHistoryRepository jobHistoryRepository;
@Autowired
private JobHistoryService jobHistoryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restJobHistoryMockMvc;
private JobHistory jobHistory;
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final JobHistoryResource jobHistoryResource = new JobHistoryResource(jobHistoryService);
this.restJobHistoryMockMvc = MockMvcBuilders.standaloneSetup(jobHistoryResource)
.setCustomArgumentResolvers(pageableArgumentResolver)
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter)
.setValidator(validator).build();
}
/**
* Create an entity for this test.
*
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
public static JobHistory createEntity(EntityManager em) {
JobHistory jobHistory = new JobHistory()
.startDate(DEFAULT_START_DATE)
.endDate(DEFAULT_END_DATE)
.language(DEFAULT_LANGUAGE);
return jobHistory;
}
@BeforeEach
public void initTest() {
jobHistory = createEntity(em);
}
@Test
@Transactional
public void createJobHistory() throws Exception {
int databaseSizeBeforeCreate = jobHistoryRepository.findAll().size();
// Create the JobHistory
restJobHistoryMockMvc.perform(post("/api/job-histories")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(jobHistory)))
.andExpect(status().isCreated());
// Validate the JobHistory in the database
List<JobHistory> jobHistoryList = jobHistoryRepository.findAll();
assertThat(jobHistoryList).hasSize(databaseSizeBeforeCreate + 1);
JobHistory testJobHistory = jobHistoryList.get(jobHistoryList.size() - 1);
assertThat(testJobHistory.getStartDate()).isEqualTo(DEFAULT_START_DATE);
assertThat(testJobHistory.getEndDate()).isEqualTo(DEFAULT_END_DATE);
assertThat(testJobHistory.getLanguage()).isEqualTo(DEFAULT_LANGUAGE);
}
@Test
@Transactional
public void createJobHistoryWithExistingId() throws Exception {
int databaseSizeBeforeCreate = jobHistoryRepository.findAll().size();
// Create the JobHistory with an existing ID
jobHistory.setId(1L);
// An entity with an existing ID cannot be created, so this API call must fail
restJobHistoryMockMvc.perform(post("/api/job-histories")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(jobHistory)))
.andExpect(status().isBadRequest());
// Validate the JobHistory in the database
List<JobHistory> jobHistoryList = jobHistoryRepository.findAll();
assertThat(jobHistoryList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void getAllJobHistories() throws Exception {
// Initialize the database
jobHistoryRepository.saveAndFlush(jobHistory);
// Get all the jobHistoryList
restJobHistoryMockMvc.perform(get("/api/job-histories?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(jobHistory.getId().intValue())))
.andExpect(jsonPath("$.[*].startDate").value(hasItem(DEFAULT_START_DATE.toString())))
.andExpect(jsonPath("$.[*].endDate").value(hasItem(DEFAULT_END_DATE.toString())))
.andExpect(jsonPath("$.[*].language").value(hasItem(DEFAULT_LANGUAGE.toString())));
}
@Test
@Transactional
public void getJobHistory() throws Exception {
// Initialize the database
jobHistoryRepository.saveAndFlush(jobHistory);
// Get the jobHistory
restJobHistoryMockMvc.perform(get("/api/job-histories/{id}", jobHistory.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(jobHistory.getId().intValue()))
.andExpect(jsonPath("$.startDate").value(DEFAULT_START_DATE.toString()))
.andExpect(jsonPath("$.endDate").value(DEFAULT_END_DATE.toString()))
.andExpect(jsonPath("$.language").value(DEFAULT_LANGUAGE.toString()));
}
@Test
@Transactional
public void getNonExistingJobHistory() throws Exception {
// Get the jobHistory
restJobHistoryMockMvc.perform(get("/api/job-histories/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateJobHistory() throws Exception {
// Initialize the database
jobHistoryService.save(jobHistory);
int databaseSizeBeforeUpdate = jobHistoryRepository.findAll().size();
// Update the jobHistory
JobHistory updatedJobHistory = jobHistoryRepository.findById(jobHistory.getId()).get();
// Disconnect from session so that the updates on updatedJobHistory are not directly saved in db
em.detach(updatedJobHistory);
updatedJobHistory
.startDate(UPDATED_START_DATE)
.endDate(UPDATED_END_DATE)
.language(UPDATED_LANGUAGE);
restJobHistoryMockMvc.perform(put("/api/job-histories")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(updatedJobHistory)))
.andExpect(status().isOk());
// Validate the JobHistory in the database
List<JobHistory> jobHistoryList = jobHistoryRepository.findAll();
assertThat(jobHistoryList).hasSize(databaseSizeBeforeUpdate);
JobHistory testJobHistory = jobHistoryList.get(jobHistoryList.size() - 1);
assertThat(testJobHistory.getStartDate()).isEqualTo(UPDATED_START_DATE);
assertThat(testJobHistory.getEndDate()).isEqualTo(UPDATED_END_DATE);
assertThat(testJobHistory.getLanguage()).isEqualTo(UPDATED_LANGUAGE);
}
@Test
@Transactional
public void updateNonExistingJobHistory() throws Exception {
int databaseSizeBeforeUpdate = jobHistoryRepository.findAll().size();
// Create the JobHistory
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restJobHistoryMockMvc.perform(put("/api/job-histories")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(jobHistory)))
.andExpect(status().isBadRequest());
// Validate the JobHistory in the database
List<JobHistory> jobHistoryList = jobHistoryRepository.findAll();
assertThat(jobHistoryList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteJobHistory() throws Exception {
// Initialize the database
jobHistoryService.save(jobHistory);
int databaseSizeBeforeDelete = jobHistoryRepository.findAll().size();
// Delete the jobHistory
restJobHistoryMockMvc.perform(delete("/api/job-histories/{id}", jobHistory.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isNoContent());
// Validate the database is empty
List<JobHistory> jobHistoryList = jobHistoryRepository.findAll();
assertThat(jobHistoryList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(JobHistory.class);
JobHistory jobHistory1 = new JobHistory();
jobHistory1.setId(1L);
JobHistory jobHistory2 = new JobHistory();
jobHistory2.setId(jobHistory1.getId());
assertThat(jobHistory1).isEqualTo(jobHistory2);
jobHistory2.setId(2L);
assertThat(jobHistory1).isNotEqualTo(jobHistory2);
jobHistory1.setId(null);
assertThat(jobHistory1).isNotEqualTo(jobHistory2);
}
}
| [
"[email protected]"
] | |
03111ffbd089c7358e1694e4a2e55426858156f1 | fb584ac54fee86accffb768b1cb8042826a77e7f | /lab3.2/Parameter.java | 62d0db7912650cc92ffe041092afb3dd7f937bb3 | [] | no_license | Emidiant/OOP_Java | d0074f4e636cb0d484b0038e725f6c99e6274d1e | ff43891349d9a820214ddd486223def4b3b71916 | refs/heads/master | 2020-04-04T11:58:21.892857 | 2018-12-28T21:25:52 | 2018-12-28T21:25:52 | 155,909,848 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | import java.util.HashMap;
public class Parameter {
private String name;
private String value;
Parameter(String parameter){
String[] parts = parameter.split("=");
this.name = parts[0].trim();
this.value = parts[1].trim();
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return (name + " = " + value);
}
}
| [
"[email protected]"
] | |
cf70196a522170bf6d318b93f9a61dfd53afb059 | de595f0126a6b88b67b361708a07c4088421a403 | /src/main/java/com/tpCarRental/repositories/CarTypeRepository.java | 07e00f48bb4fc4eed93d01f7b2280fa29d3dc1af | [] | no_license | Ernst95/TP_Car_Rental | a03398b265f0076e2d8d2fc8089102ea15cfc56b | 42a6ce24af30ffce758ec0fe459c0d05ae7e5422 | refs/heads/master | 2021-08-07T22:18:34.981574 | 2017-11-09T04:04:03 | 2017-11-09T04:04:03 | 109,504,554 | 0 | 5 | null | 2017-11-09T04:00:16 | 2017-11-04T15:04:45 | Java | UTF-8 | Java | false | false | 219 | java | package com.tpCarRental.repositories;
import com.tpCarRental.domain.CarType;
import org.springframework.data.repository.CrudRepository;
public interface CarTypeRepository extends CrudRepository<CarType, String>{
}
| [
"[email protected]"
] | |
c17e6e15da0ff23a5771d78ddccef37c3560f9d5 | f06f410ed97fa715c73f6899cbcda9956ce87051 | /P4/src/music/MP3Listener.java | 9d3d1c6ab4e3ec00f6025d632c30c99831497a89 | [] | no_license | Tarpenningk/Java-Programs | 497d5431f423a73424f592b463fef87af257f8d5 | 0c2783ff838e8a16ac1cc1949a0ce0b029d1a2e4 | refs/heads/master | 2020-08-08T08:46:03.381987 | 2019-10-09T02:47:34 | 2019-10-09T02:47:34 | 213,796,485 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 77 | java | package music;
public interface MP3Listener
{
public void mp3Done();
} | [
"[email protected]"
] | |
053a6c082be524e8ea44734769798f8f138b29b5 | eca963fa3b666daea5537b2768a8b7881d41f442 | /haxby/image/jcodec/codecs/mpeg12/MPEGPredQuad.java | f11428bf96821601d8622aba1900c0c086604218 | [
"Apache-2.0"
] | permissive | iedadata/geomapapp | 1bee9fcbb686b9a932c467cb6d1e4511277d6a46 | 5368b21c425ff188a125939877f1db1eefb7ed9b | refs/heads/master | 2023-08-17T08:47:13.342087 | 2023-08-15T20:20:25 | 2023-08-15T20:20:25 | 98,096,914 | 1 | 3 | Apache-2.0 | 2023-08-15T20:20:27 | 2017-07-23T12:38:27 | Java | UTF-8 | Java | false | false | 1,023 | java | package haxby.image.jcodec.codecs.mpeg12;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* MPEG 1/2 decoder interframe motion compensation routines.
*
* Quad subpixel interpolator which is just a sub-case of octal subpixel
* interpolator.
*
* @author The JCodec project
*
*/
public class MPEGPredQuad extends MPEGPredOct {
public MPEGPredQuad(MPEGPred other) {
super(other);
}
// TODO: This interpolation uses sinc at the very lowest (half-pel -- 1/8) level as opposed to linear as specified by the standard.
// this may be a result of color greening out in long GOPs.
@Override
public void predictPlane(byte[] ref, int refX, int refY, int refW, int refH, int refVertStep, int refVertOff,
int[] tgt, int tgtY, int tgtW, int tgtH, int tgtVertStep) {
super.predictPlane(ref, refX, refY, refW, refH, refVertStep, refVertOff, tgt, tgtY, tgtW << 1, tgtH << 1,
tgtVertStep);
}
} | [
"[email protected]"
] | |
a91c13a5b71347544b36f5cd978d9f1465dc872e | 9e01f075074e9bde74c92a34753140177b6449f0 | /src/zmarkdown/javaeditor/ZMarkdownJavaEditor.java | e40195d60f074cb88af262c1c0c092675fc4a2b7 | [
"MIT"
] | permissive | firm1/zmarkdown-editor | 597ec70ec83a556b81329d66284f48be073bac79 | 25aad852e7971cec7a3f24e1d266e56f229369a0 | refs/heads/master | 2020-06-07T13:37:50.871194 | 2014-10-14T23:14:18 | 2014-10-14T23:14:18 | 22,770,925 | 2 | 1 | null | 2017-07-14T11:48:08 | 2014-08-08T20:39:51 | Python | UTF-8 | Java | false | false | 805 | 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 zmarkdown.javaeditor;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import zmarkdown.javaeditor.ihm.Editor;
/**
*
* @author firm1
*/
public class ZMarkdownJavaEditor {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Editor edit = new Editor();
edit.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
edit.setExtendedState(JFrame.MAXIMIZED_BOTH);
edit.setVisible(true);
}
}
| [
"[email protected]"
] | |
387404cca2e244723cdcc7362c6f097bacc60196 | 26c118d9951db463ea788a4099d0c8065a882284 | /src/main/java/io/amecodelabs/Minesweeper/App.java | 02548d2571b0d844052aeb1c115ad96caa15df9d | [
"MIT"
] | permissive | amarqueze/Minesweeper | 9f6ce1ff45d714a73a5f5c84b7dc3b1d2a8d702a | d4debe45c5b8fdd7cc436fa49f2ed20123b61def | refs/heads/master | 2021-09-22T09:14:54.130872 | 2018-09-07T02:29:45 | 2018-09-07T02:29:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 293 | java | package io.amecodelabs.Minesweeper;
import io.amecodelabs.Minesweeper.config.language.SystemLanguage;
import io.amecodelabs.Minesweeper.view.ConsoleView;
public class App
{
public static void main(String[] args)
{
new ConsoleView(SystemLanguage.newInstance()).run();
}
}
| [
"[email protected]"
] | |
e283772aac20b18c1f512ecc27a138f859e4fe11 | 705a4392a9b8e8734f37c1db3dfddffc45e15b6f | /sc-excle/src/test/java/com/sc/excel/test/model/ReadModel2.java | 32c3147175894b6ee64755f7da2c0f67a3b31cb3 | [
"Apache-2.0"
] | permissive | fullshit/com-sc | 64f473804d1bbdeacd49a248a7e90e092f0a1466 | 76b66580185fab0d595619956ae6c40f60a00633 | refs/heads/master | 2020-05-31T15:52:33.690141 | 2019-03-04T11:34:54 | 2019-03-04T11:34:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,558 | java | package com.sc.excel.test.model;
import com.sc.excel.annotation.ExcelProperty;
import com.sc.excel.metadata.BaseRowModel;
import java.math.BigDecimal;
import java.util.Date;
public class ReadModel2 extends BaseRowModel {
@ExcelProperty(index = 0)
private String str;
@ExcelProperty(index = 1)
private Float ff;
@ExcelProperty(index = 2)
private Integer mm;
@ExcelProperty(index = 3)
private BigDecimal money;
@ExcelProperty(index = 4)
private Long times;
@ExcelProperty(index = 5)
private Double activityCode;
@ExcelProperty(index = 6,format = "yyyy-MM-dd")
private Date date;
@ExcelProperty(index = 7)
private String lx;
@ExcelProperty(index = 8)
private String name;
@ExcelProperty(index = 18)
private String kk;
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
public Float getFf() {
return ff;
}
public void setFf(Float ff) {
this.ff = ff;
}
public Integer getMm() {
return mm;
}
public void setMm(Integer mm) {
this.mm = mm;
}
public BigDecimal getMoney() {
return money;
}
public void setMoney(BigDecimal money) {
this.money = money;
}
public Long getTimes() {
return times;
}
public void setTimes(Long times) {
this.times = times;
}
public Double getActivityCode() {
return activityCode;
}
public void setActivityCode(Double activityCode) {
this.activityCode = activityCode;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getLx() {
return lx;
}
public void setLx(String lx) {
this.lx = lx;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getKk() {
return kk;
}
public void setKk(String kk) {
this.kk = kk;
}
@Override
public String toString() {
return "JavaModel2{" +
"str='" + str + '\'' +
", ff=" + ff +
", mm=" + mm +
", money=" + money +
", times=" + times +
", activityCode=" + activityCode +
", date=" + date +
", lx='" + lx + '\'' +
", name='" + name + '\'' +
", kk='" + kk + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
3c2f393201a5ddf770be221b01f80e1b6d73c04e | 0af3fb55c2b9b031dd2eb0efeb4297b0cce86a9f | /src/main/java/com/mycompany/app/ConnexionUnique.java | 76ff62e6d8057007db678801c5da87a6358bb165 | [] | no_license | ynestacamille/YNESTA_TPJDBC | 4d077726a75aac45ddcec2bd2b9148577b3fd0eb | 0312199c1fd8d6ea988fb5b65ef6934aaf6f60d8 | refs/heads/master | 2021-01-12T10:45:19.134523 | 2016-11-02T21:04:29 | 2016-11-02T21:04:29 | 72,675,302 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | package com.mycompany.app;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnexionUnique {
private Connection connection;
private static ConnexionUnique instance;
private String CONNECT_URL = "jdbc:mysql://mysql-camilleynesta.alwaysdata.net:3306/camilleynesta_tutojdbc";;
public ConnexionUnique() throws SQLException{
connection = DriverManager.getConnection(CONNECT_URL, "128842", "linottexqxqi");
}
public Connection getConnection(){
return connection;
}
public static ConnexionUnique getInstance() throws SQLException{
if(instance == null)
instance = new ConnexionUnique();
return instance;
}
public void setConnection (Connection connect){
connection = connect;
}
}
| [
"[email protected]"
] | |
71cf591d8af6b14d731a10807b3b8d0306eda4b1 | 7e54ac1631c1319ea085ce04db8b09dc9c60ed37 | /Food.java | a0afb32ad75f2bc93784d3e31374dad9ebc3f916 | [] | no_license | EMX107/JavaGreenfoot-SNAKE | fcfb0a18fe52a89957e242dd505c02feedb3629d | 5a2c61a34462eaf01972aaa40b6ae95b57d4f2f9 | refs/heads/main | 2023-03-21T01:56:12.363284 | 2021-03-26T16:06:47 | 2021-03-26T16:06:47 | 351,833,735 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 116 | java | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Food extends Actor {}
| [
"[email protected]"
] | |
24bb0fc23f9971f70099fe78d0a5b3fee1509154 | 5fa23d60f8bce0209870a04c7d8e4f71b96dafbb | /database/src/main/java/org/mk/badam7/database/entity/PlayerCurrentHandCardEntity.java | 7273b19efeed912c54ed853c579d8f01950115a5 | [] | no_license | makzmslv/badam7 | ab3533d56f7425b78d9511eacd55f239f2846843 | a173c33bed7505a04d450fb916c5cd8485927ea0 | refs/heads/master | 2021-01-01T15:55:47.032585 | 2015-09-30T12:06:14 | 2015-09-30T12:06:14 | 25,087,872 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,891 | java | package org.mk.badam7.database.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name = "PLAYER_CURRENT_CARD")
public class PlayerCurrentHandCardEntity
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@OneToOne
@JoinColumn(name = "REF_CARD")
private CardEntity cardEntity;
@ManyToOne
@JoinColumn(name = "REF_HAND")
private HandEntity handEntity;
@ManyToOne
@JoinColumn(name = "REF_PLAYER_CURRENT_GAME_INSTANCE")
private PlayerCurrentGameInstanceEntity playerCurrentGameInstanceEntity;
@Column(name = "STATUS")
private Integer status;
@Column(name = "CARD_REMOVAL_RANK")
private Integer cardRemovalRank;
public Integer getId()
{
return id;
}
public void setId(Integer id)
{
this.id = id;
}
public CardEntity getCardEntity()
{
return cardEntity;
}
public void setCardEntity(CardEntity cardEntity)
{
this.cardEntity = cardEntity;
}
public HandEntity getHandEntity()
{
return handEntity;
}
public void setHandEntity(HandEntity handEntity)
{
this.handEntity = handEntity;
}
public PlayerCurrentGameInstanceEntity getPlayerCurrentGameInstanceEntity()
{
return playerCurrentGameInstanceEntity;
}
public void setPlayerCurrentGameInstanceEntity(PlayerCurrentGameInstanceEntity playerCurrentGameInstanceEntity)
{
this.playerCurrentGameInstanceEntity = playerCurrentGameInstanceEntity;
}
public Integer getStatus()
{
return status;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getCardRemovalRank()
{
return cardRemovalRank;
}
public void setCardRemovalRank(Integer cardRemovalRank)
{
this.cardRemovalRank = cardRemovalRank;
}
@Override
public String toString()
{
return "PlayerCurrentCard [id=" + id + ", card=" + cardEntity + ", playerCurrentGameInstance=" + playerCurrentGameInstanceEntity + ", status=" + status + ", cardRemovalRank="
+ cardRemovalRank + "]";
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((cardEntity == null) ? 0 : cardEntity.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((playerCurrentGameInstanceEntity == null) ? 0 : playerCurrentGameInstanceEntity.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PlayerCurrentHandCardEntity other = (PlayerCurrentHandCardEntity) obj;
if (cardEntity == null)
{
if (other.cardEntity != null)
return false;
}
else if (!cardEntity.equals(other.cardEntity))
return false;
if (id == null)
{
if (other.id != null)
return false;
}
else if (!id.equals(other.id))
return false;
if (playerCurrentGameInstanceEntity == null)
{
if (other.playerCurrentGameInstanceEntity != null)
return false;
}
else if (!playerCurrentGameInstanceEntity.equals(other.playerCurrentGameInstanceEntity))
return false;
return true;
}
}
| [
"[email protected]"
] | |
f0820571b567ba061add46ee6399693ae89af5a0 | 02a8ce78f8874a301c31476df36196361f814fa8 | /src/Main.java | a7378f4974c6783a0634cebe13ccddffbaac51a8 | [] | no_license | sergioceron/CFIE3 | cb4c783aa12b2202e8d89af27e5e1ff6185446cb | fe626aac1f73cd42e8512085f2687eb1f62caeb7 | refs/heads/master | 2021-01-14T13:44:14.929909 | 2015-01-11T20:01:05 | 2015-01-11T20:01:05 | 29,103,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,410 | java | import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.metadata.ClassMetadata;
import java.util.Map;
/**
* User: sg
* Date: 16/09/12
* Time: 11:21 AM
*/
public class Main {
private static final SessionFactory ourSessionFactory;
static {
try {
ourSessionFactory = new AnnotationConfiguration().
configure("hibernate.cfg.xml").
buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession() throws HibernateException {
return ourSessionFactory.openSession();
}
public static void main(final String[] args) throws Exception {
final Session session = getSession();
try {
System.out.println("querying all the managed entities...");
final Map metadataMap = session.getSessionFactory().getAllClassMetadata();
for (Object key : metadataMap.keySet()) {
final ClassMetadata classMetadata = (ClassMetadata) metadataMap.get(key);
final String entityName = classMetadata.getEntityName();
final Query query = session.createQuery("from " + entityName);
System.out.println("executing: " + query.getQueryString());
for (Object o : query.list()) {
System.out.println(" " + o);
}
}
} finally {
session.close();
}
}
}
| [
"[email protected]"
] | |
732fc9ebbf19b6fbb6df6fa35af0beb9f85cf162 | ae69e30f8eb4ff2cd47e2336b2a2b31f271a3e5a | /Java/cses/range_queries/DynamicRangeMinimum.java | 3bdb2f40ba8a0f6bfd26327cc850e868881a83e5 | [] | no_license | bdugersuren/CompetitiveProgramming | f35048ef8e5345c5219c992f2be8b84e1f7f1cb8 | cd571222aabe3de952d90d6ddda055aa3b8c08d9 | refs/heads/master | 2023-05-12T00:45:15.065209 | 2021-05-14T13:24:53 | 2021-05-14T13:24:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,990 | java | package cses.range_queries;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
public final class DynamicRangeMinimum {
private static class SegTree {
int leftMost, rightMost;
SegTree left, right;
int min;
SegTree(int leftMost, int rightMost, int[] arr) {
this.leftMost = leftMost;
this.rightMost = rightMost;
if (leftMost == rightMost) {
min = arr[leftMost];
} else {
final int mid = leftMost + rightMost >>> 1;
left = new SegTree(leftMost, mid, arr);
right = new SegTree(mid + 1, rightMost, arr);
recalc();
}
}
private void recalc() {
if (leftMost == rightMost) {
return;
}
min = Math.min(left.min, right.min);
}
private int query(int l, int r) {
if (r < leftMost || l > rightMost) {
return (int) 1e9;
}
if (l <= leftMost && rightMost <= r) {
return min;
}
return Math.min(left.query(l, r), right.query(l, r));
}
private void update(int idx, int val) {
if (leftMost == rightMost) {
min = val;
} else {
final int mid = leftMost + rightMost >>> 1;
if (idx <= mid) {
left.update(idx, val);
} else {
right.update(idx, val);
}
recalc();
}
}
}
public static void main(String[] args) throws IOException {
final FastReader fs = new FastReader();
final PrintWriter pw = new PrintWriter(System.out);
final int n = fs.nextInt();
final int q = fs.nextInt();
final int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = fs.nextInt();
}
final SegTree st = new SegTree(0, n - 1, arr);
for (int i = 0; i < q; i++) {
final int t = fs.nextInt();
if (t == 1) {
final int idx = fs.nextInt() - 1;
final int val = fs.nextInt();
st.update(idx, val);
} else {
final int l = fs.nextInt() - 1;
final int r = fs.nextInt() - 1;
pw.println(st.query(l, r));
}
}
pw.close();
}
static final class Utils {
private static class Shuffler {
private static void shuffle(int[] x) {
final Random r = new Random();
for (int i = 0; i <= x.length - 2; i++) {
final int j = i + r.nextInt(x.length - i);
swap(x, i, j);
}
}
private static void shuffle(long[] x) {
final Random r = new Random();
for (int i = 0; i <= x.length - 2; i++) {
final int j = i + r.nextInt(x.length - i);
swap(x, i, j);
}
}
private static void swap(int[] x, int i, int j) {
final int t = x[i];
x[i] = x[j];
x[j] = t;
}
private static void swap(long[] x, int i, int j) {
final long t = x[i];
x[i] = x[j];
x[j] = t;
}
}
public static void shuffleSort(int[] arr) {
Shuffler.shuffle(arr);
Arrays.sort(arr);
}
public static void shuffleSort(long[] arr) {
Shuffler.shuffle(arr);
Arrays.sort(arr);
}
private static int[][] packG(int[][] edges, int n) {
final int[][] g = new int[n][];
final int[] size = new int[n];
for (int[] edge : edges) {
++size[edge[0]];
}
for (int i = 0; i < n; i++) {
g[i] = new int[size[i]];
}
for (int[] edge : edges) {
g[edge[0]][--size[edge[0]]] = edge[1];
}
return g;
}
private static int[][][] packGW(int[][] edges, int n) {
final int[][][] g = new int[n][][];
final int[] size = new int[n];
for (int[] edge : edges) {
++size[edge[0]];
}
for (int i = 0; i < n; i++) {
g[i] = new int[size[i]][2];
}
for (int[] edge : edges) {
g[edge[0]][--size[edge[0]]] = new int[] { edge[1], edge[2] };
}
return g;
}
private Utils() {}
}
static class FastReader {
private static final int BUFFER_SIZE = 1 << 16;
private final DataInputStream din;
private final byte[] buffer;
private int bufferPointer, bytesRead;
FastReader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
FastReader(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
final byte[] buf = new byte[1024]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
break;
}
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextSign() throws IOException {
byte c = read();
while ('+' != c && '-' != c) {
c = read();
}
return '+' == c ? 0 : 1;
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
final boolean neg = c == '-';
if (neg) { c = read(); }
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg) { return -ret; }
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ') { c = read(); }
final boolean neg = c == '-';
if (neg) { c = read(); }
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg) { return -ret; }
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ') { c = read(); }
final boolean neg = c == '-';
if (neg) { c = read(); }
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg) { return -ret; }
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) { buffer[0] = -1; }
}
private byte read() throws IOException {
if (bufferPointer == bytesRead) { fillBuffer(); }
return buffer[bufferPointer++];
}
public void close() throws IOException {
din.close();
}
}
}
| [
"[email protected]"
] | |
7b85fc9ad8ce4784028a840bae9691255be091f2 | 76b489587192c7216944cecd9c7a4553478f2ad4 | /Project1/src/main/java/com/revature/services/ChkUsrSvc.java | b2ae4d18504d2f5e91e4d37adadd643759785446 | [] | no_license | 210201sre/JonathanSchmitz-p1 | 253c8ff945d57b9b3de7648e186e0eb5939e6b6a | 92094197e16605e9fe32644222100e50dacfa51b | refs/heads/main | 2023-04-23T02:56:54.083969 | 2021-04-02T13:39:19 | 2021-04-02T13:39:19 | 345,760,903 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,090 | java | package com.revature.services;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.revature.exceptions.InvalidException;
import com.revature.exceptions.NoValidSessionException;
import com.revature.exceptions.UserNotFoundException;
import com.revature.models.Key;
import com.revature.models.User;
import com.revature.repositories.UserDAO;
@Service
public class ChkUsrSvc {
private String key = "projectzero";
private String permErrMsg = "Permission Denied";
@Autowired
private HttpServletRequest r;
@Autowired
private UserDAO userDAO;
public Key logdin() {
HttpSession session = r.getSession(false);
if (session == null || session.getAttribute(key) == null) {
throw new NoValidSessionException("User not logged in.");
}
return (Key) session.getAttribute(key);
}
public Key validateCustomer(Key k) {
return validate(k,"Customer");
}
public Key validateEmployee(Key k) {
return validate(k,"Employee");
}
public Key validateAdmin(Key k) {
return validate(k,"Admin");
}
private Key validate(Key k, String level) {
User u = userDAO.findById(k.getUid()).orElseThrow(
() -> new UserNotFoundException(String.format("SELECT: User %d does not exist.", k.getUid())));
if (level.equals("Customer")) {
if(!u.getAccesslevel().equals(level)&&!u.getAccesslevel().equals("Employee")&&!u.getAccesslevel().equals("Admin")) {
throw new InvalidException(permErrMsg);
}
} else if (level.equals("Employee")) {
if(!u.getAccesslevel().equals(level)&&!u.getAccesslevel().equals("Admin")) {
throw new InvalidException(permErrMsg);
}
} else if (level.equals("Admin")&&!u.getAccesslevel().equals(level)) {
throw new InvalidException(permErrMsg);
}
// if (!u.getAccesslevel().equals(level)&&!u.getAccesslevel().equals("Admin")) {
// throw new InvalidException("Permission Denied");
// }
return k;
}
}
| [
"[email protected]"
] | |
d6e3bce5056d962adc63f629fe1a957a7a5ab14c | c5f0b9a449b0e22ad87a05f2a4d7a010ed167cb3 | /3_implementation/src/net/hudup/core/logistic/ui/JRadioList.java | dab784df6029b221be1c37dd399cc4e832080814 | [
"MIT"
] | permissive | sunflowersoft/hudup-ext | 91bcd5b48d84ab33d6d8184e381d27d8f42315f7 | cb62d5d492a82f1ecc7bc28955a52e767837afd3 | refs/heads/master | 2023-08-03T12:25:02.578863 | 2023-07-21T08:23:52 | 2023-07-21T08:23:52 | 131,940,602 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,699 | java | /**
* HUDUP: A FRAMEWORK OF E-COMMERCIAL RECOMMENDATION ALGORITHMS
* (C) Copyright by Loc Nguyen's Academic Network
* Project homepage: hudup.locnguyen.net
* Email: [email protected]
* Phone: +84-975250362
*/
package net.hudup.core.logistic.ui;
import java.awt.GridLayout;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import net.hudup.core.Util;
import net.hudup.core.parser.TextParserUtil;
/**
* This class creates a graphic user interface (GUI) component as a list of radio buttons.
* <br>
* Modified by Loc Nguyen 2011.
*
* @author Someone on internet.
*
* @param <E> type of elements attached with radio buttons.
* @version 10.0
*/
public class JRadioList<E> extends JPanel {
/**
* Serial version UID for serializable class.
*/
private static final long serialVersionUID = 1L;
/**
* List of ratio entries. Each entry has a radio button {@link JRadioButton} and an attached object (attached element).
*/
protected List<Object[]> radioList = Util.newList();
/**
* Button group.
*/
protected ButtonGroup bg = new ButtonGroup();
/**
* Constructor with a specified list of attached object. Each object is attached with a radion button {@link JRadioButton}.
* @param listData specified list of attached object.
* @param listName name of this {@link JRadioList}.
*/
public JRadioList(List<E> listData, String listName) {
super();
setLayout(new GridLayout(0, 1));
if (listName == null || listName.isEmpty()) {
setBorder(BorderFactory.createEtchedBorder());
}
else {
setBorder(BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(), listName) );
}
setListData(listData);
}
/**
* Setting radio list with data list.
* @param listData data list.
*/
public void setListData(List<E> listData) {
for (Object[] pair : radioList) {
JRadioButton rb = (JRadioButton)pair[0];
bg.remove(rb);
remove(rb);
}
radioList.clear();
for (E e : listData) {
String text = e.toString();
JRadioButton rb = new JRadioButton(TextParserUtil.split(text, TextParserUtil.LINK_SEP, null).get(0));
bg.add(rb);
add(rb);
radioList.add(new Object[] { rb, e});
}
updateUI();
}
/**
* Getting the object attached with the selected radio button (selected item).
* @return object attached with the selected radio button (selected item).
*/
@SuppressWarnings("unchecked")
public E getSelectedItem() {
for (Object[] pair : radioList) {
JRadioButton rb = (JRadioButton)pair[0];
if (rb.isSelected())
return (E) pair[1];
}
return null;
}
}
| [
"[email protected]"
] | |
6f4253873212c4d1c344ddaa725b8e8d395a2911 | 4c8cdf42afd7b6a2c125e7412e6b82edfe1d7ac0 | /app/src/androidTest/java/REST.java | 7058d3cd92abbfa470d8ce2f9f0efde95118a455 | [] | no_license | Kjaersgaard/LegendsQuiz17 | 8ae2f5e6dd0c047a639e3fc4dad7f65ff6f059d3 | f18e4ac8dd345dc53a8cc9cad7b3a698c367688e | refs/heads/master | 2021-01-20T07:41:59.385119 | 2017-05-02T12:23:22 | 2017-05-02T12:23:22 | 90,030,535 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | /**
* Created by kjaer on 02/05/2017.
*/
public class REST {
}
| [
"Mads Thomsen"
] | Mads Thomsen |
e36cf503a5ec670fae2f872e0374c3979f0198e0 | 2f51035e9e29c8e65876e82babb7e288a4565ed6 | /3-Decorator/StarbuzzCoffeeWithSize/Mocha.java | b65636e304426e5f6d10f55ec864425b93cc78a8 | [] | no_license | rapirent/Java-Design-Patterns | 876e4c61f582850e8526aa0c91a34dee1d0ee18d | 43a3c9ca4253a6b157ef6a68cb6e3b133789e4d4 | refs/heads/master | 2023-04-18T13:25:17.537992 | 2021-05-03T05:19:26 | 2021-05-03T05:19:26 | 359,359,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 351 | java | package starbuzzCoffeeWithSize;
public class Mocha extends CondimentDecorator {
Beverage beverage;
public Mocha(Beverage beverage) {
this.beverage = beverage;
}
public String getDescription() {
return beverage.getDescription() + ", Mocha";
}
public double cost() {
return beverage.cost() + .20;
}
}
| [
"[email protected]"
] | |
aa490b1fe8ef1e43edb932271289ed0df9bac918 | b5bbae9508c1e4ecaf53ec3315676401831aa4fe | /src/main/java/com/wangab/dao/EasemobDAO.java | f67d4b580c91ef07b7fb17dd9380c333ef10e822 | [] | no_license | Wangab/WeStarService | b24449af5473a8be9f3c9217b52676f3d089f39b | 09d11d94f7be74c367724cc8e73ecea0aefe9531 | refs/heads/master | 2020-12-01T04:52:31.211859 | 2017-02-23T05:40:32 | 2017-02-23T05:40:32 | 67,204,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,414 | java | package com.wangab.dao;
import com.wangab.entity.po.EasemobPO;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Repository;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
/**
* Created by wanganbang on 11/26/16.
*/
@Repository("easemobDAO")
public class EasemobDAO {
@Value("${application.easemob.user-url}")
private String addUserUrl;
@Value("${application.easemob.token-url}")
private String token_url;
@Value("${application.easemob.client-id}")
private String client_id;
@Value("${application.easemob.client-secret}")
private String client_secret;
@Autowired
private RestTemplate restTemplate;
public String getToken() throws URISyntaxException {
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
Map<String, Object> params = new HashMap<String, Object>();
params.put("grant_type", "client_credentials");
params.put("client_id", client_id);
params.put("client_secret", client_secret);
JSONObject jsonObject = new JSONObject(params);
HttpEntity<String> formEnty = new HttpEntity<>(jsonObject.toString(), headers);
URI url = new URI(token_url);
String result = restTemplate.postForObject(url, formEnty, String.class);
String accessToken = new JSONObject(result).getString("access_token");
return accessToken;
}
public String addUser(EasemobPO easemobPO) throws URISyntaxException {
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
JSONObject jsonObject = easemobPO.toJsonObject();
HttpEntity<String> formEnty = new HttpEntity<>(jsonObject.toString(), headers);
URI url = new URI(addUserUrl);
String result = restTemplate.postForObject(url, formEnty, String.class);
return result;
}
public String getAddUserUrl() {
return addUserUrl;
}
public void setAddUserUrl(String addUserUrl) {
this.addUserUrl = addUserUrl;
}
public String getToken_url() {
return token_url;
}
public void setToken_url(String token_url) {
this.token_url = token_url;
}
public String getClient_id() {
return client_id;
}
public void setClient_id(String client_id) {
this.client_id = client_id;
}
public String getClient_secret() {
return client_secret;
}
public void setClient_secret(String client_secret) {
this.client_secret = client_secret;
}
public RestTemplate getRestTemplate() {
return restTemplate;
}
public void setRestTemplate(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
}
| [
"[email protected]"
] | |
110bc49fb88a3f3f09932af37676d224581fedc0 | 616d1fe14653c1720cfc57a8028291c9ad8dd890 | /TPMeningerie/src/Aigle.java | 58129ddc5a686f70c9ed3c7f8882482eba2c5196 | [] | no_license | Awonefr/TpAerosalm | 71666e1945b700ffffcf19613c1a2950209bc705 | af67b4ac611fdeeee00a90418b75ef6c45ac0bd6 | refs/heads/master | 2020-04-05T03:17:50.354139 | 2018-11-07T07:41:55 | 2018-11-07T07:41:55 | 156,509,038 | 0 | 0 | null | null | null | null | ISO-8859-2 | Java | false | false | 1,167 | java |
public class Aigle {
private String nomAigle;
private int ageAigle;
private String sexeAigle;
private int numEncloAigle;
private String contenueRepas;
private String heureRepas;
public String getNom() {
return this.nomAigle;
}
public int getAge() {
return this.ageAigle;
}
public String getsexe() {
return this.sexeAigle;
}
public int getNumEnclo() {
return this.numEncloAigle;
}
public String getContenueRepas() {
return this.contenueRepas;
}
public String getHeureRepas() {
return this.heureRepas;
}
public Aigle(String unNom,int unAge,String unSexe,int unNumEnclo,String unContenueRepas,String uneheureRepas) {
this.nomAigle=unNom;
this.ageAigle=unAge;
this.sexeAigle=unSexe;
this.numEncloAigle=unNumEnclo;
this.contenueRepas=unContenueRepas;
this.heureRepas=uneheureRepas;
}
public String toString() {
String mot="nom : "+nomAigle+"\n";
mot+="age : "+ageAigle+"\n";
mot+="sexe : "+sexeAigle+"\n";
mot+="numéro de l'enclo : "+numEncloAigle+"\n";
mot+="comptenu du repoas : "+contenueRepas+"\n";
mot+="heure du repas : "+heureRepas+"\n";
return mot;
}
}
| [
"[email protected]"
] | |
5ca1536281fe873df6b4a237e20a5e18b567d88f | 5a431fa70b4ba5b400ee13c27bd995adacc634d5 | /src/main/java/jp/furplag/time/Millis.java | af86394543695fb7322b53e2764f4d81b0ffcf32 | [
"Apache-2.0"
] | permissive | furplag/deamtiet | 4c6608591ef7f0145cd29729080612c377cf5ff5 | 8f615ac4ad1e8acecb568140b43c072eba3b9e2f | refs/heads/master | 2023-04-09T10:15:10.462744 | 2021-04-26T04:34:31 | 2021-04-26T04:34:31 | 112,684,457 | 0 | 0 | Apache-2.0 | 2021-04-26T04:30:20 | 2017-12-01T02:19:14 | Java | UTF-8 | Java | false | false | 4,174 | java | /**
* Copyright (C) 2017+ furplag (https://github.com/furplag)
*
* 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 jp.furplag.time;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
/**
* code snippets of timestamp .
*
* @author furplag
*
*/
public final class Millis {
/** the millis of one day. */
public static final long ofDay = 864_000_00L;
/** the epoch astronomical julian date of 1970-01-01T00:00:00.000Z. */
public static final double epoch = 2_440_587.5d;
/** the epoch millis of -4713-11-24T12:00:00.000Z. */
public static final long epochOfJulian = -210_866_760_000_000L;
/** the epoch modified julian date of 1858-11-17T00:00:00.000Z. */
public static final double epochOfModifiedJulian = 2_400_000.5d;
/** the epoch millis of 1582-10-15T00:00:00.000Z. */
public static final long epochOfGregorian = -12_219_292_800_000L;
/**
* calculates the epoch millis from {@link Millis#epoch epoch} .
*
* @param julianDate the astronomical julian date
* @return milliseconds of that have elapsed since {@link Millis#epoch epoch}
*/
public static long ofJulian(final double julianDate) {
return Double.valueOf((julianDate - Millis.epoch) * Millis.ofDay).longValue();
}
/**
* calculates the epoch millis from {@link Millis#epoch epoch} .
*
* @param modifiedJulianDate the modified julian date from {@link Millis#epochOfModifiedJulian}
* @return the epoch millis from {@link Millis#epoch epoch}
*/
public static long ofModifiedJulian(final double modifiedJulianDate) {
return ofJulian(modifiedJulianDate + Millis.epochOfModifiedJulian);
}
/**
* substitute for {@link Instant#ofEpochMilli(long)} .
*
* @param epochMilli the epoch millis from {@link Millis#epoch epoch}
* @return an {@link Instant} represented by specified epoch milliseconds from {@link Millis#epoch epoch}
*/
public static Instant toInstant(final long epochMilli) {
return Instant.ofEpochMilli(epochMilli);
}
/**
* calculates the days that have elapsed since {@link Millis#epoch epoch} .
*
* @param epochMilli the epoch millis from {@link Millis#epoch epoch}
* @return the days that have elapsed since {@link Millis#epoch epoch}
*/
public static long toEpochDay(final long epochMilli) {
return epochMilli / Millis.ofDay;
}
/**
* calculates the seconds that have elapsed since {@link Millis#epoch epoch} .
*
* @param epochMilli the epoch millis from {@link Millis#epoch epoch}
* @return the seconds that have elapsed since {@link Millis#epoch epoch}
*/
public static long toEpochSecond(final long epochMilli) {
return epochMilli / 1000L;
}
/**
* shorthand for {@code ZonedDateTime.ofInstant(Millis.toInstant(epochMilli), ZoneId.systemDefault()).toLocalDateTime()} .
*
* @param epochMilli the epoch millis from {@link Millis#epoch epoch}
* @return {@link LocalDateTime}
*/
public static LocalDateTime toLocalDateTime(final long epochMilli) {
return Deamtiet.toLocalDateTime(toInstant(epochMilli), null);
}
/**
* shorthand for {@code ZonedDateTime.ofInstant(Millis.toInstant(epochMilli), ZoneId.systemDefault()).toLocalDateTime()} .
*
* @param epochMilli the epoch millis from {@link Millis#epoch epoch}
* @param zoneId {@link ZoneId}
* @return {@link LocalDateTime}
*/
public static LocalDateTime toLocalDateTime(final long epochMilli, final ZoneId zoneId) {
return Deamtiet.toLocalDateTime(toInstant(epochMilli), zoneId);
}
/**
* Millis instances should NOT be constructed in standard programming .
*/
private Millis() {}
}
| [
"[email protected]"
] | |
3ebd10b5df255760dd8df8cee6102cce7051fbee | 779374d3536940ab5e815266ee801d9c1ddc4e22 | /flare-java/src/main/java/org/nting/flare/java/StraightPathPoint.java | a1b606eb285b9645514991762954ae26be3bf252 | [] | no_license | zsoltborcsok/flare | 5a34e8626836db60be20eaa7ae50a5573fa581ea | 2a77134e2ec42bc218a358c3090eb16ea0e640f9 | refs/heads/master | 2022-12-25T17:14:19.078311 | 2020-10-04T11:59:26 | 2020-10-04T13:51:56 | 263,033,422 | 0 | 0 | null | 2020-10-13T21:54:31 | 2020-05-11T12:17:25 | Java | UTF-8 | Java | false | false | 2,258 | java | package org.nting.flare.java;
import org.nting.flare.java.maths.Mat2D;
import org.nting.flare.java.maths.Vec2D;
public class StraightPathPoint extends PathPoint {
public float radius = 0.0f;
public StraightPathPoint() {
super(PointType.straight);
}
public StraightPathPoint(Vec2D translation) {
super(PointType.straight);
_translation = translation;
}
public StraightPathPoint(Vec2D translation, float radius) {
super(PointType.straight);
_translation = translation;
this.radius = radius;
}
public StraightPathPoint(StraightPathPoint from) {
super(from);
radius = from.radius;
}
@Override
public PathPoint makeInstance() {
return new StraightPathPoint(this);
}
@Override
public int readPoint(StreamReader reader, boolean isConnectedToBones) {
radius = reader.readFloat32("radius");
if (isConnectedToBones) {
return 8;
}
return 0;
}
@Override
public PathPoint skin(Mat2D world, float[] bones) {
StraightPathPoint point = new StraightPathPoint();
point.radius = radius; // Cascade notation (..) was used
float px = world.values()[0] * translation().values()[0] + world.values()[2] * translation().values()[1]
+ world.values()[4];
float py = world.values()[1] * translation().values()[0] + world.values()[3] * translation().values()[1]
+ world.values()[5];
float a = 0.0f, b = 0.0f, c = 0.0f, d = 0.0f, e = 0.0f, f = 0.0f;
for (int i = 0; i < 4; i++) {
int boneIndex = (int) Math.floor(_weights[i]);
float weight = _weights[i + 4];
if (weight > 0) {
int bb = boneIndex * 6;
a += bones[bb] * weight;
b += bones[bb + 1] * weight;
c += bones[bb + 2] * weight;
d += bones[bb + 3] * weight;
e += bones[bb + 4] * weight;
f += bones[bb + 5] * weight;
}
}
Vec2D pos = point.translation();
pos.values()[0] = a * px + c * py + e;
pos.values()[1] = b * px + d * py + f;
return point;
}
}
| [
"[email protected]"
] | |
c15ee419231e3e208efe3a173728278523255251 | 3c7e596b471259d01d30e3013efa82eb340bc9ad | /src/com/java/diretory/VisitAllDirsAndFiles.java | 5ea45d4240704d0bc313172aaa9286ecac78e9e0 | [] | no_license | selenium2015/Java_Example | 00e1b100de1a31d032b84869fae3c5747c0ec5b4 | a70c7dd4f5b5df66d75f852650c193439f247e72 | refs/heads/master | 2021-01-19T03:25:18.485773 | 2016-07-27T09:09:40 | 2016-07-27T09:09:40 | 53,017,221 | 1 | 0 | null | null | null | null | GB18030 | Java | false | false | 700 | java | package com.java.diretory;
import java.io.File;
/*
* 遍历目录和目录下的文件
* 使用 File 类的 dir.isDirectory() 和 dir.list() 方法来遍历目录
*
*/
public class VisitAllDirsAndFiles {
public static void main(String[] argv) throws Exception {
System.out.println("遍历目录");
File dir = new File("E:/Appium"); // 要遍历的目录
visitAllDirsAndFiles(dir);
}
public static void visitAllDirsAndFiles(File dir) {
System.out.println(dir);
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
visitAllDirsAndFiles(new File(dir, children[i]));//递归调用
}
}
}
}
| [
"[email protected]"
] | |
066d81741fa283091c6077675621c18db2bdfe4d | 7257d88388b437d9c0ca672cdee99489228abc1d | /src/main/java/com/javaex/controller/UserController.java | 03050c4193a447b6f54aa4c41ed7c75a3bd4bd3f | [] | no_license | thunderkyg/jblog | 407016374697a9e00256a83f5989d8512c2e6820 | 140cf17c8ea44c50cb494a163905b8b4ece12a37 | refs/heads/master | 2023-07-13T07:15:13.422028 | 2021-08-12T06:52:10 | 2021-08-12T06:52:10 | 394,178,239 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,705 | java | package com.javaex.controller;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.javaex.service.UserService;
import com.javaex.vo.UserVo;
@Controller
@RequestMapping(value = "/user", method = { RequestMethod.GET, RequestMethod.POST })
public class UserController {
// AutoWired
@Autowired
private UserService userService;
// LoginForm
@RequestMapping(value = "/loginForm", method = { RequestMethod.GET, RequestMethod.POST })
public String loginForm() {
System.out.println("[UserController.loginForm()]");
return "user/loginForm";
}
// Login
@RequestMapping(value = "/login", method = { RequestMethod.GET, RequestMethod.POST })
public String login(@ModelAttribute UserVo userVo, HttpSession session) {
System.out.println("[UserController.login()]");
UserVo authUser = userService.getUser(userVo);
System.out.println(authUser);
if (authUser != null) {
System.out.println("로그인 성공함");
session.setAttribute("authUser", authUser);
return "/main/index";
} else {
System.out.println("로그인 실패함");
return "redirect:/user/loginForm?result=fail";
}
}
// Logout
@RequestMapping(value = "/logout", method = { RequestMethod.GET, RequestMethod.POST })
public String logout(HttpSession session) {
//Remove Session
session.removeAttribute("authUser");
session.invalidate();
return "redirect:/";
}
// JoinForm
@RequestMapping(value = "/joinForm", method = { RequestMethod.GET, RequestMethod.POST })
public String joinForm() {
System.out.println("[UserController.joinForm()]");
return "user/joinForm";
}
// Join
@RequestMapping(value = "/join", method = { RequestMethod.GET, RequestMethod.POST })
public String join(@ModelAttribute UserVo userVo) {
System.out.println("[UserController.join()]");
System.out.println(userVo);
userService.join(userVo);
return "user/joinSuccess";
}
//Ajax(ID 중복 체크)
@ResponseBody
@RequestMapping(value = "/checkId", method = { RequestMethod.GET, RequestMethod.POST })
public boolean checkId(String id) {
System.out.println("[UserController.checkId()]");
System.out.println(id);
return userService.checkId(id);
}
}
| [
"[email protected]"
] | |
2cc7ff876b0c3621caecedd047772daac2d6590d | e7e497b20442a4220296dea1550091a457df5a38 | /main_project/socialgraph/newrecommendupdator/src/main/java/com/renren/xce/socialgraph/builder/BuilderFactory.java | f2e98717ec678ef9f31d50f463b373fa2aab9995 | [] | no_license | gunner14/old_rr_code | cf17a2dedf8dfcdcf441d49139adaadc770c0eea | bb047dc88fa7243ded61d840af0f8bad22d68dee | refs/heads/master | 2021-01-17T18:23:28.154228 | 2013-12-02T23:45:33 | 2013-12-02T23:45:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,736 | java | package com.renren.xce.socialgraph.builder;
import com.renren.xce.socialgraph.common.DataBuilder;
import com.renren.xce.socialgraph.updator.CreateRecommendDataThread;
/**
* BuilderFactory used to create different builder by type
* @author zhangnan
* @email [email protected]
*/
public class BuilderFactory {
public static DataBuilder createBuilder(String type) {
if (type.equals(CreateRecommendDataThread.COMMON_FRIENDS)) {
return new CommonFriendsBuilder();
} else if (type.equals(CreateRecommendDataThread.FREINDS_CLUSTER)) {
return new FriendClusterBuilder();
} else if (type.equals(CreateRecommendDataThread.PAGE)) {
return new PageBuilder();
} else if (type.equals(CreateRecommendDataThread.PAGECOLLEGE)) {
return new PageCollegeBuilder();
} else if (type.equals(CreateRecommendDataThread.INFO)) {
return new SameInfoFriendsBuilder();
} else if (type.equals(CreateRecommendDataThread.RVIDEO)) {
return new VideoRecommendDataBuilder();
} else if (type.equals(CreateRecommendDataThread.RBLOG)) {
return new BlogRecommendDataBuilder();
} else if (type.equals(CreateRecommendDataThread.RSITE)) {
return new RcdSiteBuilder();
} else if (type.equals(CreateRecommendDataThread.RAPP)) {
return new AppRecommendDataBuilder();
} else if (type.equals(CreateRecommendDataThread.RFOF)) {
return new RcdFoFBuilder();
} else if (type.equals(CreateRecommendDataThread.RDESK)) {
return new DeskRecommendDataBuilder();
} else if (type.equalsIgnoreCase(CreateRecommendDataThread.RFORUM)) {
return new ForumRecommendDataBuilder();
}else if(type.equalsIgnoreCase(CreateRecommendDataThread.RSHOPMASTER)) {
return new ShoppingMasterBuilder();
}
return null;
}
}
| [
"[email protected]"
] | |
b369e550ba34c8f0f5200be9655dd4d4a529a52d | 28bd4a04fad92ed3d988bd92bb8a64f710aeea8f | /src/RemoveDuplicateNumbers.java | 8cb1bae67c60bc72261225d3acc324a4dcc24f78 | [] | no_license | wbwmartin/OnePiece | d0826d0dc3e2d982c6b3f1ac428c7332089a6597 | 769599e8b0851774c25cd621289eaa2363533efb | refs/heads/master | 2021-01-16T18:56:15.933101 | 2018-02-03T05:34:23 | 2018-02-03T05:34:23 | 100,130,181 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,800 | java | import java.util.Stack;
//Given a string which contains only lowercase letters, remove duplicate letters so that every letter
// appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
//
// Example:
// Given "bcabc"
// Return "abc"
//
// Given "cbacdcbc"
// Return "acdb"
public class RemoveDuplicateNumbers {
// http://bookshadow.com/weblog/2015/12/09/leetcode-remove-duplicate-letters/
public static String removeDuplicateLetters(String s) {
if (s == null || s.length() == 0) {
return s;
}
int[] count = new int[26];
boolean[] visited = new boolean[26];
for (int i = 1; i < s.length(); i++) {
count[s.charAt(i) - 'a']++;
}
Stack<Character> stack = new Stack<>();
stack.push(s.charAt(0));
visited[s.charAt(0) - 'a'] = true;
for (int i = 1; i < s.length(); i++) {
count[s.charAt(i) - 'a']--;
if (visited[s.charAt(i) - 'a']) { // important
continue;
}
while (!stack.empty() && stack.peek() > s.charAt(i) && count[stack.peek() - 'a'] > 0) {
visited[stack.pop() - 'a'] = false;
}
stack.push(s.charAt(i));
visited[s.charAt(i) - 'a'] = true;
}
StringBuilder sb = new StringBuilder();
while (!stack.empty()) {
sb.append(stack.pop());
}
return sb.reverse().toString();
}
public static void main(String[] args) {
String s1 = "bcabc";
String s2 = "cbacdcbc";
System.out.println(removeDuplicateLetters(s1)); // abc
System.out.println(removeDuplicateLetters(s2)); // acdb
}
}
| [
"[email protected]"
] | |
10ff37c0ba23b7356e2820d58b9922db967d7923 | 0e13979e33053587c002add6dbebbc2fcaaa148d | /src/main/java/com/superops/tickets/model/entity/MovieTicketId.java | aaf36474e829eee8c2565e2ea176822a5384c7fa | [] | no_license | atul46/seat-resev | 7eb0e0d426c8ace12ed42c96e65f6f5f829dd959 | 5fb06527e116a74fde7838c517bdc88882a5c328 | refs/heads/main | 2023-03-21T22:43:43.461936 | 2021-03-15T16:49:37 | 2021-03-15T16:49:37 | 348,047,788 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 557 | java | package com.superops.tickets.model.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MovieTicketId implements Serializable {
@Id
@Column(name = "movie_id")
private String movieId;
@Id
@Column(name="theater_id")
private String theaterId;
@Id
@Column(name="user_id")
private String userId;
}
| [
"[email protected]"
] | |
596494098dc95fbeb7f99ba501ce37b8649be5a4 | 12e4cf46505c426659a78fc6225db8ef3e75c30f | /aula2308b/src/aula2308b.java | c73b84df27aa3428ba5659c2a0ebe233ad5a90a5 | [] | no_license | Voodevilish/AulasJava | 7402f076ee50f3b8a6f3eaa8058d69b41e6c0a17 | e8179926909f8490bea596f09af758dbd92ab928 | refs/heads/master | 2020-03-27T15:54:21.464398 | 2018-09-19T13:09:35 | 2018-09-19T13:09:35 | 146,746,562 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 549 | java | public class aula2308b {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int opc = 44;
switch(opc){
case 1:
System.out.println("Escolheu 1");
break;
case 2:
System.out.println("Escolheu 2");
break;
case 3:
System.out.println("Escolheu 3");
break;
default:
System.out.println("opcao invalida");
}
}
} | [
"[email protected]"
] | |
ec35d03700c1a1e912a714c55a28749d255902e1 | 895d8ce51b68f16966338558b5eb8ee7ac29e6b2 | /app/src/main/java/slogup/ssing/Network/SsingClientHelper.java | fba672737561c14f5ed060c95ad0372106a65ddc | [
"MIT"
] | permissive | sngsng/ssing | 067e50aa50d7a14f977a1a577316715706b4b484 | 6acee2c391bb1eb0213ff26258bf7d47e7bd4944 | refs/heads/master | 2020-06-21T02:40:40.514383 | 2016-12-09T00:53:35 | 2016-12-09T00:53:35 | 74,810,304 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,549 | java | package slogup.ssing.Network;
import android.content.Context;
import android.util.Log;
import com.slogup.sgcore.network.CoreError;
import com.slogup.sgcore.network.RestClient;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by sngjoong on 2016. 12. 7..
*/
public class SsingClientHelper {
private static final String LOG_TAG = SsingClientHelper.class.getSimpleName();
public static void vote(Context context, int postId, String tagName, final RestClient.RestListener listener) {
JSONObject params = new JSONObject();
try {
params.put(SsingAPIMeta.Vote.Request.POST_ID, postId);
params.put(SsingAPIMeta.Vote.Request.TAG_NAME, tagName);
} catch (JSONException e) {
e.printStackTrace();
}
RestClient restClient = new RestClient(context);
restClient.request(RestClient.Method.POST, SsingAPIMeta.Vote.URL, params, new RestClient.RestListener() {
@Override
public void onBefore() {
listener.onBefore();
}
@Override
public void onSuccess(Object response) {
Log.i(LOG_TAG, response.toString());
listener.onSuccess(response);
}
@Override
public void onFail(CoreError error) {
listener.onFail(error);
}
@Override
public void onError(CoreError error) {
listener.onError(error);
}
});
}
}
| [
"[email protected]"
] | |
fbd9b6d97a8c1a9e42423f8b3a6e8f59220b30ac | f2771bb09905bfd96d75bc8eaa10bf8a9d8767ec | /NewChessGame/src/newchessgame/Applet.java | 74cb44257a425ff19c5709ed4fbd34510150be7b | [] | no_license | jefferickso/New-Chess-Game | b132db67a3d44b406d55c90395a0ef4c675cc005 | 7269a6279c7773c5412d2359a7a86caf1308536f | refs/heads/master | 2020-04-02T13:43:38.403183 | 2018-10-24T11:33:50 | 2018-10-24T11:33:50 | 154,494,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,016 | 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 newchessgame;
import java.util.logging.Logger;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
/**
*
* @author JLErickso
*/
public class Applet extends JApplet implements GameListener{
private static final Logger LOG =
Logger.getLogger("com.nullprogram.chess.ChessApplet");
@Override
public void init() {
try {
String lnf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(lnf);
} catch (IllegalAccessException e) {
LOG.warning("Failed to access 'Look and Feel'");
} catch (InstantiationException e) {
LOG.warning("Failed to instantiate 'Look and Feel'");
} catch (ClassNotFoundException e) {
LOG.warning("Failed to find 'Look and Feel'");
} catch (UnsupportedLookAndFeelException e) {
LOG.warning("Failed to set 'Look and Feel'");
}
StandardBoard board = new StandardBoard();
Panel panel = new Panel(board);
add(panel);
Rules game = new Rules(board);
game.seat(panel, new Minimax(game));
game.addGameListener(this);
game.addGameListener(panel);
game.start();
}
@Override
public void gameEvent(final GameEvent e) {
if (e.getGame().isDone()) {
String message;
Piece.Side winner = e.getGame().getWinner();
if (winner == Piece.Side.WHITE) {
message = "White wins";
} else if (winner == Piece.Side.BLACK) {
message = "Black wins";
} else {
message = "Stalemate";
}
JOptionPane.showMessageDialog(null, message);
}
}
}
| [
"[email protected]"
] | |
07c86f5533ab4780bfb341c4aefe860312892bee | ccc44441e962851ac5ab4822aea924214271c810 | /src/main/java/com/jkm/service/impl/DeleteHistoryServiceImpl.java | 9a2a6ca6305d40e5f16333cfd3f4ed06be7e7f81 | [] | no_license | guoling1/QB_Ticket | 5a7a17fef00b6d2e2ff21ef8ebce68af2caa6600 | 8067af1da2afc3bfb0f680455a6c9b03abfb43b0 | refs/heads/master | 2021-08-14T08:24:43.575998 | 2016-12-23T06:31:06 | 2016-12-23T06:31:06 | 110,777,509 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package com.jkm.service.impl;
import com.jkm.dao.DeleteHistoryDao;
import com.jkm.service.DeleteHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by zhangbin on 2016/11/15.
*/
@Service
public class DeleteHistoryServiceImpl implements DeleteHistoryService {
@Autowired
private DeleteHistoryDao deleteHistoryDao;
@Override
public void delete(String uid) {
deleteHistoryDao.delete(uid);
}
}
| [
"[email protected]"
] | |
46aca9f1699d83e16a670adbad00318f2b4a5008 | fb444d7cbeecdb22f5a5735f2ba4bf6ad71b95c6 | /app.backend/src/main/java/de/jdynameta/jdy/spring/app/config/RestResponseEntityExceptionHandler.java | 5b02b06c40ae736f0818f865186933689ceedac3 | [] | no_license | schnurlei/jdy | 006cad4a79f59c2175d27b5429aeb5a238d314c9 | 8c96bdc7c7530010e67fea357971ef4bac88d221 | refs/heads/master | 2020-03-28T17:24:49.343694 | 2019-09-13T13:44:07 | 2019-09-13T13:44:07 | 148,785,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,693 | java | package de.jdynameta.jdy.spring.app.config;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.validation.ConstraintViolationException;
import java.sql.SQLException;
import java.time.LocalDateTime;
@RestControllerAdvice
public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(RestResponseEntityExceptionHandler.class);
@ExceptionHandler(value = { ConstraintViolationException.class})
public ResponseEntity<Object> handleConstraintViolationException(final ConstraintViolationException ex, final WebRequest request) {
LOG.error("Exception handled by RestResponseEntityExceptionHandler", ex);
final CustomErrorResponse response = new CustomErrorResponse("SQLException", ex.getLocalizedMessage());
return this.handleExceptionInternal(ex, response,
new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
}
@ExceptionHandler(value = { TransactionSystemException.class })
public ResponseEntity<Object> handleTransactionSystemException(final TransactionSystemException ex, final WebRequest request) {
LOG.error("Exception handled by RestResponseEntityExceptionHandler", ex);
final CustomErrorResponse response = new CustomErrorResponse("TransactionSystemException", ex.getMostSpecificCause().getLocalizedMessage());
return this.handleExceptionInternal(ex, response,
new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
}
@ExceptionHandler(value = { SQLException.class })
public ResponseEntity<Object> handleSQLException(final SQLException ex, final WebRequest request) {
LOG.error("Exception handled by RestResponseEntityExceptionHandler", ex);
final CustomErrorResponse response = new CustomErrorResponse("SQLException", ex.getLocalizedMessage());
return this.handleExceptionInternal(ex, response,
new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); }
@ExceptionHandler(value = { DataIntegrityViolationException.class })
public ResponseEntity<Object> handleDataIntegrityViolationException(final DataIntegrityViolationException ex, final WebRequest request) {
LOG.error("Exception handled by RestResponseEntityExceptionHandler", ex);
final CustomErrorResponse response = new CustomErrorResponse("DataIntegrityViolationException", ex.getMostSpecificCause().getLocalizedMessage());
return this.handleExceptionInternal(ex, response,
new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request);
}
public static class CustomErrorResponse {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss")
private final LocalDateTime timestamp;
private final String error;
private final String message;
public CustomErrorResponse(final String error, final String message) {
this.timestamp = LocalDateTime.now();
this.error = error;
this.message = message;
}
public LocalDateTime getTimestamp() {
return this.timestamp;
}
public String getError() {
return this.error;
}
public String getMessage() {
return this.message;
}
}
}
| [
"[email protected]"
] | |
4037a8857e2ab0510a7c1db293ee3cfbd250615b | d0521d7fcf2d67db2b3d1cf28b4627322eb71e8f | /ACARI - Project/src/model/TiposDespesas.java | db34905aedfe62412fd4ce3afac2f64c11abe570 | [] | no_license | ruan113/ACARI-APP | 612539e952b2b60b8667d2d0672ea44d576ce356 | 49362519a6fad3a3ad634666423a72c1575ae8dc | refs/heads/master | 2020-03-25T07:16:39.793600 | 2018-11-23T21:33:15 | 2018-11-23T21:33:15 | 143,551,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,135 | java | package model;
// Generated 08/08/2018 15:24:22 by Hibernate Tools 4.3.1
import java.util.HashSet;
import java.util.Set;
/**
* TiposDespesas generated by hbm2java
*/
public class TiposDespesas implements java.io.Serializable {
private int idTipo;
private String tituloTipo;
private Set despesases = new HashSet(0);
public TiposDespesas() {
}
public TiposDespesas(int idTipo) {
this.idTipo = idTipo;
}
public TiposDespesas(int idTipo, String tituloTipo, Set despesases) {
this.idTipo = idTipo;
this.tituloTipo = tituloTipo;
this.despesases = despesases;
}
public int getIdTipo() {
return this.idTipo;
}
public void setIdTipo(int idTipo) {
this.idTipo = idTipo;
}
public String getTituloTipo() {
return this.tituloTipo;
}
public void setTituloTipo(String tituloTipo) {
this.tituloTipo = tituloTipo;
}
public Set getDespesases() {
return this.despesases;
}
public void setDespesases(Set despesases) {
this.despesases = despesases;
}
}
| [
"[email protected]"
] | |
95a5649789a2682fe7d4271c33a4d8c1fec688fc | e99f78a1d7d244a8def43ca73d570f3a1b0c435f | /PIJReview/src/theappbusiness/priorityqueue/Student.java | f53b604cbff281b15612dfe8e197a719e0c8b477 | [] | no_license | BBK-PiJ-2015-10/Ongoing | 5e153280a7772b1ec6ad5df02ec2cf8115ec272d | 3a6099079c5413d864c8b3ec435f14660d6fad5e | refs/heads/master | 2021-01-13T11:59:36.191993 | 2017-06-29T18:35:31 | 2017-06-29T18:35:31 | 77,915,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,211 | java | package theappbusiness.priorityqueue;
public class Student implements Comparable {
private String name;
private Double gpa;
private Integer token;
public double getGpa() {
return gpa;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getToken() {
return token;
}
public void setToken(Integer token) {
this.token = token;
}
public void setGpa(Double gpa) {
this.gpa = gpa;
}
@Override
public int compareTo(Object other) {
Student otherStudent = (Student) other;
if(!this.gpa.equals(otherStudent.gpa)){
return -(this.gpa.compareTo(otherStudent.gpa));
}
else if (!this.name.equals(otherStudent.name)){
int result = this.name.compareTo(otherStudent.name);
if (result>0){
return 1;
}
else {
return -1;
}
}
else if (this.token!=otherStudent.token){
return (this.token.compareTo(otherStudent.token));
}
return 0;
}
public Student(String name, Double gpa, Integer token) {
this.gpa = gpa;
this.name = name;
this.token = token;
}
public Student(){
}
@Override
public String toString(){
return this.name + " " +this.gpa + " " + this.token;
}
}
| [
"[email protected]"
] | |
b868b3c4611f4663a46625bce575c8d01ed9dfa5 | 1cfdd8cad18976c3b81b703b96a67c6f7fc67882 | /oriented_object_model_practise/Ming_to_eat/src/main/java/com/ayl/gupao/version_1/preparemeal/PrepareMealFactory.java | 27323f37a4e0459382a979b359aaa0442193a0d0 | [] | no_license | brucewin6688/gupao-homework | a557ccb0383373ed0579946a14ee1b3d6dfc0482 | dee0de3cccecebeef22ed9b03c6bfa5aaf783b1e | refs/heads/master | 2020-04-19T05:08:23.907761 | 2018-04-14T17:49:59 | 2018-04-14T17:49:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | package com.ayl.gupao.version_1.preparemeal;
import com.ayl.gupao.version_1.entity.Meal;
/**
* @author AYL 2018/4/7 16:12
*/
public interface PrepareMealFactory {
Meal prepareMeal(String...dishes);
}
| [
"[email protected]"
] | |
da274f9ef50d15cd67d198da745e636b4063e725 | 8602cf1c87b1fb3ca1875df11efbe1573170c861 | /NamingThread.java | 09bad2a51c3c73fc31db537ba36eefe980cf0ad7 | [] | no_license | sunu09/Thread-Practice-Try-Catch | 7e822dd10fab8abffc98df74e9db8b697c5b721d | e3ce8bf9360ba4ce74fff18b9d3f0f6db3a98aa4 | refs/heads/main | 2023-04-06T13:52:15.348597 | 2021-04-12T02:46:05 | 2021-04-12T02:46:05 | 355,982,397 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,416 | java | package com.tts;
// if you use,
// System.out.println(t1.getName());
// System.out.println(t2.getName()); --- it will give name of thread as thread 0, thread 1.
// you can give name to thread by using (t1.setName("Hi Thread").
// or can write down at the end of code by adding comma before semi-colon.
public class NamingThread {
public static void main(String[] args) throws Exception {
Thread t1 = new Thread(() ->{
for (int i=0; i<5; i++) {
System.out.println("Hi");
try {
Thread.sleep(500);
} catch (Exception e) {
}
}
}, "Hi Thread");
Thread t2 = new Thread(() ->{
for (int i=0; i<5; i++) {
System.out.println("Hello");
try {
Thread.sleep(500);
} catch (Exception e) {
}
}
}, "Hello Thread");
// t1.setName("Hi Thread");
// t2.setName("Hello Thread");
System.out.println(t1.getName());
System.out.println(t2.getName());
t1.start();
try{Thread.sleep(50);} catch(Exception e){}
t2.start();
// System.out.println(t1.isAlive());
t1.join();
t2.join();
System.out.println(t2.isAlive());
System.out.println("Bye");
}
}
| [
"[email protected]"
] | |
9fbbdcb81985c3dc61e41c5e5fa1a0e7531687fa | 12c0e200d81fcaa44757e35d922543a29f520374 | /CrawlerExample/src/imagecrawler/ImageCrawlController.java | 6c7e71f9c51283290def48bf880b394ad8f22579 | [] | no_license | tumaolin94/my_backup | 77234b7129bed79c26c0bfcc6326e82238403489 | 4ac92f94ebb76c2aefb388e8366c44ef7654b1de | refs/heads/master | 2020-03-28T04:50:53.800844 | 2018-09-06T22:27:24 | 2018-09-06T22:27:24 | 147,740,422 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,787 | java | package imagecrawler;
/**
* 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.
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import edu.uci.ics.crawler4j.crawler.CrawlConfig;
import edu.uci.ics.crawler4j.crawler.CrawlController;
import edu.uci.ics.crawler4j.fetcher.PageFetcher;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtConfig;
import edu.uci.ics.crawler4j.robotstxt.RobotstxtServer;
/**
* @author Yasser Ganjisaffar
*/
public class ImageCrawlController {
private static final Logger logger = LoggerFactory.getLogger(ImageCrawlController.class);
public static void main(String[] args) throws Exception {
// if (args.length < 3) {
// logger.info("Needed parameters: ");
// logger.info("\t rootFolder (it will contain intermediate crawl data)");
// logger.info("\t numberOfCrawlers (number of concurrent threads)");
// logger.info("\t storageFolder (a folder for storing downloaded images)");
// return;
// }
String rootFolder = "crawl/image";
int numberOfCrawlers = 5;
String storageFolder = "crawl/image/storage";
CrawlConfig config = new CrawlConfig();
config.setCrawlStorageFolder(rootFolder);
/*
* Since images are binary content, we need to set this parameter to
* true to make sure they are included in the crawl.
*/
config.setIncludeBinaryContentInCrawling(true);
String[] crawlDomains = {"https://uci.edu/"};
PageFetcher pageFetcher = new PageFetcher(config);
RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);
for (String domain : crawlDomains) {
controller.addSeed(domain);
}
ImageCrawler.configure(crawlDomains, storageFolder);
controller.start(ImageCrawler.class, numberOfCrawlers);
}
}
| [
"[email protected]"
] | |
696525d8bd2dc5d1f1d433220d7633c0f29d9356 | 61bfe36b403683c715b9edb4d4f5d01f03960213 | /sources/androidx/interpolator/view/animation/LookupTableInterpolator.java | 4763b93e42b6a8d28bf2fb194be27f7f3af4b63b | [] | no_license | tusharkeshav/Notification_hijacker_malware | 959ccac34dcf069b1e461bd308dac9cdfd623c85 | 33322a71bb6108b35aa036642b80264139826ed2 | refs/heads/main | 2023-04-07T04:40:37.072404 | 2021-04-19T12:29:53 | 2021-04-19T12:29:53 | 359,343,331 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 782 | java | package androidx.interpolator.view.animation;
import android.view.animation.Interpolator;
abstract class LookupTableInterpolator implements Interpolator {
private final float mStepSize = (1.0f / ((float) (this.mValues.length - 1)));
private final float[] mValues;
protected LookupTableInterpolator(float[] fArr) {
this.mValues = fArr;
}
public float getInterpolation(float f) {
if (f >= 1.0f) {
return 1.0f;
}
if (f <= 0.0f) {
return 0.0f;
}
int min = Math.min((int) (((float) (this.mValues.length - 1)) * f), this.mValues.length - 2);
return this.mValues[min] + (((f - (((float) min) * this.mStepSize)) / this.mStepSize) * (this.mValues[min + 1] - this.mValues[min]));
}
}
| [
"[email protected]"
] | |
cbcf98c1d4c81507ea40095820bae6a9b7d353bb | 17a23b6e1f37ed70ed4896abdacac1cc004b4221 | /jlight-web/src/main/java/com/lew/jlight/web/exception/handler/GlobalExceptionHandler.java | 35f16f7c48ddf5481341d09c64dd1b2c426fd3a0 | [
"Apache-2.0"
] | permissive | HulkHou/Jlight | 28457f92b8bad508272d1d25def1d4a05de37811 | cbd67e4c0ab62d5e33a4f414b29d4b005b0174cf | refs/heads/master | 2021-01-11T20:19:42.850387 | 2017-05-02T02:21:53 | 2017-05-02T02:21:53 | 79,090,926 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,442 | java | package com.lew.jlight.web.exception.handler;
import com.lew.jlight.core.Response;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice()
public class GlobalExceptionHandler {
@ExceptionHandler(RuntimeException.class)
@ResponseBody
public Response exceptionHandler(RuntimeException e) {
Response resp = new Response();
resp.setCode(1);
String errorMsg = e.getMessage();
if(errorMsg.indexOf(":")>-1){
errorMsg = errorMsg.split(":")[1];
}
resp.setMsg(errorMsg);
return resp;
}
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return (container -> {
ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
container.addErrorPages(error401Page, error404Page, error500Page);
});
}
}
| [
"[email protected]"
] | |
d92b4104d51462dcc141197de76caf9fdf0b2aca | d68148558ff58b680a3e67383862b159a7dc908f | /app/src/main/java/nichele/meusgastos/SectionedRecyclerView/RecyclerViewType.java | 5a7d062f044ce59b6560dde1d39904fca8168b87 | [] | no_license | viniciuscn/MeusGastos | 73917cd46512dbc859f5597a3479585805173c85 | 1506d3d3fa1d7cd3d1d393283bbe7eea557f3882 | refs/heads/master | 2020-07-31T17:09:26.550847 | 2020-02-06T19:25:29 | 2020-02-06T19:25:29 | 210,686,499 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 125 | java | package nichele.meusgastos.SectionedRecyclerView;
public enum RecyclerViewType {
LINEAR_VERTICAL,LINEAR_HORIZONTAL,GRID;
}
| [
"[email protected]"
] | |
4422522fa3a12e66badaf40d7b745ccfaece600f | 130f321a23dee784274f861c352ae2bf19cf4aeb | /src/number/MultipleWords.java | ff6afc4e2575a1390aef471ab05894ad4c9cc230 | [] | no_license | venerakadyr/Java_Project_B14 | ef2da72c7f25b56639ce253f1a8d1ebd8a07f17e | f4c90b6e53ee07c3a71c8104016abbf800c398e2 | refs/heads/master | 2022-09-17T20:05:51.176889 | 2020-05-27T19:52:22 | 2020-05-27T19:52:22 | 220,682,456 | 0 | 0 | null | 2020-05-27T19:52:23 | 2019-11-09T18:03:12 | Java | UTF-8 | Java | false | false | 697 | java | package number;
public class MultipleWords {
public static void main(String[] args) {
// 9) Given a String of: "knife", "wooden spoons", "plates", "cups",
// "forks", "pan", "pot", "trash can”, “fridge”, “dish washer”
//Go through the array and print the value if there is multiple words.
String [] words = {"knife", "wooden spoons", " plates", "cups", "forks", "pan", "pot", "trash can", "fridge", "dish washer"};
for(int i=0; i < words.length; i++) {
if(words[i].trim().contains(" ")) {
// trim() takes care of spaces before or after the words
System.out.println(words[i]);
}
}
}
} | [
"[email protected]"
] | |
252adedc0186f3799eb25894b4df06a1e3a11998 | 54210520db4839c898942faaa7b94606443ff9d9 | /src/test/java/com/cybertek/tests/day10_sync/ExplicitWaitExample.java | 2f9761ea841ee5cd9347f6921c878b6c704ea3e8 | [] | no_license | davutbilgic/EU2TestNGProject-dvt | df208dd5b0210b5f6b2be471fee6e8f1d95e6e22 | 5d12371ab8c4f2256ec0eb38b4458e732dec03f9 | refs/heads/master | 2023-05-28T20:59:30.356194 | 2020-05-27T19:51:18 | 2020-05-27T19:51:18 | 265,970,810 | 0 | 0 | null | 2023-05-09T18:50:44 | 2020-05-21T23:11:08 | Java | UTF-8 | Java | false | false | 1,888 | java | package com.cybertek.tests.day10_sync;
import com.cybertek.utilities.WebDriverFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class ExplicitWaitExample {
WebDriver driver;
@BeforeMethod
public void setUpMethod(){
driver = WebDriverFactory.getDriver("chrome");
}
@AfterMethod
public void afterMethod() throws InterruptedException {
Thread.sleep(2000);
driver.quit();
}
@Test
public void test1(){
driver.get("http://practice.cybertekschool.com/dynamic_loading/1");
//click start button
driver.findElement(By.tagName("button")).click();
//locate username inputbox
WebElement usernameInputbox = driver.findElement(By.id("username"));
//HOW TO WAIT EXPLICITLY ?
//Create Explicit wait object
WebDriverWait wait = new WebDriverWait(driver,10);
//calling until method from wait object
wait.until(ExpectedConditions.visibilityOf(usernameInputbox));
usernameInputbox.sendKeys("MikeSmith");
}
@Test
public void test2(){
driver.get("http://practice.cybertekschool.com/dynamic_controls");
//click enable
driver.findElement(By.xpath("//button[.='Enable']")).click();
//finding inputbox
WebElement inputbox = driver.findElement(By.xpath("(//input)[2]"));
//wait until element is clickable
WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.elementToBeClickable(inputbox));
inputbox.sendKeys("MikeSmith");
}
} | [
"[email protected]"
] | |
f297428bb995099158799aed7454725bec0a90b2 | 13c371fffd8c0ecd5e735755e7337a093ac00e30 | /com/planet_ink/coffee_mud/Abilities/Spells/Spell_DemonGate.java | 492f4f12368fa5c28fe51b555f1f30233bf88925 | [
"Apache-2.0"
] | permissive | z3ndrag0n/CoffeeMud | e6b0c58953e47eb58544039b0781e4071a016372 | 50df765daee37765e76a1632a04c03f8a96d8f40 | refs/heads/master | 2020-09-15T10:27:26.511725 | 2019-11-18T15:41:42 | 2019-11-18T15:41:42 | 223,416,916 | 1 | 0 | Apache-2.0 | 2019-11-22T14:09:54 | 2019-11-22T14:09:53 | null | UTF-8 | Java | false | false | 7,889 | java | package com.planet_ink.coffee_mud.Abilities.Spells;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;
import java.util.*;
/*
Copyright 2002-2019 Bo Zimmerman
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.
*/
public class Spell_DemonGate extends Spell
{
@Override
public String ID()
{
return "Spell_DemonGate";
}
private final static String localizedName = CMLib.lang().L("Demon Gate");
@Override
public String name()
{
return localizedName;
}
private final static String localizedStaticDisplay = CMLib.lang().L("(Demon Gate)");
@Override
public String displayText()
{
return localizedStaticDisplay;
}
@Override
public int abstractQuality()
{
return Ability.QUALITY_BENEFICIAL_SELF;
}
@Override
public int enchantQuality()
{
return Ability.QUALITY_INDIFFERENT;
}
@Override
protected int canAffectCode()
{
return CAN_MOBS;
}
@Override
protected int canTargetCode()
{
return 0;
}
@Override
protected int overrideMana()
{
return 100;
}
@Override
public int classificationCode()
{
return Ability.ACODE_SPELL|Ability.DOMAIN_CONJURATION;
}
@Override
public long flags()
{
return Ability.FLAG_SUMMONING;
}
protected MOB myTarget=null;
@Override
public boolean tick(final Tickable ticking, final int tickID)
{
if(tickID==Tickable.TICKID_MOB)
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if(myTarget==null)
myTarget=mob.getVictim();
else
if(myTarget!=mob.getVictim())
unInvoke();
}
}
return super.tick(ticking,tickID);
}
@Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost,msg);
if((affected!=null)
&&(affected instanceof MOB)
&&(msg.amISource((MOB)affected)||msg.amISource(((MOB)affected).amFollowing())||(msg.source()==invoker()))
&&(msg.sourceMinor()==CMMsg.TYP_QUIT))
{
unInvoke();
if(msg.source().playerStats()!=null)
msg.source().playerStats().setLastUpdated(0);
}
}
@Override
public void unInvoke()
{
final MOB mob=(MOB)affected;
super.unInvoke();
if((canBeUninvoked())&&(mob!=null))
{
final Room R=mob.location();
if(R!=null)
{
if(mob.amFollowing()!=null)
R.showOthers(mob,mob.amFollowing(),CMMsg.MSG_OK_ACTION,L("^F^<FIGHT^><S-NAME> uses the fight to wrest itself from out of <T-YOUPOSS> control!^?%0DTo <T-YOUPOSS> great relief, it disappears back into its home plane.^</FIGHT^>^?"));
else
R.showOthers(mob,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> disappears back into its home plane."));
}
if(mob.amDead())
mob.setLocation(null);
mob.destroy();
}
}
@Override
public boolean invoke(final MOB mob, final List<String> commands, final Physical givenTarget, final boolean auto, final int asLevel)
{
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=proficiencyCheck(mob,0,auto);
if(success)
{
invoker=mob;
final CMMsg msg=CMClass.getMsg(mob,null,this,verbalCastCode(mob,null,auto),auto?"":L("^S<S-NAME> open(s) the gates of the abyss, incanting angrily.^?"));
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
final MOB otherMonster=mob.location().fetchInhabitant("the great demonbeast$");
final MOB myMonster = determineMonster(mob, mob.phyStats().level()+(getXLEVELLevel(mob)+(2*getX1Level(mob))));
if(otherMonster!=null)
{
myMonster.location().showOthers(myMonster,mob,CMMsg.MSG_OK_ACTION,L("^F^<FIGHT^><S-NAME> wrests itself from out of <T-YOUPOSS> control!^</FIGHT^>^?"));
myMonster.setVictim(otherMonster);
}
else
if(CMLib.dice().rollPercentage()<10)
{
myMonster.location().showOthers(myMonster,mob,CMMsg.MSG_OK_ACTION,L("^F^<FIGHT^><S-NAME> wrests itself from out of <T-YOUPOSS> control!^</FIGHT^>^?"));
myMonster.setVictim(mob);
}
else
{
myMonster.setVictim(mob.getVictim());
CMLib.commands().postFollow(myMonster,mob,true);
if(myMonster.amFollowing()!=mob)
mob.tell(L("@x1 seems unwilling to follow you.",myMonster.name()));
}
invoker=mob;
beneficialAffect(mob,myMonster,asLevel,0);
}
}
else
return beneficialWordsFizzle(mob,null,L("<S-NAME> attempt(s) to open the gates of the abyss, but fail(s)."));
// return whether it worked
return success;
}
public MOB determineMonster(final MOB caster, final int level)
{
final MOB newMOB=CMClass.getMOB("GenRideable");
final Rideable ride=(Rideable)newMOB;
newMOB.basePhyStats().setAbility(22 + super.getXLEVELLevel(caster));
newMOB.basePhyStats().setLevel(level+ 2 + super.getXLEVELLevel(caster));
CMLib.factions().setAlignment(newMOB,Faction.Align.EVIL);
newMOB.basePhyStats().setWeight(850);
newMOB.basePhyStats().setRejuv(PhyStats.NO_REJUV);
newMOB.baseCharStats().setStat(CharStats.STAT_STRENGTH,18);
newMOB.baseCharStats().setStat(CharStats.STAT_DEXTERITY,18);
newMOB.baseCharStats().setStat(CharStats.STAT_CONSTITUTION,18);
newMOB.baseCharStats().setMyRace(CMClass.getRace("Demon"));
newMOB.baseCharStats().getMyRace().startRacing(newMOB,false);
newMOB.baseCharStats().setStat(CharStats.STAT_GENDER,'M');
newMOB.recoverPhyStats();
newMOB.recoverCharStats();
newMOB.basePhyStats().setArmor(CMLib.leveler().getLevelMOBArmor(newMOB));
newMOB.basePhyStats().setAttackAdjustment(CMLib.leveler().getLevelAttack(newMOB));
newMOB.basePhyStats().setDamage(CMLib.leveler().getLevelMOBDamage(newMOB));
newMOB.basePhyStats().setSpeed(CMLib.leveler().getLevelMOBSpeed(newMOB));
newMOB.setName(L("the great demonbeast"));
newMOB.setDisplayText(L("a horrendous demonbeast is stalking around here"));
newMOB.setDescription(L("Blood red skin with massive horns, and of course muscles in places you didn`t know existed."));
newMOB.addNonUninvokableEffect(CMClass.getAbility("Prop_ModExperience"));
ride.setRiderCapacity(2);
newMOB.recoverCharStats();
newMOB.recoverPhyStats();
newMOB.recoverMaxState();
newMOB.resetToMaxState();
newMOB.text();
newMOB.bringToLife(caster.location(),true);
CMLib.beanCounter().clearZeroMoney(newMOB,null);
newMOB.setMoneyVariation(0);
newMOB.location().showOthers(newMOB,null,CMMsg.MSG_OK_ACTION,L("<S-NAME> tears through the fabric of reality and steps into this world!"));
caster.location().recoverRoomStats();
newMOB.setStartRoom(null);
return(newMOB);
}
}
| [
"[email protected]"
] | |
13d54e091dfc943be36e8335b7bcdb5f80c889ac | 48c5663dcec916e795bcedec82dea8bf9c178cb7 | /src/main/java/com/example/demo/thread/safe/ThreadSafeDoubleCheckedLazyInition.java | 623481161482b4de4fdf58800a8e0f7778a1d232 | [] | no_license | SimonePan/java-demo | 0ac958126897a9b7773f385270079ab58aa1bb7e | 7f5530e81275bdc8b6abb0e688e73b7ae4e25366 | refs/heads/master | 2022-07-02T06:54:25.780445 | 2021-04-19T09:45:32 | 2021-04-19T09:45:32 | 193,301,023 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 598 | java | package com.example.demo.thread.safe;
import com.example.demo.thread.unsafe.Sequence;
/**
* @description: 双重校验延迟初始化
* @author: Grace.Pan
* @create: 2019-12-18 19:46
*/
public class ThreadSafeDoubleCheckedLazyInition {
private static volatile Sequence sequence;
public static Sequence getSequence() {
if (sequence == null) {
synchronized (ThreadSafeDoubleCheckedLazyInition.class) {
if (sequence == null) {
sequence = new Sequence(2);
}
}
}
return sequence;
}
}
| [
"[email protected]"
] | |
4acd5ba0c8f8ff6ab8edc6717c5bcc895480ee19 | 1a4441661a500e9b1355e222d5749d8b7042fe33 | /project/src/main/java/com/hu/cs/project/project/ProjectApplication.java | 80810db6b86d9227918dca4faa369bb100cb74f9 | [] | no_license | MySpringProject/ClassProject | b9f4663edd7e386614c69d9f0f7465977ca598b4 | 8f3e3c56ae0750aeafc6f4f4596b33a0e465c367 | refs/heads/master | 2020-07-28T01:03:02.610618 | 2019-10-16T16:42:25 | 2019-10-16T16:42:25 | 209,262,999 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 320 | java | package com.hu.cs.project.project;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ProjectApplication {
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
}
}
| [
"[email protected]"
] | |
f3ecef314cefb2c8a9320c5f4a04ba21329d7a34 | e6a977b8c8ac1546aeeaf4e7ffd7f467324a832d | /ac/monitor/components/error-monitor/src/main/java/com/hp/it/perf/monitor/config/ConnectConfig.java | e45c29c2aec5d2ca656c71b4e3b1b2989d7044ec | [] | no_license | shengyao15/performance_project | 6c86d6493d2c2d79d3e0d3585f96557a8584b1f6 | d3f7a66e9065379452fcda0bb6209a529822393c | refs/heads/master | 2021-05-16T03:07:16.637843 | 2017-11-01T06:35:58 | 2017-11-01T06:35:58 | 20,017,606 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 967 | java | package com.hp.it.perf.monitor.config;
import java.util.HashMap;
import java.util.Map;
public class ConnectConfig implements ConnectConfigMXBean {
private Map<String, String> configs = new HashMap<String, String>(1);
/* (non-Javadoc)
* @see com.hp.it.perf.monitor.config.ConnectConfigMXBean#getConfigs()
*/
@Override
public Map<String, String> getConfigs() {
return configs;
}
/* (non-Javadoc)
* @see com.hp.it.perf.monitor.config.ConnectConfigMXBean#setConfigs(java.util.Map)
*/
@Override
public void setConfigs(Map<String, String> configs) {
this.configs = configs;
}
/* (non-Javadoc)
* @see com.hp.it.perf.monitor.config.ConnectConfigMXBean#put(java.lang.String, java.lang.String)
*/
@Override
public void put(String k, String v){
configs.put(k, v);
}
/* (non-Javadoc)
* @see com.hp.it.perf.monitor.config.ConnectConfigMXBean#remove(java.lang.String)
*/
@Override
public void remove(String k){
configs.remove(k);
}
}
| [
"[email protected]"
] | |
ef44d91d99ed46e553fa2c73f9d49711eeffa6cb | 7af90676a3109ec9ac67046a1fa45deb1f1b108f | /WN/src/main/java/cn/powerun/springBoot/controller/SpotsController.java | 92255bf822c7f8b77b4c8dfc1aeb8f43a2b6e1df | [] | no_license | MarkXv/project-java | 4cd3d30d2fcc21ace887aedb19f6206d9f215aef | 693a9ea7ce39e377a22228160541fc69bf62d917 | refs/heads/master | 2022-12-24T18:15:11.359042 | 2019-08-27T14:12:34 | 2019-08-27T14:12:34 | 142,419,561 | 1 | 0 | null | 2022-12-16T04:54:32 | 2018-07-26T09:30:45 | JavaScript | UTF-8 | Java | false | false | 4,422 | java | package cn.powerun.springBoot.controller;
import cn.powerun.springBoot.pojo.spot.Category;
import cn.powerun.springBoot.pojo.spot.Spots;
import cn.powerun.springBoot.service.CategoryService;
import cn.powerun.springBoot.service.SpotsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* Created by Administrator on 2017/10/20.
*/
@Controller
@RequestMapping("/backend/spots")
public class SpotsController {
@Autowired
private SpotsService spotsService;
@Autowired
private CategoryService categoryService;
/**
* 请求查看景点管理首页
*
* @return
*/
@RequestMapping("/index")
public String tospots(Model model) {
List<Spots> spotsList = spotsService.findAll();
List<Category> categoryList = categoryService.findAll();
model.addAttribute("spotsList", spotsList);
model.addAttribute("categoryList",categoryList);
return "pages/backend/main/manage/spots/spotsframe";
}
/**
* 请求查看页面
*
* @return
*/
@RequestMapping("/view")
public String tospotsview(Model model, String spotsId) {
Spots spots = spotsService.findSpotsById(spotsId);
model.addAttribute("spots", spots);
return "pages/backend/main/manage/spots/baseOP/spotsview";
}
/**
* 修改状态为禁用状态
*
* @param spotsIds
* @return
*/
@RequestMapping("/stop")
public String toStop(@RequestParam("spotsId") String[] spotsIds) {
Integer state = 0;
//测试
/*String[] spotsIds = {"1"};*/
System.out.println(spotsIds);
spotsService.updateState(spotsIds, state);
return "redirect:/backend/spots/index";
}
/**
* 修改状态为启用状态
*
* @param spotsIds
* @return
*/
@RequestMapping("/start")
public String toStart(@RequestParam("spotsId") String[] spotsIds) {
//测试
/*String spotsId = "200";*/
Integer state = 1;
spotsService.updateState(spotsIds, state);
return "redirect:/backend/spots/index";
}
/**
* 请求景点添加界面
*
* @return
*/
@RequestMapping("/add")
public String tospotsAdd(Model model) {
List<Category> categoryList = categoryService.findAll();
/* for (Category c : categoryList) {
System.out.println(c);
}*/
model.addAttribute("categoryList", categoryList);
return "/pages/backend/main/manage/spots/baseOP/spotsadd";
}
//保存景点信息
@RequestMapping("/save")
public String saveSpots(Spots spots/*, String imgurls*/) {
spotsService.saveSpots(spots);
//重定向到景点主页面
return "redirect:/backend/spots/index";
}
/*@RequestMapping("")*/
/**
* 请求修改页面
*/
@RequestMapping("/update")
public String tospotsupdate(Model model, String spotsId) {
List<Category> categoryList = categoryService.findAll();
Spots spots = spotsService.findSpotsById(spotsId);
model.addAttribute("categoryList", categoryList);
model.addAttribute("spots", spots);
return "pages/backend/main/manage/spots/baseOP/spotsupdate";
}
//修改景点信息
@RequestMapping("/updatespots")
public String updateSpots(Spots spots, String imgurls) {
spotsService.updateSpots(spots);
//重定向到景点主页面
return "redirect:/backend/spots/index";
}
//删除景点信息
@RequestMapping("/delete")
public String deleteSpots(@RequestParam("spotsId")String[] spotsIds, String imgurls) {
spotsService.deleteSpots(spotsIds);
//重定向到景点主页面
return "redirect:/backend/spots/index";
}
/**
* 请求景点-类别页面
*
* @return
*/
/* @RequestMapping("/spotscategory")
public String tospotscategory(Model model,String spotsId) throws JsonProcessingException {
List<Category> categoryList = categoryService.findCategoryBySpotsId(spotsId);
return "pages/backend/main/manage/spots/spots_category";
}*/
}
| [
"[email protected]"
] |
Subsets and Splits