blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
โ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d0f4985659749a2870e392690631c53784c47898 | ac194cbd5cbfbdb9c227d890cc7fd2a09aabd75e | /oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/ttl/DataTTLKeeperTimer.java | 98a08b3eb7f8c46de7a0464ddcc0fabd73c72920 | [
"BSD-3-Clause",
"MIT",
"Apache-2.0"
]
| permissive | wansongzhang/incubator-skywalking | c0ed7f8a1761b39ca47b893951dfca3c2c7cf2c9 | 7bb577a4e900c7f747a3e665b448f1ca1d93c415 | refs/heads/master | 2020-04-02T13:17:45.645951 | 2018-10-22T12:20:29 | 2018-10-22T12:20:29 | 154,475,292 | 1 | 0 | Apache-2.0 | 2018-10-24T09:34:39 | 2018-10-24T09:34:39 | null | UTF-8 | Java | false | false | 6,205 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.oap.server.core.storage.ttl;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.*;
import lombok.Setter;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
import org.apache.skywalking.oap.server.core.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.record.Record;
import org.apache.skywalking.oap.server.core.cluster.*;
import org.apache.skywalking.oap.server.core.config.DownsamplingConfigService;
import org.apache.skywalking.oap.server.core.storage.*;
import org.apache.skywalking.oap.server.core.storage.model.*;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.joda.time.DateTime;
import org.slf4j.*;
/**
* @author peng-yongsheng
*/
public enum DataTTLKeeperTimer {
INSTANCE;
private static final Logger logger = LoggerFactory.getLogger(DataTTLKeeperTimer.class);
private ModuleManager moduleManager;
private ClusterNodesQuery clusterNodesQuery;
@Setter private DataTTL dataTTL;
public void start(ModuleManager moduleManager) {
this.moduleManager = moduleManager;
this.clusterNodesQuery = moduleManager.find(ClusterModule.NAME).getService(ClusterNodesQuery.class);
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(
new RunnableWithExceptionProtection(this::delete,
t -> logger.error("Remove data in background failure.", t)), 1, 5, TimeUnit.MINUTES);
}
private void delete() {
List<RemoteInstance> remoteInstances = clusterNodesQuery.queryRemoteNodes();
if (CollectionUtils.isNotEmpty(remoteInstances) && !remoteInstances.get(0).isSelf()) {
logger.info("The selected first address is {}. Skip.", remoteInstances.get(0).toString());
return;
}
TimeBuckets timeBuckets = convertTimeBucket(new DateTime());
logger.info("Beginning to remove expired metrics from the storage.");
logger.info("Metrics in minute dimension before {}, are going to be removed.", timeBuckets.minuteTimeBucketBefore);
logger.info("Metrics in hour dimension before {}, are going to be removed.", timeBuckets.hourTimeBucketBefore);
logger.info("Metrics in day dimension before {}, are going to be removed.", timeBuckets.dayTimeBucketBefore);
logger.info("Metrics in month dimension before {}, are going to be removed.", timeBuckets.monthTimeBucketBefore);
IModelGetter modelGetter = moduleManager.find(CoreModule.NAME).getService(IModelGetter.class);
DownsamplingConfigService downsamplingConfigService = moduleManager.find(CoreModule.NAME).getService(DownsamplingConfigService.class);
List<Model> models = modelGetter.getModels();
models.forEach(model -> {
if (model.isIndicator()) {
execute(model.getName(), timeBuckets.minuteTimeBucketBefore, Indicator.TIME_BUCKET);
if (downsamplingConfigService.shouldToHour()) {
execute(model.getName() + Const.ID_SPLIT + Downsampling.Hour.getName(), timeBuckets.hourTimeBucketBefore, Indicator.TIME_BUCKET);
}
if (downsamplingConfigService.shouldToDay()) {
execute(model.getName() + Const.ID_SPLIT + Downsampling.Day.getName(), timeBuckets.dayTimeBucketBefore, Indicator.TIME_BUCKET);
}
if (downsamplingConfigService.shouldToMonth()) {
execute(model.getName() + Const.ID_SPLIT + Downsampling.Month.getName(), timeBuckets.monthTimeBucketBefore, Indicator.TIME_BUCKET);
}
} else {
execute(model.getName(), timeBuckets.recordDataTTL, Record.TIME_BUCKET);
}
});
}
TimeBuckets convertTimeBucket(DateTime currentTime) {
TimeBuckets timeBuckets = new TimeBuckets();
timeBuckets.recordDataTTL = Long.valueOf(currentTime.plusMinutes(0 - dataTTL.getRecordDataTTL()).toString("yyyyMMddHHmm"));
timeBuckets.minuteTimeBucketBefore = Long.valueOf(currentTime.plusMinutes(0 - dataTTL.getMinuteMetricsDataTTL()).toString("yyyyMMddHHmm"));
timeBuckets.hourTimeBucketBefore = Long.valueOf(currentTime.plusHours(0 - dataTTL.getHourMetricsDataTTL()).toString("yyyyMMddHH"));
timeBuckets.dayTimeBucketBefore = Long.valueOf(currentTime.plusDays(0 - dataTTL.getDayMetricsDataTTL()).toString("yyyyMMdd"));
timeBuckets.monthTimeBucketBefore = Long.valueOf(currentTime.plusMonths(0 - dataTTL.getMonthMetricsDataTTL()).toString("yyyyMM"));
return timeBuckets;
}
private void execute(String modelName, long timeBucketBefore, String timeBucketColumnName) {
try {
moduleManager.find(StorageModule.NAME).getService(IHistoryDeleteDAO.class).deleteHistory(modelName, timeBucketColumnName, timeBucketBefore);
} catch (IOException e) {
logger.warn("History delete failure, error message: {}", e.getMessage());
}
}
class TimeBuckets {
private long recordDataTTL;
private long minuteTimeBucketBefore;
private long hourTimeBucketBefore;
private long dayTimeBucketBefore;
private long monthTimeBucketBefore;
}
} | [
"[email protected]"
]
| |
2d545de12df3ba7156c0c39666c0c8f9c0821015 | d7f9985c3049e663c4070c2efa0a15d7b3fb46c4 | /DequeuePopHandler.java | 756034ab4cf83c02810cf362a54c751ecb021893 | []
| no_license | Aviel212/StackAndQueue | f7a1a7e811000cb5e7ebee439eea415a02472aec | 4251b4a1f39747f3f61e73e9269e97c86046157c | refs/heads/master | 2020-03-13T16:41:53.840093 | 2018-05-04T22:49:31 | 2018-05-04T22:49:31 | 131,204,175 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,641 | java | import javax.swing.JOptionPane;
/**
*This class defines two overloaded constructors, in order to match the overloaded constructors
*in 'GeneralHandler' class. And responsible to delete one element from the Stack/Queue
*/
public class DequeuePopHandler extends GeneralHandler{
/**DequeuePopHandler constructor, initializes a new DequeuePopHandler
*@param intQ the reference to a Queue of Integers
*/
public DequeuePopHandler(Queue<Integer> intQ){
super(intQ);
}
/**DequeuePopHandler constructor, initializes a new DequeuePopHandler
*@param intSt the reference to a Stack of Integers
*/
public DequeuePopHandler(Stack<Integer> intSt){
super(intSt);
}
@Override
/**This method implements the abstact method "processRequest",
*inherited from GeneralHandler class. This method Dequeue/Pop an item from
*the Queue/Stack respectively, and presents message to the user,
*if the examined Queue/Stack is empty, issues an appropriate message to the user
*/
public void processRequest(){
JOptionPane dialog = new JOptionPane();
String action=null,type=null;
int val=0;
if(intQ==null){
action="pop";
type="Stack";
if(intSt.isEmpty()){
dialog.showMessageDialog(null,"The "+type+" is Empty!!!!");
return;
}
else val = intSt.pop();
}
else {
action="dequeue";
type="Queue";
if(intQ.isEmpty()){
dialog.showMessageDialog(null,"The "+type+" is Empty!!!!"); //check about writing the same twice
return;
}
else val = intQ.dequeue();
}
dialog.showMessageDialog(null,"value "+action+" from "+ type +" is: "+ val);
}
} | [
"[email protected]"
]
| |
72d4cfa089506f0b99ae3e09dff44d8266d3823c | 39b45cc5f6fe57ce184fd9a3a9e7afdbf572eaf8 | /bmh/src/etsy/PaymentTemplate.java | 9f29f426b22e5573ccbc315ed0bdf94f54a2d343 | []
| no_license | madale2010/Online-Shop | 80d518a47d8a514363078f82ecfab9e25f0015f5 | f0f951324f0b38834c032249bd8da8aab5286d14 | refs/heads/master | 2023-03-23T11:11:51.857329 | 2021-03-19T00:26:31 | 2021-03-19T00:26:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,202 | java | package etsy;
public class PaymentTemplate {
private int payment_templateId;
private boolean allowBt;
private boolean allowCheck;
private boolean allowMo;
private boolean allowOther;
private boolean allowPaypal;
private boolean allowCc;
private String paypalEmail;
private String name;
private String firstLine;
private String secondLine;
private String city;
private String state;
private String zip;
private int countryId;
private int userId;
private int listingPaymentId;
/**
* @return the payment_templateId
*/
public int getPayment_templateId() {
return payment_templateId;
}
/**
* @param payment_templateId the payment_templateId to set
*/
public void setPayment_templateId(int payment_templateId) {
this.payment_templateId = payment_templateId;
}
/**
* @return the allowBt
*/
public boolean isAllowBt() {
return allowBt;
}
/**
* @param allowBt the allowBt to set
*/
public void setAllowBt(boolean allowBt) {
this.allowBt = allowBt;
}
/**
* @return the allowCheck
*/
public boolean isAllowCheck() {
return allowCheck;
}
/**
* @param allowCheck the allowCheck to set
*/
public void setAllowCheck(boolean allowCheck) {
this.allowCheck = allowCheck;
}
/**
* @return the allowMo
*/
public boolean isAllowMo() {
return allowMo;
}
/**
* @param allowMo the allowMo to set
*/
public void setAllowMo(boolean allowMo) {
this.allowMo = allowMo;
}
/**
* @return the allowOther
*/
public boolean isAllowOther() {
return allowOther;
}
/**
* @param allowOther the allowOther to set
*/
public void setAllowOther(boolean allowOther) {
this.allowOther = allowOther;
}
/**
* @return the allowPaypal
*/
public boolean isAllowPaypal() {
return allowPaypal;
}
/**
* @param allowPaypal the allowPaypal to set
*/
public void setAllowPaypal(boolean allowPaypal) {
this.allowPaypal = allowPaypal;
}
/**
* @return the allowCc
*/
public boolean isAllowCc() {
return allowCc;
}
/**
* @param allowCc the allowCc to set
*/
public void setAllowCc(boolean allowCc) {
this.allowCc = allowCc;
}
/**
* @return the paypalEmail
*/
public String getPaypalEmail() {
return paypalEmail;
}
/**
* @param paypalEmail the paypalEmail to set
*/
public void setPaypalEmail(String paypalEmail) {
this.paypalEmail = paypalEmail;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the firstLine
*/
public String getFirstLine() {
return firstLine;
}
/**
* @param firstLine the firstLine to set
*/
public void setFirstLine(String firstLine) {
this.firstLine = firstLine;
}
/**
* @return the secondLine
*/
public String getSecondLine() {
return secondLine;
}
/**
* @param secondLine the secondLine to set
*/
public void setSecondLine(String secondLine) {
this.secondLine = secondLine;
}
/**
* @return the city
*/
public String getCity() {
return city;
}
/**
* @param city the city to set
*/
public void setCity(String city) {
this.city = city;
}
/**
* @return the state
*/
public String getState() {
return state;
}
/**
* @param state the state to set
*/
public void setState(String state) {
this.state = state;
}
/**
* @return the zip
*/
public String getZip() {
return zip;
}
/**
* @param zip the zip to set
*/
public void setZip(String zip) {
this.zip = zip;
}
/**
* @return the countryId
*/
public int getCountryId() {
return countryId;
}
/**
* @param countryId the countryId to set
*/
public void setCountryId(int countryId) {
this.countryId = countryId;
}
/**
* @return the userId
*/
public int getUserId() {
return userId;
}
/**
* @param userId the userId to set
*/
public void setUserId(int userId) {
this.userId = userId;
}
/**
* @return the listingPaymentId
*/
public int getListingPaymentId() {
return listingPaymentId;
}
/**
* @param listingPaymentId the listingPaymentId to set
*/
public void setListingPaymentId(int listingPaymentId) {
this.listingPaymentId = listingPaymentId;
}
/**
*Retrieves the PaymentTemplate associated with the Shop
*/
public static void findShopPaymentTemplates(String shopId){EtsyService.getService("/shops/"+shopId+"/payment_templates");}
/**
*Creates a new PaymentTemplate
*/
public static void createShopPaymentTemplate(String shopId){EtsyService.postService("/shops/"+shopId+"/payment_templates");}
/**
*Updates a PaymentTemplate
*/
public static void updateShopPaymentTemplate(String shopId, int paymentTemplateId){EtsyService.putService("/shops/"+shopId+"/payment_templates/"+paymentTemplateId);}
/**
*Retrieves a set of PaymentTemplate objects associated to a User.
*/
public static void getAllUserPaymentTemplates(String userId){EtsyService.getService("/users/"+userId+"/payments/templates");}
}
| [
"[email protected]"
]
| |
127b81928b0745355bdb966d8b63777baa4172cf | f9aa29d844f0b47fa2efed5c55166c4d9fab5723 | /algorithm/java/src/leetcode/binarySearch/SearchA2DMatrix.java | b3a2dff134f8ecf43b787cd29d5643947ad46e3a | []
| no_license | Sung-jin/study | a27dc0f5832592afbbb9de2c78c7f39b36b65555 | ac3de63139c7dd298c484c78bc5cb5adb2173817 | refs/heads/master | 2023-09-04T10:48:36.488256 | 2023-09-03T13:36:07 | 2023-09-03T13:36:07 | 142,510,582 | 0 | 1 | null | 2023-03-05T22:48:42 | 2018-07-27T01:04:56 | Java | UTF-8 | Java | false | false | 2,200 | java | package leetcode.binarySearch;
/*
Q.74 Search a 2D Matrix
You are given an m x n integer matrix matrix with the following two properties:
Each row is sorted in non-decreasing order.
The first integer of each row is greater than the last integer of the previous row.
Given an integer target, return true if target is in matrix or false otherwise.
You must write a solution in O(log(m * n)) time complexity.
*/
public class SearchA2DMatrix {
public boolean searchMatrix(int[][] matrix, int target) {
int[] row = findRow(matrix, target);
return isContainTarget(row, target);
}
private int[] findRow(int[][] matrix, int target) {
if (matrix.length == 1) return matrix[0];
int s = 0, e = matrix.length - 1;
while (s < e) {
int mid = (s + e) / 2;
int[] targetMatrix = matrix[mid];
if (targetMatrix[0] <= target && targetMatrix[targetMatrix.length - 1] >= target) return targetMatrix;
else if (targetMatrix[0] < target) s = mid - 1;
else e = mid;
}
return new int[]{};
}
private boolean isContainTarget(int[] row, int target) {
if (row.length == 0) return false;
if (row.length == 1 && row[0] == target) return true;
int l = 0, r = row.length - 1;
while (l < r) {
int mid = (l + r) / 2;
if (row[mid] == target) return true;
else if (row[mid] > target) r = mid - 1;
else l = mid;
}
return false;
}
}
/*
public boolean searchMatrix(int[][] matrix, int target) {
int row_num = matrix.length;
int col_num = matrix[0].length;
int begin = 0, end = row_num * col_num - 1;
while(begin <= end){
int mid = (begin + end) / 2;
int mid_value = matrix[mid/col_num][mid%col_num];
if( mid_value == target){
return true;
}else if(mid_value < target){
//Should move a bit further, otherwise dead loop.
begin = mid+1;
}else{
end = mid-1;
}
}
return false;
}
// 2 ์ฐจ์ ๋ฐฐ์ด์ด๋ผ๊ณ ํ๋๋ผ๋, ์ ์ฒด์ ์ผ๋ก ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ ๋์ด ์๊ธฐ ๋๋ฌธ์,
// ํ๋์ ๋ฐฐ์ด๋ก ํ๋จํ์ฌ binary search ๋ฅผ ํ๋ฉด ๋๋ค.
*/ | [
"[email protected]"
]
| |
9eec8859d5fa77f4fc2ee1a2522aa4ab41ce40df | 541565c863de82445094d531a74f27911a995ee6 | /src/test/java/vip/aquan/annotationdemo/AnnotationdemoApplicationTests.java | cc9993e6aa6f7529dcc9fa42c7273ba407518bb4 | []
| no_license | chupeigege/AnnotationDemo | db5dd75d481f6da25a2b5090c9fa8b75a1833f41 | 96cade23ce7d21d4edf04d66930c52d168c6d9b6 | refs/heads/master | 2022-10-07T00:05:16.527751 | 2022-09-12T06:18:29 | 2022-09-12T06:18:29 | 249,148,402 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package vip.aquan.annotationdemo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class AnnotationdemoApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
]
| |
31365142fd5aa55e25f60fa09fe32ddb15025a56 | 473fc28d466ddbe9758ca49c7d4fb42e7d82586e | /app/src/main/java/com/syd/source/aosp/external/mockito/src/test/java/org/mockito/internal/stubbing/answers/ReturnsArgumentAtTest.java | f72005aeaa706b132819b701bc3ce00b8ce4eb4c | [
"MIT",
"Apache-2.0"
]
| permissive | lz-purple/Source | a7788070623f2965a8caa3264778f48d17372bab | e2745b756317aac3c7a27a4c10bdfe0921a82a1c | refs/heads/master | 2020-12-23T17:03:12.412572 | 2020-01-31T01:54:37 | 2020-01-31T01:54:37 | 237,205,127 | 4 | 2 | null | null | null | null | UTF-8 | Java | false | false | 9,964 | java | /*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.stubbing.answers;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.mockito.exceptions.base.MockitoException;
import org.mockito.exceptions.misusing.WrongTypeOfReturnValue;
import org.mockito.internal.invocation.InvocationBuilder;
import org.mockito.invocation.Invocation;
import org.mockito.invocation.InvocationOnMock;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
public class ReturnsArgumentAtTest {
@Test
public void should_be_able_to_return_the_first_parameter() throws Throwable {
assertThat(new ReturnsArgumentAt(0).answer(invocationWith("A", "B"))).isEqualTo("A");
}
@Test
public void should_be_able_to_return_the_second_parameter()
throws Throwable {
assertThat(new ReturnsArgumentAt(1).answer(invocationWith("A", "B", "C"))).isEqualTo("B");
}
@Test
public void should_be_able_to_return_the_last_parameter() throws Throwable {
assertThat(new ReturnsArgumentAt(-1).answer(invocationWith("A"))).isEqualTo("A");
assertThat(new ReturnsArgumentAt(-1).answer(invocationWith("A", "B"))).isEqualTo("B");
}
@Test
public void should_be_able_to_return_the_specified_parameter() throws Throwable {
assertThat(new ReturnsArgumentAt(0).answer(invocationWith("A", "B", "C"))).isEqualTo("A");
assertThat(new ReturnsArgumentAt(1).answer(invocationWith("A", "B", "C"))).isEqualTo("B");
assertThat(new ReturnsArgumentAt(2).answer(invocationWith("A", "B", "C"))).isEqualTo("C");
}
@Test
public void should_identify_bad_parameter_type_for_invocation() throws Exception {
try {
new ReturnsArgumentAt(1).validateFor(new InvocationBuilder().method("varargsReturningString")
.argTypes(Object[].class)
.args(new Object(), new Object(), new Object())
.toInvocation());
Assertions.fail("should scream");
} catch (WrongTypeOfReturnValue ignored) { }
try {
new ReturnsArgumentAt(0).validateFor(new InvocationBuilder().method("oneArray")
.argTypes(boolean[].class)
.args(true, false, false)
.toInvocation());
Assertions.fail("should scream");
} catch (WrongTypeOfReturnValue ignored) { }
try {
new ReturnsArgumentAt(0).validateFor(new InvocationBuilder().method("mixedVarargsReturningString")
.argTypes(Object.class, String[].class)
.args(new Object(), new String[]{"A", "B", "C"})
.toInvocation());
Assertions.fail("should scream");
} catch (WrongTypeOfReturnValue ignored) { }
}
@Test
public void should_not_scream_when_mixed_vararg_parameter_is_compatible_with_invocation() throws Exception {
new ReturnsArgumentAt(1).validateFor(new InvocationBuilder().method("mixedVarargsReturningString")
.argTypes(Object.class, String[].class)
.args(new Object(), new String[]{"A", "B", "C"})
.toInvocation());
}
@Test
public void should_handle_returning_vararg_as_array() throws Throwable {
Invocation mixedVarargsReturningStringArray = new InvocationBuilder().method("mixedVarargsReturningStringArray")
.argTypes(Object.class, String[].class)
.args(new Object(), new String[]{"A", "B", "C"})
.toInvocation();
new ReturnsArgumentAt(1).validateFor(mixedVarargsReturningStringArray);
assertThat(new ReturnsArgumentAt(1).answer(mixedVarargsReturningStringArray)).isEqualTo(new String[]{"A", "B", "C"});
Invocation mixedVarargsReturningObjectArray = new InvocationBuilder().method("mixedVarargsReturningStringArray")
.argTypes(Object.class, String[].class)
.args(new Object(), new String[]{"A", "B", "C"})
.toInvocation();
new ReturnsArgumentAt(1).validateFor(mixedVarargsReturningObjectArray);
assertThat(new ReturnsArgumentAt(1).answer(mixedVarargsReturningObjectArray)).isEqualTo(new String[]{"A", "B", "C"});
}
@Test
public void should_raise_an_exception_if_index_is_not_in_allowed_range_at_creation_time() throws Throwable {
try {
new ReturnsArgumentAt(-30);
fail();
} catch (Exception e) {
assertThat(e.getMessage()).containsIgnoringCase("argument index")
.containsIgnoringCase("positive number")
.contains("1")
.containsIgnoringCase("last argument");
}
}
@Test
public void should_allow_possible_argument_types() throws Exception {
new ReturnsArgumentAt(0).validateFor(
new InvocationBuilder().method("intArgumentReturningInt")
.argTypes(int.class)
.arg(1000)
.toInvocation()
);
new ReturnsArgumentAt(0).validateFor(
new InvocationBuilder().method("toString")
.argTypes(String.class)
.arg("whatever")
.toInvocation()
);
new ReturnsArgumentAt(2).validateFor(
new InvocationBuilder().method("varargsObject")
.argTypes(int.class, Object[].class)
.args(1000, "Object", "Object")
.toInvocation()
);
new ReturnsArgumentAt(1).validateFor(
new InvocationBuilder().method("threeArgumentMethod")
.argTypes(int.class, Object.class, String.class)
.args(1000, "Object", "String")
.toInvocation()
);
}
@Test
public void should_fail_if_index_is_not_in_range_for_one_arg_invocation() throws Throwable {
try {
new ReturnsArgumentAt(30).validateFor(new InvocationBuilder().method("oneArg")
.arg("A")
.toInvocation());
fail();
} catch (MockitoException e) {
assertThat(e.getMessage())
.containsIgnoringCase("invalid argument index")
.containsIgnoringCase("iMethods.oneArg")
.containsIgnoringCase("[0] String")
.containsIgnoringCase("position")
.contains("30");
}
}
@Test
public void should_fail_if_index_is_not_in_range_for_example_with_no_arg_invocation() throws Throwable {
try {
new ReturnsArgumentAt(ReturnsArgumentAt.LAST_ARGUMENT).validateFor(
new InvocationBuilder().simpleMethod().toInvocation()
);
fail();
} catch (MockitoException e) {
assertThat(e.getMessage())
.containsIgnoringCase("invalid argument index")
.containsIgnoringCase("iMethods.simpleMethod")
.containsIgnoringCase("no arguments")
.containsIgnoringCase("last parameter wanted");
}
}
@Test
public void should_fail_if_argument_type_of_signature_is_incompatible_with_return_type() throws Throwable {
try {
new ReturnsArgumentAt(2).validateFor(
new InvocationBuilder().method("varargsReturningString")
.argTypes(Object[].class)
.args("anyString", new Object(), "anyString")
.toInvocation()
);
fail();
} catch (WrongTypeOfReturnValue e) {
assertThat(e.getMessage())
.containsIgnoringCase("argument of type")
.containsIgnoringCase("Object")
.containsIgnoringCase("varargsReturningString")
.containsIgnoringCase("should return")
.containsIgnoringCase("String")
.containsIgnoringCase("possible argument indexes");
}
}
private static InvocationOnMock invocationWith(Object... parameters) {
return new InvocationBuilder().method("varargsReturningString")
.argTypes(Object[].class)
.args(parameters).toInvocation();
}
}
| [
"[email protected]"
]
| |
610ef332ae2098a7901960b6d22af5739d5730d9 | 6389d343987b24d387621a60d12b1314287ebdae | /app/AREA/app/src/main/java/com/example/area/Services/Services_action.java | 040e81e437643b7450ee9ea896e4e423ef163aeb | []
| no_license | Auguste0904/AREA | 13144b8c9a682764bb483313b41190474d67eb12 | 67f05b2418ac2fbb4147f1ac7c4f8149a2b8363e | refs/heads/master | 2023-03-25T02:56:35.381775 | 2021-03-19T08:25:31 | 2021-03-19T08:25:31 | 346,635,183 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,011 | java | package com.example.area.Services;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import com.example.area.R;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
import com.example.area.actions.Epitech_action;
import com.example.area.actions.Github_action;
import com.example.area.actions.Gitlab_action;
import com.example.area.actions.Gmail_action;
import com.example.area.actions.Timer_action;
import com.example.area.actions.Trello_action;
import com.example.area.login_register.Epitech_login;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class Services_action extends AppCompatActivity {
OkHttpClient client = new OkHttpClient();
public static final MediaType JSON
= MediaType.parse("application/json; charset=utf-8");
public static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19";
String userInfos;
String token;
String url;
String TriggerJSON;
String ActionJSON;
@Override
public void onBackPressed() {
finish();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.services_action);
// pour rรฉcupรฉrer le token qu'on passe de classe en classe
Intent prevInt = getIntent();
userInfos = prevInt.getStringExtra("json");
TriggerJSON = prevInt.getStringExtra("trigger");
ActionJSON = prevInt.getStringExtra("action");
try {
JSONObject obj = new JSONObject(userInfos);
token = obj.getString("token");
} catch (JSONException e) {
e.printStackTrace();
}
ImageButton githubBtn = findViewById(R.id.github);
githubBtn.setOnClickListener(v -> {
GitAuth();
});
ImageButton gmailBtn = findViewById(R.id.gmail);
gmailBtn.setOnClickListener(v -> {
GoogleAuth();
});
ImageButton gitlabBtn = findViewById(R.id.gitlab);
gitlabBtn.setOnClickListener(v -> {
GitlabAuth();
});
ImageButton timerBtn = findViewById(R.id.timer);
timerBtn.setOnClickListener(v -> {
Intent intent = new Intent(Services_action.this, Timer_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
});
ImageButton trelloBtn = findViewById(R.id.trello);
trelloBtn.setOnClickListener(v -> {
TrelloAuth();
});
ImageButton epitechBtn = findViewById(R.id.epitech);
epitechBtn.setOnClickListener(v -> {
EpitechAuth();
});
ImageButton backBtn = findViewById(R.id.back);
backBtn.setOnClickListener(v -> {onBackPressed();});
}
private void GitAuth() {
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/connexion/getGithub")
.get()
.addHeader("Authorization", "Bearer " + token)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("TEST", "ERROR: failed to get github url");
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
url = response.body().string();
url = url.replace("\"", "");
// ----------------------------------------------
runOnUiThread(() -> {
setContentView(R.layout.web_view);
WebView auth = findViewById(R.id.web);
auth.loadUrl(url);
auth.getSettings().setJavaScriptEnabled(true);
auth.setWebViewClient(new WebViewClient() {
private static final String REDIRECT_URL = "http://localhost:8081";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNow) {
if (urlNow.contains(REDIRECT_URL)) {
Log.e("TEST", urlNow);
splitUrl(urlNow); // Permet de rรฉcupรฉrer le token dans l'url. Pour l'intant je ne fait rien de ce token
Intent intent = new Intent(Services_action.this, Github_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
} else {
view.loadUrl(urlNow);
}
return true;
}
});
});
}
});
}
private void GitlabAuth() {
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/connexion/getGitlab")
.get()
.addHeader("Authorization", "Bearer " + token)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("TEST", "ERROR: failed to get gitlab url");
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
url = response.body().string();
url = url.replace("\"", "");
// ------------------------------------------
runOnUiThread(() -> {
setContentView(R.layout.web_view);
WebView auth = findViewById(R.id.web);
auth.getSettings().setUserAgentString(USER_AGENT);
auth.getSettings().setJavaScriptEnabled(true);
auth.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
auth.loadUrl(url);
auth.setWebViewClient(new WebViewClient() {
private static final String REDIRECT_URL = "http://localhost:8081";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNow) {
if (urlNow.contains(REDIRECT_URL)) {
Log.e("TEST", urlNow);
splitUrl(urlNow); // Permet de rรฉcupรฉrer le token dans l'url. Pour l'intant je ne fait rien de ce token
Intent intent = new Intent(Services_action.this, Gitlab_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
} else {
view.loadUrl(urlNow);
}
return true;
}
});
});
}
});
}
private void GoogleAuth(){
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/user/getGoogle")
.get()
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
runOnUiThread(() -> {
setContentView(R.layout.web_view);
WebView auth = findViewById(R.id.web);
auth.getSettings().setUserAgentString(USER_AGENT);
auth.getSettings().setJavaScriptEnabled(true);
auth.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
try {
auth.setWebViewClient(new WebViewClient() {
private static final String REDIRECT_URL = "http://localhost:8081";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNow) {
if (urlNow.contains(REDIRECT_URL)) {
splitUrl(urlNow); // Permet de rรฉcupรฉrer le token dans l'url. Pour l'intant je ne fait rien de ce token
JSONObject userInfos2 = new JSONObject();
try {
userInfos2.put("code", splitUrl(urlNow));
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(JSON, userInfos2.toString());
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/user/loginGoogle")
.addHeader("Authorization", "Bearer " + token)
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Intent intent = new Intent(Services_action.this, Gmail_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
}
});
} else {
view.loadUrl(urlNow);
}
return true;
}
});
JSONObject obj = new JSONObject(response.body().string());
String url = obj.getString("url");
Log.e("TEST", url);
auth.loadUrl(url);
} catch (IOException | JSONException e) {
e.printStackTrace();
}
});
}
});
}
private void TrelloAuth() {
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/connexion/getTrello ")
.get()
.addHeader("Authorization", "Bearer " + token)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("TEST", "ERROR: failed to get Trello url");
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
url = response.body().string();
url = url.replace("\"", "");
// -------------------------------------------
runOnUiThread(() -> {
setContentView(R.layout.web_view);
WebView auth = findViewById(R.id.web);
auth.getSettings().setUserAgentString(USER_AGENT);
auth.getSettings().setJavaScriptEnabled(true);
auth.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
auth.loadUrl(url);
auth.setWebViewClient(new WebViewClient() {
private static final String REDIRECT_URL = "http://localhost:8081";
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNow) {
if (urlNow.contains(REDIRECT_URL)) {
Log.e("TEST1", urlNow);
splitUrl(urlNow); // Permet de rรฉcupรฉrer le token dans l'url. Pour l'intant je ne fait rien de ce token
JSONObject userInfos2 = new JSONObject();
try {
userInfos2.put("code", splitUrl(urlNow));
} catch (JSONException e) {
e.printStackTrace();
}
Log.e("TEST", userInfos2.toString());
RequestBody body = RequestBody.create(JSON, userInfos2.toString());
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/connexion/loginTrello")
.addHeader("Authorization", "Bearer " + token)
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Intent intent = new Intent(Services_action.this, Trello_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
}
});
} else {
view.loadUrl(urlNow);
}
return true;
}
});
});
}
});
}
private void EpitechAuth() {
setContentView(R.layout.login_epitech);
EditText email = findViewById(R.id.email_epitech);
EditText autolog = findViewById(R.id.autoLogin);
Button valid = findViewById(R.id.valid_btn);
valid.setOnClickListener(v -> {
if (!email.getText().toString().equals("") && !autolog.getText().toString().equals("")) {
JSONObject userInfos2 = new JSONObject();
try {
userInfos2.put("email", email.getText().toString());
userInfos2.put("autolog", autolog.getText().toString());
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody body = RequestBody.create(JSON, userInfos2.toString());
Request request = new Request.Builder()
.url("http://10.0.2.2:8080/api/connexion/loginEpitech ")
.post(body)
.addHeader("Authorization", "Bearer " + token)
.build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("TEST", "ERROR: failed to get Epitech url");
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Log.e("TEST", response.body().string());
Intent intent = new Intent(Services_action.this, Epitech_action.class);
intent.putExtra("json", userInfos);
intent.putExtra("trigger", TriggerJSON);
intent.putExtra("action", ActionJSON);
startActivity(intent);
}
});
}
});
}
private String splitUrl(String url) {
String[] outerSplit = url.split("=");
String accessToken = null;
accessToken = outerSplit[1];
accessToken = accessToken.split("&")[0];
Log.e("TEST", accessToken);
return accessToken;
}
} | [
"[email protected]"
]
| |
fd5b8c5b4fc4ebcb341021295ba05959c9e9a7e4 | 598ce22c4ac54afb7867a4c3b37f74b3f2fefe5e | /assignment3/src/main/java/no/westerdals/student/vegeiv13/innlevering3/utils/ConfigurationHandler.java | f38283ec42c72436951a253fc4d607e2006b9109 | []
| no_license | eivindveg/PG3100-assignments | 30cb64397871d977754daf834d65ed03b522bcb9 | b2d95bbe64c7b1f8392deed28c66c72660da3add | refs/heads/master | 2021-01-19T17:48:20.121386 | 2014-11-23T18:20:32 | 2014-11-23T18:20:32 | 26,766,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,345 | java | package no.westerdals.student.vegeiv13.innlevering3.utils;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
public class ConfigurationHandler {
private static final Object threadLock = new Object();
private static ConfigurationHandler instance;
private final Configuration configuration;
private ConfigurationHandler() {
Configuration tempConf;
try {
tempConf = new XMLConfiguration("config.xml");
} catch (ConfigurationException e) {
try {
tempConf = new XMLConfiguration("conf/config.xml");
} catch (ConfigurationException e1) {
System.err.println("Unable to load configuration, using default values");
tempConf = new XMLConfiguration();
}
}
configuration = tempConf;
}
public static ConfigurationHandler getInstance() {
if (instance == null) {
synchronized (threadLock) {
if (instance == null) {
instance = new ConfigurationHandler();
}
}
}
return instance;
}
public Configuration getConfiguration() {
return configuration;
}
}
| [
"[email protected]"
]
| |
97381ff4f804dfde228860a851fc2fe07b584d8f | 217833fb464893f111196302defd28e41dc3718e | /Student.java | 6ee1c8ab8f972acb36f2156aaa45648cd3f362ac | []
| no_license | nrayapat/Rayapati-Nikhil-Chandra | 8dacf8bd6839217e70b33fb4f90039be9f0cef0d | bb26383ace485e03c1772a0bd774ad46a7eab912 | refs/heads/master | 2020-03-26T16:18:10.361777 | 2018-09-04T05:00:50 | 2018-09-04T05:00:50 | 145,092,765 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 707 | java | package com.capgemini.day6;
public class Student {
private String name;
private int rollno;
private String branch;
public Student() {
super();
// TODO Auto-generated constructor stub
}
public Student(String name, int rollno, String branch) {
super();
this.name = name;
this.rollno = rollno;
this.branch = branch;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getRollno() {
return rollno;
}
public void setRollno(int rollno) {
this.rollno = rollno;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
}
| [
"[email protected]"
]
| |
791260748bfff2fc358cdf0d38596aea50b564b7 | 0229e399fa4de5411a0ae2522d42d9b118026f86 | /TimeCardApplication/src/main/java/com/cg/leavemanagement/model/EmployeeLeaveDetailsEntity.java | c4359a2bfd5c4143b8a30972ae15e15cc81c31fb | []
| no_license | AnushaR508/AnushaSpringProject | 2520ae33721fc9dfe124d5777c61405a05f04b40 | c33c2c982b114681e13c726e081118488e61076a | refs/heads/master | 2023-01-23T19:18:25.674351 | 2020-12-04T06:16:51 | 2020-12-04T06:16:51 | 318,421,335 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,831 | java | package com.cg.leavemanagement.model;
import java.time.LocalDate;
import java.util.Date;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonFormat;
@Entity
public class EmployeeLeaveDetailsEntity {
/**
* Employee Id which is referred as primary key
*/
@Id
private long empId;
/**
* Employee Name
*/
private String empName;
/**
* leave Id with reference to leave type
*/
private int leaveId;
/**
* Employee Leave Type
*/
private String leaveType;
/**
* Start Date of the leave
*/
@JsonFormat(pattern="yyyy-MM-dd")
private LocalDate startDate;
/**
* End Date of the leave
*/
@JsonFormat(pattern="yyyy-MM-dd")
private LocalDate endDate;
/**
* Total available leaves for an employee
*/
private int leaveAvailable;
/**
* Total leaves approved for an employee
*/
private int leaveDebit;
/**
* Total leaves cancelled by an employee
*/
private int leaveCredit;
/**
* Leave Applied status
*/
private int leaveApplied;
/**
* Leave Cancelled status
*/
private int leaveCancelled;
public int getLeaveCredit() {
return leaveCredit;
}
public long getEmpId() {
return empId;
}
public void setEmpId(long empId) {
this.empId = empId;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public void setLeaveCredit(int leaveCredit) {
this.leaveCredit = leaveCredit;
}
public int getLeaveId() {
return leaveId;
}
public void setLeaveId(int leaveId) {
this.leaveId = leaveId;
}
public String getLeaveType() {
return leaveType;
}
public void setLeaveType(String leaveType) {
this.leaveType = leaveType;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
public LocalDate getEndDate() {
return endDate;
}
public void setEndDate(LocalDate endDate) {
this.endDate = endDate;
}
public int getLeaveAvailable() {
return leaveAvailable;
}
public void setLeaveAvailable(int leaveAvailable) {
this.leaveAvailable = leaveAvailable;
}
public int getLeaveDebit() {
return leaveDebit;
}
public void setLeaveDebit(int leaveDebit) {
this.leaveDebit = leaveDebit;
}
public int getLeaveApplied() {
return leaveApplied;
}
public void setLeaveApplied(int leaveApplied) {
this.leaveApplied = leaveApplied;
}
public int getLeaveCancelled() {
return leaveCancelled;
}
public void setLeaveCancelled(int leaveCancelled) {
this.leaveCancelled = leaveCancelled;
}
public EmployeeLeaveDetailsEntity(long empId, String empName,
int leaveId,String leaveType, LocalDate startDate, LocalDate endDate,
int leaveAvailable, int leaveDebit, int leaveCredit, int leaveApplied, int leaveCancelled) {
super();
this.empId = empId;
this.empName = empName;
this.leaveId = leaveId;
this.leaveType = leaveType;
this.startDate = startDate;
this.endDate = endDate;
this.leaveAvailable = leaveAvailable;
this.leaveDebit = leaveDebit;
this.leaveCredit = leaveCredit;
this.leaveApplied = leaveApplied;
this.leaveCancelled = leaveCancelled;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (empId ^ (empId >>> 32));
result = prime * result + ((empName == null) ? 0 : empName.hashCode());
result = prime * result + ((endDate == null) ? 0 : endDate.hashCode());
result = prime * result + leaveApplied;
result = prime * result + leaveAvailable;
result = prime * result + leaveCancelled;
result = prime * result + leaveCredit;
result = prime * result + leaveDebit;
result = prime * result + leaveId;
result = prime * result + ((leaveType == null) ? 0 : leaveType.hashCode());
result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EmployeeLeaveDetailsEntity other = (EmployeeLeaveDetailsEntity) obj;
if (empId != other.empId)
return false;
if (empName == null) {
if (other.empName != null)
return false;
} else if (!empName.equals(other.empName))
return false;
if (endDate == null) {
if (other.endDate != null)
return false;
} else if (!endDate.equals(other.endDate))
return false;
if (leaveApplied != other.leaveApplied)
return false;
if (leaveAvailable != other.leaveAvailable)
return false;
if (leaveCancelled != other.leaveCancelled)
return false;
if (leaveCredit != other.leaveCredit)
return false;
if (leaveDebit != other.leaveDebit)
return false;
if (leaveId != other.leaveId)
return false;
if (leaveType == null) {
if (other.leaveType != null)
return false;
} else if (!leaveType.equals(other.leaveType))
return false;
if (startDate == null) {
if (other.startDate != null)
return false;
} else if (!startDate.equals(other.startDate))
return false;
return true;
}
public EmployeeLeaveDetailsEntity() {
super();
}
@Override
public String toString() {
return "EmployeeLeaveDetailsEntity [EmployeeId=" + empId + ", EmployeeName=" + empName + ", TotalLeaves=24, "
+ ", LeaveDebit=" + leaveDebit + ", LeaveCredit=" + leaveCredit +"\n LeaveBalance = 24"+"-"+"("+leaveDebit+"-"+leaveCredit+")="+leaveAvailable+"]";
}
} | [
"[email protected]"
]
| |
658bd3bcc686dbd3a8070749151bf4951d4fa2a6 | 62774e6de56acf8c4d4d014f1f5ee709feef6502 | /car-dealer2/src/main/java/org/softuni/cardealer/web/controllers/SuppliersController.java | 20a30002439d494eabe9b1f396145be5a4482c58 | []
| no_license | Chris-Mk/Hibernate | 35a9c42679ad6d20925c96d6d3929ad86649f700 | eb338734c0136d5292e06f7ab2688e4fda31d93c | refs/heads/master | 2023-07-24T00:20:36.222180 | 2023-07-19T19:29:16 | 2023-07-19T19:29:16 | 205,900,454 | 0 | 0 | null | 2023-07-19T19:29:18 | 2019-09-02T16:56:37 | Java | UTF-8 | Java | false | false | 2,766 | java | package org.softuni.cardealer.web.controllers;
import org.modelmapper.ModelMapper;
import org.softuni.cardealer.domain.models.binding.AddSupplierBindingModel;
import org.softuni.cardealer.domain.models.service.SupplierServiceModel;
import org.softuni.cardealer.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.validation.Valid;
import java.util.List;
@Controller
@RequestMapping("/suppliers")
public class SuppliersController extends BaseController {
private final SupplierService supplierService;
private final ModelMapper modelMapper;
@Autowired
public SuppliersController(SupplierService supplierService, ModelMapper modelMapper) {
this.supplierService = supplierService;
this.modelMapper = modelMapper;
}
@PostMapping("/add")
public ModelAndView addSupplier(@Valid @ModelAttribute AddSupplierBindingModel bindingModel, BindingResult bindingResult) {
if(bindingResult.hasErrors()) {
throw new IllegalArgumentException();
//TODO: DO SOMETHING
}
this.supplierService.saveSupplier(this.modelMapper.map(bindingModel, SupplierServiceModel.class));
return this.redirect("all");
}
@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Invalid data provided!")
public String exceptionHandler(IllegalArgumentException ex) {
return ex.getMessage();
}
@PostMapping("/edit/{id}")
public ModelAndView editSupplier(@PathVariable String id, @Valid @ModelAttribute AddSupplierBindingModel bindingModel, BindingResult bindingResult) {
if(bindingResult.hasErrors()) {
//TODO: DO SOMETHING
}
this.supplierService.editSupplier(id, this.modelMapper.map(bindingModel, SupplierServiceModel.class));
return this.redirect("/suppliers/all");
}
@PostMapping("/delete/{id}")
public ModelAndView deleteSupplier(@PathVariable String id) {
this.supplierService.deleteSupplier(id);
return this.redirect("/suppliers/all");
}
@GetMapping("/all")
public ModelAndView allSuppliers(ModelAndView modelAndView) {
modelAndView.addObject("suppliers", this.supplierService.findAll());
return this.view("all-suppliers", modelAndView);
}
@GetMapping("/fetch")
@ResponseBody
public List<SupplierServiceModel> fetchSuppliers() {
return this.supplierService.findAll();
}
}
| [
"[email protected]"
]
| |
73dafd18c6ebf6217749b05875a5f6f23d3a9ca8 | 7c9fac81f1ac2e1e2b783041076cfb0c8935feb7 | /src/main/java/com/activemq/messagequeue/MessagequeueApplication.java | 1dc1d57912c217f833eacd0c64e296bf2d26f27c | []
| no_license | EamonYin/MessageQueue | 7d604064622b2eaa09a5b962ab1be67cce3b93ff | 1cdbdd9d3d215a56d5be2296fb2887eb1cd244e8 | refs/heads/master | 2022-04-02T07:16:59.129931 | 2019-12-17T06:22:57 | 2019-12-17T06:22:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 342 | java | package com.activemq.messagequeue;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MessagequeueApplication {
public static void main(String[] args) {
SpringApplication.run(MessagequeueApplication.class, args);
}
}
| [
"[email protected]"
]
| |
2da7689826f4780f475cd53ca9eed8986c70884b | 812b3c77e542d53c45cf5c18e3821e196a524d63 | /editor/cn/ValidParentheses.java | 49729a22975b0ef0561b802e2917a10cb1afc810 | []
| no_license | zoro-learner/leetcode | 7adbbddf78bd63c2f7d27b881c69bf21c0744e5b | 26b4250acdbcf0ca44248954fb1ea22057cc5cd3 | refs/heads/master | 2023-02-17T11:19:14.224269 | 2021-01-14T01:43:27 | 2021-01-14T01:43:27 | 284,855,913 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,194 | java | package leetcode.editor.cn;
//Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
// determine if the input string is valid.
//
// An input string is valid if:
//
//
// Open brackets must be closed by the same type of brackets.
// Open brackets must be closed in the correct order.
//
//
// Note that an empty string is also considered valid.
//
// Example 1:
//
//
//Input: "()"
//Output: true
//
//
// Example 2:
//
//
//Input: "()[]{}"
//Output: true
//
//
// Example 3:
//
//
//Input: "(]"
//Output: false
//
//
// Example 4:
//
//
//Input: "([)]"
//Output: false
//
//
// Example 5:
//
//
//Input: "{[]}"
//Output: true
//
// Related Topics ๆ ๅญ็ฌฆไธฒ
// ๐ 1813 ๐ 0
import java.util.Stack;
/**
* @author zoro-learner
* @create 2020-08-26 10:33:06
*/
public class ValidParentheses {
public static void main(String[] args) {
Solution solution = new ValidParentheses().new Solution();
}
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public boolean isValid(String s) {
Stack<Character> stack = new Stack<>();
for (char ch : s.toCharArray()) {
if (isOpenBrackets(ch)) {
stack.push(ch);
} else if(isCloseBrackets(ch) && !stack.isEmpty()) {
char open = stack.pop();
if (!isMatched(open, ch)) {
return false;
}
} else {
return false;
}
}
return stack.size() == 0;
}
private boolean isCloseBrackets(char ch) {
return ch == ')' || ch == ']' || ch == '}';
}
private boolean isMatched(char open, char close) {
switch (open) {
case '(':
return close == ')';
case '[':
return close == ']';
case '{':
return close == '}';
default:
return false;
}
}
private boolean isOpenBrackets(char ch) {
return ch == '(' || ch == '[' || ch == '{';
}
}
//leetcode submit region end(Prohibit modification and deletion)
} | [
"[email protected]"
]
| |
cf83377fc686f31bfef158108cc44a58819ddf18 | ae5eb1a38b4d22c82dfd67c86db73592094edc4b | /project179/src/test/java/org/gradle/test/performance/largejavamultiproject/project179/p898/Test17979.java | c8ee12b86cb00db444814fe59307d10460aac70f | []
| no_license | big-guy/largeJavaMultiProject | 405cc7f55301e1fd87cee5878a165ec5d4a071aa | 1cd6a3f9c59e9b13dffa35ad27d911114f253c33 | refs/heads/main | 2023-03-17T10:59:53.226128 | 2021-03-04T01:01:39 | 2021-03-04T01:01:39 | 344,307,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,272 | java | package org.gradle.test.performance.largejavamultiproject.project179.p898;
import org.gradle.test.performance.largejavamultiproject.project179.p897.Production17952;
import org.junit.Test;
import static org.junit.Assert.*;
public class Test17979 {
Production17979 objectUnderTest = new Production17979();
@Test
public void testProperty0() {
Production17952 value = new Production17952();
objectUnderTest.setProperty0(value);
assertEquals(value, objectUnderTest.getProperty0());
}
@Test
public void testProperty1() {
Production17965 value = new Production17965();
objectUnderTest.setProperty1(value);
assertEquals(value, objectUnderTest.getProperty1());
}
@Test
public void testProperty2() {
Production17978 value = new Production17978();
objectUnderTest.setProperty2(value);
assertEquals(value, objectUnderTest.getProperty2());
}
@Test
public void testProperty3() {
String value = "value";
objectUnderTest.setProperty3(value);
assertEquals(value, objectUnderTest.getProperty3());
}
@Test
public void testProperty4() {
String value = "value";
objectUnderTest.setProperty4(value);
assertEquals(value, objectUnderTest.getProperty4());
}
@Test
public void testProperty5() {
String value = "value";
objectUnderTest.setProperty5(value);
assertEquals(value, objectUnderTest.getProperty5());
}
@Test
public void testProperty6() {
String value = "value";
objectUnderTest.setProperty6(value);
assertEquals(value, objectUnderTest.getProperty6());
}
@Test
public void testProperty7() {
String value = "value";
objectUnderTest.setProperty7(value);
assertEquals(value, objectUnderTest.getProperty7());
}
@Test
public void testProperty8() {
String value = "value";
objectUnderTest.setProperty8(value);
assertEquals(value, objectUnderTest.getProperty8());
}
@Test
public void testProperty9() {
String value = "value";
objectUnderTest.setProperty9(value);
assertEquals(value, objectUnderTest.getProperty9());
}
} | [
"[email protected]"
]
| |
ef08940c1af6192e3ae90bba11a9a2d8611f8f1d | 7559bead0c8a6ad16f016094ea821a62df31348a | /src/com/vmware/vim25/LoginBySSPIRequestType.java | 953d8f9d6a72ea751829ae5c8f393ccefb69cacc | []
| no_license | ZhaoxuepengS/VsphereTest | 09ba2af6f0a02d673feb9579daf14e82b7317c36 | 59ddb972ce666534bf58d84322d8547ad3493b6e | refs/heads/master | 2021-07-21T13:03:32.346381 | 2017-11-01T12:30:18 | 2017-11-01T12:30:18 | 109,128,993 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,748 | java |
package com.vmware.vim25;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for LoginBySSPIRequestType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="LoginBySSPIRequestType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="_this" type="{urn:vim25}ManagedObjectReference"/>
* <element name="base64Token" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="locale" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "LoginBySSPIRequestType", propOrder = {
"_this",
"base64Token",
"locale"
})
public class LoginBySSPIRequestType {
@XmlElement(required = true)
protected ManagedObjectReference _this;
@XmlElement(required = true)
protected String base64Token;
protected String locale;
/**
* Gets the value of the this property.
*
* @return
* possible object is
* {@link ManagedObjectReference }
*
*/
public ManagedObjectReference getThis() {
return _this;
}
/**
* Sets the value of the this property.
*
* @param value
* allowed object is
* {@link ManagedObjectReference }
*
*/
public void setThis(ManagedObjectReference value) {
this._this = value;
}
/**
* Gets the value of the base64Token property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getBase64Token() {
return base64Token;
}
/**
* Sets the value of the base64Token property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setBase64Token(String value) {
this.base64Token = value;
}
/**
* Gets the value of the locale property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLocale() {
return locale;
}
/**
* Sets the value of the locale property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLocale(String value) {
this.locale = value;
}
}
| [
"[email protected]"
]
| |
5d89fd26cb6430d90343d1faa992e3d3aae045c7 | 2fc8a0b00056f4a486648cfa34c8addfd3f49aee | /DequeueusingArray.java | 7e0db1197804091dbaf207665a19774d92bc433c | []
| no_license | ayushi-singh13/data-structure | 0a3ff182246b218ae97251fb5725755529bae528 | 8c4ef516aa7fcb66fc30a1a9a0a0110c7b8cfc45 | refs/heads/main | 2023-06-17T23:24:36.620574 | 2021-07-05T20:03:04 | 2021-07-05T20:03:04 | 329,945,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,168 | java | import java.util.Scanner;
class DequeueusingArray
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int front=-1,rear=-1;
System.out.println(" Enter the size of the array");
int size=sc.nextInt();
int arr[]=new int[size];
while(true)
{
System.out.println("\nEnter the choice: 1.InsertFirst 2. InsertLast 3. deleteFirst 4. deleteLast 5. Display");
int ch=sc.nextInt();
switch(ch)
{
case 1:System.out.println("Enter the element:");
int x=sc.nextInt();
if(front==-1&& rear==-1)
{
front=rear=0;
arr[front]=x;
}
else if(front==(rear+1)%size)
System.out.println("Dequeue is full.");
else if(front==0)
{
front=size-1;
arr[front]=x;
}
else
{
front--;
arr[front]=x;
}
break;
case 2:
System.out.println("enter the element:");
int y=sc.nextInt();
if(front==-1&& rear==-1)
{
front=rear=0;
arr[rear]=y;
}
else if(front==(rear+1)%size)
System.out.println("Dequeue is full.");
else if(rear==size-1)
{
rear=0;
arr[rear]=y;
}
else
{
rear=rear+1;
arr[rear]=y;
}
break;
case 3:
if(front==-1&&rear==-1)
System.out.println("Dequeueis empty");
else if(front==rear)
front=rear=-1;
else if(front==size-1)
front=0;
else
front=front+1;
break;
case 4:
if(front==-1&&rear==-1)
System.out.println("Dequeue is empty");
else if(front==rear)
front=rear=-1;
else if(rear==0)
rear=size-1;
else
rear=rear-1;
break;
case 5: int i=front;
if(i==-1)
System.out.println("Dequeueis empty.");
else
{
System.out.println("Elements are:");
while(i!=rear)
{
System.out.println(arr[i]+" ");
i=(i+1)%size; }
}
System.out.print(arr[i]);
break;
}
}
}
} | [
"[email protected]"
]
| |
0a6f6860971d6efd913545e6e9e4e46cc2627bde | 61084f4544d344a151571203541b9297e5978a9c | /src/main/java/eu/jajugoshy/javadev/XmasTreeCreator.java | f8db38e71f478cac442ac47884bd0b8bc98244b6 | []
| no_license | jajugoshy/xmasTree | 766858aeddfe0cb4849bdf388b15cd2f96a5e52a | f759006a5800536452bc813f91579b78034b65a9 | refs/heads/master | 2021-03-08T19:32:20.467626 | 2016-04-14T13:10:25 | 2016-04-14T13:10:25 | 56,232,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,432 | java | package eu.jajugoshy.javadev;
public class XmasTreeCreator {
private static String character;
public String createXmasTree(String text, int levels, String side) {
String tree;
this.character = text;
switch(side)
{
case "left": tree = this.left(levels); break;
case "right": tree = this.right(levels); break;
case "down": tree = this.down(levels); break;
default: tree = this.top(levels); break;
}
return tree;
}
private static String createLine(int spaces, int text)
{
StringBuilder sb = new StringBuilder();
StringBuilder sb1 = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
if(spaces!=0) for(int i=0;i<spaces;i++) sb1.append(" ");
for(int i=0;i<=text;i++) sb2.append(character);
sb.append(sb1.toString());
sb.append(sb2.toString());
return sb.toString();
}
private String left(int lev) {
StringBuilder right = new StringBuilder();
StringBuilder topPart = new StringBuilder();
int treeCount=0;
if((lev % 2)==0) treeCount = lev/2;
else treeCount = (lev-1)/2+1;
for(int i=0; i<treeCount;i++)
{
int spaces = lev-1-2*i;
int text = 2*i;
topPart.append(XmasTreeCreator.createLine(spaces,text));
topPart.append("\n");
}
right.append(topPart);
StringBuilder botPart = new StringBuilder();
for(int i=treeCount-2; i>=0;i--)
{
int spaces = lev-1-2*i;
int text = 2*i;
botPart.append(XmasTreeCreator.createLine(spaces,text));
if(i!=0)botPart.append("\n");
}
right.append(botPart);
return right.toString();
}
private String right(int lev) {
StringBuilder right = new StringBuilder();
StringBuilder topPart = new StringBuilder();
int treeCount=0;
if((lev % 2)==0) treeCount = lev/2;
else treeCount = (lev-1)/2+1;
for(int i=0; i<treeCount;i++)
{
int text = 2*i;
topPart.append(XmasTreeCreator.createLine(0,text));
topPart.append("\n");
}
StringBuilder botPart = new StringBuilder();
for(int i=treeCount-2; i>=0;i--)
{
int text = 2*i;
botPart.append(XmasTreeCreator.createLine(0,text));
if(i!=0)botPart.append("\n");
}
right.append(topPart);
right.append(botPart);
return right.toString();
}
private String down(int lev) {
StringBuilder down = new StringBuilder();
for(int i=lev-1; i>=0;i--)
{
int spaces = lev-i-1;
int text = 2*i;
down.append(XmasTreeCreator.createLine(spaces,text));
if(i!=0)down.append("\n");
}
return down.toString();
}
private String top(int lev) {
StringBuilder top = new StringBuilder();
for(int i=0; i<lev;i++)
{
int spaces = lev-i-1;
int text = 2*i;
top.append(XmasTreeCreator.createLine(spaces,text));
if(i!=lev-1)top.append("\n");
}
return top.toString();
}
}
| [
"[email protected]"
]
| |
515d1f6c656d19837c7c89c32f75626d3c1fc68b | 3a3279c133d7838ffcf38ef184c3cdbf1262f0c8 | /src/main/PriceUpdater.java | 7c21c71627750d1102b507167eaa7af92b6fa180 | []
| no_license | abhi9254/Pricetrend | 0899dcf7bf086e7750d9326a3afd8c629fadb8c8 | 54e28a5d46ed2da2a01e49f53afaf0077b0e7246 | refs/heads/master | 2021-04-27T13:30:19.941440 | 2018-02-22T06:33:33 | 2018-02-22T06:33:33 | 122,440,340 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,755 | java | package main;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import crawl.Crawler;
public class PriceUpdater {
public PriceUpdater() {
}
public void updatePrices() {
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(4);
System.out.println("Current time " + LocalDateTime.now().getHour() + " hr");
ArrayList<Long> p_list = new ArrayList<Long>();
Products prds = new Products();
p_list = prds.getAllProducts();
for (long p_id : p_list) {
// check time of day
if (LocalDateTime.now().getHour() > 5 && LocalDateTime.now().getHour() < 8) {
System.out.println("Downtime");
scheduledExecutorService.shutdown();
break;
}
else {
ArrayList<URL> p_urls = new ArrayList<URL>();
Product prd = new Product(p_id);
p_urls = prd.getProductURLs();
for (URL p_url : p_urls)
scheduledExecutorService.scheduleAtFixedRate(new PriceUpdaterService(p_id, p_url), 0, 30,
TimeUnit.MINUTES);
}
}
}
}
class PriceUpdaterService implements Runnable {
private long p_id;
private URL p_url;
PriceUpdaterService(long p_id2, URL p_url) {
this.p_id = p_id2;
this.p_url = p_url;
}
@Override
public void run() {
updateProductPrice(p_id, p_url);
}
private void updateProductPrice(long p_id2, URL p_url) {
try {
Crawler crw = new Crawler();
Float p_price = crw.getPriceFromURL(p_url);
System.out.println(LocalDateTime.now() + " Updated p_id " + p_id2 + " : " + p_price);
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
]
| |
78b681dc348f08c7742434a248126abaa8dfac89 | 9b253b05c5127aa7204414b1b445ea154dc20220 | /efile/efile.sypglass/src/main/java/com/sundeinfo/sypglass/mapper/UserDepartmentMapper.java | 5e4b0fdea14a5cff4faf6b8110294fd5c06cc36b | []
| no_license | libiao1205/efile | bf282f1c1f07139e7e3f280133dce2f77b9f6a6b | 9fcb3151759c8fed7c678e45909283c4afe58553 | refs/heads/master | 2023-06-03T11:24:24.388168 | 2021-06-18T05:53:03 | 2021-06-18T05:53:03 | 378,046,531 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,091 | java | package com.sundeinfo.sypglass.mapper;
import com.sundeinfo.sypglass.model.UserDepartment;
import com.sundeinfo.sypglass.model.UserDepartmentExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface UserDepartmentMapper {
long countByExample(UserDepartmentExample example);
int deleteByExample(UserDepartmentExample example);
int deleteByPrimaryKey(Long id);
int insert(UserDepartment record);
int insertSelective(UserDepartment record);
List<UserDepartment> selectByExample(UserDepartmentExample example);
UserDepartment selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UserDepartment record, @Param("example") UserDepartmentExample example);
int updateByExample(@Param("record") UserDepartment record, @Param("example") UserDepartmentExample example);
int updateByPrimaryKeySelective(UserDepartment record);
int updateByPrimaryKey(UserDepartment record);
} | [
"[email protected]"
]
| |
24f449e9170ff9d10029c39db8224613d2b9dd3c | 9a3675172cf4b5afec2e6f47c8526a0108949740 | /app/src/main/java/com/a99live/zhibo/live/view/DownLoadDialog.java | a3daa74573a6749888a36f4ddf82f4d8ae963f26 | []
| no_license | luomingstar/StarLive | c7f5421ed380d78d73cac9becab41a48b000b39a | 1aa414e5acc21f3483cc58db6daf6aab9b5b95f3 | refs/heads/master | 2021-07-21T03:15:53.184466 | 2017-10-28T06:33:27 | 2017-10-28T06:33:27 | 108,625,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,190 | java | package com.a99live.zhibo.live.view;
import android.app.Activity;
import android.app.Dialog;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.a99live.zhibo.live.R;
import com.a99live.zhibo.live.utils.UIUtils;
/**
* Created by fuyk on 2016/9/2.
*/
public class DownLoadDialog implements View.OnClickListener {
private Activity mAct;
private Dialog mDialog;
private View mView;
private TextView tv_ok;
private TextView tv_msg;
private ProgressBar pb_load;
public DownLoadDialog(Activity activity) {
this.mAct = activity;
init();
}
private void init() {
mDialog = new Dialog(mAct, R.style.mask_dialog);
mDialog.setCanceledOnTouchOutside(false);
mDialog.setCancelable(false);
mView = View.inflate(mAct, R.layout.view_notify_upgrade, null);
tv_ok = (TextView) mView.findViewById(R.id.tv_ok);
tv_msg = (TextView) mView.findViewById(R.id.textView1);
pb_load = (ProgressBar) mView.findViewById(R.id.progressBar1);
tv_ok.setOnClickListener(this);
mDialog.setContentView(mView, new ViewGroup.LayoutParams(UIUtils.dip2px(270), ViewGroup.LayoutParams.MATCH_PARENT));
mDialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL, 0);
Window dialogWindow = mDialog.getWindow();
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setWindowAnimations(R.style.cdt_dialog_anim);
}
public DownLoadDialog setMessage(String strId) {
tv_msg.setText(strId);
return this;
}
public DownLoadDialog setMessage(int strId) {
tv_msg.setText(strId);
return this;
}
public void show() {
mDialog.show();
}
public void dismiss() {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
@Override
public void onClick(View view) {
dismiss();
}
public void setProgress(long loaded, long total) {
pb_load.setMax((int) total);
pb_load.setProgress((int) loaded);
}
}
| [
"[email protected]"
]
| |
2ec3f0a8a00115ceb74cdb4790772554d95a2a49 | 35ad18da695aeb0b6de7b192a2b75a0bea9d1b59 | /app/src/main/java/com/example/android/things/Page.java | e5a90f49a4595b8fccf8ca4cdee42292fb33918d | []
| no_license | mykolaveremeichyk/5things | 515a115d9c2a8b7777d55c63bbf9aca40b258165 | 9aff0e953a5a30eaddf506bb231ca2a2bc4fe945 | refs/heads/master | 2021-05-31T23:50:24.265543 | 2016-02-28T10:12:51 | 2016-02-28T10:12:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 847 | java | package com.example.android.things;
import java.util.Map;
/**
* Created by NickVeremeichyk on 2/27/16.
*/
public class Page {
private String question;
private String info;
private Map<String, Boolean> answers;
public Page() {
}
public Page(String question, String info) {
this.question = question;
this.info = info;
}
public Page(String question, String info, Map<String, Boolean> answers) {
this.question = question;
this.info = info;
this.answers = answers;
}
public String getQuestion() {
return question;
}
public String getInfo() {
return info;
}
public void setAnswers(Map<String, Boolean> answers) {
this.answers = answers;
}
public Map<String, Boolean> getAnswers() {
return answers;
}
}
| [
"[email protected]"
]
| |
a8900a3f43025eaf4f74a4e16a6e14251bea10de | 1c8e9f5d6e8ecbd73f991bc5a6c38518cffebf05 | /src/java/prod/org/burroloco/util/string/ShortNameUnique.java | eccf20d896f823ad0a8bd8e95db7da8ee5dffd58 | []
| no_license | dbastin/donkey | 8f902105b0ade172c94c46097626ff0480b5e14c | 2a50609d6eb5b295aa3cbc4b0c3aada5c0f9d010 | refs/heads/master | 2021-01-22T04:40:18.906571 | 2014-02-25T04:34:14 | 2014-02-25T04:34:14 | 12,771,545 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 93 | java | package org.burroloco.util.string;
public interface ShortNameUnique extends StringUnique {}
| [
"dbastin@080cfd25-d5d9-4c59-82ea-70d02a200d8b"
]
| dbastin@080cfd25-d5d9-4c59-82ea-70d02a200d8b |
936cb028c06a8a2dcb8fef18f32fe9708760b5b1 | 075e2a71f7998033bb195c15de25c72f0f647a10 | /src/main/java/co/com/ceiba/aplicacion/manejador/ManejadorComandoRespuesta.java | eb571c300b35452114848385b400808d49460d6b | []
| no_license | FelipeFranco-Ceiba/Ceiba-Odontologia | 46e95c574e74be2cc89f06797ddd87b5275307b5 | 2a1825c814fbab9e77f74af672af4628272c86e9 | refs/heads/master | 2023-01-21T06:47:25.799387 | 2020-12-03T18:43:26 | 2020-12-03T18:43:26 | 314,406,892 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 210 | java | package co.com.ceiba.aplicacion.manejador;
import org.springframework.transaction.annotation.Transactional;
public interface ManejadorComandoRespuesta<R, T> {
@Transactional
R ejecutar(T comando);
}
| [
"[email protected]"
]
| |
aad9c486f93a7132f7352f33ee2065953c7a4dc9 | 47f3da07a227681a5d7994232e4c343b27c57aae | /GuidFinderDesktop/src/main/java/edu/eci/arsw/GuidFinderDesktop/persistence/impl/VolatileMemory.java | 1c4c761dd8779e1d52c42b6689e0669987a4acb5 | []
| no_license | SebastianGoenaga/Parcial1_ARSW | 2e8b89418625ff1aa5dc5ccc0e21f748e06414a6 | 805e359bd40176aa7cbc18edd2b5dba4b035abe4 | refs/heads/master | 2020-04-24T10:20:51.742964 | 2019-03-07T16:49:50 | 2019-03-07T16:49:50 | 171,891,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package edu.eci.arsw.GuidFinderDesktop.persistence.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import edu.eci.arsw.GuidFinderDesktop.GuidFinder2;
import edu.eci.arsw.GuidFinderDesktop.model.UIrequest;
import edu.eci.arsw.GuidFinderDesktop.model.UIresponse;
import edu.eci.arsw.GuidFinderDesktop.persistence.GuidPersistence;
@Component("vm")
public class VolatileMemory implements GuidPersistence{
@Autowired
GuidFinder2 guidFinder;
List<UIresponse> responses = new LinkedList<UIresponse>();
@Override
public List<UIresponse> getAll() {
return responses;
}
@Override
public UIresponse consult(UIrequest request) {
UIresponse response = new UIresponse(guidFinder.consult(request.getRequest()), new Date(), request.getRequest());
responses.add(response);
return response;
}
}
| [
"[email protected]"
]
| |
695f331a7c37e54e637515e8af13f58dbba32eec | a59ef59e5a1650c044350c09348517162f0a96d5 | /src/controller/StatusController.java | e558a73204ee64998d3daacf807a1ae49bef3e49 | []
| no_license | Praxe-Dev/BeerItSimple | 7e4261afbb8ea675976805a0c79b9643801efcfb | cb10b49211f1e371f56f5eecbe18ad21641be29b | refs/heads/master | 2023-06-09T03:59:55.147865 | 2020-08-11T13:16:19 | 2020-08-11T13:16:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 499 | java | package controller;
import business.StatusBusiness;
import exception.ConnectionException;
import exception.DataQueryException;
import model.Status;
import java.util.ArrayList;
public class StatusController {
private StatusBusiness statusBusiness;
public StatusController() throws ConnectionException {
this.statusBusiness = new StatusBusiness();
}
public ArrayList<Status> getAllStatus() throws DataQueryException {
return statusBusiness.getAllStatus();
}
}
| [
"[email protected]"
]
| |
b5a42606ccddcfff1ed7f127068692d01e5cfbbd | 1fd9681ecaa80552c7b429aec751f2086aa82743 | /src/main/java/com/silita/biaodaa/utils/HtmlTagUtils.java | a33a599a9f0443251bcaaded4983385a0fdcd88f | []
| no_license | janck13/notice-analysis | 7ffac818ed9c8bef7460160eeafcab520e251afc | c6f7dd8e6f976a8f7eb0badc5982c5f8b88fa705 | refs/heads/master | 2020-05-23T16:56:58.822786 | 2018-12-14T03:32:55 | 2018-12-14T03:32:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,182 | java | package com.silita.biaodaa.utils;
/**
* Created by dh on 2018/7/10.
*/
public class HtmlTagUtils {
public static String clearInvalidTag(String content){
// content = content.replaceAll("<(?!img|br|p|/p).*?>",""); //ๅป้คๆๆๆ ็ญพ๏ผๅชๅฉimg,br,p
// content = content.replaceAll("<script[^>]*?>.*?</script >","");//ๅป้คscriptๅ
// content = content.replaceAll("(style|class|align)+?=*?\".*\"","");//ๅป้คๆ ทๅผๅฑๆง
// content = content.replaceAll("<!--[\\s\\S\\W\\w.]*-->","");//ๅป้คๆ ทๅผๅฑๆง
// content = content.replaceAll("&.*?;","");//ๅป้ค่ฝฌไนๅญ็ฌฆ'
// content = content.replaceAll("[ ]*","");//ๅ้ค็ฉบๆ ผ
// content = content.replaceAll("\\n\\n","");//ๅ้ค่ฟ็ปญๆข่ก็ฌฆ
content = content.replaceAll("(<(?!img|br|p|/p).*?>)" + //ๅป้คๆๆๆ ็ญพ๏ผๅชๅฉimg,br,p
"|(<script[^>]*?>.*?</script >)" +//ๅป้คscriptๅ
"|((style|class|align)+?=*?\".*\")" +//ๅป้คๆ ทๅผๅฑๆง
"|(<!--[\\s\\S\\W\\w.]*-->)" +//ๅป้คๆณจ้
"|(&.*?;)" +//ๅป้ค่ฝฌไนๅญ็ฌฆ
"|([ ]*)" +//ๅ้ค็ฉบๆ ผ
"|(\\n\\n)","");//ๅ้ค่ฟ็ปญๆข่ก็ฌฆ
return content;
}
public static String clearTagByTable(String content){
// content = content.replaceAll("<(?!img|br|p|/p|table|/table|tr|/tr|/td|td|span|/span).*?>",""); //ๅป้คๆๆๆ ็ญพ๏ผๅชๅฉimg,br,p
// content = content.replaceAll("<script[^>]*?>.*?</script >","");//ๅป้คscriptๅ
// content = content.replaceAll("<!--[\\s\\S\\W\\w.]*-->","");//ๅป้คๆ ทๅผๅฑๆง
// content = content.replaceAll("&.*?;","");//ๅป้ค่ฝฌไนๅญ็ฌฆ'
// content = content.replaceAll("\\n\\n","");//ๅ้ค่ฟ็ปญๆข่ก็ฌฆ
content = content.replaceAll("(<(?!img|br|p|/p|table|/table|tr|/tr|/td|td|span|/span).*?>)" + //ๅป้คๆๆๆ ็ญพ๏ผๅชๅฉimg,br,p
"|(<script[^>]*?>.*?</script >)" +//ๅป้คscriptๅ
"|(<!--[\\s\\S\\W\\w.]*-->)" +//ๅป้คๆณจ้
"|(&.*?;)" +//ๅป้ค่ฝฌไนๅญ็ฌฆ
"|(\\n\\n)","");//ๅ้ค่ฟ็ปญๆข่ก็ฌฆ
return content;
}
}
| [
"[email protected]"
]
| |
991b57d43ecff7b0189119ae26f4f0c3f5635f20 | 33000dc984593e0d82df358de307063c60987027 | /javaForImpatient/chapterOne/RunnableEx.java | 20155b299a8cd786e4f8df33b789cd198bb9114a | []
| no_license | jivel/Java8ForReallyImpatient | 5aabc4ba54025026538683e0339f4220494a056b | d14c36de3984eec3a00b0863dac13e25bac4dbc3 | refs/heads/master | 2021-01-12T20:06:48.516133 | 2014-01-19T06:13:48 | 2014-01-19T06:13:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 149 | java | package javaForImpatient.chapterOne;
/*
* Associated with assignment six.
*/
public interface RunnableEx {
public void run() throws Exception;
}
| [
"[email protected]"
]
| |
24b19e0f9fc1d7edf9b0cd2c62c4344bafd45458 | 643eabc9dd919e8587f823e695fe57769830b57f | /src/test/java/com/github/swm/integrationtests/helpers/StepEventOperationsHelper.java | ee33cb10a3b6e0bfb5bfc670ef3e5ab2c1ef32b7 | []
| no_license | MadTribe/collab_engine_client | 6e1564ac3d439c506bc005bb6db0babf4e70101b | 6480a98f7da8202119c8e5a3081a3b7f59018676 | refs/heads/master | 2020-03-30T03:22:11.086617 | 2015-05-02T09:05:00 | 2015-05-02T09:05:00 | 31,153,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,828 | java | package com.github.swm.integrationtests.helpers;
import com.github.swm.userclient.App;
import com.github.swm.userclient.commands.CommandResponse;
import com.github.swm.userclient.commands.EntityOperations;
import java.util.List;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Created by paul.smout on 08/03/2015.
*/
public class StepEventOperationsHelper {
// final static Logger logger = LoggerFactory.getLogger(OperationsHelper.class);
private App app;
public StepEventOperationsHelper(App app) {
this.app = app;
}
public CommandResponse I_create_a_new_script(String name, String source) {
CommandResponse resp = app.runCommand(cmd(format("script -op %s -name %s -- %s", "NEW", name, source)));
assertThat(resp.getSuccess(),is(true));
return resp;
}
public CommandResponse I_edit_the_script(String name, String source) {
CommandResponse resp = app.runCommand(cmd(format("script -op %s -name %s -- %s", EntityOperations.EDIT, name, source)));
assertThat(resp.getSuccess(),is(true));
return resp;
}
public CommandResponse I_list_my_scripts(String match) {
CommandResponse resp = app.runCommand(cmd(format("script -op %s -name %s", EntityOperations.LIST_MATCHING, match)));
assertThat(resp.getSuccess(),is(true));
return resp;
}
public CommandResponse I_get_the_script_by_name(String name) {
CommandResponse resp = app.runCommand(cmd(format("script -op %s -name %s", EntityOperations.SHOW_ONE, name)));
assertThat(resp.getSuccess(),is(true));
return resp;
}
private List<String> cmd(String cmd){
return asList(cmd.split(" "));
}
}
| [
"[email protected]"
]
| |
ad947c445f84a44d3c024e444499d4d9c9bec1be | 79de2bd1a25f9b87058c3f853ff8f4127aee43f1 | /Idea-Project/src/main/java/com/puzhen/visionstorage/script/Create50x50Image.java | f8603ddc9a0bdf062d78c8f6bebb7d7da58971a2 | []
| no_license | Clifnich/MapReduce-Graphics | e29f699023bf4f4c1ac1df9e663de6f441b28ac6 | adb4ba8e6399d82dfc7c6ab95a29e2b5981c1442 | refs/heads/master | 2021-07-21T04:29:00.624643 | 2017-10-30T08:33:36 | 2017-10-30T08:33:36 | 102,490,589 | 0 | 0 | null | 2017-10-26T13:36:55 | 2017-09-05T14:20:08 | Java | UTF-8 | Java | false | false | 366 | java | package com.puzhen.visionstorage.script;
import com.puzhen.visionstorage.main.ImageProcessBO;
public class Create50x50Image {
public static void main(String[] args) {
if (ImageProcessBO.createDataFile(50, 50, "test-data/50x50.txt")) {
System.out.println("Done");
} else {
System.err.println("Error");
}
}
}
| [
"[email protected]"
]
| |
7dea65139e074423df49f76475c2f33eee0eb237 | d80dd6d55b215a19d8bb7464b1c683d9656c912c | /wm/src/main/java/com/yi/ylwm/xcb/xcb_screen_iterator_t.java | d35e34e6bb5be203ee2ed85eec99f50f9bf25275 | []
| no_license | bYiyLi/ylwm | 3044b00c6cf12d4e9ac31725063e558c45c0d65f | c6f5dd497bdbc84ae1dd23ac23c37c976127a469 | refs/heads/master | 2023-04-11T17:14:32.636735 | 2021-05-04T01:15:38 | 2021-05-04T01:15:38 | 363,722,036 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,487 | java | package com.yi.ylwm.xcb;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
/**
* <i>native declaration : /usr/include/xcb/xproto.h</i><br>
* This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
* a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
* For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
*/
public class xcb_screen_iterator_t extends Structure {
/** C type : xcb_screen_t* */
public com.yi.ylwm.xcb.xcb_screen_t.ByReference data;
public int rem;
public int index;
public xcb_screen_iterator_t() {
super();
}
@Override
protected List<String> getFieldOrder(){
return Arrays.asList("data", "rem", "index");
}
/** @param data C type : xcb_screen_t* */
public xcb_screen_iterator_t(com.yi.ylwm.xcb.xcb_screen_t.ByReference data, int rem, int index) {
super();
this.data = data;
this.rem = rem;
this.index = index;
}
public xcb_screen_iterator_t(Pointer peer) {
super(peer);
}
public static class ByReference extends xcb_screen_iterator_t implements Structure.ByReference {
};
public static class ByValue extends xcb_screen_iterator_t implements Structure.ByValue {
};
}
| [
"[email protected]"
]
| |
db8651c8124c7996ec34265b9dacee371dde324c | 218a4e08047ca8437ed82f990764cd75ebae6bf9 | /BaiduMapsApiDemo/src/baidumapsdk/demo/BaseMapDemo.java | cff32a6194e850256a774295610a48cc1fc1499c | []
| no_license | hongguangqq/GLandroid | ee2f9be86dd00d95c0334afaeb1c8d845c4d87ad | 625a2adb0ee79331f54b6eb67e70b866cff33c30 | refs/heads/master | 2021-01-23T14:13:35.723917 | 2017-06-04T08:24:41 | 2017-06-04T08:24:41 | 93,247,787 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,556 | java | package baidumapsdk.demo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BaiduMapOptions;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.model.LatLng;
/**
* ๆผ็คบMapView็ๅบๆฌ็จๆณ
*/
public class BaseMapDemo extends Activity {
@SuppressWarnings("unused")
private static final String LTAG = BaseMapDemo.class.getSimpleName();
private MapView mMapView;
private BaiduMap mBaiduMap;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (intent.hasExtra("x") && intent.hasExtra("y")) {
// ๅฝ็จintentๅๆฐๆถ๏ผ่ฎพ็ฝฎไธญๅฟ็นไธบๆๅฎ็น
Bundle b = intent.getExtras();
LatLng p = new LatLng(b.getDouble("y"), b.getDouble("x"));
mMapView = new MapView(this,
new BaiduMapOptions().mapStatus(new MapStatus.Builder()
.target(p).build()));
} else {
mMapView = new MapView(this, new BaiduMapOptions());
}
setContentView(mMapView);
mBaiduMap = mMapView.getMap();
}
@Override
protected void onPause() {
super.onPause();
// activity ๆๅๆถๅๆถๆๅๅฐๅพๆงไปถ
mMapView.onPause();
}
@Override
protected void onResume() {
super.onResume();
// activity ๆขๅคๆถๅๆถๆขๅคๅฐๅพๆงไปถ
mMapView.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
// activity ้ๆฏๆถๅๆถ้ๆฏๅฐๅพๆงไปถ
mMapView.onDestroy();
}
}
| [
"[email protected]"
]
| |
575dd399f3fd64a6fb24a0050fa427162cfcdc19 | 78b4e01da55d44fa1b0974c39dc7c3d7881402e6 | /VoronoiGame/src/Client.java | eb113732a541f881e264d19132fb84eae1ac82cc | []
| no_license | tt810/HeuristicProblemSolving | 463c38e90dac30e1be2cbd45bd332b98333d9e54 | 738cb642712f955f34d210ce177c859c9861217e | refs/heads/master | 2016-09-06T13:25:54.567117 | 2012-02-02T03:58:57 | 2012-02-02T03:58:57 | 2,602,583 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,041 | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.Set;
/**
*
*/
/**
* @author ting
*
*/
public class Client {
/**
* @param args
*/
private static BufferedReader stdIn;
private static int totalTurn = 0;
private static int totalPlayer;
private static int me;
private static int currentTurn = 0;
public Client(String host, int port){
Socket socket = null;
PrintWriter out = null;
BufferedReader in = null;
try{
socket = new Socket(host, port);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
}catch(UnknownHostException e){
System.err.println("unknown host: "+host);
}catch(IOException e){
System.exit(1);
}
Character boardInfo;
StringBuffer state = new StringBuffer();
try{
while((boardInfo = (char)in.read()) != null){
state.append(boardInfo);
if(state.toString().endsWith("\":")){
out.println(process(state.append("\n").toString()));
state.delete(0, state.length());
continue;
}
}
out.close();
in.close();
stdIn.close();
socket.close();
}catch(IOException e){
}
}
private String process(String info){
System.out.print(info);
String[] lines = info.split("\n");
if(totalTurn == 0){
totalTurn = Integer.parseInt(lines[1].split(" ")[2]);
totalPlayer = Integer.parseInt(lines[2].split(" ")[2]);
me = Integer.parseInt(lines[3].split(" ")[3]);
}
float[] playerScores = new float[totalPlayer];
for(int i=0; i<totalPlayer; i++){
playerScores[i] = Integer.parseInt(lines[6+i].split(" ")[1]);
}
int boardState = totalPlayer * currentTurn + me;
currentTurn++;
// System.out.println(totalTurn + " *** "+totalPlayer + " **** "+
// me + " ***** "+boardState);
Set<Site> sites = new HashSet<Site>();
Set<Point> sPoints = new HashSet<Point>();
// for(int i=0; i<boardState; i++){
// sites[i] = new Site();
// }
int from = 8+totalPlayer;
// System.out.println("BoardState: "+boardState);
for(int i=0; i<boardState; i++){
String[] strs = lines[from+i].split(" ");
Site site = new Site();
site.p = new Point(Integer.parseInt(strs[1]),
Integer.parseInt(strs[2]));
String owner = strs[0].substring(0, strs[0].length()-1);
site.owner = Integer.parseInt(owner);
sites.add(site);
sPoints.add(site.p);
}
Board board = new Board(totalTurn*totalPlayer, me);
board.sites = sites;
board.sPoints = sPoints;
for(Site site:sites){
System.out.println(site.p);
}
if(boardState == (totalTurn*totalPlayer-1)) return board.beachyMove();
return board.getMyStep();
}
public static void main(String[] args) {
stdIn = new BufferedReader(new InputStreamReader(System.in));
String host = args[0];
int port = Integer.parseInt(args[1]);
Client client = new Client(host, port);
}
}
| [
"[email protected]"
]
| |
e3fa0dfcda25b35768037af5d4dd10634f141b61 | 7ba3d13c96769b03e8df3042170f72bebf151367 | /assignment4/DivideByZero.java | 257527a66238fbcfc64a049ebf51d7efe3ea53c8 | []
| no_license | JS-Choi513/3th_grade_JAVA | 0ed46a8e6b5529a6da65c57679a0af952643b0b8 | 32e8a006465cb0228c93d3d4fc61f50355a5f7de | refs/heads/master | 2023-05-12T06:41:43.268222 | 2023-05-03T02:25:22 | 2023-05-03T02:25:22 | 255,853,447 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 469 | java | package assignment4;
public class DivideByZero{
public static void main(String[]args){
try{
System.out.println(3/0);
} catch(Exception e){//Exception์ ๊ณ์ธต๊ตฌ์กฐ: Exception->RuntimeException->ArithmeticException ์ ๊ฐ์ง๋ค.
//๋ฐ๋ผ์ ์์ธ์ ์ธํ์
์ ์์ ๊ณ์ธต์ผ๋ก ์ง์ ํด๋ ๊ฐ์ ๊ฒฐ๊ณผ๊ฐ ๋์จ๋ค.
System.out.println("Caugth runtime exception(0409) => "+ e);
}
}
} | [
"[email protected]"
]
| |
051200e69507c3c2dc137c7bbc97df73f21c675a | 781f9729bf2c5df3b986130b7143480f5d400f92 | /Final/src/main/java/EstablishConnection.java | 391a8ca4630ff805b8de8461d8ac254cb19ff6a0 | []
| no_license | JesusNunez1031/Mongodb-Using-Java | c592a801223fc52cb5a9a4903dd7dc20dea47038 | aa9e2c88d710cdc548bcfea4aed326ad8d335dcb | refs/heads/master | 2021-06-24T07:15:24.138098 | 2020-11-03T06:03:19 | 2020-11-03T06:03:19 | 160,635,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36,452 | java | import com.mongodb.BasicDBObject;
import com.mongodb.DBCursor;
import com.mongodb.MongoClient;
import com.mongodb.client.*;
import com.mongodb.client.result.UpdateResult;
import org.bson.Document;
import org.bson.conversions.Bson;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.mongodb.client.model.Aggregates.group;
import static com.mongodb.client.model.Aggregates.out;
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.in;
import static com.mongodb.client.model.Indexes.descending;
import static com.mongodb.client.model.Projections.excludeId;
import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import static com.mongodb.client.model.Sorts.ascending;
import static jdk.nashorn.internal.objects.NativeArray.sort;
import com.mongodb.client.model.Aggregates.*;
/*
Compile:
javac -cp mongo-java-driver-3.4.3.jar EstablishConnection.java
Run:
java -cp mongo-java-driver-3.4.3.jar:. EstablishConnection
*/
//Add full time to the studnet.csv
public class EstablishConnection {
public static void menu() {
System.out.println("----------------------Program Menu----------------------");
System.out.println("1. Insert");
System.out.println("2. Search");
System.out.println("3. Print all documents from specific collection");
System.out.println("4. Update");
System.out.println("5. Delete");
System.out.println("6. Aggregation (Sort)");
System.out.println("7. Exit");
System.out.println("--------------------------------------------------------");
}
public static void main(String args[]) {
menu();
Scanner input = new Scanner(System.in);
int user_input = input.nextInt();
List<String> array = new ArrayList<String>();
Map<String, Object> languagesMapDetail = new HashMap<String, Object>();
//Set all database variables
String server_name = "localhost";
int port = 27017;
String database_name = "Techx";
String collection_class = "classes";
String collection_Mentor = "mentors";
String collection_Student = "students";
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.SEVERE);
//Connect to Mongodb Instance
MongoClient mongoClient = new MongoClient(server_name, port);
MongoDatabase database = mongoClient.getDatabase(database_name);
//collection for classes
MongoCollection<Document> collectionClass = database.getCollection(collection_class);
//collection for mentors
MongoCollection<Document> collectionMentor = database.getCollection(collection_Mentor);
//collection for students
MongoCollection<Document> collectionStudent = database.getCollection(collection_Student);
//Iterator for classes
MongoCursor<Document> classes = collectionClass.find().iterator();
//Iterator for mentors
MongoCursor<Document> mentors = collectionMentor.find().iterator();
//Iterator for students
MongoCursor<Document> students = collectionStudent.find().iterator();
//Query to find a document through multiple fields
BasicDBObject query = new BasicDBObject();
// Document myDoc = collectionClass.find().first();
// System.out.println(myDoc.toJson());
//FindIterable<Document> cursor = collectionClass.find();
while (user_input != 7) {
if (user_input == 1) {
System.out.println("Choose collection[1: Classes 2: Mentors 3: Students]");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.println("Enter the values for the following Categories: ");
// Skip the newline
input.nextLine();
System.out.println("Course:");
String courseNum = input.nextLine();
System.out.println("Class Name:");
String className = input.nextLine();
System.out.println("Instructor:");
String instructor = input.nextLine();
Document newClass = new Document("Course Number", courseNum)
.append("Class Name", className)
.append("Instructor", instructor);
collectionClass.insertOne(newClass);
System.out.println(className + " was added to classes!");
break;
case 2:
System.out.println("Enter the values for the following Categories: ");
// Skip the newline
input.nextLine();
System.out.println("First Name:");
String firstName = input.nextLine();
System.out.println("Last Name:");
String lastName = input.nextLine();
System.out.println("Home State, format[\"CA\"]:");
String state = input.nextLine();
System.out.println("Undergraduate Alma Mater:");
String underGradalmaMater = input.nextLine();
System.out.println("Graduate Alma Mater:");
String gradAlmaMater = input.nextLine();
System.out.println("Thesis Focus:");
String thesis = input.nextLine();
System.out.println("Tech Interest:");
String interest = input.nextLine();
System.out.println("Department/Team:");
String department = input.nextLine();
System.out.println("Role:");
String role = input.nextLine();
System.out.println("How many years have you worked at Google?");
int years = input.nextInt();
System.out.println("Mentee(s):");
String mentees = input.nextLine();
Document newMentor = new Document("First Name", firstName)
.append("Last Name", lastName)
.append("Home State", state)
.append("Undergraduate Alma Mater", underGradalmaMater)
.append("Graduate Alma Mater", gradAlmaMater)
.append("Thesis Focus", thesis)
.append("Tech Interest", interest)
.append("Department/Team", department)
.append("Role", role)
.append("How many years have your worked at Google?", years)
.append("Mentee(s)", mentees);
collectionMentor.insertOne(newMentor);
System.out.println(firstName + " " + lastName + " was added to mentors!");
break;
case 3:
System.out.println("Enter the values for the following Categories: ");
// Skip the newline
input.nextLine();
System.out.println("First Name:");
String studentFirstName = input.nextLine();
System.out.println("Last Name:");
String studentLastName = input.nextLine();
System.out.println("School:");
String school = input.nextLine();
System.out.println("How many classes are you taking?:");
int classNum = input.nextInt();
System.out.println("Enter the classes names:");
// Skip the newline
input.nextLine();
for (int i = 0; i < classNum; i++) {
System.out.println("Class " + i + ":");
String classesTaking = input.nextLine();
array.add(classesTaking);
}
System.out.println("Home State, format[\"CA\"]:");
String studentState = input.nextLine();
System.out.println("Enter the following level of knowledge for the following languages [Beginner, Intermediate, Expert, N/A]");
String[] language = {"Java", "Python", "C++", "HTML/CSS", "Javascript"};
for (int i = 0; i < 5; i++) {
System.out.println("Level of knowledge for " + language[i] + ":");
String level = input.nextLine();
languagesMapDetail.put(language[i], level);
}
System.out.println("Horoscope:");
String horoscope = input.nextLine();
System.out.println("Favorite Cuisine:");
String cuisine = input.nextLine();
System.out.println("Type of Diet:");
String diet = input.nextLine();
System.out.println("Favorite Music Genre:");
String music = input.nextLine();
boolean fulltime;
if (array.size() >= 4) {
fulltime = true;
} else fulltime = false;
Document newStudent = new Document("First Name", studentFirstName)
.append("Last Name", studentLastName)
.append("School", school)
.append("Current Classes", array)
.append("Home State", studentState)
.append("Programming Languages", languagesMapDetail)
.append("Horoscope", horoscope)
.append("Favorite Cuisine", cuisine)
.append("Type of Diet", diet)
.append("Favorite Music Genre", music)
.append("Full Time", fulltime);
collectionStudent.insertOne(newStudent);
System.out.println(studentFirstName + " " + studentLastName + " was added to students!");
break;
}
menu();
user_input = input.nextInt();
} else if (user_input == 2) {
System.out.println("Choose collection[1: Classes 2: Mentors 3: Students]");
int choice = input.nextInt();
//skip line
input.nextLine();
switch (choice) {
case 1:
System.out.println("Search by? [Course Number, Class Name, Instructor]");
String selection = input.nextLine();
System.out.println("What is the specific value for " + selection + ":");
String value = input.nextLine();
List<Document> listObjects = collectionClass.find(eq(selection, value)).into(new ArrayList<Document>());
for (Document aList : listObjects) {
System.out.println(aList);
}
Document myDoc = Document.parse(collectionClass.find(eq(selection, value)).toString());
//System.out.println(myDoc.toJson() + "\n");
break;
case 2:
System.out.println("Search by? [First Name, Last Name, Home State, Undergraduate Alma Mater, Graduate Alma Mater,\n" +
" Thesis Focus, Tech Interest, Department/Team, Role, How many years have you worked at Google?, Mentee(s)]");
selection = input.nextLine();
System.out.println("What is the specific value for " + selection + ":");
value = input.nextLine();
listObjects = collectionMentor.find(eq(selection, value)).into(new ArrayList<Document>());
for (Document aList : listObjects) {
System.out.println(aList + "\n\n");
}
//myDoc = collectionMentor.find(eq(selection, value)).first();
//System.out.println(myDoc.toJson() + "\n");
break;
case 3:
System.out.println("Search by? [First Name, Last Name, School, Current Classes, Home State,\n" +
"Programming Languages, Horoscope, Favorite Cuisine, Type of Diet, Favorite Music Genre]");
selection = input.nextLine();
System.out.println("What is the specific value for " + selection + ":");
if (selection.equals("Programming Languages")) {
String language = input.nextLine();
System.out.println("What level of skill are you looking for?");
String knowledge = input.nextLine();
listObjects = collectionStudent.find(eq(selection + "." + language, knowledge)).into(new ArrayList<Document>());
for (Document aList : listObjects) {
System.out.println(aList);
}
//myDoc = collectionStudent.find(eq(selection + "." + language, knowledge)).first();
//System.out.println(myDoc.toJson() + "\n");
} else if(selection.equals("Current Classes")) {
System.out.println("What class are you looking for?");
String classSearch = input.nextLine();
myDoc = collectionStudent.find(eq(selection + ".", new BasicDBObject("$in",Arrays.asList(classSearch)))).first();
System.out.println(myDoc);
}else {
value = input.nextLine();
listObjects = collectionStudent.find(eq(selection, value)).into(new ArrayList<Document>());
for (Document aList : listObjects) {
System.out.println(aList);
}
//myDoc = collectionStudent.find(eq(selection, value)).first();
//System.out.println(myDoc.toJson() + "\n");
}
break;
}
menu();
user_input = input.nextInt();
} else if (user_input == 3) {
System.out.println("Choose collection[1: Classes 2: Mentors 3: Students]");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.print("Classes: ");
try {
while (classes.hasNext()) {
System.out.println(classes.next().toJson());
}
} finally {
System.out.println("Done");
}
break;
case 2:
System.out.print("Mentors: ");
try {
while (mentors.hasNext()) {
System.out.println(mentors.next().toJson());
}
} finally {
System.out.println("Done");
}
break;
case 3:
System.out.print("Students: ");
try {
while (students.hasNext()) {
System.out.println(students.next().toJson());
}
} finally {
System.out.println("Done");
}
break;
}
menu();
user_input = input.nextInt();
} else if (user_input == 4) {
System.out.println("Choose collection[1: Classes 2: Mentors 3: Students]");
int choice = input.nextInt();
// Skip the newline
input.nextLine();
switch (choice) {
case 1:
System.out.println("What value would you like to update? [Course Number, Class Name, Instructor]");
String updateValue = input.nextLine();
// Skip the newline
input.nextLine();
String currentChangeValue;
input.nextLine();
String updatedChangeValue;
if (updateValue.equals("Course Number")) {
System.out.println("Whats the current course number?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new course number: ");
updatedChangeValue = input.nextLine();
collectionClass.updateOne(eq("Course Number", currentChangeValue), new Document("$set", new Document("Course Number", updatedChangeValue)));
System.out.println("Course Number updated!");
} else if (updateValue.equals("Class Name")) {
System.out.println("Whats the current class name?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new class name: ");
updatedChangeValue = input.nextLine();
collectionClass.updateOne(eq("Class Name", currentChangeValue), new Document("$set", new Document("Class Name", updatedChangeValue)));
System.out.println("Class Name updated!");
} else if (updateValue.equals("Instructor")) {
System.out.println("Whats the current Instructor?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new instructors name: ");
updatedChangeValue = input.nextLine();
collectionClass.updateOne(eq("Instructor", currentChangeValue), new Document("$set", new Document("Instructor", updatedChangeValue)));
System.out.println("Class Instructor updated!");
} else {
System.out.println("***No valid matches***");
}
break;
case 2:
System.out.println("What value would you like to update? \n " +
"[First Name, Last Name, Home State, Undergraduate Alma Mater, Graduate Alma Mater,\n" +
" Thesis Focus, Tech Interest, Department/Team, Role, How many years have your worked at Google?, Mentee(s)]");
updateValue = input.nextLine();
if (updateValue.equals("First Name")) {
System.out.println("Whats the current first name?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new first name: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("First Name", updatedChangeValue)));
} else if (updateValue.equals("Last Name")) {
System.out.println("Whats the current last name?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new first name: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Last Name", currentChangeValue), new Document("$set", new Document("Last Name", updatedChangeValue)));
} else if (updateValue.equals("Home State")) {
System.out.println("Whats the current home state?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new home state: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Home State", currentChangeValue), new Document("$set", new Document("Home State", updatedChangeValue)));
} else if (updateValue.equals("Undergraduate Alma Mater")) {
System.out.println("Whats your current Undergraduate Alma Mater?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new Undergraduate Alma Mater: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Undergraduate Alma Mater", currentChangeValue), new Document("$set", new Document("Undergraduate Alma Mater", updatedChangeValue)));
} else if (updateValue.equals("Graduate Alma Mater")) {
System.out.println("Whats your current Graduate Alma Mater?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new Graduate Alma Mater: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Graduate Alma Mater", currentChangeValue), new Document("$set", new Document("Graduate Alma Mater", updatedChangeValue)));
} else if (updateValue.equals("Thesis Focus")) {
System.out.println("Whats your current thesis focus?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new thesis focus: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Thesis Focus", currentChangeValue), new Document("$set", new Document("Thesis Focus", updatedChangeValue)));
} else if (updateValue.equals("Tech Interest")) {
System.out.println("Whats your current tech interest?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new tech interest: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Tech Interest", currentChangeValue), new Document("$set", new Document("Tech Interest", updatedChangeValue)));
} else if (updateValue.equals("Department/Team")) {
System.out.println("Whats your current department/team?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new department/team: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Department/Team", currentChangeValue), new Document("$set", new Document("Department/Team", updatedChangeValue)));
} else if (updateValue.equals("Role")) {
System.out.println("Whats your current role?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new role: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Role", currentChangeValue), new Document("$set", new Document("Role", updatedChangeValue)));
} else if (updateValue.equals("How many years have your worked at Google?")) {
System.out.println("How many years have you currently work at Google?");
currentChangeValue = input.nextLine();
System.out.println("Enter new number of years: ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("How many years have your worked at Google?", currentChangeValue), new Document("$set", new Document("How many years have your worked at Google?", updatedChangeValue)));
} else if (updateValue.equals("Mentee(s)")) {
System.out.println("Who are your current mentee(s)?");
currentChangeValue = input.nextLine();
System.out.println("Enter new mentee(s): ");
updatedChangeValue = input.nextLine();
collectionMentor.updateOne(eq("Mentee(s)", currentChangeValue), new Document("$set", new Document("Mentee(s)", updatedChangeValue)));
} else {
System.out.println("***No valid matches***");
}
break;
case 3:
System.out.println("What value would you like to update? \n " +
"[First Name, Last Name, School, Current Classes, Home State,\n" +
" Programming Languages, Horoscope, Favorite Cuisine, Type of Diet, Favorite Music Genre, Full Time]");
updateValue = input.nextLine();
if (updateValue.equals("First Name")) {
System.out.println("Whats the current first name?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new first name: ");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("First Name", updatedChangeValue)));
} else if (updateValue.equals("Last Name")) {
System.out.println("Whats the current last name?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new first name: ");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("Last Name", currentChangeValue), new Document("$set", new Document("Last Name", updatedChangeValue)));
} else if (updateValue.equals("School")) {
System.out.println("Who's school are you updating?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new school: ");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("School", updatedChangeValue)));
} else if (updateValue.equals("Current Classes")) {
System.out.println("Who's classes are you updating?");
currentChangeValue = input.nextLine();
System.out.println("Enter the new classes");
updatedChangeValue = input.nextLine();
String[] arrayOfClasses = updatedChangeValue.split(",");
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Current Classes", Arrays.toString(arrayOfClasses))));
} else if (updateValue.equals("Home State")) {
System.out.println("Who's home state are you updating?");
currentChangeValue = input.nextLine();
System.out.println("Enter " + currentChangeValue + "'s new home state:");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Home State", updatedChangeValue)));
} else if (updateValue.equals("Programming Languages")) {
System.out.println("Who's programming languages are you updating?");
currentChangeValue = input.nextLine();
System.out.println("Which programming language do you want to update? [Java, Python, C++, HTML/CSS, Javascript]");
String language = input.nextLine();
System.out.println("What is " + currentChangeValue + "'s new level of knowledge for " + language + "?");
String levelOfKnowledge = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Programming Languages." + language, levelOfKnowledge)));
} else if (updateValue.equals("Horoscope")) {
System.out.println("Who's horoscope are you updating?");
currentChangeValue = input.nextLine();
System.out.println("What is " + currentChangeValue + "'s new horoscope");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Horoscope", updatedChangeValue)));
} else if (updateValue.equals("Favorite Cuisine")) {
System.out.println("Who's favorite cuisine are you updating?");
currentChangeValue = input.nextLine();
System.out.println("What is " + currentChangeValue + "'s new favorite cuisine?");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Favorite Cuisine", updatedChangeValue)));
} else if (updateValue.equals("Type of Diet")) {
System.out.println("Who's type of diet are you updating?");
currentChangeValue = input.nextLine();
System.out.println("What is " + currentChangeValue + "'s new type of diet?");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Type of Diet", updatedChangeValue)));
} else if (updateValue.equals("Favorite Music Genre")) {
System.out.println("Who's favorite music genre are you updating?");
currentChangeValue = input.nextLine();
System.out.println("What is " + currentChangeValue + "'s new favorite music genre?");
updatedChangeValue = input.nextLine();
collectionStudent.updateOne(eq("First Name", currentChangeValue), new Document("$set", new Document("Favorite Music Genre", updatedChangeValue)));
} else {
System.out.println("***No valid matches***");
}
break;
}
menu();
user_input = input.nextInt();
} else if (user_input == 5) {
System.out.println("Choose collection[1: Classes 2: Mentors 3: Students]");
int choice = input.nextInt();
String valueToDelete;
// Skip the newline
input.nextLine();
switch (choice) {
case 1:
System.out.println("****Deleting from Classes collection****\n");
System.out.println("What class would you like to delete?");
valueToDelete = input.nextLine();
collectionClass.deleteOne(eq("Class Name", valueToDelete));
System.out.println(valueToDelete + " was deleted!");
break;
case 2:
System.out.println("****Deleting from Mentors collection****\n");
System.out.println("Enter the first name of the mentor who's data you would like to delete?");
String firstName = input.nextLine();
System.out.println("Enter last name:");
String lastName = input.nextLine();
query.append("First Name", firstName).append("Last Name", lastName);
collectionMentor.deleteOne(query);
System.out.println(firstName + " " + lastName + " was deleted!");
break;
case 3:
System.out.println("****Deleting from Students collection****\n");
System.out.println("Enter the first name of the student who's data you would like to delete?");
firstName = input.nextLine();
System.out.println("Enter last name:");
lastName = input.nextLine();
query.append("First Name", firstName).append("Last Name", lastName);
collectionStudent.deleteOne(query);
System.out.println(firstName + " " + lastName + " was deleted!");
break;
}
menu();
user_input = input.nextInt();
} else if (user_input == 6) {
System.out.println("Choose collection[2: Mentors 3: Students]");
int choice = input.nextInt();
String valueToDelete;
// Skip the newline
input.nextLine();
switch (choice) {
case 1:
break;
case 2:
System.out.println("Mentors years worked at google sorted in descending order:");
List<Document> list = collectionMentor.find().sort(descending("How many years have you worked at Google?")).into(new ArrayList<Document>());
for (Document aList : list) {
System.out.println(aList);
}
break;
case 3:
System.out.println("Students schools sorted in descending order:");
List<Document> list2 = collectionStudent.find().sort(descending("School")).into(new ArrayList<Document>());
for (Document aList : list2) {
System.out.println(aList);
}
break;
}
menu();
user_input = input.nextInt();
}
}
}
} | [
"[email protected]"
]
| |
f7bcaabe0e5bb55cb45d67fd2b56344a7c594dab | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mobileqqi/classes.jar/QQService/REPLYCODE.java | 995544c8a06e716b25062817e8bababcd5aaf565 | []
| no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 3,302 | java | package QQService;
import java.io.Serializable;
public final class REPLYCODE
implements Serializable
{
public static final REPLYCODE REPLYCODE_ERROR_EXCEPTION;
public static final REPLYCODE REPLYCODE_ERROR_FUNCNAME;
public static final REPLYCODE REPLYCODE_ERR_FAVOR_OVERLIMIT;
public static final REPLYCODE REPLYCODE_ERR_FILTERED;
public static final REPLYCODE REPLYCODE_ERR_LABLE_WRONG;
public static final REPLYCODE REPLYCODE_ERR_PIC_OVERLIMIT;
public static final REPLYCODE REPLYCODE_ERR_UIN_INVALID;
public static final REPLYCODE REPLYCODE_ERR_VOTED;
public static final REPLYCODE REPLYCODE_SUCC;
public static final int _REPLYCODE_ERROR_EXCEPTION = 1;
public static final int _REPLYCODE_ERROR_FUNCNAME = 2;
public static final int _REPLYCODE_ERR_FAVOR_OVERLIMIT = 53;
public static final int _REPLYCODE_ERR_FILTERED = 56;
public static final int _REPLYCODE_ERR_LABLE_WRONG = 52;
public static final int _REPLYCODE_ERR_PIC_OVERLIMIT = 55;
public static final int _REPLYCODE_ERR_UIN_INVALID = 54;
public static final int _REPLYCODE_ERR_VOTED = 51;
public static final int _REPLYCODE_SUCC = 0;
private static REPLYCODE[] a;
private String __T = new String();
private int __value;
static
{
if (!REPLYCODE.class.desiredAssertionStatus()) {}
for (boolean bool = true;; bool = false)
{
$assertionsDisabled = bool;
a = new REPLYCODE[9];
REPLYCODE_SUCC = new REPLYCODE(0, 0, "REPLYCODE_SUCC");
REPLYCODE_ERROR_EXCEPTION = new REPLYCODE(1, 1, "REPLYCODE_ERROR_EXCEPTION");
REPLYCODE_ERROR_FUNCNAME = new REPLYCODE(2, 2, "REPLYCODE_ERROR_FUNCNAME");
REPLYCODE_ERR_VOTED = new REPLYCODE(3, 51, "REPLYCODE_ERR_VOTED");
REPLYCODE_ERR_LABLE_WRONG = new REPLYCODE(4, 52, "REPLYCODE_ERR_LABLE_WRONG");
REPLYCODE_ERR_FAVOR_OVERLIMIT = new REPLYCODE(5, 53, "REPLYCODE_ERR_FAVOR_OVERLIMIT");
REPLYCODE_ERR_UIN_INVALID = new REPLYCODE(6, 54, "REPLYCODE_ERR_UIN_INVALID");
REPLYCODE_ERR_PIC_OVERLIMIT = new REPLYCODE(7, 55, "REPLYCODE_ERR_PIC_OVERLIMIT");
REPLYCODE_ERR_FILTERED = new REPLYCODE(8, 56, "REPLYCODE_ERR_FILTERED");
return;
}
}
private REPLYCODE(int paramInt1, int paramInt2, String paramString)
{
this.__T = paramString;
this.__value = paramInt2;
a[paramInt1] = this;
}
public static REPLYCODE convert(int paramInt)
{
int i = 0;
while (i < a.length)
{
if (a[i].value() == paramInt) {
return a[i];
}
i += 1;
}
if (!$assertionsDisabled) {
throw new AssertionError();
}
return null;
}
public static REPLYCODE convert(String paramString)
{
int i = 0;
while (i < a.length)
{
if (a[i].toString().equals(paramString)) {
return a[i];
}
i += 1;
}
if (!$assertionsDisabled) {
throw new AssertionError();
}
return null;
}
public String toString()
{
return this.__T;
}
public int value()
{
return this.__value;
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mobileqqi\classes2.jar
* Qualified Name: QQService.REPLYCODE
* JD-Core Version: 0.7.0.1
*/ | [
"[email protected]"
]
| |
50cbbc2587486da7cd74aec745fda751814280d0 | e784d1f79820a163b58257875192acdbaf1d5acc | /dotoyo_hr/src/com/dotoyo/buildjob/certificateCenter/dto/HotCertDto.java | 3580bfffd8a6723be9ec3b9634b8dc0b0973b7ea | []
| no_license | reaganjava/hr | e8e0198f0b265aa3a83f6772726f6517f33cbe3e | 8bb5ec41ebb1c0c311b68d67984fcc9037a458ab | refs/heads/master | 2020-04-06T03:33:39.926183 | 2013-06-24T10:19:18 | 2013-06-24T10:19:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,210 | java | package com.dotoyo.buildjob.certificateCenter.dto;
import java.io.Serializable;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import com.dotoyo.buildjob.common.constant.ApplicationConstant;
public class HotCertDto implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7141792024866083592L;
private Long id;
private String certCode;// ่ฏไนฆ็ผ็
public HotCertDto() {
}
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return the certCode
*/
public String getCertCode() {
return certCode == null ? "" : certCode.trim();
}
/**
* @param certCode
* the certCode to set
*/
public void setCertCode(String certCode) {
this.certCode = certCode;
}
@Override
public String toString() {
try {
return BeanUtils.describe(this).toString();
} catch (Exception e) {
Logger.getLogger(this.getClass()).error(
ApplicationConstant.ERROR_CONVERTING_OBJECT_TO_STRING, e);
}
return super.toString();
}
}
| [
"[email protected]"
]
| |
e21e4046feea8e73dcf265e23c8b908313e69f8c | 5453b7b99b11c07c5d2f66c2187237bd8b8235ef | /MTBasics/com/threads/basics3/UseExecutorFramework.java | ffa3695ab3c0cece827764fa0358aaa847442d55 | []
| no_license | sahilgupta5/MultiThreadingInJava | 7eafb94064fd01ad26e15fcc90f7ce8901931f15 | 7ac9c0f3a4054ed9df7457c610aeab1ba8262f03 | refs/heads/master | 2021-01-10T03:55:25.096937 | 2016-04-02T19:42:49 | 2016-04-02T19:42:49 | 54,792,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,821 | java | package com.threads.basics3;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* This class shows the use of executor framework, explains thread pools along
* with the use of shutdown, awaitTermination and shutdownNow methods.
*
* @author Sahil Gupta
*
*/
class runner extends Thread {
final static int COUNT_END = 1000;
int TID;
int count = 0;
public runner(int tid) {
TID = tid;
}
public void run() {
System.out.println("Starting thread: " + TID + " with count: " + count);
for (int i = 0; i < COUNT_END; i++) {
count++;
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Ending thread: " + TID + " with count: " + count);
}
}
public class UseExecutorFramework {
// Vary the number of threads in the pool i.e. between 0 and N_THREADS_TOTAL
// to see how executor service completes your threads/tasks.
final static int N_THREADS_POOL = 10;
final static int N_THREADS_TOTAL = 100;
public static void main(String args[]) {
ExecutorService es = Executors.newFixedThreadPool(N_THREADS_POOL);
for (int i = 0; i < N_THREADS_TOTAL; i++) {
Runnable worker = new runner(i);
es.execute(worker);
}
/**
* http://stackoverflow.com/questions/18425026/shutdown-and-
* awaittermination-which-first-call-have-any-difference shutdownNow :
*
* Attempts to stop all actively executing tasks, halts the processing
* of waiting tasks, and returns a list of the tasks that were awaiting
* execution. These tasks are drained (removed) from the task queue upon
* return from this method.
*
* This method does not wait for actively executing tasks to terminate.
* Use awaitTermination to do that.
*
* There are no guarantees beyond best-effort attempts to stop
* processing actively executing tasks. This implementation cancels
* tasks via Thread.interrupt(), so any task that fails to respond to
* interrupts may never terminate shutdown:
*
* Initiates an orderly shutdown in which previously submitted tasks are
* executed, but no new tasks will be accepted. Invocation has no
* additional effect if already shut down.
*
* This method does not wait for previously submitted tasks to complete
* execution. Use awaitTermination to do that. awaitTermination:
*
* Blocks until all tasks have completed execution after a shutdown
* request, or the timeout occurs, or the current thread is interrupted,
* whichever happens first.
*/
es.shutdown();
// Wait until all threads are finish
try {
es.awaitTermination(1, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Finished all threads");
}
}
| [
"[email protected]"
]
| |
17570eaf19f3c2306921511053fd6715b7147719 | 04cff0b054f3ec896099786cbc73d21a57fdc83a | /huawei_push/src/main/java/com/huawei/hms/support/api/push/PushReceiver.java | edf0623550300246e6d7a2012157195bdb1724a8 | []
| no_license | zuoyuan333/umeng_push_replace_jar | d5cfe824de21fcb51231b8a62e66d414082fdc11 | 68c604cd787be3a60b2a5551406e86933929d0ec | refs/heads/master | 2021-07-10T22:01:49.407811 | 2020-11-03T09:38:04 | 2020-11-03T09:38:04 | 211,770,040 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 486 | java | package com.huawei.hms.support.api.push;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
public abstract class PushReceiver extends BroadcastReceiver {
public void onToken(Context var1, String var2, Bundle var3) {
this.onToken(var1, var2);
}
public void onToken(Context var1, String var2) {
}
@Override
public void onReceive(Context context, Intent intent) {
}
}
| [
"[email protected]"
]
| |
979688a0702c2936d84bcca8e2db5e20d2587096 | 5cd81e872bc3e71e493cccd4ee0311c60ff93db8 | /JavaCncepts/src/oops_interface_assignmets/mobilePage.java | 86080f6bcce6992952a5362a8fe38d40af4f50d3 | []
| no_license | gudusanghamitra03/June2021javasessions | e8c6669dfb343cdb7dc3ff9bf028a746cb63de2c | 02f928f168b1d1ee6b65aee5ce372ec245f9b34f | refs/heads/master | 2023-07-05T07:27:39.487985 | 2021-08-28T17:29:54 | 2021-08-28T17:29:54 | 400,550,316 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 164 | java | package oops_interface_assignmets;
public interface mobilePage extends W3C {
public void Login();
public void title();
public void createAccount();
}
| [
"[email protected]"
]
| |
0d984093940b16796bce7812d2cb05c2e97e5ab5 | 36f11aea4016d8fec2611b651dbdc92f489ea350 | /nacid/src/com/nacid/bl/applications/Person.java | 97007c0629ff04aa28584199abe4e88d53eb7178 | [
"MIT"
]
| permissive | governmentbg/NACID-DOCTORS-TITLES | a91eecfee6d6510ace5499a18c4dbe25680743be | 72b79b14af654573e5d23e0048adeac20d06696a | refs/heads/master | 2022-12-03T22:39:48.965063 | 2020-08-28T07:11:13 | 2020-08-28T07:11:13 | 281,618,972 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 344 | java | package com.nacid.bl.applications;
import com.nacid.bl.applications.base.PersonBase;
import com.nacid.bl.nomenclatures.Country;
import com.nacid.bl.nomenclatures.FlatNomenclature;
public interface Person extends PersonBase {
public Country getBirthCountry();
public Country getCitizenship();
public PersonDocument getPersonDocument();
}
| [
"[email protected]"
]
| |
b4243083a186fdb0e38665febbf180a67533fccb | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipseswt_cluster/60195/tar_0.java | dbc5887da8c1a1951ae38f8ae69118b7172a9fe9 | []
| no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 108,011 | java | /*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.internal.Converter;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.accessibility.*;
/**
* Control is the abstract superclass of all windowed user interface classes.
* <p>
* <dl>
* <dt><b>Styles:</b>
* <dd>BORDER</dd>
* <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
* <dt><b>Events:</b>
* <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,
* MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize, Traverse,
* DragDetect, MenuDetect</dd>
* </dl>
* <p>
* Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
* </p><p>
* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.
* </p>
*/
public abstract class Control extends Widget implements Drawable {
int /*long*/ fixedHandle;
int /*long*/ redrawWindow, enableWindow;
int drawCount;
Composite parent;
Cursor cursor;
Menu menu;
Font font;
String toolTipText;
Object layoutData;
Accessible accessible;
Control () {
}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
* <p>
* The style value is either one of the style constants defined in
* class <code>SWT</code> which is applicable to instances of this
* class, or must be built by <em>bitwise OR</em>'ing together
* (that is, using the <code>int</code> "|" operator) two or more
* of those <code>SWT</code> style constants. The class description
* lists the style constants that are applicable to the class.
* Style bits are also inherited from superclasses.
* </p>
*
* @param parent a composite control which will be the parent of the new instance (cannot be null)
* @param style the style of control to construct
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*
* @see SWT#BORDER
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
public Control (Composite parent, int style) {
super (parent, style);
this.parent = parent;
createWidget (0);
}
int /*long*/ defaultFont () {
return display.defaultFont;
}
void deregister () {
super.deregister ();
if (fixedHandle != 0) display.removeWidget (fixedHandle);
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) display.removeWidget (imHandle);
}
boolean drawGripper (int x, int y, int width, int height) {
int /*long*/ paintHandle = paintHandle ();
int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle);
if (window == 0) return false;
OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, new byte [1], x, y, width, height, OS.GTK_ORIENTATION_VERTICAL);
return true;
}
void enableWidget (boolean enabled) {
OS.gtk_widget_set_sensitive (handle, enabled);
}
int /*long*/ eventHandle () {
return handle;
}
void fixFocus (Control focusControl) {
Shell shell = getShell ();
Control control = this;
while ((control = control.parent) != null) {
if (control.setFocus ()) return;
if (control == shell) break;
}
shell.setSavedFocus (focusControl);
int /*long*/ focusHandle = shell.fixedHandle;
OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
OS.gtk_widget_grab_focus (focusHandle);
OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
}
int /*long*/ focusHandle () {
return handle;
}
int /*long*/ fontHandle () {
return handle;
}
boolean hasFocus () {
return this == display.getFocusControl();
}
void hookEvents () {
int /*long*/ windowProc2 = display.windowProc2;
int /*long*/ windowProc3 = display.windowProc3;
/* Connect the keyboard signals */
int /*long*/ focusHandle = focusHandle ();
int focusMask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK;
OS.gtk_widget_add_events (focusHandle, focusMask);
OS.g_signal_connect (focusHandle, OS.popup_menu, windowProc2, POPUP_MENU);
OS.g_signal_connect (focusHandle, OS.show_help, windowProc3, SHOW_HELP);
OS.g_signal_connect (focusHandle, OS.key_press_event, windowProc3, KEY_PRESS_EVENT);
OS.g_signal_connect (focusHandle, OS.key_release_event, windowProc3, KEY_RELEASE_EVENT);
OS.g_signal_connect (focusHandle, OS.focus, windowProc3, FOCUS);
OS.g_signal_connect (focusHandle, OS.focus_in_event, windowProc3, FOCUS_IN_EVENT);
OS.g_signal_connect (focusHandle, OS.focus_out_event, windowProc3, FOCUS_OUT_EVENT);
/* Connect the mouse signals */
int /*long*/ eventHandle = eventHandle ();
int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK |
OS.GDK_BUTTON_RELEASE_MASK | OS.GDK_ENTER_NOTIFY_MASK |
OS.GDK_LEAVE_NOTIFY_MASK;
OS.gtk_widget_add_events (eventHandle, eventMask);
OS.g_signal_connect (eventHandle, OS.button_press_event, windowProc3, BUTTON_PRESS_EVENT);
OS.g_signal_connect (eventHandle, OS.button_release_event, windowProc3, BUTTON_RELEASE_EVENT);
OS.g_signal_connect (eventHandle, OS.motion_notify_event, windowProc3, MOTION_NOTIFY_EVENT);
OS.g_signal_connect (eventHandle, OS.enter_notify_event, windowProc3, ENTER_NOTIFY_EVENT);
OS.g_signal_connect (eventHandle, OS.leave_notify_event, windowProc3, LEAVE_NOTIFY_EVENT);
OS.g_signal_connect (eventHandle, OS.scroll_event, windowProc3, SCROLL_EVENT);
/*
* Feature in GTK. Events such as mouse move are propagate up
* the widget hierarchy and are seen by the parent. This is the
* correct GTK behavior but not correct for SWT. The fix is to
* hook a signal after and stop the propagation using a negative
* event number to distinguish this case.
*/
OS.g_signal_connect_after (eventHandle, OS.button_press_event, windowProc3, -BUTTON_PRESS_EVENT);
OS.g_signal_connect_after (eventHandle, OS.button_release_event, windowProc3, -BUTTON_RELEASE_EVENT);
OS.g_signal_connect_after (eventHandle, OS.motion_notify_event, windowProc3, -MOTION_NOTIFY_EVENT);
/* Connect the event_after signal for both key and mouse */
OS.g_signal_connect (eventHandle, OS.event_after, windowProc3, EVENT_AFTER);
if (focusHandle != eventHandle) {
OS.g_signal_connect (focusHandle, OS.event_after, windowProc3, EVENT_AFTER);
}
/* Connect the paint signal */
int /*long*/ paintHandle = paintHandle ();
int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK;
OS.gtk_widget_add_events (paintHandle, paintMask);
OS.g_signal_connect (paintHandle, OS.expose_event, windowProc3, -EXPOSE_EVENT);
OS.g_signal_connect (paintHandle, OS.visibility_notify_event, windowProc3, VISIBILITY_NOTIFY_EVENT);
OS.g_signal_connect_after (paintHandle, OS.expose_event, windowProc3, EXPOSE_EVENT);
/* Connect the Input Method signals */
OS.g_signal_connect_after (handle, OS.realize, windowProc2, REALIZE);
OS.g_signal_connect (handle, OS.unrealize, windowProc2, UNREALIZE);
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
OS.g_signal_connect (imHandle, OS.commit, windowProc3, COMMIT);
OS.g_signal_connect (imHandle, OS.preedit_changed, windowProc2, PREEDIT_CHANGED);
}
int /*long*/ topHandle = topHandle ();
OS.g_signal_connect_after (topHandle, OS.map, windowProc2, MAP);
}
int /*long*/ hoverProc (int /*long*/ widget) {
if(!hooks (SWT.MouseHover) && !filters (SWT.MouseHover)) return 0;
Event event = new Event ();
int [] x = new int [1], y = new int [1], mask = new int [1];
OS.gdk_window_get_pointer (0, x, y, mask);
event.x = x [0];
event.y = y [0];
int /*long*/ eventHandle = eventHandle ();
int /*long*/ window = OS.GTK_WIDGET_WINDOW (eventHandle);
OS.gdk_window_get_origin (window, x, y);
event.x -= x [0];
event.y -= y [0];
setInputState (event, mask [0]);
postEvent (SWT.MouseHover, event);
return 0;
}
int /*long*/ topHandle() {
if (fixedHandle != 0) return fixedHandle;
return super.topHandle ();
}
int /*long*/ paintHandle () {
int /*long*/ topHandle = topHandle ();
int /*long*/ paintHandle = handle;
while (paintHandle != topHandle) {
if ((OS.GTK_WIDGET_FLAGS (paintHandle) & OS.GTK_NO_WINDOW) == 0) break;
paintHandle = OS.gtk_widget_get_parent (paintHandle);
}
return paintHandle;
}
int /*long*/ paintWindow () {
int /*long*/ paintHandle = paintHandle ();
OS.gtk_widget_realize (paintHandle);
return OS.GTK_WIDGET_WINDOW (paintHandle);
}
/**
* Returns the preferred size of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
* allow the caller to ask a control questions such as "Given a particular
* width, how high does the control need to be to show all of the contents?"
* To indicate that the caller does not wish to constrain a particular
* dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
* </p>
*
* @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
* @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
* @return the preferred size of the control
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Layout
* @see #getBorderWidth
* @see #getBounds
* @see #getSize
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
}
Control computeTabGroup () {
if (isTabGroup()) return this;
return parent.computeTabGroup ();
}
Control[] computeTabList() {
if (isTabGroup()) {
if (getVisible() && getEnabled()) {
return new Control[] {this};
}
}
return new Control[0];
}
Control computeTabRoot () {
Control[] tabList = parent._getTabList();
if (tabList != null) {
int index = 0;
while (index < tabList.length) {
if (tabList [index] == this) break;
index++;
}
if (index == tabList.length) {
if (isTabGroup ()) return this;
}
}
return parent.computeTabRoot ();
}
void checkBorder () {
if (getBorderWidth () == 0) style &= ~SWT.BORDER;
}
void createWidget (int index) {
checkOrientation (parent);
super.createWidget (index);
showWidget ();
setInitialBounds ();
setZOrder (null, false);
checkBorder ();
}
/**
* Returns the preferred size of the receiver.
* <p>
* The <em>preferred size</em> of a control is the size that it would
* best be displayed at. The width hint and height hint arguments
* allow the caller to ask a control questions such as "Given a particular
* width, how high does the control need to be to show all of the contents?"
* To indicate that the caller does not wish to constrain a particular
* dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
* </p><p>
* If the changed flag is <code>true</code>, it indicates that the receiver's
* <em>contents</em> have changed, therefore any caches that a layout manager
* containing the control may have been keeping need to be flushed. When the
* control is resized, the changed flag will be <code>false</code>, so layout
* manager caches can be retained.
* </p>
*
* @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
* @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
* @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
* @return the preferred size of the control.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Layout
* @see #getBorderWidth
* @see #getBounds
* @see #getSize
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
return computeNativeSize (handle, wHint, hHint, changed);
}
Point computeNativeSize (int /*long*/ h, int wHint, int hHint, boolean changed) {
int width = wHint, height = hHint;
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (h, requisition);
width = wHint == SWT.DEFAULT ? OS.GTK_WIDGET_REQUISITION_WIDTH (h) : wHint;
height = hHint == SWT.DEFAULT ? OS.GTK_WIDGET_REQUISITION_HEIGHT (h) : hHint;
}
return new Point (width, height);
}
void forceResize () {
/*
* Force size allocation on all children of this widget's
* topHandle. Note that all calls to gtk_widget_size_allocate()
* must be preceded by a call to gtk_widget_size_request().
*/
int /*long*/ topHandle = topHandle ();
int flags = OS.GTK_WIDGET_FLAGS (topHandle);
OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE);
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (topHandle, requisition);
GtkAllocation allocation = new GtkAllocation ();
allocation.x = OS.GTK_WIDGET_X (topHandle);
allocation.y = OS.GTK_WIDGET_Y (topHandle);
allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
OS.gtk_widget_size_allocate (topHandle, allocation);
if ((flags & OS.GTK_VISIBLE) == 0) {
OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE);
}
}
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
* then the object is created and returned.
*
* @return the accessible object
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see Accessible#addAccessibleListener
* @see Accessible#addAccessibleControlListener
*
* @since 2.0
*/
public Accessible getAccessible () {
checkWidget ();
if (accessible == null) {
accessible = Accessible.internal_new_Accessible (this);
}
return accessible;
}
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null),
* unless the receiver is a shell. In this case, the location is
* relative to the display.
*
* @return the receiver's bounding rectangle
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Rectangle getBounds () {
checkWidget();
int /*long*/ topHandle = topHandle ();
int x = OS.GTK_WIDGET_X (topHandle);
int y = OS.GTK_WIDGET_Y (topHandle);
if ((state & ZERO_SIZED) != 0) {
return new Rectangle (x, y, 0, 0);
}
int width = OS.GTK_WIDGET_WIDTH (topHandle);
int height = OS.GTK_WIDGET_HEIGHT (topHandle);
return new Rectangle (x, y, width, height);
}
/**
* Sets the receiver's size and location to the rectangular
* area specified by the argument. The <code>x</code> and
* <code>y</code> fields of the rectangle are relative to
* the receiver's parent (or its display if its parent is null).
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param rect the new bounds for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, rect.width, rect.height);
}
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
* <code>y</code> arguments are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the <code>x</code>
* and <code>y</code> arguments are relative to the display.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param x the new x coordinate for the receiver
* @param y the new y coordinate for the receiver
* @param width the new width for the receiver
* @param height the new height for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
}
void markLayout (boolean changed, boolean all) {
/* Do nothing */
}
void moveHandle (int x, int y) {
int /*long*/ topHandle = topHandle ();
int /*long*/ parentHandle = parent.parentingHandle ();
OS.gtk_fixed_move (parentHandle, topHandle, x, y);
}
void resizeHandle (int width, int height) {
int /*long*/ topHandle = topHandle ();
OS.gtk_widget_set_size_request (topHandle, width, height);
if (topHandle != handle) OS.gtk_widget_set_size_request (handle, width, height);
}
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int /*long*/ topHandle = topHandle ();
int flags = OS.GTK_WIDGET_FLAGS (topHandle);
OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE);
boolean sameOrigin = true, sameExtent = true;
if (move) {
int oldX = OS.GTK_WIDGET_X (topHandle);
int oldY = OS.GTK_WIDGET_Y (topHandle);
sameOrigin = x == oldX && y == oldY;
if (!sameOrigin) {
if (enableWindow != 0) {
OS.gdk_window_move (enableWindow, x, y);
}
moveHandle (x, y);
}
}
if (resize) {
int oldWidth = 0, oldHeight = 0;
if ((state & ZERO_SIZED) == 0) {
oldWidth = OS.GTK_WIDGET_WIDTH (topHandle);
oldHeight = OS.GTK_WIDGET_HEIGHT (topHandle);
}
sameExtent = width == oldWidth && height == oldHeight;
if (!sameExtent && !(width == 0 && height == 0)) {
int newWidth = Math.max (1, width);
int newHeight = Math.max (1, height);
if (redrawWindow != 0) {
OS.gdk_window_resize (redrawWindow, newWidth, newHeight);
}
if (enableWindow != 0) {
OS.gdk_window_resize (enableWindow, newWidth, newHeight);
}
resizeHandle (newWidth, newHeight);
}
}
if (!sameOrigin || !sameExtent) {
/*
* Cause a size allocation this widget's topHandle. Note that
* all calls to gtk_widget_size_allocate() must be preceded by
* a call to gtk_widget_size_request().
*/
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (topHandle, requisition);
GtkAllocation allocation = new GtkAllocation ();
if (move) {
allocation.x = x;
allocation.y = y;
} else {
allocation.x = OS.GTK_WIDGET_X (topHandle);
allocation.y = OS.GTK_WIDGET_Y (topHandle);
}
if (resize) {
allocation.width = width;
allocation.height = height;
} else {
allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
}
OS.gtk_widget_size_allocate (topHandle, allocation);
}
if ((flags & OS.GTK_VISIBLE) == 0) {
OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE);
}
/*
* Bug in GTK. Widgets cannot be sized smaller than 1x1.
* The fix is to hide zero-sized widgets and show them again
* when they are resized larger.
*/
if (!sameExtent) {
if (width == 0 && height == 0) {
state |= ZERO_SIZED;
if (enableWindow != 0) {
OS.gdk_window_hide (enableWindow);
}
OS.gtk_widget_hide (topHandle);
} else {
state &= ~ZERO_SIZED;
if ((state & HIDDEN) == 0) {
if (enableWindow != 0) {
OS.gdk_window_show_unraised (enableWindow);
}
OS.gtk_widget_show (topHandle);
}
}
}
int result = 0;
if (move && !sameOrigin) {
sendEvent (SWT.Move);
result |= MOVED;
}
if (resize && !sameExtent) {
sendEvent (SWT.Resize);
result |= RESIZED;
}
return result;
}
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @return the receiver's location
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point getLocation () {
checkWidget();
int /*long*/ topHandle = topHandle ();
int x = OS.GTK_WIDGET_X (topHandle);
int y = OS.GTK_WIDGET_Y (topHandle);
return new Point (x, y);
}
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @param location the new location for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
* parent (or its display if its parent is null), unless
* the receiver is a shell. In this case, the point is
* relative to the display.
*
* @param x the new x coordinate for the receiver
* @param y the new y coordinate for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLocation(int x, int y) {
checkWidget();
setBounds (x, y, 0, 0, true, false);
}
/**
* Returns a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
* The y coordinate of the result is the height of the
* receiver.
*
* @return the receiver's size
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point getSize () {
checkWidget();
if ((state & ZERO_SIZED) != 0) {
return new Point (0, 0);
}
int /*long*/ topHandle = topHandle ();
int width = OS.GTK_WIDGET_WIDTH (topHandle);
int height = OS.GTK_WIDGET_HEIGHT (topHandle);
return new Point (width, height);
}
/**
* Sets the receiver's size to the point specified by the argument.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause them to be
* set to zero instead.
* </p>
*
* @param size the new size for the receiver
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
/**
* Sets the receiver's size to the point specified by the arguments.
* <p>
* Note: Attempting to set the width or height of the
* receiver to a negative number will cause that
* value to be set to zero instead.
* </p>
*
* @param width the new width for the receiver
* @param height the new height for the receiver
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setSize (int width, int height) {
checkWidget();
setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true);
}
/**
* Moves the receiver above the specified control in the
* drawing order. If the argument is null, then the receiver
* is moved to the top of the drawing order. The control at
* the top of the drawing order will not be covered by other
* controls even if they occupy intersecting areas.
*
* @param control the sibling control (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #moveBelow
*/
public void moveAbove (Control control) {
checkWidget();
if (control != null) {
if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
}
setZOrder (control, true);
}
/**
* Moves the receiver below the specified control in the
* drawing order. If the argument is null, then the receiver
* is moved to the bottom of the drawing order. The control at
* the bottom of the drawing order will be covered by all other
* controls which occupy intersecting areas.
*
* @param control the sibling control (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #moveAbove
*/
public void moveBelow (Control control) {
checkWidget();
if (control != null) {
if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
}
setZOrder (control, false);
}
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
* from its layout, if there is one.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #computeSize
*/
public void pack () {
pack (true);
}
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
* from its layout, if there is one.
* <p>
* If the changed flag is <code>true</code>, it indicates that the receiver's
* <em>contents</em> have changed, therefore any caches that a layout manager
* containing the control may have been keeping need to be flushed. When the
* control is resized, the changed flag will be <code>false</code>, so layout
* manager caches can be retained.
* </p>
*
* @param changed whether or not the receiver's contents have changed
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #computeSize
*/
public void pack (boolean changed) {
setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
}
/**
* Sets the layout data associated with the receiver to the argument.
*
* @param layoutData the new layout data for the receiver.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setLayoutData (Object layoutData) {
checkWidget();
this.layoutData = layoutData;
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
* to coordinates relative to the receiver.
* <p>
* @param x the x coordinate to be translated
* @param y the y coordinate to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 2.1
*/
public Point toControl (int x, int y) {
checkWidget ();
int /*long*/ eventHandle = eventHandle ();
OS.gtk_widget_realize (eventHandle);
int /*long*/ window = OS.GTK_WIDGET_WINDOW (eventHandle);
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
return new Point (x - origin_x [0], y - origin_y [0]);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
* to coordinates relative to the receiver.
* <p>
* @param point the point to be translated (must not be null)
* @return the translated coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point toControl (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
return toControl (point.x, point.y);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
* the receiver, to display relative coordinates.
* <p>
* @param x the x coordinate to be translated
* @param y the y coordinate to be translated
* @return the translated coordinates
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @since 2.1
*/
public Point toDisplay (int x, int y) {
checkWidget();
int /*long*/ eventHandle = eventHandle ();
OS.gtk_widget_realize (eventHandle);
int /*long*/ window = OS.GTK_WIDGET_WINDOW (eventHandle);
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
return new Point (origin_x [0] + x, origin_y [0] + y);
}
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
* the receiver, to display relative coordinates.
* <p>
* @param point the point to be translated (must not be null)
* @return the translated coordinates
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the point is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Point toDisplay (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
return toDisplay (point.x, point.y);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
* it one of the messages defined in the <code>ControlListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see ControlListener
* @see #removeControlListener
*/
public void addControlListener(ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Resize,typedListener);
addListener (SWT.Move,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the control gains or loses focus, by sending
* it one of the messages defined in the <code>FocusListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see FocusListener
* @see #removeFocusListener
*/
public void addFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.FocusIn,typedListener);
addListener(SWT.FocusOut,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
* by sending it one of the messages defined in the
* <code>HelpListener</code> interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see HelpListener
* @see #removeHelpListener
*/
public void addHelpListener (HelpListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Help, typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard, by sending
* it one of the messages defined in the <code>KeyListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see KeyListener
* @see #removeKeyListener
*/
public void addKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.KeyUp,typedListener);
addListener(SWT.KeyDown,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when mouse buttons are pressed and released, by sending
* it one of the messages defined in the <code>MouseListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseListener
* @see #removeMouseListener
*/
public void addMouseListener(MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.MouseDown,typedListener);
addListener(SWT.MouseUp,typedListener);
addListener(SWT.MouseDoubleClick,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse moves, by sending it one of the
* messages defined in the <code>MouseMoveListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseMoveListener
* @see #removeMouseMoveListener
*/
public void addMouseMoveListener(MouseMoveListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.MouseMove,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse passes or hovers over controls, by sending
* it one of the messages defined in the <code>MouseTrackListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseTrackListener
* @see #removeMouseTrackListener
*/
public void addMouseTrackListener (MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.MouseEnter,typedListener);
addListener (SWT.MouseExit,typedListener);
addListener (SWT.MouseHover,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver needs to be painted, by sending it
* one of the messages defined in the <code>PaintListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see PaintListener
* @see #removePaintListener
*/
public void addPaintListener(PaintListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener(SWT.Paint,typedListener);
}
/**
* Adds the listener to the collection of listeners who will
* be notified when traversal events occur, by sending it
* one of the messages defined in the <code>TraverseListener</code>
* interface.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see TraverseListener
* @see #removeTraverseListener
*/
public void addTraverseListener (TraverseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Traverse,typedListener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see ControlListener
* @see #addControlListener
*/
public void removeControlListener (ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Move, listener);
eventTable.unhook (SWT.Resize, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the control gains or loses focus.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see FocusListener
* @see #addFocusListener
*/
public void removeFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.FocusIn, listener);
eventTable.unhook (SWT.FocusOut, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see HelpListener
* @see #addHelpListener
*/
public void removeHelpListener (HelpListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Help, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see KeyListener
* @see #addKeyListener
*/
public void removeKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.KeyUp, listener);
eventTable.unhook (SWT.KeyDown, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when mouse buttons are pressed and released.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseListener
* @see #addMouseListener
*/
public void removeMouseListener (MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MouseDown, listener);
eventTable.unhook (SWT.MouseUp, listener);
eventTable.unhook (SWT.MouseDoubleClick, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse moves.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseMoveListener
* @see #addMouseMoveListener
*/
public void removeMouseMoveListener(MouseMoveListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MouseMove, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse passes or hovers over controls.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see MouseTrackListener
* @see #addMouseTrackListener
*/
public void removeMouseTrackListener(MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.MouseEnter, listener);
eventTable.unhook (SWT.MouseExit, listener);
eventTable.unhook (SWT.MouseHover, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver needs to be painted.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see PaintListener
* @see #addPaintListener
*/
public void removePaintListener(PaintListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook(SWT.Paint, listener);
}
/**
* Removes the listener from the collection of listeners who will
* be notified when traversal events occur.
*
* @param listener the listener which should be notified
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see TraverseListener
* @see #addTraverseListener
*/
public void removeTraverseListener(TraverseListener listener) {
checkWidget ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Traverse, listener);
}
boolean filterKey (int keyval, int /*long*/ event) {
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
return OS.gtk_im_context_filter_keypress (imHandle, event);
}
return false;
}
Menu [] findMenus (Control control) {
if (menu != null && this != control) return new Menu [] {menu};
return new Menu [0];
}
void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
oldShell.fixShell (newShell, this);
oldDecorations.fixDecorations (newDecorations, this, menus);
}
int /*long*/ fixedMapProc (int /*long*/ widget) {
OS.GTK_WIDGET_SET_FLAGS (widget, OS.GTK_MAPPED);
int /*long*/ widgetList = OS.gtk_container_get_children (widget);
if (widgetList != 0) {
int /*long*/ widgets = widgetList;
while (widgets != 0) {
int /*long*/ child = OS.g_list_data (widgets);
if (OS.GTK_WIDGET_VISIBLE (child) && OS.gtk_widget_get_child_visible (child) && !OS.GTK_WIDGET_MAPPED (child)) {
OS.gtk_widget_map (child);
}
widgets = OS.g_list_next (widgets);
}
OS.g_list_free (widgetList);
}
if ((OS.GTK_WIDGET_FLAGS (widget) & OS.GTK_NO_WINDOW) == 0) {
OS.gdk_window_show_unraised (OS.GTK_WIDGET_WINDOW (widget));
}
return 0;
}
/**
* Forces the receiver to have the <em>keyboard focus</em>, causing
* all keyboard events to be delivered to it.
*
* @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #setFocus
*/
public boolean forceFocus () {
checkWidget();
if (display.focusEvent == SWT.FocusOut) return false;
Shell shell = getShell ();
shell.setSavedFocus (this);
if (!isEnabled () || !isVisible ()) return false;
shell.bringToTop (false);
return forceFocus (focusHandle ());
}
boolean forceFocus (int /*long*/ focusHandle) {
OS.gtk_widget_grab_focus (focusHandle);
Shell shell = getShell ();
int /*long*/ shellHandle = shell.shellHandle;
int /*long*/ handle = OS.gtk_window_get_focus (shellHandle);
while (handle != 0) {
if (handle == focusHandle) return true;
if (display.getWidget (handle) != null) return false;
handle = OS.gtk_widget_get_parent (handle);
}
return false;
}
/**
* Returns the receiver's background color.
*
* @return the background color
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Color getBackground () {
checkWidget();
return Color.gtk_new (display, getBackgroundColor ());
}
GdkColor getBackgroundColor () {
return getBgColor ();
}
GdkColor getBgColor () {
int /*long*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
OS.gtk_style_get_bg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
return color;
}
GdkColor getBaseColor () {
int /*long*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
OS.gtk_style_get_base (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
return color;
}
/**
* Returns the receiver's border width.
*
* @return the border width
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public int getBorderWidth () {
checkWidget();
return 0;
}
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
* not selectable from the user interface and draws with an
* inactive or "grayed" look.
*
* @return the receiver's enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #isEnabled
*/
public boolean getEnabled () {
checkWidget ();
return (state & DISABLED) == 0;
}
/**
* Returns the font that the receiver will use to paint textual information.
*
* @return the receiver's font
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Font getFont () {
checkWidget();
if (font != null) return font;
return Font.gtk_new (display, defaultFont ());
}
int /*long*/ getFontDescription () {
int /*long*/ fontHandle = fontHandle ();
return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle));
}
/**
* Returns the foreground color that the receiver will use to draw.
*
* @return the receiver's foreground color
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Color getForeground () {
checkWidget();
return Color.gtk_new (display, getForegroundColor ());
}
GdkColor getForegroundColor () {
return getFgColor ();
}
GdkColor getFgColor () {
int /*long*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
return color;
}
Point getIMCaretPos () {
return new Point (0, 0);
}
GdkColor getTextColor () {
int /*long*/ fontHandle = fontHandle ();
OS.gtk_widget_realize (fontHandle);
GdkColor color = new GdkColor ();
OS.gtk_style_get_text (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
return color;
}
/**
* Returns layout data which is associated with the receiver.
*
* @return the receiver's layout data
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Object getLayoutData () {
checkWidget();
return layoutData;
}
/**
* Returns the receiver's pop up menu if it has one, or null
* if it does not. All controls may optionally have a pop up
* menu that is displayed when the user requests one for
* the control. The sequence of key strokes, button presses
* and/or button releases that are used to request a pop up
* menu is platform specific.
*
* @return the receiver's menu
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Menu getMenu () {
checkWidget();
return menu;
}
/**
* Returns the receiver's monitor.
*
* @return the receiver's monitor
*
* @since 3.0
*/
public Monitor getMonitor () {
checkWidget();
Monitor monitor = null;
int /*long*/ screen = OS.gdk_screen_get_default ();
if (screen != 0) {
int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ());
GdkRectangle dest = new GdkRectangle ();
OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
monitor = new Monitor ();
monitor.handle = monitorNumber;
monitor.x = dest.x;
monitor.y = dest.y;
monitor.width = dest.width;
monitor.height = dest.height;
monitor.clientX = monitor.x;
monitor.clientY = monitor.y;
monitor.clientWidth = monitor.width;
monitor.clientHeight = monitor.height;
} else {
monitor = display.getPrimaryMonitor ();
}
return monitor;
}
/**
* Returns the receiver's parent, which must be a <code>Composite</code>
* or null when the receiver is a shell that was created with null or
* a display for a parent.
*
* @return the receiver's parent
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public Composite getParent () {
checkWidget();
return parent;
}
Control [] getPath () {
int count = 0;
Shell shell = getShell ();
Control control = this;
while (control != shell) {
count++;
control = control.parent;
}
control = this;
Control [] result = new Control [count];
while (control != shell) {
result [--count] = control;
control = control.parent;
}
return result;
}
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
* shell. Shells return themselves, even if they are children
* of other shells.
*
* @return the receiver's shell
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getParent
*/
public Shell getShell() {
checkWidget();
return _getShell();
}
Shell _getShell() {
return parent._getShell();
}
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
*
* @return the receiver's tool tip text
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public String getToolTipText () {
checkWidget();
return toolTipText;
}
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, this method
* may still indicate that it is considered visible even though
* it may not actually be showing.
* </p>
*
* @return the receiver's visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean getVisible () {
checkWidget();
return (state & HIDDEN) == 0;
}
int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
Shell shell = _getShell ();
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
if (gdkEvent.type == OS.GDK_3BUTTON_PRESS) return 0;
display.dragStartX = (int) gdkEvent.x;
display.dragStartY = (int) gdkEvent.y;
display.dragging = false;
int button = gdkEvent.button;
int type = gdkEvent.type != OS.GDK_2BUTTON_PRESS ? SWT.MouseDown : SWT.MouseDoubleClick;
sendMouseEvent (type, button, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, event);
int result = 0;
if ((state & MENU) != 0) {
if (gdkEvent.button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
if (showMenu ((int)gdkEvent.x_root, (int)gdkEvent.y_root)) {
result = 1;
}
}
}
/*
* It is possible that the shell may be
* disposed at this point. If this happens
* don't send the activate and deactivate
* events.
*/
if (!shell.isDisposed ()) {
shell.setActiveControl (this);
}
return result;
}
int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
GdkEventButton gdkEvent = new GdkEventButton ();
OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
/*
* Feature in GTK. When button 4, 5, 6, or 7 is released, GTK
* does not deliver a corresponding GTK event. Button 6 and 7
* are mapped to buttons 4 and 5 in SWT. The fix is to change
* the button number of the event to a negative number so that
* it gets dispatched by GTK. SWT has been modified to look
* for negative button numbers.
*/
int button = gdkEvent.button;
if (button == -6) button = 4;
if (button == -7) button = 5;
sendMouseEvent (SWT.MouseUp, button, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, event);
return 0;
}
int /*long*/ gtk_commit (int /*long*/ imcontext, int /*long*/ text) {
if (text == 0) return 0;
int length = OS.strlen (text);
if (length == 0) return 0;
byte [] buffer = new byte [length];
OS.memmove (buffer, text, length);
char [] chars = Converter.mbcsToWcs (null, buffer);
sendIMKeyEvent (SWT.KeyDown, null, chars);
return 0;
}
int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
GdkEventCrossing gdkEvent = new GdkEventCrossing ();
OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof);
if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL) return 0;
if (gdkEvent.subwindow != 0) return 0;
sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, event);
return 0;
}
int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
GdkEvent event = new GdkEvent ();
OS.memmove (event, gdkEvent, GdkEvent.sizeof);
switch (event.type) {
case OS.GDK_BUTTON_PRESS: {
if (widget != eventHandle ()) break;
if ((state & MENU) == 0) {
GdkEventButton gdkEventButton = new GdkEventButton ();
OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
if (gdkEventButton.button == 3) {
showMenu ((int) gdkEventButton.x_root, (int) gdkEventButton.y_root);
}
}
break;
}
case OS.GDK_FOCUS_CHANGE: {
if (widget != focusHandle ()) break;
GdkEventFocus gdkEventFocus = new GdkEventFocus ();
OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
sendFocusEvent (gdkEventFocus.in != 0 ? SWT.FocusIn : SWT.FocusOut);
break;
}
}
return 0;
}
int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
if ((state & OBSCURED) != 0) return 0;
if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
GdkEventExpose gdkEvent = new GdkEventExpose ();
OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
Event event = new Event ();
event.count = gdkEvent.count;
event.x = gdkEvent.area_x;
event.y = gdkEvent.area_y;
event.width = gdkEvent.area_width;
event.height = gdkEvent.area_height;
GCData data = new GCData ();
data.damageRgn = gdkEvent.region;
GC gc = event.gc = GC.gtk_new (this, data);
OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region);
sendEvent (SWT.Paint, event);
gc.dispose ();
event.gc = null;
return 0;
}
int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) {
/* Stop GTK traversal for every widget */
return 1;
}
int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
// widget could be disposed at this point
if (handle != 0) {
Control oldControl = display.imControl;
if (oldControl != this) {
if (oldControl != null && !oldControl.isDisposed ()) {
int /*long*/ oldIMHandle = oldControl.imHandle ();
if (oldIMHandle != 0) OS.gtk_im_context_reset (oldIMHandle);
}
}
if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) OS.gtk_im_context_focus_in (imHandle);
}
}
return 0;
}
int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
// widget could be disposed at this point
if (handle != 0) {
if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
OS.gtk_im_context_focus_out (imHandle);
}
}
}
return 0;
}
int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
if (!hasFocus ()) return 0;
GdkEventKey gdkEvent = new GdkEventKey ();
OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1;
// widget could be disposed at this point
if (isDisposed ()) return 0;
if (filterKey (gdkEvent.keyval, event)) return 1;
// widget could be disposed at this point
if (isDisposed ()) return 0;
if (translateTraversal (gdkEvent)) return 1;
// widget could be disposed at this point
if (isDisposed ()) return 0;
return super.gtk_key_press_event (widget, event);
}
int /*long*/ gtk_key_release_event (int /*long*/ widget, int /*long*/ event) {
if (!hasFocus ()) return 0;
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
if (OS.gtk_im_context_filter_keypress (imHandle, event)) return 1;
}
return super.gtk_key_release_event (widget, event);
}
int /*long*/ gtk_leave_notify_event (int /*long*/ widget, int /*long*/ event) {
display.removeMouseHoverTimeout (handle);
GdkEventCrossing gdkEvent = new GdkEventCrossing ();
OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof);
if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL) return 0;
if (gdkEvent.subwindow != 0) return 0;
sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, event);
return 0;
}
int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
int result = 0;
int /*long*/ eventPtr = OS.gtk_get_current_event ();
if (eventPtr != 0) {
GdkEventKey keyEvent = new GdkEventKey ();
OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
if (keyEvent.type == OS.GDK_KEY_PRESS) {
Control focusControl = display.getFocusControl ();
int /*long*/ focusHandle = focusControl != null ? focusControl.focusHandle () : 0;
if (focusHandle != 0) {
display.mnemonicControl = this;
OS.gtk_widget_event (focusHandle, eventPtr);
display.mnemonicControl = null;
}
result = 1;
}
OS.gdk_event_free (eventPtr);
}
return result;
}
int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
GdkEventMotion gdkEvent = new GdkEventMotion ();
OS.memmove (gdkEvent, event, GdkEventMotion.sizeof);
if (hooks (SWT.DragDetect)) {
if (!display.dragging) {
if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) != 0) {
if (OS.gtk_drag_check_threshold (handle, display.dragStartX, display.dragStartY, (int) gdkEvent.x, (int) gdkEvent.y)) {
display.dragging = true;
Event e = new Event ();
e.x = display.dragStartX;
e.y = display.dragStartY;
postEvent (SWT.DragDetect, e);
}
}
}
}
if (hooks (SWT.MouseHover) || filters (SWT.MouseHover)) {
display.addMouseHoverTimeout (handle);
}
double x_root = gdkEvent.x_root, y_root = gdkEvent.y_root;
if (gdkEvent.is_hint != 0) {
int [] pointer_x = new int [1], pointer_y = new int [1];
OS.gdk_window_get_pointer (0, pointer_x, pointer_y, null);
x_root = pointer_x [0];
y_root = pointer_y [0];
}
sendMouseEvent (SWT.MouseMove, 0, gdkEvent.time, x_root, y_root, gdkEvent.state, event);
return 0;
}
int /*long*/ gtk_popup_menu (int /*long*/ widget) {
if (!hasFocus()) return 0;
int [] x = new int [1], y = new int [1];
OS.gdk_window_get_pointer (0, x, y, null);
showMenu (x [0], y [0]);
return 0;
}
int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) {
display.showIMWindow (this);
return 0;
}
int /*long*/ gtk_realize (int /*long*/ widget) {
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
OS.gtk_im_context_set_client_window (imHandle, window);
}
return 0;
}
int /*long*/ gtk_scroll_event (int /*long*/ widget, int /*long*/ eventPtr) {
GdkEventScroll gdkEvent = new GdkEventScroll ();
OS.memmove (gdkEvent, eventPtr, GdkEventScroll.sizeof);
switch (gdkEvent.direction) {
case OS.GDK_SCROLL_UP:
if (!sendMouseEvent (SWT.MouseWheel, 0, 3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, eventPtr)) {
return 1;
}
break;
case OS.GDK_SCROLL_DOWN:
if (!sendMouseEvent (SWT.MouseWheel, 0, -3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, eventPtr)) {
return 1;
}
break;
case OS.GDK_SCROLL_LEFT:
sendMouseEvent (SWT.MouseDown, 4, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, eventPtr);
break;
case OS.GDK_SCROLL_RIGHT:
sendMouseEvent (SWT.MouseDown, 5, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, gdkEvent.state, eventPtr);
break;
}
return 0;
}
int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) {
if (!hasFocus ()) return 0;
return sendHelpEvent (helpType) ? 1 : 0;
}
int /*long*/ gtk_unrealize (int /*long*/ widget) {
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) OS.gtk_im_context_set_client_window (imHandle, 0);
return 0;
}
int /*long*/ gtk_visibility_notify_event (int /*long*/ widget, int /*long*/ event) {
GdkEventVisibility gdkEvent = new GdkEventVisibility ();
OS.memmove (gdkEvent, event, GdkEventVisibility.sizeof);
if (gdkEvent.state == OS.GDK_VISIBILITY_FULLY_OBSCURED) {
state |= OBSCURED;
} else {
if ((state & OBSCURED) != 0) {
int /*long*/ window = gdkEvent.window;
int [] width = new int [1], height = new int [1];
OS.gdk_drawable_get_size (window, width, height);
GdkRectangle rect = new GdkRectangle ();
rect.width = width [0];
rect.height = height [0];
OS.gdk_window_invalidate_rect (window, rect, true);
}
state &= ~OBSCURED;
}
return 0;
}
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Control</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param data the platform specific GC data
* @return the platform specific GC handle
*/
public int /*long*/ internal_new_GC (GCData data) {
checkWidget ();
int /*long*/ window = paintWindow ();
if (window == 0) SWT.error (SWT.ERROR_NO_HANDLES);
int /*long*/ gdkGC = OS.gdk_gc_new (window);
if (gdkGC == 0) error (SWT.ERROR_NO_HANDLES);
if (data != null) {
int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
if ((data.style & mask) == 0) {
data.style |= style & (mask | SWT.MIRRORED);
}
data.drawable = window;
data.device = display;
data.background = getBackgroundColor ();
data.foreground = getForegroundColor ();
data.font = font != null ? font.handle : defaultFont ();
}
return gdkGC;
}
int /*long*/ imHandle () {
return 0;
}
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public
* API for <code>Control</code>. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
* </p>
*
* @param hDC the platform specific GC handle
* @param data the platform specific GC data
*/
public void internal_dispose_GC (int /*long*/ gdkGC, GCData data) {
checkWidget ();
OS.g_object_unref (gdkGC);
}
/**
* Returns <code>true</code> if the underlying operating
* system supports this reparenting, otherwise <code>false</code>
*
* @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean isReparentable () {
checkWidget();
return true;
}
boolean isShowing () {
/*
* This is not complete. Need to check if the
* widget is obscurred by a parent or sibling.
*/
if (!isVisible ()) return false;
Control control = this;
while (control != null) {
Point size = control.getSize ();
if (size.x == 0 || size.y == 0) {
return false;
}
control = control.parent;
}
return true;
}
boolean isTabGroup () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
for (int i=0; i<tabList.length; i++) {
if (tabList [i] == this) return true;
}
}
int code = traversalCode (0, null);
if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
}
boolean isTabItem () {
Control [] tabList = parent._getTabList ();
if (tabList != null) {
for (int i=0; i<tabList.length; i++) {
if (tabList [i] == this) return false;
}
}
int code = traversalCode (0, null);
return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
}
/**
* Returns <code>true</code> if the receiver is enabled and all
* of the receiver's ancestors are enabled, and <code>false</code>
* otherwise. A disabled control is typically not selectable from the
* user interface and draws with an inactive or "grayed" look.
*
* @return the receiver's enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getEnabled
*/
public boolean isEnabled () {
checkWidget ();
return getEnabled () && parent.isEnabled ();
}
boolean isFocusAncestor (Control control) {
while (control != null && control != this) {
control = control.parent;
}
return control == this;
}
/**
* Returns <code>true</code> if the receiver has the user-interface
* focus, and <code>false</code> otherwise.
*
* @return the receiver's focus state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean isFocusControl () {
checkWidget();
return hasFocus ();
}
/**
* Returns <code>true</code> if the receiver is visible and all
* of the receiver's ancestors are visible and <code>false</code>
* otherwise.
*
* @return the receiver's visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #getVisible
*/
public boolean isVisible () {
checkWidget();
return getVisible () && parent.isVisible ();
}
Decorations menuShell () {
return parent.menuShell ();
}
boolean mnemonicHit (char key) {
return false;
}
boolean mnemonicMatch (char key) {
return false;
}
void register () {
super.register ();
if (fixedHandle != 0) display.addWidget (fixedHandle, this);
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) display.addWidget (imHandle, this);
}
/**
* Causes the entire bounds of the receiver to be marked
* as needing to be redrawn. The next time a paint request
* is processed, the control will be completely painted,
* including the background.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #update
* @see PaintListener
* @see SWT#Paint
* @see SWT#NO_BACKGROUND
* @see SWT#NO_REDRAW_RESIZE
* @see SWT#NO_MERGE_PAINTS
*/
public void redraw () {
checkWidget();
if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return;
forceResize ();
int /*long*/ paintHandle = paintHandle ();
int width = OS.GTK_WIDGET_WIDTH (paintHandle);
int height = OS.GTK_WIDGET_HEIGHT (paintHandle);
redrawWidget (0, 0, width, height, false);
}
/**
* Causes the rectangular area of the receiver specified by
* the arguments to be marked as needing to be redrawn.
* The next time a paint request is processed, that area of
* the receiver will be painted, including the background.
* If the <code>all</code> flag is <code>true</code>, any
* children of the receiver which intersect with the specified
* area will also paint their intersecting areas. If the
* <code>all</code> flag is <code>false</code>, the children
* will not be painted.
*
* @param x the x coordinate of the area to draw
* @param y the y coordinate of the area to draw
* @param width the width of the area to draw
* @param height the height of the area to draw
* @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #update
* @see PaintListener
* @see SWT#Paint
* @see SWT#NO_BACKGROUND
* @see SWT#NO_REDRAW_RESIZE
* @see SWT#NO_MERGE_PAINTS
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return;
redrawWidget (x, y, width, height, all);
}
void redrawWidget (int x, int y, int width, int height, boolean all) {
if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
int /*long*/ window = paintWindow ();
GdkRectangle rect = new GdkRectangle ();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
OS.gdk_window_invalidate_rect (window, rect, all);
}
void releaseChild () {
parent.removeControl (this);
}
void releaseHandle () {
super.releaseHandle ();
fixedHandle = 0;
}
void releaseWidget () {
display.removeMouseHoverTimeout (handle);
super.releaseWidget ();
int /*long*/ imHandle = imHandle ();
if (imHandle != 0) {
OS.gtk_im_context_reset (imHandle);
OS.gtk_im_context_set_client_window (imHandle, 0);
}
if (enableWindow != 0) {
OS.gdk_window_set_user_data (enableWindow, 0);
OS.gdk_window_destroy (enableWindow);
enableWindow = 0;
}
redrawWindow = 0;
if (menu != null && !menu.isDisposed ()) {
menu.dispose ();
}
menu = null;
cursor = null;
toolTipText = null;
parent = null;
layoutData = null;
accessible = null;
}
void sendFocusEvent (int type) {
Shell shell = _getShell ();
Display display = this.display;
display.focusControl = this;
display.focusEvent = type;
sendEvent (type);
display.focusControl = null;
display.focusEvent = SWT.None;
/*
* It is possible that the shell may be
* disposed at this point. If this happens
* don't send the activate and deactivate
* events.
*/
if (!shell.isDisposed ()) {
switch (type) {
case SWT.FocusIn:
shell.setActiveControl (this);
break;
case SWT.FocusOut:
if (shell != display.getActiveShell ()) {
shell.setActiveControl (null);
}
break;
}
}
}
boolean sendHelpEvent (int /*long*/ helpType) {
Control control = this;
while (control != null) {
if (control.hooks (SWT.Help)) {
control.postEvent (SWT.Help);
return true;
}
control = control.parent;
}
return false;
}
boolean sendMouseEvent (int type, int button, int time, double x_root, double y_root, int state, int /*long*/ eventPtr) {
return sendMouseEvent (type, button, 0, 0, false, time, x_root, y_root, state, eventPtr);
}
boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, int time, double x_root, double y_root, int state, int /*long*/ eventPtr) {
if(!hooks (type) && !filters (type)) return true;
Event event = new Event ();
event.time = time;
event.button = button;
event.detail = detail;
event.count = count;
int /*long*/ window = OS.GTK_WIDGET_WINDOW (eventHandle ());
int [] origin_x = new int [1], origin_y = new int [1];
OS.gdk_window_get_origin (window, origin_x, origin_y);
event.x = (int)x_root - origin_x [0];
event.y = (int)y_root - origin_y [0];
setInputState (event, state);
if (send) {
sendEvent (type, event);
if (isDisposed()) return false;
} else {
postEvent (type, event);
}
return event.doit;
}
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the control
* if the argument is null.
*
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setBackground (Color color) {
checkWidget();
GdkColor gdkColor = null;
if (color != null) {
if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
gdkColor = color.handle;
}
boolean set = false;
if (gdkColor == null) {
int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) != 0;
} else {
GdkColor oldColor = getBackgroundColor ();
set = oldColor.pixel != gdkColor.pixel;
}
if (set) setBackgroundColor (gdkColor);
}
void setBackgroundColor (int /*long*/ handle, GdkColor color) {
int index = OS.GTK_STATE_NORMAL;
int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
int /*long*/ ptr = OS.gtk_rc_style_get_bg_pixmap_name (style, index);
if (ptr != 0) OS.g_free (ptr);
String name = color == null ? "<parent>" : "<none>";
byte[] buffer = Converter.wcsToMbcs (null, name, true);
ptr = OS.g_malloc (buffer.length);
OS.memmove (ptr, buffer, buffer.length);
OS.gtk_rc_style_set_bg_pixmap_name (style, index, ptr);
OS.gtk_rc_style_set_bg (style, index, color);
int flags = OS.gtk_rc_style_get_color_flags (style, index);
flags = (color == null) ? flags & ~OS.GTK_RC_BG : flags | OS.GTK_RC_BG;
OS.gtk_rc_style_set_color_flags (style, index, flags);
OS.gtk_widget_modify_style (handle, style);
}
void setBackgroundColor (GdkColor color) {
setBackgroundColor(handle, color);
}
/**
* If the argument is <code>true</code>, causes the receiver to have
* all mouse events delivered to it until the method is called with
* <code>false</code> as the argument.
*
* @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setCapture (boolean capture) {
checkWidget();
/* FIXME !!!!! */
/*
if (capture) {
OS.gtk_widget_grab_focus (handle);
} else {
OS.gtk_widget_grab_default (handle);
}
*/
}
/**
* Sets the receiver's cursor to the cursor specified by the
* argument, or to the default cursor for that kind of control
* if the argument is null.
* <p>
* When the mouse pointer passes over a control its appearance
* is changed to match the control's cursor.
* </p>
*
* @param cursor the new cursor (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setCursor (Cursor cursor) {
checkWidget();
if (cursor != null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
this.cursor = cursor;
setCursor (cursor != null ? cursor.handle : 0);
}
void setCursor (int /*long*/ cursor) {
int /*long*/ window = paintWindow ();
if (window != 0) {
OS.gdk_window_set_cursor (window, cursor);
OS.gdk_flush ();
}
}
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
* not selectable from the user interface and draws with an
* inactive or "grayed" look.
*
* @param enabled the new enabled state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setEnabled (boolean enabled) {
checkWidget();
if (((state & DISABLED) == 0) == enabled) return;
Control control = null;
boolean fixFocus = false;
if (!enabled) {
if (display.focusEvent != SWT.FocusOut) {
control = display.getFocusControl ();
fixFocus = isFocusAncestor (control);
}
}
if (enabled) {
state &= ~DISABLED;
} else {
state |= DISABLED;
}
enableWidget (enabled);
if (enabled) {
if (enableWindow != 0) {
OS.gdk_window_set_user_data (enableWindow, 0);
OS.gdk_window_destroy (enableWindow);
enableWindow = 0;
}
} else {
OS.gtk_widget_realize (handle);
int /*long*/ parentHandle = parent.parentingHandle ();
int /*long*/ window = OS.GTK_WIDGET_WINDOW (parentHandle);
Rectangle rect = getBounds ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.x = rect.x;
attributes.y = rect.y;
attributes.width = rect.width;
attributes.height = rect.height;
attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask);
attributes.wclass = OS.GDK_INPUT_ONLY;
attributes.window_type = OS.GDK_WINDOW_CHILD;
enableWindow = OS.gdk_window_new (window, attributes, OS.GDK_WA_X | OS.GDK_WA_Y);
if (enableWindow != 0) {
int /*long*/ topHandle = topHandle ();
OS.gdk_window_set_user_data (enableWindow, parentHandle);
if (!OS.GDK_WINDOWING_X11 ()) {
OS.gdk_window_raise (enableWindow);
} else {
int /*long*/ topWindow = OS.GTK_WIDGET_WINDOW (topHandle);
int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (topWindow);
int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid (enableWindow);
int xScreen = OS.XDefaultScreen (xDisplay);
int flags = OS.CWStackMode | OS.CWSibling;
XWindowChanges changes = new XWindowChanges ();
changes.sibling = OS.gdk_x11_drawable_get_xid (topWindow);
changes.stack_mode = OS.Above;
OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);
}
if (OS.GTK_WIDGET_VISIBLE (topHandle)) OS.gdk_window_show_unraised (enableWindow);
}
}
if (fixFocus) fixFocus (control);
}
/**
* Causes the receiver to have the <em>keyboard focus</em>,
* such that all keyboard events will be delivered to it. Focus
* reassignment will respect applicable platform constraints.
*
* @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #forceFocus
*/
public boolean setFocus () {
checkWidget();
if ((style & SWT.NO_FOCUS) != 0) return false;
return forceFocus ();
}
/**
* Sets the font that the receiver will use to paint textual information
* to the font specified by the argument, or to the default font for that
* kind of control if the argument is null.
*
* @param font the new font (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setFont (Font font) {
checkWidget();
this.font = font;
int /*long*/ fontDesc;
if (font == null) {
fontDesc = defaultFont ();
} else {
if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
fontDesc = font.handle;
}
setFontDescription (fontDesc);
}
void setFontDescription (int /*long*/ font) {
OS.gtk_widget_modify_font (handle, font);
}
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the control
* if the argument is null.
*
* @param color the new color (or null)
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setForeground (Color color) {
checkWidget();
GdkColor gdkColor = null;
if (color != null) {
if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
gdkColor = color.handle;
}
boolean set = false;
if (gdkColor == null) {
int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) != 0;
} else {
GdkColor oldColor = getForegroundColor ();
set = oldColor.pixel != gdkColor.pixel;
}
if (set) setForegroundColor (gdkColor);
}
void setForegroundColor (GdkColor color) {
OS.gtk_widget_modify_fg (handle, OS.GTK_STATE_NORMAL, color);
}
void setInitialBounds () {
if ((state & ZERO_SIZED) != 0) {
/*
* Feature in GTK. On creation, each widget's allocation is
* initialized to a position of (-1, -1) until the widget is
* first sized. The fix is to set the value to (0, 0) as
* expected by SWT.
*/
int /*long*/ topHandle = topHandle ();
OS.GTK_WIDGET_SET_X (topHandle, 0);
OS.GTK_WIDGET_SET_Y (topHandle, 0);
} else {
resizeHandle (1, 1);
forceResize ();
}
}
/**
* Sets the receiver's pop up menu to the argument.
* All controls may optionally have a pop up
* menu that is displayed when the user requests one for
* the control. The sequence of key strokes, button presses
* and/or button releases that are used to request a pop up
* menu is platform specific.
*
* @param menu the new pop up menu
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
* <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
* <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setMenu (Menu menu) {
checkWidget();
if (menu != null) {
if ((menu.style & SWT.POP_UP) == 0) {
error (SWT.ERROR_MENU_NOT_POP_UP);
}
if (menu.parent != menuShell ()) {
error (SWT.ERROR_INVALID_PARENT);
}
}
this.menu = menu;
}
/**
* Changes the parent of the widget to be the one provided if
* the underlying operating system supports this feature.
* Answers <code>true</code> if the parent is successfully changed.
*
* @param parent the new parent for the control.
* @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
* </ul>
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean setParent (Composite parent) {
checkWidget ();
if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
if (parent.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
if (this.parent == parent) return true;
if (!isReparentable ()) return false;
releaseChild ();
Shell newShell = parent.getShell (), oldShell = getShell ();
Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
Menu [] menus = oldShell.findMenus (this);
if (oldShell != newShell || oldDecorations != newDecorations) {
fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
newDecorations.fixAccelGroup ();
oldDecorations.fixAccelGroup ();
}
int /*long*/ topHandle = topHandle ();
int /*long*/ newParent = parent.parentingHandle();
int x = OS.GTK_WIDGET_X (topHandle);
int y = OS.GTK_WIDGET_Y (topHandle);
OS.gtk_widget_reparent (topHandle, newParent);
OS.gtk_fixed_move (newParent, topHandle, x, y);
this.parent = parent;
setZOrder (null, false);
return true;
}
boolean setRadioSelection (boolean value) {
return false;
}
/**
* If the argument is <code>false</code>, causes subsequent drawing
* operations in the receiver to be ignored. No drawing of any kind
* can occur in the receiver until the flag is set to true.
* Graphics operations that occurred while the flag was
* <code>false</code> are lost. When the flag is set to <code>true</code>,
* the entire widget is marked as needing to be redrawn.
* <p>
* Note: This operation is a hint and may not be supported on some
* platforms or for some widgets.
* </p>
*
* @param redraw the new redraw state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #redraw
* @see #update
*/
public void setRedraw (boolean redraw) {
checkWidget();
if (redraw) {
if (--drawCount == 0) {
if (redrawWindow != 0) {
int /*long*/ window = paintWindow ();
OS.gdk_window_destroy (redrawWindow);
OS.gdk_window_set_events (window, OS.gtk_widget_get_events (paintHandle ()));
redrawWindow = 0;
}
}
} else {
if (drawCount++ == 0) {
if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) != 0) {
int /*long*/ window = paintWindow ();
Rectangle rect = getBounds ();
GdkWindowAttr attributes = new GdkWindowAttr ();
attributes.width = rect.width;
attributes.height = rect.height;
attributes.event_mask = OS.GDK_EXPOSURE_MASK;
attributes.window_type = OS.GDK_WINDOW_CHILD;
redrawWindow = OS.gdk_window_new (window, attributes, 0);
if (redrawWindow != 0) {
int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK |
OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK |
OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK;
OS.gdk_window_set_events (window, OS.gdk_window_get_events (window) & ~mouseMask);
OS.gdk_window_set_back_pixmap (redrawWindow, 0, false);
OS.gdk_window_show (redrawWindow);
}
}
}
}
}
boolean setTabGroupFocus (boolean next) {
return setTabItemFocus (next);
}
boolean setTabItemFocus (boolean next) {
if (!isShowing ()) return false;
return forceFocus ();
}
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
*
* @param string the new tool tip text (or null)
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setToolTipText (String string) {
checkWidget();
Shell shell = _getShell ();
shell.setToolTipText (eventHandle (), toolTipText = string);
}
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
* <p>
* If one of the receiver's ancestors is not visible or some
* other condition makes the receiver not visible, marking
* it visible may not actually cause it to be displayed.
* </p>
*
* @param visible the new visibility state
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setVisible (boolean visible) {
checkWidget();
if (((state & HIDDEN) == 0) == visible) return;
int /*long*/ topHandle = topHandle();
if (visible) {
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in the show
* event. If this happens, just return.
*/
sendEvent (SWT.Show);
if (isDisposed ()) return;
state &= ~HIDDEN;
if ((state & ZERO_SIZED) == 0) {
if (enableWindow != 0) OS.gdk_window_show_unraised (enableWindow);
OS.gtk_widget_show (topHandle);
}
} else {
/*
* Bug in GTK. Invoking gtk_widget_hide() on a widget that has
* focus causes a focus_out_event to be sent. If the client disposes
* the widget inside the event, GTK GP's. The fix is to reassign focus
* before hiding the widget.
*
* NOTE: In order to stop the same widget from taking focus,
* temporarily clear and set the GTK_VISIBLE flag.
*/
Control control = null;
boolean fixFocus = false;
if (display.focusEvent != SWT.FocusOut) {
control = display.getFocusControl ();
fixFocus = isFocusAncestor (control);
}
if (fixFocus) {
OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE);
fixFocus (control);
if (isDisposed ()) return;
OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE);
}
state |= HIDDEN;
OS.gtk_widget_hide (topHandle);
if (enableWindow != 0) OS.gdk_window_hide (enableWindow);
sendEvent (SWT.Hide);
}
}
void setZOrder (Control sibling, boolean above) {
setZOrder (sibling, above, true);
}
void setZOrder (Control sibling, boolean above, boolean fixChildren) {
int /*long*/ topHandle = topHandle ();
int /*long*/ siblingHandle = sibling != null ? sibling.topHandle () : 0;
int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
if (window != 0) {
int /*long*/ siblingWindow = 0;
if (sibling != null) {
if (above && sibling.enableWindow != 0) {
siblingWindow = enableWindow;
} else {
siblingWindow = OS.GTK_WIDGET_WINDOW (siblingHandle);
}
}
int /*long*/ redrawWindow = fixChildren ? parent.redrawWindow : 0;
if (!OS.GDK_WINDOWING_X11 () || (siblingWindow == 0 && redrawWindow == 0)) {
if (above) {
OS.gdk_window_raise (window);
if (redrawWindow != 0) OS.gdk_window_raise (redrawWindow);
if (enableWindow != 0) OS.gdk_window_raise (enableWindow);
} else {
if (enableWindow != 0) OS.gdk_window_lower (enableWindow);
OS.gdk_window_lower (window);
}
} else {
XWindowChanges changes = new XWindowChanges ();
changes.sibling = OS.gdk_x11_drawable_get_xid (siblingWindow != 0 ? siblingWindow : redrawWindow);
changes.stack_mode = above ? OS.Above : OS.Below;
if (redrawWindow != 0 && siblingWindow == 0) changes.stack_mode = OS.Below;
int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid (window);
int xScreen = OS.XDefaultScreen (xDisplay);
int flags = OS.CWStackMode | OS.CWSibling;
/*
* Feature in X. If the receiver is a top level, XConfigureWindow ()
* will fail (with a BadMatch error) for top level shells because top
* level shells are reparented by the window manager and do not share
* the same X window parent. This is the correct behavior but it is
* unexpected. The fix is to use XReconfigureWMWindow () instead.
* When the receiver is not a top level shell, XReconfigureWMWindow ()
* behaves the same as XConfigureWindow ().
*/
OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);
if (enableWindow != 0) {
changes.sibling = OS.gdk_x11_drawable_get_xid (window);
changes.stack_mode = OS.Above;
xWindow = OS.gdk_x11_drawable_get_xid (enableWindow);
OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);
}
}
}
if (fixChildren) {
if (above) {
parent.moveAbove (topHandle, siblingHandle);
} else {
parent.moveBelow (topHandle, siblingHandle);
}
}
/* Make sure that the parent internal windows are on the bottom of the stack */
if (!above && fixChildren) parent.fixZOrder ();
}
boolean showMenu (int x, int y) {
Event event = new Event ();
event.x = x;
event.y = y;
sendEvent (SWT.MenuDetect, event);
if (event.doit) {
if (menu != null && !menu.isDisposed ()) {
menu.createIMMenu (imHandle());
if (event.x != x || event.y != y) {
menu.setLocation (event.x, event.y);
}
menu.setVisible (true);
return true;
}
}
return false;
}
void showWidget () {
// Comment this line to disable zero-sized widgets
state |= ZERO_SIZED;
int /*long*/ topHandle = topHandle ();
int /*long*/ parentHandle = parent.parentingHandle ();
OS.gtk_container_add (parentHandle, topHandle);
if (handle != 0 && handle != topHandle) OS.gtk_widget_show (handle);
if ((state & ZERO_SIZED) == 0) {
if (fixedHandle != 0) OS.gtk_widget_show (fixedHandle);
}
}
void sort (int [] items) {
/* Shell Sort from K&R, pg 108 */
int length = items.length;
for (int gap=length/2; gap>0; gap/=2) {
for (int i=gap; i<length; i++) {
for (int j=i-gap; j>=0; j-=gap) {
if (items [j] <= items [j + gap]) {
int swap = items [j];
items [j] = items [j + gap];
items [j + gap] = swap;
}
}
}
}
}
/**
* Based on the argument, perform one of the expected platform
* traversal action. The argument should be one of the constants:
* <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>,
* <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>,
* <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
*
* @param traversal the type of traversal
* @return true if the traversal succeeded
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public boolean traverse (int traversal) {
checkWidget ();
Event event = new Event ();
event.doit = true;
event.detail = traversal;
return traverse (event);
}
boolean translateMnemonic (Event event, Control control) {
if (control == this) return false;
if (!isVisible () || !isEnabled ()) return false;
event.doit = this == display.mnemonicControl || mnemonicMatch (event.character);
return traverse (event);
}
boolean translateMnemonic (int keyval, GdkEventKey gdkEvent) {
int key = OS.gdk_keyval_to_unicode (keyval);
if (key < 0x20) return false;
if (gdkEvent.state == 0) {
int code = traversalCode (keyval, gdkEvent);
if ((code & SWT.TRAVERSE_MNEMONIC) == 0) return false;
} else {
Shell shell = _getShell ();
int mask = OS.GDK_CONTROL_MASK | OS.GDK_SHIFT_MASK | OS.GDK_MOD1_MASK;
if ((gdkEvent.state & mask) != OS.gtk_window_get_mnemonic_modifier (shell.shellHandle)) return false;
}
Decorations shell = menuShell ();
if (shell.isVisible () && shell.isEnabled ()) {
Event event = new Event ();
event.detail = SWT.TRAVERSE_MNEMONIC;
if (setKeyState (event, gdkEvent)) {
return translateMnemonic (event, null) || shell.translateMnemonic (event, this);
}
}
return false;
}
boolean translateTraversal (GdkEventKey keyEvent) {
int detail = SWT.TRAVERSE_NONE;
int key = keyEvent.keyval;
int code = traversalCode (key, keyEvent);
boolean all = false;
switch (key) {
case OS.GDK_Escape: {
all = true;
detail = SWT.TRAVERSE_ESCAPE;
break;
}
case OS.GDK_KP_Enter:
case OS.GDK_Return: {
all = true;
detail = SWT.TRAVERSE_RETURN;
break;
}
case OS.GDK_ISO_Left_Tab:
case OS.GDK_Tab: {
boolean next = (keyEvent.state & OS.GDK_SHIFT_MASK) == 0;
detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
break;
}
case OS.GDK_Up:
case OS.GDK_Left:
case OS.GDK_Down:
case OS.GDK_Right: {
boolean next = key == OS.GDK_Down || key == OS.GDK_Right;
detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
break;
}
case OS.GDK_Page_Up:
case OS.GDK_Page_Down: {
all = true;
if ((keyEvent.state & OS.GDK_CONTROL_MASK) == 0) return false;
detail = key == OS.GDK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
break;
}
default:
return false;
}
Event event = new Event ();
event.doit = (code & detail) != 0;
event.detail = detail;
event.time = keyEvent.time;
if (!setKeyState (event, keyEvent)) return false;
Shell shell = getShell ();
Control control = this;
do {
if (control.traverse (event)) return true;
if (!event.doit && control.hooks (SWT.Traverse)) return false;
if (control == shell) return false;
control = control.parent;
} while (all && control != null);
return false;
}
int traversalCode (int key, GdkEventKey event) {
int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS;
Shell shell = getShell ();
if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
return code;
}
boolean traverse (Event event) {
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in the traverse
* event. If this happens, return true to stop further
* event processing.
*/
sendEvent (SWT.Traverse, event);
if (isDisposed ()) return true;
if (!event.doit) return false;
switch (event.detail) {
case SWT.TRAVERSE_NONE: return true;
case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
case SWT.TRAVERSE_RETURN: return traverseReturn ();
case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
}
return false;
}
boolean traverseEscape () {
return false;
}
boolean traverseGroup (boolean next) {
Control root = computeTabRoot ();
Control group = computeTabGroup ();
Control [] list = root.computeTabList ();
int length = list.length;
int index = 0;
while (index < length) {
if (list [index] == group) break;
index++;
}
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in focus in
* or out events. Ensure that a disposed widget is
* not accessed.
*/
if (index == length) return false;
int start = index, offset = (next) ? 1 : -1;
while ((index = ((index + offset + length) % length)) != start) {
Control control = list [index];
if (!control.isDisposed () && control.setTabGroupFocus (next)) {
return true;
}
}
if (group.isDisposed ()) return false;
return group.setTabGroupFocus (next);
}
boolean traverseItem (boolean next) {
Control [] children = parent._getChildren ();
int length = children.length;
int index = 0;
while (index < length) {
if (children [index] == this) break;
index++;
}
/*
* It is possible (but unlikely), that application
* code could have disposed the widget in focus in
* or out events. Ensure that a disposed widget is
* not accessed.
*/
if (index == length) return false;
int start = index, offset = (next) ? 1 : -1;
while ((index = (index + offset + length) % length) != start) {
Control child = children [index];
if (!child.isDisposed () && child.isTabItem ()) {
if (child.setTabItemFocus (next)) return true;
}
}
return false;
}
boolean traverseReturn () {
return false;
}
boolean traversePage (boolean next) {
return false;
}
boolean traverseMnemonic (char key) {
return mnemonicHit (key);
}
/**
* Forces all outstanding paint requests for the widget
* to be processed before this method returns.
*
* @exception SWTException <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*
* @see #redraw
* @see PaintListener
* @see SWT#Paint
*/
public void update () {
checkWidget ();
update (false);
}
void update (boolean all) {
// checkWidget();
if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return;
if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
int /*long*/ window = paintWindow ();
display.flushExposes (window, all);
OS.gdk_window_process_updates (window, all);
}
void updateLayout (boolean all) {
/* Do nothing */
}
}
| [
"[email protected]"
]
| |
78afa153d25a38e722f9c41d5de17a7aba1c5cc6 | 13b1addea37fce0c7f37672958b3b6c8f8edcc78 | /src/main/java/me/yong_ju/hello_dagger/LoginCommandModule.java | 73c870f8dc2000555b530ec633bbc91606aedbe8 | []
| no_license | sei40kr/hello-dagger | 058e5275a1ed789be880e7a6ead313fd05c2b271 | 24f0cfe82a86d7cce5d9d00f08ce08ab7893a743 | refs/heads/master | 2022-12-27T01:31:53.709226 | 2020-05-17T03:32:01 | 2020-05-17T03:32:01 | 262,351,108 | 0 | 0 | null | 2020-10-13T21:52:59 | 2020-05-08T14:53:58 | Java | UTF-8 | Java | false | false | 363 | java | package me.yong_ju.hello_dagger;
import dagger.Binds;
import dagger.BindsOptionalOf;
import dagger.Module;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
@Module
interface LoginCommandModule {
@Binds
@IntoMap
@StringKey("login")
Command loginCommand(LoginCommand command);
@BindsOptionalOf
Account optionalAccount();
}
| [
"[email protected]"
]
| |
c67a23386d836ab9559f297985a581d525ac6b33 | 90cfe9debcfc7f7b862b08e79c77a6e0c07c2d98 | /app/src/main/java/com/example/recognizemlkit/model/ViewProfileModel.java | 71056f66baabcda9512ac41a58482ebbfb662a3a | []
| no_license | unisysTechHub/RecognizeMLKit | 6ceb00c565ec3c059223d1f966bac2495f5f07e9 | cbac641cf3ad4ecae3f14ee6a63e5601f5fc20e6 | refs/heads/master | 2020-07-17T20:19:02.824536 | 2019-09-03T14:02:37 | 2019-09-03T14:02:37 | 206,091,687 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,149 | java | package com.example.recognizemlkit.model;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.databinding.Observable;
import java.util.LinkedHashMap;
public class ViewProfileModel implements Parcelable {
LinkedHashMap<String, String> extractedLines;
Observable textView;
public ViewProfileModel(){}
protected ViewProfileModel(Parcel in) {
}
public static final Creator<ViewProfileModel> CREATOR = new Creator<ViewProfileModel>() {
@Override
public ViewProfileModel createFromParcel(Parcel in) {
return new ViewProfileModel(in);
}
@Override
public ViewProfileModel[] newArray(int size) {
return new ViewProfileModel[size];
}
};
public LinkedHashMap<String, String> getExtractedLines() {
return extractedLines;
}
public void setExtractedLines(LinkedHashMap<String, String> extractedLines) {
this.extractedLines = extractedLines;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
}
}
| [
"[email protected]"
]
| |
2315fed3861afe51984216e3fea4f37b7d3c676e | 882a1a28c4ec993c1752c5d3c36642fdda3d8fad | /proxies/com/microsoft/bingads/v12/campaignmanagement/TargetSettingDetail.java | 26d54a6c72439f9ded1365aedeaac62f1f574d13 | [
"MIT"
]
| permissive | BazaRoi/BingAds-Java-SDK | 640545e3595ed4e80f5a1cd69bf23520754c4697 | e30e5b73c01113d1c523304860180f24b37405c7 | refs/heads/master | 2020-07-26T08:11:14.446350 | 2019-09-10T03:25:30 | 2019-09-10T03:25:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,453 | java |
package com.microsoft.bingads.v12.campaignmanagement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for TargetSettingDetail complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="TargetSettingDetail">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="CriterionTypeGroup" type="{https://bingads.microsoft.com/CampaignManagement/v12}CriterionTypeGroup" minOccurs="0"/>
* <element name="TargetAndBid" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TargetSettingDetail", propOrder = {
"criterionTypeGroup",
"targetAndBid"
})
public class TargetSettingDetail {
@XmlElement(name = "CriterionTypeGroup")
@XmlSchemaType(name = "string")
protected CriterionTypeGroup criterionTypeGroup;
@XmlElement(name = "TargetAndBid")
protected Boolean targetAndBid;
/**
* Gets the value of the criterionTypeGroup property.
*
* @return
* possible object is
* {@link CriterionTypeGroup }
*
*/
public CriterionTypeGroup getCriterionTypeGroup() {
return criterionTypeGroup;
}
/**
* Sets the value of the criterionTypeGroup property.
*
* @param value
* allowed object is
* {@link CriterionTypeGroup }
*
*/
public void setCriterionTypeGroup(CriterionTypeGroup value) {
this.criterionTypeGroup = value;
}
/**
* Gets the value of the targetAndBid property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean getTargetAndBid() {
return targetAndBid;
}
/**
* Sets the value of the targetAndBid property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setTargetAndBid(Boolean value) {
this.targetAndBid = value;
}
}
| [
"[email protected]"
]
| |
e86efea0574519991d756317678cd7edadc67a37 | 08a98a6e540c394f565c5decc1a59f0f1d3738e2 | /Java/pruebaArticulo/build/generated/jax-wsCache/UsuariosWS/webservices/RegistrarUsuario.java | a1c1963c28cf6f7ac757b0c89ed3081978ffb876 | []
| no_license | mfmontess/ArticuloApp | e50c79e43c22c90cdb4701824f960534aad8166c | fe5f8ca4eac004572c806a068e476bfeb678ad38 | refs/heads/master | 2020-03-12T18:46:32.543035 | 2019-02-11T01:47:48 | 2019-02-11T01:47:48 | 130,769,131 | 1 | 0 | null | 2019-02-11T01:47:49 | 2018-04-23T23:38:05 | Java | UTF-8 | Java | false | false | 1,766 | java |
package webservices;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for RegistrarUsuario complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="RegistrarUsuario">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="usuario" type="{http://WebServices/}usuario" minOccurs="0"/>
* <element name="clienteID" type="{http://www.w3.org/2001/XMLSchema}int"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RegistrarUsuario", propOrder = {
"usuario",
"clienteID"
})
public class RegistrarUsuario {
protected Usuario usuario;
protected int clienteID;
/**
* Gets the value of the usuario property.
*
* @return
* possible object is
* {@link Usuario }
*
*/
public Usuario getUsuario() {
return usuario;
}
/**
* Sets the value of the usuario property.
*
* @param value
* allowed object is
* {@link Usuario }
*
*/
public void setUsuario(Usuario value) {
this.usuario = value;
}
/**
* Gets the value of the clienteID property.
*
*/
public int getClienteID() {
return clienteID;
}
/**
* Sets the value of the clienteID property.
*
*/
public void setClienteID(int value) {
this.clienteID = value;
}
}
| [
"[email protected]"
]
| |
0490ec8f4b7f682bacb72b3185742e5965c39335 | b128470fef51846468c4bd71987039505c5ac10e | /src/main/java/com/hivemq/extensions/client/parameter/TlsInformationImpl.java | 52af8b90f979987eb467a079e362aa22e3255b53 | [
"Apache-2.0"
]
| permissive | Quandt2k/hivemq-community-edition | 1efda0e6e51799621100c0c787a927af975e40cc | 9297c8ed7c89c8fb22179050f171465151e06d6d | refs/heads/master | 2022-01-28T17:10:35.701645 | 2019-08-12T10:05:56 | 2019-08-12T10:05:56 | 201,237,692 | 0 | 1 | Apache-2.0 | 2022-01-14T07:51:14 | 2019-08-08T10:44:57 | Java | UTF-8 | Java | false | false | 2,371 | java | /*
* Copyright 2019 dc-square GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hivemq.extensions.client.parameter;
import com.google.common.base.Preconditions;
import com.hivemq.annotations.NotNull;
import com.hivemq.extension.sdk.api.client.parameter.TlsInformation;
import java.security.cert.X509Certificate;
/**
* @author Florian Limpรถck
* @since 4.0.0
*/
public class TlsInformationImpl implements TlsInformation {
private final @NotNull X509Certificate certificate;
private final @NotNull X509Certificate[] certificateChain;
private final @NotNull String cipherSuite;
private final @NotNull String protocol;
public TlsInformationImpl(final @NotNull X509Certificate certificate,
final @NotNull X509Certificate[] certificateChain,
final @NotNull String cipherSuite,
final @NotNull String protocol) {
Preconditions.checkNotNull(certificate, "certificate must never be null");
Preconditions.checkNotNull(certificateChain, "certificate chain must never be null");
Preconditions.checkNotNull(cipherSuite, "cipher suite must never be null");
Preconditions.checkNotNull(protocol, "protocol must never be null");
this.certificate = certificate;
this.certificateChain = certificateChain;
this.cipherSuite = cipherSuite;
this.protocol = protocol;
}
@Override
public @NotNull X509Certificate getCertificate() {
return certificate;
}
@Override
public @NotNull X509Certificate[] getCertificateChain() {
return certificateChain;
}
@Override
public @NotNull String getCipherSuite() {
return cipherSuite;
}
@Override
public @NotNull String getProtocol() {
return protocol;
}
}
| [
"[email protected]"
]
| |
4e16335d413b31fac1fc8ceadd3703d08fd18942 | a8e17bb2fd47a23f29fa4e8d83aaf55d3833708c | /Warehouse/src/main/java/warehouse/persistence/utils/DatabasePurge.java | a15bbf01fec630cbe27c6c2a95fe42433c701e44 | []
| no_license | Xiphereal/IeiWarehouse | df993e36cefd41a29f41367d5cf5928e68a290fe | 620f747623604187b3067bcb46d35c4e5ea816aa | refs/heads/master | 2023-02-20T20:56:39.465512 | 2021-01-20T20:01:58 | 2021-01-20T20:01:58 | 310,397,332 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 640 | java | package warehouse.persistence.utils;
import warehouse.persistence.MySQLConnection;
public class DatabasePurge {
public static void purgeAllTables() {
// Note that the table deletion order do matters.
purgeTable("articulo");
purgeTable("comunicacioncongreso");
purgeTable("ejemplar");
purgeTable("libro");
purgeTable("publicacion_has_persona");
purgeTable("revista");
purgeTable("persona");
purgeTable("publicacion");
}
public static void purgeTable(String tableName) {
MySQLConnection.performUpdate("DELETE FROM " + tableName + ";");
}
}
| [
"[email protected]"
]
| |
25f3039bf03075fc880c1df3b8cc3354100eecd2 | 1feee9fd34ac662466589f0eefc77f500fad97d3 | /src/team2102/robot/OI.java | 6f7d8dbf357ab0eca5d4cd4b8f9a77ff8e8e8273 | []
| no_license | Paradox2102/Artemis | 14d54c02ec03960cd11f2329c1a4740b602b1e66 | 95bb1c1ff1b777d124b64d7eae268faa78d34c56 | refs/heads/master | 2021-05-14T08:24:52.327915 | 2018-01-04T19:01:09 | 2018-01-04T19:01:09 | 116,296,737 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 4,620 | java | package team2102.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import team2102.robot.commands.AutoSpinShooterCommand;
import team2102.robot.commands.CalibrateGearCommand;
import team2102.robot.commands.ClimbCommand;
import team2102.robot.commands.DriveToBoilerCommand;
import team2102.robot.commands.DropOffGearAndDriveAwayCommand;
import team2102.robot.commands.IntakeCommand;
import team2102.robot.commands.ReleaseGearCommand;
import team2102.robot.commands.ShiftCommand;
import team2102.robot.commands.ShootCommand;
import team2102.robot.commands.SpinShooterCommand;
import team2102.robot.commands.TeleopPlaceGearCommand;
import team2102.robot.commands.ToggleDriveCommand;
import team2102.robot.commands.TurnCommand;
import team2102.robot.commands.TurnToBoilerCommand;
import team2102.robot.commands.UnjamFeederCommand;
import team2102.robot.commands.UnjamIntakeCommand;
import team2102.robot.subsystems.DriveSubsystem.DistanceSide;
import team2102.robot.subsystems.DriveSubsystem.DriveSide;
import team2102.robot.triggers.POVChangeTrigger;
/**
* This class is the glue that binds the controls on the physical operator
* interface to the commands and command groups that allow control of the robot.
*/
public class OI {
private static final double k_deadzone = 0.5;
private static final double k_dzMagnitudeSquared = 2 * k_deadzone * k_deadzone;
private final Joystick m_driveStick = new Joystick(0);
private final Joystick m_otherStick = new Joystick(1);
private final Button shiftBtn = new JoystickButton(m_driveStick, 5);
private final Button spinShooterBtn = new JoystickButton(m_otherStick, 2);
private final Button shootBtn = new JoystickButton(m_otherStick, 1);
private final Button unjamBtn = new JoystickButton(m_otherStick, 3);
private final Button unjamIntakeBtn = new JoystickButton(m_otherStick, 5);
private final Button intakeBtn = new JoystickButton(m_otherStick, 4);
private final Button climberBtn = new JoystickButton(m_otherStick, 6);
private final Button turnBoilerBtn = new JoystickButton(m_otherStick, 10);
private final Button driveBoilerBtn = new JoystickButton(m_otherStick, 12);
private final Button toggleDriveDirectionBtn = new JoystickButton(m_driveStick, 7);
private final Button gearDriveBtn = new JoystickButton(m_otherStick, 9);
private final Button gearReleaseBtn = new JoystickButton(m_otherStick, 7);
private final Button gearReleaseAndDriveAwayBtn = new JoystickButton(m_otherStick, 11);
// private final Button climbGoalBtn = new JoystickButton(m_driveStick, 11);
private final Button testBtn = new JoystickButton(m_driveStick, 3);
private boolean m_driveReversed = false;
public OI() {
for (int i = 0; i < 8; ++i) {
int angle = i * 45;
(new POVChangeTrigger(m_driveStick, angle)).whenActive(new TurnCommand(angle, 1000.0 / 45.0, 400));
}
//new AutoSpinShooterCommand()
spinShooterBtn.toggleWhenPressed(new SpinShooterCommand(3200));
// new SpinShooterCommand(3200));
shootBtn.whileHeld(new ShootCommand());
unjamBtn.whileHeld(new UnjamFeederCommand());
unjamIntakeBtn.whileHeld(new UnjamIntakeCommand());
shiftBtn.toggleWhenPressed(new ShiftCommand());
intakeBtn.whileHeld(new IntakeCommand());
climberBtn.whileHeld(new ClimbCommand());
turnBoilerBtn.whenPressed(new TurnToBoilerCommand(10, 800, DriveSide.BOTH));
driveBoilerBtn.whenPressed(new DriveToBoilerCommand(135, 800, 8.0));// distance
// 125,
// normally
toggleDriveDirectionBtn.whenPressed(new ToggleDriveCommand());
gearDriveBtn.whenPressed(new TeleopPlaceGearCommand());
gearReleaseBtn.whenPressed(new ReleaseGearCommand());
gearReleaseAndDriveAwayBtn.whenPressed(new DropOffGearAndDriveAwayCommand());
// climbGoalBtn.whenPressed(new MoveCameraCommand(CameraPosition.DOWN));
testBtn.whenPressed(new CalibrateGearCommand(800, 180, 80, DistanceSide.LEFT, 80 * RobotMap.k_inchesToTicks, true));
}
public void toggleReversed() {
m_driveReversed = !m_driveReversed;
}
public double getX() {
double x = m_driveStick.getX();
return x * x * x;
}
public double getY() {
double y = (m_driveReversed ? 1 : -1) * m_driveStick.getY();
return y * y * y;
}
public double getAdjustment() {
double adj = -m_otherStick.getY();
return adj * adj * adj;
}
public double getThrottle() {
return m_otherStick.getThrottle();
}
public boolean outsideDeadzone() {
double x = m_driveStick.getX();
double y = m_driveStick.getY();
return x * x + y * y > k_dzMagnitudeSquared;
}
}
| [
"[email protected]"
]
| |
232ef8a4c58f2c6ff1bc26fc2609fc6390ee6af8 | e38adafa932f9c9f386e82bd1b16a000dc1b3613 | /src/main/java/fi/csc/microarray/databeans/features/table/HeaderProvider.java | f049a576ec5c71de44fb1ada149a62a2e6a56e46 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | chipster/chipster | 1844cf655443ae75423adaa81edfa17ba102fbf2 | 07a19b305d0a602e70c0d1cec71efea6cf79a281 | refs/heads/master | 2021-07-22T18:59:28.590186 | 2020-12-17T14:59:24 | 2020-12-17T14:59:24 | 8,553,857 | 34 | 11 | MIT | 2020-12-15T13:13:44 | 2013-03-04T11:03:05 | Java | UTF-8 | Java | false | false | 1,636 | java | package fi.csc.microarray.databeans.features.table;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.log4j.Logger;
import fi.csc.microarray.client.Session;
import fi.csc.microarray.databeans.DataBean;
import fi.csc.microarray.databeans.DataBean.DataNotAvailableHandling;
import fi.csc.microarray.databeans.features.ConstantStringFeature;
import fi.csc.microarray.databeans.features.Feature;
import fi.csc.microarray.databeans.features.FeatureProviderBase;
import fi.csc.microarray.databeans.features.table.TableColumnProvider.MatrixParseSettings;
import fi.csc.microarray.exception.MicroarrayException;
import fi.csc.microarray.util.LookaheadLineReader;
public class HeaderProvider extends FeatureProviderBase {
/**
* Logger for this class
*/
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(HeaderProvider.class);
public Feature createFeature(String namePostfix, DataBean bean) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Session.getSession().getDataManager().getContentStream(bean, DataNotAvailableHandling.EMPTY_ON_NA)))) {
MatrixParseSettings settings = TableColumnProvider.inferSettings(bean);
LookaheadLineReader source = new LookaheadLineReader(bufferedReader);
String header = TableColumnProvider.getHeader(source, settings);
return new ConstantStringFeature(bean, this, header);
} catch (MicroarrayException | IOException e) {
throw new RuntimeException(e.getMessage() + " (when reading data header out of " + bean.getName() + ")", e);
}
}
}
| [
"[email protected]"
]
| |
5577ba7cbdd7b418cf7b9f772ed25741cf40b748 | 073e6b6382de517f3133d040887f575d7656218a | /src/main/java/content/IndexController.java | 404dc247e1257a1f3c1c933d3fb57cad0b14dc8c | []
| no_license | leanne89/roofing-excellence | 0a43841fa9a2d182740f98751d138e67a4d32f7e | bcba81ed6a7b62ae9ffd1ad6c5c7d3592de55860 | refs/heads/master | 2020-03-24T12:16:04.990773 | 2018-12-15T18:28:15 | 2018-12-15T18:28:15 | 142,709,056 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 825 | java | package content;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpSession;
@Controller
public class IndexController
{
@RequestMapping(value = "/", method = RequestMethod.GET)
String index(HttpSession session)
{
String contactTokenName = "contactToken";
generateToken(session, contactTokenName);
String reviewTokenName = "reviewToken";
generateToken(session, reviewTokenName);
return "index";
}
private String generateToken(HttpSession session, String tokenName)
{
String token = Double.toString(Math.random());
session.setAttribute(tokenName, token);
return token;
}
}
| [
"[email protected]"
]
| |
bf138ec335ebb7af5b40f17fd2bfaf22010f710e | dd2715842ddb9dee6d29b7e850b393e97a944842 | /gith/EmployeeCoreJava/src/com/employee/Employee.java | 232055a4688bbef5f84320cd906307d79a7c695a | []
| no_license | soniamathew/EmployeeCoreJAVA | 8c7a644b94626f9874ffd3ffad9b0ceefb44c1ea | 7fe23204526e24b068d32b876a8e5aabc06722e7 | refs/heads/master | 2020-03-24T00:34:54.329404 | 2018-07-25T12:40:42 | 2018-07-25T12:40:42 | 142,297,722 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 699 | java | package com.employee;
public class Employee {
private int empID;
private String fName;
private String lName;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
private int age;
public Employee() {
}
public int getEmpID() {
return empID;
}
public String getfName() {
return fName;
}
public String getlName() {
return lName;
}
public void setEmpID(int empID) {
this.empID = empID;
}
public void setfName(String fName) {
this.fName = fName;
}
public void setlName(String lName) {
this.lName = lName;
}
}
| [
"[email protected]"
]
| |
f7331ac528732d0ad3f1dca3a03ecd84150626bf | ed7ec336f14768ce24250f3b20e1968411bed3f9 | /src/main/java/GerenciadoraClientes.java | 989457a105d9c3e894bb844db58a514221c761ea | []
| no_license | alcaldeira/poc-test-pitest-mutant | fd04f1b6942b3c0af57a09d5464bebf9ab389a7f | 988df265b57e6a6734f934a2c7f90efc7176572b | refs/heads/master | 2022-11-17T02:07:04.748641 | 2020-07-16T20:57:42 | 2020-07-16T20:57:42 | 280,006,548 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,794 | java |
import java.util.List;
public class GerenciadoraClientes {
private List<Cliente> clientesDoBanco;
public GerenciadoraClientes(List<Cliente> clientesDoBanco) {
this.clientesDoBanco = clientesDoBanco;
}
public List<Cliente> getClientesDoBanco() {
return clientesDoBanco;
}
public Cliente pesquisaCliente(int idCliente) {
for (Cliente cliente : clientesDoBanco) {
if (cliente.getId() == idCliente)
return cliente;
}
return null;
}
public void adicionaCliente(Cliente novoCliente) {
clientesDoBanco.add(novoCliente);
}
public boolean removeCliente(int idCliente) {
boolean clienteRemovido = false;
for (int i = 0; i < clientesDoBanco.size(); i++) {
Cliente cliente = clientesDoBanco.get(i);
if (cliente.getId() == idCliente) {
clientesDoBanco.remove(i);
clienteRemovido = true;
break;
}
}
return clienteRemovido;
}
public boolean clienteAtivo(int idCliente) {
boolean clienteAtivo = false;
for (int i = 0; i < clientesDoBanco.size(); i++) {
Cliente cliente = clientesDoBanco.get(i);
if (cliente.getId() == idCliente)
if (cliente.isAtivo()) {
clienteAtivo = true;
break;
}
}
return clienteAtivo;
}
public void limpa() {
this.clientesDoBanco.clear();
}
public boolean validaIdade(int idade) throws IdadeNaoPermitidaException {
if (idade < 18 || idade > 65)
throw new IdadeNaoPermitidaException(IdadeNaoPermitidaException.MSG_IDADE_INVALIDA);
return true;
}
}
| [
"[email protected]"
]
| |
9c6ab440e9170dac5a3d15aa3f6ebb7c570c6d30 | ae715471c36e99013d47ea83e15f01e22321d2b2 | /src/Enemy.java | d08d39afda62fb71024b1f068b516f74090ca7f6 | []
| no_license | micheallam/FFXIV-DnD | 851ff647109824c36d065dfbc5376694e5325d60 | e63b67aa15994400c362085dcd8eb6137317625e | refs/heads/master | 2020-09-23T16:21:06.410180 | 2019-12-03T05:39:45 | 2019-12-03T05:39:45 | 225,539,472 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 135 | java |
public class Enemy {
static int enemyHP = 40, enemyDamage = 0;
static boolean twoEnemyAlive = true;
static boolean boss= false;
}
| [
"[email protected]"
]
| |
cd42ec2b83e14d6a431768c3f0627e301e56539d | cc998713130ce54f741a19e1ca5a8bd4eab2d9ed | /test-rabbitmq-producer/src/test/java/com/xuecheng/test/rabbitmq/Producer02_publish.java | 0c99f39fbdbc5879c949694eeddc56203f56dfeb | []
| no_license | jokeFu/frederic-fission-j | 53abf98a8579b775214a0299e1b68772a62884cd | de0d014024ef71d12628a89a05e8af6a8b86b971 | refs/heads/master | 2022-11-28T06:59:10.242304 | 2020-04-04T17:55:29 | 2020-04-04T17:55:29 | 156,668,524 | 0 | 0 | null | 2022-11-24T06:25:52 | 2018-11-08T07:40:31 | Java | UTF-8 | Java | false | false | 2,233 | java | package com.xuecheng.test.rabbitmq;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
/**
* @Auther: 0
* @Date: 2018/11/2 14:59
* @Description: ๅๅธ่ฎข้
ๆจกๅผ
*/
public class Producer02_publish {
public static final String QUEUE_INFORM_EMAIL = "queue_inform_email";
public static final String EXCHANGE_FANOUT_INFORM = "exchange_fanout_inform";
public static final String QUEUE_INFORM_SMS = "queue_inform_sms";
public static void main(String[] args) {
Connection connection = null;
Channel channel = null;
try {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
connectionFactory.setVirtualHost("/");
connection = connectionFactory.newConnection();
channel = connection.createChannel();
channel.exchangeDeclare(EXCHANGE_FANOUT_INFORM, BuiltinExchangeType.FANOUT);
channel.queueDeclare(QUEUE_INFORM_SMS, true, false, false, null);
channel.queueDeclare(QUEUE_INFORM_EMAIL, true, false, false, null);
channel.queueBind(QUEUE_INFORM_EMAIL, EXCHANGE_FANOUT_INFORM, "");
channel.queueBind(QUEUE_INFORM_SMS, EXCHANGE_FANOUT_INFORM, "");
for (int i = 0; i < 10; i++) {
String message = "send message " + System.currentTimeMillis();
channel.basicPublish(EXCHANGE_FANOUT_INFORM, "", null, message.getBytes());
System.out.println("send message.." + message);
}
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} finally {
try {
connection.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
| [
"[email protected]"
]
| |
3748362b392f9abecdd6a3e506b6d1a547d44568 | a3b13bbae65d49efa57df9c782dee29907862bfa | /IM 61-2016 Lazar Kalajdzic/src/drawing/Rectangle.java | 4b6ee728133a3a1281d944b58921c98171ee89d4 | []
| no_license | Laki997/Java-OOIT | d7b750f28e9218dce818b7802032732f21ffe373 | cc76aa7c29aadd7a7ab69b87fb5042ea510a1f45 | refs/heads/master | 2022-11-30T14:10:18.428815 | 2020-07-24T10:18:28 | 2020-07-24T10:18:28 | 282,186,808 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,047 | java | package drawing;
import java.awt.Color;
import java.awt.Graphics;
public class Rectangle extends Shape {
private Point upperLeftPoint;
private int width;
private int height;
public Point getUpperLeftPoint() {
return upperLeftPoint;
}
public void setUpperLeftPoint(Point upperLeftPoint) {
this.upperLeftPoint = upperLeftPoint;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public Rectangle() {
}
public Rectangle(Point upperLeftPoint, int width, int height) {
this.upperLeftPoint=upperLeftPoint;
this.width=width;
this.height=height;
}
public Rectangle(Point upperLeftPoint, int width, int height, boolean selected) {
this(upperLeftPoint, width, height);
setSelected(selected);
}
public String toString() {
return "[" + upperLeftPoint + " , width= " + width + " , height= " + height + " , " + super.isSelected() + "]";
}
public int area() {
return width*height;
}
@Override
public int compareTo(Object o) {
if (o instanceof Rectangle) {
return (int)(this.area()-((Rectangle)o).area());
}
return 0;
}
@Override
public void draw(Graphics g) {
g.setColor(getOutline());
g.drawRect(this.getUpperLeftPoint().getX(), this.getUpperLeftPoint().getY(), this.getWidth(), this.getHeight());
if (isSelected() == true) {
g.setColor(Color.black);
g.drawRect(this.getUpperLeftPoint().getX()-3, this.getUpperLeftPoint().getY()-3, 6, 6);
g.drawRect(this.getUpperLeftPoint().getX() + this.getWidth() - 3, this.getUpperLeftPoint().getY()-3, 6, 6);
g.drawRect(this.getUpperLeftPoint().getX()-3, this.getUpperLeftPoint().getY() + this.getHeight() - 3, 6, 6);
g.drawRect(this.getUpperLeftPoint().getX()+ this.getWidth()-3, this.getUpperLeftPoint().getY() + this.getHeight()-3, 6, 6);
}
}
@Override
public boolean contains(int x, int y) {
return (this.upperLeftPoint.getX() <= x && x <= this.upperLeftPoint.getX() + width &&
this.upperLeftPoint.getY() <= y &&
y <= this.upperLeftPoint.getY() + height);
}
@Override
public void move(int newX, int newY) {
upperLeftPoint.move(newX, newY);
}
@Override
public void DialogEdit() {
DialogRectangle dlgRectangle = new DialogRectangle();
for (Shape shape: PnlDrawing.shapesArrList) {
if (shape.isSelected()) {
String [] split = shape.toString().split(" ");
dlgRectangle.getTxtXCoord().setText(split[1]);
dlgRectangle.getTxtYCoord().setText(split[4]);
dlgRectangle.getTxtWidth().setText(split[9]);
dlgRectangle.getTxtHeight().setText(split[12]);
}
}
dlgRectangle.setVisible(true);
}
@Override
public void AreaPainter(Graphics g) {
g.setColor(getFill());
g.fillRect(this.getUpperLeftPoint().getX(), this.getUpperLeftPoint().getY(), this.getWidth(), this.getHeight());
}
}
| [
"[email protected]"
]
| |
fa94e9f1f7c8d316405463104ef94b5e436c3e24 | 6d527875bb3ab995122936190f85a584e0129fc8 | /studioOne/androidOne/src/main/java/com/sd/one/utils/encrypt/MD5.java | 9c496abc5bf39c0786f7214d5052fed9e01c152e | []
| no_license | bryant1410/androidone | 77b574f6d6017d1d259fb55d5adc77c75e6fff0f | a0f96650c919ca9483d1e1be5fcd0fec86abde56 | refs/heads/master | 2021-01-19T20:50:50.647581 | 2017-04-18T01:29:48 | 2017-04-18T01:29:48 | 88,567,506 | 1 | 0 | null | 2017-04-18T01:29:48 | 2017-04-18T01:29:48 | null | UTF-8 | Java | false | false | 2,133 | java | package com.sd.one.utils.encrypt;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* MD5ๅ ๅฏ
* @author jiang.li
* @date 2013-12-17 14:09
*/
public class MD5 {
/**ๅ
จๅฑๆฐ็ป**/
private final static String[] strDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" };
/**
* ่ฟๅๅฝขๅผไธบๆฐๅญ่ทๅญ็ฌฆไธฒ
* @param bByte
* @return
*/
private static String byteToArrayString(byte bByte) {
int iRet = bByte;
if (iRet < 0) {
iRet += 256;
}
int iD1 = iRet / 16;
int iD2 = iRet % 16;
return strDigits[iD1] + strDigits[iD2];
}
/**
* ่ฝฌๆขๅญ่ๆฐ็ปไธบ16่ฟๅถๅญไธฒ
* @param bByte
* @return
*/
private static String byteToString(byte[] bByte) {
StringBuffer sBuffer = new StringBuffer();
for (int i = 0; i < bByte.length; i++) {
sBuffer.append(byteToArrayString(bByte[i]));
}
return sBuffer.toString();
}
/**
* MD5ๅ ๅฏ
* @param str ๅพ
ๅ ๅฏ็ๅญ็ฌฆไธฒ
* @return
*/
public static String encrypt(String str) {
String result = null;
try {
result = new String(str);
MessageDigest md = MessageDigest.getInstance("MD5");
result = byteToString(md.digest(str.getBytes()));
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
return result;
}
/**
* MD5ๅ ๅฏ
* @param str ๅพ
ๅ ๅฏ็ๅญ็ฌฆไธฒ
* @param lowerCase ๅคงๅฐๅ
* @return
*/
public static String encrypt(String str,boolean lowerCase) {
String result = null;
try {
result = new String(str);
MessageDigest md = MessageDigest.getInstance("MD5");
result = byteToString(md.digest(str.getBytes()));
if(lowerCase){
result = result.toLowerCase();
}
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
return result;
}
}
| [
"huxinwu123"
]
| huxinwu123 |
be6e7c801b3e5a7c988662885bea4df245340cef | 69a4f2d51ebeea36c4d8192e25cfb5f3f77bef5e | /methods/Method_51630.java | fa90e6c4536108cf20789354ed16bf5a8df23f38 | []
| no_license | P79N6A/icse_20_user_study | 5b9c42c6384502fdc9588430899f257761f1f506 | 8a3676bc96059ea2c4f6d209016f5088a5628f3c | refs/heads/master | 2020-06-24T08:25:22.606717 | 2019-07-25T15:31:16 | 2019-07-25T15:31:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 414 | java | static Node getCompilationUnit(LanguageVersionHandler languageVersionHandler,String code){
Parser parser=languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions());
Node node=parser.parse(null,new StringReader(code));
languageVersionHandler.getSymbolFacade().start(node);
languageVersionHandler.getTypeResolutionFacade(Designer.class.getClassLoader()).start(node);
return node;
}
| [
"[email protected]"
]
| |
16e7b401780ff7f396b7b5db6b23d07793bd1f93 | 5ec06dab1409d790496ce082dacb321392b32fe9 | /clients/jaxrs-resteasy-eap/generated/src/gen/java/org/openapitools/model/ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo.java | a93504ba4ce9b9cb249fef6d4cc705f09d9b6d86 | [
"Apache-2.0"
]
| permissive | shinesolutions/swagger-aem-osgi | e9d2385f44bee70e5bbdc0d577e99a9f2525266f | c2f6e076971d2592c1cbd3f70695c679e807396b | refs/heads/master | 2022-10-29T13:07:40.422092 | 2021-04-09T07:46:03 | 2021-04-09T07:46:03 | 190,217,155 | 3 | 3 | Apache-2.0 | 2022-10-05T03:26:20 | 2019-06-04T14:23:28 | null | UTF-8 | Java | false | false | 3,594 | java | package org.openapitools.model;
import java.util.Objects;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.openapitools.model.ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplProperties;
import javax.validation.constraints.*;
import io.swagger.annotations.*;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaResteasyEapServerCodegen", date = "2019-08-05T01:00:05.540Z[GMT]")
public class ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo {
private String pid = null;
private String title = null;
private String description = null;
private ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplProperties properties = null;
/**
**/
@ApiModelProperty(value = "")
@JsonProperty("pid")
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
/**
**/
@ApiModelProperty(value = "")
@JsonProperty("title")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
/**
**/
@ApiModelProperty(value = "")
@JsonProperty("description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
/**
**/
@ApiModelProperty(value = "")
@JsonProperty("properties")
public ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplProperties getProperties() {
return properties;
}
public void setProperties(ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplProperties properties) {
this.properties = properties;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo comAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo = (ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo) o;
return Objects.equals(pid, comAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo.pid) &&
Objects.equals(title, comAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo.title) &&
Objects.equals(description, comAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo.description) &&
Objects.equals(properties, comAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo.properties);
}
@Override
public int hashCode() {
return Objects.hash(pid, title, description, properties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ComAdobeAemUpgradePrechecksTasksImplConsistencyCheckTaskImplInfo {\n");
sb.append(" pid: ").append(toIndentedString(pid)).append("\n");
sb.append(" title: ").append(toIndentedString(title)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" properties: ").append(toIndentedString(properties)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| [
"[email protected]"
]
| |
46b6968906b9f2aa66667746c6afda27b0414622 | a509334898042b896909c1f0056a7fd1f6d2177b | /src/main/java/com/learn/publisher/PublisherController.java | cdbf9559646ce3daf26425fb6cb064689e6716a3 | []
| no_license | PAVITHRA001/publisher | 9280c86381b37503c7ead3b1d617a30e8310ee32 | cee0499a56008d2a5ddb1f601149e4a61e47d059 | refs/heads/master | 2020-05-03T14:39:43.732108 | 2019-07-15T08:16:10 | 2019-07-15T08:16:10 | 178,683,669 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,236 | java | package com.learn.publisher;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
@RequestMapping("/publisher")
@RestController
public class PublisherController {
@RequestMapping(value = "/publish",method = RequestMethod.GET)
public String test(){
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare("products_queue",false,false,false,null);
String message= "product_details";
channel.basicPublish("","products_queue",null,message.getBytes());
channel.close();
connection.close();
return "Success";
}
catch (IOException | TimeoutException e){
return e.getMessage();
}
}
}
| [
"[email protected]"
]
| |
65cc4061e9933b3bd6f86a58f9e8faf7a9639f56 | 923a8d57d64e28917c11f00c79bdac6f5223c9bc | /src/main/java/ubots/winestore/domain/Compra.java | a5200d2ccd458a6fbf482d7b8e1c38ee97c09e72 | []
| no_license | jagoulartpuc/ubots-wine-store | 0d64648a15c9abfc7cbe58689622824cc0246eaa | 6926095a2552a4b1cd711b078789b80136cc4525 | refs/heads/master | 2020-08-05T04:50:40.541525 | 2019-12-05T21:55:03 | 2019-12-05T21:55:03 | 212,402,330 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 397 | java | package ubots.winestore.domain;
import java.util.List;
import lombok.Data;
@Data
public class Compra implements Comparable<Compra>{
private String codigo;
private String data;
private String cliente;
private List<Item> itens;
private Integer valorTotal;
@Override
public int compareTo(Compra o) {
return this.valorTotal.compareTo(o.getValorTotal());
}
} | [
"[email protected]"
]
| |
74bd109b9b68f4d5761ab0bcd84e57a1ba513a26 | 3adfdd089460ed85c7619b9966b1595b4eef74a7 | /src/main/java/us/aaron/demo/Item.java | d896f99d24d4418d1d5879b14e9fcb7c6c78e231 | []
| no_license | asaunders2/SpringBoot | 92cbbaa0b069f5ce497cc4b4a681e3da7210d9e4 | 9c0b37518039f42a160ce108a5d0de6e7026d93b | refs/heads/master | 2020-05-14T23:03:56.677682 | 2019-04-18T00:53:09 | 2019-04-18T00:53:09 | 181,990,583 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,003 | java | package us.aaron.demo;
public class Item {
private int productNumber;
public void setName(String name) {
this.name = name;
}
private String name;
private double price;
private boolean featured;
private String description;
private String image;
public Item(int productNumber, String name, double price, boolean featured, String description, String image) {
this.productNumber = productNumber;
this.name = name;
this.price = price;
this.featured = featured;
this.description = description;
this.image = image;
}
public int getProductNumber() {
return productNumber;
}
public String getName() {
return name;
}
public double getPrice() {
return price;
}
public boolean isFeatured() {
return featured;
}
public String getDescription() {
return description;
}
public String getImage() {
return image;
}
}
| [
"[email protected]"
]
| |
05abda278f2c41d339e96d220cb469a0fc2aeaa2 | da41a7a9b90863d977f132e081f944df3d834c5c | /CupCake/src/main/java/data/DBConnector.java | 11becc52e924383758d59345415f0d51884cc6df | []
| no_license | MartinFrederiksen/CupCake | 1499d7d9634623895d532a2951a499f608cfb6bb | 366de45b9bc7c90c93fa691a0e48bc7dc91e40cc | refs/heads/master | 2020-04-25T16:51:28.472887 | 2019-04-26T08:28:29 | 2019-04-26T08:28:29 | 172,926,787 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 934 | java | package data;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.StringJoiner;
/**
*
* @author Martin Frederiksen - Andreas Vikke
*/
public class DBConnector {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://andreasvikke.dk:3306/cupcake";
private static final String USER = "transformer";
private static final String PASSWORD = "f7qGtArm";
private static Connection connection = null;
public static Connection getConnection() {
if (connection == null) {
try {
Class.forName(DRIVER);
connection = DriverManager.getConnection(URL, USER, PASSWORD);
} catch (ClassNotFoundException | SQLException ex) {
ex.printStackTrace();
}
}
return connection;
}
}
| [
"[email protected]"
]
| |
e156635864e4cd6a34d8f8712d3a29af937aa651 | ecf565996d746266ee61f3ba30adf01577277bb8 | /huihuiMall/src/main/java/com/kshl/huihuimall/base/dal/entity/MerchantExample.java | b2239c21a993ff015591df8e995263e4d66ff80e | []
| no_license | wzhforgithub/huihuiMall | 9071030d42536f368dc0caced745659dd7a004e5 | 17e4f6eb5892a4b06b538aa42e8eb5b4e9d96a86 | refs/heads/master | 2023-04-13T12:44:21.717244 | 2018-06-07T09:48:04 | 2018-06-07T09:48:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 101,779 | java | package com.kshl.huihuimall.base.dal.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MerchantExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table merchant
*
* @mbg.generated
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table merchant
*
* @mbg.generated
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table merchant
*
* @mbg.generated
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public MerchantExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table merchant
*
* @mbg.generated
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table merchant
*
* @mbg.generated
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andNameIsNull() {
addCriterion("name is null");
return (Criteria) this;
}
public Criteria andNameIsNotNull() {
addCriterion("name is not null");
return (Criteria) this;
}
public Criteria andNameEqualTo(String value) {
addCriterion("name =", value, "name");
return (Criteria) this;
}
public Criteria andNameNotEqualTo(String value) {
addCriterion("name <>", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThan(String value) {
addCriterion("name >", value, "name");
return (Criteria) this;
}
public Criteria andNameGreaterThanOrEqualTo(String value) {
addCriterion("name >=", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThan(String value) {
addCriterion("name <", value, "name");
return (Criteria) this;
}
public Criteria andNameLessThanOrEqualTo(String value) {
addCriterion("name <=", value, "name");
return (Criteria) this;
}
public Criteria andNameLike(String value) {
addCriterion("name like", value, "name");
return (Criteria) this;
}
public Criteria andNameNotLike(String value) {
addCriterion("name not like", value, "name");
return (Criteria) this;
}
public Criteria andNameIn(List<String> values) {
addCriterion("name in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> values) {
addCriterion("name not in", values, "name");
return (Criteria) this;
}
public Criteria andNameBetween(String value1, String value2) {
addCriterion("name between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andNameNotBetween(String value1, String value2) {
addCriterion("name not between", value1, value2, "name");
return (Criteria) this;
}
public Criteria andPhoneIsNull() {
addCriterion("phone is null");
return (Criteria) this;
}
public Criteria andPhoneIsNotNull() {
addCriterion("phone is not null");
return (Criteria) this;
}
public Criteria andPhoneEqualTo(String value) {
addCriterion("phone =", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneNotEqualTo(String value) {
addCriterion("phone <>", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneGreaterThan(String value) {
addCriterion("phone >", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneGreaterThanOrEqualTo(String value) {
addCriterion("phone >=", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneLessThan(String value) {
addCriterion("phone <", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneLessThanOrEqualTo(String value) {
addCriterion("phone <=", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneLike(String value) {
addCriterion("phone like", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneNotLike(String value) {
addCriterion("phone not like", value, "phone");
return (Criteria) this;
}
public Criteria andPhoneIn(List<String> values) {
addCriterion("phone in", values, "phone");
return (Criteria) this;
}
public Criteria andPhoneNotIn(List<String> values) {
addCriterion("phone not in", values, "phone");
return (Criteria) this;
}
public Criteria andPhoneBetween(String value1, String value2) {
addCriterion("phone between", value1, value2, "phone");
return (Criteria) this;
}
public Criteria andPhoneNotBetween(String value1, String value2) {
addCriterion("phone not between", value1, value2, "phone");
return (Criteria) this;
}
public Criteria andRegistAddressIsNull() {
addCriterion("regist_address is null");
return (Criteria) this;
}
public Criteria andRegistAddressIsNotNull() {
addCriterion("regist_address is not null");
return (Criteria) this;
}
public Criteria andRegistAddressEqualTo(String value) {
addCriterion("regist_address =", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressNotEqualTo(String value) {
addCriterion("regist_address <>", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressGreaterThan(String value) {
addCriterion("regist_address >", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressGreaterThanOrEqualTo(String value) {
addCriterion("regist_address >=", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressLessThan(String value) {
addCriterion("regist_address <", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressLessThanOrEqualTo(String value) {
addCriterion("regist_address <=", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressLike(String value) {
addCriterion("regist_address like", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressNotLike(String value) {
addCriterion("regist_address not like", value, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressIn(List<String> values) {
addCriterion("regist_address in", values, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressNotIn(List<String> values) {
addCriterion("regist_address not in", values, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressBetween(String value1, String value2) {
addCriterion("regist_address between", value1, value2, "registAddress");
return (Criteria) this;
}
public Criteria andRegistAddressNotBetween(String value1, String value2) {
addCriterion("regist_address not between", value1, value2, "registAddress");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberIsNull() {
addCriterion("business_license_number is null");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberIsNotNull() {
addCriterion("business_license_number is not null");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberEqualTo(String value) {
addCriterion("business_license_number =", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberNotEqualTo(String value) {
addCriterion("business_license_number <>", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberGreaterThan(String value) {
addCriterion("business_license_number >", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberGreaterThanOrEqualTo(String value) {
addCriterion("business_license_number >=", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberLessThan(String value) {
addCriterion("business_license_number <", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberLessThanOrEqualTo(String value) {
addCriterion("business_license_number <=", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberLike(String value) {
addCriterion("business_license_number like", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberNotLike(String value) {
addCriterion("business_license_number not like", value, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberIn(List<String> values) {
addCriterion("business_license_number in", values, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberNotIn(List<String> values) {
addCriterion("business_license_number not in", values, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberBetween(String value1, String value2) {
addCriterion("business_license_number between", value1, value2, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andBusinessLicenseNumberNotBetween(String value1, String value2) {
addCriterion("business_license_number not between", value1, value2, "businessLicenseNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberIsNull() {
addCriterion("institution_code_number is null");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberIsNotNull() {
addCriterion("institution_code_number is not null");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberEqualTo(String value) {
addCriterion("institution_code_number =", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberNotEqualTo(String value) {
addCriterion("institution_code_number <>", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberGreaterThan(String value) {
addCriterion("institution_code_number >", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberGreaterThanOrEqualTo(String value) {
addCriterion("institution_code_number >=", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberLessThan(String value) {
addCriterion("institution_code_number <", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberLessThanOrEqualTo(String value) {
addCriterion("institution_code_number <=", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberLike(String value) {
addCriterion("institution_code_number like", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberNotLike(String value) {
addCriterion("institution_code_number not like", value, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberIn(List<String> values) {
addCriterion("institution_code_number in", values, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberNotIn(List<String> values) {
addCriterion("institution_code_number not in", values, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberBetween(String value1, String value2) {
addCriterion("institution_code_number between", value1, value2, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andInstitutionCodeNumberNotBetween(String value1, String value2) {
addCriterion("institution_code_number not between", value1, value2, "institutionCodeNumber");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseIsNull() {
addCriterion("account_opening_license is null");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseIsNotNull() {
addCriterion("account_opening_license is not null");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseEqualTo(String value) {
addCriterion("account_opening_license =", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseNotEqualTo(String value) {
addCriterion("account_opening_license <>", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseGreaterThan(String value) {
addCriterion("account_opening_license >", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseGreaterThanOrEqualTo(String value) {
addCriterion("account_opening_license >=", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseLessThan(String value) {
addCriterion("account_opening_license <", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseLessThanOrEqualTo(String value) {
addCriterion("account_opening_license <=", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseLike(String value) {
addCriterion("account_opening_license like", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseNotLike(String value) {
addCriterion("account_opening_license not like", value, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseIn(List<String> values) {
addCriterion("account_opening_license in", values, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseNotIn(List<String> values) {
addCriterion("account_opening_license not in", values, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseBetween(String value1, String value2) {
addCriterion("account_opening_license between", value1, value2, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andAccountOpeningLicenseNotBetween(String value1, String value2) {
addCriterion("account_opening_license not between", value1, value2, "accountOpeningLicense");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberIsNull() {
addCriterion("tax_registry_number is null");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberIsNotNull() {
addCriterion("tax_registry_number is not null");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberEqualTo(String value) {
addCriterion("tax_registry_number =", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberNotEqualTo(String value) {
addCriterion("tax_registry_number <>", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberGreaterThan(String value) {
addCriterion("tax_registry_number >", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberGreaterThanOrEqualTo(String value) {
addCriterion("tax_registry_number >=", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberLessThan(String value) {
addCriterion("tax_registry_number <", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberLessThanOrEqualTo(String value) {
addCriterion("tax_registry_number <=", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberLike(String value) {
addCriterion("tax_registry_number like", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberNotLike(String value) {
addCriterion("tax_registry_number not like", value, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberIn(List<String> values) {
addCriterion("tax_registry_number in", values, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberNotIn(List<String> values) {
addCriterion("tax_registry_number not in", values, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberBetween(String value1, String value2) {
addCriterion("tax_registry_number between", value1, value2, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andTaxRegistryNumberNotBetween(String value1, String value2) {
addCriterion("tax_registry_number not between", value1, value2, "taxRegistryNumber");
return (Criteria) this;
}
public Criteria andLegalPersonNameIsNull() {
addCriterion("legal_person_name is null");
return (Criteria) this;
}
public Criteria andLegalPersonNameIsNotNull() {
addCriterion("legal_person_name is not null");
return (Criteria) this;
}
public Criteria andLegalPersonNameEqualTo(String value) {
addCriterion("legal_person_name =", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameNotEqualTo(String value) {
addCriterion("legal_person_name <>", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameGreaterThan(String value) {
addCriterion("legal_person_name >", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameGreaterThanOrEqualTo(String value) {
addCriterion("legal_person_name >=", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameLessThan(String value) {
addCriterion("legal_person_name <", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameLessThanOrEqualTo(String value) {
addCriterion("legal_person_name <=", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameLike(String value) {
addCriterion("legal_person_name like", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameNotLike(String value) {
addCriterion("legal_person_name not like", value, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameIn(List<String> values) {
addCriterion("legal_person_name in", values, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameNotIn(List<String> values) {
addCriterion("legal_person_name not in", values, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameBetween(String value1, String value2) {
addCriterion("legal_person_name between", value1, value2, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonNameNotBetween(String value1, String value2) {
addCriterion("legal_person_name not between", value1, value2, "legalPersonName");
return (Criteria) this;
}
public Criteria andLegalPersonContactIsNull() {
addCriterion("legal_person_contact is null");
return (Criteria) this;
}
public Criteria andLegalPersonContactIsNotNull() {
addCriterion("legal_person_contact is not null");
return (Criteria) this;
}
public Criteria andLegalPersonContactEqualTo(String value) {
addCriterion("legal_person_contact =", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactNotEqualTo(String value) {
addCriterion("legal_person_contact <>", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactGreaterThan(String value) {
addCriterion("legal_person_contact >", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactGreaterThanOrEqualTo(String value) {
addCriterion("legal_person_contact >=", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactLessThan(String value) {
addCriterion("legal_person_contact <", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactLessThanOrEqualTo(String value) {
addCriterion("legal_person_contact <=", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactLike(String value) {
addCriterion("legal_person_contact like", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactNotLike(String value) {
addCriterion("legal_person_contact not like", value, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactIn(List<String> values) {
addCriterion("legal_person_contact in", values, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactNotIn(List<String> values) {
addCriterion("legal_person_contact not in", values, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactBetween(String value1, String value2) {
addCriterion("legal_person_contact between", value1, value2, "legalPersonContact");
return (Criteria) this;
}
public Criteria andLegalPersonContactNotBetween(String value1, String value2) {
addCriterion("legal_person_contact not between", value1, value2, "legalPersonContact");
return (Criteria) this;
}
public Criteria andCoverageAreaIsNull() {
addCriterion("coverage_area is null");
return (Criteria) this;
}
public Criteria andCoverageAreaIsNotNull() {
addCriterion("coverage_area is not null");
return (Criteria) this;
}
public Criteria andCoverageAreaEqualTo(String value) {
addCriterion("coverage_area =", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaNotEqualTo(String value) {
addCriterion("coverage_area <>", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaGreaterThan(String value) {
addCriterion("coverage_area >", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaGreaterThanOrEqualTo(String value) {
addCriterion("coverage_area >=", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaLessThan(String value) {
addCriterion("coverage_area <", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaLessThanOrEqualTo(String value) {
addCriterion("coverage_area <=", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaLike(String value) {
addCriterion("coverage_area like", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaNotLike(String value) {
addCriterion("coverage_area not like", value, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaIn(List<String> values) {
addCriterion("coverage_area in", values, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaNotIn(List<String> values) {
addCriterion("coverage_area not in", values, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaBetween(String value1, String value2) {
addCriterion("coverage_area between", value1, value2, "coverageArea");
return (Criteria) this;
}
public Criteria andCoverageAreaNotBetween(String value1, String value2) {
addCriterion("coverage_area not between", value1, value2, "coverageArea");
return (Criteria) this;
}
public Criteria andNumberOfBranchesIsNull() {
addCriterion("number_of_branches is null");
return (Criteria) this;
}
public Criteria andNumberOfBranchesIsNotNull() {
addCriterion("number_of_branches is not null");
return (Criteria) this;
}
public Criteria andNumberOfBranchesEqualTo(Integer value) {
addCriterion("number_of_branches =", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesNotEqualTo(Integer value) {
addCriterion("number_of_branches <>", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesGreaterThan(Integer value) {
addCriterion("number_of_branches >", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesGreaterThanOrEqualTo(Integer value) {
addCriterion("number_of_branches >=", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesLessThan(Integer value) {
addCriterion("number_of_branches <", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesLessThanOrEqualTo(Integer value) {
addCriterion("number_of_branches <=", value, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesIn(List<Integer> values) {
addCriterion("number_of_branches in", values, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesNotIn(List<Integer> values) {
addCriterion("number_of_branches not in", values, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesBetween(Integer value1, Integer value2) {
addCriterion("number_of_branches between", value1, value2, "numberOfBranches");
return (Criteria) this;
}
public Criteria andNumberOfBranchesNotBetween(Integer value1, Integer value2) {
addCriterion("number_of_branches not between", value1, value2, "numberOfBranches");
return (Criteria) this;
}
public Criteria andAnnualSalesIsNull() {
addCriterion("annual_sales is null");
return (Criteria) this;
}
public Criteria andAnnualSalesIsNotNull() {
addCriterion("annual_sales is not null");
return (Criteria) this;
}
public Criteria andAnnualSalesEqualTo(Long value) {
addCriterion("annual_sales =", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesNotEqualTo(Long value) {
addCriterion("annual_sales <>", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesGreaterThan(Long value) {
addCriterion("annual_sales >", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesGreaterThanOrEqualTo(Long value) {
addCriterion("annual_sales >=", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesLessThan(Long value) {
addCriterion("annual_sales <", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesLessThanOrEqualTo(Long value) {
addCriterion("annual_sales <=", value, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesIn(List<Long> values) {
addCriterion("annual_sales in", values, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesNotIn(List<Long> values) {
addCriterion("annual_sales not in", values, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesBetween(Long value1, Long value2) {
addCriterion("annual_sales between", value1, value2, "annualSales");
return (Criteria) this;
}
public Criteria andAnnualSalesNotBetween(Long value1, Long value2) {
addCriterion("annual_sales not between", value1, value2, "annualSales");
return (Criteria) this;
}
public Criteria andProfitIsNull() {
addCriterion("profit is null");
return (Criteria) this;
}
public Criteria andProfitIsNotNull() {
addCriterion("profit is not null");
return (Criteria) this;
}
public Criteria andProfitEqualTo(Long value) {
addCriterion("profit =", value, "profit");
return (Criteria) this;
}
public Criteria andProfitNotEqualTo(Long value) {
addCriterion("profit <>", value, "profit");
return (Criteria) this;
}
public Criteria andProfitGreaterThan(Long value) {
addCriterion("profit >", value, "profit");
return (Criteria) this;
}
public Criteria andProfitGreaterThanOrEqualTo(Long value) {
addCriterion("profit >=", value, "profit");
return (Criteria) this;
}
public Criteria andProfitLessThan(Long value) {
addCriterion("profit <", value, "profit");
return (Criteria) this;
}
public Criteria andProfitLessThanOrEqualTo(Long value) {
addCriterion("profit <=", value, "profit");
return (Criteria) this;
}
public Criteria andProfitIn(List<Long> values) {
addCriterion("profit in", values, "profit");
return (Criteria) this;
}
public Criteria andProfitNotIn(List<Long> values) {
addCriterion("profit not in", values, "profit");
return (Criteria) this;
}
public Criteria andProfitBetween(Long value1, Long value2) {
addCriterion("profit between", value1, value2, "profit");
return (Criteria) this;
}
public Criteria andProfitNotBetween(Long value1, Long value2) {
addCriterion("profit not between", value1, value2, "profit");
return (Criteria) this;
}
public Criteria andLogisticsTypeIsNull() {
addCriterion("logistics_type is null");
return (Criteria) this;
}
public Criteria andLogisticsTypeIsNotNull() {
addCriterion("logistics_type is not null");
return (Criteria) this;
}
public Criteria andLogisticsTypeEqualTo(Integer value) {
addCriterion("logistics_type =", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeNotEqualTo(Integer value) {
addCriterion("logistics_type <>", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeGreaterThan(Integer value) {
addCriterion("logistics_type >", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("logistics_type >=", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeLessThan(Integer value) {
addCriterion("logistics_type <", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeLessThanOrEqualTo(Integer value) {
addCriterion("logistics_type <=", value, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeIn(List<Integer> values) {
addCriterion("logistics_type in", values, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeNotIn(List<Integer> values) {
addCriterion("logistics_type not in", values, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeBetween(Integer value1, Integer value2) {
addCriterion("logistics_type between", value1, value2, "logisticsType");
return (Criteria) this;
}
public Criteria andLogisticsTypeNotBetween(Integer value1, Integer value2) {
addCriterion("logistics_type not between", value1, value2, "logisticsType");
return (Criteria) this;
}
public Criteria andLinkmanNameIsNull() {
addCriterion("linkman_name is null");
return (Criteria) this;
}
public Criteria andLinkmanNameIsNotNull() {
addCriterion("linkman_name is not null");
return (Criteria) this;
}
public Criteria andLinkmanNameEqualTo(String value) {
addCriterion("linkman_name =", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameNotEqualTo(String value) {
addCriterion("linkman_name <>", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameGreaterThan(String value) {
addCriterion("linkman_name >", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameGreaterThanOrEqualTo(String value) {
addCriterion("linkman_name >=", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameLessThan(String value) {
addCriterion("linkman_name <", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameLessThanOrEqualTo(String value) {
addCriterion("linkman_name <=", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameLike(String value) {
addCriterion("linkman_name like", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameNotLike(String value) {
addCriterion("linkman_name not like", value, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameIn(List<String> values) {
addCriterion("linkman_name in", values, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameNotIn(List<String> values) {
addCriterion("linkman_name not in", values, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameBetween(String value1, String value2) {
addCriterion("linkman_name between", value1, value2, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanNameNotBetween(String value1, String value2) {
addCriterion("linkman_name not between", value1, value2, "linkmanName");
return (Criteria) this;
}
public Criteria andLinkmanMobileIsNull() {
addCriterion("linkman_mobile is null");
return (Criteria) this;
}
public Criteria andLinkmanMobileIsNotNull() {
addCriterion("linkman_mobile is not null");
return (Criteria) this;
}
public Criteria andLinkmanMobileEqualTo(String value) {
addCriterion("linkman_mobile =", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileNotEqualTo(String value) {
addCriterion("linkman_mobile <>", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileGreaterThan(String value) {
addCriterion("linkman_mobile >", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileGreaterThanOrEqualTo(String value) {
addCriterion("linkman_mobile >=", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileLessThan(String value) {
addCriterion("linkman_mobile <", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileLessThanOrEqualTo(String value) {
addCriterion("linkman_mobile <=", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileLike(String value) {
addCriterion("linkman_mobile like", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileNotLike(String value) {
addCriterion("linkman_mobile not like", value, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileIn(List<String> values) {
addCriterion("linkman_mobile in", values, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileNotIn(List<String> values) {
addCriterion("linkman_mobile not in", values, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileBetween(String value1, String value2) {
addCriterion("linkman_mobile between", value1, value2, "linkmanMobile");
return (Criteria) this;
}
public Criteria andLinkmanMobileNotBetween(String value1, String value2) {
addCriterion("linkman_mobile not between", value1, value2, "linkmanMobile");
return (Criteria) this;
}
public Criteria andMainProductIsNull() {
addCriterion("main_product is null");
return (Criteria) this;
}
public Criteria andMainProductIsNotNull() {
addCriterion("main_product is not null");
return (Criteria) this;
}
public Criteria andMainProductEqualTo(String value) {
addCriterion("main_product =", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductNotEqualTo(String value) {
addCriterion("main_product <>", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductGreaterThan(String value) {
addCriterion("main_product >", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductGreaterThanOrEqualTo(String value) {
addCriterion("main_product >=", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductLessThan(String value) {
addCriterion("main_product <", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductLessThanOrEqualTo(String value) {
addCriterion("main_product <=", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductLike(String value) {
addCriterion("main_product like", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductNotLike(String value) {
addCriterion("main_product not like", value, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductIn(List<String> values) {
addCriterion("main_product in", values, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductNotIn(List<String> values) {
addCriterion("main_product not in", values, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductBetween(String value1, String value2) {
addCriterion("main_product between", value1, value2, "mainProduct");
return (Criteria) this;
}
public Criteria andMainProductNotBetween(String value1, String value2) {
addCriterion("main_product not between", value1, value2, "mainProduct");
return (Criteria) this;
}
public Criteria andBankNameIsNull() {
addCriterion("bank_name is null");
return (Criteria) this;
}
public Criteria andBankNameIsNotNull() {
addCriterion("bank_name is not null");
return (Criteria) this;
}
public Criteria andBankNameEqualTo(String value) {
addCriterion("bank_name =", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameNotEqualTo(String value) {
addCriterion("bank_name <>", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameGreaterThan(String value) {
addCriterion("bank_name >", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameGreaterThanOrEqualTo(String value) {
addCriterion("bank_name >=", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameLessThan(String value) {
addCriterion("bank_name <", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameLessThanOrEqualTo(String value) {
addCriterion("bank_name <=", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameLike(String value) {
addCriterion("bank_name like", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameNotLike(String value) {
addCriterion("bank_name not like", value, "bankName");
return (Criteria) this;
}
public Criteria andBankNameIn(List<String> values) {
addCriterion("bank_name in", values, "bankName");
return (Criteria) this;
}
public Criteria andBankNameNotIn(List<String> values) {
addCriterion("bank_name not in", values, "bankName");
return (Criteria) this;
}
public Criteria andBankNameBetween(String value1, String value2) {
addCriterion("bank_name between", value1, value2, "bankName");
return (Criteria) this;
}
public Criteria andBankNameNotBetween(String value1, String value2) {
addCriterion("bank_name not between", value1, value2, "bankName");
return (Criteria) this;
}
public Criteria andBankNumberIsNull() {
addCriterion("bank_number is null");
return (Criteria) this;
}
public Criteria andBankNumberIsNotNull() {
addCriterion("bank_number is not null");
return (Criteria) this;
}
public Criteria andBankNumberEqualTo(String value) {
addCriterion("bank_number =", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberNotEqualTo(String value) {
addCriterion("bank_number <>", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberGreaterThan(String value) {
addCriterion("bank_number >", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberGreaterThanOrEqualTo(String value) {
addCriterion("bank_number >=", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberLessThan(String value) {
addCriterion("bank_number <", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberLessThanOrEqualTo(String value) {
addCriterion("bank_number <=", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberLike(String value) {
addCriterion("bank_number like", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberNotLike(String value) {
addCriterion("bank_number not like", value, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberIn(List<String> values) {
addCriterion("bank_number in", values, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberNotIn(List<String> values) {
addCriterion("bank_number not in", values, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberBetween(String value1, String value2) {
addCriterion("bank_number between", value1, value2, "bankNumber");
return (Criteria) this;
}
public Criteria andBankNumberNotBetween(String value1, String value2) {
addCriterion("bank_number not between", value1, value2, "bankNumber");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardIsNull() {
addCriterion("legal_person_idcard is null");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardIsNotNull() {
addCriterion("legal_person_idcard is not null");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardEqualTo(String value) {
addCriterion("legal_person_idcard =", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardNotEqualTo(String value) {
addCriterion("legal_person_idcard <>", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardGreaterThan(String value) {
addCriterion("legal_person_idcard >", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardGreaterThanOrEqualTo(String value) {
addCriterion("legal_person_idcard >=", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardLessThan(String value) {
addCriterion("legal_person_idcard <", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardLessThanOrEqualTo(String value) {
addCriterion("legal_person_idcard <=", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardLike(String value) {
addCriterion("legal_person_idcard like", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardNotLike(String value) {
addCriterion("legal_person_idcard not like", value, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardIn(List<String> values) {
addCriterion("legal_person_idcard in", values, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardNotIn(List<String> values) {
addCriterion("legal_person_idcard not in", values, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardBetween(String value1, String value2) {
addCriterion("legal_person_idcard between", value1, value2, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andLegalPersonIdcardNotBetween(String value1, String value2) {
addCriterion("legal_person_idcard not between", value1, value2, "legalPersonIdcard");
return (Criteria) this;
}
public Criteria andBusinessLicenceIsNull() {
addCriterion("business_licence is null");
return (Criteria) this;
}
public Criteria andBusinessLicenceIsNotNull() {
addCriterion("business_licence is not null");
return (Criteria) this;
}
public Criteria andBusinessLicenceEqualTo(String value) {
addCriterion("business_licence =", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceNotEqualTo(String value) {
addCriterion("business_licence <>", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceGreaterThan(String value) {
addCriterion("business_licence >", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceGreaterThanOrEqualTo(String value) {
addCriterion("business_licence >=", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceLessThan(String value) {
addCriterion("business_licence <", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceLessThanOrEqualTo(String value) {
addCriterion("business_licence <=", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceLike(String value) {
addCriterion("business_licence like", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceNotLike(String value) {
addCriterion("business_licence not like", value, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceIn(List<String> values) {
addCriterion("business_licence in", values, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceNotIn(List<String> values) {
addCriterion("business_licence not in", values, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceBetween(String value1, String value2) {
addCriterion("business_licence between", value1, value2, "businessLicence");
return (Criteria) this;
}
public Criteria andBusinessLicenceNotBetween(String value1, String value2) {
addCriterion("business_licence not between", value1, value2, "businessLicence");
return (Criteria) this;
}
public Criteria andHygienicLicenseIsNull() {
addCriterion("hygienic_license is null");
return (Criteria) this;
}
public Criteria andHygienicLicenseIsNotNull() {
addCriterion("hygienic_license is not null");
return (Criteria) this;
}
public Criteria andHygienicLicenseEqualTo(String value) {
addCriterion("hygienic_license =", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseNotEqualTo(String value) {
addCriterion("hygienic_license <>", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseGreaterThan(String value) {
addCriterion("hygienic_license >", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseGreaterThanOrEqualTo(String value) {
addCriterion("hygienic_license >=", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseLessThan(String value) {
addCriterion("hygienic_license <", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseLessThanOrEqualTo(String value) {
addCriterion("hygienic_license <=", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseLike(String value) {
addCriterion("hygienic_license like", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseNotLike(String value) {
addCriterion("hygienic_license not like", value, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseIn(List<String> values) {
addCriterion("hygienic_license in", values, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseNotIn(List<String> values) {
addCriterion("hygienic_license not in", values, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseBetween(String value1, String value2) {
addCriterion("hygienic_license between", value1, value2, "hygienicLicense");
return (Criteria) this;
}
public Criteria andHygienicLicenseNotBetween(String value1, String value2) {
addCriterion("hygienic_license not between", value1, value2, "hygienicLicense");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosIsNull() {
addCriterion("management_place_photos is null");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosIsNotNull() {
addCriterion("management_place_photos is not null");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosEqualTo(String value) {
addCriterion("management_place_photos =", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosNotEqualTo(String value) {
addCriterion("management_place_photos <>", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosGreaterThan(String value) {
addCriterion("management_place_photos >", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosGreaterThanOrEqualTo(String value) {
addCriterion("management_place_photos >=", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosLessThan(String value) {
addCriterion("management_place_photos <", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosLessThanOrEqualTo(String value) {
addCriterion("management_place_photos <=", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosLike(String value) {
addCriterion("management_place_photos like", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosNotLike(String value) {
addCriterion("management_place_photos not like", value, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosIn(List<String> values) {
addCriterion("management_place_photos in", values, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosNotIn(List<String> values) {
addCriterion("management_place_photos not in", values, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosBetween(String value1, String value2) {
addCriterion("management_place_photos between", value1, value2, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlacePhotosNotBetween(String value1, String value2) {
addCriterion("management_place_photos not between", value1, value2, "managementPlacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosIsNull() {
addCriterion("company_door_face_photos is null");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosIsNotNull() {
addCriterion("company_door_face_photos is not null");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosEqualTo(String value) {
addCriterion("company_door_face_photos =", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosNotEqualTo(String value) {
addCriterion("company_door_face_photos <>", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosGreaterThan(String value) {
addCriterion("company_door_face_photos >", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosGreaterThanOrEqualTo(String value) {
addCriterion("company_door_face_photos >=", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosLessThan(String value) {
addCriterion("company_door_face_photos <", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosLessThanOrEqualTo(String value) {
addCriterion("company_door_face_photos <=", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosLike(String value) {
addCriterion("company_door_face_photos like", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosNotLike(String value) {
addCriterion("company_door_face_photos not like", value, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosIn(List<String> values) {
addCriterion("company_door_face_photos in", values, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosNotIn(List<String> values) {
addCriterion("company_door_face_photos not in", values, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosBetween(String value1, String value2) {
addCriterion("company_door_face_photos between", value1, value2, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andCompanyDoorFacePhotosNotBetween(String value1, String value2) {
addCriterion("company_door_face_photos not between", value1, value2, "companyDoorFacePhotos");
return (Criteria) this;
}
public Criteria andManagementPlaceThatIsNull() {
addCriterion("management_place_that is null");
return (Criteria) this;
}
public Criteria andManagementPlaceThatIsNotNull() {
addCriterion("management_place_that is not null");
return (Criteria) this;
}
public Criteria andManagementPlaceThatEqualTo(String value) {
addCriterion("management_place_that =", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatNotEqualTo(String value) {
addCriterion("management_place_that <>", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatGreaterThan(String value) {
addCriterion("management_place_that >", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatGreaterThanOrEqualTo(String value) {
addCriterion("management_place_that >=", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatLessThan(String value) {
addCriterion("management_place_that <", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatLessThanOrEqualTo(String value) {
addCriterion("management_place_that <=", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatLike(String value) {
addCriterion("management_place_that like", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatNotLike(String value) {
addCriterion("management_place_that not like", value, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatIn(List<String> values) {
addCriterion("management_place_that in", values, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatNotIn(List<String> values) {
addCriterion("management_place_that not in", values, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatBetween(String value1, String value2) {
addCriterion("management_place_that between", value1, value2, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andManagementPlaceThatNotBetween(String value1, String value2) {
addCriterion("management_place_that not between", value1, value2, "managementPlaceThat");
return (Criteria) this;
}
public Criteria andEnableStatusIsNull() {
addCriterion("enable_status is null");
return (Criteria) this;
}
public Criteria andEnableStatusIsNotNull() {
addCriterion("enable_status is not null");
return (Criteria) this;
}
public Criteria andEnableStatusEqualTo(Integer value) {
addCriterion("enable_status =", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusNotEqualTo(Integer value) {
addCriterion("enable_status <>", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusGreaterThan(Integer value) {
addCriterion("enable_status >", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("enable_status >=", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusLessThan(Integer value) {
addCriterion("enable_status <", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusLessThanOrEqualTo(Integer value) {
addCriterion("enable_status <=", value, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusIn(List<Integer> values) {
addCriterion("enable_status in", values, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusNotIn(List<Integer> values) {
addCriterion("enable_status not in", values, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusBetween(Integer value1, Integer value2) {
addCriterion("enable_status between", value1, value2, "enableStatus");
return (Criteria) this;
}
public Criteria andEnableStatusNotBetween(Integer value1, Integer value2) {
addCriterion("enable_status not between", value1, value2, "enableStatus");
return (Criteria) this;
}
public Criteria andEntCodeIsNull() {
addCriterion("ent_code is null");
return (Criteria) this;
}
public Criteria andEntCodeIsNotNull() {
addCriterion("ent_code is not null");
return (Criteria) this;
}
public Criteria andEntCodeEqualTo(String value) {
addCriterion("ent_code =", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeNotEqualTo(String value) {
addCriterion("ent_code <>", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeGreaterThan(String value) {
addCriterion("ent_code >", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeGreaterThanOrEqualTo(String value) {
addCriterion("ent_code >=", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeLessThan(String value) {
addCriterion("ent_code <", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeLessThanOrEqualTo(String value) {
addCriterion("ent_code <=", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeLike(String value) {
addCriterion("ent_code like", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeNotLike(String value) {
addCriterion("ent_code not like", value, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeIn(List<String> values) {
addCriterion("ent_code in", values, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeNotIn(List<String> values) {
addCriterion("ent_code not in", values, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeBetween(String value1, String value2) {
addCriterion("ent_code between", value1, value2, "entCode");
return (Criteria) this;
}
public Criteria andEntCodeNotBetween(String value1, String value2) {
addCriterion("ent_code not between", value1, value2, "entCode");
return (Criteria) this;
}
public Criteria andAuditStatusIsNull() {
addCriterion("audit_status is null");
return (Criteria) this;
}
public Criteria andAuditStatusIsNotNull() {
addCriterion("audit_status is not null");
return (Criteria) this;
}
public Criteria andAuditStatusEqualTo(Integer value) {
addCriterion("audit_status =", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusNotEqualTo(Integer value) {
addCriterion("audit_status <>", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusGreaterThan(Integer value) {
addCriterion("audit_status >", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("audit_status >=", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusLessThan(Integer value) {
addCriterion("audit_status <", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusLessThanOrEqualTo(Integer value) {
addCriterion("audit_status <=", value, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusIn(List<Integer> values) {
addCriterion("audit_status in", values, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusNotIn(List<Integer> values) {
addCriterion("audit_status not in", values, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusBetween(Integer value1, Integer value2) {
addCriterion("audit_status between", value1, value2, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditStatusNotBetween(Integer value1, Integer value2) {
addCriterion("audit_status not between", value1, value2, "auditStatus");
return (Criteria) this;
}
public Criteria andAuditTimeIsNull() {
addCriterion("audit_time is null");
return (Criteria) this;
}
public Criteria andAuditTimeIsNotNull() {
addCriterion("audit_time is not null");
return (Criteria) this;
}
public Criteria andAuditTimeEqualTo(Date value) {
addCriterion("audit_time =", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeNotEqualTo(Date value) {
addCriterion("audit_time <>", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeGreaterThan(Date value) {
addCriterion("audit_time >", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeGreaterThanOrEqualTo(Date value) {
addCriterion("audit_time >=", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeLessThan(Date value) {
addCriterion("audit_time <", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeLessThanOrEqualTo(Date value) {
addCriterion("audit_time <=", value, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeIn(List<Date> values) {
addCriterion("audit_time in", values, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeNotIn(List<Date> values) {
addCriterion("audit_time not in", values, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeBetween(Date value1, Date value2) {
addCriterion("audit_time between", value1, value2, "auditTime");
return (Criteria) this;
}
public Criteria andAuditTimeNotBetween(Date value1, Date value2) {
addCriterion("audit_time not between", value1, value2, "auditTime");
return (Criteria) this;
}
public Criteria andRegistAmountIsNull() {
addCriterion("regist_amount is null");
return (Criteria) this;
}
public Criteria andRegistAmountIsNotNull() {
addCriterion("regist_amount is not null");
return (Criteria) this;
}
public Criteria andRegistAmountEqualTo(Integer value) {
addCriterion("regist_amount =", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountNotEqualTo(Integer value) {
addCriterion("regist_amount <>", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountGreaterThan(Integer value) {
addCriterion("regist_amount >", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountGreaterThanOrEqualTo(Integer value) {
addCriterion("regist_amount >=", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountLessThan(Integer value) {
addCriterion("regist_amount <", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountLessThanOrEqualTo(Integer value) {
addCriterion("regist_amount <=", value, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountIn(List<Integer> values) {
addCriterion("regist_amount in", values, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountNotIn(List<Integer> values) {
addCriterion("regist_amount not in", values, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountBetween(Integer value1, Integer value2) {
addCriterion("regist_amount between", value1, value2, "registAmount");
return (Criteria) this;
}
public Criteria andRegistAmountNotBetween(Integer value1, Integer value2) {
addCriterion("regist_amount not between", value1, value2, "registAmount");
return (Criteria) this;
}
public Criteria andCompanyLogoIsNull() {
addCriterion("company_logo is null");
return (Criteria) this;
}
public Criteria andCompanyLogoIsNotNull() {
addCriterion("company_logo is not null");
return (Criteria) this;
}
public Criteria andCompanyLogoEqualTo(String value) {
addCriterion("company_logo =", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoNotEqualTo(String value) {
addCriterion("company_logo <>", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoGreaterThan(String value) {
addCriterion("company_logo >", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoGreaterThanOrEqualTo(String value) {
addCriterion("company_logo >=", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoLessThan(String value) {
addCriterion("company_logo <", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoLessThanOrEqualTo(String value) {
addCriterion("company_logo <=", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoLike(String value) {
addCriterion("company_logo like", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoNotLike(String value) {
addCriterion("company_logo not like", value, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoIn(List<String> values) {
addCriterion("company_logo in", values, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoNotIn(List<String> values) {
addCriterion("company_logo not in", values, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoBetween(String value1, String value2) {
addCriterion("company_logo between", value1, value2, "companyLogo");
return (Criteria) this;
}
public Criteria andCompanyLogoNotBetween(String value1, String value2) {
addCriterion("company_logo not between", value1, value2, "companyLogo");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoIsNull() {
addCriterion("linkman_idcardfront_photo is null");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoIsNotNull() {
addCriterion("linkman_idcardfront_photo is not null");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoEqualTo(String value) {
addCriterion("linkman_idcardfront_photo =", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoNotEqualTo(String value) {
addCriterion("linkman_idcardfront_photo <>", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoGreaterThan(String value) {
addCriterion("linkman_idcardfront_photo >", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoGreaterThanOrEqualTo(String value) {
addCriterion("linkman_idcardfront_photo >=", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoLessThan(String value) {
addCriterion("linkman_idcardfront_photo <", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoLessThanOrEqualTo(String value) {
addCriterion("linkman_idcardfront_photo <=", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoLike(String value) {
addCriterion("linkman_idcardfront_photo like", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoNotLike(String value) {
addCriterion("linkman_idcardfront_photo not like", value, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoIn(List<String> values) {
addCriterion("linkman_idcardfront_photo in", values, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoNotIn(List<String> values) {
addCriterion("linkman_idcardfront_photo not in", values, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoBetween(String value1, String value2) {
addCriterion("linkman_idcardfront_photo between", value1, value2, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardfrontPhotoNotBetween(String value1, String value2) {
addCriterion("linkman_idcardfront_photo not between", value1, value2, "linkmanIdcardfrontPhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoIsNull() {
addCriterion("linkman_idcardbase_photo is null");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoIsNotNull() {
addCriterion("linkman_idcardbase_photo is not null");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoEqualTo(String value) {
addCriterion("linkman_idcardbase_photo =", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoNotEqualTo(String value) {
addCriterion("linkman_idcardbase_photo <>", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoGreaterThan(String value) {
addCriterion("linkman_idcardbase_photo >", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoGreaterThanOrEqualTo(String value) {
addCriterion("linkman_idcardbase_photo >=", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoLessThan(String value) {
addCriterion("linkman_idcardbase_photo <", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoLessThanOrEqualTo(String value) {
addCriterion("linkman_idcardbase_photo <=", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoLike(String value) {
addCriterion("linkman_idcardbase_photo like", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoNotLike(String value) {
addCriterion("linkman_idcardbase_photo not like", value, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoIn(List<String> values) {
addCriterion("linkman_idcardbase_photo in", values, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoNotIn(List<String> values) {
addCriterion("linkman_idcardbase_photo not in", values, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoBetween(String value1, String value2) {
addCriterion("linkman_idcardbase_photo between", value1, value2, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andLinkmanIdcardbasePhotoNotBetween(String value1, String value2) {
addCriterion("linkman_idcardbase_photo not between", value1, value2, "linkmanIdcardbasePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoIsNull() {
addCriterion("business_license_photo is null");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoIsNotNull() {
addCriterion("business_license_photo is not null");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoEqualTo(String value) {
addCriterion("business_license_photo =", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoNotEqualTo(String value) {
addCriterion("business_license_photo <>", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoGreaterThan(String value) {
addCriterion("business_license_photo >", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoGreaterThanOrEqualTo(String value) {
addCriterion("business_license_photo >=", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoLessThan(String value) {
addCriterion("business_license_photo <", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoLessThanOrEqualTo(String value) {
addCriterion("business_license_photo <=", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoLike(String value) {
addCriterion("business_license_photo like", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoNotLike(String value) {
addCriterion("business_license_photo not like", value, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoIn(List<String> values) {
addCriterion("business_license_photo in", values, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoNotIn(List<String> values) {
addCriterion("business_license_photo not in", values, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoBetween(String value1, String value2) {
addCriterion("business_license_photo between", value1, value2, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andBusinessLicensePhotoNotBetween(String value1, String value2) {
addCriterion("business_license_photo not between", value1, value2, "businessLicensePhoto");
return (Criteria) this;
}
public Criteria andEmailIsNull() {
addCriterion("email is null");
return (Criteria) this;
}
public Criteria andEmailIsNotNull() {
addCriterion("email is not null");
return (Criteria) this;
}
public Criteria andEmailEqualTo(String value) {
addCriterion("email =", value, "email");
return (Criteria) this;
}
public Criteria andEmailNotEqualTo(String value) {
addCriterion("email <>", value, "email");
return (Criteria) this;
}
public Criteria andEmailGreaterThan(String value) {
addCriterion("email >", value, "email");
return (Criteria) this;
}
public Criteria andEmailGreaterThanOrEqualTo(String value) {
addCriterion("email >=", value, "email");
return (Criteria) this;
}
public Criteria andEmailLessThan(String value) {
addCriterion("email <", value, "email");
return (Criteria) this;
}
public Criteria andEmailLessThanOrEqualTo(String value) {
addCriterion("email <=", value, "email");
return (Criteria) this;
}
public Criteria andEmailLike(String value) {
addCriterion("email like", value, "email");
return (Criteria) this;
}
public Criteria andEmailNotLike(String value) {
addCriterion("email not like", value, "email");
return (Criteria) this;
}
public Criteria andEmailIn(List<String> values) {
addCriterion("email in", values, "email");
return (Criteria) this;
}
public Criteria andEmailNotIn(List<String> values) {
addCriterion("email not in", values, "email");
return (Criteria) this;
}
public Criteria andEmailBetween(String value1, String value2) {
addCriterion("email between", value1, value2, "email");
return (Criteria) this;
}
public Criteria andEmailNotBetween(String value1, String value2) {
addCriterion("email not between", value1, value2, "email");
return (Criteria) this;
}
public Criteria andZipCodeIsNull() {
addCriterion("zip_code is null");
return (Criteria) this;
}
public Criteria andZipCodeIsNotNull() {
addCriterion("zip_code is not null");
return (Criteria) this;
}
public Criteria andZipCodeEqualTo(String value) {
addCriterion("zip_code =", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeNotEqualTo(String value) {
addCriterion("zip_code <>", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeGreaterThan(String value) {
addCriterion("zip_code >", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeGreaterThanOrEqualTo(String value) {
addCriterion("zip_code >=", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeLessThan(String value) {
addCriterion("zip_code <", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeLessThanOrEqualTo(String value) {
addCriterion("zip_code <=", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeLike(String value) {
addCriterion("zip_code like", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeNotLike(String value) {
addCriterion("zip_code not like", value, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeIn(List<String> values) {
addCriterion("zip_code in", values, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeNotIn(List<String> values) {
addCriterion("zip_code not in", values, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeBetween(String value1, String value2) {
addCriterion("zip_code between", value1, value2, "zipCode");
return (Criteria) this;
}
public Criteria andZipCodeNotBetween(String value1, String value2) {
addCriterion("zip_code not between", value1, value2, "zipCode");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table merchant
*
* @mbg.generated do_not_delete_during_merge
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table merchant
*
* @mbg.generated
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | [
"[email protected]"
]
| |
638afedcfa06d94663035e2023c688e132580158 | 5777cd743cc25e7a9a54153053654715973f8e5c | /src/hdfs/DataNode.java | e952398e69f96c4d1cb35f06b2f1fde58ff4545c | [
"MIT"
]
| permissive | leovct/hidoop | 248f81250f5d050de2737162daa2637143893ef0 | 9ea2fe98fee0823b381b9964c3715fc03f6c25f4 | refs/heads/master | 2022-08-27T07:56:13.551161 | 2020-05-21T17:37:43 | 2020-05-21T17:37:43 | 266,290,918 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 511 | java | package hdfs;
import java.rmi.Remote;
import java.rmi.RemoteException;
import config.SettingsManager.Command;
/**
* Server NameNode interface
*
*/
public interface DataNode extends Remote {
/**
* Initiate opening of a TCP connection with the NameNode
* to write a chunk on the server.
* @param command
* @param fileName
* @param chunkNumber
* @return port number to send data on
*/
public int processChunk(Command command, String fileName, int chunkNumber) throws RemoteException;
} | [
"[email protected]"
]
| |
40fa17645b5a69d84fa82c0269188ffebe37a02b | b4cc861bf70792e1e587efe827dfdb0157442e95 | /mcp62/src/minecraft/net/minecraft/src/ItemSaddle.java | 5cd261bf39f26c2ca362958e00c7b9d85ae9b8bb | []
| no_license | popnob/ooptest | 8c61729343bf0ed113c3038b5a0f681387805ef7 | 856b396adfe5bb3a2dbdca0e22ea724776d2ce8a | refs/heads/master | 2021-01-23T08:04:35.318303 | 2012-05-30T18:05:25 | 2012-05-30T18:05:25 | 4,483,121 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,031 | java | package net.minecraft.src;
public class ItemSaddle extends Item
{
public ItemSaddle(int par1)
{
super(par1);
maxStackSize = 1;
}
/**
* Called when a player right clicks a entity with a item.
*/
public void useItemOnEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving)
{
if (par2EntityLiving instanceof EntityPig)
{
EntityPig entitypig = (EntityPig)par2EntityLiving;
if (!entitypig.getSaddled() && !entitypig.isChild())
{
entitypig.setSaddled(true);
par1ItemStack.stackSize--;
}
}
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
useItemOnEntity(par1ItemStack, par2EntityLiving);
return true;
}
}
| [
"[email protected]"
]
| |
4b351f6369b86f5fa322ff9e23fbfd35bba199e6 | d497b9da11dc358e55c5a4edf46ca41a2d20c141 | /src/main/java/com/sk/skumar/exception/CustomizedResponseEntityExceptionHandler.java | c96ca0234fc1b7fabc1791301be5845baadd963b | []
| no_license | itssanjeet/skumar | abc1821fdc37d0ea859745a528757cb79e1d4524 | 15245006c32fd3b3cd105d81736419718dcddb8e | refs/heads/master | 2022-04-19T16:36:08.305472 | 2020-04-23T17:22:44 | 2020-04-23T17:22:44 | 258,277,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,924 | java | package com.sk.skumar.exception;
import java.time.LocalTime;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import com.sk.skumar.model.UserNotFoundException;
@ControllerAdvice
@RestController
public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(Exception.class)
public final ResponseEntity<Object> handleAllException(Exception ex, WebRequest request) throws Exception {
ExceptionResponse exceptionResponse = new ExceptionResponse(LocalTime.now(), ex.getMessage(),
request.getDescription(false));
return new ResponseEntity<Object>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR);
}
@ExceptionHandler(UserNotFoundException.class)
public final ResponseEntity<Object> handleUserNotFountException(UserNotFoundException e, WebRequest req)
throws Exception {
ExceptionResponse res = new ExceptionResponse(LocalTime.now(), e.getMessage(), req.getDescription(false));
return new ResponseEntity<Object>(res, HttpStatus.NOT_FOUND);
}
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
HttpHeaders headers, HttpStatus status, WebRequest request) {
ExceptionResponse res = new ExceptionResponse(LocalTime.now(), "Validation Failed", ex.getBindingResult().toString());
return new ResponseEntity(res, HttpStatus.BAD_REQUEST);
}
}
| [
"[email protected]"
]
| |
b788afc0dd6e9b6037f1bbce7d63f8f57d358d26 | 3647f3da5e8348d5449e2e6f7575a99a2b244849 | /sday26_Net็ฝ็ป็ผ็จ/src/demo13_TCP_ไธไผ ๅพ็/UploadServer.java | 91ca7067183767f686646bbf8d6e3c12136ad99a | []
| no_license | NianDUI/chuanzhi | f3f04b5da5c15797a9134846b1d20013363e853d | 9d4a60b14801ee1483ddade080cf059a4037eacb | refs/heads/master | 2022-07-02T01:14:07.768575 | 2019-11-24T12:45:15 | 2019-11-24T12:45:15 | 223,742,493 | 0 | 0 | null | 2022-06-21T02:18:19 | 2019-11-24T12:43:30 | Java | GB18030 | Java | false | false | 1,017 | java | package demo13_TCP_ไธไผ ๅพ็;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class UploadServer {
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
// ๅๅปบๆๅกๅจSocketๅฏน่ฑก
ServerSocket ss = new ServerSocket(19191);
// ็ๅฌๅฎขๆท็ซฏ่ฟๆฅ
Socket s = ss.accept();
// ๅฐ่ฃ
้้ๅ
็ๆต
BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
// ๅฐ่ฃ
ๅพ็ๆไปถ
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("13.jpg"));
byte[] bys = new byte[1024];
int len = 0;
while ((len = bis.read(bys)) != -1) {
bos.write(bys, 0, len);
bos.flush();
}
// ็ปไธไธชๅ้ฆ
OutputStream os = s.getOutputStream();
os.write("ๅพ็ไธไผ ๆๅ".getBytes());
// ้ๆพ่ตๆบ
bos.close();
s.close();
}
}
| [
"[email protected]"
]
| |
3e71c8c55c15b119df682f1b9c0492aa0922cec0 | 13a8b15b372fe633a813bb58b2479fdd82984e82 | /cliente-servidor/Proyecto Cliente/ClienteServidor/ClienteServidor-war/src/java/clienteservidorwar/AgregarLocalidades.java | f0ae0f2821f50d45c3361b42b3b7a14d39190465 | []
| no_license | justomiguel/cliente-servidor-2010-llrv | 11a4f90bbeb7d2c29fdd712d6ffc0f182c506635 | 7cbfdf55fe5165c31d19391d90a74068dd96681e | refs/heads/master | 2020-05-17T12:03:57.331778 | 2010-06-24T08:27:14 | 2010-06-24T08:27:14 | 32,338,186 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,067 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clienteservidorwar;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.TextField;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.FacesException;
import javax.naming.NamingException;
import servers.ServerLocator;
import sessionbeans.LocalidadesFacadeRemote;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @version AgregarLocalidades.java
* @version Created on 15/06/2010, 14:20:16
* @author justomiguel
*/
public class AgregarLocalidades extends AbstractPageBean {
@EJB
private LocalidadesFacadeRemote localidades;
ServerLocator sl = new ServerLocator();
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
private TextField textField3 = new TextField();
public TextField getTextField3() {
return textField3;
}
public void setTextField3(TextField tf) {
this.textField3 = tf;
}
private TextField textField4 = new TextField();
public TextField getTextField4() {
return textField4;
}
public void setTextField4(TextField tf) {
this.textField4 = tf;
}
private Button button1 = new Button();
public Button getButton1() {
return button1;
}
public void setButton1(Button b) {
this.button1 = b;
}
private TextField textField1 = new TextField();
public TextField getTextField1() {
return textField1;
}
public void setTextField1(TextField tf) {
this.textField1 = tf;
}
private TextField textField2 = new TextField();
public TextField getTextField2() {
return textField2;
}
public void setTextField2(TextField tf) {
this.textField2 = tf;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public AgregarLocalidades() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("AgregarLocalidades Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
public String button1_action() {
/* try {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
/ localidades = sl.getLocalidadesFacadeRemote();
if (localidades.create(Integer.parseInt(textField1.getText().toString()), textField2.getText().toString(), Integer.parseInt(textField3.getText().toString()), Integer.parseInt(textField4.getText().toString()))){
return "exito";
}
} catch (NamingException ex) {
Logger.getLogger(AgregarLocalidades.class.getName()).log(Level.SEVERE, null, ex);
}
return "error";
*/
return null;
}
}
| [
"justomiguelvargas@eae7dd4b-1923-17d8-35f5-50c50db34f77"
]
| justomiguelvargas@eae7dd4b-1923-17d8-35f5-50c50db34f77 |
ae2902b84242876bb268d8d956ba2cfa7cfb8679 | fe37b85959de85e4fc3609c0e4e6981058bbbaeb | /Spring06/src/aop01/Boy.java | a7511974115c79e4b0d939193dac5452eb67b25b | []
| no_license | JeonHyeonJun/Spring | d8cb5937c1ba1e04d0437fdf5bd51e4c55f26092 | d359e1d5e7c7a548cd2697182e28c4fb0583674a | refs/heads/master | 2021-01-22T22:21:13.345854 | 2017-06-11T02:41:06 | 2017-06-11T02:41:06 | 85,535,629 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 428 | java | package aop01;
import java.util.Random;
//์ธํฐํ์ด์ค ๊ธฐ๋ฅ๊ตฌํ ํด๋์ค
public class Boy implements IPerson{
@Override
public String doSomething() {
// TODO Auto-generated method stub
System.out.println("์ฝคํจํ๋ก ๊ฒ์์ ํ๋ค");
if(new Random().nextBoolean()) //true์ false ์ค ๋๋ค ํ๊ฒ ๋์ด
throw new FireException("ํ์ฌ๋ฐ์!");
return "I am a boy";
}
}
| [
"[email protected]"
]
| |
365f9c7d66dfb1c3f499ce320402603995f7335e | 946e853c88517e7a89e785ef91b8e5a782854e46 | /contribs/taxi/src/main/java/org/matsim/contrib/taxi/util/stats/TimeProfileCollector.java | 5f5274f21bd7c099e2fc772d26c56588917464c4 | [
"LicenseRef-scancode-warranty-disclaimer"
]
| no_license | strawrange/matsim | 75922dd23ed8ed1ad54dc16e03e6a0bfe7f7c17e | 8a37ba8e22cebab0df6de2ab8e336735ed93dabe | refs/heads/master | 2020-06-18T02:03:06.435016 | 2017-11-17T00:19:38 | 2017-11-17T00:19:38 | 74,963,647 | 1 | 0 | null | 2016-11-28T10:48:36 | 2016-11-28T10:48:36 | null | UTF-8 | Java | false | false | 4,651 | java | /* *********************************************************************** *
* project: org.matsim.*
* *
* *********************************************************************** *
* *
* copyright : (C) 2015 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 org.matsim.contrib.taxi.util.stats;
import java.util.*;
import org.jfree.chart.JFreeChart;
import org.matsim.contrib.taxi.util.stats.TimeProfileCharts.*;
import org.matsim.contrib.util.CompactCSVWriter;
import org.matsim.contrib.util.chart.ChartSaveUtils;
import org.matsim.core.controler.MatsimServices;
import org.matsim.core.mobsim.framework.events.*;
import org.matsim.core.mobsim.framework.listeners.*;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.core.utils.misc.Time;
public class TimeProfileCollector
implements MobsimBeforeSimStepListener, MobsimBeforeCleanupListener
{
public interface ProfileCalculator
{
String[] getHeader();
String[] calcValues();
}
private final ProfileCalculator calculator;
private final List<Double> times = new ArrayList<>();
private final List<String[]> timeProfile = new ArrayList<>();
private final int interval;
private final String outputFile;
private final MatsimServices matsimServices;
private Customizer chartCustomizer;
private ChartType[] chartTypes = { ChartType.Line };
public TimeProfileCollector(ProfileCalculator calculator, int interval, String outputFile,
MatsimServices matsimServices)
{
this.calculator = calculator;
this.interval = interval;
this.outputFile = outputFile;
this.matsimServices = matsimServices;
}
@Override
public void notifyMobsimBeforeSimStep(@SuppressWarnings("rawtypes") MobsimBeforeSimStepEvent e)
{
if (e.getSimulationTime() % interval == 0) {
times.add(e.getSimulationTime());
timeProfile.add(calculator.calcValues());
}
}
public void setChartCustomizer(TimeProfileCharts.Customizer chartCustomizer)
{
this.chartCustomizer = chartCustomizer;
}
public void setChartTypes(ChartType... chartTypes)
{
this.chartTypes = chartTypes;
}
@Override
public void notifyMobsimBeforeCleanup(@SuppressWarnings("rawtypes") MobsimBeforeCleanupEvent e)
{
String file = matsimServices.getControlerIO()
.getIterationFilename(matsimServices.getIterationNumber(), outputFile);
String timeFormat = interval % 60 == 0 ? Time.TIMEFORMAT_HHMM : Time.TIMEFORMAT_HHMMSS;
try (CompactCSVWriter writer = new CompactCSVWriter(
IOUtils.getBufferedWriter(file + ".txt"))) {
writer.writeNext("time", calculator.getHeader());
for (int i = 0; i < timeProfile.size(); i++) {
writer.writeNext(Time.writeTime(times.get(i), timeFormat), timeProfile.get(i));
}
}
for (ChartType t : chartTypes) {
generateImage(t);
}
}
private void generateImage(ChartType chartType)
{
JFreeChart chart = TimeProfileCharts.chartProfile(calculator.getHeader(), times,
timeProfile, chartType);
if (chartCustomizer != null) {
chartCustomizer.customize(chart, chartType);
}
String imageFile = matsimServices.getControlerIO().getIterationFilename(
matsimServices.getIterationNumber(), outputFile + "_" + chartType.name());
ChartSaveUtils.saveAsPNG(chart, imageFile, 1500, 1000);
}
}
| [
"[email protected]"
]
| |
e8c4bd62e7ffc7c37c5db9d573ab29ce574dc7d0 | 2e98a3f4610e2861befb41e7e42375ede0ba1e80 | /src/com/vimukti/accounter/text/commands/reports/AutomaticTransactionsReportCommand.java | 3c22e936ed29fe04010cb58074bc5e3695354f70 | [
"Apache-2.0"
]
| permissive | kisorbiswal/accounter | 6eefd17d7973132469455d4a5d6b4c2b0a7ec9b3 | 7ef60c1d18892db72cedca411c143e377c379808 | refs/heads/master | 2021-01-20T16:34:35.511251 | 2015-10-20T09:57:42 | 2015-10-20T09:57:42 | 44,603,239 | 0 | 1 | null | 2015-10-20T11:59:08 | 2015-10-20T11:59:08 | null | UTF-8 | Java | false | false | 314 | java | package com.vimukti.accounter.text.commands.reports;
import com.vimukti.accounter.text.commands.AbstractReportCommand;
public class AutomaticTransactionsReportCommand extends AbstractReportCommand {
@Override
public int getReportType() {
return ReportTypeConstants.REPORT_TYPE_AUTOMATIC_TRANSACTIONS;
}
}
| [
"[email protected]"
]
| |
2d7a149620c661afd4dc3a4d30ca2e68e088a9db | 121e1904ee2a88e1dcd75a23bd67024231544ef9 | /src/util/LogWriter.java | 22ce1de50e8bcc839058a4ca127cf439af922487 | []
| no_license | 87980715/ArbitrageTrader | 88af8c770ea932651faa3f621b1bf10614d1571a | 1d1fb46ea650af70ba7178e87a3bfaab31663144 | refs/heads/master | 2020-04-10T21:00:06.654637 | 2017-09-19T07:32:55 | 2017-09-19T07:32:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,636 | java | package util;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
public class LogWriter extends PrintWriter {
private boolean writeToFile;
private boolean hasWritten = false;
private String data = "";
public LogWriter(String fileName) throws FileNotFoundException {
super(fileName);
writeToFile = true;
}
public LogWriter(String fileName, boolean writeToFile) throws FileNotFoundException {
super(fileName);
this.writeToFile = writeToFile;
}
/**
* Adds <code>"\n"</code> to the data to be written
*/
public void writeln() {
write("\n");
}
/**
* Adds <code>s + "\n"</code> to the data to be written
* @param s
*/
public void writeln(String s) {
write(s + "\n");
}
/**
* Adds <code>s</code> to the data to be written
* @param s
*/
public void write(String s) {
data += s;
hasWritten = true;
}
/**
* @return true if any data was written this iteration
*/
public boolean hasWritten() {
return hasWritten;
}
/**
* If any data was added this iteration, write it
* @param count
*/
public void postIteration(int count) {
if(writeToFile && hasWritten) {
super.write("###################################################\n");
super.write("Iteration " + count + " START\n");
super.write(General.getPrettyDate() + "\n");
super.write("###################################################\n");
super.write(data + "\n");
super.write("Iteration " + count + " END\n");
super.write("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
super.write("\n");
flush();
}
hasWritten = false;
data = "";
}
}
| [
"[email protected]"
]
| |
592bae79b54046ab7885aeb272382c4728627314 | 2cc07bcfe83bc6028d8c780cdff9f753fc274153 | /android/MyPackageReplacedEventReceiver.java | da293b1a05f1e3bc27faf0b62c14999d02eb1ece | [
"Apache-2.0"
]
| permissive | odai-alali/cordova-plugin-kiosk | 6e7a3eb29eabceb63a84fd2164a447b69207b1ae | bdd03dd5b56432cbff023246454c262ae572a902 | refs/heads/master | 2021-04-28T10:47:11.953796 | 2018-02-19T14:45:50 | 2018-02-19T14:45:50 | 122,074,652 | 0 | 0 | null | 2018-02-19T14:34:06 | 2018-02-19T14:34:06 | null | UTF-8 | Java | false | false | 532 | java | package jk.cordova.plugin.kiosk;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Starts {@link HomeActivity} after the app APK is updated.
*/
public class MyPackageReplacedEventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent newIntent = new Intent(context, HomeActivity.class);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
}
}
| [
"[email protected]"
]
| |
f7bdb9603b9d57095f244388e5488a20178a24ef | 57cef4280f4976ce46435ed67240bcc98a7a0c7c | /src/main/java/netcracker/Master.java | 9d3f9ba83badd30236381ab0e5778bf32d0c779e | []
| no_license | RazuvaevDenis/ContrLab | b2434d09dee77f58ea6f090cd4ab84ca16c3a7db | f4f25f1697281f8bf0bd8207c75a5164d48da164 | refs/heads/master | 2021-01-10T16:15:50.143828 | 2015-12-15T11:07:30 | 2015-12-15T11:07:30 | 48,037,555 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,809 | java | package netcracker;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;
/**
* Created by Denis on 14.12.2015.
*/
public class Master implements Runnable {
private Car current_car;
private Service service;
public static final Logger log=Logger.getLogger(Master.class.getName());
public Master(Service service){
this.service=service;
}
public void setCurrent_car(Car current_car){
this.current_car=current_car;
}
public void XMLCreate(Car car){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
Document doc = factory.newDocumentBuilder().newDocument();
Element root = doc.createElement(car.getMark());
doc.appendChild(root);
Element item1 = doc.createElement("Name");
item1.setTextContent(car.getName());
root.appendChild(item1);
Element item2 = doc.createElement("Owner");
item2.setTextContent(car.getOwner());
root.appendChild(item2);
Element item3 = doc.createElement("Handling_time");
item3.setTextContent(Integer.toString(car.getHandling_time()));
root.appendChild(item3);
File path=new File("xml");
if (!path.exists()) {
path.mkdir();
}
File file = new File("xml/NewXML"+car.getName()+ car.getOwner()+".xml");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(doc), new StreamResult(file));
} catch (ParserConfigurationException e) {
log.log(Level.ERROR,"Error." + e.getMessage(), e);
} catch (TransformerConfigurationException e) {
log.log(Level.ERROR,"Error." + e.getMessage(), e);
} catch (TransformerException e) {
log.log(Level.ERROR,"Error." + e.getMessage(), e);
}
}
public void ConnectionDB(Car car){
String url = "jdbc:mysql://localhost:3306/jdbc";
Properties property = new Properties();
try (FileInputStream fis = new FileInputStream("src/main/resources/jdbc.properties")){
property.load(fis);
} catch (IOException e) {
log.log(Level.ERROR,"Error." + e.getMessage(), e);
}
try (Connection connection = DriverManager.getConnection(url, property);
Statement st=connection.createStatement();
PreparedStatement pst=connection.prepareStatement("insert into " +car.getMark()+ "(name,owner,handling_time) VALUES(?,?,?)")) {
Class.forName("com.mysql.jdbc.Driver");
st.execute("create table if not exists "+car.getMark()+
"(car_id int(7) not null auto_increment, name varchar(1000) not null, owner varchar(1000) not null," +
"handling_time int(10) not null, constraint "+car.getMark()+"_id_pk primary key(car_id))");
pst.setString(1, car.getName());
pst.setString(2,car.getOwner());
pst.setInt(3,car.getHandling_time());
pst.executeUpdate();
pst.execute("commit");
} catch (SQLException e) {
log.log(Level.ERROR,"Error with error code " + e.getErrorCode()+"." + e.getMessage(),e);
} catch (ClassNotFoundException e) {
log.log(Level.ERROR,"Error." + e.getMessage(),e);
}
}
@Override
public void run() {
while(true){
Car car=service.Pop();
try {
Thread.sleep(car.getHandling_time());
switch(car.getType_of_record()){
case Car.CONSOLETYPE:
log.log(Level.INFO, "Car repaired - " + car.getMark() + " " + car.getName() + " " + car.getOwner());
break;
case Car.DBTYPE:
ConnectionDB(car);
case Car.XMLTYPE:
XMLCreate(car);
}
} catch (InterruptedException e) {
log.log(Level.ERROR,"Error" + e.getMessage(),e);
}
}
}
}
| [
"[email protected]"
]
| |
99a808c730aebaae134fa19a8c4ebd859e297211 | a4ea6f4ccd064f0a3b074438320fb88f739962dc | /mangooa-project/mangooa-rocketmq/src/main/java/com/mangooa/rocketmq/Message.java | 47f410b750149521517bd9af479edcb0270b09bf | [
"Apache-2.0"
]
| permissive | mangooa/mangooa | 1f38870f3fdff705512eebd797302ae4d03d916b | eb7b94e0ee14f1328af2d0c1c1b6e36ab4c631bf | refs/heads/main | 2023-03-08T07:50:32.620041 | 2021-02-17T23:44:24 | 2021-02-17T23:44:24 | 327,538,994 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 109 | java | package com.mangooa.rocketmq;
/**
* @author Weimin Gao
* @since 1.0.0
**/
public @interface Message {
}
| [
"[email protected]"
]
| |
297636cd0b572e086ac6c102bbdbd15824ab12cb | 573a66e4f4753cc0f145de8d60340b4dd6206607 | /JS-CS-Detection-byExample/Dataset (ALERT 5 GB)/3664240/rootbeer1-1.2.3/src/org/trifort/rootbeer/testcases/rootbeertest/canonical2/CanonicalArrays.java | 8d59b890d9f4071025560571f35d63f11a79368e | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
]
| permissive | mkaouer/Code-Smells-Detection-in-JavaScript | 3919ec0d445637a7f7c5f570c724082d42248e1b | 7130351703e19347884f95ce6d6ab1fb4f5cfbff | refs/heads/master | 2023-03-09T18:04:26.971934 | 2022-03-23T22:04:28 | 2022-03-23T22:04:28 | 73,915,037 | 8 | 3 | null | 2023-02-28T23:00:07 | 2016-11-16T11:47:44 | null | UTF-8 | Java | false | false | 659 | java | package org.trifort.rootbeer.testcases.rootbeertest.canonical2;
class CanonicalArrays {
private float[][] floatArray;
private float arraySum;
public CanonicalArrays(){
floatArray = new float[2][];
for(int i = 0; i < 2; ++i){
floatArray[i] = new float[2];
for(int j = 0; j < 2; ++j){
floatArray[i][j] = i * 2 + j;
}
}
}
public void sum(){
arraySum = 0;
for(int i = 0; i < floatArray.length; ++i){
for(int j = 0; j < floatArray[i].length; ++j){
arraySum += floatArray[i][j];
}
}
}
public float getResult(){
synchronized(this){
return arraySum;
}
}
}
| [
"[email protected]"
]
| |
9ea866c19e18b51646eb7fbc216bff1317bb2342 | 157d2ef1f40203d1e446f096e820185ae6e4f106 | /beige-uml-swing/src/main/java/org/beigesoft/uml/factory/awt/FactoryAsmUseCaseFullLight.java | 1b76036b69e36b606116e60d9d9c57fdc58c9206 | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
]
| permissive | demidenko05/beige-uml | e87b922140d207740ea8f01daf201a3410fcc18e | 48bfbe5b100853815032af639b32da30957305af | refs/heads/master | 2023-03-17T00:37:17.463163 | 2020-10-13T11:05:30 | 2020-10-13T11:05:30 | 47,434,951 | 1 | 1 | Apache-2.0 | 2020-10-13T07:23:41 | 2015-12-05T00:01:40 | Java | UTF-8 | Java | false | false | 4,793 | java | package org.beigesoft.uml.factory.awt;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Image;
import org.beigesoft.graphic.pojo.SettingsDraw;
import org.beigesoft.graphic.service.ISrvDraw;
import org.beigesoft.service.ISrvI18n;
import org.beigesoft.ui.service.ISrvDialog;
import org.beigesoft.uml.app.model.SettingsGraphicUml;
import org.beigesoft.uml.assembly.AsmElementUmlInteractive;
import org.beigesoft.uml.assembly.IAsmElementUmlInteractive;
import org.beigesoft.uml.assembly.ShapeFullVarious;
import org.beigesoft.uml.factory.IFactoryAsmElementUml;
import org.beigesoft.uml.factory.swing.FactoryEditorUseCaseFull;
import org.beigesoft.uml.pojo.UseCase;
import org.beigesoft.uml.service.graphic.SrvGraphicUseCase;
import org.beigesoft.uml.service.graphic.SrvGraphicShapeFull;
import org.beigesoft.uml.service.interactive.SrvInteractiveShapeVariousFull;
import org.beigesoft.uml.service.interactive.SrvInteractiveUseCase;
import org.beigesoft.uml.service.persist.xmllight.FileAndWriter;
import org.beigesoft.uml.service.persist.xmllight.SrvPersistLightXmlShapeFull;
import org.beigesoft.uml.service.persist.xmllight.SrvPersistLightXmlUseCase;
public class FactoryAsmUseCaseFullLight implements IFactoryAsmElementUml<IAsmElementUmlInteractive<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, FileAndWriter>, Graphics2D, SettingsDraw, FileAndWriter, ShapeFullVarious<UseCase>> {
private final ISrvDraw<Graphics2D, SettingsDraw, Image> srvDraw;
private final SettingsGraphicUml settingsGraphic;
private final FactoryEditorUseCaseFull factoryEditorUseCaseUmlFull;
private final SrvGraphicShapeFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, UseCase> srvGraphicUseCaseUmlFull;
private final SrvPersistLightXmlShapeFull<ShapeFullVarious<UseCase>, UseCase> srvPersistUseCaseUmlFull;
private final SrvInteractiveShapeVariousFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, Frame, UseCase> srvInteractiveUseCaseUmlFull;
public FactoryAsmUseCaseFullLight(ISrvDraw<Graphics2D, SettingsDraw, Image> srvDraw,
ISrvI18n srvI18n, ISrvDialog<Frame> srvDialog, SettingsGraphicUml settingsGraphic,
Frame frameMain) {
this.srvDraw = srvDraw;
this.settingsGraphic = settingsGraphic;
factoryEditorUseCaseUmlFull = new FactoryEditorUseCaseFull(srvI18n, srvDialog, settingsGraphic, frameMain);
SrvPersistLightXmlUseCase<UseCase> srvPersistUseCaseUml = new SrvPersistLightXmlUseCase<UseCase>();
srvPersistUseCaseUmlFull = new SrvPersistLightXmlShapeFull<ShapeFullVarious<UseCase>, UseCase>(srvPersistUseCaseUml);
SrvGraphicUseCase<UseCase, Graphics2D, SettingsDraw> srvGraphicUseCaseUml = new SrvGraphicUseCase<UseCase, Graphics2D, SettingsDraw>(srvDraw, settingsGraphic);
srvGraphicUseCaseUmlFull = new SrvGraphicShapeFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, UseCase>(srvGraphicUseCaseUml);
SrvInteractiveUseCase<UseCase, Graphics2D, SettingsDraw> srvInteractiveUseCaseUml = new SrvInteractiveUseCase<UseCase, Graphics2D, SettingsDraw>(srvGraphicUseCaseUml);
srvInteractiveUseCaseUmlFull = new SrvInteractiveShapeVariousFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, Frame, UseCase>(factoryEditorUseCaseUmlFull, srvInteractiveUseCaseUml);
}
@Override
public IAsmElementUmlInteractive<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, FileAndWriter> createAsmElementUml() {
SettingsDraw drawSettings = new SettingsDraw();
UseCase useCaseUml = new UseCase();
ShapeFullVarious<UseCase> useCaseUmlFull = new ShapeFullVarious<UseCase>();
useCaseUmlFull.setShape(useCaseUml);
AsmElementUmlInteractive<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, FileAndWriter> asmUseCase =
new AsmElementUmlInteractive<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, FileAndWriter>(useCaseUmlFull,
drawSettings, srvGraphicUseCaseUmlFull, srvPersistUseCaseUmlFull, srvInteractiveUseCaseUmlFull);
return asmUseCase;
}
//SGS:
public ISrvDraw<Graphics2D, SettingsDraw, Image> getSrvDraw() {
return srvDraw;
}
public SettingsGraphicUml getSettingsGraphic() {
return settingsGraphic;
}
public FactoryEditorUseCaseFull getFactoryEditorUseCaseUmlFull() {
return factoryEditorUseCaseUmlFull;
}
public SrvGraphicShapeFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, UseCase> getSrvGraphicUseCaseUmlFull() {
return srvGraphicUseCaseUmlFull;
}
public SrvPersistLightXmlShapeFull<ShapeFullVarious<UseCase>, UseCase> getSrvPersistUseCaseUmlFull() {
return srvPersistUseCaseUmlFull;
}
public SrvInteractiveShapeVariousFull<ShapeFullVarious<UseCase>, Graphics2D, SettingsDraw, Frame, UseCase> getSrvInteractiveUseCaseUmlFull() {
return srvInteractiveUseCaseUmlFull;
}
}
| [
"[email protected]"
]
| |
36b4283136f8005624dae1db0f262389a4b0ca7f | 44ce5c342e283ab8fcddbeb0a4dc323546f438a9 | /safepay-pay-web-boss/src/main/java/com/safepay/pay/permission/enums/OperatorTypeEnum.java | 779edd0fd9f12d0cbe47cfde95ec4a2b70870577 | []
| no_license | zhilangtaosha/safepay | e378fb7a614d3d14e0b9f6f7afe4d203468a151a | a05d5f79d806352a129bce99f86433b4493b296e | refs/heads/master | 2021-07-09T22:12:42.726806 | 2017-10-11T04:54:31 | 2017-10-11T04:54:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,333 | java | /*
* Copyright 2015-2102 .
*
* 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.safepay.pay.permission.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* ๆไฝๅ็ฑปๅ
*
* safepay
*
* @author๏ผshenjialong
*/
public enum OperatorTypeEnum {
/** ๆฎ้็จๆท **/
USER("ๆฎ้็จๆท"),
/** ่ถ
็บง็ฎก็ๅ **/
ADMIN("่ถ
็บง็ฎก็ๅ");
/** ๆ่ฟฐ */
private String desc;
private OperatorTypeEnum(String desc) {
this.desc = desc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public static OperatorTypeEnum getEnum(String value) {
OperatorTypeEnum resultEnum = null;
OperatorTypeEnum[] enumAry = OperatorTypeEnum.values();
for (int i = 0; i < enumAry.length; i++) {
if (enumAry[i].name().equals(value)) {
resultEnum = enumAry[i];
break;
}
}
return resultEnum;
}
public static Map<String, Map<String, Object>> toMap() {
OperatorTypeEnum[] ary = OperatorTypeEnum.values();
Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
for (int num = 0; num < ary.length; num++) {
Map<String, Object> map = new HashMap<String, Object>();
String key = String.valueOf(getEnum(ary[num].name()));
map.put("value", ary[num].name());
map.put("desc", ary[num].getDesc());
enumMap.put(key, map);
}
return enumMap;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List toList() {
OperatorTypeEnum[] ary = OperatorTypeEnum.values();
List list = new ArrayList();
for (int i = 0; i < ary.length; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put("value", ary[i].name());
map.put("desc", ary[i].getDesc());
list.add(map);
}
return list;
}
}
| [
"[email protected]"
]
| |
40347767e7b6a61ea246439e936ba3fddfacb92d | 0dfba369a438de167d03d86220bdec70373bda67 | /java/data structure/ds/src/dsTest/LinkedList.java | 4a59eb0099234047d95622841fd90ad98eec9fc7 | []
| no_license | kwoneunyoung/study | 7e9dbf3f98814a6a375d192fe20129e07787845c | 2a7b3525fb137237b1d165ab1e426f87efff5aa5 | refs/heads/main | 2023-06-14T16:59:40.417302 | 2021-07-08T12:22:24 | 2021-07-08T12:22:24 | 325,193,752 | 0 | 1 | null | null | null | null | UHC | Java | false | false | 1,483 | java | package dsTest;
public class LinkedList {
private Node head;
private Node tail;
private int size = 0; // ๋ช๊ฐ์ element๊ฐ ๋ด๊ฒจ ์๋๊ฐ?
private class Node { //inner class ์ฌ์ฉ
private Object data; //๊ฐ๊ฐ์ ๋
ธ๋๊ฐ ์ ์ฅํ ๋ฐ์ดํฐ
private Node next; //๋๊ฐ ๋ค์ ๋
ธ๋์ธ๊ฐ?
public Node(Object input) { //input : ๋
ธ๋๊ฐ ์ฒ์ ์์ฑ ๋์ ๋ ๋ค์ด์ค๋ ๊ฐ์ด input์ด๋ผ๋ ๋งค๊ฐ๋ณ์์ ๋ค์ด์ด
this.data = input;
this.next = null;
}
public String toString() {
return String.valueOf(this.data);
}
}
public void addFirst(Object input) {
Node newNode = new Node(input);
newNode.next = head;
head = newNode;
size++;
if(head.next == null) { //head์ next๊ฐ ์กด์ฌํ์ง ์๋๋ค๋ฉด ๋ง์ง๋ง ๋
ธ๋๋ ํค๋์๊ฐ๋ค
tail = head;
}
}
public void addLast(Object input) {
Node newNode = new Node(input);
if(size == 0) { //๋ฐ์ดํฐ๊ฐ ์๋ ์ํ๋ผ๋ฉด
addFirst(input);
} else { //๋ฐ์ดํฐ๊ฐ ์๋ ์ํ๋ผ๋ฉด
tail.next = newNode;
tail = newNode;
size++;
}
}
public String toString() {
if(head == null) {
return "[]";
}
Node temp = head;
String str = "[";
while(temp.next != null) {
str += temp.data + ", ";
temp = temp.next;
}
str += temp.data;
return str+"]";
}
public Object removeFirst() {
Node temp = head;
head = head.next;
Object returnData = temp.data;
temp = null;
size--;
return returnData;
}
}
| [
"[email protected]"
]
| |
cce12c3476b92a358296a109a48a8b87900d2222 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/20/20_6c10b8ac647a92df8ebbce7c10e4a35b2bef30e1/I2PBote/20_6c10b8ac647a92df8ebbce7c10e4a35b2bef30e1_I2PBote_t.java | 081ee7af0b0d8e26550a82d264426d937a59e93e | []
| no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 27,852 | java | /**
* Copyright (C) 2009 [email protected]
*
* The GPG fingerprint for [email protected] is:
* 6DD3 EAA2 9990 29BC 4AD2 7486 1E2C 7B61 76DC DC12
*
* This file is part of I2P-Bote.
* I2P-Bote is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* I2P-Bote is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with I2P-Bote. If not, see <http://www.gnu.org/licenses/>.
*/
package i2p.bote;
import static i2p.bote.Util._;
import i2p.bote.addressbook.AddressBook;
import i2p.bote.email.Email;
import i2p.bote.email.EmailIdentity;
import i2p.bote.email.Identities;
import i2p.bote.fileencryption.DerivedKey;
import i2p.bote.fileencryption.FileEncryptionUtil;
import i2p.bote.fileencryption.PasswordCache;
import i2p.bote.fileencryption.PasswordException;
import i2p.bote.folder.EmailFolder;
import i2p.bote.folder.EmailPacketFolder;
import i2p.bote.folder.IncompleteEmailFolder;
import i2p.bote.folder.IndexPacketFolder;
import i2p.bote.folder.MessageIdCache;
import i2p.bote.folder.Outbox;
import i2p.bote.folder.RelayPacketFolder;
import i2p.bote.folder.TrashFolder;
import i2p.bote.migration.Migrator;
import i2p.bote.network.BanList;
import i2p.bote.network.BannedPeer;
import i2p.bote.network.DhtPeerStats;
import i2p.bote.network.I2PPacketDispatcher;
import i2p.bote.network.I2PSendQueue;
import i2p.bote.network.NetworkStatus;
import i2p.bote.network.NetworkStatusSource;
import i2p.bote.network.RelayPacketHandler;
import i2p.bote.network.RelayPeer;
import i2p.bote.network.kademlia.KademliaDHT;
import i2p.bote.packet.dht.EncryptedEmailPacket;
import i2p.bote.packet.dht.IndexPacket;
import i2p.bote.service.EmailChecker;
import i2p.bote.service.ExpirationThread;
import i2p.bote.service.I2PBoteThread;
import i2p.bote.service.OutboxListener;
import i2p.bote.service.OutboxProcessor;
import i2p.bote.service.POP3Service;
import i2p.bote.service.RelayPacketSender;
import i2p.bote.service.RelayPeerManager;
import i2p.bote.service.SMTPService;
import i2p.bote.service.UpdateChecker;
import i2p.bote.service.seedless.SeedlessInitializer;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.Thread.State;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.mail.MessagingException;
import net.i2p.I2PAppContext;
import net.i2p.I2PException;
import net.i2p.client.I2PClient;
import net.i2p.client.I2PClientFactory;
import net.i2p.client.I2PSession;
import net.i2p.client.I2PSessionException;
import net.i2p.client.streaming.I2PSocketManager;
import net.i2p.client.streaming.I2PSocketManagerFactory;
import net.i2p.data.Base64;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.util.Log;
/**
* This is the core class of the application. It is implemented as a singleton.
*/
public class I2PBote implements NetworkStatusSource {
public static final int PROTOCOL_VERSION = 4;
private static final String APP_VERSION = "0.2.5";
private static final int STARTUP_DELAY = 3; // the number of minutes to wait before connecting to I2P (this gives the router time to get ready)
private static volatile I2PBote instance;
private Log log = new Log(I2PBote.class);
private I2PClient i2pClient;
private I2PSession i2pSession;
private I2PSocketManager socketManager;
private Configuration configuration;
private Identities identities;
private AddressBook addressBook;
private Outbox outbox; // stores outgoing emails for all local users
private EmailFolder inbox; // stores incoming emails for all local users
private EmailFolder sentFolder;
private TrashFolder trashFolder;
private RelayPacketFolder relayPacketFolder; // stores email packets we're forwarding for other machines
private IncompleteEmailFolder incompleteEmailFolder; // stores email packets addressed to a local user
private EmailPacketFolder emailDhtStorageFolder; // stores email packets for other peers
private IndexPacketFolder indexPacketDhtStorageFolder; // stores index packets
//TODO private PacketFolder<> addressDhtStorageFolder; // stores email address-destination mappings
private Collection<I2PBoteThread> backgroundThreads;
private SMTPService smtpService;
private POP3Service pop3Service;
private OutboxProcessor outboxProcessor; // reads emails stored in the outbox and sends them
private EmailChecker emailChecker;
private UpdateChecker updateChecker;
private KademliaDHT dht;
private RelayPeerManager peerManager;
private PasswordCache passwordCache;
private ConnectTask connectTask;
/**
* Constructs a new instance of <code>I2PBote</code> and initializes
* folders and a few other things. No background threads are spawned,
* and network connectitivy is not initialized.
*/
private I2PBote() {
Thread.currentThread().setName("I2PBoteMain");
I2PAppContext appContext = new I2PAppContext();
appContext.addShutdownTask(new Runnable() {
@Override
public void run() {
shutDown();
}
});
i2pClient = I2PClientFactory.createClient();
configuration = new Configuration();
new Migrator(configuration).migrateIfNeeded();
passwordCache = new PasswordCache(configuration);
identities = new Identities(configuration.getIdentitiesFile(), passwordCache);
addressBook = new AddressBook(configuration.getAddressBookFile(), passwordCache);
initializeFolderAccess(passwordCache);
}
/**
* Initializes objects for accessing emails and packet files on the filesystem.
* @param passwordCache
*/
private void initializeFolderAccess(PasswordCache passwordCache) {
inbox = new EmailFolder(configuration.getInboxDir(), passwordCache);
outbox = new Outbox(configuration.getOutboxDir(), passwordCache);
sentFolder = new EmailFolder(configuration.getSentFolderDir(), passwordCache);
trashFolder = new TrashFolder(configuration.getTrashFolderDir(), passwordCache);
relayPacketFolder = new RelayPacketFolder(configuration.getRelayPacketDir());
MessageIdCache messageIdCache = new MessageIdCache(configuration.getMessageIdCacheFile(), configuration.getMessageIdCacheSize());
incompleteEmailFolder = new IncompleteEmailFolder(configuration.getIncompleteDir(), messageIdCache, inbox);
emailDhtStorageFolder = new EmailPacketFolder(configuration.getEmailDhtStorageDir());
indexPacketDhtStorageFolder = new IndexPacketFolder(configuration.getIndexPacketDhtStorageDir());
}
/**
* Sets up a {@link I2PSession}, using the I2P destination stored on disk or creating a new I2P
* destination if no key file exists.
*/
private void initializeSession() {
Properties sessionProperties = new Properties();
sessionProperties.setProperty("inbound.nickname", "I2P-Bote");
sessionProperties.setProperty("outbound.nickname", "I2P-Bote");
// According to sponge, muxed depends on gzip, so leave gzip enabled
// read the local destination key from the key file if it exists
File destinationKeyFile = configuration.getDestinationKeyFile();
FileReader fileReader = null;
try {
fileReader = new FileReader(destinationKeyFile);
char[] destKeyBuffer = new char[(int)destinationKeyFile.length()];
fileReader.read(destKeyBuffer);
byte[] localDestinationKey = Base64.decode(new String(destKeyBuffer));
ByteArrayInputStream inputStream = new ByteArrayInputStream(localDestinationKey);
socketManager = I2PSocketManagerFactory.createManager(inputStream, sessionProperties);
}
catch (IOException e) {
log.debug("Destination key file doesn't exist or isn't readable." + e);
}
finally {
if (fileReader != null)
try {
fileReader.close();
}
catch (IOException e) {
log.debug("Error closing file: <" + destinationKeyFile.getAbsolutePath() + ">" + e);
}
}
// if the local destination key can't be read or is invalid, create a new one
if (socketManager == null) {
log.debug("Creating new local destination key");
try {
ByteArrayOutputStream arrayStream = new ByteArrayOutputStream();
i2pClient.createDestination(arrayStream);
byte[] localDestinationKey = arrayStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(localDestinationKey);
socketManager = I2PSocketManagerFactory.createManager(inputStream, sessionProperties);
if (socketManager == null) // null indicates an error
log.error("Error creating I2PSocketManagerFactory");
saveLocalDestinationKeys(destinationKeyFile, localDestinationKey);
} catch (I2PException e) {
log.error("Error creating local destination key.", e);
} catch (IOException e) {
log.error("Error writing local destination key to file.", e);
}
}
i2pSession = socketManager.getSession();
Destination localDestination = i2pSession.getMyDestination();
log.info("Local destination key (base64): " + localDestination.toBase64());
log.info("Local destination hash (base64): " + localDestination.calculateHash().toBase64());
log.info("Local destination hash (base32): " + Util.toBase32(localDestination));
}
/**
* Initializes daemon threads, doesn't start them yet.
*/
private void initializeServices() {
I2PPacketDispatcher dispatcher = new I2PPacketDispatcher(socketManager.getServerSocket());
backgroundThreads.add(dispatcher);
i2pSession.addMuxedSessionListener(dispatcher, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
backgroundThreads.add(passwordCache);
/* smtpService = new SMTPService();
backgroundThreads.add(smtpService);
pop3Service = new POP3Service();
backgroundThreads.add(pop3Service);*/
I2PSendQueue sendQueue = new I2PSendQueue(i2pSession, socketManager, dispatcher);
backgroundThreads.add(sendQueue);
RelayPacketSender relayPacketSender = new RelayPacketSender(sendQueue, relayPacketFolder, configuration); // reads packets stored in the relayPacketFolder and sends them
backgroundThreads.add(relayPacketSender);
SeedlessInitializer seedless = new SeedlessInitializer(socketManager);
backgroundThreads.add(seedless);
dht = new KademliaDHT(sendQueue, dispatcher, configuration.getDhtPeerFile(), seedless);
backgroundThreads.add(dht);
dht.setStorageHandler(EncryptedEmailPacket.class, emailDhtStorageFolder);
dht.setStorageHandler(IndexPacket.class, indexPacketDhtStorageFolder);
//TODO dht.setStorageHandler(AddressPacket.class, );
peerManager = new RelayPeerManager(sendQueue, getLocalDestination(), configuration.getRelayPeerFile());
backgroundThreads.add(peerManager);
dispatcher.addPacketListener(emailDhtStorageFolder);
dispatcher.addPacketListener(indexPacketDhtStorageFolder);
dispatcher.addPacketListener(new RelayPacketHandler(relayPacketFolder, dht, sendQueue, i2pSession));
dispatcher.addPacketListener(peerManager);
dispatcher.addPacketListener(relayPacketSender);
ExpirationThread expirationThread = new ExpirationThread();
expirationThread.addExpirationListener(emailDhtStorageFolder);
expirationThread.addExpirationListener(indexPacketDhtStorageFolder);
expirationThread.addExpirationListener(relayPacketSender);
backgroundThreads.add(expirationThread);
outboxProcessor = new OutboxProcessor(dht, outbox, peerManager, relayPacketFolder, identities, configuration, this);
outboxProcessor.addOutboxListener(new OutboxListener() {
/** Moves sent emails to the "sent" folder */
@Override
public void emailSent(Email email) {
try {
outbox.setNew(email, false);
log.debug("Moving email [" + email + "] to the \"sent\" folder.");
outbox.move(email, sentFolder);
}
catch (Exception e) {
log.error("Cannot move email from outbox to sent folder: " + email, e);
}
}
});
backgroundThreads.add(outboxProcessor);
emailChecker = new EmailChecker(identities, configuration, incompleteEmailFolder, emailDhtStorageFolder, indexPacketDhtStorageFolder, this, sendQueue, dht, peerManager);
backgroundThreads.add(emailChecker);
updateChecker = new UpdateChecker(this, configuration);
backgroundThreads.add(updateChecker);
}
/**
* Writes private + public keys for the local destination out to a file.
* @param keyFile
* @param localDestinationArray
* @throws DataFormatException
* @throws IOException
*/
private void saveLocalDestinationKeys(File keyFile, byte[] localDestinationArray) throws DataFormatException, IOException {
if (keyFile.exists()) {
File oldKeyFile = new File(keyFile.getPath() + "_backup");
if (!keyFile.renameTo(oldKeyFile))
log.error("Cannot rename destination key file <" + keyFile.getAbsolutePath() + "> to <" + oldKeyFile.getAbsolutePath() + ">");
}
else
if (!keyFile.createNewFile())
log.error("Cannot create destination key file: <" + keyFile.getAbsolutePath() + ">");
FileWriter fileWriter = new FileWriter(keyFile);
fileWriter.write(Base64.encode(localDestinationArray));
fileWriter.close();
Util.makePrivate(keyFile);
}
/**
* Initializes network connectivity and starts background threads.<br/>
* This is done in a separate thread so the webapp thread is not blocked
* by this method.
*/
public void startUp() {
backgroundThreads = new ArrayList<I2PBoteThread>();
connectTask = new ConnectTask();
backgroundThreads.add(connectTask);
connectTask.start();
}
public void shutDown() {
stopAllServices();
try {
if (i2pSession != null)
i2pSession.destroySession();
} catch (I2PSessionException e) {
log.error("Can't destroy I2P session.", e);
}
if (socketManager != null)
socketManager.destroySocketManager();
}
public static I2PBote getInstance() {
if (instance == null)
instance = new I2PBote();
return instance;
}
public Configuration getConfiguration() {
return configuration;
}
public static String getAppVersion() {
return APP_VERSION;
}
/**
* Returns the current router console language.
*/
public static String getLanguage() {
String language = System.getProperty("routerconsole.lang");
if (language != null)
return language;
else
return Locale.getDefault().getLanguage();
}
public Identities getIdentities() {
return identities;
}
public AddressBook getAddressBook() {
return addressBook;
}
public Destination getLocalDestination() {
if (i2pSession == null)
return null;
else
return i2pSession.getMyDestination();
}
public void sendEmail(Email email) throws Exception {
email.checkAddresses();
// sign email unless sender is anonymous
if (!email.isAnonymous()) {
String sender = email.getSender().toString();
EmailIdentity senderIdentity = identities.extractIdentity(sender);
if (senderIdentity == null)
throw new MessagingException(_("No identity matches the sender/from field: " + sender));
email.sign(senderIdentity, identities);
}
email.setSignatureFlag(); // set the signature flag so the signature isn't reverified every time the email is loaded
outbox.add(email);
if (outboxProcessor != null)
outboxProcessor.checkForEmail();
}
public synchronized void checkForMail() throws PasswordException, IOException, GeneralSecurityException {
emailChecker.checkForMail();
}
/** Returns <code>true</code> if I2P-Bote can be updated to a newer version */
public boolean isUpdateAvailable() {
if (updateChecker == null)
return false;
else
return updateChecker.isUpdateAvailable();
}
/**
* @see EmailChecker#isCheckingForMail()
*/
public synchronized boolean isCheckingForMail() {
if (emailChecker == null)
return false;
else
return emailChecker.isCheckingForMail();
}
/**
* @see EmailChecker#newMailReceived()
*/
public boolean newMailReceived() {
if (emailChecker == null)
return false;
else
return emailChecker.newMailReceived();
}
public EmailFolder getInbox() {
return inbox;
}
public Outbox getOutbox() {
return outbox;
}
public EmailFolder getSentFolder() {
return sentFolder;
}
public EmailFolder getTrashFolder() {
return trashFolder;
}
public boolean moveToTrash(EmailFolder sourceFolder, String messageId) {
return sourceFolder.move(messageId, trashFolder);
}
/**
* Reencrypts all encrypted files with a new password
* @param oldPassword
* @param newPassword
* @param confirmNewPassword
* @return An error message if the two new passwords don't match, <code>null</code> otherwise
* @throws IOException
* @throws GeneralSecurityException
* @throws PasswordException
*/
public String changePassword(byte[] oldPassword, byte[] newPassword, byte[] confirmNewPassword) throws IOException, GeneralSecurityException, PasswordException {
File passwordFile = configuration.getPasswordFile();
if (!FileEncryptionUtil.isPasswordCorrect(oldPassword, passwordFile))
return _("The old password is not correct.");
if (!Arrays.equals(newPassword, confirmNewPassword))
return _("The new password and the confirmation password do not match.");
// lock so no files are encrypted with the old password while the password is being changed
passwordCache.lockPassword();
try {
passwordCache.setPassword(newPassword);
DerivedKey newKey = passwordCache.getKey();
identities.changePassword(oldPassword, newKey);
addressBook.changePassword(oldPassword, newKey);
for (EmailFolder folder: getEmailFolders())
folder.changePassword(oldPassword, newKey);
FileEncryptionUtil.writePasswordFile(passwordFile, passwordCache.getPassword(), newKey);
}
finally {
passwordCache.unlockPassword();
}
return null;
}
/**
* Tests if a password is correct and stores it in the cache if it is.
* If the password is not correct, a <code>PasswordException</code> is thrown.
* @param password
* @throws IOException
* @throws GeneralSecurityException
* @throws PasswordException
*/
public void tryPassword(byte[] password) throws IOException, GeneralSecurityException, PasswordException {
File passwordFile = I2PBote.getInstance().getConfiguration().getPasswordFile();
boolean correct = FileEncryptionUtil.isPasswordCorrect(password, passwordFile);
if (correct)
passwordCache.setPassword(password);
else
throw new PasswordException();
}
/** Returns <code>true</code> if the password is currently cached. */
public boolean isPasswordInCache() {
return passwordCache.isPasswordInCache();
}
/**
* Returns <code>false</code> if a password is set but is not currently cached;
* <code>true</code> otherwise.
*/
public boolean isPasswordRequired() {
return passwordCache.getPassword() == null;
}
/** Removes the password from the password cache. If there is no password in the cache, nothing happens. */
public void clearPassword() {
passwordCache.clear();
identities.clearPasswordProtectedData();
addressBook.clearPasswordProtectedData();
}
private Collection<EmailFolder> getEmailFolders() {
ArrayList<EmailFolder> folders = new ArrayList<EmailFolder>();
folders.add(outbox);
folders.add(inbox);
folders.add(sentFolder);
folders.add(trashFolder);
return folders;
}
public int getNumDhtPeers() {
if (dht == null)
return 0;
else
return dht.getNumPeers();
}
public DhtPeerStats getDhtStats() {
if (dht == null)
return null;
else
return dht.getPeerStats();
}
public Set<RelayPeer> getRelayPeers() {
return peerManager.getAllPeers();
}
public Collection<BannedPeer> getBannedPeers() {
return BanList.getInstance().getAll();
}
private void startAllServices() {
for (I2PBoteThread thread: backgroundThreads)
if (thread!=null && thread.getState()==State.NEW) // the check for State.NEW is only there for ConnectTask
thread.start();
}
private void stopAllServices() {
// first ask threads nicely to shut down
for (I2PBoteThread thread: backgroundThreads)
if (thread != null)
thread.requestShutdown();
awaitShutdown(backgroundThreads, 60 * 1000);
printRunningThreads("Threads still running after requestShutdown():");
// interrupt all threads that are still running
for (I2PBoteThread thread: backgroundThreads)
if (thread!=null && thread.isAlive())
thread.interrupt();
awaitShutdown(backgroundThreads, 5 * 1000);
printRunningThreads("Threads still running 5 seconds after interrupt():");
}
private void printRunningThreads(String caption) {
log.debug(caption);
for (Thread thread: backgroundThreads)
if (thread.isAlive())
log.debug(" " + thread.getName());
}
/**
* Waits up to <code>timeout</code> milliseconds for a <code>Collection</code> of threads to end.
* @param threads
* @param timeout In milliseconds
*/
private void awaitShutdown(Collection<I2PBoteThread> threads, long timeout) {
long deadline = System.currentTimeMillis() + timeout; // the time at which any background threads that are still running are interrupted
for (I2PBoteThread thread: backgroundThreads)
if (thread != null)
try {
long remainingTime = System.currentTimeMillis() - deadline; // the time until the original timeout
if (remainingTime < 0)
return;
thread.join(remainingTime);
} catch (InterruptedException e) {
log.error("Interrupted while waiting for thread <" + thread.getName() + "> to exit", e);
}
}
/**
* Connects to the network, skipping the connect delay.<br/>
* If the delay time has already passed, calling this method has no effect.
*/
public void connectNow() {
connectTask.startSignal.countDown();
}
@Override
public NetworkStatus getNetworkStatus() {
if (!connectTask.isDone())
return connectTask.getNetworkStatus();
else if (dht != null)
return dht.isReady()?NetworkStatus.CONNECTED:NetworkStatus.CONNECTING;
else
return NetworkStatus.ERROR;
}
@Override
public boolean isConnected() {
return getNetworkStatus() == NetworkStatus.CONNECTED;
}
/**
* Waits <code>STARTUP_DELAY</code> milliseconds or until <code>startSignal</code>
* is triggered from outside this class, then sets up an I2P session and everything
* that depends on it.
*/
private class ConnectTask extends I2PBoteThread {
volatile NetworkStatus status = NetworkStatus.NOT_STARTED;
CountDownLatch startSignal = new CountDownLatch(1);
CountDownLatch doneSignal = new CountDownLatch(1);
protected ConnectTask() {
super("ConnectTask");
setDaemon(true);
}
public NetworkStatus getNetworkStatus() {
return status;
}
public boolean isDone() {
try {
return doneSignal.await(0, TimeUnit.SECONDS);
} catch (InterruptedException e) {
return false;
}
}
@Override
public void requestShutdown() {
super.requestShutdown();
startSignal.countDown();
}
@Override
public void doStep() {
status = NetworkStatus.DELAY;
try {
startSignal.await(STARTUP_DELAY, TimeUnit.MINUTES);
status = NetworkStatus.CONNECTING;
initializeSession();
initializeServices();
startAllServices();
doneSignal.countDown();
} catch (Exception e) {
status = NetworkStatus.ERROR;
log.error("Can't initialize the application.", e);
}
requestShutdown();
}
}
}
| [
"[email protected]"
]
| |
310dfdf4db7b6d3a7ababfabf14646f8fcb83d97 | f49fd748bc090a074cba6509abebc75af2c33eec | /src/main/java/wiwy/covid/config/oauth/provider/GoogleUserInfo.java | b91513878c3460fad5c8877ff48d25326a794d08 | []
| no_license | chiyongs/wiwy-covid | aeab77642a2ab8d14543c7a01928ae61bac8ad83 | 085d0a35ce94a8adf677f4a75953c5a0f495838f | refs/heads/master | 2023-06-21T15:47:35.256678 | 2021-08-02T13:16:29 | 2021-08-02T13:16:29 | 361,450,023 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 688 | java | package wiwy.covid.config.oauth.provider;
import java.util.Map;
public class GoogleUserInfo implements OAuth2UserInfo {
private Map<String, Object> attributes; // oAuth2User.getAttributes()
public GoogleUserInfo(Map<String, Object> attributes) {
this.attributes = attributes;
}
@Override
public String getProviderId() {
return (String) attributes.get("sub");
}
@Override
public String getProvider() {
return "google";
}
@Override
public String getEmail() {
return (String) attributes.get("email");
}
@Override
public String getName() {
return (String) attributes.get("name");
}
}
| [
"[email protected]"
]
| |
d4e42b0386c07bb712aa75049e4824468a833eb2 | 4c64f6667e678876529227e9dd699a5923f86b86 | /src/main/java/pl/filmbox/controllers/PersonController.java | 27c784caf245324712099e074afeca09238ced35 | [
"Apache-2.0"
]
| permissive | psorbal/Filmbox | aa96137a5f8142b4c2e1958622742489f69d6d38 | 29a7e2d36e7e3619fe6bd05221c6cfec756cb59a | refs/heads/master | 2021-06-15T23:47:48.202569 | 2017-05-02T11:45:32 | 2017-05-02T11:45:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,952 | java | package pl.filmbox.controllers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import pl.filmbox.models.Person;
import pl.filmbox.services.PersonService;
import java.util.List;
@RestController
@RequestMapping("/person")
public class PersonController {
private final PersonService personService;
@Autowired
public PersonController(PersonService personService) {
this.personService = personService;
}
@GetMapping("/all")
public ModelAndView getAllPersons() {
List<Person> people = personService.getAllPersons();
return new ModelAndView("persons/show-all", "people", people);
}
@GetMapping("/{id}")
public ModelAndView getPerson(@PathVariable Long id) {
Person person = personService.getPerson(id);
return new ModelAndView("persons/show-single", "person", person);
}
@GetMapping("/create")
public ModelAndView getCreateRoleForm() {
return new ModelAndView("persons/create", "Person", new Person());
}
@PostMapping("/create")
public ModelAndView createRole(@ModelAttribute Person person) {
personService.addPerson(person);
return new ModelAndView("redirect:/person/all");
}
@GetMapping("/edit/{id}")
public ModelAndView getEditRoleForm(@PathVariable Long id) {
Person person = personService.getPerson(id);
return new ModelAndView("persons/edit", "person", person);
}
@PutMapping("/update")
public ModelAndView updateRole(@ModelAttribute Person person) {
personService.updatePerson(person);
return new ModelAndView("redirect:/person/all");
}
@DeleteMapping("/delete/{id}")
public ModelAndView deleteRole(@PathVariable Long id) {
personService.deletePerson(id);
return new ModelAndView("redirect:/person/all");
}
}
| [
"[email protected]"
]
| |
31255a86c329baf1e43ca49b972b1e4c24c672f9 | 50e8152919a22279acec8cbf7647e30b6edb983a | /src/com/jenkinsye/oj/leetcode/LeetCode169.java | 1bac00c1b01a606323e45fc4f5fcbef76c544de0 | []
| no_license | JenkinsYe/leetcode | 59b6fb0622b783cbe457e0c8c30a033d7ed8ded3 | 4b008638454185a2258fcbff623c917d240793c1 | refs/heads/master | 2020-07-06T19:18:10.396013 | 2019-09-20T14:37:43 | 2019-09-20T14:37:43 | 203,112,968 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 628 | java | public class LeetCode169 {
public int majorityElement(int[] nums) {
int temp = nums[0];
int count = 1;
for(int i = 1; i< nums.length; i++){
if(nums[i] == temp){
count++;
}else{
count--;
if(count == 0){
temp = nums[i + 1];
}
}
}
return temp;
}
public static void main(String[] args) {
LeetCode169 leetCode169 = new LeetCode169();
int[] nums = {2,1,3,2,2,4,6,1,2,3, 2};
System.out.println(leetCode169.majorityElement(nums));
}
}
| [
"[email protected]"
]
| |
4a4e935435219bb6bd7a6aeb82617b393918748c | f777604f45a44c94ff9502b65454d34851188b9b | /src/main/java/com/os/system/web/CodeController.java | 8189ab7d6929560a53273ed42c3f845de499bff6 | []
| no_license | 2363894951/system | 9c8de58af77de322ecb8f685ada0379b08cc7e3a | 61d32dc9db1596ff6c860612d2de1ce7edb680ea | refs/heads/master | 2020-08-17T21:05:58.883295 | 2019-10-17T05:43:40 | 2019-10-17T05:43:40 | 215,177,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 60 | java | package com.os.system.web;
public class CodeController {
}
| [
"[email protected]"
]
| |
38ad1f2f05143f470b403875e32f0186cd828176 | 0344aa28d296f17f0e2379b584d185813205ca97 | /SIGD/src/models/dao/ControleUsuario.java | 77f581a9938d47b6a51ac3cbf522c153edaf333b | [
"MIT"
]
| permissive | CarlosMacaneta/Projectos-Java | df67b6e9caf71b844a0f3e0e18cfce99722eb148 | 6700b2541313a01bd6d1c5de0366dca1a5111b75 | refs/heads/master | 2022-12-16T23:31:59.061081 | 2020-09-18T15:26:29 | 2020-09-18T15:26:29 | 280,471,401 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,457 | java | package models.dao;
import controllers.FluxoDados;
import controllers.FuncController;
import controllers.GestorController;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Paths;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
import javax.swing.JTextField;
/**
*
* @author Carlos Macaneta
*/
public class ControleUsuario implements Serializable {
private final String URI1 = "log/masterUsername.txt";
private final String URI2 = "log/masterPassword.txt";
public int nivelAcesso(){
ArrayList<Gestor> gestor = new GestorController().lista();
if(gestor.isEmpty()) return 1;
else return 2;
}
public int controlUsuario(JTextField nomeUsuario, char[] senha){
String pass = "";
for (char c : senha) {
pass += c;
}
FluxoDados fd = new FluxoDados();
ArrayList<String> adminUser = new ArrayList<>();
ArrayList<String> adminPass = new ArrayList<>();
ArrayList<Gestor> gestor = new GestorController().lista();
ArrayList<Funcionario> func = new FuncController().lista();
String senhaCriptografada = Criptografia.encriptografar(pass);
if(!gestor.isEmpty()){
for (Gestor value : gestor) {
if (value.getNomeUsuario().equals(nomeUsuario.getText()) && value.getSenha().equals(senhaCriptografada)) {
Log.gestorLogged(value);
return value.getNivelAcesso();
}
}
}else try {
if(fd.readUser(adminUser, Paths.get(URI1))&&fd.readPassword(adminPass, Paths.get(URI2))){
if(fd.verificaUser(adminUser, nomeUsuario.getText())&&fd.verificaPassword(adminPass, pass)){
return 3;
}
}
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "ERRO: "+ex, "ERRO DE LEITURA", INFORMATION_MESSAGE);
}
if(!func.isEmpty()){
for (Funcionario funcionario : func) {
if (funcionario.getNomeUsuario().equals(nomeUsuario.getText()) && funcionario.getSenha().equals(senhaCriptografada)) {
Log.funcLogged(funcionario);
return funcionario.getNivelAcesso();
}
}
}
return -1;
}
} | [
"[email protected]"
]
| |
46ff7ab1f4355c32a6e289cc32be93e1037b799f | 87ad90d423780ad4b01807c56b8135fcfd8cbd76 | /Week_03/netty-gateway/src/main/java/org/geekbang/java/netty/gateway/router/HttpEndpointRouterRandom.java | ac9f9419060091d3dcaa25358196c244d8aeec68 | []
| no_license | zfy-zhang/JAVA-000 | fa60e06d7b2c7509e58523d1610d3ec3f09594a0 | 9ffbf6af45baac2cb9c4a16896a0b2e4e11a6855 | refs/heads/main | 2023-02-10T19:06:09.676909 | 2021-01-06T14:46:58 | 2021-01-06T14:46:58 | 305,304,286 | 0 | 0 | null | 2020-10-19T07:49:36 | 2020-10-19T07:49:35 | null | UTF-8 | Java | false | false | 852 | java | package org.geekbang.java.netty.gateway.router;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpRequest;
import org.geekbang.java.netty.gateway.outbound.httpclient.HttpOutboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Random;
/**
* @Description:
* @Author <a href="mailto:[email protected]">Vincent</a>
* @Create 2020/11/1
* @Modify
* @since
*/
public class HttpEndpointRouterRandom implements HttpEndpointRouter {
static Random random = new Random();
@Override
public String route(List<String> backendUrls) {
return this.getRandom(backendUrls);
}
private String getRandom(List<String> backendUrls){
int number = random.nextInt(backendUrls.size());
return backendUrls.get(number);
}
}
| [
"[email protected]"
]
| |
52b474412b245929f1b426ac7bb9c14ed6b62dee | bc8e6f90ba37500f7902d1d92dff8fa8bff25e62 | /src/main/java/com/devglan/JmsConfig.java | 883f08862d249fa4042b38b8ee42bb14af2fe3e7 | []
| no_license | anantpanthri/spring-boot-jms | 97d7db96fd5297f6d2d251bddfc85e53ae3adcc8 | 539b71de1422a66785a43c85e3ede890dc234479 | refs/heads/master | 2021-01-21T18:46:44.583390 | 2017-05-22T18:07:40 | 2017-05-22T18:07:40 | 92,083,276 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,348 | java | package com.devglan;
import org.apache.activemq.spring.ActiveMQConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.core.JmsTemplate;
@Configuration
public class JmsConfig {
String BROKER_URL = "tcp://localhost:61616";
String BROKER_USERNAME = "admin";
String BROKER_PASSWORD = "admin";
@Bean
public ActiveMQConnectionFactory connectionFactory(){
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(BROKER_URL);
connectionFactory.setPassword(BROKER_USERNAME);
connectionFactory.setUserName(BROKER_PASSWORD);
return connectionFactory;
}
@Bean
public JmsTemplate jmsTemplate(){
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(connectionFactory());
return template;
}
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency("1-1");
return factory;
}
}
| [
"[email protected]"
]
| |
91d240eb69f86f2e92f807dfd01aa1bd33f34eca | 1d460d89eb39889515431323bd00da592dde0f8f | /src/test/java/org/codingsquid/aws_s3_tutorial/AwsS3TutorialApplicationTests.java | f69a6284639982bafce3774c797f561fd0567604 | []
| no_license | gksxodnd007/spring-cloud-aws-s3-tutorial | 4df51a147bffecfefdb9f5ef1bfc9321519f84eb | a69b700eb1e63044fb4e22be7110357f8a804d5a | refs/heads/master | 2020-03-11T19:47:08.704243 | 2018-04-20T07:35:01 | 2018-04-20T07:35:01 | 130,217,781 | 6 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | java | package org.codingsquid.aws_s3_tutorial;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AwsS3TutorialApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
]
| |
36fe11c6c439eb725c1af33b3c077bdd4d2a9c18 | d2798388180b926e131b9b5e5c542de5b5dbd607 | /src/by/it/sereda/project/java/additional/FilterUTF8.java | 292ab4b4df62f5bbc642b8629cb0f933586da62d | []
| no_license | VasilevichSergey/JD2016 | 14a22a5c31ded3783014b9d89cdddf0eb6ad4398 | dfb8e38a6c4022677708dc03d0047d76bc801bfd | refs/heads/master | 2020-12-24T20:25:06.458871 | 2016-10-04T10:35:49 | 2016-10-04T10:35:49 | 58,029,314 | 0 | 0 | null | 2016-05-04T06:46:27 | 2016-05-04T06:46:27 | null | UTF-8 | Java | false | false | 2,290 | java | package by.it.sereda.project.java.additional;
import by.it.sereda.project.java.Action;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebFilter(urlPatterns = {"/*"},
initParams = {
@WebInitParam(name = "encoding", value = "UTF-8", description = "Encoding Param")})
public class FilterUTF8 implements Filter {
private String code;
public void init(FilterConfig fConfig) throws ServletException {
code = fConfig.getInitParameter("encoding");
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
//ะฟัะธะผะตั ัะธะปัััะฐ ะะะ ะะ ัะตัะฒะปะตัะพะผ.
String codeResponse = response.getCharacterEncoding();
// ัััะฐะฝะพะฒะบะฐ ะบะพะดะธัะพะฒะบะธ ะพัะฒะตัะฐ ะธะท ะฟะฐัะฐะผะตััะพะฒ ัะธะปัััะฐ, ะตัะปะธ ะฝะต ัััะฐะฝะพะฒะปะตะฝะฐ
if (code != null && !code.equalsIgnoreCase(codeResponse)) {
response.setCharacterEncoding(code);
}
String codeRequest = request.getCharacterEncoding();
// ัััะฐะฝะพะฒะบะฐ ะบะพะดะธัะพะฒะบะธ ะทะฐะฟัะพัะฐ ะธะท ะฟะฐัะฐะผะตััะพะฒ ัะธะปัััะฐ, ะตัะปะธ ะฝะต ัััะฐะฝะพะฒะปะตะฝะฐ
if (code != null && !code.equalsIgnoreCase(codeRequest)) {
request.setCharacterEncoding(code);
}
//ะฟัะธะผะตั ะพะฑัะฐัะตะฝะธั ะบ ัะตััะธะธ
//ะัะธะฒะตะดะตะฝะธะต ะทะฐะฟัะพัะฐ request ะบ http
HttpServletRequest req=(HttpServletRequest)request;
//ะฟะพะปััะตะฝะธะต ัะตััะธะธ
HttpSession session=req.getSession(true);
session.setAttribute(Action.msgMessage,"ะญัะพ ัะพะพะฑัะตะฝะธะต ะธะท ัะธะปัััะฐ");
//ะพะฑัะฐะฑะพัะบะฐ ะฟัะพัะธั
ัะธะปัััะพะฒ ัะตัะฒะปะตัะพะฒ ะธ jsp
chain.doFilter(request, response);
//ััั ะผะพะถะฝะพ ะธะทะผะตะฝะธัั/ะฟัะพัะธัะฐัั ะฒัั
ะพะดะฝะพะน ะฟะพัะพะบ, ะฝะพ ัััะธัะต, ะพะฝ ัะถะต ัะพะทะดะฐะฝ ะธ ะทะฐะฟะพะปะฝะตะฝ.
}
public void destroy() {
code = null;
}
} | [
"[email protected]"
]
| |
5bde9dc7314b49c7cc29de786602154017761b74 | abb1752d22a7cf19829d76b11cc78c012dfe6396 | /students/net1814080903318/main/java/edu/hzuapps/androidlabs/LupingActivity.java | fd05dfc3e6237b67b36ac51a4c9080e5dd80d0e3 | []
| no_license | hzuapps/android-labs-2020 | 0aba37f6a0f9e030858bc5645494518c1486d4d8 | 5e2e626d95c0311c3de07c194663367f754d0777 | refs/heads/master | 2021-07-12T17:03:48.438005 | 2021-03-14T03:37:28 | 2021-03-14T03:37:28 | 240,203,379 | 35 | 250 | null | 2021-03-14T03:37:29 | 2020-02-13T07:40:04 | Java | UTF-8 | Java | false | false | 1,608 | java | package edu.hzuapps.androidlabs;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.io.File;
import java.io.IOException;
public class LupingActivity<CameraVideoActivity> extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_luping);
}
private File createMediaFile() throws IOException {
if ((Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))) {
// ้ๆฉ่ชๅทฑ็ๆไปถๅคน
String path = Environment.getExternalStorageDirectory().getPath() + "/myvideo/";
// Constants.video_url ๆฏไธไธชๅธธ้๏ผไปฃ่กจๅญๆพ่ง้ข็ๆไปถๅคน
File mediaStorageDir = new File(path);
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.e("TAG", "ๆไปถๅคนๅๅปบๅคฑ่ดฅ");
return null;
}
}
// ๆไปถๆ นๆฎๅฝๅ็ๆฏซ็งๆฐ็ป่ชๅทฑๅฝๅ
String timeStamp = String.valueOf(System.currentTimeMillis());
timeStamp = timeStamp.substring(7);
String imageFileName = "V" + timeStamp;
String suffix = ".mp4";
File mediaFile = new File(mediaStorageDir + File.separator + imageFileName + suffix);
return mediaFile;
}else return null;
}
}
| [
"[email protected]"
]
| |
affb3c858bd12575f4ba26adf39224a0732e4bd4 | e6a324f1be84a95e101cab03c553e60c97ce5ecd | /src/main/java/org/ml4j/nn/optimisation/CostFunctionMinimiser.java | 91ce3851334642c9a7cf472c00840148571f518c | [
"Apache-2.0"
]
| permissive | gaoruixian/ml4j-nn | 85380c0f10d7fc266e31648390f5cf53ac911b63 | 1f46bd9ef8b4e50b093eb91d55b7b94860ccc343 | refs/heads/master | 2021-01-14T08:22:59.097591 | 2015-09-17T15:56:08 | 2015-09-17T15:56:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,762 | java | package org.ml4j.nn.optimisation;
import org.ml4j.DoubleMatrices;
import org.ml4j.DoubleMatrix;
public class CostFunctionMinimiser {
/**
* Optimizes the weight matrix using a given cost function. Obtained from
* https://github.com/thomasjungblut/ A few minor changes were made to make
* the function compatible with jblas library.
*/
public static DoubleMatrices<DoubleMatrix> fmincg(MinimisableCostAndGradientFunction f, DoubleMatrices<DoubleMatrix> pInput, int max_iter,
boolean verbose) {
/*
* Minimize a continuous differentialble multivariate function. Starting
* point is given by "X" (D by 1), and the function named in the string
* "f", must return a function value and a vector of partial
* derivatives. The Polack- Ribiere flavour of conjugate gradients is
* used to compute search directions, and a line search using quadratic
* and cubic polynomial approximations and the Wolfe-Powell stopping
* criteria is used together with the slope ratio method for guessing
* initial step sizes. Additionally a bunch of checks are made to make
* sure that exploration is taking place and that extrapolation will not
* be unboundedly large. The "length" gives the length of the run: if it
* is positive, it gives the maximum number of line searches, if
* negative its absolute gives the maximum allowed number of function
* evaluations. You can (optionally) give "length" a second component,
* which will indicate the reduction in function value to be expected in
* the first line-search (defaults to 1.0). The function returns when
* either its length is up, or if no further progress can be made (ie,
* we are at a minimum, or so close that due to numerical problems, we
* cannot get any closer). If the function terminates within a few
* iterations, it could be an indication that the function value and
* derivatives are not consistent (ie, there may be a bug in the
* implementation of your "f" function). The function returns the found
* solution "X", a vector of function values "fX" indicating the
* progress made and "i" the number of iterations (line searches or
* function evaluations, depending on the sign of "length") used.
*
* Usage: [X, fX, i] = fmincg(f, X, options, P1, P2, P3, P4, P5)
*
* See also: checkgrad
*
* Copyright (C) 2001 and 2002 by Carl Edward Rasmussen. Date 2002-02-13
*
*
* (C) Copyright 1999, 2000 & 2001, Carl Edward Rasmussen Permission is
* granted for anyone to copy, use, or modify these programs and
* accompanying documents for purposes of research or education,
* provided this copyright notice is retained, and note is made of any
* changes that have been made.
*
* These programs and documents are distributed without any warranty,
* express or implied. As the programs were written for research
* purposes only, they have not been tested to the degree that would be
* advisable in any important application. All use of these programs is
* entirely at the user's own risk.
*
* [ml-class] Changes Made: 1) Function name and argument specifications
* 2) Output display
*
* [tjungblut] Changes Made: 1) translated from octave to java 2) added
* an interface to exchange minimizers more easily BTW "fmincg" stands
* for Function minimize nonlinear conjugate gradient
*
* [David Vincent] Changes Made: 1) changed matrix data structers and
* matrix operatons to use jblas library 2) removed (fX) column matrix
* that stored the cost of each iteration.
*/
final double RHO = 0.01; // a bunch of constants for line
// searches
final double SIG = 0.5; // RHO and SIG are the constants in
// the
// Wolfe-Powell conditions
final double INT = 0.1; // don't reevaluate within 0.1 of the
// limit of the current bracket
final double EXT = 3.0; // extrapolate maximum 3 times the
// current bracket
final int MAX = 30; // max 20 function evaluations per line
// search
final int RATIO = 100; // maximum allowed slope ratio
DoubleMatrices<DoubleMatrix> input = pInput;
int M = 0;
int i = 0; // zero the run length counter
int red = 1; // starting point
int ls_failed = 0; // no previous line search has failed
// get function value and gradient
final Tuple<Double, DoubleMatrices<DoubleMatrix>> evaluateCost = f.evaluateCost(input);
double f1 = evaluateCost.getFirst();
DoubleMatrices<DoubleMatrix> df1 = evaluateCost.getSecond();
i = i + (max_iter < 0 ? 1 : 0);
DoubleMatrices<DoubleMatrix> s = df1.mul(-1.0d); // search direction is
// steepest
double d1 = s.mul(-1.0d).dot(s); // this is the slope
double z1 = red / (1.0 - d1); // initial step is red/(|s|+1)
while (i < Math.abs(max_iter)) {
i = i + (max_iter > 0 ? 1 : 0);// count iterations?!
// make a copy of current values
DoubleMatrices<DoubleMatrix> X0 = input;//f.getDoubleMatricesFactory().copy(input);
double f0 = f1;
DoubleMatrices<DoubleMatrix> df0 = df1;//f.getDoubleMatricesFactory().copy(df1);
// begin line search
input = input.add(s.mul(z1));
final Tuple<Double, DoubleMatrices<DoubleMatrix> > evaluateCost2 = f.evaluateCost(input);
double f2 = evaluateCost2.getFirst();
DoubleMatrices<DoubleMatrix> df2 = evaluateCost2.getSecond();
i = i + (max_iter < 0 ? 1 : 0); // count epochs?!
double d2 = df2.dot(s);
// initialize point 3 equal to point 1
double f3 = f1;
double d3 = d1;
double z3 = -z1;
if (max_iter > 0) {
M = MAX;
} else {
M = Math.min(MAX, -max_iter - i);
}
// initialize quanteties
int success = 0;
double limit = -1;
while (true) {
while (((f2 > f1 + z1 * RHO * d1) | (d2 > -SIG * d1)) && (M > 0)) {
limit = z1; // tighten the bracket
double z2 = 0.0d;
double A = 0.0d;
double B = 0.0d;
if (f2 > f1) {
// quadratic fit
z2 = z3 - (0.5 * d3 * z3 * z3) / (d3 * z3 + f2 - f3);
} else {
A = 6 * (f2 - f3) / z3 + 3 * (d2 + d3); // cubic fit
B = 3 * (f3 - f2) - z3 * (d3 + 2 * d2);
// numerical error possible - ok!
z2 = (Math.sqrt(B * B - A * d2 * z3 * z3) - B) / A;
}
if (Double.isNaN(z2) || Double.isInfinite(z2)) {
z2 = z3 / 2.0d; // if we had a numerical problem then
// bisect
}
// don't accept too close to limits
z2 = Math.max(Math.min(z2, INT * z3), (1 - INT) * z3);
z1 = z1 + z2; // update the step
input = input.add(s.mul(z2));
final Tuple<Double, DoubleMatrices<DoubleMatrix> > evaluateCost3 = f.evaluateCost(input);
f2 = evaluateCost3.getFirst();
df2 = evaluateCost3.getSecond();
M = M - 1;
i = i + (max_iter < 0 ? 1 : 0); // count epochs?!
d2 = df2.dot(s);
z3 = z3 - z2; // z3 is now relative to the location of z2
}
if (f2 > f1 + z1 * RHO * d1 || d2 > -SIG * d1) {
break; // this is a failure
} else if (d2 > SIG * d1) {
success = 1;
break; // success
} else if (M == 0) {
break; // failure
}
double A = 6 * (f2 - f3) / z3 + 3 * (d2 + d3); // make cubic
// extrapolation
double B = 3 * (f3 - f2) - z3 * (d3 + 2 * d2);
double z2 = -d2 * z3 * z3 / (B + Math.sqrt(B * B - A * d2 * z3 * z3));
// num prob or wrong sign?
if (Double.isNaN(z2) || Double.isInfinite(z2) || z2 < 0)
if (limit < -0.5) { // if we have no upper limit
z2 = z1 * (EXT - 1); // the extrapolate the maximum
// amount
} else {
z2 = (limit - z1) / 2; // otherwise bisect
}
else if ((limit > -0.5) && (z2 + z1 > limit)) {
// extraplation beyond max?
z2 = (limit - z1) / 2; // bisect
} else if ((limit < -0.5) && (z2 + z1 > z1 * EXT)) {
// extrapolationbeyond limit
z2 = z1 * (EXT - 1.0); // set to extrapolation limit
} else if (z2 < -z3 * INT) {
z2 = -z3 * INT;
} else if ((limit > -0.5) && (z2 < (limit - z1) * (1.0 - INT))) {
// too close to the limit
z2 = (limit - z1) * (1.0 - INT);
}
// set point 3 equal to point 2
f3 = f2;
d3 = d2;
z3 = -z2;
z1 = z1 + z2;
// update current estimates
input = input.add(s.mul(z2));
final Tuple<Double, DoubleMatrices<DoubleMatrix> > evaluateCost3 = f.evaluateCost(input);
f2 = evaluateCost3.getFirst();
df2 = evaluateCost3.getSecond();
M = M - 1;
i = i + (max_iter < 0 ? 1 : 0); // count epochs?!
d2 = df2.dot(s);
}// end of line search
DoubleMatrices<DoubleMatrix> tmp = null;
if (success == 1) { // if line search succeeded
f1 = f2;
if (verbose)
System.out.print("Iteration " + i + " | Cost: " + f1 + "\r");
// Polack-Ribiere direction: s =
// (df2'*df2-df1'*df2)/(df1'*df1)*s - df2;
final double numerator = (df2.dot(df2) - df1.dot(df2)) / df1.dot(df1);
s = s.mul(numerator).sub(df2);
tmp = df1;
df1 = df2;
df2 = tmp; // swap derivatives
d2 = df1.dot(s);
if (d2 > 0) { // new slope must be negative
s = df1.mul(-1.0d); // otherwise use steepest direction
d2 = s.mul(-1.0d).dot(s);
}
// realmin in octave = 2.2251e-308
// slope ratio but max RATIO
z1 = z1 * Math.min(RATIO, d1 / (d2 - 2.2251e-308));
d1 = d2;
ls_failed = 0; // this line search did not fail
} else {
input = X0;
f1 = f0;
df1 = df0; // restore point from before failed line search
// line search failed twice in a row?
if (ls_failed == 1 || i > Math.abs(max_iter)) {
break; // or we ran out of time, so we give up
}
tmp = df1;
df1 = df2;
df2 = tmp; // swap derivatives
s = df1.mul(-1.0d); // try steepest
d1 = s.mul(-1.0d).dot(s);
z1 = 1.0d / (1.0d - d1);
ls_failed = 1; // this line search failed
}
}
return input;
}
}
| [
"[email protected]"
]
| |
3fd196a7dba88bde81f5e11d8a2384ca59bc06a7 | 692a3819291038ef5d4eccb468e895510baccc1d | /src/main/java/countmeup/Candidate.java | ad16e85880161ba1ababfa2a8f61e2ecc1ac35a4 | []
| no_license | ThanosKatsikas/CountMeUp | 70bc5604c48cdabc5243a4e59d53b2a5fa282399 | 1fe6def5d697c120d76c2ad843a2bbb7cb857e3d | refs/heads/master | 2020-12-30T16:40:26.151646 | 2017-05-14T20:39:00 | 2017-05-14T20:39:00 | 91,005,608 | 0 | 0 | null | 2017-05-14T09:33:45 | 2017-05-11T17:21:55 | Java | UTF-8 | Java | false | false | 709 | java | package countmeup;
import com.fasterxml.jackson.annotation.JsonProperty;
/*
* Class candidate
* Attributes:
* Unique identifier and number of votes.
* Methods:
* Constructor - Sets the unique identifier
* and his votes to zero.
*
* GetNumberOfVotes - Returns number of votes
* the candidate has.
*
* addVote - Adds a vote to the candidate's votes
*/
public class Candidate {
@JsonProperty
private final int candidateId;
@JsonProperty
private int numberOfVotes;
Candidate (int id) {
candidateId = id;
numberOfVotes = 0;
}
public int getNumberOfVotes() {
return numberOfVotes;
}
public void addVote () {
numberOfVotes = numberOfVotes + 1;
}
}
| [
"[email protected]"
]
| |
2c7a7903571e8bec3fda688ead5e0cabbeb34514 | 303a51dcd766b43f033b63463f3cda0d540b5b56 | /src/application/Graph.java | 1374f5a3a8325e58e37b15e169bac3c63d3a837d | []
| no_license | aadame3311/GraphVisualizer | c81132bc805d69901a693d33d3c48758c5a4fc01 | 0e5883566305992ec7fb5c01e8aab2e7b624e701 | refs/heads/master | 2020-04-13T06:49:48.195426 | 2018-12-25T00:44:41 | 2018-12-25T00:44:41 | 163,031,924 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,989 | java | package application;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Vector;
public class Graph {
private Map<String, Vertex> vertexMap = new HashMap<String, Vertex>();
private Vector<Vertex> allVertex = new Vector<Vertex>();
//DFS vars.
private Map<Vertex, Boolean> visited = new HashMap<Vertex, Boolean>();
private Queue<Vertex> q = new LinkedList<Vertex>();
private Vector<Vertex> DFSPath = new Vector<Vertex>(); //stores a list of the DFS path.
// default constructor.
public Graph() {
Vertex v = new Vertex();
vertexMap.put(v.data, v);
allVertex.add(v);
}
// getter methods for private elements.
public Vertex getVertex(String key) {
if (vertexMap.containsKey(key)) {
return vertexMap.get(key);
}
else {
return null;
}
}
public Vector<Vertex> getAllVertex() { return allVertex; }
// insert vertex into graph under parent vertex.
public void InsertVertex(Vertex parent, String data) {
if (parent.data.equals(data) || parent.neighbors.containsKey(data)) return;
Vertex v = null;
// only add new vertices if they don't already exist.
if (!vertexMap.containsKey(data)) {
v = new Vertex(data);
allVertex.add(v);
vertexMap.put(data, v);
}
else {
v = vertexMap.get(data);
}
parent.neighbors.put(data, v);
return;
}
// DFS search constructs the DFS path.
private boolean DFS(Vertex start, Vertex end) {
visited.put(start, true);
if (start == end) {
DFSPath.add(start);
return true;
}
// add all neighbors to queue.
for (Map.Entry<String, Vertex> entry : start.neighbors.entrySet()) {
if (!visited.containsKey(entry.getValue())) {
//q.add(entry.getValue());
if (DFS(entry.getValue(), end)) {
DFSPath.add(start);
return true;
}
}
}
return false;
}
public Vector<Vertex> getDFSPath(Vertex s, Vertex e) {
DFSPath.clear();
visited.clear();
DFS(s, e);
return DFSPath;
}
}
| [
"[email protected]"
]
| |
747806dc85fc10b97d7b04c1cdb1f3c4a1af54b6 | 41c2c0c615aefa817ee9baf7bf074831076766fc | /src/packages/main/springDB/TestDB.java | 2d9ad95002ecaf604813135664fe04a4e4f68a9d | []
| no_license | zhichao-li/springDB | d2612ec88058397929bd46c61603d685bcabc53b | b989039d9cd23dbfaea1e181d764aeefbdf12877 | refs/heads/master | 2020-12-24T17:36:24.991651 | 2014-01-23T16:02:26 | 2014-01-23T16:02:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 523 | java | package springDB;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import springDB.domain.BiasingAudit;
public class TestDB {
public static void main(String[] args){
ApplicationContext context = new ClassPathXmlApplicationContext("config.xml");
BiasingAudit biasingAudit = (BiasingAudit) context.getBean("BiasingAudit");
biasingAudit.print();
}
}
| [
"[email protected]"
]
| |
82ea9d41e613bb31794fe6169b8d4307b6aaa906 | adce3f26d1b53ba070a70c2f844145408447ec67 | /app/src/main/java/com/applab/goodmorning/Event/activity/EventActivity.java | 4c238f31bbbfaccd9d972abff0fc43df25907ab2 | []
| no_license | izzunmustaqim/good-morning | c35be0433001e6ad9ecda01f66a07ba8e5108d60 | 0b2e581f12e5a0a0c085789fb98873c360dad40f | refs/heads/master | 2021-06-25T14:02:06.816860 | 2017-09-13T16:33:16 | 2017-09-13T16:33:16 | 103,419,174 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,257 | java | package com.applab.goodmorning.Event.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.applab.goodmorning.Account.activity.AccountDetailsActivity;
import com.applab.goodmorning.Checkout.activity.CartActivity;
import com.applab.goodmorning.Event.adapter.EventPagerAdapter;
import com.applab.goodmorning.Login.model.Token;
import com.applab.goodmorning.Login.provider.TokenProvider;
import com.applab.goodmorning.Menu.fragment.NavigationDrawerFragment;
import com.applab.goodmorning.Order.activity.OrderHistoryActivity;
import com.applab.goodmorning.R;
import com.applab.goodmorning.Register.activity.RegisterActivity;
import com.applab.goodmorning.SlidingTabs.SlidingTabLayout;
import com.applab.goodmorning.Utilities.Utilities;
public class EventActivity extends AppCompatActivity {
private Toolbar mToolbar;
private TextView mTxtTitle;
private ViewPager mPager;
private SlidingTabLayout mTabs;
private int mPage = 0;
private NavigationDrawerFragment mDrawerFragment;
private int mToolbarHeight = 100;
private View mSideMenu;
private RelativeLayout mRl;
private TextView mTxtProfileName;
private LinearLayout mBtnSignUp;
private LinearLayout mBtnAccount;
private LinearLayout mBtnHistory;
private LinearLayout mBtnLogOut;
private LinearLayout mBtnRegister;
private View mActionShop;
private boolean mIsSlide = false;
private String TAG = EventActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
mToolbar = (Toolbar) findViewById(R.id.appBar);
setSupportActionBar(mToolbar);
mTxtTitle = (TextView) mToolbar.findViewById(R.id.txtTitle);
mTxtTitle.setText(getBaseContext().getResources().getString(R.string.title_activity_events));
mPager = (ViewPager) findViewById(R.id.pager);
mPager.setOffscreenPageLimit(1);
mPager.setAdapter(new EventPagerAdapter(getSupportFragmentManager(), this));
mPager.addOnPageChangeListener(mPagerOnPageChangeListener);
mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
mTabs.setDistributeEvenly(true);
mTabs.setCustomTabView(R.layout.custom_tab_view, R.id.tabText, R.id.tabNumber, R.id.tabIcon);
mTabs.setBackgroundColor(ContextCompat.getColor(this, R.color.white));
mTabs.setSelectedIndicatorColors(ContextCompat.getColor(this, R.color.color_primary));
mTabs.setViewPager(mPager);
mPager.setCurrentItem(mPage);
mSideMenu = (View) findViewById(R.id.sideMenu);
mBtnSignUp = (LinearLayout) mSideMenu.findViewById(R.id.btnSignIn);
mBtnAccount = (LinearLayout) mSideMenu.findViewById(R.id.btnAccount);
mBtnHistory = (LinearLayout) mSideMenu.findViewById(R.id.btnHistory);
mBtnLogOut = (LinearLayout) mSideMenu.findViewById(R.id.btnSignOut);
mBtnRegister = (LinearLayout) mSideMenu.findViewById(R.id.btnRegister);
mTxtProfileName = (TextView) mSideMenu.findViewById(R.id.txtProfileName);
mRl = (RelativeLayout) findViewById(R.id.fadeRL);
mDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer);
mDrawerFragment.setUp(R.id.fragment_navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), mToolbar);
mDrawerFragment.setSelectedPosition(6);
mDrawerFragment.mDrawerToggle.setDrawerIndicatorEnabled(false);
mToolbar.setNavigationIcon(R.mipmap.menu);
mToolbar.setNavigationOnClickListener(mToolbarOnClickListener);
}
private View.OnClickListener mToolbarOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawerFragment.setOpenCloseDrawer();
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_welcome, menu);
mActionShop = (View) menu.findItem(R.id.action_shop).getActionView();
Utilities.setAddCartOnClickListener(EventActivity.this, mActionShop);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_menu) {
Utilities.setSideMenuVisible(true, mSideMenu, mRl);
return true;
} else {
return mDrawerFragment.mDrawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
}
}
@Override
protected void onPause() {
super.onPause();
Utilities.checkToCloseSideMenuForOnPause(this, mSideMenu, mRl, mDrawerFragment);
}
@Override
protected void onResume() {
super.onResume();
setDelay(this);
IntentFilter iff = new IntentFilter(TAG);
LocalBroadcastManager.getInstance(getBaseContext()).registerReceiver(broadcastReceiver, iff);
}
private void setDelay(final Context context) {
Handler handler = new Handler();
Runnable r = new Runnable() {
public void run() {
Utilities.refreshActionShop(context, mActionShop);
}
};
handler.postDelayed(r, 1000);
}
@Override
public void onBackPressed() {
if (!mIsSlide) {
Utilities.checkToCloseSideMenu(this, mSideMenu, mRl, mDrawerFragment);
} else {
Intent intent = new Intent(TAG);
intent.putExtra("isSlide", false);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}
private ViewPager.OnPageChangeListener mPagerOnPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mPage = position;
}
@Override
public void onPageScrollStateChanged(int state) {
}
};
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(TAG)) {
mIsSlide = intent.getBooleanExtra("isSlide", false);
}
}
};
}
| [
"[email protected]"
]
| |
e949ef35f686713baecce4864f6f88db5dcef31a | 605f6eca910b382089a979b1a363fa0dcb19e882 | /src/test/java/WebTests/TradesTest.java | 2cfe1068706bc11d34eaad3c6d8335eefd715d19 | []
| no_license | OlgaChe/olderbook | 40bdd3b7fdfc4b65fbc4482260cd9af7d0e6b181 | c960180e6283bed406212a1cf2652aa9e86bdb43 | refs/heads/master | 2020-04-22T22:40:04.761980 | 2019-02-14T15:56:48 | 2019-02-14T15:56:48 | 170,716,191 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,245 | java | package WebTests;
import Components.Trades;
import Setup.SetupTestWeb;
import org.testng.annotations.Test;
public class TradesTest extends SetupTestWeb {
public Trades trades;
@Test
public void setOUSDETHmarket(){
trades = new Trades();
trades.gipnokrugAbsent();
trades.clickMarketSelectorTab();
trades.clickOUSDETHtradepair();
trades.clickMarketSelectorTab();
trades.gipnokrugAbsent();
System.out.println("Trading on OUSD ETH market");
System.out.println("Last price is:");
trades.whatIsLastPrice();
System.out.println("Buy Fee is:");
trades.whatIsBuyFee();
System.out.println("Sell Fee is:");
trades.whatIsSellFee();
}
@Test(dependsOnMethods = "setOUSDETHmarket")
public void testTrade(){
trades = new Trades();
trades.setAmoutToBuy("1");
trades.setBuyPrice("1");
trades.setAmountToSell("1");
trades.setSellPrice("1");
trades.clickBuyButton();
//trades.clickSellButton();
System.out.println("Buy total is: ");
trades.whatIsBuyTotal();
System.out.println("Sell total is: ");
trades.whatIsSellTotal();
}
}
| [
"[email protected]"
]
| |
5b6f95736cb77ce5dcecc9df905c02f9ec511384 | 46b352e3b970b6c1f7fc35cf011d03cafb16e32d | /WEEK12(graph)/Graphs/src/GraphPackage/GraphAlgorithmsInterface.java | 6db3b9cf097b14a16ff5204f670e479f9d572f9e | []
| no_license | FlatFishPrincess/data_structure | f8b7836691e1116e6743590104c42fcb5c034aac | 5df96bf135b2b653070bee79c29a3b7ccefb5357 | refs/heads/master | 2020-04-30T20:09:12.473427 | 2019-11-27T06:05:26 | 2019-11-27T06:05:26 | 177,058,035 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,522 | java | package GraphPackage;
import StackAndQueuePackage.*;
/**
* An interface of methods that process an existing graph.
*
* @author Frank M. Carrano
* @author Timothy M. Henry
* @version 5.0
*/
public interface GraphAlgorithmsInterface<T> {
/**
* Performs a breadth-first traversal of this graph.
*
* @param origin An object that labels the origin vertex of the traversal.
* @return A queue of labels of the vertices in the traversal, with the label of
* the origin vertex at the queue's front.
*/
public QueueInterface<T> getBreadthFirstTraversal(T origin);
/**
* Performs a depth-first traversal of this graph.
*
* @param origin An object that labels the origin vertex of the traversal.
* @return A queue of labels of the vertices in the traversal, with the label of
* the origin vertex at the queue's front.
*/
public QueueInterface<T> getDepthFirstTraversal(T origin);
/**
* Performs a topological sort of the vertices in this graph without cycles.
*
* @return A stack of vertex labels in topological order, beginning with the
* stack's top.
*/
public StackInterface<T> getTopologicalOrder();
/**
* Finds the shortest-length path between two given vertices in this graph.
*
* @param begin An object that labels the path's origin vertex.
* @param end An object that labels the path's destination vertex.
* @param path A stack of labels that is empty initially; at the completion of
* the method, this stack contains the labels of the vertices along
* the shortest path; the label of the origin vertex is at the top,
* and the label of the destination vertex is at the bottom
* @return The length of the shortest path.
*/
public int getShortestPath(T begin, T end, StackInterface<T> path);
/**
* Finds the least-cost path between two given vertices in this graph.
*
* @param begin An object that labels the path's origin vertex.
* @param end An object that labels the path's destination vertex.
* @param path A stack of labels that is empty initially; at the completion of
* the method, this stack contains the labels of the vertices along
* the cheapest path; the label of the origin vertex is at the top,
* and the label of the destination vertex is at the bottom
* @return The cost of the cheapest path.
*/
public double getCheapestPath(T begin, T end, StackInterface<T> path);
} // end GraphAlgorithmsInterface
| [
"[email protected]"
]
| |
070317c9492e908fe204085aceec5b05d3591814 | bafd8df403148b17112241bea6e8e584d42b482c | /src/main/java/com/ruoyi/project/system/domain/vo/QueryVo.java | cbae27a8e82fefe4bddf134df7945d305438d037 | [
"LicenseRef-scancode-mulanpsl-2.0-en",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | Vetch0710/hospital | 8262a35b9cf978c55378809c5c2fe4cb02df4c8e | 15f3594a3e07a2d036a5b5c7f58be2e3a899216e | refs/heads/master | 2023-04-12T13:34:51.074849 | 2021-04-27T06:30:24 | 2021-04-27T06:30:24 | 359,290,340 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package com.ruoyi.project.system.domain.vo;
import com.ruoyi.framework.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @author Vetch
* @Description ๏ผๅๅทฅไฟกๆฏๆฅ่ฏขๆกไปถ็ฑป
* @create 2021-04-02-13:13
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class QueryVo extends BaseEntity {
private static final long serialVersionUID = 1L;
private String realName;
private String position;
private String department;
private String remanNum;
private String startTime;
private Long doctorId ;
}
| [
"[email protected]"
]
| |
1ea48b9f92d0216d0cbb5296571161e9909092a3 | 77132046c978186f6bf624219ede33bd4ffd99ba | /NightFight_Springboot/src/main/java/at/nightfight/controller/EquippedGearController.java | 9da5f940fa58f5ff9fb4d51ebf95741712cdf5d8 | []
| no_license | kingchewy/project_spartacus | 0b60212ab78af0a99f17deb31653ebe8e2799271 | a2fcd896df3cff8f9df97d22c519024e8e6ac98c | refs/heads/master | 2020-04-01T15:33:33.950364 | 2019-02-24T07:39:35 | 2019-02-24T07:39:35 | 153,342,026 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,883 | java | package at.nightfight.controller;
import at.nightfight.model.Character;
import at.nightfight.model.EquippedGear;
import at.nightfight.repository.CharacterRepository;
import at.nightfight.service.EquippedGearServiceImpl;
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.Optional;
@RestController
@RequestMapping("/resources")
public class EquippedGearController {
@Autowired
EquippedGearServiceImpl equippedGearService;
@Autowired
CharacterRepository characterRepository;
@GetMapping("/characters/{id}/equippeditems")
public ResponseEntity<EquippedGear> getCharactersEquippedGear(@PathVariable("id") Long id){
Optional<EquippedGear> equippedGear = equippedGearService.getEquippedGear(id);
if(equippedGear.isPresent() == false){
return new ResponseEntity<EquippedGear>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<EquippedGear>(equippedGear.get(), HttpStatus.OK);
}
@PostMapping("characters/{id}/equippeditems")
public ResponseEntity<Character> setEquippedItems(@PathVariable("id") Long id, @RequestBody EquippedGear equippedGear){
Optional<Character> characterOptional = characterRepository.findById(id);
if(!characterOptional.isPresent()){
return new ResponseEntity("Character with ID '" + id + "' not found!", HttpStatus.NOT_FOUND);
}
Character updatedCharacter = equippedGearService.setEquippedGear(characterOptional.get(), equippedGear);
if(updatedCharacter == null){
return new ResponseEntity("No Valid Gear To Equip", HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<Character>(updatedCharacter, HttpStatus.OK);
}
}
| [
"[email protected]"
]
| |
5f06d153c37815a28a00e34134fd6d0ff99c0b8e | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_20b300d729bff2fc2c100b670c9f1348ad78e56a/Visitor/2_20b300d729bff2fc2c100b670c9f1348ad78e56a_Visitor_s.java | 06238e70538e9b1163314c676093a5a8494976f4 | []
| no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 71,072 | java | /*
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
* Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common
* Development and Distribution License("CDDL") (collectively, the
* "License"). You may not use this file except in compliance with the
* License. You can obtain a copy of the License at
* http://www.netbeans.org/cddl-gplv2.html
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
* specific language governing permissions and limitations under the
* License. When distributing the software, include this License Header
* Notice in each file and include the License file at
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the
* License Header, with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Contributor(s):
*
* The Original Software is NetBeans. The Initial Developer of the Original
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
* Microsystems, Inc. All Rights Reserved.
*
* If you wish your version of this file to be governed by only the CDDL
* or only the GPL Version 2, indicate your decision by adding
* "[Contributor] elects to include this software in this distribution
* under the [CDDL or GPL Version 2] license." If you do not indicate a
* single choice of license, a recipient has the option to distribute
* your version of this file under either the CDDL, the GPL Version 2 or
* to extend the choice of license to its licensees as provided above.
* However, if you add GPL Version 2 code and therefore, elected the GPL
* Version 2 license, then the option applies only if the new code is
* made subject to such option by the copyright holder.
*
*/
package org.netbeans.modules.javafx.editor.format;
import com.sun.javafx.api.tree.*;
import com.sun.tools.javafx.tree.JFXTree;
import com.sun.tools.javafx.tree.JFXVarScriptInit;
import org.netbeans.api.java.source.CodeStyle;
import static org.netbeans.api.java.source.CodeStyle.BracePlacement;
import org.netbeans.api.javafx.lexer.JFXTokenId;
import org.netbeans.api.javafx.source.CompilationInfo;
import org.netbeans.api.javafx.source.TreeUtilities;
import org.netbeans.api.lexer.Token;
import org.netbeans.api.lexer.TokenId;
import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.modules.editor.indent.spi.Context;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.Position;
import java.util.List;
import java.util.Queue;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
/**
* Implementation of tree path scanner to work with actual AST to provide formating.
*
* @author Rastislav Komara (<a href="mailto:[email protected]">RKo</a>)
*/
class Visitor extends JavaFXTreePathScanner<Queue<Adjustment>, Queue<Adjustment>> {
private static Logger log = Logger.getLogger(Visitor.class.getName());
private final TreeUtilities tu;
private final CompilationInfo info;
private final Context ctx;
private int indentOffset = 0;
private final CodeStyle cs;
private static final String NEW_LINE_STRING = "\n"; // NOI18N
// private static final String NEW_LINE_STRING = System.getProperty("line.separator", "\n"); // NOI18N
protected final DocumentLinesIterator li;
private static final String STRING_EMPTY_LENGTH_ONE = " "; // NOI18N
protected static final String ONE_SPACE = STRING_EMPTY_LENGTH_ONE;
private TokenSequence<TokenId> ts;
private static final String STRING_ZERO_LENGTH = ""; // NOI18N
private boolean disableContinuosIndent;
private boolean isOrphanObjectLiterar;
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org/netbeans/modules/javafx/editor/format/Bundle"); // NOI18N
private static final String REFORMAT_FAILED_BUNDLE_KEY = "Reformat_failed._"; // NOI18N
Visitor(CompilationInfo info, Context ctx, int startOffset) {
this(info, ctx);
indentOffset = startOffset;
}
Visitor(CompilationInfo info, Context ctx) {
this.info = info;
this.ctx = ctx;
tu = new TreeUtilities(info);
cs = CodeStyle.getDefault(ctx.document());
li = new DocumentLinesIterator(ctx);
}
private int getIndentStepLevel() {
return cs.getIndentSize();
}
@Override
public Queue<Adjustment> visitInitDefinition(InitDefinitionTree node, Queue<Adjustment> adjustments) {
try {
processStandaloneNode(node, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitInitDefinition(node, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitVariable(VariableTree node, Queue<Adjustment> adjustments) {
if (node instanceof JFXVarScriptInit) return adjustments;
try {
if (isSynthetic((JFXTree) node)) {
super.visitVariable(node, adjustments);
return adjustments;
}
final int start = getStartPos(node);
if (!holdOnLine(getParent())) {
hasComment(node, adjustments);
indentLine(start, adjustments);
}
verifyVarSpaces(node, adjustments);
if (isMultiline(node) && node.getOnReplaceTree() == null) {
/*li.moveTo(start);
if (li.hasNext()) {
indentMultiline(li, getEndPos(node), adjustments);
}*/
indentEndLine(node, adjustments);
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitVariable(node, adjustments);
return adjustments;
}
private void hasComment(Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
hasComment(node, adjustments, (TokenSequence<JFXTokenId>) ts());
}
private void indentLine(Element line, Queue<Adjustment> adjustments) throws BadLocationException {
final int ls = ctx.lineStartOffset(line.getStartOffset());
indentLine(ls, adjustments);
}
private void indentLine(int ls, Queue<Adjustment> adjustments) throws BadLocationException {
indentLine(ls, adjustments, indentOffset);
}
private void indentLine(int ls, Queue<Adjustment> adjustments, int indent) throws BadLocationException {
if (ctx.lineIndent(ctx.lineStartOffset(ls)) != indent) {
adjustments.offer(Adjustment.indent(createPosition(ls), indent));
}
}
/* @Override
public Queue<Adjustment> visitExpressionStatement(ExpressionStatementTree node, Queue<Adjustment> adjustments) {
try {
processStandaloneNode(node, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE)) log.severe("Reformat failed. " + e);
}
super.visitExpressionStatement(node, adjustments);
return adjustments;
}
*/
private void processStandaloneNode(Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
final int position = getStartPos(node);
if (isFirstOnLine(position)) {
hasComment(node, adjustments);
indentLine(position, adjustments);
} else {
adjustments.offer(Adjustment.add(createPosition(position), NEW_LINE_STRING));
adjustments.offer(Adjustment.indent(createPosition(position + 1), indentOffset));
}
if (isMultiline(node)) {
indentLine(getEndPos(node), adjustments);
}
}
@Override
public Queue<Adjustment> visitIdentifier(IdentifierTree node, Queue<Adjustment> adjustments) {
try {
// if (isWidow(node)) {
if (isFirstOnLine(getStartPos(node))
&& getCurrentPath().getParentPath().getLeaf().getJavaFXKind() != Tree.JavaFXKind.INSTANTIATE_OBJECT_LITERAL) {
final int position = getStartPos(node);
indentLine(position, adjustments);
hasComment(node, adjustments);
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitIdentifier(node, adjustments);
return adjustments;
}
// private boolean isWidow(Tree node) throws BadLocationException {
// final int endPos = getEndPos(node);
// int start = getStartPos(node);
//
// return isWidow(endPos, start);
// }
private boolean isWidow(int endPos, int start) throws BadLocationException {
boolean probablyWidow = false;
final TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(endPos);
while (ts.moveNext()) {
if (JFXTokenId.WS == ts.token().id()) {
if (NEW_LINE_STRING.equals(ts.token().text().toString())) {
probablyWidow = true;
break;
}
continue;
}
break;
}
return probablyWidow && isFirstOnLine(start);
}
@Override
public Queue<Adjustment> visitUnary(UnaryTree node, Queue<Adjustment> adjustments) {
return super.visitUnary(node, adjustments);
}
@Override
public Queue<Adjustment> visitBinary(BinaryTree node, Queue<Adjustment> adjustments) {
final Tree tree = getParent();
if (tree instanceof BinaryTree) {
super.visitBinary((BinaryTree) tree, adjustments);
return adjustments;
}
try {
boolean blockRetVal = tree instanceof BlockExpressionTree && ((BlockExpressionTree) tree).getValue() == node;
if (!holdOnLine(tree) && !blockRetVal) {
hasComment(node, adjustments);
processStandaloneNode(node, adjustments);
} else if (blockRetVal) {
indentReturn(node, adjustments);
}
final int offset = getStartPos(node);
final int end = getEndPos(node);
final TokenSequence<JFXTokenId> ts = ts(node);
ts.move(offset);
while (ts.moveNext() && ts.offset() <= end) {
if ("operator".equals(ts.token().id().primaryCategory())) {
if (cs.spaceAroundBinaryOps()) {
int operatorOffset = ts.offset();
if (ts.movePrevious() && ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.add(createPosition(operatorOffset), ONE_SPACE));
}
if (!ts.moveNext())
throw new BadLocationException(BUNDLE.getString("Concurent_modification_has_occured_on_document."), ts.offset()); // NOI18N
if (ts.moveNext() && ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.add(createPosition(ts.offset()), ONE_SPACE));
}
}
}
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitBinary(node, adjustments);
return adjustments;
}
private void indentReturn(Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
int start = getStartPos(node);
ts.move(start);
boolean terminate;
while (ts.movePrevious()) {
switch (ts.token().id()) {
case WS:
if ("\n".equals(ts.token().text())) {
terminate = true;
break;
}
continue;
case RETURN:
start = ts.offset();
terminate = true;
break;
default:
terminate = true;
break;
}
if (terminate) break;
}
if (isFirstOnLine(start)) {
hasComment(adjustments, ts, start);
indentLine(start, adjustments);
} else {
adjustments.offer(Adjustment.add(createPosition(start), NEW_LINE_STRING));
adjustments.offer(Adjustment.indent(createPosition(start + 1), indentOffset));
}
}
private TokenSequence<JFXTokenId> ts(Tree node) {
return tu.tokensFor(node);
}
@SuppressWarnings({"MethodWithMoreThanThreeNegations"})
@Override
public Queue<Adjustment> visitObjectLiteralPart(ObjectLiteralPartTree node, Queue<Adjustment> adjustments) {
try {
final int offset = getStartPos(node);
if (isFirstOnLine(offset)) {
hasComment(node, adjustments);
indentLine(offset, adjustments);
} else if (!isOrphanObjectLiterar) {
adjustments.offer(Adjustment.add(createPosition(offset), NEW_LINE_STRING));
adjustments.offer(Adjustment.indent(createPosition(offset + 1), indentOffset));
}
boolean hasContinuosIndent = isMultiline(node) && !isOnSameLine(node, node.getExpression());
if (hasContinuosIndent) {
indentOffset = indentOffset + getCi();
}
super.visitObjectLiteralPart(node, adjustments);
verifyBraces(node, adjustments, cs.getMethodDeclBracePlacement(), cs.spaceBeforeMethodDeclLeftBrace(), false);
if (isMultiline(node) && !endsOnSameLine(node, getParent()) && !isSpecialCase(node)) {
indentEndLine(node, adjustments);
}
//verify spaces ocurence.
verifyOLPTSpaces(node, adjustments);
if (hasContinuosIndent) {
indentOffset = indentOffset - getCi();
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private boolean isSpecialCase(ObjectLiteralPartTree node) {
if (node.getExpression() instanceof ForExpressionTree) {
ForExpressionTree t = (ForExpressionTree) node.getExpression();
return !(t.getBodyExpression() instanceof BlockExpressionTree);
}
return false;
}
private void verifyOLPTSpaces(ObjectLiteralPartTree node, Queue<Adjustment> adjustments) throws BadLocationException {
TokenSequence<JFXTokenId> ts = ts(node);
// INDETIFIER WS* COLON WS+ ANY
verifySpacesAroundColon(adjustments, ts);
}
@SuppressWarnings({"MethodWithMultipleLoops"})
// NOI18N
private void verifyVarSpaces(VariableTree node, Queue<Adjustment> adjustments) throws BadLocationException {
TokenSequence<JFXTokenId> ts = ts(node);
while (ts.moveNext()) {
JFXTokenId id = ts.token().id();
switch (id) {
case WS:
case PUBLIC:
case PUBLIC_INIT:
case PUBLIC_READ:
case PUBLIC_READABLE:
case PRIVATE:
case STATIC:
case PROTECTED:
case DEF:
case VAR:
case NON_WRITABLE:
case OVERRIDE:
case READABLE:
case REPLACE:
continue;
case IDENTIFIER:
ts.movePrevious();
verifySpacesAroundColon(adjustments, ts);
return;
default:
return;
}
}
}
@SuppressWarnings({"MethodWithMultipleLoops", "OverlyNestedMethod", "OverlyComplexMethod", // NOI18N
"MethodWithMoreThanThreeNegations", "OverlyLongMethod" }) // NOI18N
private void verifySpacesAroundColon(Queue<Adjustment> adjustments, TokenSequence<JFXTokenId> ts) throws BadLocationException {
// INDETIFIER WS* (COLON|EQ) WS+ ANY
if (ts.moveNext()) {
if (ts.token().id() == JFXTokenId.IDENTIFIER) {
int start = ts.offset() + ts.token().length();
boolean terminate = false;
while (!terminate && ts.moveNext()) {
JFXTokenId id = ts.token().id();
switch (id) {
case WS:
continue;
case COLON: {
if (ts.offset() != start) {
adjustments.offer(Adjustment.delete(createPosition(start), createPosition(ts.offset())));
}
terminate = true;
break;
}
case EQ: {
int length = ts.offset() - start;
if (cs.spaceAroundAssignOps()) {
if (length != 1) {
adjustments.offer(Adjustment.replace(createPosition(start), createPosition(ts.offset()), ONE_SPACE));
}
} else if (length != 0) {
adjustments.offer(Adjustment.delete(createPosition(start), createPosition(ts.offset())));
}
terminate = true;
break;
}
default: return;
}
}
// verifying spaces beyond COLON
start = ts.offset() + ts.offsetToken().length();
skipWS(ts);
if (ts.offset() - start > 1) {
adjustments.offer(Adjustment.replace(createPosition(start), createPosition(ts.offset()), STRING_EMPTY_LENGTH_ONE));
} else if (ts.offset() == start) {
adjustments.offer(Adjustment.add(createPosition(ts.offset()), STRING_EMPTY_LENGTH_ONE));
}
}
}
}
private void skipWS(TokenSequence<JFXTokenId> ts, boolean forward) {
while ((forward ? ts.moveNext() : ts.movePrevious()) && ts.token().id() == JFXTokenId.WS) {
}
}
private void skipWS(TokenSequence<JFXTokenId> ts) {
skipWS(ts, true);
}
private Position createPosition(int offset) throws BadLocationException {
return ctx.document().createPosition(offset);
}
private Tree getParent() {
return getCurrentPath().getParentPath().getLeaf();
}
@Override
public Queue<Adjustment> visitOnReplace(OnReplaceTree node, Queue<Adjustment> adjustments) {
try {
hasComment(node, adjustments);
int start = getStartPos(node);
boolean firstOnLine = isFirstOnLine(start);
if (firstOnLine) {
indentOffset += getCi();
indentLine(start, adjustments);
}
super.visitOnReplace(node, adjustments);
if (firstOnLine) {
indentOffset -= getCi();
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private boolean isOnSameLine(Tree node, Tree tree) throws BadLocationException {
int index1 = getStartPos(node);
int index2 = getStartPos(tree);
return isOnSameLine(index1, index2);
}
private boolean isOnSameLine(int index1, int index2) throws BadLocationException {
return ctx.lineStartOffset(index1) == ctx.lineStartOffset(index2);
}
@Override
public Queue<Adjustment> visitSequenceDelete(SequenceDeleteTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
incIndent();
super.visitSequenceDelete(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private void decIndent() {
indentOffset = indentOffset - getIndentStepLevel();
}
private void incIndent() {
indentOffset = indentOffset + getIndentStepLevel();
}
private void indentSimpleStructure(Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
int start = getStartPos(node);
if (isFirstOnLine(start)) {
hasComment(node, adjustments);
indentLine(start, adjustments);
}
if (isMultiline(node)) {
indentLine(getEndPos(node), adjustments);
}
}
@Override
public Queue<Adjustment> visitIndexof(IndexofTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitEmptyStatement(EmptyStatementTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitBreak(BreakTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
/* @Override
public Queue<Adjustment> visitPrimitiveType(PrimitiveTypeTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
*/
@Override
public Queue<Adjustment> visitContinue(ContinueTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitSequenceEmpty(SequenceEmptyTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
incIndent();
super.visitSequenceEmpty(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
@Override
public Queue<Adjustment> visitSequenceExplicit(SequenceExplicitTree node, Queue<Adjustment> adjustments) {
try {
disableContinuosIndent = true;
// indentSimpleStructure(node, adjustments);
int start = getStartPos(node);
if (isFirstOnLine(start)) {
hasComment(node, adjustments);
indentLine(start, adjustments);
}
ExpressionTree tree = null;
List<ExpressionTree> trees = node.getItemList();
if (!trees.isEmpty()) {
tree = trees.get(trees.size() - 1);
}
boolean format = tree != null/* && !endsOnSameLine(tree, node)*/;
if (isMultiline(node) && format) {
indentLine(getEndPos(node), adjustments);
}
incIndent();
super.visitSequenceExplicit(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
} finally {
disableContinuosIndent = false;
}
return adjustments;
}
@Override
public Queue<Adjustment> visitMemberSelect(MemberSelectTree node, Queue<Adjustment> adjustments) {
return super.visitMemberSelect(node, adjustments);
}
@Override
public Queue<Adjustment> visitInterpolateValue(InterpolateValueTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitInterpolateValue(node, adjustments);
return adjustments;
}
/*
@Override
public Queue<Adjustment> visitSequenceIndexed(SequenceIndexedTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
incIndent();
super.visitSequenceIndexed(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE)) log.severe("Reformat failed. " + e);
}
return adjustments;
}
*/
@Override
public Queue<Adjustment> visitSequenceSlice(SequenceSliceTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
incIndent();
super.visitSequenceSlice(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
// @Override
// public Queue<Adjustment> visitSequenceInsert(SequenceInsertTree node, Queue<Adjustment> adjustments) {
// try {
// indentSimpleStructure(node, adjustments);
// incIndent();
// super.visitSequenceInsert(node, adjustments);
// decIndent();
// } catch (BadLocationException e) {
// if (log.isLoggable(Level.SEVERE)) log.severe("Reformat failed. " + e);
// }
// return adjustments;
// }
@Override
public Queue<Adjustment> visitSequenceRange(SequenceRangeTree node, Queue<Adjustment> adjustments) {
try {
indentSimpleStructure(node, adjustments);
incIndent();
super.visitSequenceRange(node, adjustments);
decIndent();
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private void indentMultiline(LineIterator<Element> li, int endOffset, Queue<Adjustment> adjustments) throws BadLocationException {
// final int ci = getCi();
// if (li.hasNext()) {
// indentOffset = indentOffset + ci;
// while (li.hasNext()) {
// final Element element = li.next();
// if (element.getStartOffset() > endOffset) {
// break;
// }
// indentLine(element, adjustments);
// }
// indentOffset = indentOffset - ci;
// }
}
private boolean isMultiline(Tree tree) throws BadLocationException {
return ctx.lineStartOffset(getStartPos(tree)) != ctx.lineStartOffset(getEndPos(tree));
}
private boolean holdInvocationChain = false;
private Tree starter;
@Override
public Queue<Adjustment> visitMethodInvocation(FunctionInvocationTree node, Queue<Adjustment> adjustments) {
try {
if (!holdInvocationChain) {
if (!holdOnLine(getParent())) {
processStandaloneNode(node, adjustments);
} else {
indentSimpleStructure(node, adjustments);
}
starter = node;
}
List<? extends ExpressionTree> trees = node.getArguments();
scan(trees, adjustments);
holdInvocationChain = true;
scan(node.getMethodSelect(), adjustments);
holdInvocationChain = (starter != node);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
@Override
public Queue<Adjustment> visitFunctionValue(FunctionValueTree node, Queue<Adjustment> adjustments) {
/*final Tree tree = getParent();
if (tree instanceof FunctionDefinitionTree) {
super.visitFunctionValue(node, adjustments);
} else {
try {
if (isFirstOnLine(getStartPos(node))) {
hasComment(node, adjustments);
indentLine(getStartPos(node), adjustments);
}
verifyFunctionSpaces(ts(node), node, adjustments);
super.visitFunctionValue(node, adjustments);
indentLine(getEndPos(node), adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
}*/
super.visitFunctionValue(node, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitFunctionDefinition(FunctionDefinitionTree node, Queue<Adjustment> adjustments) {
if (isSynthetic((JFXTree) node)) {
super.visitFunctionDefinition(node, adjustments);
return adjustments;
}
final TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
try {
int index = node.getModifiers() != null ? getEndPos(node.getModifiers()) : getStartPos(node);
processStandaloneNode(node, adjustments);
ts.move(index);
while (ts.moveNext()) {
final JFXTokenId id = ts.token().id();
switch (id) {
case WS:
continue;
case FUNCTION:
verifyFunctionSpaces(ts, node, adjustments);
break;
default:
break;
}
break;
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitFunctionDefinition(node, adjustments);
return adjustments;
}
private void hasComment(Tree node, Queue<Adjustment> adjustments, TokenSequence<JFXTokenId> ts) throws BadLocationException {
int index = getStartPos(node);
hasComment(adjustments, ts, index);
}
private void hasComment(Queue<Adjustment> adjustments, TokenSequence<JFXTokenId> ts, int index) throws BadLocationException {
if (isPrecededByComment(ts, index)) {
reformatComment(ts, index, adjustments);
}
}
private void reformatComment(TokenSequence<JFXTokenId> ts, int pos, Queue<Adjustment> adjustments) throws BadLocationException {
int start = pos;
while (isPrecededByComment(ts, start)) {
start = ts.offset() - 1;
// start = ctx.lineStartOffset(ts.offset());
}
LineIterator<Element> li = new DocumentLinesIterator(ctx, start);
// indentLines(pos, adjustments, li);
int oldIndent = indentOffset;
indentCommentLines(ts, pos, adjustments, li, oldIndent);
indentOffset = oldIndent;
}
private void indentCommentLines(TokenSequence<JFXTokenId> ts, int pos, Queue<Adjustment> adjustments, LineIterator<Element> li, int oldIndent) throws BadLocationException {
while (li.hasNext()) {
Element element = li.get();
if (element.getEndOffset() <= pos) {
indentLine(element, adjustments);
int index = element.getStartOffset();
ts.move(index);
if (ts.moveNext()) {
JFXTokenId id = ts.token().id();
if (id == JFXTokenId.DOC_COMMENT || id == JFXTokenId.COMMENT) {
indentOffset = oldIndent + 1;
}
}
li.next();
} else {
break;
}
}
}
private boolean isPrecededByComment(TokenSequence<JFXTokenId> ts, int pos) {
ts.move(pos);
while (ts.movePrevious()) {
JFXTokenId tid = ts.token().id();
if (tid == JFXTokenId.WS) continue;
if (JFXTokenId.isComment(tid)) return true;
return false;
}
return false;
}
private void verifyFunctionSpaces(TokenSequence<JFXTokenId> ts, Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
if (ts.moveNext() && ts.token().id() == JFXTokenId.IDENTIFIER) {
if (cs.spaceBeforeMethodDeclLeftBrace()) {
if (ts.moveNext() && ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.add(createPosition(ts.offset()), ONE_SPACE));
} else {
verifyNextIs(JFXTokenId.LPAREN, ts, adjustments, true);
}
} else {
verifyNextIs(JFXTokenId.LPAREN, ts, adjustments, true);
}
}
verifyBraces(node, adjustments, cs.getMethodDeclBracePlacement(), cs.spaceBeforeMethodDeclLeftBrace(), true);
if (!holdOnLine(getParent())) {
processStandaloneNode(node, adjustments);
}
}
private void verifyNextIs(JFXTokenId id, TokenSequence<JFXTokenId> ts, Queue<Adjustment> adjustments, boolean moveNext) throws BadLocationException {
if ((moveNext ? ts.moveNext() : ts.movePrevious()) && ts.token().id() != id) {
int startOffset = ts.offset() + (moveNext ? 0 : ts.token().length());
while (moveNext ? ts.moveNext() : ts.movePrevious()) {
if (ts.token().id() == id) {
adjustments.offer(
Adjustment.delete(createPosition(startOffset),
createPosition(ts.offset() + (moveNext ? 0 : ts.token().length()))));
}
}
}
}
@SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod"}) // NOI18N
private void verifyBraces(Tree node, Queue<Adjustment> adjustments, BracePlacement bp, boolean spaceBeforeLeftBrace, boolean checkEndBrace) throws BadLocationException {
final TokenSequence<JFXTokenId> ts = tu.tokensFor(node);
Token<JFXTokenId> obrace = moveTo(ts, JFXTokenId.LBRACE);
if (obrace != null) {
int obraceTokenStart = ts.offset();
boolean nlFound = false;
while (ts.movePrevious()) {
if (ts.token().id() != JFXTokenId.WS) {
break;
} else {
final CharSequence cs = ts.token().text();
if ("\n".equals(cs.toString())) {
nlFound = true;
}
}
}
final Document doc = ctx.document();
int oldIndent = indentOffset;
switch (bp) {
case SAME_LINE:
if (nlFound || (obraceTokenStart - (ts.offset() + ts.token().length()) > 1)) {
adjustments.offer(Adjustment.replace(doc.createPosition(ts.offset() + ts.token().length()),
doc.createPosition(obraceTokenStart),
spaceBeforeLeftBrace ? ONE_SPACE : STRING_ZERO_LENGTH));
}
break;
case NEW_LINE:
verifyNL(adjustments, ts, obraceTokenStart, nlFound);
break;
case NEW_LINE_HALF_INDENTED:
verifyNL(adjustments, ts, obraceTokenStart, nlFound);
indentOffset = indentOffset + (getIndentStepLevel() / 2);
adjustments.offer(Adjustment.indent(doc.createPosition(obraceTokenStart), indentOffset));
break;
case NEW_LINE_INDENTED:
verifyNL(adjustments, ts, obraceTokenStart, nlFound);
incIndent();
adjustments.offer(Adjustment.indent(doc.createPosition(obraceTokenStart), indentOffset));
break;
}
if (checkEndBrace) {
checkEndBrace(node, adjustments, ts);
}
// indentEndLine(node, adjustments);
indentOffset = oldIndent;
}
}
private void checkEndBrace(Tree node, Queue<Adjustment> adjustments, TokenSequence<JFXTokenId> ts) throws BadLocationException {
if (log.isLoggable(Level.INFO)) log.info("isOrphanObjectLiterar? " + isOrphanObjectLiterar);
if (isOrphanObjectLiterar) return;
Document doc = ctx.document();
final int end = getEndPos(node);
ts.move(end); //getting into last token...
if (ts.movePrevious() && ts.token().id() != JFXTokenId.RBRACE) {
return;
}
while (ts.movePrevious()) {
final JFXTokenId id = ts.token().id();
switch (id) {
case WS: {
final CharSequence cs = ts.token().text();
if (cs != null && "\n".equals(cs.toString())) {
indentEndLine(node, adjustments);
return;
}
continue;
}
default: {
adjustments.offer(Adjustment.add(doc.createPosition(end - 1), NEW_LINE_STRING));
adjustments.offer(Adjustment.indent(doc.createPosition(end), indentOffset));
return;
}
}
}
}
private SourcePositions sp() {
return info.getTrees().getSourcePositions();
}
private void verifyNL(Queue<Adjustment> adjustments, TokenSequence<JFXTokenId> ts, int originTokenStart, boolean nlFound) throws BadLocationException {
if (!nlFound || (originTokenStart - (ts.offset() + ts.token().length()) > 1)) {
adjustments.offer(Adjustment.replace(createPosition(ts.offset() + ts.token().length()),
createPosition(originTokenStart), NEW_LINE_STRING));
}
}
private Token<JFXTokenId> moveTo(TokenSequence<JFXTokenId> ts, JFXTokenId id) {
while (ts.moveNext()) {
if (ts.token().id() == id) {
return ts.token();
}
}
return null;
}
private UnitTree cu() {
return info.getCompilationUnit();
}
@SuppressWarnings({"unchecked"}) // NOI18N
private /*<T extends TokenId> */TokenSequence<? extends TokenId> ts() {
if (ts != null && ts.isValid()) {
return (TokenSequence) ts;
}
this.ts = info.getTokenHierarchy().tokenSequence(JFXTokenId.language());
return (TokenSequence) this.ts;
}
@Override
public Queue<Adjustment> visitAssignment(AssignmentTree node, Queue<Adjustment> adjustments) {
try {
processStandaloneNode(node, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitAssignment(node, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitInstantiate(InstantiateTree node, Queue<Adjustment> adjustments) {
try {
final int offset = getStartPos(node);
final Tree tree = getParent();
boolean hold = holdOnLine(tree);
boolean blockRetVal = tree instanceof BlockExpressionTree && ((BlockExpressionTree) tree).getValue() == node;
if (!blockRetVal && (!hold || isFirstOnLine(offset))) {
processStandaloneNode(node, adjustments);
} else if (blockRetVal) {
indentReturn(node, adjustments);
}
incIndent();
isOrphanObjectLiterar = node.getLiteralParts() == null || node.getLiteralParts().size() == 1;
super.visitInstantiate(node, adjustments);
decIndent();
// if (isOrphanObjectLiterar) {
// //TODO: [RKo] keep on same line!.
// int endPos = getEndPos(node);
// if (!isOnSameLine(offset, endPos)) {
// TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
// ts.move(endPos);
// if (ts.movePrevious()) {
// skipWS(ts, false);
// if (ts.moveNext()) {
// adjustments.offer(Adjustment.delete(createPosition(ts.offset()), createPosition(endPos - 1 )));
// }
// }
// }
// } else if (isMultiline(node) && !endsOnSameLine(tree, node)) {
indentEndLine(node, adjustments);
// }
isOrphanObjectLiterar = false;
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private boolean endsOnSameLine(Tree tree, Tree node) throws BadLocationException {
if (isSynthetic((JFXTree) tree) || isSynthetic((JFXTree) node)) return false;
return isOnSameLine(getEndPos(node), getEndPos(tree));
}
private boolean holdOnLine(Tree tree) {
return tree instanceof ReturnTree
|| tree instanceof VariableTree
|| tree instanceof AssignmentTree
|| tree instanceof UnaryTree
|| tree instanceof BinaryTree
|| tree instanceof CatchTree
|| tree instanceof ConditionalExpressionTree
|| tree instanceof ObjectLiteralPartTree
|| tree instanceof FunctionValueTree
|| tree instanceof SequenceExplicitTree
|| tree instanceof SequenceInsertTree
|| tree instanceof SequenceDeleteTree
|| tree instanceof FunctionInvocationTree
|| tree instanceof OnReplaceTree
|| tree instanceof ForExpressionInClauseTree;
}
private void indentEndLine(Tree node, Queue<Adjustment> adjustments) throws BadLocationException {
final int endPos = getEndPos(node);
final TokenSequence<JFXTokenId> ts = ts(node);
ts.move(endPos);
boolean shouldIndent = false;
while (ts.movePrevious()) {
final JFXTokenId id = ts.token().id();
switch (id) {
case RBRACE:
case RPAREN: {
shouldIndent = true;
continue;
}
case WS: {
final CharSequence cs = ts.token().text();
if (cs != null && "\n".equals(cs.toString()) && shouldIndent) { // NOI18N
indentLine(endPos, adjustments);
return;
}
continue;
}
default:
return;
}
}
}
private int getEndPos(Tree node) {
return (int) sp().getEndPosition(cu(), node);
}
private int getStartPos(Tree node) {
int start = (int) sp().getStartPosition(cu(), node);
//noinspection unchecked
TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(start);
while (ts.movePrevious()) {
JFXTokenId id = ts.token().id();
switch (id) {
case WS:
continue;
case LPAREN:
return ts.offset();
default:
return start;
}
}
return start;
/*int modifiersStart = getModifiersStart(node);
return Math.min(nodeStart, modifiersStart);*/
}
/*
private int getModifiersStart(Tree node) {
if (node instanceof ClassDeclarationTree) {
ClassDeclarationTree tree = (ClassDeclarationTree) node;
return includeModifiers(tree.getModifiers());
} else if (node instanceof FunctionDefinitionTree) {
FunctionDefinitionTree tree = (FunctionDefinitionTree) node;
return includeModifiers(tree.getModifiers());
} else if (node instanceof VariableTree) {
VariableTree tree = (VariableTree) node;
return includeModifiers(tree.getModifiers());
}
return Integer.MAX_VALUE;
}
*/
/*
private int includeModifiers(ModifiersTree modifiers) {
final int startPos = getStartPos(modifiers);
if (startPos < 0) return Integer.MAX_VALUE;
return startPos;
}
*/
@Override
public Queue<Adjustment> visitCompilationUnit(UnitTree node, Queue<Adjustment> adjustments) {
return super.visitCompilationUnit(node, adjustments);
}
@SuppressWarnings({"OverlyLongMethod"}) // NOI18N
@Override
public Queue<Adjustment> visitClassDeclaration(ClassDeclarationTree node, Queue<Adjustment> adjustments) {
if (isSynthetic((JFXTree) node)) {
super.visitClassDeclaration(node, adjustments);
return adjustments;
}
final Document doc = ctx.document();
try {
final int sp = getStartPos(node);
int elc = cs.getBlankLinesBeforeClass();
processStandaloneNode(node, adjustments);
if (!isFirstOnLine(sp) && !holdOnLine(getParent())) {
adjustments.offer(Adjustment.add(createPosition(sp), buildString(elc, NEW_LINE_STRING).toString()));
adjustments.offer(Adjustment.indent(createPosition(sp + elc + 1), indentOffset));
} else {
int pos = ctx.lineStartOffset(sp);
indentLine(pos, adjustments);
final Tree tree = getParent();
if (tree instanceof UnitTree || tree instanceof ClassDeclarationTree) {
pos = skipPreviousComment(pos);
int emptyLines = getEmptyLinesBefore(li, pos);
elc = elc - emptyLines;
if (elc < 0) {
Element nth = getNthElement(Math.abs(elc), li);
if (nth != null) {
adjustments.offer(Adjustment.delete(doc.createPosition(nth.getStartOffset()), doc.createPosition(pos)));
}
} else if (elc > 0) {
StringBuilder sb = buildString(elc, NEW_LINE_STRING);
adjustments.offer(Adjustment.add(doc.createPosition(pos), sb.toString()));
}
}
}
incIndent();
super.visitClassDeclaration(node, adjustments);
decIndent();
verifyBraces(node, adjustments, cs.getClassDeclBracePlacement(), cs.spaceBeforeClassDeclLeftBrace(), true);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
private boolean isSynthetic(JFXTree node) {
// JFXTree tree = (JFXTree) getCurrentPath().getLeaf();
if (node instanceof BlockExpressionTree) {
JavaFXTreePath pp = getCurrentPath().getParentPath();
if (pp != null && pp instanceof FunctionValueTree) {
pp = pp.getParentPath();
JFXTree tree = (JFXTree) pp.getLeaf();
if (tree instanceof FunctionDefinitionTree) {
return synthetic(tree);
}
}
}
return synthetic(node);
}
private boolean synthetic(JFXTree node) {
return node.getGenType() == SyntheticTree.SynthType.SYNTHETIC || getStartPos(node) == getEndPos(node);
}
private Tree firstImport;
private Tree lastImport;
@Override
public Queue<Adjustment> visitImport(ImportTree importTree, Queue<Adjustment> adjustments) {
if (log.isLoggable(Level.FINE)) log.fine("Visiting import" + importTree); // NOI18N
try {
final int ls = ctx.lineStartOffset(getStartPos(importTree));
processStandaloneNode(importTree, adjustments);
if (firstImport == null) {
firstImport = getFirstImport();
}
if (lastImport == null) {
lastImport = getLastImport();
}
if (importTree.equals(firstImport)) {
li.moveTo(ls);
final int lines = getEmptyLinesBefore(li, ls);
final int linesBeforeImports = cs.getBlankLinesBeforeImports();
if (linesBeforeImports != lines) {
adjustLinesBefore(lines, linesBeforeImports, adjustments, li, ls);
}
}
if (importTree.equals(lastImport)) {
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitImport(importTree, adjustments);
return adjustments;
}
private Tree getLastImport() {
final List<? extends ImportTree> trees = getCurrentPath().getCompilationUnit().getImports();
if (!trees.isEmpty()) {
return trees.get(trees.size() - 1);
}
return null;
}
private Tree getFirstImport() {
final List<? extends ImportTree> trees = getCurrentPath().getCompilationUnit().getImports();
if (!trees.isEmpty()) {
return trees.get(0);
}
return null;
}
private void adjustLinesBefore(int realLines, int linesRequired, Queue<Adjustment> list, LineIterator<Element> li, int pos) throws BadLocationException {
linesRequired = linesRequired - realLines;
if (linesRequired < 0) {
Element nth = getNthElement(Math.abs(linesRequired), li);
if (nth != null) {
list.add(Adjustment.delete(createPosition(nth.getStartOffset()), createPosition(pos)));
}
} else if (linesRequired > 0) {
StringBuilder sb = buildString(linesRequired, NEW_LINE_STRING);
list.add(Adjustment.add(createPosition(pos), sb.toString()));
}
}
private boolean isFirstOnLine(int offset) throws BadLocationException {
final int ls = ctx.lineStartOffset(offset);
final Document doc = ctx.document();
final String s = doc.getText(ls, offset - ls);
return isEmpty(s);
}
@Override
public Queue<Adjustment> visitCompoundAssignment(CompoundAssignmentTree node, Queue<Adjustment> adjustments) {
/*
if (getCurrentPath().getParentPath().getLeaf() instanceof ExpressionStatementTree) {
return adjustments;
}*/
try {
processStandaloneNode(node, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitCompoundAssignment(node, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitReturn(ReturnTree returnTree, Queue<Adjustment> adjustments) {
try {
processStandaloneNode(returnTree, adjustments);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
super.visitReturn(returnTree, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitStringExpression(StringExpressionTree node, Queue<Adjustment> adjustments) {
try {
boolean ml = isMultiline(node);
if (!(ml || isFirstOnLine(getStartPos(node)))) {
return adjustments;
}
hasComment(node, adjustments);
if (ml) {
li.moveTo(getStartPos(node));
int endPos = getEndPos(node);
//second line.
// int indent = indentOffset + getCi();
incIndent();
while (li.hasNext()) {
Element element = li.next();
if (element.getEndOffset() >= endPos) {
break;
}
indentLine(element.getStartOffset(), adjustments);
}
}
// super.visitStringExpression(node, adjustments);
List<ExpressionTree> trees = node.getPartList();
trees = trees.subList(1, trees.size() - 2);
scan(trees, adjustments);
if (ml) {
decIndent();
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
@Override
public Queue<Adjustment> visitLiteral(LiteralTree literalTree, Queue<Adjustment> adjustments) {
try {
final int offset = getStartPos(literalTree);
if (isFirstOnLine(offset)) {
hasComment(literalTree, adjustments);
indentLine(offset, adjustments, indentOffset);
// indentLine(offset, adjustments, isWidow(literalTree) ? indentOffset : (indentOffset + getCi()));
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e); // NOI18N
}
return adjustments;
}
@Override
public Queue<Adjustment> visitTimeLiteral(TimeLiteralTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitTypeAny(TypeAnyTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitTypeUnknown(TypeUnknownTree node, Queue<Adjustment> adjustments) {
return adjustments;
}
@Override
public Queue<Adjustment> visitWhileLoop(WhileLoopTree node, Queue<Adjustment> adjustments) {
try {
hasComment(node, adjustments);
verifySpaceBefore(node, adjustments, cs.spaceBeforeWhile());
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeWhileLeftBrace(), true);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
super.visitWhileLoop(node, adjustments);
return adjustments;
}
private void verifySpaceBefore(Tree node, Queue<Adjustment> adjustments, boolean spaceBefore) throws BadLocationException {
final int start = getStartPos(node);
verifySpaceBefore(adjustments, spaceBefore, start);
}
private void verifySpaceBefore(Queue<Adjustment> adjustments, boolean spaceBefore, int start) throws BadLocationException {
if (!isFirstOnLine(start) && spaceBefore) {
//noinspection unchecked
final TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(start);
if (ts.movePrevious() && ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.add(toPos(start), STRING_EMPTY_LENGTH_ONE));
}
}
}
@Override
public Queue<Adjustment> visitForExpression(ForExpressionTree node, Queue<Adjustment> adjustments) {
try {
if (!holdOnLine(getParent())) {
processStandaloneNode(node, adjustments);
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeWhileLeftBrace(), true);
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
boolean followedByBlock = node.getBodyExpression() instanceof BlockExpressionTree;
if (!followedByBlock) {
incIndent();
}
super.visitForExpression(node, adjustments);
if (!followedByBlock) {
decIndent();
}
return adjustments;
}
@Override
// public Queue<Adjustment> visitIf(IfTree node, Queue<Adjustment> adjustments) {
public Queue<Adjustment> visitConditionalExpression(ConditionalExpressionTree node, Queue<Adjustment> adjustments) {
try {
if (!isPreceededByElse(node)) {
processStandaloneNode(node, adjustments);
}
verifyBraces(node.getTrueExpression(), adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeIfLeftBrace(), true);
verifySpaceBefore(node.getFalseExpression(), adjustments, cs.spaceBeforeElse());
verifyBraces(node.getFalseExpression(), adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeElseLeftBrace(), true);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
// super.visitIf(node, adjustments);
super.visitConditionalExpression(node, adjustments);
return adjustments;
}
private boolean isPreceededByElse(ConditionalExpressionTree node) {
TokenSequence<? extends TokenId> ts = ts();
ts.move(getStartPos(node));
while (ts.movePrevious()) {
JFXTokenId id = (JFXTokenId) ts.token().id();
switch (id) {
case WS:
continue;
case ELSE:
return true;
default:
return false;
}
}
return false;
}
private Position toPos(int index) throws BadLocationException {
return createPosition(index);
}
@Override
public Queue<Adjustment> visitTry(TryTree node, Queue<Adjustment> adjustments) {
try {
processStandaloneNode(node, adjustments);
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeTryLeftBrace(), true);
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
super.visitTry(node, adjustments);
return adjustments;
}
@Override
public Queue<Adjustment> visitCatch(CatchTree node, Queue<Adjustment> adjustments) {
try {
final int start = getStartPos(node);
if (cs.placeCatchOnNewLine() && !isFirstOnLine(start)) {
adjustments.offer(Adjustment.add(toPos(start), NEW_LINE_STRING));
adjustments.offer(Adjustment.indent(toPos(start + 1), indentOffset));
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeCatchLeftBrace(), true);
verifyParens(node, adjustments, cs.spaceBeforeCatchParen(), false);
} else if (!cs.placeCatchOnNewLine() && isFirstOnLine(start)) {
final TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(start);
while (ts.movePrevious()) {
if (ts.token().id() == JFXTokenId.RBRACE) {
adjustments.offer(Adjustment.replace(toPos(ts.offset() + ts.token().length()),
toPos(start), cs.spaceBeforeCatch() ? STRING_EMPTY_LENGTH_ONE : STRING_ZERO_LENGTH));
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeCatchLeftBrace(), true);
verifyParens(node, adjustments, cs.spaceBeforeCatchParen(), false);
break;
}
}
} else {
verifySpaceBefore(node, adjustments, cs.spaceBeforeCatch() && !cs.placeCatchOnNewLine());
verifyBraces(node, adjustments, cs.getOtherBracePlacement(), cs.spaceBeforeCatchLeftBrace(), true);
verifyParens(node, adjustments, cs.spaceBeforeCatchParen(), cs.spaceWithinCatchParens());
}
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
super.visitCatch(node, adjustments);
return adjustments;
}
@SuppressWarnings({"MethodWithMultipleLoops"})
// NOI18N
private void verifyParens(Tree node, Queue<Adjustment> adjustments, boolean spaceBeforParen, boolean spaceWithin) throws BadLocationException {
final TokenSequence<JFXTokenId> ts = ts(node);
ts.move(getStartPos(node));
final int endPos = getEndPos(node);
while (ts.moveNext() && ts.offset() < endPos) {
JFXTokenId id = ts.token().id();
if (id == JFXTokenId.LPAREN) {
int lps = ts.offset();
int tl = ts.token().length();
spaceWithin(adjustments, spaceWithin, ts, endPos, lps + tl);
ts.move(lps);
while (ts.movePrevious()) {
id = ts.token().id();
if (id != JFXTokenId.WS) {
adjustments.offer(Adjustment.replace(toPos(ts.offset() + ts.token().length()),
toPos(lps), spaceBeforParen ? STRING_EMPTY_LENGTH_ONE : STRING_ZERO_LENGTH));
return;
}
}
}
}
}
private void spaceWithin(Queue<Adjustment> adjustments, boolean spaceWithin, TokenSequence<JFXTokenId> ts, int endPos, int parenEndIndex) throws BadLocationException {
if (spaceWithin) {
if (ts.moveNext() && ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.add(toPos(ts.offset()), STRING_EMPTY_LENGTH_ONE));
}
} else {
if (ts.moveNext() && ts.token().id() == JFXTokenId.WS) {
while (ts.moveNext() && ts.offset() < endPos) {
if (ts.token().id() != JFXTokenId.WS) {
adjustments.offer(Adjustment.delete(toPos(parenEndIndex), toPos(ts.offset())));
break;
}
}
}
}
}
@Override
public Queue<Adjustment> visitPostInitDefinition(InitDefinitionTree node, Queue<Adjustment> adjustments) {
if (!isSynthetic((JFXTree) node)) {
try {
processStandaloneNode(node, adjustments);
verifySpaceBefore(adjustments, cs.spaceBeforeMethodDeclLeftBrace(), getStartPos(node.getBody()));
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
}
// POSTINIT is followed by BLOCK so we don't adjust indentation offset.
super.visitPostInitDefinition(node, adjustments);
return adjustments;
}
/**
* Gets continuation indent adjustment. This is sum of spaces to be added to current indet to achieve required
* continuation offset.
*
* @return size of continuation indent adjustment.
*/
private int getCi() {
return disableContinuosIndent ? 0 : (cs.getContinuationIndentSize() - getIndentStepLevel());
}
@Override
public Queue<Adjustment> visitBlockExpression(BlockExpressionTree node, Queue<Adjustment> adjustments) {
final Tree tree = getParent();
if (isSynthetic((JFXTree) node) || (tree instanceof FunctionValueTree)) {
super.visitBlockExpression(node, adjustments);
return adjustments;
}
try {
final int start = ctx.lineStartOffset(getStartPos(node));
/*
if (isEmptyBlock(node)) {
incIndent();
li.moveTo(start);
int end = findEnd(node);
while (li.get().getEndOffset() <= end) {
indentLine(li.get(), adjustments);
if (li.hasNext()) {
li.next();
} else {
break;
}
}
} else {
*/
int endPos = getEndPos(node);
if (isFirstOnLine(endPos)) {
indentLine(start, adjustments);
}
incIndent();
super.visitBlockExpression(node, adjustments);
decIndent();
// if (isFirstOnLine(endPos) && !endsOnSameLine(node, node.getValue())) {
// final int end = ctx.lineStartOffset(endPos);
// indentLine(end, adjustments);
// }
indentEndLine(node, adjustments);
// }
} catch (BadLocationException e) {
if (log.isLoggable(Level.SEVERE))
log.severe(BUNDLE.getString(REFORMAT_FAILED_BUNDLE_KEY) + e);
}
return adjustments;
}
private int findEnd(BlockExpressionTree node) {
TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(getStartPos(node));
if (ts.moveNext() && ts.token().id() == JFXTokenId.LBRACE) {
while (ts.moveNext()) {
JFXTokenId id = ts.token().id();
switch (id) {
case RBRACE:
return ts.offset() + 1;
case WS:
continue;
default:
return getEndPos(node);
}
}
}
return getEndPos(node);
}
private boolean isEmptyBlock(BlockExpressionTree node) {
TokenSequence<JFXTokenId> ts = ts(node);
if (ts.moveNext() && ts.token().id() == JFXTokenId.LBRACE) {
while (ts.moveNext()) {
JFXTokenId id = ts.token().id();
switch (id) {
case RBRACE:
return true;
case WS:
continue;
default:
return false;
}
}
}
return false;
}
private int getEmptyLinesBefore(LineIterator<Element> iterator, int pos) throws BadLocationException {
iterator.moveTo(pos);
int res = 0;
while (iterator.hasPrevious()) {
final Element line = iterator.previous();
if (!isEmpty(line)) {
break;
}
res++;
}
return res;
}
private boolean isEmpty(Element line) throws BadLocationException {
final Document d = line.getDocument();
final String s = d.getText(line.getStartOffset(), line.getEndOffset() - line.getStartOffset());
return isEmpty(s);
}
private int skipPreviousComment(int pos) {
final TokenSequence<JFXTokenId> ts = (TokenSequence<JFXTokenId>) ts();
ts.move(pos);
while (ts.movePrevious()) {
JFXTokenId tid = ts.token().id();
if (tid == JFXTokenId.WS) continue;
if (JFXTokenId.isComment(tid)) return ts.offset();
return pos;
}
return pos;
}
private Element getNthElement(int n, LineIterator<Element> iterator) {
Element nth = null;
while (iterator.hasNext() && n != 0) {
nth = iterator.next();
n--;
}
return nth;
}
private StringBuilder buildString(int elc, String str) {
StringBuilder sb = new StringBuilder(elc);
while (elc != 0) {
sb.append(str);
elc--;
}
return sb;
}
private static final Pattern EMPTY_LINE_PTRN = Pattern.compile("\\s+"); // NOI18N
private boolean isEmpty(String text) {
return text == null || text.length() == 0 || EMPTY_LINE_PTRN.matcher(text).matches();
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.