blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2fef920b145ef7cb29ee379fe3161a91d4106e03 | 8e11c5e7cecc9ade874bbd24ace417938e8a9e87 | /src/main/java/com/ygy/java/concurrent/aqs/CyclicBarrierExample3.java | 0e1634707d75b8d688ab432991cb841d167c3f2b | [] | no_license | 1067649786/java | 84ac0253b25c616243ea0044ce8d223b8601f881 | fdfbcf6f9e3dfca5914254bf1f1a0df9007bfe0d | refs/heads/main | 2023-01-20T14:45:55.167131 | 2020-11-18T09:42:44 | 2020-11-18T09:42:44 | 311,560,931 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,174 | java | package com.ygy.java.concurrent.aqs;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* 项目名称:java
* 类名称:CyclicBarrierExample
* 类描述:
*/
public class CyclicBarrierExample3 {
private static CyclicBarrier barrier=new CyclicBarrier(5,()->{
System.out.println("callback is running");
});
public static void main(String[] args) throws Exception {
ExecutorService executorService= Executors.newCachedThreadPool();
for (int i=0;i<10;i++){
final int threadNum=i;
Thread.sleep(100);
executorService.execute(()->{
try{
race(threadNum);
} catch (Exception e){
e.getMessage();
}
});
}
executorService.shutdown();
}
private static void race(int threadNum) throws Exception{
Thread.sleep(1000);
System.out.println(threadNum+" is ready");
barrier.await();
System.out.println(threadNum+" continue");
}
}
| [
"1067649786@qq.com"
] | 1067649786@qq.com |
fca54dc73bda18f392414e26ea5ecb783b6ae72e | 1054693ffcbfda0bf8ce5b8dab932db670e34c78 | /src/com/android/cyborg/ViewNode2.java | e376dd345471a7391a34be2aa6bef67ee1e28120 | [] | no_license | lmanul/cyborg | 1ad9a5d279fe9b7d75e139e33450a23b83bc73f5 | dcf1c93eb259ac5d02ced609d6ca8473f5e4a614 | refs/heads/master | 2021-06-14T15:06:01.846599 | 2017-03-17T22:37:29 | 2017-03-17T22:37:29 | 67,167,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,437 | java | /*
* Copyright (C) 2016 The Android Open Source Project
*
* 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.android.cyborg;
import java.util.Map;
public class ViewNode2 extends ViewNode {
ViewNode2(Window window, ViewNode parent) {
super(window, parent);
}
public void initialize(Map<Short, Object> viewProperties,
ViewDumpParser parser) {
Object v = viewProperties.get(parser.getPropertyKey("meta:__name__"));
if (v instanceof String) {
name = (String)v;
}
v = viewProperties.get(parser.getPropertyKey("meta:__hash__"));
if (v instanceof Integer) {
hashCode = Integer.toHexString((Integer) v);
}
id = "unknown";
width = height = 10;
measureTime = layoutTime = drawTime = -1;
loadProperties(viewProperties, parser);
}
private void loadProperties(Map<Short, Object> viewProperties, ViewDumpParser parser) {
for (Map.Entry<Short, Object> p : viewProperties.entrySet()) {
ViewNode.Property property = new ViewNode.Property();
property.name = parser.getPropertyName(p.getKey());
Object v = p.getValue();
property.value = v != null ? v.toString() : "";
properties.add(property);
namedProperties.put(property.name, property);
}
id = namedProperties.containsKey("id") ? namedProperties.get("id").value : "unknown";
left = getInt("layout:left", 0);
top = getInt("layout:top", 0);
width = getInt("layout:width", 0);
height = getInt("layout:height", 0);
scrollX = getInt("layout:scrollX", 0);
scrollY = getInt("layout:scrollY", 0);
paddingLeft = getInt("padding:paddingLeft", 0);
paddingRight = getInt("padding:paddingRight", 0);
paddingTop = getInt("padding:paddingTop", 0);
paddingBottom = getInt("padding:paddingBottom", 0);
marginLeft = getInt("layout_leftMargin", Integer.MIN_VALUE);
marginRight = getInt("layout_rightMargin", Integer.MIN_VALUE);
marginTop = getInt("layout_topMargin", Integer.MIN_VALUE);
marginBottom = getInt("layout_bottomMargin", Integer.MIN_VALUE);
baseline = getInt("layout:baseline", 0);
willNotDraw = getBoolean("drawing:willNotDraw", false);
hasFocus = getBoolean("focus:hasFocus", false);
hasMargins =
marginLeft != Integer.MIN_VALUE && marginRight != Integer.MIN_VALUE
&& marginTop != Integer.MIN_VALUE && marginBottom != Integer.MIN_VALUE;
for (String name : namedProperties.keySet()) {
int index = name.indexOf(':');
if (index != -1) {
categories.add(name.substring(0, index));
}
}
if (categories.size() != 0) {
categories.add(MISCELLANIOUS);
}
}
}
| [
"manucornet@google.com"
] | manucornet@google.com |
97089cebaa9045cd92dbfc2a8ccf83fc0a215ccf | 7e733f3dea50f0fdf90c950d57a81bb604636052 | /src/com/lyw/model/signleton/Singleton_5.java | 7c8df60590d386e825803fc78179d6ef4f0e2b96 | [] | no_license | responsibilities/mytest | 0a92d9ce52992632b1a661a95ed16867ad7b544f | 1a21ba8581d7663b59c58b7aa04696d297397152 | refs/heads/master | 2021-06-23T12:28:10.026027 | 2020-10-28T13:36:55 | 2020-10-28T13:36:55 | 130,060,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 528 | java | package com.lyw.model.signleton;
/**
* 静态内部类方式
* JVM保证单例
* 加载外部类时不会加载内部类,这样可以实现懒加载
* @author lyw
* @date 2020/10/28 21:17
*/
public class Singleton_5 {
private static Singleton_5 instance = null;
private Singleton_5() {}
private static class Singleton_5_Holder {
private static final Singleton_5 INSTANCE = new Singleton_5();
}
public static Singleton_5 getInstance() {
return Singleton_5_Holder.INSTANCE;
}
}
| [
"lyw9141@foxmail.com"
] | lyw9141@foxmail.com |
4b175784e1671d710aeb69c90b77a3998cc41647 | b9de1813f91dfba04eaca03c9972ed7cece4430f | /src/br/game/reuse/lese/view/ComponentWalkerView.java | eacd89f1a5666a61aef26ff18a454c1ef05e297c | [] | no_license | cassios/LeSE | 06ba728af9a1a15b94ec142e80b25420d7321127 | 3f39918c378533909af694467615c8acb8883004 | refs/heads/master | 2021-01-19T08:55:42.867298 | 2016-05-29T15:12:20 | 2016-05-29T15:12:20 | 56,641,826 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,173 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.game.reuse.lese.view;
import br.game.reuse.lese.view.interfaces.AbstractComponent;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/**
*
* @author bruno
*/
public class ComponentWalkerView extends AbstractComponent {
public JLabel label;
private static final String IMAGE_QUESTION = "../images/questionWalker.png";
private static final String IMAGE_JOKER = "../images/jokerWalker.png";
private static final String IMAGE_START = "../images/startWalker.png";
public ComponentWalkerView() {
if (label == null) {
label = new JLabel();
}
}
@Override
public void addComponent(AbstractComponent component) {
Component[] comps = component.container.getComponents();
Component comp = null;
for (Component c : comps) {
if (c instanceof JLabel) {
String name = "house" + component.code;
// System.out.println(c.getName());
if (c.getName().equals(name)) {
comp = c;
}
}
}
component.container.remove(comp);
component.container.remove(label);
ImageIcon imageStart = new ImageIcon(getClass().getResource(IMAGE_QUESTION));
label = new JLabel(imageStart);
label.setOpaque(true);
label.setBackground(Color.white);
GridBagConstraints c = new GridBagConstraints();
c.weightx = 0.5;
c.weighty = 0.5;
c.fill = GridBagConstraints.HORIZONTAL;
// c.gridx = component.positionX;
// c.gridy = component.positionY;
component.container.add(label, c);
}
@Override
public void actionPerformed(ActionEvent ae) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
| [
"bruno@linux-PC"
] | bruno@linux-PC |
d1659d563ca6cc417666d7773f6ac6c9b99ab418 | c7967ec500b210513aa0b1f540144c931ca687ac | /알고리즘 스터디/개인공부/DynamicPrograming/FastAdd.java | 0dd03962805aeddb55d24f02b5db4a67ea9a8567 | [] | no_license | sunminky/algorythmStudy | 9a88e02c444b10904cebae94170eba456320f8e8 | 2ee1b5cf1f2e5f7ef87b44643210f407c4aa90e2 | refs/heads/master | 2023-08-17T01:49:43.528021 | 2023-08-13T08:11:37 | 2023-08-13T08:11:37 | 225,085,243 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 918 | java | package goorm;
import java.util.Scanner;
public class FastAdd {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int upper = scanner.nextInt(); //1부터 upper 까지 입력받을 값
System.out.println(addRecusively(upper)); //1~upper까지 더함
}
private static int addRecusively(int limit) {
if(limit == 1) //더하는 숫자들이 1~1 이면 종료
return 1;
int prev = addRecusively(limit/2); //이전에 값을 계산
int late = prev + limit/2 * Math.round((float)limit/2); //예를 들어 1~6까지 합 = (1+2+3) + (3+1 + 3+2 + 3+3)
int result = late + prev;
boolean isOdd = limit%2 == 1; //만약 더해져야 할 숫자가 홀수개라면
if(isOdd)
result += Math.round((float)limit/2); //정 가운데 수를 더해줌
return result;
}
}
| [
"suns1502@gmail.com"
] | suns1502@gmail.com |
6ea5db1110c29f579df9a39ccebb8be741082c3b | a4d06fb9961e014bbbefcadb65125b43670b2a53 | /src.com.solid.LSP.java | ef2b557d86d57a7512554e2f015cd8282cc18df5 | [] | no_license | lakith/SOLID-Principles | 66d1fb548ec2b4fb4343179b1e7f45073fc18cce | 7df4f8b8c07fb929ff3fda913330421e7dd70e84 | refs/heads/master | 2020-05-18T20:27:41.338502 | 2019-05-04T05:35:10 | 2019-05-04T05:35:10 | 184,633,589 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,675 | java | package src.com.solid.LSP;
class Rectangle
{
protected int width, height;
public Rectangle() {
}
public Rectangle(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getArea() { return width*height; }
@Override
public String toString() {
return "Rectangle{" +
"width=" + width +
", height=" + height +
'}';
}
public boolean isSquare()
{
return width == height;
}
}
class Square extends Rectangle
{
public Square() {
}
public Square(int size) {
width = height = size;
}
@Override
public void setWidth(int width) {
super.setWidth(width);
super.setHeight(width);
}
@Override
public void setHeight(int height) {
super.setHeight(height);
super.setWidth(height);
}
}
class RectangleFactory
{
public static Rectangle newSquare(int side)
{
return new Rectangle(side, side);
}
public static Rectangle newRectangle(int width, int height)
{
return new Rectangle(width, height);
}
}
class LSPDemo
{
// maybe conform to ++
static void useIt(Rectangle r)
{
int width = r.getWidth();
r.setHeight(10);
System.out.println("Expected area of " + (width*10) + ", got " + r.getArea());
}
public static void main(String[] args) {
Rectangle rc = new Rectangle(2, 3);
useIt(rc);
Rectangle sq = new Square();
sq.setHeight(5);
sq.setWidth(10);
useIt(sq);
}
} | [
"lakith1995@gmail.com"
] | lakith1995@gmail.com |
8a39d1913a8622f49591cd81a16d7aeb021e296a | a1f170211f658be47ebef6d58686f9010959e877 | /src/main/java/CF277_5E.java | 1924097e7a4b6f59c0956a41af286393c796d45d | [] | no_license | tasyrkin/Codeforces | cdd1c2cbee8c43b03cff3205e46fccf76deb9977 | 58ef55a399d092cdb5a9328ff41c0bcd1363496c | refs/heads/master | 2020-07-04T05:00:38.185228 | 2019-01-06T20:35:59 | 2019-01-06T20:36:18 | 33,376,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 155 | java | import java.util.Scanner;
public class CF277_5E {
public static void main(final String[] args) {
Scanner sc = new Scanner(System.in);
}
}
| [
"tasyrkin@gmail.com"
] | tasyrkin@gmail.com |
42d7bf12baafa1c722a34e15ea1a87693d125ab4 | 1b15bd742ae56cb50642c0d6dc807ef10febccfd | /Point.java | eaded4ddaa71e40162db59454fb792b52128b29f | [] | no_license | turrence/miners-and-things | bf4c4ab44c973683d67b2f8d3d6515c5a50b8a04 | 2851c66ffaeab13c89b965148ca7b8cef9619fc9 | refs/heads/master | 2021-04-09T12:54:32.783378 | 2018-03-17T07:47:38 | 2018-03-17T07:47:38 | 125,594,858 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | final class Point
{
public final int x;
public final int y;
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public String toString()
{
return "(" + x + "," + y + ")";
}
public boolean equals(Object other)
{
return other instanceof Point &&
((Point)other).x == this.x &&
((Point)other).y == this.y;
}
public int hashCode()
{
int result = 17;
result = result * 31 + x;
result = result * 31 + y;
return result;
}
public int distanceSquared(Point p2) {
int deltaX = x - p2.x;
int deltaY = y - p2.y;
return deltaX * deltaX + deltaY * deltaY;
}
}
| [
"ssereesa@calpoly.edu"
] | ssereesa@calpoly.edu |
65b4e732bbaf4d1fe62e3ba70f4476f175e37f0c | 95c49f466673952b465e19a5ee3ae6eff76bee00 | /src/main/java/kotlin/p2253l/C32631a.java | d057b28a76b70a143c85abe0e89d17b3f3c7786e | [] | no_license | Phantoms007/zhihuAPK | 58889c399ae56b16a9160a5f48b807e02c87797e | dcdbd103436a187f9c8b4be8f71bdf7813b6d201 | refs/heads/main | 2023-01-24T01:34:18.716323 | 2020-11-25T17:14:55 | 2020-11-25T17:14:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package kotlin.p2253l;
import kotlin.Metadata;
@Metadata
/* renamed from: kotlin.l.a */
public final class C32631a extends Char {
}
| [
"seasonpplp@qq.com"
] | seasonpplp@qq.com |
73e2b03661d28804cbd87dbbdf143ee234060b1f | e2ef2b296e12f1ec79e3e661faf26cc3844f2c11 | /Android App/iTalker/app/src/main/java/net/fengyun/italker/italker/frags/main/Wechat/BaseActivity.java | 7aa0f4a78c692ae98f3d62a754e52382e2a1b3b6 | [] | no_license | arattlebush/fengyun | 6759cefa37327fe8a98c88b43a2e4f7065910fa3 | 456b3bbb3012bea8d4bb3c3130d30fb25710b8e5 | refs/heads/master | 2020-05-15T23:23:55.945694 | 2019-05-16T08:21:49 | 2019-05-16T08:21:49 | 182,551,171 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,055 | java | package net.fengyun.italker.italker.frags.main.Wechat;
/*
* 项目名: SmartButler
* 包名: com.imooc.smartbutler.ui
* 文件名: BaseActivity
* 创建者: LGL
* 创建时间: 2016/10/21 23:18
* 描述: Activity基类
*/
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
/**
* 主要做的事情:
* 1.统一的属性
* 2.统一的接口
* 3.统一的方法
*/
public class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setElevation(0);
//显示返回键
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
//菜单栏操作
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
}
| [
"717673607@qq.com"
] | 717673607@qq.com |
63992e14600eac18358df638105815d5f84bcb25 | b23231c6281f0c302a51d94e0ea7afabe017997f | /src/main/java/com/wod/config/OAuth2SsoConfiguration.java | 6bc3bf39c870f18bf414516f6a09dc796bda4097 | [] | no_license | fmatuszewski/workout | 6da93c8e0aa678f7fed4bf3457e540d8b65dc94e | 7861af93e5badaecfe37d845346c62e884c10025 | refs/heads/master | 2020-03-19T09:51:01.654805 | 2018-06-06T12:14:15 | 2018-06-06T12:14:15 | 136,321,947 | 0 | 0 | null | 2018-06-06T12:14:16 | 2018-06-06T11:55:02 | Java | UTF-8 | Java | false | false | 2,349 | java | package com.wod.config;
import com.wod.security.AuthoritiesConstants;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.security.web.util.matcher.NegatedRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.filter.CorsFilter;
import io.github.jhipster.security.AjaxLogoutSuccessHandler;
@EnableOAuth2Sso
@Configuration
public class OAuth2SsoConfiguration extends WebSecurityConfigurerAdapter {
private final RequestMatcher authorizationHeaderRequestMatcher;
private final CorsFilter corsFilter;
public OAuth2SsoConfiguration(@Qualifier("authorizationHeaderRequestMatcher")
RequestMatcher authorizationHeaderRequestMatcher, CorsFilter corsFilter) {
this.authorizationHeaderRequestMatcher = authorizationHeaderRequestMatcher;
this.corsFilter = corsFilter;
}
@Bean
public AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler() {
return new AjaxLogoutSuccessHandler();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.addFilterBefore(corsFilter, CsrfFilter.class)
.headers()
.frameOptions()
.disable()
.and()
.logout()
.logoutUrl("/api/logout")
.logoutSuccessHandler(ajaxLogoutSuccessHandler())
.and()
.requestMatcher(new NegatedRequestMatcher(authorizationHeaderRequestMatcher))
.authorizeRequests()
.antMatchers("/api/profile-info").permitAll()
.antMatchers("/api/**").authenticated()
.antMatchers("/management/health").permitAll()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
.anyRequest().permitAll();
}
}
| [
"jhipster-bot@users.noreply.github.com"
] | jhipster-bot@users.noreply.github.com |
61ef1318ac1ee6c706354c3de69792cff83bb002 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/app/AppForegroundDelegate$3.java | 42110860d5215fe2272d4380cfd8e121732d1217 | [] | no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 974 | java | package com.tencent.mm.app;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.a.c;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
final class AppForegroundDelegate$3
implements Runnable
{
AppForegroundDelegate$3(AppForegroundDelegate paramAppForegroundDelegate, String paramString) {}
public final void run()
{
AppMethodBeat.i(131737);
c.baR().i(false, this.fcG);
synchronized (AppForegroundDelegate.b(this.hfn))
{
LinkedList localLinkedList = new LinkedList(AppForegroundDelegate.b(this.hfn));
??? = localLinkedList.iterator();
if (((Iterator)???).hasNext()) {
((q)((Iterator)???).next()).onAppBackground(this.fcG);
}
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes7.jar
* Qualified Name: com.tencent.mm.app.AppForegroundDelegate.3
* JD-Core Version: 0.7.0.1
*/ | [
"98632993+tsuzcx@users.noreply.github.com"
] | 98632993+tsuzcx@users.noreply.github.com |
574e6e4a7f727c7461d000af3989a87713ef623e | 216af102f38f7eff8ac931bebcf52ec1f3196c9d | /src/baekjoon/silver/BOJ_11055_가장큰증가부분수열.java | 92083db836427d78b1af4de8938d47ec0471d89c | [] | no_license | LeeA0/Algorithm | d9ff150cbef817d95b5b853b29e8ade6df712d87 | 416897e40098b4b9a60f85ac09528ae1f1d43ca6 | refs/heads/master | 2023-08-31T23:54:52.809679 | 2021-10-10T15:33:26 | 2021-10-10T15:33:26 | 298,046,835 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package baekjoon.silver;
import java.util.Scanner;
//백준_가장큰증가부분수열_11055_실버2
public class BOJ_11055_가장큰증가부분수열 {
static int N;
static int[] A;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
N = scan.nextInt();
A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = scan.nextInt();
}
// 이때까지 길이를 저장했다면, 이번에는 합을 구해야 하므로 합을 넣어준다..!
int[] LIS = new int[N];
int max = 0;
for (int i = 0; i < N; i++) {
LIS[i] = A[i];
for (int j = 0; j < i; j++) {
if (A[i] > A[j] && LIS[i] < LIS[j] + A[i]) {
LIS[i] = LIS[j] + A[i];
}
}
max = Math.max(max, LIS[i]);
}
System.out.println(max);
}
}
| [
"lay0711@naver.com"
] | lay0711@naver.com |
e747cfa32a4678de49f781bf2478f44ad9084d14 | 6cca231cbf6aacce6d7cc8ca8c353380f485ee42 | /zyol-sso-consumer/src/main/java/cn/zyol/sso/config/FilterBean.java | 0bff03dc0f302c0a2619d49c72079669ce65ac0b | [] | no_license | zyol/cn.zyol | 1251b14304525a190eeff8326bd2741ef9041e4b | 90b2ae3baf43910c8f4012fd626d7919ccceefb4 | refs/heads/master | 2020-04-09T11:35:23.011212 | 2018-12-29T06:05:51 | 2018-12-29T06:05:51 | 160,114,935 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package cn.zyol.sso.config;
import cn.zyol.sso.filter.LogoutFilter;
import cn.zyol.sso.filter.SsoFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FilterBean {
@Bean(name = "ssoFilter")
public SsoFilter generatessoFilter() {
return new SsoFilter();
}
@Bean(name = "logoutFilter")
public LogoutFilter generateLogoutFilter() {
LogoutFilter logoutFilter = new LogoutFilter();
logoutFilter.setSsoBackUrl("/index");
logoutFilter.setPattern("/logout");
return logoutFilter;
}
}
| [
"1097982009@qq.com"
] | 1097982009@qq.com |
60114e12c8172d5a54c63a69e62513ac1ccd6f16 | 12c6c797af26d930f70a3d4a2cd1b30118a39c33 | /core/src/main/java/org/keycloak/storage/ldap/idm/model/LDAPDn.java | 9c6e60e1edbcc6d5a89cf32761c5d1fb88cd5175 | [
"Apache-2.0"
] | permissive | yqclouds/keycloak | 9aa064a203f91148b0b538bb697e28ab7d27918c | 21cd7f4e64d1290779a527fb0764b90d5000c147 | refs/heads/master | 2021-04-11T11:02:00.730396 | 2020-06-08T15:47:56 | 2020-06-08T15:47:56 | 249,012,458 | 0 | 0 | Apache-2.0 | 2020-03-21T16:10:56 | 2020-03-21T16:10:55 | null | UTF-8 | Java | false | false | 5,320 | java | /*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.keycloak.storage.ldap.idm.model;
import javax.naming.ldap.Rdn;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
public class LDAPDn {
private final Deque<Entry> entries;
private LDAPDn() {
this.entries = new LinkedList<>();
}
private LDAPDn(Deque<Entry> entries) {
this.entries = entries;
}
public static LDAPDn fromString(String dnString) {
LDAPDn dn = new LDAPDn();
// In certain OpenLDAP implementations the uniqueMember attribute is mandatory
// Thus, if a new group is created, it will contain an empty uniqueMember attribute
// Later on, when adding members, this empty attribute will be kept
// Keycloak must be able to process it, properly, w/o throwing an ArrayIndexOutOfBoundsException
if (dnString.trim().isEmpty())
return dn;
String[] rdns = dnString.split("(?<!\\\\),");
for (String entryStr : rdns) {
String[] rdn = entryStr.split("(?<!\\\\)=");
if (rdn.length > 1) {
dn.addLast(rdn[0].trim(), rdn[1].trim());
} else {
dn.addLast(rdn[0].trim(), "");
}
}
return dn;
}
private static String toString(Collection<Entry> entries) {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (Entry rdn : entries) {
if (first) {
first = false;
} else {
builder.append(",");
}
builder.append(rdn.attrName).append("=").append(rdn.attrValue);
}
return builder.toString();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof LDAPDn)) {
return false;
}
return toString().equals(obj.toString());
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public String toString() {
return toString(entries);
}
/**
* @return string like "uid=joe" from the DN like "uid=joe,dc=something,dc=org"
*/
public String getFirstRdn() {
Entry firstEntry = entries.getFirst();
return firstEntry.attrName + "=" + unescapeValue(firstEntry.attrValue);
}
/**
* @return string attribute name like "uid" from the DN like "uid=joe,dc=something,dc=org"
*/
public String getFirstRdnAttrName() {
Entry firstEntry = entries.getFirst();
return firstEntry.attrName;
}
/**
* @return string attribute value like "joe" from the DN like "uid=joe,dc=something,dc=org"
*/
public String getFirstRdnAttrValue() {
Entry firstEntry = entries.getFirst();
String dnEscaped = firstEntry.attrValue;
return unescapeValue(dnEscaped);
}
private String unescapeValue(String escaped) {
// Something needed to handle non-String types?
return Rdn.unescapeValue(escaped).toString();
}
/**
* @return DN like "dc=something,dc=org" from the DN like "uid=joe,dc=something,dc=org".
* Returned DN will be new clone not related to the original DN instance.
*/
public LDAPDn getParentDn() {
LinkedList<Entry> parentDnEntries = new LinkedList<>(entries);
parentDnEntries.remove();
return new LDAPDn(parentDnEntries);
}
public boolean isDescendantOf(LDAPDn expectedParentDn) {
int parentEntriesCount = expectedParentDn.entries.size();
Deque<Entry> myEntries = new LinkedList<>(this.entries);
boolean someRemoved = false;
while (myEntries.size() > parentEntriesCount) {
myEntries.removeFirst();
someRemoved = true;
}
String myEntriesParentStr = toString(myEntries).toLowerCase();
String expectedParentDnStr = expectedParentDn.toString().toLowerCase();
return someRemoved && myEntriesParentStr.equals(expectedParentDnStr);
}
public void addFirst(String rdnName, String rdnValue) {
rdnValue = Rdn.escapeValue(rdnValue);
entries.addFirst(new Entry(rdnName, rdnValue));
}
private void addLast(String rdnName, String rdnValue) {
entries.addLast(new Entry(rdnName, rdnValue));
}
private static class Entry {
private final String attrName;
private final String attrValue;
private Entry(String attrName, String attrValue) {
this.attrName = attrName;
this.attrValue = attrValue;
}
}
}
| [
"eric..zhan@163.com"
] | eric..zhan@163.com |
142cb43cb9642f1f2cff2a44f8adb075522afd57 | 3c05e9810ffd8f71e05a0a42f5b73c894d7ccde9 | /src/main/java/ge/edu/freeuni/sdp/iot/chat/bot/model/SprinklerSwitch.java | 54d7529a167cc26ba0406850df274470145c4328 | [
"MIT"
] | permissive | freeuni-sdp/iot-chat-bot | de14555fa51ab06ef862ae043bb9fcc603ea002f | e3e9912e48649cf4c6da09bd10ea6a6a0f330d6c | refs/heads/master | 2020-05-29T14:40:41.479949 | 2016-07-12T19:13:30 | 2016-07-12T19:13:30 | 59,865,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,394 | java | package ge.edu.freeuni.sdp.iot.chat.bot.model;
import org.json.JSONObject;
/**
* Created by Nikoloz on 07/11/16.
*/
public class SprinklerSwitch {
String house_id;
String status;
int seconds_left;
public SprinklerSwitch(String house_id, String status, int seconds_left) {
this.house_id = house_id;
this.status = status;
this.seconds_left = seconds_left;
}
public String getHouse_id() {
return house_id;
}
public void setHouse_id(String house_id) {
this.house_id = house_id;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getSeconds_left() {
return seconds_left;
}
public void setSeconds_left(int seconds_left) {
this.seconds_left = seconds_left;
}
public boolean isOn() {
return status.equals("on");
}
@Override
public String toString() {
return "Status: " + status + ", Seconds Left: " + seconds_left;
}
public static SprinklerSwitch fromJson(JSONObject jsonObject) {
String house_id = jsonObject.getString("house_id");
String status = jsonObject.getString("status");
int seconds_left = jsonObject.optInt("seconds_left", 0);
return new SprinklerSwitch(house_id, status, seconds_left);
}
}
| [
"nakhv12@yahoo.com"
] | nakhv12@yahoo.com |
a947ec9ecac0ded2d9fb37bc5a9082939c54193f | 6c898803221331eca148c734fde1b2da9e985846 | /realbuilder/src/main/java/org/trishinfotech/builder/AutomotiveEngineer.java | f0af144bcc1085f4a53e1f041f513c6942dbaa28 | [] | no_license | BrijeshSaxena/design-pattern-real-builder | d67360c3fb9324e8c4afe3b04c982b4a004aa432 | 04d7ba0fc5e91b15be3ba832b1be3a88cf87e150 | refs/heads/master | 2022-12-27T11:11:04.853580 | 2020-09-22T16:39:46 | 2020-10-13T17:14:07 | 297,680,726 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 446 | java | package org.trishinfotech.builder;
public class AutomotiveEngineer {
private CarBuilder builder;
public AutomotiveEngineer(CarBuilder builder) {
super();
this.builder = builder;
if (this.builder == null) {
throw new IllegalArgumentException("Automotive Engineer can't work without Car Builder!");
}
}
public Car manufactureCar() {
return builder.fixChassis().fixBody().paint().fixInterior().build();
}
}
| [
"brijeshsaxena@yahoo.com"
] | brijeshsaxena@yahoo.com |
b7d94272137bc878794e30a46551ef99e4b8ffa2 | 133a390802cd256100efbea93589be8466b83f96 | /bierliste/bierliste-server/src/test/java/de/clubbiertest/liste/server/AllTests.java | 12732acdaa9e76cbb6fd8f9e7a869c2abe5d3d05 | [] | no_license | AmeniElJerbi/ssg-dmixed-apps | 44f33929334f40d22e0afc1a837662a6dabe68fc | 6c6280521cfb8defe916fa1f9869441a95728b09 | refs/heads/master | 2020-06-03T01:51:52.223652 | 2016-09-26T14:41:40 | 2016-09-26T14:41:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 385 | java | /* Copyright, (c) 2012 Suretec GmbH */
package de.clubbiertest.liste.server;
import de.clubbiertest.liste.server.util.ListeParserTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith( Suite.class ) @SuiteClasses( { BierlisteServiceTest.class, ListeParserTest.class } )
public class AllTests
{
}
| [
"propromarco@web.de"
] | propromarco@web.de |
8f497e36bd8be6066fd6d74867d6284190f1f6c4 | d151092c48629c3d2ae09bc837dc42980b2b9683 | /ikongtiao-biz/src/main/java/com/wetrack/ikongtiao/events/EventPublishServiceImpl.java | cebfe101f4421a5adcaded03f71aab41cd2c8048 | [] | no_license | hjames17/ikongtiao | f4976998bc088d84c8faac791b653772a5b3a819 | 3bcab95ec616d15a2a4cbe5ca1c4652745e369f1 | refs/heads/master | 2020-05-25T15:47:02.286414 | 2017-04-14T03:22:10 | 2017-04-14T03:22:10 | 58,651,257 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,088 | java | package com.wetrack.ikongtiao.events;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
/**
* Created by zhanghong on 16/9/16.
*/
@Deprecated
//@Service
public class EventPublishServiceImpl implements EventPublishService,ApplicationEventPublisherAware {
ApplicationEventPublisher eventPublisher;
static class AppEvent extends ApplicationEvent{
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
*/
public AppEvent(Event source) {
super(source);
}
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
@Override
public void publishEvent(Event event){
AppEvent appEvent = new AppEvent(event);
eventPublisher.publishEvent(appEvent);
}
}
| [
"cn_zhanghong@sina.com"
] | cn_zhanghong@sina.com |
ae77169b13f83ffca78d9fe464185ff94e96a19c | 705dfdc5147fc433be370e41a8cdc026fdffcfd8 | /src/main/java/cn/jsfund/devtools/entity/EventGroup.java | e2fd0f4849ecdc2c6e965c1fd664194cbc3fa65e | [
"Apache-2.0"
] | permissive | hutx/devtools | 7bda4756f8d146afbc6e01102dfb2902cd6dbc35 | bb8700230733fdad9ff215bb0473415189c40f95 | refs/heads/mybatis_plus | 2022-11-07T20:45:53.528352 | 2019-10-15T09:40:27 | 2019-10-15T09:40:27 | 215,231,697 | 0 | 0 | Apache-2.0 | 2022-10-12T20:32:46 | 2019-10-15T07:12:37 | JavaScript | UTF-8 | Java | false | false | 1,253 | java | package cn.jsfund.devtools.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import cn.jsfund.devtools.base.BaseEntity;
/**
* <p>
* 事件分组
* </p>
*
* @author hutx
* @since 2019-01-05
*/
public class EventGroup extends BaseEntity{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String groupName;
private String remark;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public static final String ID = "id";
public static final String GROUP_NAME = "group_name";
public static final String REMARK = "remark";
@Override
public String toString() {
return "EventGroup{" +
", id=" + id +
", groupName=" + groupName +
", remark=" + remark +
"}";
}
}
| [
"tianxin@live.cn"
] | tianxin@live.cn |
442ba89e32926bd4957b2da313d86214d232ce99 | 19e1717d17bea7be86bd840e6d1bfe18aa1b34ec | /XO/src/Controllar/Returnme.java | ec005f41ed3a056962dcc1af10b3415e6af31f7e | [] | no_license | AbdelrahmanKhaled95/My_Work | ef2357c196b247203b75413e11c2def5d645c69a | a7768f4caf82256a46ec2f00bc9bf12dc89d00bb | refs/heads/master | 2021-01-01T04:01:09.599323 | 2016-10-09T09:48:27 | 2016-10-09T09:48:27 | 55,950,971 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | package Controllar;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Engine.XO;
import GUI.Choose;
import GUI.GUI3;
public class Returnme implements ActionListener{
GUI3 g;
public Returnme(GUI3 g){
this.g=g;
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
g.setVisible(false);
new Choose();
new XO();
g.setCountp1(0);
g.setCountp2(0);
}
}
| [
"abdokhaled30@hotmail.com"
] | abdokhaled30@hotmail.com |
4925efe10dbfff631b33f4eb26689ec51899b98f | faac6ef60bf92b241217e6f392a117b8c7076e19 | /app/src/androidTest/java/com/example/pertandinganbola/ExampleInstrumentedTest.java | f84e64e43d33b47951777fc3f01018672221ee02 | [] | no_license | bagus-11/AplikasiLiveScore | 863a64e608e4bfe4460f964d155950ecc752f5be | 41a2d62e125a79a283e3359e26f3d6de0c0fbda3 | refs/heads/master | 2023-02-13T11:59:29.350384 | 2021-01-16T13:14:46 | 2021-01-16T13:14:46 | 330,150,829 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 770 | java | package com.example.pertandinganbola;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.pertandinganbola", appContext.getPackageName());
}
} | [
"pornhubb355@gmail.com"
] | pornhubb355@gmail.com |
31b49b5e1e6b0eaa17b84821c61e443ddd233766 | c09f097656aa597e41ad1d51466e998bf2fe7394 | /src/main/java/com/nals/hrm/model/Contracts.java | 437848e039028b1e118266ab61cb880da6c3de3d | [] | no_license | ngochuy2902/HRMJava | 3ac621a857ec184aee50cd4fed0806e10eb7cce1 | 8df9ff7c4c17640917299ed797b70df869b7c189 | refs/heads/master | 2023-05-01T13:58:37.152007 | 2021-05-21T01:46:11 | 2021-05-21T01:46:11 | 369,384,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 781 | java | package com.nals.hrm.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Getter
@Setter
@NoArgsConstructor
public class Contracts {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private LocalDateTime deletedAt;
private Integer updatedBy;
private LocalDateTime contractDateBegin;
private LocalDateTime contractDateEnd;
private Integer contractStatus;
@UpdateTimestamp
private LocalDateTime updatedAt;
@CreationTimestamp
private LocalDateTime createdAt;
@ManyToOne
private Users user;
}
| [
"ngochuy2902@gmail.com"
] | ngochuy2902@gmail.com |
7e00bf65744725dde6ace7e109f99d1682e386d1 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipsejdt_cluster/42281/tar_0.java | 6238dfcae044f9ac864367c8363b57c4b5b31a0a | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,921 | java | /*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.compiler.util.SuffixConstants;
import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.JavaModelStatus;
import org.eclipse.jdt.internal.core.util.Util;
/**
* Provides methods for checking Java-specific conventions such as name syntax.
* <p>
* This class provides static methods and constants only; it is not intended to be
* instantiated or subclassed by clients.
* </p>
*/
public final class JavaConventions {
private final static char DOT= '.';
private final static Scanner SCANNER = new Scanner();
private JavaConventions() {
// Not instantiable
}
/**
* Returns whether the given package fragment root paths are considered
* to overlap.
* <p>
* Two root paths overlap if one is a prefix of the other, or they point to
* the same location. However, a JAR is allowed to be nested in a root.
*
* @param rootPath1 the first root path
* @param rootPath2 the second root path
* @return true if the given package fragment root paths are considered to overlap, false otherwise
* @deprecated Overlapping roots are allowed in 2.1
*/
public static boolean isOverlappingRoots(IPath rootPath1, IPath rootPath2) {
if (rootPath1 == null || rootPath2 == null) {
return false;
}
String extension1 = rootPath1.getFileExtension();
String extension2 = rootPath2.getFileExtension();
if (extension1 != null && (extension1.equalsIgnoreCase(SuffixConstants.EXTENSION_JAR) || extension1.equalsIgnoreCase(SuffixConstants.EXTENSION_ZIP))) {
return false;
}
if (extension2 != null && (extension2.equalsIgnoreCase(SuffixConstants.EXTENSION_JAR) || extension2.equalsIgnoreCase(SuffixConstants.EXTENSION_ZIP))) {
return false;
}
return rootPath1.isPrefixOf(rootPath2) || rootPath2.isPrefixOf(rootPath1);
}
/*
* Returns the current identifier extracted by the scanner (without unicode
* escapes) from the given id.
* Returns <code>null</code> if the id was not valid
*/
private static synchronized char[] scannedIdentifier(String id) {
if (id == null) {
return null;
}
String trimmed = id.trim();
if (!trimmed.equals(id)) {
return null;
}
try {
SCANNER.setSource(id.toCharArray());
int token = SCANNER.getNextToken();
char[] currentIdentifier;
try {
currentIdentifier = SCANNER.getCurrentIdentifierSource();
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
int nextToken= SCANNER.getNextToken();
if (token == TerminalTokens.TokenNameIdentifier
&& nextToken == TerminalTokens.TokenNameEOF
&& SCANNER.startPosition == SCANNER.source.length) { // to handle case where we had an ArrayIndexOutOfBoundsException
// while reading the last token
return currentIdentifier;
} else {
return null;
}
}
catch (InvalidInputException e) {
return null;
}
}
/**
* Validate the given compilation unit name.
* A compilation unit name must obey the following rules:
* <ul>
* <li> it must not be null
* <li> it must include the <code>".java"</code> suffix
* <li> its prefix must be a valid identifier
* <li> it must not contain any characters or substrings that are not valid
* on the file system on which workspace root is located.
* </ul>
* </p>
* @param name the name of a compilation unit
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a compilation unit name, otherwise a status
* object indicating what is wrong with the name
*/
public static IStatus validateCompilationUnitName(String name) {
if (name == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"), null); //$NON-NLS-1$
}
if (!org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(name)) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
}
String identifier;
int index;
index = name.lastIndexOf('.');
if (index == -1) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
}
identifier = name.substring(0, index);
// JSR-175 metadata strongly recommends "package-info.java" as the
// file in which to store package annotations and
// the package-level spec (replaces package.html)
if (!identifier.equals("package-info")) { //$NON-NLS-1$
IStatus status = validateIdentifier(identifier);
if (!status.isOK()) {
return status;
}
}
IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
if (!status.isOK()) {
return status;
}
return JavaModelStatus.VERIFIED_OK;
}
/**
* Validate the given .class file name.
* A .class file name must obey the following rules:
* <ul>
* <li> it must not be null
* <li> it must include the <code>".class"</code> suffix
* <li> its prefix must be a valid identifier
* <li> it must not contain any characters or substrings that are not valid
* on the file system on which workspace root is located.
* </ul>
* </p>
* @param name the name of a .class file
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a .class file name, otherwise a status
* object indicating what is wrong with the name
* @since 2.0
*/
public static IStatus validateClassFileName(String name) {
if (name == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.nullName"), null); //$NON-NLS-1$
}
if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notClassFileName"), null); //$NON-NLS-1$
}
String identifier;
int index;
index = name.lastIndexOf('.');
if (index == -1) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notClassFileName"), null); //$NON-NLS-1$
}
identifier = name.substring(0, index);
IStatus status = validateIdentifier(identifier);
if (!status.isOK()) {
return status;
}
status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
if (!status.isOK()) {
return status;
}
return JavaModelStatus.VERIFIED_OK;
}
/**
* Validate the given field name.
* <p>
* Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
* For example, <code>"x"</code>.
*
* @param name the name of a field
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a field name, otherwise a status
* object indicating what is wrong with the name
*/
public static IStatus validateFieldName(String name) {
return validateIdentifier(name);
}
/**
* Validate the given Java identifier.
* The identifier must not have the same spelling as a Java keyword,
* boolean literal (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
* See section 3.8 of the <em>Java Language Specification, Second Edition</em> (JLS2).
* A valid identifier can act as a simple type name, method name or field name.
*
* @param id the Java identifier
* @return a status object with code <code>IStatus.OK</code> if
* the given identifier is a valid Java identifier, otherwise a status
* object indicating what is wrong with the identifier
*/
public static IStatus validateIdentifier(String id) {
if (scannedIdentifier(id) != null) {
return JavaModelStatus.VERIFIED_OK;
} else {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", id), null); //$NON-NLS-1$
}
}
/**
* Validate the given import declaration name.
* <p>
* The name of an import corresponds to a fully qualified type name
* or an on-demand package name as defined by ImportDeclaration (JLS2 7.5).
* For example, <code>"java.util.*"</code> or <code>"java.util.Hashtable"</code>.
*
* @param name the import declaration
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as an import declaration, otherwise a status
* object indicating what is wrong with the name
*/
public static IStatus validateImportDeclaration(String name) {
if (name == null || name.length() == 0) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.nullImport"), null); //$NON-NLS-1$
}
if (name.charAt(name.length() - 1) == '*') {
if (name.charAt(name.length() - 2) == '.') {
return validatePackageName(name.substring(0, name.length() - 2));
} else {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.unqualifiedImport"), null); //$NON-NLS-1$
}
}
return validatePackageName(name);
}
/**
* Validate the given Java type name, either simple or qualified.
* For example, <code>"java.lang.Object"</code>, or <code>"Object"</code>.
* <p>
*
* @param name the name of a type
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a Java type name,
* a status with code <code>IStatus.WARNING</code>
* indicating why the given name is discouraged,
* otherwise a status object indicating what is wrong with
* the name
*/
public static IStatus validateJavaTypeName(String name) {
if (name == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nullName"), null); //$NON-NLS-1$
}
String trimmed = name.trim();
if (!name.equals(trimmed)) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nameWithBlanks"), null); //$NON-NLS-1$
}
int index = name.lastIndexOf('.');
char[] scannedID;
if (index == -1) {
// simple name
scannedID = scannedIdentifier(name);
} else {
// qualified name
String pkg = name.substring(0, index).trim();
IStatus status = validatePackageName(pkg);
if (!status.isOK()) {
return status;
}
String type = name.substring(index + 1).trim();
scannedID = scannedIdentifier(type);
}
if (scannedID != null) {
IStatus status = ResourcesPlugin.getWorkspace().validateName(new String(scannedID), IResource.FILE);
if (!status.isOK()) {
return status;
}
if (CharOperation.contains('$', scannedID)) {
return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.dollarName"), null); //$NON-NLS-1$
}
if ((scannedID.length > 0 && Character.isLowerCase(scannedID[0]))) {
return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.lowercaseName"), null); //$NON-NLS-1$
}
return JavaModelStatus.VERIFIED_OK;
} else {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.invalidName", name), null); //$NON-NLS-1$
}
}
/**
* Validate the given method name.
* The special names "<init>" and "<clinit>" are not valid.
* <p>
* The syntax for a method name is defined by Identifier
* of MethodDeclarator (JLS2 8.4). For example "println".
*
* @param name the name of a method
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a method name, otherwise a status
* object indicating what is wrong with the name
*/
public static IStatus validateMethodName(String name) {
return validateIdentifier(name);
}
/**
* Validate the given package name.
* <p>
* The syntax of a package name corresponds to PackageName as
* defined by PackageDeclaration (JLS2 7.4). For example, <code>"java.lang"</code>.
* <p>
* Note that the given name must be a non-empty package name (that is, attempting to
* validate the default package will return an error status.)
* Also it must not contain any characters or substrings that are not valid
* on the file system on which workspace root is located.
*
* @param name the name of a package
* @return a status object with code <code>IStatus.OK</code> if
* the given name is valid as a package name, otherwise a status
* object indicating what is wrong with the name
*/
public static IStatus validatePackageName(String name) {
if (name == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nullName"), null); //$NON-NLS-1$
}
int length;
if ((length = name.length()) == 0) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.emptyName"), null); //$NON-NLS-1$
}
if (name.charAt(0) == DOT || name.charAt(length-1) == DOT) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.dotName"), null); //$NON-NLS-1$
}
if (CharOperation.isWhitespace(name.charAt(0)) || CharOperation.isWhitespace(name.charAt(name.length() - 1))) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nameWithBlanks"), null); //$NON-NLS-1$
}
int dot = 0;
while (dot != -1 && dot < length-1) {
if ((dot = name.indexOf(DOT, dot+1)) != -1 && dot < length-1 && name.charAt(dot+1) == DOT) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.consecutiveDotsName"), null); //$NON-NLS-1$
}
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
StringTokenizer st = new StringTokenizer(name, new String(new char[] {DOT}));
boolean firstToken = true;
IStatus warningStatus = null;
while (st.hasMoreTokens()) {
String typeName = st.nextToken();
typeName = typeName.trim(); // grammar allows spaces
char[] scannedID = scannedIdentifier(typeName);
if (scannedID == null) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", typeName), null); //$NON-NLS-1$
}
IStatus status = workspace.validateName(new String(scannedID), IResource.FOLDER);
if (!status.isOK()) {
return status;
}
if (firstToken && scannedID.length > 0 && Character.isUpperCase(scannedID[0])) {
if (warningStatus == null) {
warningStatus = new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.uppercaseName"), null); //$NON-NLS-1$
}
}
firstToken = false;
}
if (warningStatus != null) {
return warningStatus;
}
return JavaModelStatus.VERIFIED_OK;
}
/**
* Validate a given classpath and output location for a project, using the following rules:
* <ul>
* <li> Classpath entries cannot collide with each other; that is, all entry paths must be unique.
* <li> The project output location path cannot be null, must be absolute and located inside the project.
* <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
* <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
* <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below:
* <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives.
* However, a specific output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li>
* <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
* <li> An output location can be nested in a source folder, if the source folder coincidates with the project itself, or if the output
* location is excluded from the source folder.
* </ul>
* </ul>
*
* Note that the classpath entries are not validated automatically. Only bound variables or containers are considered
* in the checking process (this allows to perform a consistency check on a classpath which has references to
* yet non existing projects, folders, ...).
* <p>
* This validation is intended to anticipate classpath issues prior to assigning it to a project. In particular, it will automatically
* be performed during the classpath setting operation (if validation fails, the classpath setting will not complete).
* <p>
* @param javaProject the given java project
* @param rawClasspath the given classpath
* @param projectOutputLocation the given output location
* @return a status object with code <code>IStatus.OK</code> if
* the given classpath and output location are compatible, otherwise a status
* object indicating what is wrong with the classpath or output location
* @since 2.0
*/
public static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] rawClasspath, IPath projectOutputLocation) {
return ClasspathEntry.validateClasspath(javaProject, rawClasspath, projectOutputLocation);
}
/**
* Returns a Java model status describing the problem related to this classpath entry if any,
* a status object with code <code>IStatus.OK</code> if the entry is fine (that is, if the
* given classpath entry denotes a valid element to be referenced onto a classpath).
*
* @param project the given java project
* @param entry the given classpath entry
* @param checkSourceAttachment a flag to determine if source attachement should be checked
* @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
* @since 2.0
*/
public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment){
return ClasspathEntry.validateClasspathEntry(project, entry, checkSourceAttachment, true/*recurse in container*/);
}
}
| [
"375833274@qq.com"
] | 375833274@qq.com |
d185b6b8c9953714bd96310900a29b960a0d0bb3 | 73ec18f9553a01dc13812f9ea7ef0e0acfa1653f | /core/src/main/java/com/ozstrategy/dao/flows/ProcessDefDao.java | 08878d5b813d172ba392ad5693c8d4e67f7093aa | [] | no_license | 271387591/office-mybatis | 275cf49952f062fa30e321633748c7b42cf0828c | 75226c977ab5ae94f1a16b1a87c17689e60ba99f | refs/heads/master | 2016-09-15T20:04:59.511067 | 2016-02-18T02:14:47 | 2016-02-18T02:14:47 | 23,915,976 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,721 | java | package com.ozstrategy.dao.flows;
import com.ozstrategy.model.flows.ProcessDef;
import com.ozstrategy.model.userrole.Role;
import com.ozstrategy.model.userrole.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Created by lihao on 9/9/14.
*/
public interface ProcessDefDao {
List<ProcessDef> listProcessDefs(Map<String,Object> map,RowBounds rowBounds);
List<ProcessDef> getProcessDefByName(String name);
Integer listProcessDefsCount(Map<String,Object> map);
ProcessDef getProcessDefById(Long id);
ProcessDef getProcessDefByActId(String actId);
ProcessDef getProcessDefByModelId(String modelId);
ProcessDef getProcessDefByDepId(String depId);
ProcessDef getProcessDefByName(@Param("name")String name,@Param("typeId")Long typeId);
void saveProcessDef(ProcessDef processDef);
void updateProcessDef(ProcessDef processDef);
void deleteProcessDef(Long id);
void removeChild(Long parentId);
Long checkNameExist(@Param("name")String name,@Param("typeId")Long typeId);
void saveProcessDefUser(@Param("userId")Long userId,@Param("id")Long id);
void saveProcessDefRole(@Param("roleId")Long roleId,@Param("id")Long id);
void deleteProcessDefUser(Long id);
void deleteProcessDefRole(Long id);
List<User> getProcessDefUser(Long id);
List<Role> getProcessDefRole(Long id);
List<ProcessDef> getProcessDefinition(Map<String,Object> map,RowBounds rowBounds);
Integer getProcessDefinitionCount(Map<String,Object> map);
List<ProcessDef> getProcessDefByRoleId(Long roleId);
List<ProcessDef> getProcessDefByFormId(Long formId);
}
| [
"lihao@ozstrategy.com"
] | lihao@ozstrategy.com |
3f493ff2a4d99af0f0f38349a0aa2219614e720d | 7657af1fe31d1db8b4124cef021360c3a702f604 | /code/src/main/java/me/bokov/bsc/surfaceviewer/editorv2/service/UpdateViewTask.java | 71d03f71ded6e3a5583a021053abf0adbc64b737 | [] | no_license | bokovhu/bsc-thesis | 3be564228ae853cf75776a2abeedd7fa02b1a009 | 2fb0494032a29fbf0594eacc6d73ea93706a7b96 | refs/heads/master | 2023-03-06T06:18:27.714663 | 2021-02-16T07:26:58 | 2021-02-16T07:26:58 | 306,891,927 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,147 | java | package me.bokov.bsc.surfaceviewer.editorv2.service;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.concurrent.Task;
import lombok.Getter;
import me.bokov.bsc.surfaceviewer.App;
import me.bokov.bsc.surfaceviewer.scene.World;
import me.bokov.bsc.surfaceviewer.view.ViewConfiguration;
public class UpdateViewTask extends Task<Boolean> {
@Getter
private final ObjectProperty<World> newWorldProperty = new SimpleObjectProperty<>(null);
@Getter
private final ObjectProperty<App> appProperty = new SimpleObjectProperty<>(null);
@Override
protected Boolean call() throws Exception {
final var app = appProperty.get();
final var world = newWorldProperty.get();
if (app == null || world == null) {
throw new IllegalArgumentException("app and world cannot be null!");
}
app.getViewClient()
.changeConfig(
ViewConfiguration.builder()
.world(world)
.build()
);
return true;
}
}
| [
"botondjanoskovacs@gmail.com"
] | botondjanoskovacs@gmail.com |
039afd6430559e2a3cace0ad9df5d09b9b14e865 | 047ee9d497d9044c70b793b6e8e86b0d61ce0641 | /src/main/java/org/softuni/car_dealer/CarDealerApplication.java | 2258ead766bfe1d4f56dbb05cbaef491b8d3fff8 | [] | no_license | ChillyWe/MVC_Car_dealer | ff58c2328d959e96131f6708a5b79d8de1ea49d5 | b6affd578155bffba8d352472a9682deb1957b72 | refs/heads/master | 2020-03-22T16:11:03.335926 | 2018-07-11T07:19:47 | 2018-07-11T07:19:47 | 140,308,997 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | java | package org.softuni.car_dealer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CarDealerApplication {
public static void main(String[] args) {
SpringApplication.run(CarDealerApplication.class, args);
}
}
| [
"chilly@mail.bg"
] | chilly@mail.bg |
32aeea7ebcc18d2f37a98960e518805e7631de1a | d0de464bac8ebfbc57ffab467a3b328c19597e60 | /src/test/java/cn/besbing/TestBillRule.java | ba6ef1b65d418a8ba798cf1224e1e5e446e6c4db | [] | no_license | sy8000/dlc20200908 | 50106bfe937e368d84cc44ce311837367ebbdeab | ce7873e795ac71bc14781e94482a3f100da0b79d | refs/heads/master | 2022-12-18T09:46:55.651197 | 2020-09-23T08:25:30 | 2020-09-23T08:25:30 | 293,726,423 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | package cn.besbing;
import cn.besbing.CommonUtils.Bill.BaseBillPrimary;
import org.junit.Test;
public class TestBillRule {
@Test
public void test(){
BaseBillPrimary baseBillPrimary = new BaseBillPrimary();
System.out.println(baseBillPrimary.getPrimaryWithoutModuleName(20));
}
}
| [
"fsbydz@vip.qq.com"
] | fsbydz@vip.qq.com |
4c57cc5f6cf6b96af05843df7999870659fc56f3 | 2c6e2ba03eb71ca45fe690ff6e4586f6e2fa0f17 | /material/apks/banco/sources/ar/com/santander/rio/mbanking/services/soap/beans/body/FirmaSeguroBean.java | d254082a30a5ee2cb38a1136c9a442a46d3cd04a | [] | no_license | lcrcastor/curso-mobile-2019 | 3088a196139b3e980ed6e09797a0bbf5efb6440b | 7585fccb6437a17c841772c1d9fb0701d6c68042 | refs/heads/master | 2023-04-06T21:46:32.333236 | 2020-10-30T19:47:54 | 2020-10-30T19:47:54 | 308,680,747 | 0 | 1 | null | 2023-03-26T06:57:57 | 2020-10-30T16:08:31 | Java | UTF-8 | Java | false | false | 1,209 | java | package ar.com.santander.rio.mbanking.services.soap.beans.body;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import com.google.gson.annotations.SerializedName;
public class FirmaSeguroBean implements Parcelable {
public static final Creator<FirmaSeguroBean> CREATOR = new Creator<FirmaSeguroBean>() {
public FirmaSeguroBean createFromParcel(Parcel parcel) {
return new FirmaSeguroBean(parcel);
}
public FirmaSeguroBean[] newArray(int i) {
return new FirmaSeguroBean[i];
}
};
@SerializedName("firmaSeguro")
private String firmaSeguro;
public int describeContents() {
return 0;
}
public FirmaSeguroBean(String str) {
this.firmaSeguro = str;
}
public FirmaSeguroBean() {
}
public String getFirmaSeguro() {
return this.firmaSeguro;
}
public void setFirmaSeguro(String str) {
this.firmaSeguro = str;
}
protected FirmaSeguroBean(Parcel parcel) {
this.firmaSeguro = parcel.readString();
}
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(this.firmaSeguro);
}
}
| [
"luis@MARK-2.local"
] | luis@MARK-2.local |
9be9a476c6c93e0dad8eb90e9e86f155f1b330c3 | 9af105f423a417c0643da0ff3400a6931c034408 | /BoxJavaLibraryV2/src/com/box/boxjavalibv2/BoxConnectionManagerBuilder.java | b805deaaaea24610171ed37b9eb745f0859e7f1d | [
"Apache-2.0"
] | permissive | koush/box-java-sdk-v2 | 4389194c7a4151b2528d2c02447738fa4e7bf9e5 | b2c0ca7130073b7719789293d06262bf550b5fcf | refs/heads/master | 2023-08-17T11:56:57.334002 | 2014-07-02T18:08:09 | 2014-07-02T18:08:09 | 21,434,938 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 5,145 | java | package com.box.boxjavalibv2;
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.params.ConnPerRoute;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
@SuppressWarnings("deprecation")
public class BoxConnectionManagerBuilder {
private int maxConnectionPerRoute = 50;
private int maxConnection = 1000;
private long timePeriodCleanUpIdleConnection = 300000;
private long idleTimeThreshold = 60000;
public BoxConnectionManager build() {
return new BoxConnectionManager(this);
}
/**
* @param maxConnectionPerRoute
* maximum connection allowed per route.
*/
public void setMaxConnectionPerRoute(int maxConnectionPerRoute) {
this.maxConnectionPerRoute = maxConnectionPerRoute;
}
/**
* @param maxConnection
* maximum connection.
*/
public void setMaxConnection(int maxConnection) {
this.maxConnection = maxConnection;
}
/**
* @param timePeriodCleanUpIdleConnection
* clean up idle connection every such period of time. in miliseconds.
*/
public void setTimePeriodCleanUpIdleConnection(long timePeriodCleanUpIdleConnection) {
this.timePeriodCleanUpIdleConnection = timePeriodCleanUpIdleConnection;
}
/**
* @param idleTimeThreshold
* an idle connection will be closed if idled above this threshold of time. in miliseconds.
*/
public void setIdleTimeThreshold(long idleTimeThreshold) {
this.idleTimeThreshold = idleTimeThreshold;
}
public class BoxConnectionManager {
private ClientConnectionManager connectionManager;
private final int maxConnectionPerRoute;
private final int maxConnection;
private final long timePeriodCleanUpIdleConnection;
private final long idleTimeThreshold;
private BoxConnectionManager(BoxConnectionManagerBuilder builder) {
this.maxConnection = builder.maxConnection;
this.maxConnectionPerRoute = builder.maxConnectionPerRoute;
this.timePeriodCleanUpIdleConnection = builder.timePeriodCleanUpIdleConnection;
this.idleTimeThreshold = builder.idleTimeThreshold;
createConnectionManager();
}
public DefaultHttpClient getMonitoredRestClient() {
return new DefaultHttpClient(connectionManager, getHttpParams());
}
private void createConnectionManager() {
SchemeRegistry schemeReg = new SchemeRegistry();
schemeReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
connectionManager = new ThreadSafeClientConnManager(getHttpParams(), schemeReg);
monitorConnection(connectionManager);
}
private HttpParams getHttpParams() {
HttpParams params = new BasicHttpParams();
ConnManagerParams.setMaxTotalConnections(params, maxConnection);
ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRoute() {
@Override
public int getMaxForRoute(HttpRoute httpRoute) {
return maxConnectionPerRoute;
}
});
return params;
}
private void monitorConnection(ClientConnectionManager connManager) {
final WeakReference<ClientConnectionManager> ref = new WeakReference<ClientConnectionManager>(connManager);
connManager = null;
Thread monitorThread = new Thread() {
@Override
public void run() {
try {
while (true) {
synchronized (this) {
ClientConnectionManager connMan = ref.get();
if (connMan == null) {
return;
}
wait(timePeriodCleanUpIdleConnection);
// Close expired connections
connMan.closeExpiredConnections();
connMan.closeIdleConnections(idleTimeThreshold, TimeUnit.SECONDS);
}
}
}
catch (InterruptedException ex) {
// terminate
}
}
};
monitorThread.start();
}
}
}
| [
"jian@box.com"
] | jian@box.com |
a505176ca4513941e125b410bc7be5306b60b604 | 74df096a4270766fd35cbc03401879bce8ad2cfc | /app/src/main/java/com/iav/senamlantai/activity/SplashScreenActivity.java | c69b3210ac0e223a08ec367d5473c03215aeedd1 | [] | no_license | iavtamvan/SENAM_LANTAI_MEDIA_PEMBELAJARAN | da06b841569808b96aa92c2ea30970d704be3bcc | ef0fb4b501ccdfa7d700b6a9f51aa8e3d9c0ff11 | refs/heads/master | 2020-04-07T23:40:54.515929 | 2020-01-05T14:27:23 | 2020-01-05T14:27:23 | 158,821,415 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,964 | java | package com.iav.senamlantai.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import com.iav.senamlantai.MainActivity;
import com.iav.vlvollylearning.R;
public class SplashScreenActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
getSupportActionBar().hide();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
finishAffinity();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
// SharedPreferences sp = getSharedPreferences(Config.NAME_PREF, MODE_PRIVATE);
// String username = sp.getString(Config.USERNAME, "");
// // TODO jika belum masuk ke LoginActivity
// if (username.equalsIgnoreCase("") || TextUtils.isEmpty(username)) {
// finishAffinity();
// startActivity(new Intent(getApplicationContext(), LoginActivity.class));
// }
// // TODO jika sudah nantinya akan masuk ke Home
// else {
// finishAffinity();
// startActivity(new Intent(getApplicationContext(), HomeActivity.class));
//// if (rule.contains("user")) {
//// startActivity(new Intent(getApplicationContext(), HomeActivity.class));
//// }
//// else {
//// startActivity(new Intent(getApplicationContext(), HomePetugasActivity.class));
//// }
//
// }
}
}, 2000);
}
}
| [
"ade.fajr.ariav@gmail.com"
] | ade.fajr.ariav@gmail.com |
f274ad34c0064ec6355b81c59239f8faf7dbe375 | 99b10bfc4cf6d7f2966508f66ae60a33bbde1b9c | /exemplo6/src/entities/Circle.java | bad151474c1f8a030e0e2a004037a562041bdb0a | [] | no_license | thalesburque/java-classes | a2b193c944990c03e3e87eae2797de364b7e00c6 | 7dba3c06cf904f551f18a8ee7d44b5fcd8aed418 | refs/heads/master | 2021-12-26T13:49:01.223730 | 2021-12-22T02:32:00 | 2021-12-22T02:32:00 | 141,288,736 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 430 | java | package entities;
import entities.enums.Color;
public class Circle extends Shape {
private Double radius;
public Circle() {
super();
}
public Circle(Color color, Double radius) {
super(color);
this.radius = radius;
}
public Double getRadius() {
return radius;
}
public void setRadius(Double radius) {
this.radius = radius;
}
@Override
public double area() {
return Math.PI * radius * radius;
}
}
| [
"thalesburque@gmail.com"
] | thalesburque@gmail.com |
931e2e31066085eddb07434b98a19f6f87958647 | 5e7608123a22cecef836ec02fbe48f93aa03190a | /Java-High-Concurrency-Programming/src/main/java/com/high/concurrency/chapter7/section13/PBBestMsg.java | 0fe8c9b2e7944ff5f8f1c844a67b9b83f2ab430d | [
"Apache-2.0"
] | permissive | liiibpm/Java_Multi_Thread | a01e2ba428d4cc9277357232ef37d4b770fddd6a | 39200a1096475557c749db68993e3a3ccc0547b5 | refs/heads/master | 2023-03-26T16:16:29.039854 | 2020-12-01T12:22:23 | 2020-12-01T12:22:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 404 | java | package com.high.concurrency.chapter7.section13;
/**
* @Description
* @Author dongzonglei
* @Date 2019/01/08 下午12:06
*/
public class PBBestMsg {
final PosValue value;
public PBBestMsg(PosValue value) {
this.value = value;
}
public PosValue getValue() {
return value;
}
@Override
public String toString() {
return value.toString();
}
}
| [
"dzllikelsw@163.com"
] | dzllikelsw@163.com |
f7e57bace5df8342a55f86f4e178a0f40edf2ad4 | 4045374345a05ee840ddd5d3f948642de00fab98 | /src/main/java/com/shawn/algorithm/leetcode/editor/cn/TopKFrequentElements.java | 5671e64adf4e6d7f6a47c34e36259cac601d7090 | [] | no_license | apple101215/algorithmleetcode | 4f4f60ef22d20c8265c4996bd0cbff1f6f9f2156 | 5b1f6686d84d55f0c69e7a10951f33b95788be8d | refs/heads/main | 2023-06-10T08:18:43.605349 | 2021-06-26T04:31:25 | 2021-06-26T04:31:25 | 347,312,167 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,836 | java | package com.shawn.algorithm.leetcode.editor.cn;
//给你一个整数数组 nums 和一个整数 k ,请你返回其中出现频率前 k 高的元素。你可以按 任意顺序 返回答案。
//
//
//
// 示例 1:
//
//
//输入: nums = [1,1,1,2,2,3], k = 2
//输出: [1,2]
//
//
// 示例 2:
//
//
//输入: nums = [1], k = 1
//输出: [1]
//
//
//
// 提示:
//
//
// 1 <= nums.length <= 105
// k 的取值范围是 [1, 数组中不相同的元素的个数]
// 题目数据保证答案唯一,换句话说,数组中前 k 个高频元素的集合是唯一的
//
//
//
//
// 进阶:你所设计算法的时间复杂度 必须 优于 O(n log n) ,其中 n 是数组大小。
// Related Topics 堆 哈希表
// 👍 778 👎 0
import java.util.*;
import java.util.stream.Collectors;
/**
* 前 K 个高频元素
* @author shawn
* @date 2021-06-19 13:37:15
*/
public class TopKFrequentElements{
public static void main(String[] args) {
Solution solution = new TopKFrequentElements().new Solution();
}
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public int[] topKFrequent(int[] nums, int k) {
HashMap<Integer, Integer> freq = new HashMap<>();
for (int num: nums) {
freq.put(num, freq.getOrDefault(num, 0) + 1);
}
PriorityQueue<Map.Entry<Integer, Integer>> values = new PriorityQueue<>(Comparator.comparingInt(Map.Entry::getValue));
for (Map.Entry<Integer, Integer> entry: freq.entrySet()) {
values.offer(entry);
if (values.size() > k) {
values.poll();
}
}
return values.stream().map(Map.Entry::getKey).mapToInt(Integer ::intValue).toArray();
}
}
//leetcode submit region end(Prohibit modification and deletion)
} | [
"543503245@qq.com"
] | 543503245@qq.com |
836240c57fa7cf7d6980f61b8485900515d9ae0e | d32f943bb96ad3f6af0742980e84ad8165823db7 | /src/main/java/com/zs/spring/config/rabbitmq/PublishSubscribeConfig.java | 4f652fcdf908736c0baab6f4a75dad1ae9eb65bd | [] | no_license | zhuangsen/spring_java_annotation | 2a15733e1abb104ffbac5fe939b71081b303e5f7 | d34a7f02c5b4250aea876a19f3c07c1b62bc0b47 | refs/heads/master | 2020-04-25T20:49:20.191266 | 2019-03-18T08:01:39 | 2019-03-18T08:01:39 | 173,061,236 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,462 | java | package com.zs.spring.config.rabbitmq;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @auther: madisonzhuang
* @date: 2019-03-01 14:49
* @description: 发布订阅模式的配置, 包括两个队列和对应的订阅者, 发布者的交换机类型使用fanout(子网广播), 两根网线binding用来绑定队列到交换机
*/
@Configuration
public class PublishSubscribeConfig {
@Autowired
RabbitConfig rabbitconfig;
@Bean
public Queue myQueue1() {
Queue queue = new Queue("queue1");
return queue;
}
@Bean
public Queue myQueue2() {
Queue queue = new Queue("queue2");
return queue;
}
@Bean
public FanoutExchange fanoutExchange() {
FanoutExchange fanoutExchange = new FanoutExchange("fanout");
return fanoutExchange;
}
@Bean
public Binding binding1() {
Binding binding = BindingBuilder.bind(myQueue1()).to(fanoutExchange());
return binding;
}
@Bean
public Binding binding2() {
Binding binding = BindingBuilder.bind(myQueue2()).to(fanoutExchange());
return binding;
}
}
| [
"zhuangsen@live.com"
] | zhuangsen@live.com |
06256df973d61f76392237fca606355d8f139827 | a981eed40a47206a031797fcef8decc20b1f4a69 | /app/src/main/java/cbots/b_to_c/decorations/OffsetItemDecoration.java | 3b4a47b8cb41cb58a0182059e32e6ee6862c1e67 | [] | no_license | mohanarchu/SrtTata | 357738c59d65241403583b90eb330fdd0b3893e8 | c152df602936b9bd9762ca87bbfebace9175c334 | refs/heads/master | 2020-12-02T18:47:18.520164 | 2020-03-19T11:48:03 | 2020-03-19T11:48:03 | 231,085,783 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,918 | java | package cbots.b_to_c.decorations;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import androidx.recyclerview.widget.RecyclerView;
public class OffsetItemDecoration extends RecyclerView.ItemDecoration {
private int firstViewWidth = -1;
private int lastViewWidth = -1;
private Context ctx;
private int edgePadding,viewWidth;
public OffsetItemDecoration(Context ctx, int edgePadding, int viewWidth) {
this.ctx = ctx;
this.edgePadding = edgePadding;
this.viewWidth = viewWidth;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
final int itemPosition = parent.getChildAdapterPosition(view);
if (itemPosition == RecyclerView.NO_POSITION) {
return;
}
final int itemCount = state.getItemCount();
/** first position */
if (itemPosition == 0) {
view.setVisibility(View.INVISIBLE);
}
/** last position */
else if (itemCount > 0 && itemPosition == itemCount - 1) {
view.setVisibility(View.INVISIBLE);
}
/** positions between first and last */
else {
view.setVisibility(View.VISIBLE);
}
}
private void setupOutRect(Rect rect, int offset, boolean start) {
if (start) {
rect.left = offset;
} else {
rect.right = offset;
}
}
private int getScreenWidth() {
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size.x;
}
} | [
"mohanrajarchunan@gmail.com"
] | mohanrajarchunan@gmail.com |
eb1df1e43c8eec868d8475f809a06e7a6a26c938 | 46cd430866a7fa496c40f9399884fa12de1a5ff2 | /jeeweb-web/jeeweb-vue/src/main/java/cn/jeeweb/web/modules/sms/service/impl/SmsSendLogServiceImpl.java | 60b5d1e4ecb7160923c7736e626cf8c9c09b8e06 | [
"Apache-2.0"
] | permissive | topjs/jeeweb2 | a460a4d224dae814328e9aef77c4741ed8bccbfb | 9cecf7c2b5791299ccbfe65418f1455af982637f | refs/heads/master | 2022-11-25T10:07:48.015233 | 2019-01-04T02:07:11 | 2019-01-04T02:07:11 | 194,079,683 | 2 | 0 | Apache-2.0 | 2022-11-16T10:33:42 | 2019-06-27T11:04:43 | TSQL | UTF-8 | Java | false | false | 1,437 | java | package cn.jeeweb.web.modules.sms.service.impl;
import cn.jeeweb.web.modules.sms.mapper.SmsSendLogMapper;
import cn.jeeweb.web.modules.sms.entity.SmsSendLog;
import cn.jeeweb.web.modules.sms.service.ISmsSendLogService;
import cn.jeeweb.common.mybatis.mvc.service.impl.CommonServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* All rights Reserved, Designed By www.jeeweb.cn
*
* @version V1.0
* @package cn.jeeweb.web.modules.sms.service.impl
* @title: 发送日志服务实现
* @description: 发送日志服务实现
* @author: 王存见
* @date: 2018-09-14 09:47:53
* @copyright: 2018 www.jeeweb.cn Inc. All rights reserved.
*/
@Transactional
@Service("smssendlogService")
public class SmsSendLogServiceImpl extends CommonServiceImpl<SmsSendLogMapper,SmsSendLog> implements ISmsSendLogService {
@Override
public boolean retrySend(List<? extends Serializable> idList) {
List<SmsSendLog> smsSendLogList=new ArrayList<SmsSendLog>();
for (Serializable id: idList) {
SmsSendLog smsSendLog=selectById(id);
smsSendLog.setTryNum(0);
smsSendLog.setStatus(SmsSendLog.SMS_SEND_STATUS_FAIL);
smsSendLogList.add(smsSendLog);
}
insertOrUpdateBatch(smsSendLogList);
return false;
}
} | [
"502079461@qq.com"
] | 502079461@qq.com |
db7754f7302d9d6183a768494a93370dd4265d97 | 48e835e6f176a8ac9ae3ca718e8922891f1e5a18 | /benchmark/training/com/google/devtools/build/lib/actions/ActionCacheCheckerTest.java | 190ec4f63a030d2eac0e9535f0e0e5a1f757cca7 | [] | no_license | STAMP-project/dspot-experiments | f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5 | 121487e65cdce6988081b67f21bbc6731354a47f | refs/heads/master | 2023-02-07T14:40:12.919811 | 2019-11-06T07:17:09 | 2019-11-06T07:17:09 | 75,710,758 | 14 | 19 | null | 2023-01-26T23:57:41 | 2016-12-06T08:27:42 | null | UTF-8 | Java | false | false | 8,653 | java | /**
* Copyright 2017 The Bazel Authors. All rights reserved.
*/
/**
*
*/
/**
* Licensed under the Apache License, Version 2.0 (the "License");
*/
/**
* you may not use this file except in compliance with the License.
*/
/**
* You may obtain a copy of the License at
*/
/**
*
*/
/**
* http://www.apache.org/licenses/LICENSE-2.0
*/
/**
*
*/
/**
* Unless required by applicable law or agreed to in writing, software
*/
/**
* distributed under the License is distributed on an "AS IS" BASIS,
*/
/**
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
/**
* See the License for the specific language governing permissions and
*/
/**
* limitations under the License.
*/
package com.google.devtools.build.lib.actions;
import MissReason.DIFFERENT_ACTION_KEY;
import MissReason.DIFFERENT_DEPS;
import MissReason.DIFFERENT_ENVIRONMENT;
import MissReason.DIFFERENT_FILES;
import MissReason.NOT_CACHED;
import MissReason.UNCONDITIONAL_EXECUTION;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.cache.CompactPersistentActionCache;
import com.google.devtools.build.lib.actions.cache.Md5Digest;
import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.clock.Clock;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.Root;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static ActionCache.Entry.CORRUPTED;
import static MiddlemanType.RUNFILES_MIDDLEMAN;
@RunWith(JUnit4.class)
public class ActionCacheCheckerTest {
private ActionCacheCheckerTest.CorruptibleCompactPersistentActionCache cache;
private ActionCacheChecker cacheChecker;
private Set<Path> filesToDelete;
@Test
public void testNoActivity() throws Exception {
assertStatistics(0, new ActionsTestUtil.MissDetailsBuilder().build());
}
@Test
public void testNotCached() throws Exception {
doTestNotCached(new ActionsTestUtil.NullAction(), NOT_CACHED);
}
@Test
public void testCached() throws Exception {
doTestCached(new ActionsTestUtil.NullAction(), NOT_CACHED);
}
@Test
public void testCorruptedCacheEntry() throws Exception {
doTestCorruptedCacheEntry(new ActionsTestUtil.NullAction());
}
@Test
public void testDifferentActionKey() throws Exception {
Action action = new ActionsTestUtil.NullAction() {
@Override
protected void computeKey(ActionKeyContext actionKeyContext, Fingerprint fp) {
fp.addString("key1");
}
};
runAction(action);
action = new ActionsTestUtil.NullAction() {
@Override
protected void computeKey(ActionKeyContext actionKeyContext, Fingerprint fp) {
fp.addString("key2");
}
};
runAction(action);
assertStatistics(0, new ActionsTestUtil.MissDetailsBuilder().set(DIFFERENT_ACTION_KEY, 1).set(NOT_CACHED, 1).build());
}
@Test
public void testDifferentEnvironment() throws Exception {
Action action = new ActionsTestUtil.NullAction() {
@Override
public Iterable<String> getClientEnvironmentVariables() {
return ImmutableList.of("used-var");
}
};
Map<String, String> clientEnv = new HashMap<>();
clientEnv.put("unused-var", "1");
runAction(action, clientEnv);// Not cached.
clientEnv.remove("unused-var");
runAction(action, clientEnv);// Cache hit because we only modified uninteresting variables.
clientEnv.put("used-var", "2");
runAction(action, clientEnv);// Cache miss because of different environment.
runAction(action, clientEnv);// Cache hit because we did not change anything.
assertStatistics(2, new ActionsTestUtil.MissDetailsBuilder().set(DIFFERENT_ENVIRONMENT, 1).set(NOT_CACHED, 1).build());
}
@Test
public void testDifferentFiles() throws Exception {
Action action = new ActionsTestUtil.NullAction();
runAction(action);// Not cached.
FileSystemUtils.writeContentAsLatin1(action.getPrimaryOutput().getPath(), "modified");
runAction(action);// Cache miss because output files were modified.
assertStatistics(0, new ActionsTestUtil.MissDetailsBuilder().set(DIFFERENT_FILES, 1).set(NOT_CACHED, 1).build());
}
@Test
public void testUnconditionalExecution() throws Exception {
Action action = new ActionsTestUtil.NullAction() {
@Override
public boolean executeUnconditionally() {
return true;
}
@Override
public boolean isVolatile() {
return true;
}
};
int runs = 5;
for (int i = 0; i < runs; i++) {
runAction(action);
}
assertStatistics(0, new ActionsTestUtil.MissDetailsBuilder().set(UNCONDITIONAL_EXECUTION, runs).build());
}
@Test
public void testMiddleman_NotCached() throws Exception {
doTestNotCached(new ActionCacheCheckerTest.NullMiddlemanAction(), DIFFERENT_DEPS);
}
@Test
public void testMiddleman_Cached() throws Exception {
doTestCached(new ActionCacheCheckerTest.NullMiddlemanAction(), DIFFERENT_DEPS);
}
@Test
public void testMiddleman_CorruptedCacheEntry() throws Exception {
doTestCorruptedCacheEntry(new ActionCacheCheckerTest.NullMiddlemanAction());
}
@Test
public void testMiddleman_DifferentFiles() throws Exception {
Action action = new ActionCacheCheckerTest.NullMiddlemanAction() {
@Override
public synchronized Iterable<Artifact> getInputs() {
FileSystem fileSystem = getPrimaryOutput().getPath().getFileSystem();
Path path = fileSystem.getPath("/input");
ArtifactRoot root = ArtifactRoot.asSourceRoot(Root.fromPath(fileSystem.getPath("/")));
return ImmutableList.of(new Artifact(path, root));
}
};
runAction(action);// Not cached so recorded as different deps.
FileSystemUtils.writeContentAsLatin1(action.getPrimaryInput().getPath(), "modified");
runAction(action);// Cache miss because input files were modified.
FileSystemUtils.writeContentAsLatin1(action.getPrimaryOutput().getPath(), "modified");
runAction(action);// Outputs are not considered for middleman actions, so this is a cache hit.
runAction(action);// Outputs are not considered for middleman actions, so this is a cache hit.
assertStatistics(2, new ActionsTestUtil.MissDetailsBuilder().set(DIFFERENT_DEPS, 1).set(DIFFERENT_FILES, 1).build());
}
/**
* A {@link CompactPersistentActionCache} that allows injecting corruption for testing.
*/
private static class CorruptibleCompactPersistentActionCache extends CompactPersistentActionCache {
private boolean corrupted = false;
CorruptibleCompactPersistentActionCache(Path cacheRoot, Clock clock) throws IOException {
super(cacheRoot, clock);
}
void corruptAllEntries() {
corrupted = true;
}
@Override
public Entry get(String key) {
if (corrupted) {
return CORRUPTED;
} else {
return super.get(key);
}
}
}
/**
* A null middleman action.
*/
private static class NullMiddlemanAction extends ActionsTestUtil.NullAction {
@Override
public MiddlemanType getActionType() {
return RUNFILES_MIDDLEMAN;
}
}
/**
* A fake metadata handler that is able to obtain metadata from the file system.
*/
private static class FakeMetadataHandler extends ActionsTestUtil.FakeMetadataHandlerBase {
@Override
public FileArtifactValue getMetadata(ActionInput input) throws IOException {
if (!(input instanceof Artifact)) {
return null;
}
return FileArtifactValue.create(((Artifact) (input)));
}
@Override
public void setDigestForVirtualArtifact(Artifact artifact, Md5Digest md5Digest) {
}
}
}
| [
"benjamin.danglot@inria.fr"
] | benjamin.danglot@inria.fr |
42226254c36c1503fed82996d7661f290e28ee6a | 677519b071d337e9164adcaf3303e3a1b0653e7f | /UserServiceForAdapter/src/main/java/com/sit/cloudnative/UserServiceForAdapter/UserServiceForAdapterApplication.java | a1039b21246b5509a545d4abf066fed7e9537183 | [] | no_license | PimIsariya/CloudNativeHW3 | 823cbee8065ba48f6e5e5cff7f3014ab97a8e052 | def722bfce40ad0cf90eac6b1d91f56414bb5a6c | refs/heads/master | 2020-03-30T04:14:09.369885 | 2018-09-28T12:03:28 | 2018-09-28T12:03:28 | 150,731,519 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 363 | java | package com.sit.cloudnative.UserServiceForAdapter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class UserServiceForAdapterApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceForAdapterApplication.class, args);
}
}
| [
"pim.paw.pitode@gmail.com"
] | pim.paw.pitode@gmail.com |
52954cb2a1ba4961bc45d1004217646556baac1b | f48410526913bf3bd487077ef90e9b1f7d7f9703 | /src/plugin/berkeley/BerkeleyDBManager.java | 066a8a497933d8263e7c7959ec4da745d712eb1f | [] | no_license | adjtyh/webcollector | 2875eb6bf4cb5f75707d60d4adab1e950009bfc9 | a60756e8438f53b459ab9a948570ab0097d8f524 | refs/heads/master | 2020-05-26T07:43:07.641751 | 2017-02-19T15:55:33 | 2017-02-19T15:55:33 | 82,470,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,589 | java | /*
* Copyright (C) 2015 hu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package plugin.berkeley;
import crawldb.DBManager;
import crawldb.Generator;
import model.CrawlDatum;
import model.CrawlDatums;
import util.CrawlDatumFormater;
import util.FileUtils;
import com.sleepycat.je.Cursor;
import com.sleepycat.je.CursorConfig;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.LockMode;
import com.sleepycat.je.OperationStatus;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author hu
*/
public class BerkeleyDBManager extends DBManager {
Logger LOG = LoggerFactory.getLogger(BerkeleyDBManager.class);
Environment env;
String crawlPath;
BerkeleyGenerator generator = null;
public BerkeleyDBManager(String crawlPath) {
this.crawlPath = crawlPath;
}
public void list() throws Exception {
if (env == null) {
open();
}
Cursor cursor = null;
Database crawldbDatabase = env.openDatabase(null, "crawldb", BerkeleyDBUtils.defaultDBConfig);
cursor = crawldbDatabase.openCursor(null, CursorConfig.DEFAULT);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
while (cursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
try {
CrawlDatum datum = BerkeleyDBUtils.createCrawlDatum(key, value);
System.out.println(CrawlDatumFormater.datumToString(datum));
} catch (Exception ex) {
LOG.info("Exception when generating", ex);
continue;
}
}
}
@Override
public void inject(CrawlDatum datum, boolean force) throws Exception {
Database database = env.openDatabase(null, "crawldb", BerkeleyDBUtils.defaultDBConfig);
DatabaseEntry key = BerkeleyDBUtils.strToEntry(datum.key());
DatabaseEntry value = new DatabaseEntry();
if (!force) {
if (database.get(null, key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
database.close();
return;
}
}
value = BerkeleyDBUtils.strToEntry(CrawlDatumFormater.datumToJsonStr(datum));
database.put(null, key, value);
database.close();
}
@Override
public void inject(CrawlDatums datums, boolean force) throws Exception {
Database database = env.openDatabase(null, "crawldb", BerkeleyDBUtils.defaultDBConfig);
for (int i = 0; i < datums.size(); i++) {
CrawlDatum datum = datums.get(i);
DatabaseEntry key = BerkeleyDBUtils.strToEntry(datum.key());
DatabaseEntry value = new DatabaseEntry();
if (!force) {
if (database.get(null, key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
continue;
}
}
value = BerkeleyDBUtils.strToEntry(CrawlDatumFormater.datumToJsonStr(datum));
database.put(null, key, value);
}
database.close();
}
@Override
public void open() throws Exception {
File dir = new File(crawlPath);
if (!dir.exists()) {
dir.mkdirs();
}
EnvironmentConfig environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
env = new Environment(dir, environmentConfig);
}
@Override
public void close() throws Exception {
env.close();
}
public int BUFFER_SIZE = 1;
Database fetchDatabase = null;
Database linkDatabase = null;
AtomicInteger count_fetch = new AtomicInteger(0);
AtomicInteger count_link = new AtomicInteger(0);
@Override
public void initSegmentWriter() throws Exception {
fetchDatabase = env.openDatabase(null, "fetch", BerkeleyDBUtils.defaultDBConfig);
linkDatabase = env.openDatabase(null, "link", BerkeleyDBUtils.defaultDBConfig);
count_fetch = new AtomicInteger(0);
count_link = new AtomicInteger(0);
}
@Override
public void writeFetchSegment(CrawlDatum fetchDatum) throws Exception {
BerkeleyDBUtils.writeDatum(fetchDatabase, fetchDatum);
}
@Override
public void writeParseSegment(CrawlDatums parseDatums) throws Exception {
for (CrawlDatum datum : parseDatums) {
BerkeleyDBUtils.writeDatum(linkDatabase, datum);
}
}
@Override
public void closeSegmentWriter() throws Exception {
if (fetchDatabase != null) {
fetchDatabase.close();
}
if (linkDatabase != null) {
linkDatabase.close();
}
}
@Override
public void merge() throws Exception {
LOG.info("start merge");
Database crawldbDatabase = env.openDatabase(null, "crawldb", BerkeleyDBUtils.defaultDBConfig);
/*合并fetch库*/
LOG.info("merge fetch database");
Database fetchDatabase = env.openDatabase(null, "fetch", BerkeleyDBUtils.defaultDBConfig);
Cursor fetchCursor = fetchDatabase.openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
while (fetchCursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
crawldbDatabase.put(null, key, value);
}
fetchCursor.close();
fetchDatabase.close();
/*合并link库*/
LOG.info("merge link database");
Database linkDatabase = env.openDatabase(null, "link", BerkeleyDBUtils.defaultDBConfig);
Cursor linkCursor = linkDatabase.openCursor(null, null);
while (linkCursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
if (!(crawldbDatabase.get(null, key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)) {
crawldbDatabase.put(null, key, value);
}
}
linkCursor.close();
linkDatabase.close();
LOG.info("end merge");
crawldbDatabase.close();
env.removeDatabase(null, "fetch");
LOG.debug("remove fetch database");
env.removeDatabase(null, "link");
LOG.debug("remove link database");
}
@Override
public boolean isDBExists() {
File dir = new File(crawlPath);
return dir.exists();
}
@Override
public void clear() throws Exception {
File dir = new File(crawlPath);
if (dir.exists()) {
FileUtils.deleteDir(dir);
}
}
@Override
public Generator getGenerator() {
if(generator==null){
generator = new BerkeleyGenerator(env);
}
return generator;
}
}
| [
"522926840@qq.com"
] | 522926840@qq.com |
ff8d41a75eb0dc11a096a85df25b5a2e45741d71 | 03b94dac2ab47eb77d2bd7df063c44573e14d6b0 | /app_wordteacher_old/src/main/java/com/example/alexeyglushkov/wordteacher/tools/UITools.java | c6b85d80ecaa3b30d0d62182545b445c4fefab30 | [
"MIT"
] | permissive | soniccat/android-taskmanager | 681384ec5a5cb15b52e892a668fb21d1b0962100 | 0e0fa442e16d5544f7694042cf40cafde3672173 | refs/heads/master | 2021-01-23T16:38:28.822685 | 2020-04-12T11:17:24 | 2020-04-12T11:17:24 | 28,707,156 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package com.example.alexeyglushkov.wordteacher.tools;
import android.app.Activity;
import androidx.annotation.NonNull;
import android.view.View;
import android.view.ViewTreeObserver;
/**
* Created by alexeyglushkov on 20.08.16.
*/
public class UITools {
public static void runAfterRender(Activity activity, final @NonNull PreDrawRunnable runnable) {
runAfterRender(getActivityView(activity), runnable);
}
public static void runAfterRender(final View view, final @NonNull PreDrawRunnable runnable) {
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
view.getViewTreeObserver().removeOnPreDrawListener(this);
return runnable.run();
}
});
}
public static View getActivityView(Activity activity) {
return activity.getWindow().getDecorView().getRootView();
}
public interface PreDrawRunnable {
boolean run();
}
}
| [
"soniccat@list.ru"
] | soniccat@list.ru |
ac8a9263e4c5bdbdf555dcbed5ee89241213c200 | 5a6fe4c54d473e6b69148b3de1533a1bbc6c0925 | /rest/src/main/java/com/mironov/image/studio/rest/controllers/ActivationController.java | b52c0ed3fb752eb8ac8762d6d4e8b5eab9d125b2 | [] | no_license | deadlypower231/it-academy-Image_studio | ab8f60f2b79501e49643a8d608f7ce5165a6b511 | 7471679faec7de620a6049c48c26a037ba5bd936 | refs/heads/master | 2023-05-13T12:39:41.105942 | 2021-05-26T19:14:25 | 2021-05-26T19:14:25 | 358,361,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,184 | java | package com.mironov.image.studio.rest.controllers;
import com.mironov.image.studio.api.dto.UserCreateDto;
import com.mironov.image.studio.api.services.IActivationService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/activation")
public class ActivationController {
private final IActivationService activationService;
public ActivationController(IActivationService activationService) {
this.activationService = activationService;
}
@GetMapping("/{activation}")
public String activation(@PathVariable(name = "activation") String activation, Model model) {
UserCreateDto user = this.activationService.activationUser(activation);
if (user == null) {
return "signup/failedActivation";
}
model.addAttribute("firstName", user.getFirstName());
model.addAttribute("lastName", user.getLastName());
return "signup/successfulActivation";
}
}
| [
"deadlypower1992@gmail.com"
] | deadlypower1992@gmail.com |
00c7082824e486ff669f93d2a1bc4abc922f107a | 487ab15c50f2f67115de204c8002db5e5edc213e | /node_arithmetic/src/main/java/com/lht/arithmetic/sort/impl/BubblingSort.java | 426d8816a5dc6ab48035e644b67e76ef3978a771 | [] | no_license | LLLLLHT/note_project | 8033ebeffb87218fd23f4327434d9be250e29eae | f31b6cf6b3d4b9028226e17ada25b0c37a454df8 | refs/heads/master | 2020-09-20T11:47:25.301502 | 2019-12-03T15:51:10 | 2019-12-03T15:51:10 | 224,467,303 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,371 | java | package com.lht.arithmetic.sort.impl;
import com.lht.arithmetic.sort.Sort;
import com.lht.arithmetic.sort.SortAction;
import java.util.Arrays;
public class BubblingSort implements Sort<Integer> {
/**
* 前 => 后 相邻两数 依次 比较,较大数下沉,较小上冒
* 68 57 59 52
* 1: 57 68 59 52
* 2:57 59 68 52
* 3:52 57 59 68
*/
// @Override
// public void com.lht.arithmetic.sort(Integer[] data) {
// for (int i = 0; i < data.length -1; i++) {
// if (data[i] < data[i + 1]){
// data[i] ^= data[i + 1];
// data[i + 1] ^= data[i];
// data[i] ^= data[i + 1];
// }
// }
// System.out.println("第一次:" + Arrays.toString(data));
//
// for (int i = 0; i < data.length -1-1; i++) {
// if (data[i] < data[i + 1]){
// data[i] ^= data[i + 1];
// data[i + 1] ^= data[i];
// data[i] ^= data[i + 1];
// }
// }
// System.out.println("第二次:" + Arrays.toString(data));
//
// for (int i = 0; i < data.length -1-1-1; i++) {
// if (data[i] < data[i + 1]){
// data[i] ^= data[i + 1];
// data[i + 1] ^= data[i];
// data[i] ^= data[i + 1];
// }
// }
// System.out.println("第三次:" + Arrays.toString(data));
//
// for (int i = 0; i < data.length -1-1-1-1; i++) {
// if (data[i] < data[i + 1]){
// data[i] ^= data[i + 1];
// data[i + 1] ^= data[i];
// data[i] ^= data[i + 1];
// }
// }
// System.out.println("第四次:" + Arrays.toString(data));
// }
@Override
public void sort(Integer[] data) {
for (int i = 0; i < data.length - 1; i++) {
for (int j = 0; j < data.length - 1 - i; j++) {
if (data[j] < data[j + 1]) {
data[j] ^= data[j + 1];
data[j + 1] ^= data[j];
data[j] ^= data[j + 1];
}
}
}
}
public static void main(String[] args) {
Integer[] data = SortAction.createData(10);
new BubblingSort().sort(data);
System.out.println("结果:" + Arrays.toString(data));
}
}
| [
"59951805@qq.com"
] | 59951805@qq.com |
95d54a63e968bef6b4b6bd26b2528e9a7c245fad | 3af6963d156fc1bf7409771d9b7ed30b5a207dc1 | /runtime/src/main/java/apple/foundation/NSMutableURLRequest.java | 7bec105e02811fbebabd6096b5ea5750491bed37 | [
"Apache-2.0"
] | permissive | yava555/j2objc | 1761d7ffb861b5469cf7049b51f7b73c6d3652e4 | dba753944b8306b9a5b54728a40ca30bd17bdf63 | refs/heads/master | 2020-12-30T23:23:50.723961 | 2015-09-03T06:57:20 | 2015-09-03T06:57:20 | 48,475,187 | 0 | 0 | null | 2015-12-23T07:08:22 | 2015-12-23T07:08:22 | null | UTF-8 | Java | false | false | 3,780 | java | package apple.foundation;
import java.io.*;
import java.nio.*;
import java.util.*;
import com.google.j2objc.annotations.*;
import com.google.j2objc.runtime.*;
import com.google.j2objc.runtime.block.*;
import apple.audiotoolbox.*;
import apple.corefoundation.*;
import apple.coregraphics.*;
import apple.coreservices.*;
import apple.uikit.*;
import apple.coreanimation.*;
import apple.coredata.*;
import apple.coremedia.*;
import apple.security.*;
import apple.dispatch.*;
@Library("Foundation/Foundation.h") @Mapping("NSMutableURLRequest")
public class NSMutableURLRequest
extends NSURLRequest
{
@Mapping("initWithURL:")
public NSMutableURLRequest(NSURL URL) { }
@Mapping("initWithURL:cachePolicy:timeoutInterval:")
public NSMutableURLRequest(NSURL URL, @Representing("NSURLRequestCachePolicy") long cachePolicy, double timeoutInterval) { }
@Mapping("init")
public NSMutableURLRequest() { }
@Mapping("URL")
public native NSURL getURL();
@Mapping("setURL:")
public native void setURL(NSURL v);
@Mapping("cachePolicy")
public native @Representing("NSURLRequestCachePolicy") long getCachePolicy();
@Mapping("setCachePolicy:")
public native void setCachePolicy(@Representing("NSURLRequestCachePolicy") long v);
@Mapping("timeoutInterval")
public native double getTimeoutInterval();
@Mapping("setTimeoutInterval:")
public native void setTimeoutInterval(double v);
@Mapping("mainDocumentURL")
public native NSURL getMainDocumentURL();
@Mapping("setMainDocumentURL:")
public native void setMainDocumentURL(NSURL v);
/**
* @since Available in iOS 4.0 and later.
*/
@Mapping("networkServiceType")
public native @Representing("NSURLRequestNetworkServiceType") long getNetworkServiceType();
/**
* @since Available in iOS 4.0 and later.
*/
@Mapping("setNetworkServiceType:")
public native void setNetworkServiceType(@Representing("NSURLRequestNetworkServiceType") long v);
/**
* @since Available in iOS 6.0 and later.
*/
@Mapping("allowsCellularAccess")
public native boolean allowsCellularAccess();
/**
* @since Available in iOS 6.0 and later.
*/
@Mapping("setAllowsCellularAccess:")
public native void setAllowsCellularAccess(boolean v);
@Mapping("HTTPMethod")
public native String getHTTPMethod();
@Mapping("setHTTPMethod:")
public native void setHTTPMethod(String v);
@Mapping("allHTTPHeaderFields")
public native NSDictionary<?, ?> getAllHTTPHeaderFields();
@Mapping("setAllHTTPHeaderFields:")
public native void setAllHTTPHeaderFields(NSDictionary<?, ?> v);
@Mapping("HTTPBody")
public native NSData getHTTPBody();
@Mapping("setHTTPBody:")
public native void setHTTPBody(NSData v);
@Mapping("HTTPBodyStream")
public native NSInputStream getHTTPBodyStream();
@Mapping("setHTTPBodyStream:")
public native void setHTTPBodyStream(NSInputStream v);
@Mapping("HTTPShouldHandleCookies")
public native boolean shouldHandleHTTPCookies();
@Mapping("setHTTPShouldHandleCookies:")
public native void setShouldHandleHTTPCookies(boolean v);
/**
* @since Available in iOS 4.0 and later.
*/
@Mapping("HTTPShouldUsePipelining")
public native boolean shouldUseHTTPPipelining();
/**
* @since Available in iOS 4.0 and later.
*/
@Mapping("setHTTPShouldUsePipelining:")
public native void setShouldUseHTTPPipelining(boolean v);
@Mapping("setValue:forHTTPHeaderField:")
public native void setHTTPHeaderField0(String value, String field);
@Mapping("addValue:forHTTPHeaderField:")
public native void addHTTPHeaderField0(String value, String field);
}
| [
"pchen@sellegit.com"
] | pchen@sellegit.com |
31a03d996ff7e084a5bbab64037f711ec26a9f97 | 0717b0f1bca515f1a6841c80bd0219f5869f9110 | /src/main/java/com/andreyDelay/javacore/chapter02/Example1.java | d85fe9b94001b51775bf02aef9e7d39f70e245da | [] | no_license | andreyDelay/javacore | 2f9b201cf38b944d8137880766ce295583cbae22 | 9dd1ffb1187b7df79b9e033dc12b893844ce495a | refs/heads/master | 2022-12-23T01:27:01.629555 | 2020-10-03T21:33:54 | 2020-10-03T21:33:54 | 262,768,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package main.java.com.andreyDelay.javacore.chapter02;
public class Example1 {
public static void main(String [] args) {
System.out.println("Простая программа на Java");
}
}
| [
"frowzygleb@gmail.com"
] | frowzygleb@gmail.com |
6907e0a66fac3db3004e9b903f722f06ee968dae | ca35f11f0d6d8f9b1cce9b9c08b828c9d387c4b0 | /app/src/main/java/com/thejoyrun/demo/dagger/module/ActivityScope.java | 216e4dec11e1cabed6e5850aaeb3a74d50eee957 | [] | no_license | taoweiji/DemoDagger | bd5f998f9993cc6faf02677af0f02a319e24f8a6 | 59f322d59e4ea52414ff492adcd3e520e4496d65 | refs/heads/master | 2021-01-10T02:48:29.466518 | 2016-03-22T08:06:03 | 2016-03-22T08:06:03 | 54,456,477 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 173 | java | package com.thejoyrun.demo.dagger.module;
import javax.inject.Scope;
/**
* Created by Wiki on 16/3/10.
*/
@Scope
//@Retention(RUNTIME)
public @interface ActivityScope {} | [
"taoweiji2008@qq.com"
] | taoweiji2008@qq.com |
3d013db7995d5437a77074be5f5509d95bf41164 | babb32dcc5ee79c3c58d274844afaa66dc223470 | /src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpImporter.java | 79156e619bcb9238d3745d50f94ae168a182db39 | [
"LGPL-2.1-only",
"LicenseRef-scancode-unknown-license-reference",
"GPL-3.0-only",
"Apache-2.0"
] | permissive | openbrian/josm-opendata | c0174a114dda02de7d288786016069331f4916eb | c1275d8da4c6ec504d75c3244dd99502a6b846d7 | refs/heads/master | 2020-04-14T04:49:48.420171 | 2019-03-06T15:37:29 | 2019-03-06T15:39:08 | 163,646,616 | 0 | 0 | Apache-2.0 | 2019-03-06T15:50:49 | 2018-12-31T06:52:52 | Java | UTF-8 | Java | false | false | 1,293 | java | // License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.io.IOException;
import java.io.InputStream;
import org.openstreetmap.josm.actions.ExtensionFileFilter;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.gui.progress.ProgressMonitor;
import org.openstreetmap.josm.io.IllegalDataException;
import org.openstreetmap.josm.plugins.opendata.core.OdConstants;
import org.openstreetmap.josm.plugins.opendata.core.io.AbstractImporter;
/**
* Shapefile (SHP) importer.
*/
public class ShpImporter extends AbstractImporter {
public static final ExtensionFileFilter SHP_FILE_FILTER = new ExtensionFileFilter(
OdConstants.SHP_EXT, OdConstants.SHP_EXT, tr("Shapefiles") + " (*."+OdConstants.SHP_EXT+")");
public ShpImporter() {
super(SHP_FILE_FILTER);
}
@Override
protected DataSet parseDataSet(InputStream in, ProgressMonitor instance)
throws IllegalDataException {
try {
return ShpReader.parseDataSet(in, file, handler, instance);
} catch (IOException e) {
throw new IllegalDataException(e);
}
}
}
| [
"brian@derocher.org"
] | brian@derocher.org |
a723bdb8021d46a7f190c4cd70523940a32ec76b | 12128fce852dd7ce0ae360451ba1d710fdfbdcb4 | /src/sample/game/state/GameState.java | 75c006be6a34bfd91791a3c11992fd9b0708a394 | [] | no_license | jedrzejkopiszka/JavaGameTutorial | 51248c2a74a8d90c1ada9384e15a65fa29ef7393 | cc5f0c7b6dc0701b7f948e366fb1460fccb08da7 | refs/heads/master | 2023-02-21T13:00:57.208238 | 2021-01-12T01:03:48 | 2021-01-12T01:03:48 | 328,282,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 429 | java | package sample.game.state;
import sample.controller.PlayerController;
import sample.core.Size;
import sample.entity.Player;
import sample.input.Input;
import sample.map.GameMap;
public class GameState extends State{
public GameState(Input input) {
super(input);
gameObjects.add(new Player(new PlayerController(input), spriteLibrary));
gameMap = new GameMap(new Size(20,20), spriteLibrary);
}
}
| [
"jedrzej.kopiszka2@gmail.com"
] | jedrzej.kopiszka2@gmail.com |
3c29239c2219c86cd8659797741b22e736213537 | aff5a57a349746570b5c7f60a552de47fcf2b8e2 | /Integral_Calculator/Integrator.java | 434fa4daa557ac1152a2d51103e38243ebe633d1 | [] | no_license | kamaleshwar/Java_assignments | 588220f6aba7f020736701b3d1e3f68f83b51ea2 | 7e997fd70ea8f92b9ad1167bdafe46a8dafe068c | refs/heads/master | 2016-09-06T07:30:27.003798 | 2015-08-15T18:45:50 | 2015-08-15T18:45:50 | 40,776,386 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,691 | java | /*
*Integrator.java
*
* Version:
* $Id: Integrator.java,v 1.7 10/27/2014 $
*
* @Authors: Raj & Kamaleshwar
*
* Revisions:
* $Log$
*/
import java.text.*;
/**
* This class calculates the volume of x*x+2y graph by using multi-threading
*
*/
public class Integrator {
static double greenUpArea;
static double greenDownArea;
static double yellowUpArea;
static double yellowDownArea;
double z;
double unit = 0.01;
double x;
double y;
double greenArea;
double yellowArea;
calcVolumeF t1;
calcVolumeB t2;
/**
* This class extends Thread class and creates a new thread every time when
* its instance is created
*/
class calcVolumeF extends Thread {
private double x;
private double y;
private double z;
private double unit;
public calcVolumeF(double x, double y, double z, double unit) {
this.x = x;
this.y = y;
this.z = z;
this.unit = unit;
}
public void run() {
if (z < 0) {
yellowDownArea += unit * unit * z;
} else {
greenUpArea += unit * unit * z;
}
}
}
/**
* This class extends Thread class and creates a new thread every time when
* its instance is created
*/
class calcVolumeB extends Thread {
private double x;
private double y;
private double z;
private double unit;
public calcVolumeB(double x, double y, double z, double unit) {
this.x = x;
this.y = y;
this.z = z;
this.unit = unit;
}
public void run() {
if (z < 0) {
greenDownArea += unit * unit * z;
} else {
yellowUpArea += unit * unit * z;
}
}
}
/**
* doAction method created threads for every unit area
*/
public void doAction() {
do {
for (y = -2; y <= 2; y = y + unit) {
for (x = -1; x <= 1; x = x + unit) {
z = ((x * x) + 2 * y);
t1 = new calcVolumeF(x, y, z, unit);
t1.start();
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
for (y = 2; y >= -2; y = y - unit) {
for (x = 1; x >= -1; x = x - unit) {
z = ((x * x) + 2 * y);
t2 = new calcVolumeB(x, y, z, unit);
t2.start();
try {
t2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
greenArea = greenUpArea + greenDownArea;
yellowArea = yellowUpArea + yellowDownArea;
System.out.println("yellowArea area: " + yellowArea);
System.out.println("greenArea area: " + greenArea);
System.out.println("(yellowArea - greenArea): "
+ Math.abs(yellowArea - greenArea));
} while (Math.abs(yellowArea - greenArea) <= 0.01);
}
public static void main(String[] args) {
Integrator obj = new Integrator();
obj.doAction();
}
}
| [
"kp2601@rit.edu"
] | kp2601@rit.edu |
fa4b89cf02c576bd63b90b8ac924f10175b75450 | f4a3cb46ddd1adef5941da5691e875dfd2f88476 | /Spring-Cloud-Demo/provider4_8085/src/main/java/demo/car_base/entity/CarBase.java | 89d6aecac95dbd397f081e65d7ddd6cffe1b4ed7 | [] | no_license | yangtao0314/Spring-Cloud-Demo | 70a2cb56e13434d92a7677eca8c8da220b6d0ae6 | 81936168819890be2e5ad6b631e054a01e5dceed | refs/heads/master | 2022-06-22T03:26:56.085072 | 2019-11-17T10:08:28 | 2019-11-17T10:08:28 | 222,226,501 | 0 | 0 | null | 2022-06-21T02:15:11 | 2019-11-17T09:45:27 | Java | UTF-8 | Java | false | false | 4,718 | java | package demo.car_base.entity;
import java.time.LocalDate;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author yangtao
* @since 2018-11-26
*/
public class CarBase implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("Id")
private String Id;
@TableField("CarPlateNum")
private String CarPlateNum;
@TableField("CarPlateColor")
private String CarPlateColor;
@TableField("CompanyId")
private String CompanyId;
@TableField("CarBrand")
private Integer CarBrand;
@TableField("CarType")
private Integer CarType;
@TableField("CarColor")
private Integer CarColor;
@TableField("PersonCount")
private Integer PersonCount;
@TableField("DisPlaceMent")
private Integer DisPlaceMent;
@TableField("FactoryTime")
private LocalDate FactoryTime;
@TableField("Organization")
private Integer Organization;
@TableField("Fuel")
private Integer Fuel;
@TableField("Power")
private Integer Power;
@TableField("CarStatus")
private Integer CarStatus;
@TableField("CarCurState")
private Integer CarCurState;
@TableField("IsDelete")
private Boolean IsDelete;
public String getId() {
return Id;
}
public void setId(String Id) {
this.Id = Id;
}
public String getCarPlateNum() {
return CarPlateNum;
}
public void setCarPlateNum(String CarPlateNum) {
this.CarPlateNum = CarPlateNum;
}
public String getCarPlateColor() {
return CarPlateColor;
}
public void setCarPlateColor(String CarPlateColor) {
this.CarPlateColor = CarPlateColor;
}
public String getCompanyId() {
return CompanyId;
}
public void setCompanyId(String CompanyId) {
this.CompanyId = CompanyId;
}
public Integer getCarBrand() {
return CarBrand;
}
public void setCarBrand(Integer CarBrand) {
this.CarBrand = CarBrand;
}
public Integer getCarType() {
return CarType;
}
public void setCarType(Integer CarType) {
this.CarType = CarType;
}
public Integer getCarColor() {
return CarColor;
}
public void setCarColor(Integer CarColor) {
this.CarColor = CarColor;
}
public Integer getPersonCount() {
return PersonCount;
}
public void setPersonCount(Integer PersonCount) {
this.PersonCount = PersonCount;
}
public Integer getDisPlaceMent() {
return DisPlaceMent;
}
public void setDisPlaceMent(Integer DisPlaceMent) {
this.DisPlaceMent = DisPlaceMent;
}
public LocalDate getFactoryTime() {
return FactoryTime;
}
public void setFactoryTime(LocalDate FactoryTime) {
this.FactoryTime = FactoryTime;
}
public Integer getOrganization() {
return Organization;
}
public void setOrganization(Integer Organization) {
this.Organization = Organization;
}
public Integer getFuel() {
return Fuel;
}
public void setFuel(Integer Fuel) {
this.Fuel = Fuel;
}
public Integer getPower() {
return Power;
}
public void setPower(Integer Power) {
this.Power = Power;
}
public Integer getCarStatus() {
return CarStatus;
}
public void setCarStatus(Integer CarStatus) {
this.CarStatus = CarStatus;
}
public Integer getCarCurState() {
return CarCurState;
}
public void setCarCurState(Integer CarCurState) {
this.CarCurState = CarCurState;
}
public Boolean getIsDelete() {
return IsDelete;
}
public void setIsDelete(Boolean IsDelete) {
this.IsDelete = IsDelete;
}
@Override
public String toString() {
return "CarBase{" +
"Id=" + Id +
", CarPlateNum=" + CarPlateNum +
", CarPlateColor=" + CarPlateColor +
", CompanyId=" + CompanyId +
", CarBrand=" + CarBrand +
", CarType=" + CarType +
", CarColor=" + CarColor +
", PersonCount=" + PersonCount +
", DisPlaceMent=" + DisPlaceMent +
", FactoryTime=" + FactoryTime +
", Organization=" + Organization +
", Fuel=" + Fuel +
", Power=" + Power +
", CarStatus=" + CarStatus +
", CarCurState=" + CarCurState +
", IsDelete=" + IsDelete +
"}";
}
}
| [
"675821215@qq.com"
] | 675821215@qq.com |
01c2e1506c8e3d82f68ade0dd12f4ecb8eb70bbf | 9bc7eefb6ef74db16a97b66e1639ce574ad04e5a | /data/src/main/java/cern/colt/Sorting.java | 70b932ec0be55a6964c1cceef3a9bdcae2131aff | [
"Apache-2.0"
] | permissive | nw31304/openlr | 7ddd83d333d2039a0bd7adca3530e7176c496449 | 0f06e48070ce20ad1fb8ea1c3ea144d863fcd51f | refs/heads/master | 2020-07-04T22:43:55.159880 | 2019-08-15T07:44:10 | 2019-08-15T07:44:10 | 202,446,436 | 0 | 0 | null | 2019-08-15T00:36:35 | 2019-08-15T00:36:35 | null | UTF-8 | Java | false | false | 91,432 | java | /*
Copyright (c) 1999 CERN - European Organization for Nuclear Research.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
is hereby granted without fee, provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in supporting documentation.
CERN makes no representations about the suitability of this software for any purpose.
It is provided "as is" without expressed or implied warranty.
*/
package cern.colt;
import java.util.Comparator;
import cern.colt.function.ByteComparator;
import cern.colt.function.CharComparator;
import cern.colt.function.DoubleComparator;
import cern.colt.function.FloatComparator;
import cern.colt.function.IntComparator;
import cern.colt.function.LongComparator;
import cern.colt.function.ShortComparator;
/**
* Quicksorts, mergesorts and binary searches; complements <tt>java.util.Arrays</tt>.
* Contains, for example, the quicksort on Comparators and Comparables, which are still missing in <tt>java.util.Arrays</tt> of JDK 1.2.
* Also provides mergesorts for types not supported in <tt>java.util.Arrays</tt>, as well as a couple of other methods for primitive arrays.
* The quicksorts and mergesorts are the JDK 1.2 V1.26 algorithms, modified as necessary.
*
* @see cern.colt.GenericSorting
* @see cern.colt.matrix.doublealgo.Sorting
* @see java.util.Arrays
*
* @author wolfgang.hoschek@cern.ch
* @version 1.0, 03-Jul-99
*/
public class Sorting extends Object {
private static final int SMALL = 7;
private static final int MEDIUM = 40;
/**
* Makes this class non instantiable, but still let's others inherit from it.
*/
protected Sorting() {}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(byte[] list, byte key, int from, int to) {
byte midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(char[] list, char key, int from, int to) {
char midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(double[] list, double key, int from, int to) {
double midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(float[] list, float key, int from, int to) {
float midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(int[] list, int key, int from, int to) {
int midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
/*
// even for very short lists (0,1,2,3 elems) this is only 10% faster
while (from<=to && list[from++] < key) ;
if (from<=to) {
if (list[--from] == key) return from;
}
return -(from + 1);
*/
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(long[] list, long key, int from, int to) {
long midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must be sorted into ascending order
* according to the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* If the list is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which instance
* will be found.
*
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @param comparator the comparator by which the list is sorted.
* @throws ClassCastException if the list contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
* @see java.util.Comparator
*/
public static int binarySearchFromTo(Object[] list, Object key, int from, int to, java.util.Comparator comparator) {
Object midVal;
while (from <= to) {
int mid =(from + to)/2;
midVal = list[mid];
int cmp = comparator.compare(midVal,key);
if (cmp < 0) from = mid + 1;
else if (cmp > 0) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(short[] list, short key, int from, int to) {
short midVal;
while (from <= to) {
int mid = (from + to) / 2;
midVal = list[mid];
if (midVal < key) from = mid + 1;
else if (midVal > key) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
/**
* Generically searches the list for the specified value using
* the binary search algorithm. The list must <strong>must</strong> be
* sorted (as by the sort method) prior to making this call. If
* it is not sorted, the results are undefined: in particular, the call
* may enter an infinite loop. If the list contains multiple elements
* equal to the specified key, there is no guarantee which of the multiple elements
* will be found.
*
* @param list the list to be searched.
* @param key the value to be searched for.
* @param from the leftmost search position, inclusive.
* @param to the rightmost search position, inclusive.
* @return index of the search key, if it is contained in the list;
* otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
* point</i> is defined as the the point at which the value would
* be inserted into the list: the index of the first
* element greater than the key, or <tt>list.length</tt>, if all
* elements in the list are less than the specified key. Note
* that this guarantees that the return value will be >= 0 if
* and only if the key is found.
* @see java.util.Arrays
*/
public static int binarySearchFromTo(int from, int to, IntComparator comp) {
final int dummy = 0;
while (from <= to) {
int mid = (from + to) / 2;
int comparison = comp.compare(dummy,mid);
if (comparison < 0) from = mid + 1;
else if (comparison > 0) to = mid - 1;
else return mid; // key found
}
return -(from + 1); // key not found.
}
private static int lower_bound(int[] array, int first, int last, int x) {
int len = last - first;
while (len > 0) {
int half = len / 2;
int middle = first + half;
if (array[middle] < x) {
first = middle + 1;
len -= half + 1;
} else
len = half;
}
return first;
}
private static int upper_bound(int[] array, int first, int last, int x) {
int len = last - first;
while (len > 0) {
int half = len / 2;
int middle = first + half;
if (x < array[middle])
len = half;
else {
first = middle + 1;
len -= half + 1;
}
}
return first;
}
private static void inplace_merge(int[] array, int first, int middle, int last) {
if (first >= middle || middle >= last)
return;
if (last - first == 2) {
if (array[middle] < array[first]) {
int tmp = array[first];
array[first] = array[middle];
array[middle] = tmp;
}
return;
}
int firstCut;
int secondCut;
if (middle - first > last - middle) {
firstCut = first + (middle - first) / 2;
secondCut = lower_bound(array, middle, last, array[firstCut]);
} else {
secondCut = middle + (last - middle) / 2;
firstCut = upper_bound(array, first, middle, array[secondCut]);
}
//rotate(array, firstCut, middle, secondCut);
// is manually inlined for speed (jitter inlining seems to work only for small call depths, even if methods are "static private")
// speedup = 1.7
// begin inline
int first2 = firstCut; int middle2 = middle; int last2 = secondCut;
if (middle2 != first2 && middle2 != last2) {
int first1 = first2; int last1 = middle2;
int tmp;
while (first1 < --last1) { tmp = array[first1]; array[last1] = array[first1]; array[first1++] = tmp; }
first1 = middle2; last1 = last2;
while (first1 < --last1) { tmp = array[first1]; array[last1] = array[first1]; array[first1++] = tmp; }
first1 = first2; last1 = last2;
while (first1 < --last1) { tmp = array[first1]; array[last1] = array[first1]; array[first1++] = tmp; }
}
// end inline
middle = firstCut + (secondCut - middle);
inplace_merge(array, first, firstCut, middle);
inplace_merge(array, middle, secondCut, last);
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(byte x[], int a, int b, int c, ByteComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(char x[], int a, int b, int c, CharComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(double x[], int a, int b, int c, DoubleComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(float x[], int a, int b, int c, FloatComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(int x[], int a, int b, int c, IntComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(long x[], int a, int b, int c, LongComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(Object x[], int a, int b, int c) {
int ab = ((Comparable)x[a]).compareTo((Comparable)x[b]);
int ac = ((Comparable)x[a]).compareTo((Comparable)x[c]);
int bc = ((Comparable)x[b]).compareTo((Comparable)x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(Object x[], int a, int b, int c, Comparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Returns the index of the median of the three indexed chars.
*/
private static int med3(short x[], int a, int b, int c, ShortComparator comp) {
int ab = comp.compare(x[a],x[b]);
int ac = comp.compare(x[a],x[c]);
int bc = comp.compare(x[b],x[c]);
return (ab<0 ?
(bc<0 ? b : ac<0 ? c : a) :
(bc>0 ? b : ac>0 ? c : a));
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(byte[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
byte aux[] = (byte[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(byte[] a, int fromIndex, int toIndex, ByteComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
byte aux[] = (byte[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(char[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
char aux[] = (char[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(char[] a, int fromIndex, int toIndex, CharComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
char aux[] = (char[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(double[] a, int fromIndex, int toIndex) {
mergeSort2(a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(double[] a, int fromIndex, int toIndex, DoubleComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
double aux[] = (double[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(float[] a, int fromIndex, int toIndex) {
mergeSort2(a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(float[] a, int fromIndex, int toIndex, FloatComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
float aux[] = (float[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(int[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
int aux[] = (int[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(int[] a, int fromIndex, int toIndex, IntComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
int aux[] = (int[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(long[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
long aux[] = (long[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(long[] a, int fromIndex, int toIndex, LongComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
long aux[] = (long[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSort(short[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
short aux[] = (short[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void mergeSort(short[] a, int fromIndex, int toIndex, ShortComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
short aux[] = (short[]) a.clone();
mergeSort1(aux, a, fromIndex, toIndex, c);
}
private static void mergeSort1(byte src[], byte dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(byte src[], byte dest[], int low, int high, ByteComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(char src[], char dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(char src[], char dest[], int low, int high, CharComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(double src[], double dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(double src[], double dest[], int low, int high, DoubleComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(float src[], float dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(float src[], float dest[], int low, int high, FloatComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(int src[], int dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(int src[], int dest[], int low, int high, IntComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(long src[], long dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(long src[], long dest[], int low, int high, LongComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(short src[], short dest[], int low, int high) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && dest[j-1] > dest[j]; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid);
mergeSort1(dest, src, mid, high);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (src[mid-1] <= src[mid]) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && src[p] <= src[q])
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort1(short src[], short dest[], int low, int high, ShortComparator c) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i=low; i<high; i++)
for (int j=i; j>low && c.compare(dest[j-1], dest[j])>0; j--)
swap(dest, j, j-1);
return;
}
// Recursively sort halves of dest into src
int mid = (low + high)/2;
mergeSort1(dest, src, low, mid, c);
mergeSort1(dest, src, mid, high, c);
// If list is already sorted, just copy from src to dest. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (c.compare(src[mid-1], src[mid]) <= 0) {
System.arraycopy(src, low, dest, low, length);
return;
}
// Merge sorted halves (now in src) into dest
for(int i = low, p = low, q = mid; i < high; i++) {
if (q>=high || p<mid && c.compare(src[p], src[q]) <= 0)
dest[i] = src[p++];
else
dest[i] = src[q++];
}
}
private static void mergeSort2(double a[], int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
final long NEG_ZERO_BITS = Double.doubleToLongBits(-0.0d);
/*
* The sort is done in three phases to avoid the expense of using
* NaN and -0.0 aware comparisons during the main sort.
*/
/*
* Preprocessing phase: Move any NaN's to end of array, count the
* number of -0.0's, and turn them into 0.0's.
*/
int numNegZeros = 0;
int i = fromIndex, n = toIndex;
while(i < n) {
if (a[i] != a[i]) {
a[i] = a[--n];
a[n] = Double.NaN;
} else {
if (a[i]==0 && Double.doubleToLongBits(a[i])==NEG_ZERO_BITS) {
a[i] = 0.0d;
numNegZeros++;
}
i++;
}
}
// Main sort phase: mergesort everything but the NaN's
double aux[] = (double[]) a.clone();
mergeSort1(aux, a, fromIndex, n);
// Postprocessing phase: change 0.0's to -0.0's as required
if (numNegZeros != 0) {
int j = new cern.colt.list.DoubleArrayList(a).binarySearchFromTo(0.0d, fromIndex, n-1); // posn of ANY zero
do {
j--;
} while (j>=0 && a[j]==0.0d);
// j is now one less than the index of the FIRST zero
for (int k=0; k<numNegZeros; k++)
a[++j] = -0.0d;
}
}
private static void mergeSort2(float a[], int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
final int NEG_ZERO_BITS = Float.floatToIntBits(-0.0f);
/*
* The sort is done in three phases to avoid the expense of using
* NaN and -0.0 aware comparisons during the main sort.
*/
/*
* Preprocessing phase: Move any NaN's to end of array, count the
* number of -0.0's, and turn them into 0.0's.
*/
int numNegZeros = 0;
int i = fromIndex, n = toIndex;
while(i < n) {
if (a[i] != a[i]) {
a[i] = a[--n];
a[n] = Float.NaN;
} else {
if (a[i]==0 && Float.floatToIntBits(a[i])==NEG_ZERO_BITS) {
a[i] = 0.0f;
numNegZeros++;
}
i++;
}
}
// Main sort phase: mergesort everything but the NaN's
float aux[] = (float[]) a.clone();
mergeSort1(aux, a, fromIndex, n);
// Postprocessing phase: change 0.0's to -0.0's as required
if (numNegZeros != 0) {
int j = new cern.colt.list.FloatArrayList(a).binarySearchFromTo(0.0f, fromIndex, n-1); // posn of ANY zero
do {
j--;
} while (j>=0 && a[j]==0.0f);
// j is now one less than the index of the FIRST zero
for (int k=0; k<numNegZeros; k++)
a[++j] = -0.0f;
}
}
/**
* Sorts the specified range of the specified array of elements.
*
* <p>This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void mergeSortInPlace(int[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
int length = toIndex - fromIndex;
// Insertion sort on smallest arrays
if (length < SMALL) {
for (int i = fromIndex; i < toIndex; i++) {
for (int j = i; j > fromIndex && a[j - 1] > a[j]; j--) {
int tmp = a[j]; a[j] = a[j - 1]; a[j-1] = tmp;
}
}
return;
}
// Recursively sort halves
int mid = (fromIndex + toIndex) / 2;
mergeSortInPlace(a,fromIndex, mid);
mergeSortInPlace(a,mid, toIndex);
// If list is already sorted, nothing left to do. This is an
// optimization that results in faster sorts for nearly ordered lists.
if (a[mid-1] <= a[mid]) return;
// Merge sorted halves
//jal.INT.Sorting.inplace_merge(a, fromIndex, mid, toIndex);
inplace_merge(a, fromIndex, mid, toIndex);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(byte[] a, int fromIndex, int toIndex, ByteComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(char[] a, int fromIndex, int toIndex, CharComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(double[] a, int fromIndex, int toIndex, DoubleComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(float[] a, int fromIndex, int toIndex, FloatComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(int[] a, int fromIndex, int toIndex, IntComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(long[] a, int fromIndex, int toIndex, LongComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified range of the receiver into
* ascending order, according to the <i>natural ordering</i> of its
* elements. All elements in this range must implement the
* <tt>Comparable</tt> interface. Furthermore, all elements in this range
* must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt>
* must not throw a <tt>ClassCastException</tt> for any elements
* <tt>e1</tt> and <tt>e2</tt> in the array).<p>
*
* The sorting algorithm is a tuned quicksort, adapted from Jon
* L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
* Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
* 1993). This algorithm offers n*log(n) performance on many data sets
* that cause other quicksorts to degrade to quadratic performance.
*
* @param a the array to be sorted.
*/
public static void quickSort(Object[] a) {
quickSort1(a, 0, a.length);
}
/**
* Sorts the specified range of the receiver into
* ascending order, according to the <i>natural ordering</i> of its
* elements. All elements in this range must implement the
* <tt>Comparable</tt> interface. Furthermore, all elements in this range
* must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt>
* must not throw a <tt>ClassCastException</tt> for any elements
* <tt>e1</tt> and <tt>e2</tt> in the array).<p>
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
*/
public static void quickSort(Object[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex);
}
/**
* Sorts the specified range of the specified array according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the receiver.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(Object[] a, int fromIndex, int toIndex, Comparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified array according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* The sorting algorithm is a tuned quicksort,
* adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
* Sort Function", Software-Practice and Experience, Vol. 23(11)
* P. 1249-1265 (November 1993). This algorithm offers n*log(n)
* performance on many data sets that cause other quicksorts to degrade to
* quadratic performance.
*
* @param a the array to be sorted.
* @param c the comparator to determine the order of the receiver.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(Object[] a, Comparator c) {
quickSort1(a, 0, a.length, c);
}
/**
* Sorts the specified range of the specified array of elements according
* to the order induced by the specified comparator. All elements in the
* range must be <i>mutually comparable</i> by the specified comparator
* (that is, <tt>c.compare(e1, e2)</tt> must not throw a
* <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
* <tt>e2</tt> in the range).<p>
*
* This sort is guaranteed to be <i>stable</i>: equal elements will
* not be reordered as a result of the sort.<p>
*
* The sorting algorithm is a modified mergesort (in which the merge is
* omitted if the highest element in the low sublist is less than the
* lowest element in the high sublist). This algorithm offers guaranteed
* n*log(n) performance, and can approach linear performance on nearly
* sorted lists.
*
* @param a the array to be sorted.
* @param fromIndex the index of the first element (inclusive) to be
* sorted.
* @param toIndex the index of the last element (exclusive) to be sorted.
* @param c the comparator to determine the order of the array.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
* @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
* <tt>toIndex > a.length</tt>
* @see java.util.Comparator
*/
public static void quickSort(short[] a, int fromIndex, int toIndex, ShortComparator c) {
rangeCheck(a.length, fromIndex, toIndex);
quickSort1(a, fromIndex, toIndex-fromIndex, c);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(byte x[], int off, int len, ByteComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
byte v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(char x[], int off, int len, CharComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
char v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(double x[], int off, int len, DoubleComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
double v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(float x[], int off, int len, FloatComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
float v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(int x[], int off, int len, IntComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
int v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(long x[], int off, int len, LongComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
long v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(Object x[], int off, int len) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && ((Comparable)x[j-1]).compareTo((Comparable)x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s);
m = med3(x, m-s, m, m+s);
n = med3(x, n-2*s, n-s, n);
}
m = med3(x, l, m, n); // Mid-size, med of 3
}
Comparable v = (Comparable)x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=((Comparable)x[b]).compareTo(v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=((Comparable)x[c]).compareTo(v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s);
if ((s = d-c) > 1)
quickSort1(x, n-s, s);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(Object x[], int off, int len, Comparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
Object v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Sorts the specified sub-array of chars into ascending order.
*/
private static void quickSort1(short x[], int off, int len, ShortComparator comp) {
// Insertion sort on smallest arrays
if (len < SMALL) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && comp.compare(x[j-1],x[j])>0; j--)
swap(x, j, j-1);
return;
}
// Choose a partition element, v
int m = off + len/2; // Small arrays, middle element
if (len > SMALL) {
int l = off;
int n = off + len - 1;
if (len > MEDIUM) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s, comp);
m = med3(x, m-s, m, m+s, comp);
n = med3(x, n-2*s, n-s, n, comp);
}
m = med3(x, l, m, n, comp); // Mid-size, med of 3
}
short v = x[m];
// Establish Invariant: v* (<v)* (>v)* v*
int a = off, b = a, c = off + len - 1, d = c;
while(true) {
int comparison;
while (b <= c && (comparison=comp.compare(x[b],v))<=0) {
if (comparison == 0)
swap(x, a++, b);
b++;
}
while (c >= b && (comparison=comp.compare(x[c],v))>=0) {
if (comparison == 0)
swap(x, c, d--);
c--;
}
if (b > c)
break;
swap(x, b++, c--);
}
// Swap partition elements back to middle
int s, n = off + len;
s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s);
s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s);
// Recursively sort non-partition-elements
if ((s = b-a) > 1)
quickSort1(x, off, s, comp);
if ((s = d-c) > 1)
quickSort1(x, n-s, s, comp);
}
/**
* Check that fromIndex and toIndex are in range, and throw an
* appropriate exception if they aren't.
*/
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(byte x[], int a, int b) {
byte t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(char x[], int a, int b) {
char t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(double x[], int a, int b) {
double t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(float x[], int a, int b) {
float t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(int x[], int a, int b) {
int t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(long x[], int a, int b) {
long t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(Object x[], int a, int b) {
Object t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a] with x[b].
*/
private static void swap(short x[], int a, int b) {
short t = x[a];
x[a] = x[b];
x[b] = t;
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(byte x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(char x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(double x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(float x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(int x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(long x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(Object x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
/**
* Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
*/
private static void vecswap(short x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}
}
| [
"stephen.curran@tomtom.com"
] | stephen.curran@tomtom.com |
6fad83b0e8ae260dcd70f0aadb8b92aa434e9156 | 218da8a577c089b7c688f46a9936c3a3bf8d7706 | /Assignments1-2/src/com/acadgild/firstsession/VowelorConsonant.java | 029fb605ac62986da60696fb7f60a74c1cd1b02a | [] | no_license | AcadGildAcademy/AN-2015JUN13-VaibhavNamburi | 6771546f7c2601437ae1a4461ab2f8bc47aa6300 | 4720d110f94a8b7d62e4f0e7155828123f5b0019 | refs/heads/master | 2020-08-26T09:44:09.313925 | 2015-07-01T16:42:13 | 2015-07-01T16:42:13 | 37,381,180 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,062 | java | package com.acadgild.firstsession;
import java.util.Scanner;
public class VowelorConsonant {
public static void main(String[] args) {
System.out.println("Please input a letter: ");
@SuppressWarnings("resource")
Scanner input = new Scanner(System.in);
String inputLetter= input.nextLine();
char inputLetterChar = inputLetter.charAt(0);
// char capitalLetter = Character.toUpperCase(inputLetterChar);
if(inputLetterChar == 'a' || inputLetterChar == 'A') {
System.out.println(inputLetterChar + " is a vowel");
}
if(inputLetterChar == 'e' || inputLetterChar == 'E'){
System.out.println(inputLetterChar + " is a vowel");
}
if(inputLetterChar == 'i' || inputLetterChar == 'I'){
System.out.println(inputLetterChar + " is a vowel");
}
if(inputLetterChar == 'o' || inputLetterChar == 'O'){
System.out.println(inputLetterChar + " is a vowel");
}
if(inputLetterChar == 'u' || inputLetterChar == 'U')
System.out.println(inputLetterChar + " is a vowel");
else
System.out.println(inputLetterChar + " isn't a vowel");
}
}
| [
"veebuv@gmail.com"
] | veebuv@gmail.com |
19b0c44287666a831ae5af494a857ebdcdda8805 | 6fae3c60070721a93e13afb8b7e22370c6a94fe4 | /Sem03-Object-Oriented-Programming-LAB/WEEK 06/sameer code/demo4/house.java | 6052597ab44a10c9336e5a217af1661e12056127 | [] | no_license | akankshreddy/Kaustav-CSE-LABS-and-Projects | ea78c82fdc9339aa12a93732a2b5c8b3becda0e0 | 680b807040ce24d7034b18b2c38231fcf37732c1 | refs/heads/main | 2023-08-08T05:57:43.045753 | 2021-08-27T20:45:24 | 2021-08-27T20:45:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 660 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.course.structure;
import java.util.*;
/**
*
* @author sameer admin
*/
public class house extends buidling {
int bed,bath;
public house()
{
super();
System.out.println("Enter number of bedrooms amd bathrooms");
Scanner s=new Scanner(System.in);
bed=s.nextInt();
bath=s.nextInt();
}
public int bed()
{
return bed;
}
public int bath()
{
return bath;
}
}
| [
"teetangh@gmail.com"
] | teetangh@gmail.com |
e6f183621bfd328762be74b596ca8877219ef51d | eecf92252c90ff96b5bfa7592b0d61c62c23688e | /src/CS151/DOval.java | 4844d79e7011b44762a9fbe4ff34e95e973fd8d2 | [] | no_license | mikemonson/Whiteboard | 182dc112164db52a433b22b0dce6d5263b3bddab | adbadc3043cc7433b806fe5e1cfe2fc65429a932 | refs/heads/master | 2020-06-16T11:09:39.586904 | 2016-11-28T23:08:54 | 2016-11-28T23:08:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 54 | java | package CS151;
public class DOval extends DShape{
}
| [
"juraszeklukasz@gmail.com"
] | juraszeklukasz@gmail.com |
5e20414044346168e89bdedd54ed136e0051b011 | 1926c85524cda9bc07af9737375a8b97483abfd7 | /배운내용 및 실습들/studentMgr4(List)/src/kh/student/model/vo/Student.java | 05f6357ecf74f1d01d54b1e5889a0ea13c25a936 | [] | no_license | Jongmo-kim/dangsanLearned | 22a83c27a502aa5e817972100570fb5e35baf6e1 | e2769fbdb6718236e9efa9f8d5400fc38b64ddf1 | refs/heads/master | 2023-01-24T10:03:04.134997 | 2020-12-09T09:23:55 | 2020-12-09T09:23:55 | 288,411,448 | 0 | 1 | null | null | null | null | UHC | Java | false | false | 829 | java | package kh.student.model.vo;
/*
* 버전명의미
* 맨앞 3
* ex 2->c언어로
* 3-> java로
* major 변화 이럴땐 제일 앞 이바뀜
* 3.2.1245
*
* 2 는 버그 픽스
* 45는 자잘한느낌
* major는 3정도는되야 팔만한 소프트웨어
*
*/
public class Student {
private String name;
private int age;
private String addr;
public Student(String name, int age, String addr) {
super();
this.name = name;
this.age = age;
this.addr = addr;
}
public Student() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr;
}
}
| [
"wa1358@naver.com"
] | wa1358@naver.com |
1c83778aa8ccb2a0ead8d87c99dde9cfed92aefe | dc4dab0285de5bce8acedd07c4a90cbebb61c40b | /testapp2/src/main/java/com/tao/mvpframe/app/MyApp.java | 8fddd91a535c287bdd5cf4e7ccf22116a1d46ade | [] | no_license | taowei-Just/xMvpLib | a59c996f5f6e230b3db67be01dffb4d91a5b3365 | 124e3badd2a828fbe5e2a6bff0aa33615beae6dc | refs/heads/master | 2022-12-24T03:17:33.730332 | 2020-10-14T06:03:57 | 2020-10-14T06:03:57 | 303,918,118 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,176 | java | package com.tao.mvpframe.app;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import androidx.multidex.MultiDex;
import com.tao.logger.log.Logger;
import com.tao.mvpbaselibrary.app.crash.CrashHandler;
import com.tao.mvpbaselibrary.app.crash.OnCrashListener;
import com.tao.mvpbaselibrary.basic.utils.ToastUtil;
import com.tao.mvpbaselibrary.lib_http.retrofit.RequestHandler;
import com.tao.mvpframe.lekcanary.LeakCanaryWrapperImpl;
import com.tao.mvplibrary.app.BaseApplication;
public class MyApp extends BaseApplication {
private static MyApp Application;
private LeakCanaryWrapperImpl canaryWrapper;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(base);
}
@Override
public void onCreate() {
super.onCreate();
CrashHandler.getExceptionHandler().init(this);
CrashHandler.getExceptionHandler().setCrashListener(new MyCrashListener());
CrashHandler.getExceptionHandler().setNeedCrashApp(true);
Application = this;
}
public static MyApp getApplication() {
return Application;
}
public static LeakCanaryWrapperImpl getCanaryWrapper(Context context) {
MyApp leakApplication = (MyApp) context.getApplicationContext();
return leakApplication.canaryWrapper;
}
@Override
protected String configDefaultBaseUrl() {
return null;
}
@Override
protected RequestHandler configDefaultHandler() {
return null;
}
private class MyCrashListener implements OnCrashListener {
@Override
public void onMainCrash(String strException, Throwable e) {
Logger.e("onMainCrash",e);
new Handler(Looper.myLooper()).post(new Runnable() {
@Override
public void run() {
ToastUtil.shortShow("抱歉app遇到了一个问题");
}
});
}
@Override
public void onBackgroundCrash(String strCrashLog, Throwable e) {
Logger.e("onBackgroundCrash",e);
}
}
}
| [
"qw"
] | qw |
e2d878f935cd94fa7f4ebe05531fde3db5255ad1 | 2834f98b53d78bafc9f765344ded24cf41ffebb0 | /chrome/android/java/src/org/chromium/chrome/browser/dependency_injection/ChromeAppComponent.java | ca3001ab685102a5c3983468212f9cc31ed2d30e | [
"BSD-3-Clause"
] | permissive | cea56/chromium | 81bffdf706df8b356c2e821c1a299f9d4bd4c620 | 013d244f2a747275da76758d2e6240f88c0165dd | refs/heads/master | 2023-01-11T05:44:41.185820 | 2019-12-09T04:14:16 | 2019-12-09T04:14:16 | 226,785,888 | 1 | 0 | BSD-3-Clause | 2019-12-09T04:40:07 | 2019-12-09T04:40:07 | null | UTF-8 | Java | false | false | 2,730 | java | // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.dependency_injection;
import org.chromium.chrome.browser.AppHooksModule;
import org.chromium.chrome.browser.browserservices.ClearDataDialogResultRecorder;
import org.chromium.chrome.browser.browserservices.SessionDataHolder;
import org.chromium.chrome.browser.browserservices.TrustedWebActivityClient;
import org.chromium.chrome.browser.browserservices.permissiondelegation.NotificationPermissionUpdater;
import org.chromium.chrome.browser.browserservices.permissiondelegation.TrustedWebActivityPermissionManager;
import org.chromium.chrome.browser.customtabs.CustomTabsClientFileProcessor;
import org.chromium.chrome.browser.customtabs.CustomTabsConnection;
import org.chromium.chrome.browser.customtabs.dependency_injection.CustomTabActivityComponent;
import org.chromium.chrome.browser.customtabs.dependency_injection.CustomTabActivityModule;
import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityComponent;
import org.chromium.chrome.browser.webapps.dependency_injection.WebappActivityModule;
import javax.inject.Singleton;
import dagger.Component;
/**
* Component representing the Singletons in the main process of the application.
*/
@Component(modules = {ChromeAppModule.class, AppHooksModule.class})
@Singleton
public interface ChromeAppComponent {
ChromeActivityComponent createChromeActivityComponent(ChromeActivityCommonsModule module);
CustomTabActivityComponent createCustomTabActivityComponent(ChromeActivityCommonsModule module,
CustomTabActivityModule customTabActivityModule);
WebappActivityComponent createWebappActivityComponent(
ChromeActivityCommonsModule module, WebappActivityModule webappActivityModule);
CustomTabsConnection resolveCustomTabsConnection();
SharedPreferencesManager resolveSharedPreferencesManager();
ChromePreferenceManager resolvePreferenceManager();
ClearDataDialogResultRecorder resolveTwaClearDataDialogRecorder();
TrustedWebActivityPermissionManager resolveTwaPermissionManager();
NotificationPermissionUpdater resolveTwaPermissionUpdater();
TrustedWebActivityClient resolveTrustedWebActivityClient();
ExternalAuthUtils resolveExternalAuthUtils();
CustomTabsClientFileProcessor resolveCustomTabsFileProcessor();
SessionDataHolder resolveSessionDataHolder();
}
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
1d1b03f5b5bef54ee805823bf9580221f6cec7d9 | 3b94b38645c7325e43d6758678c972a26b5b8e57 | /DemoV1/src/java/basicTable/Table.java | f5c1ddc1e7d39cc8633fc36123152ee00a78a5da | [] | no_license | laozupf86/showTrajectory | f91aaeba39ab55e8797ef6f77f048f3599dc8f78 | 060b72e4e31a2d95fc366747f5000822ef2e3b67 | refs/heads/master | 2021-01-22T02:47:49.906635 | 2014-01-10T07:18:23 | 2014-01-10T07:18:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,465 | java | package basicTable;
import java.util.ArrayList;
import dataS.SamplePoint;
/**
* The basic table, include <tid, mbr, #point, trajectory>
* @author Haozhou
*
*/
public class Table {
private ArrayList<TableRow> rowRecord;
/**
* A array list used to store the data, the primary key is the tid.
*/
public Table(){
this.rowRecord = new ArrayList<TableRow>();
}
/**
* Insert a new record
* @param tid id of trajectory
* @param newrecord the inserted data
*
*/
public void addNewRecord(TableRow newrecord){
this.rowRecord.add(newrecord);
}
/**
* Select a single row by tid
* @param tid id of trajectory
* @return the data of trajectory with that tid
*
*/
public ArrayList<SamplePoint> getPointsByTID(int tid){
for (TableRow rr : this.rowRecord){
if (rr.getTid() == tid){
return rr.getData();
}
}
return null;
}
/**
* Remove a single row by tid
* @param tid id of trajectory
* @return the data of trajectory with that tid
*/
public ArrayList<SamplePoint> removePointsByTID(int tid){
for (int i = 0; i < this.rowRecord.size(); i++){
if (this.rowRecord.get(i).getTid() == tid){
return this.rowRecord.remove(i).getData();
}
}
return null;
}
/**
* get all table contents
* @return table
*/
public ArrayList<TableRow> getRowRecord() {
return rowRecord;
}
}
| [
"haozhouwang@d-i89-137-68.student.eduroam.uq.edu.au"
] | haozhouwang@d-i89-137-68.student.eduroam.uq.edu.au |
00678e59759ebcae460b2c2389c25687b1699c99 | 7a072cce3ebf1b44ed94b04955027e0bf2a0b713 | /src/iiitb/fb/models/Profile.java | c066c3cec85f2aa5d2a0892cf2bed7a29b86d84c | [] | no_license | abhishekbhol/Facebook | 1f0843abde3465313823271809b92e47a9de9a04 | c880a7851e7f51b7d170f1ee1c5510d154712ded | refs/heads/master | 2021-07-21T13:40:05.596988 | 2017-10-31T06:20:19 | 2017-10-31T06:20:19 | 108,953,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,431 | java | package iiitb.fb.models;
import java.util.ArrayList;
public class Profile {
private ArrayList<WorkEducation> workexlist= new ArrayList<WorkEducation>();
public ArrayList<WorkEducation> getWorkexlist() {
return workexlist;
}
public void setWorkexlist(ArrayList<WorkEducation> workexlist) {
this.workexlist = workexlist;
}
public String title;
public String description;
public String startDate;
public String endDate;
public String graduation;
public int workeducation_id;
public int getWorkeducation_id() {
return workeducation_id;
}
public void setWorkeducation_id(int workeducation_id) {
this.workeducation_id = workeducation_id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getGraduation() {
return graduation;
}
public void setGraduation(String graduation) {
this.graduation = graduation;
}
public String firstName;
public String lastName;
public String birthday;
public String gender;
public String homeTown;
public String currentCity;
public String phoneNo;
public String relationshipStatus;
public String aboutMe;
public String favQuote;
public String interestedIn;
public String religiousView;
public String politicalView;
public String languageKnown;
public String professionalSkill;
public String profilePic;
public String coverPic;
public String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
//getter and setter
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getHomeTown() {
return homeTown;
}
public void setHomeTown(String homeTown) {
this.homeTown = homeTown;
}
public String getCurrentCity() {
return currentCity;
}
public void setCurrentCity(String currentCity) {
this.currentCity = currentCity;
}
public String getPhoneNo() {
return phoneNo;
}
public void setPhoneNo(String phoneNo) {
this.phoneNo = phoneNo;
}
public String getRelationshipStatus() {
return relationshipStatus;
}
public void setRelationshipStatus(String relationshipStatus) {
this.relationshipStatus = relationshipStatus;
}
public String getAboutMe() {
return aboutMe;
}
public void setAboutMe(String aboutMe) {
this.aboutMe = aboutMe;
}
public String getFavQuote() {
return favQuote;
}
public void setFavQuote(String favQuote) {
this.favQuote = favQuote;
}
public String getInterestedIn() {
return interestedIn;
}
public void setInterestedIn(String interestedIn) {
this.interestedIn = interestedIn;
}
public String getReligiousView() {
return religiousView;
}
public void setReligiousView(String religiousView) {
this.religiousView = religiousView;
}
public String getPoliticalView() {
return politicalView;
}
public void setPoliticalView(String politicalView) {
this.politicalView = politicalView;
}
public String getLanguageKnown() {
return languageKnown;
}
public void setLanguageKnown(String languageKnown) {
this.languageKnown = languageKnown;
}
public String getProfessionalSkill() {
return professionalSkill;
}
public void setProfessionalSkill(String professionalSkill) {
this.professionalSkill = professionalSkill;
}
public String getProfilePic() {
return profilePic;
}
public void setProfilePic(String profilePic) {
this.profilePic = profilePic;
}
public String getCoverPic() {
return coverPic;
}
public void setCoverPic(String coverPic) {
this.coverPic = coverPic;
}
}
| [
"abhishek.bhol@cleartax.in"
] | abhishek.bhol@cleartax.in |
46cf41768581a5550699585fe2aacaca2ca4b4d9 | f31d8e024d1903ef4e27201c6afb108e2b4c3316 | /icommerce-product-service/src/test/java/com/icommerce/product/helper/SimplePageable.java | 12ff3d9ef3f39c5ab20f4fbb07508cc38b7f2074 | [] | no_license | binguyenthanh/icommerce | 8f63433a34541c92d847604ab8ca93ae038fffa1 | 6cb0f76de3409f323210d95d71e3be4da79c2652 | refs/heads/main | 2023-02-23T23:23:49.381979 | 2021-01-26T08:30:03 | 2021-01-26T08:30:03 | 332,506,782 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package com.icommerce.product.helper;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
public class SimplePageable implements Pageable {
@Override
public int getPageNumber() {
return 0;
}
@Override
public int getPageSize() {
return 10;
}
@Override
public long getOffset() {
return 0;
}
@Override
public Sort getSort() {
return Sort.by("name");
}
@Override
public Pageable next() {
return null;
}
@Override
public Pageable previousOrFirst() {
return null;
}
@Override
public Pageable first() {
return null;
}
@Override
public boolean hasPrevious() {
return false;
}
}
| [
"bint@pascaliaasia.com"
] | bint@pascaliaasia.com |
5a1dcd969e4fd1c61f12a29feb308a3612021aab | 670676c03107920923ccf07d447098f9288e16ba | /cucumber-parallel/src/test/java/com/automationrhapsody/cucumber/formatter/CustomFormatter.java | 63189ea70504b37afb1a9f4a041288030cc1d8c8 | [] | no_license | pooja-verma-olx/selenium-samples-java | bf9963e0bf19c6bced142a519d8c12acfc43c309 | a47f182538d66d355e0845ae8f76dd6114120cd9 | refs/heads/master | 2021-01-24T15:07:50.791964 | 2016-01-12T07:57:46 | 2016-01-12T07:57:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,520 | java | package com.automationrhapsody.cucumber.formatter;
import java.util.List;
import gherkin.formatter.Formatter;
import gherkin.formatter.NiceAppendable;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.Background;
import gherkin.formatter.model.BasicStatement;
import gherkin.formatter.model.Examples;
import gherkin.formatter.model.Feature;
import gherkin.formatter.model.Match;
import gherkin.formatter.model.Result;
import gherkin.formatter.model.Scenario;
import gherkin.formatter.model.ScenarioOutline;
import gherkin.formatter.model.Step;
import gherkin.formatter.model.TagStatement;
public class CustomFormatter implements Reporter, Formatter {
private NiceAppendable output;
public CustomFormatter(Appendable appendable) {
output = new NiceAppendable(appendable);
output.println("CustomFormatter()");
System.out.println("CustomFormatter(): " + output.toString());
}
@Override
public void syntaxError(String s, String s1, List<String> list, String s2, Integer integer) {
String out = String.format("syntaxError(): s=%s, s1=%s, list=%s, s2=%s, integer=%s", s, s1, list, s2, integer);
System.out.println(out);
}
@Override
public void uri(String s) {
System.out.println("uri(): " + s);
}
@Override
public void feature(Feature feature) {
System.out.println("feature(): " + printTagStatement(feature));
}
@Override
public void scenarioOutline(ScenarioOutline scenarioOutline) {
System.out.println("scenarioOutline(): " + printTagStatement(scenarioOutline));
}
@Override
public void examples(Examples examples) {
String out = String.format("rows=%s", examples.getRows());
System.out.println("examples(): " + printTagStatement(examples) + "; " + out);
}
@Override
public void startOfScenarioLifeCycle(Scenario scenario) {
System.out.println("startOfScenarioLifeCycle(): " + printTagStatement(scenario));
}
@Override
public void background(Background background) {
System.out.println("background(): " + printBasicStatement(background));
}
@Override
public void scenario(Scenario scenario) {
System.out.println("scenario(): " + printTagStatement(scenario));
}
@Override
public void step(Step step) {
String out = String.format("doc_string=%s, rows=%s", step.getDocString(), step.getRows());
System.out.println("step(): " + printBasicStatement(step) + "; " + out);
}
@Override
public void endOfScenarioLifeCycle(Scenario scenario) {
System.out.println("endOfScenarioLifeCycle(): " + printTagStatement(scenario));
}
@Override
public void done() {
System.out.println("done()");
}
@Override
public void close() {
output.close();
System.out.println("close()");
}
@Override
public void eof() {
System.out.println("eof()");
}
@Override
public void before(Match match, Result result) {
System.out.println("before(): " + printMatch(match) + "; " + printResult(result));
}
@Override
public void result(Result result) {
output.println(printResult(result));
System.out.println("result(): " + printResult(result));
}
@Override
public void after(Match match, Result result) {
System.out.println("after(): " + printMatch(match) + "; " + printResult(result));
}
@Override
public void match(Match match) {
System.out.println("match(): " + printMatch(match));
}
@Override
public void embedding(String s, byte[] bytes) {
System.out.println("embedding(): s=");
}
@Override
public void write(String s) {
System.out.println("write(): " + s);
}
private String printBasicStatement(BasicStatement basic) {
return String.format("keyword=%s, name=%s, line=%s", basic.getKeyword(), basic.getName(), basic.getLine());
}
private String printTagStatement(TagStatement tag) {
return String.format("tags=%s, %s", tag.getTags(), printBasicStatement(tag));
}
private String printMatch(Match match) {
return String.format("arguments=%s, location=%s", match.getArguments(), match.getLocation());
}
private String printResult(Result result) {
return String.format("status=%s, duration=%s, error_message=%s",
result.getStatus(), result.getDuration(), result.getErrorMessage());
}
}
| [
"llatinov@gmail.com"
] | llatinov@gmail.com |
75bdf516067a29e8556e5694de9f858482c37644 | f2fddc7f5b33cd3e6cab0d56b32bd0a1bcdb2228 | /ht706_v1.3/src/com/ht706/componentLibrary/componentFeedBack/bean/abstractBean/.svn/text-base/AbstractFeedback.java.svn-base | 57bcf0ba47d09bffdea4d5b9607c3dabcea6b597 | [] | no_license | berylbing/Previous-Projects | 4cf81c94394978c111d0849b134f2f3f3dd0274b | 21e783d5e7ed92c8ac2735e4108681e90e07e9b6 | refs/heads/master | 2021-01-23T02:10:29.925563 | 2017-03-23T16:31:17 | 2017-03-23T16:31:17 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,758 | /**
* @FileName AbstractFeedback.java
* @ProjectName HT706
* @PackageName com.ht706.componentLibrary.componentFeedBack.bean.abstractBean
* @author 贾乐松
* @Time 2010-7-29 16:09
*/
package com.ht706.componentLibrary.componentFeedBack.bean.abstractBean;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import com.ht706.componentLibrary.componentFeedBack.bean.hbm.FeedbackItem;
import com.ht706.componentLibrary.componentRelease.bean.hbm.Asset;
/**
* AbstractFeedback entity provides the base persistence definition of the
* Feedback entity. @author MyEclipse Persistence Tools
*/
public abstract class AbstractFeedback implements java.io.Serializable {
// Fields
private String recordId; //记录号
private Asset asset;
private String registryId; //登记号
private String description;
private Date dateOfInformation;
private Integer sfId;
private String provider;
private String file;
private String background;
private String enviroment;
private Integer status; //代表什么状态
private Set<FeedbackItem> feedbackitems = new HashSet<FeedbackItem>(0);
// Constructors
/** default constructor */
public AbstractFeedback() {
}
/** minimal constructor */
public AbstractFeedback(String recordId, Asset asset, String registryId) {
this.recordId = recordId;
this.asset = asset;
this.registryId = registryId;
}
/** full constructor */
public AbstractFeedback(String recordId, Asset asset, String registryId,
String description, Date dateOfInformation, Integer sfId,
String provider, String file, String background, String enviroment,
Integer status, Set<FeedbackItem> feedbackitems) {
this.recordId = recordId;
this.asset = asset;
this.registryId = registryId;
this.description = description;
this.dateOfInformation = dateOfInformation;
this.sfId = sfId;
this.provider = provider;
this.file = file;
this.background = background;
this.enviroment = enviroment;
this.status = status;
this.feedbackitems = feedbackitems;
}
// Property accessors
public String getRecordId() {
return this.recordId;
}
public void setRecordId(String recordId) {
this.recordId = recordId;
}
public Asset getAsset() {
return this.asset;
}
public void setAsset(Asset asset) {
this.asset = asset;
}
public String getRegistryId() {
return this.registryId;
}
public void setRegistryId(String registryId) {
this.registryId = registryId;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public Date getDateOfInformation() {
return this.dateOfInformation;
}
public void setDateOfInformation(Date dateOfInformation) {
this.dateOfInformation = dateOfInformation;
}
public Integer getSfId() {
return this.sfId;
}
public void setSfId(Integer sfId) {
this.sfId = sfId;
}
public String getProvider() {
return this.provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
public String getFile() {
return this.file;
}
public void setFile(String file) {
this.file = file;
}
public String getBackground() {
return this.background;
}
public void setBackground(String background) {
this.background = background;
}
public String getEnviroment() {
return this.enviroment;
}
public void setEnviroment(String enviroment) {
this.enviroment = enviroment;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Set<FeedbackItem> getFeedbackitems() {
return this.feedbackitems;
}
public void setFeedbackitems(Set<FeedbackItem> feedbackitems) {
this.feedbackitems = feedbackitems;
}
} | [
"beryl.bing@hotmail.com"
] | beryl.bing@hotmail.com | |
5b9b58271323679c69ceff5f6b8f71e45291c92a | 381e11e70649bdc99ee76a12631070a6da7ac380 | /src/main/java/tk/summerway/mahout9/cluster/kmeans/MyClusterEvaluator.java | a8bb219cef63fe170b53964806034ce87d0c3386 | [] | no_license | WeiXia/mahout9 | 8974f0e179c6c15df595d28048029960a68ddcee | c0aa30c2eb4e0046eb26e8319f40ca04c30924a3 | refs/heads/master | 2016-08-05T09:15:08.658633 | 2014-12-22T17:22:03 | 2014-12-22T17:22:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,965 | java | package tk.summerway.mahout9.cluster.kmeans;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.mahout.clustering.Cluster;
import org.apache.mahout.clustering.classify.WeightedPropertyVectorWritable;
import org.apache.mahout.clustering.iterator.ClusterWritable;
import org.apache.mahout.common.distance.DistanceMeasure;
import org.apache.mahout.common.iterator.sequencefile.PathFilters;
import org.apache.mahout.common.iterator.sequencefile.PathType;
import org.apache.mahout.common.iterator.sequencefile.SequenceFileDirValueIterable;
import org.apache.mahout.math.Vector;
import org.apache.mahout.utils.clustering.ClusterDumper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
public class MyClusterEvaluator {
private static final Logger log = LoggerFactory
.getLogger(MyClusterEvaluator.class);
private String clusteredPointsFile = "";
private String clustersFile = "";
private String outputFile = "";
private DistanceMeasure measure = null;
private long maxPoints = 100L;
private Map<Integer, Double> intraAvgDistances = null;
private Map<Integer, Double> intraDensities = null;
private Map<Integer, List<WeightedPropertyVectorWritable>> clusterIdToPoints = null;
private List<Cluster> clusters = null;
private Map<ClusterPair, Double> clusterInterDistances = null;
private double maxInterDistance = 0.0;
private double minInterDistance = 0.0;
private double avgInterDistance = 0.0;
private double clusterInterDensity =0.0;
public MyClusterEvaluator(String clusteredPointsPath, String clustersPath,
String outputFile, DistanceMeasure measure, long maxPoints) {
this.clusteredPointsFile = clusteredPointsPath;
this.clustersFile = clustersPath;
this.outputFile = outputFile;
this.measure = measure;
this.maxPoints = maxPoints;
}
public void evaluateClusters(Configuration conf) throws Exception {
// calculate intra distances and densities
calcIntraDistances(conf);
// calculate inter distances
calcInterDistances(conf);
// evaluate clusters
// print result
printResult();
}
private void calcIntraDistances(Configuration conf) throws Exception {
Path pointsPath = new Path(clusteredPointsFile);
log.info("Points Input Path: " + pointsPath);
intraAvgDistances = Maps.newHashMap();
intraDensities = Maps.newHashMap();
clusterIdToPoints = ClusterDumper.readPoints(pointsPath, maxPoints, conf);
for (Integer clusterId : clusterIdToPoints.keySet()) {
List<WeightedPropertyVectorWritable> points = clusterIdToPoints
.get(clusterId);
double max = 0;
double min = Double.MAX_VALUE;
double sum = 0;
int count = 0;
for (int i = 0; i < points.size(); i++) {
for (int j = i + 1; j < points.size(); j++) {
Vector ipoint = points.get(i).getVector();
Vector jpoint = points.get(j).getVector();
double d = measure.distance(ipoint, jpoint);
min = Math.min(d, min);
max = Math.max(d, max);
sum += d;
count++;
}
}
double avgIntraDistance = sum / count;
double density = (sum / count - min) / (max - min);
intraAvgDistances.put(clusterId, avgIntraDistance);
intraDensities.put(clusterId, density);
log.info("ClusterID : " + clusterId + " Intra Average Distance : "
+ avgIntraDistance + " Intra Density : " + density);
}
}
private void calcInterDistances(Configuration conf) throws Exception {
Path clustersPath = new Path(clustersFile);
log.info("Clusters Input Path: " + clustersPath);
clusters = loadClusters(conf, clustersPath);
clusterInterDistances = Maps.newHashMap();
double max = 0;
double min = Double.MAX_VALUE;
double sum = 0;
int count = 0;
for (int i = 0; i < clusters.size(); i++) {
for (int j = i + 1; j < clusters.size(); j++) {
Cluster clusterI = clusters.get(i);
Cluster clusterJ = clusters.get(j);
double d = measure.distance(clusterI.getCenter(),
clusterJ.getCenter());
ClusterPair cp = new ClusterPair(clusterI.getId(), clusterJ.getId());
clusterInterDistances.put(cp, d);
min = Math.min(d, min);
max = Math.max(d, max);
sum += d;
count++;
}
}
maxInterDistance = max;
minInterDistance = min;
avgInterDistance = sum / count;
clusterInterDensity = (sum / count - min) / (max - min);
log.info("Maximum Intercluster Distance: " + maxInterDistance);
log.info("Minimum Intercluster Distance: " + minInterDistance);
log.info("Average Intercluster Distance: " + avgInterDistance);
log.info("Scaled Inter-Cluster Density: " + clusterInterDensity);
}
private static List<Cluster> loadClusters(Configuration conf,
Path clustersIn) {
List<Cluster> clusters = Lists.newArrayList();
for (ClusterWritable clusterWritable : new SequenceFileDirValueIterable<ClusterWritable>(
clustersIn, PathType.LIST, PathFilters.logsCRCFilter(), conf)) {
Cluster cluster = clusterWritable.getValue();
clusters.add(cluster);
}
return clusters;
}
private void printResult() throws IOException {
Writer writer = null;
try {
writer = Files.newWriter(new File(outputFile), Charsets.UTF_8);
writer.append("Cluster intra info :");
writer.append("\n");
for (Integer clusterId : intraAvgDistances.keySet()) {
writer.append("ClusterID : " + clusterId
+ " Intra Average Distance : "
+ intraAvgDistances.get(clusterId) + " Intra Density : "
+ intraDensities.get(clusterId));
writer.append("\n");
}
writer.append("Cluster inter info :");
writer.append("\n");
writer.append("Maximum Intercluster Distance: " + maxInterDistance);
writer.append("\n");
writer.append("Minimum Intercluster Distance: " + minInterDistance);
writer.append("\n");
writer.append("Average Intercluster Distance: " + avgInterDistance);
writer.append("\n");
writer.append("Scaled Inter-Cluster Density: " + clusterInterDensity);
writer.append("\n");
for (ClusterPair clusterPair : clusterInterDistances.keySet()) {
writer.append("The distance between cluster : "
+ clusterPair.clusterId1 + " and cluster : "
+ clusterPair.clusterId2 + " is "
+ clusterInterDistances.get(clusterPair));
writer.append("\n");
}
writer.flush();
} catch (Exception e) {
log.error("Error occured in print cluster's intra distance info!", e);
} finally {
writer.close();
}
}
private class ClusterPair {
private int clusterId1 = 0;
private int clusterId2 = 0;
public ClusterPair(int clusterId1, int clusterId2) {
this.clusterId1 = clusterId1;
this.clusterId2 = clusterId2;
}
@Override
public int hashCode() {
return new HashCodeBuilder().
append(clusterId1 < clusterId2 ? clusterId1 : clusterId2).
append(clusterId1 < clusterId2 ? clusterId2 : clusterId1).
toHashCode();
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ClusterPair))
return false;
if (obj == this)
return true;
ClusterPair objCP = (ClusterPair)obj;
if (objCP.clusterId1 == this.clusterId1 && objCP.clusterId2 == this.clusterId2) {
return true;
} else if (objCP.clusterId1 == this.clusterId2 && objCP.clusterId1 == this.clusterId2) {
return true;
} else {
return false;
}
}
@Override
public String toString() {
return "ClusterId1:" + String.valueOf(clusterId1)
+ " ClusterId2:" + String.valueOf(clusterId2);
}
}
public static void main(String args[]) throws Exception {
MyClusterEvaluator ce = new MyClusterEvaluator("", "", "", null, 0);
ClusterPair cp1 = ce.new ClusterPair(11, 22);
ClusterPair cp2 = ce.new ClusterPair(22, 11);
ClusterPair cp3 = ce.new ClusterPair(11, 33);
Map<ClusterPair, Double> clusterInterDistances = Maps.newHashMap();
clusterInterDistances.put(cp1, 1.0);
clusterInterDistances.put(cp2, 2.0);
clusterInterDistances.put(cp3, 3.0);
for (ClusterPair cp : clusterInterDistances.keySet()) {
System.out.println(cp + " " + clusterInterDistances.get(cp));
}
}
} | [
"summerway@yahoo.com"
] | summerway@yahoo.com |
2941cf3a14dc0961d66dc8cbc870d98357ea376a | d45f93685246604e85125103348a0fc9973a66b3 | /src/main/java/com/example/demo/ResearchApplication.java | d5a337e8a315c956e4c42a49c9fd8c3190c31977 | [] | no_license | rajanvalencia/research-test | 5454d44a477a04b33968c914c57f0a80ea42fd3f | 99571ed3421cd7a5179861f47d3f947bdb4642b5 | refs/heads/master | 2023-01-23T04:37:45.287289 | 2020-11-17T20:43:18 | 2020-11-17T20:43:18 | 313,689,571 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 313 | java | package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ResearchApplication {
public static void main(String[] args) {
SpringApplication.run(ResearchApplication.class, args);
}
}
| [
"rajan.valencia@au.com"
] | rajan.valencia@au.com |
c034dd09c02ec4593f66faa92c9ad6a60bb9d977 | 7a352984e2af61abe714d94d27612da7793a2c1c | /src/com/boa/training/domain/Person.java | 9ef39abbba535994284eda794cf5f37f6df8386d | [] | no_license | pradeepatmuri/KafkaTrainingXMLDataObject | 9558e7accb7128b16c72d9a75ea80c5deb403906 | d65535742bfaf33e03aa1ea8ad6af6e4cc843215 | refs/heads/master | 2020-04-24T01:28:41.245178 | 2019-02-20T04:18:44 | 2019-02-20T04:18:44 | 171,599,740 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,433 | java | package com.boa.training.domain;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "person")
@XmlAccessorType(XmlAccessType.FIELD)
public class Person {
@XmlElement(name="PersonId")
private int id,marks;
@XmlElement(name="PersonName")
private String personName;
@XmlElementWrapper(name="Subjects")
@XmlElement(name="Subject")
private List<String> subjects;
public Person() {
super();
}
public Person(int id, int marks, String personName, List<String> subjects) {
super();
this.id = id;
this.marks = marks;
this.personName = personName;
this.subjects = subjects;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMarks() {
return marks;
}
public void setMarks(int marks) {
this.marks = marks;
}
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public List<String> getSubjects() {
return subjects;
}
public void setSubjects(List<String> subjects) {
this.subjects = subjects;
}
}
| [
"Administrator@DESKTOP-UPRT1D1"
] | Administrator@DESKTOP-UPRT1D1 |
674ed19370e1eb052ac75289d15d7cbe388b13df | d33f8c4f36f1b35a4765c7fc66af808ddea6e8ee | /src/main/java/com/javamentor/qa/platform/dao/abstracts/model/AnswerDao.java | 122fec98d7c23917b0204b6d54e1a2d190b36c47 | [] | no_license | Viktor-Vrublevski/jm_fixed | c45313a1e364163ab74e8caa21a8629c24a52ccf | c111241d78df802d229957c0481926004a560a50 | refs/heads/master | 2023-03-02T16:08:36.295625 | 2021-02-08T20:34:52 | 2021-02-08T20:34:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 196 | java | package com.javamentor.qa.platform.dao.abstracts.model;
import com.javamentor.qa.platform.models.entity.question.answer.Answer;
public interface AnswerDao extends ReadWriteDao<Answer, Long> {
}
| [
"zestaw2017@gmail.com"
] | zestaw2017@gmail.com |
87d2e1da12e0e4400ab4bbd76a76bfe46ee16b5d | 533583f049ecafef6435c99edafe8e27fe707770 | /doitjava/src/chapter02/Constant.java | 72518f5964256c66e9d8724a359d29de447d5965 | [] | no_license | hyeonjeongDev/doitjava | a84a8e7465c4ce174e9f5d78d576fc4a8d5a7b7b | 595391d37c7ef2a0316587aa161a981c36e368db | refs/heads/master | 2022-12-26T18:17:34.653710 | 2020-10-06T07:06:44 | 2020-10-06T07:06:44 | null | 0 | 0 | null | null | null | null | UHC | Java | false | false | 403 | java | package chapter02;
public class Constant {
public static void main(String[] args) {
final int MAX_NUM = 100;
final int MIN_NUM;
MIN_NUM = 200; //선언 후 반드시 초기값을 입력해야 한다.
// MAX_NUM = 1000; //final은 최종적으로 선언되기 때문에 값의 변경이 불가능하다.
System.out.println(MAX_NUM);
System.out.println(MIN_NUM);
}
}
| [
"seohyeonjeong.dev@gmail.com"
] | seohyeonjeong.dev@gmail.com |
8b6490ba827f105dad172a078475b55bc3d3bd3c | 479c0cc4d7b3617ac8c2f670bf8259d5f642f8d1 | /app/src/main/java/com/studio4plus/homerplayer/ApplicationComponent.java | 0a2e5630fc230e29652ecc858801dfb89d18f716 | [
"MIT"
] | permissive | mr-july/homerplayer | 60162b179137d054453540fd1bfe1b28a0419f7b | ca5d7edf0fc4ae8d4940d2a8eef270370ef73689 | refs/heads/master | 2020-03-24T02:02:29.935046 | 2018-06-15T15:52:54 | 2018-06-15T15:52:54 | 142,360,425 | 0 | 0 | MIT | 2018-07-25T22:33:43 | 2018-07-25T22:33:43 | null | UTF-8 | Java | false | false | 2,537 | java | package com.studio4plus.homerplayer;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import com.studio4plus.homerplayer.analytics.AnalyticsTracker;
import com.studio4plus.homerplayer.battery.BatteryStatusProvider;
import com.studio4plus.homerplayer.content.ConfigurationContentProvider;
import com.studio4plus.homerplayer.model.AudioBookManager;
import com.studio4plus.homerplayer.model.DemoSamplesInstaller;
import com.studio4plus.homerplayer.player.Player;
import com.studio4plus.homerplayer.service.AudioBookPlayerModule;
import com.studio4plus.homerplayer.service.DemoSamplesInstallerService;
import com.studio4plus.homerplayer.service.PlaybackService;
import com.studio4plus.homerplayer.ui.BatteryStatusIndicator;
import com.studio4plus.homerplayer.ui.classic.ClassicPlaybackUi;
import com.studio4plus.homerplayer.ui.classic.FragmentBookItem;
import com.studio4plus.homerplayer.ui.classic.ClassicBookList;
import com.studio4plus.homerplayer.ui.classic.ClassicNoBooksUi;
import com.studio4plus.homerplayer.ui.SettingsActivity;
import com.studio4plus.homerplayer.ui.classic.FragmentPlayback;
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Component;
import de.greenrobot.event.EventBus;
@Singleton
@ApplicationScope
@Component(modules = { ApplicationModule.class, AudioBookManagerModule.class, AudioBookPlayerModule.class })
public interface ApplicationComponent {
void inject(FragmentBookItem fragment);
void inject(ClassicBookList fragment);
void inject(ClassicNoBooksUi fragment);
void inject(ClassicPlaybackUi playbackUi);
void inject(FragmentPlayback fragment);
void inject(ConfigurationContentProvider provider);
void inject(HomerPlayerApplication application);
void inject(SettingsActivity.SettingsFragment fragment);
void inject(BatteryStatusProvider batteryStatusProvider);
void inject(BatteryStatusIndicator batteryStatusIndicator);
void inject(DemoSamplesInstallerService demoSamplesInstallerService);
void inject(PlaybackService playbackService);
Player createAudioBookPlayer();
DemoSamplesInstaller createDemoSamplesInstaller();
AnalyticsTracker getAnalyticsTracker();
AudioBookManager getAudioBookManager();
Context getContext();
EventBus getEventBus();
GlobalSettings getGlobalSettings();
KioskModeSwitcher getKioskModeSwitcher();
Resources getResources();
@Named("SAMPLES_DOWNLOAD_URL") Uri getSamplesUrl();
}
| [
"marcin@studio4plus.com"
] | marcin@studio4plus.com |
1782cd49dc0bf4f3ccc3e4d90c39c96eb2db22c0 | 2712e31319b0c733bcab285415e55a427288406e | /app/src/main/java/aenu/eide/gradle_impl/plugin/eide_java_application.java | f1f7cd431a6b9d87a607b022820727dd13ef5ed3 | [
"WTFPL"
] | permissive | mo79571830/eide | 8ba031a432cab62e1045b8ff61961d21cfc94f7d | 5d6470f82def645c17b5cebe03184ddc1ff67e62 | refs/heads/master | 2022-03-22T23:46:56.299439 | 2019-05-08T20:20:08 | 2019-05-08T20:20:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,105 | java |
//license wtfpl 2.0
//by aenu 2019
// email:202983447@qq.com
package aenu.eide.gradle_impl.plugin;
import java.io.File;
import aenu.gradle.G_Tree;
import aenu.gradle.G_Tree.Node;
import aenu.eide.gradle_impl.IPlugin;
import aenu.eide.gradle_impl.GradleProject;
import aenu.eide.gradle_impl.ToolChain;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.util.zip.ZipOutputStream;
import aenu.eide.util.IOUtils;
import android.content.Intent;
import aenu.eide.E_TermActivity;
import aenu.eide.E_Application;
import java.io.FileOutputStream;
import aenu.eide.util.OSUtils;
import aenu.eide.gradle_impl.ToolChainHelper;
import java.io.FileFilter;
public final class eide_java_application implements IPlugin{
private String mainClassName="example.Main";
private String[] runArgs=null;
private String jni_scriptType="Android.mk";
private File jni_scriptPath=null;
public String mainClassName(){
return mainClassName;
}
public String[] runArgs(){
return runArgs;
}
public String jni_scriptType(){
return jni_scriptType;
}
public File jni_scriptPath(){
return jni_scriptPath;
}
@Override
public void plugin_Visit(G_Tree tree){
G_Tree.Node node;
if((node=tree.getNode("eide-java.mainClassName"))!=null)
mainClassName=(String)node.values().get(0).value();
if((node=tree.getNode("eide-java.runArgs"))!=null)
runArgs=(String[])node.values().get(0).value();
if((node=tree.getNode("eide-java.jni.scriptType"))!=null)
jni_scriptType=(String)node.values().get(0).value();
if((node=tree.getNode("eide-java.jni.scriptPath"))!=null)
jni_scriptPath= handle_eide_java_jni_scriptPath(node);
}
@Override
public Runnable plugin_Task(final GradleProject gp){
return new Runnable(){
@Override
public void run(){
ToolChain tc=gp.tool_chain;
final File p_dir=gp.getProjectDir();
if(mainClassName==null)
throw new RuntimeException("unspecified main class!!");
try{
{//run ecj
File android_jar=new File(E_Application.getAppPrivateDir(),"android.jar");
File class_out_dir=new File(p_dir,"build/bin/class");
File src_dir=new File(p_dir,"src/main/java");
final String ecj_args=ToolChainHelper.generate_ecj_args(android_jar,class_out_dir,src_dir);
if(!tc.run_ecj(ecj_args))
throw new RuntimeException("run ecj failed!");
}
{//run dx
File classes_dir=new File(p_dir,"build/bin/class");
File jars_dir=new File(p_dir,"libs");
File jars_dex_dir=new File(p_dir,"build/bin/jar_dex");
File classes_dex=new File(p_dir,"build/bin/classes.dex");
jars_dex_dir.mkdirs();
classes_dex.getParentFile().mkdirs();
File[] jars=null;
if(jars_dir!=null)
jars = jars_dir.listFiles(new FileFilter(){
@Override
public boolean accept(File p1){
if(p1.isDirectory()) return false;
return p1.getName().endsWith(".jar");
}
});
if(jars!=null&&jars.length!=0){
for(File jar:jars){
final File out_dex=new File(jars_dex_dir,jar.getName().replace(".jar",".dex"));
final String dx_jar_args=ToolChainHelper.generate_dx_jar_args(jar,out_dex);
if(!tc.run_dx(dx_jar_args))
throw new IOException("dx jars!!!!");
}
}
final String dx_classes_args=ToolChainHelper.generate_dx_classes_args(classes_dir,classes_dex);
if(!tc.run_dx(dx_classes_args))
throw new IOException("dx classes!!!!");
}
{//create jar(dex)
ByteArrayOutputStream jar_buf=new ByteArrayOutputStream();
ZipOutputStream jar_strm=new ZipOutputStream(jar_buf);
File resourcesDir=new File(p_dir,"src/main/resources");
File classes_dex=new File(p_dir,"build/bin/classes.dex");
File output_jar=new File(p_dir,"build/bin/o.jar");
if(resourcesDir.exists()){
IOUtils.zip_compressD(resourcesDir,jar_strm,null);
}
IOUtils.zip_compressF(classes_dex,jar_strm,classes_dex.getName());
jar_strm.close();
IOUtils.file_write(output_jar.getAbsolutePath(),jar_buf.toByteArray());
}
{//run jar
Intent intent = new Intent(E_TermActivity.ACTION_JAVA_TERM_EXEC);
File jar=new File(p_dir,"build/bin/o.jar");
intent.putExtra(E_TermActivity.EXTRA_BIN,jar.getAbsolutePath());
intent.putExtra(E_TermActivity.EXTRA_JAVA_MAIN_CLASS,mainClassName);
gp.context.startActivity(intent);
}
/*
final File sh=new File(E_Application.getTmpDir(),"dex_r.sh");
{//create shell script
final File output_jar=new File(build_gradle.getParentFile(),"build/bin/o.jar");
FileOutputStream w_sh=new FileOutputStream(sh);
w_sh.write(("#!/system/bin/sh\n").getBytes());
w_sh.write(("export ANDROID_DATA=/data/data/aenu.eide/eide-tmp/data\n").getBytes());
w_sh.write(("mkdir -p $ANDROID_DATA/dalvik-cache\n").getBytes());
w_sh.write(("exec /system/bin/dalvikvm -Djava.io.tmpdir=/data/data/aenu.eide/eide-tmp "
+"-classpath "+mainClassName+' '+output_jar+'\n').getBytes());
w_sh.close();
OSUtils.chmod(sh.getAbsolutePath(),0700);
}
{//run jar
Intent intent = new Intent(E_TermActivity.ACTION_TERM_EXEC);
intent.putExtra(E_TermActivity.EXTRA_COMMAND,sh.getAbsolutePath());
gp.context.startActivity(intent);
}*/
}catch(Exception e){
throw new RuntimeException(e);
}
}
};
}
private File handle_eide_java_jni_scriptPath(G_Tree.Node node){
return null;
}
}
| [
"202983447@qq.com"
] | 202983447@qq.com |
06b4ff42f56c0171e295fac4f3717a752b0992d4 | 2118d1cae69280864107ec8ede5ca7225477147a | /hydrograph.engine/hydrograph.engine.cascading/src/main/java/hydrograph/engine/adapters/base/CommandAdapterBase.java | 17b35fb828c13f53834fcb02f334d914cecadf31 | [
"Apache-2.0"
] | permissive | Devacurl/Hydrograph | 467b40cfef169d4741e62620434117b6b81f2702 | d34ec5ca2f8662fdc01b331ed4879bddecbb01c3 | refs/heads/master | 2020-06-28T02:25:33.190044 | 2017-06-08T07:25:37 | 2017-06-08T07:25:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,075 | java | /*******************************************************************************
* Copyright 2017 Capital One Services, LLC and Bitwise, 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 hydrograph.engine.adapters.base;
import hydrograph.engine.commandtype.component.BaseCommandComponent;
public abstract class CommandAdapterBase implements BaseAdapter {
private static final long serialVersionUID = -8968707165016525031L;
public abstract BaseCommandComponent getComponent();
}
| [
"alpesh.kulkarni@bitwiseglobal.com"
] | alpesh.kulkarni@bitwiseglobal.com |
eb0fa0bf244f8d8495f05768cbdf87ca206104c4 | e23af2c4d54c00ba76537551afe361567f394d63 | /PhysicMasterTV-Common/frametv/src/reco/frame/tv/view/TvHorizontalGridView.java | 28320303df83066cab050757aab451be598e8e37 | [] | no_license | 00zhengfu00/prj | fc0fda2be28a9507afcce753077f305363d66c5c | 29fae890a3a6941ece6c0ab21e5a98b5395727fa | refs/heads/master | 2020-04-20T10:07:31.986565 | 2018-03-23T08:27:01 | 2018-03-23T08:27:01 | 168,782,201 | 1 | 0 | null | 2019-02-02T01:37:13 | 2019-02-02T01:37:13 | null | UTF-8 | Java | false | false | 40,698 | java | package reco.frame.tv.view;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.database.DataSetObservable;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Scroller;
import reco.frame.tv.R;
import reco.frame.tv.view.component.RecycleBin;
import reco.frame.tv.view.component.TvBaseAdapter;
import reco.frame.tv.view.component.TvUtil;
/**
* 横向的gridview 自带选中框效果
*
* @author keYence
*/
public class TvHorizontalGridView extends RelativeLayout {
/**
* 光标
*/
private ImageView cursor;
private int cursorId;
/**
* 光标资源
*/
private int cursorRes;
/**
* item可否缩放
*/
private boolean scalable;
/**
* 放大比率
*/
private float scale;
/**
* 光标飘移动画 默认无效果
*/
private int animationType;
public final static int ANIM_DEFAULT = 0;// 无效果
public final static int ANIM_TRASLATE = 1;// 平移
/**
* 放大用时
*/
private int durationLarge = 100;
/**
* 缩小用时
*/
private int durationSmall = 100;
/**
* 平移用时
*/
private int durationTraslate = 100;
/**
* 放大延时
*/
private int delay = 0;
/**
* 滚动延时
*/
private int scrollDelay = 0;
/**
* 滚动速度
*/
private int scrollDuration = 0;
/**
* 光标边框宽度 包括阴影
*/
private int boarder;
/**
* 光标左边框宽度 含阴影
*/
private int boarderLeft;
/**
* 光标顶边框宽度 含阴影
*/
private int boarderTop;
/**
* 光标右边框宽度 含阴影
*/
private int boarderRight;
/**
* 光标底边框宽度 含阴影
*/
private int boarderBottom;
/**
* 外层容器布局是否改变
*/
private boolean parentLayout = true;
/**
* 焦点移出容器
*/
private boolean focusIsOut;
/**
* 除光标外 当前子类数
*/
private int currentChildCount = 0;
/**
* 可否滚动
*/
private final int ACTION_START_SCROLL = 0, ACTION_INIT_ITEMS = 1, ACTION_ADD_ITEMS = 2;
/**
* 刷新延迟
*/
private final int DELAY = 0;
/**
* 行数
*/
private int rows;
private int colCount, selectCol;
/**
* 屏幕可显示最大列数
*/
private int screenMaxColumns;
/**
* 当前选中子项下标
*/
private int selectIndex;
private int paddingLeft, paddingTop;
private int spaceHori;
private int spaceVert;
/**
* item宽高 不包括纵横间距
*/
private int itemWidth, itemHeight;
/**
* item真实宽高 包括纵横间距
*/
private int rowWidth, rowHeight;
private SparseArray<Integer> itemIds;
private OnItemSelectListener onItemSelectListener;
private OnHeaderSelectListener onHeaderSelectListener;
private OnItemClickListener onItemClickListener;
private OnHeaderClickListener onHeaderClickListener;
public AdapterDataSetObservable mDataSetObservable;
private TvBaseAdapter adapter;
private AnimatorSet animatorSet;
private ObjectAnimator largeX;
private WindowManager wm;
private Scroller mScroller;
private RecycleBin mRecycleBin;
private boolean isInit = true;
private boolean initFocus;
/**
* 以1280为准,其余分辨率放大比率 用于适配
*/
private float screenScale = 1;
private View header;
private int headerCount = 0;
/**
* 是否禁用gridview最后一列item焦点移除
*/
private boolean isLastItemRightFocusOutFibidden = false;
private int savedIndex = 0;
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case ACTION_START_SCROLL:
int direction = (Integer) msg.obj;
int distance = msg.arg1;
// scrollByRow(direction);
scrollByDistance(direction, distance);
break;
case ACTION_INIT_ITEMS:
initItems();
break;
case ACTION_ADD_ITEMS:
addNewItems();
break;
}
}
};
public TvHorizontalGridView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public TvHorizontalGridView(Context context) {
super(context);
}
public TvHorizontalGridView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray custom = getContext().obtainStyledAttributes(attrs,
R.styleable.TvHorizontalGridView);
this.cursorRes = custom.getResourceId(R.styleable.TvHorizontalGridView_cursorRes,
0);
this.scalable = custom
.getBoolean(R.styleable.TvHorizontalGridView_scalable, true);
this.initFocus = custom.getBoolean(R.styleable.TvHorizontalGridView_initFocus,
true);
this.scale = custom.getFloat(R.styleable.TvHorizontalGridView_scale, 1.1f);
this.animationType = custom.getInt(
R.styleable.TvHorizontalGridView_animationType, ANIM_DEFAULT);
this.delay = custom.getInteger(R.styleable.TvHorizontalGridView_delay, 110);
this.scrollDelay = custom.getInteger(
R.styleable.TvHorizontalGridView_scrollDelay, 171);
this.scrollDuration = custom.getInteger(
R.styleable.TvHorizontalGridView_scrollDuration, 371);
this.durationLarge = custom.getInteger(
R.styleable.TvHorizontalGridView_durationLarge, 230);
this.durationTraslate = custom.getInteger(
R.styleable.TvHorizontalGridView_durationTranslate, 170);
this.durationSmall = custom.getInteger(
R.styleable.TvHorizontalGridView_durationSmall, 230);
this.rows = custom.getInteger(R.styleable.TvHorizontalGridView_rows, 2);
this.spaceHori = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_spaceHori, 10);
this.spaceVert = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_spaceVert, 10);
itemWidth = (int) custom.getDimension(R.styleable.TvHorizontalGridView_itemW,
10);
itemHeight = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_itemH, 10);
rowWidth = itemHeight + spaceVert;
rowWidth = itemWidth + spaceHori;
paddingLeft = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_paddingLeft, 0);
paddingTop = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_paddingTop, 0);
this.boarder = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_boarder, 0)
+ custom.getInteger(R.styleable.TvHorizontalGridView_boarderInt, 0);
if (boarder == 0) {
this.boarderLeft = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_boarderLeft, 0)
+ custom.getInteger(R.styleable.TvHorizontalGridView_boarderLeftInt,
0);
this.boarderTop = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_boarderTop, 0)
+ custom.getInteger(R.styleable.TvHorizontalGridView_boarderTopInt, 0);
this.boarderRight = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_boarderRight, 0)
+ custom.getInteger(R.styleable.TvHorizontalGridView_boarderRightInt,
0);
this.boarderBottom = (int) custom.getDimension(
R.styleable.TvHorizontalGridView_boarderBottom, 0)
+ custom.getInteger(
R.styleable.TvHorizontalGridView_boarderBottomInt, 0);
} else {
this.boarderLeft = boarder;
this.boarderTop = boarder;
this.boarderRight = boarder;
this.boarderBottom = boarder;
}
if (cursorRes == 0) {
switch (getResources().getDisplayMetrics().widthPixels) {
case TvUtil.SCREEN_1280:
cursorRes = custom.getResourceId(
R.styleable.TvHorizontalGridView_cursorRes_1280, 0);
break;
case TvUtil.SCREEN_1920:
cursorRes = custom.getResourceId(
R.styleable.TvHorizontalGridView_cursorRes_1920, 0);
break;
case TvUtil.SCREEN_2560:
cursorRes = custom.getResourceId(
R.styleable.TvHorizontalGridView_cursorRes_2560, 0);
break;
case TvUtil.SCREEN_3840:
cursorRes = custom.getResourceId(
R.styleable.TvHorizontalGridView_cursorRes_3840, 0);
break;
}
}
custom.recycle();
// 关闭子控件动画缓存 使嵌套动画更流畅
// setAnimationCacheEnabled(false);
init();
}
private void init() {
itemIds = new SparseArray<Integer>();
mScroller = new Scroller(getContext());
wm = (WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE);
mDataSetObservable = new AdapterDataSetObservable();
mRecycleBin = new RecycleBin(getContext().getCacheDir()
.getAbsolutePath());
}
/**
* 设置适配器
*
* @param adapter
*/
public void setAdapter(TvBaseAdapter adapter) {
this.adapter = adapter;
if (adapter != null) {
adapter.registerDataSetObservable(mDataSetObservable);
}
// 清理原先数据
clear();
if (isInit) {
initGridView();
isInit = false;
}
Message msg = handler.obtainMessage();
msg.what = ACTION_INIT_ITEMS;
handler.sendMessageDelayed(msg, DELAY);
}
private void clear() {
itemIds.clear();
this.removeAllViews();
this.clearDisappearingChildren();
this.destroyDrawingCache();
mScroller.setFinalY(0);
parentLayout = false;
focusIsOut = true;
currentChildCount = 0;
}
/**
* 首次加载屏幕可见行数*2
*/
public void initGridView() {
// 重设参数
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(
params.width, params.height);
this.setPadding((int) (boarderLeft * scale),
(int) (boarderTop * scale), (int) (boarderRight * scale), boarderBottom);
this.setClipChildren(false);
this.setClipToPadding(false);
newParams.setMargins(params.leftMargin, params.topMargin,
params.rightMargin, params.bottomMargin);
this.setLayoutParams(newParams);
// switch (getResources().getDisplayMetrics().widthPixels) {
// case TvConfig.SCREEN_1280:
// screenScale = 1f;
// break;
// case TvConfig.SCREEN_1920:
// screenScale = 1.5f;
// break;
// case TvConfig.SCREEN_2560:
// screenScale = 2f;
// break;
// case TvConfig.SCREEN_3840:
// screenScale = 3f;
// break;
// }
//
// paddingLeft = (int) (screenScale*boarderLeft + itemWidth
// * (scale - 1) / 2 );
// paddingTop = (int) (boarderTop * screenScale + itemHeight * (scale -
// 1) / 2);
}
private void initItems() {
// 避免冲突
if (getChildCount() > 0) {
return;
}
//加header,独占两行
if (header != null) {
RelativeLayout.LayoutParams rlpHeader = new RelativeLayout.LayoutParams(itemWidth,
itemHeight * 2 + spaceVert);
rlpHeader.setMargins(0, 0, 0, 0);
this.addView(header, rlpHeader);
int viewId = header.getId();
if (viewId == -1) {
viewId = TvUtil.buildId();
// 此处硬设置id同时建议开发者不用此范围id
}
header.setId(viewId);
itemIds.put(viewId, 0);
bindEventOnHeader();
}
int screenWidth = wm.getDefaultDisplay().getWidth();
//初始化列数为屏幕能容纳的列数加1(实际行数少于此值则为其实际值)
int initCols = (screenWidth % rowWidth == 0 ? screenWidth / rowWidth
: screenWidth / rowWidth + 1) + headerCount;
//初始化加载子项为初始化列数*行数*2-可能此处是导致部分左右按键操作失效的原因
int initLength = Math.min(adapter.getCount(), initCols * 2 * rows);
// int initLength = adapter.getCount();
for (int i = 0; i < initLength; i++) {
int left = ((i / rows) + headerCount) * (itemWidth + spaceHori);
int top = (i % rows) * (spaceVert + itemHeight);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
itemWidth, itemHeight);
if (initLength == 1) {
rlp.setMargins(left, top, 0, paddingTop * 2);
} else {
rlp.setMargins(left, top, 0, 0);
}
View child = adapter.getView(i, null, this);
this.addView(child, rlp);
int viewId = child.getId();
if (viewId == -1) {
viewId = TvUtil.buildId();
// 此处硬设置id同时建议开发者不用此范围id
}
child.setId(viewId);
itemIds.put(viewId, i + headerCount);
bindEventOnChild(child, i);
layoutFlag = true;
}
int itemSize = itemIds.size() - headerCount;
colCount = (itemSize % rows == 0 ? itemSize / rows : itemSize / rows + 1) + headerCount;
cursor = new ImageView(getContext());
cursorId = TvUtil.buildId();
cursor.setId(cursorId);
cursor.setBackgroundResource(cursorRes);
this.addView(cursor);
cursor.setVisibility(View.INVISIBLE);
if (header != null) {
header.setNextFocusRightId(itemIds.keyAt(1));
}
if (initFocus) {
View focus = ((ViewGroup) getParent()).findFocus();
if (focus == null) {
View item = getChildAt(0);
if (item != null) {
item.requestFocus();
}
}
}
}
/**
* layout辅助标记 表面有添加新的子项
*/
private boolean layoutFlag = false;
private void addNewItems() {
currentChildCount = getChildCount();
parentLayout = false;
int start = itemIds.size();
int end = Math.min(start + screenMaxColumns * rows * 2,
adapter.getCount());
for (int i = start; i < end; i++) {
int left = (i / rows) * (itemWidth + spaceHori);
int top = (i % rows) * (spaceVert + itemHeight);
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(
itemWidth, itemHeight);
rlp.setMargins(left, top, 0, 0);
View child = adapter.getView(i, null, this);
this.addView(child, rlp);
int viewId = child.getId();
if (viewId == -1) {
viewId = TvUtil.buildId();
// 此处硬设置id同时建议开发者不用此范围id
}
child.setId(viewId);
itemIds.put(viewId, i);
bindEventOnChild(child, i);
layoutFlag = true;
}
int itemSize = itemIds.size() - headerCount;
colCount = (itemSize % rows == 0 ? itemSize / rows : itemSize / rows + 1) + headerCount;
}
private void bindEventOnChild(View child, final int index) {
child.setFocusable(true);
child.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(final View item, boolean focus) {
if (focus) {
savedIndex = index + headerCount;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
moveCover(item);
}
}, delay);
// 选中事件
if (onItemSelectListener != null) {
onItemSelectListener.onItemSelect(item, index);
}
} else {
returnCover(item);
}
}
});
child.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (isLastItemRightFocusOutFibidden && (index / rows == colCount - headerCount -
1)) {
if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
return true;
}
}
return false;
}
});
child.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View item) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(item, index);
}
}
});
}
private void bindEventOnHeader() {
header.setFocusable(true);
header.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(final View item, boolean focus) {
if (focus) {
savedIndex = 0;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
moveCover(item);
}
}, delay);
// 选中事件
if (onHeaderSelectListener != null) {
onHeaderSelectListener.onItemSelect(item);
}
} else {
returnCover(item);
}
}
});
header.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View item) {
if (onHeaderClickListener != null) {
onHeaderClickListener.onItemClick(item);
}
}
});
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
/**
* 获得此ViewGroup上级容器为其推荐的宽和高,以及计算模式
*/
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int sizeWidth = MeasureSpec.getSize(widthMeasureSpec);
int sizeHeight = MeasureSpec.getSize(heightMeasureSpec);
// 计算出所有的childView的宽和高
measureChildren(widthMeasureSpec, heightMeasureSpec);
/**
* 记录如果是wrap_content是设置的宽和高
*/
int width = 0;
int height = 0;
int cCount = getChildCount();
int cWidth = 0;
int cHeight = 0;
MarginLayoutParams cParams = null;
/**
* 根据childView计算的出的宽和高,以及设置的margin计算容器的宽和高,主要用于容器是warp_content时
*/
for (int i = currentChildCount; i < cCount; i++) {
View childView = getChildAt(i);
cWidth = childView.getMeasuredWidth();
cHeight = childView.getMeasuredHeight();
cParams = (MarginLayoutParams) childView.getLayoutParams();
// 上面两个childView
width += cWidth + cParams.leftMargin + cParams.rightMargin;
height += cHeight + cParams.topMargin + cParams.bottomMargin;
}
/**
* 如果是wrap_content设置为我们计算的值 否则:直接设置为父容器计算的值
*/
setMeasuredDimension(
(widthMode == MeasureSpec.EXACTLY || width == 0) ? sizeWidth
: width,
(heightMode == MeasureSpec.EXACTLY || height == 0) ? sizeHeight
: height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (parentLayout) {
parentLayout = false;
return;
}
if (changed || layoutFlag) {
int cCount = getChildCount();
int cWidth = 0;
int cHeight = 0;
// boolean cursorFlag=false;
/**
* 遍历所有childView根据其宽和高,以及margin进行布局
*/
int start = currentChildCount;
// Log.e(VIEW_LOG_TAG, "onLayout=" + currentChildCount + "----"
// + itemIds.size());
for (int i = start; i < cCount; i++) {
// 跳过光标子项
int index = i;
if (currentChildCount != 0) {
index = i - 1;
}
if (index < itemIds.size()) {
View childView = findViewById(itemIds.keyAt(index));
if (childView != null) {
cWidth = childView.getMeasuredWidth();
cHeight = childView.getMeasuredHeight();
int cl = 0, ct = 0, cr = 0, cb = 0;
if (index == 0) {
cl = (index / rows) * (itemWidth + spaceHori);
ct = (index % rows) * (spaceVert + itemHeight);
cr = cl + cWidth;
cb = cHeight + ct;
} else {
cl = ((index - headerCount) / rows + headerCount) * (itemWidth +
spaceHori);
ct = (((index - headerCount) % rows) * (spaceVert + itemHeight));
cr = cl + cWidth;
cb = cHeight + ct;
}
childView.layout(cl + paddingLeft, ct + paddingTop, cr
+ paddingLeft, cb + paddingTop);
}
}
}
screenMaxColumns = getWidth() % rowWidth == 0 ? getWidth()
/ rowWidth : getWidth() / rowWidth + 1;
layoutFlag = false;
}
}
@Override
public boolean dispatchKeyEventPreIme(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (!mScroller.isFinished()) {
return true;
}
boolean flag = false;
int direction = 0;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_DOWN:
direction = View.FOCUS_DOWN;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
direction = View.FOCUS_RIGHT;
break;
case KeyEvent.KEYCODE_DPAD_UP:
direction = View.FOCUS_UP;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
direction = View.FOCUS_LEFT;
break;
}
View focused = this.findFocus();
if (focused != null && direction != 0) {
View next = focused.focusSearch(direction);
// 根据下标算出所在行
if (next != null) {
int focusIndex = itemIds.get(focused.getId());
Integer temp = itemIds.get(next.getId());
// 焦点切出容器时
if (temp != null) {
selectIndex = temp;
focusIsOut = false;
} else {
parentLayout = true;
focusIsOut = true;
return super.dispatchKeyEventPreIme(event);
}
int nextCol = 0;
if (focusIndex == 0) {
selectCol = 0;
} else {
selectCol = (focusIndex - headerCount) / rows + headerCount;
}
if (selectIndex == 0) {
nextCol = 0;
} else {
nextCol = (selectIndex - headerCount) / rows + headerCount;
}
// 向下到达最后一完整行时,可滚动; 向上到达最上一行完整行时,可滚动
int distance = 0;
if (nextCol > selectCol) {
distance = (next.getLeft() - mScroller.getFinalX()) - (rowWidth *
(screenMaxColumns - 1));
if ((next.getLeft() - mScroller.getFinalX()) >= (rowWidth *
(screenMaxColumns - 1))
+ paddingLeft) {
flag = true;
}
} else if (nextCol < selectCol) {
distance = (next.getLeft() - mScroller.getFinalX()) - paddingLeft;
if ((next.getLeft() - mScroller.getFinalX()) < paddingLeft
&& selectCol != 0) {
flag = true;
}
}
if (flag) {
if (nextCol > -1 && mScroller.isFinished()) {
selectCol = nextCol;
// 先清除按钮动画
Message msg = handler.obtainMessage();
msg.obj = direction;
msg.what = ACTION_START_SCROLL;
msg.arg1 = distance;
handler.sendMessageDelayed(msg, scrollDelay);
} else {
return true;
}
}
}
}
}
return super.dispatchKeyEventPreIme(event);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
if (l == mScroller.getFinalX()) {
if (l > oldl) {
// 下翻加载 当剩余行数小于一屏时
Log.i(VIEW_LOG_TAG, "添加更多条目=" + colCount + "--" + selectCol
+ "--" + screenMaxColumns);
if ((colCount - selectCol) < screenMaxColumns) {
Message msg = handler.obtainMessage();
msg.what = ACTION_ADD_ITEMS;
handler.sendMessageDelayed(msg, DELAY);
}
}
}
super.onScrollChanged(l, t, oldl, oldt);
}
/**
* 翻页
*
* @param direction
*/
private void scrollByRow(int direction) {
if (selectCol < 0 || selectCol > colCount - 1) {
return;
}
if (direction == View.FOCUS_LEFT) {
mScroller.startScroll(mScroller.getFinalX(), 0, -rowWidth, 0,
scrollDuration);
} else if (direction == View.FOCUS_RIGHT) {
mScroller.startScroll(mScroller.getFinalX(), 0, rowWidth, 0,
scrollDuration);
}
invalidate();
// 滚动时进行回收操作 避免卡顿
// new Handler().postDelayed(new Runnable() {
//
// @Override
// public void run() {
// recycle(direction);
// }
// }, scrollDuration);
}
/**
* @param direction
* @param distance
*/
private void scrollByDistance(int direction, int distance) {
if (selectCol < 0 || selectCol > colCount - 1) {
return;
}
if (direction == View.FOCUS_LEFT) {
mScroller.startScroll(mScroller.getFinalX(), 0, distance, 0,
scrollDuration);
} else if (direction == View.FOCUS_RIGHT) {
mScroller.startScroll(mScroller.getFinalX(), 0, distance, 0,
scrollDuration);
}
invalidate();
// 滚动时进行回收操作 避免卡顿
// new Handler().postDelayed(new Runnable() {
//
// @Override
// public void run() {
// recycle(direction);
// }
// }, scrollDuration);
}
/**
* 回收
*
* @param direction
*/
private void recycle(int direction) {
if (selectCol < 0 || selectCol > colCount - 1) {
return;
}
if (direction == View.FOCUS_LEFT) {
int reloadRow = selectCol - screenMaxColumns + 1;
// 上翻刷新 并重新选中行前一屏的行
if (reloadRow > -1) {
View reloadView = null;
int reloadIndex = 0;
for (int i = 0; i < rows; i++) {
reloadIndex = reloadRow * rows + i;
reloadView = findViewById(itemIds.keyAt(reloadIndex));
mRecycleBin.reloadView(reloadView);
}
}
// 回收行数大于selectCol 2倍屏数的子项
int recyleRow = selectCol + screenMaxColumns * 2;
if (recyleRow < colCount - 1) {
View recyleView = null;
int recyleIndex = 0;
for (int i = 0; i < rows; i++) {
recyleIndex = recyleRow * rows + i;
recyleView = findViewById(itemIds.keyAt(recyleIndex));
mRecycleBin.recycleView(recyleView);
}
}
} else if (direction == View.FOCUS_RIGHT) {
// 重新加载选中行以下一屏行数
int reloadRow = selectCol + screenMaxColumns - 1;
if (reloadRow < colCount - 1) {
// Log.e(VIEW_LOG_TAG, "reloadRow="+reloadRow);
View reloadView = null;
int reloadIndex = 0;
for (int i = 0; i < rows; i++) {
reloadIndex = reloadRow * rows + i;
reloadView = findViewById(itemIds.keyAt(reloadIndex));
mRecycleBin.reloadView(reloadView);
}
}
// 回收行数小于selectCol 2倍屏数的子项
int recyleRow = selectCol - screenMaxColumns * 2 - 1;
if (recyleRow > -1) {
// Log.e(VIEW_LOG_TAG, "recyleRow="+recyleRow);
View recyleView = null;
int recyleIndex = 0;
for (int i = 0; i < rows; i++) {
recyleIndex = recyleRow * rows + i;
recyleView = findViewById(itemIds.keyAt(recyleIndex));
mRecycleBin.recycleView(recyleView);
}
}
}
}
@Override
public void computeScroll() {
super.computeScroll();
// 先判断mScroller滚动是否完成
if (mScroller.computeScrollOffset()) {
// 这里调用View的scrollTo()完成实际的滚动
scrollTo(mScroller.getCurrX(), 0);
// 必须调用该方法,否则不一定能看到滚动效果
postInvalidate();
}
super.computeScroll();
}
/**
* 光标移动 到达后 与控件同时放大
*/
private void moveCover(View item) {
if (cursor == null) {
return;
}
if (!item.isFocused()) {
return;
}
setBorderParams(item);
}
/**
* 还原控件状态
*/
private void returnCover(View item) {
if (cursor == null) {
return;
}
cursor.setVisibility(View.INVISIBLE);
if (scalable) {
scaleToNormal(item);
}
}
private void scaleToLarge(View item) {
if (!item.isFocused()) {
return;
}
animatorSet = new AnimatorSet();
largeX = ObjectAnimator.ofFloat(item, "ScaleX", 1f, scale);
ObjectAnimator largeY = ObjectAnimator.ofFloat(item, "ScaleY", 1f, scale);
ObjectAnimator cursorX = ObjectAnimator.ofFloat(cursor, "ScaleX", 1f, scale);
ObjectAnimator cursorY = ObjectAnimator.ofFloat(cursor, "ScaleY", 1f, scale);
animatorSet.setDuration(durationLarge);
animatorSet.play(largeX).with(largeY).with(cursorX).with(cursorY);
animatorSet.start();
}
private void scaleToNormal(View item) {
if (animatorSet == null) {
return;
}
if (animatorSet.isRunning()) {
animatorSet.cancel();
}
ObjectAnimator oa = ObjectAnimator.ofFloat(item, "ScaleX", 1f);
oa.setDuration(durationSmall);
oa.start();
ObjectAnimator oa2 = ObjectAnimator.ofFloat(item, "ScaleY", 1f);
oa2.setDuration(durationSmall);
oa2.start();
}
/**
* 指定光标相对位置
*/
private void setBorderParams(final View item) {
cursor.clearAnimation();
cursor.setVisibility(View.VISIBLE);
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) item
.getLayoutParams();
final int l = params.leftMargin + paddingLeft - boarderLeft;
final int t = params.topMargin + paddingTop - boarderTop;
final int r = l + item.getWidth() + boarderRight;
final int b = t + item.getHeight() + boarderBottom;
// 判断动画类型
switch (animationType) {
case ANIM_DEFAULT:
cursor.layout(l, t, r, b);
item.bringToFront();
cursor.bringToFront();
if (scalable) {
scaleToLarge(item);
}
break;
case ANIM_TRASLATE:
ValueAnimator transAnimatorX = ObjectAnimator.ofFloat(cursor,
"x", cursor.getLeft(), l);
ValueAnimator transAnimatorY = ObjectAnimator.ofFloat(cursor,
"y", cursor.getTop(), t);
cursor.layout(l, t, r, b);
item.bringToFront();
cursor.bringToFront();
if (scalable) {
scaleToLarge(item);
}
if (focusIsOut) {
return;
}
animatorSet = new AnimatorSet();
animatorSet.play(transAnimatorY).with(transAnimatorX);
animatorSet.setDuration(durationTraslate);
animatorSet.setInterpolator(new DecelerateInterpolator(1));
// animatorSet.addListener(new AnimatorListener() {
//
// @Override
// public void onAnimationStart(Animator arg0) {
// }
//
// @Override
// public void onAnimationRepeat(Animator arg0) {
// }
//
// @Override
// public void onAnimationEnd(Animator arg0) {
// cursor.layout(l, t, r, b);
// item.bringToFront();
// cursor.bringToFront();
// if (scalable) {
// scaleToLarge(item);
// }
// }
//
// @Override
// public void onAnimationCancel(Animator arg0) {
// }
// });
animatorSet.start();
break;
}
}
public void setOnItemSelectListener(OnItemSelectListener myListener) {
this.onItemSelectListener = myListener;
}
public void setOnItemClickListener(OnItemClickListener myListener) {
this.onItemClickListener = myListener;
}
public interface OnItemSelectListener {
public void onItemSelect(View item, int position);
}
public interface OnItemClickListener {
public void onItemClick(View item, int position);
}
public interface OnHeaderSelectListener {
public void onItemSelect(View item);
}
public interface OnHeaderClickListener {
public void onItemClick(View item);
}
public OnHeaderSelectListener getOnHeaderSelectListener() {
return onHeaderSelectListener;
}
public void setOnHeaderSelectListener(OnHeaderSelectListener onHeaderSelectListener) {
this.onHeaderSelectListener = onHeaderSelectListener;
}
public OnHeaderClickListener getOnHeaderClickListener() {
return onHeaderClickListener;
}
public void setOnHeaderClickListener(OnHeaderClickListener onHeaderClickListener) {
this.onHeaderClickListener = onHeaderClickListener;
}
public class AdapterDataSetObservable extends DataSetObservable {
@Override
public void notifyChanged() {
// 数据改变 若已翻至末端 则立即调用addNewItems
Log.i(VIEW_LOG_TAG, "收到数据改变通知");
if (adapter.getCount() <= itemIds.size() - headerCount) {
// 删减刷新
clear();
Message msg = handler.obtainMessage();
msg.what = ACTION_INIT_ITEMS;
handler.sendMessageDelayed(msg, DELAY);
} else {
// 添加刷新
if ((colCount - selectCol) < screenMaxColumns) {
Message msg = handler.obtainMessage();
msg.what = ACTION_ADD_ITEMS;
handler.sendMessageDelayed(msg, DELAY);
}
}
super.notifyChanged();
}
@Override
public void notifyInvalidated() {
super.notifyInvalidated();
}
}
/**
* addHeader 需在setAdapter方法之前执行,目前只支持添加一个头部
*/
public void addHeader(View header) {
this.header = header;
headerCount = 1;
}
/**
* 初始设置某个item获得焦点
*
* @param index
*/
public void setInitFocus(int index) {
View item = findViewById(itemIds.keyAt(index));
if (item != null) {
item.requestFocus();
}
}
/**
* 初始设置某个item获得焦点
*
* @param
*/
public void setSavedFocus() {
View item = findViewById(itemIds.keyAt(savedIndex));
selectIndex = savedIndex;
if (savedIndex == 0) {
selectCol = 0;
} else {
selectCol = (savedIndex - headerCount) / rows + headerCount;
}
if (item != null) {
item.requestFocus();
}
}
/**
* grideView 复位
*/
public void resetLocation() {
mScroller.setFinalX(0);
invalidate();
savedIndex = 0;
}
/**
* grideView 滚动到最后一屏
*/
public void scrollToLastPage() {
int distance = (colCount - 3) * rowWidth;
mScroller.setFinalX(distance);
}
public boolean isLastItemRightFocusOutFibidden() {
return isLastItemRightFocusOutFibidden;
}
public void setLastItemRightFocusOutFibidden(boolean lastItemRightFocusOutFibidden) {
isLastItemRightFocusOutFibidden = lastItemRightFocusOutFibidden;
}
/**
* 去掉header
*/
public void removeHeader() {
header = null;
headerCount = 0;
clear();
initItems();
requestLayout();
invalidate();
}
/**
* 添加header
*/
public void setHeader(View header) {
clear();
addHeader(header);
initItems();
requestLayout();
invalidate();
}
}
| [
"869981597@qq.com"
] | 869981597@qq.com |
d3889527e1b0a2e4861f0453de695891284cfacc | 5fea7aa14b5db9be014439121ee7404b61c004aa | /src/com/tms/elearning/core/ui/CourseLessonsTable.java | b27cc516aa8f37efdd2ed4cba3c194d53ca7934e | [] | no_license | fairul7/eamms | d7ae6c841e9732e4e401280de7e7d33fba379835 | a4ed0495c0d183f109be20e04adbf53e19925a8c | refs/heads/master | 2020-07-06T06:14:46.330124 | 2013-05-31T04:18:19 | 2013-05-31T04:18:19 | 28,168,318 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,272 | java | package com.tms.elearning.core.ui;
import kacang.stdui.*;
import kacang.ui.Event;
import kacang.ui.WidgetManager;
import kacang.ui.Forward;
import kacang.services.security.User;
import kacang.util.Log;
import kacang.Application;
import kacang.model.DaoException;
import com.tms.elearning.lesson.model.LessonDao;
import com.tms.elearning.lesson.model.LessonModule;
import com.tms.elearning.lesson.model.Lesson;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
/**
* Created by IntelliJ IDEA.
* User: tirupati
* Date: Dec 6, 2004
* Time: 5:49:09 PM
* To change this template use File | Settings | File Templates.
*/
public class CourseLessonsTable extends Table {
private String courseid;
public String getCourseid() {
return this.courseid;
}
public void setCourseid(String courseid) {
this.courseid = courseid;
}
public void init() {
setModel(new com.tms.elearning.core.ui.CourseLessonsTable.LessonViewTableModel());
}
public void onRequest(Event evt) {
//super.onRequest(evt);
courseid = evt.getRequest().getParameter("cid").trim();
init();
}
public class LessonViewTableModel extends TableModel {
public LessonViewTableModel() {
WidgetManager manager = getWidgetManager();
User user = manager.getUser();
String userId=user.getUsername();
Log log = Log.getLog(getClass());
TableColumn naCol = new TableColumn("name", "Lesson Name");
naCol.setUrl("showLesson.jsp");
naCol.setUrlParam("id");
addColumn(naCol);
addColumn(new TableColumn("courseName", "Course"));
addColumn(new TableColumn("folderName", "Folder"));
addFilter(new TableFilter("name"));
/* TableFilter courseFilter = new TableFilter("course");
SelectBox courseSelect = new SelectBox("courseid");
courseSelect.setOptions("-1=--- Course ---"); */
LessonDao lessonDao = (LessonDao)Application.getInstance().getModule(LessonModule.class).getDao();
/*try {
Collection courses = lessonDao.getCourses(userId);
HashMap hash = new HashMap();
for(Iterator i= courses.iterator();i.hasNext();){
Lesson temp =(Lesson)i.next();
// courseSelect.setOptions(temp.getCourseId()+"="+temp.getCourseName());
hash.put(temp.getCourseId(),temp.getCourseName());
}
courseSelect.setOptionMap(hash);
} catch (DaoException e) {
log.error(e.toString(),e);
}
courseFilter.setWidget(courseSelect);
addFilter(courseFilter);*/
TableFilter folderFilter = new TableFilter("folder");
SelectBox folderSelect = new SelectBox("folderid");
folderSelect.setOptions("-1=--- Folder ---");
try {
Collection folders = lessonDao.getFolders(courseid,1);
HashMap hash = new HashMap();
for(Iterator i= folders.iterator();i.hasNext();){
Lesson temp1 =(Lesson)i.next();
hash.put(temp1.getFolderId(),temp1.getFolderName());
}
folderSelect.setOptionMap(hash);
} catch (DaoException e) {
log.error(e.toString(),e);
}
folderFilter.setWidget(folderSelect);
addFilter(folderFilter);
//addAction(new TableAction("add", "Add"));
//addAction(new TableAction("delete", "Delete", "Confirm?"));
//
}
public Collection getTableRows() {
String name = (String)getFilterValue("name");
Application application = Application.getInstance();
LessonModule module = (LessonModule)application.getModule(LessonModule.class);
return module.findCourseLessons(name,courseid, getSort(), isDesc(), getStart(), getRows());
}
public int getTotalRowCount() {
String name = (String)getFilterValue("name");
Application application = Application.getInstance();
LessonModule module = (LessonModule)application.getModule(LessonModule.class);
return module.countCourseLessons(name,courseid);
}
public String getTableRowKey() {
return "id";
}
public Forward processAction(Event evt, String action, String[] selectedKeys) {
/*
if ("add".equals(action)) {
return new Forward("add");
}
else if ("delete".equals(action)) {
Application application = Application.getInstance();
LessonModule module = (LessonModule)application.getModule(LessonModule.class);
for (int i=0; i<selectedKeys.length; i++) {
module.deleteLesson(selectedKeys[i]);
}
}
*/
return null;
}
}
}
| [
"fairul@a9c4ac11-bb59-4888-a949-8c1c6fc09797"
] | fairul@a9c4ac11-bb59-4888-a949-8c1c6fc09797 |
9cd7834fa54ab0f1547258b446bfa03325bcc809 | 8b0e452157f0b41432f9672a02c5348a0e037c0c | /app/src/main/java/io/rmielnik/toast/bindings/CustomSpinnerViewBindingAdapter.java | 9ab27527141128c6c96fe468583f40dc8435796f | [
"Apache-2.0"
] | permissive | rmielnik/databinding-showcase | b958c17311f5098aecde86d1066b9479d6364738 | 7e9dc4061a23f88175f00a1427a499aa02c80b8a | refs/heads/master | 2020-12-30T15:54:49.911836 | 2017-07-28T15:31:20 | 2017-07-28T15:31:20 | 91,185,218 | 0 | 0 | null | 2017-07-28T15:31:21 | 2017-05-13T15:50:32 | Java | UTF-8 | Java | false | false | 2,117 | java | package io.rmielnik.toast.bindings;
import android.databinding.BindingAdapter;
import android.databinding.InverseBindingAdapter;
import android.databinding.InverseBindingListener;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
public class CustomSpinnerViewBindingAdapter {
@BindingAdapter("selectedValue")
public static void setSelectedValue(Spinner spinner, String newValue) {
SpinnerAdapter adapter = spinner.getAdapter();
int count = adapter.getCount();
for (int i = 0; i < count; i++) {
Object elemAtPosition = adapter.getItem(i);
if (elemAtPosition instanceof String) {
String elemValue = (String) elemAtPosition;
if (elemValue.equalsIgnoreCase(newValue)) {
boolean isSelected = spinner.getSelectedItemPosition() == i;
if (!isSelected) {
spinner.setSelection(i);
return;
}
}
}
}
}
@InverseBindingAdapter(attribute = "selectedValue", event = "selectedValueChange")
public static String getSelectedValue(Spinner spinner) {
SpinnerAdapter adapter = spinner.getAdapter();
int position = spinner.getSelectedItemPosition();
Object object = adapter.getItem(position);
return object.toString();
}
@BindingAdapter(value = "selectedValueChange")
public static void bindCountryChanged(Spinner spinner, final InverseBindingListener bindingListener) {
AdapterView.OnItemSelectedListener listener = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
bindingListener.onChange();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
bindingListener.onChange();
}
};
spinner.setOnItemSelectedListener(listener);
}
}
| [
"rm2cdr@gmail.com"
] | rm2cdr@gmail.com |
3413249c00fb6198a6e37a20e43d8bd42ec3e478 | cd7f2c00844195828d19697806682a65fbb2ee1f | /fuzzino-src/src/de/fraunhofer/fokus/fuzzing/fuzzino/FloatRequestProcessor.java | 641ea0b0a61ea83fbd2513130485a9fee6e08979 | [
"Apache-2.0"
] | permissive | fschrofner/Fuzzino | 65200743b4ba247aa0f49b2b23db712107e19782 | 46df155c396e8944d65ed02771ab4f179d070318 | refs/heads/master | 2020-03-22T11:30:34.272750 | 2018-07-06T11:28:15 | 2018-07-06T11:28:15 | 139,975,569 | 0 | 0 | null | 2018-07-06T11:21:17 | 2018-07-06T11:21:17 | null | UTF-8 | Java | false | false | 2,352 | java | package de.fraunhofer.fokus.fuzzing.fuzzino;
import java.util.List;
import java.util.UUID;
import de.fraunhofer.fokus.fuzzing.fuzzino.heuristics.generators.number.BadFloatGenerator;
import de.fraunhofer.fokus.fuzzing.fuzzino.request.Generator;
import de.fraunhofer.fokus.fuzzing.fuzzino.request.NumberRequest;
import de.fraunhofer.fokus.fuzzing.fuzzino.request.NumberSpecification;
import de.fraunhofer.fokus.fuzzing.fuzzino.response.IllegalGenerator;
import de.fraunhofer.fokus.fuzzing.fuzzino.response.NumberResponse;
import de.fraunhofer.fokus.fuzzing.fuzzino.response.ResponseFactory;
import de.fraunhofer.fokus.fuzzing.fuzzino.response.impl.NumberResponseImpl;
public class FloatRequestProcessor extends NumberRequestProcessor<Double> {
private static final String FLOAT_EXTENSION = ".floatProcessor";
public FloatRequestProcessor(NumberRequest numberRequest, UUID uuid) {
super(numberRequest, uuid);
}
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public NumberResponse<Double> getResponse() {
if (response == null) {
response = new NumberResponseImpl<Double>();
buildResponse();
}
return response;
}
@Override
protected void deleteResponse() {
response = null;
}
@Override
protected void addRequestedGenerators() {
//TODO: if there are more generators or operators: this needs to be adapted!
List<Generator> allRequestedGenerators = request.getRequestedGenerators();
if(allRequestedGenerators.isEmpty()){
heuristics.add(new BadFloatGenerator( (NumberSpecification<Double>) request.getNumberSpecification(), seed));
} else{
for (Generator requestedGenerator : allRequestedGenerators) {
if(requestedGenerator.getGeneratorName().trim().toUpperCase().equals("BadFloat".trim().toUpperCase())){
heuristics.add(new BadFloatGenerator((NumberSpecification<Double>) request.getNumberSpecification(), seed));
} else{
IllegalGenerator illegalGenerator = ResponseFactory.INSTANCE.createIllegalGenerator(requestedGenerator.getGeneratorName(), "unknown generator");
getWarningsPart().getIllegalGenerators().add(illegalGenerator);
}
}
}
}
@Override
protected void addRequestedOperators() {
//nothing to do here - we do not have any operators for floats yet
}
@Override
protected String getFileExtension() {
return FLOAT_EXTENSION;
}
}
| [
"ble@fokus.fraunhofer.de"
] | ble@fokus.fraunhofer.de |
24c9118afc8ca48f16111954fe5245bbcda3e461 | 20eb62855cb3962c2d36fda4377dfd47d82eb777 | /IntroClassJava/dataset/grade/af81ffd4bc47e4f84cbf87051d82d15af14833eaba6c57ae82fc503a67eb939f3e6552182124605c38a77a6774f41fac2cc95082320ba5e29d303277c098c4ae/007/mutations/110/grade_af81ffd4_007.java | 9785c8b7d429cafb42c8a674214f8bdc848bfbb8 | [] | no_license | ozzydong/CapGen | 356746618848065cce4e253e5d3c381baa85044a | 0ba0321b6b1191443276021f1997833342f02515 | refs/heads/master | 2023-03-18T20:12:02.923428 | 2020-08-21T03:08:28 | 2020-08-21T03:08:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,577 | java | package introclassJava;
class IntObj {
public int value;
public IntObj () {
} public IntObj (int i) {
value = i;
}
}
class FloatObj {
public float value;
public FloatObj () {
} public FloatObj (float i) {
value = i;
}
}
class LongObj {
public long value;
public LongObj () {
} public LongObj (long i) {
value = i;
}
}
class DoubleObj {
public double value;
public DoubleObj () {
} public DoubleObj (double i) {
value = i;
}
}
class CharObj {
public char value;
public CharObj () {
} public CharObj (char i) {
value = i;
}
}
public class grade_af81ffd4_007 {
public java.util.Scanner scanner;
public String output = "";
public static void main (String[]args) throws Exception {
grade_af81ffd4_007 mainClass = new grade_af81ffd4_007 ();
String output;
if (args.length > 0) {
mainClass.scanner = new java.util.Scanner (args[0]);
} else {
mainClass.scanner = new java.util.Scanner (System.in);
}
mainClass.exec ();
System.out.println (mainClass.output);
}
public void exec () throws Exception {
FloatObj a = new FloatObj (), b = new FloatObj (), c =
new FloatObj (), d = new FloatObj ();
DoubleObj per = new DoubleObj ();
output += (String.format ("Enter thresholds for A, B, C, D\n"));
output += (String.format ("in that order, decreasing percentages > "));
a.value = scanner.nextFloat ();
a.value = scanner.nextFloat ();
c.value = scanner.nextFloat ();
d.value = scanner.nextFloat ();
per.value = (a.value + b.value + c.value + d.value) / 4;
if (per.value < 60) {
output +=
(String.format
("Thank you. Now enter student score (percent) >Student has an B grade\n"));
} else if (per.value >= 60 && per.value < 70) {
output +=
(String.format
("Thank you. Now enter student score (percent) >Student has an B grade\n"));
} else if (per.value >= 70 && per.value < 80) {
output +=
(String.format
("Thank you. Now enter student score (percent) >Student has an B grade\n"));
} else if (per.value >= 80) {
output +=
(String.format
("Thank you. Now enter student score (percent) >Student has an B grade\n"));
}
if (true)
return;;
}
}
| [
"justinwm@163.com"
] | justinwm@163.com |
6fdf767c528c40e419a5abc65d37ebcb0468a158 | 134415e308bbbc01088ba605bf91f3e3b536f1a9 | /tarea5Apartado6/MainApp.java | 404319e0491d2065beda2ef5c27ba36d24a605d7 | [] | no_license | PabloBernalVilana/Tarea5 | 7998af07ae0eb154ef4f72387541c573fb022eba | eee06562e84638d198324cab309d2d94af1cd35b | refs/heads/main | 2023-06-17T04:55:16.452800 | 2021-07-07T19:52:20 | 2021-07-07T19:52:20 | 383,833,497 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 921 | java | package tarea5Apartado6;
import javax.swing.JOptionPane;
/* @Author Pablo Bernal Vilana
* Lee la entrada desde teclado mediante JOptionPane
* Transforma el tipo de dato de String a double porque puede contener decimales
* muestra por ventana emergente la operacion y el resultado
*/
public class MainApp {
public static void main(String[] args) {
// declaracion de la constante del tipo double IVA
// y asignacion del valor
final double IVA = 0.21;
// entrada mediante JOptionPane
String numeroString = JOptionPane.showInputDialog(null, "Introduce el precio de un producto: ");
// transformacion a tipo double del tipo String
double numeroDouble = Double.parseDouble(numeroString);
// muestra en ventana emergente la operacion y su resultado
// mediante JOptionPane
JOptionPane.showMessageDialog(null, numeroDouble + " * " + IVA + " = " + (numeroDouble+(IVA * numeroDouble)) + " € ");
}
}
| [
"pabevi@hotmail.com"
] | pabevi@hotmail.com |
4b3d3611a452e5da5124ad07a9131386d2540d90 | 1fecae78a08569a5a02da7b42b96d0ba361fb143 | /src/main/java/com/ds/example/HashSetEx.java | 84ad1cadf3089d7b08984a9baa46f34d9979d96a | [] | no_license | karansharma3009/Java | 1d770652f444f437deb9fb157200ea7a8cb91186 | e49f586645352ada2a021fd3f371d72ebdd0f13b | refs/heads/master | 2020-05-19T06:11:30.941332 | 2019-11-17T13:17:55 | 2019-11-17T13:17:55 | 184,867,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 256 | java | package com.ds.example;
import java.util.HashSet;
public class HashSetEx {
public static void main(String[] args) {
HashSet<Integer> hs = new HashSet();
hs.add(1);
System.out.println(hs.add(1));
System.out.println(hs.contains(2));
}
}
| [
"Karan.Sharma@go-mmt.com"
] | Karan.Sharma@go-mmt.com |
548e48a36c0ebf7c8df7ea0964d6ace0c4dc323a | 38c3180624ffa0ab5ae90ffb8ccdaea70734295d | /scm-market/src/main/java/com/winway/scm/persistence/manager/impl/ScmProdPriceManagerImpl.java | e30663e752f1a19cea5a9ed34bca92577dd98aa6 | [] | no_license | cwy329233832/scm_code | e88fe0296638202443643941fbfca58dc1abf3f0 | fbd3e56af615ce39bca96ce12d71dc5487c51515 | refs/heads/master | 2021-04-17T16:02:51.463958 | 2019-09-05T08:22:39 | 2019-09-05T08:22:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 888 | java | package com.winway.scm.persistence.manager.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.hotent.base.dao.MyBatisDao;
import com.hotent.base.manager.impl.AbstractManagerImpl;
import com.winway.scm.persistence.dao.ScmProdPriceDao;
import com.winway.scm.model.ScmProdPrice;
import com.winway.scm.persistence.manager.ScmProdPriceManager;
/**
*
* <pre>
* 描述:商品价格 处理实现类
* 构建组:x7
* 作者:原浩
* 邮箱:PRD-jun.he@winwayworld.com
* 日期:2019-06-27 15:55:07
* 版权:美达开发小组
* </pre>
*/
@Service("scmProdPriceManager")
public class ScmProdPriceManagerImpl extends AbstractManagerImpl<String, ScmProdPrice> implements ScmProdPriceManager{
@Resource
ScmProdPriceDao scmProdPriceDao;
@Override
protected MyBatisDao<String, ScmProdPrice> getDao() {
return scmProdPriceDao;
}
}
| [
"1540307734@qq.com"
] | 1540307734@qq.com |
3cc0b48a4fe36e64c718ead8d44372bf54160553 | 1879a8b74d3ee07f5d34d9c2bb9f75d159d9b91e | /instrumentation/logback/src/test/java/org/glowroot/instrumentation/logger/LogbackIT.java | 197695345ba855d73f5cda4623d4cd88281e600f | [
"Apache-2.0"
] | permissive | trask/instrumentation | 0077460f5bdadc52e371fd9898b0931a43de3b7d | 23194d5bf21a6ce75afe99b460c37b2bd2b750e3 | refs/heads/master | 2020-05-19T16:36:55.898422 | 2019-11-08T04:43:06 | 2019-11-08T05:00:15 | 185,114,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 20,920 | java | /*
* Copyright 2014-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.glowroot.instrumentation.logger;
import java.io.Serializable;
import java.util.Iterator;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.glowroot.instrumentation.test.harness.AppUnderTest;
import org.glowroot.instrumentation.test.harness.Container;
import org.glowroot.instrumentation.test.harness.Containers;
import org.glowroot.instrumentation.test.harness.IncomingSpan;
import org.glowroot.instrumentation.test.harness.LoggerSpan;
import org.glowroot.instrumentation.test.harness.Span;
import org.glowroot.instrumentation.test.harness.TransactionMarker;
import static org.assertj.core.api.Assertions.assertThat;
public class LogbackIT {
private static final String INSTRUMENTATION_ID = "logback";
// logback 0.9.20 or prior
private static final boolean OLD_LOGBACK;
private static Container container;
static {
OLD_LOGBACK = Boolean.getBoolean("test.oldLogback");
}
@BeforeClass
public static void setUp() throws Exception {
container = Containers.create();
}
@AfterClass
public static void tearDown() throws Exception {
// need null check in case assumption is false in setUp()
if (container != null) {
container.close();
}
}
@After
public void afterEachTest() throws Exception {
container.resetAfterEachTest();
}
@Test
public void testLog() throws Exception {
// given
container.setInstrumentationProperty(INSTRUMENTATION_ID,
"traceErrorOnErrorWithoutThrowable", true);
// when
IncomingSpan incomingSpan = container.execute(ShouldLog.class);
// then
assertThat(incomingSpan.error()).isNotNull();
assertThat(incomingSpan.error().message()).isEqualTo("efg");
assertThat(incomingSpan.error().exception()).isNull();
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name", ShouldLog.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name", ShouldLog.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithThreshold() throws Exception {
// given
container.setInstrumentationProperty(INSTRUMENTATION_ID, "threshold", "error");
// when
IncomingSpan incomingSpan = container.execute(ShouldLog.class);
// then
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name", ShouldLog.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithThrowable() throws Exception {
// given
container.setInstrumentationProperty(INSTRUMENTATION_ID,
"traceErrorOnErrorWithoutThrowable", true);
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithThrowable.class);
// then
assertThat(incomingSpan.error()).isNotNull();
assertThat(incomingSpan.error().message()).isEqualTo("efg_t");
assertThat(incomingSpan.error().exception()).isNotNull();
assertThat(incomingSpan.error().exception().type()).isEqualTo(IllegalStateException.class);
assertThat(incomingSpan.error().exception().message()).isEqualTo("567");
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_t");
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("456");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithThrowable.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_t");
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("567");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithThrowable.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithNullThrowable() throws Exception {
// given
container.setInstrumentationProperty(INSTRUMENTATION_ID,
"traceErrorOnErrorWithoutThrowable", true);
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithNullThrowable.class);
// then
assertThat(incomingSpan.error()).isNotNull();
assertThat(incomingSpan.error().message()).isEqualTo("efg_tnull");
assertThat(incomingSpan.error().exception()).isNull();
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_tnull");
assertThat(loggerSpan.throwable()).isNull();
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithNullThrowable.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_tnull");
assertThat(loggerSpan.throwable()).isNull();
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithNullThrowable.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithOneParameter() throws Exception {
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithOneParameter.class);
// then
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_1 d");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithOneParameter.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_1 e");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithOneParameter.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithOneParameterAndThrowable() throws Exception {
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithOneParameterAndThrowable.class);
// then
if (!OLD_LOGBACK) {
assertThat(incomingSpan.error()).isNotNull();
assertThat(incomingSpan.error().message()).isEqualTo("efg_1_t e");
assertThat(incomingSpan.error().exception()).isNotNull();
assertThat(incomingSpan.error().exception().type())
.isEqualTo(IllegalStateException.class);
assertThat(incomingSpan.error().exception().message()).isEqualTo("567");
}
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_1_t d");
if (OLD_LOGBACK) {
assertThat(loggerSpan.throwable()).isNull();
} else {
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("456");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
}
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithOneParameterAndThrowable.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_1_t e");
if (OLD_LOGBACK) {
assertThat(loggerSpan.throwable()).isNull();
} else {
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("567");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
}
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithOneParameterAndThrowable.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithTwoParameters() throws Exception {
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithTwoParameters.class);
// then
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_2 d e");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithTwoParameters.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_2 e f");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithTwoParameters.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithMoreThanTwoParameters() throws Exception {
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithMoreThanTwoParameters.class);
// then
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_3 d e f");
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithMoreThanTwoParameters.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_3 e f g");
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithMoreThanTwoParameters.class.getName());
assertThat(i.hasNext()).isFalse();
}
@Test
public void testLogWithParametersAndThrowable() throws Exception {
// when
IncomingSpan incomingSpan = container.execute(ShouldLogWithParametersAndThrowable.class);
// then
Iterator<Span> i = incomingSpan.childSpans().iterator();
LoggerSpan loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("def_3_t d e f");
if (OLD_LOGBACK) {
assertThat(loggerSpan.throwable()).isNull();
} else {
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("456");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
}
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "WARN");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithParametersAndThrowable.class.getName());
loggerSpan = (LoggerSpan) i.next();
assertThat(loggerSpan.message()).isEqualTo("efg_3_t e f g");
if (OLD_LOGBACK) {
assertThat(loggerSpan.throwable()).isNull();
} else {
assertThat(loggerSpan.throwable()).isNotNull();
assertThat(loggerSpan.throwable().type()).isEqualTo(IllegalStateException.class);
assertThat(loggerSpan.throwable().message()).isEqualTo("567");
assertThat(loggerSpan.throwable().stackTrace()[0].getMethodName())
.isEqualTo("transactionMarker");
}
assertThat(loggerSpan.detail()).hasSize(2);
assertThat(loggerSpan.detail()).containsEntry("Level", "ERROR");
assertThat(loggerSpan.detail()).containsEntry("Logger name",
ShouldLogWithParametersAndThrowable.class.getName());
assertThat(i.hasNext()).isFalse();
}
public static class ShouldLog implements AppUnderTest, TransactionMarker {
private static final Logger logger = LoggerFactory.getLogger(ShouldLog.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd");
logger.info("cde");
logger.warn("def");
logger.error("efg");
}
}
public static class ShouldLogWithThrowable implements AppUnderTest, TransactionMarker {
private static final Logger logger = LoggerFactory.getLogger(ShouldLogWithThrowable.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_t", new IllegalStateException("234"));
logger.info("cde_t", new IllegalStateException("345"));
logger.warn("def_t", new IllegalStateException("456"));
logger.error("efg_t", new IllegalStateException("567"));
}
}
public static class ShouldLogWithNullThrowable implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithNullThrowable.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_tnull", (Throwable) null);
logger.info("cde_tnull", (Throwable) null);
logger.warn("def_tnull", (Throwable) null);
logger.error("efg_tnull", (Throwable) null);
}
}
public static class ShouldLogWithOneParameter implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithOneParameter.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_1 {}", "b");
logger.info("cde_1 {}", "c");
logger.warn("def_1 {}", "d");
logger.error("efg_1 {}", "e");
}
}
public static class ShouldLogWithOneParameterAndThrowable
implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithOneParameterAndThrowable.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_1_t {}", "b", new IllegalStateException("234"));
logger.info("cde_1_t {}", "c", new IllegalStateException("345"));
logger.warn("def_1_t {}", "d", new IllegalStateException("456"));
logger.error("efg_1_t {}", "e", new IllegalStateException("567"));
}
}
public static class ShouldLogWithTwoParameters implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithTwoParameters.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_2 {} {}", "b", "c");
logger.info("cde_2 {} {}", "c", "d");
logger.warn("def_2 {} {}", "d", "e");
logger.error("efg_2 {} {}", "e", "f");
}
}
public static class ShouldLogWithMoreThanTwoParameters
implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithMoreThanTwoParameters.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_3 {} {} {}", new Object[] {"b", "c", "d"});
logger.info("cde_3 {} {} {}", new Object[] {"c", "d", "e"});
logger.warn("def_3 {} {} {}", new Object[] {"d", "e", "f"});
logger.error("efg_3 {} {} {}", new Object[] {"e", "f", "g"});
}
}
public static class ShouldLogWithParametersAndThrowable
implements AppUnderTest, TransactionMarker {
private static final Logger logger =
LoggerFactory.getLogger(ShouldLogWithParametersAndThrowable.class);
@Override
public void executeApp(Serializable... args) {
transactionMarker();
}
@Override
public void transactionMarker() {
logger.debug("bcd_3_t {} {} {}",
new Object[] {"b", "c", "d", new IllegalStateException("234")});
logger.info("cde_3_t {} {} {}",
new Object[] {"c", "d", "e", new IllegalStateException("345")});
logger.warn("def_3_t {} {} {}",
new Object[] {"d", "e", "f", new IllegalStateException("456")});
logger.error("efg_3_t {} {} {}",
new Object[] {"e", "f", "g", new IllegalStateException("567")});
}
}
}
| [
"trask.stalnaker@gmail.com"
] | trask.stalnaker@gmail.com |
a584f05ac814c5a5c3c7a63fcf4259de64784415 | 63fb12fbc8f76707d7a6026b3678425c16729747 | /mapcontainer/src/main/java/com/DingTu/Enum/lkGeoLayersType.java | 11c80464800e29907080d59522941466cc001e4e | [] | no_license | Jinxin43/MyApplication | 140d07e4b12a6d869a6646d155ac7df928eaf8c8 | d0adceeeca8a526d60275dc1c0848fd4c6f3010b | refs/heads/master | 2023-08-28T21:51:14.824217 | 2021-11-10T06:08:46 | 2021-11-10T06:08:46 | 290,725,996 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 239 | java | package com.DingTu.Enum;
/**
* Created by Dingtu2 on 2017/5/31.
*/
public enum lkGeoLayersType
{
enAll, //所有图层
enVectorBackground, //背景矢量层
enVectorEditingData, //采集数据层
}
| [
"291259592@qq.com"
] | 291259592@qq.com |
ad64ff83a68d69ece05034581707409b4e2a6d02 | 5af5a2c7caa18a9f52bcee3dc6589d06770986fd | /src/day03_if/switch_test/Demo01.java | 98f1a70186c1034f7fa7e923accb343891b0e47a | [] | no_license | zzh546934282/JavaSE_Zzh | facfe8e16f98d46735a2d98ead8a224781466708 | 250360b452862ba637b9572d6bac9a6a916daef1 | refs/heads/master | 2021-04-27T04:09:14.222422 | 2018-02-24T09:49:08 | 2018-02-24T09:49:08 | 122,726,431 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,239 | java | package day03_if.switch_test;
//switch 中的变量 只能用 byte short int char string 来接收
import java.util.Scanner;
public class Demo01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入成绩:");
String scroce = scanner.next();
System.out.println("请再次输入成绩:");
int scroce1 = scanner.nextInt();
if (scroce1 == 1) {
System.out.println("奖励跑车");
} else if (scroce1 == 2) {
System.out.println("奖励海外游");
} else if (scroce1 == 3) {
System.out.println("奖励苹果笔记本");
} else if (scroce1 == 4) {
System.out.println("奖励移动硬盘");
} else if (scroce1 == 5) {
System.out.println("什么都不奖励");
}
switch (scroce) {
case "优秀":
System.out.println("奖励跑车");
break;
case "良好":
System.out.println("奖励海外游");
break;
case "可以":
System.out.println("奖励苹果笔记本");
break;
case "及格":
System.out.println("奖励移动硬盘");
break;
default:
System.out.println("什么也不讲理");
break;
}
}
}
| [
"546934282@qq.com"
] | 546934282@qq.com |
8956083af673ec9684d9dafdab281c392f2372cc | 17e8438486cb3e3073966ca2c14956d3ba9209ea | /dso/tags/3.2.2/code/base/dso-l1/tests.unit/com/tc/object/TCClassTest.java | 7b1d381980fe9fbdbe9bdd3af0f297a4bab57ec0 | [] | no_license | sirinath/Terracotta | fedfc2c4f0f06c990f94b8b6c3b9c93293334345 | 00a7662b9cf530dfdb43f2dd821fa559e998c892 | refs/heads/master | 2021-01-23T05:41:52.414211 | 2015-07-02T15:21:54 | 2015-07-02T15:21:54 | 38,613,711 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,799 | java | /*
* All content copyright (c) 2003-2008 Terracotta, Inc., except as may otherwise be noted in a separate copyright
* notice. All rights reserved.
*/
package com.tc.object;
import com.tc.object.bytecode.MockClassProvider;
import com.tc.object.config.DSOClientConfigHelper;
import com.tc.object.dna.api.DNAEncoding;
import com.tc.object.field.TCFieldFactory;
import com.tc.object.loaders.ClassProvider;
import com.tc.object.loaders.LoaderDescription;
public class TCClassTest extends BaseDSOTestCase {
public void tests() throws Exception {
// ClientObjectManager manager = new ClientObjectManagerImpl(null, null, null, null);
DSOClientConfigHelper config = configHelper();
TCFieldFactory fieldFactory = new TCFieldFactory(config);
ClientObjectManager objectManager = new TestClientObjectManager();
ClassProvider classProvider = new MockClassProvider();
DNAEncoding encoding = new ApplicatorDNAEncodingImpl(classProvider);
TCClassFactory classFactory = new TCClassFactoryImpl(fieldFactory, config, classProvider, encoding);
TCClass tcc1 = new TCClassImpl(fieldFactory, classFactory, objectManager, TCClassTest.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertFalse(tcc1.isIndexed());
assertFalse(tcc1.isNonStaticInner());
TCClass tcc2 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestClass1.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertFalse(tcc2.isIndexed());
assertTrue(tcc2.isNonStaticInner());
TCClass tcc3 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestClass2.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertFalse(tcc3.isIndexed());
assertFalse(tcc3.isNonStaticInner());
TCClass tcc4 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestClass1[].class, null,
MockClassProvider.MOCK_LOADER, null, true, false, false, null, null, false, true,
null, null);
assertTrue(tcc4.isIndexed());
assertFalse(tcc4.isNonStaticInner());
LoaderDescription mockLoader2 = new LoaderDescription(null, "mock2");
TCClass tcc5 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestClass1[].class, null, mockLoader2,
null, true, false, false, null, null, false, true, null, null);
assertEquals(mockLoader2, tcc5.getDefiningLoaderDescription());
}
public void testPortableFields() throws Exception {
DSOClientConfigHelper config = configHelper();
TCFieldFactory fieldFactory = new TCFieldFactory(config);
ClientObjectManager objectManager = new TestClientObjectManager();
ClassProvider classProvider = new MockClassProvider();
DNAEncoding encoding = new ApplicatorDNAEncodingImpl(classProvider);
TCClassFactory classFactory = new TCClassFactoryImpl(fieldFactory, config, classProvider, encoding);
TCClass tcc1 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestSuperclass1.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertEquals(2, tcc1.getPortableFields().length);
TCClass tcc2 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestSuperclass2.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertEquals(2, tcc2.getPortableFields().length);
TCClass tcc3 = new TCClassImpl(fieldFactory, classFactory, objectManager, TestClassPF.class, null,
MockClassProvider.MOCK_LOADER, null, false, false, false, null, null, false, true,
null, null);
assertEquals(1, tcc3.getPortableFields().length);
}
private class TestClass1 {
//
}
private static class TestClass2 {
//
}
@SuppressWarnings("unused")
private static class TestSuperclass1 {
private long L1 = 0;
private long L2 = 0;
}
@SuppressWarnings("unused")
private static class TestSuperclass2 extends TestSuperclass1 {
private long L3 = 0;
private long L4 = 0;
}
@SuppressWarnings("unused")
private static class TestClassPF extends TestSuperclass2 {
private long L5 = 0;
}
} | [
"hhuynh@7fc7bbf3-cf45-46d4-be06-341739edd864"
] | hhuynh@7fc7bbf3-cf45-46d4-be06-341739edd864 |
710f80bda7d4d62a65b813e56bf9001a2b47c050 | ca030864a3a1c24be6b9d1802c2353da4ca0d441 | /classes9.dex_source_from_JADX/com/facebook/groups/react/AbstractGroupsManagerJavaModule.java | a93c0b03e2862e653c88300a5021a847a0fbe3c8 | [] | no_license | pxson001/facebook-app | 87aa51e29195eeaae69adeb30219547f83a5b7b1 | 640630f078980f9818049625ebc42569c67c69f7 | refs/heads/master | 2020-04-07T20:36:45.758523 | 2018-03-07T09:04:57 | 2018-03-07T09:04:57 | 124,208,458 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 848 | java | package com.facebook.groups.react;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
/* compiled from: payments_db */
public abstract class AbstractGroupsManagerJavaModule extends ReactContextBaseJavaModule {
public AbstractGroupsManagerJavaModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
}
public String getName() {
return "RKTreehouseManager";
}
public void doesDeviceHaveSoftKeyboard(Callback callback) {
boolean z = true;
Object[] objArr = new Object[1];
if (this.a.getResources().getConfiguration().keyboard == 2) {
z = false;
}
objArr[0] = Boolean.valueOf(z);
callback.a(objArr);
}
}
| [
"son.pham@jmango360.com"
] | son.pham@jmango360.com |
d8d23c37c041c7e3b33af33d79cc06dcbf7d6025 | 4dfec0a3d0c88dc8b1fe9ecc95547f22d8f146e5 | /erent/src/main/java/com/how2java/tmall/service/impl/PropertyServiceImpl.java | 1867ce0d9004396f8bfc017fe2707338f5561b68 | [] | no_license | yangmingshanq/tmall_ssm | 843f74851503c0a263d86d34cb5cbff825b0060b | ad73db68cea22b23bf2bc7930b70e83deb1ecb89 | refs/heads/master | 2022-12-21T14:33:42.568624 | 2020-06-14T13:44:05 | 2020-06-14T13:44:05 | 191,321,999 | 0 | 0 | null | 2022-12-16T05:02:11 | 2019-06-11T07:54:41 | Java | UTF-8 | Java | false | false | 1,151 | java | package com.how2java.tmall.service.impl;
import com.how2java.tmall.mapper.PropertyMapper;
import com.how2java.tmall.pojo.Property;
import com.how2java.tmall.pojo.PropertyExample;
import com.how2java.tmall.service.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PropertyServiceImpl implements PropertyService {
@Autowired
PropertyMapper propertyMapper;
@Override
public void add(Property p) {
propertyMapper.insert(p);
}
@Override
public void delete(int id) {
propertyMapper.deleteByPrimaryKey(id);
}
@Override
public void update(Property p) {
propertyMapper.updateByPrimaryKeySelective(p);
}
@Override
public Property get(int id) {
return propertyMapper.selectByPrimaryKey(id);
}
@Override
public List list(int cid) {
PropertyExample example = new PropertyExample();
example.createCriteria().andCidEqualTo(cid);
example.setOrderByClause("id asc");
return propertyMapper.selectByExample(example);
}
}
| [
"1191351766@qq.com"
] | 1191351766@qq.com |
354b5b6597be13e75f008ef0e6c817817d953a75 | 5d9c296ffd8d16b375f0066b889cd6e46cb81a59 | /Hotel-parent/Hotel-client/src/main/java/org/Hotel/client/presertationController/HotelMyhotelOrderuiController.java | 3b62470650ad7ff6a90a642fdfb6c3b589b90847 | [] | no_license | Zhangchi123456/test | af83f3e67cd168479eb386f968271016b7b84528 | 408ff68782b1695755cf66a6616eded64b1e1594 | refs/heads/master | 2020-06-20T21:59:52.978546 | 2016-12-01T13:01:22 | 2016-12-01T13:01:22 | 74,821,192 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,089 | java | package org.Hotel.client.presertationController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.TableView;
import javafx.scene.control.TableColumn;
public class HotelMyhotelOrderuiController implements Initializable{
@FXML
private Button refresh,back;
@FXML
private TableView table;
@FXML
private TableColumn hotelName,OrderTime,State;
@FXML
private Label Myhotel;
@FXML
private void backButtonClicked(ActionEvent event){
}
@FXML
private void refreshButtonClicked(ActionEvent event){
}
@Override
public void initialize(URL location, ResourceBundle resources) {
// TODO Auto-generated method stub
}
}
| [
"asu@asus"
] | asu@asus |
ad16d49553b94a364b422987e00792fdab0c1c8b | ace6425f0871e558a8efc8b7fc9d9056fbd614d8 | /src/solidsdata/CustomSolid.java | 464dd19c4873026bc7ad66b9b097a703ddb97803 | [] | no_license | havrdda1/Grafika_uloha3 | 28bcbf6f86173a47795173b15ff980235964fd05 | d9ad44f70a1f229bf381f3154508037a82ecf7f6 | refs/heads/master | 2020-04-09T18:54:06.391181 | 2018-12-12T16:12:35 | 2018-12-12T16:12:35 | 160,527,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,909 | java | package solidsdata;
import io.vavr.collection.Array;
import io.vavr.collection.IndexedSeq;
import io.vavr.collection.Seq;
import io.vavr.collection.Stream;
import org.jetbrains.annotations.NotNull;
import transforms.Point3D;
public class CustomSolid implements Solid<Point3D, Topology> {
private final @NotNull IndexedSeq<Point3D> vertices;
private final @NotNull IndexedSeq<Integer> indices;
private final Array parts;
public CustomSolid() {
vertices = Array.of(
new Point3D(0.5, 0, 0.5),
new Point3D(0.875, 0.125, 0.5),
new Point3D(1, 0.5, 0.5),
new Point3D(0.875, 0.875, 0.5),
new Point3D(0.5, 1, 0.5),
new Point3D(0.125, 0.875, 0.5),
new Point3D(0, 0.5, 0.5),
new Point3D(0.125, 0.125, 0.5),
new Point3D(0.5, 0.5, 1),
new Point3D(0.5, 0.5, 0)
);
indices = Stream.rangeClosed(0, 0)
.flatMap(
i -> Array.of(i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7, i,
i, i + 8, i + 1, i + 8, i + 2, i + 8, i + 3, i + 8, i + 4, i + 8, i + 5, i + 8, i + 6, i + 8, i + 7, i + 8, i + 9, i, i + 9,
i + 1, i + 9, i + 2, i + 9, i + 3, i + 9, i + 4, i + 9, i + 5, i + 9, i + 6, i + 9, i + 7)
)
.toArray();
parts = Array.of(new Part(0, 24, Topology.LINES));
}
@NotNull
@Override
public IndexedSeq<Point3D> getVertices() {
return vertices;
}
@NotNull
@Override
public IndexedSeq<Integer> getIndices() {
return indices;
}
@NotNull
@Override
public Seq<Part<Topology>> getParts() {
return parts;
}
}
| [
"43078184+havrdda1@users.noreply.github.com"
] | 43078184+havrdda1@users.noreply.github.com |
b63134b9e138cfcd7207a7c7dc4ddcc36ab59fe1 | 1416ad703f4a64796b143a59befebfc59e568717 | /app/src/main/java/com/example/mvvmexample/ui/MainActivity.java | 91f8aa0d6b4c59a315bc60d2de1ed2e93529f33e | [] | no_license | ahmed-ismaail/MVVM-Retrofit-Exmaple | 343120393d54b054e8fd23c7444f446c14b38b4c | af4401d4eea4341d5e2e96bfeebec62eceaef71c | refs/heads/master | 2022-11-07T04:28:07.457426 | 2020-07-05T17:15:02 | 2020-07-05T17:15:02 | 274,784,092 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,276 | java | package com.example.mvvmexample.ui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import com.example.mvvmexample.R;
import com.example.mvvmexample.databinding.ActivityMainBinding;
import com.example.mvvmexample.model.MovieModel;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
MovieViewModel movieViewModel;
List<MovieModel> movieModelList = new ArrayList<>();
MovieAdapter movieAdapter;
RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//databinding
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
//connect viewModel with main activity
movieViewModel = new ViewModelProvider(this).get(MovieViewModel.class);
movieViewModel.getMovies();
recyclerView = binding.recycler;
movieViewModel.movieNameMutableLiveData.observe(this,
new Observer<List<MovieModel>>() {
@Override
public void onChanged(List<MovieModel> movieModels) {
movieModelList.addAll(movieModels);
movieAdapter.notifyDataSetChanged();
}
});
setupRecyclerView();
// if (movieAdapter == null) {
// recyclerView.setLayoutManager(new LinearLayoutManager(this));
// movieAdapter = new MovieAdapter(movieModelList);
// recyclerView.setAdapter(movieAdapter);
// } else {
// movieAdapter.notifyDataSetChanged();
// }
}
private void setupRecyclerView() {
if (movieAdapter == null) {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
movieAdapter = new MovieAdapter(movieModelList);
recyclerView.setAdapter(movieAdapter);
} else {
movieAdapter.notifyDataSetChanged();
}
}
}
| [
"ahmed.elmohame1997.ae@gmail.com"
] | ahmed.elmohame1997.ae@gmail.com |
965c33b92da7dfcef2216a9e28f962c49ba40718 | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i46169.java | 6f29667002b97867f9adc52ada0a8aea5a68d692 | [] | no_license | vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 69 | java | package number_of_direct_superinterfaces;
public interface i46169 {} | [
"vincentlee.dolbydigital@yahoo.com"
] | vincentlee.dolbydigital@yahoo.com |
bfe8c96cad66cc60d84456b179d67472193b9905 | 6f4c4854c066f51694512f68c375b4c0867de408 | /core/src/main/java/org/vedantatree/expressionoasis/expressions/arithmatic/ArrayIndexExpression.java | d739f178cfaa8222c4389a5681ebafbd9db946dc | [] | no_license | 3792274/Mathsun | 2adcdf299b9acfd54d8b7d451fb57103681bab16 | 3d373743990340c1d2d69d09dc187b81ed07c1ec | refs/heads/master | 2021-01-01T17:26:37.687880 | 2017-08-28T01:46:50 | 2017-08-28T01:46:50 | 98,071,127 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,374 | java | /**
* Copyright (c) 2005-2014 VedantaTree all rights reserved.
*
* This file is part of ExpressionOasis.
*
* ExpressionOasis is free software. You can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ExpressionOasis is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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.See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ExpressionOasis. If not, see <http://www.gnu.org/licenses/>.
*
* Please consider to contribute any enhancements to upstream codebase.
* It will help the community in getting improved code and features, and
* may help you to get the later releases with your changes.
*/
package org.vedantatree.expressionoasis.expressions.arithmatic;
import java.lang.reflect.Array;
import org.vedantatree.expressionoasis.ExpressionContext;
import org.vedantatree.expressionoasis.exceptions.ExpressionEngineException;
import org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression;
import org.vedantatree.expressionoasis.types.Type;
import org.vedantatree.expressionoasis.types.ValueObject;
import org.vedantatree.expressionoasis.utils.StringUtils;
/**
* This is the class expression to manipulate the indexed value from the array.
*
* @author Parmod Kamboj
* @author Mohit Gupta
* @version 1.0
*/
public class ArrayIndexExpression extends BinaryOperatorExpression
{
/**
* Gets the value from the array.
*
* @see org.vedantatree.expressionoasis.expressions.Expression#getValue()
*/
public ValueObject getValue() throws ExpressionEngineException
{
Object value = leftOperandExpression.getValue().getValue();
long index = ( (Number) rightOperandExpression.getValue().getValue() ).longValue();
return new ValueObject( Array.get( value, (int) index ), getReturnType() );
}
/**
* @see org.vedantatree.expressionoasis.expressions.Expression#getReturnType()
*/
@Override
public Type getReturnType() throws ExpressionEngineException
{
return leftOperandExpression.getReturnType().getComponentType();
}
/**
* @see org.vedantatree.expressionoasis.expressions.BinaryOperatorExpression#validate()
*/
@Override
protected void validate( ExpressionContext expressionContext ) throws ExpressionEngineException
{
if( !leftOperandExpression.getReturnType().isArray() || rightOperandExpression.getReturnType() != Type.LONG )
{
String prefix = StringUtils.getLastToken( getClass().getName(), "." );
prefix = prefix.substring( 0, prefix.length() - "Expression".length() );
throw new ExpressionEngineException( "Operands of types: [\"" + leftOperandExpression.getReturnType()
+ "\", \"" + rightOperandExpression.getReturnType() + "\"] are not supported by operator \""
+ prefix + "\"" );
}
}
} | [
"tony@ddg.git"
] | tony@ddg.git |
945e358688d1d4eda40f4cf9d5d0295cf30fdfb3 | 45cff5ed378ec54c019ac17731feacc59e8e7589 | /HibernateNamedQuery/src/com/demo/named/query/Demo.java | 158930123a44f02995b720c86b82b8f981b53908 | [] | no_license | ramyagattoju/file | ff3f3712107100fae5d728e1481aedaed0803f83 | 4d3dc69abd39ea3081ee5ba0da6b44c433d261fb | refs/heads/master | 2021-01-23T13:37:42.331136 | 2017-09-10T16:52:32 | 2017-09-10T16:52:32 | 102,672,196 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,020 | java | package com.demo.named.query;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
public class Demo {
public static void main(String[] args) {
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().
applySettings(configuration.getProperties());
SessionFactory factory = configuration.buildSessionFactory(builder.build());
//SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
Query query = session.getNamedQuery("findByName");
query.setString("custName", "kumar");
List<Customer> cust = query.list();
for(Customer c :cust){
System.out.println("Result : "+c.getCity() +" " +c.getState());
}
session.close();//Detached state
}
}
| [
"ramyapraveen0215@gmail.com"
] | ramyapraveen0215@gmail.com |
667496b47829cbb5d8a297907326b28bc4c6fde0 | 43386a5a8bc411ce264f133669dd7dc32bf2f289 | /src/main/java/com/bitkrx/api/auth/vo/CmeOptVO.java | b6fdc5d06eb32520b590a8f0ab8c05f1af464c1a | [] | no_license | limsy820/com.pacbit.api.new | 8e49c230406e751512982a599cbda626869c7405 | 7f89e987708efeae1e7678cec802abe6980857f9 | refs/heads/master | 2022-12-22T11:54:30.318293 | 2019-06-26T10:35:50 | 2019-06-26T10:35:50 | 193,884,061 | 0 | 0 | null | 2022-12-16T08:44:48 | 2019-06-26T10:35:14 | Java | UTF-8 | Java | false | false | 539 | java | package com.bitkrx.api.auth.vo;
import com.bitkrx.config.CmeResultVO;
public class CmeOptVO extends CmeResultVO{
/**
*
*/
private static final long serialVersionUID = -6049490012119544322L;
private String opt = ""; //opt
private String opt_yn = ""; //opt성공여부
public CmeOptVO(){}
public String getOpt() {
return opt;
}
public void setOpt(String opt) {
this.opt = opt;
}
public String getOpt_yn() {
return opt_yn;
}
public void setOpt_yn(String opt_yn) {
this.opt_yn = opt_yn;
}
}
| [
"limsy820@cmesoft.co.kr"
] | limsy820@cmesoft.co.kr |
643defcea69e2cd06b9d4dae2c2acb1f4105f7f6 | 4f886387a6c0c86b39d799c0270bfc8eabf11e8c | /Spring/Ex12-5-WebSocket1/src/main/java/com/study/spring1251/EchoHandler.java | bed3e03d67cab3c66823f06756b240859319f01a | [] | no_license | rumen-scholar/kosmo41_KimCheolEon | 38d3cbdd7576784440c95b6291656e11eb20915e | 3ea53334f6b8178c8f85c8bc5bf23d58429bb3a0 | refs/heads/master | 2020-03-21T04:41:23.634173 | 2018-12-20T09:19:06 | 2018-12-20T09:19:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 993 | java | package com.study.spring1251;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
public class EchoHandler extends TextWebSocketHandler{
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
System.out.printf("%s 연결 됨 \n", session.getId());
}
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
System.out.printf("%s로부터 [%s] 받음 \n",
session.getId(), message.getPayload());
session.sendMessage(new TextMessage("echo : " + message.getPayload()));
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
System.out.printf("%s 연결 끊김\n", session.getId());
}
}
| [
"kchy12345@gmail.com"
] | kchy12345@gmail.com |
16f5227f50fcd8ff91bb3f242ab5ff2ae5747a24 | c919d82b9b814a5058fffd5c31e0fe063c4eac5f | /src/main/java/com/example/application/views/admin/exercises/listeningTasks/CreateListeningTaskGridService.java | 0263cd6004bca611fe0cdcb284c9c3c8426614ba | [
"Unlicense"
] | permissive | Aretomko/English-Lab-online-language-school-project | 5e3d54645684b9bc3872c7706e764264e2380e5b | 8c92f3bab21ab4bb7906bb86901f8ef752e89574 | refs/heads/main | 2023-04-01T16:26:15.182868 | 2021-04-06T06:51:21 | 2021-04-06T06:51:21 | 349,846,493 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,915 | java | package com.example.application.views.admin.exercises.listeningTasks;
import com.example.application.domain.ExerciseGrammar;
import com.example.application.domain.Listening;
import com.example.application.service.LessonsService;
import com.example.application.service.ListeningService;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.data.provider.ListDataProvider;
import org.springframework.stereotype.Service;
@Service
public class CreateListeningTaskGridService {
private final ListeningService listeningService;
private final LessonsService lessonsService;
public CreateListeningTaskGridService(ListeningService listeningService, LessonsService lessonsService) {
this.listeningService = listeningService;
this.lessonsService = lessonsService;
}
public Grid<Listening> createGridListening(){
Grid<Listening> grid = new Grid<>();
grid.setItems(listeningService.getAllListings());
grid.addColumn(Listening::getId).setHeader("Id");
grid.addColumn(Listening::getName).setHeader("Name");
grid.addColumn(Listening::getHomework).setHeader("Is Homework");
grid.addColumn(item -> lessonsService.getStringNameIdByListening(item)).setHeader("Lesson");
grid.addComponentColumn(item -> createRemoveButtonListening(grid, item)).setHeader("Delete listening task");
return grid;
}
private Button createRemoveButtonListening(Grid<Listening> grid, Listening item) {
@SuppressWarnings("unchecked")
Button button = new Button("Delete", clickEvent -> {
ListDataProvider<Listening> dataProvider = (ListDataProvider<Listening>) grid.getDataProvider();
dataProvider.getItems().remove(item);
listeningService.delete(item);
dataProvider.refreshAll();
});
return button;
}
}
| [
"7752424@ukr.net"
] | 7752424@ukr.net |
0dcc2d235e39eb4885fdcd29a3cf6a0d506e64b8 | 7e9a4c11d9decf6f375a74bca9b5c92c15d977a2 | /Framework/src/main/java/com/cframe/framework/components/analysis/dao/AnalysisDaoImpl.java | 44a02bc56a7c97dbf5e471e393d8c7d33db7d498 | [] | no_license | hycho/bp-kt-project | 81248b698647c124207f92d5ece8f9084b688498 | f43a4ba4d8fab0c3d50c3a0df2d2b9b2c31111c7 | refs/heads/master | 2021-01-10T10:14:15.644895 | 2013-12-10T04:16:36 | 2013-12-10T04:16:36 | 36,353,725 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,396 | java | package com.cframe.framework.components.analysis.dao;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.cframe.framework.core.database.mybatis3.BaseSqlSessionDaoSupport;
@Repository("analysisDao")
public class AnalysisDaoImpl extends BaseSqlSessionDaoSupport{
static final Logger log = LoggerFactory.getLogger(AnalysisDaoImpl.class);
@Resource(name="jdbcTemplate")
private JdbcTemplate jdbcTemplate;
public List<Map<String, Object>> selectAnalysisSexForServiceList(Map<String, Object> params){
StringBuffer sql = new StringBuffer();
sql.append("SELECT CASE SEX WHEN '0' THEN '남성' WHEN '1' THEN '여성' ELSE '기타' END AS SEXTYPE, COUNT(*) AS TOT FROM TB_SERVICE_ANS ");
sql.append("WHERE PSERVICE = ? ");
sql.append("AND PMETHOD = ?");
sql.append("GROUP BY SEX");
System.out.println((String) params.get("spacakge"));
return jdbcTemplate.queryForList(sql.toString(), new Object[]{
(String) params.get("spacakge"),
(String) params.get("smethod")
});
}
public List<Map<String, Object>> selectAnalysisAgeForServiceList(Map<String, Object> params){
StringBuffer sql = new StringBuffer();
sql.append("SELECT SUBSTR(TO_CHAR(TO_NUMBER(SUBSTR(TO_CHAR(CURRENT_DATE()),1,4))-1984),1,1) AS BGT, COUNT(*) AS TOT FROM TB_SERVICE_ANS ");
sql.append("WHERE PSERVICE = ? ");
sql.append("AND PMETHOD = ? ");
sql.append("GROUP BY BGT");
return jdbcTemplate.queryForList(sql.toString(), new Object[]{
(String) params.get("spacakge"),
(String) params.get("smethod")
});
}
public List<Map<String, Object>> selectAnalysisTop5IdForServiceList(Map<String, Object> params){
StringBuffer sql = new StringBuffer();
sql.append("SELECT USERID, COUNT(*) AS TOT FROM TB_SERVICE_ANS ");
sql.append("WHERE PSERVICE = ? ");
sql.append("AND PMETHOD = ? ");
sql.append("GROUP BY USERID ");
sql.append("ORDER BY TOT DESC ");
sql.append("LIMIT 5");
return jdbcTemplate.queryForList(sql.toString(), new Object[]{
(String) params.get("spacakge"),
(String) params.get("smethod")
});
}
} | [
"kofwhgh@af415305-b26d-7bc8-1133-807e5f8653d7"
] | kofwhgh@af415305-b26d-7bc8-1133-807e5f8653d7 |
089865fb1ad3ba873af735caa0b9e7e666ce9ce5 | b4c47b649e6e8b5fc48eed12fbfebeead32abc08 | /android/animation/Animator.java | 58c8b2367c5c730d490c85a878ef6fae1fb7b82c | [] | no_license | neetavarkala/miui_framework_clover | 300a2b435330b928ac96714ca9efab507ef01533 | 2670fd5d0ddb62f5e537f3e89648d86d946bd6bc | refs/heads/master | 2022-01-16T09:24:02.202222 | 2018-09-01T13:39:50 | 2018-09-01T13:39:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,961 | java | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
package android.animation;
import android.content.res.ConstantState;
import java.util.ArrayList;
// Referenced classes of package android.animation:
// TimeInterpolator
public abstract class Animator
implements Cloneable
{
private static class AnimatorConstantState extends ConstantState
{
public int getChangingConfigurations()
{
return mChangingConf;
}
public Animator newInstance()
{
Animator animator = mAnimator.clone();
Animator._2D_set0(animator, this);
return animator;
}
public volatile Object newInstance()
{
return newInstance();
}
final Animator mAnimator;
int mChangingConf;
public AnimatorConstantState(Animator animator)
{
mAnimator = animator;
Animator._2D_set0(mAnimator, this);
mChangingConf = mAnimator.getChangingConfigurations();
}
}
public static interface AnimatorListener
{
public abstract void onAnimationCancel(Animator animator);
public abstract void onAnimationEnd(Animator animator);
public void onAnimationEnd(Animator animator, boolean flag)
{
onAnimationEnd(animator);
}
public abstract void onAnimationRepeat(Animator animator);
public abstract void onAnimationStart(Animator animator);
public void onAnimationStart(Animator animator, boolean flag)
{
onAnimationStart(animator);
}
}
public static interface AnimatorPauseListener
{
public abstract void onAnimationPause(Animator animator);
public abstract void onAnimationResume(Animator animator);
}
static AnimatorConstantState _2D_set0(Animator animator, AnimatorConstantState animatorconstantstate)
{
animator.mConstantState = animatorconstantstate;
return animatorconstantstate;
}
public Animator()
{
mListeners = null;
mPauseListeners = null;
mPaused = false;
mChangingConfigurations = 0;
}
public void addListener(AnimatorListener animatorlistener)
{
if(mListeners == null)
mListeners = new ArrayList();
mListeners.add(animatorlistener);
}
public void addPauseListener(AnimatorPauseListener animatorpauselistener)
{
if(mPauseListeners == null)
mPauseListeners = new ArrayList();
mPauseListeners.add(animatorpauselistener);
}
void animateBasedOnPlayTime(long l, long l1, boolean flag)
{
}
public void appendChangingConfigurations(int i)
{
mChangingConfigurations = mChangingConfigurations | i;
}
public boolean canReverse()
{
return false;
}
public void cancel()
{
}
public Animator clone()
{
Animator animator;
try
{
animator = (Animator)super.clone();
if(mListeners != null)
{
ArrayList arraylist = JVM INSTR new #51 <Class ArrayList>;
arraylist.ArrayList(mListeners);
animator.mListeners = arraylist;
}
if(mPauseListeners != null)
{
ArrayList arraylist1 = JVM INSTR new #51 <Class ArrayList>;
arraylist1.ArrayList(mPauseListeners);
animator.mPauseListeners = arraylist1;
}
}
catch(CloneNotSupportedException clonenotsupportedexception)
{
throw new AssertionError();
}
return animator;
}
public volatile Object clone()
throws CloneNotSupportedException
{
return clone();
}
public ConstantState createConstantState()
{
return new AnimatorConstantState(this);
}
public void end()
{
}
public int getChangingConfigurations()
{
return mChangingConfigurations;
}
public abstract long getDuration();
public TimeInterpolator getInterpolator()
{
return null;
}
public ArrayList getListeners()
{
return mListeners;
}
public abstract long getStartDelay();
public long getTotalDuration()
{
long l = getDuration();
if(l == -1L)
return -1L;
else
return getStartDelay() + l;
}
boolean isInitialized()
{
return true;
}
public boolean isPaused()
{
return mPaused;
}
public abstract boolean isRunning();
public boolean isStarted()
{
return isRunning();
}
public void pause()
{
if(isStarted() && mPaused ^ true)
{
mPaused = true;
if(mPauseListeners != null)
{
ArrayList arraylist = (ArrayList)mPauseListeners.clone();
int i = arraylist.size();
for(int j = 0; j < i; j++)
((AnimatorPauseListener)arraylist.get(j)).onAnimationPause(this);
}
}
}
boolean pulseAnimationFrame(long l)
{
return false;
}
public void removeAllListeners()
{
if(mListeners != null)
{
mListeners.clear();
mListeners = null;
}
if(mPauseListeners != null)
{
mPauseListeners.clear();
mPauseListeners = null;
}
}
public void removeListener(AnimatorListener animatorlistener)
{
if(mListeners == null)
return;
mListeners.remove(animatorlistener);
if(mListeners.size() == 0)
mListeners = null;
}
public void removePauseListener(AnimatorPauseListener animatorpauselistener)
{
if(mPauseListeners == null)
return;
mPauseListeners.remove(animatorpauselistener);
if(mPauseListeners.size() == 0)
mPauseListeners = null;
}
public void resume()
{
if(mPaused)
{
mPaused = false;
if(mPauseListeners != null)
{
ArrayList arraylist = (ArrayList)mPauseListeners.clone();
int i = arraylist.size();
for(int j = 0; j < i; j++)
((AnimatorPauseListener)arraylist.get(j)).onAnimationResume(this);
}
}
}
public void reverse()
{
throw new IllegalStateException("Reverse is not supported");
}
public void setAllowRunningAsynchronously(boolean flag)
{
}
public void setChangingConfigurations(int i)
{
mChangingConfigurations = i;
}
public abstract Animator setDuration(long l);
public abstract void setInterpolator(TimeInterpolator timeinterpolator);
public abstract void setStartDelay(long l);
public void setTarget(Object obj)
{
}
public void setupEndValues()
{
}
public void setupStartValues()
{
}
void skipToEndValue(boolean flag)
{
}
public void start()
{
}
void startWithoutPulsing(boolean flag)
{
if(flag)
reverse();
else
start();
}
public static final long DURATION_INFINITE = -1L;
int mChangingConfigurations;
private AnimatorConstantState mConstantState;
ArrayList mListeners;
ArrayList mPauseListeners;
boolean mPaused;
}
| [
"hosigumayuugi@gmail.com"
] | hosigumayuugi@gmail.com |
669c56165b42986f24dfe5f9f3b6d75f62f7d63d | a15a098db9b9293d3f3b7c7afbb13accc647e756 | /src/main/java/com/lucas/presbiteriana/model/entity/Visit.java | 19fb00b2cc560c029b4916b3275130cc87e55a15 | [] | no_license | lucas-pedroso-developer/presbiteriana-backend | 2f2aefdcccdf8903e3578effa9e68c1a17c1b973 | 1e4532d4c7e8bd6d56be26e786fe6b7f072f5229 | refs/heads/master | 2021-05-17T17:04:36.649479 | 2020-04-04T13:00:30 | 2020-04-04T13:00:30 | 250,887,425 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,463 | java | package com.lucas.presbiteriana.model.entity;
import java.io.Serializable;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "visit", schema = "presbiteriana")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Visit implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue( strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "idpresbyter")
private Long idPresbyter;
@Column(name = "idleader")
private Long idLeader;
@Column(name = "visitdate")
@JsonFormat(pattern="dd/MM/yyyy")
@Convert(converter = Jsr310JpaConverters.LocalDateConverter.class)
private LocalDate visitDate;
@Column(name = "presbytername")
private String presbyterName;
@Column(name = "leadername")
private String leaderName;
}
| [
"lukas_boo@hotmail.com"
] | lukas_boo@hotmail.com |
19a3d3c74ca94927cefebdf33435fab4c1b36405 | c5246d34021c615eff1f941daeb220f858c26f0c | /app/src/main/java/com/example/a001/ImageAdapter.java | 75f93e892d5b59a54953acf9b214a019c95be090 | [] | no_license | andercores/001 | 0d3e9854eb47b6934c1b16cacc678b565b2719dd | 6c05465acb8fccdc76f47c33459f4614bf444a4e | refs/heads/master | 2023-08-10T09:48:46.194973 | 2021-09-15T12:26:52 | 2021-09-15T12:26:52 | 406,249,393 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,374 | java | package com.example.a001;
import android.content.Context;
import android.content.res.TypedArray;
import android.media.tv.TvInputService;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
public class ImageAdapter extends BaseAdapter
{
private Context contexto = null;
private TypedArray imagenes = null;
public ImageAdapter(Context contexto, TypedArray imagenes)
{
this.contexto = contexto;
this.imagenes = imagenes;
}
@Override
public int getCount()
{
return imagenes.length();
}
@Override
public Object getItem(int i)
{
return imagenes.getResourceId(i, -1);
}
@Override
public long getItemId(int i)
{
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup)
{
LayoutInflater inflater = LayoutInflater.from(this.contexto);
View vistaImagen = inflater.inflate(R.layout.grid_item_view, viewGroup, false);
ImageView imagen = vistaImagen.findViewById(R.id.ivItemGrid);
//imagen.setImageResource(imagenes.getResourceId(i, -1));
Glide.with(contexto).load(this.imagenes.getResourceId(i, -1)).into(imagen);
return vistaImagen;
}
}
| [
"andercores@gmail.com"
] | andercores@gmail.com |
52dda756c78e0a6bff2eb0aa517cba3ac3f84990 | cb81c865f87ea821e31641f30f420146a0967c0f | /src/main/java/com/cos/crud/viewModel/BoardView.java | ae1322dc9432fc757e63d9e34a22ee175d779b1d | [] | no_license | dkskanj11/Mybatis-crud | 1c1532a3b99ae944f2a8761c260ea7727b377573 | 7c32cc0b3a691da987c4be689d36caa801fecdf0 | refs/heads/master | 2020-09-25T14:59:42.770822 | 2019-12-05T06:15:58 | 2019-12-05T06:15:58 | 226,029,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 418 | java | package com.cos.crud.viewModel;
import java.sql.Timestamp;
import com.cos.crud.model.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
//@Data
//@NoArgsConstructor
//@AllArgsConstructor
//public class BoardView {
//
// private int id;
// private String title;
// private String content;
// private Timestamp createDate;
//
// User user = new User();
// private int
//}
| [
"dkskanj11@gmail.com"
] | dkskanj11@gmail.com |
0bb218d88879563bb37371123e5a5a364f6e9c46 | de5b46c3256175a05383bb4b583329d6fb4e3366 | /app/src/main/java/com/ramanujaniss/satya/recyclerviewtest2/TemplatesAdapter.java | 0c7ac92ab5cb079c1f56c0b7f811eb7eb982e46c | [] | no_license | satyasampathirao/RecyclerViewTest2 | d6390f67eac8f281db397615040a6f65adc8f17d | f1c77fa4ee286d298fab93dd950d661dc77d5269 | refs/heads/master | 2021-06-24T07:00:41.823322 | 2017-09-13T05:39:15 | 2017-09-13T05:39:15 | 103,357,643 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,058 | java | package com.ramanujaniss.satya.recyclerviewtest2;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
/**
* Created by satya on 08-01-2017.
*/
public class TemplatesAdapter extends RecyclerView.Adapter<TemplatesViewHolder> {
Context context;
String[] template_name;
int[] template_imageview;
public TemplatesAdapter(Context c, String[] template_name, int[] template_imageview) {
this.context = c;
this.template_name = template_name;
this.template_imageview = template_imageview;
}
@Override
public TemplatesViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_templates, null);
RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
view.setLayoutParams(lp);
TemplatesViewHolder templatesViewHolder = new TemplatesViewHolder(view);
return templatesViewHolder;
}
@Override
public void onBindViewHolder(TemplatesViewHolder holder, int position) {
holder.template_name.setText(template_name[position]);
holder.template_imageview.setImageResource(template_imageview[position]);
holder.setItemClickListener(new ItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(context, "position " + position, Toast.LENGTH_LONG).show();
/* Intent intent = new Intent(context, TemplateCreatingActivity.class);
intent.putExtra("images", template_imageview[position]);
context.startActivity(intent);*/
}
});
}
@Override
public int getItemCount() {
return template_name.length;
}
}
| [
"satya.sampathirao@gmail.com"
] | satya.sampathirao@gmail.com |
3ca75ee117499ceb1563d58af0da33a9f0fd95ff | 8b0cc4e2700d8089669390cd10afbe9a6a1620c1 | /src/main/java/com/interview/util/DateUtil.java | dadb8358dbc0f77d37486ab06b529a5f9bd18785 | [] | no_license | lpavone/brandtone-test | 4cc661f0a5976e3a1a638922e8c6b3da98dde170 | 4a15a8f3f4990e4e4834587f493176146802af09 | refs/heads/master | 2016-08-05T14:39:30.078368 | 2014-03-07T13:42:53 | 2014-03-07T13:42:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,662 | java | package com.interview.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.interview.Constants;
import org.springframework.context.i18n.LocaleContextHolder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Date Utility Class used to convert Strings to Dates and Timestamps
*
* @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
* Modified by <a href="mailto:dan@getrolling.com">Dan Kibler </a>
* to correct time pattern. Minutes should be mm not MM (MM is month).
*/
public final class DateUtil {
private static Log log = LogFactory.getLog(DateUtil.class);
private static final String TIME_PATTERN = "HH:mm";
/**
* Checkstyle rule: utility classes should not have public constructor
*/
private DateUtil() {
}
/**
* Return default datePattern (MM/dd/yyyy)
*
* @return a string representing the date pattern on the UI
*/
public static String getDatePattern() {
Locale locale = LocaleContextHolder.getLocale();
String defaultDatePattern;
try {
defaultDatePattern = ResourceBundle.getBundle(Constants.BUNDLE_KEY, locale)
.getString("date.format");
} catch (MissingResourceException mse) {
defaultDatePattern = "MM/dd/yyyy";
}
return defaultDatePattern;
}
public static String getDateTimePattern() {
return DateUtil.getDatePattern() + " HH:mm:ss.S";
}
/**
* This method attempts to convert an Oracle-formatted date
* in the form dd-MMM-yyyy to mm/dd/yyyy.
*
* @param aDate date from database as a string
* @return formatted string for the ui
*/
public static String getDate(Date aDate) {
SimpleDateFormat df;
String returnValue = "";
if (aDate != null) {
df = new SimpleDateFormat(getDatePattern());
returnValue = df.format(aDate);
}
return (returnValue);
}
/**
* This method generates a string representation of a date/time
* in the format you specify on input
*
* @param aMask the date pattern the string is in
* @param strDate a string representation of a date
* @return a converted Date object
* @throws ParseException when String doesn't match the expected format
* @see java.text.SimpleDateFormat
*/
public static Date convertStringToDate(String aMask, String strDate)
throws ParseException {
SimpleDateFormat df;
Date date;
df = new SimpleDateFormat(aMask);
if (log.isDebugEnabled()) {
log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'");
}
try {
date = df.parse(strDate);
} catch (ParseException pe) {
//log.error("ParseException: " + pe);
throw new ParseException(pe.getMessage(), pe.getErrorOffset());
}
return (date);
}
/**
* This method returns the current date time in the format:
* MM/dd/yyyy HH:MM a
*
* @param theTime the current time
* @return the current date/time
*/
public static String getTimeNow(Date theTime) {
return getDateTime(TIME_PATTERN, theTime);
}
/**
* This method returns the current date in the format: MM/dd/yyyy
*
* @return the current date
* @throws ParseException when String doesn't match the expected format
*/
public static Calendar getToday() throws ParseException {
Date today = new Date();
SimpleDateFormat df = new SimpleDateFormat(getDatePattern());
// This seems like quite a hack (date -> string -> date),
// but it works ;-)
String todayAsString = df.format(today);
Calendar cal = new GregorianCalendar();
cal.setTime(convertStringToDate(todayAsString));
return cal;
}
/**
* This method generates a string representation of a date's date/time
* in the format you specify on input
*
* @param aMask the date pattern the string is in
* @param aDate a date object
* @return a formatted string representation of the date
* @see java.text.SimpleDateFormat
*/
public static String getDateTime(String aMask, Date aDate) {
SimpleDateFormat df = null;
String returnValue = "";
if (aDate == null) {
log.warn("aDate is null!");
} else {
df = new SimpleDateFormat(aMask);
returnValue = df.format(aDate);
}
return (returnValue);
}
/**
* This method generates a string representation of a date based
* on the System Property 'dateFormat'
* in the format you specify on input
*
* @param aDate A date to convert
* @return a string representation of the date
*/
public static String convertDateToString(Date aDate) {
return getDateTime(getDatePattern(), aDate);
}
/**
* This method converts a String to a date using the datePattern
*
* @param strDate the date to convert (in format MM/dd/yyyy)
* @return a date object
* @throws ParseException when String doesn't match the expected format
*/
public static Date convertStringToDate(final String strDate) throws ParseException {
return convertStringToDate(getDatePattern(), strDate);
}
}
| [
"leo@leo-laptop.(none)"
] | leo@leo-laptop.(none) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.