hexsha
stringlengths
40
40
size
int64
8
1.04M
content
stringlengths
8
1.04M
avg_line_length
float64
2.24
100
max_line_length
int64
4
1k
alphanum_fraction
float64
0.25
0.97
6a07366b565e2654473c565386237969f0fed88b
2,577
package com.ymcsoft.function.util; import org.junit.Test; import java.util.Arrays; import java.util.function.DoubleFunction; import java.util.function.IntFunction; import java.util.function.LongFunction; import static junit.framework.TestCase.assertEquals; public class FunctionWithExceptionTest { @Test(expected = Exception.class) public void handleException() throws Exception{ Arrays.stream(new Object[]{new Object()}).map(FunctionWithException.handleFunctionWithException(this::exceptionMethod)).findAny().get(); } @Test public void handleWithNoException() throws Exception { String expected = "this is a test"; String actual = Arrays.stream(new String[]{expected}).map(FunctionWithException.handleFunctionWithException(this::noExceptionMethod)).findAny().get(); assertEquals(expected, actual); } @Test(expected = Exception.class) public void testHandleIntFunctionWithException() throws Exception { IntFunction<Integer> func = FunctionWithException.handleIntFunctionWithException(this::exceptionMethod); func.apply(0); } @Test public void testHandleIntFunctionWithNoException() throws Exception { IntFunction<Integer> func = FunctionWithException.handleIntFunctionWithException(this::noExceptionMethod); assertEquals(10, func.apply(10).intValue()); } @Test(expected = Exception.class) public void testHandleDoubleFunctionWithException() throws Exception { DoubleFunction func = FunctionWithException.handleDoubleFunctionWithException(this::exceptionMethod); func.apply(0.0); } @Test public void testHandleDoubleFunctionWithNoException() throws Exception { DoubleFunction func = FunctionWithException.handleDoubleFunctionWithException(this::noExceptionMethod); assertEquals(10.0, func.apply(10.0)); } @Test(expected = Exception.class) public void testHandleLongFunctionWithException() throws Exception { LongFunction func = FunctionWithException.handleLongFunctionWithException(this::exceptionMethod); func.apply(0); } @Test public void testHandleLongFunctionWithNoException() throws Exception { LongFunction func = FunctionWithException.handleLongFunctionWithException(this::noExceptionMethod); assertEquals(10L, func.apply(10L)); } private <T> T exceptionMethod(T obj) throws Exception { throw new Exception("Test Exception"); } private <T> T noExceptionMethod(T obj) throws Exception { return obj; } }
37.347826
158
0.737679
f593f3fbc28b8352aae0872280a952c47595d0de
3,213
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.iosdevicecontrol.webinspector; import com.google.auto.value.AutoValue; import com.google.common.base.Optional; /** Information about an application in an inspector message. */ @AutoValue public abstract class InspectorApplication extends MessageDict { /** Returns a new builder. */ public static Builder builder() { return new AutoValue_InspectorApplication.Builder(); } /** A builder for creating inspector applications. */ @AutoValue.Builder public abstract static class Builder extends MessageDict.Builder { @Override public abstract Builder applicationBundleId(String applicationBundleId); @Override public abstract Builder applicationId(String applicationId); @Override public abstract Builder applicationName(String applicationName); @Override public final Builder hostApplicationId(String hostApplicationId) { return optionalHostApplicationId(hostApplicationId); } @Override public abstract Builder isApplicationActive(boolean isApplicationActive); @Override public abstract Builder isApplicationProxy(boolean isApplicationProxy); @Override public final Builder isApplicationReady(boolean isApplicationReady) { return optionalIsApplicationReady(isApplicationReady); } @Override public final Builder remoteAutomationEnabled(boolean remoteAutomationEnabled) { return optionalRemoteAutomationEnabled(remoteAutomationEnabled); } @Override public abstract InspectorApplication build(); abstract Builder optionalHostApplicationId(String hostApplicationId); abstract Builder optionalIsApplicationReady(boolean isApplicationReady); abstract Builder optionalRemoteAutomationEnabled(boolean remoteAutomationEnabled); } @Override public abstract String applicationBundleId(); @Override public abstract String applicationId(); @Override public abstract String applicationName(); public abstract Optional<String> optionalHostApplicationId(); @Override public abstract boolean isApplicationActive(); @Override public abstract boolean isApplicationProxy(); public abstract Optional<Boolean> optionalIsApplicationReady(); public abstract Optional<Boolean> optionalRemoteAutomationEnabled(); @Override final String hostApplicationId() { return fromOptional(optionalHostApplicationId()); } @Override final boolean isApplicationReady() { return fromOptional(optionalIsApplicationReady()); } @Override final boolean remoteAutomationEnabled() { return fromOptional(optionalRemoteAutomationEnabled()); } }
30.028037
86
0.772487
156d7cd5a0dcfd2a75eb0b49fc45aed379e1f009
1,808
package javax.mail; import java.util.*; public class FetchProfile { private Vector specials; private Vector headers; public FetchProfile() { this.specials = null; this.headers = null; } public void add(final Item item) { if (this.specials == null) { this.specials = new Vector(); } this.specials.addElement(item); } public void add(final String headerName) { if (this.headers == null) { this.headers = new Vector(); } this.headers.addElement(headerName); } public boolean contains(final Item item) { return this.specials != null && this.specials.contains(item); } public boolean contains(final String headerName) { return this.headers != null && this.headers.contains(headerName); } public Item[] getItems() { if (this.specials == null) { return new Item[0]; } final Item[] s = new Item[this.specials.size()]; this.specials.copyInto(s); return s; } public String[] getHeaderNames() { if (this.headers == null) { return new String[0]; } final String[] s = new String[this.headers.size()]; this.headers.copyInto(s); return s; } public static class Item { public static final Item ENVELOPE; public static final Item CONTENT_INFO; public static final Item FLAGS; private String name; protected Item(final String name) { this.name = name; } static { ENVELOPE = new Item("ENVELOPE"); CONTENT_INFO = new Item("CONTENT_INFO"); FLAGS = new Item("FLAGS"); } } }
24.767123
73
0.544248
a487a13270d55e5dd1b1f5a313f3f33ba23340a5
5,206
package com.zm.service.service; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; import org.apache.ibatis.session.RowBounds; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.zm.service.context.ErrorCode; import com.zm.service.context.HandleException; import com.zm.service.context.WXPayCharge; import com.zm.service.entity.Order; import com.zm.service.entity.Transaction; import com.zm.service.feign.client.ReserveClient; import com.zm.service.feign.client.TransactionClient; import com.zm.service.feign.client.UserClient; import com.zm.service.mapper.OrderMapper; import com.zm.service.utils.JSONUtils; import com.zm.service.utils.MyWxPayUtil; import com.zm.service.utils.RedissonUtil; import tk.mybatis.mapper.entity.Example; @Service public class OrderService { @Autowired OrderMapper orderMapper; @Autowired TransactionClient transClient; @Autowired UserClient userClient; @Autowired ReserveClient reserveClient; @Autowired RedissonUtil redissonUtil; public List<Order> getMyOrder(Integer uid, int pageIndex, int pageSize) { Example ex = new Example(Order.class); ex.createCriteria().andEqualTo("uid", uid); ex.setOrderByClause("id desc"); RowBounds rowBounds = new RowBounds((pageIndex-1)*pageSize, pageSize); List<Order> orderList = orderMapper.selectByExampleAndRowBounds(ex, rowBounds); return orderList; } public Order create(Integer uid, Integer code, int amount, String info) { Order order = new Order(); order.setSn(generateOrderSN(uid)); order.setUid(uid); order.setAmount(amount); order.setCode(code); order.setInfo(info); Date now = new Date(); order.setCreatetime(now); order.setInvalidtime(new Date(now.getTime()+5*60*1000)); order.setState(Order.STATE_NEW); orderMapper.insertUseGeneratedKeys(order); return order; } public Object getCharge(Integer uid, String openid, Long orderid, String payWay, String ip) { Order order = orderMapper.selectByPrimaryKey(orderid); if(order == null){ throw new HandleException(ErrorCode.ARG_ERROR, "order不存在"); } if(payWay.equals("WX_XCX")){ order.setPayway(payWay); WXPayCharge charge = MyWxPayUtil.getPayCharge(openid, "租盟-订金", "", order.getSn(), order.getAmount(), ip); order.setPaysn(charge.getPrepay_id()); order.setState(Order.STATE_PAYING); orderMapper.updateByPrimaryKey(order); return charge; }else{ throw new HandleException(ErrorCode.ARG_ERROR, "不支持的支付方式"); } } /** * 生成按日期的订单号 * @param uid * @return */ private String generateOrderSN(Integer uid){ DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); Date date = new Date(); String sn = sdf.format(date); String uidStr = String.format("%06d", uid); Random r = new Random(date.getTime()+uid); int number = r.nextInt(999999); String randomStr = String.format("%06d", number); sn = sn+uidStr+randomStr; return sn; } public void payOver(String ordersn, String settlement_total_fee, String attach, String time_end) { String info; redissonUtil.tryLock(ordersn, TimeUnit.MILLISECONDS, 300, 300); Example ex = new Example(Order.class); ex.createCriteria().andEqualTo("sn", ordersn); Order order = orderMapper.selectOneByExample(ex); if(order.getState() == order.STATE_COMPELTE){ redissonUtil.unlock(ordersn); return;//状态不符不处理 }else{ if(order.getAmount() != Integer.parseInt(settlement_total_fee)){ redissonUtil.unlock(ordersn); return;//金额不符不处理 } order.setState(Order.STATE_COMPELTE); DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); Date payovertime = null; try { payovertime = sdf.parse(time_end); } catch (ParseException e) { e.printStackTrace(); } order.setPayovertime(payovertime); info = order.getInfo(); orderMapper.updateByPrimaryKey(order); } redissonUtil.unlock(ordersn); //支付成功后的处理 int transCode = order.getCode(); if(transCode == Order.CODE_TRANSACTION){ //给账户充值 userClient.addCash(order.getUid(), order.getAmount(), "充值订金"); //通知交易完成 transClient.payOver(Long.valueOf(info)); } else if(transCode == Order.CODE_RESERVE){ //给账户充值 userClient.addCoin(order.getUid(), order.getAmount()/100, "充值看房币"); //通知完成看房预约 reserveClient.payOver(Long.valueOf(info)); } } public void handleInvalidOrder() { Example ex = new Example(Order.class); ex.createCriteria().andLessThan("state", Order.STATE_COMPELTE).andLessThanOrEqualTo("invalidtime", new Date()); List<Order> orders = orderMapper.selectByExample(ex); for(Order order : orders){ order.setState(Order.STATE_INVALID); orderMapper.updateByPrimaryKey(order); //支付成功后的处理 String info = order.getInfo(); int transCode = order.getCode(); if(transCode == Order.CODE_TRANSACTION){ //通知交易取消 transClient.cancel(Long.valueOf(info)); } else if(transCode == Order.CODE_RESERVE){ //通知完成看房取消 reserveClient.cancel(Long.valueOf(info)); } } } }
29.247191
113
0.726854
60472891a3cffcb4087c07942b6fb953120687fb
1,101
package com.example.demo.domain; import java.time.LocalDateTime; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; @Document(collection = "Article") public class Article { @Id private String id; private String title; private String body; private LocalDateTime createdAt; private LocalDateTime modifiedAt; public Article() { this.createdAt = LocalDateTime.now(); this.modifiedAt = this.createdAt; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } public LocalDateTime getCreatedAt() { return createdAt; } public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; } public LocalDateTime getModifiedAt() { return modifiedAt; } public void setModifiedAt(LocalDateTime modifiedAt) { this.modifiedAt = modifiedAt; } }
16.938462
62
0.725704
61a7f1284ec2433743639004213b684a8099ccd2
1,308
package games; import java.util.ArrayList; public class Kaitenzushi { public static void main(String[] args) { Kaitenzushi ks = new Kaitenzushi(); /**/ System.out.println("5 " + ks.getMaximumEatenDishCount(6, new int[]{1,2,3,3,2,1}, 1)); System.out.println("4 " + ks.getMaximumEatenDishCount(6, new int[]{1,2,3,3,2,1}, 2)); System.out.println("2 " + ks.getMaximumEatenDishCount(7, new int[]{1,2,1,2,1,2,1}, 2)); System.out.println("2 " + ks.getMaximumEatenDishCount(2, new int[]{1,2}, 2)); System.out.println("2 " + ks.getMaximumEatenDishCount(3, new int[]{1,2,1,2,1,2,2}, 3)); } public int getMaximumEatenDishCount(int N, int[] D, int K) { ArrayList<Integer> kLastDishes = new ArrayList<Integer>(); int counter = 0; // fill cache for(int c=0; c<K; c++) { int elem = D[c]; if(!kLastDishes.contains(elem)) { counter++; } kLastDishes.add(D[c]); } for(int i=K; i<(Math.min(N, D.length)); i++) { int elem = D[i]; if(!kLastDishes.contains(elem)) { kLastDishes.add(elem); kLastDishes.remove(0); counter++; } } return counter; } }
30.418605
95
0.528287
20e1a88536d0aee20bdfce5a4f53c8b892f8afdb
8,510
/* * Copyright 2016-2017 Florent Weber <florent.weber@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.amaze.bench.actor; import com.google.common.base.Stopwatch; import io.amaze.bench.api.metric.Metric; import io.amaze.bench.api.metric.Metrics; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import oshi.json.SystemInfo; import oshi.json.software.os.OSProcess; import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly; import static io.amaze.bench.actor.WatcherActorConstants.UNIT_BYTES; import static io.amaze.bench.actor.WatcherActorConstants.UNIT_MILLIS; import static io.amaze.bench.api.metric.Metric.metric; import static java.lang.String.format; /** * One-time task that will measure the difference between process metrics between calls to startWatch and stopWatch. */ final class StopwatchThread implements Runnable { private static final Logger log = LogManager.getLogger(); private final ProcessWatcherActorInput message; private final Metrics metrics; private final SystemInfo systemInfo; private final Stopwatch stopwatch; private final CountDownLatch stopping = new CountDownLatch(1); private final CountDownLatch stopped = new CountDownLatch(1); private long beforeVirtualSize; private long beforeResidentSetSize; private long beforeKernelTime; private long beforeUserTime; StopwatchThread(final Metrics metrics, final SystemInfo systemInfo, final ProcessWatcherActorInput message) { this.metrics = metrics; this.systemInfo = systemInfo; this.message = message; stopwatch = Stopwatch.createUnstarted(); } @Override public void run() { try { Optional<OSProcess> beforeProcess = process(); if (!beforeProcess.isPresent()) { return; } startMetrics(beforeProcess.get()); awaitUninterruptibly(stopping); Optional<OSProcess> afterProcess = process(); if (!afterProcess.isPresent()) { return; } stopMetrics(afterProcess.get()); } finally { stopped.countDown(); } } void stop() { stopping.countDown(); awaitUninterruptibly(stopped); } private Optional<OSProcess> process() { try { return Optional.ofNullable(systemInfo.getOperatingSystem().getProcess(message.getPid())); } catch (Exception e) { // NOSONAR - We want to catch everything log.warn("Pid {} not found", message.getPid(), e); return Optional.empty(); } } private void stopMetrics(final OSProcess afterProcess) { long afterVirtualSize = afterProcess.getVirtualSize(); long afterResidentSetSize = afterProcess.getResidentSetSize(); long afterKernelTime = afterProcess.getKernelTime(); long afterUserTime = afterProcess.getUserTime(); long now = System.currentTimeMillis(); metrics.sinkFor(afterVirtualSize()).timed(now, afterVirtualSize); metrics.sinkFor(deltaVirtualSize()).add(afterVirtualSize - beforeVirtualSize); metrics.sinkFor(afterResidentSet()).timed(now, afterResidentSetSize); metrics.sinkFor(deltaResidentSet()).add(afterResidentSetSize - beforeResidentSetSize); metrics.sinkFor(afterKernelTime()).timed(now, afterKernelTime); metrics.sinkFor(deltaKernelTime()).add(afterKernelTime - beforeKernelTime); metrics.sinkFor(afterUserTime()).timed(now, afterUserTime); metrics.sinkFor(deltaUserTime()).add(afterUserTime - beforeUserTime); metrics.sinkFor(elapsed()).add(stopwatch.elapsed(TimeUnit.MILLISECONDS)); } private void startMetrics(final OSProcess beforeProcess) { stopwatch.start(); beforeVirtualSize = beforeProcess.getVirtualSize(); beforeResidentSetSize = beforeProcess.getResidentSetSize(); beforeKernelTime = beforeProcess.getKernelTime(); beforeUserTime = beforeProcess.getUserTime(); long now = System.currentTimeMillis(); metrics.sinkFor(beforeVirtualSize()).timed(now, beforeVirtualSize); metrics.sinkFor(beforeResidentSet()).timed(now, beforeResidentSetSize); metrics.sinkFor(beforeKernelTime()).timed(now, beforeKernelTime); metrics.sinkFor(beforeUserTime()).timed(now, beforeUserTime); } private Metric beforeVirtualSize() { return metric(format("proc.%s.before.mem.virtualSize", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("Virtual memory usage before %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric afterVirtualSize() { return metric(format("proc.%s.after.mem.virtualSize", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("Virtual memory usage after %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric deltaVirtualSize() { return metric(format("proc.%s.delta.mem.virtualSize", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("Virtual memory usage delta %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric beforeResidentSet() { return metric(format("proc.%s.before.mem.residentRet", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("RAM usage before %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric afterResidentSet() { return metric(format("proc.%s.after.mem.residentRet", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("RAM usage after %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric deltaResidentSet() { return metric(format("proc.%s.delta.mem.residentRet", message.getMetricKeyPrefix()), UNIT_BYTES) // .label(format("RAM usage delta %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric beforeKernelTime() { return metric(format("proc.%s.before.cpu.kernelTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU sys time before %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric afterKernelTime() { return metric(format("proc.%s.after.cpu.kernelTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU sys time after %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric deltaKernelTime() { return metric(format("proc.%s.delta.cpu.kernelTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU sys time delta %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric beforeUserTime() { return metric(format("proc.%s.before.cpu.userTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU user time before %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric afterUserTime() { return metric(format("proc.%s.after.cpu.userTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU user time after %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric deltaUserTime() { return metric(format("proc.%s.delta.cpu.userTime", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("CPU user time delta %s", message.getMetricLabelSuffix())).minValue(0).build(); } private Metric elapsed() { return metric(format("proc.%s.elapsed", message.getMetricKeyPrefix()), UNIT_MILLIS) // .label(format("Elapsed time %s", message.getMetricLabelSuffix())).minValue(0).build(); } }
41.921182
117
0.688367
1b8cb7ca00db3d2e05a66c99a7dbcc7573ab0153
3,511
/* * Sunshine Conversations API * * The version of the OpenAPI document: 9.4.5 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ package com.zendesk.sunshine_conversations_client.model; import java.util.Objects; import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonValue; import com.zendesk.sunshine_conversations_client.model.ActionSubset; import com.zendesk.sunshine_conversations_client.model.CarouselMessage; import com.zendesk.sunshine_conversations_client.model.CarouselMessageDisplaySettings; import com.zendesk.sunshine_conversations_client.model.Field; import com.zendesk.sunshine_conversations_client.model.FileMessage; import com.zendesk.sunshine_conversations_client.model.FormMessage; import com.zendesk.sunshine_conversations_client.model.FormResponseMessage; import com.zendesk.sunshine_conversations_client.model.ImageMessage; import com.zendesk.sunshine_conversations_client.model.Item; import com.zendesk.sunshine_conversations_client.model.ListMessage; import com.zendesk.sunshine_conversations_client.model.LocationMessage; import com.zendesk.sunshine_conversations_client.model.LocationMessageCoordinates; import com.zendesk.sunshine_conversations_client.model.LocationMessageLocation; import com.zendesk.sunshine_conversations_client.model.TemplateMessage; import com.zendesk.sunshine_conversations_client.model.TextMessage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.net.URI; import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true) @JsonSubTypes({ @JsonSubTypes.Type(value = CarouselMessage.class, name = "carousel"), @JsonSubTypes.Type(value = CarouselMessage.class, name = "carouselMessage"), @JsonSubTypes.Type(value = FileMessage.class, name = "file"), @JsonSubTypes.Type(value = FileMessage.class, name = "fileMessage"), @JsonSubTypes.Type(value = FormMessage.class, name = "form"), @JsonSubTypes.Type(value = FormMessage.class, name = "formMessage"), @JsonSubTypes.Type(value = FormResponseMessage.class, name = "formResponse"), @JsonSubTypes.Type(value = FormResponseMessage.class, name = "formResponseMessage"), @JsonSubTypes.Type(value = ImageMessage.class, name = "image"), @JsonSubTypes.Type(value = ImageMessage.class, name = "imageMessage"), @JsonSubTypes.Type(value = ListMessage.class, name = "list"), @JsonSubTypes.Type(value = ListMessage.class, name = "listMessage"), @JsonSubTypes.Type(value = LocationMessage.class, name = "location"), @JsonSubTypes.Type(value = LocationMessage.class, name = "locationMessage"), @JsonSubTypes.Type(value = TemplateMessage.class, name = "template"), @JsonSubTypes.Type(value = TemplateMessage.class, name = "templateMessage"), @JsonSubTypes.Type(value = TextMessage.class, name = "text"), @JsonSubTypes.Type(value = TextMessage.class, name = "textMessage"), }) public interface Content { public String getType(); }
48.09589
121
0.806038
386387bf6c6a1d7bc0a4dae58934eae3b3f1ce68
499
package io.github.coffeebreak.embedded.toxiproxy.core.utils; import java.io.IOException; import java.net.ServerSocket; public class PortScavenger { public static int getFreePort() { try (ServerSocket socket = new ServerSocket(0)) { socket.setReuseAddress(true); return socket.getLocalPort(); } catch (IOException e) { throw new RuntimeException("Could not find a free TCP/IP port to start embedded Jetty HTTP Server on"); } } }
29.352941
115
0.671343
da8e90ed6ec95d38fa524053dde7a77beb570fd9
2,242
package org.apache.isis.extensions.viewer.wicket.pdfjs.ui.components; import java.util.Objects; import javax.activation.MimeType; import javax.inject.Inject; import org.apache.wicket.Component; import org.apache.wicket.model.IModel; import org.apache.isis.applib.services.inject.ServiceInjector; import org.apache.isis.applib.value.Blob; import org.apache.isis.core.metamodel.spec.ManagedObject; import org.apache.isis.viewer.wicket.model.models.ScalarModel; import org.apache.isis.viewer.wicket.ui.ComponentFactoryAbstract; import org.apache.isis.viewer.wicket.ui.ComponentType; import org.apache.isis.extensions.viewer.wicket.pdfjs.metamodel.facet.PdfJsViewerFacet; import lombok.val; @org.springframework.stereotype.Component public class PdfJsViewerPanelComponentFactory extends ComponentFactoryAbstract { private static final long serialVersionUID = 1L; @Inject public PdfJsViewerPanelComponentFactory() { super(ComponentType.SCALAR_NAME_AND_VALUE, PdfJsViewerPanel.class); } public ApplicationAdvice appliesTo(IModel<?> model) { if (!(model instanceof ScalarModel)) { return ApplicationAdvice.DOES_NOT_APPLY; } val scalarModel = (ScalarModel) model; val facet = scalarModel.getFacet(PdfJsViewerFacet.class); if(facet == null) { return ApplicationAdvice.DOES_NOT_APPLY; } val managedObject = scalarModel.getObject(); val isPdf = isPdf(managedObject); return this.appliesIf(isPdf); } private static boolean isPdf(final ManagedObject objectAdapter) { if (objectAdapter == null) { return false; } final Object modelObject = objectAdapter.getPojo(); if (!(modelObject instanceof Blob)) { return false; } final Blob blob = (Blob) modelObject; final MimeType mimeType = blob.getMimeType(); return Objects.equals("application", mimeType.getPrimaryType()) && Objects.equals("pdf", mimeType.getSubType()); } public Component createComponent(String id, IModel<?> model) { ScalarModel scalarModel = (ScalarModel) model; return new PdfJsViewerPanel(id, scalarModel); } }
32.970588
87
0.710972
977cb33d7969bdc92cbc66d47717e92aee7350a8
2,109
package com.ideabobo.action; import java.util.HashMap; import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Controller; import com.google.gson.Gson; import com.ideabobo.model.Replay; import com.ideabobo.service.ReplayService; import com.ideabobo.util.GetNowTime; import com.ideabobo.util.IdeaAction; import com.ideabobo.util.Page; @Controller public class ReplayAction extends IdeaAction { @Resource private ReplayService replayService; private static final long serialVersionUID = -3218238026025256103L; private Replay replay; public Replay getReplay() { return replay; } public void setReplay(Replay replay) { this.replay = replay; } public String replay(){ return SUCCESS; } public void getList(){ String replayname = request.getParameter("sreplayname"); String sort = request.getParameter("sort"); String order = request.getParameter("order"); Page page = new Page(); Map paramsMap = new HashMap(); paramsMap.put("replayname", replayname); paramsMap.put("sort", "order by "+sort+" "+order); String pageNo = (String) this.request.getParameter("page"); String pageSizes = (String) this.request.getParameter("rows"); if (pageNo == null) { page.setPageSize(10); page.setPageNo(1); } else { page.setPageSize(Integer.parseInt(pageSizes)); page.setPageNo(Integer.parseInt(pageNo)); } page = replayService.findByPage(page, paramsMap); Gson json = new Gson(); Map<String, Object> map = new HashMap<String, Object>(); map.put("total", page.getTotal()); map.put("rows", page.getList()); render(json.toJson(map)); } public void add(){ String action = request.getParameter("action"); if(replay != null){ if(action.equals("add")){ replayService.save(replay); render("操作成功!"); }else { String id = request.getParameter("id"); replay.setId(Integer.parseInt(id)); replayService.update(replay); render("操作成功!"); } } } public void deleteItem(){ String id = request.getParameter("id"); replayService.delete(Integer.parseInt(id)); render("操作成功"); } }
25.409639
68
0.708867
111010fbba39f588e7d393f3db7375442716021f
673
package Tarea.entity; import org.glassfish.jersey.linking.InjectLinks; import javax.ws.rs.core.Link; import java.security.acl.Group; import java.util.ArrayList; import java.util.List; /** * Created by esr on 26/10/15. */ public class Respcollection { @InjectLinks({}) private List<Link> links; private List<Group> Respuesta = new ArrayList<>(); public List<Link> getLinks() { return links; } public void setLinks(List<Link> links) { this.links = links; } public List<Group> getRespuesta() { return Respuesta; } public void setRespuesta(List<Group> respuesta) { Respuesta = respuesta; } }
19.794118
54
0.655275
8ffc4e778c0d812c76c601cb44dade835af5f1de
1,188
package test_locally.api.webhook; import com.slack.api.webhook.Payload; import org.junit.Test; import static com.slack.api.model.Attachments.*; import static com.slack.api.model.block.Blocks.*; import static com.slack.api.model.block.composition.BlockCompositions.plainText; import static com.slack.api.webhook.WebhookPayloads.payload; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; public class WebhookPayloadsTest { @Test public void test() { Payload payload = payload(it -> { return it.text("fallback") .blocks(asBlocks( section(s -> s.text(plainText("Hi"))), image(i -> i.imageUrl("https://www.example.com/foo.png")) )) .attachments(asAttachments( attachment(a -> a.actions(asActions(action(ac -> ac.name("foo"))))), attachment(a -> a.fields(asFields(field(f -> f.title("title"))))) )); }); assertThat(payload, is(notNullValue())); } }
37.125
96
0.605219
772198eb989c87b1418e133a1f644c9585b5a536
4,474
package com.jcohy.scis.controller; import com.jcohy.scis.common.JsonResult; import com.jcohy.scis.common.PageJson; import com.jcohy.scis.model.Expert; import com.jcohy.scis.model.Project; import com.jcohy.scis.service.AllotService; import com.jcohy.scis.service.ProjectService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; /** * Copyright : 2017- www.jcohy.com * Created by jiac on 18:07 2018/4/7 * Email: jia_chao23@126.com * ClassName: ProjectController * Description: **/ @Controller @RequestMapping("/project") public class ProjectController extends BaseController{ private static final Logger logger = LoggerFactory.getLogger(ProjectController.class); @Autowired private ProjectService projectService; @Autowired private AllotService allotService; @GetMapping("/history") public String history(){ return "/project/history"; } @GetMapping("/all") @ResponseBody public PageJson<Project> all(){ PageRequest pageRequest = getPageRequest(); Page<Project> projects = projectService.findAll(pageRequest); for(Project project : projects.getContent()){ Expert expert = allotService.findByProject(project); if(expert == null){ project.setExpert(null); } project.setOperator("admin"); project.setExpert(expert); } List<Project> collect = projects.getContent().stream().filter(x -> x.getEStatus() == 1).collect(Collectors.toList()); PageJson<Project> page = new PageJson<>(); page.setCode(0); page.setMsg("成功"); page.setCount(collect.size()); page.setData(collect); return page; } @DeleteMapping("/{id}/del") @ResponseBody public JsonResult del(@PathVariable("id") Integer id){ try { allotService.delete(id); } catch (Exception e) { e.printStackTrace(); return JsonResult.fail("删除失败"); } return JsonResult.ok(); } @GetMapping("/change/{id}") @ResponseBody public JsonResult change(@SessionAttribute("role")String role,@PathVariable("id") Integer id,@RequestParam("advise") String advise){ logger.error("role:{} id: {} advice: {}",role,id,advise); try { projectService.changeStatus(id,role,advise); } catch (Exception e) { e.printStackTrace(); return JsonResult.fail("修改失败"); } return JsonResult.ok(); } @GetMapping("/{id}") public String detail(@PathVariable Integer id, ModelMap map){ Project project = projectService.findById(id); map.put("project",project); Expert expert = allotService.findByProject(project); map.put("expert",expert); return "detail"; } /** * 搜索模糊查询 * @param keyword * @return */ @PostMapping("/search") @ResponseBody public JsonResult searchJob(String keyword){ List<Project> projects = projectService.findByNameLike(keyword); System.out.println("============================="); projects.forEach(System.out::println); return JsonResult.ok().set("data", projects); } @GetMapping("/reject/{id}") @ResponseBody public JsonResult reject(@SessionAttribute("role")String role,@PathVariable("id") Integer id,@RequestParam("advise") String advise){ logger.error("role:{} id: {} advice: {}",role,id,advise); try { projectService.reject(id,role,advise); } catch (Exception e) { e.printStackTrace(); return JsonResult.fail("修改失败"); } return JsonResult.ok(); } @GetMapping("/video/{id}") public String video(@PathVariable("id") Integer id,ModelMap map){ logger.error("id: {}",id); try { // projectService.changeStatus(id,role,advise); Project project = projectService.findById(id); map.put("url",project.getVideo().getDownloadUrl()); } catch (Exception e) { } return "video"; } }
32.42029
136
0.634555
57d73de334e55e558a30e78e0c5c4161df91d8ac
1,210
package com.weiit.resource.common.config; import com.weiit.resource.common.utils.WeiitUtil; /** * LBS地图服务配置-目前支持百度、微信、高德三家服务商 * * @version 1.0 * @author:半个鼠标(137075251@qq.com) * @date:2018年3月22日 * @company http://www.wei-it.com 微邦互联 */ public class WeiitLBSConfig { public static String lbsOpen = "1";//open=1表示开启百度地图集成、open=2表示开启微信地图集成,open=3表示高德地图集成 /** * 百度地图开发者配置 */ public static String lbsBaiduAppId = "";//百度地图应用ID public static String lbsBaiduAk = "";//百度地图应用AK public static String getLbsOpen() { if (WeiitUtil.getPropertiesKey("lbsOpen") != null) { lbsOpen = WeiitUtil.getPropertiesKey("lbsOpen"); } return lbsOpen; } public static String getLbsBaiduAppId() { if (WeiitUtil.getPropertiesKey("lbsBaiduAppId") != null) { lbsBaiduAppId = WeiitUtil.getPropertiesKey("lbsBaiduAppId"); } return lbsBaiduAppId; } public static String getLbsBaiduAk() { if (WeiitUtil.getPropertiesKey("lbsBaiduAk") != null) { lbsBaiduAk = WeiitUtil.getPropertiesKey("lbsBaiduAk"); } return lbsBaiduAk; } }
26.304348
90
0.620661
5651957fe87fc036f558a4ac69fb4af715bf93c5
1,098
/* * Copyright (C) 2019 Straight Technologies * All rights reserved. * https://www.str8tech.com * * This program is free software under the MIT License */ package com.str8tech.verisure; import com.github.cliftonlabs.json_simple.JsonException; import com.str8tech.verisure.json.ErrorResponse; import com.str8tech.verisure.json.InstallationResponse; import com.str8tech.verisure.json.OverviewResponse; import java.util.List; import org.apache.http.client.methods.CloseableHttpResponse; /** * * @author richard.strate */ public interface JsonParser { /** * Try to parse out a * {@link com.str8tech.verisure.json.ErrorResponse ErrorResponse} from the * HTTP response body/content, catching any exceptions and returning NULL * instead. * * @param response * @return Returns the error response or NULL if something fails */ ErrorResponse parseErrorContent(CloseableHttpResponse response); OverviewResponse parseOverviewResponse(String json) throws JsonException; List<InstallationResponse> parseInstallationResponses(String json) throws JsonException; }
28.153846
90
0.773224
83e9691881f74cc5a0f6bfb702cb4a98a48bfc4c
2,529
/* * Copyright 2016 Crown Copyright * * 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 uk.gov.gchq.gaffer.graphql; import org.junit.Before; import org.junit.Test; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.traffic.ElementGroup; import uk.gov.gchq.gaffer.user.User; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; public class ContextBuilderTest { private User user; private Graph graph; @Before public void before() { // Setup User user = new User.Builder() .userId("user02") .build(); // Setup graph graph = new Graph.Builder() .graphId("graph1") .storeProperties(StreamUtil.openStream(getClass(), "map-store.properties")) .addSchemas(StreamUtil.openStreams(ElementGroup.class, "schema")) .build(); } @Test public void testValid() throws GrafferQLException { final GrafferQLContext context = new GrafferQLContext.Builder() .graph(graph) .user(user) .build(); assertEquals(context.getGraph(), graph); assertEquals(context.getUser(), user); } @Test public void testNoGraph() { try { new GrafferQLContext.Builder() .user(user) .build(); fail("Should have thrown exception with missing graph"); } catch (final GrafferQLException e) { assertNotNull(e.getMessage()); } } @Test public void testNoUser() { try { new GrafferQLContext.Builder() .graph(graph) .build(); fail("Should have thrown exception with missing user"); } catch (final GrafferQLException e) { assertNotNull(e.getMessage()); } } }
30.107143
91
0.618426
dde22beb32d6b69a2eb8eb5c5425af06a7e52c20
1,482
/* * Copyright 2007 Apache Software Foundation * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. 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. For additional information regarding * copyright in this work, please see the NOTICE file in the top level * directory of this distribution. */ package com.rometools.propono.atom.common.rome; import java.util.Date; import com.rometools.rome.feed.module.Module; /** * ROME Extension Module to Atom protocol extensions to Atom format. */ public interface AppModule extends Module { public static final String URI = "http://www.w3.org/2007/app"; /** True if entry is a draft */ public Boolean getDraft(); /** Set to true if entry is a draft */ public void setDraft(Boolean draft); /** Time of last edit */ public Date getEdited(); /** Set time of last edit */ public void setEdited(Date edited); }
32.933333
75
0.724696
51454f7451aa727b01b80029abc64586a41d58db
991
package net.dontdrinkandroot.example.wassh.wicket.component; import net.dontdrinkandroot.example.wassh.wicket.WebApplication; import org.apache.wicket.authorization.Action; import org.apache.wicket.authroles.authorization.strategies.role.Roles; import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeAction; import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeActions; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.model.Model; /** * @author Philip Washington Sorst <philip@sorst.net> */ @AuthorizeActions(actions = {@AuthorizeAction(action = Action.RENDER, roles = {Roles.USER})}) public class LogoutLink extends Link<Void> { public LogoutLink(String id) { super(id); this.setBody(Model.of("Log out")); } @Override public void onClick() { this.getSession().invalidate(); this.setResponsePage(WebApplication.get().getHomePage()); } }
33.033333
94
0.753784
6b3cd5fb2a830614b5a7e6015dad3a9404638239
2,489
package gov.va.escreening.dto.template; import gov.va.escreening.condition.BlockTranslator; import gov.va.escreening.condition.BlockUtil; import java.util.List; import java.util.Set; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) public class TemplateFollowingConditionBlock{ private TemplateBaseContent left; private String operator; private TemplateBaseContent right; private List<TemplateFollowingConditionBlock> conditions; public TemplateBaseContent getLeft() { return left; } public void setLeft(TemplateBaseContent left) { this.left = left; } public String getOperator() { return operator; } public void setOperator(String operator) { this.operator = operator; } public TemplateBaseContent getRight() { return right; } public void setRight(TemplateBaseContent right) { this.right = right; } public List<TemplateFollowingConditionBlock> getConditions() { return conditions; } public void setConditions(List<TemplateFollowingConditionBlock> conditions) { this.conditions = conditions; } private String connector; public String getConnector() { return connector; } public void setConnector(String connector) { this.connector = connector; } private String getOperatorForConnector() { if ("AND".equalsIgnoreCase(connector)) { return " && "; } else { return " || "; } } public StringBuilder toFreeMarker(StringBuilder sb, Set<Integer>ids){ return appendTranslation(BlockUtil.getFreeMarkerTranslator(), sb, ids); } public StringBuilder toSpringEl(StringBuilder sb, Set<Integer>ids){ return appendTranslation(BlockUtil.getSpringElTranslator(), sb, ids); } /** * Translates subconditions with proper parenthesization * @param translator * @param sb * @param ids * @return */ public StringBuilder appendTranslation(BlockTranslator translator, StringBuilder sb, Set<Integer>ids){ StringBuilder result = sb; result.append(" ") .append(getOperatorForConnector()) .append(" (") .append(BlockUtil.translateCondition(translator, operator, left, right, ids)); if (conditions != null && conditions.size() > 0){ for(TemplateFollowingConditionBlock tfcb : conditions){ result = tfcb.appendTranslation(translator, result, ids); } } return result.append(" ) "); } }
22.423423
103
0.703897
abf46dd79b31168fe7f799c30edf36a0e22fd125
1,930
package com.codepath.apps.simpletweet.fragments; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.Log; import com.codepath.apps.simpletweet.TwitterApplication; import com.codepath.apps.simpletweet.TwitterClient; import com.codepath.apps.simpletweet.models.Tweet; import com.loopj.android.http.JsonHttpResponseHandler; import org.json.JSONArray; import cz.msebera.android.httpclient.Header; /** * Created by earroyof on 6/30/16. */ public class UserTimelineFragment extends TweetsListFragment{ private TwitterClient client; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get client client = TwitterApplication.getRestClient(); // Singleton client populateTimeline(); } public static UserTimelineFragment newInstance(String screenName) { UserTimelineFragment userTimelineFragment = new UserTimelineFragment(); Bundle args = new Bundle(); args.putString("screen name", screenName); userTimelineFragment.setArguments(args); return userTimelineFragment; } // Send an API request to get timeline json // Fill the listview by creating the tweet objects from the json private void populateTimeline() { String screenName = getArguments().getString("screen name"); client.getUserTimeline(screenName, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONArray response) { Log.d("mydebug", response.toString()); addAll(Tweet.fromJsonArray(response)); } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) { Log.d("myDebug", errorResponse.toString()); } }); } }
33.859649
115
0.696373
43398e450bd8b356de3474757df69a25eaf0bbbb
539
package pl.sdacademy.tarr2020java6.java.zaawansowana.powtorka; /** * @author : Jakub Olszewski [http://github.com/jakub-olszewski] * @project : tarr2019java4-tdd-project * @since : 23.05.2020 **/ public class OsobaNaPlazy extends Plaza { private PilkaPlazowa pilka;// zmienna nie zainicjowana, nie posiada wartosci // pudełko public OsobaNaPlazy(){ this.pilka = new PilkaPlazowa(); // PilkaPlazowa pilka = new PilkaPlazowa(); } public void rozbicieParawanu(){ pilka.pompowanie(); } }
24.5
80
0.679035
af44d27447f3e10f16fd55696139260b0feaea46
3,600
package io.methinks.android.apptest.question; import android.content.Context; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.FragmentActivity; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.DisplayMetrics; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import java.util.ArrayList; import java.util.HashMap; import io.methinks.android.apptest.Global; import io.methinks.android.apptest.Log; import io.methinks.android.apptest.question.adapter.ViewControllerAdapter; /** * Created by kgy 2019. 9. 24. */ public class ViewControllerManager extends FragmentActivity { protected static HashMap<String, ArrayList<Object>> answerMap; protected int num_pages; protected ViewPager mPager; protected PagerAdapter pagerAdapter; protected static ViewControllerAdapter adapter; protected static ProgressBar progressBar; protected Button prev; protected Button skip; protected EditText openEndEditText; protected static Context context; protected org.json.JSONObject currQuestion; protected static HashMap<String, String> sequenceLogicCache; public static HashMap<String, Object> cache; protected BottomSheetFragment bottomSheetFragment; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); try{ setRequestedOrientation(getIntent().getIntExtra("orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)); }catch (IllegalStateException e){ Log.w("API 26 doesn't support setRequestedOrientation function."); } DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int height = displayMetrics.heightPixels; int width = displayMetrics.widthPixels; boolean isQuestion = getIntent().getBooleanExtra("isQuestion", true); boolean isRequired = getIntent().getBooleanExtra("isRequired", false); if(isQuestion){ bottomSheetFragment = BottomSheetFragment.getInstance(height, width, isRequired); bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag()); }else{ boolean isBugReport = getIntent().getBooleanExtra("isBugReport", false); bottomSheetFragment = BottomSheetFragment.getInstance(height, width, isRequired, isBugReport); bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag()); } } @Override protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); } @Override public void onBackPressed() { if(!getIntent().getBooleanExtra("isRequired", false)){ super.onBackPressed(); } } @Override protected void onDestroy() { Global.isShowingQuestion = false; if(ViewConstant.pack.getType().equals(QuestionPack.EVENT_TYPE)){ Global.eventQuestionPack = null; }else{ Global.packQueue.remove(Global.packQueue.peek()); } if(Global.hover != null) Global.hover.setVisible(); if(Global.hover != null) { Global.hoverPopup.setInvisible(); Global.hoverPopup.isOpened = false; } super.onDestroy(); } }
33.027523
119
0.713889
e50d02ef33d9f31270cfb3b176b84299c54f6c69
3,927
package org.summerclouds.facade.core; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import org.summerclouds.common.core.node.MProperties; public class Model { private ArrayList<Definition> definitions = new ArrayList<Definition>(); private Definition definition = new Definition(); private MProperties properties = new MProperties(); private TreeMap<String, Service> services = new TreeMap<>(); private TreeMap<String, Struct> structs = new TreeMap<>(); public Definition getDefinition() { return definition; } public void addDefinition(Definition def) { definitions.add(def); for (FieldDefinition value : def.getFieldTypes().values()) definition.addFieldType(value); for (Map.Entry<String, String> value : def.getAliases().entrySet()) definition.addAlias(value.getKey(), value.getValue()); } public void setProperty(String key, Object value) { properties.put(key, value); } public void addService(String name, Service service) { services.put(name, service); } public void addStruct(String name, Struct struct) { structs.put(name, struct); } public void dump() { System.out.println("========= Properties =============="); properties.forEach((k,v) -> System.out.println(k + "=" + v)); System.out.println("========= Definitions ============="); for (Definition def : definitions) def.dump(); System.out.println("========= Definition ============="); definition.dump(); System.out.println("========= Structures =============="); for (Entry<String, Struct> struct : structs.entrySet()) { System.out.println(">>> " + struct.getKey()); struct.getValue().dump(); } System.out.println("========= Services ================"); for (Entry<String, Service> service : services.entrySet()) { System.out.println(">>> " + service.getKey()); service.getValue().dump(); } System.out.println("========= Modules ================="); for (String module : getModules()) { System.out.println(">>> " + module); for (Struct struct : getModuleStructs(module)) { System.out.println("--- Struct: " + struct.getName()); // struct.dump(); } for (Service service : getModuleServices(module)) { System.out.println("--- Service: " + service.getName()); // service.dump(); } } } public Map<String, Struct> getStructs() { return structs; } public String getAliasFor(String type) { return definition.getAliases().get(type); } public Map<String, Service> getServices() { return services; } public List<Definition> getDefinitions() { return definitions; } public MProperties getProperties() { return properties; } public Set<String> getModules() { TreeSet<String> set = new TreeSet<>(); for (Entry<String, Struct> struct : structs.entrySet()) { String module = struct.getValue().getProperties().getString("module", null); if (module != null) set.add(module); } for (Entry<String, Service> service : services.entrySet()) { String module = service.getValue().getProperties().getString("module", null); if (module != null) set.add(module); } return set; } public List<Struct> getModuleStructs(String name) { ArrayList<Struct> list = new ArrayList<>(); for (Entry<String, Struct> struct : structs.entrySet()) { String module = struct.getValue().getProperties().getString("module", null); if (module != null && module.equals(name)) list.add(struct.getValue()); } return list; } public List<Service> getModuleServices(String name) { ArrayList<Service> list = new ArrayList<>(); for (Entry<String, Service> service : services.entrySet()) { String module = service.getValue().getProperties().getString("module", null); if (module != null && module.equals(name)) list.add(service.getValue()); } return list; } }
29.30597
80
0.6603
0a1b2f544f617ca501cfd9ec2df558cbc3263fd5
8,910
/* * Copyright 2019 EMBL - European Bioinformatics Institute * 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 uk.ac.ebi.biosamples.legacy.json.controller; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.Link; import org.springframework.hateoas.MediaTypes; import org.springframework.hateoas.PagedResources; import org.springframework.hateoas.Resource; import org.springframework.hateoas.Resources; import org.springframework.hateoas.core.EmbeddedWrapper; import org.springframework.hateoas.core.EmbeddedWrappers; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import uk.ac.ebi.biosamples.legacy.json.domain.ExternalLinksRelation; import uk.ac.ebi.biosamples.legacy.json.domain.GroupsRelations; import uk.ac.ebi.biosamples.legacy.json.domain.SamplesRelations; import uk.ac.ebi.biosamples.legacy.json.repository.SampleRepository; import uk.ac.ebi.biosamples.legacy.json.service.ExternalLinksResourceAssembler; import uk.ac.ebi.biosamples.legacy.json.service.GroupRelationsResourceAssembler; import uk.ac.ebi.biosamples.legacy.json.service.PagedResourcesConverter; import uk.ac.ebi.biosamples.legacy.json.service.SampleRelationsResourceAssembler; import uk.ac.ebi.biosamples.model.ExternalReference; import uk.ac.ebi.biosamples.model.Relationship; import uk.ac.ebi.biosamples.model.Sample; @RestController @RequestMapping( value = "/groupsrelations", produces = {MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ExposesResourceFor(GroupsRelations.class) public class GroupsRelationsController { private Logger log = LoggerFactory.getLogger(getClass()); private final SampleRepository sampleRepository; private final GroupRelationsResourceAssembler groupRelationsResourceAssembler; private final SampleRelationsResourceAssembler sampleRelationsResourceAssembler; private final ExternalLinksResourceAssembler externalLinksResourceAssembler; private final PagedResourcesConverter pagedResourcesConverter; public GroupsRelationsController( SampleRepository sampleRepository, ExternalLinksResourceAssembler externalLinksResourceAssembler, GroupRelationsResourceAssembler groupRelationsResourceAssembler, SampleRelationsResourceAssembler sampleRelationsResourceAssembler, PagedResourcesConverter pagedResourcesConverter) { this.sampleRepository = sampleRepository; this.externalLinksResourceAssembler = externalLinksResourceAssembler; this.groupRelationsResourceAssembler = groupRelationsResourceAssembler; this.sampleRelationsResourceAssembler = sampleRelationsResourceAssembler; this.pagedResourcesConverter = pagedResourcesConverter; } @CrossOrigin @GetMapping public PagedResources<Resource<GroupsRelations>> allGroupsRelations( @RequestParam(value = "page", required = false, defaultValue = "0") Integer page, @RequestParam(value = "size", required = false, defaultValue = "50") Integer size, @RequestParam(value = "sort", required = false, defaultValue = "asc") String sort) { log.warn("ACCESSING DEPRECATED API at GroupsRelationsController /"); PagedResources<Resource<Sample>> groups = sampleRepository.findGroups(page, size); PagedResources<Resource<GroupsRelations>> groupsRelations = this.pagedResourcesConverter.toGroupsRelationsPagedResource(groups); groupsRelations.add(linkTo(methodOn(this.getClass()).search()).withRel("search")); return groupsRelations; } @CrossOrigin @GetMapping("/search") public Resources search() { log.warn("ACCESSING DEPRECATED API at GroupsRelationsController /search"); Resources searchResources = Resources.wrap(Collections.emptyList()); searchResources.add(linkTo(methodOn(this.getClass()).search()).withSelfRel()); searchResources.add( linkTo(methodOn(this.getClass()).findOneByAccession(null)).withRel("findOneByAccession")); return searchResources; } @CrossOrigin @GetMapping("/search/findOneByAccession") public ResponseEntity<Resource<GroupsRelations>> findOneByAccession( @RequestParam(value = "accession") String accession) { log.warn("ACCESSING DEPRECATED API at GroupsRelationsController /{accession:SAMEG\\d+}"); return this.getGroupsRelationsByAccession(accession); } @CrossOrigin @GetMapping("/{accession:SAMEG\\d+}") public ResponseEntity<Resource<GroupsRelations>> getGroupsRelationsByAccession( @PathVariable String accession) { log.warn("ACCESSING DEPRECATED API at GroupsRelationsController /"); Optional<Sample> sample = sampleRepository.findByAccession(accession); if (!sample.isPresent()) { return ResponseEntity.notFound().build(); } return ResponseEntity.ok( groupRelationsResourceAssembler.toResource(new GroupsRelations(sample.get()))); } @CrossOrigin @GetMapping("/{accession:SAMEG\\d+}/samples") public ResponseEntity<Resources<SamplesRelations>> getGroupSamplesRelations( @PathVariable String accession) { log.warn( "ACCESSING DEPRECATED API at GroupsRelationsController /{accession:SAMEG\\d+}/samples"); Optional<Sample> group = sampleRepository.findByAccession(accession); if (!group.isPresent()) { return ResponseEntity.notFound().build(); } List<Resource> associatedSamples = group.get().getRelationships().stream() .map(Relationship::getTarget) .map(sampleRepository::findByAccession) .filter(Optional::isPresent) .map(Optional::get) .map(SamplesRelations::new) .map(sampleRelationsResourceAssembler::toResource) .collect(Collectors.toList()); Link selfLink = linkTo(methodOn(this.getClass()).getGroupSamplesRelations(accession)).withSelfRel(); Resources responseBody = new Resources(wrappedCollection(associatedSamples, SamplesRelations.class), selfLink); return ResponseEntity.ok(responseBody); } @CrossOrigin @GetMapping("/{accession:SAMEG\\d+}/externalLinks") public ResponseEntity<Resources<ExternalLinksRelation>> getGroupExternalLinks( @PathVariable String accession) { log.warn( "ACCESSING DEPRECATED API at GroupsRelationsController /{accession:SAMEG\\d+}/externalLinks"); Optional<Sample> group = sampleRepository.findByAccession(accession); if (!group.isPresent()) { return ResponseEntity.notFound().build(); } List<Resource> associatedSamples = group.get().getExternalReferences().stream() .map(ExternalReference::getUrl) .map(ExternalLinksRelation::new) .map(externalLinksResourceAssembler::toResource) .collect(Collectors.toList()); Link selfLink = linkTo(methodOn(this.getClass()).getGroupSamplesRelations(accession)).withSelfRel(); Resources responseBody = new Resources(wrappedCollection(associatedSamples, ExternalLinksRelation.class), selfLink); return ResponseEntity.ok(responseBody); } /** * Wrap the collection and return an empty _embedded if provided collection is empty * * @param resourceCollection The collection to wrap * @param collectionClass the class to use to create the empty collection wrapper * @return A resource collection */ private Collection wrappedCollection(List<Resource> resourceCollection, Class collectionClass) { EmbeddedWrappers wrappers = new EmbeddedWrappers(false); EmbeddedWrapper wrapper; if (resourceCollection.isEmpty()) wrapper = wrappers.emptyCollectionOf(collectionClass); else wrapper = wrappers.wrap(resourceCollection); return Collections.singletonList(wrapper); } }
45.692308
102
0.776768
c2e548b78e75f363eeefe640189d6e6ea1ac2eba
49,763
package com.cyl.musiclake.player; import android.annotation.SuppressLint; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.media.audiofx.AudioEffect; import android.os.Build; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.support.v4.media.session.PlaybackStateCompat; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; import androidx.media.session.MediaButtonReceiver; import com.cyl.musiclake.R; import com.cyl.musiclake.api.music.MusicApi; import com.cyl.musiclake.api.net.ApiManager; import com.cyl.musiclake.api.net.RequestCallBack; import com.cyl.musiclake.bean.Music; import com.cyl.musiclake.data.PlayHistoryLoader; import com.cyl.musiclake.data.PlayQueueLoader; import com.cyl.musiclake.common.Constants; import com.cyl.musiclake.common.Extras; import com.cyl.musiclake.event.MetaChangedEvent; import com.cyl.musiclake.event.PlaylistEvent; import com.cyl.musiclake.event.StatusChangedEvent; import com.cyl.musiclake.player.playback.PlayProgressListener; import com.cyl.musiclake.player.playqueue.PlayQueueManager; import com.cyl.musiclake.ui.music.playpage.PlayerActivity; import com.cyl.musiclake.ui.widget.appwidgets.StandardWidget; import com.cyl.musiclake.utils.CoverLoader; import com.cyl.musiclake.utils.FileUtils; import com.cyl.musiclake.utils.LogUtil; import com.cyl.musiclake.utils.NetworkUtils; import com.cyl.musiclake.utils.SPUtils; import com.cyl.musiclake.utils.SystemUtils; import com.cyl.musiclake.utils.ToastUtils; import org.greenrobot.eventbus.EventBus; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Random; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; public class MusicPlayerService extends Service { private static final String TAG = "MusicPlayerService"; public static final String ACTION_SERVICE = "com.cyl.music_lake.service";// 广播标志 // 通知栏 public static final String ACTION_NEXT = "com.cyl.music_lake.notify.next";// 下一首广播标志 public static final String ACTION_PREV = "com.cyl.music_lake.notify.prev";// 上一首广播标志 public static final String ACTION_PLAY_PAUSE = "com.cyl.music_lake.notify.play_state";// 播放暂停广播 public static final String ACTION_CLOSE = "com.cyl.music_lake.notify.close";// 播放暂停广播 public static final String ACTION_IS_WIDGET = "ACTION_IS_WIDGET";// 播放暂停广播 public static final String ACTION_LYRIC = "com.cyl.music_lake.notify.lyric";// 播放暂停广播 public static final String PLAY_STATE_CHANGED = "com.cyl.music_lake.play_state";// 播放暂停广播 public static final String PLAY_STATE_LOADING_CHANGED = "com.cyl.music_lake.play_state_loading";// 播放loading public static final String DURATION_CHANGED = "com.cyl.music_lake.duration";// 播放时长 public static final String TRACK_ERROR = "com.cyl.music_lake.error"; public static final String SHUTDOWN = "com.cyl.music_lake.shutdown"; public static final String REFRESH = "com.cyl.music_lake.refresh"; public static final String PLAY_QUEUE_CLEAR = "com.cyl.music_lake.play_queue_clear"; //清空播放队列 public static final String PLAY_QUEUE_CHANGE = "com.cyl.music_lake.play_queue_change"; //播放队列改变 public static final String META_CHANGED = "com.cyl.music_lake.metachanged";//状态改变(歌曲替换) public static final String SCHEDULE_CHANGED = "com.cyl.music_lake.schedule";//定时广播 public static final String CMD_TOGGLE_PAUSE = "toggle_pause";//按键播放暂停 public static final String CMD_NEXT = "next";//按键下一首 public static final String CMD_PREVIOUS = "previous";//按键上一首 public static final String CMD_PAUSE = "pause";//按键暂停 public static final String CMD_PLAY = "play";//按键播放 public static final String CMD_STOP = "stop";//按键停止 public static final String CMD_FORWARD = "forward";//按键停止 public static final String CMD_REWIND = "reward";//按键停止 public static final String SERVICE_CMD = "cmd_service";//状态改变 public static final String FROM_MEDIA_BUTTON = "media";//状态改变 public static final String CMD_NAME = "name";//状态改变 public static final String UNLOCK_DESKTOP_LYRIC = "unlock_lyric"; //音量改变增加 public static final int TRACK_WENT_TO_NEXT = 2; //下一首 public static final int RELEASE_WAKELOCK = 3; //播放完成 public static final int TRACK_PLAY_ENDED = 4; //播放完成 public static final int TRACK_PLAY_ERROR = 5; //播放出错 public static final int PREPARE_ASYNC_UPDATE = 7; //PrepareAsync装载进程 public static final int PLAYER_PREPARED = 8; //mediaplayer准备完成 public static final int AUDIO_FOCUS_CHANGE = 12; //音频焦点改变 public static final int VOLUME_FADE_DOWN = 13; //音量改变减少 public static final int VOLUME_FADE_UP = 14; //音量改变增加 private final int NOTIFICATION_ID = 0x123; private long mNotificationPostTime = 0; private int mServiceStartId = -1; /** * 错误次数,超过最大错误次数,自动停止播放 */ private int playErrorTimes = 0; private int MAX_ERROR_TIMES = 1; private static final boolean DEBUG = true; private MusicPlayerEngine mPlayer = null; public PowerManager.WakeLock mWakeLock; private PowerManager powerManager; public Music mPlayingMusic = null; private List<Music> mPlayQueue = new ArrayList<>(); private List<Integer> mHistoryPos = new ArrayList<>(); private int mPlayingPos = -1; private int mNextPlayPos = -1; private String mPlaylistId = Constants.PLAYLIST_QUEUE_ID; //广播接收者 ServiceReceiver mServiceReceiver; HeadsetReceiver mHeadsetReceiver; StandardWidget mStandardWidget; HeadsetPlugInReceiver mHeadsetPlugInReceiver; IntentFilter intentFilter; private FloatLyricViewManager mFloatLyricViewManager; private MediaSessionManager mediaSessionManager; private AudioAndFocusManager audioAndFocusManager; private NotificationManager mNotificationManager; private NotificationCompat.Builder mNotificationBuilder; private Notification mNotification; private IMusicServiceStub mBindStub = new IMusicServiceStub(this); private boolean isRunningForeground = false; private boolean isMusicPlaying = false; //暂时失去焦点,会再次回去音频焦点 private boolean mPausedByTransientLossOfFocus = false; //播放缓存进度 private int percent = 0; boolean mServiceInUse = false; //工作线程和Handler private MusicPlayerHandler mHandler; private HandlerThread mWorkThread; //主线程Handler private Handler mMainHandler; private boolean showLyric; private static MusicPlayerService instance; //歌词定时器 private Timer lyricTimer; public static MusicPlayerService getInstance() { return instance; } private static List<PlayProgressListener> listenerList = new ArrayList<>(); public static void addProgressListener(PlayProgressListener listener) { listenerList.add(listener); } public static void removeProgressListener(PlayProgressListener listener) { listenerList.remove(listener); } private Disposable disposable = Observable .interval(500, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(v -> { for (int i = 0; i < listenerList.size(); i++) { listenerList.get(i).onProgressUpdate(getCurrentPosition(), getDuration()); } }); public class MusicPlayerHandler extends Handler { private final WeakReference<MusicPlayerService> mService; private float mCurrentVolume = 1.0f; public MusicPlayerHandler(final MusicPlayerService service, final Looper looper) { super(looper); mService = new WeakReference<>(service); } @Override public void handleMessage(Message msg) { super.handleMessage(msg); MusicPlayerService service = mService.get(); synchronized (mService) { switch (msg.what) { case VOLUME_FADE_DOWN: mCurrentVolume -= 0.05f; if (mCurrentVolume > 0.2f) { sendEmptyMessageDelayed(VOLUME_FADE_DOWN, 10); } else { mCurrentVolume = 0.2f; } service.mPlayer.setVolume(mCurrentVolume); break; case VOLUME_FADE_UP: mCurrentVolume += 0.01f; if (mCurrentVolume < 1.0f) { sendEmptyMessageDelayed(VOLUME_FADE_UP, 10); } else { mCurrentVolume = 1.0f; } service.mPlayer.setVolume(mCurrentVolume); break; case TRACK_WENT_TO_NEXT: //mplayer播放完毕切换到下一首 // service.setAndRecordPlayPos(service.mNextPlayPos); mMainHandler.post(() -> service.next(true)); // service.updateCursor(service.mPlayQueue.get(service.mPlayPos).mId); // service.bumpSongCount(); //更新歌曲的播放次数 break; case TRACK_PLAY_ENDED://mPlayer播放完毕且暂时没有下一首 if (PlayQueueManager.INSTANCE.getPlayModeId() == PlayQueueManager.PLAY_MODE_REPEAT) { service.seekTo(0, false); mMainHandler.post(service::play); } else { mMainHandler.post(() -> service.next(true)); } break; case TRACK_PLAY_ERROR://mPlayer播放错误 LogUtil.e(TAG, "TRACK_PLAY_ERROR " + msg.obj + "---"); ToastUtils.show("Song play address is abnormal, please switch other songs"); playErrorTimes++; if (playErrorTimes < MAX_ERROR_TIMES) { mMainHandler.post(() -> service.next(true)); } else { mMainHandler.post(service::pause); } break; case RELEASE_WAKELOCK://释放电源锁 service.mWakeLock.release(); break; case PREPARE_ASYNC_UPDATE: percent = (int) msg.obj; LogUtil.e(TAG, "PREPARE_ASYNC_UPDATE Loading ... " + percent); notifyChange(PLAY_STATE_LOADING_CHANGED); break; case PLAYER_PREPARED: //执行prepared之后 准备完成,更新总时长 //准备完成,可以播放 LogUtil.e(TAG, "PLAYER_PREPARED"); isMusicPlaying = true; updateNotification(false); notifyChange(PLAY_STATE_CHANGED); break; case AUDIO_FOCUS_CHANGE: switch (msg.arg1) { case AudioManager.AUDIOFOCUS_LOSS://失去音频焦点 case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT://暂时失去焦点 if (service.isPlaying()) { mPausedByTransientLossOfFocus = msg.arg1 == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT; } mMainHandler.post(service::pause); break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: removeMessages(VOLUME_FADE_UP); sendEmptyMessage(VOLUME_FADE_DOWN); break; case AudioManager.AUDIOFOCUS_GAIN://重新获取焦点 //重新获得焦点,且符合播放条件,开始播放 if (!service.isPlaying() && mPausedByTransientLossOfFocus) { mPausedByTransientLossOfFocus = false; mCurrentVolume = 0f; service.mPlayer.setVolume(mCurrentVolume); mMainHandler.post(service::play); } else { removeMessages(VOLUME_FADE_DOWN); sendEmptyMessage(VOLUME_FADE_UP); } break; default: } break; } } } } @Override public void onCreate() { super.onCreate(); LogUtil.e(TAG, "onCreate"); instance = this; //初始化广播 initReceiver(); //初始化参数 initConfig(); //初始化电话监听服务 initTelephony(); //初始化通知 initNotify(); //初始化音乐播放服务 initMediaPlayer(); } /** * 参数配置,AudioManager、锁屏 */ @SuppressLint("InvalidWakeLockTag") private void initConfig() { //初始化主线程Handler mMainHandler = new Handler(Looper.getMainLooper()); PlayQueueManager.INSTANCE.getPlayModeId(); //初始化工作线程 mWorkThread = new HandlerThread("MusicPlayerThread"); mWorkThread.start(); mHandler = new MusicPlayerHandler(this, mWorkThread.getLooper()); //电源键 powerManager = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "PlayerWakelockTag"); mFloatLyricViewManager = new FloatLyricViewManager(this); //初始化和设置MediaSessionCompat mediaSessionManager = new MediaSessionManager(mBindStub, this, mMainHandler); audioAndFocusManager = new AudioAndFocusManager(this, mHandler); } /** * 释放通知栏; */ private void releaseServiceUiAndStop() { if (isPlaying() || mHandler.hasMessages(TRACK_PLAY_ENDED)) { return; } if (DEBUG) LogUtil.d(TAG, "Nothing is playing anymore, releasing notification"); cancelNotification(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mediaSessionManager.release(); if (!mServiceInUse) { savePlayQueue(false); stopSelf(mServiceStartId); } } /** * 重新加载当前进度 */ public void reloadPlayQueue() { mPlayQueue.clear(); mHistoryPos.clear(); mPlayQueue = PlayQueueLoader.INSTANCE.getPlayQueue(); mPlayingPos = SPUtils.getPlayPosition(); if (mPlayingPos >= 0 && mPlayingPos < mPlayQueue.size()) { mPlayingMusic = mPlayQueue.get(mPlayingPos); updateNotification(true); seekTo(SPUtils.getPosition(), true); notifyChange(META_CHANGED); } notifyChange(PLAY_QUEUE_CHANGE); } /** * 初始化电话监听服务 */ private void initTelephony() { TelephonyManager telephonyManager = (TelephonyManager) this .getSystemService(Context.TELEPHONY_SERVICE);// 获取电话通讯服务 telephonyManager.listen(new ServicePhoneStateListener(), PhoneStateListener.LISTEN_CALL_STATE);// 创建一个监听对象,监听电话状态改变事件 } /** * 初始化音乐播放服务 */ private void initMediaPlayer() { mPlayer = new MusicPlayerEngine(this); mPlayer.setHandler(mHandler); reloadPlayQueue(); } /** * 初始化广播 */ private void initReceiver() { //实例化过滤器,设置广播 intentFilter = new IntentFilter(ACTION_SERVICE); mServiceReceiver = new ServiceReceiver(); mHeadsetReceiver = new HeadsetReceiver(); mStandardWidget = new StandardWidget(); mHeadsetPlugInReceiver = new HeadsetPlugInReceiver(); intentFilter.addAction(ACTION_NEXT); intentFilter.addAction(ACTION_PREV); intentFilter.addAction(META_CHANGED); intentFilter.addAction(SHUTDOWN); intentFilter.addAction(ACTION_PLAY_PAUSE); //注册广播 registerReceiver(mServiceReceiver, intentFilter); registerReceiver(mHeadsetReceiver, intentFilter); registerReceiver(mHeadsetPlugInReceiver, intentFilter); registerReceiver(mStandardWidget, intentFilter); } /** * 启动Service服务,执行onStartCommand * * @param intent * @param flags * @param startId * @return */ @Override public int onStartCommand(Intent intent, int flags, int startId) { LogUtil.d(TAG, "Got new intent " + intent + ", startId = " + startId); mServiceStartId = startId; mServiceInUse = true; if (intent != null) { final String action = intent.getAction(); if (SHUTDOWN.equals(action)) { LogUtil.e("Music player is about to close"); // mShutdownScheduled = true; releaseServiceUiAndStop(); return START_NOT_STICKY; } handleCommandIntent(intent); } return START_NOT_STICKY; } /** * 绑定Service * * @param intent * @return */ @Nullable @Override public IBinder onBind(Intent intent) { return mBindStub; } private void setAndRecordPlayPos(int mNextPlayPos) { mPlayingPos = mNextPlayPos; } /** * 下一首 */ public void next(Boolean isAuto) { synchronized (this) { mPlayingPos = PlayQueueManager.INSTANCE.getNextPosition(isAuto, mPlayQueue.size(), mPlayingPos); LogUtil.e(TAG, "next: " + mPlayingPos); stop(false); playCurrentAndNext(); } } /** * 上一首 */ public void prev() { synchronized (this) { // if (!NetworkUtils.isNetworkAvailable(this)) { // ToastUtils.show("网络不可用,请检查网络连接"); // return; // } mPlayingPos = PlayQueueManager.INSTANCE.getPreviousPosition(mPlayQueue.size(), mPlayingPos); LogUtil.e(TAG, "prev: " + mPlayingPos); stop(false); playCurrentAndNext(); } } /** * 播放当前歌曲 */ private void playCurrentAndNext() { synchronized (this) { if (mPlayingPos >= mPlayQueue.size() || mPlayingPos < 0) { return; } mPlayingMusic = mPlayQueue.get(mPlayingPos); //更新当前歌曲 notifyChange(META_CHANGED); updateNotification(true); //更新播放播放状态 isMusicPlaying = false; notifyChange(PLAY_STATE_CHANGED); updateNotification(false); LogUtil.e(TAG, "playingSongInfo:" + mPlayingMusic.toString()); if (mPlayingMusic.getUri() == null || !Objects.equals(mPlayingMusic.getType(), Constants.LOCAL) || mPlayingMusic.getUri().equals("") || mPlayingMusic.getUri().equals("null")) { if (!NetworkUtils.isNetworkAvailable(this)) { ToastUtils.show("The network is unavailable, please check the network connection"); } else { ApiManager.request(MusicApi.INSTANCE.getMusicInfo(mPlayingMusic), new RequestCallBack<Music>() { @Override public void success(Music result) { LogUtil.e(TAG, "-----" + result.toString()); mPlayingMusic = result; saveHistory(); playErrorTimes = 0; mPlayer.setDataSource(mPlayingMusic.getUri()); } @Override public void error(String msg) { LogUtil.e(TAG, "Play abnormally-----" + msg); checkPlayErrorTimes(); } }); } } saveHistory(); mHistoryPos.add(mPlayingPos); if (mPlayingMusic.getUri() != null) { if (!mPlayingMusic.getUri().startsWith(Constants.IS_URL_HEADER) && !FileUtils.exists(mPlayingMusic.getUri())) { checkPlayErrorTimes(); } else { playErrorTimes = 0; mPlayer.setDataSource(mPlayingMusic.getUri()); } } mediaSessionManager.updateMetaData(mPlayingMusic); audioAndFocusManager.requestAudioFocus(); final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); if (mPlayer.isInitialized()) { mHandler.removeMessages(VOLUME_FADE_DOWN); mHandler.sendEmptyMessage(VOLUME_FADE_UP); //组件调到正常音量 // isMusicPlaying = true; // notifyChange(PLAY_STATE_CHANGED); } } } /** * 异常播放,自动切换下一首 */ private void checkPlayErrorTimes() { if (playErrorTimes > MAX_ERROR_TIMES) { pause(); } else { playErrorTimes++; ToastUtils.show("Play address is abnormal, automatically switch to the next song"); next(false); } } /** * 停止播放 * * @param remove_status_icon */ public void stop(boolean remove_status_icon) { if (mPlayer != null && mPlayer.isInitialized()) { mPlayer.stop(); } if (remove_status_icon) { cancelNotification(); } if (remove_status_icon) { isMusicPlaying = false; } } /** * 获取下一首位置 * * @return */ private int getNextPosition(Boolean isAuto) { int playModeId = PlayQueueManager.INSTANCE.getPlayModeId(); if (mPlayQueue == null || mPlayQueue.isEmpty()) { return -1; } if (mPlayQueue.size() == 1) { return 0; } if (playModeId == PlayQueueManager.PLAY_MODE_REPEAT && isAuto) { if (mPlayingPos < 0) { return 0; } else { return mPlayingPos; } } else if (playModeId == PlayQueueManager.PLAY_MODE_RANDOM) { return new Random().nextInt(mPlayQueue.size()); } else { if (mPlayingPos == mPlayQueue.size() - 1) { return 0; } else if (mPlayingPos < mPlayQueue.size() - 1) { return mPlayingPos + 1; } } return mPlayingPos; } /** * 获取上一首位置 * * @return */ private int getPreviousPosition() { int playModeId = PlayQueueManager.INSTANCE.getPlayModeId(); if (mPlayQueue == null || mPlayQueue.isEmpty()) { return -1; } if (mPlayQueue.size() == 1) { return 0; } if (playModeId == PlayQueueManager.PLAY_MODE_REPEAT) { if (mPlayingPos < 0) { return 0; } } else if (playModeId == PlayQueueManager.PLAY_MODE_RANDOM) { mPlayingPos = new Random().nextInt(mPlayQueue.size()); return new Random().nextInt(mPlayQueue.size()); } else { if (mPlayingPos == 0) { return mPlayQueue.size() - 1; } else if (mPlayingPos > 0) { return mPlayingPos - 1; } } return mPlayingPos; } /** * 根据位置播放音乐 * * @param position */ public void playMusic(int position) { if (position >= mPlayQueue.size() || position == -1) { mPlayingPos = PlayQueueManager.INSTANCE.getNextPosition(true, mPlayQueue.size(), position); } else { mPlayingPos = position; } if (mPlayingPos == -1) return; playCurrentAndNext(); } /** * 音乐播放 */ public void play() { if (mPlayer.isInitialized()) { mPlayer.start(); isMusicPlaying = true; notifyChange(PLAY_STATE_CHANGED); audioAndFocusManager.requestAudioFocus(); mHandler.removeMessages(VOLUME_FADE_DOWN); mHandler.sendEmptyMessage(VOLUME_FADE_UP); //组件调到正常音量 updateNotification(false); } else { playCurrentAndNext(); } } public int getAudioSessionId() { synchronized (this) { return mPlayer.getAudioSessionId(); } } /** * 【在线音乐,搜索的音乐】加入播放队列并播放音乐 * * @param music */ public void play(Music music) { if (music == null) return; if (mPlayingPos == -1 || mPlayQueue.size() == 0) { mPlayQueue.add(music); mPlayingPos = 0; } else if (mPlayingPos < mPlayQueue.size()) { mPlayQueue.add(mPlayingPos, music); } else { mPlayQueue.add(mPlayQueue.size(), music); } //发送播放列表改变 notifyChange(PLAY_QUEUE_CHANGE); LogUtil.e(TAG, music.toString()); mPlayingMusic = music; playCurrentAndNext(); } /** * 下一首播放 * * @param music 设置的歌曲 */ public void nextPlay(Music music) { if (mPlayQueue.size() == 0) { play(music); } else if (mPlayingPos < mPlayQueue.size()) { mPlayQueue.add(mPlayingPos + 1, music); //发送播放列表改变 notifyChange(PLAY_QUEUE_CHANGE); } } /** * 切换歌单播放 * 1、歌单不一样切换,不一样不切换 * 2、相同歌单只切换歌曲 * 3、相同歌曲不重新播放 * * @param musicList 歌单 * @param id 歌曲位置id * @param pid 歌单id */ public void play(List<Music> musicList, int id, String pid) { LogUtil.d(TAG, "musicList = " + musicList.size() + " id = " + id + " pid = " + pid + " mPlaylistId =" + mPlaylistId); if (musicList.size() <= id) return; if (mPlaylistId.equals(pid) && id == mPlayingPos) return; if (!mPlaylistId.equals(pid) || mPlayQueue.size() == 0 || mPlayQueue.size() != musicList.size()) { setPlayQueue(musicList); mPlaylistId = pid; } mPlayingPos = id; playCurrentAndNext(); } /** * 播放暂停 */ public void playPause() { if (isPlaying()) { pause(); } else { if (mPlayer.isInitialized()) { play(); } else { playCurrentAndNext(); } } } /** * 暂停播放 */ public void pause() { if (DEBUG) LogUtil.d(TAG, "Pausing playback"); synchronized (this) { mHandler.removeMessages(VOLUME_FADE_UP); mHandler.sendEmptyMessage(VOLUME_FADE_DOWN); if (isPlaying()) { isMusicPlaying = false; notifyChange(PLAY_STATE_CHANGED); updateNotification(false); TimerTask task = new TimerTask() { public void run() { final Intent intent = new Intent( AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(intent); //由系统接收,通知系统audio_session将关闭,不再使用音效 mPlayer.pause(); } }; Timer timer = new Timer(); timer.schedule(task, 200); } } } /** * 是否正在播放音乐 * * @return 是否正在播放音乐 */ public boolean isPlaying() { return isMusicPlaying; } /** * 跳到输入的进度 */ public void seekTo(long pos, boolean isInit) { LogUtil.e(TAG, "seekTo " + pos); if (mPlayer != null && mPlayer.isInitialized() && mPlayingMusic != null) { mPlayer.seek(pos); LogUtil.e(TAG, "seekTo success"); } else if (isInit) { // playCurrentAndNext(); // mPlayer.seek(pos); // mPlayer.pause(); LogUtil.e(TAG, "seekTo failure"); } } @Override public boolean onUnbind(Intent intent) { LogUtil.e(TAG, "onUnbind"); mServiceInUse = false; savePlayQueue(false); releaseServiceUiAndStop(); stopSelf(mServiceStartId); return true; } /** * 保存播放队列 * * @param full 是否存储 */ private void savePlayQueue(boolean full) { if (full) { PlayQueueLoader.INSTANCE.updateQueue(mPlayQueue); } if (mPlayingMusic != null) { //保存歌曲id SPUtils.saveCurrentSongId(mPlayingMusic.getMid()); } //保存歌曲id SPUtils.setPlayPosition(mPlayingPos); //保存歌曲进度 SPUtils.savePosition(getCurrentPosition()); LogUtil.e(TAG, "Save song id=" + mPlayingPos + " Song progress= " + getCurrentPosition()); } private void saveHistory() { PlayHistoryLoader.INSTANCE.addSongToHistory(mPlayingMusic); savePlayQueue(false); } /** * 获取正在播放的歌曲[本地|网络] */ public void removeFromQueue(int position) { try { LogUtil.e(TAG, position + "---" + mPlayingPos + "---" + mPlayQueue.size()); if (position == mPlayingPos) { mPlayQueue.remove(position); if (mPlayQueue.size() == 0) { clearQueue(); } else { playMusic(position); } } else if (position > mPlayingPos) { mPlayQueue.remove(position); } else if (position < mPlayingPos) { mPlayQueue.remove(position); mPlayingPos = mPlayingPos - 1; } notifyChange(PLAY_QUEUE_CLEAR); } catch (Exception e) { e.printStackTrace(); } } /** * 获取正在播放的歌曲[本地|网络] */ public void clearQueue() { mPlayingMusic = null; isMusicPlaying = false; mPlayingPos = -1; mPlayQueue.clear(); mHistoryPos.clear(); savePlayQueue(true); stop(true); notifyChange(META_CHANGED); notifyChange(PLAY_STATE_CHANGED); notifyChange(PLAY_QUEUE_CLEAR); } /** * 获取正在播放进度 */ public long getCurrentPosition() { if (mPlayer != null && mPlayer.isInitialized()) { return mPlayer.position(); } else { return 0; } } /** * 获取总时长 */ public long getDuration() { if (mPlayer != null && mPlayer.isInitialized() && mPlayer.isPrepared()) { return mPlayer.duration(); } return 0; } /** * 是否准备播放 * * @return */ public boolean isPrepared() { if (mPlayer != null) { return mPlayer.isPrepared(); } return false; } /** * 发送更新广播 * * @param what 发送更新广播 */ private void notifyChange(final String what) { if (DEBUG) LogUtil.d(TAG, "notifyChange: what = " + what); switch (what) { case META_CHANGED: mFloatLyricViewManager.loadLyric(mPlayingMusic); updateWidget(META_CHANGED); // notifyChange(PLAY_STATE_CHANGED); EventBus.getDefault().post(new MetaChangedEvent(mPlayingMusic)); break; case PLAY_STATE_CHANGED: updateWidget(ACTION_PLAY_PAUSE); mediaSessionManager.updatePlaybackState(); EventBus.getDefault().post(new StatusChangedEvent(isPrepared(), isPlaying(), percent * getDuration())); break; case PLAY_QUEUE_CLEAR: case PLAY_QUEUE_CHANGE: EventBus.getDefault().post(new PlaylistEvent(Constants.PLAYLIST_QUEUE_ID, null)); break; case PLAY_STATE_LOADING_CHANGED: //播放loading EventBus.getDefault().post(new StatusChangedEvent(isPrepared(), isPlaying(), percent * getDuration())); break; } } /** * 更新桌面小控件 */ private void updateWidget(String action) { Intent intent = new Intent(action); intent.putExtra(ACTION_IS_WIDGET, true); intent.putExtra(Extras.PLAY_STATUS, isPlaying()); if (action.equals(META_CHANGED)) { intent.putExtra(Extras.SONG, mPlayingMusic); } sendBroadcast(intent); } /** * 获取标题 * * @return */ public String getTitle() { if (mPlayingMusic != null) { return mPlayingMusic.getTitle(); } return null; } /** * 获取歌手专辑 * * @return */ public String getArtistName() { if (mPlayingMusic != null) { return mPlayingMusic.getArtist(); // return ConvertUtils.getArtistAndAlbum(mPlayingMusic.getArtist(), mPlayingMusic.getAlbum()); } return null; } /** * 获取专辑名 * * @return */ private String getAlbumName() { if (mPlayingMusic != null) { return mPlayingMusic.getArtist(); } return null; } /** * 获取当前音乐 * * @return */ public Music getPlayingMusic() { if (mPlayingMusic != null) { return mPlayingMusic; } return null; } /** * 设置播放队列 * * @param playQueue 播放队列 */ public void setPlayQueue(List<Music> playQueue) { mPlayQueue.clear(); mHistoryPos.clear(); mPlayQueue.addAll(playQueue); notifyChange(PLAY_QUEUE_CHANGE); savePlayQueue(true); } /** * 获取播放队列 * * @return 获取播放队列 */ public List<Music> getPlayQueue() { if (mPlayQueue.size() > 0) { return mPlayQueue; } return mPlayQueue; } /** * 获取当前音乐在播放队列中的位置 * * @return 当前音乐在播放队列中的位置 */ public int getPlayPosition() { if (mPlayingPos >= 0) { return mPlayingPos; } else return 0; } /** * 初始化通知栏 */ private void initNotify() { mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); final String albumName = getAlbumName(); final String artistName = getArtistName(); String text = TextUtils.isEmpty(albumName) ? artistName : artistName + " - " + albumName; int playButtonResId = isMusicPlaying ? R.drawable.ic_pause : R.drawable.ic_play; Intent nowPlayingIntent = new Intent(this, PlayerActivity.class); nowPlayingIntent.setAction(Constants.DEAULT_NOTIFICATION); PendingIntent clickIntent = PendingIntent.getActivity(this, 0, nowPlayingIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (mNotificationPostTime == 0) { mNotificationPostTime = System.currentTimeMillis(); } mNotificationBuilder = new NotificationCompat.Builder(this, initChannelId()) .setSmallIcon(R.drawable.ic_music) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setContentIntent(clickIntent) .setContentTitle(getTitle()) .setContentText(text) .setWhen(mNotificationPostTime) .addAction(playButtonResId, "", retrievePlaybackAction(ACTION_PLAY_PAUSE)) .addAction(R.drawable.ic_skip_previous, "", retrievePlaybackAction(ACTION_PREV)) .addAction(R.drawable.ic_skip_next, "", retrievePlaybackAction(ACTION_NEXT)) .addAction(R.drawable.ic_lyric, "", retrievePlaybackAction(ACTION_LYRIC)) .addAction(R.drawable.ic_clear, "", retrievePlaybackAction(ACTION_CLOSE)) .setDeleteIntent(MediaButtonReceiver.buildMediaButtonPendingIntent( this, PlaybackStateCompat.ACTION_STOP)); if (SystemUtils.isJellyBeanMR1()) { mNotificationBuilder.setShowWhen(false); } if (SystemUtils.isLollipop()) { //线控 isRunningForeground = true; mNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); androidx.media.app.NotificationCompat.MediaStyle style = new androidx.media.app.NotificationCompat.MediaStyle() .setMediaSession(mediaSessionManager.getMediaSession()) .setShowActionsInCompactView(1, 0, 2, 3, 4); mNotificationBuilder.setStyle(style); } if (mPlayingMusic != null) { CoverLoader.INSTANCE.loadImageViewByMusic(this, mPlayingMusic, bitmap -> { mNotificationBuilder.setLargeIcon(bitmap); mNotification = mNotificationBuilder.build(); mNotificationManager.notify(NOTIFICATION_ID, mNotification); return null; }); } mNotification = mNotificationBuilder.build(); } /** * 创建Notification ChannelID * * @return 频道id */ private String initChannelId() { // 通知渠道的id String id = "music_lake_01"; // 用户可以看到的通知渠道的名字. CharSequence name = "Music Lake"; // 用户可以看到的通知渠道的描述 String description = "Notification bar playback control"; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { int importance = NotificationManager.IMPORTANCE_LOW; NotificationChannel mChannel; mChannel = new NotificationChannel(id, name, importance); mChannel.setDescription(description); mChannel.enableLights(false); mChannel.enableVibration(false); //最后在notificationmanager中创建该通知渠道 mNotificationManager.createNotificationChannel(mChannel); } return id; } private PendingIntent retrievePlaybackAction(final String action) { Intent intent = new Intent(action); intent.setComponent(new ComponentName(this, MusicPlayerService.class)); return PendingIntent.getService(this, 0, intent, 0); } public String getAudioId() { if (mPlayingMusic != null) { return mPlayingMusic.getMid(); } else { return null; } } /** * 显示桌面歌词 * 开个定时器定时刷新桌面歌词 * * @param show */ public void showDesktopLyric(boolean show) { if (show) { // 开启定时器,每隔0.5秒刷新一次 if (lyricTimer == null) { lyricTimer = new Timer(); lyricTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (isMusicPlaying){ //正在播放时刷新 mFloatLyricViewManager.updateLyric(getCurrentPosition(), getDuration()); } } }, 0, 1); } } else { if (lyricTimer != null) { lyricTimer.cancel(); lyricTimer = null; } mFloatLyricViewManager.removeFloatLyricView(this); } } /** * 电话监听 */ private class ServicePhoneStateListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { LogUtil.d(TAG, "TelephonyManager state=" + state + ",incomingNumber = " + incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_OFFHOOK: //接听状态 case TelephonyManager.CALL_STATE_RINGING: //响铃状态 pause(); break; } } } /** * 更新状态栏通知 * * @param isChange 是否改变歌曲信息 */ private void updateNotification(boolean isChange) { if (isChange) { if (mPlayingMusic != null) { CoverLoader.INSTANCE.loadImageViewByMusic(this, mPlayingMusic, bitmap -> { mNotificationBuilder.setLargeIcon(bitmap); mNotification = mNotificationBuilder.build(); mNotificationManager.notify(NOTIFICATION_ID, mNotification); return null; }); } mNotificationBuilder.setContentTitle(getTitle()); mNotificationBuilder.setContentText(getArtistName()); mNotificationBuilder.setTicker(getTitle() + "-" + getArtistName()); } LogUtil.d("Playback status = " + isPlaying()); if (isMusicPlaying) mNotificationBuilder.mActions.get(0).icon = R.drawable.ic_pause; else mNotificationBuilder.mActions.get(0).icon = R.drawable.ic_play; mNotification = mNotificationBuilder.build(); mFloatLyricViewManager.updatePlayStatus(isMusicPlaying); if (mPlayingMusic != null) { startForeground(NOTIFICATION_ID, mNotification); mNotificationManager.notify(NOTIFICATION_ID, mNotification); } } /** * 取消通知 */ private void cancelNotification() { stopForeground(true); mNotificationManager.cancel(NOTIFICATION_ID); isRunningForeground = false; } /** * Service broadcastReceiver 监听service中广播 */ private class ServiceReceiver extends BroadcastReceiver { // public ServiceReceiver() { // intentFilter.addAction(Intent.ACTION_SCREEN_OFF); // } @Override public void onReceive(Context context, Intent intent) { LogUtil.d(TAG, intent.getAction()); // if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { // LogUtil.e(TAG, "屏幕熄灭进入锁屏界面"); // Intent lockScreen = new Intent(MusicPlayerService.this, LockScreenPlayerActivity.class); // lockScreen.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // startActivity(lockScreen); // } if (!intent.getBooleanExtra(ACTION_IS_WIDGET, false)) { handleCommandIntent(intent); } } } /** * Intent处理 * * @param intent */ private void handleCommandIntent(Intent intent) { final String action = intent.getAction(); final String command = SERVICE_CMD.equals(action) ? intent.getStringExtra(CMD_NAME) : null; if (DEBUG) LogUtil.d(TAG, "handleCommandIntent: action = " + action + ", command = " + command); if (CMD_NEXT.equals(command) || ACTION_NEXT.equals(action)) { next(false); } else if (CMD_PREVIOUS.equals(command) || ACTION_PREV.equals(action)) { prev(); } else if (CMD_TOGGLE_PAUSE.equals(command) || PLAY_STATE_CHANGED.equals(action) || ACTION_PLAY_PAUSE.equals(action)) { if (isPlaying()) { pause(); mPausedByTransientLossOfFocus = false; } else { play(); } } else if (UNLOCK_DESKTOP_LYRIC.equals(command)) { mFloatLyricViewManager.saveLock(false, true); } else if (CMD_PAUSE.equals(command)) { pause(); mPausedByTransientLossOfFocus = false; } else if (CMD_PLAY.equals(command)) { play(); } else if (CMD_STOP.equals(command)) { pause(); mPausedByTransientLossOfFocus = false; seekTo(0, false); releaseServiceUiAndStop(); } else if (ACTION_LYRIC.equals(action)) { startFloatLyric(); } else if (ACTION_CLOSE.equals(action)) { stop(true); stopSelf(); releaseServiceUiAndStop(); System.exit(0); } } /** * 开启歌词 */ private void startFloatLyric() { if (SystemUtils.isOpenFloatWindow()) { showLyric = !showLyric; SPUtils.putAnyCommit(SPUtils.SP_KEY_FLOAT_LYRIC_LOCK, false); showDesktopLyric(showLyric); } else { SystemUtils.applySystemWindow(); } } /** * 耳机插入广播接收器 */ public class HeadsetPlugInReceiver extends BroadcastReceiver { public HeadsetPlugInReceiver() { if (Build.VERSION.SDK_INT >= 21) { intentFilter.addAction(AudioManager.ACTION_HEADSET_PLUG); } else { intentFilter.addAction(Intent.ACTION_HEADSET_PLUG); } } @Override public void onReceive(Context context, Intent intent) { if (intent != null && intent.hasExtra("state")) { //通过判断 "state" 来知道状态 final boolean isPlugIn = intent.getExtras().getInt("state") == 1; LogUtil.e(TAG, "Headphone plugged in :" + isPlugIn); } } } /** * 耳机拔出广播接收器 */ private class HeadsetReceiver extends BroadcastReceiver { final BluetoothAdapter bluetoothAdapter; public HeadsetReceiver() { intentFilter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY); //有线耳机拔出变化 intentFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED); //蓝牙耳机连接变化 bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); } @Override public void onReceive(Context context, Intent intent) { if (isRunningForeground) { //当前是正在运行的时候才能通过媒体按键来操作音频 switch (intent.getAction()) { case BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED: LogUtil.e("Bluetooth headset plug-in status changed"); if (bluetoothAdapter != null && BluetoothProfile.STATE_DISCONNECTED == bluetoothAdapter.getProfileConnectionState(BluetoothProfile.HEADSET) && isPlaying()) { //蓝牙耳机断开连接 同时当前音乐正在播放 则将其暂停 pause(); } break; case AudioManager.ACTION_AUDIO_BECOMING_NOISY: LogUtil.e("Wired headset plug-in status changed"); if (isPlaying()) { //有线耳机断开连接 同时当前音乐正在播放 则将其暂停 pause(); } break; } } } } @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @Override public void onDestroy() { super.onDestroy(); LogUtil.e(TAG, "onDestroy"); disposable.dispose(); // Remove any sound effects final Intent audioEffectsIntent = new Intent( AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(audioEffectsIntent); savePlayQueue(false); //释放mPlayer if (mPlayer != null) { mPlayer.stop(); isMusicPlaying = false; mPlayer.release(); mPlayer = null; } // 释放Handler资源 if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); mHandler = null; } // 释放工作线程资源 if (mWorkThread != null && mWorkThread.isAlive()) { mWorkThread.quitSafely(); mWorkThread.interrupt(); mWorkThread = null; } audioAndFocusManager.abandonAudioFocus(); cancelNotification(); //注销广播 unregisterReceiver(mServiceReceiver); unregisterReceiver(mHeadsetReceiver); unregisterReceiver(mHeadsetPlugInReceiver); unregisterReceiver(mStandardWidget); if (mWakeLock.isHeld()) mWakeLock.release(); } }
33.353217
188
0.568957
e93f691ce2a4189ca945bd580dc275beefc3e862
1,550
package suryagaddipati.codeclimate; import com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.type.*; import com.fasterxml.jackson.databind.*; import hudson.plugins.analysis.core.*; import hudson.plugins.analysis.util.model.*; import java.io.*; import java.lang.reflect.*; import java.util.*; public class CodeClimateResultParser extends AbstractAnnotationParser { protected CodeClimateResultParser(String defaultEncoding) { super(defaultEncoding); } @Override public Collection<FileAnnotation> parse(InputStream file, String moduleName) throws InvocationTargetException { ObjectMapper mapper = new ObjectMapper(); ArrayList<FileAnnotation> annotations = new ArrayList<FileAnnotation>(); try { mapper.setVisibilityChecker(mapper.getSerializationConfig().getDefaultVisibilityChecker() .withFieldVisibility(JsonAutoDetect.Visibility.ANY) .withGetterVisibility(JsonAutoDetect.Visibility.NONE) .withSetterVisibility(JsonAutoDetect.Visibility.NONE) .withCreatorVisibility(JsonAutoDetect.Visibility.NONE)); List<CodeClimateWarning> warnings= mapper.readValue(file, new TypeReference<List<CodeClimateWarning>>() { }); for(CodeClimateWarning warning: warnings){ annotations.add( new CodeClimateAnnotation(warning)); } } catch (IOException e) { throw new RuntimeException(e) ; } return annotations; } }
38.75
122
0.7
a89d0edf1a8232ddfba5a788c882b4b0e9205fe4
501
package org.arkecosystem.crypto.transactions.serializers; import java.nio.ByteBuffer; import org.arkecosystem.crypto.encoding.Hex; import org.arkecosystem.crypto.transactions.Transaction; public class HtlcRefund extends AbstractSerializer { public HtlcRefund(ByteBuffer buffer, Transaction transaction) { super(buffer, transaction); } @Override public void serialize() { this.buffer.put(Hex.decode(this.transaction.asset.htlcRefundAsset.lockTransactionId)); } }
29.470588
94
0.768463
fc6054543152c9244294be951807ff9400306c11
1,837
package com.parse.starter.Collation; import android.util.Log; import android.widget.Button; import android.widget.TextView; public class CollatedIdea { String title; String description; String author; public String id; public Integer votes; public TextView voteView; public Button upVote; public Button dwnVote; public boolean dwnActive = false; public boolean upActive = false; public CollatedIdea(String title, String description, String author){ this.title=title; this.description=description; this.author=author; } public CollatedIdea(){} public void setVotes(Integer votes){ this.votes=votes; if (voteView!=null) { voteView.setText(Integer.toString(votes)); } } public void setId(String id){ this.id = id; } public void setVoteView(TextView tv){ voteView = tv; } public void setButtons(Button upVote,Button dwnVote){ this.upVote = upVote; this.dwnVote = dwnVote; if (this.upVote!=null){ Log.i("setButtons","upvote not null"); } if (this.dwnVote!=null){ Log.i("setButtons","dwnvote not null"); } } public void resetButtonColors(){ upVote.setBackgroundResource(android.R.drawable.btn_default); dwnVote.setBackgroundResource(android.R.drawable.btn_default); } public void disableButton(String key){ if (key.equals("voteConUp")){ upActive = true; dwnActive = false; } else { dwnActive = true; upActive = false; } } public void resetButtons(){ upActive = false; dwnActive = false; } }
23.857143
74
0.580838
4dcbbf1bdf4d403ece21a433a13d64d147639847
3,258
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package co.edu.uniandes.csw.servicios.ejb; import co.edu.uniandes.csw.servicios.entities.ClienteEntity; import co.edu.uniandes.csw.servicios.entities.SolicitudServicioEntity; import co.edu.uniandes.csw.servicios.exceptions.BusinessLogicException; import co.edu.uniandes.csw.servicios.persistence.ClientePersistence; import co.edu.uniandes.csw.servicios.persistence.SolicitudServicioPersistence; import javax.ejb.Stateless; import javax.inject.Inject; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * Clase que implementa la conexion con la persistencia para la relación entre * la entidad de Cliente y Servicio. * * @author ISIS2603 */ @Stateless public class ClienteSolicitudServicioLogic { private static final Logger LOGGER = Logger.getLogger(ClienteSolicitudServicioLogic.class.getName()); @Inject private SolicitudServicioPersistence solicitudServicioPersistence; @Inject private ClientePersistence clientePersistence; public SolicitudServicioEntity addSolicitudServicio(Long clientesId, Long solicitudServiciosId) { LOGGER.log(Level.INFO, "Inicia proceso de asociarle una solicitud de servicio al cliente con id = {0}", clientesId); ClienteEntity clienteEntity = clientePersistence.find(clientesId); SolicitudServicioEntity solicitudServicioEntity = solicitudServicioPersistence.find(solicitudServiciosId); solicitudServicioEntity.setCliente(clienteEntity); LOGGER.log(Level.INFO, "Termina proceso de asociarle una solicitud de servicio a un cliente con id = {0}", clientesId); return solicitudServicioPersistence.find(solicitudServiciosId); } public List<SolicitudServicioEntity> getServicios(Long clientesId) { LOGGER.log(Level.INFO, "Inicia proceso de consultar todos los servicios del cliente con id = {0}", clientesId); return clientePersistence.find(clientesId).getServicios(); } public SolicitudServicioEntity getSolicitudServicio(Long clientesId, Long solicitudServiciosId) throws BusinessLogicException { List<SolicitudServicioEntity> servicios = clientePersistence.find(clientesId).getServicios(); SolicitudServicioEntity servicioEntity = solicitudServicioPersistence.find(solicitudServiciosId); int index = servicios.indexOf(servicioEntity); if (index >= 0) { return servicios.get(index); } throw new BusinessLogicException("El servicio no está asociado al cliente"); } public List<SolicitudServicioEntity> replaceSolicitudServicios(Long clientesId, List<SolicitudServicioEntity> servicios) { LOGGER.log(Level.INFO, "Inicia proceso de reemplazar los servicios asocidos al clente con id = {0}", clientesId); ClienteEntity clienteEntity = clientePersistence.find(clientesId); clienteEntity.setServicios(servicios); LOGGER.log(Level.INFO, "Termina proceso de reemplazar los servicios asocidos al cliente con id = {0}", clientesId); return clienteEntity.getServicios(); } }
45.887324
131
0.766728
5ae3660f62656b2fa418c347adfb45c27f7c24ee
4,276
/** * Copyright (c) 2015, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.intel.stl.ui.model; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; import com.intel.stl.api.configuration.LoggingThreshold; import com.intel.stl.ui.common.STLConstants; public enum LoggingThresholdViz { ALL(LoggingThreshold.ALL, STLConstants.K0698_ALL.getValue()), TRACE(LoggingThreshold.TRACE, STLConstants.K0632_TRACE.getValue()), DEBUG(LoggingThreshold.DEBUG, STLConstants.K0630_DEBUG.getValue()), INFO(LoggingThreshold.INFO, STLConstants.K0631_INFO.getValue()), WARN(LoggingThreshold.WARN, STLConstants.K3002_WARN.getValue()), ERROR(LoggingThreshold.ERROR, STLConstants.K0030_ERROR.getValue()), OFF(LoggingThreshold.OFF, STLConstants.K0699_OFF.getValue()); private final static EnumMap<LoggingThreshold, String> loggingThresholdNameMap = new EnumMap<LoggingThreshold, String>(LoggingThreshold.class); static { for (LoggingThresholdViz thresholdViz : LoggingThresholdViz.values()) { loggingThresholdNameMap.put(thresholdViz.threshold, thresholdViz.name); } }; private final static Map<String, LoggingThreshold> loggingThresholdMap = new HashMap<String, LoggingThreshold>(); static { for (LoggingThresholdViz thresholdViz : LoggingThresholdViz.values()) { loggingThresholdMap.put(thresholdViz.getName(), thresholdViz.getThreshold()); } } private final static Map<LoggingThreshold, Integer> loggingThresholdMapAtId = new HashMap<LoggingThreshold, Integer>(); static { for (LoggingThresholdViz thresholdViz : LoggingThresholdViz.values()) { loggingThresholdMapAtId.put(thresholdViz.getThreshold(), thresholdViz.getId()); } } private final LoggingThreshold threshold; private final String name; private final int id; private LoggingThresholdViz(LoggingThreshold threshold, String name) { this.name = name; this.threshold = threshold; this.id = threshold.getId(); } public LoggingThreshold getThreshold() { return threshold; } public String getName() { return name; } public int getId() { return id; } public static String getLoggingThresholdName(LoggingThreshold threshold) { return loggingThresholdNameMap.get(threshold); } public static LoggingThreshold getLoggingThreshold(String name) { return loggingThresholdMap.get(name); } public static int getLoggingThresholdAtId(LoggingThreshold threshold) { return loggingThresholdMapAtId.get(threshold); } }
38.178571
84
0.718428
daa9e712040f863a393ea2df2f6fc7b3ab0ce473
9,072
package io.github.howiefh.jeews.modules.sys.controller; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import io.github.howiefh.jeews.common.BaseSpringJUnit4Test; import io.github.howiefh.jeews.common.shiro.ShiroTestUtils; import io.github.howiefh.jeews.modules.sys.entity.User; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.UUID; import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.hateoas.LinkDiscoverer; import org.springframework.hateoas.MediaTypes; import org.springframework.hateoas.RelProvider; import org.springframework.hateoas.hal.CurieProvider; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import com.fasterxml.jackson.databind.ObjectMapper; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserControllerTest extends BaseSpringJUnit4Test { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; private static int id; private static List<Integer> ids = new ArrayList<Integer>(); @Before public void setUp() { mockMvc = MockMvcBuilders.webAppContextSetup(wac).alwaysDo(print()) // 默认每次执行请求后都做的动作 .build(); User user = new User(); user.setId(1L); user.setUsername("root"); user.setLocked(false); ShiroTestUtils.mockSubject(user); } @After public void tearDown() { ShiroTestUtils.clearSubject(); } @Test public void testGetList() throws Exception { mockMvc.perform( get("/users?page=0&size=10&sort=id,asc&sort=username,desc&username=user").accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isOk()) // 200 .andExpect(content().contentType(MediaTypes.HAL_JSON)); // 验证响应contentType mockMvc.perform( get("/users?page=0&size=10&sort=id,asc&sort=username,desc&email=10").accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isOk()) // 200 .andExpect(content().contentType(MediaTypes.HAL_JSON)); // 验证响应contentType mockMvc.perform(get("/users?page=0&size=10&sort=id,asc").accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isOk()) // 200 .andExpect(content().contentType(MediaTypes.HAL_JSON)); mockMvc.perform(get("/users").accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isOk()) // 200 .andExpect(content().contentType(MediaTypes.HAL_JSON)); } @Test public void testGet() throws Exception { mockMvc.perform(get("/users/{id}", 1L).accept(MediaTypes.HAL_JSON)).andExpect(status().isOk()) // 200 .andExpect(content().contentType(MediaTypes.HAL_JSON)) // 验证响应contentType .andExpect(header().doesNotExist("Etag")).andExpect(jsonPath("$.username").value("root")).andReturn(); } @Test public void test1Create() throws Exception { String requestBody = "{\"username\":\"fh" + UUID.randomUUID() + "\",\"password\":\"123456\",\"email\":\"" + UUID.randomUUID() + "@qq.om\",\"mobile\":" + "\"" + new Random().nextInt() + "\",\"roles\":[1,2],\"organizations\":[1],\"locked\":true}"; MvcResult result = mockMvc .perform( post("/users").contentType(MediaType.APPLICATION_JSON).content(requestBody) .accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isCreated()) // 201 .andExpect(jsonPath("$.id").exists()) // 使用Json path验证JSON .andExpect(content().contentType(MediaTypes.HAL_JSON)).andReturn(); // 验证响应contentType String location = result.getResponse().getHeader("Location"); id = getId(location); } @Test public void test2Update() throws Exception { String requestBody = "{\"id\":" + id + ",\"username\":\"user" + id + "\",\"roles\":[1]}"; // requestBody = "{\"id\":"+id+",\"username\":\"user" + id + // "\",\"password\":\"123456\",\"roles\":[1]}"; mockMvc.perform( put("/users/{id}", id).contentType(MediaType.APPLICATION_JSON).content(requestBody) .accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isOk()) // 200 .andExpect(jsonPath("$.id").value(id)) // 使用Json path验证JSON // 请参考http://goessner.net/articles/JsonPath/ .andExpect(content().contentType(MediaTypes.HAL_JSON)); // 验证响应contentType String errorBody = "{username:user2,password:123456,roles:[1]}"; MvcResult result = mockMvc .perform( put("/users/{id}", id).contentType(MediaType.APPLICATION_JSON).content(errorBody) .accept(MediaType.APPLICATION_JSON)) // 执行请求 .andExpect(status().isInternalServerError()) // 500错误请求 .andExpect(jsonPath("$.code").value(500 + "")) // 使用Json // path验证JSON .andReturn(); assertTrue(HttpMessageNotReadableException.class.isAssignableFrom(result.getResolvedException().getClass()));// 错误的请求内容体 } @Test public void test3Delete() throws Exception { mockMvc.perform(delete("/users/{id}", id).contentType(MediaType.APPLICATION_JSON).accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isNoContent()); // 204 mockMvc.perform(delete("/users/?id={id}", 0L).accept(MediaType.APPLICATION_JSON)) // 执行请求 .andExpect(status().isInternalServerError()) // 500错误请求 .andExpect(jsonPath("$.code").value(500 + "")) // 使用Json // path验证JSON .andReturn(); } @Test public void test4DeleteAll() throws Exception { for (int i = 0; i < 3; i++) { String requestBody = "{\"username\":\"u" + UUID.randomUUID() + "\",\"password\":\"123456\",\"roles\":[1, 2],\"locked\":true}"; MvcResult result = mockMvc .perform( post("/users").contentType(MediaType.APPLICATION_JSON).content(requestBody) .accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isCreated()) // 201 .andReturn(); String location = result.getResponse().getHeader("Location"); id = getId(location); ids.add(id); } mockMvc.perform( delete("/users").contentType(MediaType.APPLICATION_JSON).content(ids.toString()) .accept(MediaTypes.HAL_JSON)) // 执行请求 .andExpect(status().isNoContent()); // 204 } @Test public void enablesHyperMediaSupportFromXml() { assertThat(wac.getBean(RelProvider.class), is(notNullValue())); assertThat(wac.getBean(CurieProvider.class), is(notNullValue())); assertThat(wac.getBean(LinkDiscoverer.class), is(notNullValue())); ObjectMapper objectMapper = (ObjectMapper) wac.getBean("_halObjectMapper"); assertThat(objectMapper, is(notNullValue())); assertTrue(objectMapper.getDateFormat().equals(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"))); } private int getId(String location) { int index = location.lastIndexOf('/'); if (index != -1) { return Integer.valueOf(location.substring(index + 1)); } return -1; } }
48.513369
128
0.636354
907e1ab30a05f890e9e04f8b6bd9a2e0cec16547
3,153
/* * Copyright (c) 2001-2019, Inversoft Inc., All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, * either express or implied. See the License for the specific * language governing permissions and limitations under the License. */ package org.primeframework.mvc.locale; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Locale; import com.google.inject.Inject; import org.apache.commons.lang3.LocaleUtils; import org.primeframework.mvc.config.MVCConfiguration; import org.primeframework.mvc.guice.Nullable; /** * This is the default LocaleProvider implementation. * * @author Brian Pontarelli */ public class DefaultLocaleProvider implements LocaleProvider { private final MVCConfiguration configuration; private final HttpServletRequest request; private final HttpServletResponse response; /** * Optionally inject the request. * * @param request The request. */ @Inject public DefaultLocaleProvider(@Nullable HttpServletRequest request, @Nullable HttpServletResponse response, MVCConfiguration configuration) { this.request = request; this.response = response; this.configuration = configuration; } /** * Looks up the Locale using this search order: * <p/> * <ol> * <li>If there is no request, use the system default</li> * <li>If there is a request, try a persistent cookie</li> * <li>If the locale hasn't been found, get it from the request Accept-Language header</li> * </ol> * * @return The Locale and never null. */ @Override public Locale get() { if (request == null) { return Locale.getDefault(); } String key = configuration.localeCookieName(); // Try a persistent cookie first Cookie[] cookies = request.getCookies(); if (cookies != null) { String value = null; for (Cookie cookie : cookies) { if (cookie.getName().equals(key)) { value = cookie.getValue(); break; } } if (value != null) { try { return LocaleUtils.toLocale(value); } catch (Exception e) { // Ignore and keep going } } } return request.getLocale(); } /** * Sets the Locale into the response as a cookie. * * @param locale The Locale to store. */ @Override public void set(Locale locale) { if (response == null) { return; } String key = configuration.localeCookieName(); Cookie cookie = new Cookie(key, locale != null ? locale.toString() : null); cookie.setMaxAge(locale != null ? Integer.MAX_VALUE : 0); cookie.setPath("/"); response.addCookie(cookie); } }
28.151786
108
0.669838
0abc49ed5a45c203c12fc4d726d90675b9df522d
5,134
/* * 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.tomcat.util.bcel.classfile; import java.io.DataInputStream; import java.io.IOException; import org.apache.tomcat.util.bcel.Constants; import org.apache.tomcat.util.bcel.util.BCELComparator; /** * Class for fields and methods. * * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A> */ public class FieldOrMethod extends AccessFlags implements Cloneable { private static final long serialVersionUID = -3383525930205542157L; private static BCELComparator _cmp = new BCELComparator() { @Override public boolean equals( Object o1, Object o2 ) { FieldOrMethod THIS = (FieldOrMethod) o1; FieldOrMethod THAT = (FieldOrMethod) o2; return THIS.getName().equals(THAT.getName()) && THIS.getSignature().equals(THAT.getSignature()); } @Override public int hashCode( Object o ) { FieldOrMethod THIS = (FieldOrMethod) o; return THIS.getSignature().hashCode() ^ THIS.getName().hashCode(); } }; protected int name_index; // Points to field name in constant pool protected int signature_index; // Points to encoded signature protected int attributes_count; // No. of attributes protected Attribute[] attributes; // Collection of attributes protected ConstantPool constant_pool; FieldOrMethod() { } /** * Construct object from file stream. * @param file Input stream * @throws IOException * @throws ClassFormatException */ protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null, constant_pool); attributes_count = file.readUnsignedShort(); attributes = new Attribute[attributes_count]; for (int i = 0; i < attributes_count; i++) { attributes[i] = Attribute.readAttribute(file, constant_pool); } } /** * @param access_flags Access rights of method * @param name_index Points to field name in constant pool * @param signature_index Points to encoded signature * @param attributes Collection of attributes * @param constant_pool Array of constants */ protected FieldOrMethod(int access_flags, int name_index, int signature_index, Attribute[] attributes, ConstantPool constant_pool) { this.access_flags = access_flags; this.name_index = name_index; this.signature_index = signature_index; this.constant_pool = constant_pool; setAttributes(attributes); } /** * @param attributes Collection of object attributes. */ public final void setAttributes( Attribute[] attributes ) { this.attributes = attributes; attributes_count = (attributes == null) ? 0 : attributes.length; } /** * @return Name of object, i.e., method name or field name */ public final String getName() { ConstantUtf8 c; c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); return c.getBytes(); } /** * @return String representation of object's type signature (java style) */ public final String getSignature() { ConstantUtf8 c; c = (ConstantUtf8) constant_pool.getConstant(signature_index, Constants.CONSTANT_Utf8); return c.getBytes(); } /** * Return value as defined by given BCELComparator strategy. * By default two FieldOrMethod objects are said to be equal when * their names and signatures are equal. * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { return _cmp.equals(this, obj); } /** * Return value as defined by given BCELComparator strategy. * By default return the hashcode of the FieldOrMethod's name XOR signature. * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return _cmp.hashCode(this); } }
34.226667
98
0.65037
65d5a0f1ed410eb3d406dc56e2ba55943e76f41f
4,354
/** * */ package org.adorsys.adcshdwr.jpa; import java.math.BigDecimal; import java.util.Date; import javax.persistence.Column; import javax.persistence.Enumerated; import javax.persistence.MappedSuperclass; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; import org.adorsys.adcore.jpa.AbstractIdentifData; import org.adorsys.adcore.utils.BigDecimalUtils; import org.adorsys.adcore.utils.FinancialOps; import org.adorsys.javaext.description.Description; import org.apache.commons.lang3.StringUtils; /** * @author boriswaguia * */ @MappedSuperclass @Description("CdrPymntItem_description") public abstract class CdrAbstractPymntItem extends AbstractIdentifData{ @Column @Description("CdrPymntItem_pymntNbr_description") @NotNull private String pymntNbr; @Column @Description("CdrPymntItem_pymntMode_description") @Enumerated @NotNull private CdrPymntMode pymntMode; @Column @Description("CdrPymntItem_pymntDocType_description") private String pymntDocType; @Column @Description("CdrPymntItem_pymntDocNbr_description") private String pymntDocNbr; @Temporal(TemporalType.TIMESTAMP) @Description("CdrPymnt_pymntDt_description") @NotNull private Date pymntDt; @Column @Description("CdrPymntItem_amt_description") @NotNull private BigDecimal amt; @Column @Description("CdrPymntItem_rcvdAmt_description") private BigDecimal rcvdAmt; @Column @Description("CdrPymntItem_diffAmt_description") private BigDecimal diffAmt; public String getPymntNbr() { return this.pymntNbr; } public void setPymntNbr(final String pymntNbr) { this.pymntNbr = pymntNbr; } public CdrPymntMode getPymntMode() { return this.pymntMode; } public void setPymntMode(final CdrPymntMode pymntMode) { this.pymntMode = pymntMode; } public String getPymntDocType() { return this.pymntDocType; } public void setPymntDocType(final String pymntDocType) { this.pymntDocType = pymntDocType; } public String getPymntDocNbr() { return this.pymntDocNbr; } public void setPymntDocNbr(final String pymntDocNbr) { this.pymntDocNbr = pymntDocNbr; } public BigDecimal getAmt() { return this.amt; } public void setAmt(final BigDecimal amt) { this.amt = amt; } public Date getPymntDt() { return pymntDt; } public void setPymntDt(Date pymntDt) { this.pymntDt = pymntDt; } public BigDecimal getRcvdAmt() { return this.rcvdAmt; } public void setRcvdAmt(final BigDecimal rcvdAmt) { this.rcvdAmt = rcvdAmt; } public BigDecimal getDiffAmt() { return this.diffAmt; } public void setDiffAmt(final BigDecimal diffAmt) { this.diffAmt = diffAmt; } @Override public String makeIdentif() { return pymntNbr + "_ " + pymntMode.name() + "_" + pymntDocType + "_" + pymntDocNbr; } /** * contentEquals. * * @param persDi * @return */ public boolean contentEquals(CdrAbstractPymntItem target) { if(!StringUtils.equals(target.pymntNbr,pymntNbr)) return false; if(target.pymntMode != pymntMode) return false; if(!StringUtils.equals(target.pymntDocType,pymntDocType)) return false; if(!StringUtils.equals(target.pymntDocNbr,pymntDocNbr)) return false; if(!BigDecimalUtils.numericEquals(target.amt,amt)) return false; if(!BigDecimalUtils.numericEquals(target.rcvdAmt,rcvdAmt)) return false; if(!BigDecimalUtils.numericEquals(target.diffAmt,diffAmt)) return false; return true; } /** * copyTo. * * @param target */ public void copyTo(CdrAbstractPymntItem target) { target.pymntNbr=pymntNbr; target.pymntDt = pymntDt; target.pymntMode=pymntMode; target.pymntDocType=pymntDocType; target.pymntDocNbr=pymntDocNbr; target.amt=amt; target.rcvdAmt=rcvdAmt; target.diffAmt=diffAmt; } /** * evlte. * */ public void evlte() { if(this.amt == null) amt = BigDecimal.ZERO; if(this.rcvdAmt == null) rcvdAmt = BigDecimal.ZERO; if(this.diffAmt == null) diffAmt = BigDecimal.ZERO; this.diffAmt = FinancialOps.substract(rcvdAmt, amt); } public CdrPymntObject toPymntObject() { CdrPymntObject pymntObject = new CdrPymntObject(); pymntObject.setAmt(amt); pymntObject.setOrigDocNbr(pymntDocNbr); pymntObject.setOrigItemNbr(getIdentif()); pymntObject.setOrigDocType(CdrPymntItemInfo.getDocType()); pymntObject.setPymntNbr(pymntNbr); return pymntObject; } }
22.795812
85
0.759761
1007adf69483cffa29b1284608af9080bb273f8d
141,629
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package etrt.system; import etrt.database.My_CNX; import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.ButtonModel; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; /** * * @author leduy */ public class THI_Form extends javax.swing.JFrame { int sum; int visit_id; int thi_id; ButtonGroup [] btngrp; /** * Creates new form THI_Form */ public THI_Form() { initComponents(); addActions(); this.setLocationRelativeTo(null); Border border = jLabel2.getBorder(); Border margin = new EmptyBorder(0,5,0,5); jLabel2.setBorder(new CompoundBorder(border, margin)); } public THI_Form(String name, String date, int visitID) { initComponents(); addActions(); this.setLocationRelativeTo(null); Border border = jLabel2.getBorder(); Border margin = new EmptyBorder(0,5,0,5); jLabel2.setBorder(new CompoundBorder(border, margin)); jTextField_Name.setText(name); jTextField_Date.setText(date); visit_id = visitID; btngrp = new ButtonGroup[]{buttonGroup1,buttonGroup2,buttonGroup3, buttonGroup4,buttonGroup5, buttonGroup6,buttonGroup7,buttonGroup8,buttonGroup9,buttonGroup10,buttonGroup11,buttonGroup12,buttonGroup13, buttonGroup14,buttonGroup15,buttonGroup16,buttonGroup17,buttonGroup18,buttonGroup19,buttonGroup20,buttonGroup21, buttonGroup22,buttonGroup23,buttonGroup24,buttonGroup25 }; } public void addActions(){ Component[] components = jPanel1. getComponents(); for(Component component: components){ if(component instanceof JPanel){ Component[] sub_components = ((JPanel) component).getComponents(); for(Component subComponent: sub_components){ if(subComponent instanceof JRadioButton){ JRadioButton radioButton = (JRadioButton) subComponent; radioButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // AbstractButton aButton = (AbstractButton)e.getSource(); // sum += Integer.parseInt(radioButton.getActionCommand()); // jTextField_Sum_Score.setText(String.valueOf(sum)); if(e.getStateChange() == ItemEvent.SELECTED) { sum += Integer.parseInt(radioButton.getActionCommand()); }else{ sum -= Integer.parseInt(radioButton.getActionCommand()); } jTextField_Sum_Score.setText(String.valueOf(sum)); } }); } } } } } public String strBuild(String str1, String str2) { StringBuilder strBuilder = new StringBuilder(str1); strBuilder.append(str2); //convert stringBuffer to String, call it resultString, code return strBuilder.toString(); } // public String sum(){ // sum = Integer.parseInt(buttonGroup1.getSelection().getActionCommand()); // return String.valueOf(sum); // } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); buttonGroup2 = new javax.swing.ButtonGroup(); buttonGroup3 = new javax.swing.ButtonGroup(); buttonGroup4 = new javax.swing.ButtonGroup(); buttonGroup5 = new javax.swing.ButtonGroup(); buttonGroup6 = new javax.swing.ButtonGroup(); buttonGroup7 = new javax.swing.ButtonGroup(); buttonGroup8 = new javax.swing.ButtonGroup(); buttonGroup9 = new javax.swing.ButtonGroup(); buttonGroup10 = new javax.swing.ButtonGroup(); buttonGroup11 = new javax.swing.ButtonGroup(); buttonGroup12 = new javax.swing.ButtonGroup(); buttonGroup13 = new javax.swing.ButtonGroup(); buttonGroup14 = new javax.swing.ButtonGroup(); buttonGroup15 = new javax.swing.ButtonGroup(); buttonGroup16 = new javax.swing.ButtonGroup(); buttonGroup17 = new javax.swing.ButtonGroup(); buttonGroup18 = new javax.swing.ButtonGroup(); buttonGroup19 = new javax.swing.ButtonGroup(); buttonGroup20 = new javax.swing.ButtonGroup(); buttonGroup21 = new javax.swing.ButtonGroup(); buttonGroup22 = new javax.swing.ButtonGroup(); buttonGroup23 = new javax.swing.ButtonGroup(); buttonGroup24 = new javax.swing.ButtonGroup(); buttonGroup25 = new javax.swing.ButtonGroup(); jScrollPane2 = new javax.swing.JScrollPane(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jTextField_Name = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jTextField_Date = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jPanel_F1 = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jRadioButton_F1N = new javax.swing.JRadioButton(); jRadioButton_F1S = new javax.swing.JRadioButton(); jRadioButton_F1Y = new javax.swing.JRadioButton(); jPanel_F2 = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); jRadioButton_F2N = new javax.swing.JRadioButton(); jRadioButton_F2S = new javax.swing.JRadioButton(); jRadioButton_F2Y = new javax.swing.JRadioButton(); jPanel_E3 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); jRadioButton_E3N = new javax.swing.JRadioButton(); jRadioButton_E3S = new javax.swing.JRadioButton(); jRadioButton_E3Y = new javax.swing.JRadioButton(); jPanel_F4 = new javax.swing.JPanel(); jLabel11 = new javax.swing.JLabel(); jRadioButton_F4N = new javax.swing.JRadioButton(); jRadioButton_F4S = new javax.swing.JRadioButton(); jRadioButton_F4Y = new javax.swing.JRadioButton(); jPanel_C5 = new javax.swing.JPanel(); jLabel12 = new javax.swing.JLabel(); jRadioButton_C5N = new javax.swing.JRadioButton(); jRadioButton_C5S = new javax.swing.JRadioButton(); jRadioButton_C5Y = new javax.swing.JRadioButton(); jPanel_E6 = new javax.swing.JPanel(); jLabel13 = new javax.swing.JLabel(); jRadioButton_E6N = new javax.swing.JRadioButton(); jRadioButton_E6S = new javax.swing.JRadioButton(); jRadioButton_E6Y = new javax.swing.JRadioButton(); jPanel_F7 = new javax.swing.JPanel(); jLabel14 = new javax.swing.JLabel(); jRadioButton_F7N = new javax.swing.JRadioButton(); jRadioButton_F7S = new javax.swing.JRadioButton(); jRadioButton_F7Y = new javax.swing.JRadioButton(); jPanel_C8 = new javax.swing.JPanel(); jLabel15 = new javax.swing.JLabel(); jRadioButton_C8N = new javax.swing.JRadioButton(); jRadioButton_C8S = new javax.swing.JRadioButton(); jRadioButton_C8Y = new javax.swing.JRadioButton(); jPanel_F9 = new javax.swing.JPanel(); jLabel16 = new javax.swing.JLabel(); jRadioButton_F9N = new javax.swing.JRadioButton(); jRadioButton_F9S = new javax.swing.JRadioButton(); jRadioButton_F9Y = new javax.swing.JRadioButton(); jPanel_E10 = new javax.swing.JPanel(); jLabel17 = new javax.swing.JLabel(); jRadioButton_E10N = new javax.swing.JRadioButton(); jRadioButton_E10S = new javax.swing.JRadioButton(); jRadioButton_E10Y = new javax.swing.JRadioButton(); jPanel_C11 = new javax.swing.JPanel(); jLabel18 = new javax.swing.JLabel(); jRadioButton_C11N = new javax.swing.JRadioButton(); jRadioButton_C11S = new javax.swing.JRadioButton(); jRadioButton_C11Y = new javax.swing.JRadioButton(); jPanel_F12 = new javax.swing.JPanel(); jLabel19 = new javax.swing.JLabel(); jRadioButton_F12N = new javax.swing.JRadioButton(); jRadioButton_F12S = new javax.swing.JRadioButton(); jRadioButton_F12Y = new javax.swing.JRadioButton(); jPanel_F13 = new javax.swing.JPanel(); jLabel20 = new javax.swing.JLabel(); jRadioButton_F13N = new javax.swing.JRadioButton(); jRadioButton_F13S = new javax.swing.JRadioButton(); jRadioButton_F13Y = new javax.swing.JRadioButton(); jPanel_E14 = new javax.swing.JPanel(); jLabel21 = new javax.swing.JLabel(); jRadioButton_E14N = new javax.swing.JRadioButton(); jRadioButton_E14S = new javax.swing.JRadioButton(); jRadioButton_E14Y = new javax.swing.JRadioButton(); jPanel_F15 = new javax.swing.JPanel(); jLabel22 = new javax.swing.JLabel(); jRadioButton49 = new javax.swing.JRadioButton(); jRadioButton50 = new javax.swing.JRadioButton(); jRadioButton51 = new javax.swing.JRadioButton(); jPanel_E16 = new javax.swing.JPanel(); jLabel23 = new javax.swing.JLabel(); jRadioButton52 = new javax.swing.JRadioButton(); jRadioButton53 = new javax.swing.JRadioButton(); jRadioButton54 = new javax.swing.JRadioButton(); jPanel_E17 = new javax.swing.JPanel(); jLabel24 = new javax.swing.JLabel(); jRadioButton55 = new javax.swing.JRadioButton(); jRadioButton56 = new javax.swing.JRadioButton(); jRadioButton57 = new javax.swing.JRadioButton(); jPanel_F18 = new javax.swing.JPanel(); jLabel25 = new javax.swing.JLabel(); jRadioButton58 = new javax.swing.JRadioButton(); jRadioButton59 = new javax.swing.JRadioButton(); jRadioButton60 = new javax.swing.JRadioButton(); jPanel_C19 = new javax.swing.JPanel(); jLabel26 = new javax.swing.JLabel(); jRadioButton61 = new javax.swing.JRadioButton(); jRadioButton62 = new javax.swing.JRadioButton(); jRadioButton63 = new javax.swing.JRadioButton(); jPanel_F20 = new javax.swing.JPanel(); jLabel27 = new javax.swing.JLabel(); jRadioButton64 = new javax.swing.JRadioButton(); jRadioButton65 = new javax.swing.JRadioButton(); jRadioButton66 = new javax.swing.JRadioButton(); jPanel_E21 = new javax.swing.JPanel(); jLabel28 = new javax.swing.JLabel(); jRadioButton67 = new javax.swing.JRadioButton(); jRadioButton68 = new javax.swing.JRadioButton(); jRadioButton69 = new javax.swing.JRadioButton(); jPanel_E22 = new javax.swing.JPanel(); jLabel29 = new javax.swing.JLabel(); jRadioButton70 = new javax.swing.JRadioButton(); jRadioButton71 = new javax.swing.JRadioButton(); jRadioButton72 = new javax.swing.JRadioButton(); jPanel_C23 = new javax.swing.JPanel(); jLabel30 = new javax.swing.JLabel(); jRadioButton73 = new javax.swing.JRadioButton(); jRadioButton74 = new javax.swing.JRadioButton(); jRadioButton75 = new javax.swing.JRadioButton(); jPanel_F24 = new javax.swing.JPanel(); jLabel31 = new javax.swing.JLabel(); jRadioButton76 = new javax.swing.JRadioButton(); jRadioButton77 = new javax.swing.JRadioButton(); jRadioButton78 = new javax.swing.JRadioButton(); jPanel_E25 = new javax.swing.JPanel(); jLabel32 = new javax.swing.JLabel(); jRadioButton79 = new javax.swing.JRadioButton(); jRadioButton80 = new javax.swing.JRadioButton(); jRadioButton81 = new javax.swing.JRadioButton(); jLabel7 = new javax.swing.JLabel(); jTextField_Sum_Score = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jButton_Submit = new javax.swing.JButton(); jButton_Save = new javax.swing.JButton(); jButton_Cancel = new javax.swing.JButton(); jButton_Help = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jPanel1.setBackground(new java.awt.Color(255, 255, 255)); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N jLabel1.setText("Tinnitus Handicap Inventory (THI)"); jLabel2.setFont(new java.awt.Font("Tahoma", 2, 10)); // NOI18N jLabel2.setText("<html>This form is for informational purposes only and" + "should not take the <br/> place of consultation and evalution by a healthcare professional </html>"); jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jLabel3.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N jLabel3.setText("Your name:"); jTextField_Name.setBackground(new java.awt.Color(229, 229, 255)); jTextField_Name.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 13)); // NOI18N jLabel4.setText("Date:"); jTextField_Date.setBackground(new java.awt.Color(229, 229, 255)); jTextField_Date.setHorizontalAlignment(javax.swing.JTextField.CENTER); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel5.setText("<html><strong>Instruction:</strong> The purpose of this questionnaire is to identify, quantify, and place evaluate the difficulties that you may be experiencing <br/>" + "because of tinnitus. Please do not skip any question. When you have answer all those questions, add up your total score, based on <br/>" + "the value for each response.</html>"); jLabel6.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel6.setText("1. Because of your tinnitus, is it difficult to concentrate?"); buttonGroup1.add(jRadioButton_F1N); jRadioButton_F1N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F1N.setText("No (0)"); jRadioButton_F1N.setActionCommand("0"); buttonGroup1.add(jRadioButton_F1S); jRadioButton_F1S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F1S.setText("Sometimes (2)"); jRadioButton_F1S.setActionCommand("2"); jRadioButton_F1S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F1SActionPerformed(evt); } }); buttonGroup1.add(jRadioButton_F1Y); jRadioButton_F1Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F1Y.setText("Yes (4)"); jRadioButton_F1Y.setActionCommand("4"); jRadioButton_F1Y.setAutoscrolls(true); jRadioButton_F1Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F1YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F1Layout = new javax.swing.GroupLayout(jPanel_F1); jPanel_F1.setLayout(jPanel_F1Layout); jPanel_F1Layout.setHorizontalGroup( jPanel_F1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F1Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F1Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F1S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F1N) .addGap(14, 14, 14)) ); jPanel_F1Layout.setVerticalGroup( jPanel_F1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(jRadioButton_F1N) .addComponent(jRadioButton_F1S) .addComponent(jRadioButton_F1Y)) .addContainerGap()) ); jRadioButton_F1N.getAccessibleContext().setAccessibleName(""); jRadioButton_F1S.getAccessibleContext().setAccessibleName(""); jRadioButton_F1Y.getAccessibleContext().setAccessibleName(""); jPanel_F2.setBackground(new java.awt.Color(255, 255, 255)); jLabel9.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel9.setText("2. Does the loudness of your tinnitus make it difficult for you to hear people?"); buttonGroup2.add(jRadioButton_F2N); jRadioButton_F2N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F2N.setText("No (0)"); jRadioButton_F2N.setActionCommand("0"); buttonGroup2.add(jRadioButton_F2S); jRadioButton_F2S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F2S.setText("Sometimes (2)"); jRadioButton_F2S.setActionCommand("2"); jRadioButton_F2S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F2SActionPerformed(evt); } }); buttonGroup2.add(jRadioButton_F2Y); jRadioButton_F2Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F2Y.setText("Yes (4)"); jRadioButton_F2Y.setActionCommand("4"); jRadioButton_F2Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F2YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F2Layout = new javax.swing.GroupLayout(jPanel_F2); jPanel_F2.setLayout(jPanel_F2Layout); jPanel_F2Layout.setHorizontalGroup( jPanel_F2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F2Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F2Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F2S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F2N) .addGap(14, 14, 14)) ); jPanel_F2Layout.setVerticalGroup( jPanel_F2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F2Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(jRadioButton_F2N) .addComponent(jRadioButton_F2S) .addComponent(jRadioButton_F2Y)) .addContainerGap()) ); jLabel10.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel10.setText("3. Does your tinnitus make you angry?"); buttonGroup3.add(jRadioButton_E3N); jRadioButton_E3N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E3N.setText("No (0)"); jRadioButton_E3N.setActionCommand("0"); buttonGroup3.add(jRadioButton_E3S); jRadioButton_E3S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E3S.setText("Sometimes (2)"); jRadioButton_E3S.setActionCommand("2"); jRadioButton_E3S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E3SActionPerformed(evt); } }); buttonGroup3.add(jRadioButton_E3Y); jRadioButton_E3Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E3Y.setText("Yes (4)"); jRadioButton_E3Y.setActionCommand("4"); jRadioButton_E3Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E3YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E3Layout = new javax.swing.GroupLayout(jPanel_E3); jPanel_E3.setLayout(jPanel_E3Layout); jPanel_E3Layout.setHorizontalGroup( jPanel_E3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E3Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel10) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_E3Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E3S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E3N) .addGap(14, 14, 14)) ); jPanel_E3Layout.setVerticalGroup( jPanel_E3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E3Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10) .addComponent(jRadioButton_E3N) .addComponent(jRadioButton_E3S) .addComponent(jRadioButton_E3Y)) .addContainerGap()) ); jPanel_F4.setBackground(new java.awt.Color(255, 255, 255)); jPanel_F4.setToolTipText(""); jLabel11.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel11.setText("4. Does your tinnitus make you feel confused?"); buttonGroup4.add(jRadioButton_F4N); jRadioButton_F4N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F4N.setText("No (0)"); jRadioButton_F4N.setActionCommand("0"); buttonGroup4.add(jRadioButton_F4S); jRadioButton_F4S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F4S.setText("Sometimes (2)"); jRadioButton_F4S.setActionCommand("2"); jRadioButton_F4S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F4SActionPerformed(evt); } }); buttonGroup4.add(jRadioButton_F4Y); jRadioButton_F4Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F4Y.setText("Yes (4)"); jRadioButton_F4Y.setActionCommand("4"); jRadioButton_F4Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F4YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F4Layout = new javax.swing.GroupLayout(jPanel_F4); jPanel_F4.setLayout(jPanel_F4Layout); jPanel_F4Layout.setHorizontalGroup( jPanel_F4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F4Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F4Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F4S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F4N) .addGap(14, 14, 14)) ); jPanel_F4Layout.setVerticalGroup( jPanel_F4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F4Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(jRadioButton_F4N) .addComponent(jRadioButton_F4S) .addComponent(jRadioButton_F4Y)) .addContainerGap()) ); jLabel12.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel12.setText("5. Because of your tinnitus, do you feel desperate?"); buttonGroup5.add(jRadioButton_C5N); jRadioButton_C5N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C5N.setText("No (0)"); jRadioButton_C5N.setActionCommand("0"); buttonGroup5.add(jRadioButton_C5S); jRadioButton_C5S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C5S.setText("Sometimes (2)"); jRadioButton_C5S.setActionCommand("2"); jRadioButton_C5S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C5SActionPerformed(evt); } }); buttonGroup5.add(jRadioButton_C5Y); jRadioButton_C5Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C5Y.setText("Yes (4)"); jRadioButton_C5Y.setActionCommand("4"); jRadioButton_C5Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C5YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_C5Layout = new javax.swing.GroupLayout(jPanel_C5); jPanel_C5.setLayout(jPanel_C5Layout); jPanel_C5Layout.setHorizontalGroup( jPanel_C5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_C5Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel12) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_C5Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C5S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C5N) .addGap(14, 14, 14)) ); jPanel_C5Layout.setVerticalGroup( jPanel_C5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_C5Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_C5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12) .addComponent(jRadioButton_C5N) .addComponent(jRadioButton_C5S) .addComponent(jRadioButton_C5Y)) .addContainerGap()) ); jPanel_E6.setBackground(new java.awt.Color(255, 255, 255)); jPanel_E6.setToolTipText(""); jLabel13.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel13.setText("6. Do you complain a great deal about yout tinnitus?"); buttonGroup6.add(jRadioButton_E6N); jRadioButton_E6N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E6N.setText("No (0)"); jRadioButton_E6N.setActionCommand("0"); buttonGroup6.add(jRadioButton_E6S); jRadioButton_E6S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E6S.setText("Sometimes (2)"); jRadioButton_E6S.setActionCommand("2"); jRadioButton_E6S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E6SActionPerformed(evt); } }); buttonGroup6.add(jRadioButton_E6Y); jRadioButton_E6Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E6Y.setText("Yes (4)"); jRadioButton_E6Y.setActionCommand("4"); jRadioButton_E6Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E6YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E6Layout = new javax.swing.GroupLayout(jPanel_E6); jPanel_E6.setLayout(jPanel_E6Layout); jPanel_E6Layout.setHorizontalGroup( jPanel_E6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E6Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_E6Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E6S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E6N) .addGap(14, 14, 14)) ); jPanel_E6Layout.setVerticalGroup( jPanel_E6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E6Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel13) .addComponent(jRadioButton_E6N) .addComponent(jRadioButton_E6S) .addComponent(jRadioButton_E6Y)) .addContainerGap()) ); jLabel14.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel14.setText("7. Because of your tinnitus, do you have trouble falling to sleep at night? "); buttonGroup7.add(jRadioButton_F7N); jRadioButton_F7N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F7N.setText("No (0)"); jRadioButton_F7N.setActionCommand("0"); buttonGroup7.add(jRadioButton_F7S); jRadioButton_F7S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F7S.setText("Sometimes (2)"); jRadioButton_F7S.setActionCommand("2"); jRadioButton_F7S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F7SActionPerformed(evt); } }); buttonGroup7.add(jRadioButton_F7Y); jRadioButton_F7Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F7Y.setText("Yes (4)"); jRadioButton_F7Y.setActionCommand("4"); jRadioButton_F7Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F7YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F7Layout = new javax.swing.GroupLayout(jPanel_F7); jPanel_F7.setLayout(jPanel_F7Layout); jPanel_F7Layout.setHorizontalGroup( jPanel_F7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F7Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel14) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F7Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F7S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F7N) .addGap(14, 14, 14)) ); jPanel_F7Layout.setVerticalGroup( jPanel_F7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F7Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel14) .addComponent(jRadioButton_F7N) .addComponent(jRadioButton_F7S) .addComponent(jRadioButton_F7Y)) .addContainerGap()) ); jPanel_C8.setBackground(new java.awt.Color(255, 255, 255)); jPanel_C8.setToolTipText(""); jLabel15.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel15.setText("8. Do you feel as though you cannot escape your tinnitus?"); buttonGroup8.add(jRadioButton_C8N); jRadioButton_C8N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C8N.setText("No (0)"); jRadioButton_C8N.setActionCommand("0"); buttonGroup8.add(jRadioButton_C8S); jRadioButton_C8S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C8S.setText("Sometimes (2)"); jRadioButton_C8S.setActionCommand("2"); jRadioButton_C8S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C8SActionPerformed(evt); } }); buttonGroup8.add(jRadioButton_C8Y); jRadioButton_C8Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C8Y.setText("Yes (4)"); jRadioButton_C8Y.setActionCommand("4"); jRadioButton_C8Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C8YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_C8Layout = new javax.swing.GroupLayout(jPanel_C8); jPanel_C8.setLayout(jPanel_C8Layout); jPanel_C8Layout.setHorizontalGroup( jPanel_C8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_C8Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_C8Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C8S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C8N) .addGap(14, 14, 14)) ); jPanel_C8Layout.setVerticalGroup( jPanel_C8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_C8Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_C8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel15) .addComponent(jRadioButton_C8N) .addComponent(jRadioButton_C8S) .addComponent(jRadioButton_C8Y)) .addContainerGap()) ); jLabel16.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel16.setText("<html>9. Does your tinnitus interfere with your ability to enjoy your social activities" + "<br/>&nbsp;&nbsp;&nbsp;(such as going out to dinner, to the movies)? </html>"); buttonGroup9.add(jRadioButton_F9N); jRadioButton_F9N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F9N.setText("No (0)"); jRadioButton_F9N.setActionCommand("0"); buttonGroup9.add(jRadioButton_F9S); jRadioButton_F9S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F9S.setText("Sometimes (2)"); jRadioButton_F9S.setActionCommand("2"); jRadioButton_F9S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F9SActionPerformed(evt); } }); buttonGroup9.add(jRadioButton_F9Y); jRadioButton_F9Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F9Y.setText("Yes (4)"); jRadioButton_F9Y.setActionCommand("4"); jRadioButton_F9Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F9YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F9Layout = new javax.swing.GroupLayout(jPanel_F9); jPanel_F9.setLayout(jPanel_F9Layout); jPanel_F9Layout.setHorizontalGroup( jPanel_F9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F9Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F9Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F9S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F9N) .addGap(14, 14, 14)) ); jPanel_F9Layout.setVerticalGroup( jPanel_F9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F9Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel16) .addComponent(jRadioButton_F9N) .addComponent(jRadioButton_F9S) .addComponent(jRadioButton_F9Y)) .addContainerGap()) ); jPanel_E10.setBackground(new java.awt.Color(255, 255, 255)); jPanel_E10.setToolTipText(""); jLabel17.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel17.setText("10. Because of your tinnitus, do you feel frustrated?"); buttonGroup10.add(jRadioButton_E10N); jRadioButton_E10N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E10N.setText("No (0)"); jRadioButton_E10N.setActionCommand("0"); buttonGroup10.add(jRadioButton_E10S); jRadioButton_E10S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E10S.setText("Sometimes (2)"); jRadioButton_E10S.setActionCommand("2"); jRadioButton_E10S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E10SActionPerformed(evt); } }); buttonGroup10.add(jRadioButton_E10Y); jRadioButton_E10Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E10Y.setText("Yes (4)"); jRadioButton_E10Y.setActionCommand("4"); jRadioButton_E10Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E10YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E10Layout = new javax.swing.GroupLayout(jPanel_E10); jPanel_E10.setLayout(jPanel_E10Layout); jPanel_E10Layout.setHorizontalGroup( jPanel_E10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E10Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel17) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_E10Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E10S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E10N) .addGap(14, 14, 14)) ); jPanel_E10Layout.setVerticalGroup( jPanel_E10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E10Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel17) .addComponent(jRadioButton_E10N) .addComponent(jRadioButton_E10S) .addComponent(jRadioButton_E10Y)) .addContainerGap()) ); jLabel18.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel18.setText("11. Because of your tinnitus, do you feel that you have a terrible disease?"); buttonGroup11.add(jRadioButton_C11N); jRadioButton_C11N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C11N.setText("No (0)"); jRadioButton_C11N.setActionCommand("0"); buttonGroup11.add(jRadioButton_C11S); jRadioButton_C11S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C11S.setText("Sometimes (2)"); jRadioButton_C11S.setActionCommand("2"); jRadioButton_C11S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C11SActionPerformed(evt); } }); buttonGroup11.add(jRadioButton_C11Y); jRadioButton_C11Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_C11Y.setText("Yes (4)"); jRadioButton_C11Y.setActionCommand("4"); jRadioButton_C11Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_C11YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_C11Layout = new javax.swing.GroupLayout(jPanel_C11); jPanel_C11.setLayout(jPanel_C11Layout); jPanel_C11Layout.setHorizontalGroup( jPanel_C11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_C11Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel18) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_C11Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C11S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_C11N) .addGap(14, 14, 14)) ); jPanel_C11Layout.setVerticalGroup( jPanel_C11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_C11Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_C11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel18) .addComponent(jRadioButton_C11N) .addComponent(jRadioButton_C11S) .addComponent(jRadioButton_C11Y)) .addContainerGap()) ); jPanel_F12.setBackground(new java.awt.Color(255, 255, 255)); jPanel_F12.setToolTipText(""); jLabel19.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel19.setText("12. Does your tinnitus make it difficult for you to enjoy life?"); buttonGroup12.add(jRadioButton_F12N); jRadioButton_F12N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F12N.setText("No (0)"); jRadioButton_F12N.setActionCommand("0"); buttonGroup12.add(jRadioButton_F12S); jRadioButton_F12S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F12S.setText("Sometimes (2)"); jRadioButton_F12S.setActionCommand("2"); jRadioButton_F12S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F12SActionPerformed(evt); } }); buttonGroup12.add(jRadioButton_F12Y); jRadioButton_F12Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F12Y.setText("Yes (4)"); jRadioButton_F12Y.setActionCommand("4"); jRadioButton_F12Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F12YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F12Layout = new javax.swing.GroupLayout(jPanel_F12); jPanel_F12.setLayout(jPanel_F12Layout); jPanel_F12Layout.setHorizontalGroup( jPanel_F12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F12Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel19) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F12Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F12S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F12N) .addGap(14, 14, 14)) ); jPanel_F12Layout.setVerticalGroup( jPanel_F12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F12Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel19) .addComponent(jRadioButton_F12N) .addComponent(jRadioButton_F12S) .addComponent(jRadioButton_F12Y)) .addContainerGap()) ); jLabel20.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel20.setText("13. Does your tinnitus interfere with your job or your household responsibilites?"); buttonGroup13.add(jRadioButton_F13N); jRadioButton_F13N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F13N.setText("No (0)"); jRadioButton_F13N.setActionCommand("0"); buttonGroup13.add(jRadioButton_F13S); jRadioButton_F13S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F13S.setText("Sometimes (2)"); jRadioButton_F13S.setActionCommand("2"); jRadioButton_F13S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F13SActionPerformed(evt); } }); buttonGroup13.add(jRadioButton_F13Y); jRadioButton_F13Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_F13Y.setText("Yes (4)"); jRadioButton_F13Y.setActionCommand("4"); jRadioButton_F13Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_F13YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F13Layout = new javax.swing.GroupLayout(jPanel_F13); jPanel_F13.setLayout(jPanel_F13Layout); jPanel_F13Layout.setHorizontalGroup( jPanel_F13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F13Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel20) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_F13Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F13S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_F13N) .addGap(14, 14, 14)) ); jPanel_F13Layout.setVerticalGroup( jPanel_F13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F13Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20) .addComponent(jRadioButton_F13N) .addComponent(jRadioButton_F13S) .addComponent(jRadioButton_F13Y)) .addContainerGap()) ); jPanel_E14.setBackground(new java.awt.Color(255, 255, 255)); jPanel_E14.setToolTipText(""); jLabel21.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel21.setText("14. Beause of your tinnitus, do you find that you are often irritable?"); buttonGroup14.add(jRadioButton_E14N); jRadioButton_E14N.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E14N.setText("No (0)"); jRadioButton_E14N.setActionCommand("0"); buttonGroup14.add(jRadioButton_E14S); jRadioButton_E14S.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E14S.setText("Sometimes (2)"); jRadioButton_E14S.setActionCommand("2"); jRadioButton_E14S.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E14SActionPerformed(evt); } }); buttonGroup14.add(jRadioButton_E14Y); jRadioButton_E14Y.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton_E14Y.setText("Yes (4)"); jRadioButton_E14Y.setActionCommand("4"); jRadioButton_E14Y.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton_E14YActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E14Layout = new javax.swing.GroupLayout(jPanel_E14); jPanel_E14.setLayout(jPanel_E14Layout); jPanel_E14Layout.setHorizontalGroup( jPanel_E14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E14Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel21) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton_E14Y) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E14S) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton_E14N) .addGap(14, 14, 14)) ); jPanel_E14Layout.setVerticalGroup( jPanel_E14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E14Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel21) .addComponent(jRadioButton_E14N) .addComponent(jRadioButton_E14S) .addComponent(jRadioButton_E14Y)) .addContainerGap()) ); jLabel22.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel22.setText("15. Because of your tinnitus, is it difficult for you to read?"); buttonGroup15.add(jRadioButton49); jRadioButton49.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton49.setText("No (0)"); jRadioButton49.setActionCommand("0"); buttonGroup15.add(jRadioButton50); jRadioButton50.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton50.setText("Sometimes (2)"); jRadioButton50.setActionCommand("2"); jRadioButton50.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton50ActionPerformed(evt); } }); buttonGroup15.add(jRadioButton51); jRadioButton51.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton51.setText("Yes (4)"); jRadioButton51.setActionCommand("4"); jRadioButton51.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton51ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F15Layout = new javax.swing.GroupLayout(jPanel_F15); jPanel_F15.setLayout(jPanel_F15Layout); jPanel_F15Layout.setHorizontalGroup( jPanel_F15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F15Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel22) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton51) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton50) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton49) .addGap(14, 14, 14)) ); jPanel_F15Layout.setVerticalGroup( jPanel_F15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F15Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel22) .addComponent(jRadioButton49) .addComponent(jRadioButton50) .addComponent(jRadioButton51)) .addContainerGap()) ); jPanel_E16.setBackground(new java.awt.Color(255, 255, 255)); jPanel_E16.setToolTipText(""); jLabel23.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel23.setText("16. Does your tinnitus make you upset?"); buttonGroup16.add(jRadioButton52); jRadioButton52.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton52.setText("No (0)"); jRadioButton52.setActionCommand("0"); buttonGroup16.add(jRadioButton53); jRadioButton53.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton53.setText("Sometimes (2)"); jRadioButton53.setActionCommand("2"); jRadioButton53.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton53ActionPerformed(evt); } }); buttonGroup16.add(jRadioButton54); jRadioButton54.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton54.setText("Yes (4)"); jRadioButton54.setActionCommand("4"); jRadioButton54.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton54ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E16Layout = new javax.swing.GroupLayout(jPanel_E16); jPanel_E16.setLayout(jPanel_E16Layout); jPanel_E16Layout.setHorizontalGroup( jPanel_E16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E16Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel23) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton54) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton53) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton52) .addGap(14, 14, 14)) ); jPanel_E16Layout.setVerticalGroup( jPanel_E16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E16Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel23) .addComponent(jRadioButton52) .addComponent(jRadioButton53) .addComponent(jRadioButton54)) .addContainerGap()) ); jLabel24.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel24.setText("<html> 17. Do you feel that your tinnitus problem has placed stress on your relationships" + "<br/>&nbsp;&nbsp;&nbsp; with members of your family and friends? <html/>"); buttonGroup17.add(jRadioButton55); jRadioButton55.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton55.setText("No (0)"); jRadioButton55.setActionCommand("0"); buttonGroup17.add(jRadioButton56); jRadioButton56.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton56.setText("Sometimes (2)"); jRadioButton56.setActionCommand("2"); jRadioButton56.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton56ActionPerformed(evt); } }); buttonGroup17.add(jRadioButton57); jRadioButton57.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton57.setText("Yes (4)"); jRadioButton57.setActionCommand("4"); jRadioButton57.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton57ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E17Layout = new javax.swing.GroupLayout(jPanel_E17); jPanel_E17.setLayout(jPanel_E17Layout); jPanel_E17Layout.setHorizontalGroup( jPanel_E17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E17Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel24) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton57) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton56) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton55) .addGap(14, 14, 14)) ); jPanel_E17Layout.setVerticalGroup( jPanel_E17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E17Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel24) .addComponent(jRadioButton55) .addComponent(jRadioButton56) .addComponent(jRadioButton57)) .addContainerGap()) ); jPanel_F18.setBackground(new java.awt.Color(255, 255, 255)); jPanel_F18.setToolTipText(""); jLabel25.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel25.setText("<html>18. Do you find it difficult to focus your attention away from your tinnitus and on" + "<br/>&nbsp;&nbsp;&nbsp; other things?<html/>"); buttonGroup18.add(jRadioButton58); jRadioButton58.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton58.setText("No (0)"); jRadioButton58.setActionCommand("0"); buttonGroup18.add(jRadioButton59); jRadioButton59.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton59.setText("Sometimes (2)"); jRadioButton59.setActionCommand("2"); jRadioButton59.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton59ActionPerformed(evt); } }); buttonGroup18.add(jRadioButton60); jRadioButton60.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton60.setText("Yes (4)"); jRadioButton60.setActionCommand("4"); jRadioButton60.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton60ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F18Layout = new javax.swing.GroupLayout(jPanel_F18); jPanel_F18.setLayout(jPanel_F18Layout); jPanel_F18Layout.setHorizontalGroup( jPanel_F18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F18Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel25) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton60) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton59) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton58) .addGap(14, 14, 14)) ); jPanel_F18Layout.setVerticalGroup( jPanel_F18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F18Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel25) .addComponent(jRadioButton58) .addComponent(jRadioButton59) .addComponent(jRadioButton60)) .addContainerGap()) ); jLabel26.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel26.setText("19. Do you feel that you have no control over your tinnitus?"); buttonGroup19.add(jRadioButton61); jRadioButton61.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton61.setText("No (0)"); jRadioButton61.setActionCommand("0"); buttonGroup19.add(jRadioButton62); jRadioButton62.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton62.setText("Sometimes (2)"); jRadioButton62.setActionCommand("2"); jRadioButton62.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton62ActionPerformed(evt); } }); buttonGroup19.add(jRadioButton63); jRadioButton63.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton63.setText("Yes (4)"); jRadioButton63.setActionCommand("4"); jRadioButton63.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton63ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_C19Layout = new javax.swing.GroupLayout(jPanel_C19); jPanel_C19.setLayout(jPanel_C19Layout); jPanel_C19Layout.setHorizontalGroup( jPanel_C19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_C19Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel26) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton63) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton62) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton61) .addGap(14, 14, 14)) ); jPanel_C19Layout.setVerticalGroup( jPanel_C19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_C19Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_C19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel26) .addComponent(jRadioButton61) .addComponent(jRadioButton62) .addComponent(jRadioButton63)) .addContainerGap()) ); jPanel_F20.setBackground(new java.awt.Color(255, 255, 255)); jPanel_F20.setToolTipText(""); jLabel27.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel27.setText("20. Because of your tinnitus, do you feel tired?"); buttonGroup20.add(jRadioButton64); jRadioButton64.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton64.setText("No (0)"); jRadioButton64.setActionCommand("0"); buttonGroup20.add(jRadioButton65); jRadioButton65.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton65.setText("Sometimes (2)"); jRadioButton65.setActionCommand("2"); jRadioButton65.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton65ActionPerformed(evt); } }); buttonGroup20.add(jRadioButton66); jRadioButton66.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton66.setText("Yes (4)"); jRadioButton66.setActionCommand("4"); jRadioButton66.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton66ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F20Layout = new javax.swing.GroupLayout(jPanel_F20); jPanel_F20.setLayout(jPanel_F20Layout); jPanel_F20Layout.setHorizontalGroup( jPanel_F20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F20Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel27) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton66) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton65) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton64) .addGap(14, 14, 14)) ); jPanel_F20Layout.setVerticalGroup( jPanel_F20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F20Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel27) .addComponent(jRadioButton64) .addComponent(jRadioButton65) .addComponent(jRadioButton66)) .addContainerGap()) ); jLabel28.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel28.setText("21. Because of your tinnitus, do you feel depressed?"); buttonGroup21.add(jRadioButton67); jRadioButton67.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton67.setText("No (0)"); jRadioButton67.setActionCommand("0"); buttonGroup21.add(jRadioButton68); jRadioButton68.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton68.setText("Sometimes (2)"); jRadioButton68.setActionCommand("2"); jRadioButton68.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton68ActionPerformed(evt); } }); buttonGroup21.add(jRadioButton69); jRadioButton69.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton69.setText("Yes (4)"); jRadioButton69.setActionCommand("4"); jRadioButton69.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton69ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E21Layout = new javax.swing.GroupLayout(jPanel_E21); jPanel_E21.setLayout(jPanel_E21Layout); jPanel_E21Layout.setHorizontalGroup( jPanel_E21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E21Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel28) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton69) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton68) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton67) .addGap(14, 14, 14)) ); jPanel_E21Layout.setVerticalGroup( jPanel_E21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E21Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel28) .addComponent(jRadioButton67) .addComponent(jRadioButton68) .addComponent(jRadioButton69)) .addContainerGap()) ); jPanel_E22.setBackground(new java.awt.Color(255, 255, 255)); jPanel_E22.setToolTipText(""); jLabel29.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel29.setText("22. Does your tinnitus make you feel anxious?"); buttonGroup22.add(jRadioButton70); jRadioButton70.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton70.setText("No (0)"); jRadioButton70.setActionCommand("0"); buttonGroup22.add(jRadioButton71); jRadioButton71.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton71.setText("Sometimes (2)"); jRadioButton71.setActionCommand("2"); jRadioButton71.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton71ActionPerformed(evt); } }); buttonGroup22.add(jRadioButton72); jRadioButton72.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton72.setText("Yes (4)"); jRadioButton72.setActionCommand("4"); jRadioButton72.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton72ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E22Layout = new javax.swing.GroupLayout(jPanel_E22); jPanel_E22.setLayout(jPanel_E22Layout); jPanel_E22Layout.setHorizontalGroup( jPanel_E22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E22Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel29) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton72) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton71) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton70) .addGap(14, 14, 14)) ); jPanel_E22Layout.setVerticalGroup( jPanel_E22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E22Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel29) .addComponent(jRadioButton70) .addComponent(jRadioButton71) .addComponent(jRadioButton72)) .addContainerGap()) ); jLabel30.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel30.setText("23. Do you feel that you can no longer cope eith your tinnitus?"); buttonGroup23.add(jRadioButton73); jRadioButton73.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton73.setText("No (0)"); jRadioButton73.setActionCommand("0"); buttonGroup23.add(jRadioButton74); jRadioButton74.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton74.setText("Sometimes (2)"); jRadioButton74.setActionCommand("2"); jRadioButton74.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton74ActionPerformed(evt); } }); buttonGroup23.add(jRadioButton75); jRadioButton75.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton75.setText("Yes (4)"); jRadioButton75.setActionCommand("4"); jRadioButton75.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton75ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_C23Layout = new javax.swing.GroupLayout(jPanel_C23); jPanel_C23.setLayout(jPanel_C23Layout); jPanel_C23Layout.setHorizontalGroup( jPanel_C23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_C23Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel30) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton75) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton74) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton73) .addGap(14, 14, 14)) ); jPanel_C23Layout.setVerticalGroup( jPanel_C23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_C23Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_C23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel30) .addComponent(jRadioButton73) .addComponent(jRadioButton74) .addComponent(jRadioButton75)) .addContainerGap()) ); jPanel_F24.setBackground(new java.awt.Color(255, 255, 255)); jPanel_F24.setToolTipText(""); jLabel31.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel31.setText("24. Does your tinnitus get worse when you are under stress?"); buttonGroup24.add(jRadioButton76); jRadioButton76.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton76.setText("No (0)"); jRadioButton76.setActionCommand("0"); buttonGroup24.add(jRadioButton77); jRadioButton77.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton77.setText("Sometimes (2)"); jRadioButton77.setActionCommand("2"); jRadioButton77.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton77ActionPerformed(evt); } }); buttonGroup24.add(jRadioButton78); jRadioButton78.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton78.setText("Yes (4)"); jRadioButton78.setActionCommand("4"); jRadioButton78.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton78ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_F24Layout = new javax.swing.GroupLayout(jPanel_F24); jPanel_F24.setLayout(jPanel_F24Layout); jPanel_F24Layout.setHorizontalGroup( jPanel_F24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_F24Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel31) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton78) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton77) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton76) .addGap(14, 14, 14)) ); jPanel_F24Layout.setVerticalGroup( jPanel_F24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_F24Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_F24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel31) .addComponent(jRadioButton76) .addComponent(jRadioButton77) .addComponent(jRadioButton78)) .addContainerGap()) ); jLabel32.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jLabel32.setText("25. Does your tinnitus make you feel insecure?"); buttonGroup25.add(jRadioButton79); jRadioButton79.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton79.setText("No (0)"); jRadioButton79.setActionCommand("0"); buttonGroup25.add(jRadioButton80); jRadioButton80.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton80.setText("Sometimes (2)"); jRadioButton80.setActionCommand("2"); jRadioButton80.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton80ActionPerformed(evt); } }); buttonGroup25.add(jRadioButton81); jRadioButton81.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jRadioButton81.setText("Yes (4)"); jRadioButton81.setActionCommand("4"); jRadioButton81.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton81ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel_E25Layout = new javax.swing.GroupLayout(jPanel_E25); jPanel_E25.setLayout(jPanel_E25Layout); jPanel_E25Layout.setHorizontalGroup( jPanel_E25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel_E25Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel32) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButton81) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton80) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton79) .addGap(14, 14, 14)) ); jPanel_E25Layout.setVerticalGroup( jPanel_E25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_E25Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel_E25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel32) .addComponent(jRadioButton79) .addComponent(jRadioButton80) .addComponent(jRadioButton81)) .addContainerGap()) ); jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel7.setText("The sum of all responses is your THI Score >>>"); jTextField_Sum_Score.setEditable(false); jTextField_Sum_Score.setBackground(new java.awt.Color(229, 229, 255)); jTextField_Sum_Score.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jTextField_Sum_Score.setHorizontalAlignment(javax.swing.JTextField.CENTER); jTextField_Sum_Score.setText("0"); jTextField_Sum_Score.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2)); jTextField_Sum_Score.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField_Sum_ScoreActionPerformed(evt); } }); jLabel8.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N jLabel8.setText("<html>" + "0-16: Slight or no handicap (Grade 1) <br/>" + "18-36: Mild handicap (Grade 2) <br/>" + "38-56: Moderate handicap (Grade 3) <br/>" + "58-76: Severe handicap (Grade 4) <br/>" + "78-100: Catastrophic handicap (Grade 5)" + "</html>"); jButton_Submit.setBackground(new java.awt.Color(204, 204, 255)); jButton_Submit.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 14)); // NOI18N jButton_Submit.setText("<html><center>Submit</center></html>"); jButton_Submit.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButton_Submit.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jButton_SubmitMouseExited(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jButton_SubmitMouseEntered(evt); } }); jButton_Submit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_SubmitActionPerformed(evt); } }); jButton_Save.setBackground(new java.awt.Color(204, 204, 255)); jButton_Save.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 14)); // NOI18N jButton_Save.setText("<html><center>Save</center></html>"); jButton_Save.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButton_Save.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jButton_SaveMouseExited(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jButton_SaveMouseEntered(evt); } }); jButton_Save.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_SaveActionPerformed(evt); } }); jButton_Cancel.setBackground(new java.awt.Color(204, 204, 255)); jButton_Cancel.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 14)); // NOI18N jButton_Cancel.setText("<html><center>Cancel</center></html>"); jButton_Cancel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButton_Cancel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jButton_CancelMouseExited(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jButton_CancelMouseEntered(evt); } }); jButton_Cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_CancelActionPerformed(evt); } }); jButton_Help.setBackground(new java.awt.Color(204, 204, 255)); jButton_Help.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 14)); // NOI18N jButton_Help.setText("<html><center>Help</center></html>"); jButton_Help.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jButton_Help.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jButton_HelpMouseExited(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jButton_HelpMouseEntered(evt); } }); jButton_Help.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton_HelpActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(49, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(16, 16, 16) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField_Sum_Score, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton_Submit, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton_Save, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton_Cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton_Help, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel_E25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F24, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_C23, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E22, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E21, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F20, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_C19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField_Name, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTextField_Date)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(71, 71, 71) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanel_F2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_C5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_C8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_C11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_F15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel_E17, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGap(116, 116, 116)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(16, 16, 16) .addComponent(jLabel1))) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(32, 32, 32) .addComponent(jLabel3)) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField_Name, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(jTextField_Date, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(18, 18, 18) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F4, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_C5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E6, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F7, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_C8, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E10, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_C11, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F12, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F13, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E14, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F15, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E16, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_C19, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F20, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E21, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E22, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_C23, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_F24, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel_E25, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTextField_Sum_Score, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addGap(25, 25, 25) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton_Submit) .addComponent(jButton_Save) .addComponent(jButton_Cancel) .addComponent(jButton_Help))) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(43, Short.MAX_VALUE)) ); jScrollPane2.setViewportView(jPanel1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2) .addGap(5, 5, 5)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jRadioButton_F1SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F1SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F1SActionPerformed private void jRadioButton_F1YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F1YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F1YActionPerformed private void jRadioButton_F2SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F2SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F2SActionPerformed private void jRadioButton_F2YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F2YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F2YActionPerformed private void jRadioButton_E3SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E3SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E3SActionPerformed private void jRadioButton_E3YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E3YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E3YActionPerformed private void jRadioButton_F4SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F4SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F4SActionPerformed private void jRadioButton_F4YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F4YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F4YActionPerformed private void jRadioButton_C5SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C5SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C5SActionPerformed private void jRadioButton_C5YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C5YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C5YActionPerformed private void jRadioButton_E6SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E6SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E6SActionPerformed private void jRadioButton_E6YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E6YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E6YActionPerformed private void jRadioButton_F7SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F7SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F7SActionPerformed private void jRadioButton_F7YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F7YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F7YActionPerformed private void jRadioButton_C8SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C8SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C8SActionPerformed private void jRadioButton_C8YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C8YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C8YActionPerformed private void jRadioButton_F9SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F9SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F9SActionPerformed private void jRadioButton_F9YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F9YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F9YActionPerformed private void jRadioButton_E10SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E10SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E10SActionPerformed private void jRadioButton_E10YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E10YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E10YActionPerformed private void jRadioButton_C11SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C11SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C11SActionPerformed private void jRadioButton_C11YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_C11YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_C11YActionPerformed private void jRadioButton_F12SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F12SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F12SActionPerformed private void jRadioButton_F12YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F12YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F12YActionPerformed private void jRadioButton_F13SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F13SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F13SActionPerformed private void jRadioButton_F13YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_F13YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_F13YActionPerformed private void jRadioButton_E14SActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E14SActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E14SActionPerformed private void jRadioButton_E14YActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_E14YActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton_E14YActionPerformed private void jRadioButton50ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton50ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton50ActionPerformed private void jRadioButton51ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton51ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton51ActionPerformed private void jRadioButton53ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton53ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton53ActionPerformed private void jRadioButton54ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton54ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton54ActionPerformed private void jRadioButton56ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton56ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton56ActionPerformed private void jRadioButton57ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton57ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton57ActionPerformed private void jRadioButton59ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton59ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton59ActionPerformed private void jRadioButton60ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton60ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton60ActionPerformed private void jRadioButton62ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton62ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton62ActionPerformed private void jRadioButton63ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton63ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton63ActionPerformed private void jRadioButton65ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton65ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton65ActionPerformed private void jRadioButton66ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton66ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton66ActionPerformed private void jRadioButton68ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton68ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton68ActionPerformed private void jRadioButton69ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton69ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton69ActionPerformed private void jRadioButton71ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton71ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton71ActionPerformed private void jRadioButton72ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton72ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton72ActionPerformed private void jRadioButton74ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton74ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton74ActionPerformed private void jRadioButton75ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton75ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton75ActionPerformed private void jRadioButton77ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton77ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton77ActionPerformed private void jRadioButton78ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton78ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton78ActionPerformed private void jRadioButton80ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton80ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton80ActionPerformed private void jRadioButton81ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton81ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jRadioButton81ActionPerformed private void jButton_SubmitMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_SubmitMouseExited // TODO add your handling code here: }//GEN-LAST:event_jButton_SubmitMouseExited private void jButton_SubmitMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_SubmitMouseEntered // TODO add your handling code here: }//GEN-LAST:event_jButton_SubmitMouseEntered private void jButton_SubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SubmitActionPerformed // TODO add your handling code here: PreparedStatement st; ResultSet rs; String [] scores = new String [25]; int [] scores_int = new int[25]; for(int i = 0; i< scores.length; i++){ ButtonModel val = btngrp[i].getSelection(); if(val == null){ JOptionPane.showMessageDialog(null,"Question# "+(i+1)+" is blank","Empty field",2 ); return; } else scores[i] = val.getActionCommand(); } String query = "INSERT INTO THI values (null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; try{ st = My_CNX.getConnection().prepareStatement(query); // if(f1 != null) // st.setString(1, f1); // else // st.setNull(1, Types.INTEGER); for(int i = 0; i< 25; i++){ st.setString(i+1, scores[i]); scores_int[i] = Integer.parseInt(scores[i]); } // int fscore = score + f2 + f4 + f7 + f9 + f12 + f13 + f15 + f18 +f20 + f24; // int escore = e3 + e6 + e10 + e14 + e16 + e17 + e21 + e22 + e25; // int cscore = c5 + c8 + c11 + c19 + c23; int fscore = scores_int[0] + scores_int[1] + scores_int[3] + scores_int[6] + scores_int[8] + scores_int[11]+ scores_int[12] + scores_int[14] + scores_int[17] + scores_int[19] + scores_int[23]; int escore = scores_int[2] + scores_int[5] + scores_int[9] + scores_int[13] + scores_int[15] + scores_int[16] + scores_int[20] + scores_int[21] + scores_int[24]; int cscore = scores_int[4] + scores_int[7] + scores_int[10] + scores_int[18] + scores_int[22]; st.setInt(26,fscore); st.setInt(27,escore); st.setInt(28,cscore); st.setInt(29, sum); st.setInt(30, visit_id); String handicap_severity; if(sum >=0 && sum <18) handicap_severity = "slight severity"; else if(sum<38) handicap_severity = "mild"; else if(sum<58) handicap_severity = "moderate"; else if (sum < 78) handicap_severity = "severe"; else{ handicap_severity = "catastrophic"; } if(st.executeUpdate() != 0){ JOptionPane.showMessageDialog(null, "THI form has been submitted"+ "\n" + "Total THI score: " + sum + "\n" + "(F)Function score: "+ fscore + "\n" + "(E)Emotional score: "+ escore + "\n" + "(C)Catastriphic score: "+ cscore + "\n" + "Handicap severity: " + handicap_severity); } else{ JOptionPane.showMessageDialog(null, "Error: Check your information"); } // this.dispose(); }catch (SQLException ex) { Logger.getLogger(Add_Visit_Form.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton_SubmitActionPerformed private void jButton_SaveMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_SaveMouseExited // TODO add your handling code here: }//GEN-LAST:event_jButton_SaveMouseExited private void jButton_SaveMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_SaveMouseEntered // TODO add your handling code here: }//GEN-LAST:event_jButton_SaveMouseEntered private void jButton_SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SaveActionPerformed // TODO add your handling code here: PreparedStatement st; ResultSet rs; // Use it for the save buttons String [] scores = new String [25]; int [] scores_int = new int[25]; for(int i = 0; i< scores.length; i++){ ButtonModel val = btngrp[i].getSelection(); if(val == null) scores[i]= null; else scores[i] = val.getActionCommand(); } String query = "INSERT INTO THI values (null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; String query1 = "select * from thi where thi_id = last_insert_id()"; try{ st = My_CNX.getConnection().prepareStatement(query); // if(f1 != null) // st.setString(1, f1); // else // st.setNull(1, Types.INTEGER); for(int i = 0; i< 25; i++){ st.setString(i+1, scores[i]); if(scores[i] != null) scores_int[i] = Integer.parseInt(scores[i]); else scores_int[i] = 0; } // int fscore = score + f2 + f4 + f7 + f9 + f12 + f13 + f15 + f18 +f20 + f24; // int escore = e3 + e6 + e10 + e14 + e16 + e17 + e21 + e22 + e25; // int cscore = c5 + c8 + c11 + c19 + c23; int fscore = scores_int[0] + scores_int[1] + scores_int[3] + scores_int[6] + scores_int[8] + scores_int[11]+ scores_int[12] + scores_int[14] + scores_int[17] + scores_int[19] + scores_int[23]; int escore = scores_int[2] + scores_int[5] + scores_int[9] + scores_int[13] + scores_int[15] + scores_int[16] + scores_int[20] + scores_int[21] + scores_int[24]; int cscore = scores_int[4] + scores_int[7] + scores_int[10] + scores_int[18] + scores_int[22]; st.setInt(26,fscore); st.setInt(27,escore); st.setInt(28,cscore); st.setInt(29, sum); st.setInt(30, visit_id); if(st.executeUpdate() != 0){ try{ st = My_CNX.getConnection().prepareStatement(query1); rs = st.executeQuery(); if(rs.next()){ thi_id = rs.getInt("thi_id"); } }catch (SQLException ex) { Logger.getLogger(Visit_Form.class.getName()).log(Level.SEVERE, null, ex); } JOptionPane.showMessageDialog(null, "THI form has been saved. Your THI# is " + thi_id); } else{ JOptionPane.showMessageDialog(null, "Error: Check your information"); } // this.dispose(); }catch (SQLException ex) { Logger.getLogger(Add_Visit_Form.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_jButton_SaveActionPerformed private void jButton_CancelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_CancelMouseExited // TODO add your handling code here: }//GEN-LAST:event_jButton_CancelMouseExited private void jButton_CancelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_CancelMouseEntered // TODO add your handling code here: }//GEN-LAST:event_jButton_CancelMouseEntered private void jButton_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CancelActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jButton_CancelActionPerformed private void jButton_HelpMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_HelpMouseExited // TODO add your handling code here: }//GEN-LAST:event_jButton_HelpMouseExited private void jButton_HelpMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton_HelpMouseEntered // TODO add your handling code here: }//GEN-LAST:event_jButton_HelpMouseEntered private void jButton_HelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_HelpActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jButton_HelpActionPerformed private void jTextField_Sum_ScoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_Sum_ScoreActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextField_Sum_ScoreActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(THI_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(THI_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(THI_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(THI_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new THI_Form().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup10; private javax.swing.ButtonGroup buttonGroup11; private javax.swing.ButtonGroup buttonGroup12; private javax.swing.ButtonGroup buttonGroup13; private javax.swing.ButtonGroup buttonGroup14; private javax.swing.ButtonGroup buttonGroup15; private javax.swing.ButtonGroup buttonGroup16; private javax.swing.ButtonGroup buttonGroup17; private javax.swing.ButtonGroup buttonGroup18; private javax.swing.ButtonGroup buttonGroup19; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.ButtonGroup buttonGroup20; private javax.swing.ButtonGroup buttonGroup21; private javax.swing.ButtonGroup buttonGroup22; private javax.swing.ButtonGroup buttonGroup23; private javax.swing.ButtonGroup buttonGroup24; private javax.swing.ButtonGroup buttonGroup25; private javax.swing.ButtonGroup buttonGroup3; private javax.swing.ButtonGroup buttonGroup4; private javax.swing.ButtonGroup buttonGroup5; private javax.swing.ButtonGroup buttonGroup6; private javax.swing.ButtonGroup buttonGroup7; private javax.swing.ButtonGroup buttonGroup8; private javax.swing.ButtonGroup buttonGroup9; private javax.swing.JButton jButton_Cancel; private javax.swing.JButton jButton_Help; private javax.swing.JButton jButton_Save; private javax.swing.JButton jButton_Submit; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel28; private javax.swing.JLabel jLabel29; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel30; private javax.swing.JLabel jLabel31; private javax.swing.JLabel jLabel32; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel_C11; private javax.swing.JPanel jPanel_C19; private javax.swing.JPanel jPanel_C23; private javax.swing.JPanel jPanel_C5; private javax.swing.JPanel jPanel_C8; private javax.swing.JPanel jPanel_E10; private javax.swing.JPanel jPanel_E14; private javax.swing.JPanel jPanel_E16; private javax.swing.JPanel jPanel_E17; private javax.swing.JPanel jPanel_E21; private javax.swing.JPanel jPanel_E22; private javax.swing.JPanel jPanel_E25; private javax.swing.JPanel jPanel_E3; private javax.swing.JPanel jPanel_E6; private javax.swing.JPanel jPanel_F1; private javax.swing.JPanel jPanel_F12; private javax.swing.JPanel jPanel_F13; private javax.swing.JPanel jPanel_F15; private javax.swing.JPanel jPanel_F18; private javax.swing.JPanel jPanel_F2; private javax.swing.JPanel jPanel_F20; private javax.swing.JPanel jPanel_F24; private javax.swing.JPanel jPanel_F4; private javax.swing.JPanel jPanel_F7; private javax.swing.JPanel jPanel_F9; private javax.swing.JRadioButton jRadioButton49; private javax.swing.JRadioButton jRadioButton50; private javax.swing.JRadioButton jRadioButton51; private javax.swing.JRadioButton jRadioButton52; private javax.swing.JRadioButton jRadioButton53; private javax.swing.JRadioButton jRadioButton54; private javax.swing.JRadioButton jRadioButton55; private javax.swing.JRadioButton jRadioButton56; private javax.swing.JRadioButton jRadioButton57; private javax.swing.JRadioButton jRadioButton58; private javax.swing.JRadioButton jRadioButton59; private javax.swing.JRadioButton jRadioButton60; private javax.swing.JRadioButton jRadioButton61; private javax.swing.JRadioButton jRadioButton62; private javax.swing.JRadioButton jRadioButton63; private javax.swing.JRadioButton jRadioButton64; private javax.swing.JRadioButton jRadioButton65; private javax.swing.JRadioButton jRadioButton66; private javax.swing.JRadioButton jRadioButton67; private javax.swing.JRadioButton jRadioButton68; private javax.swing.JRadioButton jRadioButton69; private javax.swing.JRadioButton jRadioButton70; private javax.swing.JRadioButton jRadioButton71; private javax.swing.JRadioButton jRadioButton72; private javax.swing.JRadioButton jRadioButton73; private javax.swing.JRadioButton jRadioButton74; private javax.swing.JRadioButton jRadioButton75; private javax.swing.JRadioButton jRadioButton76; private javax.swing.JRadioButton jRadioButton77; private javax.swing.JRadioButton jRadioButton78; private javax.swing.JRadioButton jRadioButton79; private javax.swing.JRadioButton jRadioButton80; private javax.swing.JRadioButton jRadioButton81; private javax.swing.JRadioButton jRadioButton_C11N; private javax.swing.JRadioButton jRadioButton_C11S; private javax.swing.JRadioButton jRadioButton_C11Y; private javax.swing.JRadioButton jRadioButton_C5N; private javax.swing.JRadioButton jRadioButton_C5S; private javax.swing.JRadioButton jRadioButton_C5Y; private javax.swing.JRadioButton jRadioButton_C8N; private javax.swing.JRadioButton jRadioButton_C8S; private javax.swing.JRadioButton jRadioButton_C8Y; private javax.swing.JRadioButton jRadioButton_E10N; private javax.swing.JRadioButton jRadioButton_E10S; private javax.swing.JRadioButton jRadioButton_E10Y; private javax.swing.JRadioButton jRadioButton_E14N; private javax.swing.JRadioButton jRadioButton_E14S; private javax.swing.JRadioButton jRadioButton_E14Y; private javax.swing.JRadioButton jRadioButton_E3N; private javax.swing.JRadioButton jRadioButton_E3S; private javax.swing.JRadioButton jRadioButton_E3Y; private javax.swing.JRadioButton jRadioButton_E6N; private javax.swing.JRadioButton jRadioButton_E6S; private javax.swing.JRadioButton jRadioButton_E6Y; private javax.swing.JRadioButton jRadioButton_F12N; private javax.swing.JRadioButton jRadioButton_F12S; private javax.swing.JRadioButton jRadioButton_F12Y; private javax.swing.JRadioButton jRadioButton_F13N; private javax.swing.JRadioButton jRadioButton_F13S; private javax.swing.JRadioButton jRadioButton_F13Y; private javax.swing.JRadioButton jRadioButton_F1N; private javax.swing.JRadioButton jRadioButton_F1S; private javax.swing.JRadioButton jRadioButton_F1Y; private javax.swing.JRadioButton jRadioButton_F2N; private javax.swing.JRadioButton jRadioButton_F2S; private javax.swing.JRadioButton jRadioButton_F2Y; private javax.swing.JRadioButton jRadioButton_F4N; private javax.swing.JRadioButton jRadioButton_F4S; private javax.swing.JRadioButton jRadioButton_F4Y; private javax.swing.JRadioButton jRadioButton_F7N; private javax.swing.JRadioButton jRadioButton_F7S; private javax.swing.JRadioButton jRadioButton_F7Y; private javax.swing.JRadioButton jRadioButton_F9N; private javax.swing.JRadioButton jRadioButton_F9S; private javax.swing.JRadioButton jRadioButton_F9Y; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextField jTextField_Date; private javax.swing.JTextField jTextField_Name; private javax.swing.JTextField jTextField_Sum_Score; // End of variables declaration//GEN-END:variables }
54.305598
193
0.666918
c52d1d51f2686bf2e4ac2e9930b297b05ba08cad
13,979
/** * * Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com> * * ==================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ==================================================================== */ package org.jclouds.compute; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.reportMatcher; import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.testng.Assert.assertEquals; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Serializable; import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.easymock.IArgumentMatcher; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Credentials; import org.jclouds.io.Payload; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContext; import org.jclouds.ssh.ExecResponse; import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshException; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; import com.google.inject.Module; /** * * * @author Adrian Cole */ @Test(groups = "live") public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTest { private static final ExecResponse EXEC_GOOD = new ExecResponse("", "", 0); private static final ExecResponse EXEC_BAD = new ExecResponse("", "", 1); public StubComputeServiceIntegrationTest() { provider = "stub"; } @Override public void testCorrectAuthException() throws Exception { } protected void buildSocketTester() { SocketOpen socketOpen = createMock(SocketOpen.class); expect(socketOpen.apply(new IPSocket("144.175.1.1", 22))).andReturn(true); expect(socketOpen.apply(new IPSocket("144.175.1.2", 22))).andReturn(true); expect(socketOpen.apply(new IPSocket("144.175.1.3", 22))).andReturn(true); expect(socketOpen.apply(new IPSocket("144.175.1.4", 22))).andReturn(true); expect(socketOpen.apply(new IPSocket("144.175.1.5", 22))).andReturn(true); replay(socketOpen); socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS); } @Override protected void checkHttpGet(NodeMetadata node) { } @Override protected Module getSshModule() { return new AbstractModule() { @Override protected void configure() { SshClient.Factory factory = createMock(SshClient.Factory.class); SshClient client1 = createMock(SshClient.class); SshClient client2 = createMock(SshClient.class); SshClient client3 = createMock(SshClient.class); SshClient client4 = createMock(SshClient.class); SshClient client5 = createMock(SshClient.class); expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn( client1); runScriptAndService(client1, 1); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( client2).times(2); expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "romeo"))).andThrow( new SshException("Auth fail")); client2.connect(); try { runScript(client2, "runScriptWithCreds", Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class .getResourceAsStream("/runscript.sh")), 2); } catch (IOException e) { Throwables.propagate(e); } client2.disconnect(); expect(factory.create(new IPSocket("144.175.1.3", 22), new Credentials("root", "password3"))).andReturn( client3).times(2); expect(factory.create(new IPSocket("144.175.1.4", 22), new Credentials("root", "password4"))).andReturn( client4).times(2); expect(factory.create(new IPSocket("144.175.1.5", 22), new Credentials("root", "password5"))).andReturn( client5).times(2); runScriptAndInstallSsh(client3, "bootstrap", 3); runScriptAndInstallSsh(client4, "bootstrap", 4); runScriptAndInstallSsh(client5, "bootstrap", 5); expect( factory.create(eq(new IPSocket("144.175.1.1", 22)), eq(new Credentials("root", keyPair.get("private"))))).andReturn(client1); expect( factory.create(eq(new IPSocket("144.175.1.2", 22)), eq(new Credentials("root", keyPair.get("private"))))).andReturn(client2); expect( factory.create(eq(new IPSocket("144.175.1.3", 22)), eq(new Credentials("root", keyPair.get("private"))))).andReturn(client3); expect( factory.create(eq(new IPSocket("144.175.1.4", 22)), eq(new Credentials("root", keyPair.get("private"))))).andReturn(client4); expect( factory.create(eq(new IPSocket("144.175.1.5", 22)), eq(new Credentials("root", keyPair.get("private"))))).andReturn(client5); helloAndJava(client2); helloAndJava(client3); helloAndJava(client4); helloAndJava(client5); replay(factory); replay(client1); replay(client2); replay(client3); replay(client4); replay(client5); bind(SshClient.Factory.class).toInstance(factory); } private void runScriptAndService(SshClient client, int nodeId) { client.connect(); try { runScript(client, "jboss", Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class .getResourceAsStream("/initscript_with_jboss.sh")), nodeId); } catch (IOException e) { Throwables.propagate(e); } client.disconnect(); } private void runScriptAndInstallSsh(SshClient client, String scriptName, int nodeId) { client.connect(); try { runScript(client, scriptName, Strings2.toStringAndClose(StubComputeServiceIntegrationTest.class .getResourceAsStream("/initscript_with_java.sh")), nodeId); } catch (IOException e) { Throwables.propagate(e); } client.disconnect(); } private void runScript(SshClient client, String scriptName, String script, int nodeId) { client.put(scriptName, script); expect(client.exec("chmod 755 " + scriptName + "")).andReturn(EXEC_GOOD); expect(client.getUsername()).andReturn("root").atLeastOnce(); expect(client.getHostAddress()).andReturn(nodeId + "").atLeastOnce(); expect(client.exec("./" + scriptName + " init")).andReturn(EXEC_GOOD); expect(client.exec("./" + scriptName + " start")).andReturn(EXEC_GOOD); expect(client.exec("./" + scriptName + " status")).andReturn(EXEC_GOOD); // next status says the script is done, since not found. expect(client.exec("./" + scriptName + " status")).andReturn(EXEC_BAD); expect(client.exec("./" + scriptName + " tail")).andReturn(EXEC_GOOD); expect(client.exec("./" + scriptName + " tailerr")).andReturn(EXEC_GOOD); } private void helloAndJava(SshClient client) { client.connect(); expect(client.exec("echo hello")).andReturn(new ExecResponse("hello", "", 0)); expect(client.exec("java -version")).andReturn(new ExecResponse("", "1.6", 0)); client.disconnect(); } }; } @Override protected void setupCredentials() { identity = "stub"; credential = "stub"; } protected void assertNodeZero(Set<? extends NodeMetadata> metadataSet) { // TODO: this fails so we override it. } public static Payload payloadEq(String value) { reportMatcher(new PayloadEquals(value)); return null; } public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext<ConcurrentMap<String, NodeMetadata>, ConcurrentMap<String, NodeMetadata>> stubContext = new ComputeServiceContextFactory() .createContext(provider, identity, credential).getProviderSpecificContext(); } private static class PayloadEquals implements IArgumentMatcher, Serializable { private static final long serialVersionUID = 583055160049982067L; private final Object expected; public PayloadEquals(Object expected) { this.expected = expected; } public boolean matches(Object actual) { if (this.expected == null) { return actual == null; } try { String real = Strings2.toStringAndClose(((Payload) actual).getInput()); assertEquals(real, expected); return true; } catch (IOException e) { Throwables.propagate(e); return false; } } public void appendTo(StringBuffer buffer) { appendQuoting(buffer); buffer.append(expected); appendQuoting(buffer); } private void appendQuoting(StringBuffer buffer) { if (expected instanceof String) { buffer.append("\""); } else if (expected instanceof Character) { buffer.append("'"); } } @Override public boolean equals(Object o) { if (o == null || !this.getClass().equals(o.getClass())) return false; PayloadEquals other = (PayloadEquals) o; return this.expected == null && other.expected == null || this.expected != null && this.expected.equals(other.expected); } @Override public int hashCode() { throw new UnsupportedOperationException("hashCode() is not supported"); } } @Override protected void setupKeyPairForTest() throws FileNotFoundException, IOException { keyPair = ImmutableMap.<String, String> of("public", "ssh-rsa", "private", "-----BEGIN RSA PRIVATE KEY-----"); } // TODO: I have absolutely no idea why I have to redeclare all this cruft. If // I don't, then we // get all sorts of not allowed to depend on errors. @Override public void testImagesCache() throws Exception { super.testImagesCache(); } @Override public void testCompareSizes() throws Exception { super.testCompareSizes(); } @Test(enabled = true, dependsOnMethods = { "testImagesCache" }) public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception { super.testAScriptExecutionAfterBootWithBasicTemplate(); } @Test(enabled = true, dependsOnMethods = { "testCompareSizes" }) public void testCreateAndRunAService() throws Exception { super.testCreateAndRunAService(); } @Test(enabled = true, dependsOnMethods = "testTemplateMatch") public void testCreateTwoNodesWithRunScript() throws Exception { super.testCreateTwoNodesWithRunScript(); } @Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript") public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { super.testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired(); } @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testCredentialsCache() throws Exception { super.testCredentialsCache(); } @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { super.testGet(); } @Test(enabled = true, dependsOnMethods = "testGet") public void testOptionToNotBlock() throws Exception { super.testOptionToNotBlock(); } @Test(enabled = true, dependsOnMethods = "testGet") public void testReboot() throws Exception { super.testReboot(); } @Test(enabled = true, dependsOnMethods = "testReboot") public void testSuspendResume() throws Exception { super.testSuspendResume(); } @Test(enabled = true, dependsOnMethods = { "testImagesCache" }) public void testTemplateMatch() throws Exception { super.testTemplateMatch(); } @Override public void testGetNodesWithDetails() throws Exception { super.testGetNodesWithDetails(); } @Override public void testListNodes() throws Exception { super.testListNodes(); } @Override public void testDestroyNodes() { super.testDestroyNodes(); } @Override protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { super.cleanup(); } }
36.403646
140
0.643608
8a7c5fddd4f6e179118cd6c9add7c2503b627d74
1,699
/* * 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.ignite.internal.processors.query.stat; import java.util.UUID; import org.apache.ignite.internal.processors.query.stat.messages.StatisticsRequest; /** * Statistics request with target/sender node id. */ public class StatisticsAddressedRequest { /** Statistics request */ private final StatisticsRequest req; /** Target/sender node id. */ private final UUID nodeId; /** * Constructor. * * @param req Statistics request. * @param nodeId Target/sender node id. */ public StatisticsAddressedRequest(StatisticsRequest req, UUID nodeId) { this.req = req; this.nodeId = nodeId; } /** * @return Statistics request. */ public StatisticsRequest req() { return req; } /** * @return Target/sender node id. */ public UUID nodeId() { return nodeId; } }
28.79661
83
0.691583
c56888351670f949a0f6d13a15f198c4db1b853d
713
// Code generated by lark suite oapi sdk gen package com.larksuite.oapi.service.vc.v1.model; import com.google.gson.annotations.SerializedName; public class ReserveUpdateReqBody { @SerializedName("end_time") private Long endTime; @SerializedName("meeting_settings") private ReserveMeetingSetting meetingSettings; public Long getEndTime() { return this.endTime; } public void setEndTime(Long endTime) { this.endTime = endTime; } public ReserveMeetingSetting getMeetingSettings() { return this.meetingSettings; } public void setMeetingSettings(ReserveMeetingSetting meetingSettings) { this.meetingSettings = meetingSettings; } }
25.464286
75
0.7223
0031b4937fa3f258b62ab9e1f3d34b8ddbf3f351
805
package io.renren.modules.cailiao.service; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.cailiao.entity.WisdplatCailiaoTableEntity; /** * * * @author chenshun * @email sunlightcs@gmail.com * @date 2019-12-25 15:40:40 */ public interface WisdplatCailiaoTableService extends IService<WisdplatCailiaoTableEntity> { PageUtils queryPage(Map<String, Object> params); /** * 根据属性查询 * @param map * @return */ public List findProperty(Map<String,Object> map); int insert(WisdplatCailiaoTableEntity entity); /** * 删除方法 * @param entity * @return */ public int deleteInfo(WisdplatCailiaoTableEntity entity); }
21.756757
91
0.704348
5250dee666cc31bbbaa634aa0ee5234bd065856f
5,616
package kaptainwutax.itraders.container; import kaptainwutax.itraders.container.slot.FakeSlot; import kaptainwutax.itraders.container.slot.PouchSlot; import kaptainwutax.itraders.init.InitPacket; import kaptainwutax.itraders.net.packet.S2CPouchScroll; import kaptainwutax.itraders.world.data.DataEggPouch; import kaptainwutax.itraders.world.storage.PouchInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerEggPouch extends Container { public EntityPlayer player; private World world; public PouchInventory pouchInventory; public ContainerEggPouch(World world, EntityPlayer player) { this.world = world; this.player = player; this.pouchInventory = world.isRemote ? new PouchInventory(true) : DataEggPouch.get(world).getOrCreatePouch(player); for (int row = 0; row < 6; row++) { for (int column = 0; column < 9; column++) { int slotId = row * 9 + column; PouchSlot slot = new PouchSlot(this.pouchInventory, slotId, 8 + column * 18, 28 + row * 18); this.addSlotToContainer(slot); } } FakeSlot fakeSlot = new FakeSlot(this.pouchInventory, 0, 0); this.addSlotToContainer(fakeSlot); for (int row = 0; row < 3; row++) { for (int column = 0; column < 9; column++) { int slotId = row * 9 + column + 9; this.addSlotToContainer(new Slot(player.inventory, slotId, 8 + column * 18, 140 + row * 18)); } } for (int hotbar = 0; hotbar < 9; hotbar++) { this.addSlotToContainer(new Slot(player.inventory, hotbar, 8 + hotbar * 18, 198)); } if (!this.world.isRemote) this.pouchInventory.addListener(this); } @Override public boolean canInteractWith(EntityPlayer player) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack stack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack stackInSlot = slot.getStack(); stack = stackInSlot.copy(); int containerSlots = this.inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(stackInSlot, containerSlots, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(stackInSlot, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (stackInSlot.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } slot.onTake(player, stackInSlot); } return stack; } protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { boolean flag = false; int i = startIndex; if (reverseDirection) { i = endIndex - 1; } if (stack.isStackable()) { while (!stack.isEmpty()) { if (reverseDirection) { if (i < startIndex) { break; } } else if (i >= endIndex) { break; } Slot slot = this.inventorySlots.get(i); ItemStack stackInSlot = slot.getStack(); if (!stackInSlot.isEmpty() && stackInSlot.getItem() == stack.getItem() && (!stack.getHasSubtypes() || stack.getMetadata() == stackInSlot.getMetadata()) && ItemStack.areItemStackTagsEqual(stack, stackInSlot)) { int j = stackInSlot.getCount() + stack.getCount(); int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize()); if (j <= maxSize) { stack.setCount(0); stackInSlot.setCount(j); slot.onSlotChanged(); flag = true; } else if (stackInSlot.getCount() < maxSize) { stack.shrink(maxSize - stackInSlot.getCount()); stackInSlot.setCount(maxSize); slot.onSlotChanged(); flag = true; } } i += reverseDirection ? -1 : 1; } } if (!stack.isEmpty()) { i = reverseDirection ? endIndex - 1 : startIndex; while (true) { if (reverseDirection) { if (i < startIndex) { break; } } else if (i >= endIndex) { break; } Slot slot = this.inventorySlots.get(i); ItemStack stackInSlot = slot.getStack(); if (stackInSlot.isEmpty() && slot.isItemValid(stack)) { if (stack.getCount() > slot.getSlotStackLimit()) { slot.putStack(stack.splitStack(slot.getSlotStackLimit())); } else { slot.putStack(stack.splitStack(stack.getCount())); } slot.onSlotChanged(); flag = true; break; } if (reverseDirection) { --i; } else { ++i; } } } return flag; } @Override public void detectAndSendChanges() { this.pouchInventory.onContentsChanged(); super.detectAndSendChanges(); for (int i = 0; i < this.inventorySlots.size(); ++i) { for (int j = 0; j < this.listeners.size(); ++j) { if (this.inventorySlots.get(i) instanceof PouchSlot) { ((IContainerListener) this.listeners.get(j)).sendSlotContents(this, i, this.inventorySlots.get(i).getStack()); } } } } public void onMove(int amount) { this.pouchInventory.move(amount); if (!this.world.isRemote) { InitPacket.PIPELINE.sendTo( new S2CPouchScroll(this.pouchInventory.currentScroll, this.pouchInventory.totalScroll), (EntityPlayerMP) this.player); } } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); if (!this.world.isRemote) this.pouchInventory.removeListener(this); } }
26.742857
108
0.675036
0d75d262aa538f19a30382a4905be9aa55aebe13
1,363
package com.github.mikesafonov.smpp.core.connection; import com.cloudhopper.smpp.SmppBindType; import com.cloudhopper.smpp.type.LoggingOptions; import com.github.mikesafonov.smpp.config.SmppProperties; import javax.validation.constraints.NotNull; import static java.util.Objects.requireNonNull; public class TransceiverConfiguration extends BaseSmppSessionConfiguration { public TransceiverConfiguration(@NotNull String name, @NotNull SmppProperties.Credentials credentials, boolean loggingBytes, boolean loggingPdu, int windowsSize, String systemType) { super(); setType(SmppBindType.TRANSCEIVER); setName(requireNonNull(name)); setHost(credentials.getHost()); setPort(credentials.getPort()); setSystemId(credentials.getUsername()); setPassword(credentials.getPassword()); setWindowSize(windowsSize); setSystemType(systemType); LoggingOptions loggingOptions = new LoggingOptions(); loggingOptions.setLogBytes(loggingBytes); loggingOptions.setLogPdu(loggingPdu); setLoggingOptions(loggingOptions); } public String configInformation() { return String.format("%s host=%s port=%d username=%s windowsSize=%d", getName(), getHost(), getPort(), getSystemId(), getWindowSize()); } }
37.861111
115
0.713133
373c8e7d43ba893a516cc4d0cbf10554ad6bb9dd
105
package edu.jalc.everydaythings.bottle; public interface Fillable{ public void fill(double amount); }
17.5
39
0.790476
a66292156e008005b5a428cada2ef86335fd5744
2,001
package br.com.vidal.projeto_mv_xpto.view.controller; import java.util.List; import java.util.Optional; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import br.com.vidal.projeto_mv_xpto.service.movimentacao.MovimentacaoService; import br.com.vidal.projeto_mv_xpto.shared.MovimentacaoDto; import br.com.vidal.projeto_mv_xpto.view.model.RequestInstituicaoFinanceira; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @RestController @RequestMapping("api/v1/movimentacao") public class MovimentacaoController { @Autowired MovimentacaoService service; @GetMapping() public ResponseEntity<?> retornaTodos() { List<MovimentacaoDto> listaMovimentacaoDto = service.retornaTodos(); if (listaMovimentacaoDto.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } else { return new ResponseEntity<>(listaMovimentacaoDto, HttpStatus.OK); } } @GetMapping(path = "/{id}") public ResponseEntity<?> retornaPorId(@PathVariable Integer id) { Optional<MovimentacaoDto> movimentacaoDto = service.retornaPorId(id); if (movimentacaoDto.isPresent()) { return new ResponseEntity<>(movimentacaoDto, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } } @PostMapping() public ResponseEntity<?> gravarMovimentacao(@RequestBody @Valid RequestInstituicaoFinanceira request) { MovimentacaoDto movimentacaoDto = service.gravarMovimentacao(request); return new ResponseEntity<>(movimentacaoDto, HttpStatus.CREATED); } }
30.318182
105
0.782609
deb9a05efb6b7a8b75ccf5ff45879ffa71ca85de
766
package org.doraemon.framework.base; /** * Created with IntelliJ IDEA. * Description: 描述 * Author: fengwenping * Date: 2020/1/6 0:46 */ public enum GenderEnum implements IEnumProvider<Integer> { MALE(1, "男"), FEMALE(2, "女"); private final Integer code; private final String name; GenderEnum(Integer code, String name) { this.code = code; this.name = name; } @Override public Integer getCode() { return this.code; } @Override public String getName() { return this.name; } @Override public String toString() { return this.info(); } public static void main(String[] args) { System.out.println(GenderEnum.FEMALE.toString()); } }
18.682927
58
0.5953
d1e62cb0f555a897f6a9bb5e1f9eb12917e9ed91
9,370
/****************************************************************************** * Copyright 2009-2020 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.exactpro.sf.services.netty; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.exactpro.sf.aml.script.actions.WaitAction; import com.exactpro.sf.common.messages.IMessage; import com.exactpro.sf.common.messages.IMessageFactory; import com.exactpro.sf.configuration.IDictionaryManager; import com.exactpro.sf.configuration.workspace.IWorkspaceDispatcher; import com.exactpro.sf.scriptrunner.actionmanager.actioncontext.IActionContext; import com.exactpro.sf.services.AbstractService; import com.exactpro.sf.services.IInitiatorService; import com.exactpro.sf.services.IServiceSettings; import com.exactpro.sf.services.ServiceEvent.Type; import com.exactpro.sf.services.ServiceEventFactory; import com.exactpro.sf.services.ServiceStatus; import com.exactpro.sf.services.netty.internal.NettyEmbeddedPipeline; import com.exactpro.sf.services.netty.internal.handlers.RawSendHandler; import com.exactpro.sf.services.netty.sessions.AbstractNettySession; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelPipeline; import io.netty.channel.nio.NioEventLoopGroup; public abstract class AbstractNettyService extends AbstractService implements IInitiatorService { protected final Logger logger = LoggerFactory.getLogger(getClass().getName() + '@' + Integer.toHexString(hashCode())); protected IMessageFactory msgFactory; protected IWorkspaceDispatcher workspaceDispatcher; @Nullable protected volatile NioEventLoopGroup nioEventLoopGroup; protected volatile AbstractNettySession mainSession; @NotNull protected final ConcurrentMap<AbstractNettySession, Future<?>> heartBeatFuture = new ConcurrentHashMap<>(); /**Doesn't perform any channel initialization*/ protected static final ChannelInitializer<Channel> NOOP_CHANNEL_INITIALIZER = new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel ch) throws Exception { } }; private class HeartBeatTask implements Runnable { private final AbstractNettySession session; HeartBeatTask(AbstractNettySession session) { this.session = Objects.requireNonNull(session, "Session can't be null"); } @Override public void run() { try { sendHeartBeat(session); } catch (Exception e) { logger.error("Heartbeat not sending in session: {}", session, e); } } } @Override public AbstractNettySession getSession() { return mainSession; } @Override public IMessage receive(IActionContext actionContext, IMessage msg) throws InterruptedException { return WaitAction.waitForMessage(actionContext, msg, !msg.getMetaData().isAdmin()); } @Override protected void internalInit() throws Exception { super.internalInit(); this.msgFactory = Objects.requireNonNull(serviceContext.getDictionaryManager().getMessageFactory(settings.getDictionaryName())); this.workspaceDispatcher = Objects.requireNonNull(serviceContext.getWorkspaceDispatcher(), "'Workspace dispatcher' parameter"); initService(serviceContext.getDictionaryManager(), settings); } @Override protected void internalStart() throws Exception { super.internalStart(); nioEventLoopGroup = new NioEventLoopGroup(); connect(); } @Override protected void internalDispose() { try { heartBeatFuture.keySet().forEach(this::stopSendHeartBeats); mainSession.close(); } catch (RuntimeException e) { serviceMonitor.onEvent(ServiceEventFactory.createEventError(getServiceName(), Type.DISPOSING, "Session close", "Session '" + serviceName + "' has not been closed", e)); } finally { super.internalDispose(); } } @Override protected void disposeResources() { try { NioEventLoopGroup nioEventLoopGroup = this.nioEventLoopGroup; if (nioEventLoopGroup != null) { if (!nioEventLoopGroup.isShutdown()) { try { if (!nioEventLoopGroup.shutdownGracefully().awaitUninterruptibly(5, TimeUnit.SECONDS)) { serviceMonitor.onEvent(ServiceEventFactory.createEventError(getServiceName(), Type.DISPOSING, "Events executor close", "Events executor '" + serviceName + "' has not been closed for 5 seconds")); } this.nioEventLoopGroup = null; } catch (Exception e) { logger.error(e.getMessage(), e); } } } } finally { super.disposeResources(); } } protected abstract void sendHeartBeat(AbstractNettySession session) throws InterruptedException; /** * This method is called before session closing. * Please call super.disposeService from finally block of your implementation * @param session not null session */ protected void disposeService(@NotNull AbstractNettySession session) { } protected abstract int getPort(); protected abstract String getHost(); protected void initChannelCloseFuture(AbstractNettySession session, Channel channel) { channel.closeFuture().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { changeStatus(ServiceStatus.ERROR, "Failed to close channel", future.cause()); } stopSendHeartBeats(session); } }); } protected void addRawSendHandler(ChannelPipeline pipeline) { NettyEmbeddedPipeline embeddedPipeline = createEmbeddedPipeline(); if (embeddedPipeline != null) { loggingConfigurator.registerLogger(embeddedPipeline, getServiceName()); } pipeline.addLast(new RawSendHandler(embeddedPipeline, this::acceptToSendRaw)); } /** * Filters for decoded messages when user tries to send raw * @param message the decoded message * @return {@code true} if the message should be sent further. Otherwise, returns {@code false} */ protected boolean acceptToSendRaw(IMessage message) { return true; } /** * * @return embedded pipeline to use in sending raw messages or {@code null} if it is not supported */ @Nullable protected NettyEmbeddedPipeline createEmbeddedPipeline() { return null; } @NotNull protected abstract AbstractNettySession createSession(Channel channel); /** * @deprecated Please use {@link #AbstractService#internalInit()} */ @Deprecated protected void initService(IDictionaryManager dictionaryManager, IServiceSettings settings) { } protected void startSendHeartBeats(AbstractNettySession session, long heartbeatInterval) { if (heartbeatInterval > 0) { heartBeatFuture.compute(session, (nettySession, future) -> { if (future != null) { logger.error("IllegalState: heartbeat timer not stopped"); future.cancel(true); } return taskExecutor.addRepeatedTask(new HeartBeatTask(session), heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS); }); } } protected void stopSendHeartBeats(AbstractNettySession session) { Future<?> future = heartBeatFuture.remove(session); if (future != null) { future.cancel(false); } } public void stop(String message, Throwable cause) { disposeResources(); } public void onExceptionCaught(Channel channel, Throwable cause) { String message = "Exception caught in netty's pipeline in channel " + channel.id(); changeStatus(ServiceStatus.ERROR, message, cause); stop(message, cause); } }
39.041667
223
0.667556
6495189eaf4a2bbf7cc8da37202e4ece29236eaf
1,442
package com.twasyl.slideshowfx.server.service; /** * <p>This interfaces lists all common response codes returned by a {@link AbstractSlideshowFXService}.</p> * * @author Thierry Wasylczenko * @version 1.0.0 * @since SlideshowFX 1.0 */ public interface IServicesCode { /** * The status code indicating the service went normally. */ int RESPONSE_CODE_OK = 200; /** * The status code indicating the chat has been added successfully. */ int RESPONSE_CODE_MESSAGE_ADDED = 201; /** * The status code indicating the chat message has been updated successfully. */ int RESPONSE_CODE_MESSAGE_UPDATED = 202; /** * The status code indicating the quiz has been started successfully. */ int RESPONSE_CODE_QUIZ_STARTED = 203; /** * The status code indicating the quiz has been stopped successfully. */ int RESPONSE_CODE_QUIZ_STOPPED = 204; /** * The status code indicating the current quiz has been retrieved successfully. */ int RESPONSE_CODE_QUIZ_RETRIEVED = 205; /** * The status code indicating an error occurred. */ int RESPONSE_CODE_ERROR = 400; /** * The status code indicating that a chat message has not been found. */ int RESPONSE_CODE_MESSAGE_NOT_FOUND = 404; /** * The status code indicating tno quiz is currently active. */ int RESPONSE_CODE_QUIZ_NOT_ACTIVE = 404; }
25.75
107
0.670596
9674cb79a9f448f1ca5fe52dc7ae4e4680427987
6,710
package li.strolch.utils.helper; import static org.junit.Assert.assertEquals; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.TimeZone; import org.junit.BeforeClass; import org.junit.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class XmlSignHelperTest { private static XmlDomSigner helper; @BeforeClass public static void beforeClass() { helper = new XmlDomSigner(new File("src/test/resources/test.jks"), "client", "server", "changeit".toCharArray()); } @Test public void shouldSign() { Document document = createDoc(); helper.sign(document); assertSignatureElemExists(document); } @Test public void shouldSignWithNamespaces() { Document document = createDocWithNamespaces(); // hack for signing with namespaces problem document = XmlDomSigner.parse(XmlDomSigner.transformToBytes(document)); helper.sign(document); assertSignatureElemExists(document); } private void assertSignatureElemExists(Document document) { NodeList nl = document.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature"); assertEquals("Expected exactly one Signature element!", 1, nl.getLength()); } @Test public void shouldValidate() { File signedXmlFile = new File("src/test/resources/SignedXmlFile.xml"); Document document = XmlDomSigner.parse(signedXmlFile); setIdAttr(document); helper.validate(document); } @Test public void shouldValidateWithNamespaces() { File signedXmlFile = new File("src/test/resources/SignedXmlFileWithNamespaces.xml"); Document document = XmlDomSigner.parse(signedXmlFile); setIdAttrNs(document); helper.validate(document); } private void setIdAttr(Document document) { NodeList authnRequestNodes = document.getElementsByTagName("AuthnRequest"); if (authnRequestNodes.getLength() != 1) throw new IllegalStateException("Multiple or no AuthnRequest Node found in document!"); Element authnRequestNode = (Element) authnRequestNodes.item(0); authnRequestNode.setIdAttribute("ID", true); } private void setIdAttrNs(Document document) { NodeList authnRequestNodes = document .getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "AuthnRequest"); if (authnRequestNodes.getLength() != 1) throw new IllegalStateException("Multiple or no AuthnRequest Node found in document!"); Element authnRequestNode = (Element) authnRequestNodes.item(0); authnRequestNode.setIdAttribute("ID", true); } @Test public void shouldSignAndValidate() { Document document = createDoc(); helper.sign(document); helper.validate(document); } @Test public void shouldSignAndValidateWithNamespaces() { Document document = createDocWithNamespaces(); // hack for signing with namespaces problem document = XmlDomSigner.parse(XmlDomSigner.transformToBytes(document)); helper.sign(document); helper.validate(document); } public static Document createDoc() { String issuer = "test"; String destination = "test"; String assertionConsumerServiceUrl = "test"; Calendar issueInstant = Calendar.getInstance(); // create dates SimpleDateFormat simpleDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); simpleDf.setTimeZone(TimeZone.getTimeZone("UTC")); String issueInstantS = simpleDf.format(issueInstant.getTime()); String notBeforeS = issueInstantS; issueInstant.add(Calendar.SECOND, 10); String notOnOrAfterS = simpleDf.format(issueInstant.getTime()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder; try { docBuilder = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException("Failed to configure document builder!", e); } Document doc = docBuilder.newDocument(); Element authnReqE = doc.createElement("AuthnRequest"); authnReqE.setAttribute("Version", "2.0"); authnReqE.setAttribute("IssueInstant", issueInstantS); authnReqE.setAttribute("ProtocolBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); authnReqE.setAttribute("AssertionConsumerServiceURL", assertionConsumerServiceUrl); authnReqE.setAttribute("Destination", destination); doc.appendChild(authnReqE); Element issuerE = doc.createElement("Issuer"); issuerE.setTextContent(issuer); authnReqE.appendChild(issuerE); Element conditionsE = doc.createElement("Conditions"); conditionsE.setAttribute("NotBefore", notBeforeS); conditionsE.setAttribute("NotOnOrAfter", notOnOrAfterS); authnReqE.appendChild(conditionsE); return doc; } public static Document createDocWithNamespaces() { String issuer = "test"; String destination = "test"; String assertionConsumerServiceUrl = "test"; Calendar issueInstant = Calendar.getInstance(); // create dates SimpleDateFormat simpleDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); simpleDf.setTimeZone(TimeZone.getTimeZone("UTC")); String issueInstantS = simpleDf.format(issueInstant.getTime()); String notBeforeS = issueInstantS; issueInstant.add(Calendar.SECOND, 10); String notOnOrAfterS = simpleDf.format(issueInstant.getTime()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder docBuilder; try { docBuilder = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException("Failed to configure document builder!", e); } Document doc = docBuilder.newDocument(); Element authnReqE = doc.createElementNS("urn:oasis:names:tc:SAML:2.0:protocol", "AuthnRequest"); authnReqE.setPrefix("samlp"); authnReqE.setAttribute("Version", "2.0"); authnReqE.setAttribute("IssueInstant", issueInstantS); authnReqE.setAttribute("ProtocolBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); authnReqE.setAttribute("AssertionConsumerServiceURL", assertionConsumerServiceUrl); authnReqE.setAttribute("Destination", destination); doc.appendChild(authnReqE); Element issuerE = doc.createElementNS("urn:oasis:names:tc:SAML:2.0:assertion", "Issuer"); issuerE.setPrefix("saml"); issuerE.setTextContent(issuer); authnReqE.appendChild(issuerE); Element conditionsE = doc.createElementNS("urn:oasis:names:tc:SAML:2.0:assertion", "Conditions"); conditionsE.setPrefix("saml"); conditionsE.setAttribute("NotBefore", notBeforeS); conditionsE.setAttribute("NotOnOrAfter", notOnOrAfterS); authnReqE.appendChild(conditionsE); return doc; } }
32.572816
99
0.767213
8560e180c72fecada043c0956ec54e6b37b02fc7
689
package com.cvars.ScotiaTracker.strategy.search; import com.cvars.ScotiaTracker.model.pojo.Invoice; import com.cvars.ScotiaTracker.strategy.search.SearchStrategy; import java.util.ArrayList; import java.util.List; public class SupplierSearch implements SearchStrategy { @Override public List<Invoice> search(List<Invoice> invoices, String searchAttribute) { List<Invoice> li = new ArrayList<>(); String lowerCase = searchAttribute.toLowerCase(); for (Invoice i: invoices) { String sid = i.getSupplierName().toLowerCase(); if (sid.contains(lowerCase)){ li.add(i); } } return li; } }
29.956522
81
0.664731
b4ac11586ccb8ea977b7ae877344db42903c3db2
1,983
/* * Copyright (c) 2020. www.hoprxi.com All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package catalog.hoprxi.core.domain.model; import catalog.hoprxi.core.infrastructure.i18n.Label; import java.util.Objects; /*** * @author <a href="www.hoprxi.com/authors/guan xianghuang">guan xiangHuang</a> * @since JDK8.0 * @version 0.0.1 builder 2019-04-29 */ public class Specification { public static final Specification UNDEFINED = new Specification(""); private String value; public Specification(String value) { this.value = Objects.requireNonNull(value, "value required").trim(); } public static Specification rebulid(String value) { if (value.equals("")) return UNDEFINED; return new Specification(value); } public String name() { return Label.SPEC_NAME; } public String value() { return value; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Specification that = (Specification) o; return value != null ? value.equals(that.value) : that.value == null; } @Override public int hashCode() { return value != null ? value.hashCode() : 0; } @Override public String toString() { return "Specification{" + "value='" + value + '\'' + '}'; } }
27.541667
79
0.641452
3c5bc8d6bee59385d2771f01d6caa5c345261a1c
448
package com.mouensis.framework.web.resovler; /** * 字段描述符异常 * * @author zhuyuan * @date 2020/11/18 20:57 */ public class FieldDescriptorException extends QueryDtoException { private static final long serialVersionUID = -7010381028611616443L; public FieldDescriptorException(String message) { super(message); } public FieldDescriptorException(String message, Throwable cause) { super(message, cause); } }
21.333333
71
0.714286
5b3a4bf7c07450d2d7c5b48017ba221eb3d27067
6,315
package com.businesscard.ui.main.systemManagement; import java.util.HashMap; import webservice.MemoWebPara; import webservice.WebServiceDelegate; import webservice.WebServiceUtils; import com.businesscard.data.dbDriver.CreateUserDB; import com.businesscard.domain.Emtity.Accounts; import com.businesscard.domain.Service.AccountsService; import com.businesscard.mobile.R; import com.businesscard.ui.main.FirstEditActivity; import com.businesscard.ui.main.SlidingActivity; import com.businesscard.ui.main.viewModel.MyProgressDialog; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class LoginAndRegistActivity extends Activity implements WebServiceDelegate { private Button btn_login, btn_regist; private EditText et_userphone, et_password; private AccountsService acs; private String userPhone, password; private WebServiceUtils webService; private SharedPreferences login_sp; private boolean loginOrRegistr;// login=true,register=false @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); btn_login = (Button) findViewById(R.id.btn_login); btn_regist = (Button) findViewById(R.id.btn_regist); et_userphone = (EditText) findViewById(R.id.et_userphone); et_userphone.setText(""); et_password = (EditText) findViewById(R.id.et_password); et_password.setText(""); webService = new WebServiceUtils(MemoWebPara.SM_NAMESPACE, MemoWebPara.SM_URL, this); SQLiteDatabase db = openOrCreateDatabase("BusinessCard.db3", MODE_PRIVATE, null); acs = new AccountsService(db); login_sp = getSharedPreferences("Login", MODE_PRIVATE); if (login_sp.getBoolean("login_in", false)) { Intent intent = new Intent(LoginAndRegistActivity.this, SlidingActivity.class); startActivity(intent); finish(); } btn_login.setOnClickListener(new OnClickListener() { @SuppressLint("SdCardPath") @Override public void onClick(View v) { // TODO Auto-generated method stub userPhone = et_userphone.getText().toString(); password = et_password.getText().toString(); loginOrRegistr = true; if (userPhone.equals("") || password.equals("")) { Toast toast = Toast.makeText(LoginAndRegistActivity.this, "用户名密码请填完整", Toast.LENGTH_SHORT); toast.show(); } else { loginOrRegistr = true; HashMap<String, Object> args = new HashMap<String, Object>(); args.put("tel", userPhone); args.put("pwd", password); MyProgressDialog.show(LoginAndRegistActivity.this, "登陆中,请稍后……", true, false); webService.callWebService("login", args, boolean.class); } } }); btn_regist.setOnClickListener(new OnClickListener() { @SuppressLint("SdCardPath") @Override public void onClick(View arg0) { // TODO Auto-generated method stub userPhone = et_userphone.getText().toString(); password = et_password.getText().toString(); loginOrRegistr = false; if (userPhone.equals("") || password.equals("")) { Toast toast = Toast.makeText(LoginAndRegistActivity.this, "用户名密码请填完整", Toast.LENGTH_SHORT); toast.show(); } else if (!userPhone.matches("^(13|15|18)\\d{9}$")) { Toast.makeText(getApplicationContext(), "电话号码格式不正确!", Toast.LENGTH_SHORT).show(); } else { HashMap<String, Object> args = new HashMap<String, Object>(); args.put("tel", userPhone); args.put("pwd", password); // 调用web服务 MyProgressDialog.show(LoginAndRegistActivity.this, "注册中,请稍后……", true, false); webService.callWebService("register", args, boolean.class); } } }); } private void saveUserInfo() { SharedPreferences sharedPreferences = getSharedPreferences( "current_user", MODE_PRIVATE); Editor editor = sharedPreferences.edit(); editor.putString("userPhone", userPhone); editor.commit(); login_sp = getSharedPreferences("Login", MODE_PRIVATE); editor = login_sp.edit(); editor.putBoolean("login_in", true); editor.commit(); } @Override public void handleException(Object ex) { // TODO Auto-generated method stub MyProgressDialog.cancel(); Toast toast = Toast.makeText(LoginAndRegistActivity.this, "请检查网络连接", Toast.LENGTH_SHORT); toast.show(); } @SuppressLint("SdCardPath") @Override public void handleResultOfWebService(String methodName, Object result) { // TODO Auto-generated method stub boolean flag = (Boolean) result; if (flag == true) { saveUserInfo(); Accounts ac = new Accounts(); ac.setAccount(userPhone); ac.setPwd(et_password.getText().toString()); if (loginOrRegistr == true & acs.findAccountByID(userPhone) == null) { acs.addAccount(ac); String path = "/data/data/com.businesscard.mobile/databases/"; new CreateUserDB(path, userPhone, LoginAndRegistActivity.this); Intent intent = new Intent(LoginAndRegistActivity.this, FirstEditActivity.class); startActivity(intent); finish(); } else if (loginOrRegistr == true & acs.findAccountByID(userPhone) != null) { Intent intent = new Intent(LoginAndRegistActivity.this, SlidingActivity.class); startActivity(intent); finish(); } else if (loginOrRegistr == false) { acs.addAccount(ac); String path = "/data/data/com.businesscard.mobile/databases/"; new CreateUserDB(path, userPhone, LoginAndRegistActivity.this); Intent intent = new Intent(LoginAndRegistActivity.this, FirstEditActivity.class); startActivity(intent); finish(); } } else if (flag == false) { if (loginOrRegistr == true) { MyProgressDialog.cancel(); Toast toast = Toast.makeText(LoginAndRegistActivity.this, "密码不正确", Toast.LENGTH_SHORT); toast.show(); } else if (loginOrRegistr == false) { MyProgressDialog.cancel(); Toast toast = Toast.makeText(LoginAndRegistActivity.this, "用户已存在", Toast.LENGTH_SHORT); toast.show(); } } } }
33.770053
82
0.726207
e1bb4a924f4f0fe974fc743d8d1a404085767810
174,479
/** * Autogenerated by Thrift Compiler (0.11.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package edu.cmu.lti.oaqa.similarity; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2019-01-15") public class QueryService { public interface Iface { public void setQueryTimeParams(java.lang.String queryTimeParams) throws QueryException, org.apache.thrift.TException; public java.util.List<ReplyEntry> knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException; public java.util.List<ReplyEntry> rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException; public double getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws QueryException, org.apache.thrift.TException; } public interface AsyncIface { public void setQueryTimeParams(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException; public void knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException; public void rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException; public void getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException; } public static class Client extends org.apache.thrift.TServiceClient implements Iface { public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> { public Factory() {} public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } } public Client(org.apache.thrift.protocol.TProtocol prot) { super(prot, prot); } public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { super(iprot, oprot); } public void setQueryTimeParams(java.lang.String queryTimeParams) throws QueryException, org.apache.thrift.TException { send_setQueryTimeParams(queryTimeParams); recv_setQueryTimeParams(); } public void send_setQueryTimeParams(java.lang.String queryTimeParams) throws org.apache.thrift.TException { setQueryTimeParams_args args = new setQueryTimeParams_args(); args.setQueryTimeParams(queryTimeParams); sendBase("setQueryTimeParams", args); } public void recv_setQueryTimeParams() throws QueryException, org.apache.thrift.TException { setQueryTimeParams_result result = new setQueryTimeParams_result(); receiveBase(result, "setQueryTimeParams"); if (result.err != null) { throw result.err; } return; } public java.util.List<ReplyEntry> knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException { send_knnQuery(k, queryObj, retExternId, retObj); return recv_knnQuery(); } public void send_knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws org.apache.thrift.TException { knnQuery_args args = new knnQuery_args(); args.setK(k); args.setQueryObj(queryObj); args.setRetExternId(retExternId); args.setRetObj(retObj); sendBase("knnQuery", args); } public java.util.List<ReplyEntry> recv_knnQuery() throws QueryException, org.apache.thrift.TException { knnQuery_result result = new knnQuery_result(); receiveBase(result, "knnQuery"); if (result.isSetSuccess()) { return result.success; } if (result.err != null) { throw result.err; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "knnQuery failed: unknown result"); } public java.util.List<ReplyEntry> rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws QueryException, org.apache.thrift.TException { send_rangeQuery(r, queryObj, retExternId, retObj); return recv_rangeQuery(); } public void send_rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) throws org.apache.thrift.TException { rangeQuery_args args = new rangeQuery_args(); args.setR(r); args.setQueryObj(queryObj); args.setRetExternId(retExternId); args.setRetObj(retObj); sendBase("rangeQuery", args); } public java.util.List<ReplyEntry> recv_rangeQuery() throws QueryException, org.apache.thrift.TException { rangeQuery_result result = new rangeQuery_result(); receiveBase(result, "rangeQuery"); if (result.isSetSuccess()) { return result.success; } if (result.err != null) { throw result.err; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "rangeQuery failed: unknown result"); } public double getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws QueryException, org.apache.thrift.TException { send_getDistance(obj1, obj2); return recv_getDistance(); } public void send_getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) throws org.apache.thrift.TException { getDistance_args args = new getDistance_args(); args.setObj1(obj1); args.setObj2(obj2); sendBase("getDistance", args); } public double recv_getDistance() throws QueryException, org.apache.thrift.TException { getDistance_result result = new getDistance_result(); receiveBase(result, "getDistance"); if (result.isSetSuccess()) { return result.success; } if (result.err != null) { throw result.err; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getDistance failed: unknown result"); } } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> { private org.apache.thrift.async.TAsyncClientManager clientManager; private org.apache.thrift.protocol.TProtocolFactory protocolFactory; public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void setQueryTimeParams(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException { checkReady(); setQueryTimeParams_call method_call = new setQueryTimeParams_call(queryTimeParams, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class setQueryTimeParams_call extends org.apache.thrift.async.TAsyncMethodCall<Void> { private java.lang.String queryTimeParams; public setQueryTimeParams_call(java.lang.String queryTimeParams, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.queryTimeParams = queryTimeParams; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("setQueryTimeParams", org.apache.thrift.protocol.TMessageType.CALL, 0)); setQueryTimeParams_args args = new setQueryTimeParams_args(); args.setQueryTimeParams(queryTimeParams); args.write(prot); prot.writeMessageEnd(); } public Void getResult() throws QueryException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return null; } } public void knnQuery(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException { checkReady(); knnQuery_call method_call = new knnQuery_call(k, queryObj, retExternId, retObj, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class knnQuery_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<ReplyEntry>> { private int k; private java.nio.ByteBuffer queryObj; private boolean retExternId; private boolean retObj; public knnQuery_call(int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.k = k; this.queryObj = queryObj; this.retExternId = retExternId; this.retObj = retObj; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("knnQuery", org.apache.thrift.protocol.TMessageType.CALL, 0)); knnQuery_args args = new knnQuery_args(); args.setK(k); args.setQueryObj(queryObj); args.setRetExternId(retExternId); args.setRetObj(retObj); args.write(prot); prot.writeMessageEnd(); } public java.util.List<ReplyEntry> getResult() throws QueryException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_knnQuery(); } } public void rangeQuery(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException { checkReady(); rangeQuery_call method_call = new rangeQuery_call(r, queryObj, retExternId, retObj, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class rangeQuery_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<ReplyEntry>> { private double r; private java.nio.ByteBuffer queryObj; private boolean retExternId; private boolean retObj; public rangeQuery_call(double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.r = r; this.queryObj = queryObj; this.retExternId = retExternId; this.retObj = retObj; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("rangeQuery", org.apache.thrift.protocol.TMessageType.CALL, 0)); rangeQuery_args args = new rangeQuery_args(); args.setR(r); args.setQueryObj(queryObj); args.setRetExternId(retExternId); args.setRetObj(retObj); args.write(prot); prot.writeMessageEnd(); } public java.util.List<ReplyEntry> getResult() throws QueryException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_rangeQuery(); } } public void getDistance(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException { checkReady(); getDistance_call method_call = new getDistance_call(obj1, obj2, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getDistance_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Double> { private java.nio.ByteBuffer obj1; private java.nio.ByteBuffer obj2; public getDistance_call(java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.obj1 = obj1; this.obj2 = obj2; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getDistance", org.apache.thrift.protocol.TMessageType.CALL, 0)); getDistance_args args = new getDistance_args(); args.setObj1(obj1); args.setObj2(obj2); args.write(prot); prot.writeMessageEnd(); } public java.lang.Double getResult() throws QueryException, org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getDistance(); } } } public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); public Processor(I iface) { super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>())); } protected Processor(I iface, java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { super(iface, getProcessMap(processMap)); } private static <I extends Iface> java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { processMap.put("setQueryTimeParams", new setQueryTimeParams()); processMap.put("knnQuery", new knnQuery()); processMap.put("rangeQuery", new rangeQuery()); processMap.put("getDistance", new getDistance()); return processMap; } public static class setQueryTimeParams<I extends Iface> extends org.apache.thrift.ProcessFunction<I, setQueryTimeParams_args> { public setQueryTimeParams() { super("setQueryTimeParams"); } public setQueryTimeParams_args getEmptyArgsInstance() { return new setQueryTimeParams_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public setQueryTimeParams_result getResult(I iface, setQueryTimeParams_args args) throws org.apache.thrift.TException { setQueryTimeParams_result result = new setQueryTimeParams_result(); try { iface.setQueryTimeParams(args.queryTimeParams); } catch (QueryException err) { result.err = err; } return result; } } public static class knnQuery<I extends Iface> extends org.apache.thrift.ProcessFunction<I, knnQuery_args> { public knnQuery() { super("knnQuery"); } public knnQuery_args getEmptyArgsInstance() { return new knnQuery_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public knnQuery_result getResult(I iface, knnQuery_args args) throws org.apache.thrift.TException { knnQuery_result result = new knnQuery_result(); try { result.success = iface.knnQuery(args.k, args.queryObj, args.retExternId, args.retObj); } catch (QueryException err) { result.err = err; } return result; } } public static class rangeQuery<I extends Iface> extends org.apache.thrift.ProcessFunction<I, rangeQuery_args> { public rangeQuery() { super("rangeQuery"); } public rangeQuery_args getEmptyArgsInstance() { return new rangeQuery_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public rangeQuery_result getResult(I iface, rangeQuery_args args) throws org.apache.thrift.TException { rangeQuery_result result = new rangeQuery_result(); try { result.success = iface.rangeQuery(args.r, args.queryObj, args.retExternId, args.retObj); } catch (QueryException err) { result.err = err; } return result; } } public static class getDistance<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getDistance_args> { public getDistance() { super("getDistance"); } public getDistance_args getEmptyArgsInstance() { return new getDistance_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public getDistance_result getResult(I iface, getDistance_args args) throws org.apache.thrift.TException { getDistance_result result = new getDistance_result(); try { result.success = iface.getDistance(args.obj1, args.obj2); result.setSuccessIsSet(true); } catch (QueryException err) { result.err = err; } return result; } } } public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); public AsyncProcessor(I iface) { super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>())); } protected AsyncProcessor(I iface, java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { super(iface, getProcessMap(processMap)); } private static <I extends AsyncIface> java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { processMap.put("setQueryTimeParams", new setQueryTimeParams()); processMap.put("knnQuery", new knnQuery()); processMap.put("rangeQuery", new rangeQuery()); processMap.put("getDistance", new getDistance()); return processMap; } public static class setQueryTimeParams<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setQueryTimeParams_args, Void> { public setQueryTimeParams() { super("setQueryTimeParams"); } public setQueryTimeParams_args getEmptyArgsInstance() { return new setQueryTimeParams_args(); } public org.apache.thrift.async.AsyncMethodCallback<Void> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<Void>() { public void onComplete(Void o) { setQueryTimeParams_result result = new setQueryTimeParams_result(); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; setQueryTimeParams_result result = new setQueryTimeParams_result(); if (e instanceof QueryException) { result.err = (QueryException) e; result.setErrIsSet(true); msg = result; } else if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, setQueryTimeParams_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException { iface.setQueryTimeParams(args.queryTimeParams,resultHandler); } } public static class knnQuery<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, knnQuery_args, java.util.List<ReplyEntry>> { public knnQuery() { super("knnQuery"); } public knnQuery_args getEmptyArgsInstance() { return new knnQuery_args(); } public org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>>() { public void onComplete(java.util.List<ReplyEntry> o) { knnQuery_result result = new knnQuery_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; knnQuery_result result = new knnQuery_result(); if (e instanceof QueryException) { result.err = (QueryException) e; result.setErrIsSet(true); msg = result; } else if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, knnQuery_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException { iface.knnQuery(args.k, args.queryObj, args.retExternId, args.retObj,resultHandler); } } public static class rangeQuery<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, rangeQuery_args, java.util.List<ReplyEntry>> { public rangeQuery() { super("rangeQuery"); } public rangeQuery_args getEmptyArgsInstance() { return new rangeQuery_args(); } public org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>>() { public void onComplete(java.util.List<ReplyEntry> o) { rangeQuery_result result = new rangeQuery_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; rangeQuery_result result = new rangeQuery_result(); if (e instanceof QueryException) { result.err = (QueryException) e; result.setErrIsSet(true); msg = result; } else if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, rangeQuery_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<ReplyEntry>> resultHandler) throws org.apache.thrift.TException { iface.rangeQuery(args.r, args.queryObj, args.retExternId, args.retObj,resultHandler); } } public static class getDistance<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getDistance_args, java.lang.Double> { public getDistance() { super("getDistance"); } public getDistance_args getEmptyArgsInstance() { return new getDistance_args(); } public org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Double>() { public void onComplete(java.lang.Double o) { getDistance_result result = new getDistance_result(); result.success = o; result.setSuccessIsSet(true); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getDistance_result result = new getDistance_result(); if (e instanceof QueryException) { result.err = (QueryException) e; result.setErrIsSet(true); msg = result; } else if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getDistance_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Double> resultHandler) throws org.apache.thrift.TException { iface.getDistance(args.obj1, args.obj2,resultHandler); } } } public static class setQueryTimeParams_args implements org.apache.thrift.TBase<setQueryTimeParams_args, setQueryTimeParams_args._Fields>, java.io.Serializable, Cloneable, Comparable<setQueryTimeParams_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setQueryTimeParams_args"); private static final org.apache.thrift.protocol.TField QUERY_TIME_PARAMS_FIELD_DESC = new org.apache.thrift.protocol.TField("queryTimeParams", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setQueryTimeParams_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setQueryTimeParams_argsTupleSchemeFactory(); public java.lang.String queryTimeParams; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { QUERY_TIME_PARAMS((short)1, "queryTimeParams"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // QUERY_TIME_PARAMS return QUERY_TIME_PARAMS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.QUERY_TIME_PARAMS, new org.apache.thrift.meta_data.FieldMetaData("queryTimeParams", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setQueryTimeParams_args.class, metaDataMap); } public setQueryTimeParams_args() { } public setQueryTimeParams_args( java.lang.String queryTimeParams) { this(); this.queryTimeParams = queryTimeParams; } /** * Performs a deep copy on <i>other</i>. */ public setQueryTimeParams_args(setQueryTimeParams_args other) { if (other.isSetQueryTimeParams()) { this.queryTimeParams = other.queryTimeParams; } } public setQueryTimeParams_args deepCopy() { return new setQueryTimeParams_args(this); } @Override public void clear() { this.queryTimeParams = null; } public java.lang.String getQueryTimeParams() { return this.queryTimeParams; } public setQueryTimeParams_args setQueryTimeParams(java.lang.String queryTimeParams) { this.queryTimeParams = queryTimeParams; return this; } public void unsetQueryTimeParams() { this.queryTimeParams = null; } /** Returns true if field queryTimeParams is set (has been assigned a value) and false otherwise */ public boolean isSetQueryTimeParams() { return this.queryTimeParams != null; } public void setQueryTimeParamsIsSet(boolean value) { if (!value) { this.queryTimeParams = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case QUERY_TIME_PARAMS: if (value == null) { unsetQueryTimeParams(); } else { setQueryTimeParams((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case QUERY_TIME_PARAMS: return getQueryTimeParams(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case QUERY_TIME_PARAMS: return isSetQueryTimeParams(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof setQueryTimeParams_args) return this.equals((setQueryTimeParams_args)that); return false; } public boolean equals(setQueryTimeParams_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_queryTimeParams = true && this.isSetQueryTimeParams(); boolean that_present_queryTimeParams = true && that.isSetQueryTimeParams(); if (this_present_queryTimeParams || that_present_queryTimeParams) { if (!(this_present_queryTimeParams && that_present_queryTimeParams)) return false; if (!this.queryTimeParams.equals(that.queryTimeParams)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetQueryTimeParams()) ? 131071 : 524287); if (isSetQueryTimeParams()) hashCode = hashCode * 8191 + queryTimeParams.hashCode(); return hashCode; } @Override public int compareTo(setQueryTimeParams_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetQueryTimeParams()).compareTo(other.isSetQueryTimeParams()); if (lastComparison != 0) { return lastComparison; } if (isSetQueryTimeParams()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryTimeParams, other.queryTimeParams); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("setQueryTimeParams_args("); boolean first = true; sb.append("queryTimeParams:"); if (this.queryTimeParams == null) { sb.append("null"); } else { sb.append(this.queryTimeParams); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (queryTimeParams == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryTimeParams' was not present! Struct: " + toString()); } // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class setQueryTimeParams_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public setQueryTimeParams_argsStandardScheme getScheme() { return new setQueryTimeParams_argsStandardScheme(); } } private static class setQueryTimeParams_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<setQueryTimeParams_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, setQueryTimeParams_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // QUERY_TIME_PARAMS if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.queryTimeParams = iprot.readString(); struct.setQueryTimeParamsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, setQueryTimeParams_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.queryTimeParams != null) { oprot.writeFieldBegin(QUERY_TIME_PARAMS_FIELD_DESC); oprot.writeString(struct.queryTimeParams); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class setQueryTimeParams_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public setQueryTimeParams_argsTupleScheme getScheme() { return new setQueryTimeParams_argsTupleScheme(); } } private static class setQueryTimeParams_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<setQueryTimeParams_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; oprot.writeString(struct.queryTimeParams); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; struct.queryTimeParams = iprot.readString(); struct.setQueryTimeParamsIsSet(true); } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class setQueryTimeParams_result implements org.apache.thrift.TBase<setQueryTimeParams_result, setQueryTimeParams_result._Fields>, java.io.Serializable, Cloneable, Comparable<setQueryTimeParams_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setQueryTimeParams_result"); private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setQueryTimeParams_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setQueryTimeParams_resultTupleSchemeFactory(); public QueryException err; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ERR((short)1, "err"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ERR return ERR; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setQueryTimeParams_result.class, metaDataMap); } public setQueryTimeParams_result() { } public setQueryTimeParams_result( QueryException err) { this(); this.err = err; } /** * Performs a deep copy on <i>other</i>. */ public setQueryTimeParams_result(setQueryTimeParams_result other) { if (other.isSetErr()) { this.err = new QueryException(other.err); } } public setQueryTimeParams_result deepCopy() { return new setQueryTimeParams_result(this); } @Override public void clear() { this.err = null; } public QueryException getErr() { return this.err; } public setQueryTimeParams_result setErr(QueryException err) { this.err = err; return this; } public void unsetErr() { this.err = null; } /** Returns true if field err is set (has been assigned a value) and false otherwise */ public boolean isSetErr() { return this.err != null; } public void setErrIsSet(boolean value) { if (!value) { this.err = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ERR: if (value == null) { unsetErr(); } else { setErr((QueryException)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ERR: return getErr(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ERR: return isSetErr(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof setQueryTimeParams_result) return this.equals((setQueryTimeParams_result)that); return false; } public boolean equals(setQueryTimeParams_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_err = true && this.isSetErr(); boolean that_present_err = true && that.isSetErr(); if (this_present_err || that_present_err) { if (!(this_present_err && that_present_err)) return false; if (!this.err.equals(that.err)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287); if (isSetErr()) hashCode = hashCode * 8191 + err.hashCode(); return hashCode; } @Override public int compareTo(setQueryTimeParams_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr()); if (lastComparison != 0) { return lastComparison; } if (isSetErr()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("setQueryTimeParams_result("); boolean first = true; sb.append("err:"); if (this.err == null) { sb.append("null"); } else { sb.append(this.err); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class setQueryTimeParams_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public setQueryTimeParams_resultStandardScheme getScheme() { return new setQueryTimeParams_resultStandardScheme(); } } private static class setQueryTimeParams_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<setQueryTimeParams_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, setQueryTimeParams_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ERR if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, setQueryTimeParams_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.err != null) { oprot.writeFieldBegin(ERR_FIELD_DESC); struct.err.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class setQueryTimeParams_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public setQueryTimeParams_resultTupleScheme getScheme() { return new setQueryTimeParams_resultTupleScheme(); } } private static class setQueryTimeParams_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<setQueryTimeParams_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetErr()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetErr()) { struct.err.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, setQueryTimeParams_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class knnQuery_args implements org.apache.thrift.TBase<knnQuery_args, knnQuery_args._Fields>, java.io.Serializable, Cloneable, Comparable<knnQuery_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQuery_args"); private static final org.apache.thrift.protocol.TField K_FIELD_DESC = new org.apache.thrift.protocol.TField("k", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField QUERY_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("queryObj", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField RET_EXTERN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("retExternId", org.apache.thrift.protocol.TType.BOOL, (short)3); private static final org.apache.thrift.protocol.TField RET_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("retObj", org.apache.thrift.protocol.TType.BOOL, (short)4); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQuery_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQuery_argsTupleSchemeFactory(); public int k; // required public java.nio.ByteBuffer queryObj; // required public boolean retExternId; // required public boolean retObj; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { K((short)1, "k"), QUERY_OBJ((short)2, "queryObj"), RET_EXTERN_ID((short)3, "retExternId"), RET_OBJ((short)4, "retObj"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // K return K; case 2: // QUERY_OBJ return QUERY_OBJ; case 3: // RET_EXTERN_ID return RET_EXTERN_ID; case 4: // RET_OBJ return RET_OBJ; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __K_ISSET_ID = 0; private static final int __RETEXTERNID_ISSET_ID = 1; private static final int __RETOBJ_ISSET_ID = 2; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.K, new org.apache.thrift.meta_data.FieldMetaData("k", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.QUERY_OBJ, new org.apache.thrift.meta_data.FieldMetaData("queryObj", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.RET_EXTERN_ID, new org.apache.thrift.meta_data.FieldMetaData("retExternId", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.RET_OBJ, new org.apache.thrift.meta_data.FieldMetaData("retObj", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQuery_args.class, metaDataMap); } public knnQuery_args() { } public knnQuery_args( int k, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) { this(); this.k = k; setKIsSet(true); this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj); this.retExternId = retExternId; setRetExternIdIsSet(true); this.retObj = retObj; setRetObjIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public knnQuery_args(knnQuery_args other) { __isset_bitfield = other.__isset_bitfield; this.k = other.k; if (other.isSetQueryObj()) { this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(other.queryObj); } this.retExternId = other.retExternId; this.retObj = other.retObj; } public knnQuery_args deepCopy() { return new knnQuery_args(this); } @Override public void clear() { setKIsSet(false); this.k = 0; this.queryObj = null; setRetExternIdIsSet(false); this.retExternId = false; setRetObjIsSet(false); this.retObj = false; } public int getK() { return this.k; } public knnQuery_args setK(int k) { this.k = k; setKIsSet(true); return this; } public void unsetK() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __K_ISSET_ID); } /** Returns true if field k is set (has been assigned a value) and false otherwise */ public boolean isSetK() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __K_ISSET_ID); } public void setKIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __K_ISSET_ID, value); } public byte[] getQueryObj() { setQueryObj(org.apache.thrift.TBaseHelper.rightSize(queryObj)); return queryObj == null ? null : queryObj.array(); } public java.nio.ByteBuffer bufferForQueryObj() { return org.apache.thrift.TBaseHelper.copyBinary(queryObj); } public knnQuery_args setQueryObj(byte[] queryObj) { this.queryObj = queryObj == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(queryObj.clone()); return this; } public knnQuery_args setQueryObj(java.nio.ByteBuffer queryObj) { this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj); return this; } public void unsetQueryObj() { this.queryObj = null; } /** Returns true if field queryObj is set (has been assigned a value) and false otherwise */ public boolean isSetQueryObj() { return this.queryObj != null; } public void setQueryObjIsSet(boolean value) { if (!value) { this.queryObj = null; } } public boolean isRetExternId() { return this.retExternId; } public knnQuery_args setRetExternId(boolean retExternId) { this.retExternId = retExternId; setRetExternIdIsSet(true); return this; } public void unsetRetExternId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETEXTERNID_ISSET_ID); } /** Returns true if field retExternId is set (has been assigned a value) and false otherwise */ public boolean isSetRetExternId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETEXTERNID_ISSET_ID); } public void setRetExternIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETEXTERNID_ISSET_ID, value); } public boolean isRetObj() { return this.retObj; } public knnQuery_args setRetObj(boolean retObj) { this.retObj = retObj; setRetObjIsSet(true); return this; } public void unsetRetObj() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETOBJ_ISSET_ID); } /** Returns true if field retObj is set (has been assigned a value) and false otherwise */ public boolean isSetRetObj() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETOBJ_ISSET_ID); } public void setRetObjIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETOBJ_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case K: if (value == null) { unsetK(); } else { setK((java.lang.Integer)value); } break; case QUERY_OBJ: if (value == null) { unsetQueryObj(); } else { if (value instanceof byte[]) { setQueryObj((byte[])value); } else { setQueryObj((java.nio.ByteBuffer)value); } } break; case RET_EXTERN_ID: if (value == null) { unsetRetExternId(); } else { setRetExternId((java.lang.Boolean)value); } break; case RET_OBJ: if (value == null) { unsetRetObj(); } else { setRetObj((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case K: return getK(); case QUERY_OBJ: return getQueryObj(); case RET_EXTERN_ID: return isRetExternId(); case RET_OBJ: return isRetObj(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case K: return isSetK(); case QUERY_OBJ: return isSetQueryObj(); case RET_EXTERN_ID: return isSetRetExternId(); case RET_OBJ: return isSetRetObj(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof knnQuery_args) return this.equals((knnQuery_args)that); return false; } public boolean equals(knnQuery_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_k = true; boolean that_present_k = true; if (this_present_k || that_present_k) { if (!(this_present_k && that_present_k)) return false; if (this.k != that.k) return false; } boolean this_present_queryObj = true && this.isSetQueryObj(); boolean that_present_queryObj = true && that.isSetQueryObj(); if (this_present_queryObj || that_present_queryObj) { if (!(this_present_queryObj && that_present_queryObj)) return false; if (!this.queryObj.equals(that.queryObj)) return false; } boolean this_present_retExternId = true; boolean that_present_retExternId = true; if (this_present_retExternId || that_present_retExternId) { if (!(this_present_retExternId && that_present_retExternId)) return false; if (this.retExternId != that.retExternId) return false; } boolean this_present_retObj = true; boolean that_present_retObj = true; if (this_present_retObj || that_present_retObj) { if (!(this_present_retObj && that_present_retObj)) return false; if (this.retObj != that.retObj) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + k; hashCode = hashCode * 8191 + ((isSetQueryObj()) ? 131071 : 524287); if (isSetQueryObj()) hashCode = hashCode * 8191 + queryObj.hashCode(); hashCode = hashCode * 8191 + ((retExternId) ? 131071 : 524287); hashCode = hashCode * 8191 + ((retObj) ? 131071 : 524287); return hashCode; } @Override public int compareTo(knnQuery_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetK()).compareTo(other.isSetK()); if (lastComparison != 0) { return lastComparison; } if (isSetK()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.k, other.k); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetQueryObj()).compareTo(other.isSetQueryObj()); if (lastComparison != 0) { return lastComparison; } if (isSetQueryObj()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryObj, other.queryObj); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetRetExternId()).compareTo(other.isSetRetExternId()); if (lastComparison != 0) { return lastComparison; } if (isSetRetExternId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retExternId, other.retExternId); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetRetObj()).compareTo(other.isSetRetObj()); if (lastComparison != 0) { return lastComparison; } if (isSetRetObj()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retObj, other.retObj); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQuery_args("); boolean first = true; sb.append("k:"); sb.append(this.k); first = false; if (!first) sb.append(", "); sb.append("queryObj:"); if (this.queryObj == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.queryObj, sb); } first = false; if (!first) sb.append(", "); sb.append("retExternId:"); sb.append(this.retExternId); first = false; if (!first) sb.append(", "); sb.append("retObj:"); sb.append(this.retObj); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // alas, we cannot check 'k' because it's a primitive and you chose the non-beans generator. if (queryObj == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryObj' was not present! Struct: " + toString()); } // alas, we cannot check 'retExternId' because it's a primitive and you chose the non-beans generator. // alas, we cannot check 'retObj' because it's a primitive and you chose the non-beans generator. // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class knnQuery_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public knnQuery_argsStandardScheme getScheme() { return new knnQuery_argsStandardScheme(); } } private static class knnQuery_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQuery_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, knnQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // K if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.k = iprot.readI32(); struct.setKIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // QUERY_OBJ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.queryObj = iprot.readBinary(); struct.setQueryObjIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // RET_EXTERN_ID if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.retExternId = iprot.readBool(); struct.setRetExternIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // RET_OBJ if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.retObj = iprot.readBool(); struct.setRetObjIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method if (!struct.isSetK()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'k' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetRetExternId()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'retExternId' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetRetObj()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'retObj' was not found in serialized data! Struct: " + toString()); } struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, knnQuery_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(K_FIELD_DESC); oprot.writeI32(struct.k); oprot.writeFieldEnd(); if (struct.queryObj != null) { oprot.writeFieldBegin(QUERY_OBJ_FIELD_DESC); oprot.writeBinary(struct.queryObj); oprot.writeFieldEnd(); } oprot.writeFieldBegin(RET_EXTERN_ID_FIELD_DESC); oprot.writeBool(struct.retExternId); oprot.writeFieldEnd(); oprot.writeFieldBegin(RET_OBJ_FIELD_DESC); oprot.writeBool(struct.retObj); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class knnQuery_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public knnQuery_argsTupleScheme getScheme() { return new knnQuery_argsTupleScheme(); } } private static class knnQuery_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQuery_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, knnQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; oprot.writeI32(struct.k); oprot.writeBinary(struct.queryObj); oprot.writeBool(struct.retExternId); oprot.writeBool(struct.retObj); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, knnQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; struct.k = iprot.readI32(); struct.setKIsSet(true); struct.queryObj = iprot.readBinary(); struct.setQueryObjIsSet(true); struct.retExternId = iprot.readBool(); struct.setRetExternIdIsSet(true); struct.retObj = iprot.readBool(); struct.setRetObjIsSet(true); } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class knnQuery_result implements org.apache.thrift.TBase<knnQuery_result, knnQuery_result._Fields>, java.io.Serializable, Cloneable, Comparable<knnQuery_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("knnQuery_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new knnQuery_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new knnQuery_resultTupleSchemeFactory(); public java.util.List<ReplyEntry> success; // required public QueryException err; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"), ERR((short)1, "err"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; case 1: // ERR return ERR; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST , "ReplyEntryList"))); tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(knnQuery_result.class, metaDataMap); } public knnQuery_result() { } public knnQuery_result( java.util.List<ReplyEntry> success, QueryException err) { this(); this.success = success; this.err = err; } /** * Performs a deep copy on <i>other</i>. */ public knnQuery_result(knnQuery_result other) { if (other.isSetSuccess()) { java.util.List<ReplyEntry> __this__success = new java.util.ArrayList<ReplyEntry>(other.success.size()); for (ReplyEntry other_element : other.success) { __this__success.add(new ReplyEntry(other_element)); } this.success = __this__success; } if (other.isSetErr()) { this.err = new QueryException(other.err); } } public knnQuery_result deepCopy() { return new knnQuery_result(this); } @Override public void clear() { this.success = null; this.err = null; } public int getSuccessSize() { return (this.success == null) ? 0 : this.success.size(); } public java.util.Iterator<ReplyEntry> getSuccessIterator() { return (this.success == null) ? null : this.success.iterator(); } public void addToSuccess(ReplyEntry elem) { if (this.success == null) { this.success = new java.util.ArrayList<ReplyEntry>(); } this.success.add(elem); } public java.util.List<ReplyEntry> getSuccess() { return this.success; } public knnQuery_result setSuccess(java.util.List<ReplyEntry> success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public QueryException getErr() { return this.err; } public knnQuery_result setErr(QueryException err) { this.err = err; return this; } public void unsetErr() { this.err = null; } /** Returns true if field err is set (has been assigned a value) and false otherwise */ public boolean isSetErr() { return this.err != null; } public void setErrIsSet(boolean value) { if (!value) { this.err = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.util.List<ReplyEntry>)value); } break; case ERR: if (value == null) { unsetErr(); } else { setErr((QueryException)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); case ERR: return getErr(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); case ERR: return isSetErr(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof knnQuery_result) return this.equals((knnQuery_result)that); return false; } public boolean equals(knnQuery_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } boolean this_present_err = true && this.isSetErr(); boolean that_present_err = true && that.isSetErr(); if (this_present_err || that_present_err) { if (!(this_present_err && that_present_err)) return false; if (!this.err.equals(that.err)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287); if (isSetErr()) hashCode = hashCode * 8191 + err.hashCode(); return hashCode; } @Override public int compareTo(knnQuery_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr()); if (lastComparison != 0) { return lastComparison; } if (isSetErr()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("knnQuery_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; if (!first) sb.append(", "); sb.append("err:"); if (this.err == null) { sb.append("null"); } else { sb.append(this.err); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class knnQuery_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public knnQuery_resultStandardScheme getScheme() { return new knnQuery_resultStandardScheme(); } } private static class knnQuery_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<knnQuery_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, knnQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); struct.success = new java.util.ArrayList<ReplyEntry>(_list0.size); ReplyEntry _elem1; for (int _i2 = 0; _i2 < _list0.size; ++_i2) { _elem1 = new ReplyEntry(); _elem1.read(iprot); struct.success.add(_elem1); } iprot.readListEnd(); } struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 1: // ERR if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, knnQuery_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); for (ReplyEntry _iter3 : struct.success) { _iter3.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if (struct.err != null) { oprot.writeFieldBegin(ERR_FIELD_DESC); struct.err.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class knnQuery_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public knnQuery_resultTupleScheme getScheme() { return new knnQuery_resultTupleScheme(); } } private static class knnQuery_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<knnQuery_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, knnQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } if (struct.isSetErr()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); for (ReplyEntry _iter4 : struct.success) { _iter4.write(oprot); } } } if (struct.isSetErr()) { struct.err.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, knnQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.success = new java.util.ArrayList<ReplyEntry>(_list5.size); ReplyEntry _elem6; for (int _i7 = 0; _i7 < _list5.size; ++_i7) { _elem6 = new ReplyEntry(); _elem6.read(iprot); struct.success.add(_elem6); } } struct.setSuccessIsSet(true); } if (incoming.get(1)) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class rangeQuery_args implements org.apache.thrift.TBase<rangeQuery_args, rangeQuery_args._Fields>, java.io.Serializable, Cloneable, Comparable<rangeQuery_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rangeQuery_args"); private static final org.apache.thrift.protocol.TField R_FIELD_DESC = new org.apache.thrift.protocol.TField("r", org.apache.thrift.protocol.TType.DOUBLE, (short)1); private static final org.apache.thrift.protocol.TField QUERY_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("queryObj", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField RET_EXTERN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("retExternId", org.apache.thrift.protocol.TType.BOOL, (short)3); private static final org.apache.thrift.protocol.TField RET_OBJ_FIELD_DESC = new org.apache.thrift.protocol.TField("retObj", org.apache.thrift.protocol.TType.BOOL, (short)4); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new rangeQuery_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new rangeQuery_argsTupleSchemeFactory(); public double r; // required public java.nio.ByteBuffer queryObj; // required public boolean retExternId; // required public boolean retObj; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { R((short)1, "r"), QUERY_OBJ((short)2, "queryObj"), RET_EXTERN_ID((short)3, "retExternId"), RET_OBJ((short)4, "retObj"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // R return R; case 2: // QUERY_OBJ return QUERY_OBJ; case 3: // RET_EXTERN_ID return RET_EXTERN_ID; case 4: // RET_OBJ return RET_OBJ; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __R_ISSET_ID = 0; private static final int __RETEXTERNID_ISSET_ID = 1; private static final int __RETOBJ_ISSET_ID = 2; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.R, new org.apache.thrift.meta_data.FieldMetaData("r", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); tmpMap.put(_Fields.QUERY_OBJ, new org.apache.thrift.meta_data.FieldMetaData("queryObj", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.RET_EXTERN_ID, new org.apache.thrift.meta_data.FieldMetaData("retExternId", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.RET_OBJ, new org.apache.thrift.meta_data.FieldMetaData("retObj", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rangeQuery_args.class, metaDataMap); } public rangeQuery_args() { } public rangeQuery_args( double r, java.nio.ByteBuffer queryObj, boolean retExternId, boolean retObj) { this(); this.r = r; setRIsSet(true); this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj); this.retExternId = retExternId; setRetExternIdIsSet(true); this.retObj = retObj; setRetObjIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public rangeQuery_args(rangeQuery_args other) { __isset_bitfield = other.__isset_bitfield; this.r = other.r; if (other.isSetQueryObj()) { this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(other.queryObj); } this.retExternId = other.retExternId; this.retObj = other.retObj; } public rangeQuery_args deepCopy() { return new rangeQuery_args(this); } @Override public void clear() { setRIsSet(false); this.r = 0.0; this.queryObj = null; setRetExternIdIsSet(false); this.retExternId = false; setRetObjIsSet(false); this.retObj = false; } public double getR() { return this.r; } public rangeQuery_args setR(double r) { this.r = r; setRIsSet(true); return this; } public void unsetR() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __R_ISSET_ID); } /** Returns true if field r is set (has been assigned a value) and false otherwise */ public boolean isSetR() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __R_ISSET_ID); } public void setRIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __R_ISSET_ID, value); } public byte[] getQueryObj() { setQueryObj(org.apache.thrift.TBaseHelper.rightSize(queryObj)); return queryObj == null ? null : queryObj.array(); } public java.nio.ByteBuffer bufferForQueryObj() { return org.apache.thrift.TBaseHelper.copyBinary(queryObj); } public rangeQuery_args setQueryObj(byte[] queryObj) { this.queryObj = queryObj == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(queryObj.clone()); return this; } public rangeQuery_args setQueryObj(java.nio.ByteBuffer queryObj) { this.queryObj = org.apache.thrift.TBaseHelper.copyBinary(queryObj); return this; } public void unsetQueryObj() { this.queryObj = null; } /** Returns true if field queryObj is set (has been assigned a value) and false otherwise */ public boolean isSetQueryObj() { return this.queryObj != null; } public void setQueryObjIsSet(boolean value) { if (!value) { this.queryObj = null; } } public boolean isRetExternId() { return this.retExternId; } public rangeQuery_args setRetExternId(boolean retExternId) { this.retExternId = retExternId; setRetExternIdIsSet(true); return this; } public void unsetRetExternId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETEXTERNID_ISSET_ID); } /** Returns true if field retExternId is set (has been assigned a value) and false otherwise */ public boolean isSetRetExternId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETEXTERNID_ISSET_ID); } public void setRetExternIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETEXTERNID_ISSET_ID, value); } public boolean isRetObj() { return this.retObj; } public rangeQuery_args setRetObj(boolean retObj) { this.retObj = retObj; setRetObjIsSet(true); return this; } public void unsetRetObj() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __RETOBJ_ISSET_ID); } /** Returns true if field retObj is set (has been assigned a value) and false otherwise */ public boolean isSetRetObj() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __RETOBJ_ISSET_ID); } public void setRetObjIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __RETOBJ_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case R: if (value == null) { unsetR(); } else { setR((java.lang.Double)value); } break; case QUERY_OBJ: if (value == null) { unsetQueryObj(); } else { if (value instanceof byte[]) { setQueryObj((byte[])value); } else { setQueryObj((java.nio.ByteBuffer)value); } } break; case RET_EXTERN_ID: if (value == null) { unsetRetExternId(); } else { setRetExternId((java.lang.Boolean)value); } break; case RET_OBJ: if (value == null) { unsetRetObj(); } else { setRetObj((java.lang.Boolean)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case R: return getR(); case QUERY_OBJ: return getQueryObj(); case RET_EXTERN_ID: return isRetExternId(); case RET_OBJ: return isRetObj(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case R: return isSetR(); case QUERY_OBJ: return isSetQueryObj(); case RET_EXTERN_ID: return isSetRetExternId(); case RET_OBJ: return isSetRetObj(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof rangeQuery_args) return this.equals((rangeQuery_args)that); return false; } public boolean equals(rangeQuery_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_r = true; boolean that_present_r = true; if (this_present_r || that_present_r) { if (!(this_present_r && that_present_r)) return false; if (this.r != that.r) return false; } boolean this_present_queryObj = true && this.isSetQueryObj(); boolean that_present_queryObj = true && that.isSetQueryObj(); if (this_present_queryObj || that_present_queryObj) { if (!(this_present_queryObj && that_present_queryObj)) return false; if (!this.queryObj.equals(that.queryObj)) return false; } boolean this_present_retExternId = true; boolean that_present_retExternId = true; if (this_present_retExternId || that_present_retExternId) { if (!(this_present_retExternId && that_present_retExternId)) return false; if (this.retExternId != that.retExternId) return false; } boolean this_present_retObj = true; boolean that_present_retObj = true; if (this_present_retObj || that_present_retObj) { if (!(this_present_retObj && that_present_retObj)) return false; if (this.retObj != that.retObj) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(r); hashCode = hashCode * 8191 + ((isSetQueryObj()) ? 131071 : 524287); if (isSetQueryObj()) hashCode = hashCode * 8191 + queryObj.hashCode(); hashCode = hashCode * 8191 + ((retExternId) ? 131071 : 524287); hashCode = hashCode * 8191 + ((retObj) ? 131071 : 524287); return hashCode; } @Override public int compareTo(rangeQuery_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetR()).compareTo(other.isSetR()); if (lastComparison != 0) { return lastComparison; } if (isSetR()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.r, other.r); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetQueryObj()).compareTo(other.isSetQueryObj()); if (lastComparison != 0) { return lastComparison; } if (isSetQueryObj()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryObj, other.queryObj); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetRetExternId()).compareTo(other.isSetRetExternId()); if (lastComparison != 0) { return lastComparison; } if (isSetRetExternId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retExternId, other.retExternId); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetRetObj()).compareTo(other.isSetRetObj()); if (lastComparison != 0) { return lastComparison; } if (isSetRetObj()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.retObj, other.retObj); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("rangeQuery_args("); boolean first = true; sb.append("r:"); sb.append(this.r); first = false; if (!first) sb.append(", "); sb.append("queryObj:"); if (this.queryObj == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.queryObj, sb); } first = false; if (!first) sb.append(", "); sb.append("retExternId:"); sb.append(this.retExternId); first = false; if (!first) sb.append(", "); sb.append("retObj:"); sb.append(this.retObj); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // alas, we cannot check 'r' because it's a primitive and you chose the non-beans generator. if (queryObj == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'queryObj' was not present! Struct: " + toString()); } // alas, we cannot check 'retExternId' because it's a primitive and you chose the non-beans generator. // alas, we cannot check 'retObj' because it's a primitive and you chose the non-beans generator. // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class rangeQuery_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public rangeQuery_argsStandardScheme getScheme() { return new rangeQuery_argsStandardScheme(); } } private static class rangeQuery_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<rangeQuery_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, rangeQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // R if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.r = iprot.readDouble(); struct.setRIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // QUERY_OBJ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.queryObj = iprot.readBinary(); struct.setQueryObjIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // RET_EXTERN_ID if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.retExternId = iprot.readBool(); struct.setRetExternIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // RET_OBJ if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.retObj = iprot.readBool(); struct.setRetObjIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method if (!struct.isSetR()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'r' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetRetExternId()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'retExternId' was not found in serialized data! Struct: " + toString()); } if (!struct.isSetRetObj()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'retObj' was not found in serialized data! Struct: " + toString()); } struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, rangeQuery_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(R_FIELD_DESC); oprot.writeDouble(struct.r); oprot.writeFieldEnd(); if (struct.queryObj != null) { oprot.writeFieldBegin(QUERY_OBJ_FIELD_DESC); oprot.writeBinary(struct.queryObj); oprot.writeFieldEnd(); } oprot.writeFieldBegin(RET_EXTERN_ID_FIELD_DESC); oprot.writeBool(struct.retExternId); oprot.writeFieldEnd(); oprot.writeFieldBegin(RET_OBJ_FIELD_DESC); oprot.writeBool(struct.retObj); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class rangeQuery_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public rangeQuery_argsTupleScheme getScheme() { return new rangeQuery_argsTupleScheme(); } } private static class rangeQuery_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<rangeQuery_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, rangeQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; oprot.writeDouble(struct.r); oprot.writeBinary(struct.queryObj); oprot.writeBool(struct.retExternId); oprot.writeBool(struct.retObj); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, rangeQuery_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; struct.r = iprot.readDouble(); struct.setRIsSet(true); struct.queryObj = iprot.readBinary(); struct.setQueryObjIsSet(true); struct.retExternId = iprot.readBool(); struct.setRetExternIdIsSet(true); struct.retObj = iprot.readBool(); struct.setRetObjIsSet(true); } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class rangeQuery_result implements org.apache.thrift.TBase<rangeQuery_result, rangeQuery_result._Fields>, java.io.Serializable, Cloneable, Comparable<rangeQuery_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("rangeQuery_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new rangeQuery_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new rangeQuery_resultTupleSchemeFactory(); public java.util.List<ReplyEntry> success; // required public QueryException err; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"), ERR((short)1, "err"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; case 1: // ERR return ERR; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.LIST , "ReplyEntryList"))); tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(rangeQuery_result.class, metaDataMap); } public rangeQuery_result() { } public rangeQuery_result( java.util.List<ReplyEntry> success, QueryException err) { this(); this.success = success; this.err = err; } /** * Performs a deep copy on <i>other</i>. */ public rangeQuery_result(rangeQuery_result other) { if (other.isSetSuccess()) { java.util.List<ReplyEntry> __this__success = new java.util.ArrayList<ReplyEntry>(other.success.size()); for (ReplyEntry other_element : other.success) { __this__success.add(new ReplyEntry(other_element)); } this.success = __this__success; } if (other.isSetErr()) { this.err = new QueryException(other.err); } } public rangeQuery_result deepCopy() { return new rangeQuery_result(this); } @Override public void clear() { this.success = null; this.err = null; } public int getSuccessSize() { return (this.success == null) ? 0 : this.success.size(); } public java.util.Iterator<ReplyEntry> getSuccessIterator() { return (this.success == null) ? null : this.success.iterator(); } public void addToSuccess(ReplyEntry elem) { if (this.success == null) { this.success = new java.util.ArrayList<ReplyEntry>(); } this.success.add(elem); } public java.util.List<ReplyEntry> getSuccess() { return this.success; } public rangeQuery_result setSuccess(java.util.List<ReplyEntry> success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public QueryException getErr() { return this.err; } public rangeQuery_result setErr(QueryException err) { this.err = err; return this; } public void unsetErr() { this.err = null; } /** Returns true if field err is set (has been assigned a value) and false otherwise */ public boolean isSetErr() { return this.err != null; } public void setErrIsSet(boolean value) { if (!value) { this.err = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.util.List<ReplyEntry>)value); } break; case ERR: if (value == null) { unsetErr(); } else { setErr((QueryException)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); case ERR: return getErr(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); case ERR: return isSetErr(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof rangeQuery_result) return this.equals((rangeQuery_result)that); return false; } public boolean equals(rangeQuery_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } boolean this_present_err = true && this.isSetErr(); boolean that_present_err = true && that.isSetErr(); if (this_present_err || that_present_err) { if (!(this_present_err && that_present_err)) return false; if (!this.err.equals(that.err)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287); if (isSetErr()) hashCode = hashCode * 8191 + err.hashCode(); return hashCode; } @Override public int compareTo(rangeQuery_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr()); if (lastComparison != 0) { return lastComparison; } if (isSetErr()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("rangeQuery_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; if (!first) sb.append(", "); sb.append("err:"); if (this.err == null) { sb.append("null"); } else { sb.append(this.err); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class rangeQuery_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public rangeQuery_resultStandardScheme getScheme() { return new rangeQuery_resultStandardScheme(); } } private static class rangeQuery_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<rangeQuery_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, rangeQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); struct.success = new java.util.ArrayList<ReplyEntry>(_list8.size); ReplyEntry _elem9; for (int _i10 = 0; _i10 < _list8.size; ++_i10) { _elem9 = new ReplyEntry(); _elem9.read(iprot); struct.success.add(_elem9); } iprot.readListEnd(); } struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 1: // ERR if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, rangeQuery_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.success.size())); for (ReplyEntry _iter11 : struct.success) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if (struct.err != null) { oprot.writeFieldBegin(ERR_FIELD_DESC); struct.err.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class rangeQuery_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public rangeQuery_resultTupleScheme getScheme() { return new rangeQuery_resultTupleScheme(); } } private static class rangeQuery_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<rangeQuery_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, rangeQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } if (struct.isSetErr()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetSuccess()) { { oprot.writeI32(struct.success.size()); for (ReplyEntry _iter12 : struct.success) { _iter12.write(oprot); } } } if (struct.isSetErr()) { struct.err.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, rangeQuery_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.success = new java.util.ArrayList<ReplyEntry>(_list13.size); ReplyEntry _elem14; for (int _i15 = 0; _i15 < _list13.size; ++_i15) { _elem14 = new ReplyEntry(); _elem14.read(iprot); struct.success.add(_elem14); } } struct.setSuccessIsSet(true); } if (incoming.get(1)) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getDistance_args implements org.apache.thrift.TBase<getDistance_args, getDistance_args._Fields>, java.io.Serializable, Cloneable, Comparable<getDistance_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getDistance_args"); private static final org.apache.thrift.protocol.TField OBJ1_FIELD_DESC = new org.apache.thrift.protocol.TField("obj1", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField OBJ2_FIELD_DESC = new org.apache.thrift.protocol.TField("obj2", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getDistance_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getDistance_argsTupleSchemeFactory(); public java.nio.ByteBuffer obj1; // required public java.nio.ByteBuffer obj2; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { OBJ1((short)1, "obj1"), OBJ2((short)2, "obj2"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // OBJ1 return OBJ1; case 2: // OBJ2 return OBJ2; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.OBJ1, new org.apache.thrift.meta_data.FieldMetaData("obj1", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.OBJ2, new org.apache.thrift.meta_data.FieldMetaData("obj2", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getDistance_args.class, metaDataMap); } public getDistance_args() { } public getDistance_args( java.nio.ByteBuffer obj1, java.nio.ByteBuffer obj2) { this(); this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(obj1); this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(obj2); } /** * Performs a deep copy on <i>other</i>. */ public getDistance_args(getDistance_args other) { if (other.isSetObj1()) { this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(other.obj1); } if (other.isSetObj2()) { this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(other.obj2); } } public getDistance_args deepCopy() { return new getDistance_args(this); } @Override public void clear() { this.obj1 = null; this.obj2 = null; } public byte[] getObj1() { setObj1(org.apache.thrift.TBaseHelper.rightSize(obj1)); return obj1 == null ? null : obj1.array(); } public java.nio.ByteBuffer bufferForObj1() { return org.apache.thrift.TBaseHelper.copyBinary(obj1); } public getDistance_args setObj1(byte[] obj1) { this.obj1 = obj1 == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(obj1.clone()); return this; } public getDistance_args setObj1(java.nio.ByteBuffer obj1) { this.obj1 = org.apache.thrift.TBaseHelper.copyBinary(obj1); return this; } public void unsetObj1() { this.obj1 = null; } /** Returns true if field obj1 is set (has been assigned a value) and false otherwise */ public boolean isSetObj1() { return this.obj1 != null; } public void setObj1IsSet(boolean value) { if (!value) { this.obj1 = null; } } public byte[] getObj2() { setObj2(org.apache.thrift.TBaseHelper.rightSize(obj2)); return obj2 == null ? null : obj2.array(); } public java.nio.ByteBuffer bufferForObj2() { return org.apache.thrift.TBaseHelper.copyBinary(obj2); } public getDistance_args setObj2(byte[] obj2) { this.obj2 = obj2 == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(obj2.clone()); return this; } public getDistance_args setObj2(java.nio.ByteBuffer obj2) { this.obj2 = org.apache.thrift.TBaseHelper.copyBinary(obj2); return this; } public void unsetObj2() { this.obj2 = null; } /** Returns true if field obj2 is set (has been assigned a value) and false otherwise */ public boolean isSetObj2() { return this.obj2 != null; } public void setObj2IsSet(boolean value) { if (!value) { this.obj2 = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case OBJ1: if (value == null) { unsetObj1(); } else { if (value instanceof byte[]) { setObj1((byte[])value); } else { setObj1((java.nio.ByteBuffer)value); } } break; case OBJ2: if (value == null) { unsetObj2(); } else { if (value instanceof byte[]) { setObj2((byte[])value); } else { setObj2((java.nio.ByteBuffer)value); } } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case OBJ1: return getObj1(); case OBJ2: return getObj2(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case OBJ1: return isSetObj1(); case OBJ2: return isSetObj2(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getDistance_args) return this.equals((getDistance_args)that); return false; } public boolean equals(getDistance_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_obj1 = true && this.isSetObj1(); boolean that_present_obj1 = true && that.isSetObj1(); if (this_present_obj1 || that_present_obj1) { if (!(this_present_obj1 && that_present_obj1)) return false; if (!this.obj1.equals(that.obj1)) return false; } boolean this_present_obj2 = true && this.isSetObj2(); boolean that_present_obj2 = true && that.isSetObj2(); if (this_present_obj2 || that_present_obj2) { if (!(this_present_obj2 && that_present_obj2)) return false; if (!this.obj2.equals(that.obj2)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetObj1()) ? 131071 : 524287); if (isSetObj1()) hashCode = hashCode * 8191 + obj1.hashCode(); hashCode = hashCode * 8191 + ((isSetObj2()) ? 131071 : 524287); if (isSetObj2()) hashCode = hashCode * 8191 + obj2.hashCode(); return hashCode; } @Override public int compareTo(getDistance_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetObj1()).compareTo(other.isSetObj1()); if (lastComparison != 0) { return lastComparison; } if (isSetObj1()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.obj1, other.obj1); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetObj2()).compareTo(other.isSetObj2()); if (lastComparison != 0) { return lastComparison; } if (isSetObj2()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.obj2, other.obj2); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getDistance_args("); boolean first = true; sb.append("obj1:"); if (this.obj1 == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.obj1, sb); } first = false; if (!first) sb.append(", "); sb.append("obj2:"); if (this.obj2 == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.obj2, sb); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if (obj1 == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'obj1' was not present! Struct: " + toString()); } if (obj2 == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'obj2' was not present! Struct: " + toString()); } // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getDistance_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getDistance_argsStandardScheme getScheme() { return new getDistance_argsStandardScheme(); } } private static class getDistance_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getDistance_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, getDistance_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // OBJ1 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.obj1 = iprot.readBinary(); struct.setObj1IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // OBJ2 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.obj2 = iprot.readBinary(); struct.setObj2IsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getDistance_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.obj1 != null) { oprot.writeFieldBegin(OBJ1_FIELD_DESC); oprot.writeBinary(struct.obj1); oprot.writeFieldEnd(); } if (struct.obj2 != null) { oprot.writeFieldBegin(OBJ2_FIELD_DESC); oprot.writeBinary(struct.obj2); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getDistance_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getDistance_argsTupleScheme getScheme() { return new getDistance_argsTupleScheme(); } } private static class getDistance_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getDistance_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getDistance_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; oprot.writeBinary(struct.obj1); oprot.writeBinary(struct.obj2); } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getDistance_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; struct.obj1 = iprot.readBinary(); struct.setObj1IsSet(true); struct.obj2 = iprot.readBinary(); struct.setObj2IsSet(true); } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getDistance_result implements org.apache.thrift.TBase<getDistance_result, getDistance_result._Fields>, java.io.Serializable, Cloneable, Comparable<getDistance_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getDistance_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.DOUBLE, (short)0); private static final org.apache.thrift.protocol.TField ERR_FIELD_DESC = new org.apache.thrift.protocol.TField("err", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getDistance_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getDistance_resultTupleSchemeFactory(); public double success; // required public QueryException err; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"), ERR((short)1, "err"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; case 1: // ERR return ERR; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __SUCCESS_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE))); tmpMap.put(_Fields.ERR, new org.apache.thrift.meta_data.FieldMetaData("err", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryException.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getDistance_result.class, metaDataMap); } public getDistance_result() { } public getDistance_result( double success, QueryException err) { this(); this.success = success; setSuccessIsSet(true); this.err = err; } /** * Performs a deep copy on <i>other</i>. */ public getDistance_result(getDistance_result other) { __isset_bitfield = other.__isset_bitfield; this.success = other.success; if (other.isSetErr()) { this.err = new QueryException(other.err); } } public getDistance_result deepCopy() { return new getDistance_result(this); } @Override public void clear() { setSuccessIsSet(false); this.success = 0.0; this.err = null; } public double getSuccess() { return this.success; } public getDistance_result setSuccess(double success) { this.success = success; setSuccessIsSet(true); return this; } public void unsetSuccess() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); } public void setSuccessIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); } public QueryException getErr() { return this.err; } public getDistance_result setErr(QueryException err) { this.err = err; return this; } public void unsetErr() { this.err = null; } /** Returns true if field err is set (has been assigned a value) and false otherwise */ public boolean isSetErr() { return this.err != null; } public void setErrIsSet(boolean value) { if (!value) { this.err = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((java.lang.Double)value); } break; case ERR: if (value == null) { unsetErr(); } else { setErr((QueryException)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); case ERR: return getErr(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); case ERR: return isSetErr(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getDistance_result) return this.equals((getDistance_result)that); return false; } public boolean equals(getDistance_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true; boolean that_present_success = true; if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (this.success != that.success) return false; } boolean this_present_err = true && this.isSetErr(); boolean that_present_err = true && that.isSetErr(); if (this_present_err || that_present_err) { if (!(this_present_err && that_present_err)) return false; if (!this.err.equals(that.err)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(success); hashCode = hashCode * 8191 + ((isSetErr()) ? 131071 : 524287); if (isSetErr()) hashCode = hashCode * 8191 + err.hashCode(); return hashCode; } @Override public int compareTo(getDistance_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetErr()).compareTo(other.isSetErr()); if (lastComparison != 0) { return lastComparison; } if (isSetErr()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.err, other.err); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getDistance_result("); boolean first = true; sb.append("success:"); sb.append(this.success); first = false; if (!first) sb.append(", "); sb.append("err:"); if (this.err == null) { sb.append("null"); } else { sb.append(this.err); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getDistance_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getDistance_resultStandardScheme getScheme() { return new getDistance_resultStandardScheme(); } } private static class getDistance_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getDistance_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, getDistance_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) { struct.success = iprot.readDouble(); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 1: // ERR if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getDistance_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); oprot.writeDouble(struct.success); oprot.writeFieldEnd(); } if (struct.err != null) { oprot.writeFieldBegin(ERR_FIELD_DESC); struct.err.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getDistance_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getDistance_resultTupleScheme getScheme() { return new getDistance_resultTupleScheme(); } } private static class getDistance_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getDistance_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getDistance_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } if (struct.isSetErr()) { optionals.set(1); } oprot.writeBitSet(optionals, 2); if (struct.isSetSuccess()) { oprot.writeDouble(struct.success); } if (struct.isSetErr()) { struct.err.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getDistance_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.success = iprot.readDouble(); struct.setSuccessIsSet(true); } if (incoming.get(1)) { struct.err = new QueryException(); struct.err.read(iprot); struct.setErrIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } }
36.609106
397
0.650623
0398e8749dd0e9641e4ff4bb0880c0a8530ee5fa
3,133
package com.example.springbootmysql.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.example.springbootmysql.annotation.Secure; import com.example.springbootmysql.model.Employee; import com.example.springbootmysql.service.EmployeeService; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; @RestController @RequestMapping("/employee") public class EmployeeController { @Autowired EmployeeService employeeService; @ApiOperation(value = "Get Emloyee details by Id") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully retrieved employee details") }) @GetMapping(value="/{id}",produces=MediaType.APPLICATION_JSON_VALUE) public Employee getEmployee(@PathVariable int id){ return employeeService.getEmployee(id); } @GetMapping(value="/get/{name}",produces=MediaType.APPLICATION_JSON_VALUE) public Employee getEmployeeByName(@PathVariable String name){ return employeeService.getEmployeeByName(name); } @GetMapping(value="/getByIdAndName/{id}/{name}",produces=MediaType.APPLICATION_JSON_VALUE) public Employee getEmployeeByNameAndId(@PathVariable int id,@PathVariable String name){ return employeeService.getEmployeeByIdAndName(id, name); } @GetMapping(value="/getAllEmployeeNameDesc",produces=MediaType.APPLICATION_JSON_VALUE) public List<Employee> getEmployeeByNameDesc(){ return employeeService.findAllEmployeeNameDesc(); } @GetMapping(value="/getEmployees",produces=MediaType.APPLICATION_JSON_VALUE) @Secure(crudOperation = "READ") public List<Employee> getAllEmployee(@RequestHeader("accessToken") String accessToken){ return employeeService.getAllEmployee(); } @PostMapping(value="/createEmployee") public Employee createEmployee(@RequestBody Employee emp){ return employeeService.createEmployee(emp); } @DeleteMapping(value="/deleteEmployee") public void deleteEmployee(@RequestBody Employee emp){ employeeService.deleteEmployee(emp); } @GetMapping(value="/consumeGetEmployee/{id}",produces=MediaType.APPLICATION_JSON_VALUE) public Employee consumeGetEmployee(@PathVariable int id){ return employeeService.consumeGetEmployee(id); } /** * This is the method to consume employee..... * @return */ @GetMapping(value="/consumePostEmployee",produces=MediaType.APPLICATION_JSON_VALUE) public Employee consumePostEmployee(){ return employeeService.consumePostEmployee(); } }
36.858824
106
0.789339
33d0833a932ef7f4cb340c5db19167478082980c
4,505
/** * The MIT License (MIT) * * Copyright (c) 2016 Alexey Saenko * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package me.geenee.controller; import com.fasterxml.jackson.databind.MapperFeature; import java.io.IOException; import java.util.LinkedList; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Before; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.mock.http.MockHttpOutputMessage; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; /** * Class has some abstract stuff for testing REST API. * * @author Alexey Saenko (alexey.saenko@gmail.com) * @version $Id$ */ @WebAppConfiguration @SuppressWarnings("PMD.AbstractClassWithoutAbstractMethod") @Slf4j public abstract class AbstractRestTest { /** * Mock MVC. */ private transient MockMvc mvc; /** * Http Message converter. */ private transient MappingJackson2HttpMessageConverter converter; /** * Web application context. */ @Autowired private transient WebApplicationContext context; /** * Sets mock mvc. * @throws Exception If something goes wrong. */ @Before public final void setMockMvc() throws Exception { this.mvc = MockMvcBuilders .webAppContextSetup(this.context) .build(); } /** * Sets http message converter. */ @Before public final void setConverter() { this.converter = new MappingJackson2HttpMessageConverter(); this.converter.getObjectMapper().disable(MapperFeature.USE_ANNOTATIONS); } /** * Gets mock mvc. * @return MVC. */ public final MockMvc getMvc() { return this.mvc; } /** * Converts the given object to json string. * @param obj Given object. * @return Json string. * @throws IOException If something goes wrong. */ protected final String json(final Object obj) throws IOException { final MockHttpOutputMessage result = new MockHttpOutputMessage(); this.converter.write(obj, MediaType.APPLICATION_JSON_UTF8, result); final String json = result.getBodyAsString(); log.debug("Json of object: {}", json); return json; } /** * Converts iterable to list. * @param iterable Iterable. * @param <T> Type of items. * @return List of items. */ protected final <T> List<T> toList(final Iterable<T> iterable) { final List<T> result = new LinkedList<T>(); for (final T item : iterable) { result.add(item); } return result; } /** * Check against size of elements. * @param size Size. * @return Result matcher. */ protected final ResultMatcher listHasSize( final Matcher<? super java.lang.Integer> size ) { return MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(size)); } }
31.950355
83
0.698779
19cf1ddefa555f2349499e4f71b2773b8fd6f8a7
3,684
package com.base.baseproject.utils; import android.app.ProgressDialog; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.support.annotation.NonNull; import android.widget.ImageView; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.base.baseproject.BuildConfig; import com.base.baseproject.R; import com.bumptech.glide.Glide; import java.util.Random; /** * Created by Phong on 11/9/2016. */ public class Utils { private static ProgressDialog progressDialog; public static void showProgress(Context context, String message) { dismissCurrentDialog(); progressDialog = new ProgressDialog(context); progressDialog.setMessage(message); progressDialog.show(); } public static void dismissCurrentDialog() { if (progressDialog != null) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = null; } } public static ProgressDialog showLoadingDialog(Context context) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.show(); if (progressDialog.getWindow() != null) { progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); } progressDialog.setContentView(R.layout.layout_progress_dialog); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); return progressDialog; } public static ProgressDialog showLoadingDialog(Context context, String message) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setMessage(message); progressDialog.show(); progressDialog.setIndeterminate(true); progressDialog.setCancelable(true); return progressDialog; } public static MaterialDialog createAlertDialog(Context context) { return new MaterialDialog.Builder(context) .canceledOnTouchOutside(true) .positiveText(context.getString(R.string.lbl_ok)) .build(); } public static void showToast(Context context, String message) { if (!message.isEmpty()) { Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT); toast.setGravity(17, 0, 230); toast.show(); } } public static boolean isDebuggable() { boolean debuggable = false; try { debuggable = BuildConfig.DEBUG; } catch (Exception e) { } return debuggable; } @NonNull public static String getRandomId() { String possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; long currentTime = System.currentTimeMillis(); StringBuilder builder = new StringBuilder(String.valueOf(currentTime)); builder.append("_"); for (int i = 0; i < 20; i++) { Random random = new Random(); builder.append(possible.charAt(random.nextInt(possible.length()))); } return builder.toString(); } public static void loadImageWithGlide(Context context, ImageView imageView, String url, int placeholder) { if (url.isEmpty() || context == null) { return; } Glide.with(context) .load(url) .centerCrop() .error(placeholder) .placeholder(placeholder) .crossFade() .into(imageView); } }
32.034783
110
0.646851
82b74c8e5a81c3bc912690e412e34a3ffc29c26a
3,619
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.proteosuite; /* --------------------- * ScatterPlotDemo1.java * --------------------- * (C) Copyright 2002-2006, by Object Refinery Limited. * */ import org.proteosuite.SampleXYDataset2; import java.awt.Color; import java.awt.Shape; import java.awt.geom.Rectangle2D; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.util.ShapeUtilities; /** * A demo scatter plot. */ public class ScatterPlotDemo1 extends ApplicationFrame { /** * A demonstration application showing a scatter plot. * * @param title the frame title. */ public ScatterPlotDemo1(String title) { super(title); JPanel chartPanel = createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createScatterPlot("2D View", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setUseOutlinePaint(true); Shape square = new Rectangle2D.Float(100.0f, 100.0f, 100.0f, 100.0f); plot = (XYPlot) chart.getPlot(); renderer.setSeriesShape(0, square); renderer.setSeriesShape(1, square); renderer.setSeriesShape(2, square); renderer.setSeriesShape(3, square); renderer.setSeriesShape(4, square); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setTickMarkInsideLength(2.0f); domainAxis.setTickMarkOutsideLength(0.0f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setTickMarkInsideLength(2.0f); rangeAxis.setTickMarkOutsideLength(0.0f); return chart; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(new SampleXYDataset2()); ChartPanel chartPanel = new ChartPanel(chart); //chartPanel.setVerticalAxisTrace(true); //chartPanel.setHorizontalAxisTrace(true); // popup menu conflicts with axis trace chartPanel.setPopupMenu(null); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); return chartPanel; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { ScatterPlotDemo1 demo = new ScatterPlotDemo1("2D View"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } }
31.198276
81
0.664825
c4f4b073c4fdd59894ea01610c42f27c1dd170a5
558
package iHashTag; public class TweetWithSentiment { private String line; private String cssClass; public TweetWithSentiment() { } public TweetWithSentiment(String line, String cssClass) { super(); this.line = line; this.cssClass = cssClass; } public String getLine() { return line; } public String getCssClass() { return cssClass; } @Override public String toString() { return "TweetWithSentiment [line=" + line + ", cssClass=" + cssClass + "]"; } }
18
83
0.596774
5b399ef2f4ed660ab5395bc49a35ffc456da362f
109
/** * This package contains the repositories of the application. */ package com.reciperegistry.Repository;
21.8
61
0.770642
f6845b305eae97924d565242d121f3ab950f7cb4
398
package org.wso2.carbon.device.mgt.core.geo.geoHash.geoHashStrategy; import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; /** * This interface is to decide a length for the geohash prefix * which will be used to group the clusters based on geohash */ public interface GeoHashLengthStrategy { int getGeohashLength(GeoCoordinate southWest, GeoCoordinate northEast, int zoom); }
33.166667
85
0.791457
c26ee17755d1059aab0b8f757c0a78f4b64bd5fb
2,765
package com.bootdo.common.domain; import com.alibaba.fastjson.JSON; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * tree TODO <br> * * @author kangxu2 2017-1-7 * */ public class MenuTree<T> { /** * 节点ID */ private String id; /** * 显示节点文本 */ private String title; private String jump; private String icon; /** * 节点状态,open closed */ private Map<String, Object> state; /** * 节点是否被选中 true false */ private boolean checked = false; /** * 节点属性 */ private Map<String, Object> attributes; /** * 节点的子节点 */ private List<MenuTree<T>> list = new ArrayList<MenuTree<T>>(); /** * 父ID */ private String parentId; /** * 是否有父节点 */ private boolean hasParent = false; /** * 是否有子节点 */ private boolean hasChildren = false; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getJump() { return jump; } public void setJump(String jump) { this.jump = jump; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public Map<String, Object> getState() { return state; } public void setState(Map<String, Object> state) { this.state = state; } public boolean isChecked() { return checked; } public void setChecked(boolean checked) { this.checked = checked; } public Map<String, Object> getAttributes() { return attributes; } public void setAttributes(Map<String, Object> attributes) { this.attributes = attributes; } public List<MenuTree<T>> getList() { return list; } public void setList(List<MenuTree<T>> list) { this.list = list; } public boolean isHasParent() { return hasParent; } public void setHasParent(boolean isParent) { this.hasParent = isParent; } public boolean isHasChildren() { return hasChildren; } public void setChildren(boolean isChildren) { this.hasChildren = isChildren; } public String getParentId() { return parentId; } public void setParentId(String parentId) { this.parentId = parentId; } public MenuTree(String id, String title, Map<String, Object> state, boolean checked, Map<String, Object> attributes, List<MenuTree<T>> list, boolean isParent, boolean isChildren, String parentID) { super(); this.id = id; this.title = title; this.state = state; this.checked = checked; this.attributes = attributes; this.list = list; this.hasParent = isParent; this.hasChildren = isChildren; this.parentId = parentID; } public MenuTree() { super(); } @Override public String toString() { return JSON.toJSONString(this); } }
16.360947
117
0.664376
fa49711d27a71d227cceae3ab97d84dd9712d135
12,569
package com.lazerycode.jmeter.configuration; import org.apache.commons.io.FilenameUtils; import org.apache.maven.plugin.MojoExecutionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.TreeSet; import static com.lazerycode.jmeter.configuration.JMeterCommandLineArguments.*; import static com.lazerycode.jmeter.utility.UtilityFunctions.isNotSet; import static com.lazerycode.jmeter.utility.UtilityFunctions.isSet; /** * Creates an arguments array to pass to the JMeter object to run tests. * * @author Mark Collin */ public class JMeterArgumentsArray { private static final Logger LOGGER = LoggerFactory.getLogger(JMeterArgumentsArray.class); private final String jMeterHome; private boolean disableTests; private final TreeSet<JMeterCommandLineArguments> argumentList = new TreeSet<>(); private DateTimeFormatter dateFormat = DateTimeFormatter.BASIC_ISO_DATE; private ProxyConfiguration proxyConfiguration; private boolean timestampResults = false; private boolean appendTimestamp = false; private String resultFileExtension = ".jtl"; private String remoteStartServerList; private List<String> customPropertiesFiles = new ArrayList<>(); private String testFile; private String resultsLogFileName; private String jmeterLogFileName; private String logsDirectory; private String resultsDirectory; private String reportDirectory; private LogLevel overrideRootLogLevel; /** * Create an instance of JMeterArgumentsArray * * @param disableGUI If GUI should be disabled or not * @param jMeterHomeDirectory The JMETER_HOME directory, what JMeter bases its classpath on * @throws MojoExecutionException Exception */ public JMeterArgumentsArray(boolean disableGUI, String jMeterHomeDirectory) throws MojoExecutionException { if (isNotSet(jMeterHomeDirectory)) { throw new MojoExecutionException("Unable to set JMeter Home Directory..."); } jMeterHome = jMeterHomeDirectory; argumentList.add(JMETER_HOME_OPT); if (disableGUI) { argumentList.add(NONGUI_OPT); disableTests = false; } else { disableTests = true; } } public JMeterArgumentsArray setRemoteStop() { argumentList.add(REMOTE_STOP); return this; } public JMeterArgumentsArray setRemoteStart() { argumentList.add(REMOTE_OPT); return this; } public JMeterArgumentsArray setRemoteStartServerList(String serverList) { if (isNotSet(serverList)) return this; remoteStartServerList = serverList; argumentList.add(REMOTE_OPT_PARAM); return this; } public JMeterArgumentsArray setProxyConfig(ProxyConfiguration configuration) { if (configuration == null) return this; this.proxyConfiguration = configuration; if (isSet(proxyConfiguration.getHost())) { argumentList.add(PROXY_HOST); argumentList.add(PROXY_PORT); } if (isSet(proxyConfiguration.getUsername())) { argumentList.add(PROXY_USERNAME); } if (isSet(proxyConfiguration.getPassword())) { argumentList.add(PROXY_PASSWORD); } if (isSet(proxyConfiguration.getHostExclusions())) { argumentList.add(NONPROXY_HOSTS); } return this; } public JMeterArgumentsArray addACustomPropertiesFiles(List<File> customPropertiesFiles) { if (isNotSet(customPropertiesFiles)) return this; for (File customPropertiesFile : customPropertiesFiles) { this.customPropertiesFiles.add(customPropertiesFile.getAbsolutePath()); argumentList.add(PROPFILE2_OPT); } return this; } public JMeterArgumentsArray setLogRootOverride(String requestedLogLevel) { if (isNotSet(requestedLogLevel)) { return this; } for (LogLevel logLevel : LogLevel.values()) { if (logLevel.toString().equalsIgnoreCase(requestedLogLevel)) { overrideRootLogLevel = logLevel; argumentList.add(LOGLEVEL); return this; } } LOGGER.warn("Unknown log level {}", requestedLogLevel); return this; } public JMeterArgumentsArray setResultsDirectory(String resultsDirectory) { this.resultsDirectory = resultsDirectory; return this; } public JMeterArgumentsArray setLogsDirectory(String logsDirectory) { this.logsDirectory = logsDirectory; return this; } public JMeterArgumentsArray setResultsTimestamp(boolean addTimestamp) { timestampResults = addTimestamp; return this; } public JMeterArgumentsArray setResultsFileNameDateFormat(String dateFormat) { if (isSet(dateFormat)) { try { this.dateFormat = DateTimeFormatter.ofPattern(dateFormat); } catch (Exception ex) { LOGGER.error("'" + dateFormat + "' is an invalid DateTimeFormat. Defaulting to Standard ISO_8601.", ex); } } return this; } public JMeterArgumentsArray appendTimestamp(boolean append) { appendTimestamp = append; return this; } public JMeterArgumentsArray setResultFileOutputFormatIsCSV(boolean isCSVFormat) { if (isCSVFormat) { resultFileExtension = ".csv"; } else { resultFileExtension = ".jtl"; } return this; } public JMeterArgumentsArray setTestFile(File value, File testFilesDirectory) { if (isNotSet(value)) return this; testFile = value.getAbsolutePath(); String resultFilename = FilenameUtils.removeExtension(testFilesDirectory.toURI().relativize(value.toURI()).getPath().replace("\\", "/").replace("/", "_") ); resultsLogFileName = resultsDirectory + File.separator; if (timestampResults) { //TODO investigate when timestamp is generated. if (appendTimestamp) { resultsLogFileName += String.format("%s-%s%s", resultFilename, LocalDateTime.now().format(dateFormat), resultFileExtension); } else { resultsLogFileName += String.format("%s-%s%s", LocalDateTime.now().format(dateFormat), resultFilename, resultFileExtension); } } else { resultsLogFileName += resultFilename + resultFileExtension; } if (isSet(logsDirectory)) { jmeterLogFileName = logsDirectory + File.separator + value.getName() + ".log"; argumentList.add(JMLOGFILE_OPT); } argumentList.add(TESTFILE_OPT); argumentList.add(LOGFILE_OPT); disableTests = false; return this; } public JMeterArgumentsArray setReportsDirectory(String reportDirectory) { argumentList.add(REPORT_AT_END_OPT); argumentList.add(REPORT_OUTPUT_FOLDER_OPT); this.reportDirectory = reportDirectory; return this; } public JMeterArgumentsArray setServerMode(String exportedHostname, int port) { argumentList.add(SERVER_OPT); disableTests = true; if (isSet(logsDirectory)) { if (null == exportedHostname) { exportedHostname = "localhost"; } jmeterLogFileName = logsDirectory + File.separator + String.format("%s_%s.log", exportedHostname, port); argumentList.add(JMLOGFILE_OPT); } return this; } public String getResultsLogFileName() { return resultsLogFileName; } /** * Generate an arguments array representing the command line options you want to send to JMeter. * The order of the array is determined by the order the values in JMeterCommandLineArguments are defined. * * @return An array representing the command line sent to JMeter * @throws MojoExecutionException Exception */ public List<String> buildArgumentsArray() throws MojoExecutionException { if (!argumentList.contains(TESTFILE_OPT) && !disableTests) { throw new MojoExecutionException("No test(s) specified!"); } List<String> argumentsArray = new ArrayList<>(); for (JMeterCommandLineArguments argument : argumentList) { switch (argument) { case NONGUI_OPT: argumentsArray.add(NONGUI_OPT.getCommandLineArgument()); break; case TESTFILE_OPT: argumentsArray.add(TESTFILE_OPT.getCommandLineArgument()); argumentsArray.add(testFile); break; case LOGFILE_OPT: argumentsArray.add(LOGFILE_OPT.getCommandLineArgument()); argumentsArray.add(resultsLogFileName); break; case JMETER_HOME_OPT: argumentsArray.add(JMETER_HOME_OPT.getCommandLineArgument()); argumentsArray.add(jMeterHome); break; case LOGLEVEL: argumentsArray.add(LOGLEVEL.getCommandLineArgument()); argumentsArray.add(overrideRootLogLevel.toString()); break; case PROPFILE2_OPT: for (String customPropertiesFile : customPropertiesFiles) { argumentsArray.add(PROPFILE2_OPT.getCommandLineArgument()); argumentsArray.add(customPropertiesFile); } break; case REMOTE_OPT: argumentsArray.add(REMOTE_OPT.getCommandLineArgument()); break; case PROXY_HOST: argumentsArray.add(PROXY_HOST.getCommandLineArgument()); argumentsArray.add(proxyConfiguration.getHost()); break; case PROXY_PORT: argumentsArray.add(PROXY_PORT.getCommandLineArgument()); argumentsArray.add(proxyConfiguration.getPort()); break; case PROXY_USERNAME: argumentsArray.add(PROXY_USERNAME.getCommandLineArgument()); argumentsArray.add(proxyConfiguration.getUsername()); break; case PROXY_PASSWORD: argumentsArray.add(PROXY_PASSWORD.getCommandLineArgument()); argumentsArray.add(proxyConfiguration.getPassword()); break; case NONPROXY_HOSTS: argumentsArray.add(NONPROXY_HOSTS.getCommandLineArgument()); argumentsArray.add(proxyConfiguration.getHostExclusions()); break; case REMOTE_STOP: argumentsArray.add(REMOTE_STOP.getCommandLineArgument()); break; case REMOTE_OPT_PARAM: argumentsArray.add(REMOTE_OPT_PARAM.getCommandLineArgument()); argumentsArray.add(remoteStartServerList); break; case JMLOGFILE_OPT: argumentsArray.add(JMLOGFILE_OPT.getCommandLineArgument()); argumentsArray.add(jmeterLogFileName); break; case REPORT_AT_END_OPT: argumentsArray.add(REPORT_AT_END_OPT.getCommandLineArgument()); break; case REPORT_OUTPUT_FOLDER_OPT: argumentsArray.add(REPORT_OUTPUT_FOLDER_OPT.getCommandLineArgument()); argumentsArray.add(reportDirectory); break; case SERVER_OPT: argumentsArray.add(SERVER_OPT.getCommandLineArgument()); break; case SYSTEM_PROPFILE: case JMETER_PROPERTY: case JMETER_GLOBAL_PROP: case SYSTEM_PROPERTY: case VERSION_OPT: case PROPFILE_OPT: case REPORT_GENERATING_OPT: case HELP_OPT: //Unhandled options, they will be ignored break; } } return argumentsArray; } }
37.744745
161
0.623439
feb17687f07b716393eec836dd1dc241903ae822
1,596
package org.simbasecurity.dwclient.dropwizard.config; import org.hibernate.validator.constraints.NotEmpty; import com.fasterxml.jackson.annotation.JsonProperty; import com.yammer.dropwizard.client.JerseyClientConfiguration; public class SimbaManagerRestConfiguration extends JerseyClientConfiguration { @NotEmpty @JsonProperty private String simbaURL = "http://localhost:8087/simba/manager"; @NotEmpty @JsonProperty private String simbaWebURL = "http://localhost:8087/simba"; /** * The role name that gets access to the Simba Manager REST services. */ @NotEmpty @JsonProperty private String appUserRole; /** * The application user that has the appUserRole so it can access the Simba Manager REST services. */ @NotEmpty @JsonProperty private String appUser; /** * The application user's password */ @NotEmpty @JsonProperty private String appPassword; public String getSimbaManagerURL() { return simbaURL; } public void setSimbaURL(String simbaURL) { this.simbaURL = simbaURL; } public String getSimbaWebURL() { return simbaWebURL; } public void setSimbaWebURL(String simbaWebURL) { this.simbaWebURL = simbaWebURL; } public void setAppUserRole(String appUserRole) { this.appUserRole = appUserRole; } public void setAppUser(String appUser) { this.appUser = appUser; } public void setAppPassword(String appPassword) { this.appPassword = appPassword; } public String getAppUserRole() { return appUserRole; } public String getAppUser() { return appUser; } public String getAppPassword() { return appPassword; } }
19.95
99
0.756266
c142e72f7d54d4600810dd0b4ef9e8529ea4803e
1,271
package de.kaesdingeling.spring.openapi.generator.example.rest.server.apis; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import de.kaesdingeling.spring.openapi.generator.example.rest.server.models.LoginData; import de.kaesdingeling.spring.openapi.generator.example.rest.server.models.ProfileData; @RestController @RequestMapping("login") public class RESTApiLoginExample { @PostMapping("login") public ResponseEntity<ProfileData> login(@RequestBody LoginData loginData) { if (loginData != null) { if (loginData.getUsername().contentEquals("admin") && loginData.getPassword().contentEquals("admin")) { return new ResponseEntity<ProfileData>(ProfileData.builder() .username("admin") .firstName("max") .lastName("mustermann") .active(true) .build(), HttpStatus.OK); } else { return new ResponseEntity<ProfileData>(HttpStatus.FORBIDDEN); } } else { return new ResponseEntity<ProfileData>(HttpStatus.BAD_REQUEST); } } }
37.382353
106
0.775767
639d853ad359da4ce93488b6da3544e50f181563
211
package org.penemunxt.communication; public interface INXTCommunicationDataFactories { public INXTCommunicationDataFactory getDataInFactory(); public INXTCommunicationDataFactory getDataOutFactory(); }
30.142857
58
0.843602
a75acf5217738f93efc101058f8c386fcf151c1d
357
package com.aboutcoder.packease.utils.thread; /** * <Description> * Copyright © 2013-2016 AboutCoder.COM. All rights reserved.<br /> * * @author jeromechan<br /> * @CreateDate 9/6/16 8:39 PM<br /> * @description <br /> */ public abstract class PEAsyncProxyParam { /** * Processing async function */ public void execute() { } }
19.833333
67
0.635854
d03224de7465850d69bf383fc613570db3c690bd
901
package com.tencent.msdk.dns; import com.tencent.msdk.dns.core.LookupResult; import com.tencent.msdk.dns.core.stat.StatisticsMerge; /** * 监控SDK的解析情况的接口 */ public interface ILookedUpListener { /** * 通过接口调用完成域名解析后的回调 * * @param hostname 域名 * @param lookupResult {@link LookupResult<StatisticsMerge>}实例, 即域名解析结果 */ void onLookedUp(String hostname, LookupResult<StatisticsMerge> lookupResult); /** * 预解析完成一次域名解析后的回调 * * @param hostname 域名 * @param lookupResult {@link LookupResult<StatisticsMerge>}实例, 即域名解析结果 */ void onPreLookedUp(String hostname, LookupResult<StatisticsMerge> lookupResult); /** * 异步解析完成一次域名解析后的回调 * * @param hostname 域名 * @param lookupResult {@link LookupResult<StatisticsMerge>}实例, 即域名解析结果 */ void onAsyncLookedUp(String hostname, LookupResult<StatisticsMerge> lookupResult); }
25.742857
86
0.694784
2dfd5da9cf197e7d9506c301eb8eeed896c0b536
538
package save.time.ferramentas; import javax.persistence.Query; import save.time.connection.Connection; public abstract class AuxiliarBd { public static void execute(Query query) { Connection.getConnection().getTransaction().begin(); query.executeUpdate(); Connection.getConnection().getTransaction().commit(); } public static void persist(Object objeto) { Connection.getConnection().getTransaction().begin(); Connection.getConnection().persist(objeto); Connection.getConnection().getTransaction().commit(); } }
24.454545
55
0.758364
12f84080f61f78fdc8ba3e8aebf1eaf2018bac08
925
package com.xzjie.cms.repository; import com.xzjie.cms.model.WxAccountFans; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.lang.Nullable; public interface WxFansRepository extends JpaRepository<WxAccountFans, Long>, JpaSpecificationExecutor<WxAccountFans> { boolean existsByOpenId(String openId); WxAccountFans findByOpenId(String openId); @Query(nativeQuery = true, value = "SELECT * FROM (SELECT f.* FROM wx_account_fans f LEFT JOIN wx_fans_tag t ON f.id = t.fans_id) A") Page<WxAccountFans> findFansAll(@Nullable Specification<WxAccountFans> specification, Pageable pageable); }
42.045455
137
0.817297
2bfdadad33e9cb4c8ecefe70174e3c0edf22950f
5,899
/* * Copyright ConsenSys AG. * * 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. * * SPDX-License-Identifier: Apache-2.0 */ package org.hyperledger.besu.ethereum.eth.manager.task; import static org.hyperledger.besu.util.FutureUtils.completedExceptionally; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; import org.hyperledger.besu.plugin.services.metrics.OperationTimer; import java.util.Collection; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Supplier; import com.google.common.base.Stopwatch; public abstract class AbstractEthTask<T> implements EthTask<T> { private double taskTimeInSec = -1.0D; private final OperationTimer taskTimer; protected final AtomicReference<CompletableFuture<T>> result = new AtomicReference<>(); private final Collection<CompletableFuture<?>> subTaskFutures = new ConcurrentLinkedDeque<>(); protected AbstractEthTask(final MetricsSystem metricsSystem) { this(buildOperationTimer(metricsSystem)); } protected AbstractEthTask(final OperationTimer taskTimer) { this.taskTimer = taskTimer; } private static OperationTimer buildOperationTimer(final MetricsSystem metricsSystem) { final LabelledMetric<OperationTimer> ethTasksTimer = metricsSystem.createLabelledTimer( BesuMetricCategory.SYNCHRONIZER, "task", "Internal processing tasks", "taskName"); if (ethTasksTimer == NoOpMetricsSystem.NO_OP_LABELLED_1_OPERATION_TIMER) { return () -> new OperationTimer.TimingContext() { final Stopwatch stopwatch = Stopwatch.createStarted(); @Override public double stopTimer() { return stopwatch.elapsed(TimeUnit.MILLISECONDS) / 1000.0; } }; } else { return ethTasksTimer.labels(AbstractEthTask.class.getSimpleName()); } } @Override public final CompletableFuture<T> run() { if (result.compareAndSet(null, new CompletableFuture<>())) { executeTaskTimed(); result.get().whenComplete((r, t) -> cleanup()); } return result.get(); } @Override public final CompletableFuture<T> runAsync(final ExecutorService executor) { if (result.compareAndSet(null, new CompletableFuture<>())) { executor.execute(this::executeTaskTimed); result.get().whenComplete((r, t) -> cleanup()); } return result.get(); } @Override public final void cancel() { synchronized (result) { result.compareAndSet(null, new CompletableFuture<>()); result.get().cancel(false); } } public final boolean isDone() { return result.get() != null && result.get().isDone(); } public final boolean isSucceeded() { return isDone() && !result.get().isCompletedExceptionally(); } public final boolean isFailed() { return isDone() && result.get().isCompletedExceptionally(); } public final boolean isCancelled() { return isDone() && result.get().isCancelled(); } /** * Utility for executing completable futures that handles cleanup if this EthTask is cancelled. * * @param subTask a subTask to execute * @param <S> the type of data returned from the CompletableFuture * @return The completableFuture that was executed */ protected final <S> CompletableFuture<S> executeSubTask( final Supplier<CompletableFuture<S>> subTask) { synchronized (result) { if (!isCancelled()) { final CompletableFuture<S> subTaskFuture = subTask.get(); subTaskFutures.add(subTaskFuture); subTaskFuture.whenComplete((r, t) -> subTaskFutures.remove(subTaskFuture)); return subTaskFuture; } else { return completedExceptionally(new CancellationException()); } } } /** * Helper method for sending subTask to worker that will clean up if this EthTask is cancelled. * * @param scheduler the scheduler that will run worker task * @param subTask a subTask to execute * @param <S> the type of data returned from the CompletableFuture * @return The completableFuture that was executed */ protected final <S> CompletableFuture<S> executeWorkerSubTask( final EthScheduler scheduler, final Supplier<CompletableFuture<S>> subTask) { return executeSubTask(() -> scheduler.scheduleSyncWorkerTask(subTask)); } /** Execute core task logic. */ protected abstract void executeTask(); /** Executes the task while timed by a timer. */ public void executeTaskTimed() { final OperationTimer.TimingContext timingContext = taskTimer.startTimer(); try { executeTask(); } finally { taskTimeInSec = timingContext.stopTimer(); } } public double getTaskTimeInSec() { return taskTimeInSec; } /** Cleanup any resources when task completes. */ protected void cleanup() { for (final CompletableFuture<?> subTaskFuture : subTaskFutures) { subTaskFuture.cancel(false); } } }
34.497076
118
0.719613
e49cb66ab4eac02efa96f82cf72a855e5642b4da
114
package com.abstracts.factory.action; public abstract class AbstractProductA { public abstract void show(); }
16.285714
40
0.780702
8b728420bea6e747f7ca4c9c2c87ded9b719e054
7,077
package org.sharedhealth.datasense.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; public class Address { @JsonProperty("address_line") private String addressLine; @JsonProperty("division_id") private String divisionId; @JsonProperty("district_id") private String districtId; @JsonProperty("upazila_id") private String upazilaId; @JsonProperty("city_corporation_id") private String cityCorporationId; @JsonProperty("union_or_urban_ward_id") private String unionOrUrbanWardId; @JsonProperty("union_id") @JsonInclude(NON_EMPTY) private String unionId; @JsonProperty("thana_id") @JsonInclude(NON_EMPTY) private String thanaId; public Address() { } public Address(String addressLine, String divisionId, String districtId, String upazilaId, String cityCorporationId, String unionOrUrbanWardId, String unionId, String thanaId) { this.addressLine = addressLine; this.divisionId = divisionId; this.districtId = districtId; this.upazilaId = upazilaId; this.cityCorporationId = cityCorporationId; this.unionOrUrbanWardId = unionOrUrbanWardId; this.unionId = unionId; this.thanaId = thanaId; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Address)) return false; Address address = (Address) o; if (addressLine != null ? !addressLine.equals(address.addressLine) : address.addressLine != null) return false; if (divisionId != null ? !divisionId.equals(address.divisionId) : address.divisionId != null) return false; if (districtId != null ? !districtId.equals(address.districtId) : address.districtId != null) return false; if (upazilaId != null ? !upazilaId.equals(address.upazilaId) : address.upazilaId != null) return false; if (cityCorporationId != null ? !cityCorporationId.equals(address.cityCorporationId) : address .cityCorporationId != null) return false; if (unionOrUrbanWardId != null ? !unionOrUrbanWardId.equals(address.unionOrUrbanWardId) : address .unionOrUrbanWardId != null) return false; if (unionId != null ? !unionId.equals(address.unionId) : address.unionId != null) return false; if (thanaId != null ? !thanaId.equals(address.thanaId) : address.thanaId != null) return false; return true; } @Override public int hashCode() { int result = addressLine != null ? addressLine.hashCode() : 0; result = 31 * result + (divisionId != null ? divisionId.hashCode() : 0); result = 31 * result + (districtId != null ? districtId.hashCode() : 0); result = 31 * result + (upazilaId != null ? upazilaId.hashCode() : 0); result = 31 * result + (cityCorporationId != null ? cityCorporationId.hashCode() : 0); result = 31 * result + (unionOrUrbanWardId != null ? unionOrUrbanWardId.hashCode() : 0); result = 31 * result + (unionId != null ? unionId.hashCode() : 0); result = 31 * result + (thanaId != null ? thanaId.hashCode() : 0); return result; } @Override public String toString() { final StringBuilder sb = new StringBuilder("Address{"); sb.append("addressLine='").append(addressLine).append('\''); sb.append(", divisionId='").append(divisionId).append('\''); sb.append(", districtId='").append(districtId).append('\''); sb.append(", upazilaId='").append(upazilaId).append('\''); sb.append(", cityCorporationId='").append(cityCorporationId).append('\''); sb.append(", unionOrUrbanWardId='").append(unionOrUrbanWardId).append('\''); sb.append(", unionId='").append(unionId).append('\''); sb.append(", thanaId='").append(thanaId).append('\''); sb.append('}'); return sb.toString(); } public String getAddressLine() { return addressLine; } public void setAddressLine(String addressLine) { this.addressLine = addressLine; } public String getDivisionId() { return divisionId; } public void setDivisionId(String divisionId) { this.divisionId = divisionId; } public String getDistrictId() { return districtId; } public void setDistrictId(String districtId) { this.districtId = districtId; } public String getUpazilaId() { return upazilaId; } public void setUpazilaId(String upazilaId) { this.upazilaId = upazilaId; } public String getCityCorporationId() { return cityCorporationId; } public void setCityCorporationId(String cityCorporationId) { this.cityCorporationId = cityCorporationId; } public String getUnionOrUrbanWardId() { return unionOrUrbanWardId; } public void setUnionOrUrbanWardId(String unionOrUrbanWardId) { this.unionOrUrbanWardId = unionOrUrbanWardId; } public String createUserGeneratedDistrictId() { return divisionId + districtId; } public String createUserGeneratedUpazillaId() { return divisionId + districtId + upazilaId; } public String createUserGeneratedCityCorporationId() { return divisionId + districtId + upazilaId + cityCorporationId; } public String createUserGeneratedWardId() { return divisionId + districtId + upazilaId + cityCorporationId + unionOrUrbanWardId; } public String getUnionId() { return unionId; } public void setUnionId(String unionId) { this.unionId = unionId; } public String getThanaId() { return thanaId; } public void setThanaId(String thanaId) { this.thanaId = thanaId; } public static String getAddressCodeForLevel(String code, int level) { if (code.length() < (level * 2)) { return ""; //fail instead? } int beginIndex = (level - 1) * 2; return code.substring(beginIndex, beginIndex + 2); } public String getLocationCode() { StringBuilder locationBuilder = new StringBuilder(); if (StringUtils.isNotBlank(divisionId)) locationBuilder.append(divisionId.trim()); if (StringUtils.isNotBlank(districtId)) locationBuilder.append(districtId.trim()); if (StringUtils.isNotBlank(upazilaId)) locationBuilder.append(upazilaId.trim()); if (StringUtils.isNotBlank(cityCorporationId)) locationBuilder.append(cityCorporationId.trim()); if (StringUtils.isNotBlank(unionId)) locationBuilder.append(unionId.trim()); if (StringUtils.isNotBlank(unionOrUrbanWardId)) locationBuilder.append(unionOrUrbanWardId.trim()); return StringUtils.isNotBlank(locationBuilder.toString()) ? locationBuilder.toString() : null; } }
34.691176
119
0.661297
01d7523d69da04e7230fa15d3dab2eee4b54d590
170
package com.ivaneye.jjvm.domain.attr; import lombok.Data; /** * @author ivaneye * @since 2021-07-10 23:17:03 */ @Data public class Deprecated extends Attribute { }
13.076923
43
0.705882
8846beecda82722c1a501a07ecc6924fd4318355
316
package com.practice.my.practice.web.admin.sys.service.impl; import com.practice.my.practice.web.admin.sys.service.RoleService; import org.springframework.stereotype.Service; /** * @author Pengcheng Zhao * @version 1.0 * @date 2019/6/6 16:00 */ @Service public class RoleServiceImpl implements RoleService { }
22.571429
66
0.768987
5bbf4ce553bf3dac4b58df5f1461a239b1975c33
489
package com.zype.android.webapi.events.settings; import com.zype.android.webapi.RequestTicket; import com.zype.android.webapi.events.DataEvent; import com.zype.android.webapi.model.settings.LiveStreamSettingsResponse; /** * Created by Evgeny Cherkasov on 21.11.2016. */ public class LiveStreamSettingsEvent extends DataEvent<LiveStreamSettingsResponse> { public LiveStreamSettingsEvent(RequestTicket ticket, LiveStreamSettingsResponse data) { super(ticket, data); } }
30.5625
91
0.795501
c14b72d4e863e19207ae5edafbb27515e26d4830
1,772
package Entily; import java.io.Serializable; import java.util.Objects; import javax.swing.JOptionPane; public class Autor implements Serializable{ private String codAutor; private String nomeAutor; public Autor(String codAutor,String nomeAutor){ this.codAutor = codAutor; this.nomeAutor = nomeAutor; } Autor() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public String toString() { JOptionPane.showMessageDialog(null,"Autor = " + nomeAutor,"",JOptionPane.INFORMATION_MESSAGE); return "codAutor=" + codAutor + ", nomeAutor=" + nomeAutor; } @Override public int hashCode() { int hash = 5; hash = 23 * hash + Objects.hashCode(this.codAutor); hash = 23 * hash + Objects.hashCode(this.nomeAutor); return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Autor other = (Autor) obj; if (this.codAutor != other.codAutor) { return false; } if (!Objects.equals(this.nomeAutor, this.nomeAutor)) { return false; } return true; } public String getCodAutor() { return codAutor; } public void setCodAutor(String codAutor) { this.codAutor = codAutor; } public String getNomeAutor() { return nomeAutor; } public void setNomeAutor(String nomeAutor) { this.nomeAutor = nomeAutor; } }
24.273973
135
0.585214
c7b07c2ff9c14e1f2bd40c02509618e8fb289e19
739
package org.mycompany.springspike.first; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class FirstService { private final FirstRepository firstRepository; private final FirstEntityToFirstDTOMapper firstEntityToFirstDTOMapper; public List<FirstDTO> getFirstDTO() { List<FirstEntity> firstEntities = firstRepository.findAll(); return firstEntities.stream() .map(firstEntityToFirstDTOMapper::mapToDTO) .collect(Collectors.toList()); } public void postFirstDTO(FirstDTO firstDTO) { firstRepository.save(firstEntityToFirstDTOMapper.mapFromDTO(firstDTO)); } }
28.423077
75
0.794317
4fe5b77599a77bc102d9c1c31d534092129f67ff
5,609
// // MethodDeclaration.java -- Truffle nodes MethodDeclaration.* // Project PorcE // // Copyright (c) 2018 The University of Texas at Austin. All rights reserved. // // Use and redistribution of this file is governed by the license terms in // the LICENSE file found in the project's top-level directory and also found at // URL: http://orc.csres.utexas.edu/license.shtml . // package orc.run.porce; import orc.run.porce.NewContinuation.StopCachingException; import orc.run.porce.runtime.PorcEClosure; import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.dsl.ImportStatic; import com.oracle.truffle.api.dsl.Introspectable; import com.oracle.truffle.api.dsl.NodeChild; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.ExplodeLoop; public class MethodDeclaration { public static class MethodClosure { final Object[] environment; public MethodClosure(final Object[] environment) { this.environment = environment; } } @Introspectable @ImportStatic(SpecializationConfiguration.class) public static class NewMethodClosure extends Expression { @Children protected final Expression[] capturedExprs; @Child protected Expression capturedTerminator; protected final int nMethods; private volatile MethodClosure closureCache = null; private volatile long closureCacheChangeCount = 0; private volatile long closureCacheUseCount = 0; public NewMethodClosure(final Expression capturedTerminator, final Expression[] capturedExprs, final int nMethods) { this.capturedTerminator = capturedTerminator; this.capturedExprs = capturedExprs; this.nMethods = nMethods; } boolean isCachable() { if (CompilerDirectives.inInterpreter() && closureCacheChangeCount > 0) { long usePerChange = closureCacheUseCount / closureCacheChangeCount; return usePerChange >= 7 || closureCacheUseCount < 50; } else { return true; } } @SuppressWarnings("boxing") @Specialization(guards = { "EnvironmentCaching" }, rewriteOn = StopCachingException.class) @ExplodeLoop public Object cached(final VirtualFrame frame) throws StopCachingException { final int len = capturedExprs.length + nMethods; CompilerAsserts.compilationConstant(len); /* if (!isCachable()) { CompilerAsserts.neverPartOfCompilation("Cache invalidation should not be in compiled code."); throw new StopCachingException(); } */ MethodClosure closure = closureCache; if (closure != null) { // If we have a cached environment then check that the cache is // still valid. for (int i = 0; i < capturedExprs.length; i++) { // Contains break if (closure.environment[i] != capturedExprs[i].execute(frame)) { closure = null; // If we had a cached closure and invalidated it, don't cache again. closureCache = null; throw new StopCachingException(); } } } if (closure == null) { // If we don't have a cached environment build one and set the // cache. final Object[] capturedValues = new Object[len]; for (int i = 0; i < capturedExprs.length; i++) { capturedValues[i] = capturedExprs[i].execute(frame); } closure = new MethodClosure(capturedValues); closureCache = closure; /* if (CompilerDirectives.inInterpreter()) closureCacheChangeCount++; */ } /* if (CompilerDirectives.inInterpreter()) { closureCacheUseCount++; long useCount = closureCacheUseCount; if (useCount > 5000) { closureCacheUseCount = 0; closureCacheChangeCount = 0; } } */ return closure; } @Specialization(replaces = { "cached" }) @ExplodeLoop public Object universal(final VirtualFrame frame) { final Object[] capturedValues = new Object[capturedExprs.length + nMethods]; for (int i = 0; i < capturedExprs.length; i++) { capturedValues[i] = capturedExprs[i].execute(frame); } return new MethodClosure(capturedValues); } public static NewMethodClosure create(final Expression capturedTerminator, final Expression[] capturedExprs, final int nMethods) { return MethodDeclarationFactory.NewMethodClosureNodeGen.create(capturedTerminator, capturedExprs, nMethods); } } @NodeChild("closure") public static class NewMethod extends Expression { final int index; final RootCallTarget callTarget; final boolean isRoutine; protected NewMethod(final int index, final RootCallTarget callTarget, final boolean isRoutine) { this.index = index; this.callTarget = callTarget; this.isRoutine = isRoutine; } @Specialization public PorcEClosure run(final MethodClosure closure) { if(closure.environment[index] == null) { // This races with itself if the closure is reused. But that doesn't matter since any instance is equivalent. final PorcEClosure m = new PorcEClosure(closure.environment, callTarget, isRoutine); closure.environment[index] = m; } return (PorcEClosure) closure.environment[index]; } public static NewMethod create(final Expression closure, final int index, final PorcERootNode rootNode, final boolean isRoutine) { final RootCallTarget callTarget = rootNode.getCallTarget(); return MethodDeclarationFactory.NewMethodNodeGen.create(index, callTarget, isRoutine, closure); } } }
32.610465
138
0.71314
cc625a0dadf861a1351562ff4c9e048c05751191
342
package de.springbootbuch.database_examples.springdata; /** * Part of springbootbuch.de. * * @author Michael J. Simons * @author @rotnroll666 */ public class CustomerBulkLoaderImpl implements CustomerBulkLoader { @Override public void loadCustomers(String fileName) { System.out.println("Loading customers from " + fileName); } }
21.375
67
0.75731
926a9fd33cd9c981dd7920a52ef706a75665ae55
5,646
/* * 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.commons.collections.list; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import junit.framework.Test; import org.apache.commons.collections.BulkTest; /** * Test class for NodeCachingLinkedList, a performance optimised LinkedList. * * @version $Revision: 646780 $ $Date: 2008-04-10 13:48:07 +0100 (Thu, 10 Apr 2008) $ * * @author Jeff Varszegi * @author Phil Steitz */ public class TestNodeCachingLinkedList extends TestAbstractLinkedList { public TestNodeCachingLinkedList(String testName) { super(testName); } public static void main(String args[]) { compareSpeed(); String[] testCaseName = { TestNodeCachingLinkedList.class.getName()}; junit.textui.TestRunner.main(testCaseName); } public static Test suite() { return BulkTest.makeSuite(TestNodeCachingLinkedList.class); } //----------------------------------------------------------------------- public List makeEmptyList() { return new NodeCachingLinkedList(); } public String getCompatibilityVersion() { return "3"; } //----------------------------------------------------------------------- public void testShrinkCache() { if (isRemoveSupported() == false || isAddSupported() == false) return; resetEmpty(); NodeCachingLinkedList list = (NodeCachingLinkedList) collection; list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); list.removeAllNodes(); // Will dump all 4 elements into cache ((NodeCachingLinkedList) list).setMaximumCacheSize(2); // shrink cache list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); checkNodes(); list.removeNode(list.getNode(0, false)); // no room in cache list.removeNode(list.getNode(0, false)); list.removeNode(list.getNode(0, false)); checkNodes(); list.addAll( Arrays.asList( new String[]{"1", "2", "3", "4"})); checkNodes(); } //----------------------------------------------------------------------- public static void compareSpeed() { NodeCachingLinkedList ncll = new NodeCachingLinkedList(); LinkedList ll = new LinkedList(); Object o1 = new Object(); Object o2 = new Object(); int loopCount = 4000000; long startTime, endTime; System.out.println("Testing relative execution time of commonly-used methods..."); startTime = System.currentTimeMillis(); for(int x = loopCount; x > 0; x--) { // unrolled a few times to minimize effect of loop ll.addFirst(o1); ll.addLast(o2); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); // ll.addFirst(o1); ll.addLast(o2); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); // ll.addFirst(o1); ll.addLast(o2); ll.removeFirst(); ll.removeLast(); ll.add(o1); ll.remove(0); } endTime = System.currentTimeMillis(); System.out.println("Time with LinkedList: " + (endTime - startTime) + " ms"); startTime = System.currentTimeMillis(); for(int x = loopCount; x > 0; x--) { ncll.addFirst(o1); ncll.addLast(o2); ncll.removeFirst(); ncll.removeLast(); ncll.add(o1); ncll.remove(0); // ncll.addFirst(o1); ncll.addLast(o2); ncll.removeFirst(); ncll.removeLast(); ncll.add(o1); ncll.remove(0); // ncll.addFirst(o1); ncll.addLast(o2); ncll.removeFirst(); ncll.removeLast(); ncll.add(o1); ncll.remove(0); } endTime = System.currentTimeMillis(); System.out.println("Time with NodeCachingLinkedList: " + (endTime - startTime) + " ms"); } // public void testCreate() throws Exception { // resetEmpty(); // writeExternalFormToDisk((java.io.Serializable) collection, // "D:/dev/collections/data/test/NodeCachingLinkedList.emptyCollection.version3.obj"); // resetFull(); // writeExternalFormToDisk((java.io.Serializable) collection, // "D:/dev/collections/data/test/NodeCachingLinkedList.fullCollection.version3.obj"); // } }
35.961783
97
0.550124
6db3103351fdb5dad21198c425886cd4d7942268
141
package edu.upc.eetac.dsa.group7.dao; /** * Created by Alex on 29/11/15. */ public class UserAlreadyExistsException extends Exception { }
17.625
59
0.737589
ee09e93bc75130126be1f69d24dd0e322371268f
527
package com.apress.springrecipes.court.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.view.ResourceBundleViewResolver; @Configuration public class ViewResolverConfiguration { @Bean public ResourceBundleViewResolver viewResolver() { ResourceBundleViewResolver viewResolver = new ResourceBundleViewResolver(); viewResolver.setBasename("court-views"); return viewResolver; } }
29.277778
83
0.793169
1fa05411e5fc96c2845e734e16f95103b4fdfbc7
373
package org.batfish.representation.cisco_nxos; import java.io.Serializable; import javax.annotation.Nonnull; /** Configuration for a TACACS server. */ public final class TacacsServer implements Serializable { public TacacsServer(String host) { _host = host; } public @Nonnull String getHost() { return _host; } private final @Nonnull String _host; }
19.631579
57
0.739946
6390e8bcb2c85faf09ef8ca5f2f54dbc56f89eb7
3,277
package com.edu.monash.fit3077.view; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.lifecycle.ViewModelProvider; import com.edu.monash.fit3077.model.BidOffer; import com.edu.monash.fit3077.model.BidRequest; import com.edu.monash.fit3077.model.Student; import com.edu.monash.fit3077.model.Tutor; import com.edu.monash.fit3077.model.User; import com.edu.monash.fit3077.viewAdapter.AdvancedBidOfferListAdapter; import com.edu.monash.fit3077.viewModel.BidDetailsViewModel; import java.util.ArrayList; /** * This class represents a bid offer list which contains a SELECT button and a CHAT button beside each of the bid offer item. * The bid offer list is displayed under the BIDDERS tab on the bid request details page. * This class passes in callbacks to the RecyclerView adapter so that actions can be triggered when the SELECT/CHAT button is clicked. * This type of bid offer list is used for the bid initiator (student) and when the selected bid request is a CLOSE bid. */ public class AdvancedBidOfferListFragment extends BidOfferListFragmentFactory implements BidOfferSelectWinnerClickListener, BidOfferChatButtonClickListener { private AdvancedBidOfferListAdapter advancedAdapter; private BidDetailsViewModel bidDetailsViewModel; public AdvancedBidOfferListFragment(BidRequest bidRequest, ArrayList<BidOffer> bidOffers) { super(bidRequest, bidOffers); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View fragment = super.onCreateView(inflater, container, savedInstanceState); advancedAdapter = new AdvancedBidOfferListAdapter( this, this); super.initializeBidOfferRecyclerView(advancedAdapter); bidDetailsViewModel = new ViewModelProvider(requireActivity()).get(BidDetailsViewModel.class); return fragment; } @Override protected void setBidOffersRecyclerViewData(ArrayList<BidOffer> offers, String bidSubjectId) { // set the updated/latest bid offers to the RecyclerView // the changes of bid offers is being observed in the parent class: BidOfferListFragmentFactory advancedAdapter.setBidOffersData(offers, bidSubjectId); advancedAdapter.setSelectedBidRequest(super.selectedBidRequest); } @Override public void onChatButtonClicked(String bidRequestID, Student student, Tutor tutor) { ArrayList<User> chatParticipants = new ArrayList<>(); chatParticipants.add(student); chatParticipants.add(tutor); Intent chatRoomIntent = new Intent(requireActivity(), ChatActivity.class); chatRoomIntent.putExtra(ChatActivity.CHAT_BID_REQUEST, selectedBidRequest.getId()); chatRoomIntent.putExtra(ChatActivity.CHAT_PARTICIPANTS, chatParticipants); startActivity(chatRoomIntent); } @Override public void onSelectWinnerBidButtonClicked(BidOffer winnerBidOffer) { // updates an observable live data in the bid view model so that the program can know that user has chosen a winner bid offer bidDetailsViewModel.userCloseDownBidRequest(selectedBidRequest, winnerBidOffer); } }
45.513889
157
0.778761
f63845140af4e6e47dac8ac2d810979cfa0a4620
610
package com.cellum.rnd.protoapp; import android.text.TextUtils; import java.util.HashMap; import java.util.Map; /** * Created by oszkotamas on 19/09/15. */ public class ScreenFlow { private final Map<String, Screen> screens = new HashMap<String, Screen>(); public Screen forName(String name) { return screens.get(name); } public void reset() { screens.clear(); } public ScreenFlow add(Screen screen) { String name = screen.getName(); if(!TextUtils.isEmpty(name)) { screens.put(name, screen); } return this; } }
18.484848
78
0.618033
86e7bb0f1b55270db6d1d01766645b3f600be324
11,170
package com.joker.pager; import android.content.Context; import android.os.Handler; import android.os.Message; import android.support.annotation.NonNull; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import com.joker.pager.adapter.BannerViewPagerAdapter; import com.joker.pager.holder.ViewHolderCreator; import com.joker.pager.listener.OnItemClickListener; import java.lang.reflect.Field; import java.util.List; /** * BannerPager * * @author joker * @date 2018/1/10. */ public class BannerPager<T> extends RelativeLayout implements ViewPager.OnPageChangeListener { private static final String TAG = BannerPager.class.getSimpleName(); private BannerViewPager mViewPager; private BannerViewPagerAdapter<T> mAdapter; private LinearLayout mIndicatorLayout; private ImageView mCurrentIndicator; private PagerOptions mPagerOptions; private boolean isStartLoop; private boolean isDetached2StopLoop; private ViewPagerScroller mScroller; private OnPageChangeListener mPageChangeListener; private Handler mHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { int currentItem = mViewPager.getCurrentItem(); if (currentItem < mAdapter.getCount() - 1) { currentItem++; } else { currentItem = 0; } mViewPager.setCurrentItem(currentItem); sendHandlerEmptyMessage(); trace("切换轮播图"); return true; } }); private OnTouchListener mOnTouchListener = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { performClick(); return mViewPager.onTouchEvent(event); } }; public BannerPager(Context context) { this(context, null); } public BannerPager(Context context, AttributeSet attrs) { this(context, attrs, 0); } public BannerPager(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context, attrs, defStyleAttr); } private void init(Context context, AttributeSet attrs, int defStyleAttr) { LayoutInflater.from(context).inflate(R.layout.widget_banner_pager, this); mViewPager = (BannerViewPager) findViewById(R.id.widget_view_pager); mIndicatorLayout = (LinearLayout) findViewById(R.id.widget_indicator_container); mPagerOptions = new PagerOptions.Builder(context).build(); initViewPagerScroll(); mViewPager.setOffscreenPageLimit(3); mViewPager.addOnPageChangeListener(this); setOnTouchListener(mOnTouchListener); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); if (isDetached2StopLoop && !isStartLoop) { startTurning(); isDetached2StopLoop = false; } trace("onAttachedToWindow"); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (!isDetached2StopLoop && isStartLoop) { stopTurning(); isDetached2StopLoop = true; } trace("onDetachedFromWindow"); } /** * 设置ViewPager的滑动速度 */ private void initViewPagerScroll() { try { final Field scroller = ViewPager.class.getDeclaredField("mScroller"); scroller.setAccessible(true); mScroller = new ViewPagerScroller(mViewPager.getContext()); scroller.set(mViewPager, mScroller); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (mPageChangeListener != null) { mPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } } @Override public void onPageSelected(int position) { // 切换indicator if(mIndicatorLayout.getChildCount()==0){ return; } final int realPosition = position % mIndicatorLayout.getChildCount(); setIndicatorSelected(realPosition); if (mPageChangeListener != null) { mPageChangeListener.onPageSelected(realPosition); } } @Override public void onPageScrollStateChanged(int state) { if (mPageChangeListener != null) { mPageChangeListener.onPageScrollStateChanged(state); } } @Override public boolean dispatchTouchEvent(MotionEvent ev) { handleEvent(ev); return super.dispatchTouchEvent(ev); } private void handleEvent(MotionEvent ev) { //没有使能loop 或者 没有调用start if (!mPagerOptions.mLoopEnable || !isStartLoop) { return; } switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_OUTSIDE: trace("dispatchTouchEvent: " + ev.getX()); removeHandlerMessages(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: trace("dispatchTouchEvent: " + ev.getX()); removeHandlerMessages(); sendHandlerEmptyMessage(); break; default: trace("未知事件: " + ev.getAction()); break; } } private void sendHandlerEmptyMessage() { if (mHandler != null && mPagerOptions.mLoopEnable) { mHandler.sendEmptyMessageDelayed(0, mPagerOptions.mDelayedTime); } } private void removeHandlerMessages() { if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); } } private void setIndicatorSelected(int currentItem) { if (mCurrentIndicator != null) { mCurrentIndicator.setImageDrawable(mPagerOptions.mIndicatorDrawable[0]); mCurrentIndicator.setSelected(false); } final ImageView indicator = (ImageView) mIndicatorLayout.getChildAt(currentItem); indicator.setSelected(true); indicator.setImageDrawable(mPagerOptions.mIndicatorDrawable[1]); mCurrentIndicator = indicator; } /** * 设置 PagerOptions * * @param options options * @return BannerPager<T> */ public BannerPager<T> setPagerOptions(PagerOptions options) { mPagerOptions = options; return this; } /** * 设置 page data * * @param data List<T> * @param creator ViewHolderCreator */ public void setPages(@NonNull List<T> data, @NonNull ViewHolderCreator creator) { mAdapter = new BannerViewPagerAdapter<>(data, creator); mViewPager.setAdapter(mAdapter); mAdapter.setLoopEnable(mPagerOptions.mLoopEnable); mAdapter.setViewPager(mViewPager); initIndicator(); handlePagerOptions(); } private void initIndicator() { final int count = mAdapter.getRealCount(); mIndicatorLayout.removeAllViews(); IndicatorView indicator; for (int i = 0; i < count; i++) { indicator = new IndicatorView(getContext()); mIndicatorLayout.addView(indicator); indicator.setPagerOptions(mPagerOptions); } setIndicatorSelected(mViewPager.getCurrentItem()); trace("indicator count : " + mIndicatorLayout.getChildCount()); } private void handlePagerOptions() { //设置每页之间间距 mViewPager.setPageMargin(mPagerOptions.mPagePadding); //设置预显示宽 final ViewGroup.MarginLayoutParams mp = (MarginLayoutParams) mViewPager.getLayoutParams(); mp.leftMargin = mp.rightMargin = mPagerOptions.mPrePagerWidth; mViewPager.setLayoutParams(mp); //设置指示器位置 LayoutParams lp = (LayoutParams) mIndicatorLayout.getLayoutParams(); lp.addRule(mPagerOptions.mIndicatorAlign); if (mPagerOptions.mIndicatorMarginBottom != -1) { lp.bottomMargin = mPagerOptions.mIndicatorMarginBottom; } mIndicatorLayout.setLayoutParams(lp); //设置切换效果 mViewPager.setPageTransformer(true, mPagerOptions.mPageTransformer); //设置滚动速度 mScroller.setScrollDuration(mPagerOptions.mScrollDuration); //设置指示器显示隐藏 mIndicatorLayout.setVisibility(mPagerOptions.mIndicatorVisibility); } public void clearPages() { mAdapter.clearData(); initIndicator(); } public ViewPager getViewPager() { return mViewPager; } /** * 暂时不停供外部使用 */ private void setCurrentItem(int position) { if (mPagerOptions.mLoopEnable) { final int realCount = mAdapter.getRealCount(); final int multiple = mViewPager.getCurrentItem() / realCount; position = position + multiple * realCount; } mViewPager.setCurrentItem(position, false); trace("new position: " + position); } public boolean isStartLoop() { return isStartLoop; } /** * 开始轮播 */ public void startTurning() { if (mAdapter == null) { return; } if (isStartLoop) { stopTurning(); } mPagerOptions.mLoopEnable = true; mAdapter.setLoopEnable(true); mViewPager.addOnPageChangeListener(this); sendHandlerEmptyMessage(); isStartLoop = true; isDetached2StopLoop = false; trace("startTurning "); } /** * 停止轮播 */ public void stopTurning() { removeHandlerMessages(); mViewPager.removeOnPageChangeListener(this); isStartLoop = false; isDetached2StopLoop = true; trace("stopTurning "); } private void trace(String msg) { if (mPagerOptions.mDebug) { Log.d(TAG, "===> " + msg); } } /** * 获取ViewPager的滚动速度 */ public int getScrollDuration() { return mScroller.getScrollDuration(); } /** * 设置 page 改变监听 * * @param listener OnPageChangeListener */ public BannerPager<T> setOnPageChangeListener(OnPageChangeListener listener) { mPageChangeListener = listener; return this; } /** * 设置 Item点击监听 * * @param listener OnItemClickListener * @return BannerPager */ public BannerPager<T> setOnItemClickListener(OnItemClickListener listener) { mViewPager.setOnItemClickListener(listener); return this; } }
30.686813
98
0.635542
3d25904ab3e99cacab477de3dab3a8c8eeb232e2
1,108
import java.sql.Timestamp; public class Entry { private String id; private String state; private String type; private String host; private String timestamp; public Entry(String id, String state, String type, String host, String timestamp) throws Exception { this.id = id; this.state = state; this.type = type; this.host = host; this.timestamp = timestamp; } public String getId(){ return this.id;} public void setId(String id){ this.id = id; } public String getState(){ return this.state; } public void setState(String state){ this.state = state; } public String getType(){ return this.type; } public void setType(String type){ this.type = type; } public String getHost(){ return this.host; } public void setHost(String host){ this.host = host; } public String getTimestamp(){ return this.timestamp; } public void setTimestamp(String timestamp){ this.timestamp = timestamp; } }
19.103448
104
0.594765
9928a858e75b78459c8bf75252a9119c3f1d4478
29,230
/* * Copyright 2000-2020 Vaadin Ltd. * * 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.vaadin.client; import java.util.function.Supplier; import com.google.gwt.core.client.Duration; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.RepeatingCommand; import com.google.gwt.user.client.Timer; import com.vaadin.client.flow.collection.JsArray; import com.vaadin.client.flow.collection.JsCollections; import com.vaadin.client.flow.collection.JsMap; import com.vaadin.client.flow.collection.JsSet; import com.vaadin.client.flow.util.NativeFunction; import elemental.client.Browser; import elemental.dom.Document; import elemental.dom.Element; import elemental.dom.NodeList; import elemental.html.HeadElement; import elemental.html.LinkElement; import elemental.html.ScriptElement; import elemental.html.SpanElement; import elemental.html.StyleElement; /** * ResourceLoader lets you dynamically include external scripts and styles on * the page and lets you know when the resource has been loaded. * * You can also preload resources, allowing them to get cached by the browser * without being evaluated. This enables downloading multiple resources at once * while still controlling in which order e.g. scripts are executed. * * @author Vaadin Ltd * @since 1.0 */ public class ResourceLoader { private class StyleSheetLoadListener implements ResourceLoadListener { private final String url; private StyleSheetLoadListener(String url) { this.url = url; } @Override public void onLoad(ResourceLoadEvent event) { // Chrome, IE, Edge all fire load for errors, must check // stylesheet data if (BrowserInfo.get().isChrome() || BrowserInfo.get().isIE() || BrowserInfo.get().isEdge()) { int styleSheetLength = getStyleSheetLength(url); // Error if there's an empty stylesheet if (styleSheetLength == 0) { fireError(event); return; } } fireLoad(event); } @Override public void onError(ResourceLoadEvent event) { fireError(event); } } private class HtmlLoadListener implements ResourceLoadListener, Runnable { private final ResourceLoadEvent event; private boolean errorFired; private HtmlLoadListener(ResourceLoadEvent event) { this.event = event; } @Override public void run() { // Invoked through HTMLImports.whenReady if (!errorFired) { fireLoad(event); } } @Override public void onLoad(ResourceLoadEvent event) { if (!supportsHtmlWhenReady) { assert !errorFired; fireLoad(event); } } @Override public void onError(ResourceLoadEvent event) { assert !errorFired; errorFired = true; fireError(event); } } private class SimpleLoadListener implements ResourceLoadListener { @Override public void onLoad(ResourceLoadEvent event) { fireLoad(event); } @Override public void onError(ResourceLoadEvent event) { fireError(event); } } /** * Event fired when a resource has been loaded. */ public static class ResourceLoadEvent { private final ResourceLoader loader; private final String resourceData; /** * Creates a new event. * * @param loader * the resource loader that has loaded the resource * @param resourceData * the url or content of the loaded resource or the JS * expression that imports the resource */ public ResourceLoadEvent(ResourceLoader loader, String resourceData) { this.loader = loader; this.resourceData = resourceData; } /** * Gets the resource loader that has fired this event. * * @return the resource loader */ public ResourceLoader getResourceLoader() { return loader; } /** * Gets the absolute url or content of the loaded resource or the JS * expression that imports the resource. * * @return the absolute url or content of the loaded resource or the JS * expression that imports the resource */ public String getResourceData() { return resourceData; } } /** * Event listener that gets notified when a resource has been loaded. */ public interface ResourceLoadListener { /** * Notifies this ResourceLoadListener that a resource has been loaded. * Some browsers do not support any way of detecting load errors. In * these cases, onLoad will be called regardless of the status. * * @see ResourceLoadEvent * * @param event * a resource load event with information about the loaded * resource */ void onLoad(ResourceLoadEvent event); /** * Notifies this ResourceLoadListener that a resource could not be * loaded, e.g. because the file could not be found or because the * server did not respond. Some browsers do not support any way of * detecting load errors. In these cases, onLoad will be called * regardless of the status. * * @see ResourceLoadEvent * * @param event * a resource load event with information about the resource * that could not be loaded. */ void onError(ResourceLoadEvent event); } private final JsSet<String> loadedResources = JsCollections.set(); private final JsMap<String, JsArray<ResourceLoadListener>> loadListeners = JsCollections .map(); private Registry registry; private final boolean supportsHtmlWhenReady = GWT.isClient() && supportsHtmlWhenReady(); /** * Creates a new resource loader. You should not create you own resource * loader, but instead use {@link Registry#getResourceLoader()} to get an * instance. * * @param registry * the global registry * @param initFromDom * <code>true</code> if currently loaded resources should be * marked as loaded, <code>false</code> to ignore currently * loaded resources */ public ResourceLoader(Registry registry, boolean initFromDom) { this.registry = registry; if (initFromDom) { initLoadedResourcesFromDom(); } } /** * Populates the resource loader with the scripts currently added to the * page. */ private void initLoadedResourcesFromDom() { Document document = Browser.getDocument(); // detect already loaded scripts and stylesheets NodeList scripts = document.getElementsByTagName("script"); for (int i = 0; i < scripts.getLength(); i++) { ScriptElement element = (ScriptElement) scripts.item(i); String src = element.getSrc(); if (src != null && src.length() != 0) { loadedResources.add(src); } } NodeList links = document.getElementsByTagName("link"); for (int i = 0; i < links.getLength(); i++) { LinkElement linkElement = (LinkElement) links.item(i); String rel = linkElement.getRel(); String href = linkElement.getHref(); if (("stylesheet".equalsIgnoreCase(rel) || "import".equalsIgnoreCase(rel)) && href != null && href.length() != 0) { loadedResources.add(href); } } } /** * Load a script and notify a listener when the script is loaded. Calling * this method when the script is currently loading or already loaded * doesn't cause the script to be loaded again, but the listener will still * be notified when appropriate. * <p> * Loads all dependencies with {@code async = false} and * {@code defer = false} attribute values, see * {@link #loadScript(String, ResourceLoadListener, boolean, boolean)}. * * @param scriptUrl * the url of the script to load * @param resourceLoadListener * the listener that will get notified when the script is loaded */ public void loadScript(final String scriptUrl, final ResourceLoadListener resourceLoadListener) { loadScript(scriptUrl, resourceLoadListener, false, false); } /** * Load a script and notify a listener when the script is loaded. Calling * this method when the script is currently loading or already loaded * doesn't cause the script to be loaded again, but the listener will still * be notified when appropriate. * * * @param scriptUrl * url of script to load * @param resourceLoadListener * listener to notify when script is loaded * @param async * What mode the script.async attribute should be set to * @param defer * What mode the script.defer attribute should be set to */ public void loadScript(final String scriptUrl, final ResourceLoadListener resourceLoadListener, boolean async, boolean defer) { loadScript(scriptUrl, resourceLoadListener, async, defer, "text/javascript"); } /** * Load a script with type module and notify a listener when the script is * loaded. Calling this method when the script is currently loading or * already loaded doesn't cause the script to be loaded again, but the * listener will still be notified when appropriate. * * * @param scriptUrl * url of script to load. It should be an external URL. * @param resourceLoadListener * listener to notify when script is loaded * @param async * What mode the script.async attribute should be set to * @param defer * What mode the script.defer attribute should be set to */ public void loadJsModule(final String scriptUrl, final ResourceLoadListener resourceLoadListener, boolean async, boolean defer) { loadScript(scriptUrl, resourceLoadListener, async, defer, "module"); } private void loadScript(String scriptUrl, ResourceLoadListener resourceLoadListener, boolean async, boolean defer, String type) { final String url = WidgetUtil.getAbsoluteUrl(scriptUrl); ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(url, resourceLoadListener, loadListeners)) { ScriptElement scriptTag = Browser.getDocument() .createScriptElement(); scriptTag.setSrc(url); scriptTag.setType(type); scriptTag.setAsync(async); scriptTag.setDefer(defer); addOnloadHandler(scriptTag, new SimpleLoadListener(), event); getHead().appendChild(scriptTag); } } /** * Inlines a script and notify a listener when the script is loaded. Calling * this method when the script is currently loading or already loaded * doesn't cause the script to be loaded again, but the listener will still * be notified when appropriate. * * @param scriptContents * the script contents to inline * @param resourceLoadListener * listener to notify when script is loaded */ public void inlineScript(String scriptContents, final ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, scriptContents); if (loadedResources.has(scriptContents)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(scriptContents, resourceLoadListener, loadListeners)) { ScriptElement scriptElement = getDocument().createScriptElement(); scriptElement.setTextContent(scriptContents); scriptElement.setType("text/javascript"); addOnloadHandler(scriptElement, new SimpleLoadListener(), event); getHead().appendChild(scriptElement); } } private static Document getDocument() { return Browser.getDocument(); } private static HeadElement getHead() { return getDocument().getHead(); } /** * Loads an HTML import and notify a listener when the HTML import is * loaded. Calling this method when the HTML import is currently loading or * already loaded doesn't cause the HTML import to be loaded again, but the * listener will still be notified when appropriate. * * @param htmlUrl * url of HTML import to load * @param resourceLoadListener * listener to notify when the HTML import is loaded * @param async * loads the import asynchronously, if {@code true}, * synchronously otherwise */ public void loadHtml(final String htmlUrl, final ResourceLoadListener resourceLoadListener, boolean async) { final String url = WidgetUtil.getAbsoluteUrl(htmlUrl); ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(url, resourceLoadListener, loadListeners)) { LinkElement linkTag = getDocument().createLinkElement(); linkTag.setAttribute("rel", "import"); linkTag.setAttribute("href", url); if (async) { linkTag.setAttribute("async", "true"); } HtmlLoadListener listener = new HtmlLoadListener(event); addOnloadHandler(linkTag, listener, event); getHead().appendChild(linkTag); if (supportsHtmlWhenReady) { addHtmlImportsReadyHandler(listener); } } } /** * Inlines an HTML import and notify a listener when the HTML import is * loaded. Calling this method when the HTML import is currently loading or * already loaded doesn't cause the HTML import to be loaded again, but the * listener will still be notified when appropriate. * * @param htmlContents * the html contents to inline * @param resourceLoadListener * listener to notify when the HTML import is loaded */ public void inlineHtml(String htmlContents, final ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, htmlContents); if (loadedResources.has(htmlContents)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(htmlContents, resourceLoadListener, loadListeners)) { SpanElement spanElement = getDocument().createSpanElement(); spanElement.setInnerHTML(htmlContents); spanElement.setAttribute("hidden", "true"); HtmlLoadListener listener = new HtmlLoadListener(event); getDocument().appendChild(spanElement); addOnloadHandler(spanElement, listener, event); if (supportsHtmlWhenReady) { addHtmlImportsReadyHandler(listener); } } } /** * Sets the provided task to be run by <code>HTMLImports.whenReady</code>. * The task is run immediately if <code>HTMLImports.whenReady</code> is not * supported. * * @param task * the task to run, not <code>null</code> */ public void runWhenHtmlImportsReady(Runnable task) { assert task != null; if (supportsHtmlWhenReady) { addHtmlImportsReadyHandler(task); } else { task.run(); } } private static native boolean supportsHtmlWhenReady() /*-{ return !!($wnd.HTMLImports && $wnd.HTMLImports.whenReady); }-*/; private static native void addHtmlImportsReadyHandler(Runnable handler) /*-{ $wnd.HTMLImports.whenReady($entry(function() { handler.@Runnable::run()(); })); }-*/; /** * Adds an onload listener to the given element, which should be a link or a * script tag. The listener is called whenever loading is complete or an * error occurred. * * @param element * the element to attach a listener to * @param listener * the listener to call * @param event * the event passed to the listener */ public static native void addOnloadHandler(Element element, ResourceLoadListener listener, ResourceLoadEvent event) /*-{ element.onload = $entry(function() { element.onload = null; element.onerror = null; element.onreadystatechange = null; listener.@com.vaadin.client.ResourceLoader.ResourceLoadListener::onLoad(Lcom/vaadin/client/ResourceLoader$ResourceLoadEvent;)(event); }); element.onerror = $entry(function() { element.onload = null; element.onerror = null; element.onreadystatechange = null; listener.@com.vaadin.client.ResourceLoader.ResourceLoadListener::onError(Lcom/vaadin/client/ResourceLoader$ResourceLoadEvent;)(event); }); element.onreadystatechange = function() { if ("loaded" === element.readyState || "complete" === element.readyState ) { element.onload(arguments[0]); } }; }-*/; /** * Load a stylesheet and notify a listener when the stylesheet is loaded. * Calling this method when the stylesheet is currently loading or already * loaded doesn't cause the stylesheet to be loaded again, but the listener * will still be notified when appropriate. * * @param stylesheetUrl * the url of the stylesheet to load * @param resourceLoadListener * the listener that will get notified when the stylesheet is * loaded */ public void loadStylesheet(final String stylesheetUrl, final ResourceLoadListener resourceLoadListener) { final String url = WidgetUtil.getAbsoluteUrl(stylesheetUrl); final ResourceLoadEvent event = new ResourceLoadEvent(this, url); if (loadedResources.has(url)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(url, resourceLoadListener, loadListeners)) { LinkElement linkElement = getDocument().createLinkElement(); linkElement.setRel("stylesheet"); linkElement.setType("text/css"); linkElement.setHref(url); if (BrowserInfo.get().isSafariOrIOS()) { // Safari doesn't fire any events for link elements // See http://www.phpied.com/when-is-a-stylesheet-really-loaded/ Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { private final Duration duration = new Duration(); @Override public boolean execute() { int styleSheetLength = getStyleSheetLength(url); if (getStyleSheetLength(url) > 0) { fireLoad(event); return false; // Stop repeating } else if (styleSheetLength == 0) { // "Loaded" empty sheet -> most likely 404 error fireError(event); return true; } else if (duration.elapsedMillis() > 60 * 1000) { fireError(event); return false; } else { return true; // Continue repeating } } }, 10); } else { addOnloadHandler(linkElement, new StyleSheetLoadListener(url), event); if (BrowserInfo.get().isOpera()) { // Opera onerror never fired, assume error if no onload in x // seconds new Timer() { @Override public void run() { if (!loadedResources.has(url)) { fireError(event); } } }.schedule(5 * 1000); } } getHead().appendChild(linkElement); } } /** * Inlines a stylesheet and notify a listener when the stylesheet is loaded. * Calling this method when the stylesheet is currently loading or already * loaded doesn't cause the stylesheet to be loaded again, but the listener * will still be notified when appropriate. * * @param styleSheetContents * the contents to inline * @param resourceLoadListener * the listener that will get notified when the stylesheet is * loaded */ public void inlineStyleSheet(String styleSheetContents, final ResourceLoadListener resourceLoadListener) { final ResourceLoadEvent event = new ResourceLoadEvent(this, styleSheetContents); if (loadedResources.has(styleSheetContents)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (addListener(styleSheetContents, resourceLoadListener, loadListeners)) { StyleElement styleSheetElement = getDocument().createStyleElement(); styleSheetElement.setTextContent(styleSheetContents); styleSheetElement.setType("text/css"); addCssLoadHandler(styleSheetContents, event, styleSheetElement); getHead().appendChild(styleSheetElement); } } /** * Loads a dynamic import via the provided JS {@code expression} and reports * the result via the {@code resourceLoadListener}. * * @param expression * the JS expression which returns a Promise * @param resourceLoadListener * a listener to report the Promise result exection */ public void loadDynamicImport(String expression, ResourceLoadListener resourceLoadListener) { ResourceLoadEvent event = new ResourceLoadEvent(this, expression); NativeFunction function = new NativeFunction(expression); runPromiseExpression(expression, () -> function.call(null), () -> resourceLoadListener.onLoad(event), () -> resourceLoadListener.onError(event)); } private void addCssLoadHandler(String styleSheetContents, ResourceLoadEvent event, StyleElement styleSheetElement) { if (BrowserInfo.get().isSafariOrIOS() || BrowserInfo.get().isOpera()) { // Safari and Opera don't fire any events for link elements // See http://www.phpied.com/when-is-a-stylesheet-really-loaded/ new Timer() { @Override public void run() { if (loadedResources.has(styleSheetContents)) { fireLoad(event); } else { fireError(event); } } }.schedule(5 * 1000); } else { addOnloadHandler(styleSheetElement, new ResourceLoadListener() { @Override public void onLoad(ResourceLoadEvent event) { fireLoad(event); } @Override public void onError(ResourceLoadEvent event) { fireError(event); } }, event); } } private static native int getStyleSheetLength(String url) /*-{ for(var i = 0; i < $doc.styleSheets.length; i++) { if ($doc.styleSheets[i].href === url) { var sheet = $doc.styleSheets[i]; try { var rules = sheet.cssRules; if (rules === undefined) { rules = sheet.rules; } if (rules === null) { // Style sheet loaded, but can't access length because of XSS -> assume there's something there return 1; } // Return length so we can distinguish 0 (probably 404 error) from normal case. return rules.length; } catch (err) { return 1; } } } // No matching stylesheet found -> not yet loaded return -1; }-*/; private static boolean addListener(String resourceId, ResourceLoadListener listener, JsMap<String, JsArray<ResourceLoadListener>> listenerMap) { JsArray<ResourceLoadListener> listeners = listenerMap.get(resourceId); if (listeners == null) { listeners = JsCollections.array(); listeners.push(listener); listenerMap.set(resourceId, listeners); return true; } else { listeners.push(listener); return false; } } private void fireError(ResourceLoadEvent event) { registry.getSystemErrorHandler() .handleError("Error loading " + event.getResourceData()); String resource = event.getResourceData(); JsArray<ResourceLoadListener> listeners = loadListeners.get(resource); loadListeners.delete(resource); if (listeners != null && !listeners.isEmpty()) { for (int i = 0; i < listeners.length(); i++) { ResourceLoadListener listener = listeners.get(i); if (listener != null) { listener.onError(event); } } } } private void fireLoad(ResourceLoadEvent event) { Console.log("Loaded " + event.getResourceData()); String resource = event.getResourceData(); JsArray<ResourceLoadListener> listeners = loadListeners.get(resource); loadedResources.add(resource); loadListeners.delete(resource); if (listeners != null && !listeners.isEmpty()) { for (int i = 0; i < listeners.length(); i++) { ResourceLoadListener listener = listeners.get(i); if (listener != null) { listener.onLoad(event); } } } } private static native void runPromiseExpression(String expression, Supplier<Object> promiseSupplier, Runnable onSuccess, Runnable onError) /*-{ try { var promise = promiseSupplier.@java.util.function.Supplier::get(*)(); if ( !(promise instanceof $wnd.Promise )){ throw new Error('The expression "'+expression+'" result is not a Promise.'); } promise.then( function(result) { onSuccess.@java.lang.Runnable::run(*)(); } , function(error) { console.error(error); onError.@java.lang.Runnable::run(*)(); } ); } catch(error) { console.error(error); onError.@java.lang.Runnable::run(*)(); } }-*/; }
37.141042
146
0.587
28bbd6eebb271aaaaef3fef6b01cc59f16539426
409
package com.kayosystem.honki.chapter08.lesson36; public class Attendance { public String arrive; public String leave; public void setLeave(String leave) { this.leave = leave; } public void setArrive(String arrive) { this.arrive = arrive; } public String getLeave() { return leave; } public String getArrive() { return arrive; } }
16.36
48
0.616137
c052aa1d81006eba140d4a84cf1b998a4aa032b6
1,895
package com.logicaldoc.gui.frontend.client.services; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.logicaldoc.gui.common.client.ServerException; import com.logicaldoc.gui.common.client.beans.GUIParameter; /** * The client side stub for the Document Service. This service allows r/w * operations on documents. * * @author Marco Meschieri - LogicalDOC * @since 7.3.1 */ @RemoteServiceRelativePath("update") public interface UpdateService extends RemoteService { /** * Check if the current installation has an update package available * * @param userNo The current UserNo * @param currentRelease The actual release * @return List of informations about the available update package or null */ public GUIParameter[] checkUpdate(String userNo, String currentRelease); /** * Downloads an update package * * @param userNo The current UserNo * @param id ID of the package to download * @param fileName Name of the package file * @param fileName Size of the package file expressed in MB * @return 0 if the download was successful */ public void download(String userNo, String id, String fileName, int size); /** * Confirms an update package * * @param userNo The update file to confirm * @return The path of the update folder */ public String confirm(String updateFileName) throws ServerException; /** * Retrieves more informations from * * @param updateFileName File name of the downloaded update package * @return ChangeLog and Install file contents */ public String[] getNotes(String updateFileName) throws ServerException; /** * Checks the status of the current download process * * @return download status code and download progress */ public int[] checkDownloadStatus(); }
31.583333
76
0.724538
d2c5ec1b90ace797ea2bb87e10f3e4b516c0dd29
1,288
package cruft.wtf.gimlet.jdbc.task; import cruft.wtf.gimlet.jdbc.SqlUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.sql.*; import java.util.List; public class SimpleQueryTaskTest { private static Connection connection; @BeforeClass public static void setup() throws SQLException { connection = DriverManager.getConnection("jdbc:hsqldb:mem:simplequerytasktest;shutdown=true"); System.out.println("Created connection"); } @AfterClass public static void teardown() throws SQLException { connection.close(); System.out.println("Closed connection"); } @Test public void test() throws Exception { List<String> queries = SqlUtil.parseQueries("/create.sql"); for (String q : queries) { Statement stmt = connection.createStatement(); stmt.executeQuery(q); stmt.close(); System.out.println("Executed query " + q); } Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("select * from customer"); while (rs.next()) { System.out.println(rs.getString(2)); } rs.close(); } @Test public void herro() { } }
25.76
102
0.636646
4b51a255803dd8e8cf7a9161b9910e8c63db0695
180
package pl.exsio.querydsl.entityql.jdbc; import org.springframework.data.relational.core.mapping.NamingStrategy; public class DefaultNamingStrategy implements NamingStrategy { }
25.714286
71
0.85
8b4d970f5767585eace6978006952d339d75ecaf
334
package org.redline_rpm.changelog; /** * This exception is thrown when Changelog entries are not in descending order by date * Copyright (c) 2007-2016 FreeCompany */ public class DatesOutOfSequenceException extends ChangelogParseException { public DatesOutOfSequenceException() { super(OUT_OF_SEQUENCE); } }
22.266667
87
0.748503
42b85448935ab6978a989a2fbfc83095ff167d55
3,129
/** * Copyright 2009-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mybatis.guice; import javax.inject.Inject; import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNotNull; public abstract class AbstractMyBatisModuleTestCase { @Inject private Contact contact; @Inject private ContactMapperClient contactMapperClient; @Inject private Counter counter; public void setContact(Contact contact) { this.contact = contact; } public void setContactMapperClient(ContactMapperClient contactMapperClient) { this.contactMapperClient = contactMapperClient; } @Test public void verifyNotNullMapper() { assertNotNull(this.contactMapperClient); } @Test public void insertContact() throws Exception { this.contactMapperClient.insert(this.contact); } @Test public void selectAllContacts() throws Exception { List<Contact> contacts = this.contactMapperClient.getAll(); assert contacts.size() > 0 : "Expected not empty contact table"; } @Test public void reSelectAllContacts() throws Exception { List<Contact> contacts = this.contactMapperClient.getAll(); assert contacts.size() > 0 : "Expected not empty contact table"; } @Test public void selectContact() throws Exception { Contact contact = this.contactMapperClient.selectById(this.contact.getId()); assert contact != null : "impossible to retrieve Contact with id '" + this.contact.getId() + "'"; assert this.contact.equals(contact) : "Expected " + this.contact + " but found " + contact; } @Test public void selectContactWithTypeHandler() throws Exception { Contact contact = this.contactMapperClient.selectByIdWithTypeHandler(this.contact.getId()); assert contact != null : "impossible to retrieve Contact with id '" + this.contact.getId() + "'"; assert this.contact.equals(contact) : "Expected " + this.contact + " but found " + contact; } @Test public void catchSQLException() throws Exception { Assertions.assertThrows(CustomException.class, () -> { this.contactMapperClient.brokenInsert(this.contact); }); } @Test public void testCountInterceptor() throws Exception { counter.reset(); assert 0 == counter.getCount() : "Expected 0 update in counter, but was " + counter.getCount(); this.contactMapperClient.update(contact); assert 1 == counter.getCount() : "Expected 1 update in Executor, but was " + counter.getCount(); } }
32.257732
101
0.720678
66025d0e5dcb4ec0c8e67f6842515aac038d64b3
2,281
packagecom.oserp.hiveudf; importorg.apache.hadoop.hive.ql.exec.UDAF; importorg.apache.hadoop.hive.ql.exec.UDAFEvaluator; importorg.apache.hadoop.hive.serde2.io.DoubleWritable; importorg.apache.hadoop.io.IntWritable; publicclass HiveAvgextends UDAF { public staticclass AvgEvaluate implements UDAFEvaluator { public staticclass PartialResult { public intcount; public doubletotal; public PartialResult() { count = 0; total = 0; } } private PartialResultpartialResult; @Override public voidinit() { partialResult = new PartialResult(); } public booleaniterate(IntWritable value) { // 此处一定要判断partialResult是否为空,否则会报错 // 原因就是init函数只会被调用一遍,不会为每个部分聚集操作去做初始化 //此处如果不加判断就会出错 if (partialResult==null) { partialResult =new PartialResult(); } if (value !=null) { partialResult.total =partialResult.total +value.get(); partialResult.count=partialResult.count + 1; } return true; } public PartialResult terminatePartial() { returnpartialResult; } public booleanmerge(PartialResult other) { partialResult.total=partialResult.total + other.total; partialResult.count=partialResult.count + other.count; return true; } public DoubleWritable terminate() { return newDoubleWritable(partialResult.total /partialResult.count); } } }
17.022388
91
0.428759
3a1ad1a7d9e9ac827b8bf488e62b98c58a5e8388
778
/** * */ package com.aws.resources.domain; import java.io.Serializable; /** * @author milindbangar * */ public class KeyPairObj implements Serializable{ /** * */ private static final long serialVersionUID = 1L; private String keyFingerprint; private String keyName; /** * @return the keyFingerprint */ public String getKeyFingerprint() { return keyFingerprint; } /** * @param keyFingerprint the keyFingerprint to set */ public void setKeyFingerprint(String keyFingerprint) { this.keyFingerprint = keyFingerprint; } /** * @return the keyName */ public String getKeyName() { return keyName; } /** * @param keyName the keyName to set */ public void setKeyName(String keyName) { this.keyName = keyName; } }
14.407407
55
0.669666
848cdec840f2843cf765598319071b7fdf2d6c1c
538
package com.javatmp.demo.jpa.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import javax.persistence.*; @Data @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(onlyExplicitlyIncluded = true) @Entity @Table(name = "Customer", schema = "spring") public class Customer { @EqualsAndHashCode.Include @Id @GeneratedValue(strategy= GenerationType.IDENTITY) private Long id; private String firstName; private String lastName; }
20.692308
54
0.776952
83dd71f24191ded70a10141b00452e603118361d
5,154
/******************************************************************************* * Copyright 2021 exense 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 ch.exense.step.library.kw.monitoring; import java.io.BufferedReader; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.charset.Charset; import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.script.Bindings; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import ch.exense.step.library.commons.AbstractProcessKeyword; import step.handlers.javahandler.Keyword; public class TypePerfKeywords extends AbstractProcessKeyword { protected List<Metric> metrics; protected ScriptEngine engine; protected String hostname; public TypePerfKeywords() { metrics = new ArrayList<Metric>(); ScriptEngineManager manager = new ScriptEngineManager(); engine = manager.getEngineByName("groovy"); hostname = getLocalHostname(); } @Keyword(name = "Typeperf", schema = "{\"properties\":{}}") public void getTypePerf() throws Exception { String cmd = buildCommandLine(); executeManagedCommand(cmd, PROCESS_TIMEOUT, new OutputConfiguration(false, 1000, 10000, true, true), p -> { try { executionPostProcess(p.getProcessOutputLog()); } catch (Exception e) { throw new RuntimeException(e); } }); } private String createTypePerfArgs() throws Exception { StringBuilder sb = new StringBuilder(); InputStream inputStream = this.getClass().getResourceAsStream("/typePerf.csv"); try (BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream))) { String line; while ((line = bf.readLine()) != null) { if (line.startsWith("Metric_name,Typeperf_counter")) { continue; } String[] columns = line.split(","); String expression = (columns.length > 2) ? columns[2] : ""; metrics.add(new Metric(columns[0], columns[1], expression)); sb.append(" \"").append(columns[1]).append("\""); } sb.append(" -sc 1"); if (input.containsKey("hostname")) { sb.append(" -s ").append(input.getString("hostname")); } } return sb.toString(); } protected void executionPostProcess(File file) throws Exception { // Extract the output line with values ex: "04/04/2019 // 14:05:07.730","79.863592","9181.000000" String line = Files.readAllLines(file.toPath(), Charset.defaultCharset()).get(2).replaceAll("\"", ""); String[] values = line.split(","); Bindings bindings = engine.createBindings(); if (metrics.size() == (values.length - 1)) { for (int i = 1; i < values.length; i++) { long value = Math.round(Double.parseDouble(values[i])); if (!metrics.get(i - 1).getGroovyExpression().isEmpty()) { bindings.put("value", value); Object gResult = engine.eval(metrics.get(i - 1).getGroovyExpression(), bindings); value = (long) gResult; } Map<String, Object> map = new HashMap<String, Object>(); map.put("eId", "OSmonitor"); map.put("hostname", hostname); String name = metrics.get(i - 1).getName(); output.addMeasure(name, value, map); output.add(name, value); } } } protected String buildCommandLine() throws Exception { return "typeperf " + createTypePerfArgs(); } protected String getLocalHostname() { String hostname = null; try { InetAddress ip = InetAddress.getLocalHost(); hostname = ip.getHostName(); } catch (UnknownHostException e) { logger.error("Error while getting local hostname", e); } return hostname; } public class Metric { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCounter() { return counter; } public void setCounter(String counter) { this.counter = counter; } public String getGroovyExpression() { return groovyExpression; } public void setGroovyExpression(String groovyExpression) { this.groovyExpression = groovyExpression; } public Metric(String name, String counter, String groovyExpression) { super(); this.name = name; this.counter = counter; this.groovyExpression = groovyExpression; } private String counter; private String groovyExpression; } }
31.426829
110
0.661428
3aecd6374204ad0e8f33b2e4e05c34bec68fec94
495
package com.javase.designPattern.strategy.impl; import com.javase.designPattern.strategy.BusinessProcess; import com.javase.designPattern.strategy.ProcessContext; import com.javase.designPattern.strategy.UserModel; /** * 发消息处理器 * @author 三歪 */ public class SendMessageProcess implements BusinessProcess { @Override public void process(ProcessContext context) { UserModel user = (UserModel) context.getModel(); System.out.println("给"+user.getName()+"发消息"); } }
24.75
60
0.745455
740506536910a8c2b9998908bf3be7332f601847
5,149
/* * Copyright (c) 2010, Michael Grossmann, Lukas Gross * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the jo-widgets.org nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ package org.jowidgets.spi.impl.swt.common.widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.jowidgets.common.image.IImageConstant; import org.jowidgets.common.types.Markup; import org.jowidgets.spi.impl.swt.common.image.SwtImageRegistry; import org.jowidgets.spi.impl.swt.common.util.AlignmentConvert; import org.jowidgets.spi.impl.swt.common.util.FontProvider; import org.jowidgets.spi.widgets.IButtonSpi; import org.jowidgets.spi.widgets.setup.IButtonSetupSpi; public class ButtonImpl extends AbstractActionControl implements IButtonSpi { private final SwtImageRegistry imageRegistry; public ButtonImpl(final Object parentUiReference, final IButtonSetupSpi setup, final SwtImageRegistry imageRegistry) { super(new Button((Composite) parentUiReference, SWT.NONE), imageRegistry); this.imageRegistry = imageRegistry; setText(setup.getText()); setToolTipText(setup.getToolTipText()); setIcon(setup.getIcon()); setMarkup(setup.getMarkup()); getUiReference().setAlignment(AlignmentConvert.convert(setup.getAlignment())); getUiReference().addListener(SWT.Selection, new Listener() { @Override public void handleEvent(final Event event) { fireActionPerformed(); } }); } @Override public Button getUiReference() { return (Button) super.getUiReference(); } @Override public void setText(final String text) { if (text != null) { getUiReference().setText(text); } else { setText(""); } } @Override public void setIcon(final IImageConstant icon) { getUiReference().setImage(imageRegistry.getImage(icon)); } @Override public void setMarkup(final Markup markup) { final Button button = this.getUiReference(); final Font newFont = FontProvider.deriveFont(button.getFont(), markup); button.setFont(newFont); } @Override public void setFontSize(final int size) { getUiReference().setFont(FontProvider.deriveFont(getUiReference().getFont(), size)); } @Override public void setFontName(final String fontName) { getUiReference().setFont(FontProvider.deriveFont(getUiReference().getFont(), fontName)); } @Override public void push() { final Event e = new Event(); final boolean focus = getUiReference().forceFocus(); if (focus) { e.type = SWT.KeyDown; e.keyCode = SWT.CR; e.widget = getUiReference(); Display.getCurrent().post(e); } else { // TODO LG exception handling e.type = SWT.MouseMove; final Point widgetPos = getUiReference().toDisplay(getUiReference().getLocation().x, getUiReference().getLocation().y); e.x = widgetPos.x; e.y = widgetPos.y; Display.getCurrent().post(e); e.type = SWT.MouseDown; e.button = 1; Display.getCurrent().post(e); e.type = SWT.MouseUp; Display.getCurrent().post(e); } } }
38.140741
132
0.673529