blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
59bcbc29b44c003d972e30bf07c39163c6b3348f | e1520517adcdd4ee45fb7b19e7002fdd5a46a02a | /polardbx-optimizer/src/main/java/com/alibaba/polardbx/optimizer/core/expression/calc/aggfunctions/Rank.java | 46c22f6a22bc9c6b1e7c0f232524600b8053b646 | [
"Apache-2.0"
] | permissive | huashen/galaxysql | 7702969269d7f126d36f269e3331ed1c8da4dc20 | b6c88d516367af105d85c6db60126431a7e4df4c | refs/heads/main | 2023-09-04T11:40:36.590004 | 2021-10-25T15:43:14 | 2021-10-25T15:43:14 | 421,088,419 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,372 | java | /*
* Copyright [2013-2021], Alibaba Group Holding Limited
*
* 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.alibaba.polardbx.optimizer.core.expression.calc.aggfunctions;
import com.alibaba.polardbx.optimizer.chunk.BlockBuilder;
import com.alibaba.polardbx.optimizer.chunk.Chunk;
import com.alibaba.polardbx.optimizer.core.expression.calc.AbstractAggregator;
import com.alibaba.polardbx.optimizer.core.row.Row;
import java.util.List;
import java.util.Objects;
/**
* rank不支持distinct,语义即不支持
*/
public class Rank extends AbstractAggregator {
protected long rank = 0;
protected Long count = 0L;
protected Row lastRow = null;
public Rank(int[] index, int filterArg) {
super(index != null && index.length > 0 && index[0] >= 0 ? index : new int[0], false, null, null, filterArg);
}
@Override
public void accumulate(int groupId, Chunk inputChunk, int position) {
Chunk.ChunkRow row = inputChunk.rowAt(position);
count++;
if (!sameRank(lastRow, row)) {
rank = count;
lastRow = row;
}
}
@Override
public void writeResultTo(int groupId, BlockBuilder bb) {
bb.writeLong(rank);
}
@Override
public void resetToInitValue(int groupId) {
count = 0L;
rank = 0L;
lastRow = null;
}
protected boolean sameRank(Row lastRow, Row row) {
if (lastRow == null) {
return row == null;
}
List<Object> lastRowValues = lastRow.getValues();
List<Object> rowValues = row.getValues();
for (int index : aggIndexInChunk) {
Object o1 = lastRowValues.get(index);
Object o2 = rowValues.get(index);
if (!(Objects.equals(o1, o2))) {
return false;
}
}
return true;
}
}
| [
"[email protected]"
] | |
85cf57fb569e322e903b935b4e9009ffb7513b33 | 6e371e9f819f9caeda42d61bb1b8a82fd23c1d3a | /app/src/main/java/com/example/shiran/drhelp/services/MyFirebaseMessagingService.java | 8db06dcb6452e5352e69a2b0baf52f0b596a6f95 | [] | no_license | shiranSofer/DrHelp | 730c167c3de97957efc14946cd278de0e92b392a | ada95ca24e91fc05c04f10195784e582bba90752 | refs/heads/master | 2020-06-25T22:02:10.108109 | 2019-05-18T19:40:49 | 2019-05-18T19:40:49 | 161,333,640 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,692 | java | package com.example.shiran.drhelp.services;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;
import com.example.shiran.drhelp.util.Config;
import com.example.shiran.drhelp.ui.LoginActivity;
import com.example.shiran.drhelp.util.NotificationUtils;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import org.json.JSONException;
import org.json.JSONObject;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();
private NotificationUtils notificationUtils;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage == null)
return;
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
handleNotification(remoteMessage.getNotification().getBody());
}
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
try {
JSONObject json = new JSONObject(remoteMessage.getData().toString());
handleDataMessage(json);
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
}
}
private void handleNotification(String message) {
if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
// app is in foreground, broadcast the push message
Intent pushNotification = new Intent(Config.PUSH_NOTIFICATION);
pushNotification.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);
// play notification sound
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
notificationUtils.playNotificationSound();
}else{
// If the app is in background, firebase itself handles the notification
}
}
private void handleDataMessage(JSONObject json) {
Log.e(TAG, "push json: " + json.toString());
try {
JSONObject data = json.getJSONObject("data");
String title = data.getString("title");
String message = data.getString("message");
boolean isBackground = data.getBoolean("is_background");
String imageUrl = data.getString("image");
String timestamp = data.getString("timestamp");
JSONObject payload = data.getJSONObject("payload");
Log.e(TAG, "title: " + title);
Log.e(TAG, "message: " + message);
Log.e(TAG, "isBackground: " + isBackground);
Log.e(TAG, "payload: " + payload.toString());
Log.e(TAG, "imageUrl: " + imageUrl);
Log.e(TAG, "timestamp: " + timestamp);
if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
// app is in foreground, broadcast the push message
Intent pushNotification = new Intent(Config.PUSH_NOTIFICATION);
pushNotification.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);
// play notification sound
NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
notificationUtils.playNotificationSound();
} else {
// app is in background, show the notification in notification tray
Intent resultIntent = new Intent(getApplicationContext(), LoginActivity.class);
resultIntent.putExtra("message", message);
// check for image attachment
if (TextUtils.isEmpty(imageUrl)) {
showNotificationMessage(getApplicationContext(), title, message, timestamp, resultIntent);
} else {
// image is present, show notification with image
showNotificationMessageWithBigImage(getApplicationContext(), title, message, timestamp, resultIntent, imageUrl);
}
}
} catch (JSONException e) {
Log.e(TAG, "Json Exception: " + e.getMessage());
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
}
/**
* Showing notification with text only
*/
private void showNotificationMessage(Context context, String title, String message, String timeStamp, Intent intent) {
notificationUtils = new NotificationUtils(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
notificationUtils.showNotificationMessage(title, message, timeStamp, intent);
}
/**
* Showing notification with text and image
*/
private void showNotificationMessageWithBigImage(Context context, String title, String message, String timeStamp, Intent intent, String imageUrl) {
notificationUtils = new NotificationUtils(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
notificationUtils.showNotificationMessage(title, message, timeStamp, intent, imageUrl);
}
}
| [
"[email protected]"
] | |
7b6336af022edf6dc6878f7bbc85407565a42412 | e4b8d750d9270efc4f21e047cc738f013ff54624 | /src/main/java/com/cg/opo/service/IPizzaOrderService.java | 18e72760ba5157acd5d3a482db277bc1de5cd250 | [] | no_license | SankalpDisale/gitrepository | 2b825c9cb9d4e917c4c81d2cce11fa11507f8ad9 | a6286ccf7caa62c681d7b1ab950e93b4691ee3ab | refs/heads/master | 2023-05-31T10:02:35.290596 | 2021-06-14T17:07:14 | 2021-06-14T17:07:14 | 367,561,220 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 802 | java | package com.cg.opo.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.cg.opo.exception.OrderIdNotFoundException;
import com.cg.opo.exception.OrderTypeNotFoundException;
import com.cg.opo.model.PizzaOrder;
@Service
public interface IPizzaOrderService {
public List<PizzaOrder> getAllPizzaOrder();
public PizzaOrder findPizzaOrderById(Integer pizzaOrderId) throws OrderIdNotFoundException;
public List<PizzaOrder> findOrderByType(String orderType);
public List<PizzaOrder> updatePizzaOrder(PizzaOrder pizzaOrder);
public List<PizzaOrder> deletePizzaOrder(Integer pizzaOrderId)throws OrderIdNotFoundException;
public List<PizzaOrder> savePizzaOrder(PizzaOrder pizzaOrder);
public List<PizzaOrder> saveAll();
}
| [
"[email protected]"
] | |
3295f557676470642d6d896943caa8bc77f49198 | 94138ba86d0dbf80b387064064d1d86269e927a1 | /group12/377401843/learning/src/main/java/com/zhaogd/jvm/util/Util.java | 9c2fcc183e7051fae52922cd6863365e2f9c076d | [] | no_license | DonaldY/coding2017 | 2aa69b8a2c2990b0c0e02c04f50eef6cbeb60d42 | 0e0c386007ef710cfc90340cbbc4e901e660f01c | refs/heads/master | 2021-01-17T20:14:47.101234 | 2017-06-01T00:19:19 | 2017-06-01T00:19:19 | 84,141,024 | 2 | 28 | null | 2017-06-01T00:19:20 | 2017-03-07T01:45:12 | Java | UTF-8 | Java | false | false | 555 | java | package com.zhaogd.jvm.util;
public class Util {
public static int byteToInt(byte[] codes){
String s1 = byteToHexString(codes);
return Integer.valueOf(s1, 16).intValue();
}
public static String byteToHexString(byte[] codes ){
StringBuffer buffer = new StringBuffer();
for(int i=0;i<codes.length;i++){
byte b = codes[i];
int value = b & 0xFF;
String strHex = Integer.toHexString(value);
if(strHex.length()< 2){
strHex = "0" + strHex;
}
buffer.append(strHex);
}
return buffer.toString();
}
}
| [
"[email protected]"
] | |
c7d1180f3565149adb81c9f60d872b8512b92cc0 | 073217d23171e5fff68432ccfd037da14744a72a | /src/main/java/io/swagger/model/StatusType.java | bd3f917664b0ea3c357fe912c4665ad3aefc5d6c | [] | no_license | caballerocsc/spring-server-producto | bfc37ac330475006bb877f92bc3e1156308b6c68 | 345f218b6a05b2828b1c6111ec5d0fabf0791d3c | refs/heads/master | 2020-07-25T17:58:58.470902 | 2019-09-16T04:31:14 | 2019-09-16T04:31:14 | 208,379,746 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,708 | java | package io.swagger.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* Status de respuesta.
*/
@ApiModel(description = "Status de respuesta.")
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-09-11T01:59:35.650Z")
public class StatusType {
@JsonProperty("statusCode")
private Integer statusCode = null;
@JsonProperty("statusDesc")
private String statusDesc = null;
public StatusType(Integer pStatus, String pDesc) {
this.statusCode = pStatus;
this.statusDesc = pDesc;
}
public StatusType statusCode(Integer statusCode) {
this.statusCode = statusCode;
return this;
}
/**
* Código de status.
* @return statusCode
**/
@ApiModelProperty(value = "Código de status.")
public Integer getStatusCode() {
return statusCode;
}
public void setStatusCode(Integer statusCode) {
this.statusCode = statusCode;
}
public StatusType statusDesc(String statusDesc) {
this.statusDesc = statusDesc;
return this;
}
/**
* Descripción de estatus.
* @return statusDesc
**/
@ApiModelProperty(value = "Descripción de estatus.")
public String getStatusDesc() {
return statusDesc;
}
public void setStatusDesc(String statusDesc) {
this.statusDesc = statusDesc;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
StatusType statusType = (StatusType) o;
return Objects.equals(this.statusCode, statusType.statusCode) &&
Objects.equals(this.statusDesc, statusType.statusDesc);
}
@Override
public int hashCode() {
return Objects.hash(statusCode, statusDesc);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class StatusType {\n");
sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n");
sb.append(" statusDesc: ").append(toIndentedString(statusDesc)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| [
"[email protected]"
] | |
979e289901631658a18516a3a162d40de98d430f | fb8c322870456dca95f34c3fe63b1ba11f0b83b1 | /src/main/java/edu/unas/spoi/poi/service/interfac/IPOIUnityService.java | a3d951b62b6acf75dd1dfd16034da92096b26c2a | [] | no_license | DarkusNightstalker/S-POI | a125e86ad33cd3007d88b8ec92d234c1d53c13de | 047a768c29478ac1a5f1c20447a5e32145a4aac1 | refs/heads/master | 2020-03-17T15:40:16.754991 | 2018-05-16T22:27:13 | 2018-05-16T22:27:13 | 133,719,341 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | 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 edu.unas.spoi.poi.service.interfac;
import edu.unas.spoi.poi.model.POIUnity;
import gkfire.hibernate.generic.interfac.IGenericService;
import java.io.Serializable;
/**
* The interface Ipoi unity service.
*
* @author Jhoan Brayam
*/
public interface IPOIUnityService extends IGenericService<POIUnity, Integer>{
/**
* Exist code boolean.
*
* @param code the code
* @param id the id
* @return the boolean
*/
public boolean existCode(String code, Integer id);
}
| [
"[email protected]"
] | |
30923abf34100e1a3a46c8b20bb9535ea78f4ffa | c9ae27b7f7072d4dc2534fc0a0791c9125d2ea5b | /src/main/java/com/lyc/carjava/modules/base/dto/PageDto.java | 2fe6421b03147497fd5fba72952038f7629f0393 | [] | no_license | ldda62/car-java | e86fda9e8c3f7cfc4ee40b269b0fabae6923942f | 92878ae1953223602198744a2376aa5ada3af62e | refs/heads/master | 2022-11-05T00:59:13.484444 | 2020-07-01T16:38:32 | 2020-07-01T16:38:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 249 | java | package com.lyc.carjava.modules.base.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value = "分页参数",description = "请求参数")
public class PageDto {
private int current;
private int pageSize;
}
| [
"[email protected]"
] | |
59b32623b7fccf7e1e41e12a2d19a893e28a1f51 | 986cbec6f971e319d0e5cec4dcb6fe2edfef190a | /app/src/test/java/decoding/com/decoding/ExampleUnitTest.java | 0d285eb5189e4f08b77a16128c8e0583abcb59ce | [] | no_license | gitaumoses4/Decoding | 8e8c3b3be89bfb93572097eb83ef53a5b2e65782 | 33e7b9241a39f181e6e3a7f4b8a2d3956dbb08bd | refs/heads/master | 2021-09-04T14:21:51.891373 | 2018-01-19T02:10:46 | 2018-01-19T02:10:46 | 103,504,699 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 399 | java | package decoding.com.decoding;
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]"
] | |
42cfb5a0aabc78662907a91254a27e81ba3decc5 | 27156e54787b811e5f11bdadd5a5dd27a13f244e | /Project_1/src/main/java/com/udacity/jwdnd/course1/cloudstorage/controller/NoteController.java | 1a0081195dd5d75eda1ce7f544d87b06b7f7f31c | [] | no_license | RodrigoEdson/JavaUdacity | 9fdd111eda13b0fba1c96f55157a2d76fef6f93d | dd8b1a94dd5c088870467e25bc27bf33bfa75cdd | refs/heads/master | 2023-06-09T06:27:47.085074 | 2021-06-27T13:02:52 | 2021-06-27T13:02:52 | 348,663,768 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,900 | java | package com.udacity.jwdnd.course1.cloudstorage.controller;
import com.udacity.jwdnd.course1.cloudstorage.model.Note;
import com.udacity.jwdnd.course1.cloudstorage.model.NoteDTO;
import com.udacity.jwdnd.course1.cloudstorage.model.User;
import com.udacity.jwdnd.course1.cloudstorage.services.NoteService;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.List;
@Controller
@RequestMapping("/note")
public class NoteController {
private NoteService noteService;
public NoteController(NoteService noteService) {
this.noteService = noteService;
}
@PostMapping
public String insertUpdateNote(Authentication auth, @ModelAttribute Note note, RedirectAttributes redirectAttributes){
User user = (User) auth.getDetails();
note.setUserId(user.getUserId());
if (note.getNoteId() == null) {
noteService.createNote(note);
}else{
noteService.udateNote(note);
}
redirectAttributes.addFlashAttribute("noteMsgOK","Note "+note.getNoteTitle()+" successfully saved");
redirectAttributes.addFlashAttribute("activeTab", "notes");
return "redirect:/home";
}
@PostMapping("/delete")
public String deleteNote (Authentication auth, RedirectAttributes redirectAttributes, @ModelAttribute NoteDTO noteDTO){
noteService.deleteNote(noteDTO.getNoteId());
redirectAttributes.addFlashAttribute("noteMsgOK","Note successfully deleted");
redirectAttributes.addFlashAttribute("activeTab", "notes");
return "redirect:/home";
}
}
| [
"[email protected]"
] | |
238ac30c41fc247839700b74e75fb8ed12e27757 | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/kylin/testing/403/ByteArray.java | 169f5d9323ce7e6737ec36bc60e9d5d6e4b1d2c9 | [] | no_license | ASSERT-KTH/synthetic-checkstyle-error-dataset | 40e8d1e0a7ebe7f7711def96a390891a6922f7bd | 40c057e1669584bfc6fecf789b5b2854660222f3 | refs/heads/master | 2023-03-18T12:50:55.410343 | 2019-01-25T09:54:39 | 2019-01-25T09:54:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,898 | 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.kylin.common.util;
import java.io.Serializable;
import java.nio.ByteBuffer;
/**
* @author yangli9
*/
public class ByteArray implements Comparable<ByteArray>, Serializable {
private static final long serialVersionUID = 1L;
public static ByteArray allocate(int length) {
return new ByteArray(new byte[length]);
}
public static ByteArray copyOf(byte[] array, int offset, int length) {
byte[] space = new byte[length];
System.arraycopy(array, offset, space, 0, length);
return new ByteArray(space, 0, length);
}
// ============================================================================
private byte[] data;
private int offset;
private int length;
public ByteArray() {
this(null, 0, 0);
}
public ByteArray(int capacity) {
this(new byte[capacity], 0, capacity);
}
public ByteArray(byte[] data) {
this(data, 0, data == null ? 0 : data.length);
}
public ByteArray(byte[] data, int offset, int length) {
this.data = data;
this.offset = offset;
this.length = length;
}
public byte[] array() {
return data;
}
public int offset() {
return offset;
}
public int length() {
return length;
}
//notice this will have a length header
public void exportData(ByteBuffer out) {
BytesUtil.writeByteArray(this.data, this.offset, this.length, out);
}
public static ByteArray importData(ByteBuffer in) {
byte[] bytes = BytesUtil.readByteArray(in);
return new ByteArray(bytes);
}
public ByteBuffer asBuffer() {
if (data == null)
return null;
else if (offset == 0 && length == data.length)
return ByteBuffer.wrap(data);
else
return ByteBuffer.wrap(data, offset, length).slice();
}
public byte[] toBytes() {
return Bytes.copy(this.array(), this.offset(), this.length());
}
public void setLength(int pos) {
this .length = pos;
}
public void reset(byte[] data, int offset, int len) {
this.data = data;
this.offset = offset;
this.length = len;
}
public byte get(int i) {
return data[offset + i];
}
@Override
public int hashCode() {
if (data == null) {
return 0;
} else {
if (length <= Bytes.SIZEOF_LONG && length > 0) {
// to avoid hash collision of byte arrays those are converted from nearby integers/longs, which is the case for kylin dictionary
long value = BytesUtil.readLong(data, offset, length);
return (int) (value ^ (value >>> 32));
}
return Bytes.hashCode(data, offset, length);
}
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ByteArray o = (ByteArray) obj;
if (this.data == null && o.data == null)
return true;
else if (this.data == null || o.data == null)
return false;
else
return Bytes.equals(this.data, this.offset, this.length, o.data, o.offset, o.length);
}
@Override
public int compareTo(ByteArray o) {
if (this.data == null && o.data == null)
return 0;
else if (this.data == null)
return -1;
else if (o.data == null)
return 1;
else
return Bytes.compareTo(this.data, this.offset, this.length, o.data, o.offset, o.length);
}
public String toReadableText() {
if (data == null) {
return null;
} else {
return BytesUtil.toHex(data, offset, length);
}
}
@Override
public String toString() {
if (data == null)
return null;
else
return Bytes.toStringBinary(data, offset, length);
}
}
| [
"[email protected]"
] | |
37fdeecb61c76902df624e1d1c507938ab611eab | 95e54d966d7515cce6a1c9639ce2602f6fc4be5d | /src/main/java/com/slin/smvc/service/HelloCxfService.java | f540377cc070d55fa1c8902c80c602240c926180 | [] | no_license | f1008611/WEB-SMVC | e855249a341f0a720557ae7e37d9fa2bbb84daf1 | 2ed3fa615881b94db11849fec301ea5b251d9b63 | refs/heads/master | 2021-01-20T07:09:55.752083 | 2014-06-13T08:34:06 | 2014-06-13T08:34:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 509 | java | package com.slin.smvc.service;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.slin.smvc.Constants;
public interface HelloCxfService {
public String sayHello(@WebParam(name = "name") String name);
public String login(@WebParam(name = "name") String name,@WebParam(name = "password") String password,@WebParam(name = "type") String type);
public String login2(@WebParam(name = "arg0") String arg0,@WebParam(name = "arg1") String arg1,@WebParam(name = "type1") String type1);
}
| [
"[email protected]"
] | |
c29b7e96265d8f205be3e675e8ad9ff76fe5fc98 | b07142fc1054b4a0586ebc866384dd8634fb021b | /grow-code/russia-shape/src/cn/itheima/russia03/entries/ShapeFactory.java | df162c7ffb7c5a7dc090f8b6f6983acfffbd173e | [] | no_license | fengyf-it/repo1 | 1413d135c1f8572513c216cf997d929bce4a15a9 | be8dc8805c961c6e65bc17b098d0afa948253df6 | refs/heads/master | 2020-12-29T15:13:23.939365 | 2020-02-04T04:46:31 | 2020-02-04T04:46:31 | 238,649,752 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 235 | java | package cn.itheima.russia03.entries;
/*
遵循MVC原理
工厂用来生成方块
*/
public class ShapeFactory {
public Shape getShape(){
System.out.println("ShapeFactory's getShape");
return null;
}
}
| [
"[email protected]"
] | |
2fa628c221be78b75bf3ffe20d129828be5b995e | 28e9aa3314109a950b33e3f8fd822f3e8e9dd025 | /src/main/java/com/doverdee/thinkinginjava/initialization/Burrito.java | a51382e273adb02948ce03b9b0d6cb2d1fe8e9ff | [] | no_license | DoverDee/JavaBase | 8778ddc9fb7e7b0eef7bfaac124226948368114f | cde35a8b70665f1eccc6c8b2010abc005676959e | refs/heads/master | 2021-06-08T22:05:28.630454 | 2020-07-26T08:04:33 | 2020-07-26T08:04:33 | 106,983,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 951 | java | package com.doverdee.thinkinginjava.initialization;//: initialization/Burrito.java
public class Burrito {
Spiciness degree;
public Burrito(Spiciness degree) { this.degree = degree;}
public void describe() {
System.out.print("This burrito is ");
switch(degree) {
case NOT: System.out.println("not spicy at all.");
break;
case MILD:
case MEDIUM: System.out.println("a little hot.");
break;
case HOT:
case FLAMING:
default: System.out.println("maybe too hot.");
}
}
public static void main(String[] args) {
Burrito
plain = new Burrito(Spiciness.NOT),
greenChile = new Burrito(Spiciness.MEDIUM),
jalapeno = new Burrito(Spiciness.HOT);
plain.describe();
greenChile.describe();
jalapeno.describe();
}
} /* Output:
This burrito is not spicy at all.
This burrito is a little hot.
This burrito is maybe too hot.
*///:~
| [
"[email protected]"
] | |
a860c27447d263595931d2ff5fb21857a1098770 | b2c74e696ba11d4b359059ebec7b00189db02793 | /app/src/main/java/com/jiaop/jplibs/design/filter/Single.java | 126a6104f4a22aff5781b9c4c53343364973b3d5 | [] | no_license | hiJiaoP/JpLibs | 803fc7d4667159fe256c4c444f3ad4b2ceed7c7c | da60215bbce07301ac1b80079626e52cdeacf6eb | refs/heads/master | 2020-03-22T15:25:01.156942 | 2018-10-16T08:50:05 | 2018-10-16T08:50:05 | 140,250,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 611 | java | package com.jiaop.jplibs.design.filter;
import java.util.ArrayList;
import java.util.List;
/**
* <pre>
* author : jiaop
* time : 2018/7/24
* desc :
* version: 1.0.0
* </pre>
*/
public class Single implements Criteria {
//单身
@Override
public List<Person> meetCriteria(List<Person> persons) {
List<Person> singlePersons = new ArrayList<>();
for (Person person : persons) {
if (person.getMaritalStatus().equalsIgnoreCase("SINGLE")) {
singlePersons.add(person);
}
}
return singlePersons;
}
}
| [
"[email protected]"
] | |
04fe482ca2fc95f4ea5512154d3f298358c50a44 | bc940525ca801390e66877e2aca519f9a4eacdcd | /html_work/PracticeSelf/src/javajungseok/CaptionTv.java | 8322f91e6805b5800c7f7d10291e6e36edf23401 | [] | no_license | gunvv00/Java_practice | 7a98e1f5b7b3afaf91ae8bd4a453b873eee49ed3 | fec8378ccc2a1535bbe7253da9d58c74b81a0306 | refs/heads/master | 2022-12-25T06:36:54.655467 | 2020-02-26T09:04:04 | 2020-02-26T09:04:04 | 232,251,272 | 0 | 0 | null | 2022-12-16T01:02:38 | 2020-01-07T05:43:04 | JavaScript | UTF-8 | Java | false | false | 159 | java | package javajungseok;
class CaptionTv extends Tv {
boolean caption;
void displayCaption(String text) {
if(caption) {
System.out.println(text);
}
}
} | [
"[email protected]"
] | |
32df29c9a6710aa03feab96d2a7a5b3dc4c5f5ae | 791f02c442779ef49944de6a8e7dfd2942d71567 | /code/SudokuSolver.java | e7f2cbe7f132f51d6fb37e91cd27d72fcfd2c579 | [] | no_license | wangsen123/leetcode | 48172e280e9092d1fb49f0bd673ea50f0691d24b | 2c9d133a4f0d82b818a11b13cd2a5628d2d95c8c | refs/heads/master | 2021-01-10T01:36:56.608758 | 2015-10-21T11:29:13 | 2015-10-21T11:29:13 | 44,602,597 | 1 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,740 | java | package code;
//Write a program to solve a Sudoku puzzle by filling the empty cells.
//
//Empty cells are indicated by the character '.'.
//
//You may assume that there will be only one unique solution.
public class SudokuSolver {
public static void main(String[] args) {
// TODO 自动生成的方法存根
}
public void solveSudoku(char[][] board) {
// for(int i=0;i<9;i++)
// for(int j=0;j<9;j++ ){
// if(board[i][j]=='.'){
// for(int k=1;k<=9;k++){
// board[i][j]=(char)('0'+k);
// if(IsValid(board,i,j)&&solveSudoku(board))
// return true;
// board[i][j]='.';
// }
// }
// }
// return false;
solve(board,0);
}
private boolean solve(char[][] board, int position) {
// TODO 自动生成的方法存根
if(position==81)
return true;
int row=position/9;
int col=position%9;
if(board[row][col]=='.'){
for(int i=1;i<=9;i++){
board[row][col]=(char)(i+'0');
if(cheak(board,position))
if(solve(board, position + 1))
return true;
board[row][col]='.';
}
}
else {
if(solve(board,position+1))
return true;
}
return false;
}
private boolean cheak(char[][] board, int position) {
// TODO 自动生成的方法存根
int row = position / 9;
int col = position % 9;
int gid;
if(row >= 0 && row <= 2)
{
if(col >= 0 && col <= 2)
gid = 0;
else if(col >= 3 && col <= 5)
gid = 1;
else
gid = 2;
}
else if(row >= 3 && row <= 5)
{
if(col >= 0 && col <= 2)
gid = 3;
else if(col >= 3 && col <= 5)
gid = 4;
else
gid = 5;
}
else
{
if(col >= 0 && col <= 2)
gid = 6;
else if(col >= 3 && col <= 5)
gid = 7;
else
gid = 8;
}
//check row, col, subgrid
for(int i = 0; i < 9; i ++)
{
//check row
if(i != col && board[row][i] == board[row][col])
return false;
//check col
if(i != row && board[i][col] == board[row][col])
return false;
//check subgrid
int r = gid/3*3+i/3;
int c = gid%3*3+i%3;
if((r != row || c != col) && board[r][c] == board[row][col])
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
5dc3634e0a05f01fa0e2a7b73db37ed134d3e492 | 31facd7f2f895cabbc2000cfb84c2b2fdf1bc254 | /kylin-spark-project/kylin-spark-engine/src/test/java/org/apache/kylin/engine/spark/job/JobStepFactoryTest.java | b29b09b418f6af82d4e6aab66b73438b7290e2de | [
"Apache-2.0",
"GPL-2.0-only",
"MIT"
] | permissive | zhangayqian/kylin-on-parquet-v2 | d8f53cdbcdf4745042a00eb5bfa2cfdcdc304f18 | 8c91814ec458a8d25baa31aad62d126123c275b9 | refs/heads/master | 2022-09-18T11:54:13.494593 | 2020-05-06T09:39:38 | 2020-05-07T02:12:10 | 262,019,667 | 0 | 0 | Apache-2.0 | 2020-05-07T10:26:59 | 2020-05-07T10:26:58 | null | UTF-8 | Java | false | false | 7,135 | 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.kylin.engine.spark.job;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.cube.CubeInstance;
import org.apache.kylin.cube.CubeManager;
import org.apache.kylin.cube.CubeSegment;
import org.apache.kylin.cube.CubeUpdate;
import org.apache.kylin.engine.spark.LocalWithSparkSessionTest;
import org.apache.kylin.job.constant.ExecutableConstants;
import org.apache.kylin.job.exception.SchedulerException;
import org.apache.kylin.metadata.MetadataConstants;
import org.apache.kylin.metadata.model.SegmentRange;
import org.apache.kylin.metadata.model.SegmentStatusEnum;
import org.apache.kylin.metadata.model.Segments;
import org.junit.Assert;
import org.junit.Test;
import org.spark_project.guava.collect.Sets;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class JobStepFactoryTest extends LocalWithSparkSessionTest {
private KylinConfig config;
private static final String CUBE_NAME = "ci_left_join_cube";
@Override
public void setup() throws SchedulerException {
super.setup();
config = getTestConfig();
}
@Override
public void after() {
super.after();
}
@Test
public void testAddStepInCubing() throws IOException {
CubeManager cubeMgr = CubeManager.getInstance(config);
CubeInstance cube = cubeMgr.getCube(CUBE_NAME);
cleanupSegments(CUBE_NAME);
CubeSegment oneSeg = cubeMgr.appendSegment(cube, new SegmentRange.TSRange(0L, Long.MAX_VALUE));
Set<CubeSegment> segments = Sets.newHashSet(oneSeg);
NSparkCubingJob job = NSparkCubingJob.create(segments, "ADMIN");
Assert.assertEquals(CUBE_NAME, job.getParam(MetadataConstants.P_CUBE_NAME));
NSparkExecutable resourceDetectStep = job.getResourceDetectStep();
Assert.assertEquals(ResourceDetectBeforeCubingJob.class.getName(),
resourceDetectStep.getSparkSubmitClassName());
Assert.assertEquals(ExecutableConstants.STEP_NAME_DETECT_RESOURCE, resourceDetectStep.getName());
job.getParams().forEach((key, value) -> Assert.assertEquals(value, resourceDetectStep.getParam(key)));
Assert.assertEquals(config.getJobTmpMetaStoreUrl(getProject(), resourceDetectStep.getId()).toString(),
resourceDetectStep.getDistMetaUrl());
NSparkExecutable cubeStep = job.getSparkCubingStep();
Assert.assertEquals(config.getSparkBuildClassName(), cubeStep.getSparkSubmitClassName());
Assert.assertEquals(ExecutableConstants.STEP_NAME_BUILD_SPARK_CUBE, cubeStep.getName());
job.getParams().forEach((key, value) -> Assert.assertEquals(value, cubeStep.getParam(key)));
Assert.assertEquals(config.getJobTmpMetaStoreUrl(getProject(), cubeStep.getId()).toString(),
cubeStep.getDistMetaUrl());
}
@Test
public void testAddStepInMerging() throws Exception {
CubeManager cubeMgr = CubeManager.getInstance(config);
CubeInstance cube = cubeMgr.getCube(CUBE_NAME);
cleanupSegments(CUBE_NAME);
/**
* Round1. Add 2 segment
*/
CubeSegment segment1 = cubeMgr.appendSegment(cube, new SegmentRange.TSRange(dateToLong("2010-01-01"), dateToLong("2013-01-01")));
CubeSegment segment2 = cubeMgr.appendSegment(cube, new SegmentRange.TSRange(dateToLong("2013-01-01"), dateToLong("2015-01-01")));
segment1.setStatus(SegmentStatusEnum.READY);
segment2.setStatus(SegmentStatusEnum.READY);
CubeInstance reloadCube = cube.latestCopyForWrite();
Segments segments = new Segments();
segments.add(segment1);
segments.add(segment2);
reloadCube.setSegments(segments);
CubeUpdate update = new CubeUpdate(reloadCube);
cubeMgr.updateCube(update);
/**
* Round2. Merge two segments
*/
reloadCube = cubeMgr.reloadCube(CUBE_NAME);
CubeSegment mergedSegment = cubeMgr.mergeSegments(reloadCube, new SegmentRange.TSRange(dateToLong("2010-01-01"), dateToLong("2015-01-01"))
, null, true);
NSparkMergingJob job = NSparkMergingJob.merge(mergedSegment, "ADMIN");
Assert.assertEquals(CUBE_NAME, job.getParam(MetadataConstants.P_CUBE_NAME));
NSparkExecutable resourceDetectStep = job.getResourceDetectStep();
Assert.assertEquals(ResourceDetectBeforeMergingJob.class.getName(),
resourceDetectStep.getSparkSubmitClassName());
Assert.assertEquals(ExecutableConstants.STEP_NAME_DETECT_RESOURCE, resourceDetectStep.getName());
job.getParams().forEach((key, value) -> Assert.assertEquals(value, resourceDetectStep.getParam(key)));
Assert.assertEquals(config.getJobTmpMetaStoreUrl(getProject(), resourceDetectStep.getId()).toString(),
resourceDetectStep.getDistMetaUrl());
NSparkExecutable mergeStep = job.getSparkMergingStep();
Assert.assertEquals(config.getSparkMergeClassName(), mergeStep.getSparkSubmitClassName());
Assert.assertEquals(ExecutableConstants.STEP_NAME_MERGER_SPARK_SEGMENT, mergeStep.getName());
job.getParams().forEach((key, value) -> Assert.assertEquals(value, mergeStep.getParam(key)));
Assert.assertEquals(config.getJobTmpMetaStoreUrl(getProject(), mergeStep.getId()).toString(),
mergeStep.getDistMetaUrl());
CubeInstance cubeInstance = cubeMgr.reloadCube(CUBE_NAME);
NSparkUpdateMetaAndCleanupAfterMergeStep cleanStep = job.getCleanUpAfterMergeStep();
job.getParams().forEach((key, value) -> {
if (key.equalsIgnoreCase(MetadataConstants.P_SEGMENT_IDS)) {
final List<String> needDeleteSegmentNames = cubeInstance.getMergingSegments(mergedSegment).stream()
.map(CubeSegment::getName).collect(Collectors.toList());
Assert.assertEquals(needDeleteSegmentNames, Arrays.asList(cleanStep.getParam(MetadataConstants.P_SEGMENT_NAMES).split(",")));
} else {
Assert.assertEquals(value, mergeStep.getParam(key));
}
});
Assert.assertEquals(config.getJobTmpMetaStoreUrl(getProject(), cleanStep.getId()).toString(),
cleanStep.getDistMetaUrl());
}
}
| [
"[email protected]"
] | |
35f7f55832bf121386b93040a11422e6cecc8872 | 3c3836785935c76dd21c94259f35cfd88584b1e5 | /sbs0819/boot-bmodule0101/src/main/java/com/boot/study/util/ValidatorUtil.java | 889fb788c5d2b0d40299738565c611dcfcaede65 | [
"Apache-2.0"
] | permissive | huaxueyihao/practise-project | 24a79992fa4831f0d6b618057f316d11c2c7b01f | 649bf47e14b891706bcb9c802dfd6af0e32f802c | refs/heads/master | 2022-06-22T22:56:00.687453 | 2019-12-06T08:28:20 | 2019-12-06T08:28:20 | 197,588,318 | 3 | 1 | Apache-2.0 | 2022-06-21T01:28:52 | 2019-07-18T13:04:01 | JavaScript | UTF-8 | Java | false | false | 1,362 | java | package com.boot.study.util;
import com.boot.study.exeception.BusinessException;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.groups.Default;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 参数校验器
*/
public class ValidatorUtil {
public static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
public static void validator(Object obj) {
Set<ConstraintViolation<Object>> set = validator.validate(obj);
set.forEach(constraint -> {
throw new BusinessException(100, constraint.getMessage());
});
}
public static void validatorProperties(Object obj, String... property) {
if (Objects.nonNull(property) && property.length > 0) {
Set<ConstraintViolation<Object>> set = Stream.of(property).flatMap(
item -> validator.validateProperty(obj, item, Default.class
).stream()).collect(Collectors.toSet());
if (Objects.nonNull(set) && set.size() > 0) {
set.forEach(constraint -> {
throw new BusinessException(100, constraint.getMessage());
});
}
}
}
}
| [
"[email protected]"
] | |
bba621c6d0bd0d2bd41078231157b94c066361ae | 2a8a7238a8f2ccb8f1aff88cd9ea7dd01cefdaec | /Mobile/APP/Play Style 0.1ver/MusicStyleList/src/com/funny/developers/musicstylelist/database/UserPlayListDBHelper.java | 01c41eae031b76b96f1d387c1a54ea7fa26630b4 | [] | no_license | mandumeans/MusicStyle-List | b9977ba58940fc5ebcbb4f076362485820edf61e | d788ea3b232b623520a16c0fdd63fff3ba9a362f | refs/heads/master | 2021-01-20T21:29:19.088649 | 2015-04-24T02:37:43 | 2015-04-24T02:37:43 | 23,391,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,431 | java | package com.funny.developers.musicstylelist.database;
import com.funny.developers.musicstylelist.dao.UserFoldersDao;
import com.funny.developers.musicstylelist.dao.UserPlayListDao;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
public class UserPlayListDBHelper extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final String DATABASE_NAME = "PlayStyle.db";
private static SQLiteDatabase db = null;
private Context mContext = null;
public UserPlayListDBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.mContext = context;
}
public static UserPlayListDBHelper mInstance = null;
public static UserPlayListDBHelper getInstance(Context context) {
if (mInstance == null) {
synchronized (UserPlayListDBHelper.class) {
if (mInstance == null) {
mInstance = new UserPlayListDBHelper(context);
try {
db = mInstance.getWritableDatabase();
} catch(SQLiteException se) {
se.getStackTrace();
}
}
}
}
return mInstance;
}
public void close() {
if(mInstance != null) {
db.close();
mInstance = null;
}
}
private static final String CREATE_TABLE_USER_FOLDERS = "create table "+ UserFoldersDao.TABLE_NAME +" (" +
UserFoldersDao.NO + " integer primary key autoincrement," +
UserFoldersDao.FOLDER_NAME + " text not null)";
private static final String CREATE_TABLE_USER_PLAY_LIST = "create table "+ UserPlayListDao.TABLE_NAME +" (" +
UserPlayListDao.NO + " integer primary key autoincrement," +
UserPlayListDao.ID + " text not null,"+
UserPlayListDao.TITLE + " text not null,"+
UserPlayListDao.THUMBNAIL + " text not null,"+
UserPlayListDao.DURATION + " integer default 0,"+
UserPlayListDao.TRACK_TYPE + " integer,"+
UserPlayListDao.UPLOADER + " text not null,"+
UserPlayListDao.ONLY_YOUTUBE + " integer default 0,"+
UserPlayListDao.FOLDER_NO + " integer,"+
"FOREIGN KEY(" + UserPlayListDao.FOLDER_NO + ") REFERENCES " +
UserFoldersDao.TABLE_NAME + "(" + UserFoldersDao.NO + ") ON DELETE CASCADE)";
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_USER_FOLDERS);
db.execSQL(CREATE_TABLE_USER_PLAY_LIST);
}
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
if(!db.isReadOnly()){
db.execSQL("PRAGMA foreign_keys=ON;");
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table if exists " + UserFoldersDao.TABLE_NAME);
db.execSQL("drop table if exists " + UserPlayListDao.TABLE_NAME);
onCreate(db);
}
public Cursor getData(String table, String[] columns) {
return db.query(table, columns, null, null, null, null, null);
}
public Cursor getData(String sql) {
return db.rawQuery(sql, null);
}
public long insert(String table, ContentValues values) {
return db.insert(table, null, values);
}
public long update(String table, ContentValues values, String whereClause) {
return db.update(table, values, whereClause, null);
}
public long delete(String table, String whereClause) {
return db.delete(table, whereClause, null);
}
}
| [
"[email protected]"
] | |
e1b64c8ff90c3b0141af84b5d88791046162783a | 76cfa3ddb10af6669ba8dc4561d043f7ca43e259 | /edu/jalc/inclass/cocacola/color/RGBColor.java | e146f1eae9618aef8e3aa0284ec96a12c39c433a | [] | no_license | ClarkLindsay/cps206 | 7a44691c6ce98ec197a79934ad4ef09c9530afad | ed05f941e1d48b965bb484b45945d1246d38f316 | refs/heads/master | 2021-01-19T13:46:37.399237 | 2017-02-25T01:41:07 | 2017-02-25T01:41:07 | 82,187,141 | 1 | 0 | null | 2017-02-16T14:06:51 | 2017-02-16T14:06:51 | null | UTF-8 | Java | false | false | 459 | java | package edu.jalc.inclass.cocacola.color;
public class RGBColor {
private final byte red;
private final byte green;
private final byte blue;
private RGBColor(){
this.red = this.green = this.blue = 0;
}
public RGBColor(byte red, byte green, byte blue){
this.red = red;
this.green = green;
this.blue = blue;
}
public byte getRed() {
return red;
}
public byte getGreen() {
return green;
}
public byte getBlue() {
return blue;
}
}
| [
"[email protected]"
] | |
1e4dcb628f613bea9a014053bad8d1de82f2ec82 | e26e12776574b476a4b4460c88de53788d3d13cf | /Assignments/Smoothie.java | 147aef8e0cc7bbe5ca828299424ad6774a906231 | [] | no_license | thymetime/CMSC203_OKitila | f8da662a37e5e6593a62b62117c857edbe498d2a | 73ea1914fb408a2564af3d73cf888633edb269b5 | refs/heads/main | 2023-04-20T11:21:45.201269 | 2021-05-16T12:32:23 | 2021-05-16T12:32:23 | 333,102,695 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,498 | java |
public class Smoothie extends Beverage {
boolean proteinPowder;
int fruits;
public Smoothie(String n, TYPE.type t, SIZE.size s, int f, boolean p) {
super(n, t, s);
this.fruits = f;
this.proteinPowder = p;
// TODO Auto-generated constructor stub
}
public Smoothie(String n, SIZE.size s, int f, boolean p) {
super(n, TYPE.type.SMOOTHIE, s);
this.fruits = f;
this.proteinPowder = p;
// TODO Auto-generated constructor stub
}
@Override
double calcPrice() {
double bevPrice = basePrice;
if (this.beverageSize == SIZE.size.MEDIUM)
bevPrice += sizePrice;
if (this.beverageSize == SIZE.size.LARGE)
bevPrice += (2 * sizePrice);
if (proteinPowder)
bevPrice += 1.50;
bevPrice += (fruits * 0.50);
return bevPrice;
}
public String toString() {
return super.toString() + ", Fruits: " + this.fruits + ", Protein Powder: " + this.proteinPowder + ", Price: " + this.calcPrice();
}
public boolean equals(Smoothie bev) {
boolean equal = false;
if (super.equals(bev) &&
(this.fruits == bev.fruits) &&
(this.proteinPowder == bev.proteinPowder)
)
return true;
return equal;
}
public boolean getProteinPowder() {
return proteinPowder;
}
public void setProteinPowder(boolean proteinPowder) {
this.proteinPowder = proteinPowder;
}
public int getFruits() {
return fruits;
}
public void setFruits(int fruits) {
this.fruits = fruits;
}
public double getBasePrice() {
return this.basePrice;
}
}
| [
"[email protected]"
] | |
58388a8cff648ce554cc16a0a792ca4df2c48a6e | 6073e54e94743271dbfc21115bee170f9e212666 | /src/main/java/hu/takefive/gimmeme/services/UpdateViewBuilder.java | 5411e615dd5bdb7982c1e15125ea9618a0b2b113 | [] | no_license | rabizoltan/gimmeme | 30e8c78fa269048841cb4c1ddb176fe569dc004b | afc798c83b54603738ccce9356fdaa2cdff353c5 | refs/heads/master | 2023-04-13T02:05:24.714507 | 2021-04-30T08:44:27 | 2021-04-30T08:44:27 | 361,863,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 196 | java | package hu.takefive.gimmeme.services;
import com.slack.api.model.view.View;
@FunctionalInterface
public interface UpdateViewBuilder<String> {
View buildUpdateView(String privateMetadata);
}
| [
"[email protected]"
] | |
32c739a6580027c2945c4d446d9380085958c379 | bba490c4f1c68fd09b8e85aa7b2424093cac7406 | /Project/Client/Moment/app/src/main/java/net/onest/moment/activity/MyFangJian.java | 7ce830bdf8a74f5aa2fa7cb9aeba31db0cac02cf | [] | no_license | Qzz0514/ACupOfJava | e4d2e85133adddec131504cd71fd2fcab7793ce8 | 23dcd5d105f4d74848372ad51957501e28b65079 | refs/heads/main | 2023-04-10T05:46:06.157773 | 2020-12-10T00:47:53 | 2020-12-10T00:47:53 | 306,031,789 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,071 | java | package net.onest.moment.activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Outline;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.ViewOutlineProvider;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.youth.banner.Banner;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import net.onest.moment.R;
import net.onest.moment.adapter.RoomAdapter;
import net.onest.moment.entity.ImageBox;
import net.onest.moment.entity.Room;
import net.onest.moment.manager.ServerConfig;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class MyFangJian extends AppCompatActivity{
private TextView shop_name;
private TextView shop_like;
private TextView shop_star;
private TextView shop_location;
private ImageView shop_image;
private ImageButton ibKefu1;
private OkHttpClient okHttpClient;
private Banner banner;
private View view;
private TextView textView;
private List<Room> rooms;
private Button button;
private ImageButton imageButton2;
private ListView listView;
private Handler myHandler = new Handler() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void handleMessage(@NonNull Message msg) {
switch (msg.what) {
case 1:
List<Room> list = (List<Room>) msg.obj;
RoomAdapter adapter =new RoomAdapter(MyFangJian.this,list, R.layout.myfangjian_item);
listView.setAdapter(adapter);
break;
case 3:
List<ImageBox> imageBox = (List<ImageBox>) msg.obj;
Log.e("handleMessage: ImageBox",imageBox.toString() );
banner.setAdapter(new BannerImageAdapter<ImageBox>(imageBox) {
@Override
public void onBindView(BannerImageHolder holder, ImageBox data, int position, int size) {
Glide.with(holder.itemView)
.load(ServerConfig.SERVER_HOME+"shop/bannerImages?image="+data.getImgName()+"&shop_id="+data.getShopId())
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.placeholder(R.drawable.aaa)
.error(R.drawable.aaa)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(30)))
.into(holder.imageView);
}
});
banner.start();
banner.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 60);
}
});
banner.setClipToOutline(true);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myfangjian);
shop_name = findViewById(R.id.shop_name);
shop_like = findViewById(R.id.shop_like);
shop_location = findViewById(R.id.shop_location);
shop_star = findViewById(R.id.shop_star);
banner = findViewById(R.id.banner);
listView =findViewById(R.id.list1);
ibKefu1 = findViewById(R.id.kefu1);
ibKefu1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = getIntent();
String shop_id = intent.getStringExtra("shop_id");
String shop_name = intent.getStringExtra("shop_name");
String shop_image = intent.getStringExtra("shop_image");
Intent intent1 = new Intent();
intent1.setClass(MyFangJian.this,ChatDetailActivity.class);
intent1.putExtra("shop_id", shop_id);
intent1.putExtra("shop_image", shop_image);
intent1.putExtra("shop_name", shop_name);
startActivity(intent1);
}
});
imageButton2 =findViewById(R.id.more1);
imageButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Intent intent = getIntent();
String shop_id = intent.getStringExtra("shop_id");
String user_id = "2";//由其他页面传过来,这里暂时用固定值
URL url = new URL(ServerConfig.SERVER_HOME+"shop/addCollection?user_id="+user_id+"&shop_id="+shop_id);
InputStream is = url.openStream();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
ArrayList<Integer> images = new ArrayList<>();
ArrayList<String> title = new ArrayList<>();
title.add("1");
title.add("2");
title.add("3");
images.add(R.drawable.aaa);
images.add(R.drawable.aaa);
images.add(R.drawable.aaa);
Intent intent = getIntent();
String shopName = intent.getStringExtra("shop_name");
String shopLike = intent.getStringExtra("shop_likes");
String shopStar = intent.getStringExtra("shop_stars");
String shopLocation = intent.getStringExtra("shop_location");
shop_name.setText(shopName);
shop_like.setText(shopLike+"");
shop_star.setText(shopStar+"");
shop_location.setText(shopLocation);
button = findViewById(R.id.yuyue);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = getIntent();
final String shop_id = intent.getStringExtra("shop_id");
final String user_id = "2";//由其他页面传过来,这里暂时用固定值
final int stars = intent.getIntExtra("shop_stars",0) + 1;
Log.e( "onClick: stars", stars + "");
new Thread() {
@Override
public void run() {
try {
URL url = new URL(ServerConfig.SERVER_HOME + "shop/addAppointment?user_id=" + user_id + "&shop_id=" + shop_id);
InputStream is = url.openStream();
URL url1 = new URL(ServerConfig.SERVER_HOME + "shop/updateLikes?shop_id=" + shop_id+"&newStars="+stars);
InputStream is1 = url1.openStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}.start();
Intent intent1 = new Intent();
intent1.setClass(MyFangJian.this,SeatActivity.class);
startActivity(intent1);
}
});
initOkHttpClient();
simpStringParamPostRequest();
downloadBanner();
}
private void downloadBanner() {
Intent intent = getIntent();
String shop_id = intent.getStringExtra("shop_id");
Log.e("downloadBanner: ", shop_id);
Request request = new Request.Builder()
.url(ServerConfig.SERVER_HOME + "shop/banner?shop_id="+shop_id)
.get()
.build();
//3. 创建CALL对象
Call call = okHttpClient.newCall(request);
//4. 提交请求并获取响应
call.enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
Log.e("sq", "请求失败");
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
String result = response.body().string();
Log.e("onResponse: ", result);
Gson gson = new Gson();
List<ImageBox> imageBoxes = gson.fromJson(result,new TypeToken<List<ImageBox>>(){}.getType());
Message msg = myHandler.obtainMessage();
msg.what = 3;
msg.obj = imageBoxes;
myHandler.sendMessage(msg);
}
});
}
private void initOkHttpClient() {
okHttpClient = new OkHttpClient();
}
private void simpStringParamPostRequest() {
Intent intent = getIntent();
String id = intent.getStringExtra("shop_id");
Log.e("run: ", id+"");
//1.创建RequestBody对象
//2.创建请求对象
Request request = new Request.Builder()
.url(ServerConfig.SERVER_HOME + "room/roomList?shop_id="+id)
.get()
.build();
//3. 创建CALL对象
Call call = okHttpClient.newCall(request);
//4. 提交请求并获取响应
call.enqueue(new Callback() {
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) {
Log.e("sq", "请求失败");
}
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
String result = response.body().string();
Log.e("onResponse: ", result);
Gson gson = new Gson();
List<Room> rooms = gson.fromJson(result,new TypeToken<List<Room>>(){}.getType());
Message msg = myHandler.obtainMessage();
msg.what = 1;
msg.obj = rooms;
myHandler.sendMessage(msg);
}
});
}
} | [
"[email protected]"
] | |
e17f795251e0ad95f3e1da139376e60efab6fc07 | 059cec41be91e0097e6e55ed2e40e5e17ac9e944 | /Backtrack/src/Match/eighth.java | 328df6621dc0dbe052c19cec5c936e056e28a5ad | [] | no_license | Wb-Alpha/Algorithm | eb48aa676876bc3e922c62b04861f332b746b407 | 59df58a71d32322ef2b616f51ba0abe8ef02e28a | refs/heads/master | 2023-03-11T05:47:29.266039 | 2021-02-24T04:14:06 | 2021-02-24T04:14:06 | 266,783,732 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 705 | java | package Match;
import java.util.*;
public class eighth {
static int[][] space;
public static void main(String[] args) {
int in = 0, count = 0;
Scanner reader = new Scanner(System.in);
in = reader.nextInt();
space = new int [in+1][in+1];
for (int i = 1; i<=in; i++) {
space[i][i] = 1;
space[i][0] = 1;
space[0][i] = 1;
}
for (int i = 1; i <= in; i++) {
count += solve(in, i);
count %= 10000;
}
System.out.println(count);
}
public static int solve(int x, int y) {
if(space[x][y] != 0)
return space[x][y];
for (int i = Math.abs(x-y) - 1; i >= 0; i--)
space[x][y] += solve(y, i);
space[x][y] %= 10000;
space[y][x] = space[x][y];
return space[x][y];
}
}
| [
"[email protected]"
] | |
aa157f50f7214a23d680557e0e9ce8fb28aa82f6 | 24552f2c77fce349fe21f6302e9bc3393a2a424c | /src/Test3.java | 2937323720ec7a5fa2a6ef7d4337ae7cf14af53c | [] | no_license | Zikirov/Safarbeg- | 47ea4539b516c60261643fd6acad0c8fd22a3ee0 | 89afa045cf95093347d7ea945f605d76191873be | refs/heads/master | 2023-06-05T17:42:17.980129 | 2021-06-17T23:38:37 | 2021-06-17T23:38:37 | 377,335,235 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 211 | java | public class Test3 {
public static void main(String[] args) {
String name="Sheri nar";
System.out.println(name+" My practice 2 ");
System.out.println("my name is safarbeg");
}
}
| [
"[email protected]"
] | |
757bdbb0e296d8648096b7f20f7989db667fb479 | 156a331ed8c9e1b6e8d4c4575f6c6660fd20975d | /final/src/main/java/com/example/controller/HomeController.java | a0d3b2d661fe57e7d322d1248a8428aad9fa5907 | [] | no_license | jang-hyun/Git-ExpressBus | 36bf87bb20033ee961391271e692b93e513ded5a | 53b5114b6d0b14eac0d6758e86da7bf1fd0e826f | refs/heads/master | 2023-02-13T01:51:17.862572 | 2021-01-15T07:50:18 | 2021-01-15T07:50:18 | 324,956,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,244 | java | package com.example.controller;
import java.util.Locale;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.WebUtils;
import com.example.mapper_oracle.UserMapper;
@Controller
public class HomeController {
@Autowired
UserMapper uMapper;
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home(Locale locale, Model model, HttpServletRequest request) {
Cookie cookie = WebUtils.getCookie(request, "user_id");
HttpSession session = request.getSession();
if (cookie != null) {
session.setAttribute("LoginVO", uMapper.login(cookie.getValue()));
}
String dest = (String) session.getAttribute("dest");
session.removeAttribute("dest");
return dest == null ? "home" : "redirect:" + dest;
}
@RequestMapping("/")
public String home() {
return "redirect:/home";
}
@RequestMapping("/test")
public void test() {
}
}
| [
"[email protected]"
] | |
a39bbc87397638ed18b693512a65aff407cb91a0 | 08a69a94bc136b53f9ccf0a10df7be60b472f324 | /src/main/java/it/algos/springvaadin/service/ATextService.java | 4887d379691b25df7825b047a23ef25773bd2527 | [] | no_license | algos-soft/springvaadin | 009a5600444280b7780d206002a0164679e2e5e0 | 99df63c86ab0b44f26f32ef7331ba80b61c6d0c3 | refs/heads/master | 2021-07-21T06:31:50.401010 | 2018-03-09T14:10:19 | 2018-03-09T14:10:19 | 93,712,658 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,798 | java | package it.algos.springvaadin.service;
import com.vaadin.spring.annotation.SpringComponent;
import it.algos.springvaadin.enumeration.EAFirstChar;
import it.algos.springvaadin.enumeration.EAPrefType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
/**
* Project springvaadin
* Created by Algos
* User: gac
* Date: gio, 07-dic-2017
* Time: 13:45
* Classe di Libreria
* Gestione e formattazione di stringhe di testo
*/
@Slf4j
@SpringComponent
@Scope("singleton")
public class ATextService {
/**
* Null-safe, short-circuit evaluation.
*
* @param stringa in ingresso da controllare
*
* @return vero se la stringa è vuota o nulla
*/
public boolean isEmpty(final String stringa) {
return stringa == null || stringa.trim().isEmpty();
}// end of method
/**
* Null-safe, short-circuit evaluation.
*
* @param stringa in ingresso da controllare
*
* @return vero se la stringa esiste è non è vuota
*/
public boolean isValid(final String stringa) {
return !isEmpty(stringa);
}// end of method
/**
* Controlla che sia una stringa e che sia valida.
*
* @param obj in ingresso da controllare
*
* @return vero se la stringa esiste è non è vuota
*/
public boolean isValid(final Object obj) {
if (obj instanceof String) {
return !isEmpty((String) obj);
} else {
return false;
}// end of if/else cycle
}// end of method
/**
* Forza il primo carattere della stringa secondo il flag
* <p>
* Se la stringa è nulla, ritorna un nullo
* Se la stringa è vuota, ritorna una stringa vuota
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
* @param flag maiuscolo o minuscolo
*
* @return uscita string in uscita
*/
private String primoCarattere(final String testoIn, EAFirstChar flag) {
String testoOut = testoIn.trim();
String primo;
String rimanente;
if (this.isValid(testoOut)) {
primo = testoOut.substring(0, 1);
switch (flag) {
case maiuscolo:
primo = primo.toUpperCase();
break;
case minuscolo:
primo = primo.toLowerCase();
break;
default: // caso non definito
break;
} // fine del blocco switch
rimanente = testoOut.substring(1);
testoOut = primo + rimanente;
}// fine del blocco if
return testoOut.trim();
}// end of method
/**
* Forza il primo carattere della stringa al carattere maiuscolo
* <p>
* Se la stringa è nulla, ritorna un nullo
* Se la stringa è vuota, ritorna una stringa vuota
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
*
* @return test formattato in uscita
*/
public String primaMaiuscola(final String testoIn) {
return primoCarattere(testoIn, EAFirstChar.maiuscolo);
}// end of method
/**
* Forza il primo carattere della stringa al carattere minuscolo
* <p>
* Se la stringa è nulla, ritorna un nullo
* Se la stringa è vuota, ritorna una stringa vuota
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
*
* @return test formattato in uscita
*/
public String primaMinuscola(final String testoIn) {
return primoCarattere(testoIn, EAFirstChar.minuscolo);
}// end of method
/**
* Elimina dal testo il tagIniziale, se esiste
* <p>
* Esegue solo se il testo è valido
* Se tagIniziale è vuoto, restituisce il testo
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
* @param tagIniziale da eliminare
*
* @return test ridotto in uscita
*/
public String levaTesta(final String testoIn, String tagIniziale) {
String testoOut = testoIn.trim();
if (this.isValid(testoOut) && this.isValid(tagIniziale)) {
tagIniziale = tagIniziale.trim();
if (testoOut.startsWith(tagIniziale)) {
testoOut = testoOut.substring(tagIniziale.length());
}// fine del blocco if
}// fine del blocco if
return testoOut.trim();
}// end of method
/**
* Elimina dal testo il tagFinale, se esiste
* <p>
* Esegue solo se il testo è valido
* Se tagFinale è vuoto, restituisce il testo
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
* @param tagFinale da eliminare
*
* @return test ridotto in uscita
*/
public String levaCoda(final String testoIn, String tagFinale) {
String testoOut = testoIn.trim();
if (this.isValid(testoOut) && this.isValid(tagFinale)) {
tagFinale = tagFinale.trim();
if (testoOut.endsWith(tagFinale)) {
testoOut = testoOut.substring(0, testoOut.length() - tagFinale.length());
}// fine del blocco if
}// fine del blocco if
return testoOut.trim();
}// end of method
/**
* Elimina il testo da tagFinale in poi
* <p>
* Esegue solo se il testo è valido
* Se tagInterrompi è vuoto, restituisce il testo
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso
* @param tagInterrompi da dove inizia il testo da eliminare
*
* @return test ridotto in uscita
*/
public String levaCodaDa(final String testoIn, String tagInterrompi) {
String testoOut = testoIn.trim();
if (this.isValid(testoOut) && this.isValid(tagInterrompi)) {
tagInterrompi = tagInterrompi.trim();
if (testoOut.contains(tagInterrompi)) {
testoOut = testoOut.substring(0, testoOut.lastIndexOf(tagInterrompi));
}// fine del blocco if
}// fine del blocco if
return testoOut.trim();
}// end of methodlevaCodaDa
/**
* Sostituisce nel testo tutte le occorrenze di oldTag con newTag.
* Esegue solo se il testo è valido
* Esegue solo se il oldTag è valido
* newTag può essere vuoto (per cancellare le occorrenze di oldTag)
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso da elaborare
* @param oldTag da sostituire
* @param newTag da inserire
*
* @return testo modificato
*/
public String sostituisce(final String testoIn, String oldTag, String newTag) {
String testoOut = "";
String prima = "";
String rimane = testoIn;
int pos = 0;
if (this.isValid(testoIn) && this.isValid(oldTag)) {
if (rimane.contains(oldTag)) {
pos = rimane.indexOf(oldTag);
while (pos != -1) {
pos = rimane.indexOf(oldTag);
if (pos != -1) {
prima += rimane.substring(0, pos);
prima += newTag;
pos += oldTag.length();
rimane = rimane.substring(pos);
}// fine del blocco if
}// fine di while
testoOut = prima + rimane;
}// fine del blocco if
}// fine del blocco if
return testoOut.trim();
}// end of method
/**
* Inserisce nel testo alla posizione indicata
* Esegue solo se il testo è valido
* Esegue solo se il newTag è valido
* Elimina spazi vuoti iniziali e finali
*
* @param testoIn ingresso da elaborare
* @param newTag da inserire
* @param pos di inserimento
*
* @return testo modificato
*/
public String inserisce(String testoIn, String newTag, int pos) {
String testoOut = testoIn;
String prima = "";
String dopo = "";
if (this.isValid(testoIn) && this.isValid(newTag)) {
prima = testoIn.substring(0, pos);
dopo = testoIn.substring(pos );
testoOut = prima + newTag + dopo;
}// fine del blocco if
return testoOut.trim();
}// end of method
public boolean isNumber(String value) {
boolean status = true;
char[] caratteri = value.toCharArray();
for (char car : caratteri) {
if (isNotNumber(car)) {
status = false;
}// end of if cycle
}// end of for cycle
return status;
}// end of method
private boolean isNotNumber(char ch) {
return !isNumber(ch);
}// end of method
private static boolean isNumber(char ch) {
return ch >= '0' && ch <= '9';
}// end of method
public String getModifiche(Object oldValue, Object newValue) {
return getModifiche(oldValue, newValue, EAPrefType.string);
} // fine del metodo
public String getModifiche(Object oldValue, Object newValue, EAPrefType type) {
String tatNew = "Aggiunto: ";
String tatEdit = "Modificato: ";
String tatDel = "Cancellato: ";
String tagSep = " -> ";
if (oldValue == null && newValue == null) {
return "";
}// end of if cycle
if (oldValue instanceof String && newValue instanceof String) {
if (this.isEmpty((String) oldValue) && isEmpty((String) newValue)) {
return "";
}// end of if cycle
if (isValid((String) oldValue) && isEmpty((String) newValue)) {
return tatDel + oldValue.toString();
}// end of if cycle
if (isEmpty((String) oldValue) && isValid((String) newValue)) {
return tatNew + newValue.toString();
}// end of if cycle
if (!oldValue.equals(newValue)) {
return tatEdit + oldValue.toString() + tagSep + newValue.toString();
}// end of if cycle
} else {
if (oldValue != null && newValue != null && oldValue.getClass() == newValue.getClass()) {
if (!oldValue.equals(newValue)) {
if (oldValue instanceof byte[]) {
try { // prova ad eseguire il codice
return tatEdit + type.bytesToObject((byte[]) oldValue) + tagSep + type.bytesToObject((byte[]) newValue);
} catch (Exception unErrore) { // intercetta l'errore
log.error(unErrore.toString() + " LibText.getDescrizione() - Sembra che il PrefType non sia del tipo corretto");
return "";
}// fine del blocco try-catch
} else {
return tatEdit + oldValue.toString() + tagSep + newValue.toString();
}// end of if/else cycle
}// end of if cycle
} else {
if (oldValue != null && newValue == null) {
if (oldValue instanceof byte[]) {
return "";
} else {
return tatDel + oldValue.toString();
}// end of if/else cycle
}// end of if cycle
if (newValue != null && oldValue == null) {
if (newValue instanceof byte[]) {
return "";
} else {
return tatNew + newValue.toString();
}// end of if/else cycle
}// end of if cycle
}// end of if/else cycle
}// end of if/else cycle
return "";
}// end of method
}// end of class
| [
"[email protected]"
] | |
a7a2c75864bd35fa0439d62b8adec07a5d18bf15 | b75912e5e851d1bb7537f9598ce7f27b9a0aabdc | /MegaDesk/src/model/Desk.java | bd5b32f1989ed50bfec5977aac0b8ecdcc2aa4ed | [] | no_license | lucicd/cit360_technical_topics | 9e822c95f7aed02709be73591152d708d356909c | 9948d879c443af6e9db186db6ea6ad066d6d559a | refs/heads/master | 2020-04-16T09:55:14.429413 | 2019-03-10T09:57:43 | 2019-03-10T09:57:43 | 165,481,998 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,877 | 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 model;
/**
*
* @author Drazen
*/
public class Desk {
private double width;
private double depth;
private int numberOfDrawers;
private SurfaceType surfaceType;
private BuildTime buildTime;
private DeskQuote deskQuote;
public Desk(double width, double depth, int numberOfDrawers,
String customer, BuildTime buildTime, SurfaceType surfaceType) {
this.width = width;
this.depth = depth;
this.numberOfDrawers = numberOfDrawers;
this.buildTime = buildTime;
this.surfaceType = surfaceType;
this.deskQuote = new DeskQuote(customer, this);
}
public double getArea()
{
return width * depth;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getDepth() {
return depth;
}
public void setDepth(double depth) {
this.depth = depth;
}
public int getNumberOfDrawers() {
return numberOfDrawers;
}
public void setNumberOfDrawers(int numberOfDrawers) {
this.numberOfDrawers = numberOfDrawers;
}
public SurfaceType getSurfaceType() {
return surfaceType;
}
public void setSurfaceType(SurfaceType surfaceType) {
this.surfaceType = surfaceType;
}
public DeskQuote getDeskQuote() {
return deskQuote;
}
public void setDeskQuote(DeskQuote deskQuote) {
this.deskQuote = deskQuote;
}
public BuildTime getBuildTime() {
return buildTime;
}
public void setBuildTime(BuildTime buildTime) {
this.buildTime = buildTime;
}
}
| [
"[email protected]"
] | |
19a11318a81c5ad26a8a0d82ba4196a87ec18c0d | b759f902de7d1792298b8724c7598830fb98c1f4 | /src/main/java/com/github/msalaslo/locking/api/dto/ErrorDTO.java | e578922fa0978222f4fb3e569ee157f85ab867c1 | [] | no_license | msalaslo/spring-data-jpa-locking | b54aab77222b3da507d4f0897fa1d1eb4eafaf18 | 241671ef09359c69785ce42174a85e8601978707 | refs/heads/main | 2023-03-08T07:30:13.573608 | 2021-02-20T20:00:21 | 2021-02-20T20:00:21 | 334,744,727 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package com.github.msalaslo.locking.api.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
/**
* DTO representing the error according to vnd.error specification.
*
* @since 1.0.0
*
*/
@Getter
@Setter
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@SuppressWarnings("squid:S2160") // BaseDTO uses reflection for equals, so the fields of the children are covered.
public class ErrorDTO extends BaseDTO {
private long timestamp;
private int status;
private String error;
private String exception;
private String message;
}
| [
"[email protected]"
] | |
e79ba0862f8e313f80fa4f741521c7972d0849ea | da6220c9b45ba9d483b1bde3f72bef21a5d8594c | /src/main/java/com/example/demo/util/SHA1.java | 6455cbe41c8cad56a831146d8e4f03099730ed66 | [] | no_license | parkdifferent/SpringBootDemo | adec9b74422e055b01ccc3022ed6cc08b2a79c83 | ebc6dac7867b527f1093fa9a074394a7290c4481 | refs/heads/master | 2020-04-05T13:40:40.591896 | 2017-06-30T02:15:44 | 2017-06-30T02:15:44 | 94,973,842 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,969 | java | /**
* 对公众平台发送给公众账号的消息加解密示例代码.
*
* @copyright Copyright (c) 1998-2014 Tencent Inc.
*/
// ------------------------------------------------------------------------
package com.example.demo.util;
import java.security.MessageDigest;
import java.util.Date;
/**
* SHA1 class
*
* 计算公众平台的消息签名接口.
*/
class SHA1 {
/**
*
* @param appSecret
* @param nonce
* @param curTime
* @return
* @throws AesException
*/
public static String getSHA1(String appSecret, String nonce, String curTime) throws AesException {
try {
String[] array = new String[] { appSecret, nonce, curTime };
StringBuffer sb = new StringBuffer();
// 字符串排序
//Arrays.sort(array);
for (int i = 0; i < 3; i++) {
sb.append(array[i]);
}
String str = sb.toString();
if (str == null) {
return null;
}
// SHA1签名生成
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(str.getBytes());
byte[] digest = md.digest();
StringBuffer hexStr = new StringBuffer();
String shaHex = "";
for (int i = 0; i < digest.length; i++) {
shaHex = Integer.toHexString(digest[i] & 0xFF);
if (shaHex.length() < 2) {
hexStr.append(0);
}
hexStr.append(shaHex);
}
return hexStr.toString();
} catch (Exception e) {
e.printStackTrace();
throw new AesException(AesException.ComputeSignatureError);
}
}
//another method
public static String getCheckSum(String appSecret, String nonce, String curTime) {
return encode("sha1", appSecret + nonce + curTime);
}
private static String encode(String algorithm, String value) {
if (value == null) {
return null;
}
try {
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
messageDigest.update(value.getBytes());
return getFormattedText(messageDigest.digest());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static String getFormattedText(byte[] bytes) {
int len = bytes.length;
StringBuilder buf = new StringBuilder(len * 2);
for (int j = 0; j < len; j++) {
buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
}
return buf.toString();
}
private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
public static void main(String[] args) throws AesException {
String appKey = "efabec6ca0048ba015339a824ca1ae3e";
String appSecret = "d559fd9d91ab";
String nonce = String.valueOf(Math.random() * 1000000);
String curTime = String.valueOf((new Date()).getTime() / 1000L);
String checkSum1 = SHA1.getCheckSum(appSecret, nonce ,curTime);//参考 计算CheckSum的java代码
String checkSum2 = SHA1.getSHA1(appSecret,nonce,curTime);
System.out.println(checkSum1);
System.out.println(checkSum2);
System.out.println(EncryptCodeUtil.hexSHA1(appSecret+nonce+curTime));
}
}
| [
"[email protected]"
] | |
7f89e111b2c77567925e315d456860d44ac05404 | 3e998529161852130f0c4f6a6e29a9921f78db6a | /src/main/java/cn/edu/seu/myjvm/instructions/references/MultiANewArray.java | 804861152f6977a1807a95c2754d072923ba4ca2 | [] | no_license | hhzhang333/MyJVM | 37dc5611c8a400e06d95b0c4c53b15d2583dffdf | bc5f64c3a90ed67c31d3626af4971ddab0b9325e | refs/heads/master | 2020-06-04T14:35:44.821395 | 2019-11-20T07:38:01 | 2019-11-20T07:38:01 | 192,063,104 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,285 | java | package cn.edu.seu.myjvm.instructions.references;
import cn.edu.seu.myjvm.instructions.base.BytecodeReader;
import cn.edu.seu.myjvm.instructions.base.Instruction;
import cn.edu.seu.myjvm.runtime.Frame;
import cn.edu.seu.myjvm.runtime.OperandStack;
import cn.edu.seu.myjvm.runtime.heap.*;
import cn.edu.seu.myjvm.runtime.heap.Class;
/**
* Created by a on 2018/3/7.
*/
public class MultiANewArray implements Instruction {
private int index;
private int dimensions;
@Override
public void fetchOperands(BytecodeReader reader) throws Exception {
this.index = reader.readU2().getData();
this.dimensions = reader.readU1().getData();
}
@Override
public void execute(Frame frame) throws Exception {
ConstantPool constantPool = frame.getMethod().getClazz().getConstantPool();
ClassRef classRef = (ClassRef) constantPool.getConstant(this.index).getValue();
Class arrClass = classRef.resolvedClass();
OperandStack stack = frame.getOperandStack();
int[] counts = popAndCheckCounts(stack, this.dimensions);
Mobject arr = newMultiDimensionalArray(counts, arrClass);
stack.pushRef(arr);
}
public int[] popAndCheckCounts(OperandStack stack, int dimensions) throws Exception {
int[] counts = new int[dimensions];
for (int i = dimensions - 1; i >= 0; i--) {
counts[i] = stack.popInt();
if (counts[i] < 0)
throw new Exception("java.lang.NegativeArraySizeException");
}
return counts;
}
public Mobject newMultiDimensionalArray(int[] counts, Class arrClass) throws Exception {
int count = counts[0];
ArrayObject arr = (ArrayObject) arrClass.newArray(count);
if (counts.length > 1) {
Mobject[] refs = arr.readRefs();
for (int i = 0; i < refs.length; i++)
refs[i] = newMultiDimensionalArray(purgeArray(counts, 1, counts.length), arrClass.componentClass());
}
return arr;
}
public int[] purgeArray(int[] arr, int start, int end) {
int count = end - start + 1;
int[] result = new int[count];
for (int i = 0; i < count; i++)
result[i] = arr[start + count];
return result;
}
}
| [
"[email protected]"
] | |
1d43681788a2fb6fe40cb9abfa415825add91aee | a20343c32d9260b2f82cd688afe6fa59159475a4 | /small_projects_when_learning_java_backend/juc/src/main/java/com/zhangyun/demo13single/Holder.java | 583f01e4481cd851cda3ebb3bea7d59ac4884349 | [] | no_license | yunkai-zhang/BUPT | 9412d797c6d6b18badc6a1c45bd4d1ca560f0321 | 974091e28d5c7f51f3cb4518ee1271938c318807 | refs/heads/main | 2023-08-28T07:08:16.207688 | 2023-08-11T15:52:30 | 2023-08-11T15:52:30 | 249,700,012 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 270 | java | package com.zhangyun.demo13single;
public class Holder {
private Holder(){
}
public static Holder getInstance(){
return InnerClass.holder;
}
public static class InnerClass{
private static final Holder holder = new Holder();
}
}
| [
"[email protected]"
] | |
5277b36b579ab0045c840e589188f15744a33dbb | bfc71289cec477684ff53b4f7e69453b10871f76 | /EMR_BDD/src/test/java/emr/stepDef/CreateNewPatientStepDef.java | 3bfe7ead6074f4c3ce274d77cd856265061fb2ab | [] | no_license | kaniz-qa/Emr-project | 16def041c19ae2f3853cbe97153e3d037d6528e2 | 2fbfcdae631677ba8485fd22db830ad19c162e2e | refs/heads/master | 2020-12-18T15:44:03.798494 | 2020-01-21T21:36:15 | 2020-01-21T21:36:15 | 235,442,730 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,370 | java | package emr.stepDef;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import emr.actions.CreateNewPatientActions;
public class CreateNewPatientStepDef {
CreateNewPatientActions loginActions = new CreateNewPatientActions();
// new patient create...................................................
@When("^Mouse over on patient $")
public void mouse_over_on_patient() {
loginActions.patientMenu();
}
@When("^Click on new$")
public void click_on_new() {
loginActions.newP();
}
@When("^Displayed iFrame$")
public void displayed_iFrame() {
loginActions.emriFramePage();
}
@When("^Select initials$")
public void select_initials() {
loginActions.getInitialSelect();
}
@When("^Input first and last name$")
public void input_first_and_last_name() {
loginActions.firstName();
loginActions.lastName();
}
@When("^Select date of birth and sex$")
public void select_date_of_birth_and_sex() {
loginActions.dob();
loginActions.gender();
}
@When("^Click on create new patient$")
public void click_on_create_new_patient() {
loginActions.addCreatePatient();
}
@Then("^I should be able to create new patient$")
public void i_should_be_able_to_create_new_patient() throws Exception {
loginActions.pCreateMsg();
}
}
| [
"[email protected]"
] | |
951505976adb7c2ff3b2fb6f89514a2d29012910 | fe4b947d7353186b2831451bbc52a2a559e4e29f | /app/src/main/java/com/tranzeet/app/ui/activity/notification_manager/NotificationManagerIPresenter.java | 6046058645c7ebcb409301f12cb7274973368087 | [] | no_license | ersalye/Taxiapp | f52106660b1112182bce4b5413f880851cee2244 | 177478f7a08dff3b5f487a1d054c965997747413 | refs/heads/master | 2022-09-24T23:46:50.522324 | 2020-06-05T08:06:07 | 2020-06-05T08:06:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 250 | java | package com.tranzeet.app.ui.activity.notification_manager;
import com.tranzeet.app.base.MvpPresenter;
public interface NotificationManagerIPresenter<V extends NotificationManagerIView> extends MvpPresenter<V> {
void getNotificationManager();
}
| [
"[email protected]"
] | |
f0c82b922574e4c1fe155e0139e8195da6998318 | c0cb4a62928ef2e01f6c14564483989f6d1d62b6 | /lighter-compiler/src/main/java/fun/connor/lighter/compiler/package-info.java | 4f8edb542a625ac95fa98f81b4a15b463ee37cb6 | [] | no_license | Spaceman1701/lighter | a4dc91a74612353d51660093793318aa8015c3bc | afbf590f84dff4122565ac5552da0dfcd2124861 | refs/heads/master | 2020-03-30T08:18:42.675993 | 2019-07-21T19:16:13 | 2019-07-21T19:16:13 | 151,005,139 | 0 | 0 | null | 2018-12-10T23:35:48 | 2018-09-30T20:41:46 | Java | UTF-8 | Java | false | false | 2,806 | java | /**
* The Lighter Compiler implementation. This library contains all the components for Lighter's compile
* time validation and code generation. This library is a <strong>compile time only</strong> dependency for
* consumers of Lighter. The Lighter runtime is contained within <code>lighter-core</code> which is
* also a dependency of this library.
*<br>
* This library is organized the following way:
* <ul>
* <li>At the top level, the {@link fun.connor.lighter.compiler.LighterAnnotationProcessor} and
* utility classes</li>
* <li>{@link fun.connor.lighter.compiler.generator} package containing code-generation implementations</li>
* <li>{@link fun.connor.lighter.compiler.model} package containing the compile-time generated application model domain objects</li>
* <li>{@link fun.connor.lighter.compiler.step} package containing the high-level compiler steps which encapsulate individual
* compile-time behaviors</li>
* <li>{@link fun.connor.lighter.compiler.validation} package containing error-reporting logic</li>
* <li>{@link fun.connor.lighter.compiler.validators} package (to be renamed) containing annotation-validators</li>
* </ul>
*
* <br>
* The Lighter Compiler works using an iterative-step approach. The compiler's behavior is broken up into a sequence
* of small steps which each provide a specific explicit or implicit refinement to the data model. In practice, there
* are two types of steps: validation steps and generation steps. Validation steps usually provide an implicit refinement
* to the model by ensuring that certain invariants are enforced before the next generation step occurs. Generation steps
* explicitly rebuild the model using the new invariants provided by each validation.
* <br>
* Currently Lighter has 7 compilation steps. The implementations can be found in the package linked above. The order
* can be found in {@link fun.connor.lighter.compiler.LighterAnnotationProcessor}. On a high level, the sequence is
* approximately as follows:
* <ol>
* <li>Each Lighter annotation is validated independently. Argument syntax and correctness is checked</li>
* <li>The general application model is generated from the set of all Lighter-annotated classes</li>
* <li>The request guard provisioning model is generated from the set of request guard annotations</li>
* <li>The general application model is validated for semantic correctness</li>
* <li>Request guard dependencies are collected and stored for lookup</li>
* <li>Application endpoint classes and controller metadata classes are generated from the model</li>
* <li>The reverse injector class for the module is generated from the generated endpoint classes</li>
* </ol>
*/
package fun.connor.lighter.compiler; | [
"[email protected]"
] | |
562c27d5d04efee31f511c6408111fcab609f9b8 | 9ae6ee8d4b0cbd0392713f1c834942c363be608e | /Documents/tpprog/Compta/src/main/java/desktop/deschamps/compta/entities/Ventes.java | 793e9020effe397291472d3c8107df91e0109b53 | [] | no_license | MathieuDeschamps/IDM-JHipster | c9b1c5855740f64dd1c20e5db3cddd0de5361686 | 8665a985c3c12f1aa33e043f72d91b68a2e91f4d | refs/heads/master | 2020-04-23T04:53:35.657068 | 2018-05-29T21:18:48 | 2018-05-29T21:18:48 | 170,923,017 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,248 | java | package desktop.deschamps.compta.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name="Ventes")
public class Ventes {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@Column(name="debutPeriode")
private java.util.Date debutPeriode;
@Column(name="finPeriode")
private java.util.Date finPeriode;
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="Unit_id")
private Category unit;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public java.util.Date getDebutPeriode() {
return debutPeriode;
}
public void setDebutPeriode(java.util.Date debutPeriode) {
this.debutPeriode = debutPeriode;
}
public java.util.Date getFinPeriode() {
return finPeriode;
}
public void setFinPeriode(java.util.Date finPeriode) {
this.finPeriode = finPeriode;
}
public Category getUnit() {
return unit;
}
public void setUnit(Category unit) {
this.unit = unit;
}
}
| [
"[email protected]"
] | |
624da73df04ef339ebcdf146534668372c849b45 | 5bc6f6d6cdb413f188556737f44af83c7f7d6a24 | /src/controllers/reports/ReportsNewServlet.java | 7fbf2c5085ab9dbf017ca403f487e45211e13489 | [] | no_license | hirasawanobuaki/daily-report | 416ce5ce6951c5d2a9afc49262fa3be217e3929e | c7c097dcfc95ab900e9259174af5b087afd67188 | refs/heads/master | 2023-02-01T18:23:17.536964 | 2020-12-04T01:26:07 | 2020-12-04T01:26:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,240 | java | package controllers.reports;
import java.io.IOException;
import java.sql.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import models.Report;
/**
* Servlet implementation class ReportsNewServlet
*/
@WebServlet("/reports/new")
public class ReportsNewServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ReportsNewServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("_token", request.getSession().getId());
Report r = new Report();
r.setReport_date(new Date(System.currentTimeMillis()));
request.setAttribute("report", r);
RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/views/reports/new.jsp");
rd.forward(request, response);
}
}
| [
"[email protected]"
] | |
5eb7cd50c667566f7b7ab4897a52bd8fd7ec5932 | 2d60e0d2c1c23d27b5dd76aa262f6b9cb036f014 | /src/main/java/com/hashmapinc/tempus/WitsmlObjects/v1311/ShowSpeed.java | baed6b2a71e628228d3f2733c1c4846e0afb5b8d | [
"Apache-2.0"
] | permissive | antolantic/WitsmlObjectsLibrary | aaf850c33d1dafd5162d52b808c70da792d14052 | 3e154f60a7b8514119acc5b05513fc8d31037fca | refs/heads/master | 2020-04-05T08:17:09.770594 | 2017-12-07T22:58:09 | 2017-12-07T22:58:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,789 | java | package com.hashmapinc.tempus.WitsmlObjects.v1311;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ShowSpeed.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre> {@code
* <simpleType name="ShowSpeed">
* <restriction base="{http://www.witsml.org/schemas/131}abstractTypeEnum">
* <enumeration value="slow"/>
* <enumeration value="moderately fast"/>
* <enumeration value="fast"/>
* <enumeration value="instantaneous"/>
* <enumeration value="none"/>
* <enumeration value="unknown"/>
* </restriction>
* </simpleType>
* } </pre>
*
*/
@XmlType(name = "ShowSpeed")
@XmlEnum
public enum ShowSpeed {
@XmlEnumValue("slow")
SLOW("slow"),
@XmlEnumValue("moderately fast")
MODERATELY_FAST("moderately fast"),
@XmlEnumValue("fast")
FAST("fast"),
@XmlEnumValue("instantaneous")
INSTANTANEOUS("instantaneous"),
@XmlEnumValue("none")
NONE("none"),
/**
* The value is not known. This value should not be used
* in normal situations. All reasonable attempts should be made to determine
* the appropriate value. Use of this value may result in rejection in some situations.
*
*/
@XmlEnumValue("unknown")
UNKNOWN("unknown");
private final String value;
ShowSpeed(String v) {
value = v;
}
public String value() {
return value;
}
public static ShowSpeed fromValue(String v) {
for (ShowSpeed c: ShowSpeed.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
| [
"[email protected]"
] | |
0bec375c467dbcb9fe7820521af86bbb5a7d8f1e | 211246306c18cdace932ae1286b6340a1fce173d | /src/main/java/com/zw/dao/UserDao.java | 1eea76c1c23aa4a8af632355efa33d3d11851d48 | [
"Apache-2.0"
] | permissive | JasonAlcoholic/springMVC | c594d237e9222a2f231f46301ae6dce49fb7f6b9 | 59ccc8abf96626b3ecb9d705c2eda0422c225c8e | refs/heads/master | 2021-01-10T16:32:49.921649 | 2015-09-29T07:57:23 | 2015-09-29T07:57:23 | 43,352,613 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,825 | java | package com.zw.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.zw.entity.User;
@Repository
public class UserDao extends BaseDao{
public List<User> getAllUsers(){
String hsql="from users";
return runSql(hsql);
}
public List<User> getByName(String name){
String hsql="from users where name = '" + name + "'";
return runSql(hsql);
}
/*@Autowired
private MongoOperations mongoTemplate;
public void insert(User user) {
mongoTemplate.insert(user);
}
public void insertAll(List<User> users) {
mongoTemplate.insertAll(users);
}
public void deleteById(String id) {
User user = new User(id, null, 0);
mongoTemplate.remove(user);
}
public void delete(User criteriaUser) {
Criteria criteria = Criteria.where("age").gt(criteriaUser.getAge());;
Query query = new Query(criteria);
mongoTemplate.remove(query, User.class);
}
public void deleteAll() {
mongoTemplate.dropCollection(User.class);
}
public void updateById(User user) {
Criteria criteria = Criteria.where("id").is(user.getId());
Query query = new Query(criteria);
Update update = Update.update("age", user.getAge()).set("name", user.getName());
mongoTemplate.updateFirst(query, update, User.class);
}
public void update(User criteriaUser, User user) {
Criteria criteria = Criteria.where("age").gt(criteriaUser.getAge());;
Query query = new Query(criteria);
Update update = Update.update("name", user.getName()).set("age", user.getAge());
mongoTemplate.updateMulti(query, update, User.class);
}
public User findById(String id) {
return mongoTemplate.findById(id, User.class);
}
public List<User> findAll() {
return mongoTemplate.findAll(User.class);
}
public List<User> find(User criteriaUser, int skip, int limit) {
Query query = getQuery(criteriaUser);
query.skip(skip);
query.limit(limit);
return mongoTemplate.find(query, User.class);
}
public User findAndModify(User criteriaUser, User updateUser) {
Query query = getQuery(criteriaUser);
Update update = Update.update("age", updateUser.getAge()).set("name", updateUser.getName());
return mongoTemplate.findAndModify(query, update, User.class);
}
public User findAndRemove(User criteriaUser) {
Query query = getQuery(criteriaUser);
return mongoTemplate.findAndRemove(query, User.class);
}
public long count(User criteriaUser) {
Query query = getQuery(criteriaUser);
return mongoTemplate.count(query, User.class);
}
private Query getQuery(User criteriaUser) {
if (criteriaUser == null) {
criteriaUser = new User();
}
Query query = new Query();
if (criteriaUser.getId() != null) {
Criteria criteria = Criteria.where("id").is(criteriaUser.getId());
query.addCriteria(criteria);
}
if (criteriaUser.getAge() > 0) {
Criteria criteria = Criteria.where("age").gt(criteriaUser.getAge());
query.addCriteria(criteria);
}
if (criteriaUser.getName() != null) {
Criteria criteria = Criteria.where("name").regex("^" + criteriaUser.getName());
query.addCriteria(criteria);
}
return query;
} */
} | [
"[email protected]"
] | |
ac196983fa3f2e0f47fd5a0cb20820261f904355 | 0a105f3a8dead64a5cd566e25a118af4a5e48be3 | /mall-coupon/src/main/java/com/henau/mall/coupon/entity/SeckillSkuRelationEntity.java | b98fa596ee7bd68e41fbd224c5518b00ed05fbc9 | [
"Apache-2.0"
] | permissive | shiljm/mall | 65b0f8d0373f9eea7e58f6fa8198df341ad2dc55 | d1b3aaaac37bf4d9b1ef9f54fb32154ab5262ec8 | refs/heads/main | 2023-07-11T01:01:42.610600 | 2021-08-07T03:07:33 | 2021-08-07T03:07:33 | 328,608,882 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 968 | java | package com.henau.mall.coupon.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 秒杀活动商品关联
*
* @author lijm
* @email [email protected]
* @date 2021-01-12 18:57:27
*/
@Data
@TableName("sms_seckill_sku_relation")
public class SeckillSkuRelationEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* 活动id
*/
private Long promotionId;
/**
* 活动场次id
*/
private Long promotionSessionId;
/**
* 商品id
*/
private Long skuId;
/**
* 秒杀价格
*/
private BigDecimal seckillPrice;
/**
* 秒杀总量
*/
private BigDecimal seckillCount;
/**
* 每人限购数量
*/
private BigDecimal seckillLimit;
/**
* 排序
*/
private Integer seckillSort;
}
| [
"[email protected]"
] | |
7a993ec70b87bfdc754d6d220b5128cbc9d3fc54 | 6f1fe90b186fb2843345a7b150fd942bf642d934 | /edu_parent/service/service_edu/src/main/java/com/zzn/eduservice/controller/EduTeacherController.java | 1742edbe54f21624bcc8feb08a82a76db380e396 | [] | no_license | Laity-zhang/SpringBoot_Edu | 1e7ab6949b56a668eaa664f2410aa1ebb256877f | 74c3efab3badecc0fc2a709e20dab1de62bed166 | refs/heads/master | 2023-03-19T06:41:11.822497 | 2021-01-05T06:36:27 | 2021-01-05T06:39:40 | 324,704,581 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,844 | java | package com.zzn.eduservice.controller;
import com.atguigu.commonutils.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzn.eduservice.entity.EduTeacher;
import com.zzn.eduservice.entity.vo.TeacherQuery;
import com.zzn.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* 讲师 前端控制器
* </p>
*
* @author zhangzhaonian
* @since 2020-11-29
*/
@Api(description = "讲师管理")
@RestController
@RequestMapping("/eduservice/teacher")
@CrossOrigin//解决浏览器跨域问题
public class EduTeacherController {
@Autowired
private EduTeacherService eduTeacherService;
//查询所有讲师信息
@ApiOperation(value = "查询所有讲师列表")
@GetMapping("findAll")
public R findAllTeacher(){
List<EduTeacher> eduTeachers = eduTeacherService.list(null);
return R.ok().data("items",eduTeachers);
}
//逻辑删除讲师信息
@ApiOperation(value = "逻辑删除讲师信息")
@DeleteMapping("{id}")
public R deleteById(@ApiParam(name = "id",value = "讲师ID",required = true) @PathVariable String id){
boolean flag = eduTeacherService.removeById(id);
if (flag){
return R.ok();
}
else {
return R.error();
}
}
//分页查询讲师信息
@ApiOperation(value = "分页查询讲师信息")
@GetMapping("pageTeacher/{current}/{limit}")
public R pageList( @ApiParam(name = "current", value = "当前页码", required = true)
@PathVariable Long current,
@ApiParam(name = "limit", value = "每页记录数", required = true)
@PathVariable Long limit){
//创建Page对象
Page<EduTeacher> pageTeacher = new Page<>(current,limit);
//调用方法实现分页,并将结果封装在pageTeacher对象里面
eduTeacherService.page(pageTeacher,null);
Long total = pageTeacher.getTotal();//总记录数
List<EduTeacher> records = pageTeacher.getRecords();//数据list集合
//Map map = new HashMap();
//map.put("total",total);
//map.put("rows",records);
//return R.ok().data(map);
return R.ok().data("total",total).data("rows",records);
}
//按组合条件分页查询讲师信息
@ApiOperation(value = "按条件分页查询信息")
@PostMapping("pageQuery/{current}/{limit}")
public R pageQuery(
@ApiParam(name = "current",value = "当前页码",required = true)
@PathVariable Long current,
@ApiParam(name = "limit",value = "每页记录数",required = true)
@PathVariable Long limit,
@ApiParam(name = "teacherQuer",value = "查询对象",required = false)
@RequestBody TeacherQuery teacherQuery){
//创建page对象
Page<EduTeacher> pageTeacher = new Page<>(current,limit);
//实现多条件查询
eduTeacherService.pageQuery(pageTeacher,teacherQuery);
List<EduTeacher> records = pageTeacher.getRecords();
long total = pageTeacher.getTotal();
return R.ok().data("total", total).data("rows", records);
}
//添加讲师
@ApiOperation(value = "添加讲师信息")
@PostMapping("addTeacher")
public R addTeacher(
@ApiParam(name = "teacher",value = "讲师对象",required = true)
@RequestBody EduTeacher eduTeacher){
boolean save = eduTeacherService.save(eduTeacher);
if (save){
return R.ok();
}
else {
return R.error();
}
}
//根据ID查询讲师信息
@ApiOperation(value = "根据ID查询讲师信息")
@GetMapping("getTeacher/{id}")
public R getTeacherById(
@ApiParam(name = "id",value = "讲师ID",required =true)
@PathVariable String id){
EduTeacher eduTeacher = eduTeacherService.getById(id);
return R.ok().data("items",eduTeacher);
}
//修改讲师信息
@ApiOperation(value = "修改讲师信息")
@PostMapping("editTeacher")
public R updateTeacherById(
@ApiParam(name = "eduTeacher",value = "讲师对象",required = true)
@RequestBody EduTeacher eduTeacher){
boolean flag = eduTeacherService.updateById(eduTeacher);
if (flag){
return R.ok();
}
else {
return R.error();
}
}
}
| [
"[email protected]"
] | |
b3e163631cb1d06194fb604485d8828800d9f6f4 | b428eb094b001ebeffa2ae13f54fd6be44f073d0 | /src/main/java/com/example/weixindemo/pojo/wxsend/BaseMessage.java | fc5d41a4e49062804795ff8e93f5f7b88b22949f | [] | no_license | lints123/weixindemo | 965dc7f21bba2d8b602c15f21d148ba4ec630c17 | 55eeea6f8a83377698811db725ce0a2e4daa8398 | refs/heads/master | 2023-06-07T13:34:32.035268 | 2019-09-30T09:11:12 | 2019-09-30T09:11:12 | 208,832,531 | 0 | 0 | null | 2023-05-26T22:15:23 | 2019-09-16T15:21:10 | Java | UTF-8 | Java | false | false | 1,151 | java | package com.example.weixindemo.pojo.wxsend;
/**
* 请求消息的基类
*/
public class BaseMessage {
// 开发者微信号
private String ToUserName;
// 发送者账号(你的OpenId)
private String FromUserName;
// 消息的创建时间
private long CreateTime;
// 消息类型
private String MsgType;
// 消息ID
private long MsgId;
public String getToUserName() {
return ToUserName;
}
public void setToUserName(String toUserName) {
ToUserName = toUserName;
}
public String getFromUserName() {
return FromUserName;
}
public void setFromUserName(String fromUserName) {
FromUserName = fromUserName;
}
public long getCreateTime() {
return CreateTime;
}
public void setCreateTime(long createTime) {
CreateTime = createTime;
}
public String getMsgType() {
return MsgType;
}
public void setMsgType(String msgType) {
MsgType = msgType;
}
public long getMsgId() {
return MsgId;
}
public void setMsgId(long msgId) {
MsgId = msgId;
}
}
| [
"[email protected]"
] | |
1294ccf91ec429dc47568c75ed5941c39163ac62 | a0bf357da01159b49abc82667c95df8dea172b63 | /1st Yr/Lab9_4.java | 4ca47f726624a215f1461c1916a1c67d22df300e | [] | no_license | xXGoziXx/CollegeWork | ac3f63931db40cfb5168639cf765201398c3a903 | c03d5df8e56379cc6ea8ead84fbf2f09afa73be0 | refs/heads/master | 2021-01-19T03:07:02.105191 | 2016-06-06T17:58:06 | 2016-06-06T19:16:03 | 60,531,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | //required Random import file
import java.util.Random;
public class Lab9_4
{
public static void main(String args[])
{
//create array
int array[] = new int [10];
//varibale to calculate sum for average
int sum = 0;
//random number generator
Random r = new Random();
//loop that inputs random numbers to array
for(int i = 0 ; i<array.length; i++ )
{
//creates random number and stores it in position i of array
array[i] = r.nextInt(1000);
//prints array numbers
System.out.print(array[i] + " ");
//gets the sum of the numbers
sum = sum + array[i];
}
//uses sum to get the average of the numbers in the array
int average = sum / array.length;
//prints average of the numbers in the array
System.out.println("\n" + "The average of the numbers in the array is: " + average);
}
} | [
"[email protected]"
] | |
b1b875fe1d4e4c4d1a31162ad261fc1bb140b6a0 | fd376b0588cff14e55748e090d9bba66c39017c1 | /src/main/java/com/techmaster/hunter/dao/impl/HunterJDBCExecutorImpl.java | c92f3d017fc03789e37d2d2bec067e47b42f6ccf | [] | no_license | hillangat/Hunter | dd73fa5a2c7b6e594e0f86467ae41c37d774786f | 56bd22b9969316aac5adde14dde82109ebf455c7 | refs/heads/master | 2018-12-19T12:01:51.693679 | 2018-10-25T01:40:52 | 2018-10-25T01:40:52 | 111,363,519 | 0 | 0 | null | 2018-09-15T23:17:40 | 2017-11-20T04:57:30 | JavaScript | UTF-8 | Java | false | false | 8,965 | java | package com.techmaster.hunter.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.jdbc.core.JdbcTemplate;
import com.techmaster.hunter.dao.types.HunterJDBCExecutor;
import com.techmaster.hunter.exception.HunterRunTimeException;
import com.techmaster.hunter.util.HunterHibernateHelper;
import com.techmaster.hunter.util.HunterUtility;
public class HunterJDBCExecutorImpl implements HunterJDBCExecutor {
private JdbcTemplate jdbcTemplate;
private Logger logger = Logger.getLogger(HunterJDBCExecutorImpl.class);
public HunterJDBCExecutorImpl(JdbcTemplate jdbcTemplate) {
super();
this.jdbcTemplate = jdbcTemplate;
}
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Override
public String getQueryForSqlId(String id) {
if(id == null || id.trim().equalsIgnoreCase("")){
String message = "Id provided is null or empty >> " + id;
logger.debug(message);
throw new IllegalArgumentException(message);
}
String
query = HunterUtility.getQueryForSqlId(id),
desc = HunterUtility.getQueryDescForSqlId(id);
logger.debug("\n Description : " + desc + "\n");
logger.debug("Retrieved query for id = " + id + " \n" + query);
return query;
}
@Override
public Map<Integer, List<Object>> executeQueryRowList(String query, List<Object> values) {
ResultSet rs = null;
Connection conn = null;
Map<Integer, List<Object>> objects = new HashMap<Integer, List<Object>>();
try {
conn = this.jdbcTemplate.getDataSource().getConnection();
PreparedStatement ps = conn.prepareStatement(query);
if(values != null && values.size() >= 1){
for(int i=0; i<values.size(); i++){
Object obj = values.get(i);
ps.setObject(i+1, obj);
}
}
rs = ps.executeQuery();
int indx = 1;
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
while(rs.next()){
List<Object> row = new ArrayList<>();
for(int j=1; j<=columnsNumber; j++){
Object obj = rs.getObject(j);
row.add(obj);
}
objects.put(indx,row);
indx++;
}
rs.close();
ps.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new HunterRunTimeException(e.getMessage());
}finally{
HunterHibernateHelper.closeConnection(conn);
}
return objects;
}
@Override
public List<Map<String, Object>> executeQueryRowMap(String query, List<Object> values) {
ResultSet rs = null;
Connection conn = null;
List<Map<String, Object>> rowMapList = new ArrayList<>();
try {
conn = this.jdbcTemplate.getDataSource().getConnection();
PreparedStatement ps = conn.prepareStatement(query);
if(values != null && values.size() >= 1){
for(int i=0; i<values.size(); i++){
Object obj = values.get(i);
ps.setObject(i+1, obj);
}
}
rs = ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
while(rs.next()){
Map<String, Object> rowMap = new HashMap<>();
for(int j=1; j<=columnsNumber; j++){
Object obj = rs.getObject(j);
String colName = rsmd.getColumnName(j);
rowMap.put(colName, obj);
}
rowMapList.add(rowMap);
}
rs.close();
ps.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}finally{
HunterHibernateHelper.closeConnection(conn);
}
return rowMapList;
}
@Override
public List<Map<String, Object>> replaceAndExecuteQuery(String query, Map<String, Object> params) {
logger.debug("Before replacing values : " + query);
query = this.replaceAllInQuery(query, params);
logger.debug("After replacing values : " + query);
List<Map<String, Object>> roMap = executeQueryRowMap(query, new ArrayList<>());
return roMap;
}
@Override
public Map<Integer, List<Object>> replaceAndExecuteQueryForRowList(String query, Map<String, Object> params) {
logger.debug("Before replacing values : " + query);
query = this.replaceAllInQuery(query, params);
logger.debug("After replacing values : " + query);
Map<Integer, List<Object>> rowList = executeQueryRowList(query, new ArrayList<>());
return rowList;
}
private String replaceAllInQuery( String query, Map<String, Object> params ) {
for(Map.Entry<String, Object> entry : params.entrySet() ){
String key = entry.getKey();
String val = entry.getValue()+"";
query = query.replaceAll(key, val);
}
return query;
}
private static String replaceValues(String query,Map<String, Object> params){
for(Map.Entry<String, Object> entry : params.entrySet() ){
String key = entry.getKey();
String val = entry.getValue()+"";
query = query.replaceAll(key, val);
}
return query;
}
@Override
public void replaceAndExecuteUpdate(String query,Map<String, Object> params) {
logger.debug("Query before replacement : " + query);
query = replaceValues(query, params);
logger.debug("Query after replacement : " + query);
Connection conn = null;
try {
conn = this.jdbcTemplate.getDataSource().getConnection();
PreparedStatement ps = conn.prepareStatement(query);
ps.executeUpdate();
ps.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public int executeUpdate(String query,List<Object> values) {
logger.debug("Executing update query : " + query);
Connection conn = null;
int rows = 0;
try {
conn = this.jdbcTemplate.getDataSource().getConnection();
PreparedStatement ps = conn.prepareStatement(query);
if(values != null && values.size() >= 1){
for(int i=0; i<values.size(); i++){
Object obj = values.get(i);
ps.setObject(i+1, obj);
}
}
rows = ps.executeUpdate();
ps.close();
conn.close();
return rows;
} catch (SQLException e) {
e.printStackTrace();
}
return rows;
}
@Override
public List<Object> getValuesList(Object[] array) {
List<Object> values = new ArrayList<>();
if(array != null && array.length > 0){
for(Object obj : array){
values.add(obj);
}
}
return values;
}
@Override
public Object executeQueryForOneReturn(String query, List<Object> values) {
Map<Integer, List<Object>> rowListMap = executeQueryRowList(query, values);
if(!rowListMap.isEmpty() && rowListMap.get(1) != null && !rowListMap.get(1).isEmpty()){
if(rowListMap.get(1).size() > 1){
logger.warn("Size is greater than one for this query!!!! Returning the first element...");
}
Object obj = rowListMap.get(1).get(0);
return obj;
}
return null;
}
@Override
public Map<String, Object> executeQueryFirstRowMap(String query, List<Object> values) {
Map<String, Object> firstMap = new HashMap<>();
List<Map<String, Object>> list = executeQueryRowMap(query, values);
if(list != null && !list.isEmpty() && list.get(0) != null && !list.get(0).isEmpty() ){
firstMap.putAll(list.get(0));
}else{
logger.debug("No data found for query : " + query);
}
return firstMap;
}
@Override
public String replaceAllColonedParams(String query, Map<String, Object> params) {
logger.debug("Replacing parameters : " + HunterUtility.stringifyMap(params));
if( query == null || !HunterUtility.isMapNotEmpty(params) ){
String message = "Either the query is null or no parameters to replace. Returning the as is query...";
logger.debug( message );
throw new IllegalArgumentException( message );
}
for(Map.Entry<String, Object> entry : params.entrySet()){
String key = entry.getKey();
String value = HunterUtility.getStringOrNullOfObj( entry.getValue() );
if( query.contains(key) ){
value = value == null ? " IS NULL " : value;
query = query.replaceAll(key, value);
}else{
logger.debug("Exception while processing query for params : " + HunterUtility.stringifyMap(params));
throw new IllegalArgumentException( "Key : "+ key +" cannot be found in Query : \n "+ query + "\n" );
}
}
logger.debug("Replaced query : \n " + query);
return query;
}
@Override
public String getReplacedAllColonedParamsQuery(String queryName, Map<String, Object> params) {
String replaced = replaceAllColonedParams(getQueryForSqlId(queryName), params);
return replaced;
}
public JdbcTemplate getJDBCTemplate() {
return this.jdbcTemplate;
}
@Override
public int getCountForSqlId(String id, List<Object> values) {
String query = this.getQueryForSqlId(id + "_COUNT");
Object obj = null;
if ( query != null ) {
obj = this.executeQueryForOneReturn(query, values);
}
return obj == null ? 0 : Integer.parseInt(obj.toString());
}
}
| [
"[email protected]"
] | |
ff2c9c1b5111abba09e4b7e2e651ecf2bcd23f34 | a0f707bd9bcfdd47b0f22c11293d477e51a254fa | /src/com/prac/dp/LongestConsPath.java | 2dcd2400c83bb8fc4ef12f7ec3e3978fc14f103a | [] | no_license | ranjithkiran/DataStructures-and-Algorithms- | d34f87d8250e01bdfc060b293007eed547949866 | 4c4db8c9653292d71bec22df91ab6ed93d1f3065 | refs/heads/master | 2021-01-18T18:27:13.574195 | 2016-08-09T04:21:13 | 2016-08-09T04:21:13 | 65,212,071 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,742 | java | package com.prac.dp;
public class LongestConsPath {
public static void main(String[] args) {
// TODO Auto-generated method stub
char mat[][] = { {'a','c','d'},
{ 'h','b','a'},
{ 'i','g','f'}};
System.out.println(getLen(mat, 'a'));
System.out.println(getLen(mat, 'e'));
System.out.println(getLen(mat, 'b'));
System.out.println(getLen(mat, 'f'));
}
public static boolean isValid(int row,int column,char mat[][]){
if(row>=0 || row<mat[0].length || column>=0 || column<mat[0].length){
return true;
}
return false;
}
private static boolean isAdjacent(char[][] mat, int row, int column, char ch) {
// TODO Auto-generated method stub
if(isValid(row,column,mat)){
if(mat[row][column]-ch==1)
return true;
}
return false;
}
public static int getLenUtil(char mat[][],int row,int column,char ch){
if(!isValid(row, column, mat) ||!isAdjacent(mat,row,column,ch))
return 0;
int rows[] ={1,-1,0,0,-1,-1,1,1};
int columns[]={0,0,1,-1,-1,1,1,-1};
int ans=0;
for(int move=0;move<8;move++){
ans=max(ans,1+getLenUtil(mat,row+rows[move],column+columns[move],ch));
}
return ans;
}
public static int getLen(char[][] mat, char c) {
int rows[] ={1,-1,0,0,-1,-1,1,1};
int columns[]={0,0,1,-1,-1,1,1,-1};
// TODO Auto-generated method stub
int ans=0;
for(int i=0;i<mat.length;i++){
for(int j=0;j<mat[0].length;j++){
if(mat[i][j]==c){
for(int move=0;move<8;move++){
ans=max(ans,getLenUtil(mat,i+rows[move],j+columns[move],c));
}
}
}
}
return ans;
}
private static int max(int a, int b) {
// TODO Auto-generated method stub
return (a>b)?a:b;
}
}
| [
"[email protected]"
] | |
8a90dfd666005d3e5f9cfd71d9f1e22d4ca64609 | a5a00464650c47794d9a963e64eab5911190ac26 | /src/main/java/com/vaccnow/vaccinationplans/enums/Fields.java | 788c1e62a06cb73e2207af96fed59c47836b46c4 | [] | no_license | piyush170889/vaccnow | 8c29be122285b6f45fa4875b5d0cad795e0f755b | d18808aa892cab71f12a895c9e7df316bbd025c7 | refs/heads/master | 2023-02-21T03:46:57.564094 | 2021-01-15T16:45:32 | 2021-01-15T16:45:32 | 329,968,653 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 105 | java | package com.vaccnow.vaccinationplans.enums;
public enum Fields {
value,
vaccineName,
branchName;
}
| [
"[email protected]"
] | |
fb00b5c39687f3162bd232b0dadb6be384cf09d8 | ff8a1dcabe9b05d60098befc55cfbee2ab9d4b73 | /core/sorcer-platform/src/main/java/sorcer/core/loki/exertion/KPEntry.java | ce8430b8d0d6a3a138a55b57b1e1b8f6f75afcbf | [
"Apache-2.0"
] | permissive | kubam10/SORCER | 4c423b0bddc8839ac54f8069c37dd6a392e23780 | 670cba3188954eb4cd2e16890715b8948819b5f6 | refs/heads/master | 2020-04-18T23:55:19.359267 | 2019-02-02T18:29:14 | 2019-02-02T18:29:14 | 167,833,815 | 0 | 1 | Apache-2.0 | 2019-01-27T16:58:57 | 2019-01-27T16:58:57 | null | UTF-8 | Java | false | false | 647 | java | package sorcer.core.loki.exertion;
import java.security.PublicKey;
import net.jini.core.entry.Entry;
public class KPEntry implements Entry {
private static final long serialVersionUID = -3134975993027375539L;
public Boolean isCreator;
public byte[] keyPair;
public PublicKey publicKey;
public String GroupSeqId;
static public KPEntry get(Boolean iscreator, byte[] keypair,
PublicKey pk, String GSUID) {
KPEntry KP = new KPEntry();
KP.isCreator = iscreator;
KP.keyPair = keypair;
KP.publicKey = pk;
KP.GroupSeqId = GSUID;
return KP;
}
public String getName() {
return "KeyPair and KeyAgreement Exertion";
}
}
| [
"[email protected]"
] | |
3172f458dae6e524392ace5bfc74a0b2f3b67ccd | dc4309b253000bcff60d89d7ecbcc897e8aa94e1 | /cs121/2018/spring/cs121-5/NumberDialerPanel.java | b10869de55c4e0471b675626d229167ee4e107a6 | [
"MIT"
] | permissive | BoiseState/MarissaSchmidt-Public | 8ece3d3f8ca9f0759783c5d899f136c2d41bac28 | e898ae208b0bc8e32a8071b1d1be5070410afb97 | refs/heads/master | 2021-05-02T08:25:04.950707 | 2020-04-20T02:25:10 | 2020-04-20T02:25:10 | 120,803,810 | 5 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,478 | java | import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* This is the class for the main panel. Contains the ActionListeners and instantiates
* all the sub-components.
* @author marissa
* @author cs121-5
* @version Spring 2018
*/
@SuppressWarnings("serial")
public class NumberDialerPanel extends JPanel
{
private JButton[][] numberButtons;
private JLabel phoneNumberLabel;
//private int[] pushedNumbers;
public NumberDialerPanel()
{
// change layout of this panel to grid layout
setLayout(new GridLayout(3, 3));
// instantiate 2D array of buttons
numberButtons = new JButton[3][3];
for(int i = 0; i < numberButtons.length; i++) // rows
{
for(int j = 0; j < numberButtons[i].length; j++) // cols
{
int value = 3 * i + j + 1;
// instantiate buttons
numberButtons[i][j] = new JButton(Integer.toString(value));
// add buttons to panel
add(numberButtons[i][j]);
// add action listeners to buttons
numberButtons[i][j].addActionListener(new NumberButtonListener());
}
}
// instantiate label
}
private class NumberButtonListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent e)
{
System.out.println("Clicked!");
JButton clicked = (JButton) e.getSource();
clicked.setBackground(Color.RED);
}
}
}
| [
"[email protected]"
] | |
4aa84946d383d801e5a8f9bf5d2ebfe7067ec652 | 9120c105e86269e7ed6414a7b4c443c411ff6588 | /Java/exercicios/src/oo/abstrato/TesteAbstrato.java | c21fc1105ae9de2c538b52455791221b69bfa129 | [] | no_license | maikcosta/Learning | da047e35d478cd3f77ba1ee782ac8c8fb3a211ef | 0efe0b3cc04e175ce400a2e6e10d7e03cbe8b29f | refs/heads/main | 2023-05-03T13:16:15.254554 | 2023-04-19T20:58:13 | 2023-04-19T20:58:13 | 241,109,324 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 237 | java | package oo.abstrato;
public class TesteAbstrato {
public static void main(String[] args) {
Mamifero a = new Cachorro();
System.out.println(a.mover());
System.out.println(a.mamar());
System.out.println(a.respirar());
}
}
| [
"[email protected]"
] | |
884b71afc30b573324224c31baf4d2e7ada7d851 | 2c64f22b8c4235dcf8de82721d1eb20c0129499d | /src/jvm/thrift/backtype/storm/generated/JavaObjectArg.java | 5e6d5b1cc2b804a05a231014a2c85d090dda7128 | [] | no_license | hodiapa/storm-elasticity-scheduler | 7b236a1324c2642dd6c8b7b7e281721efb22d712 | 85b4b6645b3272597b66ce524bf0eb3ea6dcfec9 | refs/heads/master | 2020-12-25T22:59:05.837794 | 2014-05-10T19:53:25 | 2014-05-10T19:53:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | true | 20,257 | java | /**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package backtype.storm.generated;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JavaObjectArg extends org.apache.thrift.TUnion<JavaObjectArg, JavaObjectArg._Fields> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("JavaObjectArg");
private static final org.apache.thrift.protocol.TField INT_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("int_arg", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField LONG_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("long_arg", org.apache.thrift.protocol.TType.I64, (short)2);
private static final org.apache.thrift.protocol.TField STRING_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("string_arg", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField BOOL_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("bool_arg", org.apache.thrift.protocol.TType.BOOL, (short)4);
private static final org.apache.thrift.protocol.TField BINARY_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("binary_arg", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final org.apache.thrift.protocol.TField DOUBLE_ARG_FIELD_DESC = new org.apache.thrift.protocol.TField("double_arg", org.apache.thrift.protocol.TType.DOUBLE, (short)6);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
INT_ARG((short)1, "int_arg"),
LONG_ARG((short)2, "long_arg"),
STRING_ARG((short)3, "string_arg"),
BOOL_ARG((short)4, "bool_arg"),
BINARY_ARG((short)5, "binary_arg"),
DOUBLE_ARG((short)6, "double_arg");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // INT_ARG
return INT_ARG;
case 2: // LONG_ARG
return LONG_ARG;
case 3: // STRING_ARG
return STRING_ARG;
case 4: // BOOL_ARG
return BOOL_ARG;
case 5: // BINARY_ARG
return BINARY_ARG;
case 6: // DOUBLE_ARG
return DOUBLE_ARG;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.INT_ARG, new org.apache.thrift.meta_data.FieldMetaData("int_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.LONG_ARG, new org.apache.thrift.meta_data.FieldMetaData("long_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.STRING_ARG, new org.apache.thrift.meta_data.FieldMetaData("string_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.BOOL_ARG, new org.apache.thrift.meta_data.FieldMetaData("bool_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.BINARY_ARG, new org.apache.thrift.meta_data.FieldMetaData("binary_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.DOUBLE_ARG, new org.apache.thrift.meta_data.FieldMetaData("double_arg", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(JavaObjectArg.class, metaDataMap);
}
public JavaObjectArg() {
super();
}
public JavaObjectArg(_Fields setField, Object value) {
super(setField, value);
}
public JavaObjectArg(JavaObjectArg other) {
super(other);
}
public JavaObjectArg deepCopy() {
return new JavaObjectArg(this);
}
public static JavaObjectArg int_arg(int value) {
JavaObjectArg x = new JavaObjectArg();
x.setInt_arg(value);
return x;
}
public static JavaObjectArg long_arg(long value) {
JavaObjectArg x = new JavaObjectArg();
x.setLong_arg(value);
return x;
}
public static JavaObjectArg string_arg(String value) {
JavaObjectArg x = new JavaObjectArg();
x.setString_arg(value);
return x;
}
public static JavaObjectArg bool_arg(boolean value) {
JavaObjectArg x = new JavaObjectArg();
x.setBool_arg(value);
return x;
}
public static JavaObjectArg binary_arg(ByteBuffer value) {
JavaObjectArg x = new JavaObjectArg();
x.setBinary_arg(value);
return x;
}
public static JavaObjectArg binary_arg(byte[] value) {
JavaObjectArg x = new JavaObjectArg();
x.setBinary_arg(ByteBuffer.wrap(value));
return x;
}
public static JavaObjectArg double_arg(double value) {
JavaObjectArg x = new JavaObjectArg();
x.setDouble_arg(value);
return x;
}
@Override
protected void checkType(_Fields setField, Object value) throws ClassCastException {
switch (setField) {
case INT_ARG:
if (value instanceof Integer) {
break;
}
throw new ClassCastException("Was expecting value of type Integer for field 'int_arg', but got " + value.getClass().getSimpleName());
case LONG_ARG:
if (value instanceof Long) {
break;
}
throw new ClassCastException("Was expecting value of type Long for field 'long_arg', but got " + value.getClass().getSimpleName());
case STRING_ARG:
if (value instanceof String) {
break;
}
throw new ClassCastException("Was expecting value of type String for field 'string_arg', but got " + value.getClass().getSimpleName());
case BOOL_ARG:
if (value instanceof Boolean) {
break;
}
throw new ClassCastException("Was expecting value of type Boolean for field 'bool_arg', but got " + value.getClass().getSimpleName());
case BINARY_ARG:
if (value instanceof ByteBuffer) {
break;
}
throw new ClassCastException("Was expecting value of type ByteBuffer for field 'binary_arg', but got " + value.getClass().getSimpleName());
case DOUBLE_ARG:
if (value instanceof Double) {
break;
}
throw new ClassCastException("Was expecting value of type Double for field 'double_arg', but got " + value.getClass().getSimpleName());
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(field.id);
if (setField != null) {
switch (setField) {
case INT_ARG:
if (field.type == INT_ARG_FIELD_DESC.type) {
Integer int_arg;
int_arg = iprot.readI32();
return int_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case LONG_ARG:
if (field.type == LONG_ARG_FIELD_DESC.type) {
Long long_arg;
long_arg = iprot.readI64();
return long_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case STRING_ARG:
if (field.type == STRING_ARG_FIELD_DESC.type) {
String string_arg;
string_arg = iprot.readString();
return string_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case BOOL_ARG:
if (field.type == BOOL_ARG_FIELD_DESC.type) {
Boolean bool_arg;
bool_arg = iprot.readBool();
return bool_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case BINARY_ARG:
if (field.type == BINARY_ARG_FIELD_DESC.type) {
ByteBuffer binary_arg;
binary_arg = iprot.readBinary();
return binary_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case DOUBLE_ARG:
if (field.type == DOUBLE_ARG_FIELD_DESC.type) {
Double double_arg;
double_arg = iprot.readDouble();
return double_arg;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
return null;
}
}
@Override
protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case INT_ARG:
Integer int_arg = (Integer)value_;
oprot.writeI32(int_arg);
return;
case LONG_ARG:
Long long_arg = (Long)value_;
oprot.writeI64(long_arg);
return;
case STRING_ARG:
String string_arg = (String)value_;
oprot.writeString(string_arg);
return;
case BOOL_ARG:
Boolean bool_arg = (Boolean)value_;
oprot.writeBool(bool_arg);
return;
case BINARY_ARG:
ByteBuffer binary_arg = (ByteBuffer)value_;
oprot.writeBinary(binary_arg);
return;
case DOUBLE_ARG:
Double double_arg = (Double)value_;
oprot.writeDouble(double_arg);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
_Fields setField = _Fields.findByThriftId(fieldID);
if (setField != null) {
switch (setField) {
case INT_ARG:
Integer int_arg;
int_arg = iprot.readI32();
return int_arg;
case LONG_ARG:
Long long_arg;
long_arg = iprot.readI64();
return long_arg;
case STRING_ARG:
String string_arg;
string_arg = iprot.readString();
return string_arg;
case BOOL_ARG:
Boolean bool_arg;
bool_arg = iprot.readBool();
return bool_arg;
case BINARY_ARG:
ByteBuffer binary_arg;
binary_arg = iprot.readBinary();
return binary_arg;
case DOUBLE_ARG:
Double double_arg;
double_arg = iprot.readDouble();
return double_arg;
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
throw new TProtocolException("Couldn't find a field with field id " + fieldID);
}
}
@Override
protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
switch (setField_) {
case INT_ARG:
Integer int_arg = (Integer)value_;
oprot.writeI32(int_arg);
return;
case LONG_ARG:
Long long_arg = (Long)value_;
oprot.writeI64(long_arg);
return;
case STRING_ARG:
String string_arg = (String)value_;
oprot.writeString(string_arg);
return;
case BOOL_ARG:
Boolean bool_arg = (Boolean)value_;
oprot.writeBool(bool_arg);
return;
case BINARY_ARG:
ByteBuffer binary_arg = (ByteBuffer)value_;
oprot.writeBinary(binary_arg);
return;
case DOUBLE_ARG:
Double double_arg = (Double)value_;
oprot.writeDouble(double_arg);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
switch (setField) {
case INT_ARG:
return INT_ARG_FIELD_DESC;
case LONG_ARG:
return LONG_ARG_FIELD_DESC;
case STRING_ARG:
return STRING_ARG_FIELD_DESC;
case BOOL_ARG:
return BOOL_ARG_FIELD_DESC;
case BINARY_ARG:
return BINARY_ARG_FIELD_DESC;
case DOUBLE_ARG:
return DOUBLE_ARG_FIELD_DESC;
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected org.apache.thrift.protocol.TStruct getStructDesc() {
return STRUCT_DESC;
}
@Override
protected _Fields enumForId(short id) {
return _Fields.findByThriftIdOrThrow(id);
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public int getInt_arg() {
if (getSetField() == _Fields.INT_ARG) {
return (Integer)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'int_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setInt_arg(int value) {
setField_ = _Fields.INT_ARG;
value_ = value;
}
public long getLong_arg() {
if (getSetField() == _Fields.LONG_ARG) {
return (Long)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'long_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setLong_arg(long value) {
setField_ = _Fields.LONG_ARG;
value_ = value;
}
public String getString_arg() {
if (getSetField() == _Fields.STRING_ARG) {
return (String)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'string_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setString_arg(String value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.STRING_ARG;
value_ = value;
}
public boolean getBool_arg() {
if (getSetField() == _Fields.BOOL_ARG) {
return (Boolean)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'bool_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setBool_arg(boolean value) {
setField_ = _Fields.BOOL_ARG;
value_ = value;
}
public byte[] getBinary_arg() {
setBinary_arg(org.apache.thrift.TBaseHelper.rightSize(bufferForBinary_arg()));
ByteBuffer b = bufferForBinary_arg();
return b == null ? null : b.array();
}
public ByteBuffer bufferForBinary_arg() {
if (getSetField() == _Fields.BINARY_ARG) {
return (ByteBuffer)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'binary_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setBinary_arg(byte[] value) {
setBinary_arg(ByteBuffer.wrap(value));
}
public void setBinary_arg(ByteBuffer value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.BINARY_ARG;
value_ = value;
}
public double getDouble_arg() {
if (getSetField() == _Fields.DOUBLE_ARG) {
return (Double)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'double_arg' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setDouble_arg(double value) {
setField_ = _Fields.DOUBLE_ARG;
value_ = value;
}
public boolean isSetInt_arg() {
return setField_ == _Fields.INT_ARG;
}
public boolean isSetLong_arg() {
return setField_ == _Fields.LONG_ARG;
}
public boolean isSetString_arg() {
return setField_ == _Fields.STRING_ARG;
}
public boolean isSetBool_arg() {
return setField_ == _Fields.BOOL_ARG;
}
public boolean isSetBinary_arg() {
return setField_ == _Fields.BINARY_ARG;
}
public boolean isSetDouble_arg() {
return setField_ == _Fields.DOUBLE_ARG;
}
public boolean equals(Object other) {
if (other instanceof JavaObjectArg) {
return equals((JavaObjectArg)other);
} else {
return false;
}
}
public boolean equals(JavaObjectArg other) {
return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
}
@Override
public int compareTo(JavaObjectArg other) {
int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
if (lastComparison == 0) {
return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
}
return lastComparison;
}
/**
* If you'd like this to perform more respectably, use the hashcode generator option.
*/
@Override
public int hashCode() {
return 0;
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
}
| [
"[email protected]"
] | |
f0c883417c52c15dc78eaf19f5507c3cebb66d06 | 180e78725121de49801e34de358c32cf7148b0a2 | /dataset/protocol1/neo4j/learning/2452/BoltIOException.java | c166c824c3b85ea850e6bdd5ff41875246fa2022 | [] | no_license | ASSERT-KTH/synthetic-checkstyle-error-dataset | 40e8d1e0a7ebe7f7711def96a390891a6922f7bd | 40c057e1669584bfc6fecf789b5b2854660222f3 | refs/heads/master | 2023-03-18T12:50:55.410343 | 2019-01-25T09:54:39 | 2019-01-25T09:54:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,436 | java | /*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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.neo4j.bolt.messaging;
import java.io.IOException;
import org.neo4j.kernel.api.exceptions.Status;
public class BoltIOException extends IOException implements Status.HasStatus
{
private final Status status;
public BoltIOException( Status status, String message, Throwable cause )
{
super( message, cause );
this.status = status;
}
public BoltIOException( Status status, String message )
{
this( status, message, null );
}
@Override
public Status status()
{
return status;
}
public boolean causesFailureMessage()
{
return status != Status.Request.InvalidFormat;
}
}
| [
"[email protected]"
] | |
d71c436076d6d3d0590597131f94df346eaf6ceb | e75be673baeeddee986ece49ef6e1c718a8e7a5d | /submissions/blizzard/Corpus/eclipse.jdt.ui/5532.java | fe0d22bb18c48c5848c93ca89f960c2dd5853727 | [
"MIT"
] | permissive | zhendong2050/fse18 | edbea132be9122b57e272a20c20fae2bb949e63e | f0f016140489961c9e3c2e837577f698c2d4cf44 | refs/heads/master | 2020-12-21T11:31:53.800358 | 2018-07-23T10:10:57 | 2018-07-23T10:10:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 125 | java | //3 occurences
package p;
public class B {
static {
B a;
}
static {
B a;
}
}
| [
"[email protected]"
] | |
7971e194bdf4d29b8a67ba04f395f398e853dd7c | e09b97f3318e7b8c9b22f1b49bf58df254bf7baa | /snowdrop-examples/sportsclub/spring-4_0/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/EquipmentType.java | 54a33f164f87d3395558d383f801d29cb24acaea | [] | no_license | snowdrop/legacy_content | 2837d0c570f1886b64812211ec5ef14c2f560857 | d079a58b598f3080ccee1bc95ca137fb8ffdb9b8 | refs/heads/master | 2020-12-02T08:00:41.568207 | 2017-07-10T09:39:38 | 2017-07-10T09:39:38 | 96,759,977 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 216 | java | package org.jboss.snowdrop.samples.sportsclub.domain.entity;
import java.io.Serializable;
/**
* @author Marius Bogoevici</a>
*/
public enum EquipmentType implements Serializable {
TREADMILL, STEPPER, COURT
}
| [
"[email protected]"
] | |
55396f4f6034fef94574169c70007078abca486e | be6ccaf3c352f76b5619f94fcbc9417615a2afd4 | /src/main/java/DesignPattern/PrototypePattern/Green.java | 3afb38f69e6b49c405aec4c62725f096a101707f | [] | no_license | 785562850/ProgramBase | 99f62ad27b8895dc419007fba21c010ed5f34f4e | 6b31fa99309a7f02b80978da978a9e8eda861222 | refs/heads/master | 2021-09-05T01:51:52.317516 | 2018-01-23T15:55:03 | 2018-01-23T15:55:03 | 105,422,591 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 172 | java | package DesignPattern.PrototypePattern;
/**
* Created by john on 2017/10/1.
*/
public class Green extends Color{
public Green(){
setColor("绿色");
}
}
| [
"[email protected]"
] | |
60cc8f4b4caa878e0389214c953c35650c4ffe89 | 05f7d9c62491b15e5692bdc56a3f5adeabb29d21 | /src/CLI/commands/Echo.java | dadd24815a717cddbb860e58ca91ade085a928a3 | [] | no_license | Gameslinger/SimpleClient | 4a94554133d7107acc1cdfc6dec95ef7a6e11168 | 6becf2d55a8c6a96c94fed8ab8b34cdf18b546d1 | refs/heads/master | 2021-01-22T05:00:44.370448 | 2017-02-16T19:30:27 | 2017-02-16T19:30:27 | 81,606,685 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 746 | 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 CLI.commands;
/**
*
* @author Gabriel.Maxfield
*/
public class Echo implements ICommand{
@Override
public String getName() {
return "Echo";
}
@Override
public String response(String args[]) {
String result = "";
for(int i = 1; i < args.length; i++){
result+=args[i]+" ";
}
System.out.println(result);
return result;
}
@Override
public String[] getKeys() {
return new String[]{"e","echo"};
}
}
| [
"[email protected]"
] | |
a34dc71289b42f13070db0d8c53dbfa871c6f982 | 95c49f466673952b465e19a5ee3ae6eff76bee00 | /src/main/java/com/iflytek/voiceads/p622d/p628f/AbstractC5475g.java | 818b15a015afc81bba64eb05b83e413e82e13488 | [] | no_license | Phantoms007/zhihuAPK | 58889c399ae56b16a9160a5f48b807e02c87797e | dcdbd103436a187f9c8b4be8f71bdf7813b6d201 | refs/heads/main | 2023-01-24T01:34:18.716323 | 2020-11-25T17:14:55 | 2020-11-25T17:14:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java | package com.iflytek.voiceads.p622d.p628f;
import com.iflytek.voiceads.p622d.p626d.AbstractC5307m;
/* renamed from: com.iflytek.voiceads.d.f.g */
public interface AbstractC5475g {
/* renamed from: a */
void mo38868a(AbstractC5307m mVar, int i);
/* renamed from: b */
void mo38869b(AbstractC5307m mVar, int i);
}
| [
"[email protected]"
] | |
271f9d3bce263a79a81c61b50ebc5040648b8535 | 41c4b710d35e05f10bc8714105a478b5a356f53f | /Java/HelloWorld.java | e1eedc1e7ba9f4baa3ccb81222bedd82c0ce2414 | [] | no_license | hyunsu00/polyglotSamples | bc74a901afc527c35e91733810d6f91a56290579 | d887abaa22c15e1f41714d94d7951790abb77793 | refs/heads/main | 2023-04-10T16:51:36.013164 | 2021-04-21T02:04:02 | 2021-04-21T02:04:02 | 358,655,168 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 143 | java | // HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
| [
"[email protected]"
] | |
c91c4414434f67dddb691885392e36dedf14d2b7 | b79125d440bb387b1f5f304690bce18478a70508 | /TopicSegmenter/src/tools/segmentation/LanguageModelAnalysis.java | 7af408e19ee78dec82112e16f98ca1447fc0009a | [] | no_license | pjdrm/Segmentor | cfd78a62c3a61b38965adaf1083d6762b34cf4e7 | e158ff370380f60918a37e48e1a3adb2e7a63481 | refs/heads/master | 2021-01-15T10:14:16.570614 | 2015-04-15T16:13:22 | 2015-04-15T16:13:22 | 29,870,964 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,874 | java | package tools.segmentation;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import tools.text.similarity.SortableMap;
import tools.text.similarity.SortableMap.ORDER;
import edu.mit.nlp.MyTextWrapper;
import edu.mit.nlp.segmenter.SegTester;
public class LanguageModelAnalysis {
public static void main(String[] args) {
String filePath = args[0];
List<String> segments = getSegments(filePath);
int i = 0;
try {
String lms = "";
//just to load stop words and stuff
String[] argsSegTest = new String[]{"-config", "config/dp-mine.config", "-num-segs", "2"};
TestScript.getSegTester(argsSegTest);
for(String segment : segments){
String tmpFile = "tmp/seg" + i + ".txt";
FileUtils.write(new File(tmpFile), segment);
Map<String, Double> wordCountMap = SortableMap.sort(createLanguageModel(tmpFile), ORDER.DESCENDING);
for(String word : wordCountMap.keySet()){
lms += word + " " + wordCountMap.get(word)+"\n";
}
i++;
String segLMFile = filePath.split("/")[filePath.split("/").length-1].replaceAll("\\.txt", "txt") + "_seg"+i+".txt";
File outFile = new File("langua_model_analysis/"+segLMFile);
FileUtils.write(outFile, lms, false);
lms = "";
}
}
catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Done generating LMs");
}
private static Map<String, Double> createLanguageModel(String filePath) {
MyTextWrapper textwrapper = new MyTextWrapper(filePath);
SegTester.preprocessText(textwrapper, true, false, true, true, 0);
double[][] w = textwrapper.createWordOccurrenceTable(); //D x T matrix
Map<String, Double> wordCountMap = new HashMap<String, Double>();
for(int i = 0; i < textwrapper.getLexMap().getStemLexiconSize(); i++){
wordCountMap.put(textwrapper.getLexMap().getStem(i), sumRow(i, w));
}
return wordCountMap;
}
private static Double sumRow(int i, double[][] w) {
double sum = 0.0;
for(int j = 0; j < w[i].length; j++){
sum += w[i][j];
}
return sum;
}
private static List<String> getSegments(String filePath) {
try {
List<String> lines = FileUtils.readLines(new File(filePath));
List<String> segments = new ArrayList<String>();
String currentSeg = "==========\n";
for(int i = 1; i < lines.size(); i++){
String lin = lines.get(i);
if(lin.equals("==========")){
segments.add(currentSeg+lin);
currentSeg = "==========\n";
}
else{
currentSeg += lin+"\n";
}
}
return segments;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
] | |
bf6912eb5118fdca90f419232310d87081330d81 | d8a05377893d12dd7dec99cf9fb32be3ecb4382c | /Day 08/src/main/java/Animal.java | 8c7136893f2f8b3324fdcdaf45f2fe1749d7e6dc | [] | no_license | Willson-jr/Day-8-Object-Oriented-Programming | 5ca6873c90126ffb2ecfee01d501487799264720 | d9792a227a0c3ac667a929ae6e922c763f3ce77d | refs/heads/master | 2020-07-01T16:39:10.330887 | 2019-08-08T09:46:10 | 2019-08-08T09:46:10 | 201,228,325 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,722 | java | import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@AllArgsConstructor
@Data
public class Animal {
private String name;
private String sound;
private Boolean flag;
void speak(int times){
if (flag){
System.out.print(name+ ": ");
for (int i=0; i<times; i++){
if (i == times -1) {
System.out.println(sound.toUpperCase());
} else {
System.out.print(sound.toUpperCase()+" ");
}
}
} else {
System.out.print(name+ ": ");
for (int i=0; i<times; i++){
if (i == times -1) {
System.out.println(sound.toLowerCase());
} else {
System.out.print(sound.toLowerCase()+" ");
}
}
}
}
public static void main(String[] args) {
List<Animal> zoo = new ArrayList<>();
zoo.add(new Animal("Big dog","woof",true));
zoo.add(new Animal("cow","moo",true));
zoo.add(new Animal("Small dog","woof",false));
zoo.add(new Animal("frog","croak",false));
System.out.println("Loud animals");
for (Animal one: zoo) {
if (one.flag) {
int mult = 1+(int) (Math.random()*5);
one.speak(mult);
}
}
System.out.println("Quiet animals");
for (Animal one: zoo) {
if (!one.flag) {
int mult = 1+(int) (Math.random()*5);
one.speak(mult);
}
}
}
}
| [
"[email protected]"
] | |
1b53b7beffe922973d1b8646727291a63999450c | a664f4a9e0ecddb4a07d47adc870490bb5d419e5 | /app/src/main/java/com/householdplanner/shoppingapp/repositories/MarketRepository.java | 6c5d01acbe26289aa43aeba98b1c07360849a935 | [] | no_license | juancarlospalomo/plannehr | 3c8e49bd14d729f8807de344346ed2ea6cceb825 | 1c84fc929246377b6f4ac77f94310f18dfe0af24 | refs/heads/master | 2021-01-22T05:16:28.193676 | 2015-07-15T19:03:36 | 2015-07-15T19:03:36 | 35,100,770 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,140 | java | package com.householdplanner.shoppingapp.repositories;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import com.householdplanner.shoppingapp.cross.util;
import com.householdplanner.shoppingapp.data.ShoppingListContract;
import com.householdplanner.shoppingapp.models.Market;
import com.householdplanner.shoppingapp.stores.DatabaseHelper;
public class MarketRepository {
// Database fields
private SQLiteDatabase mDatabase;
private DatabaseHelper mMarketDbHelper;
private Context mContext;
public MarketRepository(Context context) {
mMarketDbHelper = new DatabaseHelper(context);
mContext = context;
}
private void open() throws SQLException {
mDatabase = mMarketDbHelper.getWritableDatabase();
}
private SQLiteDatabase getDatabase() {
if (mDatabase == null) {
this.open();
}
return mDatabase;
}
public void close() {
if (mDatabase != null) mDatabase.close();
if (mMarketDbHelper != null) mMarketDbHelper.close();
}
/**
* Create a new market
*
* @param market market object
* @return true if it was created
*/
public boolean insert(Market market) {
ContentValues values = new ContentValues();
values.put(ShoppingListContract.MarketEntry.COLUMN_MARKET_NAME, util.capitalize(market.name));
long insertId = getDatabase().insert(ShoppingListContract.MarketEntry.TABLE_NAME, null, values);
if (insertId > 0) {
return true;
} else {
return false;
}
}
/**
* Delete a market
* @param marketId market id
* @return true if it was deleted
*/
public boolean delete(int marketId) {
boolean result = getDatabase().delete(ShoppingListContract.MarketEntry.TABLE_NAME,
ShoppingListContract.MarketEntry._ID + "=" + marketId, null) > 0;
return result;
}
/**
* Rename the market name for a supermarket id
*
* @param marketId market id
* @param newMarketName new market name
* @return true if it was renamed
*/
public boolean renameMarket(int marketId, String newMarketName) {
boolean result = true;
ContentValues values = new ContentValues();
SQLiteDatabase database = getDatabase();
values.put(ShoppingListContract.MarketEntry.COLUMN_MARKET_NAME, util.capitalize(newMarketName));
result = database.update(ShoppingListContract.MarketEntry.TABLE_NAME, values,
ShoppingListContract.MarketEntry._ID + "=" + marketId, null) > 0;
return result;
}
/**
* Get the color represeting a supermarket
*
* @param name market name
* @return color number
*/
public Integer getMarketColor(String name) {
Integer color = null;
String sql = "SELECT " + ShoppingListContract.MarketEntry.COLUMN_COLOR
+ " FROM " + ShoppingListContract.MarketEntry.TABLE_NAME
+ " WHERE " + ShoppingListContract.MarketEntry.COLUMN_MARKET_NAME + "='" + name + "'";
Cursor cursor = getDatabase().rawQuery(sql, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
String value = cursor.getString(cursor.getColumnIndex(ShoppingListContract.MarketEntry.COLUMN_COLOR));
if (value != null) {
color = Integer.parseInt(value);
}
}
}
return color;
}
/**
* Set a color to one supermarket
*
* @param marketId market identifier
* @param color color number
*/
public void setColor(int marketId, int color) {
ContentValues values = new ContentValues();
values.put(ShoppingListContract.MarketEntry.COLUMN_COLOR, color);
getDatabase().update(ShoppingListContract.MarketEntry.TABLE_NAME, values,
ShoppingListContract.MarketEntry._ID + "=" + marketId, null);
}
}
| [
"[email protected]"
] | |
3aaf9e1e59273b06a7a2dc3db79261b43fc48ec8 | 08214f7ca2c94f7fc721c189ef33103e771bcc57 | /1. Java e Orientacao a Objetos/09. Streams, Readers e Writers/bytebank-herdado-conta/src/br/com/bytebank/banco/test/io/TesteDeserializacao.java | fedc9cf40e8fa7926710e54437d5b9da269acdc0 | [] | no_license | pedrokoii/formacao-java | 686f909f2bf8be00b997478a11436ef1158d996e | 92093c0a60981d23a2041257d1fc3438532b2871 | refs/heads/main | 2023-05-15T17:00:27.711225 | 2021-06-02T15:21:53 | 2021-06-02T15:21:53 | 367,043,260 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 651 | java | package br.com.bytebank.banco.test.io;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import br.com.bytebank.banco.modelo.ContaCorrente;
public class TesteDeserializacao {
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("cc.bin"));
ContaCorrente cc = (ContaCorrente) ois.readObject();
ois.close();
System.out.println(cc.getSaldo());
System.out.println(cc.getTitular());
}
}
| [
"[email protected]"
] | |
774206844c3643fe8b2afa98dc0794acf83fc0ef | 17863edb58b488878f0af16f0c3056a457ab2bb7 | /.idea/acessModifiers/Package2/C.java | f420ffdc8307a8727fbf94dc81d9e03ce30fcb27 | [] | no_license | pandr20/Learning | d5b02e889ca9f0d3a7eea9ecb18116b64618e18e | 8fd23f0b5a8f84ada817f91e66b32471533e210d | refs/heads/main | 2023-07-08T12:05:08.640902 | 2021-08-10T08:29:52 | 2021-08-10T08:29:52 | 394,556,458 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | java | package acessModifiers.Package2;
public class C {
public String publicMessage = "This is public";
protected String protectedMessage = "This is protected";
String defaultMessage = "This is the default";
private String privateMessage = "This is the private";
}
| [
"[email protected]"
] | |
7844572ab68a36c9efbfac80c0e463e7e2c20968 | 78175c022b2b1927846562f84e2a29080f9392cf | /app/src/main/java/com/oswald/mascotas/MainActivity.java | c614834c660b2579e662539cd7dfbec9c692ff28 | [] | no_license | OswaldRijo/MascotasPersistDatos | 1abbe4dc486de45514a40d3553543a5c10bcb009 | 3470d3b43365375c31c98ca9ef4dd0376377563a | refs/heads/master | 2021-05-14T03:49:28.418043 | 2019-12-20T19:17:51 | 2019-12-20T19:17:51 | 116,625,319 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,102 | java | package com.oswald.mascotas;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.oswald.mascotas.adapters.PagerAdapter;
import com.oswald.mascotas.fragments.PerfilFragment;
import com.oswald.mascotas.fragments.RecyclerViewFragment;
import com.oswald.mascotas.pojo.Mascota;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity{
private ArrayList <Mascota> mascotas;
private RecyclerView listaMascotas;
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.toolbar);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = (ViewPager) findViewById(R.id.viewPager);
setUpViewPager();
if(toolbar!=null){
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_opciones, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.menuContacto:
startContacto();
return true;
case R.id.menuAcercaDE:
startAcercade();
return true;
case R.id.menuFav:
startFavoritos();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private ArrayList<Fragment> agregarFragment(){
ArrayList<Fragment> fragments = new ArrayList<>();
fragments.add(new RecyclerViewFragment());
fragments.add(new PerfilFragment());
return fragments;
}
private void setUpViewPager() {
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(),agregarFragment()));
tabLayout.setupWithViewPager(viewPager);
tabLayout.getTabAt(1).setIcon(R.drawable.ic_perfil);
tabLayout.getTabAt(0).setIcon(R.drawable.ic_home);
}
private void startContacto (){
Intent intento = new Intent(this, SendingMail.class);
startActivity(intento);
}
private void startAcercade (){
Intent intento = new Intent(this, AcercaDe.class);
startActivity(intento);
}
private void startFavoritos (){
Intent intento = new Intent(this, Favorito.class);
startActivity(intento);
}
}
| [
"[email protected]"
] | |
544482230cd1703bbcbd953ce20cb5b8e26e80d5 | a7ec070eca45637c1f89e032ad3807401908dba9 | /src/main/java/com/qa/ims/persistence/dao/OrderDaoMysql.java | de8537f4c0efc7f17419e713f1fd84371ec03bb0 | [
"MIT"
] | permissive | willmccuddenQA/IMS | d7cf36b0dd79d7c85df264d70e82cd8c84db1408 | 38c5f493ca51030aef7317d74a3056e7acc6c2de | refs/heads/master | 2023-02-23T12:47:00.028865 | 2021-01-22T12:57:09 | 2021-01-22T12:57:09 | 327,897,774 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,378 | java | package com.qa.ims.persistence.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.qa.ims.persistence.domain.Customer;
import com.qa.ims.persistence.domain.Item;
import com.qa.ims.persistence.domain.Order;
public class OrderDaoMysql {
public static final Logger LOGGER = Logger.getLogger(CustomerDaoMysql.class);
private String jdbcConnectionUrl;
private String username;
private String password;
public OrderDaoMysql(String username, String password) {
this.jdbcConnectionUrl = "jdbc:mysql://34.89.52.122:3306/ims";
this.username = username;
this.password = password;
}
public OrderDaoMysql(String jdbcConnectionUrl, String username, String password) {
this.jdbcConnectionUrl = jdbcConnectionUrl;
this.username = username;
this.password = password;
}
Order orderFromResultSet(ResultSet resultSet) throws SQLException {
Long order_id = resultSet.getLong("order_id");
Long customer_id = resultSet.getLong("customer_id");
String address = resultSet.getString("address");
return new Order(order_id, customer_id, address);
}
public Order readLatest() {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM orders ORDER BY order_id DESC LIMIT 1");) {
resultSet.next();
return orderFromResultSet(resultSet);
} catch (Exception e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
return null;
}
public List<Order> readAll() {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select * from orders");) {
ArrayList<Order> orders = new ArrayList<>();
while (resultSet.next()) {
orders.add(orderFromResultSet(resultSet));
}
return orders;
} catch (SQLException e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
return new ArrayList<>();
}
public Order create(Order order) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();) {
statement.executeUpdate("insert into orders(customer_id, address) values('" + order.getCustomer_id()
+ "','" + order.getAddress() + "')");
return readLatest();
} catch (Exception e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
return null;
}
public void delete(Long id) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();) {
statement.executeUpdate("delete from orders where order_id = " + id);
} catch (Exception e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();) {
statement.executeUpdate("delete from orderline where order_id = " + id);
} catch (Exception e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
}
public void deleteItem(Long order_id, Long item_id) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();){
statement.executeUpdate("delete from orderline where order_id = '"+
order_id+"' and item_id = '" + item_id + "' limit 1");
} catch (SQLException e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
}
public double calculate(Long order_id) {
List<Item> items = readItems(order_id);
double total = 0;
for(Item item: items) {
total+= item.getPrice();
}
return total;
}
public Item itemFromResultSet(ResultSet resultSet) throws SQLException {
Long id = resultSet.getLong("item_id");
String name = resultSet.getString("item_name");
double price = resultSet.getDouble("price");
return new Item(id,name,price);
}
public List<Item> readItems(Long order_id) {
ArrayList<Long> itemIds = new ArrayList<>();
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select * from orderline where order_id = '"+
order_id+"'");) {
while (resultSet.next()) {
itemIds.add(resultSet.getLong("item_id"));
}
} catch (SQLException e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
ArrayList<Item> items = new ArrayList<>();
for(int i = 0; i < itemIds.size(); i++) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select * from items where item_id = '"+
itemIds.get(i)+"'");) {
while (resultSet.next()) {
items.add(itemFromResultSet(resultSet));
}
} catch (SQLException e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
}
return items;
}
public void addItem(Long order_id, Long item_id) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();) {
statement.executeUpdate("insert into orderline(order_id, item_id) values('" + order_id
+ "','" + item_id + "')");
} catch (Exception e) {
System.out.println("Here");
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
}
public void addItem(Order order, Long item_id) {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();) {
statement.executeUpdate("insert into orderline(order_id, item_id) values('" + order.getOrder_id()
+ "','" + item_id + "')");
} catch (Exception e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
}
public List<Item> retrieveAllItems() {
try (Connection connection = DriverManager.getConnection(jdbcConnectionUrl, username, password);
Statement statement = connection.createStatement();){
ArrayList<Item> items = new ArrayList<>();
ResultSet resultSet = statement.executeQuery("select * from items");
while(resultSet.next()) {
items.add(itemFromResultSet(resultSet));
}
return items;
} catch (SQLException e) {
LOGGER.debug(e.getStackTrace());
LOGGER.error(e.getMessage());
}
return new ArrayList<>();
}
public String getJdbcConnectionUrl() {
return jdbcConnectionUrl;
}
public void setJdbcConnectionUrl(String jdbcConnectionUrl) {
this.jdbcConnectionUrl = jdbcConnectionUrl;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"[email protected]"
] | |
fe76780136ce48923a1bd60088e6f03e0466c170 | 11c309fe3e14bbe852a57f5687da5cacce893d10 | /Collections/src/Collections/Arraylist_compare.java | 37598e331f7bba71f10459a64187d82a43dfbcff | [] | no_license | somnath-pal-sudo/MiscleniousCode | 45668e304db8099b01a36b25488c3c58d6c012f3 | d36f10adbabd10b7fba39375b21036d620bc2c27 | refs/heads/master | 2023-04-07T20:20:48.922830 | 2021-04-05T14:22:29 | 2021-04-05T14:22:29 | 337,334,049 | 0 | 0 | null | 2021-04-05T14:22:30 | 2021-02-09T08:08:17 | HTML | UTF-8 | Java | false | false | 760 | java | package Collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class Arraylist_compare {
public static void main(String[] args) {
ArrayList<String> al1= new ArrayList<String>(Arrays.asList("A","B","C","D"));
ArrayList<String> al2= new ArrayList<String>(Arrays.asList("A","B","C","D","E"));
Collections.sort(al1);
Collections.sort(al2);
//System.out.println(al1.equals(al2));
//compare 2 list to find out the extra element
ArrayList<String> al3= new ArrayList<String>(Arrays.asList("A","B","C","D","E"));
ArrayList<String> al4= new ArrayList<String>(Arrays.asList("A","B","C","D","F"));
String al5=al3.removeAll(al4).toList());
System.out.println(al5);
}
}
| [
"[email protected]"
] | |
a83be05171e807a11e248b64862e516817ed255d | 62dc01dd35467584ae21f11b91f47aff7a9823cc | /FizzBuzz.java | 2058a840c342f1a6b9e97ad96cb7cea1da1f8356 | [] | no_license | MHassanNadeem/leetcode | edc31e5c97db8f1befd4b725abaa83b0dd7c074f | 12ccfe4781469409eb1189e6de76d02e3cbc358a | refs/heads/master | 2021-01-22T21:45:41.287513 | 2018-01-04T18:17:12 | 2018-01-04T18:17:12 | 85,472,742 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 786 | java | package leetcode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/* #412 Fizz Buzz
* href: https://leetcode.com/problems/fizz-buzz/ */
public class FizzBuzz {
public static List<String> solve(int n){
List<String> list = new ArrayList<String>();
for(int i=1; i<=n; i++){
if(i%15 == 0){
list.add("FizzBuzz");
}else if(i%5 == 0){
list.add("Buzz");
}else if(i%3 == 0){
list.add("Fizz");
}else{
list.add( Integer.toString(i) );
}
}
return list;
}
public static void main(String[] args) {
System.out.println( Arrays.toString( solve(20).toArray() ) );
}
}
| [
"[email protected]"
] | |
673c317cf843b17585fbc5f649eb7f1bb0ceb796 | 0a1d5c7e0c3cff80b3561a4e8000049bf7c02b5f | /src/copy.java | e9af4983b264b2dafd5312aa2f39760d8126ff9e | [] | no_license | yash15BCE0489/Yash | fd6597b4537c8f67816530a64ae4e96df1202b0c | 872a7335456c6cb4bbb2a8c89a90e9736bcaf51d | refs/heads/master | 2021-05-08T18:41:15.705740 | 2018-01-30T11:38:46 | 2018-01-30T11:38:46 | 119,527,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 396 | java | import java.io.*;
import java.util.zip.*;
public class copy {
public static void main(String args[]) throws IOException
{
FileInputStream fis=new FileInputStream("shivi.txt");
FileOutputStream fos= new FileOutputStream("1.txt");
int d;
while ((d=fis.read())!=-1)
{
fos.write(d);
}
fos.close();
fis.close();
}
}
| [
"[email protected]"
] | |
2f591533f8c1bb01f864d756637886d1df0e2abc | f08256664e46e5ac1466f5c67dadce9e19b4e173 | /sources/p602m/p613d/p639c/p648b/C13784a.java | 46d90950bd59da5e728a6188a6d57784f6584be1 | [] | no_license | IOIIIO/DisneyPlusSource | 5f981420df36bfbc3313756ffc7872d84246488d | 658947960bd71c0582324f045a400ae6c3147cc3 | refs/heads/master | 2020-09-30T22:33:43.011489 | 2019-12-11T22:27:58 | 2019-12-11T22:27:58 | 227,382,471 | 6 | 3 | null | null | null | null | UTF-8 | Java | false | false | 704 | java | package p602m.p613d.p639c.p648b;
import java.security.Provider;
import java.security.Security;
import p602m.p613d.p649d.p651b.C13792a;
/* renamed from: m.d.c.b.a */
/* compiled from: BCJcaJceHelper */
public class C13784a extends C13786c {
/* renamed from: b */
private static volatile Provider f30598b;
public C13784a() {
super(m42302a());
}
/* renamed from: a */
private static Provider m42302a() {
String str = "SC";
if (Security.getProvider(str) != null) {
return Security.getProvider(str);
}
if (f30598b != null) {
return f30598b;
}
f30598b = new C13792a();
return f30598b;
}
}
| [
"[email protected]"
] | |
6c371b1005bb831c74718d925694f2a9056eaa26 | 21acdd0951caae14a6a98135455abe1d5fda24ac | /src/Main/Main.java | 6e5a704e4ffa0ae7b0cd755ce933196ae895698c | [] | no_license | HenrikSwahn/TicTacToeServer | cf61a0cf7fa23694d6ad16a366384f6a3188154a | b5b43f93e7cf86aaeda3d05c7e07c1b2b04be27d | refs/heads/master | 2021-01-01T20:35:38.054104 | 2015-05-13T21:07:30 | 2015-05-13T21:07:30 | 33,875,623 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package Main;
import GUI.Window;
import Server.Server;
/**
* Created by henrik on 13/04/15.
*/
public class Main {
public static void main(String[] args) {
Server server = Server.getInstance();
server.setPort(6066);
Window window = new Window("Hello World");
server.setWindow(window);
new Thread(server).start();
}
}
| [
"[email protected]"
] | |
5e0fd3e4e7fc255411fd3484869c591566f47d4c | 4b9b0326f2e5108564fbe36d47bad6bb4476de34 | /src/Main.java | a3416d2819ec19719f06e0427670036ab815bc69 | [] | no_license | khoidt21/Project02_MDBooks | 09759992531520d49b1c2c82b7d210ea0feb8a3f | 7a3ecb2bac3a203f8377e5b4787a5e788fbdc01f | refs/heads/master | 2020-08-28T20:06:14.022449 | 2019-10-30T14:24:03 | 2019-10-30T14:24:03 | 217,808,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,104 | java |
import entity.Book;
import java.util.InputMismatchException;
import util.MyList;
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @author ADMIN
*/
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//boolean mainLoop = true;
BookList bookList = new BookList();
int choice = 0;
do {
System.out.println("Book List");
System.out.println("1. Input Book and add to the end");
System.out.println("2. Display books");
System.out.println("3. Search by code");
System.out.println("4. Input Book and add to beginning");
System.out.println("5. Add Book after position k");
System.out.println("6. Delete Book at position k");
System.out.println("7. Sort Book By Code");
System.out.println("8. Sort By Price Ascending");
System.out.println("0. Exit");
System.out.println("Enter your choice: ");
try {
choice = input.nextInt();
if (choice < 1 || choice > 8) {
System.out.printf("You have not entered a number between 0 and 8. " + "Try again.\n");
System.out.printf("Enter your choice between 0 and 8 only: \n");
continue;
}
switch (choice) {
case 1:
bookList.addLast();
break;
case 2:
bookList.list();
break;
case 3:
bookList.search();
break;
case 4:
bookList.addFirst();
break;
case 5:
bookList.addAfter();
break;
case 6:
bookList.deleteAt();
break;
case 7:
// sort by code
bookList.sortBookByCode();
bookList.list();
break;
case 8:
// sort price
bookList.sortBookByPrice();
bookList.list();
break;
case 0:
System.out.println("Exiting Program...");
System.exit(0);
break;
default:
System.out.println(choice + " is not a valid Menu Option! Please Select Another.");
}
} catch (InputMismatchException ex) {
System.out.println("You have entered choice is number. Try again.");
break;
}
} while (choice != 0);
}
}
| [
"[email protected]"
] | |
f1ffb62aa064e3476db4b89f8f64a5298f8bce03 | 98484b63c38e6a60f137674b58c17be1cf87c23c | /src/main/java/org/blockartistry/mod/DynSurround/client/fx/JetEffect.java | 1f24d7e39b0e7e54554c5230e5508c5222fea91e | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | ACGaming/DynamicSurroundings | 8cff928ea1a8f015e1968dc065c477a7be42263c | b338b39f755c48419238becb83f841968431305b | refs/heads/master | 2021-01-12T08:36:22.558913 | 2016-12-16T05:32:11 | 2016-12-16T05:32:11 | 76,632,638 | 0 | 0 | null | 2016-12-16T07:39:04 | 2016-12-16T07:39:03 | null | UTF-8 | Java | false | false | 6,797 | java | /*
* This file is part of Dynamic Surroundings, licensed under the MIT License (MIT).
*
* Copyright (c) OreCruncher
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.blockartistry.mod.DynSurround.client.fx;
import java.util.Random;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleBubbleJet;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleDustJet;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleFireJet;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleFountainJet;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleHelper;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleJet;
import org.blockartistry.mod.DynSurround.client.fx.particle.ParticleSteamJet;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public abstract class JetEffect extends BlockEffect {
private static final int MAX_STRENGTH = 10;
protected final BlockPos.MutableBlockPos pos1 = new BlockPos.MutableBlockPos();
protected int countBlocks(final World world, final BlockPos pos, final IBlockState state, final int dir) {
int count = 0;
int idx = pos.getY();
while (count < MAX_STRENGTH) {
if (world.getBlockState(pos1.setPos(pos.getX(), idx, pos.getZ())).getBlock() != state.getBlock())
return count;
count++;
idx += dir;
}
return count;
}
// Takes into account partial blocks because of flow
private static double jetSpawnHeight(final World world, final BlockPos pos) {
final IBlockState state = world.getBlockState(pos);
final int meta = state.getBlock().getMetaFromState(state);
return 1.1D - BlockLiquid.getLiquidHeightPercent(meta) + pos.getY();
}
public JetEffect(final int chance) {
super(chance);
}
protected void addEffect(final ParticleJet fx) {
ParticleHelper.addParticle(fx);
fx.playSound();
}
public static class Fire extends JetEffect {
public Fire(final int chance) {
super(chance);
}
@Override
public boolean trigger(final IBlockState state, final World world, final BlockPos pos, final Random random) {
return super.trigger(state, world, pos, random) && world.isAirBlock(pos.up());
}
public void doEffect(final IBlockState state, final World world, final BlockPos pos, final Random random) {
final int lavaBlocks = countBlocks(world, pos, state, -1);
final double spawnHeight = jetSpawnHeight(world, pos);
final ParticleJet effect = new ParticleFireJet(lavaBlocks, world, pos.getX() + 0.5D, spawnHeight,
pos.getZ() + 0.5D);
addEffect(effect);
}
}
public static class Bubble extends JetEffect {
public Bubble(final int chance) {
super(chance);
}
@Override
public boolean trigger(final IBlockState state, final World world, final BlockPos pos, final Random random) {
return super.trigger(state, world, pos, random) && world.getBlockState(pos.down()).getMaterial().isSolid();
}
public void doEffect(final IBlockState state, final World world, final BlockPos pos, final Random random) {
final int waterBlocks = countBlocks(world, pos, state, 1);
final ParticleJet effect = new ParticleBubbleJet(waterBlocks, world, pos.getX() + 0.5D, pos.getY() + 0.1D,
pos.getZ() + 0.5D);
addEffect(effect);
}
}
public static class Steam extends JetEffect {
public Steam(final int chance) {
super(chance);
}
protected int lavaCount(final World world, final BlockPos pos) {
int blockCount = 0;
for (int i = -1; i <= 1; i++)
for (int j = -1; j <= 1; j++)
for (int k = -1; k <= 1; k++) {
if (world.getBlockState(pos.add(i, j, k)).getBlock() == Blocks.LAVA)
blockCount++;
}
return blockCount;
}
@Override
public boolean trigger(final IBlockState state, final World world, final BlockPos pos, final Random random) {
if (!super.trigger(state, world, pos, random) || !world.isAirBlock(pos.up()))
return false;
return lavaCount(world, pos) != 0;
}
public void doEffect(final IBlockState state, final World world, final BlockPos pos, final Random random) {
final int strength = lavaCount(world, pos);
final double spawnHeight = jetSpawnHeight(world, pos);
final ParticleJet effect = new ParticleSteamJet(strength, world, pos.getX() + 0.5D, spawnHeight,
pos.getZ() + 0.5D);
addEffect(effect);
}
}
public static class Dust extends JetEffect {
public Dust(final int chance) {
super(chance);
}
@Override
public boolean trigger(final IBlockState state, final World world, final BlockPos pos, final Random random) {
return super.trigger(state, world, pos, random) && world.isAirBlock(pos.down());
}
public void doEffect(final IBlockState state, final World world, final BlockPos pos, final Random random) {
final ParticleJet effect = new ParticleDustJet(2, world, pos.getX() + 0.5D, pos.getY() - 0.2D,
pos.getZ() + 0.5D, state);
addEffect(effect);
}
}
public static class Fountain extends JetEffect {
public Fountain(final int chance) {
super(chance);
}
@Override
public boolean trigger(final IBlockState state, final World world, final BlockPos pos, final Random random) {
return super.trigger(state, world, pos, random) && world.isAirBlock(pos.up());
}
public void doEffect(final IBlockState state, final World world, final BlockPos pos, final Random random) {
final ParticleJet effect = new ParticleFountainJet(5, world, pos.getX() + 0.5D, pos.getY() + 1.1D,
pos.getZ() + 0.5D, state);
addEffect(effect);
}
}
}
| [
"[email protected]"
] | |
8c6dd62b602e984ae2c736393d310751723b33a3 | 2a37bbbb1b6d0c58afa49825cb876cd8e102ef5d | /src/L18_StackQueueQs/StackQs.java | fbb016942d2191b591d66d2aa46f1c6efeaae72d | [] | no_license | coding-blocks-archives/Crux25Jan2020PP | cf008d94b471facd8ebc5ad340774da6c91fe229 | e66f71638485931ef0973e582f23a478f1726e1d | refs/heads/master | 2020-12-22T05:07:53.785859 | 2020-07-15T15:19:08 | 2020-07-15T15:19:08 | 236,677,840 | 6 | 7 | null | null | null | null | UTF-8 | Java | false | false | 1,126 | java | package L18_StackQueueQs;
import L16_StackQueue.DynamicStack;
public class StackQs {
public static void main(String[] args) throws Exception {
DynamicStack stack = new DynamicStack();
stack.push(10);
stack.push(20);
stack.push(30);
stack.push(40);
stack.push(50);
stack.display(); // 50 40 30 20 10
displayReverse(stack); // 10 20 30 40 50
stack.display(); // 50 40 30 20 10
stack.display(); // 50 40 30 20 10
actualReverse(stack, new DynamicStack());
stack.display(); // 10 20 30 40 50
}
public static void displayReverse(DynamicStack s) throws Exception {
if (s.isEmpty()) {
return;
}
int temp = s.pop();
displayReverse(s);
System.out.println(temp);
s.push(temp);
}
public static void actualReverse(DynamicStack s, DynamicStack t) throws Exception {
if (s.isEmpty()) {
actualReverseHelper(s, t);
return;
}
t.push(s.pop());
actualReverse(s, t);
}
public static void actualReverseHelper(DynamicStack s, DynamicStack t) throws Exception {
if (t.isEmpty()) {
return;
}
int temp = t.pop();
actualReverseHelper(s, t);
s.push(temp);
}
}
| [
"[email protected]"
] | |
422acdefada047dd5962d75a9ec94eb8f104eb8e | fdb0ba5d64503231ca3234af5a614d699edadf7e | /Hadoop/Java_MapReduce_Simple/Jobs/PostalDistrictCount.java | fb8ab9c4063cc241ed3a951541b44dd66d6fabcf | [] | no_license | alexdgarland/database-demos | ac3ce42ac19baa7a682931f59f9df81e70774f07 | 80bbd74a21a55de20bc2d971fbd512091c5e67f8 | refs/heads/main | 2022-07-10T06:53:08.090075 | 2015-06-16T22:09:19 | 2015-06-16T22:09:19 | 28,584,551 | 0 | 0 | null | 2022-06-22T16:49:10 | 2014-12-29T07:42:58 | C# | UTF-8 | Java | false | false | 367 | java | package Jobs;
import AddressPartMappers.PostalDistrictMapper;
public class PostalDistrictCount
{
public static void main(String[] args) throws Exception
{
AddressPartCountJob.Run
(
PostalDistrictCount.class,
PostalDistrictMapper.class,
"Postal district count",
args
);
}
}
| [
"[email protected]"
] | |
5ec864c0b675ce5cb67cf367a43060d3a03828a9 | 67b7bc7215abc4869bf911a5dd550098689a5795 | /app/src/main/java/com/xgx/demo/utils/DateUtil.java | 0a10fbdfafb4278d9b7bfb596754a899327006b7 | [] | no_license | jinxingxgx/zydemo | 0031fe663246cb6fa171bfb6bf103d064d22ede3 | a2916eef07a120fa0c379a483c753311ed9386e0 | refs/heads/master | 2020-05-24T22:34:22.969166 | 2019-05-19T16:13:16 | 2019-05-19T16:13:16 | 187,499,621 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 276 | java | package com.xgx.demo.utils;
import java.util.Calendar;
import java.util.Date;
/**
*/
public class DateUtil {
public static Date getDateFromLong(long time){
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time);
return calendar.getTime();
}
}
| [
"[email protected]"
] | |
916828b19da6327d102437fe83659178b7ca298f | e3371c88a4398b2e8c5a932740d85561447582ed | /app/src/main/java/com/example/elric/myapplication/User.java | aea9a83ca00adcb2532f9b14e54532b5767b0580 | [] | no_license | elriczhan/MyApplication | 2cec9b6ff8b7c1f7b882913a97dbdbb1c06247b1 | 071416887baa2b4533f98411e14ceb6478462c99 | refs/heads/master | 2021-04-12T10:30:22.213540 | 2019-01-02T07:12:18 | 2019-01-02T07:12:18 | 94,753,788 | 5 | 0 | null | 2017-07-20T09:09:13 | 2017-06-19T08:25:32 | Java | UTF-8 | Java | false | false | 882 | java | package com.example.elric.myapplication;
/**
* Created by xinshei on 2018/3/5.
*/
class User {
private String name;
private int age;
private Long time;
private String avantar;
private String clazz;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public String getAvantar() {
return avantar;
}
public void setAvantar(String avantar) {
this.avantar = avantar;
}
public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
}
| [
"[email protected]"
] | |
b7e10f9780a7f8444824f84f8ef1c51cc8ddc4e7 | 64dc6a991fdadd2f64af075cac595572ac7651d1 | /app/src/main/java/nanifarfalla/app/invoices/domain/criteria/InvoicesUiNoFilter.java | d5b52cc66cc3f83709d4948f2bc5fe032e7d4442 | [] | no_license | joffrehermosilla/NanifarfallaAndroid | 3969fb73123ea73123e7294a194992dacfc43849 | 1bf6fbdb9af99f7d4f561c9078f5cfd513330310 | refs/heads/master | 2022-12-26T08:08:18.041173 | 2020-10-02T17:01:58 | 2020-10-02T17:01:58 | 277,023,481 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 414 | java | package nanifarfalla.app.invoices.domain.criteria;
import nanifarfalla.app.invoices.domain.entities.InvoiceUi;
import nanifarfalla.app.selection.specification.MemorySpecification;
/**
* Especificación para todos las facturas parciales
*/
public class InvoicesUiNoFilter implements MemorySpecification<InvoiceUi> {
@Override
public boolean isSatisfiedBy(InvoiceUi item) {
return true;
}
}
| [
"[email protected]"
] | |
176848f41a27c26c1d10b43f39d7ed8afbf002f5 | deac36a2f8e8d4597e2e1934ab8a7dd666621b2b | /java源码的副本/src-1/java.corba/org/omg/PortableServer/ThreadPolicy.java | 06f2b35241ba17e7453904cf5c49b5b5b9ea1bfa | [] | no_license | ZytheMoon/First | ff317a11f12c4ec7714367994924ee9fb4649611 | 9078fb8be8537a98483c50928cb92cf9835aed1c | refs/heads/master | 2021-04-27T00:09:31.507273 | 2018-03-06T12:25:56 | 2018-03-06T12:25:56 | 123,758,924 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 575 | java | package org.omg.PortableServer;
/**
* org/omg/PortableServer/ThreadPolicy.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from t:/workspace/corba/src/java.corba/share/classes/org/omg/PortableServer/poa.idl
* Tuesday, December 19, 2017 6:16:18 PM PST
*/
/**
* The ThreadPolicy specifies the threading model
* used with the created POA. The default is
* ORB_CTRL_MODEL.
*/
public interface ThreadPolicy extends ThreadPolicyOperations, org.omg.CORBA.Policy, org.omg.CORBA.portable.IDLEntity
{
} // interface ThreadPolicy
| [
"[email protected]"
] | |
f100c5f5a09cb91d644e09d8c189fe5e954f9e16 | 649986e965f1e2824e48cd7a602f4c1ba2393b9c | /coinChange.java | eddce427157b824dc325cfdf85f76a9009421ca3 | [] | no_license | A-B-N/DP-1 | 1d31d181d565c590e7ac96049ae7a40f1ed49e45 | 0a3646d5f428560f249c9dce805a4837a56d67d7 | refs/heads/master | 2020-07-14T07:35:57.574735 | 2019-08-30T05:17:59 | 2019-08-30T05:17:59 | 205,275,749 | 0 | 0 | null | 2019-08-30T00:46:17 | 2019-08-30T00:46:17 | null | UTF-8 | Java | false | false | 1,092 | java | //Time Complexity:O(S*n) where S is the amount and n is the number of iterations.
//Space Complexity:O(S)
// In this program, I'll be creating an extra space for the memoization table. I'll fill up the array till amount +1. I'll be having two loops, with the outer loop iterating through the amount and the inner loop for the length of the coins array. Inside the loop I'll check if the denomination is less than my amount. In that case, I'll take the minumum of that +1 as my dp[i].If my Dp[amount] is greater than amount, then I'll return -1. Else I'll return the dp[amount].
//This program was executed successfully and got accepted in leetcode.
class Solution {
public int coinChange(int[] coins, int amount) {
int[] dp=new int[amount+1];
Arrays.fill(dp,amount+1);
dp[0]=0;
for(int i=1;i<=amount;i++){
for(int j=0;j<coins.length;j++){
if(coins[j]<=i){
dp[i]=Math.min(dp[i],dp[i-coins[j]]+1);
}
}
}
return dp[amount]>amount?-1:dp[amount];
}
} | [
"[email protected]"
] | |
b9297811a877751527410b22e6a7173fbf672296 | b34654bd96750be62556ed368ef4db1043521ff2 | /registration_validation/trunk/src/java/tests/com/topcoder/registration/validation/accuracytests/AccuracyTestMemberNotBarredValidator.java | ede11220592637c95c0e9781d987d4967588675e | [] | no_license | topcoder-platform/tcs-cronos | 81fed1e4f19ef60cdc5e5632084695d67275c415 | c4ad087bb56bdaa19f9890e6580fcc5a3121b6c6 | refs/heads/master | 2023-08-03T22:21:52.216762 | 2019-03-19T08:53:31 | 2019-03-19T08:53:31 | 89,589,444 | 0 | 1 | null | 2019-03-19T08:53:32 | 2017-04-27T11:19:01 | null | UTF-8 | Java | false | false | 2,913 | java | /*
* Copyright (C) 2007 TopCoder Inc., All Rights Reserved.
*/
package com.topcoder.registration.validation.accuracytests;
import junit.framework.TestCase;
import com.cronos.onlinereview.external.impl.ExternalUserImpl;
import com.topcoder.registration.validation.ValidationInfo;
import com.topcoder.registration.validation.validators.simple.MemberNotBarredValidator;
import com.topcoder.util.datavalidator.BundleInfo;
/**
* This class contains unit tests for <code>MemberNotBarredValidator</code>
* class.
*
* @author TCSDEVELOPER
* @version 1.0
*/
public class AccuracyTestMemberNotBarredValidator extends TestCase {
/**
* The BundleInfo instance used to test.
*/
private BundleInfo bundleInfo;
/**
* The MemberNotBarredValidator instance used to test.
*/
private MemberNotBarredValidator validator = null;
/**
* Set Up the test environment before testing.
*
* @throws Exception
* to JUnit.
*/
protected void setUp() throws Exception {
super.setUp();
AccuracyTestHelper.loadNamespaces();
validator = new MemberNotBarredValidator("MemberMinimumReliabilityForRatingTypeValidator.ns");
bundleInfo = validator.getBundleInfo();
AccuracyTestHelper.setLog(validator);
}
/**
* Clean up the test environment after testing.
*
* @throws Exception
* to JUnit.
*/
protected void tearDown() throws Exception {
super.tearDown();
AccuracyTestHelper.clearNamespaces();
}
/**
* Function test : Tests
* <code>MemberNotBarredValidator(BundleInfo bundleInfo,
* int minimumNumRatings, RatingType ratingType)</code>
* method for accuracy.
*
* @throws Exception
* to JUnit.
*/
public void testMemberNotBarredValidator1Accuracy() throws Exception {
assertNotNull("Null is allowed.", new MemberNotBarredValidator(bundleInfo));
}
/**
* Function test : Tests <code>getMessage(Object obj)</code> method for
* accuracy, numRatings >= this.minimumNumRatings
*
* @throws Exception
* to JUnit.
*/
public void testGetMessageAccuracy1() throws Exception {
ValidationInfo info = AccuracyTestHelper.createValidationInfo();
info.setUser(new ExternalUserImpl(2, "handle1", "firstName", "lastName", "[email protected]"));
String msg = validator.getMessage(info);
assertNull("Null is expected.", msg);
}
/**
* Function test : Tests <code>getMessage(Object obj)</code> method for
* accuracy, numRatings < this.minimumNumRatings
*
* @throws Exception
* to JUnit.
*/
public void testGetMessageAccuracy2() throws Exception {
validator = new MemberNotBarredValidator(bundleInfo);
AccuracyTestHelper.setLog(validator);
ValidationInfo info = AccuracyTestHelper.createValidationInfo();
info.setUser(new ExternalUserImpl(3, "handle1", "firstName", "lastName", "[email protected]"));
String msg = validator.getMessage(info);
assertNotNull("Null is allowed.", msg);
}
} | [
"slion@fb370eea-3af6-4597-97f7-f7400a59c12a"
] | slion@fb370eea-3af6-4597-97f7-f7400a59c12a |
470bf70d0ced2b800602411d839da9a1ef788aac | 1ef7a44eb552547cd14efbbb0f54172f282e90c1 | /tajo-core/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java | f09d104637bbd99d07600e72cf51ca034d954cdf | [
"Apache-2.0",
"PostgreSQL",
"BSD-3-Clause",
"MIT"
] | permissive | i1befree/tajo-1 | bc1a982332ccc442ada2f77bc3fc26629bb81914 | ca03711b8d3ce2ace9803084a09153509d69f826 | refs/heads/master | 2021-01-09T06:38:21.836345 | 2015-05-18T01:24:45 | 2015-05-18T01:24:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,982 | 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.tajo.engine.planner.physical;
import org.apache.hadoop.fs.Path;
import org.apache.tajo.LocalTajoTestingUtility;
import org.apache.tajo.TajoConstants;
import org.apache.tajo.TajoTestingCluster;
import org.apache.tajo.algebra.Expr;
import org.apache.tajo.catalog.*;
import org.apache.tajo.catalog.proto.CatalogProtos.StoreType;
import org.apache.tajo.common.TajoDataTypes.Type;
import org.apache.tajo.conf.TajoConf;
import org.apache.tajo.datum.Datum;
import org.apache.tajo.datum.DatumFactory;
import org.apache.tajo.engine.parser.SQLAnalyzer;
import org.apache.tajo.engine.planner.*;
import org.apache.tajo.engine.planner.enforce.Enforcer;
import org.apache.tajo.plan.LogicalPlan;
import org.apache.tajo.plan.LogicalPlanner;
import org.apache.tajo.plan.PlanningException;
import org.apache.tajo.plan.logical.LogicalNode;
import org.apache.tajo.engine.query.QueryContext;
import org.apache.tajo.storage.*;
import org.apache.tajo.storage.fragment.FileFragment;
import org.apache.tajo.util.CommonTestingUtil;
import org.apache.tajo.worker.TaskAttemptContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.Random;
import static org.apache.tajo.TajoConstants.DEFAULT_TABLESPACE_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class TestExternalSortExec {
private TajoConf conf;
private TajoTestingCluster util;
private final String TEST_PATH = "target/test-data/TestExternalSortExec";
private CatalogService catalog;
private SQLAnalyzer analyzer;
private LogicalPlanner planner;
private StorageManager sm;
private Path testDir;
private final int numTuple = 100000;
private Random rnd = new Random(System.currentTimeMillis());
private TableDesc employee;
@Before
public void setUp() throws Exception {
this.conf = new TajoConf();
util = new TajoTestingCluster();
catalog = util.startCatalogCluster().getCatalog();
testDir = CommonTestingUtil.getTestDir(TEST_PATH);
catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
conf.setVar(TajoConf.ConfVars.WORKER_TEMPORAL_DIR, testDir.toString());
sm = StorageManager.getStorageManager(conf, testDir);
Schema schema = new Schema();
schema.addColumn("managerid", Type.INT4);
schema.addColumn("empid", Type.INT4);
schema.addColumn("deptname", Type.TEXT);
TableMeta employeeMeta = CatalogUtil.newTableMeta(StoreType.CSV);
Path employeePath = new Path(testDir, "employee.csv");
Appender appender = StorageManager.getStorageManager(conf).getAppender(employeeMeta, schema, employeePath);
appender.enableStats();
appender.init();
Tuple tuple = new VTuple(schema.size());
for (int i = 0; i < numTuple; i++) {
tuple.put(new Datum[] {
DatumFactory.createInt4(rnd.nextInt(50)),
DatumFactory.createInt4(rnd.nextInt(100)),
DatumFactory.createText("dept_" + i),
});
appender.addTuple(tuple);
}
appender.flush();
appender.close();
System.out.println(appender.getStats().getNumRows() + " rows (" + (appender.getStats().getNumBytes() / 1048576) +
" MB)");
employee = new TableDesc("default.employee", schema, employeeMeta, employeePath);
catalog.createTable(employee);
analyzer = new SQLAnalyzer();
planner = new LogicalPlanner(catalog);
}
@After
public void tearDown() throws Exception {
CommonTestingUtil.cleanupTestDir(TEST_PATH);
util.shutdownCatalogCluster();
}
String[] QUERIES = {
"select managerId, empId from employee order by managerId, empId"
};
@Test
public final void testNext() throws IOException, PlanningException {
FileFragment[] frags = StorageManager.splitNG(conf, "default.employee", employee.getMeta(), employee.getPath(),
Integer.MAX_VALUE);
Path workDir = new Path(testDir, TestExternalSortExec.class.getName());
TaskAttemptContext ctx = new TaskAttemptContext(new QueryContext(conf),
LocalTajoTestingUtility.newQueryUnitAttemptId(), new FileFragment[] { frags[0] }, workDir);
ctx.setEnforcer(new Enforcer());
Expr expr = analyzer.parse(QUERIES[0]);
LogicalPlan plan = planner.createPlan(LocalTajoTestingUtility.createDummyContext(conf), expr);
LogicalNode rootNode = plan.getRootBlock().getRoot();
PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf, sm);
PhysicalExec exec = phyPlanner.createPlan(ctx, rootNode);
ProjectionExec proj = (ProjectionExec) exec;
// TODO - should be planed with user's optimization hint
if (!(proj.getChild() instanceof ExternalSortExec)) {
UnaryPhysicalExec sortExec = proj.getChild();
SeqScanExec scan = sortExec.getChild();
ExternalSortExec extSort = new ExternalSortExec(ctx, sm,
((MemSortExec)sortExec).getPlan(), scan);
proj.setChild(extSort);
}
Tuple tuple;
Tuple preVal = null;
Tuple curVal;
int cnt = 0;
exec.init();
long start = System.currentTimeMillis();
BaseTupleComparator comparator = new BaseTupleComparator(proj.getSchema(),
new SortSpec[]{
new SortSpec(new Column("managerid", Type.INT4)),
new SortSpec(new Column("empid", Type.INT4))
});
while ((tuple = exec.next()) != null) {
curVal = tuple;
if (preVal != null) {
assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0);
}
preVal = curVal;
cnt++;
}
long end = System.currentTimeMillis();
assertEquals(numTuple, cnt);
// for rescan test
preVal = null;
exec.rescan();
cnt = 0;
while ((tuple = exec.next()) != null) {
curVal = tuple;
if (preVal != null) {
assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0);
}
preVal = curVal;
cnt++;
}
assertEquals(numTuple, cnt);
exec.close();
System.out.println("Sort Time: " + (end - start) + " msc");
}
}
| [
"[email protected]"
] | |
1d61b842f7e0e47d8dc85709d9730d03ce15747b | e39dae9abeba284e68ef6b1917983dd1af0df8bc | /src/main/java/spring/controller/UserController.java | b419903d1502ef09f33d0e17b7709d57b1a7b680 | [] | no_license | MrNopi/SpringProject | e1965db0d0af1a860e441d94e1c58fec0d279b61 | d42e45c099fdd79f4204ca2ea90b6e03302f7ed2 | refs/heads/master | 2022-12-23T07:14:12.240386 | 2020-02-18T14:21:58 | 2020-02-18T14:21:58 | 239,993,813 | 0 | 0 | null | 2022-12-16T15:25:14 | 2020-02-12T11:13:55 | Java | UTF-8 | Java | false | false | 1,845 | java | package spring.controller;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
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 spring.dto.UserResponseDto;
import spring.model.User;
import spring.service.UserService;
@RestController()
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@GetMapping(value = "/inject")
public void inject() {
User user = new User();
user.setLogin("user1");
user.setPassword("1");
userService.add(user);
User user2 = new User();
user2.setLogin("user2");
user2.setPassword("12");
userService.add(user2);
User user3 = new User();
user3.setLogin("user3");
user3.setPassword("123");
userService.add(user3);
User user4 = new User();
user4.setLogin("user4");
user4.setPassword("1234");
userService.add(user4);
}
@GetMapping(value = "/{userId}")
public UserResponseDto get(@PathVariable Long userId) {
return getDto(userService.get(userId));
}
@GetMapping(value = "/")
public List<UserResponseDto> getAll() {
return userService.listUsers()
.stream()
.map(this::getDto)
.collect(Collectors.toList());
}
private UserResponseDto getDto(User user) {
UserResponseDto userResponseDto = new UserResponseDto();
userResponseDto.setLogin(user.getLogin());
userResponseDto.setPassword(user.getPassword());
return userResponseDto;
}
}
| [
"[email protected]"
] | |
667beba4cf0b40005763b2327c663fefff70a0fc | 6b0655ba09dcfbcceefcd925d567460887f31931 | /src/lipika/youhuiquan.java | e5587a6a0f12b1779685d2f4600a19779df6bb21 | [] | no_license | bluewelkin/lipika | 73bc2e553351b6967b6699229900e12337bbca09 | 2fa5f5889bacb050e9c3cf64a9b55380e3d73954 | refs/heads/master | 2021-01-01T16:05:27.888532 | 2014-07-17T04:05:45 | 2014-07-17T04:05:45 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 934 | java | package lipika;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class youhuiquan {
public static void main(String[] args) throws IOException {
File file=new File("c:\\test6.txt");
FileInputStream fis=null;
Scanner input=null;
String str="INSERT INTO coupon(promoRuleId,couponNo,isSent,remainedTimes,STATUS,VERSION)"
+ "VALUES(38,123456789,0,1,1,0);";
fis=new FileInputStream(file);
input=new Scanner (fis);
StringBuffer nr=new StringBuffer();
File outputFile = new File("c:\\test7.txt");
FileWriter out = new FileWriter(outputFile); //创建文件写出类
while(input.hasNext())
{
String hn = input.next();
out.write(str.replace("123456789", hn)+ "\r\n"); //使用write()方法向文件写入信息
}
out.close();
}
}
| [
"[email protected]"
] | |
1c9972041a13c71f0fabe48dab89b048a4475796 | 48abebc53fb592761bc6047bb5fbed7d9a02e160 | /src/main/java/com/gc/myapp/security/jwt/JWTFilter.java | 00ceb7137694708eee660708793ca2a36c09b56a | [] | no_license | greenmaaouia/elasticTest | d6b5cc84af39c078f64c7a00768a63033b6fc868 | 821004f6238e34d665cea62e8e5d03941c92a1f6 | refs/heads/master | 2020-05-01T18:21:48.133573 | 2019-03-25T16:21:04 | 2019-03-25T16:21:04 | 177,622,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,838 | java | package com.gc.myapp.security.jwt;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* Filters incoming requests and installs a Spring Security principal if a header corresponding to a valid user is
* found.
*/
public class JWTFilter extends GenericFilterBean {
public static final String AUTHORIZATION_HEADER = "Authorization";
private TokenProvider tokenProvider;
public JWTFilter(TokenProvider tokenProvider) {
this.tokenProvider = tokenProvider;
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
String jwt = resolveToken(httpServletRequest);
if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) {
Authentication authentication = this.tokenProvider.getAuthentication(jwt);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
filterChain.doFilter(servletRequest, servletResponse);
}
private String resolveToken(HttpServletRequest request){
String bearerToken = request.getHeader(AUTHORIZATION_HEADER);
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
return bearerToken.substring(7);
}
return null;
}
}
| [
"[email protected]"
] | |
9cbe2d1450fb42aff0c3e766a792dfc446989fdd | 0eb39ae26d106ddf77be03568af144cd148e18df | /ssm_module_domain/src/main/java/com/shi/ssm/domain/Member.java | a9abb2621d3d6b8c502dce6f94edabcc3cd919a9 | [] | no_license | qianwensea/ssm_web | 2602408a918a2f2b0fe25dd7c1bc407b9ec20a14 | fb49c0c057e1388f3abb693af75f4de1be360868 | refs/heads/master | 2022-12-27T10:40:14.922256 | 2020-10-13T00:50:53 | 2020-10-13T00:50:53 | 299,844,732 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,326 | java | package com.shi.ssm.domain;
/**
* @author 千文sea
* @create 2020-10-04 15:44
* <p>
* 会员实体类
*/
public class Member {
private String id;
private String name; //姓名
private String nickname;//昵称
private String phoneNum;//电话号码
private String email;//邮箱
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "Member{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", nickname='" + nickname + '\'' +
", phoneNum='" + phoneNum + '\'' +
", email='" + email + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
8e79a552732c17f6f6c2d8dcadcd26eca6cb08f9 | c475b66ae5a0deb090b001260adcfb66de7442b9 | /Quest2/src/Formas/FiguraGeometrica.java | 3fc281c2d30311a179337ee1c683fef752034119 | [] | no_license | marcellovictor/Heranca-e-Polimorfismo-Classes-Gen-Uff | 805c61aec84c561ac56724970cd5ec824d73d2cc | 579e7a8784b13e8399f102b16947e6076031ad0f | refs/heads/master | 2023-06-15T17:06:30.110925 | 2021-07-19T18:50:46 | 2021-07-19T18:50:46 | 387,563,535 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 102 | java | package Formas;
public class FiguraGeometrica {
public double calculaArea() {
return 0.0;
}
}
| [
"[email protected]"
] | |
2b479fd533b8009f666f0fd9b4232887aac0337d | 9f591f0f55c51abad3ea260c11bc296325a2e832 | /src/test/java/com/everis/pages/packaging/MaterialsPage.java | e38130cebc1225124a355e45792f6e7a814ca418 | [] | no_license | BelaAC/MES | 912c161800213c1e6f1e59b6a5bd36935bba6a55 | cffdd847e40376c8dc4bb3e32bf47e7e78e76a5e | refs/heads/main | 2023-07-01T13:30:08.727404 | 2021-08-11T17:06:57 | 2021-08-11T17:06:57 | 359,463,380 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 953 | java | package com.everis.pages.packaging;
import org.openqa.selenium.By;
import org.openqa.selenium.support.PageFactory;
import com.everis.pages.BasePage;
import com.everis.util.TestRule;
public class MaterialsPage extends BasePage {
public MaterialsPage() {
PageFactory.initElements(TestRule.getDriver(), this);
}
/**
* Verify if the Materials Screen is being displayed
* @return
* @throws Exception
*/
public boolean verifyMaterialsisplayed() throws Exception {
boolean isMaterialsDisplayed = isElementDisplayed(By.xpath("//span[normalize-space()='Materiais']"));
boolean isOrderNumberCorrect = isElementDisplayed(
By.xpath("//*[normalize-space()='" + dataMap.get("OrderListOrderNumber") + "']"));
if(isMaterialsDisplayed && isOrderNumberCorrect) {
log("The Materials Screen was successfully loaded");
return true;
}
logFail("The system was unable to load the Materials Screen");
return false;
}
} | [
"[email protected]"
] | |
ff25b4d4b2e0ec19ccd4e1f568e92bc9538917d6 | bb5c43db869d446cba7a1bab5cabd786fa83f3a1 | /QuickDevApp/ndklib/src/test/java/com/ndklib/ExampleUnitTest.java | 011c85f0aad26d1b71b8d07be11bc954dca30fe2 | [] | no_license | wei886/QuickDevLib | 1b69132969404e60dbba39e4d09d8774d20383e0 | 255fabda52739a1f2b0c6863d59db2a7f0e6c2a2 | refs/heads/master | 2021-01-12T12:06:20.282230 | 2018-06-15T07:23:48 | 2018-06-15T07:23:48 | 69,238,202 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 388 | java | package com.ndklib;
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]"
] | |
1756f09ba180e11053f19b7be64131fb7c83bd38 | d77fc77e151177aa629549481d22ce0cf79de880 | /app/src/androidTest/java/com/cookandroid/recycle_ex2/ExampleInstrumentedTest.java | 7fbe7e2cc164760ea98f0ad0f1fbe1be6cc70290 | [] | no_license | seokjinyang/recycler_ex | 89c373b0231ddaaf60ce8a61764ceb4725f916a6 | 625044b628f41dbd9d771e1dd816ec478f4efb7f | refs/heads/master | 2022-12-10T14:04:21.722787 | 2020-09-07T14:19:47 | 2020-09-07T14:19:47 | 293,548,179 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 770 | java | package com.cookandroid.recycle_ex2;
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.cookandroid.recycle_ex2", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
7ee12b50f3eed0a3adb2dde19e09f4433571e421 | 9e8caae5a369b4545eb4ab7aa4f703369fb826b5 | /core/src/main/java/org/happyuc/webuj/protocol/core/methods/response/HucGetCompilers.java | 18482562c7766305389b4bc6d00f6ab9bf72833e | [
"Apache-2.0"
] | permissive | irchain/webu.java | da922c3cb4fced8d58cca62783aa2b5bf6ed1420 | 5ef60a89f6c7a6fec137ea62ae815d4381723e27 | refs/heads/master | 2020-03-15T10:54:57.292360 | 2018-05-30T08:29:08 | 2018-05-30T08:29:08 | 132,110,037 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | package org.happyuc.webuj.protocol.core.methods.response;
import java.util.List;
import org.happyuc.webuj.protocol.core.Response;
/**
* huc_getCompilers.
*/
public class HucGetCompilers extends Response<List<String>> {
public List<String> getCompilers() {
return getResult();
}
}
| [
"[email protected]"
] | |
1d3bb8ecd62cf2cfbc436cab8ebfd7ff1f0557ae | 9082fe0d0fcd8d4c4cf3e193cec060f206bfe065 | /FactoryMethod/src/com/company/Shape.java | 10580f35cbc7903ad6c6dcf7528a7eedc6dc8f6b | [] | no_license | AnthonyChraim/DesignPatterns | 33a3001fd9e6e899e75a032fe8ab90d055c6e162 | bb43ebf6f528d633f29d90ff306f439441627998 | refs/heads/master | 2023-03-20T01:32:30.739276 | 2021-03-11T17:58:18 | 2021-03-11T17:58:18 | 346,467,656 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | package com.company;
public interface Shape {
void draw();
}
| [
"[email protected]"
] | |
19fff98b367f758493c61f6f2e2461af6a464f4c | 4c61b2a3aedce7cf79ab36b4dbaf4f1729648ac5 | /src/main/java/com/github/bingoohuang/designpatterns/Command.java | 926228bfd71a1d38af8ba53b956c977e710b620b | [] | no_license | lovememo/design-patterns | 2375d577d563892b493c63af934c5dbb16641a4b | 64835cfb766640c065d5950dbaf8a4492131889d | refs/heads/master | 2021-01-24T16:04:22.021144 | 2014-05-08T16:05:56 | 2014-05-08T16:05:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 127 | java | package com.github.bingoohuang.designpatterns;
public interface Command {
String execute();
boolean requireLogin();
}
| [
"[email protected]"
] | |
cc43b24965281cda758abca57f3a7ecd9dd88c10 | e042eee3d5af48e2a164ac79df52cc605c03b7da | /src/main/java/springBoot/web/config/handler/LoginSuccessHandler.java | e629fdaad19592eaabe81f035ad5161e0a99a375 | [] | no_license | endddddd/Java.pre-project.Task.3.1.2 | 8ac589b2f9cd7e244a838ed59c2ce6d2d8609508 | f0a1a5aba62a474d7061a231786fcf936ceb4868 | refs/heads/master | 2022-06-24T18:22:51.695693 | 2020-03-31T19:18:40 | 2020-03-31T19:18:40 | 251,108,035 | 0 | 0 | null | 2022-06-21T03:05:43 | 2020-03-29T18:51:33 | HTML | UTF-8 | Java | false | false | 1,444 | java | package springBoot.web.config.handler;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import springBoot.web.model.User;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@Component
public class LoginSuccessHandler implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
Authentication authentication) throws IOException, ServletException {
User user = (User) authentication.getPrincipal();
HttpSession session = httpServletRequest.getSession();
session.setAttribute("user", user);
if (user.getAuthorities()
.stream()
.anyMatch(role -> "ADMIN".equals(role.getAuthority())
)) {
httpServletResponse.sendRedirect("/admin/table");
} else if (user.getAuthorities()
.stream()
.anyMatch(role -> "USER".equals(role.getAuthority())
)) {
httpServletResponse.sendRedirect("/user");
}
}
} | [
"[email protected]"
] | |
7a4cf04071e47164f4dc805f5748e391a260c324 | 1b704f35ba50296ae17f717a5a6d699c6e34477d | /spring-boot/src/main/java/com/collabera/FeMan/dto/ExerciseDTO.java | f133d0ef7a0fc0e58b0fc5fafc53e56941792360 | [] | no_license | lilchris123/fitness_website | 78d6fda84f0cb262e9659c9baf2e2adfb48d88ee | 0570f28292000bb4753cbd7f10104a4983b29187 | refs/heads/master | 2020-09-02T08:55:35.816173 | 2019-10-02T19:32:33 | 2019-10-02T19:32:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,119 | java | package com.collabera.FeMan.dto;
public class ExerciseDTO
{
private Long Exercise_id;
private String name;
private String description;
private String primary;
private String Secondary;
private String video_link;
public Long getExercise_id()
{
return Exercise_id;
}
public void setExercise_id(Long exercise_id)
{
Exercise_id = exercise_id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getPrimary()
{
return primary;
}
public void setPrimary(String primary)
{
this.primary = primary;
}
public String getSecondary()
{
return Secondary;
}
public void setSecondary(String secondary)
{
Secondary = secondary;
}
public String getVideo_link()
{
return video_link;
}
public void setVideo_link(String video_link)
{
this.video_link = video_link;
}
}
| [
"[email protected]"
] | |
fd1dd7061840b6204fc06d48977e255b8f96ae36 | dfe5caf190661c003619bfe7a7944c527c917ee4 | /src/main/java/com/vmware/vim25/HostTpmAttestationInfo.java | 345e58f6eb7c4f8e1ac23fc9349e9ce73ee6e835 | [
"BSD-3-Clause"
] | permissive | timtasse/vijava | c9787f9f9b3116a01f70a89d6ea29cc4f6dc3cd0 | 5d75bc0bd212534d44f78e5a287abf3f909a2e8e | refs/heads/master | 2023-06-01T08:20:39.601418 | 2022-10-31T12:43:24 | 2022-10-31T12:43:24 | 150,118,529 | 4 | 1 | BSD-3-Clause | 2023-05-01T21:19:53 | 2018-09-24T14:46:15 | Java | UTF-8 | Java | false | false | 1,174 | java | package com.vmware.vim25;
import java.util.Calendar;
/**
* This data object type represents result of TPM attestation.
*
* @author Stefan Dilk <[email protected]>
* @version 6.7
* @since 6.7
*/
public class HostTpmAttestationInfo extends DynamicData {
private LocalizableMessage message;
private HostTpmAttestationInfoAcceptanceStatus status;
private Calendar time;
@Override
public String toString() {
return "HostTpmAttestationInfo{" +
"message=" + message +
", status=" + status +
", time=" + time +
"} " + super.toString();
}
public LocalizableMessage getMessage() {
return message;
}
public void setMessage(final LocalizableMessage message) {
this.message = message;
}
public HostTpmAttestationInfoAcceptanceStatus getStatus() {
return status;
}
public void setStatus(final HostTpmAttestationInfoAcceptanceStatus status) {
this.status = status;
}
public Calendar getTime() {
return time;
}
public void setTime(final Calendar time) {
this.time = time;
}
}
| [
"[email protected]"
] | |
51643f883e0531f81ae67ffc4949c44826f0b5b7 | 4e7a53f44ef324772abfebc8b56fff7220ccb105 | /src/main/java/com/example/ssm/mapper/ProductMapper.java | b44bdaec80a1238c13df645df4f6e02a87a7982e | [] | no_license | 18102575692/MockShopping | f68235fe5556aea9152d35a240ca2a18fa6b8a49 | a1be3808ef54187f468ebdfed2eedbabb9fc3b8b | refs/heads/master | 2022-06-22T05:09:51.482368 | 2020-04-10T02:14:15 | 2020-04-10T02:14:15 | 254,522,303 | 0 | 0 | null | 2022-06-17T03:06:00 | 2020-04-10T02:08:12 | Java | UTF-8 | Java | false | false | 429 | java | package com.example.ssm.mapper;
import com.example.ssm.entity.Product;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
@Repository
public interface ProductMapper extends Mapper<Product> {
//查询产品
Product getProduct(Long id);
//减库存
int decreaseProduct(@Param("id") Long id,@Param("quantity") Integer quantity);
}
| [
"[email protected]"
] | |
19ca22130a3af44ddbbce8a95491d567c7a7ca76 | 38b4e798866d216da747e3ea840875d585b89eba | /src/trashcan/ui/enterdiagnosis/EnterDiagnose.java | c188382d7b37cec39a73ed29782a080c6bf56e3f | [] | no_license | WouterSchaekers/swop-dswx | 3fb2d05135bc79b3fd4e8beefcc98403dd9af8af | a4dd687fa0adaf9449de3b00618ad286bd829a54 | refs/heads/master | 2016-08-03T01:21:27.217421 | 2012-04-07T21:13:01 | 2012-04-07T21:13:01 | 32,268,900 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 749 | java | package ui.enterdiagnosis;
import ui.SelectUsecase;
import ui.Usecase;
import ui.UserinterfaceData;
import controllers.EnterDiagnoseController;
public class EnterDiagnose extends EnterDiagnoseSuperClass
{
public EnterDiagnose(UserinterfaceData data) {
super(data);
}
@Override
public Usecase Execute() {
// Create controller
try {
EnterDiagnoseController c = null;
c = new EnterDiagnoseController(data.getLoginController(),
data.getPatientFileOpenController());
this.chaindata.setController(c);
// Controller created
return new PresentEnterDiagInputForm(data, chaindata);
} catch (Exception e) {
System.out.println(e.getMessage());
return new SelectUsecase(data);
}
}
}
| [
"[email protected]@b180c425-cf1a-e361-07c7-cac54ae909d2"
] | [email protected]@b180c425-cf1a-e361-07c7-cac54ae909d2 |
d500775470a9049dcb5dad328d9a6dca18b872bd | e99ae599aa93def8f675132a163fd64838a63a33 | /EduSysDemo/src/com/edusys/dao/HocVienDAO.java | a21dcdd981136eea3653e308f04d0ed7a17166ca | [] | no_license | tuanpc1902/quan-ly-khoa-hoc | ed65ee961f84c5848992d479a4848975043ffecc | 7594689dfe6167b1b2893fa8f3a22c5f2b3a40d8 | refs/heads/master | 2023-05-30T17:02:26.882933 | 2021-06-14T17:16:09 | 2021-06-14T17:16:09 | 376,927,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,661 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.edusys.dao;
import com.edusys.utils.XJdbc;
import com.edusys.entity.HocVien;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author tuanp
*/
public class HocVienDAO extends EduSysDAO<HocVien, Integer>{
public void insert(HocVien model) {
String sql = "INSERT INTO HocVien(MaKH, MaNH, Diem) VALUES(?, ?, ?)";
XJdbc.update(sql,
model.getMaKH(),
model.getMaNH(),
model.getDiem());
}
public void update(HocVien model) {
String sql = "UPDATE HocVien SET MaKH=?, MaNH=?, Diem=? WHERE MaHV=?";
XJdbc.update(sql,
model.getMaKH(),
model.getMaNH(),
model.getDiem(),
model.getMaHV());
}
public void delete(Integer MaHV) {
String sql = "DELETE FROM HocVien WHERE MaHV=?";
XJdbc.update(sql, MaHV);
}
public List<HocVien> selectAll() {
String sql = "SELECT * FROM HocVien";
return selectBySql(sql);
}
public void selectLike(Integer MaHV) {
String sql = "SELECT HoTen FROM NguoiHoc inner join HocVien on NguoiHoc.MaNH = HocVien.MaNH where MaHV=?";
XJdbc.update(sql, MaHV);
}
public HocVien selectById(Integer mahv) {
String sql = "SELECT * FROM HocVien WHERE MaHV=?";
List<HocVien> list = selectBySql(sql, mahv);
return list.size() > 0 ? list.get(0) : null;
}
protected List<HocVien> selectBySql(String sql, Object... args) {
List<HocVien> list = new ArrayList<>();
try {
ResultSet rs = null;
try {
rs = XJdbc.query(sql, args);
while (rs.next()) {
HocVien entity = new HocVien();
entity.setMaHV(rs.getInt("MaHV"));
entity.setMaKH(rs.getInt("MaKH"));
entity.setMaNH(rs.getString("MaNH"));
entity.setDiem(rs.getDouble("Diem"));
list.add(entity);
}
} finally {
rs.getStatement().getConnection().close();
}
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
return list;
}
public List<HocVien> selectByKhoaHoc(int maKH) {
String sql = "SELECT * FROM HocVien WHERE MaKH=?";
return this.selectBySql(sql, maKH);
}
}
| [
"[email protected]"
] | |
a95ddffbc2bdfe213855208ae4600430047884cb | e1b1ce58fb1277b724022933176f0809169682d9 | /sources/android/support/v4/widget/ViewDragHelper.java | efde2597e3d5b176ddf1d70330a66327a06127e1 | [] | no_license | MR-116/com.masociete.projet_mobile-1_source_from_JADX | a5949c814f0f77437f74b7111ea9dca17140f2ea | 6cd80095cd68cb9392e6e067f26993ab2bf08bb2 | refs/heads/master | 2020-04-11T15:00:54.967026 | 2018-12-15T06:33:57 | 2018-12-15T06:33:57 | 161,873,466 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 43,257 | java | package android.support.v4.widget;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.widget.OverScroller;
import java.util.Arrays;
public class ViewDragHelper {
private static final int BASE_SETTLE_DURATION = 256;
public static final int DIRECTION_ALL = 3;
public static final int DIRECTION_HORIZONTAL = 1;
public static final int DIRECTION_VERTICAL = 2;
public static final int EDGE_ALL = 15;
public static final int EDGE_BOTTOM = 8;
public static final int EDGE_LEFT = 1;
public static final int EDGE_RIGHT = 2;
private static final int EDGE_SIZE = 20;
public static final int EDGE_TOP = 4;
public static final int INVALID_POINTER = -1;
private static final int MAX_SETTLE_DURATION = 600;
public static final int STATE_DRAGGING = 1;
public static final int STATE_IDLE = 0;
public static final int STATE_SETTLING = 2;
private static final String TAG = "ViewDragHelper";
private static final Interpolator sInterpolator = new C04021();
private int mActivePointerId = -1;
private final Callback mCallback;
private View mCapturedView;
private int mDragState;
private int[] mEdgeDragsInProgress;
private int[] mEdgeDragsLocked;
private int mEdgeSize;
private int[] mInitialEdgesTouched;
private float[] mInitialMotionX;
private float[] mInitialMotionY;
private float[] mLastMotionX;
private float[] mLastMotionY;
private float mMaxVelocity;
private float mMinVelocity;
private final ViewGroup mParentView;
private int mPointersDown;
private boolean mReleaseInProgress;
private OverScroller mScroller;
private final Runnable mSetIdleRunnable = new C04032();
private int mTouchSlop;
private int mTrackingEdges;
private VelocityTracker mVelocityTracker;
public static abstract class Callback {
public abstract boolean tryCaptureView(View view, int i);
public void onViewDragStateChanged(int state) {
}
public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
}
public void onViewCaptured(View capturedChild, int activePointerId) {
}
public void onViewReleased(View releasedChild, float xvel, float yvel) {
}
public void onEdgeTouched(int edgeFlags, int pointerId) {
}
public boolean onEdgeLock(int edgeFlags) {
return false;
}
public void onEdgeDragStarted(int edgeFlags, int pointerId) {
}
public int getOrderedChildIndex(int index) {
return index;
}
public int getViewHorizontalDragRange(View child) {
return 0;
}
public int getViewVerticalDragRange(View child) {
return 0;
}
public int clampViewPositionHorizontal(View child, int left, int dx) {
return 0;
}
public int clampViewPositionVertical(View child, int top, int dy) {
return 0;
}
}
/* renamed from: android.support.v4.widget.ViewDragHelper$1 */
static class C04021 implements Interpolator {
C04021() {
}
public float getInterpolation(float t) {
t -= 1.0f;
return ((((t * t) * t) * t) * t) + 1.0f;
}
}
/* renamed from: android.support.v4.widget.ViewDragHelper$2 */
class C04032 implements Runnable {
C04032() {
}
public void run() {
ViewDragHelper.this.setDragState(0);
}
}
public static ViewDragHelper create(ViewGroup forParent, Callback cb) {
return new ViewDragHelper(forParent.getContext(), forParent, cb);
}
public static ViewDragHelper create(ViewGroup forParent, float sensitivity, Callback cb) {
ViewDragHelper helper = create(forParent, cb);
helper.mTouchSlop = (int) (((float) helper.mTouchSlop) * (1.0f / sensitivity));
return helper;
}
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
if (forParent == null) {
throw new IllegalArgumentException("Parent view may not be null");
} else if (cb == null) {
throw new IllegalArgumentException("Callback may not be null");
} else {
this.mParentView = forParent;
this.mCallback = cb;
ViewConfiguration vc = ViewConfiguration.get(context);
this.mEdgeSize = (int) ((20.0f * context.getResources().getDisplayMetrics().density) + 0.5f);
this.mTouchSlop = vc.getScaledTouchSlop();
this.mMaxVelocity = (float) vc.getScaledMaximumFlingVelocity();
this.mMinVelocity = (float) vc.getScaledMinimumFlingVelocity();
this.mScroller = new OverScroller(context, sInterpolator);
}
}
public void setMinVelocity(float minVel) {
this.mMinVelocity = minVel;
}
public float getMinVelocity() {
return this.mMinVelocity;
}
public int getViewDragState() {
return this.mDragState;
}
public void setEdgeTrackingEnabled(int edgeFlags) {
this.mTrackingEdges = edgeFlags;
}
public int getEdgeSize() {
return this.mEdgeSize;
}
public void captureChildView(View childView, int activePointerId) {
if (childView.getParent() != this.mParentView) {
throw new IllegalArgumentException("captureChildView: parameter must be a descendant of the ViewDragHelper's tracked parent view (" + this.mParentView + ")");
}
this.mCapturedView = childView;
this.mActivePointerId = activePointerId;
this.mCallback.onViewCaptured(childView, activePointerId);
setDragState(1);
}
public View getCapturedView() {
return this.mCapturedView;
}
public int getActivePointerId() {
return this.mActivePointerId;
}
public int getTouchSlop() {
return this.mTouchSlop;
}
public void cancel() {
this.mActivePointerId = -1;
clearMotionHistory();
if (this.mVelocityTracker != null) {
this.mVelocityTracker.recycle();
this.mVelocityTracker = null;
}
}
public void abort() {
cancel();
if (this.mDragState == 2) {
int oldX = this.mScroller.getCurrX();
int oldY = this.mScroller.getCurrY();
this.mScroller.abortAnimation();
int newX = this.mScroller.getCurrX();
int newY = this.mScroller.getCurrY();
this.mCallback.onViewPositionChanged(this.mCapturedView, newX, newY, newX - oldX, newY - oldY);
}
setDragState(0);
}
public boolean smoothSlideViewTo(View child, int finalLeft, int finalTop) {
this.mCapturedView = child;
this.mActivePointerId = -1;
boolean continueSliding = forceSettleCapturedViewAt(finalLeft, finalTop, 0, 0);
if (!(continueSliding || this.mDragState != 0 || this.mCapturedView == null)) {
this.mCapturedView = null;
}
return continueSliding;
}
public boolean settleCapturedViewAt(int finalLeft, int finalTop) {
if (this.mReleaseInProgress) {
return forceSettleCapturedViewAt(finalLeft, finalTop, (int) this.mVelocityTracker.getXVelocity(this.mActivePointerId), (int) this.mVelocityTracker.getYVelocity(this.mActivePointerId));
}
throw new IllegalStateException("Cannot settleCapturedViewAt outside of a call to Callback#onViewReleased");
}
private boolean forceSettleCapturedViewAt(int finalLeft, int finalTop, int xvel, int yvel) {
int startLeft = this.mCapturedView.getLeft();
int startTop = this.mCapturedView.getTop();
int dx = finalLeft - startLeft;
int dy = finalTop - startTop;
if (dx == 0 && dy == 0) {
this.mScroller.abortAnimation();
setDragState(0);
return false;
}
this.mScroller.startScroll(startLeft, startTop, dx, dy, computeSettleDuration(this.mCapturedView, dx, dy, xvel, yvel));
setDragState(2);
return true;
}
private int computeSettleDuration(View child, int dx, int dy, int xvel, int yvel) {
xvel = clampMag(xvel, (int) this.mMinVelocity, (int) this.mMaxVelocity);
yvel = clampMag(yvel, (int) this.mMinVelocity, (int) this.mMaxVelocity);
int absDx = Math.abs(dx);
int absDy = Math.abs(dy);
int absXVel = Math.abs(xvel);
int absYVel = Math.abs(yvel);
int addedVel = absXVel + absYVel;
int addedDistance = absDx + absDy;
return (int) ((((float) computeAxisDuration(dx, xvel, this.mCallback.getViewHorizontalDragRange(child))) * (xvel != 0 ? ((float) absXVel) / ((float) addedVel) : ((float) absDx) / ((float) addedDistance))) + (((float) computeAxisDuration(dy, yvel, this.mCallback.getViewVerticalDragRange(child))) * (yvel != 0 ? ((float) absYVel) / ((float) addedVel) : ((float) absDy) / ((float) addedDistance))));
}
private int computeAxisDuration(int delta, int velocity, int motionRange) {
if (delta == 0) {
return 0;
}
int duration;
int width = this.mParentView.getWidth();
int halfWidth = width / 2;
float distance = ((float) halfWidth) + (((float) halfWidth) * distanceInfluenceForSnapDuration(Math.min(1.0f, ((float) Math.abs(delta)) / ((float) width))));
velocity = Math.abs(velocity);
if (velocity > 0) {
duration = Math.round(1000.0f * Math.abs(distance / ((float) velocity))) * 4;
} else {
duration = (int) (((((float) Math.abs(delta)) / ((float) motionRange)) + 1.0f) * 256.0f);
}
return Math.min(duration, MAX_SETTLE_DURATION);
}
private int clampMag(int value, int absMin, int absMax) {
int absValue = Math.abs(value);
if (absValue < absMin) {
return 0;
}
if (absValue <= absMax) {
return value;
}
if (value <= 0) {
return -absMax;
}
return absMax;
}
private float clampMag(float value, float absMin, float absMax) {
float absValue = Math.abs(value);
if (absValue < absMin) {
return 0.0f;
}
if (absValue <= absMax) {
return value;
}
if (value <= 0.0f) {
return -absMax;
}
return absMax;
}
private float distanceInfluenceForSnapDuration(float f) {
return (float) Math.sin((double) ((f - 0.5f) * 0.47123894f));
}
public void flingCapturedView(int minLeft, int minTop, int maxLeft, int maxTop) {
if (this.mReleaseInProgress) {
this.mScroller.fling(this.mCapturedView.getLeft(), this.mCapturedView.getTop(), (int) this.mVelocityTracker.getXVelocity(this.mActivePointerId), (int) this.mVelocityTracker.getYVelocity(this.mActivePointerId), minLeft, maxLeft, minTop, maxTop);
setDragState(2);
return;
}
throw new IllegalStateException("Cannot flingCapturedView outside of a call to Callback#onViewReleased");
}
public boolean continueSettling(boolean deferCallbacks) {
if (this.mDragState == 2) {
boolean keepGoing = this.mScroller.computeScrollOffset();
int x = this.mScroller.getCurrX();
int y = this.mScroller.getCurrY();
int dx = x - this.mCapturedView.getLeft();
int dy = y - this.mCapturedView.getTop();
if (dx != 0) {
ViewCompat.offsetLeftAndRight(this.mCapturedView, dx);
}
if (dy != 0) {
ViewCompat.offsetTopAndBottom(this.mCapturedView, dy);
}
if (!(dx == 0 && dy == 0)) {
this.mCallback.onViewPositionChanged(this.mCapturedView, x, y, dx, dy);
}
if (keepGoing && x == this.mScroller.getFinalX() && y == this.mScroller.getFinalY()) {
this.mScroller.abortAnimation();
keepGoing = false;
}
if (!keepGoing) {
if (deferCallbacks) {
this.mParentView.post(this.mSetIdleRunnable);
} else {
setDragState(0);
}
}
}
return this.mDragState == 2;
}
private void dispatchViewReleased(float xvel, float yvel) {
this.mReleaseInProgress = true;
this.mCallback.onViewReleased(this.mCapturedView, xvel, yvel);
this.mReleaseInProgress = false;
if (this.mDragState == 1) {
setDragState(0);
}
}
private void clearMotionHistory() {
if (this.mInitialMotionX != null) {
Arrays.fill(this.mInitialMotionX, 0.0f);
Arrays.fill(this.mInitialMotionY, 0.0f);
Arrays.fill(this.mLastMotionX, 0.0f);
Arrays.fill(this.mLastMotionY, 0.0f);
Arrays.fill(this.mInitialEdgesTouched, 0);
Arrays.fill(this.mEdgeDragsInProgress, 0);
Arrays.fill(this.mEdgeDragsLocked, 0);
this.mPointersDown = 0;
}
}
private void clearMotionHistory(int pointerId) {
if (this.mInitialMotionX != null && isPointerDown(pointerId)) {
this.mInitialMotionX[pointerId] = 0.0f;
this.mInitialMotionY[pointerId] = 0.0f;
this.mLastMotionX[pointerId] = 0.0f;
this.mLastMotionY[pointerId] = 0.0f;
this.mInitialEdgesTouched[pointerId] = 0;
this.mEdgeDragsInProgress[pointerId] = 0;
this.mEdgeDragsLocked[pointerId] = 0;
this.mPointersDown &= (1 << pointerId) ^ -1;
}
}
private void ensureMotionHistorySizeForId(int pointerId) {
if (this.mInitialMotionX == null || this.mInitialMotionX.length <= pointerId) {
float[] imx = new float[(pointerId + 1)];
float[] imy = new float[(pointerId + 1)];
float[] lmx = new float[(pointerId + 1)];
float[] lmy = new float[(pointerId + 1)];
int[] iit = new int[(pointerId + 1)];
int[] edip = new int[(pointerId + 1)];
int[] edl = new int[(pointerId + 1)];
if (this.mInitialMotionX != null) {
System.arraycopy(this.mInitialMotionX, 0, imx, 0, this.mInitialMotionX.length);
System.arraycopy(this.mInitialMotionY, 0, imy, 0, this.mInitialMotionY.length);
System.arraycopy(this.mLastMotionX, 0, lmx, 0, this.mLastMotionX.length);
System.arraycopy(this.mLastMotionY, 0, lmy, 0, this.mLastMotionY.length);
System.arraycopy(this.mInitialEdgesTouched, 0, iit, 0, this.mInitialEdgesTouched.length);
System.arraycopy(this.mEdgeDragsInProgress, 0, edip, 0, this.mEdgeDragsInProgress.length);
System.arraycopy(this.mEdgeDragsLocked, 0, edl, 0, this.mEdgeDragsLocked.length);
}
this.mInitialMotionX = imx;
this.mInitialMotionY = imy;
this.mLastMotionX = lmx;
this.mLastMotionY = lmy;
this.mInitialEdgesTouched = iit;
this.mEdgeDragsInProgress = edip;
this.mEdgeDragsLocked = edl;
}
}
private void saveInitialMotion(float x, float y, int pointerId) {
ensureMotionHistorySizeForId(pointerId);
float[] fArr = this.mInitialMotionX;
this.mLastMotionX[pointerId] = x;
fArr[pointerId] = x;
fArr = this.mInitialMotionY;
this.mLastMotionY[pointerId] = y;
fArr[pointerId] = y;
this.mInitialEdgesTouched[pointerId] = getEdgesTouched((int) x, (int) y);
this.mPointersDown |= 1 << pointerId;
}
private void saveLastMotion(MotionEvent ev) {
int pointerCount = ev.getPointerCount();
for (int i = 0; i < pointerCount; i++) {
int pointerId = ev.getPointerId(i);
if (isValidPointerForActionMove(pointerId)) {
float x = ev.getX(i);
float y = ev.getY(i);
this.mLastMotionX[pointerId] = x;
this.mLastMotionY[pointerId] = y;
}
}
}
public boolean isPointerDown(int pointerId) {
return (this.mPointersDown & (1 << pointerId)) != 0;
}
void setDragState(int state) {
this.mParentView.removeCallbacks(this.mSetIdleRunnable);
if (this.mDragState != state) {
this.mDragState = state;
this.mCallback.onViewDragStateChanged(state);
if (this.mDragState == 0) {
this.mCapturedView = null;
}
}
}
boolean tryCaptureViewForDrag(View toCapture, int pointerId) {
if (toCapture == this.mCapturedView && this.mActivePointerId == pointerId) {
return true;
}
if (toCapture == null || !this.mCallback.tryCaptureView(toCapture, pointerId)) {
return false;
}
this.mActivePointerId = pointerId;
captureChildView(toCapture, pointerId);
return true;
}
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
if (v instanceof ViewGroup) {
ViewGroup group = (ViewGroup) v;
int scrollX = v.getScrollX();
int scrollY = v.getScrollY();
for (int i = group.getChildCount() - 1; i >= 0; i--) {
View child = group.getChildAt(i);
if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() && y + scrollY >= child.getTop() && y + scrollY < child.getBottom()) {
if (canScroll(child, true, dx, dy, (x + scrollX) - child.getLeft(), (y + scrollY) - child.getTop())) {
return true;
}
}
}
}
return checkV && (v.canScrollHorizontally(-dx) || v.canScrollVertically(-dy));
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public boolean shouldInterceptTouchEvent(android.view.MotionEvent r27) {
/*
r26 = this;
r4 = r27.getActionMasked();
r5 = r27.getActionIndex();
if (r4 != 0) goto L_0x000d;
L_0x000a:
r26.cancel();
L_0x000d:
r0 = r26;
r0 = r0.mVelocityTracker;
r24 = r0;
if (r24 != 0) goto L_0x001f;
L_0x0015:
r24 = android.view.VelocityTracker.obtain();
r0 = r24;
r1 = r26;
r1.mVelocityTracker = r0;
L_0x001f:
r0 = r26;
r0 = r0.mVelocityTracker;
r24 = r0;
r0 = r24;
r1 = r27;
r0.addMovement(r1);
switch(r4) {
case 0: goto L_0x0040;
case 1: goto L_0x0255;
case 2: goto L_0x0148;
case 3: goto L_0x0255;
case 4: goto L_0x002f;
case 5: goto L_0x00bf;
case 6: goto L_0x0246;
default: goto L_0x002f;
};
L_0x002f:
r0 = r26;
r0 = r0.mDragState;
r24 = r0;
r25 = 1;
r0 = r24;
r1 = r25;
if (r0 != r1) goto L_0x025a;
L_0x003d:
r24 = 1;
L_0x003f:
return r24;
L_0x0040:
r22 = r27.getX();
r23 = r27.getY();
r24 = 0;
r0 = r27;
r1 = r24;
r17 = r0.getPointerId(r1);
r0 = r26;
r1 = r22;
r2 = r23;
r3 = r17;
r0.saveInitialMotion(r1, r2, r3);
r0 = r22;
r0 = (int) r0;
r24 = r0;
r0 = r23;
r0 = (int) r0;
r25 = r0;
r0 = r26;
r1 = r24;
r2 = r25;
r20 = r0.findTopChildUnder(r1, r2);
r0 = r26;
r0 = r0.mCapturedView;
r24 = r0;
r0 = r20;
r1 = r24;
if (r0 != r1) goto L_0x0094;
L_0x007d:
r0 = r26;
r0 = r0.mDragState;
r24 = r0;
r25 = 2;
r0 = r24;
r1 = r25;
if (r0 != r1) goto L_0x0094;
L_0x008b:
r0 = r26;
r1 = r20;
r2 = r17;
r0.tryCaptureViewForDrag(r1, r2);
L_0x0094:
r0 = r26;
r0 = r0.mInitialEdgesTouched;
r24 = r0;
r8 = r24[r17];
r0 = r26;
r0 = r0.mTrackingEdges;
r24 = r0;
r24 = r24 & r8;
if (r24 == 0) goto L_0x002f;
L_0x00a6:
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = r26;
r0 = r0.mTrackingEdges;
r25 = r0;
r25 = r25 & r8;
r0 = r24;
r1 = r25;
r2 = r17;
r0.onEdgeTouched(r1, r2);
goto L_0x002f;
L_0x00bf:
r0 = r27;
r17 = r0.getPointerId(r5);
r0 = r27;
r22 = r0.getX(r5);
r0 = r27;
r23 = r0.getY(r5);
r0 = r26;
r1 = r22;
r2 = r23;
r3 = r17;
r0.saveInitialMotion(r1, r2, r3);
r0 = r26;
r0 = r0.mDragState;
r24 = r0;
if (r24 != 0) goto L_0x010f;
L_0x00e4:
r0 = r26;
r0 = r0.mInitialEdgesTouched;
r24 = r0;
r8 = r24[r17];
r0 = r26;
r0 = r0.mTrackingEdges;
r24 = r0;
r24 = r24 & r8;
if (r24 == 0) goto L_0x002f;
L_0x00f6:
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = r26;
r0 = r0.mTrackingEdges;
r25 = r0;
r25 = r25 & r8;
r0 = r24;
r1 = r25;
r2 = r17;
r0.onEdgeTouched(r1, r2);
goto L_0x002f;
L_0x010f:
r0 = r26;
r0 = r0.mDragState;
r24 = r0;
r25 = 2;
r0 = r24;
r1 = r25;
if (r0 != r1) goto L_0x002f;
L_0x011d:
r0 = r22;
r0 = (int) r0;
r24 = r0;
r0 = r23;
r0 = (int) r0;
r25 = r0;
r0 = r26;
r1 = r24;
r2 = r25;
r20 = r0.findTopChildUnder(r1, r2);
r0 = r26;
r0 = r0.mCapturedView;
r24 = r0;
r0 = r20;
r1 = r24;
if (r0 != r1) goto L_0x002f;
L_0x013d:
r0 = r26;
r1 = r20;
r2 = r17;
r0.tryCaptureViewForDrag(r1, r2);
goto L_0x002f;
L_0x0148:
r0 = r26;
r0 = r0.mInitialMotionX;
r24 = r0;
if (r24 == 0) goto L_0x002f;
L_0x0150:
r0 = r26;
r0 = r0.mInitialMotionY;
r24 = r0;
if (r24 == 0) goto L_0x002f;
L_0x0158:
r16 = r27.getPointerCount();
r10 = 0;
L_0x015d:
r0 = r16;
if (r10 >= r0) goto L_0x021b;
L_0x0161:
r0 = r27;
r17 = r0.getPointerId(r10);
r0 = r26;
r1 = r17;
r24 = r0.isValidPointerForActionMove(r1);
if (r24 != 0) goto L_0x0174;
L_0x0171:
r10 = r10 + 1;
goto L_0x015d;
L_0x0174:
r0 = r27;
r22 = r0.getX(r10);
r0 = r27;
r23 = r0.getY(r10);
r0 = r26;
r0 = r0.mInitialMotionX;
r24 = r0;
r24 = r24[r17];
r6 = r22 - r24;
r0 = r26;
r0 = r0.mInitialMotionY;
r24 = r0;
r24 = r24[r17];
r7 = r23 - r24;
r0 = r22;
r0 = (int) r0;
r24 = r0;
r0 = r23;
r0 = (int) r0;
r25 = r0;
r0 = r26;
r1 = r24;
r2 = r25;
r20 = r0.findTopChildUnder(r1, r2);
if (r20 == 0) goto L_0x0220;
L_0x01aa:
r0 = r26;
r1 = r20;
r24 = r0.checkTouchSlop(r1, r6, r7);
if (r24 == 0) goto L_0x0220;
L_0x01b4:
r15 = 1;
L_0x01b5:
if (r15 == 0) goto L_0x0222;
L_0x01b7:
r13 = r20.getLeft();
r0 = (int) r6;
r24 = r0;
r18 = r13 + r24;
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = (int) r6;
r25 = r0;
r0 = r24;
r1 = r20;
r2 = r18;
r3 = r25;
r11 = r0.clampViewPositionHorizontal(r1, r2, r3);
r14 = r20.getTop();
r0 = (int) r7;
r24 = r0;
r19 = r14 + r24;
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = (int) r7;
r25 = r0;
r0 = r24;
r1 = r20;
r2 = r19;
r3 = r25;
r12 = r0.clampViewPositionVertical(r1, r2, r3);
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = r24;
r1 = r20;
r9 = r0.getViewHorizontalDragRange(r1);
r0 = r26;
r0 = r0.mCallback;
r24 = r0;
r0 = r24;
r1 = r20;
r21 = r0.getViewVerticalDragRange(r1);
if (r9 == 0) goto L_0x0215;
L_0x0211:
if (r9 <= 0) goto L_0x0222;
L_0x0213:
if (r11 != r13) goto L_0x0222;
L_0x0215:
if (r21 == 0) goto L_0x021b;
L_0x0217:
if (r21 <= 0) goto L_0x0222;
L_0x0219:
if (r12 != r14) goto L_0x0222;
L_0x021b:
r26.saveLastMotion(r27);
goto L_0x002f;
L_0x0220:
r15 = 0;
goto L_0x01b5;
L_0x0222:
r0 = r26;
r1 = r17;
r0.reportNewEdgeDrags(r6, r7, r1);
r0 = r26;
r0 = r0.mDragState;
r24 = r0;
r25 = 1;
r0 = r24;
r1 = r25;
if (r0 == r1) goto L_0x021b;
L_0x0237:
if (r15 == 0) goto L_0x0171;
L_0x0239:
r0 = r26;
r1 = r20;
r2 = r17;
r24 = r0.tryCaptureViewForDrag(r1, r2);
if (r24 == 0) goto L_0x0171;
L_0x0245:
goto L_0x021b;
L_0x0246:
r0 = r27;
r17 = r0.getPointerId(r5);
r0 = r26;
r1 = r17;
r0.clearMotionHistory(r1);
goto L_0x002f;
L_0x0255:
r26.cancel();
goto L_0x002f;
L_0x025a:
r24 = 0;
goto L_0x003f;
*/
throw new UnsupportedOperationException("Method not decompiled: android.support.v4.widget.ViewDragHelper.shouldInterceptTouchEvent(android.view.MotionEvent):boolean");
}
/* JADX WARNING: inconsistent code. */
/* Code decompiled incorrectly, please refer to instructions dump. */
public void processTouchEvent(android.view.MotionEvent r22) {
/*
r21 = this;
r3 = r22.getActionMasked();
r4 = r22.getActionIndex();
if (r3 != 0) goto L_0x000d;
L_0x000a:
r21.cancel();
L_0x000d:
r0 = r21;
r0 = r0.mVelocityTracker;
r19 = r0;
if (r19 != 0) goto L_0x001f;
L_0x0015:
r19 = android.view.VelocityTracker.obtain();
r0 = r19;
r1 = r21;
r1.mVelocityTracker = r0;
L_0x001f:
r0 = r21;
r0 = r0.mVelocityTracker;
r19 = r0;
r0 = r19;
r1 = r22;
r0.addMovement(r1);
switch(r3) {
case 0: goto L_0x0030;
case 1: goto L_0x02a0;
case 2: goto L_0x011a;
case 3: goto L_0x02b6;
case 4: goto L_0x002f;
case 5: goto L_0x008e;
case 6: goto L_0x0217;
default: goto L_0x002f;
};
L_0x002f:
return;
L_0x0030:
r17 = r22.getX();
r18 = r22.getY();
r19 = 0;
r0 = r22;
r1 = r19;
r15 = r0.getPointerId(r1);
r0 = r17;
r0 = (int) r0;
r19 = r0;
r0 = r18;
r0 = (int) r0;
r20 = r0;
r0 = r21;
r1 = r19;
r2 = r20;
r16 = r0.findTopChildUnder(r1, r2);
r0 = r21;
r1 = r17;
r2 = r18;
r0.saveInitialMotion(r1, r2, r15);
r0 = r21;
r1 = r16;
r0.tryCaptureViewForDrag(r1, r15);
r0 = r21;
r0 = r0.mInitialEdgesTouched;
r19 = r0;
r7 = r19[r15];
r0 = r21;
r0 = r0.mTrackingEdges;
r19 = r0;
r19 = r19 & r7;
if (r19 == 0) goto L_0x002f;
L_0x0078:
r0 = r21;
r0 = r0.mCallback;
r19 = r0;
r0 = r21;
r0 = r0.mTrackingEdges;
r20 = r0;
r20 = r20 & r7;
r0 = r19;
r1 = r20;
r0.onEdgeTouched(r1, r15);
goto L_0x002f;
L_0x008e:
r0 = r22;
r15 = r0.getPointerId(r4);
r0 = r22;
r17 = r0.getX(r4);
r0 = r22;
r18 = r0.getY(r4);
r0 = r21;
r1 = r17;
r2 = r18;
r0.saveInitialMotion(r1, r2, r15);
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
if (r19 != 0) goto L_0x00f5;
L_0x00b1:
r0 = r17;
r0 = (int) r0;
r19 = r0;
r0 = r18;
r0 = (int) r0;
r20 = r0;
r0 = r21;
r1 = r19;
r2 = r20;
r16 = r0.findTopChildUnder(r1, r2);
r0 = r21;
r1 = r16;
r0.tryCaptureViewForDrag(r1, r15);
r0 = r21;
r0 = r0.mInitialEdgesTouched;
r19 = r0;
r7 = r19[r15];
r0 = r21;
r0 = r0.mTrackingEdges;
r19 = r0;
r19 = r19 & r7;
if (r19 == 0) goto L_0x002f;
L_0x00de:
r0 = r21;
r0 = r0.mCallback;
r19 = r0;
r0 = r21;
r0 = r0.mTrackingEdges;
r20 = r0;
r20 = r20 & r7;
r0 = r19;
r1 = r20;
r0.onEdgeTouched(r1, r15);
goto L_0x002f;
L_0x00f5:
r0 = r17;
r0 = (int) r0;
r19 = r0;
r0 = r18;
r0 = (int) r0;
r20 = r0;
r0 = r21;
r1 = r19;
r2 = r20;
r19 = r0.isCapturedViewUnder(r1, r2);
if (r19 == 0) goto L_0x002f;
L_0x010b:
r0 = r21;
r0 = r0.mCapturedView;
r19 = r0;
r0 = r21;
r1 = r19;
r0.tryCaptureViewForDrag(r1, r15);
goto L_0x002f;
L_0x011a:
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
r20 = 1;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x019e;
L_0x0128:
r0 = r21;
r0 = r0.mActivePointerId;
r19 = r0;
r0 = r21;
r1 = r19;
r19 = r0.isValidPointerForActionMove(r1);
if (r19 == 0) goto L_0x002f;
L_0x0138:
r0 = r21;
r0 = r0.mActivePointerId;
r19 = r0;
r0 = r22;
r1 = r19;
r12 = r0.findPointerIndex(r1);
r0 = r22;
r17 = r0.getX(r12);
r0 = r22;
r18 = r0.getY(r12);
r0 = r21;
r0 = r0.mLastMotionX;
r19 = r0;
r0 = r21;
r0 = r0.mActivePointerId;
r20 = r0;
r19 = r19[r20];
r19 = r17 - r19;
r0 = r19;
r10 = (int) r0;
r0 = r21;
r0 = r0.mLastMotionY;
r19 = r0;
r0 = r21;
r0 = r0.mActivePointerId;
r20 = r0;
r19 = r19[r20];
r19 = r18 - r19;
r0 = r19;
r11 = (int) r0;
r0 = r21;
r0 = r0.mCapturedView;
r19 = r0;
r19 = r19.getLeft();
r19 = r19 + r10;
r0 = r21;
r0 = r0.mCapturedView;
r20 = r0;
r20 = r20.getTop();
r20 = r20 + r11;
r0 = r21;
r1 = r19;
r2 = r20;
r0.dragTo(r1, r2, r10, r11);
r21.saveLastMotion(r22);
goto L_0x002f;
L_0x019e:
r14 = r22.getPointerCount();
r8 = 0;
L_0x01a3:
if (r8 >= r14) goto L_0x01e9;
L_0x01a5:
r0 = r22;
r15 = r0.getPointerId(r8);
r0 = r21;
r19 = r0.isValidPointerForActionMove(r15);
if (r19 != 0) goto L_0x01b6;
L_0x01b3:
r8 = r8 + 1;
goto L_0x01a3;
L_0x01b6:
r0 = r22;
r17 = r0.getX(r8);
r0 = r22;
r18 = r0.getY(r8);
r0 = r21;
r0 = r0.mInitialMotionX;
r19 = r0;
r19 = r19[r15];
r5 = r17 - r19;
r0 = r21;
r0 = r0.mInitialMotionY;
r19 = r0;
r19 = r19[r15];
r6 = r18 - r19;
r0 = r21;
r0.reportNewEdgeDrags(r5, r6, r15);
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
r20 = 1;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x01ee;
L_0x01e9:
r21.saveLastMotion(r22);
goto L_0x002f;
L_0x01ee:
r0 = r17;
r0 = (int) r0;
r19 = r0;
r0 = r18;
r0 = (int) r0;
r20 = r0;
r0 = r21;
r1 = r19;
r2 = r20;
r16 = r0.findTopChildUnder(r1, r2);
r0 = r21;
r1 = r16;
r19 = r0.checkTouchSlop(r1, r5, r6);
if (r19 == 0) goto L_0x01b3;
L_0x020c:
r0 = r21;
r1 = r16;
r19 = r0.tryCaptureViewForDrag(r1, r15);
if (r19 == 0) goto L_0x01b3;
L_0x0216:
goto L_0x01e9;
L_0x0217:
r0 = r22;
r15 = r0.getPointerId(r4);
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
r20 = 1;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x0299;
L_0x022b:
r0 = r21;
r0 = r0.mActivePointerId;
r19 = r0;
r0 = r19;
if (r15 != r0) goto L_0x0299;
L_0x0235:
r13 = -1;
r14 = r22.getPointerCount();
r8 = 0;
L_0x023b:
if (r8 >= r14) goto L_0x0290;
L_0x023d:
r0 = r22;
r9 = r0.getPointerId(r8);
r0 = r21;
r0 = r0.mActivePointerId;
r19 = r0;
r0 = r19;
if (r9 != r0) goto L_0x0250;
L_0x024d:
r8 = r8 + 1;
goto L_0x023b;
L_0x0250:
r0 = r22;
r17 = r0.getX(r8);
r0 = r22;
r18 = r0.getY(r8);
r0 = r17;
r0 = (int) r0;
r19 = r0;
r0 = r18;
r0 = (int) r0;
r20 = r0;
r0 = r21;
r1 = r19;
r2 = r20;
r19 = r0.findTopChildUnder(r1, r2);
r0 = r21;
r0 = r0.mCapturedView;
r20 = r0;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x024d;
L_0x027c:
r0 = r21;
r0 = r0.mCapturedView;
r19 = r0;
r0 = r21;
r1 = r19;
r19 = r0.tryCaptureViewForDrag(r1, r9);
if (r19 == 0) goto L_0x024d;
L_0x028c:
r0 = r21;
r13 = r0.mActivePointerId;
L_0x0290:
r19 = -1;
r0 = r19;
if (r13 != r0) goto L_0x0299;
L_0x0296:
r21.releaseViewForPointerUp();
L_0x0299:
r0 = r21;
r0.clearMotionHistory(r15);
goto L_0x002f;
L_0x02a0:
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
r20 = 1;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x02b1;
L_0x02ae:
r21.releaseViewForPointerUp();
L_0x02b1:
r21.cancel();
goto L_0x002f;
L_0x02b6:
r0 = r21;
r0 = r0.mDragState;
r19 = r0;
r20 = 1;
r0 = r19;
r1 = r20;
if (r0 != r1) goto L_0x02d1;
L_0x02c4:
r19 = 0;
r20 = 0;
r0 = r21;
r1 = r19;
r2 = r20;
r0.dispatchViewReleased(r1, r2);
L_0x02d1:
r21.cancel();
goto L_0x002f;
*/
throw new UnsupportedOperationException("Method not decompiled: android.support.v4.widget.ViewDragHelper.processTouchEvent(android.view.MotionEvent):void");
}
private void reportNewEdgeDrags(float dx, float dy, int pointerId) {
int dragsStarted = 0;
if (checkNewEdgeDrag(dx, dy, pointerId, 1)) {
dragsStarted = 0 | 1;
}
if (checkNewEdgeDrag(dy, dx, pointerId, 4)) {
dragsStarted |= 4;
}
if (checkNewEdgeDrag(dx, dy, pointerId, 2)) {
dragsStarted |= 2;
}
if (checkNewEdgeDrag(dy, dx, pointerId, 8)) {
dragsStarted |= 8;
}
if (dragsStarted != 0) {
int[] iArr = this.mEdgeDragsInProgress;
iArr[pointerId] = iArr[pointerId] | dragsStarted;
this.mCallback.onEdgeDragStarted(dragsStarted, pointerId);
}
}
private boolean checkNewEdgeDrag(float delta, float odelta, int pointerId, int edge) {
float absDelta = Math.abs(delta);
float absODelta = Math.abs(odelta);
if ((this.mInitialEdgesTouched[pointerId] & edge) != edge || (this.mTrackingEdges & edge) == 0 || (this.mEdgeDragsLocked[pointerId] & edge) == edge || (this.mEdgeDragsInProgress[pointerId] & edge) == edge) {
return false;
}
if (absDelta <= ((float) this.mTouchSlop) && absODelta <= ((float) this.mTouchSlop)) {
return false;
}
if (absDelta < 0.5f * absODelta && this.mCallback.onEdgeLock(edge)) {
int[] iArr = this.mEdgeDragsLocked;
iArr[pointerId] = iArr[pointerId] | edge;
return false;
} else if ((this.mEdgeDragsInProgress[pointerId] & edge) != 0 || absDelta <= ((float) this.mTouchSlop)) {
return false;
} else {
return true;
}
}
private boolean checkTouchSlop(View child, float dx, float dy) {
if (child == null) {
return false;
}
boolean checkHorizontal;
boolean checkVertical;
if (this.mCallback.getViewHorizontalDragRange(child) > 0) {
checkHorizontal = true;
} else {
checkHorizontal = false;
}
if (this.mCallback.getViewVerticalDragRange(child) > 0) {
checkVertical = true;
} else {
checkVertical = false;
}
if (checkHorizontal && checkVertical) {
if ((dx * dx) + (dy * dy) <= ((float) (this.mTouchSlop * this.mTouchSlop))) {
return false;
}
return true;
} else if (checkHorizontal) {
if (Math.abs(dx) <= ((float) this.mTouchSlop)) {
return false;
}
return true;
} else if (!checkVertical) {
return false;
} else {
if (Math.abs(dy) <= ((float) this.mTouchSlop)) {
return false;
}
return true;
}
}
public boolean checkTouchSlop(int directions) {
int count = this.mInitialMotionX.length;
for (int i = 0; i < count; i++) {
if (checkTouchSlop(directions, i)) {
return true;
}
}
return false;
}
public boolean checkTouchSlop(int directions, int pointerId) {
if (!isPointerDown(pointerId)) {
return false;
}
boolean checkHorizontal;
boolean checkVertical;
if ((directions & 1) == 1) {
checkHorizontal = true;
} else {
checkHorizontal = false;
}
if ((directions & 2) == 2) {
checkVertical = true;
} else {
checkVertical = false;
}
float dx = this.mLastMotionX[pointerId] - this.mInitialMotionX[pointerId];
float dy = this.mLastMotionY[pointerId] - this.mInitialMotionY[pointerId];
if (checkHorizontal && checkVertical) {
if ((dx * dx) + (dy * dy) <= ((float) (this.mTouchSlop * this.mTouchSlop))) {
return false;
}
return true;
} else if (checkHorizontal) {
if (Math.abs(dx) <= ((float) this.mTouchSlop)) {
return false;
}
return true;
} else if (!checkVertical) {
return false;
} else {
if (Math.abs(dy) <= ((float) this.mTouchSlop)) {
return false;
}
return true;
}
}
public boolean isEdgeTouched(int edges) {
int count = this.mInitialEdgesTouched.length;
for (int i = 0; i < count; i++) {
if (isEdgeTouched(edges, i)) {
return true;
}
}
return false;
}
public boolean isEdgeTouched(int edges, int pointerId) {
return isPointerDown(pointerId) && (this.mInitialEdgesTouched[pointerId] & edges) != 0;
}
private void releaseViewForPointerUp() {
this.mVelocityTracker.computeCurrentVelocity(1000, this.mMaxVelocity);
dispatchViewReleased(clampMag(this.mVelocityTracker.getXVelocity(this.mActivePointerId), this.mMinVelocity, this.mMaxVelocity), clampMag(this.mVelocityTracker.getYVelocity(this.mActivePointerId), this.mMinVelocity, this.mMaxVelocity));
}
private void dragTo(int left, int top, int dx, int dy) {
int clampedX = left;
int clampedY = top;
int oldLeft = this.mCapturedView.getLeft();
int oldTop = this.mCapturedView.getTop();
if (dx != 0) {
clampedX = this.mCallback.clampViewPositionHorizontal(this.mCapturedView, left, dx);
ViewCompat.offsetLeftAndRight(this.mCapturedView, clampedX - oldLeft);
}
if (dy != 0) {
clampedY = this.mCallback.clampViewPositionVertical(this.mCapturedView, top, dy);
ViewCompat.offsetTopAndBottom(this.mCapturedView, clampedY - oldTop);
}
if (dx != 0 || dy != 0) {
this.mCallback.onViewPositionChanged(this.mCapturedView, clampedX, clampedY, clampedX - oldLeft, clampedY - oldTop);
}
}
public boolean isCapturedViewUnder(int x, int y) {
return isViewUnder(this.mCapturedView, x, y);
}
public boolean isViewUnder(View view, int x, int y) {
if (view != null && x >= view.getLeft() && x < view.getRight() && y >= view.getTop() && y < view.getBottom()) {
return true;
}
return false;
}
public View findTopChildUnder(int x, int y) {
for (int i = this.mParentView.getChildCount() - 1; i >= 0; i--) {
View child = this.mParentView.getChildAt(this.mCallback.getOrderedChildIndex(i));
if (x >= child.getLeft() && x < child.getRight() && y >= child.getTop() && y < child.getBottom()) {
return child;
}
}
return null;
}
private int getEdgesTouched(int x, int y) {
int result = 0;
if (x < this.mParentView.getLeft() + this.mEdgeSize) {
result = 0 | 1;
}
if (y < this.mParentView.getTop() + this.mEdgeSize) {
result |= 4;
}
if (x > this.mParentView.getRight() - this.mEdgeSize) {
result |= 2;
}
if (y > this.mParentView.getBottom() - this.mEdgeSize) {
return result | 8;
}
return result;
}
private boolean isValidPointerForActionMove(int pointerId) {
if (isPointerDown(pointerId)) {
return true;
}
Log.e(TAG, "Ignoring pointerId=" + pointerId + " because ACTION_DOWN was not received " + "for this pointer before ACTION_MOVE. It likely happened because " + " ViewDragHelper did not receive all the events in the event stream.");
return false;
}
}
| [
"[email protected]"
] | |
b161d47872045f76ccf11a9843845e51300d4174 | 3c8f5a8c74c44d194edaa91b16d8196bc2bb19f6 | /src/test/java/org/relxd/lxd/model/CreateInstancesByNameBackupsRequestTest.java | 336ae59dc77915fa7dd8245895d3bb5a53ec9d12 | [
"MIT"
] | permissive | simhaonline/lxd-sdk | bb2ce2d083eac6b097c097dfaa1aad85f7e67cdc | 7c059856e795154a0bdbcbad599fb4f5d123e4b8 | refs/heads/master | 2023-04-17T08:14:11.627471 | 2021-04-20T04:55:17 | 2021-04-20T04:55:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,766 | java | /*
* LXD
* The services listed below are referred as .....
*
* The version of the OpenAPI document: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.relxd.lxd.model;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.math.BigDecimal;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
/**
* Model tests for CreateInstancesByNameBackupsRequest
*/
public class CreateInstancesByNameBackupsRequestTest {
private final CreateInstancesByNameBackupsRequest model = new CreateInstancesByNameBackupsRequest();
/**
* Model tests for CreateInstancesByNameBackupsRequest
*/
@Test
public void testCreateInstancesByNameBackupsRequest() {
// TODO: test CreateInstancesByNameBackupsRequest
}
/**
* Test the property 'name'
*/
@Test
public void nameTest() {
// TODO: test name
}
/**
* Test the property 'expiry'
*/
@Test
public void expiryTest() {
// TODO: test expiry
}
/**
* Test the property 'instanceOnly'
*/
@Test
public void instanceOnlyTest() {
// TODO: test instanceOnly
}
/**
* Test the property 'optimizedStorage'
*/
@Test
public void optimizedStorageTest() {
// TODO: test optimizedStorage
}
}
| [
"[email protected]"
] | |
2aa823fd664e8531ebbf028c0ec4d84dcea66e9e | 96aa0283e2b97d5b42449d0173b3530582ea5cd7 | /MaterialGingerDemo/src/com/hanry/material/app/Recurring.java | fab24201466a8186f92a919490787f0f8d2d6758 | [
"Apache-2.0"
] | permissive | Hanif-abuvani/GingerMaterialRepo | d0f630fda88b64e9336191753115f787b33b95b3 | a50ba78e005dde2405ed9464f5fa6b9b152462b8 | refs/heads/master | 2021-01-01T19:39:38.943913 | 2015-07-15T07:13:48 | 2015-07-15T07:13:48 | 39,121,012 | 12 | 4 | null | null | null | null | UTF-8 | Java | false | false | 12,631 | java | package com.hanry.material.app;
import java.util.Calendar;
/**
* Created by Rey on 2/4/2015.
*/
public class Recurring {
public static final int REPEAT_NONE = 0;
public static final int REPEAT_DAILY = 1;
public static final int REPEAT_WEEKLY = 2;
public static final int REPEAT_MONTHLY = 3;
public static final int REPEAT_YEARLY = 4;
public static final int END_FOREVER = 0;
public static final int END_UNTIL_DATE = 1;
public static final int END_FOR_EVENT = 2;
public static final int MONTH_SAME_DAY = 0;
public static final int MONTH_SAME_WEEKDAY = 1;
private static final int[] WEEKDAY_MASK = {
0x01,0x02, 0x04, 0x08, 0x10, 0x20, 0x40
};
private static final int DAY_TIME = 86400000;
private long mStartTime;
private int mRepeatMode;
private int mPeriod = 1;
private int mRepeatSetting;
private int mEndMode;
private long mEndSetting;
public Recurring(){}
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append(Recurring.class.getSimpleName())
.append("[mode=");
switch (mRepeatMode){
case REPEAT_NONE:
sb.append("none");
break;
case REPEAT_DAILY:
sb.append("daily")
.append("; period=")
.append(mPeriod);
break;
case REPEAT_WEEKLY:
sb.append("weekly")
.append("; period=")
.append(mPeriod)
.append("; setting=");
for(int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++){
if(isEnabledWeekday(i))
sb.append(i);
}
break;
case REPEAT_MONTHLY:
sb.append("monthly")
.append("; period=")
.append(mPeriod)
.append("; setting=")
.append(getMonthRepeatType() == MONTH_SAME_DAY ? "same_day" : "same_weekday");
break;
case REPEAT_YEARLY:
sb.append("yearly")
.append("; period=")
.append(mPeriod);
break;
}
if(mRepeatMode != REPEAT_NONE){
switch (mEndMode){
case END_FOREVER:
sb.append("; end=forever");
break;
case END_UNTIL_DATE:
sb.append("; end=until ");
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(mEndSetting);
sb.append(cal.get(Calendar.DAY_OF_MONTH))
.append('/')
.append(cal.get(Calendar.MONTH) + 1)
.append('/')
.append(cal.get(Calendar.YEAR));
break;
case END_FOR_EVENT:
sb.append("; end=for ")
.append(mEndSetting)
.append(" events");
break;
}
}
sb.append(']');
return sb.toString();
}
public void setStartTime(long time){
mStartTime = time;
}
public long getStartTime(){
return mStartTime;
}
/**
* Set repeat mode of this recurring obj.
*/
public void setRepeatMode(int mode){
mRepeatMode = mode;
}
public int getRepeatMode(){
return mRepeatMode;
}
/**
* Set the period of this recurring obj. Depend on repeat mode, the unit can be days, weeks, months or years.
*/
public void setPeriod(int period){
mPeriod = period;
}
public int getPeriod(){
return mPeriod;
}
public int getRepeatSetting(){
return mRepeatSetting;
}
public void setRepeatSetting(int setting){
mRepeatSetting = setting;
}
public void clearWeekdaySetting(){
if(mRepeatMode != REPEAT_WEEKLY)
return;
mRepeatSetting = 0;
}
/**
* Enable repeat on a dayOfWeek. Only apply it repeat mode is REPEAT_WEEKLY.
* @param dayOfWeek value of dayOfWeek, take from Calendar obj.
* @param enable Enable this dayOfWeek or not.
*/
public void setEnabledWeekday(int dayOfWeek, boolean enable){
if(mRepeatMode != REPEAT_WEEKLY)
return;
if(enable)
mRepeatSetting = mRepeatSetting | WEEKDAY_MASK[dayOfWeek - 1];
else
mRepeatSetting = mRepeatSetting & (~WEEKDAY_MASK[dayOfWeek - 1]);
}
public boolean isEnabledWeekday(int weekday){
if(mRepeatMode != REPEAT_WEEKLY)
return false;
return (mRepeatSetting & WEEKDAY_MASK[weekday - 1]) != 0;
}
public void setMonthRepeatType(int type){
if(mRepeatMode != REPEAT_MONTHLY)
return;
mRepeatSetting = type;
}
public int getMonthRepeatType(){
return mRepeatSetting;
}
public void setEndMode(int mode){
mEndMode = mode;
}
public int getEndMode(){
return mEndMode;
}
public long getEndSetting(){
return mEndSetting;
}
public void setEndSetting(long setting){
mEndSetting = setting;
}
public void setEndDate(long date){
if(mEndMode != END_UNTIL_DATE)
return;
mEndSetting = date;
}
public long getEndDate(){
if(mEndMode != END_UNTIL_DATE)
return 0;
return mEndSetting;
}
public void setEventNumber(int number){
if(mEndMode != END_FOR_EVENT)
return;
mEndSetting = number;
}
public int getEventNumber(){
if(mEndMode != END_FOR_EVENT)
return 0;
return (int)mEndSetting;
}
public long getNextEventTime(){
return getNextEventTime(System.currentTimeMillis());
}
public long getNextEventTime(long now){
if(mStartTime >= now)
return mStartTime;
Calendar cal = Calendar.getInstance();
switch (mRepeatMode){
case REPEAT_DAILY:
return getNextDailyEventTime(cal, mStartTime, now);
case REPEAT_WEEKLY:
return getNextWeeklyEventTime(cal, mStartTime, now);
case REPEAT_MONTHLY:
return getNextMonthlyEventTime(cal, mStartTime, now);
case REPEAT_YEARLY:
return getNextYearlyEventTime(cal, mStartTime, now);
default:
return 0;
}
}
private long getNextDailyEventTime(Calendar cal, long start, long now){
long period = mPeriod * DAY_TIME;
long time = start + ((now - start) / period) * period;
do{
if(time >= now)
return time;
time += period;
}
while(true);
}
private static long gotoFirstDayOfWeek(Calendar cal){
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int firstDayOfWeek = cal.getFirstDayOfWeek();
int shift = dayOfWeek >= firstDayOfWeek ? (dayOfWeek - firstDayOfWeek) : (dayOfWeek + 7 - firstDayOfWeek);
cal.add(Calendar.DAY_OF_MONTH, -shift);
return cal.getTimeInMillis();
}
private long getNextWeeklyEventTime(Calendar cal, long start, long now){
if(mRepeatSetting == 0)
return 0;
//daily case
if(mRepeatSetting == 0x7F && mPeriod == 1){
long period = DAY_TIME;
long time = start + ((now - start) / period) * period;
do{
if(time >= now)
return time;
time += period;
}
while(true);
}
long period = mPeriod * 7 * DAY_TIME;
cal.setTimeInMillis(now);
long nowFirstDayTime = gotoFirstDayOfWeek(cal);
cal.setTimeInMillis(start);
long startFirstDayTime = gotoFirstDayOfWeek(cal);
long time = startFirstDayTime + ((nowFirstDayTime - startFirstDayTime) / period) * period;
do{
cal.setTimeInMillis(time);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
for(int i = 0; i < 7; i++){
int nextDayOfWeek = dayOfWeek + i;
if(nextDayOfWeek > Calendar.SATURDAY)
nextDayOfWeek = Calendar.SUNDAY;
if(isEnabledWeekday(nextDayOfWeek)){
long nextTime = time + i * DAY_TIME;
if(nextTime >= now)
return nextTime;
}
}
time += period;
}
while(true);
}
/**
* Get the order number of weekday. 0 mean the first, -1 mean the last.
*/
public static int getWeekDayOrderNum(Calendar cal){
return cal.get(Calendar.DAY_OF_MONTH) + 7 > cal.getActualMaximum(Calendar.DAY_OF_MONTH) ? - 1 : (cal.get(Calendar.DAY_OF_MONTH) - 1) / 7;
}
/**
* Get the day in month of the current month of Calendar.
* @param cal
* @param dayOfWeek The day of week.
* @param orderNum The order number, 0 mean the first, -1 mean the last.
* @return The day int month
*/
private static int getDay(Calendar cal, int dayOfWeek, int orderNum){
int day = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, day);
int lastWeekday = cal.get(Calendar.DAY_OF_WEEK);
int shift = lastWeekday >= dayOfWeek ? (lastWeekday - dayOfWeek) : (lastWeekday + 7 - dayOfWeek);
//find last dayOfWeek of this month
day -= shift;
if(orderNum < 0)
return day;
cal.set(Calendar.DAY_OF_MONTH, day);
int lastOrderNum = (cal.get(Calendar.DAY_OF_MONTH) - 1) / 7;
if(orderNum >= lastOrderNum)
return day;
return day - (lastOrderNum - orderNum) * 7;
}
private long getNextMonthlyEventTime(Calendar cal, long start, long now){
if(mRepeatSetting == MONTH_SAME_DAY){
cal.setTimeInMillis(now);
int nowMonthYear = cal.get(Calendar.MONTH) + cal.get(Calendar.YEAR) * 12;
cal.setTimeInMillis(start);
int startMonthYear = cal.get(Calendar.MONTH) + cal.get(Calendar.YEAR) * 12;
int startDay = cal.get(Calendar.DAY_OF_MONTH);
int monthYear = startMonthYear + ((nowMonthYear - startMonthYear) / mPeriod) * mPeriod;
do{
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.YEAR, monthYear / 12);
cal.set(Calendar.MONTH, monthYear % 12);
cal.set(Calendar.DAY_OF_MONTH, Math.min(startDay, cal.getActualMaximum(Calendar.DAY_OF_MONTH)));
if(cal.getTimeInMillis() >= now)
return cal.getTimeInMillis();
monthYear += mPeriod;
}
while(true);
}
else{
cal.setTimeInMillis(now);
int nowMonthYear = cal.get(Calendar.MONTH) + cal.get(Calendar.YEAR) * 12;
cal.setTimeInMillis(start);
int startMonthYear = cal.get(Calendar.MONTH) + cal.get(Calendar.YEAR) * 12;
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
int orderNum = getWeekDayOrderNum(cal);
int monthYear = startMonthYear + ((nowMonthYear - startMonthYear) / mPeriod) * mPeriod;
do{
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.YEAR, monthYear / 12);
cal.set(Calendar.MONTH, monthYear % 12);
cal.set(Calendar.DAY_OF_MONTH, getDay(cal, dayOfWeek, orderNum));
if(cal.getTimeInMillis() >= now)
return cal.getTimeInMillis();
monthYear += mPeriod;
}
while(true);
}
}
private long getNextYearlyEventTime(Calendar cal, long start, long now){
cal.setTimeInMillis(now);
int nowYear = cal.get(Calendar.YEAR);
cal.setTimeInMillis(start);
int startYear = cal.get(Calendar.YEAR);
int year = startYear + ((nowYear - startYear) / mPeriod) * mPeriod;
do{
cal.setTimeInMillis(start);
cal.set(Calendar.YEAR, year);
if(cal.getTimeInMillis() >= now)
return cal.getTimeInMillis();
year += mPeriod;
}
while(true);
}
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.