blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2 values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82 values | src_encoding stringclasses 28 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 5.41M | extension stringclasses 11 values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5624e5209d94e71488a938e47804e416cd39a93d | 03cb20d8ca6ade4fec4f36d1560e6cba06e56ec7 | /src/main/java/com/adobe/cq/commerce/magento/graphql/CustomizableDateOption.java | 088a65c12d06fa75ff286a6e102a56040c507300 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Pushparajan/commerce-cif-magento-graphql | e178b6f5f8551aa5911347ef2b33496c93c810ef | a04d02207f0348c6d7dada19fb3d8654ca893a75 | refs/heads/master | 2023-01-09T03:37:18.873529 | 2020-11-10T14:35:21 | 2020-11-10T14:35:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,399 | java | /*******************************************************************************
*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed 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 REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
******************************************************************************/
package com.adobe.cq.commerce.magento.graphql;
import java.util.Map;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.shopify.graphql.support.AbstractResponse;
import com.shopify.graphql.support.ID;
import com.shopify.graphql.support.SchemaViolationError;
/**
* CustomizableDateOption contains information about a date picker that is defined as part of a
* customizable option.
*/
public class CustomizableDateOption extends AbstractResponse<CustomizableDateOption> implements CustomizableOptionInterface {
public CustomizableDateOption() {}
public CustomizableDateOption(JsonObject fields) throws SchemaViolationError {
for (Map.Entry<String, JsonElement> field : fields.entrySet()) {
String key = field.getKey();
String fieldName = getFieldName(key);
switch (fieldName) {
case "option_id": {
Integer optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = jsonAsInteger(field.getValue(), key);
}
responseData.put(key, optional1);
break;
}
case "product_sku": {
String optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = jsonAsString(field.getValue(), key);
}
responseData.put(key, optional1);
break;
}
case "required": {
Boolean optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = jsonAsBoolean(field.getValue(), key);
}
responseData.put(key, optional1);
break;
}
case "sort_order": {
Integer optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = jsonAsInteger(field.getValue(), key);
}
responseData.put(key, optional1);
break;
}
case "title": {
String optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = jsonAsString(field.getValue(), key);
}
responseData.put(key, optional1);
break;
}
case "value": {
CustomizableDateValue optional1 = null;
if (!field.getValue().isJsonNull()) {
optional1 = new CustomizableDateValue(jsonAsObject(field.getValue(), key));
}
responseData.put(key, optional1);
break;
}
case "__typename": {
responseData.put(key, jsonAsString(field.getValue(), key));
break;
}
default: {
readCustomField(fieldName, field.getValue());
}
}
}
}
public String getGraphQlTypeName() {
return "CustomizableDateOption";
}
/**
* Option ID.
*/
public Integer getOptionId() {
return (Integer) get("option_id");
}
public CustomizableDateOption setOptionId(Integer arg) {
optimisticData.put(getKey("option_id"), arg);
return this;
}
/**
* The Stock Keeping Unit of the base product.
*/
public String getProductSku() {
return (String) get("product_sku");
}
public CustomizableDateOption setProductSku(String arg) {
optimisticData.put(getKey("product_sku"), arg);
return this;
}
/**
* Indicates whether the option is required.
*/
public Boolean getRequired() {
return (Boolean) get("required");
}
public CustomizableDateOption setRequired(Boolean arg) {
optimisticData.put(getKey("required"), arg);
return this;
}
/**
* The order in which the option is displayed.
*/
public Integer getSortOrder() {
return (Integer) get("sort_order");
}
public CustomizableDateOption setSortOrder(Integer arg) {
optimisticData.put(getKey("sort_order"), arg);
return this;
}
/**
* The display name for this option.
*/
public String getTitle() {
return (String) get("title");
}
public CustomizableDateOption setTitle(String arg) {
optimisticData.put(getKey("title"), arg);
return this;
}
/**
* An object that defines a date field in a customizable option.
*/
public CustomizableDateValue getValue() {
return (CustomizableDateValue) get("value");
}
public CustomizableDateOption setValue(CustomizableDateValue arg) {
optimisticData.put(getKey("value"), arg);
return this;
}
public boolean unwrapsToObject(String key) {
switch (getFieldName(key)) {
case "option_id":
return false;
case "product_sku":
return false;
case "required":
return false;
case "sort_order":
return false;
case "title":
return false;
case "value":
return true;
default:
return false;
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
d888298a3cecbf383c0b321628e681364b1a00f9 | 868208c07a389525582ff16a165f46ea8943ba3d | /xian-log/xian-gelf-common/src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java | c313003f9debf3866d1e14f523cbd8059ea9c021 | [
"Apache-2.0"
] | permissive | ilias500/xian | a50d045186a2d806091fba79cd6991fb0f767805 | 911ee227949b24b1f6883d7d47c3df4ef66a9407 | refs/heads/master | 2022-04-17T17:10:07.231717 | 2020-04-14T00:22:40 | 2020-04-14T00:22:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,974 | java | package biz.paluch.logging.gelf;
import biz.paluch.logging.RuntimeContainer;
import biz.paluch.logging.StackTraceFilter;
import biz.paluch.logging.gelf.intern.GelfMessage;
import biz.paluch.logging.gelf.intern.HostAndPortProvider;
import biz.paluch.logging.gelf.intern.PoolingGelfMessageBuilder;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
import static biz.paluch.logging.gelf.GelfMessageBuilder.newInstance;
/**
* Creates {@link GelfMessage} based on various {@link LogEvent}. A {@link LogEvent} encapsulates log-framework specifics and
* exposes commonly used details of log events.
*
* @author Mark Paluch
* @since 26.09.13 15:05
*/
public class GelfMessageAssembler implements HostAndPortProvider {
/**
* @deprecated see {@link PoolingGelfMessageBuilder#PROPERTY_USE_POOLING}.
*/
@Deprecated
public static final String PROPERTY_USE_POOLING = "logstash-gelf.message.pooling";
private static final int MAX_SHORT_MESSAGE_LENGTH = 250;
private static final int MAX_PORT_NUMBER = 65535;
private static final int MAX_MESSAGE_SIZE = Integer.MAX_VALUE;
public static final String FIELD_MESSAGE_PARAM = "MessageParam";
public static final String FIELD_STACK_TRACE = "StackTrace";
private String host;
private String version = GelfMessage.GELF_VERSION;
private String originHost;
private int port;
private String facility;
private boolean includeLogMessageParameters = true;
private StackTraceExtraction stackTraceExtraction = StackTraceExtraction.OFF;
private int maximumMessageSize = 8192;
private List<MessageField> fields = new ArrayList<MessageField>();
private Map<String, String> additionalFieldTypes = new HashMap<String, String>();
private String timestampPattern = "yyyy-MM-dd HH:mm:ss,SSSS";
private final ThreadLocal<PoolingGelfMessageBuilder> builders;
public GelfMessageAssembler() {
if (PoolingGelfMessageBuilder.usePooling()) {
builders = new ThreadLocal<PoolingGelfMessageBuilder>() {
@Override
protected PoolingGelfMessageBuilder initialValue() {
return PoolingGelfMessageBuilder.newInstance();
}
};
} else {
builders = null;
}
}
/**
* Initialize the {@link GelfMessageAssembler} from a property provider.
*
* @param propertyProvider property provider to obtain configuration properties
*/
public void initialize(PropertyProvider propertyProvider) {
host = propertyProvider.getProperty(PropertyProvider.PROPERTY_HOST);
if (host == null) {
host = propertyProvider.getProperty(PropertyProvider.PROPERTY_GRAYLOG_HOST);
}
String port = propertyProvider.getProperty(PropertyProvider.PROPERTY_PORT);
if (port == null) {
port = propertyProvider.getProperty(PropertyProvider.PROPERTY_GRAYLOG_PORT);
}
if (port != null && !"".equals(port)) {
this.port = Integer.parseInt(port);
}
originHost = propertyProvider.getProperty(PropertyProvider.PROPERTY_ORIGIN_HOST);
setExtractStackTrace(propertyProvider.getProperty(PropertyProvider.PROPERTY_EXTRACT_STACKTRACE));
setFilterStackTrace("true".equalsIgnoreCase(propertyProvider.getProperty(PropertyProvider.PROPERTY_FILTER_STACK_TRACE)));
String includeLogMessageParameters = propertyProvider
.getProperty(PropertyProvider.PROPERTY_INCLUDE_LOG_MESSAGE_PARAMETERS);
if (includeLogMessageParameters != null && !includeLogMessageParameters.trim().equals("")) {
setIncludeLogMessageParameters("true".equalsIgnoreCase(includeLogMessageParameters));
}
setupStaticFields(propertyProvider);
setupAdditionalFieldTypes(propertyProvider);
facility = propertyProvider.getProperty(PropertyProvider.PROPERTY_FACILITY);
String version = propertyProvider.getProperty(PropertyProvider.PROPERTY_VERSION);
if (version != null && !"".equals(version)) {
this.version = version;
}
String messageSize = propertyProvider.getProperty(PropertyProvider.PROPERTY_MAX_MESSAGE_SIZE);
if (messageSize != null) {
maximumMessageSize = Integer.parseInt(messageSize);
}
}
/**
* Produce a {@link GelfMessage}.
*
* @param logEvent the log event
* @return a new GelfMessage
*/
public GelfMessage createGelfMessage(LogEvent logEvent) {
GelfMessageBuilder builder = builders != null ? builders.get().recycle() : newInstance();
Throwable throwable = logEvent.getThrowable();
String message = logEvent.getFormattedMessage();
if (GelfMessage.isEmpty(message) && throwable != null) {
message = throwable.toString();
}
String shortMessage = message;
if (message.length() > MAX_SHORT_MESSAGE_LENGTH) {
shortMessage = message.substring(0, MAX_SHORT_MESSAGE_LENGTH - 1);
}
builder.withShortMessage(shortMessage).withFullMessage(message).withJavaTimestamp(logEvent.getLogTimestamp());
builder.withLevel(logEvent.getSyslogLevel());
builder.withVersion(getVersion());
builder.withAdditionalFieldTypes(additionalFieldTypes);
for (MessageField field : fields) {
Values values = getValues(logEvent, field);
if (values == null || !values.hasValues()) {
continue;
}
for (String entryName : values.getEntryNames()) {
String value = values.getValue(entryName);
if (value == null) {
continue;
}
builder.withField(entryName, value);
}
}
if (stackTraceExtraction.isEnabled() && throwable != null) {
addStackTrace(throwable, builder);
}
if (includeLogMessageParameters && logEvent.getParameters() != null) {
for (int i = 0; i < logEvent.getParameters().length; i++) {
Object param = logEvent.getParameters()[i];
builder.withField(FIELD_MESSAGE_PARAM + i, "" + param);
}
}
builder.withHost(getOriginHost());
if (null != facility) {
builder.withFacility(facility);
}
builder.withMaximumMessageSize(maximumMessageSize);
return builder.build();
}
private Values getValues(LogEvent logEvent, MessageField field) {
if (field instanceof StaticMessageField) {
return new Values(field.getName(), getValue((StaticMessageField) field));
}
if (field instanceof LogMessageField) {
LogMessageField logMessageField = (LogMessageField) field;
if (logMessageField.getNamedLogField() == LogMessageField.NamedLogField.Time) {
SimpleDateFormat dateFormat = new SimpleDateFormat(timestampPattern);
return new Values(field.getName(), dateFormat.format(new Date(logEvent.getLogTimestamp())));
}
if (logMessageField.getNamedLogField() == LogMessageField.NamedLogField.Server) {
return new Values(field.getName(), getOriginHost());
}
}
return logEvent.getValues(field);
}
private String getValue(StaticMessageField field) {
return field.getValue();
}
private void addStackTrace(Throwable thrown, GelfMessageBuilder builder) {
if (stackTraceExtraction.isFilter()) {
builder.withField(FIELD_STACK_TRACE, StackTraceFilter.getFilteredStackTrace(thrown, stackTraceExtraction.getRef()));
} else {
final StringWriter sw = new StringWriter();
StackTraceFilter.getThrowable(thrown, stackTraceExtraction.getRef()).printStackTrace(new PrintWriter(sw));
builder.withField(FIELD_STACK_TRACE, sw.toString());
}
}
private void setupStaticFields(PropertyProvider propertyProvider) {
int fieldNumber = 0;
while (true) {
final String property = propertyProvider.getProperty(PropertyProvider.PROPERTY_ADDITIONAL_FIELD + fieldNumber);
if (null == property) {
break;
}
final int index = property.indexOf('=');
if (-1 != index) {
StaticMessageField field = new StaticMessageField(property.substring(0, index), property.substring(index + 1));
addField(field);
}
fieldNumber++;
}
}
private void setupAdditionalFieldTypes(PropertyProvider propertyProvider) {
int fieldNumber = 0;
while (true) {
final String property = propertyProvider.getProperty(PropertyProvider.PROPERTY_ADDITIONAL_FIELD_TYPE + fieldNumber);
if (null == property) {
break;
}
final int index = property.indexOf('=');
if (-1 != index) {
String field = property.substring(0, index);
String type = property.substring(index + 1);
setAdditionalFieldType(field, type);
}
fieldNumber++;
}
}
public void setAdditionalFieldType(String field, String type) {
additionalFieldTypes.put(field, type);
}
public void addField(MessageField field) {
if (!fields.contains(field)) {
this.fields.add(field);
}
}
public void addFields(Collection<? extends MessageField> fields) {
this.fields.addAll(fields);
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getOriginHost() {
if (null == originHost) {
originHost = RuntimeContainer.FQDN_HOSTNAME;
}
return originHost;
}
public void setOriginHost(String originHost) {
this.originHost = originHost;
}
public int getPort() {
return port;
}
public void setPort(int port) {
if (port > MAX_PORT_NUMBER || port < 1) {
throw new IllegalArgumentException("Invalid port number: " + port + ", supported range: 1-" + MAX_PORT_NUMBER);
}
this.port = port;
}
public String getFacility() {
return facility;
}
public void setFacility(String facility) {
this.facility = facility;
}
public boolean isExtractStackTrace() {
return stackTraceExtraction.isEnabled();
}
public String getExtractStackTrace() {
if (stackTraceExtraction.isEnabled()) {
if (stackTraceExtraction.getRef() == 0) {
return "true";
}
return Integer.toString(stackTraceExtraction.getRef());
}
return "false";
}
public void setExtractStackTrace(boolean extractStackTrace) {
this.stackTraceExtraction = stackTraceExtraction.applyExtaction("" + extractStackTrace);
}
public void setExtractStackTrace(String value) {
this.stackTraceExtraction = stackTraceExtraction.applyExtaction(value);
}
public boolean isFilterStackTrace() {
return stackTraceExtraction.isEnabled();
}
public void setFilterStackTrace(boolean filterStackTrace) {
this.stackTraceExtraction = stackTraceExtraction.applyFilter(filterStackTrace);
}
public boolean isIncludeLogMessageParameters() {
return includeLogMessageParameters;
}
public void setIncludeLogMessageParameters(boolean includeLogMessageParameters) {
this.includeLogMessageParameters = includeLogMessageParameters;
}
public String getTimestampPattern() {
return timestampPattern;
}
public void setTimestampPattern(String timestampPattern) {
this.timestampPattern = timestampPattern;
}
public int getMaximumMessageSize() {
return maximumMessageSize;
}
public void setMaximumMessageSize(int maximumMessageSize) {
if (maximumMessageSize > MAX_MESSAGE_SIZE || maximumMessageSize < 1) {
throw new IllegalArgumentException(
"Invalid maximum message size: " + maximumMessageSize + ", supported range: 1-" + MAX_MESSAGE_SIZE);
}
this.maximumMessageSize = maximumMessageSize;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
if (!GelfMessage.GELF_VERSION_1_0.equals(version) && !GelfMessage.GELF_VERSION_1_1.equals(version)) {
throw new IllegalArgumentException("Invalid GELF version: " + version + ", supported range: "
+ GelfMessage.GELF_VERSION_1_0 + ", " + GelfMessage.GELF_VERSION_1_1);
}
this.version = version;
}
static class StackTraceExtraction {
private static final StackTraceExtraction OFF = new StackTraceExtraction(false, false, 0);
private static final StackTraceExtraction ON = new StackTraceExtraction(true, false, 0);
private static final StackTraceExtraction FILTERED = new StackTraceExtraction(true, true, 0);
private final boolean enabled;
private final boolean filter;
private final int ref;
private StackTraceExtraction(boolean enabled, boolean filter, int ref) {
this.enabled = enabled;
this.filter = filter;
this.ref = ref;
}
/**
* Parse the stack trace filtering value.
*
* @param value
* @return
*/
public static StackTraceExtraction from(String value, boolean filter) {
if (value == null) {
return OFF;
}
boolean enabled = Boolean.parseBoolean(value);
int ref = 0;
if (!value.equalsIgnoreCase("false") && !value.trim().isEmpty()) {
try {
ref = Integer.parseInt(value);
enabled = true;
} catch (NumberFormatException e) {
ref = 0;
}
}
return new StackTraceExtraction(enabled, filter, ref);
}
public StackTraceExtraction applyExtaction(String value) {
StackTraceExtraction parsed = from(value, isFilter());
return new StackTraceExtraction(parsed.isEnabled(), parsed.isFilter(), parsed.getRef());
}
public StackTraceExtraction applyFilter(boolean filterStackTrace) {
return new StackTraceExtraction(isEnabled(), filterStackTrace, getRef());
}
public boolean isEnabled() {
return enabled;
}
public boolean isFilter() {
return filter;
}
public int getRef() {
return ref;
}
}
}
| [
"yyang@gizwits.com"
] | yyang@gizwits.com |
ca33600cb0232b08223de52226b87c76836e55ea | 3a7f87d3fd4705e55bb22664f01fc6960a2c2d58 | /SpringOpneProject/src/main/java/com/bitcamp/op/member/service/MemberDeleteService.java | 6743830795c3f34b7ca6e9194b6dc03273e5e2cb | [] | no_license | sol0612/Spring | e40d80b58c68736931cf4ad395a827d5372b86a1 | 5317022ced351f6631b5a90676fb926cac980106 | refs/heads/master | 2020-04-02T16:40:02.354886 | 2018-12-06T02:54:44 | 2018-12-06T02:54:44 | 154,623,176 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 729 | java | package com.bitcamp.op.member.service;
import java.sql.Connection;
import java.sql.SQLException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import com.bitcamp.op.jdbc.ConnectionProvider;
import com.bitcamp.op.member.dao.JdbcTemplateMemberDao;
public class MemberDeleteService {
@Autowired
JdbcTemplateMemberDao memberDao;
public void deleteMessage(@RequestParam("userId") String userId) throws SQLException {
Connection conn = null;
conn = ConnectionProvider.getConnection();
conn.setAutoCommit(false);
memberDao.getMemberInfo(userId);
memberDao.remove(userId);
conn.commit();
}
}
| [
"42909268+sol0612@users.noreply.github.com"
] | 42909268+sol0612@users.noreply.github.com |
be415a79aba2bc91c8eadca9946a6e2393a003f5 | b091ecf00046848cb333aeb7b46039ca67d15a1d | /nested-list-weight-sum/nested-list-weight-sum.java | 8131a545962aec291cc33dda8d4f109ae6f17822 | [] | no_license | deepashree5594/LeetCode | d4284bc799f94e20399cd5ca94f3d6cfaecc53f0 | 3415676da6dd08d708efe9fed1faac2ffd9a4800 | refs/heads/main | 2023-04-24T03:17:10.821853 | 2021-05-07T15:50:23 | 2021-05-07T15:50:23 | 315,803,708 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,935 | java | /**
* // This is the interface that allows for creating nested lists.
* // You should not implement it, or speculate about its implementation
* public interface NestedInteger {
* // Constructor initializes an empty nested list.
* public NestedInteger();
*
* // Constructor initializes a single integer.
* public NestedInteger(int value);
*
* // @return true if this NestedInteger holds a single integer, rather than a nested list.
* public boolean isInteger();
*
* // @return the single integer that this NestedInteger holds, if it holds a single integer
* // Return null if this NestedInteger holds a nested list
* public Integer getInteger();
*
* // Set this NestedInteger to hold a single integer.
* public void setInteger(int value);
*
* // Set this NestedInteger to hold a nested list and adds a nested integer to it.
* public void add(NestedInteger ni);
*
* // @return the nested list that this NestedInteger holds, if it holds a nested list
* // Return empty list if this NestedInteger holds a single integer
* public List<NestedInteger> getList();
* }
*/
//BFS
//TC: O(N)
//SC: O(N)
//Did it run successfully on Leetcode? :Yes
class Solution {
public int depthSum(List<NestedInteger> nestedList) {
if (nestedList == null || nestedList.size() == 0)
return 0;
Queue<NestedInteger> queue = new LinkedList();
Queue<Integer> depthQueue = new LinkedList();
int sum = 0;
for (NestedInteger element : nestedList){
queue.add(element);
depthQueue.add(1);
}
while (!queue.isEmpty()){
NestedInteger curr = queue.poll();
int currDepth = depthQueue.poll();
if (curr.isInteger()){
int n = curr.getInteger();
sum = sum + (n * currDepth);
}
else {
List<NestedInteger> list = curr.getList();
for (NestedInteger n : list){
queue.offer(n);
depthQueue.offer(currDepth+1);
}
}
}
return sum;
}
}
//DFS
//TC: O(N)
//SC: O(depth)
//Did it run successfully on Leetcode? :Yes
// class Solution {
// int sum;
// public int depthSum(List<NestedInteger> nestedList) {
// if (nestedList == null || nestedList.size() == 0)
// return 0;
// sum = 0;
// dfs(nestedList, 1);
// return sum;
// }
// private void dfs(List<NestedInteger> nestedList, int depth){
// //base (not needed)
// //logic
// for (NestedInteger nested : nestedList){
// if (nested.isInteger()){
// sum = sum + nested.getInteger() * depth;
// }
// else {
// dfs(nested.getList(), depth+1);
// }
// }
// }
// } | [
"56852374+deepashree5594@users.noreply.github.com"
] | 56852374+deepashree5594@users.noreply.github.com |
24c68c0e93998afc9953d3a5dacc64fed1f92b2e | 3c123da66ebfaeb8e2b5e65debf4798b5557c54f | /sdms/src/test/java/com/systech/tradewinds/sdms/Test/FunnelStageTest.java | a341b4b5ff5324f291fe675c06140e67f02ffe4a | [] | no_license | madhan-QA/SDMSAutomation | 7785d8f3ab2c57783faa2f71572c5771b9efa886 | 0baa53ec718c1cec5c694f4db41f790a233ae990 | refs/heads/main | 2023-03-03T17:08:25.914531 | 2021-02-10T17:24:56 | 2021-02-10T17:24:56 | 327,350,662 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,464 | java | package com.systech.tradewinds.sdms.Test;
import java.io.IOException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.systech.tradewinds.sdms.common.BasePage;
import com.systech.tradewinds.sdms.pageobject.FunnelStageMaster;
import jxl.read.biff.BiffException;
public class FunnelStageTest extends BasePage {
FunnelStageMaster FunlStag;
@Test(groups= {"FunlStagMaster"},dependsOnGroups= {"login"},dataProvider="FunlStagData")
public void insertFunlStagData(String FunlStage,String Remarks) {
FunlStag = new FunnelStageMaster();
loadUrl(FunlStag.getPageUrl());
txtData(FunlStag.getFunlStage(),FunlStage);
txtData(FunlStag.getRemarks(),Remarks);
try {
sleep();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
btnClick(FunlStag.getSubmit());
try {
sleep();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
btnClick(FunlStag.getok());
//btnClick(FunlStag.getReset());
refresh();
}
@DataProvider(name="FunlStagData")
public Object[][] FunlStagData() throws BiffException, IOException{
Object[][] testData = null;
try {
testData = getExcel("C:\\Users\\Systech\\Desktop\\Data\\FunlStagData.xls",0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return testData;
}
}
| [
"Systech@Sathya"
] | Systech@Sathya |
34ea5cd3336df09a736e232d6f71d23a4320078d | b481b4ecfb3e3179c907d81bc271455d31dac966 | /CoreJava/src/com/threads/ThreadDemo2.java | 335d5a433d2d2ed2b2b109ec8b79753667156520 | [] | no_license | srilakshmiG/GitDemo | ca54d83de1ac43f012bfae38e87c05bdbbc4a54a | 9751dd62a93b84459d299eb94f89485e7b0b8c61 | refs/heads/master | 2020-06-10T21:07:46.327270 | 2017-03-07T01:44:42 | 2017-03-07T01:44:42 | 75,874,489 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 191 | java | package com.threads;
public class ThreadDemo2 extends Thread {
Printing p;
ThreadDemo2(Printing p){
this.p=p;
}
public void run(){
p.printTable(10);
}
}
| [
"srilakshmi.garimalla@gmail.com"
] | srilakshmi.garimalla@gmail.com |
89fdbc902ff7b5d7ae663190463fe43010753e9f | 46fd84b3cfe1d675d2cf7a629ed883060a5fc252 | /ByteShortInt/src/ByteShortInt.java | 7d034ec8167b20a76e7fd206afc5034664875d95 | [] | no_license | ManbirJaspal/Java | ce266ebfd19336299c3c8fe099b9b30ca01f930f | ebfce06a33ba202e551428111824694d9ef00fd9 | refs/heads/master | 2020-03-14T08:37:14.743819 | 2018-04-29T21:32:14 | 2018-04-29T21:32:14 | 131,528,789 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 486 | java | public class ByteShortInt {
public static void main(String[] args){
// int has a width of 32
int myMinValue = -2_147_483_648; //min and max values that int can contain
int myMaxValue = 2_147_483_647;
//byte has a width of 8
byte myByteValue = -128;
//short has a width of 16
short myShortValue = 32767; //max value
//long has a width of 64
long myLongValue = 9_223_372_036_854_775_807L; //max value
}
}
| [
"manb.jaspal@gmail.com"
] | manb.jaspal@gmail.com |
bc329174fd5feea24b9ced124c5adc4d4c8ffc70 | adebbdc802e6bc8a0e3f6841db757390231db8e1 | /TeamCode/src/main/java/org/whitneyrobotics/ftc/teamcode/tests/DemoDrivetrain.java | 893dd85744fdf2e87ad2447137243b3e9e707700 | [
"BSD-3-Clause"
] | permissive | WHSRobotics/542_19-20_ftc | f7270669d69698ab8007550cf7773294e294cb13 | 4f2d24f194ce5ff35782b543f1b1dcdc9916f3d7 | refs/heads/master | 2021-07-24T22:50:00.001288 | 2020-03-12T00:41:58 | 2020-03-12T00:41:58 | 207,155,270 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 543 | java | package org.whitneyrobotics.ftc.teamcode.tests;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import org.whitneyrobotics.ftc.teamcode.subsys.Drivetrain;
@TeleOp(name= "Demo Program")
public class DemoDrivetrain extends OpMode {
Drivetrain demoRobot;
@Override
public void init() {
demoRobot = new Drivetrain(hardwareMap);
}
@Override
public void loop() {
demoRobot.operate(-gamepad1.left_stick_y/4, -gamepad1.right_stick_y/4);
}
}
| [
"adityaalexmukerjee@gmail.com"
] | adityaalexmukerjee@gmail.com |
beea40c57ac7b896a96b1e9791b87eb97ec7599a | 3cd69da4d40f2d97130b5bf15045ba09c219f1fa | /sources/com/google/android/gms/internal/measurement/zzcv.java | fa86315ae6593ae6e4cced6b02e38cd9aff08791 | [] | no_license | TheWizard91/Album_base_source_from_JADX | 946ea3a407b4815ac855ce4313b97bd42e8cab41 | e1d228fc2ee550ac19eeac700254af8b0f96080a | refs/heads/master | 2023-01-09T08:37:22.062350 | 2020-11-11T09:52:40 | 2020-11-11T09:52:40 | 311,927,971 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,539 | java | package com.google.android.gms.internal.measurement;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.StrictMode;
import android.util.Log;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/* compiled from: com.google.android.gms:play-services-measurement-impl@@17.4.4 */
public final class zzcv {
public static zzdr<zzcs> zza(Context context) {
String str = Build.TYPE;
String str2 = Build.TAGS;
boolean z = false;
if ((str.equals("eng") || str.equals("userdebug")) && (str2.contains("dev-keys") || str2.contains("test-keys"))) {
z = true;
}
if (!z) {
return zzdr.zzc();
}
if (zzcg.zza() && !context.isDeviceProtectedStorage()) {
context = context.createDeviceProtectedStorageContext();
}
zzdr<File> zzb = zzb(context);
if (zzb.zza()) {
return zzdr.zza(zza(zzb.zzb()));
}
return zzdr.zzc();
}
private static zzdr<File> zzb(Context context) {
StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
try {
StrictMode.allowThreadDiskWrites();
File file = new File(context.getDir("phenotype_hermetic", 0), "overrides.txt");
return file.exists() ? zzdr.zza(file) : zzdr.zzc();
} catch (RuntimeException e) {
Log.e("HermeticFileOverrides", "no data dir", e);
return zzdr.zzc();
} finally {
StrictMode.setThreadPolicy(allowThreadDiskReads);
}
}
private static zzcs zza(File file) {
BufferedReader bufferedReader;
try {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
HashMap hashMap = new HashMap();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
String[] split = readLine.split(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR, 3);
if (split.length != 3) {
String valueOf = String.valueOf(readLine);
Log.e("HermeticFileOverrides", valueOf.length() != 0 ? "Invalid: ".concat(valueOf) : new String("Invalid: "));
} else {
String str = split[0];
String decode = Uri.decode(split[1]);
String decode2 = Uri.decode(split[2]);
if (!hashMap.containsKey(str)) {
hashMap.put(str, new HashMap());
}
((Map) hashMap.get(str)).put(decode, decode2);
}
} else {
String valueOf2 = String.valueOf(file);
Log.i("HermeticFileOverrides", new StringBuilder(String.valueOf(valueOf2).length() + 7).append("Parsed ").append(valueOf2).toString());
zzcs zzcs = new zzcs(hashMap);
bufferedReader.close();
return zzcs;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (Throwable th) {
zzgd.zza(th, th);
}
throw th;
}
}
| [
"agiapong@gmail.com"
] | agiapong@gmail.com |
7f113d92addf3111f89c46f36d988e4f6a5a769a | 9b35b5001296445c703154cda666f20ea4b7d305 | /NewOneToMany/src/com/meena/Question.java | e3760d3c02f62581136a55f42152f20d95071003 | [] | no_license | MeenakshiDSelenium/javaprogram | b951b56270192afb971306a74056d0b1da6e404a | 3506c79ff6433904b87a52deeaaedece188138ba | refs/heads/master | 2020-04-18T22:35:07.635440 | 2019-03-22T13:11:33 | 2019-03-22T13:11:33 | 167,797,983 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 494 | java | package com.meena;
import java.util.List;
public class Question {
private int id;
private String qName;
private List<Answer> answer;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getqName() {
return qName;
}
public void setqName(String qName) {
this.qName = qName;
}
public List<Answer> getAnswer() {
return answer;
}
public void setAnswer(List<Answer> answer) {
this.answer = answer;
}
}
| [
"hp@user"
] | hp@user |
a0a718ca903c47375dfd1787350818f0829046dc | a3ab499764af2180595b1e7f6b6e1483862a6e26 | /src/com/meng/recommend/servlets/PasswdServlet.java | d5be9a63d00a09bea93f05bc493b13e5d0c33a91 | [] | no_license | usmeng/Recommendation | 9716f8bedd2960f894aec6ed420e9af550a88ba3 | a7e9d5f02075f9c32b1fd4a6d16d8ff4e6eacd65 | refs/heads/master | 2021-01-22T02:17:33.407974 | 2017-05-25T00:31:39 | 2017-05-25T00:31:39 | 92,348,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,077 | java | package com.meng.recommend.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class PasswdServlet
*/
@WebServlet("/PasswdServlet")
public class PasswdServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public PasswdServlet() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println("try to find password!");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
| [
"xmtx112358zm@gmail.com"
] | xmtx112358zm@gmail.com |
905ed2e0773aea428ebc2cde3028a4656d0dbfbc | ba45476706b5d3cc0e8d9c9bf9dffb1540deb656 | /src/main/java/com/javadeobfuscator/deobfuscator/rules/special/RuleBisguardClassEncryption.java | ab23e084d5230d4dec8b6b2394246d64224c4c82 | [
"Apache-2.0"
] | permissive | java-deobfuscator/deobfuscator | e48ca2aa767aeae44b1de83d6110332fa0b5bfa6 | e7b6eba9bfc8962968c5eb94c1588f30e309b1e1 | refs/heads/master | 2023-07-30T23:30:27.515535 | 2023-04-01T14:39:20 | 2023-04-26T17:50:07 | 50,709,747 | 1,546 | 417 | Apache-2.0 | 2023-04-26T17:50:08 | 2016-01-30T04:58:17 | Java | UTF-8 | Java | false | false | 1,976 | java | package com.javadeobfuscator.deobfuscator.rules.special;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import com.javadeobfuscator.deobfuscator.Deobfuscator;
import com.javadeobfuscator.deobfuscator.rules.Rule;
import com.javadeobfuscator.deobfuscator.transformers.Transformer;
import com.javadeobfuscator.deobfuscator.transformers.special.BisGuardTransformer;
import org.objectweb.asm.tree.ClassNode;
public class RuleBisguardClassEncryption implements Rule {
private static final Set<String> classNames = new HashSet<>();
static {
classNames.add("JavaPreloader".toLowerCase(Locale.ROOT));
classNames.add("JavaPreloader$Cipher".toLowerCase(Locale.ROOT));
classNames.add("com/bisguard/utils/Authenticator".toLowerCase(Locale.ROOT));
}
@Override
public String getDescription() {
return "Bisguard does encrypt classes and decrypts them on load";
}
@Override
public String test(Deobfuscator deobfuscator) {
int count = 0;
for (ClassNode classNode : deobfuscator.getClasses().values()) {
if (classNames.contains(classNode.name.toLowerCase(Locale.ROOT))) {
count++;
}
}
if (count >= 2) {
byte[] manifest = deobfuscator.getInputPassthrough().get("META-INF/MANIFEST.MF");
if (manifest == null) {
return null;
}
String[] lines = new String(manifest).split("\n");
for (String line : lines) {
if (line.startsWith("Subordinate-Class: ")) {
return "Found possible Bisguard class encryption files";
}
}
}
return null;
}
@Override
public Collection<Class<? extends Transformer<?>>> getRecommendTransformers() {
return Collections.singleton(BisGuardTransformer.class);
}
}
| [
"itzsomebody@protonmail.com"
] | itzsomebody@protonmail.com |
0817242038a052b4845326c66074b00589a20c1d | 409f9b28ed4d1ca265b3fb67f87ffa7af7c0c1f3 | /src/logic/TreeReader.java | 3ee38afe36cf63755cf3390c762a160df218cab5 | [
"MIT"
] | permissive | thos-com-de/FileSync | 5466684d31162c4be46b4ea3a7e88dc3448b5e53 | ee8971ebd1e04f2fff1ac69ecbccb5890a0b7558 | refs/heads/master | 2021-01-19T01:09:03.097907 | 2017-04-07T23:38:21 | 2017-04-07T23:38:21 | 87,227,687 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 860 | java | package logic;
import java.io.File;
import model.VDir;
import model.VFile;
import model.VTree;
public class TreeReader extends VTree {
public TreeReader(File path) {
super(new VDir(path));
}
public VDir read() {
return this.read(this.getRoot());
}
protected VDir read(VDir vDir) {
File[] listFiles = vDir.listIOFiles();
for (File file : listFiles) {
if (file.isDirectory()) {
VDir vSubDir = new VDir(file);
vDir.addDir(vSubDir);
// recursive read directory
VDir subReaded = read(vSubDir);
// now we have the size and can add it to parent
vDir.setSize(vDir.getSize() + subReaded.getSize());
// count sum
this.incTotalDirs();
} else {
VFile vFile = new VFile(file);
vDir.addFile(vFile);
// count sum
this.incTotalFiles();
}
}
return vDir;
}
} | [
"noreply@github.com"
] | noreply@github.com |
ec8ab10485ab86d694e78c8d733e4db87178b407 | 55a71e79de8e46d6142ff5dfca6293876ff13d29 | /BaoLiPlay/src/main/java/com/easefun/polyvsdk/activity/PolyvOnlineVideoActivity.java | 655fae3a2395f466ef81bdd7d9d5eb0a388ab998 | [] | no_license | githubwxq/BaoLiLai | 3389ed68760b5e877eda2bc922ec579e461c5b96 | d31a5e258fb0e5969ffe4c14454fc3bb22c8d20a | refs/heads/master | 2020-04-06T13:43:17.948543 | 2018-11-14T07:55:11 | 2018-11-14T07:55:11 | 157,511,745 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,840 | java | package com.easefun.polyvsdk.activity;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.easefun.polyvsdk.PolyvSDKClient;
import com.easefun.polyvsdk.R;
import com.easefun.polyvsdk.RestVO;
import com.easefun.polyvsdk.adapter.EndlessRecyclerOnScrollListener;
import com.easefun.polyvsdk.adapter.HeaderViewRecyclerAdapter;
import com.easefun.polyvsdk.adapter.PolyvOnlineListViewAdapter;
import org.json.JSONException;
import java.util.ArrayList;
import java.util.List;
public class PolyvOnlineVideoActivity extends Activity implements View.OnClickListener {
private ImageView iv_finish;
private RecyclerView lv_online;
private PolyvOnlineListViewAdapter lv_online_adapter;
private HeaderViewRecyclerAdapter mAdapter;
private List<RestVO> data;
private View loadMoreView;
private int pageNum = 1, pageSize = 20;
;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.polyv_activity_online_video);
findIdAndNew();
initView();
}
private void findIdAndNew() {
iv_finish = (ImageView) findViewById(R.id.iv_finish);
lv_online = (RecyclerView) findViewById(R.id.lv_online);
data = new ArrayList<>();
}
private void initView() {
lv_online_adapter = new PolyvOnlineListViewAdapter(lv_online, this, data);
lv_online.setHasFixedSize(true);
LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(this);
lv_online.setLayoutManager(mLinearLayoutManager);
mAdapter = new HeaderViewRecyclerAdapter(lv_online_adapter);
lv_online.setAdapter(mAdapter);
createLoadMoreView();
lv_online.addOnScrollListener(new EndlessRecyclerOnScrollListener(mLinearLayoutManager) {
@Override
public void onLoadMore(int i) {
pageNum++;
loadMoreView.setVisibility(View.VISIBLE);
new LoadVideoList().execute();
}
});
new LoadVideoList().execute();
iv_finish.setOnClickListener(this);
}
private void createLoadMoreView() {
loadMoreView = LayoutInflater.from(this).inflate(R.layout.polyv_bottom_loadmorelayout, lv_online, false);
mAdapter.addFooterView(loadMoreView);
loadMoreView.setVisibility(View.GONE);
}
class LoadVideoList extends AsyncTask<String, String, List<RestVO>> {
@Override
protected List<RestVO> doInBackground(String... arg0) {
try {
return PolyvSDKClient.getInstance().getVideoList(pageNum, pageSize);
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(List<RestVO> result) {
super.onPostExecute(result);
loadMoreView.setVisibility(View.GONE);
if (result == null) {
mAdapter.removeFootView();
return;
}
if (result.size() < pageSize)
mAdapter.removeFootView();
data.addAll(result);
if (pageNum * pageSize - pageSize - 1 > 0) {
mAdapter.notifyItemRangeChanged(pageNum * pageSize - pageSize - 1, pageSize);
} else {
mAdapter.notifyDataSetChanged();
}
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.iv_finish:
finish();
break;
}
}
}
| [
"805380422@qq.com"
] | 805380422@qq.com |
272dc617b85178f34edbe2e4d1c66891e2c9d3f1 | 08bd28dab9a12044c901356d6bed1da8145653b9 | /clientlib/src/main/java/com/idhub/magic/clientlib/event/BlockListener.java | 67dc889da1eae04afc260aba504d66ee2f703015 | [
"MIT"
] | permissive | idhub-did-plus/did-wallet-android | 45f1943c8f4d8fd0aebe15720c73ac1833e08113 | 34f2b5ea712ed46da176167a646cbddf580e63f6 | refs/heads/master | 2020-07-01T12:59:33.768227 | 2020-01-02T06:21:22 | 2020-01-02T06:21:22 | 201,180,587 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 345 | java | package com.idhub.magic.clientlib.event;
import java.util.List;
import java.util.Optional;
import org.web3j.protocol.core.methods.response.Transaction;
import com.idhub.magic.clientlib.ProviderFactory;
import io.api.etherscan.core.impl.EtherScanApi;
import io.reactivex.disposables.Disposable;
public class BlockListener {
static {
}
}
| [
"liyuwei2010@foxmail.com"
] | liyuwei2010@foxmail.com |
0da2d631be2febf119c476c539e4942d353e2b35 | bbe34278f3ed99948588984c431e38a27ad34608 | /sources/de/danoeh/antennapod/activity/-$$Lambda$MediaplayerActivity$SGyWYC0ENzkBg8hPUBquJ6-NyWA.java | 87fd511baadf71843d1f008bd251e4a9d1268df1 | [] | no_license | sapardo10/parcial-pruebas | 7af500f80699697ab9b9291388541c794c281957 | 938a0ceddfc8e0e967a1c7264e08cd9d1fe192f0 | refs/heads/master | 2020-04-28T02:07:08.766181 | 2019-03-10T21:51:36 | 2019-03-10T21:51:36 | 174,885,553 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 577 | java | package de.danoeh.antennapod.activity;
import android.view.View;
import android.view.View.OnClickListener;
/* compiled from: lambda */
public final /* synthetic */ class -$$Lambda$MediaplayerActivity$SGyWYC0ENzkBg8hPUBquJ6-NyWA implements OnClickListener {
private final /* synthetic */ MediaplayerActivity f$0;
public /* synthetic */ -$$Lambda$MediaplayerActivity$SGyWYC0ENzkBg8hPUBquJ6-NyWA(MediaplayerActivity mediaplayerActivity) {
this.f$0 = mediaplayerActivity;
}
public final void onClick(View view) {
this.f$0.onPlayPause();
}
}
| [
"sa.pardo10@uniandes.edu.co"
] | sa.pardo10@uniandes.edu.co |
3ecc136bd3a824ac01bce89c7924ab90d2cda337 | 84daaf11d3223a6dfcacc2725d85f7b9b564be16 | /src/com/facebook/widget/WebDialog.java | 61dfe7591e46f6174125cada3767d8cd4ad71493 | [
"MIT"
] | permissive | ldarren/pico-phonegap-base | 1bf41d4efb979f9e5d678a01fb55d38f58ff6caa | 970b467474c85d594aef8af4a65129e0e12693a6 | refs/heads/master | 2021-01-20T12:03:56.338449 | 2014-03-31T08:26:45 | 2014-03-31T08:26:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 31,122 | java | /**
* Copyright 2010-present Facebook.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.widget;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.*;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.facebook.*;
import com.facebook.android.*;
import com.facebook.internal.Logger;
import com.facebook.internal.ServerProtocol;
import com.facebook.internal.Utility;
import com.facebook.internal.Validate;
import com.baroq.dungeonchronicles.R;
/**
* This class provides a mechanism for displaying Facebook Web dialogs inside a Dialog. Helper
* methods are provided to construct commonly-used dialogs, or a caller can specify arbitrary
* parameters to call other dialogs.
*/
public class WebDialog extends Dialog {
private static final String LOG_TAG = Logger.LOG_TAG_BASE + "WebDialog";
private static final String DISPLAY_TOUCH = "touch";
private static final String USER_AGENT = "user_agent";
static final String REDIRECT_URI = "fbconnect://success";
static final String CANCEL_URI = "fbconnect://cancel";
static final boolean DISABLE_SSL_CHECK_FOR_TESTING = false;
// width below which there are no extra margins
private static final int NO_BUFFER_SCREEN_WIDTH = 512;
// width beyond which we're always using the MIN_SCALE_FACTOR
private static final int MAX_BUFFER_SCREEN_WIDTH = 1024;
// the minimum scaling factor for the web dialog (60% of screen size)
private static final double MIN_SCALE_FACTOR = 0.6;
// translucent border around the webview
private static final int BACKGROUND_GRAY = 0xCC000000;
public static final int DEFAULT_THEME = android.R.style.Theme_Translucent_NoTitleBar;
private String url;
private OnCompleteListener onCompleteListener;
private WebView webView;
private ProgressDialog spinner;
private ImageView crossImageView;
private FrameLayout contentFrameLayout;
private boolean listenerCalled = false;
private boolean isDetached = false;
/**
* Interface that implements a listener to be called when the user's interaction with the
* dialog completes, whether because the dialog finished successfully, or it was cancelled,
* or an error was encountered.
*/
public interface OnCompleteListener {
/**
* Called when the dialog completes.
*
* @param values on success, contains the values returned by the dialog
* @param error on an error, contains an exception describing the error
*/
void onComplete(Bundle values, FacebookException error);
}
/**
* Constructor which can be used to display a dialog with an already-constructed URL.
*
* @param context the context to use to display the dialog
* @param url the URL of the Web Dialog to display; no validation is done on this URL, but it should
* be a valid URL pointing to a Facebook Web Dialog
*/
public WebDialog(Context context, String url) {
this(context, url, DEFAULT_THEME);
}
/**
* Constructor which can be used to display a dialog with an already-constructed URL and a custom theme.
*
* @param context the context to use to display the dialog
* @param url the URL of the Web Dialog to display; no validation is done on this URL, but it should
* be a valid URL pointing to a Facebook Web Dialog
* @param theme identifier of a theme to pass to the Dialog class
*/
public WebDialog(Context context, String url, int theme) {
super(context, theme);
this.url = url;
}
/**
* Constructor which will construct the URL of the Web dialog based on the specified parameters.
*
* @param context the context to use to display the dialog
* @param action the portion of the dialog URL following "dialog/"
* @param parameters parameters which will be included as part of the URL
* @param theme identifier of a theme to pass to the Dialog class
* @param listener the listener to notify, or null if no notification is desired
*/
public WebDialog(Context context, String action, Bundle parameters, int theme, OnCompleteListener listener) {
super(context, theme);
if (parameters == null) {
parameters = new Bundle();
}
parameters.putString(ServerProtocol.DIALOG_PARAM_DISPLAY, DISPLAY_TOUCH);
parameters.putString(ServerProtocol.DIALOG_PARAM_TYPE, USER_AGENT);
Uri uri = Utility.buildUri(ServerProtocol.getDialogAuthority(), ServerProtocol.DIALOG_PATH + action,
parameters);
this.url = uri.toString();
onCompleteListener = listener;
}
/**
* Sets the listener which will be notified when the dialog finishes.
*
* @param listener the listener to notify, or null if no notification is desired
*/
public void setOnCompleteListener(OnCompleteListener listener) {
onCompleteListener = listener;
}
/**
* Gets the listener which will be notified when the dialog finishes.
*
* @return the listener, or null if none has been specified
*/
public OnCompleteListener getOnCompleteListener() {
return onCompleteListener;
}
@Override
public void dismiss() {
if (webView != null) {
webView.stopLoading();
}
if (!isDetached) {
if (spinner.isShowing()) {
spinner.dismiss();
}
super.dismiss();
}
}
@Override
public void onDetachedFromWindow() {
isDetached = true;
super.onDetachedFromWindow();
}
@Override
public void onAttachedToWindow() {
isDetached = false;
super.onAttachedToWindow();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
sendCancelToListener();
}
});
spinner = new ProgressDialog(getContext());
spinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
spinner.setMessage(getContext().getString(R.string.com_facebook_loading));
spinner.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
sendCancelToListener();
WebDialog.this.dismiss();
}
});
requestWindowFeature(Window.FEATURE_NO_TITLE);
contentFrameLayout = new FrameLayout(getContext());
// First calculate the margins around the frame layout
Pair<Integer, Integer> margins = getMargins();
contentFrameLayout.setPadding(margins.first, margins.second, margins.first, margins.second);
/* Create the 'x' image, but don't add to the contentFrameLayout layout yet
* at this point, we only need to know its drawable width and height
* to place the webview
*/
createCrossImage();
/* Now we know 'x' drawable width and height,
* layout the webview and add it the contentFrameLayout layout
*/
int crossWidth = crossImageView.getDrawable().getIntrinsicWidth();
setUpWebView(crossWidth / 2 + 1);
/* Finally add the 'x' image to the contentFrameLayout layout and
* add contentFrameLayout to the Dialog view
*/
contentFrameLayout.addView(crossImageView, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
addContentView(contentFrameLayout,
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
private Pair<Integer, Integer> getMargins() {
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
int width = metrics.widthPixels;
int height = metrics.heightPixels;
double scaleFactor;
int scaledWidth = (int) ((float) width / metrics.density);
if (scaledWidth <= NO_BUFFER_SCREEN_WIDTH) {
scaleFactor = 1.0;
} else if (scaledWidth >= MAX_BUFFER_SCREEN_WIDTH) {
scaleFactor = MIN_SCALE_FACTOR;
} else {
// between the NO_BUFFER and MAX_BUFFER widths, we take a linear reduction to go from 100%
// of screen size down to MIN_SCALE_FACTOR
scaleFactor = MIN_SCALE_FACTOR +
((double) (MAX_BUFFER_SCREEN_WIDTH - scaledWidth))
/ ((double) (MAX_BUFFER_SCREEN_WIDTH - NO_BUFFER_SCREEN_WIDTH))
* (1.0 - MIN_SCALE_FACTOR);
}
int leftRightMargin = (int) (width * (1.0 - scaleFactor) / 2);
int topBottomMargin = (int) (height * (1.0 - scaleFactor) / 2);
return new Pair<Integer, Integer>(leftRightMargin, topBottomMargin);
}
private void sendSuccessToListener(Bundle values) {
if (onCompleteListener != null && !listenerCalled) {
listenerCalled = true;
onCompleteListener.onComplete(values, null);
}
}
private void sendErrorToListener(Throwable error) {
if (onCompleteListener != null && !listenerCalled) {
listenerCalled = true;
FacebookException facebookException = null;
if (error instanceof FacebookException) {
facebookException = (FacebookException) error;
} else {
facebookException = new FacebookException(error);
}
onCompleteListener.onComplete(null, facebookException);
}
}
private void sendCancelToListener() {
sendErrorToListener(new FacebookOperationCanceledException());
}
private void createCrossImage() {
crossImageView = new ImageView(getContext());
// Dismiss the dialog when user click on the 'x'
crossImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendCancelToListener();
WebDialog.this.dismiss();
}
});
Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.com_facebook_close);
crossImageView.setImageDrawable(crossDrawable);
/* 'x' should not be visible while webview is loading
* make it visible only after webview has fully loaded
*/
crossImageView.setVisibility(View.INVISIBLE);
}
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
LinearLayout webViewContainer = new LinearLayout(getContext());
webView = new WebView(getContext());
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new DialogWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
webView.getSettings().setSavePassword(false);
webViewContainer.setPadding(margin, margin, margin, margin);
webViewContainer.addView(webView);
webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
contentFrameLayout.addView(webViewContainer);
}
private class DialogWebViewClient extends WebViewClient {
@Override
@SuppressWarnings("deprecation")
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Utility.logd(LOG_TAG, "Redirect URL: " + url);
if (url.startsWith(WebDialog.REDIRECT_URI)) {
Bundle values = Util.parseUrl(url);
String error = values.getString("error");
if (error == null) {
error = values.getString("error_type");
}
String errorMessage = values.getString("error_msg");
if (errorMessage == null) {
errorMessage = values.getString("error_description");
}
String errorCodeString = values.getString("error_code");
int errorCode = FacebookRequestError.INVALID_ERROR_CODE;
if (!Utility.isNullOrEmpty(errorCodeString)) {
try {
errorCode = Integer.parseInt(errorCodeString);
} catch (NumberFormatException ex) {
errorCode = FacebookRequestError.INVALID_ERROR_CODE;
}
}
if (Utility.isNullOrEmpty(error) && Utility
.isNullOrEmpty(errorMessage) && errorCode == FacebookRequestError.INVALID_ERROR_CODE) {
sendSuccessToListener(values);
} else if (error != null && (error.equals("access_denied") ||
error.equals("OAuthAccessDeniedException"))) {
sendCancelToListener();
} else {
FacebookRequestError requestError = new FacebookRequestError(errorCode, error, errorMessage);
sendErrorToListener(new FacebookServiceException(requestError, errorMessage));
}
WebDialog.this.dismiss();
return true;
} else if (url.startsWith(WebDialog.CANCEL_URI)) {
sendCancelToListener();
WebDialog.this.dismiss();
return true;
} else if (url.contains(DISPLAY_TOUCH)) {
return false;
}
// launch non-dialog URLs in a full browser
getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
sendErrorToListener(new FacebookDialogException(description, errorCode, failingUrl));
WebDialog.this.dismiss();
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
if (DISABLE_SSL_CHECK_FOR_TESTING) {
handler.proceed();
} else {
super.onReceivedSslError(view, handler, error);
sendErrorToListener(new FacebookDialogException(null, ERROR_FAILED_SSL_HANDSHAKE, null));
handler.cancel();
WebDialog.this.dismiss();
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Utility.logd(LOG_TAG, "Webview loading URL: " + url);
super.onPageStarted(view, url, favicon);
if (!isDetached) {
spinner.show();
}
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (!isDetached) {
spinner.dismiss();
}
/*
* Once web view is fully loaded, set the contentFrameLayout background to be transparent
* and make visible the 'x' image.
*/
contentFrameLayout.setBackgroundColor(Color.TRANSPARENT);
webView.setVisibility(View.VISIBLE);
crossImageView.setVisibility(View.VISIBLE);
}
}
private static class BuilderBase<CONCRETE extends BuilderBase<?>> {
private Context context;
private Session session;
private String applicationId;
private String action;
private int theme = DEFAULT_THEME;
private OnCompleteListener listener;
private Bundle parameters;
protected BuilderBase(Context context, Session session, String action, Bundle parameters) {
Validate.notNull(session, "session");
if (!session.isOpened()) {
throw new FacebookException("Attempted to use a Session that was not open.");
}
this.session = session;
finishInit(context, action, parameters);
}
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) {
Validate.notNullOrEmpty(applicationId, "applicationId");
this.applicationId = applicationId;
finishInit(context, action, parameters);
}
/**
* Sets a theme identifier which will be passed to the underlying Dialog.
*
* @param theme a theme identifier which will be passed to the Dialog class
* @return the builder
*/
public CONCRETE setTheme(int theme) {
this.theme = theme;
@SuppressWarnings("unchecked")
CONCRETE result = (CONCRETE) this;
return result;
}
/**
* Sets the listener which will be notified when the dialog finishes.
*
* @param listener the listener to notify, or null if no notification is desired
* @return the builder
*/
public CONCRETE setOnCompleteListener(OnCompleteListener listener) {
this.listener = listener;
@SuppressWarnings("unchecked")
CONCRETE result = (CONCRETE) this;
return result;
}
/**
* Constructs a WebDialog using the parameters provided. The dialog is not shown,
* but is ready to be shown by calling Dialog.show().
*
* @return the WebDialog
*/
public WebDialog build() {
if (session != null && session.isOpened()) {
parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, session.getApplicationId());
parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, session.getAccessToken());
} else {
parameters.putString(ServerProtocol.DIALOG_PARAM_APP_ID, applicationId);
}
if (!parameters.containsKey(ServerProtocol.DIALOG_PARAM_REDIRECT_URI)) {
parameters.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, REDIRECT_URI);
}
return new WebDialog(context, action, parameters, theme, listener);
}
protected String getApplicationId() {
return applicationId;
}
protected Context getContext() {
return context;
}
protected int getTheme() {
return theme;
}
protected Bundle getParameters() {
return parameters;
}
protected WebDialog.OnCompleteListener getListener() {
return listener;
}
private void finishInit(Context context, String action, Bundle parameters) {
this.context = context;
this.action = action;
if (parameters != null) {
this.parameters = parameters;
} else {
this.parameters = new Bundle();
}
}
}
/**
* Provides a builder that allows construction of an arbitary Facebook web dialog.
*/
public static class Builder extends BuilderBase<Builder> {
/**
* Constructor that builds a dialog for an authenticated user.
*
* @param context the Context within which the dialog will be shown.
* @param session the Session representing an authenticating user to use for
* showing the dialog; must not be null, and must be opened.
* @param action the portion of the dialog URL following www.facebook.com/dialog/.
* See https://developers.facebook.com/docs/reference/dialogs/ for details.
* @param parameters a Bundle containing parameters to pass as part of the URL.
*/
public Builder(Context context, Session session, String action, Bundle parameters) {
super(context, session, action, parameters);
}
/**
* Constructor that builds a dialog without an authenticated user.
*
* @param context the Context within which the dialog will be shown.
* @param applicationId the application ID to be included in the dialog URL.
* @param action the portion of the dialog URL following www.facebook.com/dialog/.
* See https://developers.facebook.com/docs/reference/dialogs/ for details.
* @param parameters a Bundle containing parameters to pass as part of the URL.
*/
public Builder(Context context, String applicationId, String action, Bundle parameters) {
super(context, applicationId, action, parameters);
}
}
/**
* Provides a builder that allows construction of the parameters for showing
* the <a href="https://developers.facebook.com/docs/reference/dialogs/feed">Feed Dialog</a>.
*/
public static class FeedDialogBuilder extends BuilderBase<FeedDialogBuilder> {
private static final String FEED_DIALOG = "feed";
private static final String FROM_PARAM = "from";
private static final String TO_PARAM = "to";
private static final String LINK_PARAM = "link";
private static final String PICTURE_PARAM = "picture";
private static final String SOURCE_PARAM = "source";
private static final String NAME_PARAM = "name";
private static final String CAPTION_PARAM = "caption";
private static final String DESCRIPTION_PARAM = "description";
/**
* Constructor.
*
* @param context the Context within which the dialog will be shown.
* @param session the Session representing an authenticating user to use for
* showing the dialog; must not be null, and must be opened.
*/
public FeedDialogBuilder(Context context, Session session) {
super(context, session, FEED_DIALOG, null);
}
/**
* Constructor.
*
* @param context the Context within which the dialog will be shown.
* @param parameters a Bundle containing parameters to pass as part of the
* dialog URL. No validation is done on these parameters; it is
* the caller's responsibility to ensure they are valid. For more information,
* see <a href="https://developers.facebook.com/docs/reference/dialogs/feed/">
* https://developers.facebook.com/docs/reference/dialogs/feed/</a>.
* @param session the Session representing an authenticating user to use for
* showing the dialog; must not be null, and must be opened.
*/
public FeedDialogBuilder(Context context, Session session, Bundle parameters) {
super(context, session, FEED_DIALOG, parameters);
}
/**
* Sets the ID of the profile that is posting to Facebook. If none is specified,
* the default is "me". This profile must be either the authenticated user or a
* Page that the user is an administrator of.
*
* @param id Facebook ID of the profile to post from
* @return the builder
*/
public FeedDialogBuilder setFrom(String id) {
getParameters().putString(FROM_PARAM, id);
return this;
}
/**
* Sets the ID of the profile that the story will be published to. If not specified, it
* will default to the same profile that the story is being published from.
*
* @param id Facebook ID of the profile to post to
* @return the builder
*/
public FeedDialogBuilder setTo(String id) {
getParameters().putString(TO_PARAM, id);
return this;
}
/**
* Sets the URL of a link to be shared.
*
* @param link the URL
* @return the builder
*/
public FeedDialogBuilder setLink(String link) {
getParameters().putString(LINK_PARAM, link);
return this;
}
/**
* Sets the URL of a picture to be shared.
*
* @param picture the URL of the picture
* @return the builder
*/
public FeedDialogBuilder setPicture(String picture) {
getParameters().putString(PICTURE_PARAM, picture);
return this;
}
/**
* Sets the URL of a media file attached to this post. If this is set, any picture
* set via setPicture will be ignored.
*
* @param source the URL of the media file
* @return the builder
*/
public FeedDialogBuilder setSource(String source) {
getParameters().putString(SOURCE_PARAM, source);
return this;
}
/**
* Sets the name of the item being shared.
*
* @param name the name
* @return the builder
*/
public FeedDialogBuilder setName(String name) {
getParameters().putString(NAME_PARAM, name);
return this;
}
/**
* Sets the caption to be displayed.
*
* @param caption the caption
* @return the builder
*/
public FeedDialogBuilder setCaption(String caption) {
getParameters().putString(CAPTION_PARAM, caption);
return this;
}
/**
* Sets the description to be displayed.
*
* @param description the description
* @return the builder
*/
public FeedDialogBuilder setDescription(String description) {
getParameters().putString(DESCRIPTION_PARAM, description);
return this;
}
}
/**
* Provides a builder that allows construction of the parameters for showing
* the <a href="https://developers.facebook.com/docs/reference/dialogs/requests">Requests Dialog</a>.
*/
public static class RequestsDialogBuilder extends BuilderBase<RequestsDialogBuilder> {
private static final String APPREQUESTS_DIALOG = "apprequests";
private static final String MESSAGE_PARAM = "message";
private static final String TO_PARAM = "to";
private static final String DATA_PARAM = "data";
private static final String TITLE_PARAM = "title";
/**
* Constructor.
*
* @param context the Context within which the dialog will be shown.
* @param session the Session representing an authenticating user to use for
* showing the dialog; must not be null, and must be opened.
*/
public RequestsDialogBuilder(Context context, Session session) {
super(context, session, APPREQUESTS_DIALOG, null);
}
/**
* Constructor.
*
* @param context the Context within which the dialog will be shown.
* @param parameters a Bundle containing parameters to pass as part of the
* dialog URL. No validation is done on these parameters; it is
* the caller's responsibility to ensure they are valid. For more information,
* see <a href="https://developers.facebook.com/docs/reference/dialogs/requests/">
* https://developers.facebook.com/docs/reference/dialogs/requests/</a>.
* @param session the Session representing an authenticating user to use for
* showing the dialog; must not be null, and must be opened.
*/
public RequestsDialogBuilder(Context context, Session session, Bundle parameters) {
super(context, session, APPREQUESTS_DIALOG, parameters);
}
/**
* Sets the string users receiving the request will see. The maximum length
* is 60 characters.
*
* @param message the message
* @return the builder
*/
public RequestsDialogBuilder setMessage(String message) {
getParameters().putString(MESSAGE_PARAM, message);
return this;
}
/**
* Sets the user ID or user name the request will be sent to. If this is not
* specified, a friend selector will be displayed and the user can select up
* to 50 friends.
*
* @param id the id or user name to send the request to
* @return the builder
*/
public RequestsDialogBuilder setTo(String id) {
getParameters().putString(TO_PARAM, id);
return this;
}
/**
* Sets optional data which can be used for tracking; maximum length is 255
* characters.
*
* @param data the data
* @return the builder
*/
public RequestsDialogBuilder setData(String data) {
getParameters().putString(DATA_PARAM, data);
return this;
}
/**
* Sets an optional title for the dialog; maximum length is 50 characters.
*
* @param title the title
* @return the builder
*/
public RequestsDialogBuilder setTitle(String title) {
getParameters().putString(TITLE_PARAM, title);
return this;
}
}
}
| [
"ldarren@gmail.com"
] | ldarren@gmail.com |
c84ee419291e2121aafab00452ea41f5b3e91ca5 | 46f811f6d7a874b65b1b6da00aea17ce6668ff8b | /Project/org.xtext.sdu.formularzlanguage/xtend-gen/org/xtext/sdu/formularzlanguage/generator/FormularGenerator.java | 963e02c2a6778b282474b4192a45538c160c4cb5 | [] | no_license | Romeren/ProjectInCustomizationAndUbiquitous | 6cb486fc207dd9d324dac82986ff1459710cc1d8 | e4292fb144180df00e6fa78fdbf0819e36a116c1 | refs/heads/master | 2021-01-18T21:50:13.415900 | 2016-05-24T21:18:17 | 2016-05-24T21:18:17 | 53,489,424 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 671 | java | /**
* generated by Xtext 2.9.2
*/
package org.xtext.sdu.formularzlanguage.generator;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.generator.AbstractGenerator;
import org.eclipse.xtext.generator.IFileSystemAccess2;
import org.eclipse.xtext.generator.IGeneratorContext;
/**
* Generates code from your model files on save.
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
*/
@SuppressWarnings("all")
public class FormularGenerator extends AbstractGenerator {
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
}
}
| [
"emroe12@student.sdu.dk"
] | emroe12@student.sdu.dk |
b91199a4c2645e3b1af1c97e07281d34cada2148 | 6e0de80b2e229c3ef8c3d3a0a6f455ed04cd22a8 | /app/src/main/java/com/mimolabprojects/fudy/Model/FCMResponse.java | ddbc348a2246b4a8f997755aee29927ba136646c | [] | no_license | MimoLabProjects/Food-Ordering-android-app | 9577727299a660c2da9d834bf8770d32cd84deea | 604c7f8556c1b263034e3c60876d856070d60d8c | refs/heads/master | 2023-01-19T06:36:52.196016 | 2020-12-07T06:33:13 | 2020-12-07T06:33:13 | 318,141,171 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 242 | java | package com.mimolabprojects.fudy.Model;
import java.util.List;
public class FCMResponse {
private long multicast_id;
private int success, failure, canonical_ids;
private List <FCMResult> results;
private long message_id;
}
| [
"mimolabprojects@gmail.com"
] | mimolabprojects@gmail.com |
94f7fcaa62a1722309a6a56b48b4f89424a6ae51 | 6b77bed1d0a48ece06b3def7b6200ae247848ab6 | /src/test/java/com/crud/tasks/trello/client/MapperTestSuite.java | 5be72d6a907f39b39329e09eff70301015601e9f | [] | no_license | KonradSmuga/Trello-Edit-ToDoList | 19ffc7033ce3202ae7b2aa66b67318cbaf2e62aa | 1cfc39ec75ff74e3889aeb315b421264a695dee8 | refs/heads/master | 2021-09-14T12:23:10.213231 | 2018-05-13T19:42:19 | 2018-05-13T19:42:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,301 | java | package com.crud.tasks.trello.client;
import com.crud.tasks.domain.*;
import com.crud.tasks.mapper.TaskMapper;
import com.crud.tasks.mapper.TrelloMapper;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Arrays;
import java.util.List;
@RunWith(MockitoJUnitRunner.class)
public class MapperTestSuite {
@InjectMocks
private TaskMapper taskMapper;
@InjectMocks
private TrelloMapper trelloMapper;
@Test
public void testTaskMapper() {
//Given
Task task = new Task(1L, "test", "test");
List<Task> tasks = Arrays.asList(task);
//When
TaskDto mapToTaskDto = taskMapper.mapToTaskDto(task);
List<TaskDto> mapToTaskDtoList = taskMapper.mapToTaskDtoList(tasks);
Task mapToTask = taskMapper.mapToTask(mapToTaskDto);
//Then
Assert.assertEquals("test", mapToTaskDto.getContent());
Assert.assertEquals("test", mapToTaskDtoList.get(0).getTitle());
Assert.assertEquals("test", mapToTask.getContent());
}
@Test
public void testMapToBoard() {
//Given
TrelloListDto testTrelloListDto = new TrelloListDto("testTrelloDto", "1", true);
List<TrelloListDto> trelloLists = Arrays.asList(testTrelloListDto);
TrelloBoardDto trelloBoardDto = new TrelloBoardDto("1", "trelloBoard", trelloLists);
List<TrelloBoardDto> trelloBoardListDto = Arrays.asList(trelloBoardDto);
//when
List<TrelloBoard> trelloBoardList = trelloMapper.mapToBoards(trelloBoardListDto);
//then
Assert.assertEquals(1, trelloBoardList.get(0).getLists().size());
Assert.assertEquals(1, trelloBoardList.size());
Assert.assertEquals("trelloBoard", trelloBoardList.get(0).getName());
}
@Test
public void testMapToBoardDto() {
//given
TrelloList testTrelloList = new TrelloList("1", "testTrello", true);
List<TrelloList> trelloLists = Arrays.asList(testTrelloList);
TrelloBoard trelloBoard = new TrelloBoard("1", "testBoards", trelloLists);
List<TrelloBoard> trelloBoardList = Arrays.asList(trelloBoard);
//when
List<TrelloBoardDto> trelloBoardDtoList = trelloMapper.mapToBoardsDto(trelloBoardList);
//then
Assert.assertEquals("1", trelloBoardDtoList.get(0).getId());
Assert.assertEquals("testBoards", trelloBoardDtoList.get(0).getName());
}
@Test
public void testMapToList() {
//given
TrelloListDto trelloListDto = new TrelloListDto("1", "testTrelloDto", true);
List<TrelloListDto> trelloListsDto = Arrays.asList(trelloListDto);
//when
List<TrelloList> trelloLists = trelloMapper.mapToList(trelloListsDto);
//then
Assert.assertEquals("1", trelloLists.get(0).getId());
Assert.assertEquals("testTrelloDto", trelloLists.get(0).getName());
}
@Test
public void testMapToListDto() {
//given
TrelloList trelloList = new TrelloList("1", "testTrelloList", true);
List<TrelloList> trelloLists = Arrays.asList(trelloList);
//when
List<TrelloListDto> trelloListsDto = trelloMapper.mapToListDto(trelloLists);
//then
Assert.assertEquals("testTrelloList", trelloListsDto.get(0).getName());
}
@Test
public void testMapToCard() {
//given
TrelloCardDto trelloCardDto = new TrelloCardDto("test", "descr", "pos1", "1");
//when
TrelloCard trelloCard = trelloMapper.mapToCard(trelloCardDto);
//then
Assert.assertEquals("test", trelloCard.getName());
Assert.assertEquals("descr", trelloCard.getDescription());
Assert.assertEquals("1", trelloCard.getListId());
}
@Test
public void testMapToCardDto() {
//given
TrelloCard trelloCard = new TrelloCard("test", "descr", "pos1", "1");
//when
TrelloCardDto trelloCardDto = trelloMapper.mapToCardDto(trelloCard);
//then
Assert.assertEquals("test", trelloCardDto.getName());
Assert.assertEquals("descr", trelloCardDto.getDescription());
Assert.assertEquals("1", trelloCardDto.getListId());
}
}
| [
"smuggk@gmail.com"
] | smuggk@gmail.com |
f786f7a8a4acbd62a72094eb3a04771fec022736 | 810eee12101a6b25b5cc92be08b85a6da543852a | /workspace-sts-3.8.2.RELEASE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/admin/org/apache/jsp/WEB_002dINF/views/admin_jsp.java | a4314649cbdf59c4b9b44e8198d41bdcfee3c777 | [] | no_license | jeahuck/yang | 9aca2e9f74ff9cf9f9576a4599429b2461e9d0f2 | ebf3e47e3092531738daf49a85521207987956a0 | refs/heads/master | 2023-08-09T03:12:21.191478 | 2023-07-31T04:58:56 | 2023-07-31T04:58:56 | 73,593,283 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,984 | java | /*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/7.0.72
* Generated at: 2016-11-06 14:46:08 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp.WEB_002dINF.views;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
public final class admin_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
out.write("<title>Insert title here</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
| [
"qwpoaslkal@naver.com"
] | qwpoaslkal@naver.com |
4b242842c56a052e645a0062817fc8d227c7fab8 | ff7e7a33a4554b82954360ac686fe7b9e5ba9ab1 | /crm/crm-mvc/src/main/java/com/asahdev/controller/CustomerController.java | af8bfa02d91a11b53f804cbad897961d43e47922 | [] | no_license | asahdev15/POC | c8d9b7ca3ca43e0343bff3a77eaccde4ccea2323 | 45abb01d44632e93215addadb357cdae2fbbc980 | refs/heads/main | 2023-02-10T23:00:53.196484 | 2021-01-07T13:53:27 | 2021-01-07T13:53:27 | 245,204,747 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,279 | java | package com.asahdev.controller;
import java.util.List;
import com.asahdev.model.Customer;
import com.asahdev.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping("/customer")
public class CustomerController {
// need to inject our customer service
@Autowired
private CustomerService customerService;
@GetMapping("/list")
public String listCustomers(Model theModel) {
// get customers from the service
List<Customer> theCustomers = customerService.getCustomers();
// add the customers to the model
theModel.addAttribute("customers", theCustomers);
return "list-customers";
}
@GetMapping("/showFormForAdd")
public String showFormForAdd(Model theModel) {
// create model attribute to bind form data
Customer theCustomer = new Customer();
theModel.addAttribute("customer", theCustomer);
return "customer-form";
}
@PostMapping("/saveCustomer")
public String saveCustomer(@ModelAttribute("customer") Customer theCustomer) {
// save the customer using our service
customerService.saveCustomer(theCustomer);
return "redirect:/customer/list";
}
@GetMapping("/showFormForUpdate")
public String showFormForUpdate(@RequestParam("customerId") int theId,
Model theModel) {
// get the customer from our service
Customer theCustomer = customerService.getCustomer(theId);
// set customer as a model attribute to pre-populate the form
theModel.addAttribute("customer", theCustomer);
// send over to our form
return "customer-form";
}
@GetMapping("/delete")
public String deleteCustomer(@RequestParam("customerId") int theId) {
// delete the customer
customerService.deleteCustomer(theId);
return "redirect:/customer/list";
}
@GetMapping("/search")
public String searchCustomers(@RequestParam("theSearchName") String theSearchName,
Model theModel) {
// search customers from the service
List<Customer> theCustomers = customerService.searchCustomers(theSearchName);
// add the customers to the model
theModel.addAttribute("customers", theCustomers);
return "list-customers";
}
}
| [
"ashishsahdev15@yahoo.in"
] | ashishsahdev15@yahoo.in |
604247ace1061084ebf9eca57dbf67e05bcc2057 | c2397a3ab72ed1671fbf201b03a9eca318bb9dcc | /src/splice/model/Parser.java | 4ff922c8a821f3a43dece7aa441ebc751d89fa01 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | csurosm/ReSplicer | ec906b396ed407e472de1d1bd12c9c77623bf8c9 | 294eebab2a89df14dcfd7e6b4b91d6ae7523719b | refs/heads/master | 2021-07-17T11:05:07.094928 | 2016-09-22T14:39:52 | 2016-09-22T14:39:52 | 59,834,109 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,858 | java | /*
* The MIT License
*
* Copyright 2016 Miklós Csűrös.
*
* 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 splice.model;
import java.io.IOException;
import java.io.PushbackReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
/**
* Newick-format tree file parser.
* @author Miklós Csűrös
*/
public class Parser
{
private Parser() {} // no instantiation
// Newick format terminals
public static final char QUOTE='\'';
public static final char LPAREN='(';
public static final char RPAREN=')';
public static final char COMMA=',';
public static final char SEMICOLON=';';
public static final char LBRACKET='[';
public static final char RBRACKET=']';
public static final char DBLQUOTE='"';
public static final char HASHMARK='#';
public static final char BACKSLASH='\\';
public static final char COLON=':';
public static final char UNDERSCORE='_';
public static final String NEED_QUOTE_FOR= ""+QUOTE+LPAREN+RPAREN+COMMA+SEMICOLON+COLON+LBRACKET+RBRACKET;
/*
* The grammar used here is the following.
* [Corresponds to the Newick format used by Phylip, DRAWTREE etc., with the addition of the '#' style comments,
* see http://evolution.genetics.washington.edu/phylip/newick_doc.html].
*
* The original specification allowed internal taxon names only after the subtree,
* here we accept the name before it also.
*
* Terminals:
* SEMICOLON ;
* LPAREN (
* RPAREN )
* COMMA ,
* COLON :
* SEMICOLON ;
* LBRACKET [
* RBRACKET ]
* QUOTE '
* DBLQUOTE "
* NUMBER IEEE floating point value (Inf, -Inf, NaN are ok)
* ALPHANUM
*
* <Tree> ::= <Node> SEMICOLON
* <Node> ::= <Leaf>|<Internal>
* <Internal> ::= <Name> LPAREN <Nodelist> RPAREN <Edge length>
* | LPAREN <NodeList> RPAREN <Edge Length>
* | LPAREN <NodeList> RPAREN <Name> <Edge Length>
* <Leaf> ::= <Name> <Edge length>|<Edge length>
* <Nodelist> ::= <Node>|(<Node> COMMA <Nodelist>)
* <Edge length> ::= |<Nonzero edge>
* <Nonzero edge> ::= COLON NUMBER
* <Name> ::= <quoted or unquoted name>
*
* Whitespaces (newline, tab, space) are allowed anywhere
* between tokens. Remarks are allowed where whitespace is allowed,
* they either start with '#' and continue until the end of line or are
* enclosed in brackets.
*/
public static boolean NESTED_COMMENTS_ALLOWED=false;
public static boolean HASHMARK_COMMENTS_ALLOWED=true;
public static boolean RELAXED_NAME_PARSING=true;
public static TreeNode readNewick(Reader input) throws IOException, ParseException
{
return readNewick(input, NESTED_COMMENTS_ALLOWED, HASHMARK_COMMENTS_ALLOWED, RELAXED_NAME_PARSING);
}
public static TreeNode readNewick(
Reader input,
boolean nested_comments_allowed, // in PAUP, they are
boolean hashmark_comments_allowed,
boolean relaxed_name_parsing // tries to guess unquoted node names intelligently
) throws IOException, ParseException
{
TreeNode current_node=new TreeNode();
TreeNode root=current_node;
int c;
int parsing_state=PARSE_BEFORE_NODE;
PushbackReader R=new PushbackReader(input);
do
{
c=skipBlanksAndComments(R,nested_comments_allowed,hashmark_comments_allowed);
//
// --------------------------- LPAREN
//
if (c==LPAREN)
{
if (parsing_state == PARSE_BEFORE_NODE)
{
current_node=current_node.newChild();
// parsing_state=PARSE_BEFORE_NODE;
} else
throw new ParseException(1, "Cannot have ``"+LPAREN+"'' here.");
} else
//
// --------------------------- COMMA
//
if (c==COMMA)
{
if (parsing_state == PARSE_AFTER_NODE || parsing_state == PARSE_WITHIN_NODE || parsing_state == PARSE_BEFORE_NODE)
{
if (current_node.isRoot())
throw new ParseException(2, "Cannot have ``"+COMMA+"'' at root level.");
current_node=current_node.getParent().newChild();
parsing_state = PARSE_BEFORE_NODE;
} else
throw new ParseException(3, "Cannot have ``"+COMMA+"'' here.");
} else
//
// --------------------------- RPAREN
//
if (c==RPAREN)
{
if (parsing_state == PARSE_AFTER_NODE || parsing_state == PARSE_WITHIN_NODE || parsing_state == PARSE_BEFORE_NODE)
{
if (current_node.isRoot())
throw new ParseException(4, "Too many ``"+RPAREN+"''.");
current_node=current_node.getParent();
parsing_state = PARSE_WITHIN_NODE;
} else
throw new ParseException(5, "Cannot have ``"+RPAREN+"'' here.");
} else
//
// --------------------------- COLON
//
if (c==COLON)
{
if (parsing_state == PARSE_BEFORE_NODE || parsing_state == PARSE_WITHIN_NODE)
{
double d=parseEdgeLength(R,nested_comments_allowed,hashmark_comments_allowed);
current_node.setLength(d);
parsing_state=PARSE_AFTER_NODE;
} else
throw new ParseException(7,"Cannot have ``"+COLON+"'' here.");
} else
//
// --------------------------- SEMICOLON
//
if (c==SEMICOLON)
{
if (parsing_state == PARSE_AFTER_NODE || parsing_state == PARSE_WITHIN_NODE || parsing_state == PARSE_BEFORE_NODE)
{
if (!current_node.isRoot())
throw new ParseException(8,"Found ``"+SEMICOLON+"'' too early.");
parsing_state=PARSE_END;
}
} else if (c!=-1)
{
//
// --------------------------- taxon name
//
if (parsing_state == PARSE_WITHIN_NODE || parsing_state == PARSE_BEFORE_NODE)
{
if (!relaxed_name_parsing && current_node.getName() != null)
throw new ParseException(9, "Cannot name a node twice.");
R.unread(c);
String s=parseName(R,relaxed_name_parsing);
if (current_node.getName() != null)
current_node.setName(current_node.getName().concat(" && "+s));
else
current_node.setName(s);
} else
throw new ParseException(10, "Cannot have node name here.");
}
} while (c != -1 && parsing_state != PARSE_END);
if (parsing_state == PARSE_BEFORE_NODE && root.isLeaf())
return null;
// check if all leaves have a name
TreeNode[] leaves = root.getTraversal().getLeaves();
for (int leaf_idx=0; leaf_idx<leaves.length; leaf_idx++)
if (leaves[leaf_idx].getName()==null)
throw new ParseException(11, "Tree has unnamed terminal nodes (too many commas somewhere maybe?)");
return root;
}
// parsing states
private static final int PARSE_BEFORE_NODE=1;
private static final int PARSE_WITHIN_NODE=2;
private static final int PARSE_AFTER_NODE=3;
private static final int PARSE_END=4;
public static TreeNode[] readTrees
(
Reader input,
boolean nested_comments_allowed, // in PAUP, they are
boolean hashmark_comments_allowed,
boolean relaxed_name_parsing // tries to guess unquoted node names intelligently
) throws IOException, ParseException
{
List<TreeNode> trees = new ArrayList<>();
while (true)
{
TreeNode R = readNewick(input, nested_comments_allowed, hashmark_comments_allowed, relaxed_name_parsing);
if (R==null)
break;
trees.add(R);
}
return trees.toArray(new TreeNode[0]);
}
public static TreeNode[] readTrees(Reader input) throws IOException, ParseException
{
return readTrees(input, NESTED_COMMENTS_ALLOWED, HASHMARK_COMMENTS_ALLOWED, RELAXED_NAME_PARSING);
}
public static int nextNonWhitespace(PushbackReader input) throws IOException
{
return skipBlanksAndComments(input, false, false);
}
private static int skipBlanksAndComments (
PushbackReader input,
boolean nested_comments_allowed,
boolean hashmark_comments_allowed) throws IOException
{
return skipBlanksAndComments(input, true, nested_comments_allowed, hashmark_comments_allowed);
}
private static int skipBlanksAndComments (
PushbackReader input,
boolean comments_allowed,
boolean nested_comments_allowed,
boolean hashmark_comments_allowed) throws IOException
{
int c;
double d=1.0;
boolean parsed_a_comment=false;
do
{
do{c=input.read();} while(c!=-1 && Character.isWhitespace((char)c)); // skip leading blanks
if (comments_allowed && c==LBRACKET)
{
parsed_a_comment=true;
int nesting_level=1;
do
{
c=input.read();
if (c==RBRACKET) nesting_level--;
if (nested_comments_allowed && c==LBRACKET)
nesting_level++;
} while (nesting_level != 0 && c != -1);
} else if (hashmark_comments_allowed && c==HASHMARK)
do {c=input.read();} while (c!=-1 && c!='\n' && c!='\r');
} while(parsed_a_comment && c!=-1);
return c;
}
private static int buffer_capacity=256;
private static char[] buffer=new char[buffer_capacity];
private static int buffer_length=0;
private static void checkBuffer()
{
if (buffer_length == buffer_capacity)
{
int new_capacity=2*buffer_capacity;
char[] new_buffer=new char[new_capacity];
System.arraycopy(buffer,0,new_buffer,0,buffer_capacity);
buffer=new_buffer;
buffer_capacity=new_capacity;
}
}
private static void addToBuffer(char c)
{
checkBuffer();
buffer[buffer_length++]=c;
}
public static double parseDouble(PushbackReader input) throws IOException, ParseException
{
return parseEdgeLength(input,false,false,false,false);
}
private static double parseEdgeLength(
PushbackReader input,
boolean nested_comments_allowed,
boolean hashmark_comments_allowed) throws IOException, ParseException
{
return parseEdgeLength(input,true, nested_comments_allowed, hashmark_comments_allowed, true);
}
private static double parseEdgeLength(
PushbackReader input,
boolean comments_allowed,
boolean nested_comments_allowed,
boolean hashmark_comments_allowed,
boolean whitespace_allowed) throws IOException, ParseException
{
int c;
if (whitespace_allowed)
c=skipBlanksAndComments(input,comments_allowed,nested_comments_allowed,hashmark_comments_allowed);
else
c=input.read();
buffer_length=0;
while (c!=-1 && !Character.isWhitespace((char)c) && c!=COMMA && c!=RPAREN && c!=SEMICOLON)
{
addToBuffer((char)c);
c=input.read();
}
double retval=1.0;
if (buffer_length == 0)
retval=0.;
if (buffer_length >= 3)
{
if (buffer[0]=='N' && buffer[1]=='a' && buffer[2]=='N' && buffer_length==3)
retval=Double.NaN;
if (buffer_length==4 && buffer[1]=='I' && buffer[2]=='n' && buffer[3]=='f')
{ if (buffer[0]=='-')
retval=Double.NEGATIVE_INFINITY;
else if (buffer[0]=='+')
retval=Double.POSITIVE_INFINITY;
}
if (buffer[0]=='I' && buffer[1]=='n' && buffer[2]=='f' && buffer_length==3)
retval=Double.POSITIVE_INFINITY;
}
if (retval==1.0)
{
try
{
retval=Double.parseDouble(new String(buffer,0,buffer_length));
} catch (NumberFormatException e)
{
throw new ParseException(99,"Cannot parse edge length: "+e.toString());
}
}
if (c!=-1) input.unread(c);
return retval;
}
public static String parseString(
PushbackReader input, boolean relaxed_name_parsing) throws IOException
{
return parseName(input,relaxed_name_parsing);
}
private static String parseName(
PushbackReader input,
boolean relaxed_name_parsing) throws IOException
{
buffer_length=0;
char quote=0;
int c=input.read();
if (c==QUOTE || c==DBLQUOTE)
{
quote=(char)c;
c=input.read();
}
if (quote==0)
while(c != -1)
{
// Unquoted labels may not contain blanks, parentheses, square brackets,
// single_quotes, colons, semicolons, or commas.
if (Character.isWhitespace((char)c)
|| NEED_QUOTE_FOR.indexOf(c)>-1)
break;
if (c==UNDERSCORE) // replaced with space
c=' ';
addToBuffer((char)c);
c=input.read();
}
else // quoted
while(c != -1)
{
if (c==quote)
{
// check whether next is also a quote
c=input.read();
if (c!=quote && !relaxed_name_parsing)
{ // we're done
break;
}
if (c==quote)
{
addToBuffer((char)c);
input.read();
} else
{
// relaxed parsing: not an escaped quote but maybe just a mistake
if (c==-1
|| Character.isWhitespace((char)c)
|| c==LPAREN
|| c==RPAREN
|| c==COLON
|| c==SEMICOLON
|| c==COMMA)
{ // definitely end of name
break;
}
// otherwise it was a mistake
addToBuffer(quote);
// no need to read(): it's already done
}
} else
{ // not a quote
addToBuffer((char)c);
c=input.read();
}
}
if (c!=-1) input.unread(c);
return new String(buffer,0,buffer_length);
}
public static class ParseException extends Exception
{
public ParseException(int error_id, String s)
{
super("Parsing error "+error_id+":"+s);
}
}
// /**
// * Computes the subtree spanned by a set of terminal taxa
// */
// public static TreeNode spanTree(TreeNode root, String[] selected_taxon_name)
// {
// HashSet<String> selected_leaves = new HashSet<String>();
// for (int i=0; i<selected_taxon_name.length; i++)
// selected_leaves.add(selected_taxon_name[i]);
// TreeNode[] nodes = root.subtreeNodes();
// for (int i=0; i<nodes.length; i++)
// nodes[i].setId(i);
// TreeNode[] new_nodes = new TreeNode[nodes.length];
// for (int node_idx=0; node_idx<nodes.length; node_idx++)
// {
// TreeNode old_node = nodes[node_idx];
// if (old_node.isLeaf())
// {
// String name = old_node.getName();
// if (selected_leaves.contains(name))
// {
// // okay, we need this guy
// new_nodes[node_idx]=old_node;
// } else
// {
// new_nodes[node_idx]=null;
// }
// } else
// {
// int num_children_spanned = 0;
// int num_children = old_node.getNumChildren();
// for (int cidx=0; cidx<num_children; cidx++)
// {
// TreeNode Child = old_node.getChild(cidx);
// if (new_nodes[Child.getId()]!=null)
// {
// num_children_spanned++;
// }
// }
// if (num_children_spanned == 0)
// {
// new_nodes[node_idx]=null;
// } else if (num_children_spanned == 1)
// {
// // find that one child and move it up into this slot
// for (int cidx=0; cidx<num_children; cidx++)
// {
// TreeNode Child = old_node.getChild(cidx);
// if (new_nodes[Child.getId()]!=null)
// {
// TreeNode newChild = new_nodes[Child.getId()];
// new_nodes[node_idx]=newChild;
// newChild.setLength(newChild.getLength()+old_node.getLength());
// break;
// }
// }
// } else
// {
// TreeNode N = new TreeNode();
// for (int cidx=0; cidx<num_children; cidx++)
// {
// TreeNode Child = old_node.getChild(cidx);
// if (new_nodes[Child.getId()]!=null)
// {
// TreeNode newChild = new_nodes[Child.getId()];
// N.addChild(newChild);
// }
// }
// N.setLength(old_node.getLength());
// new_nodes[node_idx]=N;
// N.setId(node_idx);
// }
// }
// } // for node_idx
// return new_nodes[root.getId()];
// }
// /** Attempts to select the subtere spanned by a list of organisms
// */
// public static void main(String[] args) throws java.io.IOException, ParseException
// {
// if (args.length != 2)
// {
// System.err.println("Call as $0 file list\n\twhere list is a comma-separated list of terminal taxa\n\t;Output is the tree spanned by those taxa.");
// System.exit(0);
// }
// String tree_file = new String(args[0]);
// TreeNode root = readNewick(new java.io.FileReader(tree_file));
//
// String taxon_list = new String(args[1]);
// String[] selected_taxon = taxon_list.split(",");
//
// TreeNode new_root = spanTree(root,selected_taxon);
// System.out.println(new_root.newickTree(false, false, false, false));
// }
static String RCS_ID="$Id: Parser.java,v 1.1 2001/03/09 17:31:04 mcsuros Exp mcsuros $";
//
// $Log: Parser.java,v $
// Revision 1.1 2001/03/09 17:31:04 mcsuros
// Initial revision
//
//
}
| [
"csuros@catv-86-101-5-171.catv.broadband.hu"
] | csuros@catv-86-101-5-171.catv.broadband.hu |
4128cfde1bf080a457452016f67faf2255d52c4a | 2f0251e98dc852bb4a0420a0f50bdecb163b5821 | /app/src/androidTest/java/com/example/advancedjava/ExampleInstrumentedTest.java | 2e548c49132dd82847256538e064c876e3b65116 | [] | no_license | MisterPoster/advancedJava | 4107d16f88b36ccbc221fc8cc2015da4b2204348 | f7d7160389422d82dcca965eef48c7f93c2a3c67 | refs/heads/master | 2020-11-25T01:38:45.662975 | 2019-12-17T16:08:59 | 2019-12-17T16:08:59 | 228,432,959 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 719 | java | package com.example.advancedjava;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.advancedjava", appContext.getPackageName());
}
}
| [
"lordnerd999@gmail.com"
] | lordnerd999@gmail.com |
905fab8d28fc62cb6d7143a97e62e516d9d0142c | 099e50ba67baeed1f7b3b6ac4608b5ad80468634 | /src/main/java/com/zemoso/demo/repository/EmployeeRepository.java | 3afaaa17f94d600d5d8b198a3fe87e47bfae859d | [] | no_license | ManvendraSingh-Zemoso/employee-portal | e535d47ee9ad75a51e16ab5a028bbd94f4f64234 | b02d5f2e67298d99bbb6f57c7c9f04824d23df56 | refs/heads/master | 2021-09-06T17:54:11.735178 | 2018-02-09T09:40:35 | 2018-02-09T09:40:35 | 119,180,825 | 0 | 0 | null | 2018-02-09T09:40:36 | 2018-01-27T16:25:31 | null | UTF-8 | Java | false | false | 277 | java | package com.zemoso.demo.repository;
import com.zemoso.demo.model.Employee;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface EmployeeRepository extends CrudRepository<Employee,Long> {
}
| [
"manvendrasingh.narwar@zemosolabs.com"
] | manvendrasingh.narwar@zemosolabs.com |
b1d73db3ea2f1af4189e89808410bb2c8d2b634d | 81de163a0f044033f04dd59685b0ea851bf9cd09 | /facebooklogin/src/test/java/dagorik/mariachi/com/facebooklogin/ExampleUnitTest.java | 2ef62f0cc261bffbf9a41c45ffc685da74cacad1 | [] | no_license | Dagorik/AndroidBatch15 | d31b7c2127482f3a0e911569d4d355003f4a113d | faceed20fed372220097309d428da188f3d7622a | refs/heads/master | 2020-12-03T00:09:26.419507 | 2017-10-10T06:13:21 | 2017-10-10T06:13:21 | 95,994,564 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package dagorik.mariachi.com.facebooklogin;
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);
}
} | [
"dagorik@gmail.com"
] | dagorik@gmail.com |
81fd3c2ffe49d5ea07db34a802d39d18da30ec8f | 76d1211346b45c1d84c11d6e45f2998e6d6dbd10 | /user-src.database.mysql/studiranje/ip/database/io/DBTableInfoSerializer.java | af2eb918823e39341e99acb88d7004cf8f046717 | [] | no_license | mirko-27-93/007YIKorisnici | b8428342f52bd87346324f0dd81182fbef4b7211 | 8642abb2948da2f5d090f6d1cc9edcdbd4d0d7f5 | refs/heads/master | 2022-12-08T04:38:13.692457 | 2020-08-28T15:01:14 | 2020-08-28T15:01:14 | 291,072,006 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,376 | java | package studiranje.ip.database.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import com.google.gson.JsonArray;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import studiranje.ip.database.model.DBRecordInfo;
import studiranje.ip.database.model.DBTableInfo;
/**
* Серијализер када је у питању једна табела базе података.
* @author mirko
* @version 1.0
*/
public class DBTableInfoSerializer{
public String toJson(DBTableInfo info) {
JsonObject root = new JsonObject();
JsonParser parser = new JsonParser();
JsonArray columns = new JsonArray();
DBRecordInfoSerializer columnMarshall = new DBRecordInfoSerializer();
root.addProperty("table", info.getTableName());
for(DBRecordInfo record: info.getTableCoulumnsSchema().values()) {
String recordJson = columnMarshall.toJSON(record);
JsonObject recordObj = parser.parse(recordJson).getAsJsonObject();
columns.add(recordObj);
}
root.add("fields", columns);
return root.toString();
}
public DBTableInfo fromJson(String json) {
DBTableInfo info = new DBTableInfo();
JsonParser parser = new JsonParser();
JsonObject root = parser.parse(json).getAsJsonObject();
info.setTableName(root.get("table").getAsString());
JsonArray array = root.get("fields").getAsJsonArray();
DBRecordInfoSerializer columnUnmarshall = new DBRecordInfoSerializer();
for(int i=0; i<array.size(); i++) {
JsonObject object = array.get(i).getAsJsonObject();
DBRecordInfo record = columnUnmarshall.fromJSON(object);
info.add(record.getFieldName(), record);
}
return info;
}
public DBTableInfo fromJson(JsonObject root) {
DBTableInfo info = new DBTableInfo();
info.setTableName(root.get("table").getAsString());
JsonArray array = root.get("fields").getAsJsonArray();
DBRecordInfoSerializer columnUnmarshall = new DBRecordInfoSerializer();
for(int i=0; i<array.size(); i++) {
JsonObject object = array.get(i).getAsJsonObject();
DBRecordInfo record = columnUnmarshall.fromJSON(object);
info.add(record.getFieldName(), record);
}
return info;
}
public void toJson(DBTableInfo info, OutputStream os) throws UnsupportedEncodingException {
JsonObject root = new JsonObject();
JsonParser parser = new JsonParser();
JsonArray columns = new JsonArray();
DBRecordInfoSerializer columnMarshall = new DBRecordInfoSerializer();
root.addProperty("table", info.getTableName());
for(DBRecordInfo record: info.getTableCoulumnsSchema().values()) {
String recordJson = columnMarshall.toJSON(record);
JsonObject recordObj = parser.parse(recordJson).getAsJsonObject();
columns.add(recordObj);
}
root.add("fields", columns);
new PrintWriter(new OutputStreamWriter(os,"UTF-8")).println(root.toString());
}
public void toJson(DBTableInfo info, File file) throws FileNotFoundException, IOException {
if(!file.getParentFile().exists()) file.getParentFile().mkdirs();
try(FileOutputStream fos = new FileOutputStream(file)){
toJson(info, fos);
}
}
public DBTableInfo fromJson(InputStream json) throws JsonIOException, JsonSyntaxException, UnsupportedEncodingException {
DBTableInfo info = new DBTableInfo();
JsonParser parser = new JsonParser();
JsonObject root = parser.parse(new InputStreamReader(json, "UTF-8")).getAsJsonObject();
info.setTableName(root.get("table").getAsString());
JsonArray array = root.get("fields").getAsJsonArray();
DBRecordInfoSerializer columnUnmarshall = new DBRecordInfoSerializer();
for(int i=0; i<array.size(); i++) {
JsonObject object = array.get(i).getAsJsonObject();
DBRecordInfo record = columnUnmarshall.fromJSON(object);
info.add(record.getFieldName(), record);
}
return info;
}
public DBTableInfo fromJson(File json) throws JsonIOException, JsonSyntaxException, FileNotFoundException, IOException {
try(FileInputStream fis = new FileInputStream(json)){
return fromJson(json);
}
}
}
| [
"mirko.vidakovic.2020.002@gmail.com"
] | mirko.vidakovic.2020.002@gmail.com |
a953703403163650f21c33d7e518f10ae1d42918 | 515b4bad62c3c490401861bdcf31415d92c1322b | /src/com/example/nextagram_android/ReadActivity.java | fc1b046cbc3995a8388951654874d3c0e0d61a80 | [] | no_license | Jehyeok/Android-nextagram | fb01a29a3a6aca83aef3d409bf0b6d78c76bad29 | 721bea266895703c0ccc6049f615bc79f0ae8c74 | refs/heads/master | 2021-01-13T01:58:44.582411 | 2013-12-31T13:31:56 | 2013-12-31T13:31:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,350 | java | package com.example.nextagram_android;
import java.io.File;
import java.io.IOException;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class ReadActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_read);
TextView tvWriter = (TextView) findViewById(R.id.writer_in_read);
TextView tvDate = (TextView) findViewById(R.id.date_in_read);
TextView tvTitle = (TextView) findViewById(R.id.title_in_read);
TextView tvContent = (TextView) findViewById(R.id.content_in_read);
ImageView ivImage = (ImageView) findViewById(R.id.img_in_read);
String articleNumber = getIntent().getExtras().getString(
"ArticleNumber");
Toast.makeText(this, articleNumber, Toast.LENGTH_SHORT).show();
// Dao 초기화
Dao dao = new Dao(getApplicationContext());
ListData article = dao.getArticleByArticleNumber(Integer.parseInt(articleNumber));
tvTitle.setText(article.getTitle());
tvWriter.setText(article.getWriter());
tvDate.setText(article.getWriteDate());
tvContent.setText(article.getContent());
Log.i("ReadActivity : onCreate", article.getTitle());
String imgPath = getApplicationContext().getFilesDir().getPath() + "/"
+ article.getImgName();
File imgLoadPath = new File(imgPath);
if (imgLoadPath.exists()) {
// 이미지가 있으면 비트맵으로 변환해서 표현
Bitmap bitmap = BitmapFactory.decodeFile(imgPath);
ivImage.setImageBitmap(bitmap);
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("ReadActivity:OnCreate", e + "");
} catch (Exception e) {
e.printStackTrace();
Log.e("ReadActivity:OnCreate", e + "");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
try {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.read, menu);
return true;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
}
| [
"hook3748@gmail.com"
] | hook3748@gmail.com |
c6b346b4d09b31f4c322c85c09ca7df2597d7632 | a2e5828ee3230e32f62b2fde590a2ac1e5febddd | /src/main/java/StudentPool/Services/BookingServices.java | 042ed820de747cc79401a2878d61ba864a3b42cd | [] | no_license | rahulrules/StudentPoolWeb | 29ad243576327ad2d6e07455e1d067e848e64721 | c192712125d449dbed7b76475ac241a545356f58 | refs/heads/master | 2020-09-01T18:27:49.062364 | 2020-04-18T23:49:34 | 2020-04-18T23:49:34 | 219,026,264 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,567 | java | package StudentPool.Services;
import StudentPool.Database.Datasource;
import StudentPool.model.Bookings;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class BookingServices {
public static void main(String[] args) {
// System.out.println(BOOK_INSERT);
Bookings newbooking= new Bookings("RXJ08740@ucmo.edu",
2,1,"I will be on time");
BookingServices newBookService= new BookingServices();
System.out.println(newBookService.insertBooking(newbooking));
}
private static final String BOOK_TAB ="bookings";
private static final String BOOK_ID="id";
private static final String BOOK_USER_ID="user_id";
private static final String BOOK_DATE="booking_date";
private static final String BOOK_RIDEID="rideoffered_id";
private static final String BOOK_SLOTS="slots_booked";
private static final String BOOK_INST="instructions";
private static final String BOOK_VIEWBYRIDEID="SELECT * FROM "+BOOK_TAB+" WHERE "+BOOK_RIDEID+" =?";
private static final String BOOK_INSERT="INSERT INTO "+BOOK_TAB+
"("+BOOK_USER_ID+","+BOOK_DATE+","+BOOK_RIDEID+","+BOOK_SLOTS+","+BOOK_INST+") VALUES(?,?,?,?,?)";
private static final String BOOK_DELID= "DELETE"+" FROM "+BOOK_TAB+
" WHERE "+ BOOK_ID+"=?";
private static final String BOOK_UPDATE="UPDATE "+BOOK_TAB+
" SET "+BOOK_SLOTS+"=?"+","+BOOK_INST+"=?"+","+BOOK_DATE+"=?"+" WHERE "+BOOK_ID+"=?";
private static final String BOOK_GETID= "SELECT * FROM "+BOOK_TAB+" WHERE "+BOOK_ID+"=?";
private PreparedStatement ridebookings;
private PreparedStatement insertbook;
private PreparedStatement delbookbyID;
private PreparedStatement updatebookbyID;
private PreparedStatement getbookbyID;
private boolean open(){
try{
ridebookings= Datasource.getInstance().getConn().prepareStatement(BOOK_VIEWBYRIDEID);
insertbook= Datasource.getInstance().getConn().prepareStatement(BOOK_INSERT,Statement.RETURN_GENERATED_KEYS);
delbookbyID= Datasource.getInstance().getConn().prepareStatement(BOOK_DELID);
updatebookbyID= Datasource.getInstance().getConn().prepareStatement(BOOK_UPDATE);
getbookbyID= Datasource.getInstance().getConn().prepareStatement(BOOK_GETID);
return true;
} catch (SQLException e){
System.out.println("Can't Connect to Bookings Table: "+e.getMessage());
return false;
}
}
private void close(){
try {
if(ridebookings!=null){
ridebookings.close();
}
if(insertbook!=null){
insertbook.close();
}
if(delbookbyID!=null){
delbookbyID.close();
}
if(updatebookbyID!=null){
updatebookbyID.close();
}
if(getbookbyID!=null){
getbookbyID.close();
}
}catch (SQLException e){
System.out.println("Error Closing Prepared Statements for Bookings: "+e.getMessage());
}
finally {
Datasource.getInstance().close();
}
}
public Bookings ExtractBookingRS(ResultSet resultSet){
Bookings tempbooking= new Bookings();
try{
tempbooking.setId(resultSet.getInt(1));
tempbooking.setUser_id(resultSet.getString(2).toLowerCase());
tempbooking.setBooking_date(resultSet.getDate(3).toString());
tempbooking.setRideoffered_id(resultSet.getInt(4));
tempbooking.setSlots_booked(resultSet.getInt(5));
tempbooking.setInstructions(resultSet.getString(6));
}catch (SQLException e){
System.out.println("Error Processing Resultset: "+e.getMessage());
}
return tempbooking;
}
public List<Bookings> getBookingForRIdeID(Integer rideid){
List<Bookings> result= new ArrayList<>();
this.open();
try{
ridebookings.setInt(1,rideid);
ResultSet rs= ridebookings.executeQuery();
while (rs.next()){
result.add(ExtractBookingRS(rs));
}
}
catch (SQLException e){
System.out.println("Error Querying Ride ID: "+rideid+"-:"+e.getMessage());
}
finally {
this.close();
}
return new ArrayList<>(result);
}
public Integer insertBooking(Bookings newbooking){
Integer createdid=0;
this.open();
try {
insertbook.setString(1,newbooking.getUser_id());
insertbook.setTimestamp(2, Timestamp.valueOf(newbooking.getBooking_date()));
insertbook.setInt(3,newbooking.getRideoffered_id());
insertbook.setInt(4,newbooking.getSlots_booked());
insertbook.setString(5,newbooking.getInstructions());
int affectedrows= insertbook.executeUpdate();
if(affectedrows!=1){
System.out.println("Affectedrows Error Inserting into Booking table");
return -1;
}
ResultSet rs= insertbook.getGeneratedKeys();
while (rs.next()){
createdid=rs.getInt(1);
}
}catch (SQLException e){
System.out.println("Error Inserting In to Bookings Table: "+e.getMessage());
return -1;
}
finally {
this.close();
}
return createdid;
}
public Integer deletebookID(Integer id){
this.open();
try{
delbookbyID.setInt(1,id);
int affectedrows= delbookbyID.executeUpdate();
if(affectedrows!=1){
System.out.println("Affectedrows Error deleting from bookings table");
return -1;
}
return affectedrows;
}
catch (SQLException e){
System.out.println("SQL ERROR on Deleting booking:ID "+id+"'bookings' table: "+e.getMessage());
return -1;
}
finally {
this.close();
}
}
public Integer updateBookingbyID(Bookings modifybook,String id){
this.open();
try {
updatebookbyID.setInt(1,modifybook.getSlots_booked());
updatebookbyID.setString(2,modifybook.getInstructions());
updatebookbyID.setTimestamp(3, Timestamp.valueOf(modifybook.getBooking_date()));
updatebookbyID.setInt(4,Integer.valueOf(id));
int affectedrows= updatebookbyID.executeUpdate();
if(affectedrows!=1){
System.out.println("Affectedrows Error Updating into Booking table");
return -1;
}
}catch (SQLException e){
System.out.println("Error Updating In to Bookings Table: "+e.getMessage());
return -1;
}
finally {
this.close();
}
return 1;
}
public Bookings getBookingbyID(Integer bookingid){
Bookings result= new Bookings();
this.open();
try{
getbookbyID.setInt(1,bookingid);
ResultSet rs= getbookbyID.executeQuery();
while (rs.next()){
result=ExtractBookingRS(rs);
}
}
catch (SQLException e){
System.out.println("Error Querying Booking ID: "+bookingid+"-:"+e.getMessage());
}
finally {
this.close();
}
return result;
}
}
| [
"janga.rahul@gmail.com"
] | janga.rahul@gmail.com |
6e8309cedeaae1575e4788709b1947e17e98c298 | 2cf2e5972c8130b5c800baf825accb6792147d37 | /java/AULAS/src/exemplos/CadTime.java | d5e9758c617e8c839e1408710f8468f5a2a0737e | [] | no_license | renato-novais/turma21java | 0506bcc85003482a07ae1b4910bc4c6569d94ab4 | c18a89b2708cff47204271c95640e99affa50bb0 | refs/heads/main | 2023-05-22T09:43:31.566258 | 2021-06-07T04:00:15 | 2021-06-07T04:00:15 | 374,519,412 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 886 | java | package exemplos;
import java.util.Scanner;
public class CadTime {
public static void main(String[] args) {
Scanner leia = new Scanner(System.in);
String times[] = {"SPFC", "SCCP", "SEP", "SFC"};
String nomes[] = {"SAO PAULO","CORINTHIANS", "PALMEIRAS","SANTOS"};
int pontos[] = {10,8,9,4};
String aux;
int indice=0;
char op;
System.out.println("Relação de times");
for (String x : times) {
System.out.println(x);
}
System.out.println("Digite o codigo do time: ");
aux = leia.next().toUpperCase();
for (int x = 0; x<times.length ; x++) {
if (aux.equals(times[x])) {
indice = x;
break;
} else
{
indice = 100;
}
}
if (indice == 100) {
System.out.println("Vc não digitou um codigo valido!!");
}
else {
System.out.println("Voce escolheu o "+nomes[indice]+" que tem "+pontos[indice]+" pontos");
}
}
} | [
"83104807+renatons17@users.noreply.github.com"
] | 83104807+renatons17@users.noreply.github.com |
af59b7b937d4e87e70d48941e10c769c5127316f | 7ffe1d4343fc86dc6a0ebbe91d54b4ddfea367fd | /src/main/java/com/example/al2/class23/Code02_SplitSumClosedSizeHalf.java | 173f96735621364bae1a3153d26dfc923a6a8029 | [] | no_license | liuji789/spring | ccbdbdad8ef1e71a7f5c25698e4d63620d0cc139 | 5b984b3377114946660faf06d5ee959af5fa126a | refs/heads/master | 2022-12-04T17:44:07.306686 | 2022-06-25T14:01:45 | 2022-06-25T14:01:45 | 181,852,744 | 0 | 0 | null | 2022-11-16T03:17:27 | 2019-04-17T08:48:38 | Java | UTF-8 | Java | false | false | 5,884 | java | package com.example.al2.class23;
public class Code02_SplitSumClosedSizeHalf {
public static int right(int[] arr) {
if (arr == null || arr.length < 2) {
return 0;
}
int sum = 0;
for (int num : arr) {
sum += num;
}
if ((arr.length & 1) == 0) {
return process(arr, 0, arr.length / 2, sum / 2);
} else {
return Math.max(process(arr, 0, arr.length / 2, sum / 2), process(arr, 0, arr.length / 2 + 1, sum / 2));
}
}
// arr[i....]自由选择,挑选的个数一定要是picks个,累加和<=rest, 离rest最近的返回
public static int process(int[] arr, int i, int picks, int rest) {
if (i == arr.length) {
return picks == 0 ? 0 : -1;
} else {
int p1 = process(arr, i + 1, picks, rest);
// 就是要使用arr[i]这个数
int p2 = -1;
int next = -1;
if (arr[i] <= rest) {
next = process(arr, i + 1, picks - 1, rest - arr[i]);
}
if (next != -1) {
p2 = arr[i] + next;
}
return Math.max(p1, p2);
}
}
public static int dp(int[] arr) {
if (arr == null || arr.length < 2) {
return 0;
}
int sum = 0;
for (int num : arr) {
sum += num;
}
sum /= 2;
int N = arr.length;
int M = (N + 1) / 2;
int[][][] dp = new int[N + 1][M + 1][sum + 1];
for (int i = 0; i <= N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= sum; k++) {
dp[i][j][k] = -1;
}
}
}
for (int rest = 0; rest <= sum; rest++) {
dp[N][0][rest] = 0;
}
for (int i = N - 1; i >= 0; i--) {
for (int picks = 0; picks <= M; picks++) {
for (int rest = 0; rest <= sum; rest++) {
int p1 = dp[i + 1][picks][rest];
// 就是要使用arr[i]这个数
int p2 = -1;
int next = -1;
if (picks - 1 >= 0 && arr[i] <= rest) {
next = dp[i + 1][picks - 1][rest - arr[i]];
}
if (next != -1) {
p2 = arr[i] + next;
}
dp[i][picks][rest] = Math.max(p1, p2);
}
}
}
if ((arr.length & 1) == 0) {
return dp[0][arr.length / 2][sum];
} else {
return Math.max(dp[0][arr.length / 2][sum], dp[0][(arr.length / 2) + 1][sum]);
}
}
// public static int right(int[] arr) {
// if (arr == null || arr.length < 2) {
// return 0;
// }
// int sum = 0;
// for (int num : arr) {
// sum += num;
// }
// return process(arr, 0, 0, sum >> 1);
// }
//
// public static int process(int[] arr, int i, int picks, int rest) {
// if (i == arr.length) {
// if ((arr.length & 1) == 0) {
// return picks == (arr.length >> 1) ? 0 : -1;
// } else {
// return (picks == (arr.length >> 1) || picks == (arr.length >> 1) + 1) ? 0 : -1;
// }
// }
// int p1 = process(arr, i + 1, picks, rest);
// int p2 = -1;
// int next2 = -1;
// if (arr[i] <= rest) {
// next2 = process(arr, i + 1, picks + 1, rest - arr[i]);
// }
// if (next2 != -1) {
// p2 = arr[i] + next2;
// }
// return Math.max(p1, p2);
// }
//
// public static int dp1(int[] arr) {
// if (arr == null || arr.length < 2) {
// return 0;
// }
// int sum = 0;
// for (int num : arr) {
// sum += num;
// }
// sum >>= 1;
// int N = arr.length;
// int M = (arr.length + 1) >> 1;
// int[][][] dp = new int[N + 1][M + 1][sum + 1];
// for (int i = 0; i <= N; i++) {
// for (int j = 0; j <= M; j++) {
// for (int k = 0; k <= sum; k++) {
// dp[i][j][k] = -1;
// }
// }
// }
// for (int k = 0; k <= sum; k++) {
// dp[N][M][k] = 0;
// }
// if ((arr.length & 1) != 0) {
// for (int k = 0; k <= sum; k++) {
// dp[N][M - 1][k] = 0;
// }
// }
// for (int i = N - 1; i >= 0; i--) {
// for (int picks = 0; picks <= M; picks++) {
// for (int rest = 0; rest <= sum; rest++) {
// int p1 = dp[i + 1][picks][rest];
// int p2 = -1;
// int next2 = -1;
// if (picks + 1 <= M && arr[i] <= rest) {
// next2 = dp[i + 1][picks + 1][rest - arr[i]];
// }
// if (next2 != -1) {
// p2 = arr[i] + next2;
// }
// dp[i][picks][rest] = Math.max(p1, p2);
// }
// }
// }
// return dp[0][0][sum];
// }
public static int dp2(int[] arr) {
if (arr == null || arr.length < 2) {
return 0;
}
int sum = 0;
for (int num : arr) {
sum += num;
}
sum >>= 1;
int N = arr.length;
int M = (arr.length + 1) >> 1;
int[][][] dp = new int[N][M + 1][sum + 1];
for (int i = 0; i < N; i++) {
for (int j = 0; j <= M; j++) {
for (int k = 0; k <= sum; k++) {
dp[i][j][k] = Integer.MIN_VALUE;
}
}
}
for (int i = 0; i < N; i++) {
for (int k = 0; k <= sum; k++) {
dp[i][0][k] = 0;
}
}
for (int k = 0; k <= sum; k++) {
dp[0][1][k] = arr[0] <= k ? arr[0] : Integer.MIN_VALUE;
}
for (int i = 1; i < N; i++) {
for (int j = 1; j <= Math.min(i + 1, M); j++) {
for (int k = 0; k <= sum; k++) {
dp[i][j][k] = dp[i - 1][j][k];
if (k - arr[i] >= 0) {
dp[i][j][k] = Math.max(dp[i][j][k], dp[i - 1][j - 1][k - arr[i]] + arr[i]);
}
}
}
}
return Math.max(dp[N - 1][M][sum], dp[N - 1][N - M][sum]);
}
// for test
public static int[] randomArray(int len, int value) {
int[] arr = new int[len];
for (int i = 0; i < arr.length; i++) {
arr[i] = (int) (Math.random() * value);
}
return arr;
}
// for test
public static void printArray(int[] arr) {
for (int num : arr) {
System.out.print(num + " ");
}
System.out.println();
}
// for test
public static void main(String[] args) {
int maxLen = 10;
int maxValue = 50;
int testTime = 10000;
System.out.println("测试开始");
for (int i = 0; i < testTime; i++) {
int len = (int) (Math.random() * maxLen);
int[] arr = randomArray(len, maxValue);
int ans1 = right(arr);
int ans2 = dp(arr);
int ans3 = dp2(arr);
if (ans1 != ans2 || ans1 != ans3) {
printArray(arr);
System.out.println(ans1);
System.out.println(ans2);
System.out.println(ans3);
System.out.println("Oops!");
break;
}
}
System.out.println("测试结束");
}
} | [
"583115762@qq.com"
] | 583115762@qq.com |
9c621a7624ac89bbc08f9f3d7e316a789fe00c39 | a3e55ff90bb6d28414a1a544ae872888e6af05fc | /src/test/java/ar/com/guanaco/diucon/domain/CategoriaTest.java | 269e43e3eb1241023722c6edb14ac984c4258c81 | [] | no_license | guanacosoftware/diucon | 141e5ccb9c68263557ba01417d031c6f0ceeb45b | dd9b37c66ffb24ac1edf03e09f471c04f02936c6 | refs/heads/develop | 2023-05-14T14:29:56.007728 | 2020-03-27T15:35:19 | 2020-03-27T15:35:19 | 249,302,004 | 0 | 1 | null | 2023-05-09T03:43:37 | 2020-03-23T00:47:16 | Java | UTF-8 | Java | false | false | 733 | java | package ar.com.guanaco.diucon.domain;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import ar.com.guanaco.diucon.web.rest.TestUtil;
public class CategoriaTest {
@Test
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Categoria.class);
Categoria categoria1 = new Categoria();
categoria1.setId(1L);
Categoria categoria2 = new Categoria();
categoria2.setId(categoria1.getId());
assertThat(categoria1).isEqualTo(categoria2);
categoria2.setId(2L);
assertThat(categoria1).isNotEqualTo(categoria2);
categoria1.setId(null);
assertThat(categoria1).isNotEqualTo(categoria2);
}
}
| [
"miglesias@guanaosoftware.com.ar"
] | miglesias@guanaosoftware.com.ar |
f6ef79395c78caeb50023c7ce392799b12bee447 | 898425f70034e41999bdedbb291b459c6d546022 | /UTrackObject.java | 2f7d6e7427e7aa77e25b56b57f14e8ee0d1a2a6f | [] | no_license | tania97/UTrack-APp | 0e0ed84b673fb034e1ef3467c50d07c922a435a7 | 261dc724e666294aadfb9b8011155d45486f2db6 | refs/heads/master | 2020-01-19T21:10:11.250091 | 2017-06-13T13:18:42 | 2017-06-13T13:18:42 | 94,212,206 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,435 | java | package com.jordan.lucie.utrackapp;
import java.math.RoundingMode;
import java.text.NumberFormat;
/**
* UTrackObject class
* @author Group 1
* @version 1.0
*/
public class UTrackObject {
private String name;
private double latitude;
private double longitude;
private String notes;
public UTrackObject(String name, double latitude, double longitude, String notes) {
this.name = name;
this.latitude = latitude;
this.longitude = longitude;
this.notes = notes;
}
public UTrackObject(){
this.name = "null";
this.latitude = 0;
this.longitude = 0;
this.notes = "null";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String toString(){
return name +", (" + latitude + ", " + longitude + "), " + notes;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
543910aebda24bf7a8c8ab765f394f4d67c136f0 | 9f669cbd13c4a9e15a3ca2dc759e346bda4b8b6e | /ingenious/fitness/src/main/java/io/github/andypyrope/fitness/calculators/InvalidCalculatorSettingsException.java | ce0ef1291315219dde639f91f5ec9e9aec5cc7bb | [
"MIT"
] | permissive | andypyrope/ingenious | a8afdd6e0e896262fdb1869a8279ac3f7ae16f82 | 83d4c646e1bd01353ee3229c50c8265742be8ba8 | refs/heads/master | 2020-03-07T01:26:17.787137 | 2018-08-22T20:56:39 | 2018-08-22T20:56:39 | 127,183,760 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,235 | java | package io.github.andypyrope.fitness.calculators;
import java.util.Arrays;
import java.util.stream.Collectors;
/**
* An exception thrown when some of settings for a calculator provider are invalid.
*/
public class InvalidCalculatorSettingsException extends Exception {
private static final long serialVersionUID = 7444235009026614634L;
/**
* Create a generic instance of {@link InvalidCalculatorSettingsException} about no
* specific setting or reason.
*/
public InvalidCalculatorSettingsException() {
super("A setting is invalid");
}
/**
* The default constructor with a message.
*
* @param message The exception message
*/
public InvalidCalculatorSettingsException(String message) {
super(message);
}
/**
* Auto-generate a fairly specific message that describes the setting name.
*
* @param keys The setting keys
*/
public InvalidCalculatorSettingsException(final String[] keys) {
super(keys.length == 1
? "The '" + keys[0] + "' setting is invalid"
: "The following settings are invalid: " +
Arrays.stream(keys).collect(Collectors.joining(", ")));
}
}
| [
"andypyrope@gmail.com"
] | andypyrope@gmail.com |
40fdce646407914327b5386f1a6cb07a598170b4 | 99e8e0a02caa1311d7545ae9e67019055af5b06e | /Spring-Ioc/src/main/java/com/edu/zhl/service/BookDao.java | b513ab37366ded047c5eec42163bcfe54f2e5465 | [] | no_license | Vinces007/education | ee7bf112c55c54efcb6fcff7d32a6b15917a5dda | e01da888d52a53d591c40e85b635c20c2214fde7 | refs/heads/master | 2023-07-19T01:48:57.186477 | 2021-09-06T10:50:31 | 2021-09-06T10:50:31 | 395,232,682 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 79 | java | package com.edu.zhl.service;
public interface BookDao {
void getName();
}
| [
"13840148193@163.com"
] | 13840148193@163.com |
cd44c269ebb8e382ef8f79f78afd5fdb93d30bee | 55d8a6aa3a538d6599d7a8af6ebdc087273d2ccf | /api-gateway/src/main/java/com/apigateway/utils/StringRandomUtil.java | 10a9d2b2f488f54fdf3ef5c02d74d571d19ffe27 | [] | no_license | shun484/file | 7e0537ce4b71d6f996e6fbf23c9b546a2887c3e1 | 12a786913c160478b8f3cacdec1db58811ba4524 | refs/heads/master | 2023-03-04T12:22:39.355263 | 2021-02-03T09:04:49 | 2021-02-03T09:04:49 | 298,187,268 | 0 | 0 | null | 2021-02-03T09:04:50 | 2020-09-24T06:22:37 | Java | UTF-8 | Java | false | false | 1,394 | java | package com.apigateway.utils;
import java.util.Random;
/**
* Description: 随机生成字符串
* Auth: Frank
* Date: 2017-10-26
* Time: 上午 10:25
*/
public class StringRandomUtil {
private static final String CHAR = "char";//字母
private static final String NUM = "num";//数字
/**
* 获得指定长度的随机字符串
* 参照ASCII码表 65到90为大写字母,97到122为小写字母
* @param length 要生成的字符串长度
* @return 返回生成的随机字符串
*/
public static String getStringRandom(int length) {
StringBuffer valSb = new StringBuffer();
Random random = new Random();
//参数length,表示生成几位随机数
for(int i = 0; i < length; i++) {
//输出是数字还是字母
String charOrNum = random.nextInt(2) % 2 == 0 ? CHAR : NUM;
switch (charOrNum){
case CHAR:
//输出是大写字母还是小写字母
int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
valSb.append((char)(random.nextInt(26) + temp));
break;
case NUM:
valSb.append(random.nextInt(10));
break;
default:
break;
}
}
return valSb.toString();
}
}
| [
"shunge321"
] | shunge321 |
31e33f4ae78934d50ec1e7350a66ec991c35625e | 23fc90ed0b1e5b3a66d1365b2b3c72a74ca2684d | /Server/src/main/java/controller/InterchangeController.java | 63655a4d5b467aa1cb38063689d01973bced1c86 | [] | no_license | Advanced-Programming-2021/project-team-26 | ae347e8e5c5219437d9f9b06284f7b425d17d62b | 73911a716cdcf2ac0258bd245a7c607f0076e15c | refs/heads/main | 2023-06-28T14:50:24.407439 | 2021-07-21T21:03:20 | 2021-07-21T21:03:20 | 354,452,256 | 0 | 0 | null | 2021-06-16T12:05:36 | 2021-04-04T04:07:12 | Java | UTF-8 | Java | false | false | 911 | java | package controller;
import model.cards.Card;
import java.util.regex.Matcher;
public class InterchangeController {
private static InterchangeController instance;
private InterchangeController() {
}
public static InterchangeController getInstance() {
if (instance == null)
instance = new InterchangeController();
return instance;
}
public String importCommand(Matcher matcher) {
// String name = matcher.group(1);
// Card card = Database.getInstance().readCard(name);
// if (card == null)
// return "card not found";
return "done";
}
public String exchangeCommand(Matcher matcher) {
String name = matcher.group(1);
Card card = Card.getCard(name);
if (card == null)
return "card not found";
Database.getInstance().writeCard(card);
return "done";
}
}
| [
"maghaie14@yahoo.com"
] | maghaie14@yahoo.com |
a0fbf69d31b528a92ae9c1c770d6495f80454532 | 88630557b89f6393a46cfd2ca78af9b17edf6fda | /src/main/java/controllers/RatingController.java | 1ebe9189e0ef432df5293351b15d0b17a1a18d27 | [] | no_license | wiamzekri/booking | afd49ef312aa53620d9a7079969bc6c8868ffba5 | c73add318553716d0ccf2ffb164df6f6bc52c17a | refs/heads/master | 2020-04-09T05:23:33.325591 | 2018-12-02T16:40:17 | 2018-12-02T16:40:17 | 160,062,518 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,469 | java | package controllers;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import dao.ChambreRepository;
import dao.CommentaireRepository;
import dao.HotelRepository;
import dao.PrixRepository;
import dao.RatingRepository;
import dao.UserRepository;
import entities.Client;
import entities.Commentaire;
import entities.Hotel;
import entities.Prix;
import entities.Rating;
@Controller
public class RatingController {
@Autowired
private PrixRepository prixRepository;
@Autowired
private ChambreRepository chambreRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private HotelRepository hotelRepository;
@Autowired
private RatingRepository ratingRepository;
@Autowired
private CommentaireRepository commentaireRepository;
@RequestMapping(value="/rating", method=RequestMethod.GET)
public String rate(HttpServletRequest request,ModelMap model,Integer s)
{
HttpSession session = request.getSession();
Long id_hotel = (Long) session.getAttribute("id_hotel");
String date_d = (String) session.getAttribute("date_d");
String date_f = (String) session.getAttribute("date_f");
if(id_hotel == null ) return "redirect:/";
//tout offres dipos dans l'hotel pour la reservation
List<Prix> offres = prixRepository.getAllAvailableOffersByIdHotel(id_hotel, date_d, date_f);
//supprimer doublons hotels (pour affichers une seule fois la categorie simple,double...)
offres = Prix.supprimerDoublonsChambreCategorie(offres);
//map pour compter nombre chambre dispo par categorie(simple,double...) chambre
Map<Integer,Integer> nbChambresDispo = new HashMap<Integer,Integer>();
for (Prix o : offres) {
nbChambresDispo.put(o.getChambre().getType(), chambreRepository.getNbChambreDispoByType(o.getChambre().getType(), id_hotel, date_d, date_f));
}
model.put("offres",offres);
model.put("nbChambres", nbChambresDispo);
//rating
//client authentified
String username = request.getRemoteUser();
//String username = "aymen";
Client client = (Client) userRepository.findByUserName(username);
Hotel hotel = hotelRepository.findOne(id_hotel);
Rating rate = ratingRepository.getRatingUserByHotel(client.getUserid(), id_hotel);
if(rate==null)
{
rate = new Rating();
rate.setClient(client);
rate.setHotel(hotel);
rate.getHotel().setNbVote(rate.getHotel().getNbVote()+1);
}
rate.setNbEtoiles(s);
ratingRepository.save(rate);
//rating
Float avgRating = ratingRepository.getAvgRatingByHotel(id_hotel);
if(avgRating==null) avgRating = new Float(0);
rate.getHotel().setAvgRating(avgRating);
ratingRepository.save(rate);
Long[] nbPerStar = new Long[5];
for(int i=0; i < 5 ; i++)
{
Long var = ratingRepository.getHowManyRatedFor(i+1, id_hotel);
if(var != null)
{
nbPerStar[i] = var;
}
else nbPerStar[i] = new Long(0);
}
model.put("nbPerStar", nbPerStar);
//commentaire
List<Commentaire> commentaires = commentaireRepository.getAllByHotel(id_hotel);
model.put("commentaires", commentaires);
return "hebergements";
}
}
| [
"wiamzkr@gmail.com"
] | wiamzkr@gmail.com |
410dae32446784a9348fccdc596a6f631ef40106 | 6c4f357b9ecf56b3d25fdfcc710e18c530d21ff8 | /xeclipse/org.xwiki.eclipse.ui/src/main/java/org/xwiki/eclipse/ui/editors/contentassist/CompoundContentAssistProcessor.java | e52be826889d8fbdf9a9009dc76bfef0fb34dc11 | [] | no_license | shostak-vu/sandbox | 4386e95395e11aa9bb2600d25b6d90cab62e0eae | b87b7bec02c97a4846dec81353e0ef2a45056b10 | refs/heads/master | 2020-05-25T12:16:15.474261 | 2018-12-22T00:38:30 | 2018-12-22T00:38:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,322 | java | /*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
*/
package org.xwiki.eclipse.ui.editors.contentassist;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
/**
* A content assist processor that re-groups other assist processor and queries them for getting proposals.
*/
public class CompoundContentAssistProcessor implements IContentAssistProcessor
{
private List<IContentAssistProcessor> contentAssistProcessors;
public CompoundContentAssistProcessor()
{
contentAssistProcessors = new ArrayList<IContentAssistProcessor>();
}
public void addContentAssistProcessor(IContentAssistProcessor contentAssistProcessor)
{
contentAssistProcessors.add(contentAssistProcessor);
}
public void removeContentAssistProcessor(IContentAssistProcessor contentAssistProcessor)
{
contentAssistProcessors.remove(contentAssistProcessor);
}
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
{
/* Query all the registered assist processors and collect all the returned proposals. */
List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
for (IContentAssistProcessor contentAssistProcessor : contentAssistProcessors) {
ICompletionProposal[] proposals = contentAssistProcessor.computeCompletionProposals(viewer, offset);
if (proposals != null && proposals.length > 0) {
for (ICompletionProposal proposal : proposals) {
result.add(proposal);
}
}
}
return result.toArray(new ICompletionProposal[result.size()]);
}
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
return null;
}
public char[] getCompletionProposalAutoActivationCharacters()
{
return null;
}
public char[] getContextInformationAutoActivationCharacters()
{
return null;
}
public IContextInformationValidator getContextInformationValidator()
{
return null;
}
public String getErrorMessage()
{
return null;
}
}
| [
"vincent@massol.net"
] | vincent@massol.net |
8aa4c77c11e413563676e05703474f8379b50c1f | 9e003690b8459e8f8784f1a6399a8cd5ad70a1f5 | /WebSite/src/main/java/prompto/website/Application.java | 4df428acbf4ade30f2e9d02549a0eb78be0f2fd0 | [] | no_license | anshumanui/prompto-docs | a14bd48e99e612fe6c3cd022cece9456a392e0cd | ecaf23466fcecedeedda87908c54b5548d7f5c2d | refs/heads/master | 2023-04-29T08:01:29.239005 | 2021-03-11T14:57:39 | 2021-03-11T14:57:39 | 348,911,334 | 0 | 0 | null | 2021-04-25T18:02:50 | 2021-03-18T02:07:28 | null | UTF-8 | Java | false | false | 472 | java | package prompto.website;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import prompto.server.AppServer;
public class Application {
public static void main(String[] args) throws Throwable {
List<String> argsList = new ArrayList<>(Arrays.asList(args));
argsList.add("-application");
argsList.add("web-site");
argsList.add("-version");
argsList.add("1.0.0");
AppServer.main(argsList.toArray(new String[argsList.size()]));
}
}
| [
"eric.vergnaud@wanadoo.fr"
] | eric.vergnaud@wanadoo.fr |
718ccace1d9b05e0377c405b942300d83036df6a | a90c17f16db713e2650c6d62a8b42448a33e6e08 | /14301133/src/Response.java | b6659bac95e1776ac605f920f94a2a294fd13075 | [] | no_license | lolipopy/ss | 3f476b52a1e203221ed8981fda693df1217f6ed5 | 01cdfb9208e7548fc1d978789010e533a4203ce5 | refs/heads/master | 2021-01-13T07:49:34.152745 | 2016-10-23T12:38:05 | 2016-10-23T12:38:05 | 71,609,250 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,724 | java | /**
* Created by lenovo on 2016/10/7.
*/
import javax.servlet.*;
import java.io.*;
import java.util.Locale;
public class Response implements ServletResponse {
private int BUFFER_SIZE = 1024;
Request requst;
OutputStream outputStream;
PrintWriter printWriter;
public static final String WEB_ROOT = System.getProperty("user.dir") + File.separator + "src";
public Response(OutputStream outputStream) {
this.outputStream = outputStream;
}
public void setRequst(Request requst) {
this.requst = requst;
}
public void sendStaticResource() throws IOException {
byte[] bytes = new byte[BUFFER_SIZE];
FileInputStream fileInputStream = null;
try {
File file = new File(WEB_ROOT, requst.getUri());
fileInputStream = new FileInputStream(file);
int size = fileInputStream.read(bytes, 0, BUFFER_SIZE);
if (size != -1) {
outputStream.write(bytes, 0, size);
size = fileInputStream.read(bytes, 0, BUFFER_SIZE);
}
} catch (FileNotFoundException e) {
String errorMessage = "HTTP/1.1 404 File Not Found\r\n" +
"Content-Type: text/html\r\n" +
"Content-Length: 23\r\n" +
"\r\n" +
"<h1>File Not Found</h1>";
outputStream.write(errorMessage.getBytes());
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
@Override
public String getCharacterEncoding() {
return null;
}
@Override
public String getContentType() {
return null;
}
@Override
public ServletOutputStream getOutputStream() throws IOException {
return null;
}
@Override
public PrintWriter getWriter() throws IOException {
PrintWriter writer = new PrintWriter(outputStream, true);
return writer;
}
@Override
public void setCharacterEncoding(String s) {
}
@Override
public void setContentLength(int i) {
}
@Override
public void setContentType(String s) {
}
@Override
public void setBufferSize(int i) {
}
@Override
public int getBufferSize() {
return 0;
}
@Override
public void flushBuffer() throws IOException {
}
@Override
public void resetBuffer() {
}
@Override
public boolean isCommitted() {
return false;
}
@Override
public void reset() {
}
@Override
public void setLocale(Locale locale) {
}
@Override
public Locale getLocale() {
return null;
}
}
| [
"14301133@bjtu.edu.cn"
] | 14301133@bjtu.edu.cn |
b6b3c54d6aa836d3e22c0c5080d0aa33a5ff7990 | 9ab96f6c24329357d706b69498fd66a8bd4b2ce7 | /src/situacao_pessoa/FinalizadaVacinacao.java | 01d27e43b0ce9110d6cf59b6c10e900bb2763899 | [] | no_license | hiarlyfs/lab6 | ff7c3956756ea9cb2375aa62563574d95a96abbd | 0bd692795a5ef2182e9e92c45f77f10e6189c818 | refs/heads/main | 2023-04-07T05:47:28.327501 | 2021-04-17T23:59:51 | 2021-04-17T23:59:51 | 359,007,054 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 385 | java | package situacao_pessoa;
import entidade.Pessoa;
public class FinalizadaVacinacao implements Situacao{
private static final String SITUACAO_ATUAL = "Finalizada vacinacao";
public FinalizadaVacinacao() {
}
@Override
public void proximaSituacao(Pessoa pessoa) {
}
@Override
public String getSituacao() {
return this.SITUACAO_ATUAL;
}
}
| [
"hiarlyfsouto@gmail.com"
] | hiarlyfsouto@gmail.com |
a87f19915594c77fd137aa79bc6ad0724c6401a1 | f71eeaea8d2dc46f36237d2c138162a6bc4fbbd9 | /jspstudy/workspace/MyHome/src/command/guest/DownloadCommand.java | 91ca133dd9eecf69904200ea9c015c0d96455d5e | [
"Apache-2.0"
] | permissive | Learning-Ant/SPRING0914 | fb5d9081cb0f61d17a7343880032357cfa1da57d | 63c6800e9327a7d9043d5c0490420036d4bfbccf | refs/heads/master | 2023-03-16T12:08:37.759028 | 2021-03-03T04:53:00 | 2021-03-03T04:53:00 | 345,535,930 | 0 | 1 | null | 2021-03-08T05:00:53 | 2021-03-08T05:00:53 | null | UTF-8 | Java | false | false | 1,696 | java | package command.guest;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DownloadCommand {
// new DownloadCommand()로 객체를 만들 필요가 없도록 static 처리
// DownloadCommand.download(request, response) 호출
public static void download(HttpServletRequest request, HttpServletResponse response) {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
String gFilename = request.getParameter("gFilename");
String directory = "storage";
String realPath = request.getServletContext().getRealPath(directory);
File file = new File(realPath, gFilename);
response.setHeader("Content-Type", "application/x-msdownload");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(gFilename, "UTF-8"));
response.setHeader("Content-Length", file.length() + "");
bis = new BufferedInputStream( new FileInputStream(file) );
bos = new BufferedOutputStream( response.getOutputStream() );
byte[] byteArray = new byte[1024]; // 1KB
while ( (bis.read(byteArray)) != -1) {
bos.write(byteArray);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bos != null) { bos.close(); }
if (bis != null) { bis.close(); }
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| [
"gt_min@naver.com"
] | gt_min@naver.com |
312272bb022d7e3346bc9d8595ecf15cc91475cd | f3f5bab78c5af7adc14b528d160aec6cf94676a8 | /app/src/main/java/com/tatvasoft/calculator/database/HistoryDatabase.java | 5c568b7080f4bc65b5c8826c6013b8307ad04c71 | [] | no_license | PujitSomaiya/Calculator | 605a4f25b0cf6e20c8fd8d44fd6a87cc2402fb8e | fbbdc7c123b866ae8a086902384d7156344ca520 | refs/heads/master | 2022-07-25T23:37:12.270845 | 2020-05-20T04:09:51 | 2020-05-20T04:09:51 | 263,232,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,804 | java | package com.tatvasoft.calculator.database;
import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import static android.os.Build.ID;
import com.tatvasoft.calculator.ui.history.model.HistoryModel;
public class HistoryDatabase extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "HistoryData";
private static final String TABLE_POST ="History";
private static final String COLUMN_ID = "_id";
private static final String COLUMN_TIMESTAMP = "blogTimePost";
private static final String COLUMN_EXPRESSION = "expression";
private static final String COLUMN_RESULT = "result";
private HistoryModel dataModel;
public HistoryDatabase(Context context) {
super(context,DATABASE_NAME,null,DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_POST_TABLE="CREATE TABLE "+TABLE_POST+"("+COLUMN_ID+" INTEGER PRIMARY KEY AUTOINCREMENT,"+COLUMN_EXPRESSION+" TEXT,"+COLUMN_RESULT+" TEXT,"+COLUMN_TIMESTAMP+" DATETIME DEFAULT CURRENT_DATE"+")";
db.execSQL(CREATE_POST_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_POST);
onCreate(db);
}
public ArrayList<HistoryModel> listData() {
String sql = "select * from " + TABLE_POST;
SQLiteDatabase db = this.getReadableDatabase();
ArrayList<HistoryModel> dataModel = new ArrayList<>();
Cursor cursor = db.rawQuery(sql, null);
if (cursor.moveToFirst()) {
do {
int id=cursor.getInt(cursor.getColumnIndex(COLUMN_ID));
String expression = cursor.getString(cursor.getColumnIndex(COLUMN_EXPRESSION));
String result=cursor.getString(cursor.getColumnIndex(COLUMN_RESULT));
dataModel.add(new HistoryModel(id,expression, result));
}
while (cursor.moveToNext());
}
cursor.close();
db.close();
return dataModel;
}
public void addBlogData(HistoryModel dataModel){
ContentValues contentValues= new ContentValues();
contentValues.put(COLUMN_EXPRESSION,dataModel.getExpression());
contentValues.put(COLUMN_RESULT,dataModel.getFinalAns());
SQLiteDatabase db=this.getWritableDatabase();
db.insert(TABLE_POST,null,contentValues);
}
public void deleteBlog() {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("delete from "+ TABLE_POST);
db.close();
}
}
| [
"pujit555@gmail.com"
] | pujit555@gmail.com |
06ee7895c432785e9ea7cd031c8ce686827bf30c | 6452ce28231ff89df2e2d6ed17e26fa8265325f0 | /cmsapp/src/in/codeblog/cmsapp/test/UserRegistration_Test.java | 9fe9844445e4a2d7bff6badd050f8d240838d984 | [] | no_license | udayswagh/Basic_Java_Program | ba07e4d4b0eb9f11e7edf73fe3d60a3f9dbad129 | 9c9b93e7318562ef50f62d8a9e63a5af77c783f8 | refs/heads/master | 2020-08-03T22:59:08.223069 | 2019-12-09T05:43:40 | 2019-12-09T05:43:40 | 211,912,440 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 319 | java | package in.codeblog.cmsapp.test;
import in.codeblog.cmsapp.controller.UserRegistrationController;
public class UserRegistration_Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
UserRegistrationController controller=new UserRegistrationController();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
06cd757a2193f40f9de6f4f4798722b1296c5d87 | d175ed73961c4b6c2ac43252a84fb26d8fa806fc | /iBase4J-SYS-Service/src/main/java/org/ibase4j/service/impl/SysCacheServiceImpl.java | 4d1ace9646f425f040a4cfa678c0e94940cbf567 | [
"Apache-2.0",
"ICU"
] | permissive | qiangziwwq/iBase4J | b109e356d8f46512ca82991999ac4c13bd12ecea | 96b27c66be390cadd68d609de7d7a1c2ef8cd172 | refs/heads/master | 2020-07-02T02:10:59.282333 | 2020-03-11T13:57:07 | 2020-03-11T13:57:07 | 201,381,986 | 1 | 0 | Apache-2.0 | 2020-03-11T13:57:08 | 2019-08-09T03:27:10 | JavaScript | UTF-8 | Java | false | false | 1,109 | java | package org.ibase4j.service.impl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.ibase4j.service.SysCacheService;
import org.apache.dubbo.config.annotation.Service;
import top.ibase4j.core.Constants;
import top.ibase4j.core.util.CacheUtil;
@Service(interfaceClass = SysCacheService.class)
public class SysCacheServiceImpl implements SysCacheService {
Logger logger = LogManager.getLogger();
// 清缓存
@Override
public void flush() {
logger.info("清缓存开始......");
CacheUtil.getCache().delAll(Constants.CACHE_NAMESPACE + "*");
logger.info("清缓存结束!");
}
// 清缓存
@Override
public void flush(String key) {
logger.info("清缓存[{}]开始......", key);
CacheUtil.getCache().delAll(Constants.CACHE_NAMESPACE + "*" + key + "*");
if (key.contains("Permission")) {
CacheUtil.getCache().delAll(Constants.CACHE_NAMESPACE + "*shiro_redis_cache*");
}
logger.info("清缓存[{}]结束!", key);
}
}
| [
"huajieshen@126.com"
] | huajieshen@126.com |
9e8dd54b760eeaac8c859ce4e1745a1d525da3d1 | 4fc929e44e4c8ca07faa85cc7fe3f68bf1005c61 | /test/com/facebook/buck/rules/keys/RuleKeyBuilderTest.java | c084bf04af9a85b648e22c8cb640be1b9f372d18 | [
"Apache-2.0"
] | permissive | johnblaze321/buck | 99a70237f4104acdb7a8052ff651f8a8f1d96873 | 3964170ba4ecb7d5c0f269e0bd6a6d44e157950f | refs/heads/master | 2020-12-02T11:04:47.801319 | 2017-07-07T22:41:43 | 2017-07-07T23:53:13 | 96,597,214 | 1 | 0 | null | 2017-07-08T05:03:15 | 2017-07-08T05:03:15 | null | UTF-8 | Java | false | false | 12,411 | java | /*
* Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.buck.rules.keys;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import com.facebook.buck.io.ProjectFilesystem;
import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.model.BuildTargetFactory;
import com.facebook.buck.model.Either;
import com.facebook.buck.rules.AddsToRuleKey;
import com.facebook.buck.rules.ArchiveMemberSourcePath;
import com.facebook.buck.rules.BuildContext;
import com.facebook.buck.rules.BuildRule;
import com.facebook.buck.rules.BuildRuleResolver;
import com.facebook.buck.rules.BuildRuleType;
import com.facebook.buck.rules.BuildTargetSourcePath;
import com.facebook.buck.rules.BuildableContext;
import com.facebook.buck.rules.DefaultBuildTargetSourcePath;
import com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer;
import com.facebook.buck.rules.NonHashableSourcePathContainer;
import com.facebook.buck.rules.PathSourcePath;
import com.facebook.buck.rules.RuleKey;
import com.facebook.buck.rules.RuleKeyAppendable;
import com.facebook.buck.rules.RuleKeyObjectSink;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.SourcePathResolver;
import com.facebook.buck.rules.SourcePathRuleFinder;
import com.facebook.buck.rules.SourceRoot;
import com.facebook.buck.rules.SourceWithFlags;
import com.facebook.buck.rules.TargetGraph;
import com.facebook.buck.step.Step;
import com.facebook.buck.testutil.FakeFileHashCache;
import com.facebook.buck.testutil.FakeProjectFilesystem;
import com.facebook.buck.util.sha1.Sha1HashCode;
import com.google.common.base.Preconditions;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.hash.HashCode;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.junit.Test;
public class RuleKeyBuilderTest {
private static final BuildTarget TARGET_1 =
BuildTargetFactory.newInstance(Paths.get("/root"), "//example/base:one");
private static final BuildTarget TARGET_2 =
BuildTargetFactory.newInstance(Paths.get("/root"), "//example/base:one#flavor");
private static final BuildRule IGNORED_RULE = new EmptyRule(TARGET_1);
private static final BuildRule RULE_1 = new EmptyRule(TARGET_1);
private static final BuildRule RULE_2 = new EmptyRule(TARGET_2);
private static final RuleKey RULE_KEY_1 = new RuleKey("a002b39af204cdfaa5fdb67816b13867c32ac52c");
private static final RuleKey RULE_KEY_2 = new RuleKey("b67816b13867c32ac52ca002b39af204cdfaa5fd");
private static final RuleKeyAppendable IGNORED_APPENDABLE = new FakeRuleKeyAppendable("");
private static final RuleKeyAppendable APPENDABLE_1 = new FakeRuleKeyAppendable("");
private static final RuleKeyAppendable APPENDABLE_2 = new FakeRuleKeyAppendable("42");
private static final Path PATH_1 = Paths.get("path1");
private static final Path PATH_2 = Paths.get("path2");
private static final ProjectFilesystem FILESYSTEM = new FakeProjectFilesystem();
private static final SourcePath SOURCE_PATH_1 = new PathSourcePath(FILESYSTEM, PATH_1);
private static final SourcePath SOURCE_PATH_2 = new PathSourcePath(FILESYSTEM, PATH_2);
private static final ArchiveMemberSourcePath ARCHIVE_PATH_1 =
ArchiveMemberSourcePath.of(SOURCE_PATH_1, Paths.get("member"));
private static final ArchiveMemberSourcePath ARCHIVE_PATH_2 =
ArchiveMemberSourcePath.of(SOURCE_PATH_2, Paths.get("member"));
private static final DefaultBuildTargetSourcePath TARGET_PATH_1 =
new DefaultBuildTargetSourcePath(TARGET_1);
private static final DefaultBuildTargetSourcePath TARGET_PATH_2 =
new DefaultBuildTargetSourcePath(TARGET_2);
@Test
public void testUniqueness() {
String[] fieldKeys = new String[] {"key1", "key2"};
Object[] fieldValues =
new Object[] {
// Java types
null,
true,
false,
0,
42,
(long) 0,
(long) 42,
(short) 0,
(short) 42,
(byte) 0,
(byte) 42,
(float) 0,
(float) 42,
(double) 0,
(double) 42,
"",
"42",
new byte[0],
new byte[] {42},
new byte[] {42, 42},
DummyEnum.BLACK,
DummyEnum.WHITE,
Pattern.compile(""),
Pattern.compile("42"),
// Buck simple types
Sha1HashCode.of("a002b39af204cdfaa5fdb67816b13867c32ac52c"),
Sha1HashCode.of("b67816b13867c32ac52ca002b39af204cdfaa5fd"),
new SourceRoot(""),
new SourceRoot("42"),
RULE_KEY_1,
RULE_KEY_2,
BuildRuleType.of(""),
BuildRuleType.of("42"),
TARGET_1,
TARGET_2,
// Buck paths
new NonHashableSourcePathContainer(SOURCE_PATH_1),
new NonHashableSourcePathContainer(SOURCE_PATH_2),
SOURCE_PATH_1,
SOURCE_PATH_2,
ARCHIVE_PATH_1,
ARCHIVE_PATH_2,
TARGET_PATH_1,
TARGET_PATH_2,
SourceWithFlags.of(SOURCE_PATH_1, ImmutableList.of("42")),
SourceWithFlags.of(SOURCE_PATH_2, ImmutableList.of("42")),
// Buck rules & appendables
RULE_1,
RULE_2,
APPENDABLE_1,
APPENDABLE_2,
// Wrappers
Suppliers.ofInstance(42),
Optional.of(42),
Either.ofLeft(42),
Either.ofRight(42),
// Containers & nesting
ImmutableList.of(42),
ImmutableList.of(42, 42),
ImmutableMap.of(42, 42),
ImmutableList.of(ImmutableList.of(1, 2, 3, 4)),
ImmutableList.of(ImmutableList.of(1, 2), ImmutableList.of(3, 4)),
};
List<RuleKey> ruleKeys = new ArrayList<>();
List<String> desc = new ArrayList<>();
ruleKeys.add(newBuilder().build(RuleKey::new));
desc.add("<empty>");
for (String key : fieldKeys) {
for (Object val : fieldValues) {
ruleKeys.add(calcRuleKey(key, val));
String clazz = (val != null) ? val.getClass().getSimpleName() : "";
desc.add(String.format("{key=%s, val=%s{%s}}", key, clazz, val));
}
}
// all of the rule keys should be different
for (int i = 0; i < ruleKeys.size(); i++) {
for (int j = 0; j < i; j++) {
assertNotEquals(
String.format("Collision: %s == %s", desc.get(i), desc.get(j)),
ruleKeys.get(i),
ruleKeys.get(j));
}
}
}
@Test
public void testNoOp() {
RuleKey noop = newBuilder().build(RuleKey::new);
assertEquals(noop, calcRuleKey("key", ImmutableList.of()));
assertEquals(noop, calcRuleKey("key", ImmutableList.of().iterator()));
assertEquals(noop, calcRuleKey("key", ImmutableMap.of()));
assertEquals(noop, calcRuleKey("key", ImmutableList.of(IGNORED_RULE)));
assertEquals(noop, calcRuleKey("key", Suppliers.ofInstance(IGNORED_RULE)));
assertEquals(noop, calcRuleKey("key", Optional.of(IGNORED_RULE)));
assertEquals(noop, calcRuleKey("key", Either.ofLeft(IGNORED_RULE)));
assertEquals(noop, calcRuleKey("key", Either.ofRight(IGNORED_RULE)));
assertEquals(noop, calcRuleKey("key", IGNORED_RULE));
assertEquals(noop, calcRuleKey("key", IGNORED_APPENDABLE));
}
private RuleKey calcRuleKey(String key, @Nullable Object val) {
return newBuilder().setReflectively(key, val).build(RuleKey::new);
}
private RuleKeyBuilder<HashCode> newBuilder() {
Map<BuildTarget, BuildRule> ruleMap = ImmutableMap.of(TARGET_1, RULE_1, TARGET_2, RULE_2);
Map<BuildRule, RuleKey> ruleKeyMap = ImmutableMap.of(RULE_1, RULE_KEY_1, RULE_2, RULE_KEY_2);
Map<AddsToRuleKey, RuleKey> appendableKeys =
ImmutableMap.of(APPENDABLE_1, RULE_KEY_1, APPENDABLE_2, RULE_KEY_2);
BuildRuleResolver ruleResolver = new FakeBuildRuleResolver(ruleMap);
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FakeFileHashCache hashCache =
new FakeFileHashCache(
ImmutableMap.of(
FILESYSTEM.resolve(PATH_1), HashCode.fromInt(0),
FILESYSTEM.resolve(PATH_2), HashCode.fromInt(42)),
ImmutableMap.of(
pathResolver.getAbsoluteArchiveMemberPath(ARCHIVE_PATH_1), HashCode.fromInt(0),
pathResolver.getAbsoluteArchiveMemberPath(ARCHIVE_PATH_2), HashCode.fromInt(42)),
ImmutableMap.of());
return new RuleKeyBuilder<HashCode>(
ruleFinder, pathResolver, hashCache, RuleKeyBuilder.createDefaultHasher()) {
@Override
protected RuleKeyBuilder<HashCode> setBuildRule(BuildRule rule) {
if (rule == IGNORED_RULE) {
return this;
}
return setBuildRuleKey(ruleKeyMap.get(rule));
}
@Override
public RuleKeyBuilder<HashCode> setAddsToRuleKey(AddsToRuleKey appendable) {
if (appendable == IGNORED_APPENDABLE) {
return this;
}
return setAddsToRuleKey(appendableKeys.get(appendable));
}
@Override
protected RuleKeyBuilder<HashCode> setSourcePath(SourcePath sourcePath) throws IOException {
if (sourcePath instanceof BuildTargetSourcePath) {
return setSourcePathAsRule((BuildTargetSourcePath) sourcePath);
} else {
return setSourcePathDirectly(sourcePath);
}
}
@Override
protected RuleKeyBuilder<HashCode> setNonHashingSourcePath(SourcePath sourcePath) {
return setNonHashingSourcePathDirectly(sourcePath);
}
};
}
// This ugliness is necessary as we don't have mocks in Buck unit tests.
private static class FakeBuildRuleResolver extends BuildRuleResolver {
private final Map<BuildTarget, BuildRule> ruleMap;
public FakeBuildRuleResolver(Map<BuildTarget, BuildRule> ruleMap) {
super(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
this.ruleMap = ruleMap;
}
@Override
public BuildRule getRule(BuildTarget target) {
return Preconditions.checkNotNull(ruleMap.get(target), "No rule for target: " + target);
}
}
private static class FakeRuleKeyAppendable implements RuleKeyAppendable {
private final String field;
public FakeRuleKeyAppendable(String field) {
this.field = field;
}
@Override
public void appendToRuleKey(RuleKeyObjectSink sink) {
sink.setReflectively("field", field);
}
}
private static class EmptyRule implements BuildRule {
private final BuildTarget target;
public EmptyRule(BuildTarget target) {
this.target = target;
}
@Override
public BuildTarget getBuildTarget() {
return target;
}
@Override
public String getType() {
return "empty";
}
@Override
public ImmutableSortedSet<BuildRule> getBuildDeps() {
return ImmutableSortedSet.of();
}
@Override
public ProjectFilesystem getProjectFilesystem() {
return new FakeProjectFilesystem();
}
@Override
public ImmutableList<Step> getBuildSteps(
BuildContext context, BuildableContext buildableContext) {
throw new UnsupportedOperationException("getBuildSteps");
}
@Nullable
@Override
public SourcePath getSourcePathToOutput() {
return null;
}
@Override
public boolean isCacheable() {
return true;
}
}
private enum DummyEnum {
BLACK,
WHITE,
}
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
527670a01cbd53538b10d878a17976db1f78d44d | 3fdfbf4f8a3e7c53df1a8f2a4182d7ccfe41b4c5 | /app/src/main/java/com/qualityfull/reactivexandroidbyexamples/ui/orchestration/auth/AuthActivity.java | 34f8d2f7a494a84a1be51721c22ca2ff1ecb7e7b | [] | no_license | jahir8a/reactivexandroidbyexamples | 08cdb937ac75460a0cd1e36dda4612db0942e3ac | ab62cde3d526669f5aa46aa78dc57d983bc207dc | refs/heads/master | 2022-01-03T01:09:41.305898 | 2018-03-12T17:21:09 | 2018-03-12T17:21:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,998 | java | package com.qualityfull.reactivexandroidbyexamples.ui.orchestration.auth;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.qualityfull.reactivexandroidbyexamples.R;
import com.qualityfull.reactivexandroidbyexamples.ui.base.BaseActivity;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;
public class AuthActivity extends BaseActivity implements AuthMvpView {
@Inject
AuthPresenter authPresenter;
@BindView(R.id.full_name_series)
EditText editTextFullSeriesName;
@BindView(R.id.label_results)
TextView textLabelResults;
@BindView(R.id.label_errors)
TextView textLabelErrors;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityComponent().inject(this);
setContentView(R.layout.activity_auth);
ButterKnife.bind(this);
authPresenter.attachView(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
authPresenter.detachView();
}
@OnClick(R.id.button_get_token)
public void getToken() {
Timber.i("Search series");
authPresenter.showSeries(editTextFullSeriesName.getText().toString());
}
@OnClick(R.id.button_set_token)
public void setToken() {
Timber.i("Clear token");
authPresenter.clearTokenStored();
}
@Override
public void showResults(int size) {
textLabelResults.setVisibility(View.VISIBLE);
textLabelErrors.setVisibility(View.INVISIBLE);
textLabelResults.setText(getString(R.string.text_results, size));
}
@Override
public void showError(String descriptionError) {
textLabelErrors.setVisibility(View.VISIBLE);
textLabelResults.setVisibility(View.INVISIBLE);
textLabelErrors.setText(descriptionError);
}
}
| [
"yaircarreno@gmail.com"
] | yaircarreno@gmail.com |
c7de1c1624dd45670ef7e2322fbf45707f9d9058 | 5dca4c9ecaa2be0b4891bf5e8977e32c6cc8ef44 | /src/main/java/com/jag/gui/JProgressOK.java | 23781a43b395e4fcd4db26c22a61f04abd86668c | [] | no_license | jag522/JavaExamples | b1f3464528a160195ebc8ca1016284bbda412798 | 04fe9515ed7c9b23c0b923be732a3548be75e58a | refs/heads/master | 2021-01-15T10:47:16.953273 | 2014-07-19T06:12:34 | 2014-07-19T06:12:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,751 | java | package com.jag.gui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
public class JProgressOK extends JPanel {
private BorderLayout borderLayout1 = new BorderLayout();
private static JProgressBar bar = new JProgressBar();
private JButton btn = new JButton();
private final void doWork() {
final SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
int total = 100;
bar.setMaximum(total);
bar.setMinimum(0);
for (int i = 0; i < total; i++) {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
bar.setValue(i);
}
} catch (Exception e) {
}
return null;
}
public void finished() {
}
};
worker.start();
}
public JProgressOK() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(borderLayout1);
this.setDoubleBuffered(false);
bar.setDoubleBuffered(false);
btn.setDoubleBuffered(false);
btn.setText("import");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doWork();
}
});
this.add(bar, BorderLayout.SOUTH);
this.add(btn, BorderLayout.CENTER);
}
public static void main(String[] args) {
JProgressOK me = new JProgressOK();
javax.swing.JFrame frame = new javax.swing.JFrame();
frame.getContentPane().add(me, java.awt.BorderLayout.CENTER);
frame.pack();
frame.setSize(500, 100);
frame.setLocation(300, 600);
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
| [
"tyouketu@gmail.com"
] | tyouketu@gmail.com |
28b850f30d458266364b50b2812e8594e48c42e1 | e224e5afc80eb2057548c95deeda193522a511f5 | /src/main/java/com/model/entity/SysDict.java | 641d37c4c6fe03e8f5257e5d2d65ee86ba3256de | [] | no_license | qbanxiaoli/demo | e3ed4778fce08eca709bae0f3434c69cf893aa53 | 24b4a4aa5bfb6e3485d54fe5e7882c6b3269244a | refs/heads/main | 2023-03-31T10:17:23.270387 | 2021-04-01T04:19:23 | 2021-04-01T04:19:23 | 316,396,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,328 | java | package com.model.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
/**
* @author qbanxiaoli
* @description
* @create 2020-02-01 22:33
*/
@Getter
@Setter
@Entity
@Table(name = "sys_dict", indexes = @Index(name = "idx_table_name_idx_field_name_idx_field_value", columnList = "tableName,fieldName,fieldValue", unique = true))
@ApiModel(value = "数据字典")
public class SysDict extends CreatorEntity {
@Column(nullable = false, columnDefinition = "varchar(20) COMMENT '表名'")
@ApiModelProperty(value = "表名", required = true)
private String tableName;
@Column(nullable = false, columnDefinition = "varchar(20) COMMENT '字段名'")
@ApiModelProperty(value = "字段名", required = true)
private String fieldName;
@Column(nullable = false, columnDefinition = "int COMMENT '字段值'")
@ApiModelProperty(value = "字段值", required = true)
private Integer fieldValue;
@Column(nullable = false, columnDefinition = "varchar(20) COMMENT '字段描述'")
@ApiModelProperty(value = "字段描述", required = true)
private String description;
} | [
"823730820@qq.com"
] | 823730820@qq.com |
d8079a21b16f752479184a695bf8f8a3e0f23a8d | 672661e71d9f6cb16dc7105f0378b7eaa7d1cd9a | /src/Main.java | 00252c11b1e8a7e1330a5db7271e5b66c23f2df3 | [] | no_license | UAzif/DZJ-2.2 | 8aa10292db670193ef80f2abd64123321f9607a6 | 978b74d7708e823d88ccb0bb5956c55ed3d8ff36 | refs/heads/master | 2023-07-19T08:21:07.019200 | 2021-08-16T17:18:47 | 2021-08-16T17:18:47 | 396,645,361 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | java | public class Main {
public static void main(String[] args) {
double regularBonus = 0.3;
double specialBonus = 0.6;
double totalBonus = regularBonus + specialBonus;
System.out.println("Вам начислен бонус " + totalBonus);
}
}
| [
"begimot02@mail.ru"
] | begimot02@mail.ru |
2a924d56907b2634c7cd4c367b128347deb88f06 | 429d932e35a83959b491e2efe6bf5fc724b718c9 | /scrollbar.java | b28d01629d3bb10204f27db0b5b3f7111e9ec875 | [] | no_license | yanamalaumesh1874/swing-scrollbar | d2a8a005d0920682058514d8592f95e11ca24975 | ec548d70c32a8983281fd532707b2742d26add63 | refs/heads/master | 2021-05-26T11:44:32.745282 | 2020-04-08T14:56:58 | 2020-04-08T14:56:58 | 254,118,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 325 | java | import javax.swing.*;
class scrollbar
{
scrollbar()
{
JFrame f= new JFrame("Scrollbar Example");
JScrollBar s=new JScrollBar();
s.setBounds(100,100, 50,100);
f.add(s);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new scrollbar();
}
}
| [
"noreply@github.com"
] | noreply@github.com |
69132cd07cdf286b6dd1e64158483acfa181dfaa | b94aa8b424ddfad294255d958ae7fc170364f1ef | /src/com/herbtea/study/datastructure/MultiStack/FullStackException.java | 934a3edf67ebde967e9979e18e7a23aa5fda1134 | [] | no_license | herbtea30/datastructures | d238826d48c57758936d29ed99b5e2951802e853 | e279eac4ad3254b6deba4bdd125174e52262fe19 | refs/heads/master | 2020-05-16T09:01:48.387421 | 2019-04-30T08:56:02 | 2019-04-30T08:56:02 | 182,933,481 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package com.herbtea.study.datastructure.MultiStack;
public class FullStackException extends Throwable {
public FullStackException() {
super();
}
public FullStackException(String msg){
super(msg);
}
}
| [
"herbtea30@gmail.com"
] | herbtea30@gmail.com |
b5476bdbbfdd787ee1b3808ee0f511163b1d774f | 1ea57b6cb7b94a207f4b7398e7b12d71d2ae8f60 | /Java_28.5/NetBeansProjects/Portfolio/Portfeuil/src/com/wajid/portfolio/model/TransactionEntry.java | c2bfca88bbc47b67d84de96cbc0f007da17d3e72 | [] | no_license | BRICOMATA9/Teaching_ | fefbd8268be653f4e73bcd99ac9213c23688cb8b | 0b6750f1d97acb115405e1693d7b50ae9e1cdcda | refs/heads/master | 2022-11-05T00:52:36.484594 | 2019-06-06T16:41:37 | 2019-06-06T16:41:37 | 177,466,844 | 0 | 0 | null | 2022-10-05T19:27:06 | 2019-03-24T20:41:03 | HTML | UTF-8 | Java | false | false | 2,880 | 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.wajid.portfolio.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
/**
*
* @author Admin
*/
@Entity
@Table(name = "transaction_details")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"},
allowGetters = true)
public class TransactionEntry extends AuditModel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long transactionId;
@NotBlank
private String stockName;
@NotNull
private Double stockPrice;
@NotNull
private Long stockQuantity;
@NotBlank
private String transactionType;
/**
* @return the transactionId
*/
public Long getTransactionId() {
return transactionId;
}
/**
* @param transactionId the transactionId to set
*/
public void setTransactionId(Long transactionId) {
this.transactionId = transactionId;
}
/**
* @return the stockName
*/
public String getStockName() {
return stockName;
}
/**
* @param stockName the stockName to set
*/
public void setStockName(String stockName) {
this.stockName = stockName;
}
/**
* @return the stockPrice
*/
public Double getStockPrice() {
return stockPrice;
}
/**
* @param stockPrice the stockPrice to set
*/
public void setStockPrice(Double stockPrice) {
this.stockPrice = stockPrice;
}
/**
* @return the stockQuantity
*/
public Long getStockQuantity() {
return stockQuantity;
}
/**
* @param stockQuantity the stockQuantity to set
*/
public void setStockQuantity(Long stockQuantity) {
this.stockQuantity = stockQuantity;
}
/**
* @return the transactionType
*/
public String getTransactionType() {
return transactionType;
}
/**
* @param transactionType the transactionType to set
*/
public void setTransactionType(String transactionType) {
this.transactionType = transactionType;
}
}
| [
"githubfortyuds@gmail.com"
] | githubfortyuds@gmail.com |
71c2c41d2a9623c9ead57410d961b4ad6e29c37a | abfe5861aaf551d5cf9b0f44028dacb392554449 | /JAVA-Repository/study/heima/src/cn/itcast/day12/demo04/Demo02Calendar.java | 56add7540c29fc0cb8e4415c6ddf0cbcb286a1b8 | [] | no_license | berwin0415/learn | 7128bd9c494dd5bf053ac776f7f235e61f42a6c0 | 83a28b1e3de3f834081a67532d636e17c8c99b75 | refs/heads/master | 2023-01-19T20:07:18.218180 | 2021-03-16T04:55:09 | 2021-03-16T04:55:09 | 136,105,677 | 0 | 0 | null | 2023-01-07T04:22:29 | 2018-06-05T02:02:13 | JavaScript | UTF-8 | Java | false | false | 4,125 | java | package cn.itcast.day12.demo04;
import java.util.Calendar;
import java.util.Date;
/*
Calendar类的常用成员方法:
public int get(int field):返回给定日历字段的值。
public void set(int field, int value):将给定的日历字段设置为给定值。
public abstract void add(int field, int amount):根据日历的规则,为给定的日历字段添加或减去指定的时间量。
public Date getTime():返回一个表示此Calendar时间值(从历元到现在的毫秒偏移量)的Date对象。
成员方法的参数:
int field:日历类的字段,可以使用Calendar类的静态成员变量获取
public static final int YEAR = 1; 年
public static final int MONTH = 2; 月
public static final int DATE = 5; 月中的某一天
public static final int DAY_OF_MONTH = 5;月中的某一天
public static final int HOUR = 10; 时
public static final int MINUTE = 12; 分
public static final int SECOND = 13; 秒
*/
public class Demo02Calendar {
public static void main(String[] args) {
demo04();
}
/*
public Date getTime():返回一个表示此Calendar时间值(从历元到现在的毫秒偏移量)的Date对象。
把日历对象,转换为日期对象
*/
private static void demo04() {
//使用getInstance方法获取Calendar对象
Calendar c = Calendar.getInstance();
Date date = c.getTime();
System.out.println(date);
}
/*
public abstract void add(int field, int amount):根据日历的规则,为给定的日历字段添加或减去指定的时间量。
把指定的字段增加/减少指定的值
参数:
int field:传递指定的日历字段(YEAR,MONTH...)
int amount:增加/减少指定的值
正数:增加
负数:减少
*/
private static void demo03() {
//使用getInstance方法获取Calendar对象
Calendar c = Calendar.getInstance();
//把年增加2年
c.add(Calendar.YEAR,2);
//把月份减少3个月
c.add(Calendar.MONTH,-3);
int year = c.get(Calendar.YEAR);
System.out.println(year);
int month = c.get(Calendar.MONTH);
System.out.println(month);//西方的月份0-11 东方:1-12
//int date = c.get(Calendar.DAY_OF_MONTH);
int date = c.get(Calendar.DATE);
System.out.println(date);
}
/*
public void set(int field, int value):将给定的日历字段设置为给定值。
参数:
int field:传递指定的日历字段(YEAR,MONTH...)
int value:给指定字段设置的值
*/
private static void demo02() {
//使用getInstance方法获取Calendar对象
Calendar c = Calendar.getInstance();
//设置年为9999
c.set(Calendar.YEAR,9999);
//设置月为9月
c.set(Calendar.MONTH,9);
//设置日9日
c.set(Calendar.DATE,9);
//同时设置年月日,可以使用set的重载方法
c.set(8888,8,8);
int year = c.get(Calendar.YEAR);
System.out.println(year);
int month = c.get(Calendar.MONTH);
System.out.println(month);//西方的月份0-11 东方:1-12
int date = c.get(Calendar.DATE);
System.out.println(date);
}
/*
public int get(int field):返回给定日历字段的值。
参数:传递指定的日历字段(YEAR,MONTH...)
返回值:日历字段代表的具体的值
*/
private static void demo01() {
//使用getInstance方法获取Calendar对象
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
System.out.println(year);
int month = c.get(Calendar.MONTH);
System.out.println(month);//西方的月份0-11 东方:1-12
//int date = c.get(Calendar.DAY_OF_MONTH);
int date = c.get(Calendar.DATE);
System.out.println(date);
}
}
| [
"berwin0415@gmail.com"
] | berwin0415@gmail.com |
65aa4a33b77d408af5c7117eda90ab6e163df5ed | d3034b794a82797d94810c3bd06c1cfbd6b0e4a6 | /src/main/java/com/hendisantika/springbootehcache/controller/ProductController.java | 3fe4f40bd3272448704752cca6ed342c0491561a | [] | no_license | hendisantika/springboot-ehcache | 5c983a56234936a6bcda01240e772bf6eee4f22e | b7658f0e76feb32ca5e0617d35267060dcc1588f | refs/heads/master | 2023-06-07T15:32:19.309022 | 2023-05-25T12:16:18 | 2023-05-25T12:16:18 | 197,659,965 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,816 | java | package com.hendisantika.springbootehcache.controller;
import com.hendisantika.springbootehcache.model.Product;
import com.hendisantika.springbootehcache.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
/**
* Created by IntelliJ IDEA.
* Project : springboot-ehcache
* User: hendisantika
* Email: hendisantika@gmail.com
* Telegram : @hendisantika34
* Date: 2019-07-19
* Time: 05:16
*/
@RestController
@RequestMapping(value = "/api/products")
public class ProductController {
@Autowired
private ProductService pserv;
@GetMapping
@ResponseBody
public ResponseEntity<List<Product>> getAllProducts() {
List<Product> products = pserv.getAllProducts();
if (products.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(products, HttpStatus.OK);
}
/**
* Method to fetch product details on the basis of product id.
*
* @param productId
* @return
*/
@GetMapping(value = "/{product-id}")
@ResponseBody
public ResponseEntity<Product> getProductById(@PathVariable("product-id") int productId) {
Optional<Product> product = pserv.getProductById(productId);
if (!product.isPresent())
return new ResponseEntity<Product>(HttpStatus.NOT_FOUND);
return new ResponseEntity<Product>(product.get(), HttpStatus.OK);
}
/**
* Method to update product on the basis of product id.
*
* @param productId
* @param productName
* @return
*/
@PutMapping(value = "/{product-id}/{product-name}")
public ResponseEntity<Product> updateTicketById(@PathVariable("product-id") int productId, @PathVariable("product-name") String productName) {
Optional<Product> product = pserv.getProductById(productId);
if (!product.isPresent())
return new ResponseEntity<Product>(HttpStatus.NOT_FOUND);
return new ResponseEntity<Product>(pserv.updateProductById(product.get(), productName), HttpStatus.OK);
}
/**
* Method to delete product on the basis of product id.
*
* @param productId
*/
@DeleteMapping(value = "/{product-id}")
public ResponseEntity<Product> deleteProductById(@PathVariable("product-id") int productId) {
Optional<Product> product = pserv.getProductById(productId);
if (!product.isPresent())
return new ResponseEntity<Product>(HttpStatus.NOT_FOUND);
pserv.deleteProductById(productId);
return new ResponseEntity<Product>(HttpStatus.ACCEPTED);
}
}
| [
"hendisantika@yahoo.co.id"
] | hendisantika@yahoo.co.id |
56615586352bb411ec2d949b3e898b3717bf21a4 | 1dd1230ce64d36b5865e1428b5e3e93f8f602198 | /src/com/coolweather/app/model/County.java | 8afe4e200c9803c9b3b3dc63a864c46de7a10544 | [
"Artistic-2.0"
] | permissive | tomsonTang/coolweather | 266a19fbea3c3fb3af94a024af6f2af2cd305227 | 05c816b105e5cbc532e516a16202f9a28ba90e4f | refs/heads/master | 2020-04-19T10:34:49.904106 | 2014-12-17T05:51:44 | 2014-12-17T05:51:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,513 | java | package com.coolweather.app.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* @author xinyuncz.Tomson
* @version :
* 2014-12-16 下午8:53:39
*/
public class County implements Parcelable{
private int id;
private String countyName;
private String countyCode;
private int cityId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public String getCountyCode() {
return countyCode;
}
public void setCountyCode(String countyCode) {
this.countyCode = countyCode;
}
public int getCityId() {
return cityId;
}
public void setCityId(int cityId) {
this.cityId = cityId;
}
//实现可Parcelable化
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(countyName);
dest.writeString(countyCode);
dest.writeInt(cityId);
}
public static final Parcelable.Creator<County> CREATOR = new Parcelable.Creator<County>() {
@Override
public County createFromParcel(Parcel source) {
County county = new County();
county.id = source.readInt();
county.countyName = source.readString();
county.countyCode = source.readString();
county.cityId = source.readInt();
return county;
}
@Override
public County[] newArray(int size) {
return new County[size];
}
};
}
| [
"tomson_tang@yeah.net"
] | tomson_tang@yeah.net |
2d6f55babce1289825c57da2f77622d4be956c39 | 5c7e094aaf5e87b188fcad962de006f992cb7b92 | /src/main/java/org/gxl/minibean/bean/annotations/Assignment.java | c185f436a8ca089703f18c001dfaa1fe70bd03fe | [
"Apache-2.0"
] | permissive | qinlinglong/minibean | dc679a07cb35599d7515bd18fed2283ba89ba36d | 98b77f34557851223edbd3defaf075a0c9e04f5c | refs/heads/master | 2021-01-23T04:48:37.082293 | 2016-04-06T02:01:58 | 2016-04-06T02:01:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,090 | java | /*
* Copyright 2015-2101 gaoxianglong
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gxl.minibean.bean.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自动赋值标记类,作用于类,只有标记了该注解的类型才能实现后续的自动赋值
*
* @author JohnGao
*/
@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Assignment {
} | [
"gao_xianglong@sina.com"
] | gao_xianglong@sina.com |
ff9574a4b7bccb54048a39e3d229c4883f5266ff | ea44f4099a0f9a7f8083b2539fe7acd53fdd5d4b | /playgrounds/michalm/src/main/java/playground/michalm/taxi/util/stats/TaxiStatsCalculator.java | db7b1b8f05bad237effa9bf1a1ff18165ae41cec | [] | no_license | YanjieDong/matsim | ffa7dd282595cfe152b986a6dfff94a6adede44c | 29f63a518ffbd7737b49dc45046ea909df225722 | refs/heads/master | 2021-01-16T18:42:57.743327 | 2015-08-20T16:24:53 | 2015-08-20T16:24:53 | 41,093,611 | 0 | 0 | null | 2015-08-20T12:08:52 | 2015-08-20T12:08:52 | null | UTF-8 | Java | false | false | 4,516 | java | /* *********************************************************************** *
* project: org.matsim.*
* *
* *********************************************************************** *
* *
* copyright : (C) 2013 by the members listed in the COPYING, *
* LICENSE and WARRANTY file. *
* email : info at matsim dot org *
* *
* *********************************************************************** *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* See also COPYING, LICENSE and WARRANTY file *
* *
* *********************************************************************** */
package playground.michalm.taxi.util.stats;
import java.util.EnumMap;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.matsim.contrib.dvrp.data.*;
import org.matsim.contrib.dvrp.schedule.*;
import org.matsim.contrib.dvrp.schedule.Schedule.ScheduleStatus;
import playground.michalm.taxi.schedule.*;
import playground.michalm.taxi.schedule.TaxiTask.TaxiTaskType;
public class TaxiStatsCalculator
{
private final TaxiStats stats = new TaxiStats();
public TaxiStatsCalculator(Iterable<? extends Vehicle> vehicles)
{
for (Vehicle v : vehicles) {
calculateStatsImpl(v);
}
}
public TaxiStats getStats()
{
return stats;
}
private void calculateStatsImpl(Vehicle vehicle)
{
Schedule<TaxiTask> schedule = TaxiSchedules.asTaxiSchedule(vehicle.getSchedule());
if (schedule.getStatus() == ScheduleStatus.UNPLANNED) {
return;// do not evaluate - the vehicle is unused
}
for (TaxiTask t : schedule.getTasks()) {
stats.addTime(t);
if (t.getTaxiTaskType() == TaxiTaskType.PICKUP) {
Request req = ((TaxiPickupTask)t).getRequest();
double waitTime = Math.max(t.getBeginTime() - req.getT0(), 0);
stats.passengerWaitTimes.addValue(waitTime);
}
}
}
public static class TaxiStats
{
public final DescriptiveStatistics passengerWaitTimes = new DescriptiveStatistics();
public final EnumMap<TaxiTaskType, DescriptiveStatistics> timesByTaskType;
public TaxiStats()
{
timesByTaskType = new EnumMap<>(TaxiTaskType.class);
for (TaxiTaskType t : TaxiTaskType.values()) {
timesByTaskType.put(t, new DescriptiveStatistics());
}
}
public void addTime(TaxiTask task)
{
double time = task.getEndTime() - task.getBeginTime();
timesByTaskType.get(task.getTaxiTaskType()).addValue(time);
}
public double getDriveEmptyRatio()
{
double empty = timesByTaskType.get(TaxiTaskType.DRIVE_EMPTY).getSum();//not mean!
double withPassenger = timesByTaskType.get(TaxiTaskType.DRIVE_WITH_PASSENGER).getSum();//not mean!
return empty / (empty + withPassenger);
}
public DescriptiveStatistics getDriveWithPassengerTimes()
{
return timesByTaskType.get(TaxiTaskType.DRIVE_WITH_PASSENGER);
}
public static final String HEADER = "WaitT\t" //
+ "MaxWaitT"//
+ "WithPassengerT"//
+ "%EmptyDrive\t";
@Override
public String toString()
{
return new StringBuilder()//
.append(passengerWaitTimes.getMean()).append('\t') //
.append(passengerWaitTimes.getMax()).append('\t') //
.append(getDriveWithPassengerTimes().getMean()).append('\t') //
.append(getDriveEmptyRatio()).append('\t') //
.toString();
}
}
}
| [
"michal.mac@gmail.com"
] | michal.mac@gmail.com |
8dfd92bf366a0001e650496e4fa815650d805add | 523f38dfd7ba21164872af21f4b6fd7fdb5ef3cc | /src/chap18/lecture/inputstream/InputStreamEx2.java | c2df441fcadf9ba1ce7733a1996d98ca70f1b41a | [] | no_license | thirtist/java20200929 | 5b4dc29b4b2d4ee6bc023829c945c09e45a3a703 | fdf94c0d333d622f8d7614d15be02dfc8419069e | refs/heads/master | 2023-01-11T08:33:06.894958 | 2020-11-13T11:53:15 | 2020-11-13T11:53:15 | 299,485,599 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 706 | java | package chap18.lecture.inputstream;
import java.io.FileInputStream;
import java.io.InputStream;
public class InputStreamEx2 {
public static void main(String[] args) throws Exception {
String path = "src/chap18/lecture/inputstream/InputStreamEx2.java";
InputStream is = new FileInputStream(path);
// is.read(); // 이건 1바이트만
byte[] datas = new byte[10]; //배열로 몇 바이트씩 읽을지 만듦
int readCnt = is.read(datas); //파라미터의 배열길이만큼 단위로 읽음 //똑같이 읽을게 더이상 없으면 -1을 리턴
int loopCnt = 0;
while((readCnt = is.read(datas)) !=-1) {
loopCnt++;
}
System.out.println(loopCnt);
is.close();
}
}
| [
"thirtist@naver.com"
] | thirtist@naver.com |
1bfde2d447a25d8be72eaa0bfadd2931805349ac | 6d2d4af76f82e154b3aa06531adc248e3201c09b | /src/main/java/com/robertx22/mine_and_slash/database/runewords/slots_5/RuneWordInfinity.java | 8bafcee4e7758705fa6cc9f362abbbe1de3e7e46 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | AzureDoom/Mine-and-Slash | 4bd16494be00bde5a038bcc01dd66fb45209fe7f | a772326882824039eee814dcff4af321923a5736 | refs/heads/AzureBranch | 2021-07-10T03:32:16.672923 | 2020-08-16T03:59:14 | 2020-08-16T03:59:14 | 188,708,742 | 1 | 3 | NOASSERTION | 2020-02-24T09:12:49 | 2019-05-26T16:48:17 | Java | UTF-8 | Java | false | false | 1,130 | java | package com.robertx22.mine_and_slash.database.runewords.slots_5;
import com.robertx22.mine_and_slash.database.runes.*;
import com.robertx22.mine_and_slash.database.runes.base.BaseRune;
import com.robertx22.mine_and_slash.database.runewords.RuneWord;
import com.robertx22.mine_and_slash.database.stats.StatMod;
import com.robertx22.mine_and_slash.database.stats.mods.flat.resources.EnergyFlat;
import com.robertx22.mine_and_slash.database.stats.mods.flat.resources.EnergyRegenFlat;
import com.robertx22.mine_and_slash.database.stats.mods.percent.EnergyRegenPercent;
import java.util.Arrays;
import java.util.List;
public class RuneWordInfinity extends RuneWord {
@Override
public List<StatMod> mods() {
return Arrays.asList(new EnergyFlat(), new EnergyRegenFlat(), new EnergyRegenPercent());
}
@Override
public String GUID() {
return "infinity";
}
@Override
public List<BaseRune> runes() {
return Arrays.asList(new Cen(0), new Dos(0), new Ano(0), new Ber(0), new Xah(0));
}
@Override
public String locNameForLangFile() {
return "Infinity";
}
}
| [
"treborx555@gmail.com"
] | treborx555@gmail.com |
6b6423f1d8874e4fba19c2e82bc49177027c611d | c153521de60bbaab028d453e218974eb853d839e | /src/main/java/com/jokee/test/vo/School.java | 98a50afc8af9c0a0e3fd0302e50c2a0dce0fe43d | [] | no_license | PengN/api-test | 9284a3ee76f8641173d841e06d8069642fc0156e | 9ada815a1481f4eec2ab7a52e72e6ac6041c5635 | refs/heads/main | 2023-01-08T18:57:10.001692 | 2020-11-13T09:21:41 | 2020-11-13T09:21:41 | 312,526,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 851 | java | package com.jokee.test.vo;
import java.util.List;
public class School {
private List<Classes> classesList;
private String schoolName;
public School(List<Classes> classesList, String schoolName) {
this.classesList = classesList;
this.schoolName = schoolName;
}
@Override
public String toString() {
return "School{" +
"classesList=" + classesList +
", schoolName='" + schoolName + '\'' +
'}';
}
public List<Classes> getClassesList() {
return classesList;
}
public void setClassesList(List<Classes> classesList) {
this.classesList = classesList;
}
public String getSchoolName() {
return schoolName;
}
public void setSchoolName(String schoolName) {
this.schoolName = schoolName;
}
}
| [
"215232937@qq.com"
] | 215232937@qq.com |
d84e0857f2d52df2233d46bd347daf984d13e617 | a7ead1c3db8ba06ec1a47e2cd268375381c3a671 | /src/com/designPattern/creational/builder/ex1/VegBurger.java | a97be4e9444233259fc1d896961fbeb8e5344e0f | [] | no_license | hhammidd/javaProjects | baf460b1848165daa60cb897c869534e4c628403 | a6c58cdd098fb7625be3986594b2edd6cf805f92 | refs/heads/master | 2020-03-27T23:21:19.615447 | 2018-11-06T16:22:46 | 2018-11-06T16:22:46 | 147,312,036 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 239 | java | package com.designPattern.creational.builder.ex1;
public class VegBurger extends Burger {
@Override
public String name() {
return "veg burger";
}
@Override
public float price() {
return 25.0f;
}
}
| [
"hamid.shafikani@gmail.com"
] | hamid.shafikani@gmail.com |
926a0792377cf04feb4bee8f04340059ba89e7f0 | 0098c61a5004a47544d33b042abcc2d77ea7ec0b | /src/main/java/com/spleefleague/spleef/game/spleef/power/effect/EffectHeatBolts.java | a71a9060b6733673dfc2fd714da268268c0e42ae | [] | no_license | SpleefLeague/SLSpleef_new | 3b477b2f39a931d6d0663093c59dcb5b76737781 | 4b2ac2156c3fa3aa6f62349e63fda087e473d15e | refs/heads/master | 2022-09-23T01:13:15.064768 | 2022-09-17T21:03:38 | 2022-09-17T21:03:38 | 252,939,697 | 0 | 0 | null | 2022-09-17T21:03:38 | 2020-04-04T07:48:46 | Java | UTF-8 | Java | false | false | 1,340 | 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.spleefleague.spleef.game.spleef.power.effect;
import com.spleefleague.core.annotation.DBField;
import com.spleefleague.core.world.projectile.FakeProjectile;
import com.spleefleague.spleef.player.SpleefPlayer;
import org.bukkit.entity.EntityType;
/**
* @author NickM13
*/
public class EffectHeatBolts extends Effect {
@DBField
public Integer count;
@DBField
public Double spread;
@DBField
public Integer range;
@DBField
public Integer power;
public EffectHeatBolts() {
super();
}
public EffectHeatBolts(EffectHeatBolts o) {
count = o.count;
spread = o.spread;
range = o.range;
power = o.power;
}
@Override
public void reset(SpleefPlayer sp) {
}
@Override
public void updateEffect(SpleefPlayer sp) {
}
@Override
public void activate(SpleefPlayer sp) {
for (int i = 0; i < count; i++) {
//sp.getBattle().getGameWorld().shootProjectile(sp.getPlayer(), new FakeProjectile(EntityType.SNOWBALL, range, 0, power, true, 0, 0, spread));
}
}
}
| [
"NickMead0313@outlook.com"
] | NickMead0313@outlook.com |
f3cead63c2d44e7ed8eb360bcc2e2b35e23ddd80 | b1f07f70f4b5ff7ce63ae8273bb613ea66b15c4f | /transpool/transpool-web/src/main/java/servlets/AccountServlet.java | 82829993f328fb7797c0fd96c36a595f2014adba | [] | no_license | Shimon-ar/transpool-web | f1b022a64d800ecfeeaea8e35c3b791483d7ad9c | 62f417264080db87490af83395b9798b564808b1 | refs/heads/master | 2023-04-07T07:22:38.040800 | 2021-04-11T11:46:38 | 2021-04-11T11:46:38 | 287,919,009 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,303 | java | package servlets;
import org.transpool.engine.Engine;
import utilis.Constants;
import utilis.ServletUtils;
import utilis.SessionUtils;
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 java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@WebServlet(name = "AccountServlet", urlPatterns = {"/user/account"})
public class AccountServlet extends HttpServlet {
private void processRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html;charset=UTF-8");
String userName = SessionUtils.getUserName(request);
Engine engine = ServletUtils.getEngine(getServletContext());
int amount = ServletUtils.getIntParameter(request,Constants.AMOUNT);
if(amount != -1){
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
engine.makeDeposit(userName,amount,dtf.format(now));
}
try(PrintWriter out = response.getWriter()){
out.print(engine.getUser(userName).getAccount().getBalance());
out.flush();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"ars.shimon@gmail.com"
] | ars.shimon@gmail.com |
3c473dbc1faaf15775fb2b0b320b44a34c968c15 | b38fdb2e45b2b00974a33cb81f623b425811e74b | /my_goods_commons/my_goods_dao/src/main/java/com/zb/mapper/GtypeMapper.java | b3e51d0f286baa4158adcddc09dc60cdd7a65bbb | [] | no_license | wuyifan111/sese1 | d8e37e88cae00f83876de0ef88d045ae33fa6611 | 7e829d4c0dca9c96eb6016659b5acb9734df08fa | refs/heads/master | 2022-06-24T06:06:19.466475 | 2019-09-15T02:54:50 | 2019-09-15T02:54:50 | 207,442,767 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 581 | java | package com.zb.mapper;
import com.zb.pojo.Gtype;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GtypeMapper {
public Gtype getGtypeById(@Param(value = "id") Long id)throws Exception;
public List<Gtype> getGtypeListByMap(Map<String,Object> param)throws Exception;
public Integer getGtypeCountByMap(Map<String,Object> param)throws Exception;
public Integer insertGtype(Gtype gtype)throws Exception;
public Integer updateGtype(Gtype gtype)throws Exception;
}
| [
"2018166596@qq.com"
] | 2018166596@qq.com |
10bd7d6101d7004076189c12ce26d613f66e97a8 | faddd3950f7bbfcb2774fc473ddfac3eca74fbaf | /rife_v1_remaining/src/unittests/com/uwyn/rife/engine/TestSubmission.java | da4eda2477c650f9fb5060953adcff615535e198 | [] | no_license | wangbo15/rife | d4b392f6577e998f12a8b6e529886487ca9ed320 | 399468a4c6929f0f32ad2fc15906b89cfae0e1c1 | refs/heads/master | 2020-04-13T14:24:13.894322 | 2013-07-01T23:02:50 | 2013-07-01T23:02:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 42,430 | java | /*
* Copyright 2001-2008 Geert Bevin <gbevin[remove] at uwyn dot com>
* Licensed under the Apache License, Version 2.0 (the "License")
* $Id: TestSubmission.java 3918 2008-04-14 17:35:35Z gbevin $
*/
package com.uwyn.rife.engine;
import com.uwyn.rife.engine.exceptions.*;
import com.uwyn.rife.tools.ExceptionUtils;
import java.util.LinkedHashMap;
import junit.framework.TestCase;
public class TestSubmission extends TestCase
{
public TestSubmission(String name)
{
super(name);
}
public void testInstantiation()
{
Submission submission = null;
submission = new Submission();
assertNotNull(submission);
}
public void testNoInitialParameters()
{
Submission submission = new Submission();
assertEquals(submission.getParameterNames().size(), 0);
}
public void testNoInitialNamedBeans()
{
Submission submission = new Submission();
assertEquals(submission.getBeanNames().size(), 0);
}
public void testNoInitialBeans()
{
Submission submission = new Submission();
assertEquals(submission.getBeans().size(), 0);
}
public void testNoInitialFiles()
{
Submission submission = new Submission();
assertEquals(submission.getFileNames().size(), 0);
}
public void testAddParameter()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
submission.addParameter("parameter1", null);
assertEquals(submission.getParameterNames().size(), 1);
submission.addParameter("parameter2", null);
assertEquals(submission.getParameterNames().size(), 2);
submission.addParameter("parameter3", null);
assertEquals(submission.getParameterNames().size(), 3);
assertTrue(submission.containsParameter("parameter1"));
assertTrue(submission.containsParameter("parameter2"));
assertTrue(submission.containsParameter("parameter3"));
}
public void testAddParameterRegexp()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
submission.addParameterRegexp("paramA(\\d+)");
assertEquals(submission.getParameterRegexps().size(), 1);
submission.addParameterRegexp("paramB(\\d+)");
assertEquals(submission.getParameterRegexps().size(), 2);
submission.addParameterRegexp("paramC(\\d+)");
assertEquals(submission.getParameterRegexps().size(), 3);
assertTrue(submission.containsParameter("paramA1"));
assertTrue(submission.containsParameter("paramA2"));
assertTrue(submission.containsParameter("paramA3"));
assertTrue(submission.containsParameter("paramB1"));
assertTrue(submission.containsParameter("paramB2"));
assertTrue(submission.containsParameter("paramB3"));
assertTrue(submission.containsParameter("paramC1"));
assertTrue(submission.containsParameter("paramC2"));
assertTrue(submission.containsParameter("paramC3"));
assertTrue(!submission.containsParameter("paramA"));
assertTrue(!submission.containsParameter("paramB"));
assertTrue(!submission.containsParameter("paramC"));
}
public void testAddFile()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
submission.addFile("file1");
assertEquals(submission.getFileNames().size(), 1);
submission.addFile("file2");
assertEquals(submission.getFileNames().size(), 2);
submission.addFile("file3");
assertEquals(submission.getFileNames().size(), 3);
assertTrue(submission.containsFile("file1"));
assertTrue(submission.containsFile("file2"));
assertTrue(submission.containsFile("file3"));
}
public void testAddBean()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, null);
submission.addBean(bean1, null);
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 22);
assertEquals(submission.getFileNames().size(), 3);
assertTrue(submission.containsParameter("enum"));
assertTrue(submission.containsParameter("string"));
assertTrue(submission.containsParameter("stringbuffer"));
assertTrue(submission.containsParameter("int"));
assertTrue(submission.containsParameter("integer"));
assertTrue(submission.containsParameter("char"));
assertTrue(submission.containsParameter("boolean"));
assertTrue(submission.containsParameter("booleanObject"));
assertTrue(submission.containsParameter("byteObject"));
assertTrue(submission.containsParameter("double"));
assertTrue(submission.containsParameter("doubleObject"));
assertTrue(submission.containsParameter("float"));
assertTrue(submission.containsParameter("floatObject"));
assertTrue(submission.containsParameter("long"));
assertTrue(submission.containsParameter("longObject"));
assertTrue(submission.containsParameter("short"));
assertTrue(submission.containsParameter("shortObject"));
assertTrue(submission.containsParameter("date"));
assertTrue(submission.containsParameter("dateFormatted"));
assertTrue(submission.containsParameter("datesFormatted"));
assertTrue(submission.containsParameter("serializableParam"));
assertTrue(submission.containsParameter("serializableParams"));
assertTrue(submission.containsFile("stringFile"));
assertTrue(submission.containsFile("bytesFile"));
assertTrue(submission.containsFile("streamFile"));
}
public void testAddBeanPrefix()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", "prefix_", null);
submission.addBean(bean1, null);
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 22);
assertEquals(submission.getFileNames().size(), 3);
assertTrue(submission.containsParameter("prefix_enum"));
assertTrue(submission.containsParameter("prefix_string"));
assertTrue(submission.containsParameter("prefix_stringbuffer"));
assertTrue(submission.containsParameter("prefix_int"));
assertTrue(submission.containsParameter("prefix_integer"));
assertTrue(submission.containsParameter("prefix_char"));
assertTrue(submission.containsParameter("prefix_boolean"));
assertTrue(submission.containsParameter("prefix_booleanObject"));
assertTrue(submission.containsParameter("prefix_byteObject"));
assertTrue(submission.containsParameter("prefix_double"));
assertTrue(submission.containsParameter("prefix_doubleObject"));
assertTrue(submission.containsParameter("prefix_float"));
assertTrue(submission.containsParameter("prefix_floatObject"));
assertTrue(submission.containsParameter("prefix_long"));
assertTrue(submission.containsParameter("prefix_longObject"));
assertTrue(submission.containsParameter("prefix_short"));
assertTrue(submission.containsParameter("prefix_shortObject"));
assertTrue(submission.containsParameter("prefix_date"));
assertTrue(submission.containsParameter("prefix_dateFormatted"));
assertTrue(submission.containsParameter("prefix_datesFormatted"));
assertTrue(submission.containsParameter("prefix_serializableParam"));
assertTrue(submission.containsParameter("prefix_serializableParams"));
assertTrue(submission.containsFile("prefix_stringFile"));
assertTrue(submission.containsFile("prefix_bytesFile"));
assertTrue(submission.containsFile("prefix_streamFile"));
}
public void testAddBeanGroup()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, "somegroup");
submission.addBean(bean1, null);
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 5);
assertEquals(submission.getFileNames().size(), 0);
assertTrue(submission.containsParameter("enum"));
assertTrue(submission.containsParameter("string"));
assertTrue(submission.containsParameter("int"));
assertTrue(submission.containsParameter("longObject"));
assertTrue(submission.containsParameter("short"));
}
public void testAddBeanGroupPrefix()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", "prefix_", "somegroup");
submission.addBean(bean1, null);
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 5);
assertEquals(submission.getFileNames().size(), 0);
assertTrue(submission.containsParameter("prefix_enum"));
assertTrue(submission.containsParameter("prefix_string"));
assertTrue(submission.containsParameter("prefix_int"));
assertTrue(submission.containsParameter("prefix_longObject"));
assertTrue(submission.containsParameter("prefix_short"));
}
public void testAddNamedBean()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, null);
submission.addBean(bean1, "bean1");
assertTrue(submission.containsNamedBean("bean1"));
assertEquals(submission.getBeanNames().size(), 1);
assertEquals(submission.getBeanNames().iterator().next(), "bean1");
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 22);
assertEquals(submission.getFileNames().size(), 3);
assertTrue(submission.containsParameter("enum"));
assertTrue(submission.containsParameter("string"));
assertTrue(submission.containsParameter("stringbuffer"));
assertTrue(submission.containsParameter("int"));
assertTrue(submission.containsParameter("integer"));
assertTrue(submission.containsParameter("char"));
assertTrue(submission.containsParameter("boolean"));
assertTrue(submission.containsParameter("booleanObject"));
assertTrue(submission.containsParameter("byteObject"));
assertTrue(submission.containsParameter("double"));
assertTrue(submission.containsParameter("doubleObject"));
assertTrue(submission.containsParameter("float"));
assertTrue(submission.containsParameter("floatObject"));
assertTrue(submission.containsParameter("long"));
assertTrue(submission.containsParameter("longObject"));
assertTrue(submission.containsParameter("short"));
assertTrue(submission.containsParameter("shortObject"));
assertTrue(submission.containsParameter("date"));
assertTrue(submission.containsParameter("dateFormatted"));
assertTrue(submission.containsParameter("datesFormatted"));
assertTrue(submission.containsParameter("serializableParam"));
assertTrue(submission.containsParameter("serializableParams"));
assertTrue(submission.containsFile("stringFile"));
assertTrue(submission.containsFile("bytesFile"));
assertTrue(submission.containsFile("streamFile"));
BeanDeclaration bean2 = submission.getNamedBean("bean1");
assertNotNull(bean2);
assertEquals(bean1, bean2);
}
public void testAddNamedBeanPrefix()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertFalse(submission.containsNamedBean("bean1"));
BeanDeclaration bean1 = new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", "prefix_", null);
submission.addBean(bean1, "bean1");
assertTrue(submission.containsNamedBean("bean1"));
assertEquals(submission.getBeanNames().size(), 1);
assertEquals(submission.getBeanNames().iterator().next(), "bean1");
assertEquals(submission.getBeans().size(), 1);
assertEquals(submission.getBeans().iterator().next(), bean1);
assertEquals(submission.getParameterNames().size(), 22);
assertEquals(submission.getFileNames().size(), 3);
assertTrue(submission.containsParameter("prefix_enum"));
assertTrue(submission.containsParameter("prefix_string"));
assertTrue(submission.containsParameter("prefix_stringbuffer"));
assertTrue(submission.containsParameter("prefix_int"));
assertTrue(submission.containsParameter("prefix_integer"));
assertTrue(submission.containsParameter("prefix_char"));
assertTrue(submission.containsParameter("prefix_boolean"));
assertTrue(submission.containsParameter("prefix_booleanObject"));
assertTrue(submission.containsParameter("prefix_byteObject"));
assertTrue(submission.containsParameter("prefix_double"));
assertTrue(submission.containsParameter("prefix_doubleObject"));
assertTrue(submission.containsParameter("prefix_float"));
assertTrue(submission.containsParameter("prefix_floatObject"));
assertTrue(submission.containsParameter("prefix_long"));
assertTrue(submission.containsParameter("prefix_longObject"));
assertTrue(submission.containsParameter("prefix_short"));
assertTrue(submission.containsParameter("prefix_shortObject"));
assertTrue(submission.containsParameter("prefix_date"));
assertTrue(submission.containsParameter("prefix_dateFormatted"));
assertTrue(submission.containsParameter("prefix_datesFormatted"));
assertTrue(submission.containsParameter("prefix_serializableParam"));
assertTrue(submission.containsParameter("prefix_serializableParams"));
assertTrue(submission.containsFile("prefix_stringFile"));
assertTrue(submission.containsFile("prefix_bytesFile"));
assertTrue(submission.containsFile("prefix_streamFile"));
BeanDeclaration bean2 = submission.getNamedBean("bean1");
assertNotNull(bean2);
assertEquals(bean1, bean2);
}
public void testAddDuplicateParameter()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addParameter("parameter1", null);
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
try
{
submission.addParameter("parameter1", null);
fail();
}
catch (ParameterExistsException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getParameterName(), "parameter1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
}
public void testAddDuplicateFile()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addFile("file1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
try
{
submission.addFile("file1");
fail();
}
catch (FileExistsException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getFileName(), "file1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
}
public void testAddDuplicateNamedBean()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, null), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 1);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", "prefix_", null), "bean1");
fail();
}
catch (NamedSubmissionBeanExistsException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getBeanName(), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 1);
}
public void testAddBeanUnknownGroup()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, "unknown"), null);
}
catch (SubmissionBeanGroupNotFoundException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getClassName(), "com.uwyn.rife.engine.testelements.submission.BeanImpl");
assertEquals(e.getGroupName(), "unknown");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 0);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, "unknown"), "bean1");
}
catch (NamedSubmissionBeanGroupNotFoundException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getClassName(), "com.uwyn.rife.engine.testelements.submission.BeanImpl");
assertEquals(e.getGroupName(), "unknown");
assertEquals(e.getBeanName(), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 0);
}
public void testAddBeanGroupOnNonValidationClass()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanPojo", null, "thegroup"), null);
}
catch (SubmissionBeanGroupRequiresValidatedConstrainedException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getClassName(), "com.uwyn.rife.engine.testelements.submission.BeanPojo");
assertEquals(e.getGroupName(), "thegroup");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 0);
try
{
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanPojo", null, "thegroup"), "bean1");
}
catch (NamedSubmissionBeanGroupRequiresValidatedConstrainedException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getClassName(), "com.uwyn.rife.engine.testelements.submission.BeanPojo");
assertEquals(e.getGroupName(), "thegroup");
assertEquals(e.getBeanName(), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getBeanNames().size(), 0);
assertEquals(submission.getBeans().size(), 0);
}
public void testValidateBeanName()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.validateBeanName("bean1");
fail();
}
catch (NamedSubmissionBeanUnknownException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getBeanName(), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", null, null), "bean1");
try
{
submission.validateBeanName("bean1");
assertTrue(true);
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
}
public void testGetNamedBean()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.getNamedBean("bean1");
fail();
}
catch (NamedSubmissionBeanUnknownException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getBeanName(), "bean1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
submission.addBean(new BeanDeclaration("com.uwyn.rife.engine.testelements.submission.BeanImpl", "prf", null), "bean1");
try
{
assertEquals(submission.getNamedBean("bean1").getClassname(), "com.uwyn.rife.engine.testelements.submission.BeanImpl");
assertEquals(submission.getNamedBean("bean1").getPrefix(), "prf");
assertTrue(true);
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
}
public void testParameterRegexpConflict()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addParameterRegexp("parameterregexp(\\d+)");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
element.addInput("input1", null);
try
{
submission.addParameterRegexp("input(.*)");
fail();
}
catch (ParameterRegexpInputConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getInputName(), "input1");
assertEquals(e.getConflictName(), "^input(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
element.addIncookie("incookie1", null);
try
{
submission.addParameterRegexp("incookie(.*)");
fail();
}
catch (ParameterRegexpIncookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getIncookieName(), "incookie1");
assertEquals(e.getConflictName(), "^incookie(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
submission.addParameter("parameter1", null);
try
{
submission.addParameterRegexp("parameter(\\d+)");
fail();
}
catch (ParameterRegexpParameterConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getParameterName(), "parameter1");
assertEquals(e.getConflictName(), "^parameter(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
submission.addFile("file1");
try
{
submission.addParameterRegexp("file(\\d+)");
fail();
}
catch (ParameterRegexpFileConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getFileName(), "file1");
assertEquals(e.getConflictName(), "^file(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
element.setGlobalVars(new LinkedHashMap<String, GlobalVar>() {{ put("globalvar1", new GlobalVar(null)); }});
try
{
submission.addParameterRegexp("globalvar(.*)");
fail();
}
catch (ParameterRegexpGlobalVarConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getGlobalVarName(), "globalvar1");
assertEquals(e.getConflictName(), "^globalvar(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
element.setGlobalCookies(new LinkedHashMap<String, String>() {{ put("globalcookie1", null); }});
try
{
submission.addParameterRegexp("globalcookie(.*)");
fail();
}
catch (ParameterRegexpGlobalCookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getGlobalCookieName(), "globalcookie1");
assertEquals(e.getConflictName(), "^globalcookie(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterRegexps().size(), 1);
}
public void testParameterConflicts()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addParameter("parameter1", null);
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
element.addInput("input1", null);
try
{
submission.addParameter("input1", null);
fail();
}
catch (ParameterInputConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "input1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
element.addIncookie("incookie1", null);
try
{
submission.addParameter("incookie1", null);
fail();
}
catch (ParameterIncookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "incookie1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
submission.addFile("file1");
try
{
submission.addParameter("file1", null);
fail();
}
catch (ParameterFileConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "file1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 1);
submission.addParameterRegexp("regexpparameter(\\d+)");
try
{
submission.addParameter("regexpparameter1", null);
fail();
}
catch (ParameterParameterRegexpConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "regexpparameter1");
assertEquals(e.getParameterRegexp(), "^regexpparameter(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
submission.addFileRegexp("regexpfile(\\d+)");
try
{
submission.addParameter("regexpfile1", null);
fail();
}
catch (ParameterFileRegexpConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "regexpfile1");
assertEquals(e.getFileRegexp(), "^regexpfile(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
LinkedHashMap<String, GlobalVar> globals_vars = new LinkedHashMap<String, GlobalVar>();
globals_vars.put("globalvar1", new GlobalVar(null));
element = new ElementInfo("element/test2.xml", "text/html", TestElement2.class.getName(), ElementType.JAVA_CLASS);
element.setGlobalVars(globals_vars);
submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addParameter("globalvar1", null);
fail();
}
catch (ParameterGlobalVarConflictException e)
{
assertEquals(e.getDeclarationName(), "element/test2.xml");
assertEquals(e.getConflictName(), "globalvar1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 0);
LinkedHashMap<String, String> globals_cookies = new LinkedHashMap<String, String>();
globals_cookies.put("globalcookie1", null);
element = new ElementInfo("element/test2.xml", "text/html", TestElement2.class.getName(), ElementType.JAVA_CLASS);
element.setGlobalCookies(globals_cookies);
submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addParameter("globalcookie1", null);
fail();
}
catch (ParameterGlobalCookieConflictException e)
{
assertEquals(e.getDeclarationName(), "element/test2.xml");
assertEquals(e.getConflictName(), "globalcookie1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getParameterNames().size(), 0);
}
public void testFileRegexpConflict()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addFileRegexp("fileregexp(\\d+)");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
element.addInput("input1", null);
try
{
submission.addFileRegexp("input(.*)");
fail();
}
catch (FileRegexpInputConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getInputName(), "input1");
assertEquals(e.getConflictName(), "^input(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
element.addIncookie("incookie1", null);
try
{
submission.addFileRegexp("incookie(.*)");
fail();
}
catch (FileRegexpIncookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getIncookieName(), "incookie1");
assertEquals(e.getConflictName(), "^incookie(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
submission.addFile("file1");
try
{
submission.addFileRegexp("file(\\d+)");
fail();
}
catch (FileRegexpFileConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getFileName(), "file1");
assertEquals(e.getConflictName(), "^file(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
submission.addParameter("param1", null);
try
{
submission.addFileRegexp("param(\\d+)");
fail();
}
catch (FileRegexpParameterConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getParameterName(), "param1");
assertEquals(e.getConflictName(), "^param(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
element.setGlobalVars(new LinkedHashMap<String, GlobalVar>() {{ put("globalvar1", new GlobalVar(null)); }});
try
{
submission.addFileRegexp("globalvar(.*)");
fail();
}
catch (FileRegexpGlobalVarConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getGlobalVarName(), "globalvar1");
assertEquals(e.getConflictName(), "^globalvar(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
element.setGlobalCookies(new LinkedHashMap<String, String>() {{ put("globalcookie1", null); }});
try
{
submission.addFileRegexp("globalcookie(.*)");
fail();
}
catch (FileRegexpGlobalCookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getGlobalCookieName(), "globalcookie1");
assertEquals(e.getConflictName(), "^globalcookie(.*)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileRegexps().size(), 1);
}
public void testFileConflicts()
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addFile("file1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
element.addInput("input1", null);
try
{
submission.addFile("input1");
fail();
}
catch (FileInputConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "input1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
element.addIncookie("incookie1", null);
try
{
submission.addFile("incookie1");
fail();
}
catch (FileIncookieConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "incookie1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
submission.addParameter("parameter1", null);
try
{
submission.addFile("parameter1");
fail();
}
catch (FileParameterConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "parameter1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
submission.addParameterRegexp("regexpparameter(\\d+)");
try
{
submission.addFile("regexpparameter1");
fail();
}
catch (FileParameterRegexpConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "regexpparameter1");
assertEquals(e.getParameterRegexp(), "^regexpparameter(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
submission.addFileRegexp("regexpfile(\\d+)");
try
{
submission.addFile("regexpfile1");
fail();
}
catch (FileFileRegexpConflictException e)
{
assertSame(e.getDeclarationName(), "element/test4.xml");
assertEquals(e.getSubmissionName(), "submission1");
assertEquals(e.getConflictName(), "regexpfile1");
assertEquals(e.getFileRegexp(), "^regexpfile(\\d+)$");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 1);
LinkedHashMap<String, GlobalVar> globals_vars = new LinkedHashMap<String, GlobalVar>();
globals_vars.put("globalvar1", new GlobalVar(null));
element = new ElementInfo("element/test2.xml", "text/html", TestElement2.class.getName(), ElementType.JAVA_CLASS);
element.setGlobalVars(globals_vars);
submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addFile("globalvar1");
fail();
}
catch (FileGlobalVarConflictException e)
{
assertEquals(e.getDeclarationName(), "element/test2.xml");
assertEquals(e.getConflictName(), "globalvar1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 0);
LinkedHashMap<String, String> globals_cookies = new LinkedHashMap<String, String>();
globals_cookies.put("globalcookie1", null);
element = new ElementInfo("element/test2.xml", "text/html", TestElement2.class.getName(), ElementType.JAVA_CLASS);
element.setGlobalCookies(globals_cookies);
submission = new Submission();
element.addSubmission("submission1", submission);
try
{
submission.addFile("globalcookie1");
fail();
}
catch (FileGlobalCookieConflictException e)
{
assertEquals(e.getDeclarationName(), "element/test2.xml");
assertEquals(e.getConflictName(), "globalcookie1");
}
catch (EngineException e)
{
assertTrue(ExceptionUtils.getExceptionStackTrace(e), false);
}
assertEquals(submission.getFileNames().size(), 0);
}
public void testAddParameterDefaultValues()
throws EngineException
{
ElementInfo element = new ElementInfo("element/test4.xml", "/", TestElement4.class.getName(), ElementType.JAVA_CLASS);
Submission submission = new Submission();
element.addSubmission("submission1", submission);
assertTrue(false == submission.hasParameterDefaults());
submission.addParameter("parameter1", new String[] {"one","two"});
submission.addParameter("parameter2", new String[] {"three"});
submission.addParameter("parameter3", null);
assertTrue(submission.hasParameterDefaults());
assertTrue(submission.hasParameterDefaultValues("parameter1"));
assertTrue(submission.hasParameterDefaultValues("parameter2"));
assertTrue(false == submission.hasParameterDefaultValues("parameter3"));
assertNotNull(submission.getParameterDefaultValues("parameter1"));
assertNotNull(submission.getParameterDefaultValues("parameter2"));
assertNull(submission.getParameterDefaultValues("parameter3"));
assertEquals(2, submission.getParameterDefaultValues("parameter1").length);
assertEquals(1, submission.getParameterDefaultValues("parameter2").length);
assertEquals("one", submission.getParameterDefaultValues("parameter1")[0]);
assertEquals("two", submission.getParameterDefaultValues("parameter1")[1]);
assertEquals("three", submission.getParameterDefaultValues("parameter2")[0]);
}
}
class TestElement4 extends Element
{
public void processElement()
throws EngineException
{
print("the content");
}
}
| [
"gbevin@uwyn.com"
] | gbevin@uwyn.com |
0a7d097220ec5d1ac76a14655a6cd98b890deb17 | 7e81772967ca4bf1391903c9157253ded62988ad | /src/com/ptpl/controller/huifu/.svn/text-base/HuifuUserRechargeController.java.svn-base | 60614ea3ebfb7d7dba2650a11fc3f33de4ebc073 | [] | no_license | liangxiaozhen/myProject | 642f20d9e1634963c1bedf5e7dbae3454373bf43 | 9a8623e5e566b49a9e100d9d87bec521dc8bc895 | refs/heads/master | 2020-05-20T06:47:36.845266 | 2019-05-07T15:31:14 | 2019-05-07T15:31:14 | 185,431,510 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 18,285 | package com.ptpl.controller.huifu;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.huifu.util.SignUtils;
import com.huifu.util.httpClient.HttpClientHandler;
import com.ptpl.constant.Constant;
import com.ptpl.constant.Session_Constant;
import com.ptpl.constant.UserRecharge_Constant;
import com.ptpl.controller.BaseController;
import com.ptpl.model.AccInExRecord;
import com.ptpl.model.RechargeRstr;
import com.ptpl.model.UserAccount;
import com.ptpl.model.UserAccountSafeInfo;
import com.ptpl.model.UserBankCard;
import com.ptpl.model.UserBaseAccountInfo;
import com.ptpl.model.UserRecharge;
import com.ptpl.service.AccInExRecordServiceI;
import com.ptpl.service.RechargeRstrServiceI;
import com.ptpl.service.UserAccountSafeInfoServiceI;
import com.ptpl.service.UserAccountServiceI;
import com.ptpl.service.UserBankCardServiceI;
import com.ptpl.service.UserBaseAccountInfoServiceI;
import com.ptpl.service.UserRechargeServiceI;
import com.ptpl.web.util.Arith;
import com.ptpl.web.util.HuifuParams;
import com.ptpl.web.util.StringUtil;
@Controller
@RequestMapping("/HuifuUserRecharge")
public class HuifuUserRechargeController extends BaseController {
/** 充值记录*/
@Autowired
UserRechargeServiceI userRechargeService;
/** 用户基本信息 ServiceI */
@Autowired
UserBaseAccountInfoServiceI userBaseAccountInfoServiceI;
/**银行卡信息*/
@Autowired
UserBankCardServiceI userBankCardService;
/**用户账户表*/
@Autowired
UserAccountServiceI userAccountService;
/**用户收支明细记录*/
@Autowired
AccInExRecordServiceI accInExRecordService;
@Autowired
UserAccountSafeInfoServiceI userAccountSafeInfoService;
@Autowired
RechargeRstrServiceI rechargeRstrService;
/*CmdId +RespCode + MerCustId + UsrCustId + OrdId+OrdDate + TransAmt + TrxId + RetUrl+BgRetUrl+ MerPriv*/
/**
* 充值汇付返回
* @Title: userRechargeCallback
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param request
* @param @param response
* @param @param huifuParams 参数说明
* @return void 返回类型
* @author jiangxueyou
* @throws
*/
@SuppressWarnings("unused")
@RequestMapping(value="/UserRechargeCallback")
public synchronized void userRechargeCallback(HttpServletRequest request,HttpServletResponse response,HuifuParams huifuParams){
System.out.println("CallBack");
try {
UserBaseAccountInfo userBaseAccountInfo = (UserBaseAccountInfo) request.getSession().getAttribute(Session_Constant.USER);
//解密私有域
String merPriv =HttpClientHandler.getBase64Decode(huifuParams.getMerPriv());
if(userBaseAccountInfo == null){
userBaseAccountInfo = userBaseAccountInfoServiceI.getUserBaseAccountInfoById(new BigDecimal(merPriv)); // 根据id获取用户基本信息
}
BigDecimal baseid = (BigDecimal) (userBaseAccountInfo.getId() == null ? merPriv : userBaseAccountInfo.getId());
//获取用户账户信息安全对象
UserAccountSafeInfo usf = userAccountSafeInfoService.selectByBaseId(baseid);
/*返回值拼接*/
StringBuffer sb = new StringBuffer();
sb.append(StringUtils.trimToEmpty(huifuParams.getCmdId())).append(StringUtils.trimToEmpty(huifuParams.getRespCode()))
.append(StringUtils.trimToEmpty(huifuParams.getMerCustId())).append(StringUtils.trimToEmpty(huifuParams.getUsrCustId()))
.append(StringUtils.trimToEmpty(huifuParams.getOrdId())).append(StringUtils.trimToEmpty(huifuParams.getOrdDate()))
.append(StringUtils.trimToEmpty(huifuParams.getTransAmt())).append(StringUtils.trimToEmpty(huifuParams.getTrxId()))
.append(StringUtils.trimToEmpty(huifuParams.getRetUrl())).append(StringUtils.trimToEmpty(huifuParams.getBgRetUrl()))
.append(StringUtils.trimToEmpty(huifuParams.getMerPriv()));
String plainStr = sb.toString();
System.out.println(plainStr);
boolean flag = false;
flag = SignUtils.verifyByRSA(plainStr, huifuParams.getChkValue());
if (!flag) {
System.out.println("验证签名失败...");
}
if (StringUtils.isNotBlank(huifuParams.getOrdId())) {
PrintWriter out = response.getWriter();
out.print("RECV_ORD_ID_".concat(huifuParams.getOrdId()));
}
if(flag && "000".equals(huifuParams.getRespCode())){ //解签成功
//根据登录的用户,根据baseid查询到时什么会员等级,再根据会员等级和充值方式和是否启用查询当前用户在充值设置表中是设置的是自付还是他付
RechargeRstr rechargeRstr = new RechargeRstr();
if(huifuParams.getGateBusiId().equals("B2C")){//个人网银
rechargeRstr.setRechartype((short)1);
}
if(huifuParams.getGateBusiId().equals("B2B")){//企业网银
rechargeRstr.setRechartype((short)2);
}
if(huifuParams.getGateBusiId().equals("QP")){//快捷
rechargeRstr.setRechartype((short)3);
}
String ugrade = StringUtil.getIndex(usf.getUgrade());
rechargeRstr.setUgrade(ugrade);
rechargeRstr.setIsuse((short)1);//表示已经启用
RechargeRstr rstr = rechargeRstrService.getUgradeAndRecharTypeAndIsuseForRechargeRstr(rechargeRstr);
String feeObj = "";
if(rstr!=null){
if(rstr.getSelfpayratio()==100){//充值人自付比例为100%的时候就是自付
feeObj="U";
}
if(rstr.getProxypayratio()==100){
feeObj="M";
}
}else{//假如充值设置表中没有找到相应的记录,就默认手续费收取对象是商户
feeObj="M";
}
System.out.println(System.currentTimeMillis()+"接收时间-------------------------");
UserRecharge userR = new UserRecharge();
userR.setRechargeno(huifuParams.getOrdId());
userR.setBankreturnno(huifuParams.getTrxId());
UserRecharge userRechargeGet = userRechargeService.getBankReturnNo(userR);//防止重复充值生成重复的收支记录
if(userRechargeGet==null){
UserAccount userAccount = userAccountService.getUserAccountByBaseId(baseid);
AccInExRecord accInExRecord = new AccInExRecord();//存收支记录的对象
AccInExRecord accInExRecord2 = new AccInExRecord();//存手续费记录的对象
//冻结余额
double freezebalance = 0;
//可用余额
double avlbalance = 0;
double avlbalanceK = 0;//可用余额
double balanceZ = 0; //总资产
if(userAccount!=null){
//冻结金额
freezebalance = userAccount.getFreezebalance();
//可用余额
avlbalance = userAccount.getAvlbalance();
}
//充值金额
double amount = Double.valueOf(huifuParams.getTransAmt());
//充值手续费
double feeamount = Double.valueOf(huifuParams.getFeeAmt());
//充值的时候直接先不算
avlbalanceK = Arith.add(avlbalance,amount);//可用余额
balanceZ = Arith.add(avlbalanceK,freezebalance);//总金额=可用余额+冻结金额
//存入收支记录
Date date = new Date();
accInExRecord.setOutamount(0.0);//用户支出
accInExRecord.setStatus((short)1);
accInExRecord.setTotalbalance(balanceZ);//用户总金额
accInExRecord.setFreebalance(freezebalance);//冻结金额
accInExRecord.setBaseid(baseid);
accInExRecord.setType((short)1);//type 为1 表示业务类型为充值
accInExRecord.setInamount(amount);//用户收入
accInExRecord.setBalance(avlbalanceK);//可用余额
accInExRecord.setRecordtime(date);//时间
accInExRecord.setAieorderno(StringUtil.getNo()); //保存收支明细流水号
accInExRecord.setDescription("充值说明");
accInExRecord.setRemark("备注");
System.out.println(System.currentTimeMillis()+"插入时间-------------------------");
accInExRecordService.insertSelective(accInExRecord);
if(userAccount==null){//假如数据库没有这条数据的话就直接插入
userAccount = new UserAccount();
if(feeObj.equals("M")){//充值手续费为他付,也就是扣平台的钱
userAccount.setBaseid(baseid);
userAccount.setBalance(balanceZ);
userAccount.setAvlbalance(avlbalanceK);
userAccount.setFreezebalance(freezebalance);
userAccount.setBaseid(baseid);
}else if(feeObj.equals("U")){//充值手续费为自付
userAccount.setBaseid(baseid);
userAccount.setBalance(Arith.add(Arith.sub(avlbalanceK,feeamount), freezebalance));
userAccount.setAvlbalance(Arith.sub(avlbalanceK,feeamount));
userAccount.setFreezebalance(freezebalance);
userAccount.setBaseid(baseid);
}
userAccountService.insert(userAccount);
}else{//假如数据库有这条数据就修改
if(feeObj.equals("M")){//充值手续费为他付,也就是扣平台的钱
userAccount.setBaseid(baseid);
userAccount.setBalance(balanceZ);
userAccount.setAvlbalance(avlbalanceK);
userAccount.setFreezebalance(freezebalance);
userAccount.setBaseid(baseid);
}else if(feeObj.equals("U")){//充值手续费为自付
userAccount.setBaseid(baseid);
userAccount.setBalance(Arith.add(Arith.sub(avlbalanceK,feeamount), freezebalance));
userAccount.setAvlbalance(Arith.sub(avlbalanceK,feeamount));
userAccount.setFreezebalance(freezebalance);
userAccount.setBaseid(baseid);
}
userAccountService.updateUseraccount(userAccount);
}
//存手续费记录的
if(feeObj.equals("M")){
accInExRecord2.setPinamount(0.0);//表示金额为平台收入
accInExRecord2.setPoutamount(feeamount);//表示金额为平台支出
accInExRecord2.setTotalbalance(balanceZ);//用户总金额
accInExRecord2.setBalance(avlbalanceK);//可用余额
accInExRecord2.setOutamount(0.0);//充值手续费为0
accInExRecord2.setInamount(0.0);//用户收入
}
//表示扣款的是用户
if(feeObj.equals("U")){
accInExRecord2.setPinamount(0.0);//表示金额为平台收入
accInExRecord2.setPoutamount(0.0);//表示金额为平台支出
accInExRecord2.setInamount(0.0);//用户收入
accInExRecord2.setOutamount(feeamount);//表示手续费金额为用户自己给 Arith.sub(amount, feeamount);
balanceZ = Arith.add(Arith.sub(avlbalanceK,feeamount), freezebalance);//重新为总金额赋值
avlbalanceK = Arith.sub(avlbalanceK,feeamount);//重新为可用余额赋值
accInExRecord2.setTotalbalance(balanceZ);//假如扣款客户是用户自己,那么用户总金额=(可用余额-手续费)+冻结金额
accInExRecord2.setBalance(avlbalanceK);//可用余额
}
accInExRecord2.setRecordtime(date);
accInExRecord2.setType((short)2);
accInExRecord2.setStatus((short)1);
accInExRecord2.setFreebalance(freezebalance);//冻结余额
accInExRecord2.setBaseid(baseid);
accInExRecord2.setAieorderno(StringUtil.getNo()); //保存收支明细流水号
accInExRecord2.setDescription("充值手续费说明");
accInExRecord2.setRemark("充值手续费备注");
/*if(feeamount!=0 || feeObj.equals("M")){//手续费为0或者手续费是平台付的时候就不插入手续费记录
accInExRecordService.insertSelective(accInExRecord2);
}*/
if(feeObj.equals("U") && feeamount!=0){//手续费不为0并且者手续费是自付的时候才插入手续费记录
accInExRecordService.insertSelective(accInExRecord2);
}
updateRecharge(huifuParams,userBaseAccountInfo,baseid);
}
}else{
System.out.println(huifuParams.getRespDesc()+"***********************");
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 保存充值记录(修改请求的时候保存的充值记录,把充值状态给改了);
* @param huifuParams
* @param userBaseAccountInfo
* @throws Exception
*/
private void updateRecharge(HuifuParams huifuParams,UserBaseAccountInfo userBaseAccountInfo,BigDecimal baseid) throws Exception {
//根据订单号查询本地数据库的值
UserRecharge userRecharge = userRechargeService.select(huifuParams.getOrdId());
userRecharge.setEndtime(new Date());//充值结束时间
if(huifuParams.getGateBusiId().equals("B2C") || huifuParams.getGateBusiId().equals("B2B")){ //表示网银
}
if(huifuParams.getGateBusiId().equals("QP")){//表示快捷
UserBankCard userBankCard2 = new UserBankCard();
userBankCard2.setBaseid(baseid);
userBankCard2.setIsfastbindcard((short)2);
userBankCardService.findIsFastBindCard(userBankCard2);
if(userBankCardService.findIsFastBindCard(userBankCard2)==null){
DepositUserBankCard(userBaseAccountInfo,huifuParams);
}
}
if(huifuParams.getRespCode().equals("000")){
userRecharge.setStatus(UserRecharge_Constant.STATUS_ONE);//充值状态
userRecharge.setBankreturnno(huifuParams.getTrxId()); //银行返回充值订单号
userRecharge.setOriginclient(userBaseAccountInfo.getOriginclient());//充值来源 pc/手机
userRecharge.setRecharfee(Double.valueOf(huifuParams.getFeeAmt())); //充值手续费
Double recharRate = Double.valueOf(huifuParams.getFeeAmt())/100;
userRecharge.setRecharrate(recharRate); //充值费率
userRecharge.setRemark("充值成功");
userRecharge.setCardno(huifuParams.getCardId());//快捷充值的时候的卡号
userRecharge.setEndtime(new Date());//充值结束时间
userRechargeService.update(userRecharge);
}
}
/**把相关数据存进UserBankCard数据库
* @throws Exception */
public void DepositUserBankCard(UserBaseAccountInfo userBaseAccountInfo,HuifuParams huifuParams) throws Exception{
QueryCardInfoController queryCard = new QueryCardInfoController();
UserBankCard userBankCard = new UserBankCard();
Map<String, String> result = queryCard.getBankCardParams(huifuParams);
String result2 = queryCard.doBankCardPost(result);
JSONObject jsonObj = JSON.parseObject(result2);
JSONArray resultJson = jsonObj.getJSONArray("UsrCardInfolist");
JSONObject jsObj = resultJson.getJSONObject(0);
String CardId = jsObj.getString("CardId"); //卡号
String BankId = jsObj.getString("BankId"); //银行卡代号0
String ExpressFlag = jsObj.getString("ExpressFlag"); //是都是快捷卡标志 Y 是 N不是
String UpdDateTime = jsObj.getString("UpdDateTime"); //绑定时间
String RespCode = jsonObj.getString("RespCode"); //标识成功与否
Date startDate = new SimpleDateFormat("yyyyMMddhhmmss").parse(UpdDateTime); //处理绑定时间
huifuParams.setDcFlag("D");
if(RespCode.equals("000")){//标识绑卡成功
/*cardtype卡类型为1储蓄卡 username 真实姓名(realName) bindtime 绑卡时间 bindmode绑卡方式为1 bindstatus绑定状态为1 paycompany绑定通道为“汇付天下” 存进去*/
if(huifuParams.getDcFlag().equals("D")){//储蓄卡
userBankCard.setCardtype(Constant.CARDTYPE_JIEJIKA); //借记卡
}
userBankCard.setCardtype(Constant.CARDTYPE_XINYONGKA); //信用卡
if(ExpressFlag.equals("Y")){
userBankCard.setIsfastbindcard(Constant.ISFASTBINDCARD_KUAIJIE); //userBankCard表中快捷卡的标识
}
userBankCard.setBindstatus(Constant.BINDSTATUS_BIND);//表示已经绑定
userBankCard.setIsdefaultcard(Constant.ISDEFAULTCARD_YES); //是默认卡
userBankCard.setUsername(userBaseAccountInfo.getRealname()); //保存真是姓名
userBankCard.setBindtime(startDate);
userBankCard.setBindmode(Constant.BINDMODE_JIEKOU);//绑卡方式 接口
userBankCard.setPaycompany("汇付天下");
userBankCard.setBaseid(userBaseAccountInfo.getId());
userBankCard.setBankname(Constant.BANK_MAP.get(BankId));//银行代号
userBankCard.setCardno(CardId); // 银行卡号
userBankCardService.insertSelective(userBankCard);
userBankCard.setBindstatus((short) 2);
userBankCardService.updateBindStatus(userBankCard);//修改其余卡的绑定状态:已解绑
}
}
//回调网页地址
@RequestMapping(value = "/reCallback", method = {RequestMethod.POST})
public ModelAndView recallBack(HttpServletRequest request, HttpServletResponse response,
HuifuParams params) throws Exception{
String ordId = params.getOrdId();
String transAmt = params.getTransAmt();
String feeAmt = params.getFeeAmt();
String rechargeType = UserRecharge_Constant.BANK_MAP.get(params.getGateBankId());
String starttime = params.getOrdDate();
ModelAndView mav = new ModelAndView();
mav.addObject("ordId", ordId);
mav.addObject("transAmt", transAmt);
mav.addObject("feeAmt", feeAmt);
mav.addObject("rechargeType", rechargeType);
mav.addObject("respdesc", params.getRespDesc());
mav.addObject("starttime", starttime);
System.out.println(params.getRespDesc()+"*********************");
mav.setViewName("/user/recharge/recallback");
return mav;
}
}
| [
"liangxiaozhen@aliyun.com"
] | liangxiaozhen@aliyun.com | |
954d8a0ee1edabf66d0a6251cce880039be212d5 | cf3c03f5f7f89704bb3fa9361a76742dd8a8f978 | /src/com/skilldistillery/blackjack/Player.java | 24ffe28acc71782a4095b2b005a29ea545ffa11e | [] | no_license | jacobshorterivey/BlackjackProject | 241fa669644302d625639692002ac86e25c07d3a | 1687fcdb6cbdc2de4fd7333a694bd9c24bd43ba4 | refs/heads/master | 2020-08-06T07:34:51.937899 | 2019-10-26T18:33:32 | 2019-10-26T18:33:32 | 212,892,299 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 118 | java | package com.skilldistillery.blackjack;
public class Player extends Participant {
public Player() {
super();
}
}
| [
"jacobshorterivey@gmail.com"
] | jacobshorterivey@gmail.com |
4cc69a2f51a9dba09060fba78f85b558513f511f | 795cc15f77648c168adde23807b4ad068e00d0d4 | /app/src/main/java/my/edu/tarc/lab2intent/SecondActivity.java | 44ee2a4b64d350366ebe33cac88a7ba01c82c758 | [] | no_license | wongwy1998/Lab2Intent | b827bdb890edbd218e0b91124a125e77d07316fe | c95fd6b21d2af838aa50a9ec4530ad7097a0e30f | refs/heads/master | 2020-04-02T17:02:50.102768 | 2018-10-25T09:04:46 | 2018-10-25T09:04:46 | 154,641,087 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,593 | java | package my.edu.tarc.lab2intent;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class SecondActivity extends AppCompatActivity {
public static final String REPLY_TAG = "my.edu.tarc.lab2intent.REPLY" ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
String stringMsg;
TextView textViewMsg= findViewById(R.id.textViewMessage);
//Create an instance of the Intent
Intent intent=getIntent();//who called me?
if(intent.hasExtra(MainActivity.MESSAGE_TAG)){
stringMsg = intent.getStringExtra(MainActivity.MESSAGE_TAG);
// int age = intent.getIntExtra("TAG_AGE",0);
textViewMsg.setText(stringMsg);
}
}
public void sendReply(View view){
EditText editTextReply;
editTextReply = findViewById(R.id.editTextMessage);
if(TextUtils.isEmpty(editTextReply.getText())){
editTextReply.setError(getString(R.string.error_reply));
return;
}
String stringReply = editTextReply.getText().toString();
//create an instance of the Intent
Intent intent = new Intent();
//pass value tp intent
intent.putExtra(REPLY_TAG,stringReply);
//set result to OK
setResult(RESULT_OK,intent);
finish();
}
}
| [
"wongwy-wa16@student.tarc.edu.my"
] | wongwy-wa16@student.tarc.edu.my |
93023f01010556f8d0baeaa45df368c65185ad2a | 770873ac701cb8c05b0dd67bb0ab594afc51ad2e | /introduction to java/su_dung_toan_tu/src/App.java | a0625d80599fa9b59b63a43c7a2ec08c154efcb1 | [] | no_license | Tam250399/module_2 | d7d068a41e89b0587d3e846b477a2d9c10de5d30 | 43d3240574c0f28511bf8494a58e8171c41c578b | refs/heads/master | 2023-02-26T00:08:48.267122 | 2021-02-01T16:25:37 | 2021-02-01T16:25:37 | 327,562,768 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | import java.util.Scanner;
public class App {
public static void main(String[] args) throws Exception {
float width;
float height;
Scanner sc = new Scanner(System.in);
System.out.println("Enter width");
width = sc.nextFloat();
System.out.println("Enter height");
height = sc.nextFloat();
float area = width * height;
System.out.println("Area is: " + area);
}
}
| [
"tamthanhsk25@gmail.com"
] | tamthanhsk25@gmail.com |
7ae3f6486c35189c1a71cbe2a7e4fbfc25eb6227 | 968d346a6bb1aabe50c42d81f1cbddbb5ff2aff0 | /src/syntax/analyser/parser/ParserKeyword.java | 26be9271090b87e7b3e127f40dfaf30406909862 | [] | no_license | smoly87/OnefoldMachine | 59335b1c5af0d7daa9f676d3215b6986dc9db96c | 7efeebc6e54df8e0452d928befc69d40bce76670 | refs/heads/master | 2020-03-18T10:30:16.252354 | 2018-05-23T19:38:38 | 2018-05-23T19:38:38 | 134,616,344 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,022 | 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 syntax.analyser.parser;
import common.Token;
import lexer.LexerResult;
import syntax.analyser.AstNode;
import syntax.analyser.Parser;
/**
*
* @author Andrey
*/
public class ParserKeyword extends Parser{
protected String keyword;
public ParserKeyword(String keyword){
this.keyword = keyword;
}
@Override
public boolean parseLexerResult(LexerResult lexerResults) {
Token token = lexerResults.getCurToken();
String name = lexerResults.getCurToken().getName();
if( name.equals(this.keyword) ) {
AstNode resNode = new AstNode();
resNode.setToken(token);
setParseResult(resNode);
if(lexerResults.hasNext()) lexerResults.next();
return true;
}
return false;
}
}
| [
"smoly87@gmail.com"
] | smoly87@gmail.com |
d2e2902cb8e857d4fd0732d747f413496b731139 | 27076654648abf4e0e8a3f626968ab2562f92254 | /src/com/wxf/mobilesafe/db/bean/ProcessInfo.java | 160a55a36e8b11c06c8bf746067f545904574487 | [] | no_license | Mr-wxf/mobilesafe | 8153ffbb9986f6b1c0f4f379fdd14a931c714c4b | f54671e4a31f02883cdd2f9db21e6e3bde5e92e6 | refs/heads/master | 2021-01-10T18:50:06.447358 | 2016-12-14T08:26:34 | 2016-12-14T08:26:34 | 76,438,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 998 | java | package com.wxf.mobilesafe.db.bean;
import android.graphics.drawable.Drawable;
public class ProcessInfo {
public String name;
public Drawable icon;
public long memSize;
public boolean isCheck;
public boolean isSystem;
public String packageName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Drawable getIcon() {
return icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public long getMemSize() {
return memSize;
}
public void setMemSize(long memSize) {
this.memSize = memSize;
}
public boolean isCheck() {
return isCheck;
}
public void setCheck(boolean isCheck) {
this.isCheck = isCheck;
}
public boolean isSystem() {
return isSystem;
}
public void setSystem(boolean isSystem) {
this.isSystem = isSystem;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
}
| [
"359246382@qq.com"
] | 359246382@qq.com |
1db188fab15d9b1dcfd78a9700d686a21dcd11df | 051cbb67a8b4899bf22d00eca56b6eaf0fd600ea | /app/src/main/java/br/com/diaristaslimpo/limpo/to/FormularioDiaristaTo.java | 30ca7d88d63cdbfff5f536b48eaaec94031b0ba9 | [] | no_license | HugoTakahashi/DiaristaApp | 0d0f0155f081cc2b8a9be37eab714c494b17e725 | e62f26a362b452e2e1191b544ef74b2bc266bb1f | refs/heads/master | 2020-06-21T09:28:45.841745 | 2016-12-13T00:57:12 | 2016-12-13T00:57:12 | 74,795,070 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,025 | java | package br.com.diaristaslimpo.limpo.to;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
import br.com.diaristaslimpo.limpo.util.MaskUtil;
/**
* Created by Hugo on 14/11/2016.
*/
public class FormularioDiaristaTo implements Serializable {
private String nome, sobrenome, dataNascimento, cpf, email, senha, confirmacaoSenha, celular, genero;
private int id;
public FormularioDiaristaTo(){
}
public FormularioDiaristaTo(String nome, String sobrenome, String dataNascimento, String cpf, String email, String senha, String confirmacaoSenha, String celular, String genero) {
setNome(nome);
setSobrenome(sobrenome);
setDataNascimento(dataNascimento);
setCpf(cpf);
setEmail(email);
setSenha(senha);
setConfirmacaoSenha(confirmacaoSenha);
setCelular(celular);
setGenero(genero);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSobrenome() {
return sobrenome;
}
public void setSobrenome(String sobronome) {
this.sobrenome = sobronome;
}
public String getDataNascimento() {
return dataNascimento;
}
public void setDataNascimento(String dataNascimento) {
this.dataNascimento = dataNascimento;
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getConfirmacaoSenha() {
return confirmacaoSenha;
}
public void setConfirmacaoSenha(String confirmacaoSenha) {
this.confirmacaoSenha = confirmacaoSenha;
}
public String getCelular() {
return celular;
}
public void setCelular(String celular) {
this.celular = celular;
}
public String getGenero() {
return genero;
}
public void setGenero(String genero) {
this.genero = genero;
}
@Override
public String toString() {
JSONObject json = new JSONObject();
try {
json.put("Id", id);
json.put("Nome", nome);
json.put("Sobrenome", sobrenome);
json.put("DataNascimento", dataNascimento);
json.put("Cpf", MaskUtil.unmask(cpf));
json.put("Email", email);
json.put("Senha", senha);
json.put("Celular", MaskUtil.unmask(celular));
json.put("Genero", genero);
} catch (JSONException e1) {
e1.printStackTrace();
}
return String.valueOf(json);
}
} | [
"hugo_takahashi@yahoo.com"
] | hugo_takahashi@yahoo.com |
18f3b3ee66580f3a53447557b4c99132dd8cbd2f | f2a59e49ef7373db042e5c4dfa1571e49f5949cd | /src/main/java/com/pyp/protect/controller/SubsController.java | bd9500279ba027f2df1d4c228a0047933e363e7c | [] | no_license | vkesharwal/protect | 6ec012b6b236315809aea25006ee42609dd78c32 | 262aab4f0656b649cedba5e75bf543ecb12a92d7 | refs/heads/master | 2023-08-14T19:36:09.667526 | 2021-10-09T17:21:00 | 2021-10-09T17:21:00 | 415,334,707 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,340 | java | package com.pyp.protect.controller;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pyp.protect.entities.Subscribers;
import com.pyp.protect.pk.SubscriberPK;
import com.pyp.protect.services.SubscriberService;
@RestController
public class SubsController {
@Autowired
private SubscriberService subServices;
protected final Log logger = LogFactory.getLog(getClass());
@GetMapping("/subcribers/checkService")
public String serviceUp() {
return "OK";
}
@GetMapping("/subs/all")
public List<Subscribers> getAllSubs() {
return subServices.getSubscribers();
}
@GetMapping("/subs/{emailId}/{mobileNum}")
public Subscribers getSubsciber(@PathVariable String emailId,@PathVariable String mobileNum) {
SubscriberPK subPk = new SubscriberPK(emailId, mobileNum);
logger.info(emailId+" "+mobileNum);
return subServices.getSubscriber(subPk);
}
@PostMapping("/subs/addSub")
public Subscribers addSubscribers(@RequestBody Subscribers subs) {
logger.info(subs.toString());
return subServices.addSubscribers(subs);
}
@PutMapping("/subs/update")
public Subscribers updateSubscribers(@RequestBody Subscribers subs) {
return subServices.updateSubscriber(subs);
}
@DeleteMapping("/subs/delete/{emailId}/{mobileNum}")
public ResponseEntity<HttpStatus> deleteSub(@PathVariable String emailId,@PathVariable String mobileNum) {
try {
SubscriberPK subPk = new SubscriberPK(emailId, mobileNum);
subServices.deleteSubscriber(subPk);
return new ResponseEntity<>(HttpStatus.OK);
}
catch(Exception e){
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
| [
"vishalkesharwal10@gmail.com"
] | vishalkesharwal10@gmail.com |
32134c3aae09566611443a8d03751dd96860a7d4 | 84714ec1201114756324e4dca8f3730736f032a4 | /src/test/java/org/minimalj/util/DateUtilsTest.java | 67e063f978ca6e9d2f0c29477e37597621fb55d9 | [
"Apache-2.0"
] | permissive | BrunoEberhard/minimal-j | 5e896f244bcce11dbac5b4b2612814b877332fa2 | 6173c9ace6dcfc4232f31c47cc8286352a12a4ca | refs/heads/master | 2023-08-29T02:45:08.860372 | 2023-07-08T04:55:34 | 2023-07-08T04:55:34 | 33,410,104 | 19 | 4 | Apache-2.0 | 2023-07-08T04:55:35 | 2015-04-04T15:27:40 | Java | UTF-8 | Java | false | false | 3,440 | java | package org.minimalj.util;
import org.junit.Assert;
import org.junit.Test;
public class DateUtilsTest {
@Test
public void parseCH_01_02_1944() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("01.02.1944", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("01.02.1944", false));
}
@Test
public void parseCH_1_02_1944() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.02.1944", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.02.1944", false));
}
@Test
public void parseCH_1_2_1944() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.2.1944", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.2.1944", false));
}
@Test
public void parseCH_1_2_22() {
Assert.assertEquals("2022-02-01", DateUtils.parseCH("1.2.22", true));
Assert.assertEquals("2022-02-01", DateUtils.parseCH("1.2.22", false));
}
@Test
public void parseCH_1_2_44() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.2.44", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("1.2.44", false));
}
@Test
public void parseCH_7_8_2010() {
Assert.assertEquals("2010-08-07", DateUtils.parseCH("7.8.2010", true));
Assert.assertEquals("2010-08-07", DateUtils.parseCH("7.8.2010", false));
}
@Test
public void parseCH_10_8_2010() {
Assert.assertEquals("2010-08-10", DateUtils.parseCH("10.8.2010", true));
Assert.assertEquals("2010-08-10", DateUtils.parseCH("10.8.2010", false));
}
@Test
public void parseCH_10_8_10() {
Assert.assertEquals("2010-08-10", DateUtils.parseCH("10.8.10", true));
Assert.assertEquals("2010-08-10", DateUtils.parseCH("10.8.10", false));
}
@Test
public void parseCH_1_2_13() {
Assert.assertEquals("2013-02-01", DateUtils.parseCH("1.2.13", true));
Assert.assertEquals("2013-02-01", DateUtils.parseCH("1.2.13", false));
}
@Test
public void parseCH_01_02_13() {
Assert.assertEquals("2013-02-01", DateUtils.parseCH("01.02.13", true));
Assert.assertEquals("2013-02-01", DateUtils.parseCH("01.02.13", false));
}
@Test
public void parseCH_010213() {
Assert.assertEquals("2013-02-01", DateUtils.parseCH("010213", true));
Assert.assertEquals("2013-02-01", DateUtils.parseCH("010213", false));
}
@Test
public void parseCH_010244() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("010244", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("010244", false));
}
@Test
public void parseCH_01021944() {
Assert.assertEquals("1944-02-01", DateUtils.parseCH("01021944", true));
Assert.assertEquals("1944-02-01", DateUtils.parseCH("01021944", false));
}
@Test
public void parseCH_1899() {
Assert.assertEquals("1899", DateUtils.parseCH("1899", true));
}
@Test
public void parseCH_1899_Not_Part() {
Assert.assertEquals("", DateUtils.parseCH("1899", false));
}
@Test
public void parseCH_1901() {
Assert.assertEquals("1901-02", DateUtils.parseCH("02.1901", true));
}
@Test
public void parseCH_1901_Not_Part() {
Assert.assertEquals("", DateUtils.parseCH("02.1901", false));
}
@Test
public void parseCH_091274() {
Assert.assertEquals("1974-12-09", DateUtils.parseCH("091274", true));
Assert.assertEquals("1974-12-09", DateUtils.parseCH("091274", false));
}
@Test
public void parseCH_09121974() {
Assert.assertEquals("1974-12-09", DateUtils.parseCH("09121974", true));
Assert.assertEquals("1974-12-09", DateUtils.parseCH("09121974", false));
}
}
| [
"bruno.eberhard@pop.ch"
] | bruno.eberhard@pop.ch |
2b2d23bd500beeaedd0f98da7e915652ab097609 | 60b29520d669097348c2a5b5e781c3a7dde008d9 | /src/main/java/KeyboardInput.java | e69744e2b424a4101c1254870e627c60ba6ff8cb | [] | no_license | mikelumley/Yatzy | 6f32200b7f2d0939c8aa7fdd00a2d3731098c001 | 17ca6d11d61d4baeeac7872a588dc601b0b8cce9 | refs/heads/master | 2020-07-04T11:51:17.139553 | 2019-08-22T00:30:40 | 2019-08-22T00:30:40 | 202,279,868 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 243 | java | import java.util.Scanner;
public class KeyboardInput implements IKeyboardInput {
private Scanner keyboardInput = new Scanner(System.in);
@Override
public String nextLine() {
return this.keyboardInput.nextLine();
}
}
| [
"michael.lumley@myob.com"
] | michael.lumley@myob.com |
3dca3f658fb34a67ef98d46d02576f2fe76ea28b | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i49780.java | ac7a54fd84834b6db139bfd88af29a7c1640860b | [] | no_license | vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 69 | java | package number_of_direct_superinterfaces;
public interface i49780 {} | [
"vincentlee.dolbydigital@yahoo.com"
] | vincentlee.dolbydigital@yahoo.com |
3463fe42c18dda7b039bd0200e9ad17297d6bd2c | ef101dcf77a1024ffea20ad10b93898843d3e672 | /src/java基础/多线程/forkJoinPool/countDownLatchTest.java | 770987e57e900dbf51db0b6eb3f4dbcf01969041 | [] | no_license | gaoweijie/interviewDemo | 3fa0bf5e89d2fbbdab241d778ae35235606c5a40 | 498f0f85806589dcee797886eaba4f55d129eeb2 | refs/heads/master | 2022-11-27T06:36:26.492259 | 2020-08-03T14:47:45 | 2020-08-03T14:47:45 | 263,676,342 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,063 | java | package java基础.多线程.forkJoinPool;
import java.util.concurrent.CountDownLatch;
/**
* PROJECT_NAME:downLoad
* Author:lucaifang
* Date:2016/3/18
*/
public class countDownLatchTest {
public static void main(String[] args) throws InterruptedException {
CountDownLatch countDownLatch = new CountDownLatch(5);
for (int i = 0; i < 5; i++) {
new Thread(new readNum(i, countDownLatch)).start();
}
countDownLatch.await();
System.out.println("线程执行结束。。。。");
}
static class readNum implements Runnable {
private int id;
private CountDownLatch latch;
public readNum(int id, CountDownLatch latch) {
this.id = id;
this.latch = latch;
}
@Override
public void run() {
synchronized (this) {
System.out.println("id:" + id);
latch.countDown();
System.out.println("线程组任务" + id + "结束,其他任务继续");
}
}
}
} | [
"996760024@qq.com"
] | 996760024@qq.com |
6616da1b93e13b3225464410bd82fcb3c4b298fa | 11007b48b9a93aa21f146f66e867e1d76da8e934 | /spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Into.java | 3f3da827beea5ffe7f9f5702f01596bbbbb869a7 | [
"Apache-2.0"
] | permissive | lovelace-mmqs2020/spring-data-jdbc-mmqs | 02613c162f330dca456881900d25747d6494831f | b66d64ce9d3d1869dee65b0e36bfb52676faeafd | refs/heads/master | 2023-02-18T05:36:33.553705 | 2021-01-21T23:56:15 | 2021-01-21T23:56:15 | 323,690,674 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,549 | java | /*
* Copyright 2019-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.relational.core.sql;
import java.util.Arrays;
import java.util.List;
import org.springframework.util.StringUtils;
/**
* {@code INTO} clause.
*
* @author Mark Paluch
* @since 1.1
*/
public class Into extends AbstractSegment {
private final List<Table> tables;
Into(Table... tables) {
this(Arrays.asList(tables));
}
Into(List<Table> tables) {
super(tables.toArray(new Table[] {}));
this.tables = tables;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "INTO " + StringUtils.collectionToDelimitedString(tables, ", ");
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (this.getClass() != obj.getClass()) return false;
Into other = (Into) obj;
return tables.equals(other.tables);
}
@Override
public int hashCode() {
return tables.hashCode();
}
}
| [
"alexmik95@gmail.com"
] | alexmik95@gmail.com |
062388ad376935ea5793aef61f416f8bf686ad9c | 40276abd694a7cd8e906030aeeecb8ce0afe4af4 | /src/main/java/com/akqid/zblog/controller/admin/AdminPartnerController.java | 523c5f80ec06973c1850f6b5d743ca86696b272f | [] | no_license | JaquelineFu/Bkqiu | fdcb42b469c3176e360b33505d00f32dda049c0e | 3556e5d6adbe62511444e01399ccc5067be88364 | refs/heads/master | 2021-07-15T09:17:24.029558 | 2017-10-16T07:35:01 | 2017-10-16T07:35:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,777 | java | package com.akqid.zblog.controller.admin;
import com.akqid.zblog.service.PartnerService;
import com.akqid.zblog.util.ResultInfo;
import com.akqid.zblog.util.ResultInfoFactory;
import com.akqid.zblog.vo.Pager;
import com.akqid.zblog.vo.Partner;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.net.URLDecoder;
/**
*
* 后台管理员的友链操作contributor
* FILE: com.akqid.zblog.controller.admin.PartnerController.java
* MOTTO: 不积跬步无以至千里,不积小流无以至千里
* AUTHOR: akqid
* DATE: 2017/4/14
* TIME: 22:28
*/
@RestController
@RequestMapping("/admin/partner")
public class AdminPartnerController {
@Resource
private PartnerService partnerService;
@RequestMapping("/initPage")
public Pager initPage(Pager pager){
partnerService.initPage(pager );
return pager;
}
/**
* 保存友链
* @param partner
* @return
*/
@RequestMapping("/save")
public ResultInfo savePartner(Partner partner){
try {
partner.setSiteName(URLDecoder.decode(partner.getSiteName(), "utf-8"));
partner.setSiteDesc(URLDecoder.decode(partner.getSiteDesc(), "utf-8"));
partner.setSiteUrl(URLDecoder.decode(partner.getSiteUrl(), "utf-8"));
partnerService.savePartner(partner);
}catch (Exception e){
return ResultInfoFactory.getErrorResultInfo();
}
return ResultInfoFactory.getSuccessResultInfo();
}
/**
* 更新友链
* @param partner
* @return
*/
@RequestMapping("/update")
public ResultInfo updatePartner(Partner partner) {
try {
partner.setSiteName(URLDecoder.decode(partner.getSiteName(), "utf-8"));
partner.setSiteDesc(URLDecoder.decode(partner.getSiteDesc(), "utf-8"));
partner.setSiteUrl(URLDecoder.decode(partner.getSiteUrl(), "utf-8"));
if (partner.getSort()==null){
partner.setSort(0);
}
partnerService.updatePartner(partner);
} catch (Exception e) {
return ResultInfoFactory.getErrorResultInfo();
}
return ResultInfoFactory.getSuccessResultInfo();
}
/**
* 删除友链
* @param id
* @return
*/
@RequestMapping("/delete/{id}")
public ResultInfo deletePartner(@PathVariable Integer id){
try {
partnerService.deletePartner(id);
}catch (Exception e){
return ResultInfoFactory.getErrorResultInfo();
}
return ResultInfoFactory.getSuccessResultInfo();
}
}
| [
"alpzxy@163.com"
] | alpzxy@163.com |
483d3197873ea62f206b7992c1b08f8f0dad4ff4 | 5fd72ca3e6269651b1ddbba709310a9c6e3a4e25 | /app/src/main/java/com/example/guojiawei/finderproject/util/TimeCount.java | 7133ad2690d187ea848a177ec92523aa7f56ecb9 | [] | no_license | Finderchangchang/finder | c01b5ebcc83edb7ae719d5d52c4bfe9989ca0b76 | a72e479adb342a9f559cfff849aa0b279c73548c | refs/heads/master | 2021-05-03T16:29:23.966313 | 2018-04-21T15:01:17 | 2018-04-21T15:01:17 | 120,435,716 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 912 | java | package com.example.guojiawei.finderproject.util;
import android.os.CountDownTimer;
import android.widget.TextView;
/**
* 验证码定时器
* com.subzero.travel.utils
* Created by Administrator on 2016/8/10.
*/
public class TimeCount extends CountDownTimer {
private TextView tvGetcode;
public TimeCount(long millisInFuture, long countDownInterval, TextView view) {
super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
this.tvGetcode = view;
}
@Override
public void onFinish() {// 计时完毕时触发
tvGetcode.setText("重新获取");
tvGetcode.setEnabled(true);// 按钮获取焦点
}
@Override
public void onTick(long millisUntilFinished) {// 计时过程显示
tvGetcode.setEnabled(false);// 按钮不获取焦点
tvGetcode.setText(millisUntilFinished / 1000 + "s");
}
}
| [
"chang19930228"
] | chang19930228 |
684bca39f8b22836819e9d5cc8d465be028038b1 | 25eb8011bfacb8408ee299c3e01c0f0128b83bf2 | /LoginCucumber/src/main/java/ohtu/services/AuthenticationService.java | a0768b393c696cf83f447bfcc9c6b338133573c2 | [] | no_license | Craetion5/ohtu-viikko3 | fac75b96a9439dc5745eabf0645b4378e774e294 | 63dd4676a1cb414c87f40c2222a1e3a1bf7c6341 | refs/heads/master | 2020-04-07T06:15:17.372253 | 2018-11-18T21:22:47 | 2018-11-18T21:22:47 | 158,127,823 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,057 | java | package ohtu.services;
import ohtu.domain.User;
import java.util.ArrayList;
import java.util.List;
import ohtu.data_access.UserDao;
public class AuthenticationService {
private UserDao userDao;
public AuthenticationService(UserDao userDao) {
this.userDao = userDao;
}
public boolean logIn(String username, String password) {
for (User user : userDao.listAll()) {
if (user.getUsername().equals(username)
&& user.getPassword().equals(password)) {
return true;
}
}
return false;
}
public boolean createUser(String username, String password) {
if (userDao.findByName(username) != null) {
return false;
}
if (invalid(username, password)) {
return false;
}
userDao.add(new User(username, password));
return true;
}
private boolean invalid(String username, String password) {
// validity check of username and password
return false;
}
}
| [
"jetro.hulkko@helsinki.fi"
] | jetro.hulkko@helsinki.fi |
551284e55c47d518eecaf21d541b6928446e5972 | bccb412254b3e6f35a5c4dd227f440ecbbb60db9 | /hl7/pseudo/segment/CON_.java | 4663e4833f4d1bf0c4a8a18929678e67690a0e9e | [] | no_license | nlp-lap/Version_Compatible_HL7_Parser | 8bdb307aa75a5317265f730c5b2ac92ae430962b | 9977e1fcd1400916efc4aa161588beae81900cfd | refs/heads/master | 2021-03-03T15:05:36.071491 | 2020-03-09T07:54:42 | 2020-03-09T07:54:42 | 245,967,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 304 | java | package hl7.pseudo.segment;
import hl7.bean.datastructure.DataStructure;
public class CON_ extends hl7.model.V2_7.segment.CON_{
public CON_(){
super();
}
public static CON_ CLASS;
static{
CLASS = new CON_();
}
public DataStructure[][] getComponents(){
return super.getComponents();
}
}
| [
"terminator800@hanmail.net"
] | terminator800@hanmail.net |
9e95499dcb72e80cd8e2c3b3e08ba681337fe6f6 | 86224d3b7b2833eb85e24590ffbeec2f83ec4504 | /src/main/java/lab_5/model/entity/Location.java | a34c0a97837e0434ead50c26c81d1394bf851ebd | [] | no_license | MaxBardyn/hibernate_console_app | 40cc81c20998ff3c30eb012f154b66b9405a5571 | 97faba6621c1f282f73593532e3252a99d274c47 | refs/heads/main | 2023-01-29T07:19:35.743840 | 2020-12-10T16:40:01 | 2020-12-10T16:40:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 700 | java | package lab_5.model.entity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.persistence.*;
import java.util.Scanner;
@Data
@Entity
@Table(name = "location")
@Accessors(chain = true)
@NoArgsConstructor
public class Location {
private static final Scanner SCANNER = new Scanner(System.in);
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "address")
private String address;
public Location(String name, String address) {
this.name = name;
this.address = address;
}
}
| [
"maxbardyn@gmail.com"
] | maxbardyn@gmail.com |
4a2df71caa33c24d0d542c3e548ed354391a1c85 | 9b0633ca8708f48efa8a554d80d9c08dd19c88f1 | /Assignment3/OreBlob.java | 052bf786ce6386417dde0a179a0c767f332a4fd4 | [] | no_license | cbfrench/CPE102Project | 48b362819e663310a477101e86a1004d2a88ea44 | 3e5efbdda769275c65343b627ce9926e79aa4e0e | refs/heads/master | 2020-06-04T12:40:39.136926 | 2015-05-11T19:51:39 | 2015-05-11T19:51:39 | 33,626,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 327 | java | /**
* Created by Chanye on 4/28/2015.
*/
public class OreBlob
extends Animated_rate
{
private int current_img;
public OreBlob(String name, Point position, int animation_rate, int imgs, int rate)
{
super(name, position, animation_rate, imgs, rate);
this.current_img = 0;
}
}
| [
"connorfrench716@gmail.com"
] | connorfrench716@gmail.com |
3420b6078aa632bf782737fbb2b4670f588745fa | e368d9adb1fe3b2d6e20c31835ff4abeea77e4ee | /workspace_6/cnpm/src/game3x3/BoardState.java | fb1fd8b1be24f59205b93615f86ce1428d8a79ba | [] | no_license | thanghoang07/java | 29edf868f79318672707be626d9105935fd83478 | 41d62d5e9f206f0459b9c3d42a8581fc5395b223 | refs/heads/master | 2020-05-07T13:45:13.479039 | 2019-04-10T09:59:34 | 2019-04-10T09:59:34 | 180,541,189 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,436 | java | package game3x3;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// 1 - Max -Computer - hien thi so 1
// 2- Min - Uszer - hien thi so 2
public class BoardState {
List<Node> availablePoints; // danh sach nhung Vi Tri rong co the danh
int[][] board = new int[3][3];
List<Node> rootsChildrenScore = new ArrayList<>();// danh sach nhung vi tri
// con
// Danh danh gia
public int evaluateBoard() {
int score = 0;
// Cac dong
for (int i = 0; i < 3; ++i) {
int blank = 0;
int X = 0;
int O = 0;
for (int j = 0; j < 3; ++j) {
if (board[i][j] == 0) {
blank++;
} else if (board[i][j] == 1) {
X++;
} else {
O++;
}
}
score += changeInScore(X, O);
}
// Cac cot
for (int j = 0; j < 3; ++j) {
int blank = 0;
int X = 0;
int O = 0;
for (int i = 0; i < 3; ++i) {
if (board[i][j] == 0) {
blank++;
} else if (board[i][j] == 1) {
X++;
} else {
O++;
}
}
score += changeInScore(X, O);
}
int blank = 0;
int X = 0;
int O = 0;
// Duong cheo 1
for (int i = 0, j = 0; i < 3; ++i, ++j) {
if (board[i][j] == 1) {
X++;
} else if (board[i][j] == 2) {
O++;
} else {
blank++;
}
}
score += changeInScore(X, O);
blank = 0;
X = 0;
O = 0;
// Duong cheo 2
for (int i = 2, j = 0; i > -1; --i, ++j) {
if (board[i][j] == 1) {
X++;
} else if (board[i][j] == 2) {
O++;
} else {
blank++;
}
}
score += changeInScore(X, O);
return score;
}
// Cach tinh diem de danh gia
private int changeInScore(int X, int O) {
int change;
if (X == 3) {// X is Max
change = 100;
} else if (X == 2 && O == 0) {
change = 10;
} else if (X == 1 && O == 0) {
change = 1;
}
else if (O == 3) {// O is Min
change = -100;
} else if (O == 2 && X == 0) {
change = -10;
} else if (O == 1 && X == 0) {
change = -1;
} else {
change = 0;
}
return change;
}
// function MIN-VALUE(state)
public int MIN_VALUE(List<Integer> list) {// 2 ng
int min = Integer.MAX_VALUE;
int index = Integer.MIN_VALUE;
for (int i = 0; i < list.size(); ++i) {
if (list.get(i) < min) {
min = list.get(i);
index = i;
}
}
return list.get(index);
}
// function MAX-VALUE(state)
public int MAX_VALUE(List<Integer> list) {// 1 may
int max = Integer.MIN_VALUE;
int index = Integer.MIN_VALUE;
for (int i = 0; i < list.size(); ++i) {
if (list.get(i) > max) {
max = list.get(i);
index = i;
}
}
return list.get(index);
}
// Gioi han chieu sau tim kiem
int uptoDepth = 2;
public int alphaBetaMinimax(int[][] start, int alpha, int beta, int depth, int turn) {
if (depth == uptoDepth || isGameOver()) {
return evaluateBoard();
}
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
List<Node> p = getAvailableStates();// tìm ra các vị trí chưa có ai đánh
System.out.println(p.size());
if (p.isEmpty())
return 0;
// duyệt qua các vị trí trống xem vị trí nào có điểm max lớn nhất (đối
// với máy), vị trí nào có điểm min nhất (đối với ngưỿi chơi)
for (int i = 0; i < p.size(); i++) {
Node point = p.get(i);
int currentScore = 0;
if (turn == 1) {// máy 2đánh
placeAMove(point, 1);
currentScore = minimax(start, depth + 1, 2);
max = Math.max(currentScore, max);
if (depth == 0)
rootsChildrenScore.add(new Node(currentScore, point));
} else if (turn == 2) {
placeAMove(point, 2);
currentScore = minimax(start, depth + 1, 1);
min = Math.min(currentScore, min);
}
board[point.x][point.y] = 0;// reset lại vị trí point
}
if (turn == 1)
return max;// nếu là máy đánh thì trả vỿ max
return min;
}
public int minimax(int[][] start, int depth, int turn) {
if (depth == uptoDepth || isGameOver()) {
return evaluateBoard();
}
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
List<Node> p = getAvailableStates();// tìm ra các vị trí chưa có ai đánh
System.out.println(p.size());
if (p.isEmpty())
return 0;
// duyệt qua các vị trí trống xem vị trí nào có điểm max lớn nhất (đối
// với máy), vị trí nào có điểm min nhất (đối với ngưỿi chơi)
for (int i = 0; i < p.size(); i++) {
Node point = p.get(i);
int currentScore = 0;
if (turn == 1) {// máy 2đánh
placeAMove(point, 1);
currentScore = minimax(start, depth + 1, 2);
max = Math.max(currentScore, max);
if (depth == 0)
rootsChildrenScore.add(new Node(currentScore, point));
} else if (turn == 2) {
placeAMove(point, 2);
currentScore = minimax(start, depth + 1, 1);
min = Math.min(currentScore, min);
}
board[point.x][point.y] = 0;// reset lại vị trí point
}
if (turn == 1)
return max;// nếu là máy đánh thì trả vỿ max
return min;
}
// Khong con vi tri de di chuyen
public boolean isGameOver() {
return (hasXWon() || hasOWon() || getAvailableStates().isEmpty());
}
// X thang (Max)
public boolean hasXWon() {
if ((board[0][0] == board[1][1] && board[0][0] == board[2][2] && board[0][0] == 1)
|| (board[0][2] == board[1][1] && board[0][2] == board[2][0] && board[0][2] == 1)) {
return true;
}
for (int i = 0; i < 3; ++i) {
if (((board[i][0] == board[i][1] && board[i][0] == board[i][2] && board[i][0] == 1)
|| (board[0][i] == board[1][i] && board[0][i] == board[2][i] && board[0][i] == 1))) {
return true;
}
}
return false;
}
// O thang (Min)
public boolean hasOWon() {
if ((board[0][0] == board[1][1] && board[0][0] == board[2][2] && board[0][0] == 2)
|| (board[0][2] == board[1][1] && board[0][2] == board[2][0] && board[0][2] == 2)) {
return true;
}
for (int i = 0; i < 3; ++i) {
if ((board[i][0] == board[i][1] && board[i][0] == board[i][2] && board[i][0] == 2)
|| (board[0][i] == board[1][i] && board[0][i] == board[2][i] && board[0][i] == 2)) {
return true;
}
}
return false;
}
// Nhung vi tri rong co the danh
public List<Node> getAvailableStates() {
availablePoints = new ArrayList<>();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
if (board[i][j] == 0) {
availablePoints.add(new Node(i, j));
}
}
}
return availablePoints;
}
// bat dau danh (chan quan doi phuong)
public void placeAMove(Node point, int player) {
board[point.x][point.y] = player; // player = 1 for X, 2 for O
}
// Tim buoc di tot nhat
public Node returnBestMove() {
int MAX = Integer.MIN_VALUE;
int best = Integer.MIN_VALUE;
for (int i = 0; i < rootsChildrenScore.size(); ++i) {
if (MAX < rootsChildrenScore.get(i).score) {
MAX = rootsChildrenScore.get(i).score;
best = i;
}
}
Node tmp = rootsChildrenScore.get(best).pos;
rootsChildrenScore.clear();
return tmp;
}
// Nhap vao vi tri tu ban phim
void takeHumanInput() {
Scanner scan = new Scanner(System.in);
System.out.println("Your move: ");
int x = scan.nextInt();
int y = scan.nextInt();
Node point = new Node(x, y);
placeAMove(point, 2);
}
// Hien thi ban co
public void displayBoard() {
System.out.println();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
System.out.print(board[i][j] + "\t ");
}
System.out.println();
}
}
} | [
"thanghoang07@outlook.com"
] | thanghoang07@outlook.com |
27d012aa0676ea375afc57e03a90fd838a34e37b | d68c7e8cff5880bb4035cc93fce24d443aa084e7 | /manytomany/src/main/java/com/capgemini/jpa/manytomany/service/PersonServiceImpl.java | 18e7346f2e6385352a9a4fb12fe4f94758b61bdf | [] | no_license | mrunaltodkar/spring-boot | 5bd194991754ffb8fb872e26bec9ef2e23b4c190 | e1306cceb847009305fbcb09c1a48cc3eb51e3b9 | refs/heads/master | 2020-05-24T09:52:41.931402 | 2019-05-17T12:55:46 | 2019-05-17T12:55:46 | 187,216,332 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 579 | java | package com.capgemini.jpa.manytomany.service;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.capgemini.jpa.manytomany.dao.PersonDao;
import com.capgemini.jpa.manytomany.entity.Person;
@Service
public class PersonServiceImpl implements PersonService {
@Autowired
PersonDao dao;
@Override
public Set<Person> addPerson(Set<Person> person) {
dao.saveAll(person);
return person;
}
@Override
public Person getPersonById(int id) {
return dao.findById(id).get();
}
}
| [
"mrunal-sunilkumar.todkar@capgemini.com"
] | mrunal-sunilkumar.todkar@capgemini.com |
d10d20659413c044c115cf275ef23152c8ffeab1 | 1af048cb33ff887c649fded9c747e8108b13b586 | /example-springboot/springbootOnAutoConfig/src/main/java/com/edu/spring/springboot/UTF8Condition.java | 6ec00af2b9b9ea6f869062300fe9fe0bf61a1cb7 | [] | no_license | bulidWorld/toturial | b2451453518b6d93aa40431bf3480f9675a8f73b | a7d57c174cd3a5b85a44f6c9a78053cdbde57366 | refs/heads/master | 2021-01-15T23:21:41.729629 | 2018-06-26T15:52:52 | 2018-06-26T15:52:52 | 99,930,958 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 510 | java | package com.edu.spring.springboot;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
public class UTF8Condition implements Condition {
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
String encoding = System.getProperty("file.encoding");
if(encoding != null){
return "utf-8".equals(encoding.toLowerCase());
}
return false;
}
}
| [
"782213745@qq.com"
] | 782213745@qq.com |
47451a42d7d38a94328a4886f7eb285b5d24ae74 | 9ee523bb1376ee20eaa5bc2a6fa0e1220e8f5d7f | /src/main/java/com/jj/util/annotation/Descricao.java | bddb98da182ad11635a021a4bc4486585b5a4100 | [] | no_license | jacksonwc2/jj-util | 795fd1c869d045e5ed0671fcf3a1b9fe3a517542 | 0263f9b9b4143573932699ec2feb42577ac4a2b1 | refs/heads/master | 2022-12-05T16:02:11.761956 | 2019-10-15T00:52:16 | 2019-10-15T00:52:16 | 215,172,421 | 0 | 0 | null | 2022-11-24T07:53:14 | 2019-10-15T00:46:54 | Java | UTF-8 | Java | false | false | 471 | java | package com.jj.util.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Esta annotation serve para adicionar um nome mais legivel ao atributo quando for necessario<br>
* ex: codigoEmpresa seja > Código da empresa
*
*
*/
@Target({ java.lang.annotation.ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface Descricao {
String descricao() default "";
}
| [
"jwccarbonera@outlook.com"
] | jwccarbonera@outlook.com |
2b34376e95c797931f1c4ee6aa377cf3fe91725e | 93e09b29320e365a3b315cd92de75d639dcd5ada | /test/controllers/AddProxyTest.java | 1da275693aaa7def5634f42453bb833ebaa732ad | [] | no_license | siddhraj4489/forward-cat-website | 7e2f6615f6cda0d30c422fa97991efe41525ef30 | 0bb0bfde64c446e5e7af00c2f1a7467055a9989f | refs/heads/master | 2020-05-03T02:39:50.551107 | 2014-05-24T14:46:27 | 2014-05-24T14:46:27 | 24,770,797 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,318 | java | package controllers;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.forwardcat.common.ProxyMail;
import com.google.inject.AbstractModule;
import models.MailSender;
import org.apache.mailet.MailAddress;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import play.mvc.Result;
import play.test.FakeRequest;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Response;
import redis.clients.jedis.exceptions.JedisException;
import java.io.IOException;
import static models.ControllerUtils.getHash;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import static play.test.Helpers.*;
@RunWith(MockitoJUnitRunner.class)
public class AddProxyTest extends PlayTest {
String proxyMail = "test@forward.cat";
String proxyData = "{\"ua\":\"my_address@mail.com\",\"ts\":\"2013-01-27T01:58:53.874+01:00\",\"ex\":\"2013-02-01T01:58:53.874+01:00\",\"ac\":false}";
String proxyHash;
@Mock JedisPool jedisPool = mock(JedisPool.class);
@Mock Jedis jedis;
@Mock Pipeline pipeline;
@Mock MailSender mailSender;
@Mock Response<Long> expireResponse;
@Override
public AbstractModule getModule() throws IOException {
when(jedisPool.getResource()).thenReturn(jedis);
when(jedis.get("p:" + proxyMail)).thenReturn(proxyData);
when(jedis.pipelined()).thenReturn(pipeline);
when(pipeline.expire(anyString(), anyInt())).thenReturn(expireResponse);
when(expireResponse.get()).thenReturn(1L);
ProxyMail proxy = new ObjectMapper().readValue(proxyData, ProxyMail.class);
proxyHash = getHash(proxy);
return new AbstractModule() {
@Override
protected void configure() {
bind(JedisPool.class).toInstance(jedisPool);
bind(MailSender.class).toInstance(mailSender);
}
};
}
@Test
public void wrongDuration_sendBadRequest() throws Exception {
Result route = route(request("test", "user@mail.com", 10));
assertThat(status(route), is(BAD_REQUEST));
}
@Test
public void wrongEmail_sendBadRequest() throws Exception {
Result route = route(request("test", "not an address", 3));
assertThat(status(route), is(BAD_REQUEST));
}
@Test
public void wrongUsername_sendBadRequest() throws Exception {
Result route = route(request("not valid", "user@mail.com", 3));
assertThat(status(route), is(BAD_REQUEST));
}
@Test
public void chainedProxy_sendBadRequest() throws Exception {
Result route = route(request("test", "email@forward.cat", 3));
assertThat(status(route), is(BAD_REQUEST));
}
@Test
public void proxyAlreadyExists_sendBadRequest() throws Exception {
when(jedis.exists("p:test@forward.cat")).thenReturn(Boolean.TRUE);
Result route = route(request("test", "user@mail.com", 3));
assertThat(status(route), is(BAD_REQUEST));
verify(jedisPool).returnResource(jedis);
}
@Test
public void connectionError_sendBadRequest() throws Exception {
when(jedis.exists("p:test@forward.cat")).thenThrow(JedisException.class);
Result route = route(request("test", "user@mail.com", 3));
assertThat(status(route), is(INTERNAL_SERVER_ERROR));
verify(jedisPool).returnResource(jedis);
}
@Test
public void everythingFine_sendMailAndGoodResponse() throws Exception {
when(jedis.exists("p:test@forward.cat")).thenReturn(Boolean.FALSE);
Result route = route(request("test", "user@mail.com", 3));
assertThat(status(route), is(OK));
verify(jedisPool).returnResource(jedis);
verify(mailSender).sendHtmlMail(any(MailAddress.class), anyString(), anyString());
verify(jedisPool).returnResource(jedis);
}
private FakeRequest request(String proxy, String email, Integer duration) {
return fakeRequest(GET, "/add?proxy=" + proxy + "&email=" + email + "&duration=" + duration);
}
}
| [
"dani@Danis-MacBook-Air.local"
] | dani@Danis-MacBook-Air.local |
bc1155fb442287dad6cf52d1c237c51905bd0adf | 85f573af305c07112cf3296c4c9e26935b0350ad | /app/src/main/java/com/haoyigou/hyg/ui/OrderAllAct.java | 5accdb93da20f1c1f55135e2fcd85e1b03d42cc8 | [] | no_license | wuliang6661/Turuk | 0cc8c483c4a8cb536874e7025437042dcbb00a11 | 4e3a4c0562f0f0f2e7bf9fd47166541550959d62 | refs/heads/main | 2023-07-20T17:58:56.764287 | 2021-09-03T14:26:18 | 2021-09-03T14:26:18 | 402,777,968 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 29,894 | java | package com.haoyigou.hyg.ui;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alipay.sdk.app.PayTask;
import com.haoyigou.hyg.R;
import com.haoyigou.hyg.application.GlobalApplication;
import com.haoyigou.hyg.base.BaseActivity;
import com.haoyigou.hyg.common.http.AsyncHttpResponseHandler;
import com.haoyigou.hyg.common.http.HttpClient;
import com.haoyigou.hyg.entity.Constants;
import com.haoyigou.hyg.entity.OrderEntry;
import com.haoyigou.hyg.ui.homeweb.HomeWebViewAct;
import com.haoyigou.hyg.ui.personweb.PersonWebViewAct;
import com.haoyigou.hyg.utils.NetworkUtils;
import com.haoyigou.hyg.utils.SharedPreferencesUtils;
import com.haoyigou.hyg.utils.ToastUtils;
import com.haoyigou.hyg.utils.Util;
import com.haoyigou.hyg.view.SmartHeader;
import com.haoyigou.hyg.view.superadapter.CommonAdapter;
import com.haoyigou.hyg.view.superadapter.ViewHolder;
import com.haoyigou.hyg.view.widget.PayPupWindow;
import com.haoyigou.hyg.view.widget.PullDownElasticImp;
import com.haoyigou.hyg.view.widget.PullDownScrollView;
import com.haoyigou.hyg.view.widget.TopAndButtomListView;
import com.haoyigou.hyg.wxapi.WxPayTask;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by wuliang on 2017/9/1.
* <p>
* 订单页面
*/
public class OrderAllAct extends BaseActivity implements View.OnClickListener,
PullDownScrollView.RefreshListener, AdapterView.OnItemClickListener {
@BindView(R.id.all_order)
TextView allOrder;
@BindView(R.id.payment_order)
TextView paymentOrder;
@BindView(R.id.drop_order)
TextView dropOrder;
@BindView(R.id.shipped_order)
TextView shippedOrder;
@BindView(R.id.ani_line)
View aniLine;
@BindView(R.id.listview)
TopAndButtomListView listview;
@BindView(R.id.refresh_root)
SmartRefreshLayout refreshRoot;
@BindView(R.id.fenlei_layout)
RelativeLayout fenleiLayout;
@BindView(R.id.not_layout)
LinearLayout notLayout;
List<OrderEntry> orderList;
private int type = 0; //0为全部订单 1 代付款 2 代发货 3 已发货 4 退款/售后
private int page = 1; // 默认第一页
boolean isPageSun = true; //用来表示下一页没有加载 ,可以加载下一页
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_all_order);
ButterKnife.bind(this);
goBack();
setTitleText("我的订单");
orderList = new ArrayList<>();
distance = (GlobalApplication.screen_width / 4 - Util.dp2px(OrderAllAct.this, 63)) / 2;
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
Util.dp2px(OrderAllAct.this, 63), Util.dp2px(OrderAllAct.this, 2));
params.setMargins((int) distance, 0, 0, 0);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
aniLine.setLayoutParams(params);
setListener();
type = getIntent().getIntExtra("type", 0);
if (type == 4) {
fenleiLayout.setVisibility(View.GONE);
} else {
setAnniLine(type);
}
}
@Override
protected void onResume() {
super.onResume();
orderList = new ArrayList<>();
listview.setVisibility(View.GONE);
adapter = null;
page = 1;
getOrderData(type == 0 ? 4 : type - 1);
startProgressDialog("", this);
}
/**
* 设置监听
*/
private void setListener() {
allOrder.setOnClickListener(this);
paymentOrder.setOnClickListener(this);
dropOrder.setOnClickListener(this);
shippedOrder.setOnClickListener(this);
listview.setOnItemClickListener(this);
refreshRoot.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(@NonNull final RefreshLayout refreshLayout) {
page = 1;
orderList.clear();
getOrderData(type == 0 ? 4 : type - 1);
}
});
refreshRoot.setRefreshHeader(new SmartHeader(this));
refreshRoot.setHeaderHeight(60);
refreshRoot.setEnableLoadMore(true);
refreshRoot.setEnableRefresh(true);
refreshRoot.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
if (isPageSun) {
isPageSun = false;
page++;
getOrderData(type == 0 ? 4 : type - 1);
startProgressDialog("", OrderAllAct.this);
}
}
});
refreshRoot.setRefreshFooter(new SmartFooter(this));
refreshRoot.setFooterHeight(60);
listview.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// 当不滚动时
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
// 判断是否滚动到底部
if (view.getLastVisiblePosition() == view.getCount() - 1) {
//加载更多功能的代码
// if (isPageSun) {
// isPageSun = false;
// page++;
// getOrderData(type == 0 ? 4 : type - 1);
// startProgressDialog("", OrderAllAct.this);
// }
}
}
}
@Override
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
}
});
}
@Override
public void onClick(View v) {
orderList = new ArrayList<>();
page = 1;
startProgressDialog("", this);
switch (v.getId()) {
case R.id.all_order:
setAnniLine(0);
type = 0;
getOrderData(4);
break;
case R.id.payment_order:
setAnniLine(1);
type = 1;
getOrderData(0);
break;
case R.id.drop_order:
setAnniLine(2);
type = 2;
getOrderData(1);
break;
case R.id.shipped_order:
setAnniLine(3);
type = 3;
getOrderData(2);
break;
}
}
/**
* 获取订单数据
*/
private void getOrderData(int type) {
if (!NetworkUtils.isNetworkConnected(this)) {
showToast("网络无连接");
notLayout.setVisibility(View.VISIBLE);
refreshRoot.setVisibility(View.GONE);
stopProgressDialog();
return;
}
final Map<String, Object> params = new HashMap<>();
params.put("ordertype", type);
params.put("currPageNo", page);
HttpClient.post(HttpClient.ORDER_DATA, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
stopProgressDialog();
refreshRoot.finishLoadMore();
refreshRoot.finishRefresh();
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
listview.setVisibility(View.VISIBLE);
isPageSun = true;
String array = object.getString("result");
List<OrderEntry> list = JSONArray.parseArray(array, OrderEntry.class);
if (page == 1 && list.size() == 0) {
notLayout.setVisibility(View.VISIBLE);
refreshRoot.setVisibility(View.GONE);
} else {
notLayout.setVisibility(View.GONE);
refreshRoot.setVisibility(View.VISIBLE);
}
if (list == null || list.size() == 0) {
page = page == 1 ? 1 : --page;
}
Message msg = new Message();
msg.obj = list;
msg.what = 0x11;
handler.sendMessage(msg);
} else {
showToast(object.getString("message"));
}
}
}, this);
}
CommonAdapter<OrderEntry> adapter;
/**
* 设置界面适配
*/
private void setListAdapter() {
adapter = new CommonAdapter<OrderEntry>(this, R.layout.item_order_all, orderList) {
@Override
protected void convert(ViewHolder viewHolder, OrderEntry item, int position) {
viewHolder.setText(R.id.order_num, "订单编号:" + item.getOrdernum());
viewHolder.setImageUrl(R.id.order_img, item.getDetails().get(0).getPiclogo());
viewHolder.setText(R.id.order_name, item.getDetails().get(0).getName());
viewHolder.setText(R.id.order_moket_num, "×" + item.getDetails().get(0).getNum());
viewHolder.setText(R.id.order_num_txt, "共" + item.getProductnum() + "件商品 合计:");
viewHolder.setText(R.id.order_price, "¥" + item.getDetails().get(0).getDisprice());
viewHolder.setText(R.id.order_allprice, item.getDisprice());
viewHolder.setText(R.id.order_carriage, "(运费:¥" + item.getCarriage() + ")");
String name = item.getDetails().get(0).getAttrname();
if (item.getDetails().get(0).getAttrname().equals("共同")){
name= "";
}
viewHolder.setText(R.id.order_style,name);
TextView orderOldprice = viewHolder.getView(R.id.order_oldprice);
orderOldprice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
orderOldprice.setText("¥" + item.getDetails().get(0).getPrice());
viewHolder.getView(R.id.order_button1).setVisibility(View.VISIBLE);
TextView button1 = viewHolder.getView(R.id.order_button1);
TextView button2 = viewHolder.getView(R.id.order_button2);
TextView button3 = viewHolder.getView(R.id.order_button3);
if (item.getAdvanceid() != null){//advanceid为空是普通订单,不为空是预售订单
button1.setVisibility(View.GONE);
button3.setVisibility(View.GONE);
}else {
button1.setVisibility(View.VISIBLE);
if (item.getEnjoyDiscount() != null && item.getEnjoyDiscount().equals("0")){
if ("0".equals(item.getStatus())){//待付款不能领红包
button3.setVisibility(View.GONE);
}else {
button3.setVisibility(View.VISIBLE);
}
}else {
button3.setVisibility(View.GONE);
}
}
if ("3".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "已完成");
button1.setText("查看物流");
button2.setText("再次购买");
} else if ("-1".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "已取消");
button1.setText("删除订单");
button2.setText("再次购买");
} else if ("1".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "待发货");
button1.setText("提醒发货");
button2.setText("再次购买");
} else if ("0".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "待付款");
if (item.getAdvanceid() != null){//advanceid为空是普通订单,不为空是预售订单
button1.setVisibility(View.GONE);
if (item.getAdvanceStatus().equals("0")){//值为0的时候是定金未付,值为1是定金已付尾款未付
button2.setText("支付定金");
}
if (item.getAdvanceStatus().equals("1")){
button2.setText("支付尾款");
}
}else {
button1.setText("取消订单");
button2.setText("去支付");
}
} else if ("2".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "已发货");
button1.setText("查看物流");
button2.setText("确认收货");
} else if ("4".equals(item.getStatus())) {
viewHolder.setText(R.id.order_stutus, "已退款");
button1.setText("删除订单");
button2.setText("确认收货");
} else if ("-88".equals(item.getStatus())){
viewHolder.setText(R.id.order_stutus, "待取消");
button1.setVisibility(View.GONE);
button2.setText("再次购买");
}else {//6,7待退款
viewHolder.setText(R.id.order_stutus, "待退款");
button1.setVisibility(View.GONE);
button2.setText("再次购买");
}
Hodler hodler = new Hodler();
hodler.entry = item;
hodler.position = position;
button1.setTag(hodler);
button2.setTag(hodler);
button3.setTag(hodler);
button1.setOnClickListener(listener);
button2.setOnClickListener(listener);
button3.setOnClickListener(listener);
}
};
listview.setAdapter(adapter);
}
class Hodler {
OrderEntry entry;
int position;
}
PayPupWindow pupWindow;
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
final Hodler hodler = (Hodler) v.getTag();
switch (v.getId()) {
case R.id.order_button1:
switch (hodler.entry.getStatus()) {
case "2": //查看物流
case "3":
Intent intent = new Intent(OrderAllAct.this, PersonWebViewAct.class);
intent.putExtra("url", HttpClient.ORDER_RED_LOG + "?jumptype=1&ordernum=" +
hodler.entry.getDetails().get(0).getId() +
"&distributorId=" + disId);
intent.putExtra("isTitle", true);
startActivity(intent);
break;
case "-1": //删除订单
case "4":
removeOrder(hodler.entry.getOrdernum(), hodler.position);
break;
case "1": //提醒发货
remindOrder(hodler.entry.getOrdernum());
break;
case "0": //取消订单
cancleOrder(hodler.entry.getOrdernum(), hodler.position);
break;
}
break;
case R.id.order_button2:
switch (hodler.entry.getStatus()) {
case "3": //再次购买
case "-1":
case "1":
againPayShop(hodler.entry.getOrdernum());
break;
case "2": //确认收货
case "4":
confirmReceipt(hodler.entry.getOrdernum(), hodler.position);
break;
case "0": //去支付
if (hodler.entry.getAdvanceid() != null) {//advanceid为空是普通订单,不为空是预售订单
if (hodler.entry.getAdvanceStatus().equals("0")) {//值为0的时候是定金未付,值为1是定金已付尾款未付
Intent intent = new Intent(OrderAllAct.this, PersonWebViewAct.class);
intent.putExtra("url", HttpClient.PAY_ORDER_MONEY + "?ordernum=" + hodler.entry.getOrdernum()
+ "&distributorId=" + disId + "&source=1");
startActivity(intent);
}else {
Intent intent = new Intent(OrderAllAct.this, PersonWebViewAct.class);
intent.putExtra("url", HttpClient.PAY_PRESELL + "?ordernum=" + hodler.entry.getOrdernum()
+ "&distributorId=" + disId + "&source=1");
startActivity(intent);
}
}else {
pupWindow = new PayPupWindow(OrderAllAct.this);
pupWindow.setOnPayButton(new PayPupWindow.onPayButton() {
@Override
public void onClick(int type) {
pupWindow.dismiss();
if (type == 1) { //微信支付
payWX(hodler.entry.getOrdernum());
} else { //支付宝支付
payAliba(hodler.entry.getOrdernum());
}
}
});
pupWindow.showAtLocation(listview, Gravity.BOTTOM, 0, 0);
}
break;
default: //再次购买
againPayShop(hodler.entry.getOrdernum());
break;
}
break;
case R.id.order_button3:
Bundle bundle = new Bundle();
bundle.putString("orderNum", hodler.entry.getOrdernum());
Intent intent = new Intent(OrderAllAct.this, WebActivity.class);
intent.putExtras(bundle);
startActivity(intent);
break;
default:
break;
}
}
};
/**
* 删除订单
*/
private void removeOrder(String orderNum, final int position) {
Map<String, Object> params = new HashMap<>();
params.put("ordernum", orderNum);
params.put("userdelete", "1");
HttpClient.post(HttpClient.ORDER_DELETE, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
showToast("订单已删除!");
orderList.remove(position);
adapter.notifyDataSetChanged();
if (orderList.size() == 0) {
notLayout.setVisibility(View.VISIBLE);
refreshRoot.setVisibility(View.GONE);
}
} else {
showToast(object.getString("message"));
}
}
}, this);
}
/**
* 取消订单
*/
private void cancleOrder(String orderNum, final int position) {
Map<String, Object> params = new HashMap<>();
params.put("ordernum", orderNum);
HttpClient.post(HttpClient.ORDER_CANCLE, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
showToast("订单已取消!");
orderList.remove(position);
adapter.notifyDataSetChanged();
if (orderList.size() == 0) {
notLayout.setVisibility(View.VISIBLE);
refreshRoot.setVisibility(View.GONE);
}
} else {
showToast(object.getString("message"));
}
}
}, this);
}
/**
* 提醒发货
*/
private void remindOrder(String orderNum) {
Map<String, Object> params = new HashMap<>();
params.put("ordernum", orderNum);
HttpClient.post(HttpClient.ORDER_REMIND, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
showToast(object.getString("message"));
}
}, this);
}
/**
* 确认收货
*/
private void confirmReceipt(String orderNum, final int position) {
Map<String, Object> params = new HashMap<>();
params.put("ordernum", orderNum);
HttpClient.post(HttpClient.ORDER_CONFIRM, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
showToast(object.getString("message"));
orderList.remove(position);
adapter.notifyDataSetChanged();
if (orderList.size() == 0) {
notLayout.setVisibility(View.VISIBLE);
refreshRoot.setVisibility(View.GONE);
}
} else {
showToast(object.getString("message"));
}
}
}, this);
}
/**
* 再次购买
*/
private void againPayShop(String orderNum) {
Map<String, Object> params = new HashMap<>();
params.put("ordernum", orderNum);
HttpClient.post(HttpClient.ORDER_AGAGIN, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
EventBus.getDefault().post(new Boolean(false));
finish();
} else {
showToast(object.getString("message"));
}
}
}, this);
}
/**
* 微信支付
*/
private void payWX(String orderNum) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("ordernum", orderNum);
map.put("distributorId", SharedPreferencesUtils.getInstance().getString("distributorId", null));
WxPayTask task = new WxPayTask(this, 1);
task.startProgressDialog("", this);
task.execute(map);
}
/**
* 支付宝支付
*/
private void payAliba(final String orderNum) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("ordernum", orderNum);
HttpClient.post(HttpClient.ORDER_PAYALI, map, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String content) {
super.onSuccess(content);
JSONObject object = JSON.parseObject(content);
if (HttpClient.RET_SUCCESS_CODE.equals(object.getString("status"))) {
String data = object.getString("data");
new AlipayThread(data, orderNum).start();
} else {
showToast(object.getString("message"));
}
}
}, this);
}
class AlipayThread extends Thread {
String itemdata;
String orderNum;
AlipayThread(String itemdata, String orderNum) {
this.itemdata = itemdata;
this.orderNum = orderNum;
}
@Override
public void run() {
// TODO Auto-generated method stub
PayTask alipay = new PayTask(OrderAllAct.this);
String result = alipay.pay(itemdata, true);
// Log.i("log--", result);
Message msg = new Message();
msg.what = 0x22;
msg.obj = orderNum;
handler.sendMessage(msg);
super.run();
}
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0x11:
List<OrderEntry> list = (List<OrderEntry>) msg.obj;
orderList.addAll(list);
if (adapter != null) {
adapter.setmDatas(orderList);
} else {
setListAdapter();
}
break;
case 0x22: //支付宝支付完成
String orderNum = (String) msg.obj;
Bundle bundle = new Bundle();
bundle.putString("orderNum", orderNum);
goToActivity(OrderMessageAct.class, bundle, false);
break;
}
}
};
private float distance; //记录上次的位置
/**
* 动画横移
*/
private void setAnniLine(int seat) {
TranslateAnimation animation = new TranslateAnimation(distance,
GlobalApplication.screen_width / 4 * seat, 0, 0);
animation.setDuration(300);
animation.setFillAfter(true);//设置为true,动画转化结束后被应用
aniLine.startAnimation(animation);//开始动画
distance = GlobalApplication.screen_width / 4 * seat;
setTextColor(seat);
}
/**
* 设置点击效果
*/
private void setTextColor(int seat) {
TextView[] orders = new TextView[]{allOrder, paymentOrder, dropOrder, shippedOrder};
for (int i = 0; i < orders.length; i++) {
if (seat == i) {
orders[i].setTextColor(getResources().getColor(R.color.mainBlue));
} else {
orders[i].setTextColor(getResources().getColor(R.color.D));
}
}
}
@Override
public void onRefresh(PullDownScrollView view) {
new Handler().postDelayed(new Runnable() { //刷新一秒
@Override
public void run() {
// page = 1;
// orderList.clear();
// getOrderData(type == 0 ? 4 : type - 1);
// refreshRoot.finishRefresh("刷新");
}
}, 1000);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (orderList.get(position).getAdvanceid() != null) {//advanceid为空是普通订单,不为空是预售订单
if (orderList.get(position).getAdvanceStatus().equals("1")) {//值为0的时候是定金未付,值为1是定金已付尾款未付
Intent intent = new Intent(OrderAllAct.this, PersonWebViewAct.class);
intent.putExtra("url", HttpClient.PAY_PRESELL + "?ordernum=" + orderList.get(position).getOrdernum()
+ "&distributorId=" + disId + "&source=1");
startActivity(intent);
}else {
Bundle bundle = new Bundle();
bundle.putString("orderNum", orderList.get(position).getOrdernum());
goToActivity(OrderMessageAct.class, bundle, false);
}
}else {
Bundle bundle = new Bundle();
bundle.putString("orderNum", orderList.get(position).getOrdernum());
goToActivity(OrderMessageAct.class, bundle, false);
}
}
}
| [
"wy19941007"
] | wy19941007 |
633e50b9e9873f16e36a9e37d93625e7706985a6 | d78cd2e05038b0d761fae1e60e97e1828daccfb9 | /app/src/main/java/com/tetris/dmitriy/tetris/game/MessageTypes.java | 2accfe3afc52c5f4c4efbc2e590f03ac1ebf9349 | [] | no_license | Havriiash/Tetris | a6745714ca82d5b60937e6ddc301a16374775e8d | b4b8e47ba97668040782480b3f4a64e2ca632eff | refs/heads/master | 2021-06-07T07:22:36.310181 | 2016-10-04T19:10:18 | 2016-10-04T19:10:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 368 | java | package com.tetris.dmitriy.tetris.game;
/**
* Created by Dmitriy on 20.09.2016.
*/
public class MessageTypes {
public static final int SCORES = 0;
public static final int LEVEL = 1;
public static final int NEXT_FIGURE = 2;
public static final int REFRESH = 3;
public static final int CLEAR_LINE = 4;
public static final int GAME_OVER = 5;
} | [
"write.dvg@gmail.com"
] | write.dvg@gmail.com |
7031e96e3cd476df2a70611d7a39e6d9f03700fa | b86458fe524c5c94a287eab4c15ead1cdfeed5e6 | /librarys/src/main/java/com/library/book/BookApplication.java | 0a24e404f703e18dc9aeb7aef6091435fb5180f8 | [] | no_license | swastika1/library-management | f2bd3295568be948ff0ebe9d828d9d42d3bda438 | 6f331d3aec91007d3e53a224e903f55c9199a447 | refs/heads/master | 2020-04-03T09:16:55.494819 | 2018-10-29T06:10:15 | 2018-10-29T06:10:15 | 155,160,087 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 304 | java | package com.library.book;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BookApplication {
public static void main(String[] args) {
SpringApplication.run(BookApplication.class, args);
}
}
| [
"Dell@DESKTOP-S1344IK"
] | Dell@DESKTOP-S1344IK |
129554d6bc4570c13a820ab210d32e1b757dfa00 | bf2759ff78102c92b878211b4a8eabbceed03954 | /NailNews/src/com/nail/news/activity/PicturesActivity.java | 9fe9e1cfef94575794b421feacc7dfa55359262e | [] | no_license | lihaifeng14/nail | 11f9ba8eba738e9cfd7aef3621f5387e3a1f3089 | 145f52cb3d6d79f378fecfb4f73bdfdc2e48e4a2 | refs/heads/master | 2016-09-06T02:55:36.316837 | 2015-02-28T10:49:22 | 2015-02-28T10:49:22 | 22,705,690 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,142 | java | package com.nail.news.activity;
import java.util.List;
import com.nail.core.imageloader.ImageLoader;
import com.nail.news.R;
import com.nail.news.data.NewsDetailData;
import com.nail.news.data.NewsItemData.SlideData;
import com.nail.news.fragment.BaseFragment;
import com.nail.news.fragment.PicNewsFragment;
import com.nail.news.manager.NewsDetailManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.content.Intent;
public class PicturesActivity extends FragmentActivity implements
NewsDetailManager.NewDetailCallback, View.OnClickListener, BaseFragment.NotifyFragment,
ViewPager.OnPageChangeListener {
public static final String EXTRA_DOCUMENT_ID = "extra_document_id";
public static final String EXTRA_COMMENTS_COUNT = "extra_comments_count";
private NewsDetailManager mManager;
private String mDocumentId;
private String mCommentUrl;
private View mBackView;
private View mCommentsView;
private TextView mComments;
private TextView mTextTitle;
private TextView mTextNumber;
private TextView mTextContent;
private ViewPager mPager;
private List<SlideData> mSlideData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pictures);
mManager = NewsDetailManager.getInstance();
mBackView = findViewById(R.id.button_back);
mBackView.setOnClickListener(this);
mCommentsView = findViewById(R.id.button_comments);
mComments = (TextView)findViewById(R.id.text_comments);
mComments.setText(getIntent().getIntExtra(EXTRA_COMMENTS_COUNT, 0)+"评论");
mCommentsView.setOnClickListener(this);
mTextContent = (TextView)findViewById(R.id.picture_content);
mTextNumber = (TextView)findViewById(R.id.picture_num);
mTextTitle = (TextView)findViewById(R.id.picture_title);
mTextContent.setMovementMethod(ScrollingMovementMethod.getInstance());
mPager = (ViewPager)findViewById(R.id.pictures_pager);
mDocumentId = getIntent().getStringExtra(EXTRA_DOCUMENT_ID);
mManager.getDetailData(mDocumentId, this);
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.button_back:
finish();
break;
case R.id.button_comments:
if (mCommentUrl == null) {
return;
}
Intent intent = new Intent(this, CommentsActivity.class);
intent.putExtra(CommentsActivity.EXTRA_COMMENTS_URL, mCommentUrl);
startActivity(intent);
}
}
@Override
public void onDetailCallback(NewsDetailData data) {
mSlideData = data.getData().getBody().getSlides();
mCommentUrl = data.getData().getBody().getCommentsUrl();
FragmentPagerAdapter adapter = new PicturesPageAdapter(getSupportFragmentManager());
mPager.setAdapter(adapter);
mPager.setOnPageChangeListener(this);
updatePictureTitle(0);
}
@Override
public void onDetailFailed() {
}
@Override
public void onFragmentAttached(BaseFragment fragment) {
}
@Override
public void onFragmentCreatedView(BaseFragment fragment) {
}
public class PicturesPageAdapter extends FragmentPagerAdapter {
public PicturesPageAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int arg0) {
return new PicturesFragment();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
PicturesFragment fragment = (PicturesFragment)(super.instantiateItem(container, position));
if (mSlideData != null) {
fragment.setUrl(mSlideData.get(position).getImage());
}
return fragment;
}
@Override
public int getCount() {
if (mSlideData != null) {
return mSlideData.size();
}
return 0;
}
}
public static class PicturesFragment extends BaseFragment {
private String mPictureUrl;
private ImageLoader mImageLoader;
public void setUrl(String url) {
mPictureUrl = url;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mImageLoader = ImageLoader.getInstance(mActivity.getApplicationContext());
View view = inflater.inflate(R.layout.item_picture_pager, null);
ImageView imageView = (ImageView)view.findViewById(R.id.picture_pager);
mImageLoader.displayImage(mPictureUrl, imageView, R.drawable.item_picture_background_default, null);
return view;
}
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageSelected(int arg0) {
updatePictureTitle(arg0);
}
private void updatePictureTitle(int position) {
if (mSlideData == null || mSlideData.size() <= position) {
return;
}
SlideData data = mSlideData.get(position);
mTextContent.setText(data.getDescription());
mTextTitle.setText(data.getTitle());
mTextNumber.setText(String.valueOf(position+1)+"/"+mSlideData.size());
}
} | [
"lihaifeng08@163.com"
] | lihaifeng08@163.com |
4bbda2c6826967c35b15bd36ef4fe04e21ea1018 | 816e81f83a489e1f8b74accf10b77300c43ee26d | /PortfolioApp2/PortfolioApp2.Android/obj/Debug/90/android/src/crc646a24be1569a84e80/MainActivity.java | eb9d1e9937d1a656b283d293f5e44aae50374e81 | [] | no_license | ChrisPDev/PortfolioApp2 | cc2b8e2db38b7d5eed8e0080219f075bdc55bd97 | faea121dc36b5a706d2079b3339d4ceefb5571b0 | refs/heads/master | 2023-02-15T05:24:55.196682 | 2021-01-08T08:14:56 | 2021-01-08T08:14:56 | 327,568,038 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,450 | java | package crc646a24be1569a84e80;
public class MainActivity
extends crc643f46942d9dd1fff9.FormsAppCompatActivity
implements
mono.android.IGCUserPeer
{
/** @hide */
public static final String __md_methods;
static {
__md_methods =
"n_onCreate:(Landroid/os/Bundle;)V:GetOnCreate_Landroid_os_Bundle_Handler\n" +
"n_onRequestPermissionsResult:(I[Ljava/lang/String;[I)V:GetOnRequestPermissionsResult_IarrayLjava_lang_String_arrayIHandler\n" +
"";
mono.android.Runtime.register ("PortfolioApp2.Droid.MainActivity, PortfolioApp2.Android", MainActivity.class, __md_methods);
}
public MainActivity ()
{
super ();
if (getClass () == MainActivity.class)
mono.android.TypeManager.Activate ("PortfolioApp2.Droid.MainActivity, PortfolioApp2.Android", "", this, new java.lang.Object[] { });
}
public void onCreate (android.os.Bundle p0)
{
n_onCreate (p0);
}
private native void n_onCreate (android.os.Bundle p0);
public void onRequestPermissionsResult (int p0, java.lang.String[] p1, int[] p2)
{
n_onRequestPermissionsResult (p0, p1, p2);
}
private native void n_onRequestPermissionsResult (int p0, java.lang.String[] p1, int[] p2);
private java.util.ArrayList refList;
public void monodroidAddReference (java.lang.Object obj)
{
if (refList == null)
refList = new java.util.ArrayList ();
refList.add (obj);
}
public void monodroidClearReferences ()
{
if (refList != null)
refList.clear ();
}
}
| [
"CMPe.skp"
] | CMPe.skp |
2f9067ad2df4c30791cc0c8d3ccef3270c8f9458 | 3122ac39f1ce0a882b48293a77195476299c2a3b | /clients/jaxrs-resteasy/generated/src/gen/java/org/openapitools/api/ApiOriginFilter.java | fe87c6fb12c3d94113d5a38c6695ef2c0468c0c0 | [
"MIT"
] | permissive | miao1007/swaggy-jenkins | 4e6fe28470eda2428cbc584dcd365a21caa606ef | af79438c120dd47702b50d51c42548b4db7fd109 | refs/heads/master | 2020-08-30T16:50:27.474383 | 2019-04-10T13:47:17 | 2019-04-10T13:47:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 914 | java | package org.openapitools.api;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyServerCodegen", date = "2019-04-10T13:31:53.770Z[GMT]")
public class ApiOriginFilter implements javax.servlet.Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("Access-Control-Allow-Origin", "*");
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
res.addHeader("Access-Control-Allow-Headers", "Content-Type");
chain.doFilter(request, response);
}
public void destroy() {}
public void init(FilterConfig filterConfig) throws ServletException {}
}
| [
"cliffano@gmail.com"
] | cliffano@gmail.com |
82112a6fc76507507316915c1cf8be96f5968c7b | 73c5f5a5545036967df0d5ddf2cbfaa97fbe49ed | /src/src/com/rapidminer/operator/learner/tree/SingleLabelTermination.java | 5aea851b9af1eb0bd8813d646933b4a656cfded6 | [] | no_license | hejiming/rapiddataminer | 74b103cb4523ccba47150045c165dc384cf7d38f | 177e15fa67dee28b311f6d9176bbfeedae6672e2 | refs/heads/master | 2021-01-10T11:35:48.036839 | 2015-12-31T12:29:43 | 2015-12-31T12:29:43 | 48,233,639 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,755 | java | /*
* RapidMiner
*
* Copyright (C) 2001-2008 by Rapid-I and the contributors
*
* Complete list of developers available at our web site:
*
* http://rapid-i.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.rapidminer.operator.learner.tree;
import com.rapidminer.example.Attribute;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.example.Statistics;
/**
* This criterion terminates if only one single label is left.
*
* @author Sebastian Land, Ingo Mierswa
* @version $Id: SingleLabelTermination.java,v 1.5 2008/05/09 19:22:52 ingomierswa Exp $
*/
public class SingleLabelTermination implements Terminator {
public SingleLabelTermination() {}
public boolean shouldStop(ExampleSet exampleSet, int depth) {
Attribute label = exampleSet.getAttributes().getLabel();
exampleSet.recalculateAttributeStatistics(label);
return exampleSet.size() == exampleSet.getStatistics(label, Statistics.COUNT, label.getMapping().mapIndex((int)exampleSet.getStatistics(label, Statistics.MODE)));
}
}
| [
"dao.xiang.cun@163.com"
] | dao.xiang.cun@163.com |
d561a7be060586676f0448fe3896bc413079ad27 | 987b2d174fc57c68921490bf4bcea17a6fb9083a | /studentdal/src/main/java/com/shalini/student/swaggerConfig.java | a5057cdc206a8ca5bcd4258625f1f4e914c7a35f | [] | no_license | Shalini-1973/studentdal | fda72f2fbc367f79a2f7c0b384b88240cc004a45 | 05fbb547e1a61098da4ddba87c590e782dfce76b | refs/heads/main | 2023-02-28T17:12:07.542222 | 2021-02-05T21:07:54 | 2021-02-05T21:07:54 | 336,385,170 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 706 | java | package com.shalini.student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.google.common.base.Predicates;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class swaggerConfig {
@Bean
public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot"))).build();
}
}
| [
"shali@DESKTOP-HVNT3OB"
] | shali@DESKTOP-HVNT3OB |
56b7da89a32eec06df5d43a5cbe95b376c6da00a | c5de4efe967bb9f6e743f0f484a3da70cc22c016 | /app/src/main/java/com/inovaufrpe/makeparty/infra/utils/bibliotecalivroandroid/utils/RevealEffect.java | df8d21334fe4921b4841ce227c72a2fbac4fc0cc | [] | no_license | Kimbellyf/MakeParty | 0ccdfdbf77face5bc895c06a6028101537d8f54a | 3212fe885ead62e4ce2e603ddb627be4072dce2e | refs/heads/dev | 2020-03-30T13:15:23.932032 | 2018-11-21T04:11:58 | 2018-11-21T04:11:58 | 151,265,866 | 3 | 2 | null | 2018-11-21T04:12:54 | 2018-10-02T14:12:29 | Java | UTF-8 | Java | false | false | 1,876 | java | package com.inovaufrpe.makeparty.infra.utils.bibliotecalivroandroid.utils;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.ViewAnimationUtils;
/**
* Created by Ricardo Lecheta on 28/12/2014.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class RevealEffect {
public static void show(View view, long animDuration) {
// Centro da view
int cx = (view.getLeft() + view.getRight()) / 2;
int cy = (view.getTop() + view.getBottom()) / 2;
// Define o arco para a animação
int finalRadius = Math.max(view.getWidth(), view.getHeight());
// Cria a animação
Animator anim =
ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
// Inicia a animação
view.setVisibility(View.VISIBLE);
anim.setDuration(animDuration);
anim.start();
}
public static void hide(final View view, long animDuration) {
// Centro da view
int cx = (view.getLeft() + view.getRight()) / 2;
int cy = (view.getTop() + view.getBottom()) / 2;
// Define o arco para a animação
int initialRadius = view.getWidth();
// Cria a animação
Animator anim =
ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0);
// Quando a animação terminar, esconde a view
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.INVISIBLE);
}
});
// Inicia a animação
anim.setDuration(animDuration);
anim.start();
}
}
| [
"kimbelly_emanuelle@hotmail.com"
] | kimbelly_emanuelle@hotmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.