blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
71e3a684ca25c9983a1c33fb2d989e6e6e69a601 | ec6da3f18f529e021c1ec24670dc11aa0d24b950 | /src/main/java/org/spat/dao/sql/executor/DeleteExecutor.java | ce2782076cd2dc36a0a9b74b2fc193cc948f8162 | [] | no_license | org-spat/dao | 9feb2af192b5b8a1df922516d48c44fa2b49f5e3 | 0068e0ba31a57c4e1d28ab31a24a26611665f433 | refs/heads/master | 2021-06-11T19:28:48.175641 | 2017-08-30T08:19:27 | 2017-08-30T08:19:27 | 57,300,294 | 1 | 4 | null | null | null | null | UTF-8 | Java | false | false | 1,022 | java | package org.spat.dao.sql.executor;
import org.spat.dao.sql.SqlHelper;
public class DeleteExecutor<T> extends Executor<T> {
private StringBuilder where = new StringBuilder();
@Override
public Boolean execute() throws Exception {
genSQL();
SqlHelper sqlHelper = SqlHelper.get(this.strSQL, getMapping().getDatabase());
if (params != null) {
for (Object param : params){
sqlHelper.addParam(param);
}
}
return sqlHelper.execute();
}
public DeleteExecutor<T> where(String condition){
where.append(condition);
return this;
}
public DeleteExecutor<T> setParams(Object ...params){
for (Object param : params) {
this.params.add(param);
}
return this;
}
private void genSQL() {
StringBuilder sbsql = new StringBuilder();
sbsql.append("delete from ");
sbsql.append(getMapping().getTableName());
if (where.length() > 0) {
sbsql.append(" where ");
sbsql.append(this.where.toString());
}
this.strSQL = sbsql.toString();
}
}
| [
"[email protected]"
] | |
2067ea6fa9672ae417033c3765c45a7a989e0893 | b7eac9e1f237c627afe61f5cd4fb66717681e3f3 | /src/edu/AP/Project/ClashRoyale/Client/Controller/BattleController.java | eaf7628f56ca2846e1c11bc37a2197bb6a6d568f | [] | no_license | hamidreza-abooei/ClashRoyale | c229dbafe6748f496123b9ff1ac2395f10426d66 | a8d7220a9e18b931018d08cc97e7ab2db962b887 | refs/heads/master | 2023-06-19T08:19:35.070294 | 2021-07-20T13:02:37 | 2021-07-20T13:02:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,235 | java | package edu.AP.Project.ClashRoyale.Client.Controller;
import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import java.util.Objects;
import static edu.AP.Project.ClashRoyale.Client.Main.changeScene;
public class BattleController {
@FXML
private ImageView battleDeckImage;
@FXML
private ImageView battleHistoryImage;
@FXML
private ImageView profileImage;
@FXML
private JFXButton battleBtn;
@FXML
private JFXButton battleDeckBtn;
@FXML
private JFXButton battleHistory;
@FXML
private JFXButton profileBtn;
@FXML
private ImageView trainingImage;
@FXML
private ImageView trainingSmartImage;
@FXML
private ImageView oneImage;
@FXML
private ImageView twoImage;
@FXML
private JFXButton trainingBtn;
@FXML
private JFXButton trainingSmartBtn;
@FXML
private JFXButton oneBtn;
@FXML
private JFXButton twoBtn;
@FXML
private ImageView imageBox;
@FXML
void initialize(){
Image arena = new Image(Objects.requireNonNull(getClass().getResourceAsStream("../Images/arenas/arena1.png")));
imageBox.setImage(arena);
}
@FXML
void battleClick(ActionEvent event) {
}
@FXML
void battleDeckClick(ActionEvent event) {
changeScene("Views/BattleDeck.fxml");
}
@FXML
void battleHistoryClick(ActionEvent event) {
changeScene("Views/BattleHistory.fxml");
}
@FXML
void profileClick(ActionEvent event) {
changeScene("Views/Profile.fxml");
}
@FXML
void oneClick(ActionEvent event) {
}
@FXML
void trainingClick(ActionEvent event) {
}
@FXML
void trainingSmartClick(ActionEvent event) {
}
@FXML
void twoClick(ActionEvent event) {
}
@FXML
void mouseEntered(MouseEvent event) {
Image silverButtonImage = new Image(Objects.requireNonNull(getClass().getResourceAsStream("../Images/Button/silver.png")));
if (event.getSource().equals(battleDeckBtn))
battleDeckImage.setImage(silverButtonImage);
if (event.getSource().equals(battleHistory))
battleHistoryImage.setImage(silverButtonImage);
if (event.getSource().equals(profileBtn))
profileImage.setImage(silverButtonImage);
}
@FXML
void mouseExited(MouseEvent event) {
Image grayButtonImage = new Image(Objects.requireNonNull(getClass().getResourceAsStream("../Images/Button/gray.png")));
if (event.getSource().equals(battleDeckBtn))
battleDeckImage.setImage(grayButtonImage);
if (event.getSource().equals(battleHistory))
battleHistoryImage.setImage(grayButtonImage);
if (event.getSource().equals(profileBtn))
profileImage.setImage(grayButtonImage);
}
@FXML
void longEntered(MouseEvent event) {
Image goldButtonLongImage = new Image(Objects.requireNonNull(getClass().getResourceAsStream("../Images/Button/goldSolong.png")));
if (event.getSource().equals(trainingBtn))
trainingImage.setImage(goldButtonLongImage);
if (event.getSource().equals(trainingSmartBtn))
trainingSmartImage.setImage(goldButtonLongImage);
if (event.getSource().equals(oneBtn))
oneImage.setImage(goldButtonLongImage);
if (event.getSource().equals(twoBtn))
twoImage.setImage(goldButtonLongImage);
}
@FXML
void longExited(MouseEvent event) {
Image silverButtonLongImage = new Image(Objects.requireNonNull(getClass().getResourceAsStream("../Images/Button/silverSolong.png")));
if (event.getSource().equals(trainingBtn))
trainingImage.setImage(silverButtonLongImage);
if (event.getSource().equals(trainingSmartBtn))
trainingSmartImage.setImage(silverButtonLongImage);
if (event.getSource().equals(oneBtn))
oneImage.setImage(silverButtonLongImage);
if (event.getSource().equals(twoBtn))
twoImage.setImage(silverButtonLongImage);
}
}
| [
"[email protected]"
] | |
a1ba50e482576976818e373aa85d7d7f2575aa8f | 3a7a89be45138c6c714ba0a3374d3a9409c68752 | /src/main/java/org/janelia/saalfeldlab/n5/DataType.java | ca64c98620eb983d13f47368dfb2ef12193f5c1c | [
"BSD-2-Clause"
] | permissive | d-v-b/n5 | 1c811720f8f548c8e71d48d0f9ac1f53eb086b2b | 203124364856c6c2726ca81093e0b81d72015298 | refs/heads/master | 2022-06-20T08:44:12.141098 | 2020-05-11T14:21:21 | 2020-05-11T14:21:21 | 263,063,030 | 0 | 0 | BSD-2-Clause | 2020-05-11T14:16:25 | 2020-05-11T14:16:24 | null | UTF-8 | Java | false | false | 5,084 | java | /**
* Copyright (c) 2017, Stephan Saalfeld
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.janelia.saalfeldlab.n5;
import java.lang.reflect.Type;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
/**
* Enumerates available data types.
*
* @author Stephan Saalfeld
*/
public enum DataType {
UINT8("uint8", (blockSize, gridPosition, numElements) -> new ByteArrayDataBlock(blockSize, gridPosition, new byte[numElements])),
UINT16("uint16", (blockSize, gridPosition, numElements) -> new ShortArrayDataBlock(blockSize, gridPosition, new short[numElements])),
UINT32("uint32", (blockSize, gridPosition, numElements) -> new IntArrayDataBlock(blockSize, gridPosition, new int[numElements])),
UINT64("uint64", (blockSize, gridPosition, numElements) -> new LongArrayDataBlock(blockSize, gridPosition, new long[numElements])),
INT8("int8", (blockSize, gridPosition, numElements) -> new ByteArrayDataBlock(blockSize, gridPosition, new byte[numElements])),
INT16("int16", (blockSize, gridPosition, numElements) -> new ShortArrayDataBlock(blockSize, gridPosition, new short[numElements])),
INT32("int32", (blockSize, gridPosition, numElements) -> new IntArrayDataBlock(blockSize, gridPosition, new int[numElements])),
INT64("int64", (blockSize, gridPosition, numElements) -> new LongArrayDataBlock(blockSize, gridPosition, new long[numElements])),
FLOAT32("float32", (blockSize, gridPosition, numElements) -> new FloatArrayDataBlock(blockSize, gridPosition, new float[numElements])),
FLOAT64("float64", (blockSize, gridPosition, numElements) -> new DoubleArrayDataBlock(blockSize, gridPosition, new double[numElements]));
private final String label;
private DataBlockFactory dataBlockFactory;
private DataType(final String label, final DataBlockFactory dataBlockFactory) {
this.label = label;
this.dataBlockFactory = dataBlockFactory;
}
@Override
public String toString() {
return label;
}
public static DataType fromString(final String string) {
for (final DataType value : values())
if (value.toString().equals(string))
return value;
return null;
}
/**
* Factory for {@link DataBlock DataBlocks}.
*
* @param blockSize
* @param gridPosition
* @param numElements not necessarily one element per block element
* @return
*/
public DataBlock<?> createDataBlock(final int[] blockSize, final long[] gridPosition, final int numElements) {
return dataBlockFactory.createDataBlock(blockSize, gridPosition, numElements);
}
/**
* Factory for {@link DataBlock DataBlocks} with one data element for each
* block element (e.g. pixel image).
*
* @param blockSize
* @param gridPosition
* @return
*/
public DataBlock<?> createDataBlock(final int[] blockSize, final long[] gridPosition) {
return dataBlockFactory.createDataBlock(blockSize, gridPosition, DataBlock.getNumElements(blockSize));
}
private static interface DataBlockFactory {
public DataBlock<?> createDataBlock(final int[] blockSize, final long[] gridPosition, final int numElements);
}
static public class JsonAdapter implements JsonDeserializer<DataType>, JsonSerializer<DataType> {
@Override
public DataType deserialize(
final JsonElement json,
final Type typeOfT,
final JsonDeserializationContext context) throws JsonParseException {
return DataType.fromString(json.getAsString());
}
@Override
public JsonElement serialize(
final DataType src,
final Type typeOfSrc,
final JsonSerializationContext context) {
return new JsonPrimitive(src.toString());
}
}
} | [
"[email protected]"
] | |
5ca6d27ef2ccaaa1668edf659bb339bfa970493f | 78b91e80fde798313382d9326d2ee14f72c4ad04 | /src/sourabhs/datastructures/math/PowerOfTwo.java | 7e485436e243fc64f244f05a5c9b02283e116051 | [] | no_license | sourabh-repo/ds-algo | 4f9cb7dda489329db9ca9ba06a7afda3ff30c073 | c3107a0744f2a5f8903c94ab2af09b5d0cfe0f47 | refs/heads/master | 2022-12-04T13:04:36.376674 | 2020-08-20T03:43:21 | 2020-08-20T03:43:21 | 70,248,735 | 0 | 0 | null | 2020-08-20T03:43:22 | 2016-10-07T13:24:19 | Java | UTF-8 | Java | false | false | 1,010 | java | package sourabhs.datastructures.math;
/**
* @author Sourabh
*
* LeetCode:
* Given an integer, write a function to determine if it is a power of two.
*/
public class PowerOfTwo {
/**
* 00000100 ( = 4)
* & 00000111 ( = 7)
* ==========
* 00000100 ( = 4)
*
* i.e. in decimal 4 & 7 = 4
*/
public boolean isPowerOfTwo(int num) {
if(num <= 0) return false;
else if((int) (num & (num - 1)) == 0)
return true;
else
return false;
}
public boolean isPowerOfTwoUsingBitCount(int n) {
return n > 0 && Integer.bitCount(n) == 1;
}
public static void main(String[] args) {
PowerOfTwo pTwo = new PowerOfTwo();
boolean result = pTwo.isPowerOfTwo(10);
System.out.println("result is " + result);
result = pTwo.isPowerOfTwo(256);
System.out.println("result is " + result);
result = pTwo.isPowerOfTwoUsingBitCount(1000);
System.out.println("result is " + result);
result = pTwo.isPowerOfTwoUsingBitCount(1024);
System.out.println("result is " + result);
}
}
| [
"[email protected]"
] | |
b346602b57e2afd664f6303a2853afe3af775de6 | 12cccbc07299e361e7984161a4d9fb3ca541d991 | /src/test/groovy/com/synopsys/integration/rest/support/AuthenticationSupportTest.java | 15744e6d08060c77b0ac898e2230251723cfdb21 | [
"Apache-2.0"
] | permissive | JonathanKershaw/integration-rest | f8cc9a367408d35e6faaec4a43fc5d90515cea01 | b8b92154466be1242b028ea0e24ebfc8bb77d764 | refs/heads/master | 2021-01-04T00:06:14.587679 | 2020-02-10T15:45:39 | 2020-02-10T15:45:39 | 240,294,614 | 0 | 0 | Apache-2.0 | 2020-02-13T15:32:11 | 2020-02-13T15:32:10 | null | UTF-8 | Java | false | false | 3,398 | java | package com.synopsys.integration.rest.support;
import com.synopsys.integration.exception.IntegrationException;
import com.synopsys.integration.log.SilentIntLogger;
import com.synopsys.integration.rest.client.AuthenticatingIntHttpClient;
import com.synopsys.integration.rest.request.Request;
import com.synopsys.integration.rest.request.Response;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.ReflectionUtils;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import java.lang.reflect.Field;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AuthenticationSupportTest {
@Test
public void testAttemptAuthentication() throws Exception {
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece", "login", "http://www.google.com/pathpiece/login");
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece/", "login", "http://www.google.com/pathpiece/login");
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece", "/login", "http://www.google.com/pathpiece/login");
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece/", "/login", "http://www.google.com/pathpiece/login");
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece", "./login", "http://www.google.com/pathpiece/login");
assertUrlPiecesCombineAsExpected("http://www.google.com/pathpiece/", "./login", "http://www.google.com/pathpiece/login");
}
private void assertUrlPiecesCombineAsExpected(String baseUrl, String authenticationUrl, String expectedResult) throws Exception {
AuthenticatingIntHttpClient authenticatingIntHttpClient = Mockito.mock(AuthenticatingIntHttpClient.class);
HttpClientBuilder mockHttpClientBuilder = Mockito.mock(HttpClientBuilder.class);
CloseableHttpClient mockHttpClient = Mockito.mock(CloseableHttpClient.class);
Mockito.when(authenticatingIntHttpClient.getClientBuilder()).thenReturn(mockHttpClientBuilder);
Mockito.when(mockHttpClientBuilder.build()).thenReturn(mockHttpClient);
ArgumentCaptor<HttpUriRequest> requestArgumentCaptor = ArgumentCaptor.forClass(HttpUriRequest.class);
Mockito.when(mockHttpClient.execute(requestArgumentCaptor.capture())).thenReturn(Mockito.mock(CloseableHttpResponse.class));
RequestBuilder requestBuilder = RequestBuilder.create(HttpGet.METHOD_NAME);
Field loggerField = FieldUtils.getField(AuthenticatingIntHttpClient.class, "logger", true);
FieldUtils.writeField(loggerField, authenticatingIntHttpClient, new SilentIntLogger());
AuthenticationSupport authenticationSupport = new AuthenticationSupport();
authenticationSupport.attemptAuthentication(authenticatingIntHttpClient, baseUrl, authenticationUrl, requestBuilder);
HttpUriRequest request = requestArgumentCaptor.getValue();
assertEquals(expectedResult, request.getURI().toString());
}
}
| [
"[email protected]"
] | |
502de5d930e81463ea111e6397d434f8943ac18b | 83a0421f3a224b86642bd56b829cccd844eb56ac | /WEB-INF/classes/GetDirection.java | 1f61806e13d94065d61e7a2ee7dca095c27bb32a | [] | no_license | AzharShaikhSE/HotelHunt | 9a6283f02540914e94414e6a5e29be7eacd7cdfe | a09cb56569f242fec6597bcd529af3cc8ac74f2e | refs/heads/master | 2021-04-28T19:18:33.464326 | 2018-02-18T01:29:24 | 2018-02-18T01:29:24 | 121,892,185 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,628 | java | import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetDirection extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession(true);
Utility utility = new Utility(request, out);
LoginUtil loginUtil = new LoginUtil(request);
String address = (String)request.getParameter("address");
String city = (String)request.getParameter("city");
String name = (String)request.getParameter("name");
utility.printHtml("header.jsp");
out.println("<style> #container1 {width: 80%;margin: 5px 10px auto auto;padding:10px;box-shadow: 5px 5px 5px 5px #CCCCCC;background-color: #fff;float:right;}</style>");
out.println("<div id='container1'>");
out.println("<h1 style='text-align: center;background-color:#dbd9d9;width: 96.5%;margin-left:12px;padding:10px;'>Get Direction</h1>");
out.println("<br>");
out.print("<div class='post' style='float: none; width: 100%'>");
out.println("<form action='http://maps.google.com/maps' method='get' target='_blank'><label for='saddr'>Enter your location</label><input type='text' name='saddr' /><input type='hidden' name='daddr' value='"+name+","+address+","+city+"' /><input type='submit' value='Get directions'/></form>");
out.print("</div></div>");
utility.printHtml("leftNavBar.jsp");
utility.printHtml("footer.jsp");
}
}
| [
"[email protected]"
] | |
07d86265e37c4527f1373907b3cfeee65c99c597 | 447392d226b376b7cb6861b8ca6c21eab35fa2ac | /3.JavaMultithreading/src/com/javarush/task/task23/task2304/Solution.java | 7d8a8d01a5ef38aa777c8a22d3597e6b0e0d6007 | [] | no_license | Piter80/JavaRushTasks | d22e6e53e82c1ef13f64d8dbed124640641e2fa7 | 14521589ee2f489ec866b80dd65081d6d054b827 | refs/heads/master | 2020-05-17T22:49:17.402250 | 2019-04-29T06:41:37 | 2019-04-29T06:41:37 | 173,489,620 | 0 | 0 | null | 2019-04-29T06:27:03 | 2019-03-02T19:23:38 | Roff | UTF-8 | Java | false | false | 1,181 | java | package com.javarush.task.task23.task2304;
import java.util.List;
import java.util.Map;
/*
Inner 3
*/
public class Solution {
private List<Task> tasks;
private List<String> names;
private DbDataProvider taskDataProvider = new TaskDataProvider();
private DbDataProvider nameDataProvider = new NameDataProvider();
public void refresh() {
Map taskCriteria = MockView.getFakeTaskCriteria();
taskDataProvider.refreshAllData(taskCriteria);
Map nameCriteria = MockView.getFakeNameCriteria();
nameDataProvider.refreshAllData(nameCriteria);
}
private interface DbDataProvider<T> {
void refreshAllData(Map criteria);
}
class Task {
}
private class TaskDataProvider implements DbDataProvider<Task> {
@Override
public void refreshAllData(Map criteria) {
tasks = MockDB.getFakeTasks(criteria);
}
}
private class NameDataProvider implements DbDataProvider<String> {
@Override
public void refreshAllData(Map criteria) {
names = MockDB.getFakeNames(criteria);
}
}
public static void main(String[] args) {
}
}
| [
"[email protected]"
] | |
d69212c39bf28ae882a29b22b59dd48a6267b650 | 3e18f2f1f8f319cbfb08e968446cf9b3eaa9b41f | /src/main/java/com/covens/common/item/magic/ItemLocationStone.java | eb4c3967b2b891b037fed003ada320fbb0623b3b | [
"MIT"
] | permissive | zabi94/Covens-reborn | f35dbb85f78d1b297956907c3b05f0a9cc045be6 | 6fe956025ad47051e14e2e7c45893ddebc5c330a | refs/heads/master | 2020-04-10T16:17:30.713563 | 2020-03-07T13:23:22 | 2020-03-07T13:23:22 | 161,140,468 | 11 | 2 | NOASSERTION | 2019-05-08T19:31:40 | 2018-12-10T08:15:04 | Java | UTF-8 | Java | false | false | 4,433 | java | package com.covens.common.item.magic;
import java.util.List;
import java.util.Optional;
import com.covens.client.core.ModelResourceLocations;
import com.covens.common.core.helper.Log;
import com.covens.common.item.ItemMod;
import com.covens.common.item.ModItems;
import com.covens.common.lib.LibItemName;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import zabi.minecraft.minerva.common.utils.DimensionalPosition;
public class ItemLocationStone extends ItemMod {
public ItemLocationStone() {
super(LibItemName.LOCATION_STONE);
this.setMaxStackSize(1);
this.setMaxDamage(3);
}
public static boolean isBound(ItemStack stack) {
return stack.getMetadata() == 1;
}
@Override
public int getDamage(ItemStack stack) {
return checkOrSetTag(stack).getInteger("damage");
}
@Override
public void setDamage(ItemStack stack, int damage) {
checkOrSetTag(stack).setInteger("damage", damage);
}
public static Optional<DimensionalPosition> getLocation(ItemStack stack) {
NBTTagCompound tag = checkOrSetTag(stack);
if (!isBound(stack)) {
return Optional.empty();
}
NBTTagCompound coordTag = tag.getCompoundTag("coords");
int x = coordTag.getInteger("x");
int y = coordTag.getInteger("y");
int z = coordTag.getInteger("z");
int d = coordTag.getInteger("d");
return Optional.of(new DimensionalPosition(x, y, z, d));
}
public static Optional<DimensionalPosition> getLocationAndDamageStack(ItemStack stack, EntityLivingBase entityIn) {
Optional<DimensionalPosition> odp = getLocation(stack);
if (odp.isPresent()) {
stack.damageItem(1, entityIn);
}
return odp;
}
public static ItemStack bind(ItemStack stack, DimensionalPosition pos) {
ItemStack tempStack = stack.copy();
NBTTagCompound tag = checkOrSetTag(tempStack);
NBTTagCompound posTag = new NBTTagCompound();
posTag.setInteger("x", pos.getX());
posTag.setInteger("y", pos.getY());
posTag.setInteger("z", pos.getZ());
posTag.setInteger("d", pos.getDim());
tag.setTag("coords", posTag);
ItemStack res = new ItemStack(ModItems.location_stone, tempStack.getCount(), 1);
res.setTagCompound(tempStack.getTagCompound());
return res;
}
private static NBTTagCompound checkOrSetTag(ItemStack stack) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = stack.getTagCompound();
tag.setInteger("damage", 0);
if (isBound(stack) && !tag.hasKey("coords")) {
Log.w("Stone was bound but had no location data attached");
}
return tag;
}
@Override
public boolean hasEffect(ItemStack stack) {
return isBound(stack);
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
if (isBound(stack)) {
DimensionalPosition pos = getLocation(stack).get();
String dimName = "Dim " + pos.getDim(); // TODO transform this to the dimension name
tooltip.add(I18n.format("item.location_stone.bound_to", pos.getX(), pos.getY(), pos.getZ(), dimName));
} else {
tooltip.add(I18n.format("item.location_stone.unbound"));
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn);
if (!isBound(stack)) {
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, bind(stack, new DimensionalPosition(playerIn)));
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerModel() {
ModelLoader.setCustomModelResourceLocation(this, 0, ModelResourceLocations.UNBOUND_LOCATION_STONE);
ModelLoader.setCustomModelResourceLocation(this, 1, ModelResourceLocations.BOUND_LOCATION_STONE);
}
}
| [
"[email protected]"
] | |
75b676b8994fd34387b1b905c6e8bb10d58b1d50 | 881b5e08e959b0ce209ab24dde9ba9a765227c30 | /app/src/test/java/com/first/pc_02/finalproject/ExampleUnitTest.java | 88313326f62a850e7a73e7a5beef864cb56e770d | [] | no_license | lhsun001/finalProject | 76e9cdf332b0261981c40bfe89d8cb810ebfac09 | 921a3d851eba2fb131d39cff6e993b271d1b5d61 | refs/heads/master | 2021-09-03T03:07:17.216317 | 2018-01-05T03:38:53 | 2018-01-05T03:38:53 | 116,209,512 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 406 | java | package com.first.pc_02.finalproject;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
c66f213a1fbe587b0e9ea69029a20c076058529e | 04509a7c76744ed14e23e5a6661fe9cae646022f | /src/medium/leetcode59/Solution.java | efb3d7ab7ee5bf46953f056dce6e33514185853e | [
"Apache-2.0"
] | permissive | rain9155/LeetCodeSolution | 6abb5b54c751eb71aa55c8809f02bcc089e3f7ac | 3a3dc4eceda9d7264596039b1ae8ff5439432ac5 | refs/heads/master | 2023-04-15T16:36:24.928645 | 2023-03-20T11:16:22 | 2023-03-20T11:16:22 | 181,261,944 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,416 | java | package medium.leetcode59;
/**
* 螺旋矩阵 II:
* 给定一个正整数 n,生成一个包含 1 到 n2 所有元素,且元素按顺时针顺序螺旋排列的正方形矩阵。
* 示例:
* 输入: 3
* 输出:
* [
* [ 1, 2, 3 ],
* [ 8, 9, 4 ],
* [ 7, 6, 5 ]
* ]
*/
public class Solution {
/**
* O(n):
* 按层模拟:参考54题
* 顺时针输入矩阵,就是按顺序把矩阵从外到内一层一层的输入元素
* 每输入一层,起始点和边界都要做调整,起始点从(0,0)矩阵的左上角开始,边界从(n, n)开始
*/
public int[][] generateMatrix(int n) {
if(n <= 0) return null;
int[][] ret = new int[n][n];
int row = n;
int col = n;
int r = 0;
int c = 0;
int count = n * n;
int num = 1;
while (r < row && c < col && num <= count){
for(int j = c; j < col; j++, num++){
ret[r][j] = num;
}
for(int i = r + 1; i < row; i++, num++){
ret[i][col - 1] = num;
}
for(int j = col - 2; j >= c; j--, num++){
ret[row - 1][j] = num;
}
for(int i = row - 2; i > r; i--, num++){
ret[i][c] = num;
}
r++;
c++;
row--;
col--;
}
return ret;
}
}
| [
"[email protected]"
] | |
949c048c7ac931d410094bc2b626758e5db4fb2b | 689ba4f04a580423e670b8697739d8995184ec05 | /appajak/src/appajak/pajaktujuh.java | 23e8c66f919ac7611fdf276134eefebdb54e87c3 | [] | no_license | LaTeX2400/Tugas-Besar-TBO-PBO- | 2b7fad805cf4ded22234560b91757b56686fb0e1 | b821333c492019ed5689b038b33bd65c332dc378 | refs/heads/master | 2020-08-27T02:45:52.047534 | 2019-11-12T15:46:51 | 2019-11-12T15:46:51 | 217,222,490 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 702 | 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 appajak;
/**
*
* @author user
*/
//Penggunaan Inheritance dan Polymorphism
public class pajaktujuh extends Appajak {
//overriding method pada kelas appajak
public int getBiaya2(String nik)
{
String temp = nik.substring(4,6);
int iTemp = Integer.parseInt(temp);
if(iTemp==25)
{
return 1200000;
}
else if(iTemp == 24)
{
return 3700000;
}
else if(iTemp == 11)
{
return 1550000;
}
return 0;
}
}
| [
"[email protected]"
] | |
94f98e1d7d1be82ef4893cd055385bc921a40b0e | 6cade82d54ea09716bac62e32a8bcd0b20e557ca | /app/src/main/java/com/adrian/automat/pojo/PathwayDataBean.java | b9c3a88037c0944907a7cf0cafb8651378b65380 | [] | no_license | lyx0206331/Automat | c6bb9ac20e01caf213b8131762cf4b7d2cd7a344 | 5165c65e015d3d566c210029bce9e51457d5b694 | refs/heads/master | 2021-01-25T08:12:46.135594 | 2017-11-03T12:57:26 | 2017-11-03T12:57:26 | 93,726,926 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 660 | java | package com.adrian.automat.pojo;
/**
* Created by qing on 2017/6/23.
*/
public class PathwayDataBean {
/**
* gridId : 0
* maxNum : 0
* nowNum : 0
*/
private int gridId;
private int maxNum;
private int nowNum;
public int getGridId() {
return gridId;
}
public void setGridId(int gridId) {
this.gridId = gridId;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public int getNowNum() {
return nowNum;
}
public void setNowNum(int nowNum) {
this.nowNum = nowNum;
}
}
| [
"[email protected]"
] | |
e86d4e192ef39808c2a0a3751c7e53c332af685b | 521e17663b5f6f810ddab2562e5e0efdf6e09f10 | /MykitaApp/app/src/main/java/com/mykita/mykitaapp/model/Result.java | 582d468bd30ccc210a5f65164f64c749159c913b | [] | no_license | ankeshsomani/CreditCardFraudDetection | da66ded5464754ffa2a40f0f9c8742ccb1da17bb | 48374fd397ace331508acf7c71518a4916856ea7 | refs/heads/master | 2021-01-11T15:36:47.770946 | 2017-06-12T11:19:40 | 2017-06-12T11:19:40 | 82,466,989 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 414 | java | package com.mykita.mykitaapp.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by shreyas13732 on 6/1/2017.
*/
public class Result {
@SerializedName("msg")
@Expose
private String msg;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
| [
"[email protected]"
] | |
a865a4646078671f23015370e33edea0bd5f56cf | 8bba923942604359185cfceffc680b006efb9306 | /DatabasesFrameworksHibernate/XMLProcessingExercises/car_sales/src/main/java/com/car_dealer/dtos/view/xmlWrappers/CarsPartsXmlWrapper.java | 49f75682a11a54c56e4eb6d34e3d44754f8aded8 | [] | no_license | KaPrimov/JavaCoursesSoftUni | d8a48ab30421d7a847f35d970535ddc3da595597 | 9676ec4c9bc1ece13d64880ff47a3728227bf4c9 | refs/heads/master | 2022-12-04T13:27:47.249203 | 2022-07-14T14:44:10 | 2022-07-14T14:44:10 | 97,306,295 | 1 | 2 | null | 2022-11-24T09:28:28 | 2017-07-15T09:39:47 | Java | UTF-8 | Java | false | false | 743 | java | package com.car_dealer.dtos.view.xmlWrappers;
import com.car_dealer.dtos.view.CarPartsView;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "cars")
@XmlAccessorType(XmlAccessType.FIELD)
public class CarsPartsXmlWrapper {
@XmlElement(name = "car")
private List<CarPartsView> carPartsViews;
public CarsPartsXmlWrapper() {
}
public List<CarPartsView> getCarPartsViews() {
return carPartsViews;
}
public void setCarPartsViews(List<CarPartsView> carPartsViews) {
this.carPartsViews = carPartsViews;
}
}
| [
"[email protected]"
] | |
2f57f87ab772037fcea14de8dba1220eabd72aec | 2c92f358e57707fc1836e9941c556808c70b1678 | /src/Student.java | 522456cbf9c1f91751a0383d35096bc5f87a694f | [] | no_license | thisrandomstuff7/Govindu_vmeg_14881A0521 | be098f2f2952b432ca82b0c57de3cb90e0146522 | d0ae5d2fd3f686ca160328e6992f8746d48a8333 | refs/heads/master | 2021-06-24T20:18:50.288568 | 2017-09-13T13:33:58 | 2017-09-13T13:33:58 | 103,395,462 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,647 | java | import java.util.Date;
public class Student implements Comparable {
private int id;
private String fullName;
private Date birthDate;
private double avgMark;
public Student(int id, String fullName, Date birthDate, double avgMark) {
this.id = id;
this.fullName = fullName;
this.birthDate = birthDate;
this.avgMark = avgMark;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public Date getBirthDate() {
return this.birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public double getAvgMark() {
return avgMark;
}
public void setAvgMark(double avgMark) {
this.avgMark = avgMark;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Student)) {
return false;
}
Student s = (Student)o;
return this.getId() == s.getId() && this.getFullName() == s.getFullName() && this.getAvgMark() == s.getAvgMark() &&
this.getBirthDate().compareTo(s.getBirthDate()) == 0;
}
@Override
public int hashCode() {
return this.getId();
}
@Override
public int compareTo(Object o) {
if (!(o instanceof Student)) {
return -1;
}
Student s = (Student)o;
if(this.getId() < s.getId()) return -1;
else if(this.getId() > s.getId()) return 1;
else return 0;
}
} | [
"[email protected]"
] | |
9f1026f9acb07c1fe7f483efd3c00e82bbe10d93 | 8ebbb3729ba59e8b0d5b78295e042e56771f6a47 | /src/main/java/refactorings/improving/codesmells/primitiveobsession/PrimitiveObsessionToEnum.java | 1318f6c0f3ac0f4fb66911b52d902655e276876c | [] | no_license | nmahoude/refactorings | 61e8c50525ae4fd2e26399da6772260b6c8c8e06 | 7e0ead2e867eb9b8fa3fbe2f7474ae1b2c74d6f7 | refs/heads/master | 2022-12-24T12:49:52.988286 | 2022-12-16T13:45:48 | 2022-12-16T13:45:48 | 224,285,784 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,641 | java | package refactorings.improving.codesmells.primitiveobsession;
/**
*
* Example : A string is not a good container for value that can only one of
* multiple known values
*
* In this exercice, replace the String with an Enum representing the possible
* values
*
* Refactorings:
*
* @see Replace primitive with object
* @see Replace type code with subclasses
* @see Replace conditional with polymorphism
* @see Extract class
* @see Introduce parameter object
*/
public class PrimitiveObsessionToEnum {
String type;
/*
* insert a Username object
*/
public void setType(String type) {
this.type = type;
}
/**
* extract an Order class/object
*/
public String type() {
return type;
}
public static void main(String[] args) {
String commingFromElsewhere = "TYPE0";
// this one come from somewhere else in our code, we don't want to check if it's valid
var type0 = new PrimitiveObsessionToEnum();
type0.setType(commingFromElsewhere);
var type1 = new PrimitiveObsessionToEnum();
type1.setType("TYPE1");
var type2 = new PrimitiveObsessionToEnum();
type2.setType("TYPE2");
/** oops not a valid type in the domain! should not be possible */
var type3 = new PrimitiveObsessionToEnum();
type3.setType("UNKNOWN TYPE");
System.out.println(type0.type());
System.out.println(type1.type());
System.out.println(type2.type());
/** Just to show that Enum can be compared with ==, but not String in all circonstances */
if (type0.type().equals("TYPE0") && type1.type().equals("TYPE1") && /** and ... oops */
type1.type() == "TYPE2") {
System.out.println("OK");
}
}
}
| [
"[email protected]"
] | |
efcd308ea3a7e0c6151aea705087e8ceb1d7341c | 4f2c1383f3a96f1e8f31dafdf6a1234ed598b208 | /src/main/java/top/greatxiaozou/linkedHandler/Response.java | 3760c6118a90641c4b7b2539771d1f7ac0a07dac | [] | no_license | greatxiaozou/disignParttern | 75461f73c45c9a423110db194c60de8db28ced3b | fc16ded4d390af5c4f99ef475f69e402d09b0979 | refs/heads/main | 2023-02-01T00:41:24.785482 | 2020-12-16T00:33:13 | 2020-12-16T00:33:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 115 | java | package top.greatxiaozou.linkedHandler;
/**
* 响应类,表示对响应的封装
*/
public class Response {
}
| [
"[email protected]"
] | |
0b1407bee6fa07ab4238d59207cb4409cdefb346 | 19594c4bac17df2817a2b24744df3f74e363007b | /src/ru/mirea/lab24/task2/MagicChair.java | 4d2b437a2a0787251a51a18525e1effe73777e35 | [] | no_license | zaikin-v/mireajava2020 | 457d50d0a0a0773cd6ad3c3661416747fddd7c66 | b26d70fa60879b910c94b23294c125992e4b14ff | refs/heads/master | 2023-05-14T07:26:29.681532 | 2020-11-26T22:05:26 | 2020-11-26T22:05:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 598 | java | package ru.mirea.lab24.task2;
public class MagicChair implements Chair {
private final String material;
public MagicChair(String material) {
this.material = material;
}
public String getMaterial() {
return material;
}
public void someMagic(){
System.out.println("Magic");
}
@Override
public String toString() {
return "MagicChair{" +
"material='" + material + '\'' +
'}';
}
@Override
public void printChair() {
System.out.println("Магический стул");
}
}
| [
"[email protected]"
] | |
d23c78123b0c1e01cad1f8c3d7c32e51d0728d1e | 8d14a579925a6b462bdf5a631c95c984511215f9 | /Academy.Kovalevskyi.JavaDeepDive/src/main/java/academy/kovalevskyi/javadeepdive/week2/day1/Get.java | 7a1b0cfa4587f8c6b5f0b6720c41bd7c72891e9a | [] | no_license | Aleksey-Petrik/JavaPractice | c8194d27aaf8377bc83ff74cbf0b53830d85aef1 | ffe82e53b2cbd452811b20c03a293f9014cfb791 | refs/heads/master | 2023-08-19T05:33:28.287761 | 2021-09-29T11:56:59 | 2021-09-29T11:56:59 | 379,509,752 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 306 | java | package academy.kovalevskyi.javadeepdive.week2.day1;
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.METHOD)
public @interface Get {
}
| [
"[email protected]"
] | |
c921a540a76b1c2932219cc961f0131edbee466a | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/druid-io--druid/76cb06a8d8161d29d985ef048b89e6a82b489058/after/StaticMapExtractionNamespaceCacheFactoryTest.java | 570bf44184bb76904fc54d5cdddde57a0c7b6613 | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,196 | java | /*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets 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 io.druid.server.lookup.namespace;
import com.google.common.collect.ImmutableMap;
import io.druid.java.util.common.lifecycle.Lifecycle;
import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory;
import io.druid.query.lookup.namespace.ExtractionNamespace;
import io.druid.query.lookup.namespace.StaticMapExtractionNamespace;
import io.druid.server.lookup.namespace.cache.CacheScheduler;
import io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager;
import io.druid.server.metrics.NoopServiceEmitter;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Collections;
import java.util.Map;
public class StaticMapExtractionNamespaceCacheFactoryTest
{
private static final Map<String, String> MAP = ImmutableMap.<String, String>builder().put("foo", "bar").build();
private Lifecycle lifecycle;
private CacheScheduler scheduler;
@Before
public void setup() throws Exception
{
lifecycle = new Lifecycle();
lifecycle.start();
NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter();
scheduler = new CacheScheduler(
noopServiceEmitter,
Collections.<Class<? extends ExtractionNamespace>, ExtractionNamespaceCacheFactory<?>>emptyMap(),
new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter)
);
}
@After
public void tearDown()
{
lifecycle.stop();
}
@Test
public void testSimplePopulator() throws Exception
{
final StaticMapExtractionNamespaceCacheFactory factory = new StaticMapExtractionNamespaceCacheFactory();
final StaticMapExtractionNamespace namespace = new StaticMapExtractionNamespace(MAP);
CacheScheduler.VersionedCache versionedCache = factory.populateCache(namespace, null, null, scheduler);
Assert.assertNotNull(versionedCache);
Assert.assertEquals(factory.getVersion(), versionedCache.getVersion());
Assert.assertEquals(MAP, versionedCache.getCache());
}
@Test(expected = AssertionError.class)
public void testNonNullLastVersionCausesAssertionError()
{
final StaticMapExtractionNamespaceCacheFactory factory = new StaticMapExtractionNamespaceCacheFactory();
final StaticMapExtractionNamespace namespace = new StaticMapExtractionNamespace(MAP);
factory.populateCache(namespace, null, factory.getVersion(), scheduler);
}
} | [
"[email protected]"
] | |
f601b5a7c9c5d110e1523a5734c4d81295ba6156 | 352163a8f69f64bc87a9e14471c947e51bd6b27d | /bin/ext-deprecated/cybersource/testsrc/de/hybris/platform/payment/methods/impl/DefaultCardPaymentServiceImplTest.java | 6e9c5a1396b48de4eff4e3eed77cfc2dacb7e7bd | [] | no_license | GTNDYanagisawa/merchandise | 2ad5209480d5dc7d946a442479cfd60649137109 | e9773338d63d4f053954d396835ac25ef71039d3 | refs/heads/master | 2021-01-22T20:45:31.217238 | 2015-05-20T06:23:45 | 2015-05-20T06:23:45 | 35,868,211 | 3 | 5 | null | null | null | null | UTF-8 | Java | false | false | 42,456 | java | /*
* [y] hybris Platform
*
* Copyright (c) 2000-2014 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
*
*
*/
package de.hybris.platform.payment.methods.impl;
import de.hybris.bootstrap.annotations.ManualTest;
import de.hybris.platform.core.Registry;
import de.hybris.platform.core.enums.CreditCardType;
import de.hybris.platform.payment.commands.factory.CommandNotSupportedException;
import de.hybris.platform.payment.commands.request.AuthorizationRequest;
import de.hybris.platform.payment.commands.request.CaptureRequest;
import de.hybris.platform.payment.commands.request.CreateSubscriptionRequest;
import de.hybris.platform.payment.commands.request.EnrollmentCheckRequest;
import de.hybris.platform.payment.commands.request.FollowOnRefundRequest;
import de.hybris.platform.payment.commands.request.StandaloneRefundRequest;
import de.hybris.platform.payment.commands.request.SubscriptionAuthorizationRequest;
import de.hybris.platform.payment.commands.request.SubscriptionDataRequest;
import de.hybris.platform.payment.commands.request.UpdateSubscriptionRequest;
import de.hybris.platform.payment.commands.request.VoidRequest;
import de.hybris.platform.payment.commands.result.AuthorizationResult;
import de.hybris.platform.payment.commands.result.CaptureResult;
import de.hybris.platform.payment.commands.result.EnrollmentCheckResult;
import de.hybris.platform.payment.commands.result.RefundResult;
import de.hybris.platform.payment.commands.result.SubscriptionDataResult;
import de.hybris.platform.payment.commands.result.SubscriptionResult;
import de.hybris.platform.payment.commands.result.VoidResult;
import de.hybris.platform.payment.dto.BillingInfo;
import de.hybris.platform.payment.dto.CardInfo;
import de.hybris.platform.payment.dto.TransactionStatus;
import de.hybris.platform.payment.dto.TransactionStatusDetails;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Currency;
import junit.framework.Assert;
import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
@ManualTest
//manual test: sended request count to external ressouce is limited
public class DefaultCardPaymentServiceImplTest
{
private static final String TEST_CC_NUMBER = "4111111111111111";
private static final String TEST_CC_NUMBER_VISA_3D_01 = "4000000000000002";
//private static final String TEST_CC_NUMBER_VISA_3D_02 = "4000000000000119";
private static final String TEST_CC_NUMBER_VISA_3D_NOT_ENROLLED = "4000000000000051";
private static final String TEST_CC_NUMBER_VISA_3D_ERROR = "4000000000000051";
private static final int TEST_CC_EXPIRATION_MONTH = 12;
private static final int TEST_CC_EXPIRATION_YEAR = (Calendar.getInstance().get(Calendar.YEAR) + 2);
private static final Currency TEST_CURRENCY = Currency.getInstance("USD");
private static final String HTTP_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
private static final String HTTP_USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729)";
private static DefaultCardPaymentServiceImpl cardPaymentService;
@BeforeClass
public static void init()
{
Registry.activateMasterTenant();
final ApplicationContext applicationContext = Registry.getGlobalApplicationContext();
cardPaymentService = (DefaultCardPaymentServiceImpl) applicationContext.getBean("cardPaymentService");
}
@Test
public void testAuthorize() throws CommandNotSupportedException
{
final double moneyAmount = 117.83;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo billingInfo = createBillingInfo();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(billingInfo);
final AuthorizationResult resp = cardPaymentService.authorize(new AuthorizationRequest(testMerchantReferenceCode, card,
TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, resp.getTransactionStatusDetails());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), resp.getTotalAmount());
Assert.assertNotNull(resp.getAuthorizationTime());
Assert.assertNotNull(resp.getRequestId());
Assert.assertNotNull(resp.getRequestToken());
}
@Test
public void testSubscriptionAuthorizeFail() throws CommandNotSupportedException
{
final double moneyAmount = 117.83;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo billingInfo = createBillingInfo();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(billingInfo);
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
final AuthorizationResult resp = cardPaymentService.authorize(new SubscriptionAuthorizationRequest(
testMerchantReferenceCode, "9852331711410008284319", TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo,
authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.REJECTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.INVALID_REQUEST, resp.getTransactionStatusDetails());
}
@Test
public void testAuthorizeFail() throws CommandNotSupportedException
{
final double moneyAmount = 117.83;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo billingInfo = createBillingInfo();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(billingInfo);
card.setCardNumber("12354657489");
final AuthorizationResult resp = cardPaymentService.authorize(new AuthorizationRequest(testMerchantReferenceCode, card,
TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.REJECTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.INVALID_ACCOUNT_NUMBER, resp.getTransactionStatusDetails());
}
/**
* Tests authorization capture. It makes two requests: first one to authorize CC, second one to capture the
* authorization.
*
* @throws CommandNotSupportedException
*/
@Test
public void testCapture() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final CaptureResult captureResult = cardPaymentService.capture(new CaptureRequest(testMerchantReferenceCode,
authorizationResult.getRequestId(), authorizationResult.getRequestToken(), TEST_CURRENCY, BigDecimal
.valueOf(moneyAmount), authorizationResult.getPaymentProvider()));
Assert.assertEquals(testMerchantReferenceCode, captureResult.getMerchantTransactionCode());
Assert.assertEquals(TransactionStatus.ACCEPTED, captureResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, captureResult.getTransactionStatusDetails());
Assert.assertEquals(TEST_CURRENCY, captureResult.getCurrency());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), captureResult.getTotalAmount());
Assert.assertNotNull(captureResult.getRequestTime());
Assert.assertNotNull(captureResult.getRequestId());
Assert.assertNotNull(captureResult.getRequestToken());
Assert.assertNotNull(captureResult.getReconciliationId());
}
@Test
public void testEnrollmentCheckRequired() throws CommandNotSupportedException
{
final double moneyAmount = 732.19;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final CardInfo cardInfo = new CardInfo();
cardInfo.setCardNumber(TEST_CC_NUMBER_VISA_3D_01);
cardInfo.setExpirationMonth(Integer.valueOf(TEST_CC_EXPIRATION_MONTH));
cardInfo.setExpirationYear(Integer.valueOf(TEST_CC_EXPIRATION_YEAR));
final EnrollmentCheckResult enrollmentCheckResult = cardPaymentService.enrollmentCheck(new EnrollmentCheckRequest(
testMerchantReferenceCode, cardInfo, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), HTTP_ACCEPT, HTTP_USER_AGENT));
Assert.assertNotNull(enrollmentCheckResult);
Assert.assertNotNull(enrollmentCheckResult.getAcsURL());
Assert.assertNotNull(enrollmentCheckResult.getPaReq());
Assert.assertNotNull(enrollmentCheckResult.getProxyPAN());
Assert.assertNotNull(enrollmentCheckResult.getXid());
Assert.assertNotNull(enrollmentCheckResult.getProofXml());
Assert.assertEquals("Y", enrollmentCheckResult.getVeresEnrolled());
Assert.assertEquals(TransactionStatus.REJECTED, enrollmentCheckResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.THREE_D_SECURE_AUTHENTICATION_REQUIRED,
enrollmentCheckResult.getTransactionStatusDetails());
}
@Test
public void testEnrollmentCheckNotSupported() throws CommandNotSupportedException
{
final double moneyAmount = 732.19;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final CardInfo cardInfo = new CardInfo();
cardInfo.setCardNumber(TEST_CC_NUMBER_VISA_3D_NOT_ENROLLED);
cardInfo.setExpirationMonth(Integer.valueOf(TEST_CC_EXPIRATION_MONTH));
cardInfo.setExpirationYear(Integer.valueOf(TEST_CC_EXPIRATION_YEAR));
final EnrollmentCheckResult enrollmentCheckResult = cardPaymentService.enrollmentCheck(new EnrollmentCheckRequest(
testMerchantReferenceCode, cardInfo, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), HTTP_ACCEPT, HTTP_USER_AGENT));
Assert.assertNotNull(enrollmentCheckResult);
Assert.assertNull(enrollmentCheckResult.getAcsURL());
Assert.assertNull(enrollmentCheckResult.getPaReq());
Assert.assertNull(enrollmentCheckResult.getProxyPAN());
Assert.assertNull(enrollmentCheckResult.getXid());
Assert.assertNotNull(enrollmentCheckResult.getProofXml());
Assert.assertNotNull(enrollmentCheckResult.getCommerceIndicator());
Assert.assertNotSame("Y", enrollmentCheckResult.getVeresEnrolled());
Assert.assertEquals(TransactionStatus.ACCEPTED, enrollmentCheckResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.THREE_D_SECURE_NOT_SUPPORTED,
enrollmentCheckResult.getTransactionStatusDetails());
}
@Test
public void testEnrollmentCheckError() throws CommandNotSupportedException
{
final double moneyAmount = 591.33;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final CardInfo cardInfo = new CardInfo();
cardInfo.setCardNumber(TEST_CC_NUMBER_VISA_3D_ERROR);
cardInfo.setExpirationMonth(Integer.valueOf(TEST_CC_EXPIRATION_MONTH));
cardInfo.setExpirationYear(Integer.valueOf(TEST_CC_EXPIRATION_YEAR));
final EnrollmentCheckResult enrollmentCheckResult = cardPaymentService.enrollmentCheck(new EnrollmentCheckRequest(
testMerchantReferenceCode, cardInfo, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), HTTP_ACCEPT, HTTP_USER_AGENT));
Assert.assertNotNull(enrollmentCheckResult);
Assert.assertNull(enrollmentCheckResult.getAcsURL());
Assert.assertNull(enrollmentCheckResult.getPaReq());
Assert.assertNull(enrollmentCheckResult.getProxyPAN());
Assert.assertNull(enrollmentCheckResult.getXid());
Assert.assertNotNull(enrollmentCheckResult.getProofXml());
Assert.assertNotNull(enrollmentCheckResult.getCommerceIndicator());
Assert.assertNotSame("Y", enrollmentCheckResult.getVeresEnrolled());
Assert.assertEquals(TransactionStatus.ACCEPTED, enrollmentCheckResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.THREE_D_SECURE_NOT_SUPPORTED,
enrollmentCheckResult.getTransactionStatusDetails());
}
@Test
public void testVoidCreditOrCapture() throws CommandNotSupportedException
{
final double moneyAmount = 117.83;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo billingInfo = createBillingInfo();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(billingInfo);
final AuthorizationResult resp = cardPaymentService.authorize(new AuthorizationRequest(testMerchantReferenceCode, card,
TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, resp.getTransactionStatusDetails());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), resp.getTotalAmount());
Assert.assertNotNull(resp.getAuthorizationTime());
Assert.assertNotNull(resp.getRequestId());
Assert.assertNotNull(resp.getRequestToken());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final CaptureResult captureResult = cardPaymentService.capture(new CaptureRequest(testMerchantReferenceCode,
authorizationResult.getRequestId(), authorizationResult.getRequestToken(), TEST_CURRENCY, BigDecimal
.valueOf(moneyAmount), authorizationResult.getPaymentProvider()));
Assert.assertEquals(testMerchantReferenceCode, captureResult.getMerchantTransactionCode());
Assert.assertEquals(TransactionStatus.ACCEPTED, captureResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, captureResult.getTransactionStatusDetails());
Assert.assertEquals(TEST_CURRENCY, captureResult.getCurrency());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), captureResult.getTotalAmount());
Assert.assertNotNull(captureResult.getRequestTime());
Assert.assertNotNull(captureResult.getRequestId());
Assert.assertNotNull(captureResult.getRequestToken());
Assert.assertNotNull(captureResult.getReconciliationId());
final VoidResult refundResult = cardPaymentService.voidCreditOrCapture(new VoidRequest(testMerchantReferenceCode,
captureResult.getRequestId(), captureResult.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertNotNull(refundResult);
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult.getTransactionStatus());
Assert.assertEquals(refundResult.getAmount(), BigDecimal.valueOf(moneyAmount));
}
@Test
public void testVoidCreditOrCaptureNotVoidable() throws CommandNotSupportedException
{
final double moneyAmount = 117.83;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo billingInfo = createBillingInfo();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(billingInfo);
final AuthorizationResult resp = cardPaymentService.authorize(new AuthorizationRequest(testMerchantReferenceCode, card,
TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, resp.getTransactionStatusDetails());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), resp.getTotalAmount());
Assert.assertNotNull(resp.getAuthorizationTime());
Assert.assertNotNull(resp.getRequestId());
Assert.assertNotNull(resp.getRequestToken());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final VoidResult refundResult = cardPaymentService.voidCreditOrCapture(new VoidRequest(testMerchantReferenceCode,
authorizationResult.getRequestId(), authorizationResult.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertNotNull(refundResult);
Assert.assertEquals(TransactionStatus.REJECTED, refundResult.getTransactionStatus());
Assert.assertEquals(refundResult.getTransactionStatusDetails(), TransactionStatusDetails.NOT_VOIDABLE);
}
@Test
public void testRefundFollowOn() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final CaptureResult captureResult = cardPaymentService.capture(new CaptureRequest(testMerchantReferenceCode,
authorizationResult.getRequestId(), authorizationResult.getRequestToken(), TEST_CURRENCY, BigDecimal
.valueOf(moneyAmount), authorizationResult.getPaymentProvider()));
Assert.assertEquals(testMerchantReferenceCode, captureResult.getMerchantTransactionCode());
Assert.assertEquals(TransactionStatus.ACCEPTED, captureResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, captureResult.getTransactionStatusDetails());
Assert.assertEquals(TEST_CURRENCY, captureResult.getCurrency());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), captureResult.getTotalAmount());
Assert.assertNotNull(captureResult.getRequestTime());
Assert.assertNotNull(captureResult.getRequestId());
Assert.assertNotNull(captureResult.getRequestToken());
Assert.assertNotNull(captureResult.getReconciliationId());
final RefundResult refundResult = cardPaymentService.refundFollowOn(new FollowOnRefundRequest(testMerchantReferenceCode,
captureResult.getRequestId(), captureResult.getRequestToken(), captureResult.getCurrency(), captureResult
.getTotalAmount().subtract(new BigDecimal(25)), authorizationResult.getPaymentProvider()));
Assert.assertNotNull(refundResult);
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, refundResult.getTransactionStatusDetails());
Assert.assertNotNull(refundResult.getReconciliationId());
Assert.assertNotNull(refundResult.getRequestTime());
Assert.assertEquals(refundResult.getTotalAmount(), captureResult.getTotalAmount().subtract(new BigDecimal(25)));
Assert.assertNotNull(refundResult.getCurrency());
final RefundResult refundResult2 = cardPaymentService.refundFollowOn(new FollowOnRefundRequest(testMerchantReferenceCode,
captureResult.getRequestId(), captureResult.getRequestToken(), captureResult.getCurrency(), new BigDecimal(12),
authorizationResult.getPaymentProvider()));
Assert.assertNotNull(refundResult2);
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult2.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, refundResult2.getTransactionStatusDetails());
Assert.assertNotNull(refundResult2.getReconciliationId());
Assert.assertNotNull(refundResult2.getRequestTime());
Assert.assertEquals(refundResult2.getTotalAmount(), new BigDecimal("12.00"));
Assert.assertNotNull(refundResult2.getCurrency());
final RefundResult refundResult3 = cardPaymentService.refundFollowOn(new FollowOnRefundRequest(testMerchantReferenceCode,
captureResult.getRequestId(), captureResult.getRequestToken(), captureResult.getCurrency(), new BigDecimal(25),
authorizationResult.getPaymentProvider()));
Assert.assertNotNull(refundResult3);
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult3.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, refundResult3.getTransactionStatusDetails());
Assert.assertNotNull(refundResult3.getReconciliationId());
Assert.assertNotNull(refundResult3.getRequestTime());
Assert.assertEquals(refundResult3.getTotalAmount(), new BigDecimal("25.00"));
Assert.assertNotNull(refundResult3.getCurrency());
}
@Test
public void testRefundStandalone() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final CaptureResult captureResult = cardPaymentService.capture(new CaptureRequest(testMerchantReferenceCode,
authorizationResult.getRequestId(), authorizationResult.getRequestToken(), TEST_CURRENCY, BigDecimal
.valueOf(moneyAmount), authorizationResult.getPaymentProvider()));
Assert.assertEquals(testMerchantReferenceCode, captureResult.getMerchantTransactionCode());
Assert.assertEquals(TransactionStatus.ACCEPTED, captureResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, captureResult.getTransactionStatusDetails());
Assert.assertEquals(TEST_CURRENCY, captureResult.getCurrency());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), captureResult.getTotalAmount());
Assert.assertNotNull(captureResult.getRequestTime());
Assert.assertNotNull(captureResult.getRequestId());
Assert.assertNotNull(captureResult.getRequestToken());
Assert.assertNotNull(captureResult.getReconciliationId());
final RefundResult refundResult = cardPaymentService.refundStandalone(new StandaloneRefundRequest(
testMerchantReferenceCode, createBillingInfo(), getCardInfo(createBillingInfo()), captureResult.getCurrency(),
captureResult.getTotalAmount()));
Assert.assertNotNull(refundResult);
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, refundResult.getTransactionStatusDetails());
Assert.assertNotNull(refundResult.getReconciliationId());
Assert.assertNotNull(refundResult.getRequestTime());
Assert.assertEquals(refundResult.getTotalAmount(), captureResult.getTotalAmount());
Assert.assertNotNull(refundResult.getCurrency());
}
/**
* Tests subscription create and authorize functionality.
*
* @throws CommandNotSupportedException
*/
@Test
public void testCreateAndAuthorizeSubscription() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(new CreateSubscriptionRequest(
testMerchantReferenceCode, shippingInfo, TEST_CURRENCY, card, authorizationResult.getRequestId(), authorizationResult
.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
final AuthorizationResult resp = cardPaymentService.authorize(new SubscriptionAuthorizationRequest(
testMerchantReferenceCode, subscriptionResult.getSubscriptionID(), TEST_CURRENCY, BigDecimal.valueOf(moneyAmount),
shippingInfo, authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, resp.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, resp.getTransactionStatusDetails());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), resp.getTotalAmount());
Assert.assertNotNull(resp.getAuthorizationTime());
Assert.assertNotNull(resp.getRequestId());
Assert.assertNotNull(resp.getRequestToken());
}
/**
* Tests subscription create standalone.
*
* @throws CommandNotSupportedException
*/
@Test
public void testCreateSubscriptionStandalone() throws CommandNotSupportedException
{
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final CreateSubscriptionRequest request = new CreateSubscriptionRequest(testMerchantReferenceCode, shippingInfo,
TEST_CURRENCY, card, null, null, "Cybersource");
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(request);
Logger.getLogger(DefaultCardPaymentServiceImplTest.class).info(
" *** TXN RESULT: " + subscriptionResult.getTransactionStatus() + " ["
+ subscriptionResult.getTransactionStatusDetails() + "] ***");
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
}
/**
* Tests subscription use. It makes three requests: first one to authorize CC, second one to make the subscription
* and third to use it
*
* @throws CommandNotSupportedException
*/
@Test
public void testUseSubscriptionForAuthorization() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final double secondMoneyAmount = 29.92;
// authorize
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
// create subscription
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(new CreateSubscriptionRequest(
testMerchantReferenceCode, shippingInfo, TEST_CURRENCY, card, authorizationResult.getRequestId(), authorizationResult
.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
// authorize using subscription
final String subscriptionID = subscriptionResult.getSubscriptionID();
final AuthorizationResult secondAuthorizationResult = cardPaymentService.authorize(new SubscriptionAuthorizationRequest(
testMerchantReferenceCode, subscriptionID, TEST_CURRENCY, BigDecimal.valueOf(secondMoneyAmount), null,
authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, secondAuthorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(secondMoneyAmount), secondAuthorizationResult.getTotalAmount());
Assert.assertNotNull(secondAuthorizationResult.getAuthorizationTime());
Assert.assertNotNull(secondAuthorizationResult.getRequestId());
Assert.assertNotNull(secondAuthorizationResult.getRequestToken());
}
/**
* Tests subscription update. It makes three requests: first one to authorize CC, second one to make the subscription
* and third to update it
*
* @throws CommandNotSupportedException
*/
@Test
public void testUpdateSubscription() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
// authorize
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
Assert.assertNotNull(authorizationResult.getPaymentProvider());
// create subscription
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(new CreateSubscriptionRequest(
testMerchantReferenceCode, shippingInfo, TEST_CURRENCY, card, authorizationResult.getRequestId(), authorizationResult
.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
// update subscription
shippingInfo.setStreet1("1221 N NewStreet");
card.setExpirationYear(Integer.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 4));
final String subscriptionID = subscriptionResult.getSubscriptionID();
final SubscriptionResult secondSubscriptionResult = cardPaymentService.updateSubscription(new UpdateSubscriptionRequest(
testMerchantReferenceCode, subscriptionID, authorizationResult.getPaymentProvider(), shippingInfo, card));
Assert.assertEquals(TransactionStatus.ACCEPTED, secondSubscriptionResult.getTransactionStatus());
Assert.assertNotNull(secondSubscriptionResult.getRequestId());
Assert.assertNotNull(secondSubscriptionResult.getRequestToken());
}
@Test
public void testGetSubscriptionData() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
// authorize
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfoOrig = createShippingInfo();
final BillingInfo billingInfo = createBillingInfo();
final CardInfo cardOrig = getCardInfo(billingInfo);
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, cardOrig, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfoOrig));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
Assert.assertNotNull(authorizationResult.getPaymentProvider());
// create subscription first
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(new CreateSubscriptionRequest(
testMerchantReferenceCode, shippingInfoOrig, TEST_CURRENCY, cardOrig, authorizationResult.getRequestId(),
authorizationResult.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
// get info back
final SubscriptionDataResult subscriptionDataResult = cardPaymentService.getSubscriptionData(new SubscriptionDataRequest(
testMerchantReferenceCode, subscriptionResult.getSubscriptionID(), authorizationResult.getPaymentProvider()));
Logger.getLogger(DefaultCardPaymentServiceImplTest.class).info(
" *** TXN RESULT: " + subscriptionDataResult.getTransactionStatus() + " ["
+ subscriptionDataResult.getTransactionStatusDetails() + "] ***");
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionDataResult.getTransactionStatus());
Assert.assertNotNull(subscriptionDataResult.getRequestId());
Assert.assertNotNull(subscriptionDataResult.getRequestToken());
Assert.assertEquals("411111XXXXXX1111", subscriptionDataResult.getCard().getCardNumber());
Assert.assertEquals(cardOrig.getCardType(), subscriptionDataResult.getCard().getCardType());
Assert.assertEquals(cardOrig.getExpirationMonth(), subscriptionDataResult.getCard().getExpirationMonth());
Assert.assertEquals(cardOrig.getExpirationYear(), subscriptionDataResult.getCard().getExpirationYear());
Assert.assertEquals(billingInfo.getFirstName().toUpperCase(), subscriptionDataResult.getBillingInfo().getFirstName());
Assert.assertEquals(billingInfo.getLastName().toUpperCase(), subscriptionDataResult.getBillingInfo().getLastName());
Assert.assertEquals(billingInfo.getStreet1(), subscriptionDataResult.getBillingInfo().getStreet1());
Assert.assertEquals(billingInfo.getStreet2(), subscriptionDataResult.getBillingInfo().getStreet2());
Assert.assertEquals(billingInfo.getCity(), subscriptionDataResult.getBillingInfo().getCity());
Assert.assertEquals(billingInfo.getState(), subscriptionDataResult.getBillingInfo().getState());
Assert.assertEquals(billingInfo.getCountry(), subscriptionDataResult.getBillingInfo().getCountry());
Assert.assertEquals(billingInfo.getPostalCode(), subscriptionDataResult.getBillingInfo().getPostalCode());
}
/**
* Tests subscription use. It makes three requests: first one to authorize CC, second one to make the subscription
* and third to use it
*
* @throws CommandNotSupportedException
*/
@Test
public void testUseSubscriptionForStandaloneRefund() throws CommandNotSupportedException
{
final double moneyAmount = 161.47;
final double secondMoneyAmount = 29.92;
// authorize
final String testMerchantReferenceCode = generateMerchantReferenceCode();
final BillingInfo shippingInfo = createShippingInfo();
final CardInfo card = getCardInfo(createBillingInfo());
final AuthorizationResult authorizationResult = cardPaymentService.authorize(new AuthorizationRequest(
testMerchantReferenceCode, card, TEST_CURRENCY, BigDecimal.valueOf(moneyAmount), shippingInfo));
Assert.assertEquals(TransactionStatus.ACCEPTED, authorizationResult.getTransactionStatus());
Assert.assertEquals(BigDecimal.valueOf(moneyAmount), authorizationResult.getTotalAmount());
Assert.assertNotNull(authorizationResult.getAuthorizationTime());
Assert.assertNotNull(authorizationResult.getRequestId());
Assert.assertNotNull(authorizationResult.getRequestToken());
// create subscription
final SubscriptionResult subscriptionResult = cardPaymentService.createSubscription(new CreateSubscriptionRequest(
testMerchantReferenceCode, shippingInfo, TEST_CURRENCY, card, authorizationResult.getRequestId(), authorizationResult
.getRequestToken(), authorizationResult.getPaymentProvider()));
Assert.assertEquals(TransactionStatus.ACCEPTED, subscriptionResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, subscriptionResult.getTransactionStatusDetails());
Assert.assertNotNull(subscriptionResult.getRequestId());
Assert.assertNotNull(subscriptionResult.getRequestToken());
Assert.assertNotNull(subscriptionResult.getSubscriptionID());
// standalone refund using subscription
final String subscriptionID = subscriptionResult.getSubscriptionID();
final RefundResult refundResult = cardPaymentService.refundStandalone(new StandaloneRefundRequest(
testMerchantReferenceCode, subscriptionID, null, null, TEST_CURRENCY, BigDecimal.valueOf(secondMoneyAmount)));
Assert.assertEquals(TransactionStatus.ACCEPTED, refundResult.getTransactionStatus());
Assert.assertEquals(TransactionStatusDetails.SUCCESFULL, refundResult.getTransactionStatusDetails());
Assert.assertNotNull(refundResult.getReconciliationId());
Assert.assertNotNull(refundResult.getRequestTime());
Assert.assertNotNull(refundResult.getCurrency());
Assert.assertEquals(BigDecimal.valueOf(secondMoneyAmount), refundResult.getTotalAmount());
Assert.assertNotNull(refundResult.getRequestId());
Assert.assertNotNull(refundResult.getRequestToken());
}
///////////// TESTING IS OVER AT THIS POINT ///////////////
private BillingInfo createShippingInfo()
{
final BillingInfo shippingInfo = new BillingInfo();
shippingInfo.setFirstName("Jane");
shippingInfo.setLastName("Doe");
shippingInfo.setStreet1("100 Elm Street");
shippingInfo.setCity("San Mateo");
shippingInfo.setState("CA");
shippingInfo.setPostalCode("94401");
shippingInfo.setCountry("US");
shippingInfo.setEmail("[email protected]");
return shippingInfo;
}
private BillingInfo createBillingInfo()
{
final BillingInfo billingInfo = new BillingInfo();
billingInfo.setCity("Mountain View");
billingInfo.setCountry("US");
billingInfo.setEmail("[email protected]");
billingInfo.setFirstName("John");
billingInfo.setIpAddress("10.7" + "." + "7.7");
billingInfo.setLastName("Doe");
billingInfo.setPhoneNumber("650-965-6000");
billingInfo.setPostalCode("94043");
billingInfo.setState("CA");
billingInfo.setStreet1("1295 Charleston Road");
return billingInfo;
}
private CardInfo getCardInfo(final BillingInfo billingInfo)
{
final CardInfo card = new CardInfo();
card.setCardHolderFullName("John Doe");
card.setCardNumber(TEST_CC_NUMBER);
card.setExpirationMonth(Integer.valueOf(TEST_CC_EXPIRATION_MONTH));
card.setExpirationYear(Integer.valueOf(TEST_CC_EXPIRATION_YEAR));
card.setBillingInfo(billingInfo);
card.setCardType(CreditCardType.VISA);
return card;
}
private String generateMerchantReferenceCode()
{
final String currentTime = String.valueOf(System.currentTimeMillis());
return "testMerchant" + currentTime.substring(currentTime.length() - 3);
}
}
| [
"[email protected]"
] | |
835ba040fd9b339da9cb3c93ba2319d6b8161039 | ccd352da136456f0e3461db604e86415ac54c739 | /languages/src/main/java/com/buran/languages/LanguagesApplication.java | a7927e97e69bcf88a74aec29a2766fcafacd77b8 | [] | no_license | albur2021/Java_Projects_2021 | 22dc89b0457fdb4ab093cd4cb750615850227f7d | ab9749895fc6d87159e7e59c5bdc7aab3fb5c583 | refs/heads/main | 2023-08-01T23:59:57.711430 | 2021-10-08T20:36:46 | 2021-10-08T20:36:46 | 415,119,799 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 318 | java | package com.buran.languages;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LanguagesApplication {
public static void main(String[] args) {
SpringApplication.run(LanguagesApplication.class, args);
}
}
| [
"[email protected]"
] | |
8ec74119e59e1cd2b0ad59112570f2a7d9741546 | 08a7024f7c502d83f6bc844c401844f77592d0bd | /Android/Buoi1/app/src/androidTest/java/com/t3h/buoi1/ExampleInstrumentedTest.java | 9659f77b79a736a355dd330d485f0afec25ae0e8 | [] | no_license | bacnv1/LANDT1910E | b6e532b31d91939a06f9022abbfb69af84b52cc8 | 1fe6f3f89ef82244956d56096a3e6b4dfa17f533 | refs/heads/master | 2020-09-05T05:27:00.343012 | 2020-08-30T08:43:20 | 2020-08-30T08:43:20 | 219,996,601 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 742 | java | package com.t3h.buoi1;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.t3h.buoi1", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
b69654078162d60db268ad4f244ea214aa6068e7 | 64e3808f7cf3204c3f5f7a0ecb18aeb9f5882b44 | /1100~1200/1145. Binary Tree Coloring Game.java | 878a20fa7bb6059aa7ab9d2ca4fa5b2b13f7e799 | [] | no_license | yuzhe1997/Leetcode-from-start-to-the-end | f7796f711d304f41a28f86718471052847f39d5f | 46eef9fbcbb51d15319c3c14367c8455353df529 | refs/heads/master | 2023-01-30T15:16:58.237961 | 2020-12-11T14:22:09 | 2020-12-11T14:22:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,317 | java | /*
Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value from 1 to n.
Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x. The first player colors the node with value x red, and the second player colors the node with value y blue.
Then, the players take turns starting with the first player. In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an uncolored neighbor of the chosen node (either the left child, right child, or parent of the chosen node.)
If (and only if) a player cannot choose such a node in this way, they must pass their turn. If both players pass their turn, the game ends, and the winner is the player that colored more nodes.
You are the second player. If it is possible to choose such a y to ensure you win the game, return true. If it is not possible, return false.
Example 1:
Input: root = [1,2,3,4,5,6,7,8,9,10,11], n = 11, x = 3
Output: true
Explanation: The second player can choose the node with value 2.
Constraints:
root is the root of a binary tree with n nodes and distinct node values from 1 to n.
n is odd.
1 <= x <= n <= 100
*/
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class Solution {
int L = 0;
int R = 0;
public boolean btreeGameWinningMove(TreeNode root, int n, int x) {
dfs(root, x);
return L > n / 2 || R > n / 2 || (L + R) < n / 2;
}
private boolean dfs(TreeNode node, int x) {
if (node == null) return false;
if (node.val == x) {
L = sum(node.left);
R = sum(node.right);
return true;
}
return dfs(node.left, x) || dfs(node.right, x);
}
private int sum(TreeNode node) {
if (node == null) return 0;
return 1 + sum(node.left) + sum(node.right);
}
} | [
"[email protected]"
] | |
c6ce57c00495dcba89840790f7c74d80cf5902b9 | bc0c107458f246ab3938cb791b5dc04cf9e47094 | /java-basics/src/main/java/com/charjay/jcf/map/HashMapThread.java | e45c8bb599346419d11d9c04e406d3440ac8ae6b | [] | no_license | CharJay/interview | ed0a5fbea97825df87df4aef775a71f2e704eb1a | 282cebaebd20c4dd90fe39d9a680f83afe1d16df | refs/heads/master | 2021-05-19T18:32:51.710806 | 2020-04-01T04:35:17 | 2020-04-01T04:35:17 | 252,065,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 934 | java | package com.charjay.jcf.map;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* HashMap在高并发下可能导致的并发异常
*
* @author taomk 2017年8月7日 下午2:33:55
*
*/
public class HashMapThread extends Thread{
private static AtomicInteger ai = new AtomicInteger();
private static Map<Integer, Integer> m = new HashMap<Integer, Integer>(1);
@Override
public void run() {
while(ai.get()<1000*1000){
m.put(ai.get(), ai.get());
ai.incrementAndGet();
}
}
public static void main(String[] args) {
HashMapThread hmt0 = new HashMapThread();
HashMapThread hmt1 = new HashMapThread();
HashMapThread hmt2 = new HashMapThread();
HashMapThread hmt3 = new HashMapThread();
HashMapThread hmt4 = new HashMapThread();
hmt0.start();
hmt1.start();
hmt2.start();
hmt3.start();
hmt4.start();
}
}
| [
"[email protected]"
] | |
c32be618cd9cfc40b9e16ee91a397cba5f0228cf | f5f6f106b33e3720fc71960bace057e195235ea2 | /app/src/main/java/com/rizki/gurukudev/MuridLoginRegisActivity.java | 32e645a1e12054b21d9cf7353ed49634aed386fc | [] | no_license | syafiradeta/SMKCoding--Syafira-Deta-Syajida-SiJagur-Ex.SMKCoding-eventday | eacd1aae738b3ba3a2c516901e0b72ac8400f6fb | a3b74c0563782ef31926ba9e81ccaa982b9455c4 | refs/heads/master | 2020-09-16T02:42:16.970383 | 2019-11-23T17:11:21 | 2019-11-23T17:11:21 | 223,624,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,686 | java | package com.rizki.gurukudev;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MuridLoginRegisActivity extends AppCompatActivity {
private Button btnLoginMurid, btnRegisMurid;
private TextView tvhalo, tvLogin;
private EditText etEmailMurid, etPasswordMurid;
private ProgressDialog loadingBar;
private FirebaseAuth mAuth;
private DatabaseReference MuridDbRef;
private String onlineMuridId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_murid_login_regis);
btnLoginMurid = findViewById(R.id.btn_LoginMurid);
tvLogin = findViewById(R.id.tv_loginMurid);
etEmailMurid = findViewById(R.id.etEmailMurid);
etPasswordMurid = findViewById(R.id.etPasswordMurid);
mAuth = FirebaseAuth.getInstance();
loadingBar = new ProgressDialog(this);
btnRegisMurid = findViewById(R.id.btn_RegisMurid);
tvhalo = findViewById(R.id.tvhalo);
btnRegisMurid.setVisibility(View.GONE);
tvhalo.setOnClickListener(v -> {
btnLoginMurid.setVisibility(View.GONE);
tvhalo.setVisibility(View.GONE);
btnRegisMurid.setVisibility(View.VISIBLE);
btnRegisMurid.setText("Register Now");
tvLogin.setText("Register\nsebagai Murid");
});
btnRegisMurid.setOnClickListener(v -> {
String email = etEmailMurid.getText().toString();
String password = etPasswordMurid.getText().toString();
RegisterMurid(email, password);
});
btnLoginMurid.setOnClickListener(v -> {
String email = etEmailMurid.getText().toString();
String password = etPasswordMurid.getText().toString();
LoginMurid(email, password);
});
}
private void LoginMurid(String email, String password) {
if(TextUtils.isEmpty(email)){
Toast.makeText(MuridLoginRegisActivity.this, "E-mail nya jangan kosong dong", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(password)){
Toast.makeText(MuridLoginRegisActivity.this, "Hayo Password nya masih kosong tuh", Toast.LENGTH_SHORT).show();
}
else{
loadingBar.setTitle("Mencoba Login . . .");
loadingBar.setMessage("Tunggu sebentar ya! Data sedang diproses!");
loadingBar.show();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(task -> {
if(task.isSuccessful()){
Intent i = new Intent(MuridLoginRegisActivity.this, DashboardMuridActivity.class);
startActivity(i);
Toast.makeText(MuridLoginRegisActivity.this, "Halo! Selamat Datang!", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
else{
Toast.makeText(MuridLoginRegisActivity.this, "Yah Login nya gagal. Coba lagi nanti ya!", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
});
}
}
private void RegisterMurid(String email, String password) {
if(TextUtils.isEmpty(email)){
Toast.makeText(MuridLoginRegisActivity.this, "E-mail nya jangan kosong dong", Toast.LENGTH_SHORT).show();
}
else if(TextUtils.isEmpty(password)){
Toast.makeText(MuridLoginRegisActivity.this, "Hayo Password nya masih kosong tuh", Toast.LENGTH_SHORT).show();
}
else{
loadingBar.setTitle("Pendaftaran Murid");
loadingBar.setMessage("Tunggu sebentar ya! Data sedang diproses");
loadingBar.show();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(task -> {
if(task.isSuccessful()){
onlineMuridId = mAuth.getCurrentUser().getUid();
MuridDbRef = FirebaseDatabase.getInstance().getReference()
.child("Users").child("Murid").child(onlineMuridId);
MuridDbRef.setValue(true);
Toast.makeText(MuridLoginRegisActivity.this, "Horay! Pendaftaran berhasil!", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Intent i = new Intent(MuridLoginRegisActivity.this, DashboardMuridActivity.class);
startActivity(i);
}
else{
Toast.makeText(MuridLoginRegisActivity.this, "Yah registrasi nya gagal. Coba lagi nanti ya!", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
}
});
}
}
@Override
public void onBackPressed() {
back();
}
private void back() {
Intent reg = new Intent(this, Splash.class);
startActivity(reg);
finish();
}
} | [
"syafiradeta@gmail,com"
] | syafiradeta@gmail,com |
bd10a5d73b6237ebb496167e819bddba04cb8a4f | bb45ca5f028b841ca0a08ffef60cedc40090f2c1 | /app/src/main/java/com/MCWorld/widget/dialog/g$1.java | bc91b1b54f11a1f2e2435d29c1c96f271f1ebcca | [] | no_license | tik5213/myWorldBox | 0d248bcc13e23de5a58efd5c10abca4596f4e442 | b0bde3017211cc10584b93e81cf8d3f929bc0a45 | refs/heads/master | 2020-04-12T19:52:17.559775 | 2017-08-14T05:49:03 | 2017-08-14T05:49:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 702 | java | package com.MCWorld.widget.dialog;
import android.view.View;
import android.view.View.OnClickListener;
import com.MCWorld.bbs.b.g;
/* compiled from: GlobalDialog */
class g$1 implements OnClickListener {
final /* synthetic */ g bwY;
g$1(g this$0) {
this.bwY = this$0;
}
public void onClick(View view) {
int id = view.getId();
if (id == g.cb_tip) {
if (g.a(this.bwY) != null) {
g.a(this.bwY).ra();
}
} else if (id == g.tv_cancel) {
this.bwY.Op();
} else if (id == g.tv_other) {
this.bwY.Oq();
} else if (id == g.tv_confirm) {
this.bwY.sK();
}
}
}
| [
"[email protected]"
] | |
176c2e54152fc09eec544d06c680b9b701daae59 | ce3defe2dbc650ee60b63834942f4948b013046f | /app/src/main/java/com/unique/domain/outlookie/storage/EventDao.java | 83db64c332b3a8c8170574bd89c9d09155fd9314 | [] | no_license | marynightingale/Outlookie | bbff04df6d3c9652c0aa84c4cd78d8515c2d21d6 | 1ccfd9a7cd80efe918086d80b6e8d856a49a9f3d | refs/heads/master | 2020-03-27T08:22:58.579704 | 2018-09-10T19:25:34 | 2018-09-10T19:25:34 | 146,248,953 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 813 | java | package com.unique.domain.outlookie.storage;
import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import java.util.List;
@Dao
public interface EventDao {
@Insert
void insertEvent(Event event);
@Insert
void insertEvents(List<Event> events);
// @Query("SELECT * FROM Event WHERE movieId = :movieId")
// Event fetchOneMoviesbyMovieId (int movieId);
@Query("SELECT * FROM event")
LiveData<List<Event>> getAllEvents();
@Update
void updateMovie (Event event);
@Delete
void deleteMovie (Event event);
@Query("DELETE FROM event")
void deleteAll();
}
| [
"[email protected]"
] | |
74b86975ab498fde5610269bcfff2ff9907526c0 | e1ff1024f1bac734a6fe27ea602ac1164902d3bf | /DDvoice/src/main/java/com/example/ddvoice/ChatMsgViewAdapter.java | e0caa52957c61d864dc85cc5ccf8cb92b2fc58a8 | [] | no_license | sammulChan/androidGraduate | 24c9704419a03b0f87c4aa7474b7b969e91dc408 | 62b31e4e4e908934f46fddbce8bb3cf54cee5027 | refs/heads/androidGraduate | 2016-09-14T01:29:04.542121 | 2016-04-28T15:37:24 | 2016-04-28T15:37:24 | 57,279,183 | 0 | 0 | null | 2016-04-28T15:37:24 | 2016-04-28T07:10:31 | Java | UTF-8 | Java | false | false | 2,981 | java | package com.example.ddvoice;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.ddvoice.OnlineSpeechAction.SiriListItem;
import com.gc.materialdesign.views.LayoutRipple;
public class ChatMsgViewAdapter extends BaseAdapter {
int backgroundColor = Color.parseColor("#1E88E5");
private ArrayList<SiriListItem> list;
private Context ctx;
private LayoutInflater mInflater;
public ChatMsgViewAdapter(Context context, ArrayList<SiriListItem> l) {
ctx = context;
list = l;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return list.size();
}
public Object getItem(int position) {
return list.get(position);
}
public long getItemId(int position) {
return position;
}
public int getItemViewType(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
Activity context = (Activity)ctx;
ViewHolder viewHolder = null;
SiriListItem item=list.get(position);
if(position == 0 && context instanceof MainActivity){
convertView = mInflater.inflate(R.layout.main_ui,null);
LayoutRipple layoutRipple = (LayoutRipple)convertView.findViewById(R.id.phoneitems);
layoutRipple.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(ctx, PhoneActivity.class);
intent.putExtra("BACKGROUND", backgroundColor);
ctx.startActivity(intent);
}
});
}
else{
convertView = mInflater.inflate(R.layout.list_item, null);
viewHolder=new ViewHolder(
(View) convertView.findViewById(R.id.list_child),
(TextView) convertView.findViewById(R.id.chat_msg)
);
convertView.setTag(viewHolder);
String siri = String.valueOf(item.isSiri);
if(item.isSiri)viewHolder.child.setBackgroundResource(R.drawable.msgbox_rec);
else viewHolder.child.setBackgroundResource(R.drawable.msgbox_send);
viewHolder.msg.setText(item.message);
Log.v("????",item.message);
}
return convertView;
}
class ViewHolder {
protected View child;
protected TextView msg;
public ViewHolder(View child, TextView msg){
this.child = child;
this.msg = msg;
}
}
}
| [
"[email protected]"
] | |
6d72895b7c7d1c7eaf5c9df3503db19ec589c312 | 119e647d8b4b763c7ff0a567bb0a0fd4483c9330 | /firstweb/src/examples/ParameterServlet.java | eba6ce8b15028594b35716431a6386096f2b3fb9 | [] | no_license | hjoopark/boost-course | 64df43a8d9d69840cbcea0e1a11063c963eaba05 | e952ac4239c603ef31bff1d65c29ee3ed21c7854 | refs/heads/master | 2022-12-22T20:31:20.609074 | 2019-07-19T09:33:14 | 2019-07-19T09:33:14 | 196,925,806 | 1 | 0 | null | 2022-12-16T10:51:54 | 2019-07-15T04:49:13 | JavaScript | UTF-8 | Java | false | false | 1,272 | java | package examples;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class ParameterServlet
*/
@WebServlet("/Param")
public class ParameterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ParameterServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>form</title></head>");
out.println("<body>");
String name = request.getParameter("name");
String age = request.getParameter("age");
out.println("name : " + name + "<br>");
out.println("age : " +age + "<br>");
out.println("</body>");
out.println("</html>");
}
}
| [
"[email protected]"
] | |
57062ea1a281ca5529cee86aef3bc57cc078d3ff | 74cfe03426f96bc769f2ff8f50839e8398c8a2cc | /app/src/main/java/com/futuretongfu/view/MyGridView.java | c41c9e455847e43655585eb4b96a2d1a1d978a0f | [] | no_license | KqSMea8/ShouDuFu | c39b3cf59a8f86a0aee1182de73762ed363a6e5a | 2ae031cbb90e946935334f14dd5f03414afcdb18 | refs/heads/master | 2020-05-30T10:42:26.086711 | 2019-06-01T01:42:56 | 2019-06-01T01:42:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,981 | java | package com.futuretongfu.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.AbsListView;
import android.widget.GridView;
import com.futuretongfu.utils.To;
import com.futuretongfu.utils.Logger.Logger;
/**
* 自定义gridview
*
* @author DoneYang 2017/7/1
*/
public class MyGridView extends GridView implements AbsListView.OnScrollListener {
public MyGridView(Context context) {
super(context);
}
public MyGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
/**
* 重写该方法,达到使GridView适应ScrollView的效果
*/
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_MOVE) {
return true;
}
return super.dispatchTouchEvent(ev);
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
case OnScrollListener.SCROLL_STATE_FLING:
To.s("开始滚动:SCROLL_STATE_FLING");
break;
case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
To.s("正在滚动:SCROLL_STATE_TOUCH_SCROLL");
break;
case OnScrollListener.SCROLL_STATE_IDLE:
To.s("已经停止:SCROLL_STATE_IDLE");
// 判断滚动到底部
if (view.getLastVisiblePosition() == (view.getCount() - 1)) {
if (listener != null) {
listener.onScrollBottom();
}
}
break;
}
}
//调用系统GridView的监听,在停止的时候判断如果已经到底部,那么调用我们自已写的回调
//这样就是--GridView滑动到底部的回调
private OnScrollBottomListener listener;
public void setOnScrollBottomListener(OnScrollBottomListener listener) {
this.setOnScrollListener(this);
this.listener = listener;
}
public void removeOnScrollBottomListener() {
listener = null;
Logger.i("removeOnScrollBottomListener");
}
/**
* 列表视图滚动到底部监听器
*/
public interface OnScrollBottomListener {
/**
* 列表视图滚动到底部时响应
*/
public void onScrollBottom();
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}
}
| [
"[email protected]"
] | |
7f91826f284e141929cb588fca783f08464cea50 | df43e6246619c5d2928bce0cf6744e7324beba41 | /app/src/main/java/com/alink/documentmanagement/documentSent/SentWaitingFragment.java | ae528de9cae99efa82cf3b34b58b85109e5b0767 | [] | no_license | linhlq58/DocumentManagement | 0d26f43d23110b0603a47ffc328de0ca07d90e89 | ef55133b54a9e350ad6a62f9b1325760fe2ae9a2 | refs/heads/master | 2022-12-01T13:07:02.738151 | 2020-08-26T16:15:20 | 2020-08-26T16:15:20 | 290,542,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,326 | java | package com.alink.documentmanagement.documentSent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.alink.documentmanagement.appConfig.AppConfig;
import com.alink.documentmanagement.detail.documentDetail.DetailActivity;
import com.alink.documentmanagement.models.DocumentOut;
import com.alink.documentmanagement.R;
import com.alink.documentmanagement.main.BaseFragment;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
public class SentWaitingFragment extends BaseFragment implements DocumentSentInterface.ISentView {
public RecyclerView recyclerView;
public ListDocumentSentAdapter adapter;
public ArrayList<DocumentOut> listDocument;
public TextView tvEmpty;
public SwipeRefreshLayout swipeRefreshLayout;
public DocumentSentPresenter presenter = new DocumentSentPresenter(this);
public static SentWaitingFragment createInstance() {
Bundle args = new Bundle();
SentWaitingFragment fragment = new SentWaitingFragment();
fragment.setArguments(args);
return fragment;
}
@Override
protected int getLayoutResource() {
return R.layout.fragment_sent_all;
}
@Override
protected void initVariables(Bundle savedInstanceState, View rootView) {
recyclerView = rootView.findViewById(R.id.recyclerView);
swipeRefreshLayout = rootView.findViewById(R.id.layout_refresh);
tvEmpty = rootView.findViewById(R.id.tv_empty);
}
@Override
protected void initData(Bundle savedInstanceState) {
listDocument = new ArrayList<>();
//presenter.getListOut(AppConfig.VB_choxuli);
adapter = new ListDocumentSentAdapter(getActivity(), listDocument, new ListDocumentSentAdapter.IListAction() {
@Override
public void onItemClicked(int position) {
Intent intent = new Intent(getActivity(), DetailActivity.class);
intent.putExtra(AppConfig.DOCUMENT_ID, listDocument.get(position).getId());
intent.putExtra(AppConfig.DOCUMENT_TYPE, 1);
startActivity(intent);
}
});
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false));
recyclerView.setAdapter(adapter);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
presenter.getListOut(AppConfig.VB_choxuli);
}
});
}
@Override
public void onUpdateList(List<DocumentOut> listOut) {
if (listOut.isEmpty()) {
tvEmpty.setVisibility(View.VISIBLE);
} else {
tvEmpty.setVisibility(View.GONE);
}
listDocument.clear();
listDocument.addAll(listOut);
adapter.notifyDataSetChanged();
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setRefreshing(false);
}
}
@Override
public void onResume() {
super.onResume();
presenter.getListOut(AppConfig.VB_choxuli);
}
}
| [
"[email protected]"
] | |
df3d86bf360b976cd6cbec488d47295388771d20 | 18ac7faba518f4fe3bd410edc3fca3b497533fca | /app/src/test/java/com/example/labtask3/ExampleUnitTest.java | c8341a8549870fdc5ec11ad9b2f19d543ce514da | [] | no_license | shahbaazkyz/Menu-List-and-Dialing-App-Android-Studio | f659f2d107324767cc63fdd7e34f3205f07b133b | 0f216377c280ac7fd1b05332518493188bcd3591 | refs/heads/master | 2023-07-14T00:45:20.337135 | 2021-08-29T10:23:58 | 2021-08-29T10:23:58 | 401,012,339 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | package com.example.labtask3;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
e3ccde3ef0f9c8ca5a01f243d9597338ae80d174 | 70582ae3d3bb6fe6f153796606eedfa32cdd8fa9 | /AndroidStudioProjects/ApplicationSecond/app/src/main/java/com/example/konrad/applicationsecond/Layouts.java | 7d6a793bc23665dec5499c234d74d2eb5f273383 | [] | no_license | KonradSar/ApplicationSecond | fa8bd694d891f4a273c5480673b7405a7f29f391 | a348ac028acdb9554423e335e6d3aaeb2fe31f82 | refs/heads/master | 2021-06-23T01:57:29.628118 | 2017-09-08T13:53:59 | 2017-09-08T13:53:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,970 | java | package com.example.konrad.applicationsecond;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
public class Layouts extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layouts);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader.getInstance().init(config);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout2);
tabLayout.addTab(tabLayout.newTab().setText("Opis"));
tabLayout.addTab(tabLayout.newTab().setText("Zdjecie"));
tabLayout.addTab(tabLayout.newTab().setIcon(R.drawable.serce));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPagerr);
final MojPagerAdapter adapter = new MojPagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener(){
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
}
| [
"[email protected]"
] | |
36994771e533d5743d6539d962ca22585bea7995 | 042d9dd14bbcce706487fc4bb5197639ea439d75 | /app/src/main/java/com/fungeonstudio/redline/recycler/ReviewAdapter.java | b0fcf9e30b34612266bd6e63097d83cf30934d55 | [] | no_license | rexdarel/DiagonlineApp | 5e3ce82bf7c44afeafd18fcae548d1dc8aa1d4b7 | 83f40b0ad3111fdabc2487e6abfca7181d976dfe | refs/heads/master | 2021-04-26T04:36:36.577441 | 2018-02-17T16:24:34 | 2018-02-17T16:24:34 | 121,399,234 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,700 | java | package com.fungeonstudio.redline.recycler;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.fungeonstudio.redline.R;
import java.util.List;
/**
* Created by Admin on 2/15/2018.
*/
public class ReviewAdapter extends RecyclerView.Adapter<ReviewAdapter.MyViewHolder> {
private List<ItemReview> items;
private Context context;
public static class MyViewHolder extends RecyclerView.ViewHolder{
public TextView username, date, comment;
public ImageView img1, img2, userphoto;
public RatingBar ratingBar;
public MyViewHolder(View view) {
super(view);
username = (TextView) view.findViewById(R.id.tv_username);
date = (TextView) view.findViewById(R.id.tv_date);
comment = (TextView) view.findViewById(R.id.tv_text_comment);
ratingBar = (RatingBar) view.findViewById(R.id.ratingBar);
userphoto = (ImageView) view.findViewById(R.id.iv_user);
}
}
public ReviewAdapter(List<ItemReview> items, Context context) {
this.items = items;
this.context = context;
}
@Override
public ReviewAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_comment, parent, false);
return new ReviewAdapter.MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(ReviewAdapter.MyViewHolder holder, int position) {
ItemReview itemReview = items.get(position);
holder.username.setText(itemReview.getAuthor().toString());
holder.ratingBar.setRating(itemReview.getRate());
//Log.w("Review: Submitted" ,itemReview.getMessage());
// holder.date.setText(itemReview.getTimestamp().toString());
holder.comment.setText(itemReview.getMessage().toString());
/*Glide.with(context)
.load(Uri.parse(itemComment.getUserphoto()))
.transform(new CircleGlide(context))
.into(holder.userphoto);
Glide.with(context)
.load(Uri.parse(itemComment.getImg1()))
.centerCrop()
.into(holder.img1);
Glide.with(context)
.load(Uri.parse(itemComment.getImg2()))
.centerCrop()
.into(holder.img2);*/
}
@Override
public int getItemCount() {
return items.size();
}
}
| [
"[email protected]"
] | |
01a8e0b66f3fe962a7a6c4f7d6e3acc0d6c5b798 | c89223423b54844cc2641fa4f48d4bbe3bbf4fa0 | /src/activity/personalCenter.java | a0eb6bc8c880fd3d27cca79d89d6d1b5323edfc6 | [] | no_license | Recen/seubbs | 1fd0a71d9936192fee2bec138f3697ae294ee225 | c7dd5d77a30ad512a813e8e7df1439ed67688f11 | refs/heads/master | 2021-01-10T16:13:06.162409 | 2015-06-06T11:32:26 | 2015-06-06T11:32:26 | 36,663,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,926 | java | package activity;
import utli.MyApplication;
import utli.Preferences;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.recen.sbbs.R;
public class personalCenter extends Fragment{
private static final String TAG = "personalCenter";
private View view;
private Button loginButton;
private TextView nickName;
private TextView myEmail;
private TextView setting;
/* (non-Javadoc)
* @see android.support.v4.app.Fragment#onActivityCreated(android.os.Bundle)
*/
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
loginButton = (Button)view.findViewById(R.id.loginButton);
myEmail = (TextView)view.findViewById(R.id.myEmail);
setting = (TextView)view.findViewById(R.id.setting);
boolean isLogined = MyApplication.checkLogin();
if(!isLogined){
loginButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(getActivity(), Login.class);
startActivity(intent);
}
});
}else {
Log.i(TAG, "logined");
loginButton.setVisibility(View.GONE);
nickName = (TextView)view.findViewById(R.id.personName);
nickName.setVisibility(View.VISIBLE);
String nickname = MyApplication.mPreference.getString(Preferences.USER_NAME, "");
nickName.setText(nickname);
bindListener();
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
view = inflater.inflate(R.layout.person, null);
return view;
}
private void bindListener(){
nickName.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i(TAG, "dasdasdjhsajdh");
Intent intent = new Intent(getActivity(), ViewProfileActivity.class);
startActivity(intent);
}
});
myEmail.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(getActivity(), person_myEmail.class);
startActivity(intent);
}
});
setting.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(getActivity(), preference.class);
startActivity(intent);
}
});
}
}
| [
"[email protected]"
] | |
d3f6628da57ca14271c63823ac21bad7182dec9f | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/22/22_73caa590a9dfaa803be17b965858c34cef612c83/AquaWorkspaceStateTracker/22_73caa590a9dfaa803be17b965858c34cef612c83_AquaWorkspaceStateTracker_s.java | b997e65589f65f03a4a3b43af6149dd5e8fd5a5b | [] | 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 | 3,711 | java | /*
* Hex - a hex viewer and annotator
* Copyright (C) 2009-2012 Trejkaz, Hex Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.trypticon.hex.gui.prefs;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.prefs.Preferences;
import javax.swing.SwingUtilities;
import org.trypticon.hex.gui.HexApplication;
import org.trypticon.hex.gui.HexFrame;
import org.trypticon.hex.gui.notebook.Notebook;
import org.trypticon.hex.gui.notebook.NotebookStorage;
import org.trypticon.hex.util.LoggerUtils;
/**
* Workspace state tracker used for Mac platforms.
*
* @author trejkaz
*/
public class AquaWorkspaceStateTracker extends WorkspaceStateTracker {
@Override
public void save() {
Preferences topPrefs = getPrefs();
int count = 0;
for (HexFrame frame : HexFrame.findAllFrames()) {
URL notebookLocation = frame.getNotebook().getNotebookLocation();
if (notebookLocation == null) {
// User must have explicitly chosen *not* to save the notebook, so toss it.
//TODO: Modern Mac apps even restore unsaved documents. That would be nice to add.
continue;
}
Preferences openDocumentPrefs = topPrefs.node("document" + count);
openDocumentPrefs.put("location", notebookLocation.toExternalForm());
saveFrameLocation(frame, openDocumentPrefs);
count++;
}
topPrefs.putInt("count", count);
}
@Override
public boolean restore() {
Preferences topPrefs = getPrefs();
int count = topPrefs.getInt("count", -1);
if (count < 0) {
return false;
}
HexApplication application = HexApplication.get();
for (int i = 0; i < count; i++) {
final Preferences openDocumentPrefs = topPrefs.node("document" + count);
String location = openDocumentPrefs.get("location", null);
if (location == null) {
LoggerUtils.get().warning("Location for open document " + i + " missing, skipping");
continue;
}
final HexFrame frame;
try {
URL url = new URL(location);
Notebook notebook = new NotebookStorage().read(url);
frame = application.openNotebook(notebook);
} catch (MalformedURLException e) {
LoggerUtils.get().log(Level.WARNING, "Malformed URL found in preferences for document " + i + ": " +
location + ", skipping", e);
continue;
} catch (IOException e) {
LoggerUtils.get().log(Level.WARNING, "Error opening previously-open notebook: " + location + ", skipping");
continue;
}
restoreFrameLocation(frame, openDocumentPrefs);
}
return true;
}
}
| [
"[email protected]"
] | |
7bb6617ced83930607f37a69679361ad3324832b | 58a896dbf20c1b0f3e5405d50bffb97d2f4f6131 | /src/proxy/UserManagerImplProxy.java | 15b75e153470621085394c5bf511c1b2899c33f8 | [] | no_license | 1814705032/Taoists | d1feb0f4b43a4c7f065693a5f2e9e5b9ff9e1e24 | 017a7a20f9b3b3d56757f86e4f81a7606c1e1395 | refs/heads/master | 2022-04-20T06:34:28.453701 | 2020-04-16T03:59:33 | 2020-04-16T03:59:33 | 256,104,225 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,049 | java | package proxy;
public class UserManagerImplProxy implements UserManager{
private UserManager userManager;
public UserManagerImplProxy(UserManager userManager) {
this.userManager = userManager;
}
@Override
public void addUser(String userId, String userName) {
try{
//添加打印日志的功能
//开始添加用户
System.out.println("start-->addUser()");
userManager.addUser(userId, userName);
//添加用户成功
System.out.println("success-->addUser()");
}catch(Exception e){
//添加用户失败
System.out.println("error-->addUser()");
}
}
@Override
public void delUser(String userId) {
userManager.delUser(userId);
}
@Override
public String findUser(String userId) {
return userManager.findUser(userId);
}
@Override
public void modifyUser(String userId, String userName) {
userManager.modifyUser(userId, userName);
}
}
| [
"[email protected]"
] | |
bcd9b21f12226fa680dfcb8de7ab5f4aa65fcdf4 | 64539efc01aa68e70aaa5943671eae8216a7f6a0 | /dellroad-stuff-main/src/main/java/org/dellroad/stuff/schema/SQLCommand.java | 2874822130905b974107bc62a408d61cfcc57af5 | [] | no_license | tiongks/dellroad-stuff | d396d1626f73ca11f950d5da626b154db27523fc | e7651548966918a741f0783532e17d78cbb4239d | refs/heads/master | 2020-04-22T00:51:29.670589 | 2019-01-05T19:22:25 | 2019-01-05T19:22:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,753 | java |
/*
* Copyright (C) 2011 Archie L. Cobbs. All rights reserved.
*/
package org.dellroad.stuff.schema;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* An SQL {@link DatabaseAction} that executes a single SQL statement.
*/
public class SQLCommand implements DatabaseAction<Connection> {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
private final String sql;
/**
* Constructor.
*
* @param sql the SQL to execute; must be a single statement
* @throws IllegalArgumentException if {@code sql} is null or contains only whitespace
*/
public SQLCommand(String sql) {
if (sql == null)
throw new IllegalArgumentException("null sql");
sql = sql.trim();
if (sql.length() == 0)
throw new IllegalArgumentException("empty sql");
this.sql = sql;
}
public String getSQL() {
return this.sql;
}
/**
* Execute the SQL statement.
*
* <p>
* The implementation in {@link SQLCommand} creates a {@link Statement} and then executes the configured
* SQL command via {@link Statement#execute}. Subclasses may wish to override.
*
* @throws SQLException if an error occurs while accessing the database
*/
@Override
public void apply(Connection c) throws SQLException {
Statement statement = c.createStatement();
String sep = this.sql.indexOf('\n') != -1 ? "\n" : " ";
this.log.info("executing SQL statement:" + sep + this.sql);
try {
statement.execute(this.sql);
} finally {
statement.close();
}
}
}
| [
"[email protected]"
] | |
843abfda69dd88f326b522095a096da800eeaabf | c9dc9ca80cbcda26a267ec77286d205b45668505 | /model/src/test/java/no/nav/foreldrepenger/vtp/testmodell/TestscenarioHenter.java | dd2dc390f07d0269876f774bcadfcd4ef6ead5e6 | [
"MIT"
] | permissive | navikt/vtp | adc79777c719418cc6ecbdc02e24d71197c18d16 | 4c0d7ccf5c437391c4a079bddc381b4e73dbf1ab | refs/heads/master | 2023-09-04T12:27:58.370210 | 2023-09-04T08:29:46 | 2023-09-04T08:29:46 | 176,907,179 | 6 | 3 | MIT | 2023-09-13T03:45:38 | 2019-03-21T08:59:23 | Java | UTF-8 | Java | false | false | 5,562 | java | package no.nav.foreldrepenger.vtp.testmodell;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import no.nav.foreldrepenger.vtp.testmodell.util.JacksonObjectMapperTestscenario;
public class TestscenarioHenter {
private static final String PATH_TIL_SCENARIO = "scenarios/";
private static final String PERSONOPPLYSNING_JSON_FIL_NAVN = "personopplysning.json";
private static final String INNTEKTYTELSE_SØKER_JSON_FIL_NAVN = "inntektytelse-søker.json";
private static final String INNTEKTYTELSE_ANNENPART_JSON_FIL_NAVN = "inntektytelse-annenpart.json";
private static final String ORGANISASJON_JSON_FIL_NAVN = "organisasjon.json";
private static final String VARS_JSON_FIL_NAVN = "vars.json";
private static final ObjectMapper MAPPER = JacksonObjectMapperTestscenario.getObjectMapper();
private final Map<String, Object> scenarioObjects = new ConcurrentHashMap<>();
private static TestscenarioHenter testscenarioHenter;
public static synchronized TestscenarioHenter getInstance(){
if(testscenarioHenter == null){
testscenarioHenter = new TestscenarioHenter();
}
return testscenarioHenter;
}
public Object hentScenario(String scenarioId) {
return scenarioObjects.computeIfAbsent(scenarioId, s -> LesOgReturnerScenarioFraJsonfil(scenarioId));
}
public String toJson(Object object) {
try {
return MAPPER.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
private Object LesOgReturnerScenarioFraJsonfil(String scenarioId) {
String scenarioNavn = henterNavnPåScenarioMappe(scenarioId).orElseThrow(() ->
new RuntimeException("Fant ikke scenario med scenario nummer [" + scenarioId + "]"));
final ObjectNode root = MAPPER.createObjectNode();
root.set("scenario-navn", MAPPER.convertValue(scenarioNavn, new TypeReference<>() {}));
lesFilOgLeggTilIObjectNode(scenarioNavn, root, PERSONOPPLYSNING_JSON_FIL_NAVN, "personopplysninger");
lesFilOgLeggTilIObjectNode(scenarioNavn, root, INNTEKTYTELSE_SØKER_JSON_FIL_NAVN, "inntektytelse-søker");
lesFilOgLeggTilIObjectNode(scenarioNavn, root, INNTEKTYTELSE_ANNENPART_JSON_FIL_NAVN, "inntektytelse-annenpart");
lesFilOgLeggTilIObjectNode(scenarioNavn, root, ORGANISASJON_JSON_FIL_NAVN, "organisasjon");
lesFilOgLeggTilIObjectNode(scenarioNavn, root, VARS_JSON_FIL_NAVN, "vars");
return MAPPER.convertValue(root, new TypeReference<>() {});
}
private void lesFilOgLeggTilIObjectNode(String navnPåMappen, ObjectNode root, String jsonFilNavn, String navnPåNøkkel) {
try (InputStream is = TestscenarioHenter.class.getResourceAsStream("/" + PATH_TIL_SCENARIO + navnPåMappen + "/" + jsonFilNavn)) {
if (is != null) {
JsonNode verdiAvNøkkel = MAPPER.readValue(is, JsonNode.class);
root.set(navnPåNøkkel, verdiAvNøkkel);
}
} catch (IOException e) {
throw new IllegalArgumentException("Kunne ikke lese " + jsonFilNavn + "for scenario", e);
}
}
private Optional<String> henterNavnPåScenarioMappe(String scenarioNummer) {
try (BufferedReader r = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(this.getClass().getClassLoader().getResourceAsStream(PATH_TIL_SCENARIO))))) {
String navnPåMappe;
while((navnPåMappe = r.readLine()) != null) {
if (navnPåMappe.startsWith(scenarioNummer + "-")) {
return Optional.of(navnPåMappe);
}
}
return Optional.ofNullable(henterNavnPåScenarioMappeFraJARressurs(scenarioNummer));
} catch (IOException e) {
throw new IllegalArgumentException("Klarte ikke å hente resource {scenarios}", e);
}
}
private String henterNavnPåScenarioMappeFraJARressurs(String scenarioNummer) {
final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
if(jarFile.isFile()) {
try (JarFile jar = new JarFile(jarFile)) {
final Enumeration<JarEntry> entries = jar.entries();
while(entries.hasMoreElements()) {
final String name = entries.nextElement().getName();
if (name.startsWith(PATH_TIL_SCENARIO + scenarioNummer)) { // Finner mappe med korrekt scenarioID
int startIndeks = PATH_TIL_SCENARIO.length();
int sluttIndeks = name.indexOf("/", startIndeks);
return name.substring(startIndeks, sluttIndeks);
}
}
} catch (IOException e) {
throw new IllegalArgumentException("Klarte ikke å åpne JAR-fil", e);
}
}
return null;
}
}
| [
"[email protected]"
] | |
f54378a541f752426619f1c518a4b6cfba362c18 | da4c175e1f0a310e9ccc1c963900dfa781fe1da5 | /advent/day6/tests/Tests.java | 4a0bad66f5577e3fd0a3bc9c431f4c51dc21d3f6 | [] | no_license | Hirtol/AdventOfCode2019 | 99a32d10dc6fae7ae32649e08b61e4593850714b | 98d6d8e6228ac367739d3bfa0e5931d3b2d9a73d | refs/heads/master | 2020-09-27T00:41:51.462378 | 2019-12-26T18:22:09 | 2019-12-26T18:22:09 | 226,380,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,050 | java | package advent.day6.tests;
import advent.day6.Orbit;
import advent.day6.OrbitFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Tests {
@BeforeEach
public void setup(){
}
@Test
public void test1() throws FileNotFoundException {
File file = new File("C:\\Users\\Valentijn\\Nextcloud\\University Work\\Module 2\\Eclipse Projects\\CodeAdvent2019\\src\\advent\\day6\\input.txt");
Scanner scn = new Scanner(file);
OrbitFactory factory = OrbitFactory.getInstance();
while(scn.hasNextLine()){
String str = scn.nextLine();
String[] splitString = str.split("\\)");
Orbit around = factory.getNewOrbit(splitString[0]);
Orbit toOrbit = factory.getNewOrbit(splitString[1], around);
factory.addOrbit(around);
factory.addOrbit(toOrbit);
}
Assertions.assertEquals(122782, factory.orbits.stream().mapToInt(Orbit::getOrbitalAmount).sum());
}
}
| [
"[email protected]"
] | |
d1ff508e081702464bfd80479f698ed65c86c28b | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/plugin/vlog/model/d.java | e3403154c2673bc2a5501953672666f0842fbe39 | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 4,882 | java | package com.tencent.mm.plugin.vlog.model;
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.videocomposition.c.e;
import com.tencent.mm.xeffect.c;
import com.tencent.mm.xeffect.effect.EffectManager;
import com.tencent.mm.xeffect.effect.VLogEffectJNI;
import com.tencent.mm.xeffect.effect.a;
import com.tencent.mm.xeffect.effect.ae.a;
import com.tencent.mm.xeffect.effect.af;
import com.tencent.mm.xeffect.effect.j;
import kotlin.Metadata;
import kotlin.g.a.b;
@Metadata(d1={""}, d2={"Lcom/tencent/mm/plugin/vlog/model/BlendRenderProcessWrapper;", "Lcom/tencent/mm/videocomposition/render/RenderProcessCallback;", "blendBitmapProvider", "Lkotlin/Function1;", "", "Landroid/graphics/Bitmap;", "effectMgr", "Lcom/tencent/mm/xeffect/effect/EffectManager;", "(Lkotlin/jvm/functions/Function1;Lcom/tencent/mm/xeffect/effect/EffectManager;)V", "getBlendBitmapProvider", "()Lkotlin/jvm/functions/Function1;", "blendEffect", "Lcom/tencent/mm/xeffect/effect/BlendEffect;", "getBlendEffect", "()Lcom/tencent/mm/xeffect/effect/BlendEffect;", "getEffectMgr", "()Lcom/tencent/mm/xeffect/effect/EffectManager;", "height", "", "texture", "width", "blendTexture", "Lcom/tencent/mm/xeffect/InputTexture;", "pts", "ensureTexture", "", "onFrameStart", "onRelease", "uploadBitmap", "bitmap", "plugin-vlog_release"}, k=1, mv={1, 5, 1}, xi=48)
public final class d
implements e
{
private final EffectManager GmF;
private final a TXX;
private int TXY;
private int height;
private final b<Long, Bitmap> nBp;
private int width;
public d(b<? super Long, Bitmap> paramb, EffectManager paramEffectManager)
{
AppMethodBeat.i(283393);
this.nBp = paramb;
this.GmF = paramEffectManager;
paramb = this.GmF;
if (paramb == null)
{
paramb = null;
if (!(paramb instanceof a)) {
break label70;
}
}
label70:
for (paramb = (a)paramb;; paramb = null)
{
this.TXX = paramb;
AppMethodBeat.o(283393);
return;
paramb = paramb.a(j.agYd);
break;
}
}
public final void onRelease()
{
AppMethodBeat.i(283417);
if (this.TXY != 0)
{
GLES20.glDeleteTextures(1, new int[] { this.TXY }, 0);
this.TXY = 0;
}
AppMethodBeat.o(283417);
}
public final void wx(long paramLong)
{
AppMethodBeat.i(283409);
Object localObject1 = (Bitmap)this.nBp.invoke(Long.valueOf(paramLong));
Object localObject2;
if (localObject1 != null)
{
this.width = ((Bitmap)localObject1).getWidth();
this.height = ((Bitmap)localObject1).getHeight();
if (this.TXY == 0)
{
localObject2 = new int[1];
GLES20.glGenTextures(1, (int[])localObject2, 0);
GLES20.glBindTexture(3553, localObject2[0]);
GLES20.glBindTexture(3553, 0);
this.TXY = localObject2[0];
}
GLES20.glBindTexture(3553, this.TXY);
GLUtils.texImage2D(3553, 0, (Bitmap)localObject1, 0);
GLES20.glTexParameterf(3553, 10241, 9729.0F);
GLES20.glTexParameterf(3553, 10240, 9729.0F);
GLES20.glTexParameterf(3553, 10242, 10497.0F);
GLES20.glTexParameterf(3553, 10243, 10497.0F);
GLES20.glBindTexture(3553, 0);
localObject1 = new c(this.TXY, this.width, this.height);
if (localObject1 != null)
{
localObject2 = this.TXX;
if ((localObject2 == null) || (((af)localObject2).id != 0L)) {
break label360;
}
}
}
label360:
for (int i = 1;; i = 0)
{
if (i != 0)
{
localObject2 = this.GmF;
if (localObject2 != null) {
((EffectManager)localObject2).b((af)this.TXX);
}
}
localObject2 = this.TXX;
if (localObject2 != null)
{
i = ((c)localObject1).textureId;
int j = ((c)localObject1).width;
int k = ((c)localObject1).height;
localObject1 = ((a)localObject2).agXJ;
((ae.a)localObject1).textureId = i;
((ae.a)localObject1).width = j;
((ae.a)localObject1).height = k;
VLogEffectJNI.INSTANCE.setEffectTexture$renderlib_release(((ae.a)localObject1).Uby.ptr, i, j, k);
}
localObject1 = this.TXX;
if (localObject1 != null)
{
localObject1 = ((a)localObject1).agXJ;
VLogEffectJNI.INSTANCE.nSetEffectIsPreMultiplied(((ae.a)localObject1).Uby.ptr, true);
}
AppMethodBeat.o(283409);
return;
localObject1 = null;
break;
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes9.jar
* Qualified Name: com.tencent.mm.plugin.vlog.model.d
* JD-Core Version: 0.7.0.1
*/ | [
"[email protected]"
] | |
fa7b8899f1f9a96fcdaeb4ae15ce819076379083 | 83646f51b862ebc1895151dfecb1d493e4d0f3a2 | /hr-worker/src/main/java/com/devsuperior/hrworker/resources/WorkerResource.java | 67b3072ee5fc3a82e44ad40f3e990db627a67193 | [] | no_license | dan9903/ms-course-ds | 7b5851c94f211a13267fe27835aaeb8f1c3597a1 | b3993d1fb599577076622a74cf745cf435d99439 | refs/heads/main | 2023-08-14T23:34:07.173436 | 2021-10-02T21:11:37 | 2021-10-02T21:11:37 | 402,207,788 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,695 | java | package com.devsuperior.hrworker.resources;
import java.util.List;
import com.devsuperior.hrworker.entities.Worker;
import com.devsuperior.hrworker.repositories.WorkerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.core.env.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RefreshScope
@RestController
@RequestMapping(value = "/workers")
public class WorkerResource {
private static Logger logger = LoggerFactory.getLogger(WorkerResource.class);
// @Value("${test.config}")
// String testConfig;
@Autowired
private Environment env;
@Autowired
private WorkerRepository repository;
@GetMapping(value = "/configs")
public ResponseEntity<Void> getConfigs() {
// logger.info("CONFIG = " + testConfig);
return ResponseEntity.noContent().build();
}
@GetMapping
public ResponseEntity<List<Worker>> findAll() {
List<Worker> workers = repository.findAll();
return ResponseEntity.ok(workers);
}
@GetMapping(value = "/{id}")
public ResponseEntity<Worker> findById(@PathVariable Long id) {
logger.info("PORT = " + env.getProperty("local.server.port"));
Worker worker = repository.findById(id).get();
return ResponseEntity.ok(worker);
}
} | [
"[email protected]"
] | |
199ada01cbf9d34575e3778c7550b4766b6d59d0 | 9c87f7cba2355950e9adf1e5efda9244401c978c | /src/Largest1BorderedSquare.java | e3e2a56cb3e71b8ab6ba1dacbc6fa8ea8101c93f | [] | no_license | sbturan/LeetCode | 351d71a7690bf564dcb8ecb528e4223e91349743 | 1f2249c18d95fe4a6604530c079ff159b590c899 | refs/heads/master | 2023-05-01T23:22:16.618059 | 2023-04-23T16:13:46 | 2023-04-23T16:13:46 | 89,212,167 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,363 | java | public class Largest1BorderedSquare {
public static void main(String[] args) {
System.out.println(new Largest1BorderedSquare().largest1BorderedSquare(
new int [][]{{1,1,1},{1,0,1},{1,1,1}}));
}
public int largest1BorderedSquare(int[][] grid) {
int [][] dp=new int[grid.length+2][grid[0].length+2];
dp[grid.length+1][grid[0].length+1]=0;
int result=0;
for(int i=grid.length-1;i>-1;i--) {
for(int j=grid[i].length-1;j>-1;j--) {
if(grid[i][j]==1) {
dp[i+1][j+1]=dp[i+1][j+2]+1;
int k=result+1;
int t=dp[i+1][j+1];
int max=0;
while(k<=t) {
if(isSqueare(grid, i, j, k,dp)) {
max=Math.max(max,k);
}
k++;
}
result=Math.max(result, max);
}else {
dp[i+1][j+1]=0;
}
}
}
return result*result;
}
private boolean isSqueare(int[][] grid, int i,int j,int size,int [][] dp) {
if(grid.length-i<size
||grid[i].length-j<size
||dp[i+1][j+1]<size
||dp[i+size][j+1]<size) {
return false;
}
for(int k=0;k<size;k++) {
if(grid[i+k][j]!=1
||grid[i+k][j+size-1]!=1)
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
8ab2553814cd1a3b2d5dad63b0a5ca55feb6d70d | 6e0638800bfe8e6ee2915155ebfe3ea706275209 | /src/msg/msg/action/msgLiveAction.java | ff2c7f57a698e3561c519a9c8af24ef634e11b05 | [] | no_license | widdlf0/MyProject | c2bef80b1f1171c58cac7a4031353eb17a5a974e | e54f78463c8626104c5a7bfd4e5a71c84dcbccfd | refs/heads/master | 2021-08-30T18:49:47.760688 | 2017-12-19T01:58:46 | 2017-12-19T01:58:46 | 114,702,310 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,013 | java | package msg.msg.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import msg.db.MsgBean;
import msg.db.MsgDAO;
public class msgLiveAction implements Action{
public ActionForward execute(HttpServletRequest request,HttpServletResponse response)
throws Exception{
request.setCharacterEncoding("UTF-8");
ActionForward forward= new ActionForward();
MsgDAO msgDAO = new MsgDAO();
MsgBean msgBean = new MsgBean();
int num = Integer.parseInt(request.getParameter("num"));
msgDAO.setMsgLive(num);
System.out.println("메세지 살리기 성공");
request.setAttribute("msgBean", msgBean);
forward.setRedirect(false);
forward.setPath("/msgTrashBoxListAction.mg");
return forward;
}
@Override
public void executeAjax(HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO Auto-generated method stub
}
}
| [
"[email protected]"
] | |
322ea7e3ad2ce3bcff1d680c1f4de718ce9d7b6e | 6abf093021b98834687189dd86f0fff73de9809a | /tools/AndFix/libandfix/src/main/java/com/sohu/focus/libandfix/Compat.java | 1a96cb3596d8077c7460a7eeaaf16f315258a873 | [] | no_license | Hotpotboy/zhanghang | 53d1d59e1271dfb17b37bcc82940c272da84583e | 1624b953fccd3fc89b4b0c32627590aa9123ac93 | refs/heads/master | 2020-05-22T02:53:59.130067 | 2017-03-14T05:50:45 | 2017-03-14T05:50:45 | 39,623,209 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,124 | java | /*
*
* Copyright (c) 2015, alipay.com
*
* 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.sohu.focus.libandfix;
import android.annotation.SuppressLint;
import java.lang.reflect.Method;
/**
* Compatibility
*
* @author [email protected]
*
*/
public class Compat {
public static boolean isChecked = false;
public static boolean isSupport = false;
/**
* whether support on the device
*
* @return true if the device support AndFix
*/
public static synchronized boolean isSupport() {
if (isChecked)
return isSupport;
isChecked = true;
// not support alibaba's YunOs
if (!isYunOS() && AndFix.setup() && isSupportSDKVersion()) {
isSupport = true;
}
if (inBlackList()) {
isSupport = false;
}
return isSupport;
}
@SuppressLint("DefaultLocale")
private static boolean isYunOS() {
String version = null;
String vmName = null;
try {
Method m = Class.forName("android.os.SystemProperties").getMethod(
"get", String.class);
version = (String) m.invoke(null, "ro.yunos.version");
vmName = (String) m.invoke(null, "java.vm.name");
} catch (Exception e) {
// nothing todo
}
if ((vmName != null && vmName.toLowerCase().contains("lemur"))
|| (version != null && version.trim().length() > 0)) {
return true;
} else {
return false;
}
}
// from android 2.3 to android 6.0
private static boolean isSupportSDKVersion() {
if (android.os.Build.VERSION.SDK_INT >= 8
&& android.os.Build.VERSION.SDK_INT <= 23) {
return true;
}
return false;
}
private static boolean inBlackList() {
return false;
}
}
| [
"[email protected]"
] | |
e58331894d9517164356cabf09273e597ffda587 | c8cdff97fb4b6ce366bb6ab9adaff866b761a791 | /src/repl_it/first_practice/PrintFirstChar.java | d46bed749d4125971d9f63946b0084f28fb798ee | [] | no_license | SDET222/java-programmingC | 6a50c147f526f60382c8febfe68c1a1c7f2921b2 | f6098a8a3ff2412135120efde901ab3ac558c362 | refs/heads/master | 2023-06-22T00:48:25.451665 | 2021-07-26T23:51:53 | 2021-07-26T23:51:53 | 366,196,266 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 554 | java | package repl_it.first_practice;
import java.util.Scanner;
public class PrintFirstChar {
public static void main(String[] args) {
/**Write a program that will print out the first character of the word.*/
Scanner scan = new Scanner(System.in);
System.out.println("Enter word");
String word = scan.next();
System.out.println(word.charAt(0));
String name ="Orkhan";
String nameIs = name=="Orkhan" ? "It is ok" : "Wrong name";
System.out.println(nameIs);
}
}
| [
"[email protected]"
] | |
3362c1b79e4ec295da3d8e4b2d4d189e75c8bcaa | fc11db827ab734d69637659e240fa1b94f1e114d | /src/main/java/Process/ClassifySpiderProcess.java | 6f329313907963f85bc3693ecb14361e598cc2da | [] | no_license | APOLLO2333/SimpleNovelSpider | 17f9bfa101c8072c6542459f8b17c0fe9d70625c | e6bdcdc1a869b1c9f997c20c64596abf2b55f0d7 | refs/heads/master | 2020-06-05T04:14:59.085943 | 2019-06-17T08:54:47 | 2019-06-17T08:54:47 | 192,310,045 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,210 | java | package Process;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.webmagic.selector.Selectable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
public class ClassifySpiderProcess implements PageProcessor {
private Site site = Site.me().setSleepTime(3000).setRetrySleepTime(3);
private BlockingQueue<String> blockingQueue;
public ClassifySpiderProcess() {
}
public ClassifySpiderProcess(BlockingQueue<String> blockingQueue) {
this.blockingQueue = blockingQueue;
}
@Override
public void process(Page page) {
// String firstLink = page.getHtml().xpath("/html/body/div[4]/a[1]/@href").toString();
// Selectable selectable = page.getHtml().$("body > div.pages").;
List<String> links = page.getHtml().$("body > div.pages").links().all();
// String firstLink = page.getHtml().$("body > div.pages > a:nth-child(1)").links().toString();
String firstLink = links.get(0);
String currentLink = page.getHtml().$("body > div.pages > b").toString().substring(26, 27);
// String lastLink = page.getHtml().xpath("/html/body/div[4]/a[text()='尾页']/@href").toString();
String lastLink = links.get(links.size() - 1);
String url = firstLink.split("_")[0] + "_";
int firstPage = Integer.parseInt(firstLink.split("_")[1].split("\\.")[0]);
int currentPage = Integer.parseInt(currentLink);
int lastPage = Integer.parseInt(lastLink.split("_")[1].split("\\.")[0]);
Set<String> TargetLinks = new HashSet<>(page.getHtml().links().regex("/wapbook/\\d+.html").all());
for (String link : TargetLinks) {
try {
blockingQueue.put(link);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (currentPage <= lastPage && currentPage >= firstPage) {
page.addTargetRequest(url + (currentPage + 1) + ".html");
}
}
@Override
public Site getSite() {
return site;
}
}
| [
"[email protected]"
] | |
cb8c8f3c730742eed09813438e337601c19fb0e6 | 8f26d9568eb3fcc00e04fe28f4cf21efb5320a6b | /FlightChess/src/main/java/flightchess/stsm/bussiness/entities/repositories/RoomDAOImpl.java | 3e2ab9ea3699842b20b993b6ca155b432c790fbd | [] | no_license | TOKISAKIKURUMI/FlightChess | 8d9c1858b46107308ebd01502c898ed2d508f97b | 068ca57c63c816ee61a2c9b19593185a3749b275 | refs/heads/master | 2016-08-12T11:38:19.023084 | 2016-03-31T12:28:51 | 2016-03-31T12:28:51 | 55,148,301 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,350 | java | package flightchess.stsm.bussiness.entities.repositories;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import flightchess.stsm.bussiness.entities.Room;
@Repository
public class RoomDAOImpl implements RoomDAO {
@Autowired
private SessionFactory sessionFactory;
private Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
public void addRoom(Room room) {
getCurrentSession().save(room);
}
public void updateRoom(Room room) {
Room roomToUpdate = getRoom(room.getRoomId());
roomToUpdate.setRoomStatus(room.getRoomRstatus());
roomToUpdate.setPlayerslist(room.getPlayerslist());
getCurrentSession().update(roomToUpdate);
}
public Room getRoom(int id) {
Room room = (Room) getCurrentSession().get(Room.class, id);
return room;
}
public void deleteRoom(int id) {
Room room = getRoom(id);
if (room != null)
getCurrentSession().delete(room);
}
@SuppressWarnings("unchecked")
public List<Room> getRooms() {
return getCurrentSession().createQuery("from Room").list();
}
}
| [
"[email protected]"
] | |
6a1864371ff60995a595b6d7c4034d0e1cc44022 | b48e06366fead556f677666cba2817ad4e0c9acf | /app/src/main/java/com/example/cse3311/loccareandroid/DBManager.java | 7737b9412fa9a77dfa458ce338e219c59529bfb9 | [] | no_license | dehanz13/LocCareAndroid | e6bc92ad5cca4951168141faf0ea57f170225dd6 | 1409b1bef818a0bc19447fdcd52e74a510e08306 | refs/heads/master | 2020-04-08T06:48:07.922367 | 2018-11-26T04:59:25 | 2018-11-26T04:59:25 | 159,113,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,444 | java | package com.example.cse3311.loccareandroid;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.content.ContentValues;
import java.util.Vector;
public class DBManager extends SQLiteOpenHelper {
//Create DB
private static final int Db_VERSION = 1;
private static final String DB_NAME = "loccare";
// Table names
private static final String USER_TABLE = "users";
private static final String ROOM_TABLE = "rooms";
// Users Table Columns
private static final String USER_FIRST_NAME = "first_name";
private static final String USER_LAST_NAME = "last_name";
private static final String USER_ID = "id";
private static final String USER_ROLE = "role";
private static final String USER_EMAIL = "email";
private static final String USER_PASS = "password";
private static final String USER_ROOM_CODE = "room_code";
private static final String USER_LAT = "latitude";
private static final String USER_LON = "longitude";
// Room Table Columns
private static final String ROOM_ID = "id";
private static final String ROOM_CODE = "room_code";
private static final String ROOM_NAME = "name";
public DBManager(Context context) {
super(context, DB_NAME, null, Db_VERSION);
}
private static final String CREATE_TABLE_USER = "CREATE TABLE " + USER_TABLE + "(" + USER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +
USER_FIRST_NAME + " TEXT," +USER_LAST_NAME + " TEXT," + USER_ROLE + " TEXT," + USER_EMAIL + " TEXT," + USER_PASS + " TEXT, " +
USER_ROOM_CODE + " TEXT," + USER_LAT + " REAL," + USER_LON + " REAL" /*" FOREIGN KEY(" + ROOM_CODE + ") "*/ + ")";
private static final String CREATE_TABLE_ROOM = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, %s CHAR(5), %s TEXT)",
ROOM_TABLE, ROOM_ID, ROOM_CODE, ROOM_NAME);
@Override
public void onCreate(SQLiteDatabase sqLitedb) {
sqLitedb.execSQL(CREATE_TABLE_ROOM);
sqLitedb.execSQL(CREATE_TABLE_USER);
}
@Override
public void onUpgrade(SQLiteDatabase sqLitedb, int i, int i1) {
sqLitedb.execSQL("DROP TABLE IF EXISTS " + USER_TABLE);
sqLitedb.execSQL("DROP TABLE IF EXISTS " + ROOM_TABLE);
onCreate(sqLitedb);
}
public void addNewUser(UserModel user){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(USER_FIRST_NAME, user.getFirstName());
values.put(USER_LAST_NAME, user.getLastName());
values.put(USER_ROLE, user.getRole());
values.put(USER_EMAIL, user.getEmail());
values.put(USER_PASS, user.getPassword());
db.insert(USER_TABLE, null, values);
db.close();
}
public void addNewRoom(RoomModel room) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(ROOM_NAME, room.getName());
values.put(ROOM_CODE, room.getCode());
db.insertOrThrow(ROOM_TABLE, null, values);
db.close();
}
public UserModel retrieveUser(String email) {
SQLiteDatabase db = this.getWritableDatabase();
String query = String.format("SELECT * from %s WHERE %s = \"%s\";", USER_TABLE, USER_EMAIL, email);
Cursor cursor = db.rawQuery(query, null);
UserModel user = new UserModel();
if (cursor.moveToFirst()) {
user.setEmail(cursor.getString(cursor.getColumnIndex(USER_EMAIL)));
user.setFirstName(cursor.getString(cursor.getColumnIndex(USER_FIRST_NAME)));
user.setLastName(cursor.getString(cursor.getColumnIndex(USER_LAST_NAME)));
user.setPassword(cursor.getString(cursor.getColumnIndex(USER_PASS)));
user.setRole(cursor.getString(cursor.getColumnIndex(USER_ROLE)));
user.setRoomCode(cursor.getString(cursor.getColumnIndex(USER_ROOM_CODE)));
} else {
user = null;
}
cursor.close();
return user;
}
public boolean roomExists(String roomCode) {
boolean exists = false;
SQLiteDatabase db = this.getReadableDatabase();
String query = String.format("SELECT * from %s WHERE %s = \"%s\";", ROOM_TABLE, ROOM_CODE, roomCode);
Cursor cursor = db.rawQuery(query, null);
RoomModel room = new RoomModel();
if (cursor.moveToFirst()) {
// room.setName(cursor.getString(cursor.getColumnIndex(USER_EMAIL)));
// room.setCode(cursor.getString(cursor.getColumnIndex(USER_FIRST_NAME)));
exists = true;
}
cursor.close();
return exists;
}
public RoomModel retrieveRoom(String roomCode) {
SQLiteDatabase db = this.getReadableDatabase();
String query = String.format("SELECT * from %s WHERE %s = \"%s\";", ROOM_TABLE, ROOM_CODE, roomCode);
Cursor cursor = db.rawQuery(query, null);
RoomModel room = new RoomModel();
if (cursor.moveToFirst()) {
room.setName(cursor.getString(cursor.getColumnIndex(ROOM_NAME)));
room.setCode(cursor.getString(cursor.getColumnIndex(ROOM_CODE)));
}
cursor.close();
return room;
}
public UserModel updateUserRoomCode(UserModel user) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(USER_ROOM_CODE, user.getRoomCode());
String whereClause = String.format("%s=?", USER_EMAIL);
String[] whereArgs = new String[] {
user.getEmail()
};
db.update(USER_TABLE, values, whereClause, whereArgs);
db.close();
return user;
}
public UserModel updateUserLocation(UserModel user) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(USER_LAT, user.getLatitude());
values.put(USER_LON, user.getLongitude());
String whereClause = String.format("%s=?", USER_EMAIL);
String[] whereArgs = new String[] {
user.getEmail()
};
db.update(USER_TABLE, values, whereClause, whereArgs);
db.close();
return user;
}
public Vector<UserModel> getUsersByRoom(String roomCode) {
SQLiteDatabase db = this.getReadableDatabase();
String query = String.format("SELECT * from %s WHERE %s = \"%s\";", USER_TABLE, USER_ROOM_CODE, roomCode);
Cursor cursor = db.rawQuery(query, null);
Vector<UserModel> users = new Vector<UserModel>();
if (cursor.moveToFirst()) {
do {
UserModel user = new UserModel();
user.setFirstName(cursor.getString(cursor.getColumnIndex(USER_FIRST_NAME)));
user.setLastName(cursor.getString(cursor.getColumnIndex(USER_LAST_NAME)));
user.setEmail(cursor.getString(cursor.getColumnIndex(USER_EMAIL)));
user.setRole(cursor.getString(cursor.getColumnIndex(USER_ROLE)));
user.setRoomCode(cursor.getString(cursor.getColumnIndex(USER_ROOM_CODE)));
users.add(user);
} while (cursor.moveToNext());
}
cursor.close();
return users;
}
}
| [
"[email protected]"
] | |
c15f6169346d68ff4fbc04599e36bd3bb815771d | cb1c725a6baf2517abafd53451b7dfaf5fe0840b | /maven-multi-module-archetype/src/main/resources/archetype-resources/__rootArtifactId__-app/src/main/java/app/exception/GlobalControllerExceptionHandler.java | cc3f8ad9c49d0bde5df2b8894e1abbd51cbfc658 | [
"Apache-2.0"
] | permissive | digimono/maven-archetypes | 2ff38491a79e3f33a357ad497e9b6ed1e624f0bd | 6b115187e826a271ea4f77f6fea01094cad7aa34 | refs/heads/master | 2023-01-08T22:51:46.961179 | 2019-11-29T01:22:33 | 2019-11-29T01:22:33 | 192,632,070 | 1 | 0 | Apache-2.0 | 2022-12-27T14:45:04 | 2019-06-19T00:49:52 | Java | UTF-8 | Java | false | false | 7,914 | java | /*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ${package}.app.exception;
import com.google.common.base.Joiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author ${author}
*/
@ControllerAdvice
public class GlobalControllerExceptionHandler {
private static final Logger LOG =
LoggerFactory.getLogger(GlobalControllerExceptionHandler.class);
private static final String SERVER_ERROR_MESSAGE = "系统繁忙,请稍后重试";
private static final String INVALID_FORMAT_MESSAGE = "参数错误,请检查参数";
private static final String MISSING_PARAMS_MESSAGE = "缺少参数,请检查参数";
private static final String MEDIA_TYPE_NOT_ACCEPTABLE_MESSAGE = "Unsupported MediaType";
private static final String HTTP_METHOD_UNSUPPORTED_MESSAGE = "Unsupported HttpMethod";
private final String errorCodeKey;
private final String errorMessageKey;
protected GlobalControllerExceptionHandler() {
this("code", "message");
}
protected GlobalControllerExceptionHandler(String errorCodeKey, String errorMessageKey) {
this.errorCodeKey = errorCodeKey;
this.errorMessageKey = errorMessageKey;
}
@ExceptionHandler({
HttpMediaTypeNotAcceptableException.class,
HttpRequestMethodNotSupportedException.class,
})
@ResponseStatus(HttpStatus.OK)
public ModelAndView handleMediaTypeException(HttpServletRequest request, Exception ex) {
String requestURI = getRequestURI(request);
LOG.error("{} {}, Msg: {}", request.getMethod(), requestURI, ex.getMessage(), ex);
int code;
String message;
if (ex instanceof HttpMediaTypeNotAcceptableException) {
code = HttpStatus.NOT_ACCEPTABLE.value();
message = MEDIA_TYPE_NOT_ACCEPTABLE_MESSAGE;
} else if (ex instanceof HttpRequestMethodNotSupportedException) {
HttpRequestMethodNotSupportedException exception =
(HttpRequestMethodNotSupportedException) ex;
String method = exception.getMethod();
String[] supportedMethods = exception.getSupportedMethods();
code = HttpStatus.METHOD_NOT_ALLOWED.value();
message =
String.format(
"%s: %s, supported methods: %s",
HTTP_METHOD_UNSUPPORTED_MESSAGE, method, Arrays.toString(supportedMethods));
} else {
code = HttpStatus.INTERNAL_SERVER_ERROR.value();
message = SERVER_ERROR_MESSAGE;
}
return genModelAndView(code, message);
}
@ExceptionHandler({
HttpMessageNotReadableException.class,
MissingServletRequestParameterException.class,
})
@ResponseStatus(HttpStatus.OK)
public ModelAndView handleBadRequestException(HttpServletRequest request, Exception ex) {
String requestURI = getRequestURI(request);
LOG.error("{} {}, Msg: {}", request.getMethod(), requestURI, ex.getMessage(), ex);
String message;
if (ex instanceof MissingServletRequestParameterException) {
String parameterName = ((MissingServletRequestParameterException) ex).getParameterName();
message = String.format("%s:[ %s ]", MISSING_PARAMS_MESSAGE, parameterName);
} else {
message = INVALID_FORMAT_MESSAGE;
}
return genModelAndView(HttpStatus.BAD_REQUEST.value(), message);
}
@ExceptionHandler({
BindException.class,
MethodArgumentNotValidException.class,
})
@ResponseStatus(HttpStatus.OK)
public ModelAndView handleArgumentException(HttpServletRequest request, Exception ex) {
String requestURI = getRequestURI(request);
LOG.error("{} {}, Msg: {}", request.getMethod(), requestURI, ex.getMessage(), ex);
String message;
Errors errors = getErrors(ex);
if (errors != null) {
List<String> errList =
errors.getFieldErrors().stream().map(FieldError::getField).collect(Collectors.toList());
message =
String.format(
"%s:[ %s ]", INVALID_FORMAT_MESSAGE, Joiner.on(", ").skipNulls().join(errList));
} else {
message = INVALID_FORMAT_MESSAGE;
}
return genModelAndView(HttpStatus.BAD_REQUEST.value(), message);
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.OK)
public ModelAndView handleException(HttpServletRequest request, Exception ex) {
String requestURI = getRequestURI(request);
LOG.error("{} {}, Msg: {}", request.getMethod(), requestURI, ex.getMessage(), ex);
return genModelAndView(HttpStatus.INTERNAL_SERVER_ERROR.value(), SERVER_ERROR_MESSAGE);
}
private String getRequestURI(HttpServletRequest request) {
String requestURI;
String queryString = request.getQueryString();
if (queryString != null && queryString.length() > 0) {
requestURI = String.format("%s?%s", request.getRequestURI(), queryString);
} else {
requestURI = request.getRequestURI();
}
return requestURI;
}
private Map<String, Object> genModelMap(int code, String message) {
Map<String, Object> model = new HashMap<>(2);
model.put(this.errorCodeKey, code);
if (message != null) {
model.put(this.errorMessageKey, message);
}
return model;
}
private ModelAndView genModelAndView(int code, String message) {
MappingJackson2JsonView jsonView = new MappingJackson2JsonView();
jsonView.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
ModelAndView mav = new ModelAndView();
mav.setView(jsonView);
mav.addAllObjects(genModelMap(code, message));
return mav;
}
private Errors getErrors(Exception ex) {
if (ex == null) {
return null;
}
if (ex instanceof BindException) {
return ((BindException) ex).getBindingResult();
} else if (ex instanceof MethodArgumentNotValidException) {
return ((MethodArgumentNotValidException) ex).getBindingResult();
}
return null;
}
}
| [
"[email protected]"
] | |
7e6a42a5f4ee01006af4c828c2b899bb27ac56d1 | 32978b5f198d362f66d8624597f224857494dc85 | /prestamos.core/src/main/java/ar/gov/cjpmv/prestamos/core/persistence/prestamo/Banco.java | d25b4db0c7fbbe4c6f6291e9a2bd7849bb9ab74a | [] | no_license | lusardim/cjpmv | 92292c21d98e93b15a58705150d5dde3cc33e121 | 3588e21c77a0f631be1e7c29b9c4cbe4f786def3 | refs/heads/master | 2021-12-14T13:21:43.924164 | 2021-12-09T17:42:01 | 2021-12-09T17:42:01 | 122,205,275 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,673 | java | package ar.gov.cjpmv.prestamos.core.persistence.prestamo;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class Banco implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2466201194955920342L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Basic(optional=false)
@Column(nullable=false)
private String nombre;
@OneToMany(mappedBy="banco")
private List<CuentaBancaria> listaCuentas;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public void setListaCuentas(List<CuentaBancaria> listaCuentas) {
this.listaCuentas = listaCuentas;
}
public List<CuentaBancaria> getListaCuentas() {
return listaCuentas;
}
@Override
public String toString(){
return this.getNombre();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.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;
Banco other = (Banco) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
| [
"[email protected]"
] | |
1ccec363833272dd4267931820fcb649d91d8421 | 4135a5c87202bbd2da78464d63232a591fd5237f | /DS_Elementary sorts/src/Combinesort/TestJUnit.java | 2fe6c73a7590c7091d92f9a0c48cdd4a6ef79554 | [] | no_license | karthiksvs/Data-Structures | 2baaeb444ca4a5213e9befb0e03f142c4e70eaee | cc4f73b6ab703caa91897c0141c1ba606c09bf4c | refs/heads/master | 2020-09-03T13:25:03.005327 | 2020-02-07T10:39:55 | 2020-02-07T10:39:55 | 219,472,974 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 26,635 | java | /**
* This is JUnit that tests the lower method in StringHandling class.
* This contains 80 testcases.
*
* Please don't run this file.
* You can add your own test cases to this file by just copy and
* paste the last three lines of the code (TestCase80).
*
* @author Deepak Kumar
* @author Vipul
*/
package Combinesort;
import org.junit.Test;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
public class TestJUnit {
@Test
public void testCase1() {
int[] arr = {787, 879, 180, 316, 904, 612, 778, 936, 422, 859};
int[] res = {180, 316, 422, 612, 778, 787, 859, 879, 904, 936};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase2() {
int[] arr = {2, 605, 128, 1, 176, 307, 671, 439, 131, 441, 690, 878, 381, 802, 816, 887, 165, 66, 198, 593, 546, 105, 451, 669, 861, 946, 488};
int[] res = {1, 2, 66, 105, 128, 131, 165, 176, 198, 307, 381, 439, 441, 451, 488, 546, 593, 605, 669, 671, 690, 802, 816, 861, 878, 887, 946};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase3() {
int[] arr = {197, 17, 697, 379, 879, 677, 770, 23, 743, 535, 55, 441, 520, 170, 524, 535, 509, 619, 778, 146, 920, 918, 957};
int[] res = {17, 23, 55, 146, 170, 197, 379, 441, 509, 520, 524, 535, 535, 619, 677, 697, 743, 770, 778, 879, 918, 920, 957};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase4() {
int[] arr = {};
int[] res = {};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase5() {
int[] arr = {283, 641, 532, 804, 677, 833, 169, 425, 987, 909, 487, 592, 553, 892, 269, 529, 929, 638, 387, 3, 54, 695, 90, 296, 575};
int[] res = {3, 54, 90, 169, 269, 283, 296, 387, 425, 487, 529, 532, 553, 575, 592, 638, 641, 677, 695, 804, 833, 892, 909, 929, 987};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase6() {
int[] arr = {619, 91, 466, 740, 845, 998, 919, 441, 246, 151, 546, 199, 623, 413, 842, 899, 465, 345, 749, 133, 342};
int[] res = {91, 133, 151, 199, 246, 342, 345, 413, 441, 465, 466, 546, 619, 623, 740, 749, 842, 845, 899, 919, 998};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase7() {
int[] arr = {457, 31, 987, 632, 314, 636, 665, 58, 271, 933, 308, 159, 766, 181, 967, 655, 334};
int[] res = {31, 58, 159, 181, 271, 308, 314, 334, 457, 632, 636, 655, 665, 766, 933, 967, 987};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase8() {
int[] arr = {329, 92, 283, 227, 88, 311, 289, 77, 81, 310, 206, 331, 999, 405, 588, 459, 251, 483, 549, 658, 966, 71, 441, 690, 328, 844, 979, 56, 258};
int[] res = {56, 71, 77, 81, 88, 92, 206, 227, 251, 258, 283, 289, 310, 311, 328, 329, 331, 405, 441, 459, 483, 549, 588, 658, 690, 844, 966, 979, 999};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase9() {
int[] arr = {457, 387, 664, 132, 998, 706, 453, 15, 134, 74, 350};
int[] res = {15, 74, 132, 134, 350, 387, 453, 457, 664, 706, 998};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase10() {
int[] arr = {846, 352, 796, 575};
int[] res = {352, 575, 796, 846};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase11() {
int[] arr = {166, 190, 819, 956, 815, 431, 463, 195, 633, 51, 905, 475, 662, 50, 160, 447};
int[] res = {50, 51, 160, 166, 190, 195, 431, 447, 463, 475, 633, 662, 815, 819, 905, 956};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase12() {
int[] arr = {3, 32, 65, 50, 812, 459, 584, 815, 877, 500, 429, 759, 623, 824, 262, 283, 719, 206, 437, 990, 497, 765, 175, 968, 603, 157, 708};
int[] res = {3, 32, 50, 65, 157, 175, 206, 262, 283, 429, 437, 459, 497, 500, 584, 603, 623, 708, 719, 759, 765, 812, 815, 824, 877, 968, 990};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase13() {
int[] arr = {694, 933, 479, 557, 917, 221, 840, 773, 769, 752, 492, 487, 115};
int[] res = {115, 221, 479, 487, 492, 557, 694, 752, 769, 773, 840, 917, 933};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase14() {
int[] arr = {638, 810, 352, 400, 882, 983, 940, 903, 789, 545, 612, 699, 333, 275, 70, 872, 765, 71, 924, 233, 73, 816, 941, 884, 919, 525, 974, 236, 465};
int[] res = {70, 71, 73, 233, 236, 275, 333, 352, 400, 465, 525, 545, 612, 638, 699, 765, 789, 810, 816, 872, 882, 884, 903, 919, 924, 940, 941, 974, 983};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase15() {
int[] arr = {304, 100, 667, 984, 710, 371, 947, 522, 324, 709, 755, 397, 179, 404, 938, 73, 542};
int[] res = {73, 100, 179, 304, 324, 371, 397, 404, 522, 542, 667, 709, 710, 755, 938, 947, 984};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase16() {
int[] arr = {736, 628, 944, 914, 500, 72, 590, 503, 602, 593, 169, 705, 971, 264, 380, 103, 101, 452, 843};
int[] res = {72, 101, 103, 169, 264, 380, 452, 500, 503, 590, 593, 602, 628, 705, 736, 843, 914, 944, 971};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase17() {
int[] arr = {411, 35, 549, 143, 822, 583};
int[] res = {35, 143, 411, 549, 583, 822};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase18() {
int[] arr = {657, 379, 703, 669, 208, 207, 612, 723, 795, 21, 788, 135, 529, 227, 222, 230, 805, 110, 435, 675, 416};
int[] res = {21, 110, 135, 207, 208, 222, 227, 230, 379, 416, 435, 529, 612, 657, 669, 675, 703, 723, 788, 795, 805};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase19() {
int[] arr = {38, 56, 398};
int[] res = {38, 56, 398};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase20() {
int[] arr = {722, 757, 839, 875, 472, 99, 338, 574, 209, 896, 623, 275, 349, 661, 838, 647, 394, 476, 12, 19, 672, 416, 90, 8};
int[] res = {8, 12, 19, 90, 99, 209, 275, 338, 349, 394, 416, 472, 476, 574, 623, 647, 661, 672, 722, 757, 838, 839, 875, 896};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase21() {
int[] arr = {904, 232, 663, 557, 501, 159, 766, 561, 624, 124, 393, 3, 410, 16, 484, 904, 39, 103, 44, 695, 583, 365, 412, 618, 768, 813, 268, 367, 912};
int[] res = {3, 16, 39, 44, 103, 124, 159, 232, 268, 365, 367, 393, 410, 412, 484, 501, 557, 561, 583, 618, 624, 663, 695, 766, 768, 813, 904, 904, 912};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase22() {
int[] arr = {979, 161, 954, 326, 386, 379, 503, 83, 965, 138, 981, 405, 168, 134, 736, 656, 362, 228, 390};
int[] res = {83, 134, 138, 161, 168, 228, 326, 362, 379, 386, 390, 405, 503, 656, 736, 954, 965, 979, 981};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase23() {
int[] arr = {992, 638, 31, 212, 646, 260, 715, 13, 539, 984, 411, 425, 602, 899, 610, 856};
int[] res = {13, 31, 212, 260, 411, 425, 539, 602, 610, 638, 646, 715, 856, 899, 984, 992};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase24() {
int[] arr = {879, 338};
int[] res = {338, 879};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase25() {
int[] arr = {82, 66, 214, 267, 904, 335, 16, 186, 532, 976, 887, 20, 851, 137, 489, 250, 883, 301, 95, 814, 437, 995, 228, 797};
int[] res = {16, 20, 66, 82, 95, 137, 186, 214, 228, 250, 267, 301, 335, 437, 489, 532, 797, 814, 851, 883, 887, 904, 976, 995};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase26() {
int[] arr = {655, 56, 775, 5, 241, 237, 343, 900, 650, 496, 533, 486, 939, 922, 694, 510, 831, 624, 773, 429, 268, 882};
int[] res = {5, 56, 237, 241, 268, 343, 429, 486, 496, 510, 533, 624, 650, 655, 694, 773, 775, 831, 882, 900, 922, 939};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase27() {
int[] arr = {597, 45, 809, 782, 805, 301, 478, 332, 612, 973, 265, 189};
int[] res = {45, 189, 265, 301, 332, 478, 597, 612, 782, 805, 809, 973};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase28() {
int[] arr = {765, 666, 971, 187, 925, 803, 320, 307, 67, 224, 118, 540, 504, 367, 143, 647, 103, 384, 854, 53};
int[] res = {53, 67, 103, 118, 143, 187, 224, 307, 320, 367, 384, 504, 540, 647, 666, 765, 803, 854, 925, 971};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase29() {
int[] arr = {448, 958, 804, 598, 618, 638, 282, 932, 515, 890, 895, 344, 190, 119, 615, 509, 326, 400, 283, 606, 544, 114, 706, 113, 530, 534, 808, 108, 893};
int[] res = {108, 113, 114, 119, 190, 282, 283, 326, 344, 400, 448, 509, 515, 530, 534, 544, 598, 606, 615, 618, 638, 706, 804, 808, 890, 893, 895, 932, 958};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase30() {
int[] arr = {324, 720};
int[] res = {324, 720};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase31() {
int[] arr = {692};
int[] res = {692};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase32() {
int[] arr = {194, 753, 375, 655, 890, 339, 413, 891, 582, 628, 340, 694, 729};
int[] res = {194, 339, 340, 375, 413, 582, 628, 655, 694, 729, 753, 890, 891};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase33() {
int[] arr = {529, 507, 93, 39, 356, 895, 178, 512, 770, 979, 575, 536, 125, 20, 618, 212, 403, 318, 898, 4, 847, 797};
int[] res = {4, 20, 39, 93, 125, 178, 212, 318, 356, 403, 507, 512, 529, 536, 575, 618, 770, 797, 847, 895, 898, 979};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase34() {
int[] arr = {7, 118, 807, 879, 807, 778, 723, 967, 295, 671};
int[] res = {7, 118, 295, 671, 723, 778, 807, 807, 879, 967};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase35() {
int[] arr = {812, 295, 170, 60, 70, 772, 157, 154, 102, 161, 420, 525, 797, 285, 55, 226, 376, 242};
int[] res = {55, 60, 70, 102, 154, 157, 161, 170, 226, 242, 285, 295, 376, 420, 525, 772, 797, 812};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase36() {
int[] arr = {17, 362, 573, 283, 924, 498, 464, 930, 762, 988, 621, 902, 350, 234, 205, 2, 405, 687, 912, 182, 940, 74, 822, 329, 118};
int[] res = {2, 17, 74, 118, 182, 205, 234, 283, 329, 350, 362, 405, 464, 498, 573, 621, 687, 762, 822, 902, 912, 924, 930, 940, 988};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase37() {
int[] arr = {274};
int[] res = {274};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase38() {
int[] arr = {977, 346, 671, 92, 919, 462, 456, 810, 157, 145, 965, 21, 953, 179, 265, 139, 641, 309, 919, 907, 244, 458, 486, 272, 943, 554, 269};
int[] res = {21, 92, 139, 145, 157, 179, 244, 265, 269, 272, 309, 346, 456, 458, 462, 486, 554, 641, 671, 810, 907, 919, 919, 943, 953, 965, 977};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase39() {
int[] arr = {673, 351, 655, 50, 60, 974, 380, 0, 836, 994, 504, 205, 608, 541, 841, 708, 553, 231, 591, 801, 319, 404, 633, 505, 537};
int[] res = {0, 50, 60, 205, 231, 319, 351, 380, 404, 504, 505, 537, 541, 553, 591, 608, 633, 655, 673, 708, 801, 836, 841, 974, 994};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase40() {
int[] arr = {108, 741, 978, 228};
int[] res = {108, 228, 741, 978};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortInsertion(arr));
}
@Test
public void testCase41() {
int[] arr = {772, 707, 712, 614, 966, 999, 70};
int[] res = {70, 614, 707, 712, 772, 966, 999};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase42() {
int[] arr = {46, 82, 648, 786, 795, 516, 24, 364, 364, 752, 898, 809, 201, 615, 809, 884, 257, 22};
int[] res = {22, 24, 46, 82, 201, 257, 364, 364, 516, 615, 648, 752, 786, 795, 809, 809, 884, 898};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase43() {
int[] arr = {287, 399, 591, 67, 740, 853, 407, 76, 658, 295, 282, 639, 106, 712, 343, 702, 544, 409, 992, 405, 916, 542, 163, 950, 242};
int[] res = {67, 76, 106, 163, 242, 282, 287, 295, 343, 399, 405, 407, 409, 542, 544, 591, 639, 658, 702, 712, 740, 853, 916, 950, 992};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase44() {
int[] arr = {775, 927, 978, 665, 251, 536, 304, 201, 966, 944, 979, 766, 535, 70, 624, 652, 236, 822, 925, 734, 714, 770, 695, 323, 935, 865};
int[] res = {70, 201, 236, 251, 304, 323, 535, 536, 624, 652, 665, 695, 714, 734, 766, 770, 775, 822, 865, 925, 927, 935, 944, 966, 978, 979};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase45() {
int[] arr = {769, 919, 643, 629, 677, 665, 503, 452, 917, 983, 116, 400, 853, 803, 676, 323, 715, 524, 410};
int[] res = {116, 323, 400, 410, 452, 503, 524, 629, 643, 665, 676, 677, 715, 769, 803, 853, 917, 919, 983};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase46() {
int[] arr = {884, 513, 722, 172, 643, 16, 184, 405, 803, 699, 3, 545, 84, 159, 334};
int[] res = {3, 16, 84, 159, 172, 184, 334, 405, 513, 545, 643, 699, 722, 803, 884};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase47() {
int[] arr = {448, 11, 285, 732, 753, 47, 709, 193, 616, 879, 31, 847, 948, 106, 126, 489, 142, 23, 213, 121, 197, 84, 329, 596};
int[] res = {11, 23, 31, 47, 84, 106, 121, 126, 142, 193, 197, 213, 285, 329, 448, 489, 596, 616, 709, 732, 753, 847, 879, 948};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase48() {
int[] arr = {468, 940, 198, 450, 524, 765, 197, 793, 754, 621, 341};
int[] res = {197, 198, 341, 450, 468, 524, 621, 754, 765, 793, 940};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase49() {
int[] arr = {73, 625, 864, 156, 521, 192, 794, 571, 295, 156, 809, 660, 110, 31, 721, 708, 404};
int[] res = {31, 73, 110, 156, 156, 192, 295, 404, 521, 571, 625, 660, 708, 721, 794, 809, 864};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase50() {
int[] arr = {646, 787, 35, 727, 812, 148, 550, 546, 6, 220, 420, 432, 480, 266, 626, 803, 38, 469, 635, 215, 453, 630};
int[] res = {6, 35, 38, 148, 215, 220, 266, 420, 432, 453, 469, 480, 546, 550, 626, 630, 635, 646, 727, 787, 803, 812};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase51() {
int[] arr = {848};
int[] res = {848};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase52() {
int[] arr = {22, 454, 857, 814, 542, 125, 190, 865, 926, 697, 365, 125, 718, 843, 82, 394, 953, 197, 734, 706, 462};
int[] res = {22, 82, 125, 125, 190, 197, 365, 394, 454, 462, 542, 697, 706, 718, 734, 814, 843, 857, 865, 926, 953};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase53() {
int[] arr = {220, 796, 976, 620, 306, 324, 412};
int[] res = {220, 306, 324, 412, 620, 796, 976};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase54() {
int[] arr = {26, 178, 878, 208, 517, 480, 15, 186, 627, 996, 582, 934, 783, 46, 51, 950, 692, 623, 818, 739, 727, 985, 826, 556, 64, 316, 192, 837};
int[] res = {15, 26, 46, 51, 64, 178, 186, 192, 208, 316, 480, 517, 556, 582, 623, 627, 692, 727, 739, 783, 818, 826, 837, 878, 934, 950, 985, 996};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase55() {
int[] arr = {385, 715, 349, 78, 2, 664, 204, 448, 469, 225, 49, 182, 920, 23, 349, 742, 34, 271, 818, 191, 188};
int[] res = {2, 23, 34, 49, 78, 182, 188, 191, 204, 225, 271, 349, 349, 385, 448, 469, 664, 715, 742, 818, 920};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase56() {
int[] arr = {512, 569};
int[] res = {512, 569};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase57() {
int[] arr = {297, 470, 722, 861, 972, 453, 134, 557, 486};
int[] res = {134, 297, 453, 470, 486, 557, 722, 861, 972};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase58() {
int[] arr = {113, 791, 229, 706, 993, 64, 331, 193, 488, 74, 218, 860, 846, 829, 341, 373, 565, 968, 335};
int[] res = {64, 74, 113, 193, 218, 229, 331, 335, 341, 373, 488, 565, 706, 791, 829, 846, 860, 968, 993};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase59() {
int[] arr = {995, 92, 384};
int[] res = {92, 384, 995};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase60() {
int[] arr = {873, 913, 472, 891, 376, 385, 822, 128, 593};
int[] res = {128, 376, 385, 472, 593, 822, 873, 891, 913};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase61() {
int[] arr = {839, 168, 758, 779, 479, 180, 964, 774};
int[] res = {168, 180, 479, 758, 774, 779, 839, 964};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase62() {
int[] arr = {81, 594, 838, 125, 799, 789, 434, 653, 371, 652};
int[] res = {81, 125, 371, 434, 594, 652, 653, 789, 799, 838};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase63() {
int[] arr = {346, 640, 885, 442, 571, 398, 928, 205, 829, 854, 128, 740, 223, 557, 288, 623};
int[] res = {128, 205, 223, 288, 346, 398, 442, 557, 571, 623, 640, 740, 829, 854, 885, 928};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase64() {
int[] arr = {608, 849, 11, 298, 125, 983, 600, 530, 212, 913, 342, 189, 851, 457, 961, 193, 447, 127, 593, 576, 647, 481, 850, 720, 916, 613, 317};
int[] res = {11, 125, 127, 189, 193, 212, 298, 317, 342, 447, 457, 481, 530, 576, 593, 600, 608, 613, 647, 720, 849, 850, 851, 913, 916, 961, 983};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase65() {
int[] arr = {284, 303, 585, 841, 147, 586, 793, 634};
int[] res = {147, 284, 303, 585, 586, 634, 793, 841};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase66() {
int[] arr = {479, 277, 749, 983, 434, 585, 519, 255, 655, 887, 625, 313, 594, 114, 166, 964, 677, 509, 672};
int[] res = {114, 166, 255, 277, 313, 434, 479, 509, 519, 585, 594, 625, 655, 672, 677, 749, 887, 964, 983};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase67() {
int[] arr = {499, 241, 1, 877, 346, 866, 681, 132, 192, 577, 340, 848, 76, 701, 382, 2, 296, 902, 231, 114, 85, 454, 797, 266, 611, 217};
int[] res = {1, 2, 76, 85, 114, 132, 192, 217, 231, 241, 266, 296, 340, 346, 382, 454, 499, 577, 611, 681, 701, 797, 848, 866, 877, 902};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase68() {
int[] arr = {699, 223, 7, 538, 30, 571, 950, 406, 996, 754, 214, 424, 451, 509, 69, 733, 436, 12, 395, 434, 949, 300, 34, 711, 739, 276, 22, 747, 460};
int[] res = {7, 12, 22, 30, 34, 69, 214, 223, 276, 300, 395, 406, 424, 434, 436, 451, 460, 509, 538, 571, 699, 711, 733, 739, 747, 754, 949, 950, 996};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase69() {
int[] arr = {427, 666, 885, 42, 771, 342, 276, 372, 595, 798, 469, 163, 422, 860, 452, 131, 299, 729};
int[] res = {42, 131, 163, 276, 299, 342, 372, 422, 427, 452, 469, 595, 666, 729, 771, 798, 860, 885};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase70() {
int[] arr = {821, 191, 408, 528, 379, 527, 371, 658, 819, 835, 657, 170, 146, 879, 24, 62, 702, 977};
int[] res = {24, 62, 146, 170, 191, 371, 379, 408, 527, 528, 657, 658, 702, 819, 821, 835, 879, 977};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase71() {
int[] arr = {279, 538, 865, 909, 410, 596, 595, 338, 871, 312, 545, 639, 295, 190, 428, 554, 832, 479, 802, 750, 594, 791, 189, 575, 321, 839, 802, 768};
int[] res = {189, 190, 279, 295, 312, 321, 338, 410, 428, 479, 538, 545, 554, 575, 594, 595, 596, 639, 750, 768, 791, 802, 802, 832, 839, 865, 871, 909};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase72() {
int[] arr = {384, 304, 385, 64, 102, 263, 638, 310, 791, 430};
int[] res = {64, 102, 263, 304, 310, 384, 385, 430, 638, 791};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase73() {
int[] arr = {426, 11, 302, 542, 634, 931, 886, 203, 350, 54, 381, 337};
int[] res = {11, 54, 203, 302, 337, 350, 381, 426, 542, 634, 886, 931};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase74() {
int[] arr = {768, 12, 918, 750, 521, 156};
int[] res = {12, 156, 521, 750, 768, 918};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase75() {
int[] arr = {618, 439, 419, 285, 771, 321, 961, 552, 651, 526, 778, 51, 586, 231, 973, 271, 602, 979, 724, 740, 274};
int[] res = {51, 231, 271, 274, 285, 321, 419, 439, 526, 552, 586, 602, 618, 651, 724, 740, 771, 778, 961, 973, 979};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase76() {
int[] arr = {365, 108, 53, 670, 136, 112, 792, 115, 61, 771, 123, 128, 337, 596, 432, 974, 855, 562, 941, 125, 957};
int[] res = {53, 61, 108, 112, 115, 123, 125, 128, 136, 337, 365, 432, 562, 596, 670, 771, 792, 855, 941, 957, 974};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase77() {
int[] arr = {50, 259, 962, 952, 180, 972, 245, 356, 806, 372, 211, 958, 949, 728, 38, 841, 553, 821, 270};
int[] res = {38, 50, 180, 211, 245, 259, 270, 356, 372, 553, 728, 806, 821, 841, 949, 952, 958, 962, 972};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase78() {
int[] arr = {369, 998, 66, 67, 289, 621, 626, 159, 198, 509};
int[] res = {66, 67, 159, 198, 289, 369, 509, 621, 626, 998};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase79() {
int[] arr = {672, 745, 257, 78, 528, 638, 406, 399, 557, 636, 168, 327, 891, 597, 886, 838, 134, 719, 593, 297, 271, 592, 40, 847, 580, 319};
int[] res = {40, 78, 134, 168, 257, 271, 297, 319, 327, 399, 406, 528, 557, 580, 592, 593, 597, 636, 638, 672, 719, 745, 838, 847, 886, 891};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
@Test
public void testCase80() {
int[] arr = {912, 441, 105, 588, 284, 808};
int[] res = {105, 284, 441, 588, 808, 912};
Solution s = new Solution();
Assert.assertArrayEquals( res, s.sortSelection(arr));
}
}
| [
"[email protected]"
] | |
9812187abce9ce7c7357f5b3f621d92460c65f31 | 5e518e80a8be4bc6ce2d9b7067500ff71707864f | /sandbox-encryption/src/test/java/tryanderror/encryption/Rsa.java | 7dbde9decdfedd50543904f14f4e8539db0e7fbb | [] | no_license | signed/sandboxes | 7a510b4ee421f0eb9478dac2e0f952ab6dd4ce41 | a662ff7e5483b75ac52a1c356effe9bedf83b4f7 | refs/heads/master | 2023-08-17T04:06:51.490936 | 2023-08-15T19:42:55 | 2023-08-15T19:42:55 | 4,309,543 | 1 | 0 | null | 2014-06-01T10:01:47 | 2012-05-12T20:34:47 | Java | UTF-8 | Java | false | false | 3,821 | java | package tryanderror.encryption;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.*;
import static org.mockito.Matchers.isNotNull;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.math.BigInteger;
import java.net.URL;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.Collection;
import java.util.Enumeration;
import javax.crypto.Cipher;
import org.junit.Test;
public class Rsa {
@Test
public void generateAPublicAnAPrivateRsaKey() throws Exception {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(2048);
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.getPrivate();
KeyFactory fact = KeyFactory.getInstance("RSA");
RSAPublicKeySpec pub = fact.getKeySpec(kp.getPublic(),
RSAPublicKeySpec.class);
RSAPrivateKeySpec priv = fact.getKeySpec(kp.getPrivate(),
RSAPrivateKeySpec.class);
}
@Test
public void retrieveKeysFromAPkcs12File() throws Exception {
KeyStore keystore = java.security.KeyStore.getInstance("PKCS12");
File file = getFileFor("bundle.p12");
keystore.load(new FileInputStream(file), "secret".toCharArray());
for (Enumeration enums = keystore.aliases(); enums.hasMoreElements();) {
String alias = (String) enums.nextElement();
if (keystore.isKeyEntry(alias)) {
PrivateKey key = (PrivateKey) keystore.getKey(alias, "secret".toCharArray());
}
}
}
@Test
public void retriveKeyFromAPkcs7File() throws Exception {
File publicKeyFile = getFileFor("server.p7b");
FileInputStream fileInputStream = new FileInputStream(publicKeyFile);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
Collection collection = certificateFactory.generateCertificates(fileInputStream);
Certificate certificate = (Certificate) collection.iterator().next();
PublicKey publicKey = certificate.getPublicKey();
System.out.println(publicKey);
assertThat(publicKey, is(notNullValue()));
}
public void saveToFile(String fileName, BigInteger mod, BigInteger exp) throws IOException {
FileOutputStream out = new FileOutputStream(fileName);
BufferedOutputStream out2 = new BufferedOutputStream(out);
ObjectOutputStream oout = new ObjectOutputStream(out2);
try {
oout.writeObject(mod);
oout.writeObject(exp);
} catch (Exception e) {
throw new IOException("Unexpected error", e);
} finally {
oout.close();
}
}
@Test
public void testname() throws Exception {
KeyPair keys = KeyPairGenerator.getInstance("RSA").generateKeyPair();
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, keys.getPublic());
byte[] rawData = "top secret".getBytes();
byte[] encrypted = cipher.doFinal(rawData);
cipher.init(Cipher.DECRYPT_MODE, keys.getPrivate());
byte[] decrypted = cipher.doFinal(encrypted);
String notASecretAnyMore = new String(decrypted);
}
private File getFileFor(String filename) {
URL url = getClass().getResource("/rsa_keys/server/"+filename);
File file = new File(url.getFile());
return file;
}
} | [
"[email protected]"
] | |
23a73d354dafdf828e9a171e3060cb4b795e6a21 | b9eb0d8f877e88ca818d5063c56245f75e69c3a1 | /src/main/java/com/example/springbootcommunityweb/controller/LoginController.java | 64dbbb581fed5c37d5e8e6d9cc6e5b5296e1ec7a | [] | no_license | leejohy-0223/Spring-Boot-Community-Web | 63216f8ef3cc60d2264d7b79f713e4783474754e | 080fb61fb0e0ddbf939137701fb0c6c96d78ee79 | refs/heads/master | 2023-08-01T20:59:28.899942 | 2021-09-15T14:53:09 | 2021-09-15T14:53:09 | 406,403,359 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 552 | java | package com.example.springbootcommunityweb.controller;
import com.example.springbootcommunityweb.annotation.SocialUser;
import com.example.springbootcommunityweb.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class LoginController {
@GetMapping("/login")
public String login() {
return "login";
}
@GetMapping("/loginSuccess")
public String loginComplete(@SocialUser User user) {
return "redirect:/board/list";
}
}
| [
"[email protected]"
] | |
7a534a4ff0059835867961628e48247a507e5be9 | 25baed098f88fc0fa22d051ccc8027aa1834a52b | /src/main/java/com/ljh/daoMz/JytTradeinfoLogMapper.java | a2c413e30befc05bb6d3b862d34ca415bce71451 | [] | no_license | woai555/ljh | a5015444082f2f39d58fb3e38260a6d61a89af9f | 17cf8f4415c9ae7d9fedae46cd9e9d0d3ce536f9 | refs/heads/master | 2022-07-11T06:52:07.620091 | 2022-01-05T06:51:27 | 2022-01-05T06:51:27 | 132,585,637 | 0 | 0 | null | 2022-06-17T03:29:19 | 2018-05-08T09:25:32 | Java | UTF-8 | Java | false | false | 278 | java | package com.ljh.daoMz;
import com.ljh.bean.JytTradeinfoLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ljh
* @since 2020-10-26
*/
public interface JytTradeinfoLogMapper extends BaseMapper<JytTradeinfoLog> {
}
| [
"[email protected]"
] | |
4e1827fb7203001f39e79e2143a0e10ca7db9000 | 486678450069363a9aa09b46495ab9d4b0e579a5 | /Resturant/src/main/java/com/pavansrivatsav/service/ItemCategoryService.java | f8719fe035e4c0f5bb3f12bb841b79a38a3f6be7 | [] | no_license | PavanSrivatsav/RestaurantJava | d6becaec061ce158ac202db6d5e5fc1933f38957 | 275a39914041045cd8db47edc1edaa88d32a1dfa | refs/heads/master | 2020-05-23T10:17:24.039640 | 2017-02-01T10:17:26 | 2017-02-01T10:17:26 | 80,413,402 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,387 | java | package com.pavansrivatsav.service;
import com.pavansrivatsav.dao.ItemCategoryDAO;
import com.pavansrivatsav.exception.ServiceException;
import com.pavansrivatsav.exception.ValidationException;
import com.pavansrivatsav.modal.ItemCategory;
import com.pavansrivatsav.validator.ItemCategoryValidator;
public class ItemCategoryService {
private ItemCategoryValidator itcValidator = new ItemCategoryValidator();
public void insert(ItemCategory itc) throws ServiceException {
ItemCategoryDAO itcdao = new ItemCategoryDAO();
try {
itcValidator.validateInsert(itc);
itcdao.insert(itc);
} catch (ValidationException e) {
// e.printStackTrace();
throw new ServiceException("Could not insert into itemCategory");
}
}
public void update(ItemCategory itc) throws ServiceException {
ItemCategoryDAO itcdao = new ItemCategoryDAO();
try {
itcValidator.validateUpdate(itc);
itcdao.update(itc);
} catch (ValidationException e) {
// e.printStackTrace();
throw new ServiceException("Could not update itemCategory");
}
}
public void delete(ItemCategory itc) throws ServiceException {
ItemCategoryDAO itcdao = new ItemCategoryDAO();
try {
itcValidator.validateDelete(itc);
itcdao.delete(itc.getId());
} catch (ValidationException e) {
// e.printStackTrace();
throw new ServiceException("Could not delete itemCategory");
}
}
}
| [
"[email protected]"
] | |
cf2575ed592aa423ced697c503920122e0a20af6 | 0ab1a7a81f238b22f52bed1e4ae02acbe1daeda1 | /pay_android/app/src/main/java/com/example/epay/adapter/TransferDetailListAdapter.java | 495404cf71f76a7ff93a399aa700f8c53b263e1a | [] | no_license | 1521zxc/Mke | 844e32319bc73d49d2c17af3a3bee27db8aefea1 | 9aa2ec69b79e3000300d3c6e3617b314a4bd64b3 | refs/heads/master | 2022-12-09T15:08:04.844050 | 2019-09-25T09:54:46 | 2019-09-25T09:54:46 | 194,998,805 | 0 | 0 | null | 2022-12-08T02:06:53 | 2019-07-03T07:07:08 | Java | UTF-8 | Java | false | false | 2,277 | java | package com.example.epay.adapter;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import com.example.epay.R;
import com.example.epay.base.TBaseAdapter;
import com.example.epay.bean.TransferList;
import com.example.epay.util.DateUtil;
import java.util.ArrayList;
/**
* Created by liujin on 2018/1/20.
*/
public class TransferDetailListAdapter extends TBaseAdapter<TransferList> {
public TransferDetailListAdapter(Activity context, ArrayList<TransferList> list) {
super(context, list);
}
@Override
public int getItemResourceId() {
return R.layout.item_transfer_detail;
}
@Override
public void initItemView(PxViewHolder view, final ArrayList<TransferList> list, final int position) {
view.<TextView>find(R.id.item_sum).setText("¥"+list.get(position).getSum());
Drawable drawable = null;
if(list.get(position).getType().equals("1")) {
drawable = context.getResources().getDrawable(R.drawable.icon_weixin_pay);
}else if(list.get(position).getType().equals("2")){
drawable = context.getResources().getDrawable(R.drawable.icon_alipay_pay);
}else if (list.get(position).getType().equals("3")){
drawable = context.getResources().getDrawable(R.drawable.qq);
}else if (list.get(position).getType().equals("4")){
drawable = context.getResources().getDrawable(R.drawable.jd);
}else if (list.get(position).getType().equals("5")){
drawable = context.getResources().getDrawable(R.drawable.baidu);
}else if (list.get(position).getType().equals("6")){
drawable = context.getResources().getDrawable(R.drawable.union);
}
//第一是距左边距离,第二是距上边距离,第三第四分别是长宽
drawable.setBounds(0,0,(int)(0.07*w),(int)(0.07*w));
//drawable 第一个是文字TOP
view.<TextView>find(R.id.item_sum).setCompoundDrawables(drawable,null,null,null);
view.<TextView>find(R.id.item_fee).setText("¥"+list.get(position).getServiceFee());
view.<TextView>find(R.id.item_time).setText(DateUtil.format2(list.get(position).getTransferTime(),"yyyy-MM-dd HH:mm:ss"));
}
}
| [
"[email protected]"
] | |
d338347d74bf18a7362a05ae2d3937349ae839ae | bb733ab4e8d708aa002710dcbbb451d9d263eae3 | /Pancakes.java | 223a221c6c50e6dbfa5fbe1d465fa0f4e1d97327 | [] | no_license | AbdullahJasim/GoogleCodejam | 422f8ef1a47ca07af9dc8004d3d1c5a879b24b91 | 5e5b126dba0b84420bb97edce7b3f4c16f77d486 | refs/heads/master | 2020-12-24T18:13:34.078618 | 2016-05-20T05:42:23 | 2016-05-20T05:42:23 | 57,459,162 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,540 | java | public class Pancakes {
private void printOutput(int caseNum, String pancakes) {
char[] newPancakes = pancakes.toCharArray();
int steps = flipPancakes(newPancakes, 0);
System.out.println("Case #" + caseNum + ": " + steps);
}
//Find the pancake with the blank page at the very bottom
private int lastPancake(char[] pancakes) {
for (int i = pancakes.length - 1; i > 0; i--) {
if (pancakes[i] != '+') {
return i;
}
}
return 0;
}
//Recursive function, flip all necessary top pancakes then call again
//Return the number of steps when all pancakes are on the happy side
private int flipPancakes(char[] pancakes, int step) {
if (checkIfReady(pancakes)) return step;
char[] flippedPancakes = new char[pancakes.length];
int lastPancake = lastPancake(pancakes) + 1;
for (int i = lastPancake; i < pancakes.length; i++) {
flippedPancakes[i] = '+';
}
int j = lastPancake;
for (int i = 0; i < lastPancake; i++) {
if (pancakes[i] == '-') {
flippedPancakes[i] = '+';
} else {
flippedPancakes[i] = '-';
}
}
return flipPancakes(flippedPancakes, step + 1);
}
private boolean checkIfReady(char[] pancakes) {
boolean ready = true;
for (int i = 0; i < pancakes.length; i++) {
if (pancakes[i] != '+') return false;
}
return true;
}
public static void main(String args []) {
int i = 1;
Pancakes pancakes = new Pancakes();
while (i < Integer.parseInt(args[0]) + 1) {
pancakes.printOutput(i, args[i]);
i++;
}
System.exit(0);
}
} | [
"[email protected]"
] | |
675176b8364fe0e1f02522780ed1c2670b406a50 | 6b289d839630ec3f41923e11b5b199bba3de8e3b | /CarrotMarket/src/main/java/carrot/market/test/service/MarketService.java | fe0c9b2f3cd85644ec3b967858a89481a5edeb11 | [] | no_license | searpier/Market | a3bf9fb5ab54cd94fadaafb3f7fe2efdc1a65d1e | a56148fc046ac272b1f94d54c3ac42650b327fad | refs/heads/master | 2022-05-01T00:05:36.014731 | 2022-04-01T12:24:45 | 2022-04-01T12:24:45 | 220,669,747 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,727 | java | package carrot.market.test.service;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import carrot.market.test.model.Product;
import carrot.market.test.model.User;
import carrot.market.test.repository.MarketDAO;
import carrot.market.test.repository.MarketRepository;
/**
* @Author : 전상수
* @Date : 2019. 11. 08.
* @Class 설명 : 당근마켓 서비스
*
*/
@Service
public class MarketService {
@Autowired
MarketRepository repo;
/* 회원등록 */
public int insertUser(User user) {
return repo.insertUser(user);
}
/* 회원로그인 */
public User selectUser(User user) {
return repo.selectUser(user);
}
/* 상품등록 */
public int insertProduct(Product product) {
return repo.insertProduct(product);
}
/* 차량등록 */
public int insertCar(Product product) {
return repo.insertCar(product);
}
/* 상품 전체 조회 */
public List<Product> selectProducts() {
return repo.selectProducts();
}
/* 일련번호로 상품조회 */
public Product selectProductBySeq(String productSeq) {
return repo.selectProductBySeq(productSeq);
}
/* 필터조건으로 차량조회 */
public List<Product> selectCarByFilter(HashMap<String, String> productSeq) {
return repo.selectCarByFilter(productSeq);
}
/* 일련번호로 차량조회 */
public Product selectCarBySeq(String productSeq) {
return repo.selectCarBySeq(productSeq);
}
/* 카테고리로 상품조회 */
public List<Product> selectProductByCategory(String category) {
return repo.selectProductByCategory(category);
}
}
| [
"searp@DESKTOP-6FU4SS6"
] | searp@DESKTOP-6FU4SS6 |
45d169bef47ee014c74b5b1e1302ab82ddf9b22a | fd9fbcc4249c63df38fab3fbc1cde7cdb3936b19 | /src/test/java/com/changmin/AOP/AOPTest.java | 62dad1682026df4a276002424f4383931602a5ff | [] | no_license | pcm5566/SpringAOPDemo | 71d494675215e20f70aa63b0d4a62e44e2e6d58b | 617fba89443b8b344f43b54239de0033c159e36f | refs/heads/master | 2020-04-02T01:48:54.677802 | 2018-10-20T06:28:22 | 2018-10-20T06:28:22 | 153,876,434 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 230 | java | package com.changmin.AOP;
import org.testng.annotations.Test;
public class AOPTest {
@Test
public void proxy(){
ForumService forumService = new ForumServiceImpl();
forumService.removeTopic(1200);
}
}
| [
"[email protected]"
] | |
a871aa312991582c69f157b1ce8559e42cfda098 | a495da428ac50c496aa68a3fd8bfc8805cf1ea9c | /src/algorithm2/Bits.java | 65c5a80dde5ac982af6d345ce273c0691cf1daca | [] | no_license | shizhh/Leetcode | e44620c20689bf828f4133231dd1805851164980 | e9fb00114464ef16f92a021a209e86bc0811e2b0 | refs/heads/master | 2020-12-13T23:41:28.810515 | 2020-06-27T10:12:32 | 2020-06-27T10:12:32 | 46,402,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | package algorithm2;
/**
* Created by szh on 16/7/28.
*/
public class Bits {
private int BITSPERWORD = 32;
private int SHIFT = 5;
private int MASK = 0x1F;
private int N = 10000000;
private int[] a = new int[1 + N/BITSPERWORD];
void set(int i){
a[i>>SHIFT] |= (1<<(i & MASK));
}
void clr(int i){
a[i>>SHIFT] &= ~(1<<(i & MASK));
}
int test(int i){
return a[i>>SHIFT] & (1<<(i & MASK));
}
public static void main(String[] args){
Bits main = new Bits();
main.set(1);
//main.set(1);
// for(int i=0; i<15; i++){
// System.out.println(i+" "+main.a[i]);
// }
System.out.println(main.MASK);
}
}
| [
"[email protected]"
] | |
60f9fa886ed0e906f87f4c56bfeb8330c227353d | 670853388ab3d93d6062272ee9426ff4156a38ab | /projectsix/projectsix-module1/src/test/java/com/projectsix/module1/AppTest.java | b357ed8ed2f5795040f28a49b67acd0f38ad0f8a | [] | no_license | ForrestCorry/Maven | b1126e9fb08fd9a7ad4e88cc501c862fa7c1072a | 7691cc0ef3c52f992d689abed4accd15c7854648 | refs/heads/master | 2020-04-19T04:34:35.062045 | 2016-08-24T17:17:30 | 2016-08-24T17:17:30 | 66,484,288 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 543 | java | package com.projectsix.module1;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class AppTest {
public AppTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of main method, of class App.
*/
@Test
public void testMain() {
}
}
| [
"[email protected]"
] | |
965ecc302997174903517991910db5228f864f04 | f1fa160a6dd30002b0a4cd4effebf69da18073ce | /src/main/java/com/assignment/mindbow/services/ManagerServiceImpl.java | b41fc0b5ca346e5e669f16c2e9fcf90350440ecc | [] | no_license | pravinbhosale96/mindboserassement | 42e86ac101a95d864d9bdaa6820f4cbeb7304b2a | ae31a49366377f595dec572a8daec5904442f055 | refs/heads/master | 2022-12-04T11:19:35.636034 | 2020-08-15T02:30:33 | 2020-08-15T02:30:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,976 | java | package com.assignment.mindbow.services;
import java.sql.SQLDataException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import com.assignment.mindbow.entities.Manager;
import com.assignment.mindbow.exceptions.DataNotValidException;
import com.assignment.mindbow.repositories.ManagerRepository;
import com.assignment.mindbow.utility.Response;
import com.assignment.mindbow.utility.UtilityMethods;
@Service
@PropertySource(value = { "classpath:application.properties" }, ignoreResourceNotFound = true)
public class ManagerServiceImpl implements UserDetailsService,ManagerService {
Logger logger = LoggerFactory.getLogger(ManagerServiceImpl.class);
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private ManagerRepository managerRepository;
protected String sendEmailEnable;
public List<Manager> findAll() {
return managerRepository.findAll();
}
public Manager findOne(Long id) {
Manager manager=null;
return manager;
}
public Response save(Manager manager) throws DataNotValidException
{
Response response=new Response();
String managerPassword=manager.getPassword();
if(!UtilityMethods.isNullOrEmpty(managerPassword))
{
logger.info("Password "+managerPassword);
manager.setPassword(passwordEncoder.encode(managerPassword));
managerRepository.save(manager);
response.setStatus(200);
response.setStatusMessage("Manager created");
}
else
{
throw new DataNotValidException("Password is missing please provide password");
}
return response;
}
public void delete(Long id)
{
managerRepository.deleteById(id);
}
@Override
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
Manager user = managerRepository.findOneByEmail(email);
logger.info(email);
if (user == null) {
throw new UsernameNotFoundException("Invalid username or password.");
}
Date date = null;
try {
date =new Date();
} catch (Exception e) {
e.printStackTrace();
}
List<SimpleGrantedAuthority> grantedAuthorities = new ArrayList<>();
grantedAuthorities.add(0, new SimpleGrantedAuthority("ROLE_ADMIN"));
return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(),
grantedAuthorities);
}
}
| [
"[email protected]"
] | |
838a8b3ae4fe3708837e46b659063da2f9b6bf85 | 0b87ccd4fdf5acc868790bbba3828a4b6ab5a331 | /app/src/main/java/com/jeevscode/jeeva/demoapp/MainActivity.java | 7df65b1d811ad935abbf168ec85a3c263f319326 | [] | no_license | jeevak001/Android-APITry-DemoApp-PagerFragmentsActivity | 399653c2bac8da6292bb41b4c2596648c918ed9a | 2e9fec386032e26ce16e6edb3d15ea9015160e6d | refs/heads/master | 2021-05-16T13:08:02.817723 | 2017-09-30T13:56:55 | 2017-09-30T13:56:55 | 105,355,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,409 | java | package com.jeevscode.jeeva.demoapp;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
}
}
| [
"[email protected]"
] | |
86881c8f719090163baa71961f5551edbfde5941 | 12a3ec2221d9333757a852ee5d46fd5f8cb3571a | /InOrderTraversal.java | 0b4cf304f285e64ae159d31a3f1d01269b7b90ea | [] | no_license | turalf/java | b936911977d4a03eb550c584bde73915a8aceb96 | e2334bf1a599260e2c2cd97884c2d341fedcb60f | refs/heads/master | 2020-12-02T06:33:02.260947 | 2017-07-25T14:13:37 | 2017-07-25T14:13:37 | 96,852,251 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,598 | java | import java.util.*;
import java.util.stream.*;
public class Traversal{
public static void main(String ... args){
try(Scanner sc = new Scanner(System.in)){
inOrderTraverse(generateTree(Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray(),0));
preOrderTraverse(generateTree(Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray(),0));
}
}
public static void inOrderTraverse(TreeNode tree){
while(tree != null){
while(tree.left != null){
tree = tree.left;
}
System.out.print(tree.val +" ");
if(tree.right != null){
tree = tree.right;
}
else{
while(tree.parent != null && tree == tree.parent.right) tree = tree.parent;
tree = tree.parent;
if (tree!=null) {
System.out.print(tree.val +" ");
tree = tree.right;
}
}
}
}
public static void preOrderTraverse(TreeNode tree){
while(tree != null){
System.out.print(tree.val);
if(tree.left != null)
tree = tree.left;
else if (tree.right != null) {
tree = tree.right;
}
else{
while (tree.parent != null && tree.parent.right = tree) tree = tree.parent;
}
}
}
private static TreeNode generateTree(int [] in, int i){
if(i >= in.length || in[i] == -1)
return null;
TreeNode t = new TreeNode(in[i]);
t.left = generateTree(in,2*i+1);
if (t.left != null)
t.left.parent = t;
t.right = generateTree(in,2*i + 2);
if (t.right != null)
t.right.parent = t;
return t;
}
}
class TreeNode{
TreeNode left, right, parent;
int val;
public TreeNode(int val){
this.val = val;
}
}
| [
"[email protected]"
] | |
103f078602f61aa237365d73ce174b15147e1969 | 7e0c2431472dadbfaf8864ba2d0f826febb3aa95 | /src/main/java/com/Invoicer/Biller/utils/JwtUtils.java | ca63703d4b368ed93759e57e994ba97b1cd698cc | [] | no_license | stutilaad/Invoicer-App-BackEnd | 5080d0b682cae9ce2b018904808e7eee2617d398 | 71dfef256affa99880e4436e3022cbaaa1e27d4a | refs/heads/master | 2022-12-11T16:27:34.178909 | 2020-09-01T16:39:10 | 2020-09-01T16:39:10 | 285,545,602 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,837 | java | package com.Invoicer.Biller.utils;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
@Component
public class JwtUtils implements Serializable {
private static final long serialVersionUID = -2550185165626007488L;
public static final long JWT_TOKEN_VALIDITY = 5 * 60 * 60;
@Value("${jwt.secret}")
private String secret;
//retrieve username from jwt token
public String getUsernameFromToken(String token) {
return getClaimFromToken(token, Claims::getSubject);
}
//retrieve expiration date from jwt token
public Date getExpirationDateFromToken(String token) {
return getClaimFromToken(token, Claims::getExpiration);
}
public <T> T getClaimFromToken(String token, Function<Claims, T> claimsResolver) {
final Claims claims = getAllClaimsFromToken(token);
return claimsResolver.apply(claims);
}
//for retrieveing any information from token we will need the secret key
private Claims getAllClaimsFromToken(String token) {
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
}
//check if the token has expired
private Boolean isTokenExpired(String token) {
final Date expiration = getExpirationDateFromToken(token);
return expiration.before(new Date());
}
//generate token for user
public String generateToken(String userId) {
Map<String, Object> claims = new HashMap<>();
return doGenerateToken( userId);
}
//while creating the token -
//1. Define claims of the token, like Issuer, Expiration, Subject, and the ID
//2. Sign the JWT using the HS512 algorithm and secret key.
//3. According to JWS Compact Serialization(https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-3.1)
// compaction of the JWT to a URL-safe string
private String doGenerateToken( String subject) {
return Jwts
.builder()
// .setClaims(claims)
.setSubject(subject)
.setIssuedAt(new Date(System.currentTimeMillis()))
.setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_VALIDITY * 1000))
.signWith(SignatureAlgorithm.HS512, secret).compact();
}
//validate token
public Boolean validateToken(String token, UserDetails biller) {
final String username = getUsernameFromToken(token);
return (username.equals(biller.getUsername()) && !isTokenExpired(token));
}
} | [
"[email protected]"
] | |
9e9c9dc3def67d9586db4a4dc77db165ef429e3e | c01a80acd844e93106f694d396bcfc9b5d12dd35 | /RestoreIpAddress/Solution.java | 52e598515a6929660160e8c8e420d8e21644e8d9 | [] | no_license | shaowei-su/MySubLC | c8ccc25ffc552b297eb69ff7b2f888f7aa45fa33 | 1a8048c16f782e025f0da85ac79dcb6a02e9166d | refs/heads/master | 2020-06-02T10:20:36.557147 | 2015-09-22T21:00:34 | 2015-09-22T21:00:34 | 37,701,847 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java | import java.util.*;
public class Solution {
public boolean isValid(String s) {
if (s.charAt(0) == '0' && s.length() > 1) {
return false;
}
int num = Integer.parseInt(s);
return num >= 0 && num <= 255;
}
public void restoreHelper(List<String> res, String s, int pos, StringBuilder sb, int times) {
if (sb.length() == s.length() + 3 && times == 4) {
String temp = sb.toString();
res.add(temp);
return;
} else {
for (int i = 1; i <= 3 && pos + i <= s.length(); i++) {
if (isValid(s.substring(pos, pos + i))) {
if (sb.length() != 0) {
sb.append(".");
}
sb.append(s.substring(pos, pos + i));//i element
restoreHelper(res, s, pos + i, sb, times + 1);
sb.delete(sb.length() - i, sb.length());
if (sb.length() != 0) {
sb.delete(sb.length() - 1, sb.length());
}
}
}
}
return ;
}
public List<String> restoreIpAddresses(String s) {
List<String> res = new ArrayList<String>();
if (s == null || s.length() == 0 || s.length() > 12) {
return res;
}
StringBuilder sb = new StringBuilder();
restoreHelper(res, s, 0, sb, 0);
return res;
}
public static void main(String[] args) {
Solution sol = new Solution();
List<String> res = sol.restoreIpAddresses("010010");
for (String s: res) {
System.out.println(s);
}
}
} | [
"[email protected]"
] | |
8a711dca5d7ec229c36fd2b8e6f7dfc0bbe7fb98 | 695b1ff0074fd4b77effa966243b5634750cfa21 | /ace-gwt-editor/src/main/java/ace/client/JSEditorToolbar.java | 605acb433a1b7fe46a4e0e45fca47641899d33dc | [] | no_license | bsorrentino/ace-gwt | 204f65bfa1ef8f100965ad76ef5dff82c6f12431 | e8fafdc8c1971220f0cb0f5e87321118ac55a892 | refs/heads/master | 2020-04-23T08:54:14.918849 | 2011-02-07T21:23:53 | 2011-02-07T21:23:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,858 | java | /*
* Copyright 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package ace.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.i18n.client.Constants;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* A sample toolbar for use with {@link RichTextArea}. It provides a simple UI
* for all rich text formatting, dynamically displayed only for the available
* functionality.
*/
public class JSEditorToolbar extends Composite {
/**
* This {@link ClientBundle} is used for all the button icons. Using a bundle
* allows all of these images to be packed into a single image, which saves a
* lot of HTTP requests, drastically improving startup time.
*/
public interface Images extends ClientBundle {
@Source("ace/public/images/indent.gif")
ImageResource indent();
@Source("ace/public/images/outdent.gif")
ImageResource outdent();
@Source("ace/public/images/save.png")
ImageResource save();
}
/**
* This {@link Constants} interface is used to make the toolbar's strings
* internationalizable.
*/
public interface Strings extends Constants {
@DefaultStringValue("indent")
String indent();
@DefaultStringValue("outdent")
String outdent();
@DefaultStringValue("save content")
String save();
}
/**
* We use an inner EventHandler class to avoid exposing event methods on the
* RichTextToolbar itself.
*/
private class EventHandler implements ClickHandler, ChangeHandler, KeyUpHandler {
public void onChange(ChangeEvent event) {
Widget sender = (Widget) event.getSource();
/*
if (sender == backColors) {
basic.setBackColor(backColors.getValue(backColors.getSelectedIndex()));
backColors.setSelectedIndex(0);
} else if (sender == foreColors) {
basic.setForeColor(foreColors.getValue(foreColors.getSelectedIndex()));
foreColors.setSelectedIndex(0);
} else if (sender == fonts) {
basic.setFontName(fonts.getValue(fonts.getSelectedIndex()));
fonts.setSelectedIndex(0);
} else if (sender == fontSizes) {
basic.setFontSize(fontSizesConstants[fontSizes.getSelectedIndex() - 1]);
fontSizes.setSelectedIndex(0);
}
*/
}
public void onClick(ClickEvent event) {
Widget sender = (Widget) event.getSource();
if( sender == save ) {
fireSaveEvent( new JSEditorSaveEvent(editor) );
}
/*
if (sender == bold) {
basic.toggleBold();
} else if (sender == italic) {
basic.toggleItalic();
} else if (sender == underline) {
basic.toggleUnderline();
} else if (sender == subscript) {
basic.toggleSubscript();
} else if (sender == superscript) {
basic.toggleSuperscript();
} else if (sender == strikethrough) {
extended.toggleStrikethrough();
} else if (sender == indent) {
extended.rightIndent();
} else if (sender == outdent) {
extended.leftIndent();
} else if (sender == justifyLeft) {
basic.setJustification(RichTextArea.Justification.LEFT);
} else if (sender == justifyCenter) {
basic.setJustification(RichTextArea.Justification.CENTER);
} else if (sender == justifyRight) {
basic.setJustification(RichTextArea.Justification.RIGHT);
} else if (sender == insertImage) {
String url = Window.prompt("Enter an image URL:", "http://");
if (url != null) {
extended.insertImage(url);
}
} else if (sender == createLink) {
String url = Window.prompt("Enter a link URL:", "http://");
if (url != null) {
extended.createLink(url);
}
} else if (sender == removeLink) {
extended.removeLink();
} else if (sender == hr) {
extended.insertHorizontalRule();
} else if (sender == ol) {
extended.insertOrderedList();
} else if (sender == ul) {
extended.insertUnorderedList();
} else if (sender == removeFormat) {
extended.removeFormat();
} else if (sender == richText) {
// We use the RichTextArea's onKeyUp event to update the toolbar status.
// This will catch any cases where the user moves the cursur using the
// keyboard, or uses one of the browser's built-in keyboard shortcuts.
updateStatus();
}
*/
}
public void onKeyUp(KeyUpEvent event) {
Widget sender = (Widget) event.getSource();
/*
if (sender == richText) {
// We use the RichTextArea's onKeyUp event to update the toolbar status.
// This will catch any cases where the user moves the cursur using the
// keyboard, or uses one of the browser's built-in keyboard shortcuts.
updateStatus();
}
*/
}
}
private static final RichTextArea.FontSize[] fontSizesConstants = new RichTextArea.FontSize[] {
RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL,
RichTextArea.FontSize.SMALL, RichTextArea.FontSize.MEDIUM,
RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
RichTextArea.FontSize.XX_LARGE};
private Images images = (Images) GWT.create(Images.class);
private Strings strings = (Strings) GWT.create(Strings.class);
private EventHandler handler = new EventHandler();
private final JSEditorProxy editor;
private final HandlerManager hm;
//private RichTextArea.BasicFormatter basic;
//private RichTextArea.ExtendedFormatter extended;
private VerticalPanel outer = new VerticalPanel();
private HorizontalPanel topPanel = new HorizontalPanel();
private HorizontalPanel bottomPanel = new HorizontalPanel();
private PushButton indent;
private PushButton outdent;
private PushButton save;
private ToggleButton bold;
private ToggleButton italic;
private ToggleButton underline;
private ToggleButton subscript;
private ToggleButton superscript;
private ToggleButton strikethrough;
private PushButton justifyLeft;
private PushButton justifyCenter;
private PushButton justifyRight;
private PushButton hr;
private PushButton ol;
private PushButton ul;
private PushButton insertImage;
private PushButton createLink;
private PushButton removeLink;
private PushButton removeFormat;
private ListBox backColors;
private ListBox foreColors;
private ListBox fonts;
private ListBox fontSizes;
/**
* Creates a new toolbar that drives the given rich text area.
*
* @param richText the rich text area to be controlled
*/
public JSEditorToolbar(JSEditorProxy editor ) {
this.editor = editor;
//this.basic = richText.getBasicFormatter();
//this.extended = richText.getExtendedFormatter();
hm = new HandlerManager(editor);
outer.add(topPanel);
//outer.add(bottomPanel);
//topPanel.setWidth("100%");
//bottomPanel.setWidth("100%");
initWidget(outer);
setStyleName("gwt-RichTextToolbar");
//richText.addStyleName("hasRichTextToolbar");
topPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
topPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
topPanel.setSpacing(3);
topPanel.add( new Label("JSEditor") {{ setWidth("70px"); }} );
topPanel.add(save = createPushButton(images.save(), strings.save()));
topPanel.add(indent = createPushButton(images.indent(), strings.indent())); indent.setEnabled(false);
topPanel.add(outdent = createPushButton(images.outdent(), strings.outdent()));outdent.setEnabled(false);
/*
if (basic != null) {
topPanel.add(bold = createToggleButton(images.bold(), strings.bold()));
topPanel.add(italic = createToggleButton(images.italic(),
strings.italic()));
topPanel.add(underline = createToggleButton(images.underline(),
strings.underline()));
topPanel.add(subscript = createToggleButton(images.subscript(),
strings.subscript()));
topPanel.add(superscript = createToggleButton(images.superscript(),
strings.superscript()));
topPanel.add(justifyLeft = createPushButton(images.justifyLeft(),
strings.justifyLeft()));
topPanel.add(justifyCenter = createPushButton(images.justifyCenter(),
strings.justifyCenter()));
topPanel.add(justifyRight = createPushButton(images.justifyRight(),
strings.justifyRight()));
}
if (extended != null) {
topPanel.add(strikethrough = createToggleButton(images.strikeThrough(),
strings.strikeThrough()));
topPanel.add(indent = createPushButton(images.indent(), strings.indent()));
topPanel.add(outdent = createPushButton(images.outdent(),
strings.outdent()));
topPanel.add(hr = createPushButton(images.hr(), strings.hr()));
topPanel.add(ol = createPushButton(images.ol(), strings.ol()));
topPanel.add(ul = createPushButton(images.ul(), strings.ul()));
topPanel.add(insertImage = createPushButton(images.insertImage(),
strings.insertImage()));
topPanel.add(createLink = createPushButton(images.createLink(),
strings.createLink()));
topPanel.add(removeLink = createPushButton(images.removeLink(),
strings.removeLink()));
topPanel.add(removeFormat = createPushButton(images.removeFormat(),
strings.removeFormat()));
}
if (basic != null) {
bottomPanel.add(backColors = createColorList("Background"));
bottomPanel.add(foreColors = createColorList("Foreground"));
bottomPanel.add(fonts = createFontList());
bottomPanel.add(fontSizes = createFontSizes());
// We only use these handlers for updating status, so don't hook them up
// unless at least basic editing is supported.
richText.addKeyUpHandler(handler);
richText.addClickHandler(handler);
}
*/
}
public void addHandler( JSEditorHandler h ) {
hm.addHandler( JSEditorSaveEvent.getType(), h);
}
public void removeHandler( JSEditorHandler h ) {
hm.removeHandler( JSEditorSaveEvent.getType(), h);
}
protected void fireSaveEvent( JSEditorSaveEvent e ) {
hm.fireEvent(e);
}
private ListBox createColorList(String caption) {
ListBox lb = new ListBox();
lb.addChangeHandler(handler);
lb.setVisibleItemCount(1);
lb.addItem(caption);
/*
lb.addItem(strings.white(), "white");
lb.addItem(strings.black(), "black");
lb.addItem(strings.red(), "red");
lb.addItem(strings.green(), "green");
lb.addItem(strings.yellow(), "yellow");
lb.addItem(strings.blue(), "blue");
*/
return lb;
}
private ListBox createFontList() {
ListBox lb = new ListBox();
lb.addChangeHandler(handler);
lb.setVisibleItemCount(1);
/*
lb.addItem(strings.font(), "");
lb.addItem(strings.normal(), "");
lb.addItem("Times New Roman", "Times New Roman");
lb.addItem("Arial", "Arial");
lb.addItem("Courier New", "Courier New");
lb.addItem("Georgia", "Georgia");
lb.addItem("Trebuchet", "Trebuchet");
lb.addItem("Verdana", "Verdana");
*/
return lb;
}
private ListBox createFontSizes() {
ListBox lb = new ListBox();
lb.addChangeHandler(handler);
lb.setVisibleItemCount(1);
/*
lb.addItem(strings.size());
lb.addItem(strings.xxsmall());
lb.addItem(strings.xsmall());
lb.addItem(strings.small());
lb.addItem(strings.medium());
lb.addItem(strings.large());
lb.addItem(strings.xlarge());
lb.addItem(strings.xxlarge());
*/
return lb;
}
private PushButton createPushButton(ImageResource img, String tip) {
PushButton pb = new PushButton(new Image(img));
pb.addClickHandler(handler);
pb.setTitle(tip);
return pb;
}
private ToggleButton createToggleButton(ImageResource img, String tip) {
ToggleButton tb = new ToggleButton(new Image(img));
tb.addClickHandler(handler);
tb.setTitle(tip);
return tb;
}
/**
* Updates the status of all the stateful buttons.
*/
private void updateStatus() {
/*
if (basic != null) {
bold.setDown(basic.isBold());
italic.setDown(basic.isItalic());
underline.setDown(basic.isUnderlined());
subscript.setDown(basic.isSubscript());
superscript.setDown(basic.isSuperscript());
}
if (extended != null) {
strikethrough.setDown(extended.isStrikethrough());
}
*/
}
}
| [
"[email protected]"
] | |
562e9fb803f157ab467cbb3a2bd6764b1442c088 | a6f3812c0e90ea6a028fa0d607bf05016617725a | /tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/op/data/ParallelInterleaveDataset.java | bf87079b34c7f9281de3a0c57b22e7128a455205 | [
"Apache-2.0"
] | permissive | matijadj/java | 2047436d99b3ddb58fa79d50f2176133702f22ad | 5e775e1b97e835e029ec669824c550a8227262db | refs/heads/master | 2023-07-22T03:27:22.022779 | 2021-08-31T21:09:12 | 2021-08-31T21:09:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,051 | java | /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=======================================================================*/
// This class has been generated, DO NOT EDIT!
package org.tensorflow.op.data;
import java.util.List;
import org.tensorflow.ConcreteFunction;
import org.tensorflow.Operand;
import org.tensorflow.Operation;
import org.tensorflow.OperationBuilder;
import org.tensorflow.Output;
import org.tensorflow.ndarray.Shape;
import org.tensorflow.op.Operands;
import org.tensorflow.op.RawOp;
import org.tensorflow.op.Scope;
import org.tensorflow.op.annotation.Endpoint;
import org.tensorflow.op.annotation.Operator;
import org.tensorflow.types.TInt64;
import org.tensorflow.types.family.TType;
/**
* Creates a dataset that applies {@code f} to the outputs of {@code input_dataset}.
* The resulting dataset is similar to the {@code InterleaveDataset}, except that the
* dataset will fetch records from the interleaved datasets in parallel.
* <p>The {@code tf.data} Python API creates instances of this op from
* {@code Dataset.interleave()} when the {@code num_parallel_calls} parameter of that method
* is set to any value other than {@code None}.
* <p>By default, the output of this dataset will be deterministic, which may result
* in the dataset blocking if the next data item to be returned isn't available.
* In order to avoid head-of-line blocking, one can either set the {@code deterministic}
* attribute to "false", or leave it as "default" and set the
* {@code experimental_deterministic} parameter of {@code tf.data.Options} to {@code False}.
* This can improve performance at the expense of non-determinism.
*/
@Operator(
group = "data"
)
public final class ParallelInterleaveDataset extends RawOp implements Operand<TType> {
/**
* The name of this op, as known by TensorFlow core engine
*/
public static final String OP_NAME = "ParallelInterleaveDatasetV4";
private Output<? extends TType> handle;
@SuppressWarnings("unchecked")
private ParallelInterleaveDataset(Operation operation) {
super(operation);
int outputIdx = 0;
handle = operation.output(outputIdx++);
}
/**
* Factory method to create a class wrapping a new ParallelInterleaveDatasetV4 operation.
*
* @param scope current scope
* @param inputDataset Dataset that produces a stream of arguments for the function {@code f}.
* @param otherArguments Additional arguments to pass to {@code f} beyond those produced by {@code input_dataset}.
* Evaluated once when the dataset is instantiated.
* @param cycleLength Number of datasets (each created by applying {@code f} to the elements of
* {@code input_dataset}) among which the {@code ParallelInterleaveDatasetV2} will cycle in a
* round-robin fashion.
* @param blockLength Number of elements at a time to produce from each interleaved invocation of a
* dataset returned by {@code f}.
* @param bufferOutputElements The number of elements each iterator being interleaved should buffer (similar
* to the {@code .prefetch()} transformation for each interleaved iterator).
* @param prefetchInputElements Determines the number of iterators to prefetch, allowing buffers to warm up and
* data to be pre-fetched without blocking the main thread.
* @param numParallelCalls Determines the number of threads that should be used for fetching data from
* input datasets in parallel. The Python API {@code tf.data.experimental.AUTOTUNE}
* constant can be used to indicate that the level of parallelism should be autotuned.
* @param f A function mapping elements of {@code input_dataset}, concatenated with
* {@code other_arguments}, to a Dataset variant that contains elements matching
* {@code output_types} and {@code output_shapes}.
* @param outputTypes the value of the outputTypes property
* @param outputShapes the value of the outputShapes property
* @param options carries optional attribute values
* @return a new instance of ParallelInterleaveDataset
*/
@Endpoint(
describeByClass = true
)
public static ParallelInterleaveDataset create(Scope scope, Operand<? extends TType> inputDataset,
Iterable<Operand<?>> otherArguments, Operand<TInt64> cycleLength, Operand<TInt64> blockLength,
Operand<TInt64> bufferOutputElements, Operand<TInt64> prefetchInputElements,
Operand<TInt64> numParallelCalls, ConcreteFunction f,
List<Class<? extends TType>> outputTypes, List<Shape> outputShapes, Options... options) {
OperationBuilder opBuilder = scope.env().opBuilder(OP_NAME, scope.makeOpName("ParallelInterleaveDataset"));
opBuilder.addInput(inputDataset.asOutput());
opBuilder.addInputList(Operands.asOutputs(otherArguments));
opBuilder.addInput(cycleLength.asOutput());
opBuilder.addInput(blockLength.asOutput());
opBuilder.addInput(bufferOutputElements.asOutput());
opBuilder.addInput(prefetchInputElements.asOutput());
opBuilder.addInput(numParallelCalls.asOutput());
opBuilder = scope.apply(opBuilder);
opBuilder.setAttr("f", f);
opBuilder.setAttr("output_types", Operands.toDataTypes(outputTypes));
Shape[] outputShapesArray = new Shape[outputShapes.size()];
for (int i = 0 ; i < outputShapesArray.length ; i++) {
outputShapesArray[i] = outputShapes.get(i);
}
opBuilder.setAttr("output_shapes", outputShapesArray);
if (options != null) {
for (Options opts : options) {
if (opts.deterministic != null) {
opBuilder.setAttr("deterministic", opts.deterministic);
}
}
}
return new ParallelInterleaveDataset(opBuilder.build());
}
/**
* Sets the deterministic option.
*
* @param deterministic A string indicating the op-level determinism to use. Deterministic controls
* whether the interleave is allowed to return elements out of order if the next
* element to be returned isn't available, but a later element is. Options are
* "true", "false", and "default". "default" indicates that determinism should be
* decided by the {@code experimental_deterministic} parameter of {@code tf.data.Options}.
* @return this Options instance.
*/
public static Options deterministic(String deterministic) {
return new Options().deterministic(deterministic);
}
/**
* Gets handle.
*
* @return handle.
*/
public Output<? extends TType> handle() {
return handle;
}
@Override
@SuppressWarnings("unchecked")
public Output<TType> asOutput() {
return (Output<TType>) handle;
}
/**
* Optional attributes for {@link org.tensorflow.op.data.ParallelInterleaveDataset}
*/
public static class Options {
private String deterministic;
private Options() {
}
/**
* Sets the deterministic option.
*
* @param deterministic A string indicating the op-level determinism to use. Deterministic controls
* whether the interleave is allowed to return elements out of order if the next
* element to be returned isn't available, but a later element is. Options are
* "true", "false", and "default". "default" indicates that determinism should be
* decided by the {@code experimental_deterministic} parameter of {@code tf.data.Options}.
* @return this Options instance.
*/
public Options deterministic(String deterministic) {
this.deterministic = deterministic;
return this;
}
}
}
| [
"[email protected]"
] | |
a6390860bc5bc136ca0df8e117d2ec1072ad3e66 | 6b3746399fe2d5bbe624fc08a39d0026319eedb8 | /src/demoproto/PatientSummary.java | d6ce4db3f737838984f4931b54f9674c13802f5b | [
"MIT"
] | permissive | arif1177/JavaProject_Patient_Information_Processing_Demo | 2cc825cb021772efb351e2effd128df094d2f529 | aa4966682b3b8bab62ca3ca87be23ee6d8faed32 | refs/heads/master | 2022-05-30T16:29:09.362747 | 2020-05-01T15:46:39 | 2020-05-01T15:46:39 | 260,495,422 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,330 | 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 demoproto;
import java.util.ArrayList;
import java.util.List;
/**
* This class has necessary patient information e.g. IDs, total LoS, (different) total benefits, list of principalMBS and MBS codes that they had
* @author akhan
*/
public class PatientSummary
{
public String memberID;
public String memberShipID;
public int totalAdmission;
public int LoS;
public double hospBen;
public double medBen;
public double prosBen;
public List<AdmissionSummary> admissionSummary;
public List<String> principalMBSList;
public List<Integer> principalMBSFreq;
public List<String> MBSList;
public List<Integer> MBSFreq;
public PatientSummary(String memberID, String memberShipID, int totalAdmission, int LoS, double hospBen,double medBen, double prosBen)
{
this.memberID = memberID;
this.memberShipID = memberShipID;
this.totalAdmission = totalAdmission;
this.LoS = LoS;
this.hospBen = hospBen;
this.medBen = medBen;
this.prosBen = prosBen;
this.MBSList = new ArrayList<>();
this.MBSFreq = new ArrayList<>();
this.principalMBSList = new ArrayList<>();
this.principalMBSFreq = new ArrayList<>();
}
/**
* MBS list and their summary information is updated from information of all the admissions
* that this patient have made. Also patients own MBS code summaries are updated from these input information
* @param asm Admission summary of this patient. That is saved into this class.
* @param mbsSummary Main MBS summary class that have all the list and related summary information. This class is
* iteratively updated after the function is executed.
*/
public void processPatientAndMBSSummaryfromAdmissionSummary(List<AdmissionSummary> asm, MBSSummary mbsSummary)
{
this.admissionSummary = asm;
for(AdmissionSummary as:this.admissionSummary)
{
if(Utility.addItemInStringListWithFreqAndRetIsUnique(as.principal_mbs,1,principalMBSList,principalMBSFreq))
{//this is unique prin MBS for a patient. Plus counter
mbsSummary.addFreqOfPrincipalMBSInPatient(as.principal_mbs);
}
//add counter for prin MBS in admission
mbsSummary.addFreqForPrinMBSInAdmission(as.principal_mbs, as);
for(String s:as.mbsList)
{
if(Utility.addItemInStringListWithFreqAndRetIsUnique(s, 1, MBSList, MBSFreq))
{//this is first time this MBS is occurring for the patient. Plus counter
mbsSummary.addFreqOfMBSInPatient(s);
}
//add counter for MBS in admission
mbsSummary.addFreqOfMBSInAdmission(s);
}
}
}
/**
*
* @return necessary JTable row data to show in appropriate format
*/
public Object[] getSummaryPatientInfoRow()
{
return new Object[]{this.memberID, this.memberShipID,this.totalAdmission, this.LoS, this.hospBen,this.medBen, this.prosBen};
}
}
| [
"[email protected]"
] | |
21992de549dba18821ac2661a3c11f77eb7f6726 | aa1192d64dd1577ff3e426ddc07831308d290c9c | /jericho-ejb/src/main/java/za/co/jericho/exception/EntityValidatorException.java | 2c0233a971e3e2f11a73791e3ec3bfe66881852f | [] | no_license | jacowk/jericho | 189a3df45cf74343665a9b76d36c2856ee25d662 | ade08e4abbcdd9fa2fe1332edab58fbb46d163fb | refs/heads/master | 2021-01-21T04:47:32.261432 | 2016-06-16T12:41:29 | 2016-06-16T12:41:29 | 49,664,896 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 425 | 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 za.co.jericho.exception;
/**
*
* @author user
*/
public class EntityValidatorException extends RuntimeException {
public EntityValidatorException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
96778622feb98c12e189c6c11f679044c511728b | 250f76a5c09b48914b25cc0de8eaf28ad30f6375 | /java_knowledge/src/main/java/cn/com/frodo/knowledge/msgsubscriber/step_four_generics/ApiWrapper.java | 831ac08409dd4e84356d0a357a9353d8db7e23d5 | [] | no_license | frodoking/Java | 73409e2389417459b80016d43a8f0e888d8b11d8 | 044a49466091b7737b32c1c1ecb558d5d146fc1a | refs/heads/master | 2023-06-09T13:13:07.210965 | 2023-06-09T03:32:14 | 2023-06-09T03:32:14 | 29,135,773 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,098 | java | package cn.com.frodo.knowledge.msgsubscriber.step_four_generics;
import cn.com.frodo.knowledge.msgsubscriber.Cat;
import cn.com.frodo.knowledge.msgsubscriber.step_three_asynchronous2.Api;
import java.net.URI;
import java.util.List;
public class ApiWrapper {
Api api;
public void queryCats(String query, final Callback<List<Cat>> catsCallback) {
api.queryCats(query, new Api.CatsQueryCallback() {
@Override
public void onCatListReceived(List<Cat> cats) {
catsCallback.onResult(cats);
}
@Override
public void onQueryFailed(Exception e) {
catsCallback.onError(e);
}
});
}
public void store(Cat cat, final Callback<URI> uriCallback) {
api.store(cat, new Api.StoreCallback() {
@Override
public void onCatStored(URI uri) {
uriCallback.onResult(uri);
}
@Override
public void onStoreFailed(Exception e) {
uriCallback.onError(e);
}
});
}
}
| [
"[email protected]"
] | |
0060aab9677b4fe9c020881741fdfeac57c6907b | beae15656116c48136c24bf0c55185c3ddfc034f | /app/src/com/csc207_0898/triageapp/Temperature.java | f1290cad25525c12b859eaa53bf01e33ed62718c | [] | no_license | cheeseonhead/TriageApp | 971b2af1ca73f9e8bca41f0440b38088af4ed57a | ba9a7d0166cbf03d184d5df4769599b123cbd3d8 | refs/heads/master | 2016-09-06T12:01:28.189448 | 2015-03-26T01:15:08 | 2015-03-26T01:15:08 | 32,900,293 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,701 | java | package com.csc207_0898.triageapp;
/**
* Class Temperature contains one variable which is a float for the temperate
* which must be between 10.0 and 50.0 in Celcius.
*
*/
public class Temperature {
private float temperature;
/**
* Public constructor for Temperature class which takes a single argument as
* a float and assigns it to the private variable temperature using setTemp.
*
* @param temperature
* The temperature as a float.
*/
public Temperature(float temperature) throws Exception {
set(temperature);
}
/**
* Checks if the temperature falls into a valid range and then sets the
* private variable temperature to this value.
*
* @param newTemperature
* The temperature being validated.
* @throws Exception
* If newTemperature is invalid.
*/
public void set(float newTemperature) throws Exception {
if (validateTemperature(newTemperature)) {
temperature = newTemperature;
}
}
/**
* Returns the variable associated with this object,
*
* @return
* Temperature as a float.
*/
public float get() {
return temperature;
}
/**
* Returns whether or not the argument temperature, as a float, falls into a
* valid range, throws an exception if not.
*
* @param temperature
* The temperature being validated.
* @return
* True, if the temperature is valid.
* @throws Exception
* If the temperature is invalid.
*/
public boolean validateTemperature(float temperature) throws Exception {
if (temperature < 10.0 || temperature > 50.0) {
throw new InvalidTemperatureException();
}
return true;
}
@Override
public String toString(){
return Float.toString(get()) + " degrees";
}
}
| [
"[email protected]"
] | |
e3e11027c282c2dcf921cbe36d04747234d48ec3 | 81ede6e233c8114382994a233fffc90ac77565f2 | /src/main/java/com/vacomall/common/util/ShiroUtil.java | e0122151a98f7d585e1dc762bb84c0c679bb4217 | [] | no_license | p555iii/recordPro | 91b2c46edb4b0d06cb41bf64903ab508a13f169b | 06d3d2683efd6f417ebb6934bb18ee2d95ebd25b | refs/heads/master | 2021-08-08T00:04:18.823750 | 2017-11-09T07:07:20 | 2017-11-09T07:07:20 | 107,936,359 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,024 | java | package com.vacomall.common.util;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.subject.Subject;
import com.vacomall.entity.SysUser;
/**
* Shiro工具类
* @author jameszhou
*
*/
public class ShiroUtil {
/**
* 密码加密
* @param password
* @param salt
* @return
*/
public static String md51024Pwd(String password,Object salt){
return new SimpleHash("MD5", password, salt, 1024).toString();
}
/**
* 获取当前Session中的用户
* @return
*/
public static SysUser getSessionUser(){
Subject subject = SecurityUtils.getSubject();
if(subject != null){
Object object = subject.getPrincipal();
if(object != null){
SysUser sysUser = (SysUser) object;
return sysUser;
}
}
return null;
}
/**
* 获取当前用户ID
* @return
*/
public static String getSessionUid(){
SysUser sysUser = getSessionUser();
if(sysUser != null){
return sysUser.getId();
}
return null;
}
}
| [
"[email protected]"
] | |
36c094a4e5830a964cba4c7c5206c4a305df86bd | d82efd2733e9e0092ea9dd196c25deb08f076f5a | /common/src/main/java/shared/exceptions/PlayerLimitExceededException.java | be60b307abdcadaa534ef7e964ecad026887aac7 | [] | no_license | SE2-Busfahrer-SS20/SE2-Busfahrer-SS20 | b7c6ec25542d1c05d6f0a74d37f0048163cfd758 | dda5f4033f8554159d4702756079e358a31bdb55 | refs/heads/master | 2021-05-21T14:37:08.233695 | 2020-06-16T10:55:23 | 2020-06-16T10:55:23 | 252,682,886 | 0 | 0 | null | 2020-06-16T13:21:21 | 2020-04-03T09:05:10 | Java | UTF-8 | Java | false | false | 406 | java | package shared.exceptions;
public class PlayerLimitExceededException extends Exception {
public PlayerLimitExceededException(String message, Throwable cause) {
super(message, cause);
}
public PlayerLimitExceededException(String message) {
super(message);
}
public PlayerLimitExceededException() {
super("PlayersCount must be between 2 and 8 Players.");
}
}
| [
"[email protected]"
] | |
57f1cff9e5b548fbc27dd13a28a35f5bd4532a75 | bc75e27dbc79fe1cb03ad34786c2f89e517e869f | /ch03_ex2_TestScore/src/TestScoreApp.java | 8395582f5b5b7c9124de622f281dd1ed037e4e66 | [] | no_license | emiliesedziol/bootcampfall2017 | 391e023d9ad03a99d58fdc042a7840beef34f915 | 2f5611d4cab13b9ad6b2142f842269db6fa345b5 | refs/heads/master | 2021-05-04T15:39:50.883590 | 2018-02-05T00:54:18 | 2018-02-05T00:54:18 | 120,235,388 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,080 | java | import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;
public class TestScoreApp {
public static void main(String[] args) {
// display operational messages
System.out.println("Enter test scores that range from 0 to 100.");
System.out.println("To end the program, enter 999.");
System.out.println(); // print a blank line
// initialize variables and create a Scanner object
int scoreTotal = 0;
int scoreCount = 0;
int testScore = 0;
int minScore = 0;
int maxScore = 0;
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
// get a series of test scores from the user
while (testScore != 999)
{
// get the input from the user
System.out.print("Enter score: ");
testScore = sc.nextInt();
// accumulate score count and score total
if (testScore <= 100)
{
scoreCount++;
scoreTotal += testScore;
if (minScore == 0) minScore = testScore;
minScore = Math.min(minScore, testScore);
maxScore = Math.max(maxScore, testScore);
}
else if (testScore != 999) {
System.out.println("Invalid entry, not counted");
}
}
// display the score count, score total, and average score
double averageScore = (double) scoreTotal / scoreCount;
NumberFormat numberFormatter = new DecimalFormat("##.0");
String result = numberFormatter.format(averageScore);
String message = "\n"
+ "Score count: " + scoreCount + "\n"
+ "Score total: " + scoreTotal + "\n"
+ "Average score: " + result + "\n"
+ "Minimum score: " + minScore + "\n"
+ "Max score " + maxScore;
System.out.println(message);
System.out.println("done!");
}
} | [
"[email protected]"
] | |
957a3ba98e7ea7e2ed504e27860175e01368d16f | 0095f00280d629e4845673b789995804a3983be7 | /app/build /generated/source/r/debug/android/support/compat/R.java | 5d26dd7568529963f22d8393744d6a3eeb4d7491 | [] | no_license | huangdaojian/AserbaosAndroid | 06ea789c1e26219c9f9d416459b3dc94bea21258 | 62ebf89b7d0472caea9a57cdfd2f8dda3155c7f3 | refs/heads/master | 2020-04-16T12:34:20.885176 | 2019-01-14T01:01:03 | 2019-01-14T01:01:03 | 165,585,338 | 2 | 0 | null | 2019-01-14T02:54:10 | 2019-01-14T02:54:10 | null | UTF-8 | Java | false | false | 10,167 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* gradle plugin from the resource data it found. It
* should not be modified by hand.
*/
package android.support.compat;
public final class R {
public static final class attr {
public static final int alpha = 0x7f020029;
public static final int font = 0x7f0200a0;
public static final int fontProviderAuthority = 0x7f0200a2;
public static final int fontProviderCerts = 0x7f0200a3;
public static final int fontProviderFetchStrategy = 0x7f0200a4;
public static final int fontProviderFetchTimeout = 0x7f0200a5;
public static final int fontProviderPackage = 0x7f0200a6;
public static final int fontProviderQuery = 0x7f0200a7;
public static final int fontStyle = 0x7f0200a8;
public static final int fontVariationSettings = 0x7f0200a9;
public static final int fontWeight = 0x7f0200aa;
public static final int ttcIndex = 0x7f020190;
}
public static final class color {
public static final int notification_action_color_filter = 0x7f040053;
public static final int notification_icon_bg_color = 0x7f040054;
public static final int ripple_material_light = 0x7f040060;
public static final int secondary_text_default_material_light = 0x7f040062;
}
public static final class dimen {
public static final int compat_button_inset_horizontal_material = 0x7f05005a;
public static final int compat_button_inset_vertical_material = 0x7f05005b;
public static final int compat_button_padding_horizontal_material = 0x7f05005c;
public static final int compat_button_padding_vertical_material = 0x7f05005d;
public static final int compat_control_corner_material = 0x7f05005e;
public static final int compat_notification_large_icon_max_height = 0x7f05005f;
public static final int compat_notification_large_icon_max_width = 0x7f050060;
public static final int notification_action_icon_size = 0x7f050075;
public static final int notification_action_text_size = 0x7f050076;
public static final int notification_big_circle_margin = 0x7f050077;
public static final int notification_content_margin_start = 0x7f050078;
public static final int notification_large_icon_height = 0x7f050079;
public static final int notification_large_icon_width = 0x7f05007a;
public static final int notification_main_column_padding_top = 0x7f05007b;
public static final int notification_media_narrow_margin = 0x7f05007c;
public static final int notification_right_icon_size = 0x7f05007d;
public static final int notification_right_side_padding_top = 0x7f05007e;
public static final int notification_small_icon_background_padding = 0x7f05007f;
public static final int notification_small_icon_size_as_large = 0x7f050080;
public static final int notification_subtext_size = 0x7f050081;
public static final int notification_top_pad = 0x7f050082;
public static final int notification_top_pad_large_text = 0x7f050083;
}
public static final class drawable {
public static final int notification_action_background = 0x7f0600b9;
public static final int notification_bg = 0x7f0600ba;
public static final int notification_bg_low = 0x7f0600bb;
public static final int notification_bg_low_normal = 0x7f0600bc;
public static final int notification_bg_low_pressed = 0x7f0600bd;
public static final int notification_bg_normal = 0x7f0600be;
public static final int notification_bg_normal_pressed = 0x7f0600bf;
public static final int notification_icon_background = 0x7f0600c0;
public static final int notification_template_icon_bg = 0x7f0600c1;
public static final int notification_template_icon_low_bg = 0x7f0600c2;
public static final int notification_tile_bg = 0x7f0600c3;
public static final int notify_panel_notification_icon_bg = 0x7f0600c4;
}
public static final class id {
public static final int action_container = 0x7f07001b;
public static final int action_divider = 0x7f07001d;
public static final int action_image = 0x7f07001e;
public static final int action_text = 0x7f070024;
public static final int actions = 0x7f070025;
public static final int async = 0x7f070032;
public static final int blocking = 0x7f07003f;
public static final int chronometer = 0x7f070080;
public static final int forever = 0x7f0700cc;
public static final int icon = 0x7f07010d;
public static final int icon_group = 0x7f07010e;
public static final int info = 0x7f070114;
public static final int italic = 0x7f070116;
public static final int line1 = 0x7f07012d;
public static final int line3 = 0x7f07012e;
public static final int normal = 0x7f07014f;
public static final int notification_background = 0x7f070151;
public static final int notification_main_column = 0x7f070152;
public static final int notification_main_column_container = 0x7f070153;
public static final int right_icon = 0x7f070175;
public static final int right_side = 0x7f070176;
public static final int tag_transition_group = 0x7f0701be;
public static final int tag_unhandled_key_event_manager = 0x7f0701bf;
public static final int tag_unhandled_key_listeners = 0x7f0701c0;
public static final int text = 0x7f0701cb;
public static final int text2 = 0x7f0701cc;
public static final int time = 0x7f0701e1;
public static final int title = 0x7f0701e2;
}
public static final class integer {
public static final int status_bar_notification_info_maxnum = 0x7f080004;
}
public static final class layout {
public static final int notification_action = 0x7f090087;
public static final int notification_action_tombstone = 0x7f090088;
public static final int notification_template_custom_big = 0x7f09008f;
public static final int notification_template_icon_group = 0x7f090090;
public static final int notification_template_part_chronometer = 0x7f090094;
public static final int notification_template_part_time = 0x7f090095;
}
public static final class string {
public static final int status_bar_notification_info_overflow = 0x7f0c004d;
}
public static final class style {
public static final int TextAppearance_Compat_Notification = 0x7f0d00f8;
public static final int TextAppearance_Compat_Notification_Info = 0x7f0d00f9;
public static final int TextAppearance_Compat_Notification_Line2 = 0x7f0d00fb;
public static final int TextAppearance_Compat_Notification_Time = 0x7f0d00fe;
public static final int TextAppearance_Compat_Notification_Title = 0x7f0d0100;
public static final int Widget_Compat_NotificationActionContainer = 0x7f0d0169;
public static final int Widget_Compat_NotificationActionText = 0x7f0d016a;
}
public static final class styleable {
public static final int[] ColorStateListItem = { 0x010101a5, 0x0101031f, 0x7f020029 };
public static final int ColorStateListItem_android_color = 0;
public static final int ColorStateListItem_android_alpha = 1;
public static final int ColorStateListItem_alpha = 2;
public static final int[] FontFamily = { 0x7f0200a2, 0x7f0200a3, 0x7f0200a4, 0x7f0200a5, 0x7f0200a6, 0x7f0200a7 };
public static final int FontFamily_fontProviderAuthority = 0;
public static final int FontFamily_fontProviderCerts = 1;
public static final int FontFamily_fontProviderFetchStrategy = 2;
public static final int FontFamily_fontProviderFetchTimeout = 3;
public static final int FontFamily_fontProviderPackage = 4;
public static final int FontFamily_fontProviderQuery = 5;
public static final int[] FontFamilyFont = { 0x01010532, 0x01010533, 0x0101053f, 0x0101056f, 0x01010570, 0x7f0200a0, 0x7f0200a8, 0x7f0200a9, 0x7f0200aa, 0x7f020190 };
public static final int FontFamilyFont_android_font = 0;
public static final int FontFamilyFont_android_fontWeight = 1;
public static final int FontFamilyFont_android_fontStyle = 2;
public static final int FontFamilyFont_android_ttcIndex = 3;
public static final int FontFamilyFont_android_fontVariationSettings = 4;
public static final int FontFamilyFont_font = 5;
public static final int FontFamilyFont_fontStyle = 6;
public static final int FontFamilyFont_fontVariationSettings = 7;
public static final int FontFamilyFont_fontWeight = 8;
public static final int FontFamilyFont_ttcIndex = 9;
public static final int[] GradientColor = { 0x0101019d, 0x0101019e, 0x010101a1, 0x010101a2, 0x010101a3, 0x010101a4, 0x01010201, 0x0101020b, 0x01010510, 0x01010511, 0x01010512, 0x01010513 };
public static final int GradientColor_android_startColor = 0;
public static final int GradientColor_android_endColor = 1;
public static final int GradientColor_android_type = 2;
public static final int GradientColor_android_centerX = 3;
public static final int GradientColor_android_centerY = 4;
public static final int GradientColor_android_gradientRadius = 5;
public static final int GradientColor_android_tileMode = 6;
public static final int GradientColor_android_centerColor = 7;
public static final int GradientColor_android_startX = 8;
public static final int GradientColor_android_startY = 9;
public static final int GradientColor_android_endX = 10;
public static final int GradientColor_android_endY = 11;
public static final int[] GradientColorItem = { 0x010101a5, 0x01010514 };
public static final int GradientColorItem_android_color = 0;
public static final int GradientColorItem_android_offset = 1;
}
}
| [
"[email protected]"
] | |
2691aa2bfcb8f9a9d039bbf814dc16838d344b36 | 31dee92f5ceccb219dbd69a086b65506e872ac89 | /src/test/java/Actions/LiveTest.java | 4729d27f250b4473264d2c58a9c49ee905065619 | [] | no_license | moitreyeeC/MapSynq | 506470249b7537e9985acd0898b10bd067e53d9a | fae984ffadf88ae783676ad2b672e0ecbf78d5f6 | refs/heads/master | 2020-04-22T10:48:45.044287 | 2019-02-19T06:41:51 | 2019-02-19T06:41:51 | 170,318,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,286 | java | package Actions;
import static org.testng.Assert.assertEquals;
import org.openqa.selenium.By;
import org.testng.Assert;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import Pages.Live;
@Listeners(CustomListener.class)
public class LiveTest extends PersonalTest {
@Test(priority=1,description="check live status")
public void incident() throws InterruptedException
{
Live l=new Live(driver);
l.incident();
String expectedvalue="No incident information available for current area.";
String actualvalue=driver.findElement(By.xpath("//div[@id='divIncidentInfo']")).getText();
if(!expectedvalue.equals(actualvalue))
{
driver.navigate().refresh();
Thread.sleep(3000);
driver.findElement(By.xpath("//input[@id='txtSearchIncidentsingapore']")).sendKeys("Changi Airport");
Thread.sleep(3000);
driver.findElement(By.xpath("//div[contains(text(),'14:07')]")).click();
}
else
{
System.out.println(actualvalue);
}
}
@Test(priority=2,description="check camera position")
public void camera() throws InterruptedException
{
Live c=new Live(driver);
c.camera();
}
@Test(priority=3,description="check toll list")
public void toll() throws InterruptedException
{
Live t=new Live(driver);
t.toll();
}
}
| [
"[email protected]"
] | |
24de64935805c72844fa35051063f598606b9466 | 8fa39bcc167c4108d8ce98585e95366996dca8d9 | /src/main/java/com/cristi/cardatabase/domain/OwnerRepository.java | 3cac868ef531b1efc84f4f09fddbe76a7f85bb83 | [] | no_license | idcristi/spring-react-project | b057d92783c152db97eef4c293ccd2f1c1d090de | 59e8f8ad62a5ed40dc2b949aec2fd9f20474a7f1 | refs/heads/master | 2020-09-13T12:27:44.133746 | 2019-11-20T15:35:03 | 2019-11-20T19:57:49 | 222,779,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 173 | java | package com.cristi.cardatabase.domain;
import org.springframework.data.repository.CrudRepository;
public interface OwnerRepository extends CrudRepository<Owner, Long> {
}
| [
"[email protected]"
] | |
5879db8df7c030460eaf2a1d17e350ad6436ca21 | 8611f5e3cd4bca6ed14e1f4c181547fee5b1fd07 | /EdurekaProject28042018/src/day4/AlertAndFrameHandling.java | 571fb563a5f647119b5592f4dae3b37e27712ac1 | [] | no_license | saurabhd2106/selenium3.0-qatechhub | 49fc490caaa6a24f966bf08c44d7e109acf90818 | 4468ef6f7114a87ceda6b0699dc131c015e1afbe | refs/heads/master | 2020-03-17T23:14:23.892730 | 2018-06-27T19:57:20 | 2018-06-27T19:57:20 | 134,036,562 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,084 | java | package day4;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
public class AlertAndFrameHandling {
public static void main(String[] args) throws InterruptedException {
ChromeDriver driver;
String url = "https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_alert";
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\Saurabh Dhingra\\workspace\\libs\\chromeDriver36\\chromedriver.exe");
// \n \t -- escape character
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get(url);
driver.switchTo().frame("iframeResult");
//To come out of a frame use defaultContent..
// driver.switchTo().defaultContent();
driver.findElement(By.tagName("button")).click();
Alert alert = driver.switchTo().alert();
System.out.println("Message on the alert is :: "+alert.getText());
Thread.sleep(3000);
alert.accept();
//alert.dismiss();
}
}
| [
"Saurabh [email protected]"
] | Saurabh [email protected] |
6c8a3e0ecb30dd3fff2c29bb9314355d9c6c88c9 | f5f311a7d010c4ec724d00d9b9ad4fbb7ed5c3d6 | /eclipse代码/elemeServlet/src/bean/GetShop.java | 09f1911bd1e512fae8318f176b8bee316a01a974 | [] | no_license | fenghong97/Green-Hat | 1c5694daf929b99d947484db1fcc5d14a9897a65 | b8fbf3dbe1e4186be824ea3d50708ee732b1681e | refs/heads/master | 2020-04-25T03:02:46.500574 | 2019-06-16T14:48:21 | 2019-06-16T14:48:21 | 172,462,423 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 1,891 | java | package bean;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.*;
public class GetShop {
public void go() {
//Á¬½ÓÊý¾Ý¿â
ResultSet rs = null;
Sql sql = new Sql();
sql.link("ysw", "123456", "eleme");
sql.runq("select * from shop");
rs = sql.getRs();
try {
String data = new String("[\n");
int cnt = 0;
while(rs.next()) {
String temp = new String("");
if(cnt!=0) temp += ",\n"; ++cnt;
temp += "{ \"name\":\""+rs.getString("Name")+"\",";
temp += "\"imageURL\":\""+rs.getString("ImageURL")+"\",";
temp += "\"score\":\""+rs.getString("Score")+"\",";
temp += "\"sale\":\""+rs.getString("Sale")+"\",";
temp += "\"sprice\":\""+rs.getString("MinPrice")+"\",";
temp += "\"dprice\":\""+rs.getString("Dprice")+"\",";
temp += "\"distance\":\""+rs.getString("Distance")+"\",";
temp += "\"time\":\""+rs.getString("GetTime")+"\" }";
data += temp;
}
data += "\n]";
//DEBUG
System.out.println(data);
String to = "H:\\Tomcat\\apache-tomcat-9.0.5\\webapps\\ele\\shopdata.json";
File file = new File(to);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
try {
file.delete();
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
try {
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
//FileWriter fw = new FileWriter(file, true);
//fw.write(data);
//fw.close();
osw.write(data);
osw.flush();
} catch (IOException e) {
e.printStackTrace();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sql.close();
}
}
| [
"[email protected]"
] | |
0937c82aa822ed60e4b7ebd1261aa642625643ca | 9aac0fa0c3b8a1b7b1d6554bcd3bb871162338ee | /MerrySystem/src/com/dream/weddingexpo/dao/impl/TopDaoImpl.java | 4d4474be4130f5f3d63fe7f76d96d562c5570946 | [] | no_license | sogngenWang/project | 310022882466991b1c77486d7802958b8307d414 | d85ce7808a495ea07e8eac7fc0ba95eb4844a262 | refs/heads/master | 2023-03-17T11:38:29.105709 | 2015-04-20T05:11:16 | 2015-04-20T05:11:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,572 | java | package com.dream.weddingexpo.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Order;
import com.dream.weddingexpo.bean.Top;
import com.dream.weddingexpo.constant.Constants;
import com.dream.weddingexpo.dao.TopDao;
import com.dream.weddingexpo.utils.CommonUtils;
public class TopDaoImpl implements TopDao {
private Session session;
private Criteria criteria;
private Map<String, String> paramMap = new HashMap<String, String>();
public TopDaoImpl() {
Configuration conf = new Configuration().configure();
SessionFactory sessionFactory = conf.buildSessionFactory();
session = sessionFactory.openSession();
}
private Map<String, String> getTopParamMap(Top top) {
paramMap.put(Constants.Top_topId, top.getTopId());
paramMap.put(Constants.Top_messageId, top.getMessageId());
return paramMap;
}
@SuppressWarnings("unchecked")
@Override
public List<Top> topList(Top top) {
session.clear();
criteria = session.createCriteria(top.getClass());
CommonUtils.setCriteria(getTopParamMap(top), criteria);
return criteria.list();
}
@SuppressWarnings("unchecked")
@Override
public Top detailTop(Top top) {
session.clear();
criteria = session.createCriteria(top.getClass());
CommonUtils.setCriteria(getTopParamMap(top), criteria);
List<Top> topList = criteria.list();
if(null != topList && !topList.isEmpty()){
return topList.get(0);
}
return null;
}
@Override
public void addTop(Top top) {
Transaction transaction = session.beginTransaction();
transaction.begin();
top = (Top)session.merge(top);
session.save(top);
transaction.commit();
}
@Override
public void deleteTop(Top top) {
Transaction transaction = session.beginTransaction();
transaction.begin();
top = (Top)session.merge(top);
session.delete(top);
transaction.commit();
}
@Override
public Top updateTop(Top top) {
Transaction transaction = session.beginTransaction();
transaction.begin();
top = (Top)session.merge(top);
session.save(top);
transaction.commit();
return top;
}
@SuppressWarnings("unchecked")
@Override
public List<Top> listTopOrderById(Top top) {
session.clear();
criteria = session.createCriteria(top.getClass());
CommonUtils.setCriteria(getTopParamMap(top), criteria);
criteria.addOrder(Order.asc(Constants.Top_topId));
return criteria.list();
}
}
| [
"[email protected]"
] | |
77ff78ae92755e74c1474a69d07c8e633af290f7 | 344c15ec4918269b972fdc520d25d5739f5f12b3 | /Java II Orientação a Objetos/Aula6/src/exercicio02/TesteErro.java | 543392ac0b9140ad212afbb443b266d5caf16546 | [] | no_license | ordnaelmedeiros/alura | ffe63ea17d64abf2288c041d6a2f98cbe7775fe3 | 199f48b8338022f93ff85de8e4a93291eeda113e | refs/heads/master | 2020-04-09T04:59:17.872037 | 2018-08-29T09:19:24 | 2018-08-29T09:19:24 | 60,308,573 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 658 | java | package exercicio02;
public class TesteErro {
public static void main(String[] args) {
System.out.println("inicio do main");
metodo1();
System.out.println("fim do main");
}
static void metodo1() {
System.out.println("inicio do metodo1");
metodo2();
System.out.println("fim do metodo1");
}
static void metodo2() {
System.out.println("inicio do metodo2");
int[] array = new int[10];
try {
for (int i = 0; i <= 15; i++) {
array[i] = i;
System.out.println(i);
}
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("erro: " + e);
}
System.out.println("fim do metodo2");
}
} | [
"[email protected]"
] | |
eed499a83a25d6908dcb9f2c9bca1f0550e67166 | 8ecc2c160c079f087cb50f07d0f6056ad8434a00 | /streams/src/main/java/org/apache/kafka/streams/processor/ConnectedStoreProvider.java | 84ba1c879cc33f8f0e541cded66d2e1ac7606c13 | [
"Apache-2.0",
"CDDL-1.0",
"EPL-2.0",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | satishd/kafka | f6f256847ff492ef9264ef6da1df0ab1273e9a99 | b58b944e70780029806a6004114bba43ce5b9483 | refs/heads/trunk | 2023-08-31T07:33:55.677224 | 2021-02-18T15:01:49 | 2021-02-18T15:01:49 | 52,782,583 | 2 | 2 | Apache-2.0 | 2023-04-14T12:41:23 | 2016-02-29T10:18:39 | Java | UTF-8 | Java | false | false | 4,921 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kafka.streams.processor;
import org.apache.kafka.streams.Topology;
import org.apache.kafka.streams.kstream.KStream;
import org.apache.kafka.streams.kstream.Named;
import org.apache.kafka.streams.kstream.TransformerSupplier;
import org.apache.kafka.streams.kstream.ValueTransformerSupplier;
import org.apache.kafka.streams.kstream.ValueTransformerWithKeySupplier;
import org.apache.kafka.streams.state.StoreBuilder;
import java.util.Set;
/**
* Provides a set of {@link StoreBuilder}s that will be automatically added to the topology and connected to the
* associated processor.
* <p>
* Implementing this interface is recommended when the associated processor wants to encapsulate its usage of its state
* stores, rather than exposing them to the user building the topology.
* <p>
* In the event that separate but related processors may want to share the same store, different {@link ConnectedStoreProvider}s
* may provide the same instance of {@link StoreBuilder}, as shown below.
* <pre>{@code
* class StateSharingProcessors {
* StoreBuilder<KeyValueStore<String, String>> storeBuilder =
* Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("myStore"), Serdes.String(), Serdes.String());
*
* class SupplierA implements ProcessorSupplier<String, Integer> {
* Processor<String, Integer> get() {
* return new Processor() {
* private StateStore store;
*
* void init(ProcessorContext context) {
* this.store = context.getStateStore("myStore");
* }
*
* void process(String key, Integer value) {
* // can access this.store
* }
*
* void close() {
* // can access this.store
* }
* }
* }
*
* Set<StoreBuilder<?>> stores() {
* return Collections.singleton(storeBuilder);
* }
* }
*
* class SupplierB implements ProcessorSupplier<String, String> {
* Processor<String, String> get() {
* return new Processor() {
* private StateStore store;
*
* void init(ProcessorContext context) {
* this.store = context.getStateStore("myStore");
* }
*
* void process(String key, String value) {
* // can access this.store
* }
*
* void close() {
* // can access this.store
* }
* }
* }
*
* Set<StoreBuilder<?>> stores() {
* return Collections.singleton(storeBuilder);
* }
* }
* }
* }</pre>
*
* @see Topology#addProcessor(String, org.apache.kafka.streams.processor.api.ProcessorSupplier, String...)
* @see KStream#process(ProcessorSupplier, String...)
* @see KStream#process(ProcessorSupplier, Named, String...)
* @see KStream#transform(TransformerSupplier, String...)
* @see KStream#transform(TransformerSupplier, Named, String...)
* @see KStream#transformValues(ValueTransformerSupplier, String...)
* @see KStream#transformValues(ValueTransformerSupplier, Named, String...)
* @see KStream#transformValues(ValueTransformerWithKeySupplier, String...)
* @see KStream#transformValues(ValueTransformerWithKeySupplier, Named, String...)
* @see KStream#flatTransform(TransformerSupplier, String...)
* @see KStream#flatTransform(TransformerSupplier, Named, String...)
* @see KStream#flatTransformValues(ValueTransformerSupplier, String...)
* @see KStream#flatTransformValues(ValueTransformerSupplier, Named, String...)
* @see KStream#flatTransformValues(ValueTransformerWithKeySupplier, String...)
* @see KStream#flatTransformValues(ValueTransformerWithKeySupplier, Named, String...)
*/
public interface ConnectedStoreProvider {
/**
* @return the state stores to be connected and added, or null if no stores should be automatically connected and added.
*/
default Set<StoreBuilder<?>> stores() {
return null;
}
} | [
"[email protected]"
] | |
85b68acb6eaf9ea425285e36299ec6873ca52f7f | b38aba09e3d7617f24d190a8c2999332f46bb2fe | /src/main/java/gui/controllers/role/RoleListController.java | af25ce1a4230e77d1723c7cba5bc44fa5bea4582 | [] | no_license | LJGuardiola-zz/Final-Seminario | 48beef0dcb4078aa693f738ec6f915b12363cd1d | 2782108244c37a5bf213c56d0adbbc2968e6b335 | refs/heads/master | 2023-04-27T10:56:17.823498 | 2021-05-04T02:38:51 | 2021-05-04T02:38:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,025 | java | package gui.controllers.role;
import api.Api;
import com.jfoenix.controls.JFXButton;
import gui.controllers.base.InnerController;
import gui.controllers.global.Session;
import gui.controllers.role.model.Role;
import gui.controllers.role.model.RoleDataModel;
import gui.util.UiExceptionHandler;
import io.datafx.controller.ViewController;
import io.datafx.controller.ViewNode;
import io.datafx.controller.context.ApplicationContext;
import io.datafx.controller.flow.action.ActionMethod;
import io.datafx.controller.flow.action.ActionTrigger;
import io.datafx.controller.flow.action.LinkAction;
import io.datafx.core.concurrent.ProcessChain;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.HBox;
import javax.annotation.PostConstruct;
@ViewController(value = "/gui/views/role/listing.fxml", title = "Listado de roles")
public class RoleListController extends InnerController {
@ViewNode
private HBox btnContainer;
@ViewNode
@LinkAction(RoleCreateController.class)
private JFXButton newButton;
@ViewNode
@LinkAction(RoleEditController.class)
private JFXButton editButton;
@ViewNode
@ActionTrigger("delete")
private JFXButton deleteButton;
@ViewNode
private TableView<Role> table;
@FXML
private TableColumn<Role, Integer> idColumn;
@FXML
private TableColumn<Role, String> nameColumn;
@FXML
private TableColumn<Role, Boolean> enabledColumn;
private RoleDataModel dataModel;
private final Session session = Session.getInstance();
@PostConstruct
private void init() {
ApplicationContext.getInstance().register(dataModel = new RoleDataModel(), RoleDataModel.class);
if (!session.hasPermission("role_update")) {
btnContainer.getChildren().remove(editButton);
} else {
table.getSelectionModel().selectedItemProperty().addListener((o, oldValue, newValue) -> {
editButton.setDisable(newValue == null);
});
}
if (!session.hasPermission("role_delete")) {
btnContainer.getChildren().remove(deleteButton);
} else {
table.getSelectionModel().selectedItemProperty().addListener((o, oldValue, newValue) -> {
deleteButton.setDisable(newValue == null);
});
}
idColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
enabledColumn.setCellValueFactory(new PropertyValueFactory<>("enabled"));
enabledColumn.setCellFactory(param -> new CheckBoxTableCell<>());
table.itemsProperty().bindBidirectional(dataModel.getData());
table.getSelectionModel().selectedItemProperty().addListener(
(o, oldValue, newValue) -> dataModel.setSelected(newValue)
);
ProcessChain.create()
.addRunnableInPlatformThread(this::startLoading)
.addSupplierInExecutor(() -> Api.getInstance().role().getAll())
.addConsumerInPlatformThread(dataModel::load)
.onException(UiExceptionHandler::handle)
.withFinal(this::endLoading)
.run();
}
@ActionMethod("delete")
private void delete() {
Role role = dataModel.getSelected();
confirm("¿Seguro desea eliminar el rol \"" + role.getName() + "\"", () -> {
ProcessChain.create()
.addRunnableInPlatformThread(this::startLoading)
.addRunnableInExecutor(() -> Api.getInstance().role().delete(role.getId()))
.addRunnableInPlatformThread(() -> dataModel.delete(role))
.onException(UiExceptionHandler::handle)
.withFinal(this::endLoading)
.run();
});
}
}
| [
"[email protected]"
] | |
378f0fff34cee88ba470c4fd9cecbc40ecc7c07a | 685036fab1d8f8840e06512e008da8eb130fe76b | /src/main/analysis/SupportAna.java | de0854fb06acb4c5f6a6ba8256e464017aae7da1 | [] | no_license | accexine/ComRepAna | 464e3609c3d4f59b918274d500cfd9337e48dbf0 | ba4a0b95c65fb5d45a119b4eecef454992131d6e | refs/heads/master | 2020-12-31T02:32:44.821253 | 2013-10-31T09:06:23 | 2013-10-31T09:06:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,391 | java | package main.analysis;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SupportAna {
public static HashMap<String, Float> degreehastab = new HashMap<String, Float>();
public static HashMap<String, Float> sephastab = new HashMap<String, Float>();
public static HashMap<String, Float> neghastab = new HashMap<String, Float>();
public static HashMap<String, Float> poshastab = new HashMap<String, Float>();
public static float weight;
public static int poscnt;
public static int negcnt;
public static ArrayList<Float> senweight = new ArrayList<Float>();
public static float totalweight;
public static int par;
public static float score=0;
public static double doAna(String text) throws IOException{
if(degreehastab.isEmpty()) dictinit();
return SuppAnalysis(text);
}
public static double SuppAnalysis(String text) throws UnsupportedEncodingException{
weight=1;
poscnt=0;
negcnt=0;
senweight.clear();
totalweight=0;
par=0;
String[] commentary = text.split(" ");
for(String term : commentary){
if(term.equals("?")||term.equals("?")) {
score=-1;
return score;
}
if(degreehastab.containsKey(term)) {
weight=weight*degreehastab.get(term);
}
else if(poshastab.containsKey(term)) {poscnt+=1;}
else if(neghastab.containsKey(term)) {negcnt+=1;}
else if(sephastab.containsKey(term)){
if(poscnt>0){
senweight.add(poscnt*weight);
par++;
}if(negcnt>0){
senweight.add(-1*negcnt*weight);
par++;
}
weight=1;
poscnt=0;
negcnt=0;
}
if(poscnt>0){
senweight.add(poscnt*weight);
par++;
weight=1;
poscnt=0;
negcnt=0;
}
if(negcnt>0){
senweight.add(-1*negcnt*weight);
par++;
weight=1;
poscnt=0;
negcnt=0;
}
}
for(float w : senweight){
totalweight=totalweight+w;
}
if(par>0) return (float)(totalweight/par);
else return totalweight;
}
public static void dictinit() throws IOException{
String dict = "dict/";
String line=null;
File file = new File(dict+"degree.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
while((line = reader.readLine())!=null){
String[] lineAry = line.split("\t");
float value=Float.parseFloat(lineAry[1]);
degreehastab.put(lineAry[0], value);
}
reader.close();
file=new File(dict+"sep.txt");
reader=new BufferedReader(new FileReader(file));
while((line=reader.readLine())!=null){
sephastab.put(line.trim(), Float.valueOf(1));
}
reader.close();
file=new File(dict+"negative.txt");
reader=new BufferedReader(new FileReader(file));
while((line=reader.readLine())!=null){
neghastab.put(line.trim(), Float.valueOf(1));
}
reader.close();
file=new File(dict+"positive.txt");
reader=new BufferedReader(new FileReader(file));
while((line=reader.readLine())!=null){
poshastab.put(line.trim(), Float.valueOf(1));
}
reader.close();
}
}
| [
"[email protected]"
] | |
b3d5a497d243f49d8b0cada769c9eb137f9bccf9 | 636aa3fed9eca60e4e70a81c7241fa7494feb29a | /Ejerciciosj/Evidencia/src/evidencia/HolaMundoThread.java | b8a68bb3e7acd382b53f3abba65bc422932e94d9 | [] | no_license | joelptw/wds | e07135b14cd9a7b6faddd643816b9c82886b54cb | aef3b45ecd52b4fcbc10ca49787fa55949dd638f | refs/heads/master | 2021-09-27T07:46:28.827901 | 2018-11-07T03:05:03 | 2018-11-07T03:05:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 796 | 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 evidencia;
import java.util.concurrent.TimeUnit;
/**
*
* @author Laboratorio 23
*/
public class HolaMundoThread extends Thread{
private String word;
public HolaMundoThread(String word)
{
this.word = word;
}
@Override
public void run()
{
for(int i =1; i <= 10 ; i++){
System.out.printf("%s: %d %s\n",Thread.
currentThread().getName(), i, word);
try {
TimeUnit.SECONDS.sleep(i);
} catch (InterruptedException e) {
System.out.printf("...");
}
}
}
}
| [
"[email protected]"
] | |
ad4a4911a25bae42cfb3b174b699ad6b88ae07b8 | b55d93e0556507c641d14f9a328b012afa6426f4 | /src/main/java/pl/sikorasoftware/config/JmsConfig.java | d6227a4107b85ca7f0b3e877ff89bd58286a2073 | [] | no_license | rsikora-private/JMS | 6adac74bef8fcd8548ebca39825a0b96b06f3a79 | f8ae4839af26ae83d969541ccca1138de6a2fde5 | refs/heads/master | 2021-01-19T01:06:58.365641 | 2016-07-24T19:29:27 | 2016-07-24T19:29:27 | 63,864,409 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,152 | java | package pl.sikorasoftware.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import pl.sikorasoftware.ExampleListener;
import javax.annotation.Resource;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.MessageListener;
/**
* Created by robertsikora on 19.07.2016.
*/
@Configuration
public class JmsConfig {
@Resource(name="queue.test")
private Destination destination;
@Bean
public ExampleListener listener(){
return new ExampleListener();
}
@Bean
public DefaultMessageListenerContainer jmsContainer(final ConnectionFactory connectionFactory,
final MessageListener messageListener){
final DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestination(destination);
container.setMessageListener(messageListener);
return container;
}
}
| [
"[email protected]"
] | |
07bc603362183422af70e6ef74c8d9b53fa9a05a | 7fc7784c59da74f9f6fd349227ea50b665de185b | /cloud-member/src/main/java/io/commchina/cloudmember/bean/MemberEntity.java | c1ec9d36b288c02783e7bfa0c28837e002330492 | [
"Apache-2.0"
] | permissive | jnyou/cloud-coding | f8330cdbf61cfc59ae086607895f0e9828f36fcd | b781b6e88ca9efe3a7266a33acef926913e8442c | refs/heads/master | 2023-06-04T21:08:03.206926 | 2021-06-18T07:16:09 | 2021-06-18T07:16:09 | 378,825,870 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,507 | java | package io.commchina.cloudmember.bean;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 会员
*
* @author jnyou
* @email [email protected]
*/
@Data
@TableName("ums_member")
public class MemberEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* 会员等级id
*/
private Long levelId;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 昵称
*/
private String nickname;
/**
* 手机号码
*/
private String mobile;
/**
* 邮箱
*/
private String email;
/**
* 头像
*/
private String header;
/**
* 性别
*/
private Integer gender;
/**
* 生日
*/
private Date birth;
/**
* 所在城市
*/
private String city;
/**
* 职业
*/
private String job;
/**
* 个性签名
*/
private String sign;
/**
* 用户来源
*/
private Integer sourceType;
/**
* 积分
*/
private Integer integration;
/**
* 成长值
*/
private Integer growth;
/**
* 启用状态
*/
private Integer status;
/**
* 注册时间
*/
private Date createTime;
/**
* 社交登录的唯一uid
*/
private String uid;
/**
* 社交登录的accessToken
*/
private String accessToken;
/**
* 社交登录返回的过期时间
*/
private long expiresIn;
}
| [
"[email protected]"
] | |
61e998cf9785a9c5d61a92b24fd0f8e27f543f4b | 75d39f45f4a56b9d16c8f72d92ff5d59eea29e30 | /src/txt/me/test/dkuznetsov/IBackend.java | c61c3e39d45bff9210e2d65f334d4a2e7861c71b | [] | no_license | inopressa/txt.test | fb109a7232ecfd97f76faf50dfc36cfbc7633311 | 928a9295479a887d6bb63e05221c3a69e5ff1c03 | refs/heads/master | 2023-06-29T13:53:15.735359 | 2021-07-29T05:39:14 | 2021-07-29T05:39:14 | 390,612,821 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 182 | java | package txt.me.test.dkuznetsov;
public interface IBackend {
public static final int SUCCESS = 200;
public static final int ERROR = 404;
int store(DataPacket packet);
}
| [
"[email protected]"
] | |
376c430d26cb249312d217222bc21ca22c81955c | 7d933417ed871afbef509dc2443d040760660cf1 | /GraduateExpermentalPrograms/ExpenseReimbursementSystem/src/org/xmlsoap/schemas/soap/encoding/TimeDocument.java | 19e2ce61f6e293e145c80911478aa40141fb8273 | [] | no_license | USTBJJT/Proj1 | 9eff97758058f8603cde9be8df46d7cf254b334c | 8a0412f8661889b9bed7084edcf39c394254e142 | refs/heads/master | 2021-01-17T14:20:19.074437 | 2017-11-19T12:52:14 | 2017-11-19T12:52:14 | 84,084,404 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,505 | java | /*
* An XML document type.
* Localname: time
* Namespace: http://schemas.xmlsoap.org/soap/encoding/
* Java type: org.xmlsoap.schemas.soap.encoding.TimeDocument
*
* Automatically generated - do not modify.
*/
package org.xmlsoap.schemas.soap.encoding;
/**
* A document containing one time(@http://schemas.xmlsoap.org/soap/encoding/) element.
*
* This is a complex type.
*/
public interface TimeDocument extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)
org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(TimeDocument.class.getClassLoader(), "schemaorg_apache_xmlbeans.system.s7C63D0A169DC56E072CF6663C2B22D75").resolveHandle("timea4a3doctype");
/**
* Gets the "time" element
*/
org.xmlsoap.schemas.soap.encoding.Time getTime();
/**
* Sets the "time" element
*/
void setTime(org.xmlsoap.schemas.soap.encoding.Time time);
/**
* Appends and returns a new empty "time" element
*/
org.xmlsoap.schemas.soap.encoding.Time addNewTime();
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.xmlsoap.schemas.soap.encoding.TimeDocument newInstance() {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
/** @param xmlAsString the string value to parse */
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, options ); }
/** @param file the file from which to load an xml document */
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, options ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, options ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, options ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, options ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(javax.xml.stream.XMLStreamReader sr) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(javax.xml.stream.XMLStreamReader sr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, options ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, null ); }
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, options ); }
/** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, null ); }
/** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */
public static org.xmlsoap.schemas.soap.encoding.TimeDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.xmlsoap.schemas.soap.encoding.TimeDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, options ); }
/** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); }
/** @deprecated {@link org.apache.xmlbeans.xml.stream.XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); }
private Factory() { } // No instance of this class allowed
}
}
| [
"[email protected]"
] | |
c28db83485e89245272d2d3638ec0c61a2976b81 | e403581f24f2bd3b03107667b801873400e60255 | /src/main/java/com/fengkuang/java/面向对象05/继承与组合58/Composite/CompositeTest.java | 3eb8f05981cb4fc6eb3a77c28e6b899c8346bf79 | [] | no_license | ruoshuixuelabi/fengkuangjava | 3fc723df9d57a70a90c49b92f37caf1658620e56 | cd1338bf3002bb58b96078d217e342b4ca1a86e8 | refs/heads/master | 2022-12-29T16:14:59.479535 | 2020-10-17T13:50:54 | 2020-10-17T13:50:54 | 304,887,754 | 2 | 4 | null | null | null | null | UTF-8 | Java | false | false | 1,614 | java | package com.fengkuang.java.面向对象05.继承与组合58.Composite;
class Animal {
private void beat() {
System.out.println("心脏跳动...");
}
public void breathe() {
beat();
System.out.println("吸一口气,吐一口气,呼吸中...");
}
}
class Bird {
// 将原来的父类组合到原来的子类,作为子类的一个组合成分
private Animal a;
public Bird(Animal a) {
this.a = a;
}
// 重新定义一个自己的breathe()方法
public void breathe() {
// 直接复用Animal提供的breathe()方法来实现Bird的breathe()方法。
a.breathe();
}
public void fly() {
System.out.println("我在天空自在的飞翔...");
}
}
class Wolf {
// 将原来的父类组合到原来的子类,作为子类的一个组合成分
private Animal a;
public Wolf(Animal a) {
this.a = a;
}
// 重新定义一个自己的breathe()方法
public void breathe() {
// 直接复用Animal提供的breathe()方法来实现Wolf的breathe()方法。
a.breathe();
}
public void run() {
System.out.println("我在陆地上的快速奔跑...");
}
}
public class CompositeTest {
public static void main(String[] args) {
// 此时需要显式创建被组合的对象
var a1 = new Animal();
var b = new Bird(a1);
b.breathe();
b.fly();
// 此时需要显式创建被组合的对象
var a2 = new Animal();
var w = new Wolf(a2);
w.breathe();
w.run();
}
}
| [
"[email protected]"
] | |
49d8a92ca6a2fc406b9d469ab9f88d45e65f0968 | 80a0886a75aa337ecb23bde090855bea8db9da08 | /src/main/java/lesson20/interfaceExample/NewInterfaceExampleImpl.java | f2ed4991eaf1bc30810e6aff88c77762a037ee29 | [] | no_license | Kreeck89/elementary_161220 | 9a95d75ac237db4a34234a6fb327cffc246947a8 | 16e588910cdbcf85b51ee562315ac95f0e8461a3 | refs/heads/main | 2023-05-01T14:23:36.609068 | 2021-04-28T18:07:15 | 2021-04-28T18:07:15 | 333,579,795 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 382 | java | package lesson20.interfaceExample;
public class NewInterfaceExampleImpl implements NewInterfaceExample, NewInterfaceExample2 {
@Override
public void print() {
System.out.println("Some logic here....");
}
@Override
public void defaultPrint(String string) {
System.out.println("NewInterfaceExampleImpl.defaultPrint method: " + string);
}
}
| [
"[email protected]"
] | |
15b0f1171778f9f4310f334e80b8fea0a1634d91 | f0ec508f4b480d8d5399a2880e4cbb0533fc2fc1 | /com.ouchgzee.headTeacher.biz/src/main/java/com/ouchgzee/headTeacher/serviceImpl/edumanage/GjtTeachPlanServiceImpl.java | d858df10692fd275c67d3d42238e6f560d07e1ab | [] | no_license | lizm335/MyLizm | a327bd4d08a33c79e9b6ef97144d63dae7114a52 | 1bcca82395b54d431fb26817e61a294f9d7dd867 | refs/heads/master | 2020-03-11T17:25:25.687426 | 2018-04-19T03:10:28 | 2018-04-19T03:10:28 | 130,146,458 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,111 | java | package com.ouchgzee.headTeacher.serviceImpl.edumanage;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ouchgzee.headTeacher.dao.study.GjtTeachPlanDao;
import com.ouchgzee.headTeacher.pojo.BzrGjtTeachPlan;
import com.ouchgzee.headTeacher.service.edumanage.BzrGjtTeachPlanService;
/**
*
* 功能说明:年级专业 实施教学计划
*
* @author 李明 [email protected]
* @Date 2016年6月17日
* @version 2.5
*
*/
@Deprecated @Service("bzrGjtTeachPlanServiceImpl") // 为将来班主任的entity/dao/service模块合并到管理后台做准备,合并后尽可能的少在班主任上写代码,防止Spring容器name冲突,组件的name需加前缀bzr
public class GjtTeachPlanServiceImpl implements BzrGjtTeachPlanService {
@Autowired
private GjtTeachPlanDao gjtTeachPlanDao;
@Override
public List<BzrGjtTeachPlan> queryGjtTeachPlan(String gradeId, String gjtSpecialtyId) {
return gjtTeachPlanDao.findByGradeIdAndKkzyAndIsDeletedOrderByCreatedDtAsc(gradeId, gjtSpecialtyId, "N");
}
}
| [
"[email protected]"
] | |
d91abca89356a4635ddb8d43caf379cc38493bc7 | 9dcdd005f444222fc90899854d8bf8a871926775 | /src/sample/BrowseFilter.java | a7952ccde2a1905b0675fe5992da0e7c3b7f328f | [] | no_license | 444iamahmed/GAME-STORE | 0a8ce1a693f955821544fd992524ed7711e4e53e | 857a4f0ec4a00898ab3470f687c532efab3d97b0 | refs/heads/main | 2023-02-11T19:49:46.378152 | 2020-12-31T18:47:25 | 2020-12-31T18:47:25 | 319,386,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,089 | java | package sample;
import java.util.ArrayList;
import java.util.Date;
public class BrowseFilter extends Filter{
private static BrowseFilter instance = null;
private Double rating;
private ArrayList<String> genres;
private ArrayList<String> platforms;
private Double maxPrice;
private SortBy sortBy;
private BrowseFilter()
{
genres = new ArrayList<>();
platforms = new ArrayList<>();
rating = 0.0;
maxPrice = 500000.0;
sortBy = SortBy.DATE;
}
public static BrowseFilter getInstance()
{
if(instance == null)
instance = new BrowseFilter();
return instance;
}
public SortBy getSortBy() {
return sortBy;
}
public void setSortBy(SortBy sortBy) {
this.sortBy = sortBy;
}
public Date getReleaseDate() {
return releaseDate;
}
public void setReleaseDate(Date releaseDate) {
this.releaseDate = releaseDate;
}
private Date releaseDate;
public double getRating() {
return rating;
}
public void setRating(Double rating) {
this.rating = rating;
}
public ArrayList<String> getGenres() {
return genres;
}
public void setGenres(ArrayList<String> genres) {
this.genres = genres;
}
public ArrayList<String> getPlatforms() {
return platforms;
}
public void setPlatforms(ArrayList<String> platforms) {
this.platforms = platforms;
}
public double getMaxPrice() {
return maxPrice;
}
public void setMaxPrice(Double maxPrice) {
this.maxPrice = maxPrice;
}
public void addGenre(String genre)
{
if(!genres.contains(genre))
genres.add(genre);
}
public void removeGenre(String genre)
{
genres.remove(genre);
}
public void addPlatform(String platform) {
if(!platforms.contains(platform))
platforms.add(platform);
}
public void removePlatform(String platform) {
platforms.remove(platform);
}
}
| [
"[email protected]"
] | |
429200b645cea2fbc7b53dba37b886a38f39ab53 | 34b6ea690b2b88c60a70b16b4b86f0f6a7586a20 | /0.3-continue/src/com/prueba/ContinueDoWhile.java | 7e45246de72313cb82b9d8797473a7123228f7cf | [] | no_license | bernalvarela/queresJava | f482e38deb7572a1f9f6e0ea51a1085c256a02ef | af150a3391064a60938b05201113811e309d8267 | refs/heads/master | 2021-07-07T20:46:13.081446 | 2019-07-08T19:11:45 | 2019-07-08T19:11:45 | 195,702,995 | 0 | 0 | null | 2020-10-13T14:25:34 | 2019-07-07T22:31:08 | Java | UTF-8 | Java | false | false | 455 | java |
package com.prueba;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class ContinueDoWhile {
public static void main(String[] args) {
Random r = new Random();
Set<Integer> aSet = new HashSet<Integer>();
int anInt;
do {
anInt = r.nextInt(10);
if (anInt % 2 == 0) {
continue;
}
System.out.println(anInt);
} while (aSet.add(anInt));
System.out.println(aSet);
}
}
| [
"[email protected]"
] | |
8ad55de8a475bbd2c2aa3e5cb87051f8ad156fb5 | 738f9d7d37bfc3b4341a0353d98df74af49290aa | /打磚塊/src/S105502525/game_controller2.java | 41024181e2c114e91ab08a1b227854c85cb50299 | [] | no_license | YangLambert/my-project | f858feb5bcec321b7115ccad32ac57a7ee54d3cc | 6ddf5a96dcf0ed8f159f0a84fd2c563c26665863 | refs/heads/master | 2020-08-07T11:43:14.082788 | 2019-10-08T01:23:06 | 2019-10-08T01:23:06 | 213,435,026 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,172 | java | package S105502525;
import java.io.File;
import javafx.animation.AnimationTimer;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Sphere;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.util.Duration;
public class game_controller2 {
private MediaPlayer mediaPlayer = new MediaPlayer(new Media(new File("sound/victory.mp3").toURI().toString()));
@FXML
private Rectangle brickblock;
@FXML
private Sphere ball;
@FXML
private Canvas canvas;
@FXML
private ImageView marry;
@FXML
private ImageView gameover;
@FXML
private ImageView victory;
private AnimationTimer rectangleAnimation;
private long lastUpdateTime = 0;
private double rectangleSpeedX = 0 ; // pixels per second
private double rectangleSpeedY = 0 ;
int i=0,j=0;
int o=0;
int cc=0;
private gmanager Gmanager;
private gmanager2 Gmanager2 = new gmanager2();
public game_controller2 (gmanager Gmanager)
{
this.Gmanager = Gmanager;
}
@FXML
private void initialize() {
brickblock.setTranslateX(220);
brickblock.setTranslateY(550);
ball.setTranslateX(250);
ball.setTranslateY(545);
marry.setTranslateX(220);
marry.setTranslateY(541);
gameover.setVisible(false);
victory.setVisible(false);
Gmanager2.set_gc(canvas.getGraphicsContext2D ());
rectangleAnimation = new AnimationTimer() {
@Override
public void handle(long timestamp) {
if (lastUpdateTime > 0) {
cc=Gmanager.get_cc();
final double elapsedSeconds = (timestamp - lastUpdateTime) / 1_000_000_000.0 ;
final double deltaX = elapsedSeconds * rectangleSpeedX;
final double balldeltaX = elapsedSeconds * i;
final double balldeltaY= elapsedSeconds * j;
final double oldX = brickblock.getTranslateX();
ball.setTranslateX(ball.getTranslateX()+balldeltaX);
ball.setTranslateY(ball.getTranslateY()+balldeltaY);
marry.setTranslateX(brickblock.getTranslateX());
marry.setTranslateY(brickblock.getTranslateY()-9);
if(cc==3){
marry.setTranslateY(brickblock.getTranslateY());
marry.setFitWidth(50);
marry.setFitHeight(47);;
marry.setImage(new Image("file:image/sword1.png"));
}
if(cc==2){
marry.setTranslateY(brickblock.getTranslateY());
marry.setFitWidth(50);
marry.setFitHeight(47);;
marry.setImage(new Image("file:image/shoot1.png"));
}
double newX =oldX + deltaX;
if(newX>=433.5640203000001){
newX=433.5640203000001;
}
else if (newX<=0){
newX=0;
}
brickblock.setTranslateX(newX);
final double deltaY = elapsedSeconds * rectangleSpeedY;
final double oldY = brickblock.getTranslateY();
final double newY =oldY + deltaY;
brickblock.setTranslateY(newY);
}
canvas.getGraphicsContext2D().clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
Gmanager2.draw(timestamp);
if( Gmanager2.isCollisionWith(ball.getTranslateX(),ball.getTranslateY())==1){
i=-i;
}
else if( Gmanager2.isCollisionWith(ball.getTranslateX(),ball.getTranslateY())==2){
j=-j;
}
if(ball.getTranslateX() <= 6|| ball.getTranslateX() >= 495){
i=-i;
}
if(ball.getTranslateY() <= 6 ){
j=-j;
}
if(ball.getTranslateY() >= 595 ){
if(o==0){
gameover.setVisible(true);
}
}
if(Gmanager2.setscreen()==1){
o=1;
victory.setVisible(true);
mediaPlayer.play();
}
if(isCollisionWith()) {
j=-j;
}
lastUpdateTime = timestamp;
}
};
rectangleAnimation.start ();
}
public void setScene(Scene scene){
FadeTransition ft = new FadeTransition(Duration.millis(3000),brickblock);
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode()==KeyCode.SPACE&&ball.getTranslateX()==250&&
ball.getTranslateY()==545) {
if(cc==1){
i=300;
j=-200;
}
else if(cc==2){
i=350;
j=-250;}
else if(cc==3){
i=150;
j=-100;}
Gmanager2.setGreenMove();
}
if (event.getCode()==KeyCode.RIGHT) {
rectangleSpeedX = 300;
}
if (event.getCode()==KeyCode.LEFT) {
rectangleSpeedX = -300;
}
}
});
scene.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.RIGHT){
rectangleSpeedX = 0;
}
if (event.getCode() == KeyCode.LEFT){
rectangleSpeedX = 0;
}
}
});
}
public boolean isCollisionWith(){
if(ball.getTranslateX() + 7 > brickblock.getTranslateX() && ball.getTranslateX() < brickblock.getTranslateX() + brickblock.getWidth() && ball.getTranslateY() > brickblock.getTranslateY() && ball.getTranslateY() < brickblock.getTranslateY() + brickblock.getHeight()){
return true;
}
return false;
}
}
| [
"[email protected]"
] | |
e7720d8da14f89117723c2260e986fb816d5799d | 2f552af9e529ab0d5af985f513ca8a6ebf7e10bd | /src/Office_Hours/Practice_10_28_2020/LargestPalindrome.java | 23a7e09fabf5777ef8b5d7d2a71698dba6ca0d41 | [] | no_license | neciporhan/Summer2020_B20_byMuhtar | 18c744e8204845a4c15be35e8548ec7ba9c81f5d | 248eb82ab4602eda409765c54f6b153bae55a26d | refs/heads/master | 2023-02-04T03:23:52.245996 | 2020-12-31T02:48:47 | 2020-12-31T02:48:47 | 324,640,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,032 | java | package Office_Hours.Practice_10_28_2020;
import java.util.ArrayList;
public class LargestPalindrome {
/*
* Create a method that will accept a String ArrayList and return the largest Palindrome String from it
=> Assume there is no Strings with the same length and there will be at least one element
*
*
* -> "dad", "abcba", "racecar", "cat", sdhodjsijiajsdijodsj
*
*
*/
public static String largestPalindrome(ArrayList<String> words) {
String largestStr = ""; // r a c e c a r 7/2 = 3
for(String word : words) {
if(word.length() > largestStr.length()) {
if(isPalindrome(word)) {
largestStr = word;
}
}
}
return largestStr;
}
private static boolean isPalindrome (String str) {
for(int i=0; i < str.length()/2; i++) {
if (str.charAt(i) != str.charAt(str.length()-1-i) ) {
return false;
}
}
return true;
}
}
| [
"[email protected]"
] | |
5cdd2970067dbf1b3ad00f92298d5c144c7ef884 | 3bc88bad2063e40a3f9f4bce4bd18cd474798cce | /백준/BOJ 15971 두 로봇/Main.java | 6ef87b7fdb1b896131e65657b6e62363769dcfc7 | [] | no_license | cocobino/ACM-ICPC | b1793403bf4f759adf6457f36a78d47dd5988135 | 03c1f8a24f50229abebe03657dc2ef75d2816244 | refs/heads/master | 2023-02-26T02:09:15.120403 | 2023-02-20T15:08:44 | 2023-02-20T15:08:44 | 128,730,398 | 3 | 1 | null | null | null | null | UHC | Java | false | false | 2,512 | java | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
static int dx[] = {-1,1,0,0,1,-1,-1,1}; //상, 하 , 좌 , 우
static int dy[] = {0,0,-1,1,1,1,-1,-1};
//오른위(4), 오른아래(5), 왼위(6), 왼아래(7)
static int map[][], com[];
static boolean visit[];
static int n,start,end,max=0,cnt=1000,rst=10000;
static ArrayList<Node>[] arr;
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO Auto-generated method stub
st =new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
start = Integer.parseInt(st.nextToken());
end = Integer.parseInt(st.nextToken());
visit = new boolean[n+1];
arr = new ArrayList[n+1];
for(int i=0; i<=n; i++)arr[i] = new ArrayList<Node>();
for(int i=0; i<n-1; i++) {
st =new StringTokenizer(br.readLine());
int from = Integer.parseInt(st.nextToken());
int to = Integer.parseInt(st.nextToken());
int cost = Integer.parseInt(st.nextToken());
arr[from].add(new Node(to,cost));
arr[to].add(new Node(from,cost));
}
dfs(start,0,0);
bw.write(String.valueOf(rst));
bw.flush();
}//main
private static void dfs(int cur, int sum, int curmax) {
// TODO Auto-generated method stub
visit[cur]= true;
if(cur == end) {
rst = sum - curmax;
return;
}
for(int i=0; i<arr[cur].size(); i++) {
if(!visit[arr[cur].get(i).to]) {
dfs(arr[cur].get(i).to, sum+arr[cur].get(i).cost,
Math.max(curmax, arr[cur].get(i).cost));
}
}
}
}//class
class Node{
int to,cost;
public Node(int to, int cost) {
this.to = to;
this.cost = cost;
}
public int getTo() {
return to;
}
public void setTo(int to) {
this.to = to;
}
public int getCost() {
return cost;
}
public void setCost(int cost) {
this.cost = cost;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.