blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2 values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82 values | src_encoding stringclasses 28 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 5.41M | extension stringclasses 11 values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b09959227c1759468637e72529e78f74102a7b7e | a71c20d9df288f31b3732faa579aada0d50082ce | /staff_room/src/kkweb/dao/KinmuDAO.java | 1eb8df6bab53665583f005ffd3393b2c66e612b2 | [] | no_license | lucentsquare2014/staff_room | 2a34432d8b31d4136f08def0603cb72942d18f30 | 0e08dba68d0274dfcd3991270e6f665a4151305f | refs/heads/master | 2021-01-18T19:25:57.249069 | 2014-07-18T08:41:55 | 2014-07-18T08:41:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,691 | java | package kkweb.dao;
import java.sql.*;
import java.util.*;
import kkweb.beans.*;
import kkweb.common.*;
public class KinmuDAO{
public boolean isThereTbl(String strWhere){
C_DBConnection dbcon = new C_DBConnection();
Connection con = null;
try{
con = dbcon.createConnection();
String sql = " select * from kinmuMST ";
if(strWhere != null){
sql += strWhere;
}
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
if(rs.next()){
return true;
}else{
return false;
}
}catch(SQLException e){
e.printStackTrace();
return false;
}finally{
dbcon.closeConection(con);
}
}
public ArrayList selectTbl(String strWhere){
ArrayList klist = new ArrayList();
B_KinmuMST kinmutbl = null;
C_DBConnection dbcon = new C_DBConnection();
Connection con = null;
try{
con = dbcon.createConnection();
String sql = "select * from kinmuMST";
if(strWhere != null){
sql += strWhere;
}
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
kinmutbl = new B_KinmuMST();
String id = rs.getString("id");
String number = rs.getString("number");
String year_month = rs.getString("year_month");
String hizuke = rs.getString("hizuke");
String youbi = rs.getString("youbi");
String PROJECTcode = rs.getString("PROJECTcode");
String KINMUcode = rs.getString("KINMUcode");
String startT = rs.getString("startT");
String endT = rs.getString("endT");
String restT = rs.getString("restT");
String cyoukaT = rs.getString("cyoukaT");
String sinyaT = rs.getString("sinyaT");
String cyokuT = rs.getString("cyokuT");
String PROJECTname = rs.getString("PROJECTname");
String SYUKUJITUname = rs.getString("SYUKUJITUname");
String furouT = rs.getString("furouT");
kinmutbl.setId(id);
kinmutbl.setNumber(number);
kinmutbl.setYear_month(year_month);
kinmutbl.setHizuke(hizuke);
kinmutbl.setYoubi(youbi);
kinmutbl.setPROJECTcode(PROJECTcode);
kinmutbl.setKINMUcode(KINMUcode);
kinmutbl.setStartT(startT);
kinmutbl.setEndT(endT);
kinmutbl.setRestT(restT);
kinmutbl.setCyoukaT(cyoukaT);
kinmutbl.setSinyaT(sinyaT);
kinmutbl.setCyokuT(cyokuT);
kinmutbl.setPROJECTname(PROJECTname);
kinmutbl.setSYUKUJITUname(SYUKUJITUname);
kinmutbl.setFurouT(furouT);
klist.add(kinmutbl);
}
return klist;
}catch(SQLException e){
e.printStackTrace();
return null;
}finally{
dbcon.closeConection(con);
}
}
}
| [
"s11013@std.it-college.ac.jp"
] | s11013@std.it-college.ac.jp |
a7c4fecb8b7d565b98836823444e057776e54609 | e1be6f145a6d716aa97e48fddd859c06b81a983f | /src/main/java/data/dao/UserDao.java | 88c338c824699461779fab286ae8dc9c07c72838 | [] | no_license | GoldDever/MyNewHiberApp | 1288b071760f51a5edbdf1570c8327bd6e280dcf | 20865a00749ac3e97f0db7ef6131efe6028a64a0 | refs/heads/master | 2023-01-12T06:37:12.629157 | 2020-11-10T19:27:10 | 2020-11-10T19:27:10 | 308,869,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 280 | java | package data.dao;
import data.entity.User;
import java.util.List;
public interface UserDao {
List<User> getAll();
User getById(long id);
void save(User user);
void remove(long id);
void update(long id, User user);
User getUserByUserName(String name);
}
| [
"69146353+GoldDever@users.noreply.github.com"
] | 69146353+GoldDever@users.noreply.github.com |
3f3ed1867f98c78776cf08c4f0fa98afa9a409ce | e027e3f29b952219f660595f125afb43091b971d | /ArraysExamples/src/com/zsqaured/reversedarray/ReverseArray.java | bb003c9bd298f5ba576ffe8feecdc7806908d530 | [] | no_license | RandyZeleznak/Masterclass | 6593b6ef910b78a7ca2057a5bead5041989db6a7 | b67779f7e70039843090bf90150d2a4c705868a7 | refs/heads/main | 2023-02-25T23:13:58.152104 | 2021-01-30T14:01:50 | 2021-01-30T14:01:50 | 332,311,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 682 | java | package com.zsqaured.reversedarray;
import java.util.Arrays;
public class ReverseArray {
public static void main(String[] args) {
int [] array = { 1,3,5,13,8,15};
System.out.println("Array = " + Arrays.toString(array));
reverse(array);
System.out.println("ReversedArray = " + Arrays.toString(array));
}
private static void reverse(int [] array){
int maxIndex = array.length-1;
int halfLength = array.length/2;
for(int i = 0; i<halfLength;i++){
int temp=array[i];
array[i]=array[maxIndex-i];
array[maxIndex-i]=temp;
}
}
}
| [
"RandyZeleznak@gmail.com"
] | RandyZeleznak@gmail.com |
9d7dafd4f41e58bca42e3be1acae05ee3b3badf9 | 5881bc75e603867fb722a1f1fe722dcbf2a7c128 | /app/src/main/java/com/mgrmobi/brandbeat/ui/base/ContainerRecentBrands.java | 5d62d93b3f12b9a34cf5349886c9514f61d284ee | [] | no_license | knight388/Brandbeat | b52def7d66394b5d21dfab68cb89a51e5f1d4a2c | 7628aeda4994e9bba51f4ac53f9e673753a7a833 | refs/heads/master | 2020-03-11T02:40:28.672292 | 2018-04-16T10:27:34 | 2018-04-16T10:27:34 | 129,725,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 360 | java | package com.mgrmobi.brandbeat.ui.base;
import com.mgrmobi.brandbeat.network.responce.ResponseBrand;
import java.util.ArrayList;
/**
* @author Vasiliy Yakimov
* Developed by Magora Team (magora-systems.com). 2016.
*/
public interface ContainerRecentBrands extends ContainerProgress {
void getBrands(ArrayList<ResponseBrand> responseBrands);
}
| [
"greatroyalone@outlook.com"
] | greatroyalone@outlook.com |
c5fe7ddbd36d2bcc07deb730eb1db08560de7792 | f0cee2112828626679cbaee168687ad776b4fd87 | /pac1/A.java | 406fc96bf128ce31d943c7e94264c92f98a7c61c | [] | no_license | Saibabu3663/saibabub | 1e92e97f40c57f7d2eb0dc448eaa3fe14d059b4d | 6c4c5492ee2bfc836f6dc60cfc533bd23e112517 | refs/heads/master | 2020-08-31T11:51:28.132264 | 2019-11-19T06:36:55 | 2019-11-19T06:36:55 | 218,684,182 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 218 | java | package com.pac1;
public class A {
private static int i=10;
private int j=20;
public static void main(String[] args) {
System.out.println(i);
A ob=new A();
System.out.println(ob.j);
}
}
| [
"sai@DESKTOP-78OQCLJ"
] | sai@DESKTOP-78OQCLJ |
14867280c597578377ceab19edc47f5c2f2e5459 | e3f6f0dd33f52b448fcb5e8c7d4e1c733d4fccc4 | /src/main/java/deserializer/VendaIngressoDeserializer.java | 0182c65522d4f9bd743e9bd1650a80bc827e08c6 | [] | no_license | dasa-community/Consumidor-Kafka | 042d8d40c5a5604dc612a9c405b19bc5aef09c69 | 0e02abb2eadba29d63e95ee2f57a7dd883a64494 | refs/heads/main | 2022-12-24T15:35:08.917767 | 2020-10-10T22:51:53 | 2020-10-10T22:51:53 | 303,002,923 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 562 | java | package deserializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import model.Venda;
import org.apache.kafka.common.serialization.Deserializer;
import java.io.IOException;
public class VendaIngressoDeserializer implements Deserializer<Venda> {
@Override
public Venda deserialize(String s, byte[] venda) {
try {
return new ObjectMapper().readValue(venda, Venda.class);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public void close() {
}
}
| [
"pedro.bazzo@dasa.com.br"
] | pedro.bazzo@dasa.com.br |
3632bf79c30a56d93f663b3a80042b96ceb8f758 | 3dbc2f473622c25cd4be9bb742d3c8b1cc9b49c4 | /ribbon/src/main/java/com/cnpc/ribbonTest/TestRibbon.java | f8796221eaf47734de4331094031788b041ef876 | [] | no_license | AsherAngelo/springcloudpart | 9fdbc466d94c9b680c2f4f35bbb83047a7041195 | d4db4aa441485187311e38f2b13da61342ff6186 | refs/heads/master | 2020-04-18T01:41:14.505921 | 2019-01-23T06:23:33 | 2019-01-23T06:23:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,081 | java | package com.cnpc.ribbonTest;
import com.netflix.client.ClientFactory;
import com.netflix.client.http.HttpRequest;
import com.netflix.client.http.HttpResponse;
import com.netflix.config.ConfigurationManager;
import com.netflix.niws.client.http.RestClient;
/**
* Created by 赵梦杰 on 2018/5/25.
*/
public class TestRibbon {
public static void main(String[] args) throws Exception{
ConfigurationManager.getConfigInstance().setProperty(
"my-client.ribbon.listOfServers", "localhost:8080,localhost:8081");
ConfigurationManager.getConfigInstance().setProperty(
"my-client.ribbon.NFLoadBalancerRuleClassName", MyRule.class.getName());
RestClient client = (RestClient) ClientFactory.getNamedClient("my-client");
HttpRequest request = HttpRequest.newBuilder().uri("/person").build();
for(int i = 0; i < 20; i++) {
HttpResponse response = client.executeWithLoadBalancer(request);
String json = response.getEntity(String.class);
System.out.println(json);
}
}
}
| [
"zhaomengjie@cnpc.com.cn"
] | zhaomengjie@cnpc.com.cn |
e784478f5b553652617d5815b469f933d7774076 | d662fe050655a012160c5c670044992dd62925ad | /src/main/java/com/djj/languagepoints/chapter8/designmode/command/Editor.java | e6e663142f3faff16894904b62e78185dbd626c0 | [] | no_license | ivydjj/java8-lambda | b5d858b125cd373f44b8ea9ed709400b164ab4ff | 83945634813741aa82aeb338179141bdda2543f6 | refs/heads/master | 2020-03-31T21:21:37.802099 | 2018-10-21T10:03:55 | 2018-10-21T10:03:55 | 152,577,268 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 406 | java | package com.djj.languagepoints.chapter8.designmode.command;
/*
文本编辑器
像 open 、 save 这样的操作称为命令
用一个统一的接口来概括这些不同的操作,这里将这个接口叫作 Action ,它代表了一个操作,所有的命令都要实现该接口
*/
// BEGIN Editor
public interface Editor {
void save();
void open();
void close();
}
// END Editor
| [
"dengjuanjuan@renwey.com"
] | dengjuanjuan@renwey.com |
fb99de73eff19904ecd57ef94c50b2072f43c51e | 967ad094074c4503bf1409a40b43b38075a03f66 | /homework6.3/src/com/gmail/m1512/dan/BinaryNumber.java | 43f569742fa136f09dafd5dbd83766f842cf9363 | [] | no_license | FTC5/Java-SE | 7f7886bb79247d4149a448247316c9d0a22ce4d4 | d0acf09d6de237ff28f4bc9168c0ce515a33e7d3 | refs/heads/master | 2021-01-01T04:04:03.583772 | 2018-01-25T12:41:15 | 2018-01-25T12:41:15 | 97,116,437 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 720 | java | package com.gmail.m1512.dan;
import java.util.Scanner;
public class BinaryNumber {
public static void main(String[] args) {
// TODO Auto-generated method stub
String num;
Scanner sc = new Scanner(System.in);
System.out.println("Input binary number");
num = sc.nextLine();
sc.close();
System.out.println(binary(num));
}
static int binary(String text) {
int num = Integer.parseInt(text);
int sum = 0;
int n = 0;
for (int i = 0; i < text.length(); i++) {
n = num % 10;
if (n == 1) {
sum += Math.pow(2, i);
num /= 10;
} else if (n == 0) {
num /= 10;
} else {
System.out.println("Error");
return 0;
}
}
return sum;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
4af9fd93d54392781f0d995a287b43c1bea95853 | a370c67c55917016ebed2ac0b763565420e7c8ab | /src/main/java/org/antonio_fenna/spark/SumNumbersFromFiles.java | df625eb9c9c6a378165dedd802a9248bb3753ccd | [] | no_license | antoniofenna/test | 0b90f6a52372c61b24e6db942ae5f4c2eac315e3 | 197ecc0f48da4004981a78ce3571232e19c30c10 | refs/heads/master | 2021-05-02T14:57:54.993174 | 2018-02-26T23:04:41 | 2018-02-26T23:04:41 | 120,728,956 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 640 | java | package org.antonio_fenna.spark;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
public class SumNumbersFromFiles {
public static void main( String[] args )
{
//STEP 1.
SparkConf conf= new SparkConf();
//STEP 2.
JavaSparkContext jsc= new JavaSparkContext(conf);
int suma= jsc
.textFile(args[0])
.map(s->Integer.valueOf(s))
.reduce((Integer,Integer2)->Integer+Integer2);
//JavaRDD<Integer> rddofIntegers=lines.map(s->Integer.valueOf(s));
//int suma= rddofIntegers.reduce((Integer,Integer2)->Integer+Integer2);
System.out.println("The sum is:"+ suma);
jsc.stop();
}
}
| [
"antonio_fenna@hotmail.com"
] | antonio_fenna@hotmail.com |
74315cc203524601088b783cbcd0712a5cd768bb | 25054d7c0497d2925248b4953f8d787bdab7ee69 | /src/main/java/com/springbootpractice/restservices/repositories/UserRepository.java | 3ebfe8e72969c52f7202fadc3b86de1ce2560236 | [] | no_license | alibaksh/springboot-practice | da75cd614cccbcfc4409063ebdc1cfe05c4c5013 | 0cfc0f6e247dd042044c8f32a9bb822e83d8359c | refs/heads/master | 2022-12-22T03:53:50.813941 | 2020-09-17T13:35:25 | 2020-09-17T13:35:25 | 268,793,819 | 0 | 0 | null | 2020-06-09T18:42:18 | 2020-06-02T12:23:43 | Java | UTF-8 | Java | false | false | 352 | java | package com.springbootpractice.restservices.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.springbootpractice.restservices.entities.User;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
User findByUsername(String username);
}
| [
"ali.mehmood@tenpearls.com"
] | ali.mehmood@tenpearls.com |
f2547b328f997d23cfdeeaf4bb3fcd142a83ef71 | 24df67cc8a4b545e462ffdc45073f2834583f77a | /src/main/game/Gamestate.java | 9186478ff3237be47d8fab037e75a359739e8972 | [] | no_license | jaagupku/dungeon-rpg | ad740840ab5807d999b32cfde1dbf275873a0ecc | de637472435c940a7a91bd983227fe22eaac74be | refs/heads/master | 2021-01-01T03:50:31.966195 | 2016-05-15T13:47:10 | 2016-05-15T13:47:10 | 56,920,967 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 92 | java | package main.game;
public enum Gamestate {
PLAYER_LOSE, GAME_NOT_OVER, PLAYER_WIN;
}
| [
"jaagupku@gmail.com"
] | jaagupku@gmail.com |
721a38d584c7abdfa85e7526fc3a2a49a81d243c | 3757e963008a5446ab70b3b53f564985327a1595 | /src/main/java/structural/decorator/Topping.java | 5e9c47210ff73b8ada3cc23bc426afbd497ad8c9 | [] | no_license | kreng/patterns | 4532fcf4f7e7ce7b6da4013eae6287bc52858b43 | 6c41b29b87e18fff3c5d02c3ac1a4bc49ea91c83 | refs/heads/master | 2022-12-05T00:26:11.426698 | 2020-08-20T19:43:10 | 2020-08-20T19:43:10 | 278,719,828 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 210 | java | package structural.decorator;
class Topping {
String product;
public Topping(String product) {
this.product = product;
}
public String getProduct() {
return product;
}
}
| [
"kreng9@mail.ru"
] | kreng9@mail.ru |
e7859ac9fd383acfe68ce58386de19aa42dd27b6 | 1832dd199cab7a294863e62dfef7b47c759e9668 | /src/test/java/guru/springframework/msscbeerservice/web/model/BeerDtoKebabTest.java | ec897a84ad2f765be29a055f42c1acf823457a73 | [] | no_license | xrangerbco275/mssc-beer-service | 5214a48c5fcab849ae081bf161f529713ca9a467 | 5b8de2de84c41232f7237e2221ac2e82dc912862 | refs/heads/master | 2020-08-30T12:42:17.478624 | 2019-11-28T18:07:34 | 2019-11-28T18:07:34 | 218,383,909 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,199 | java | package guru.springframework.msscbeerservice.web.model;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.test.context.ActiveProfiles;
import java.io.IOException;
@ActiveProfiles("kebab")
@JsonTest
class BeerDtoKebabTest extends BaseTest
{
@Test
void testDeserialization() throws IOException
{
String json = "{\"version\":null,\"created-date\":\"2019-11-08T23:38:24-0600\",\"last-modified-date\":\"2019-11-08T23:38:24-0600\",\"beer-name\":\"BeerName\",\"beer-style\":\"PALE_ALE\",\"upc\":123456789,\"price\":12.9900000000000002131628207280300557613372802734375,\"min-on-hand\":null,\"quantity-on-hand\":null,\"my-date\":\"20191108\",\"beerId\":\"c63fb54c-42d9-4105-9cda-8b5b86762521\"}\n";
BeerDto beerDto = objectMapper.readValue(json, BeerDto.class);
System.out.println(beerDto);
}
@Test
void testSerializeDto() throws JsonProcessingException
{
BeerDto beerDto = getDto();
String jsonString = objectMapper.writeValueAsString(beerDto);
System.out.println(jsonString);
}
} | [
"xrangerbco275@att.net"
] | xrangerbco275@att.net |
86211850fe30f192e0dab1623790e2ba29a0ee2c | 432127e528214a4af667ac4128290c3a64541984 | /app/src/main/java/social/evenet/activity/AddListActivity.java | e6d9ba21b716c16c07164d5e17e118f455d5a143 | [] | no_license | alexpereverzev/Evenet | 5625dc5d7f89b055bd493745af6100a681075a18 | 8c911c0f63b5f72000913544836750eaa1761e07 | refs/heads/master | 2020-04-01T22:14:10.617212 | 2015-01-14T14:22:13 | 2015-01-14T14:22:13 | 29,247,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,038 | java | package social.evenet.activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.parse.ParseAnalytics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import social.evenet.R;
import social.evenet.adapter.ListAdapter;
import social.evenet.db.DefaultList;
public class AddListActivity extends HashActivity {
private ListView listView;
private ListAdapter adapter;
private ArrayList<DefaultList> item = new ArrayList<DefaultList>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Map<String, String> dimensions = new HashMap<String, String>();
dimensions.put("page_name ", "add_lists");
ParseAnalytics.trackEvent("Page View", dimensions);
setContentView(R.layout.activity_add_list);
listView = (ListView) findViewById(R.id.list_lis);
String[] array = getResources().getStringArray(R.array.list_default);
for (int i = 0; i < array.length; i++) {
DefaultList d = new DefaultList();
d.setName(array[i]);
item.add(d);
}
DefaultList custom = new DefaultList();
custom.setName("Custom");
item.add(custom);
adapter = new ListAdapter(this, item);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i1, long l) {
Map<String, String> options = new LinkedHashMap<String, String>();
options.put("access_token", getSharedPreferences("token_info", MODE_PRIVATE).getString("token", ""));
options.put("only_in_my_areas", "0");
options.put("name", item.get(i1).getName());
App.getApi().listAdd(options);
}
});
}
}
| [
"waylander1688@gmail.com"
] | waylander1688@gmail.com |
8c167f590846df37ebdb6f17769f3a6befe80857 | b74b2fb23ad5e25548676b64dc27be54c533d1ac | /string/StringSimilarity.java | 338ebb158ee4b4e6333910950b7836071fcafe9a | [] | no_license | faraway/HankerRank | b595e2cfd421394ca22c65753bd92ca1f8c76de0 | 05aafdb5e1d9903e9dc0bef65ac3b0bca919d7f2 | refs/heads/master | 2020-04-14T23:49:13.870172 | 2014-06-27T16:40:30 | 2014-06-27T16:40:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,003 | java | package string;
/**
* String Similarity (25 Points)
For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. For example, the similarity of strings "abc" and "abd" is 2, while the similarity of strings "aaa" and "aaab" is 3.
Calculate the sum of similarities of a string S with each of it's suffixes.
Input:
The first line contains the number of test cases T. Each of the next T lines contains a string each.
Output:
Output T lines containing the answer for the corresponding test case.
Constraints:
1 <= T <= 10
The length of each string is at most 100000 and contains only lower case characters.
Sample Input:
2
ababaa
aa
Sample Output:
11
3
Explanation:
For the first case, the suffixes of the string are "ababaa", "babaa", "abaa", "baa", "aa" and "a". The similarities of each of these strings with the string "ababaa" are 6,0,3,0,1,1 respectively. Thus the answer is 6 + 0 + 3 + 0 + 1 + 1 = 11.
For the second case, the answer is 2 + 1 = 3.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
public class StringSimilarity {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int n = Integer.parseInt(line);
for (int i=0;i<n;i++){
String s = br.readLine();
char[] c = s.toCharArray();
int sum = c.length;
int stub = 0;
ArrayList<Integer> points = new ArrayList<Integer>();
for(int j=1 ;j<c.length;j++){
if(c[stub]==c[j]){
points.add(j);
}
}
sum+=points.size();
stub++;
while(points.size()>0){
Iterator<Integer> it = points.iterator();
while(it.hasNext()){
Integer integer = it.next();
if(integer+stub>c.length-1 || c[stub]!=c[integer+stub]){
it.remove();
}
}
sum+=points.size();
stub++;
}
System.out.println(sum);
}
}
}
| [
"patrick@X1.(none)"
] | patrick@X1.(none) |
5d0d109fa96a00525e84d9e6ae34bd0456038a41 | d764b946f7dd98199c20a62dd9758b50db84e94d | /src/Ejercicio3/Libro.java | 48557aa16b1e620d37a7e1c6fa54c309c5545f08 | [] | no_license | eravina-Meli/Java2 | 0abf10f92acdf86c17431694de7afb736e1582a0 | a45dd0a925a8a4f797a3871d844a8c5882249d24 | refs/heads/main | 2023-05-06T06:55:41.218416 | 2021-05-30T17:05:31 | 2021-05-30T17:05:31 | 372,074,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 737 | java | package Ejercicio3;
public class Libro {
//Atributos
private String titulo, isbn,autor;
//Contructores
public Libro(){}
public Libro(String titulo,String isbn, String autor) {
this.titulo = titulo;
this.isbn = isbn;
this.autor=autor;
}
//Metodos
public void Prestamo(){
System.out.println("Se presto el Libro " + toString());
}
public void Devolucion(){
System.out.println("Se devolvio el Libro " + toString());
}
@Override
public String toString() {
return "Libro{" +
"titulo='" + titulo + '\'' +
", isbn='" + isbn + '\'' +
", autor='" + autor + '\'' +
'}';
}
}
| [
"elton.ravina@mercadolibre.com"
] | elton.ravina@mercadolibre.com |
981104ec9bd285bd6a77642e20093d067e0836ef | 0894b391b26cbe06e4e60fad12e3df513db886fa | /src/main/java/training360/guinessapp/worldrecord/WorldRecordRepository.java | 00f592e54e011bd10cade21907e1338c1d2520fa | [] | no_license | gaborpolgar/sv2021-jvjbf-kepesitovizsga | 290771f999ef127beae8d850ee7852aef03a9136 | 8c6b797b88e7f191e04b898ad025ddb446562c30 | refs/heads/master | 2023-07-14T21:31:42.907329 | 2021-09-06T13:17:20 | 2021-09-06T13:17:20 | 403,629,151 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 192 | java | package training360.guinessapp.worldrecord;
import org.springframework.data.jpa.repository.JpaRepository;
public interface WorldRecordRepository extends JpaRepository<WorldRecord, Long> {
}
| [
"56192725+gaborpolgar@users.noreply.github.com"
] | 56192725+gaborpolgar@users.noreply.github.com |
b2531c861a13b81f2c5dbf18d3b04a12c62ed7cc | b488db964ebad715884eab6c81e4fb57f53f36c0 | /src/main/java/com/taskmanager/Service/TaskGenerator.java | 4a1d911a1ed9e7f4b292f81d9539f240215581c0 | [] | no_license | Shachty/TaskManager | 5f2809e58735642fb4ea664659b95eac42120c98 | beb0aa0b9ac51d9a1283a8c8dfcbb0ddf92c2370 | refs/heads/master | 2020-12-03T03:40:49.217571 | 2017-06-29T10:56:33 | 2017-06-29T10:56:33 | 95,760,379 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,252 | java | package com.taskmanager.Service;
import com.taskmanager.Entity.Status;
import com.taskmanager.Entity.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Random;
/**
* Created by Daniel on 27.06.2017.
*/
@Component
public class TaskGenerator {
private Random randomGenerator;
private int counter;
private String description = "Generated Task #";
private static final Logger log = LoggerFactory.getLogger(TaskGenerator.class);
public TaskGenerator(){
this.randomGenerator = new Random();
counter = 0;
}
public Task generateTask(){
LocalDateTime now = LocalDateTime.now();
log.info(description + counter);
return new Task(0,
now,
null,
now.plusMinutes(randomGenerator.nextInt(4320)),
null,
TaskTitles.values()[randomGenerator.nextInt(TaskTitles.values().length)].toString(),
description + counter++,
randomGenerator.nextInt(5),
Status.ONHOLD);
}
}
enum TaskTitles{
SLEEP, RUN, MAKEMUSIC, CLIMB, COOK, CODE
}
| [
"daniel.shatkin@gmail.com"
] | daniel.shatkin@gmail.com |
97514b63d52c7a32b4568e66225199d4ed59419f | 1dc343254d22b4423726349c0f48fefe4e3d5571 | /DeleteInternship.java | ab41261a9aa9a5bcf1716f73272d61223f2d1fd8 | [
"MIT"
] | permissive | raghvendrapurohit/online-internship-portal | 01ec03c83b770b7f9c46460b213ec866427da0f4 | 407fc54df5f9108e1efe1d5e9ba940f7986ac043 | refs/heads/master | 2021-04-26T16:45:04.373426 | 2018-06-30T07:29:23 | 2018-06-30T07:29:23 | 121,206,475 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,295 | java | import javax.servlet.*;
import java.io.*;
import java.sql.*;
import javax.servlet.http.*;
public class DeleteInternship extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
Connection con=null;
Statement st1=null,st2=null,st3=null;
ResultSet rs1=null,rs2=null,rs3=null;
String intern_id=req.getParameter("intern_id");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:mp");
}
catch(ClassNotFoundException e1)
{
pw.println(e1);
}
catch(SQLException e2)
{
pw.println(e2);
}
HttpSession session=req.getSession();
String phone1=(String)session.getAttribute("mob");
try
{
st1=con.createStatement();
st1.executeUpdate("delete from internships where internid='"+intern_id+"'");
rs2.close();
st2.close();
}
catch(SQLException e4)
{
pw.println(e4);
}
catch(Exception e5)
{
pw.println(e5);
}
res.sendRedirect("EducatorServlet");
}
public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
{
doGet(req,res);
}
} | [
"noreply@github.com"
] | noreply@github.com |
6c80a0f2a0a1e6c6941f6221c25f415eee4e5768 | 187ad440a8c832596e359fc845df33e480c1896d | /punto3/src/androidTest/java/com/juanruiz/punto3/ApplicationTest.java | bb87ee92e5900c7a2ca7fb31b2cf9c25ef1941fe | [] | no_license | juaruizra/PRACTICA3 | 2148435af1c2001a441d3e19d08afa4487ccf394 | a34b4e7a94cdf1c665aac98dcc9a03a705c625a0 | refs/heads/master | 2021-01-10T09:28:25.745958 | 2015-10-06T01:23:28 | 2015-10-06T01:23:28 | 43,716,437 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.juanruiz.punto3;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"j_ruiz963@hotmail.com"
] | j_ruiz963@hotmail.com |
ea680526c03b0fcc19466f180532ac1a8c25ebc6 | c631f5de96b16bc56bf802b6ec69cd261bb36329 | /app/src/main/java/xyz/edmw/MainApplication.java | 345617e1d4f2ee2d38057f7a5112d2c1556c8585 | [] | no_license | leeyikjiun/EDMW | 39f85a283d1e130ed25539439e7d1c8d7ecf1cb6 | a1e5da6909cfc9b59f1ced58441219d4aa977892 | refs/heads/master | 2021-01-10T08:38:19.514205 | 2016-02-13T13:25:23 | 2016-02-13T13:25:23 | 48,939,362 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 451 | java | package xyz.edmw;
import android.app.Application;
import android.content.Context;
public class MainApplication extends Application {
private static Context context;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
public static Context getContext() {
if (context == null) {
throw new NullPointerException();
}
return context;
}
}
| [
"lee.yikjiun@gmail.com"
] | lee.yikjiun@gmail.com |
650aa1ab152bf60fd7bd68920ddf6aa923e65a3e | 79b602905b5bef95971a3fa8b47052432158dce4 | /src/main/java/com/example/sweater/domain/User.java | 0c50068dbe0476c0f1b06eee5cfd872e28e2acf4 | [] | no_license | cryptobuks1/clone-twitter | eec8b55f88821dcbebac1303b9b14eba24c43549 | 7eb92337b7aaedd59057bee9a9c763fbb5099ca4 | refs/heads/master | 2020-11-28T10:37:37.172389 | 2019-12-09T19:29:15 | 2019-12-09T19:29:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,258 | java | package com.example.sweater.domain;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
@Entity
@Table(name = "usr")
public class User implements UserDetails {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotBlank(message = "Username cannot be empty")
private String username;
@NotBlank(message = "Password cannot be empty")
private String password;
private boolean active;
@Email(message = "Email is not correct")
@NotBlank(message = "Email cannot be empty")
private String email;
private String activationCode;
@ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
@CollectionTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.STRING)
private Set<Role> roles;
@OneToMany(mappedBy = "author", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Set<Message> messages;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(id, user.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
public boolean isAdmin() {
return roles.contains(Role.ADMIN);
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return isActive();
}
public void setUsername(String username) {
this.username = username;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return getRoles();
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getActivationCode() {
return activationCode;
}
public void setActivationCode(String activationCode) {
this.activationCode = activationCode;
}
public Set<Message> getMessages() {
return messages;
}
public void setMessages(Set<Message> messages) {
this.messages = messages;
}
} | [
"40837008+Wladislaw28@users.noreply.github.com"
] | 40837008+Wladislaw28@users.noreply.github.com |
cf77efa6e7e8270b060c24e9856603e95743e332 | def8aecc7105defabf62cbc1a2adee2f623ea5cb | /app/src/main/java/com/customer/admin/cpepsi_customers/Java_files/StateModel.java | be144f9754cab70c6beadf59028b12b3a85eccc3 | [] | no_license | raghsahu/CPEPSI_Customers | b690ee7f4f1b8d532058972d5a0c8caa34d7862d | 30d828fe0b1fba6ca6fff7511db4f119fb769c90 | refs/heads/master | 2020-05-20T23:07:39.098571 | 2019-11-06T15:32:28 | 2019-11-06T15:32:28 | 185,795,289 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 603 | java | package com.customer.admin.cpepsi_customers.Java_files;
public class StateModel {
private String state_id;
private String state_name;
public StateModel(String state_id, String state_name) {
this.state_id=state_id;
this.state_name=state_name;
}
public String getState_id() {
return state_id;
}
public void setState_id(String state_id) {
this.state_id = state_id;
}
public String getState_name() {
return state_name;
}
public void setState_name(String state_name) {
this.state_name = state_name;
}
}
| [
"raghvendra.19934@gmaial.com"
] | raghvendra.19934@gmaial.com |
17d071efd6395e4725d45695786cadae734d7e85 | 76eb298ea53f35d27df9d2815b58961217ac15ee | /src/main/java/io/needle/lms/exception/AvailabilityException.java | 6dc17b55f82e039670099a6de35ceb1f5f326b1c | [] | no_license | mankondavivek/lms | c87b8c0c6b7f0decaf3f0a72a96c790639dfde48 | d3c92bef74bbc948d69dea1793e581b4a998da2f | refs/heads/master | 2020-03-31T13:00:43.540463 | 2018-10-10T11:32:22 | 2018-10-10T11:32:22 | 152,237,928 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 849 | java | package io.needle.lms.exception;
public class AvailabilityException extends Exception {
/**
*
*/
private static final long serialVersionUID = -5773090141406685842L;
public AvailabilityException() {
// TODO Auto-generated constructor stub
}
public AvailabilityException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
public AvailabilityException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
public AvailabilityException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
public AvailabilityException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
// TODO Auto-generated constructor stub
}
}
| [
"34041198+mankondavivek@users.noreply.github.com"
] | 34041198+mankondavivek@users.noreply.github.com |
9a3d81189d863ff3be8fdab4abc7921e2c1c8fed | 2cb69d0cebc1db2481d35dac363771f47acc342e | /jframe-web-app/src/main/java/com/jf/system/utils/Constant.java | 6d1fe834ef69feda8f43b5738843ef8e2e97b100 | [
"BSD-3-Clause"
] | permissive | menghuanlunhui/JFrameBoot-master | 394d49b2d82498e6470c8434678e95399a089189 | ac8d573ebb5efe05bd2d8a25de940ce3364aa5fb | refs/heads/master | 2022-12-06T23:36:56.308162 | 2019-06-27T03:36:11 | 2019-06-27T03:36:11 | 189,163,226 | 0 | 0 | BSD-3-Clause | 2022-11-16T10:27:57 | 2019-05-29T06:24:20 | JavaScript | UTF-8 | Java | false | false | 1,926 | java | package com.jf.system.utils;
import java.util.ArrayList;
import java.util.List;
/**
* Created with IntelliJ IDEA.
* Description:
* User: admin
* Date: 2019-03-22
* Time: 14:50
*/
public class Constant {
public final static String APPID = "wx8cdde2f894dc5d34";
public final static String SECRET = "1d3e36dff6251390a92bc66020787b85";
public final static String SESSIONID = "sessionid";
public final static String TOKEN = "token";
public static List<String> KEYS = new ArrayList<>();
public final static String STR_UID = "uid";
public final static String STR_CONFIRM = "confirm";
public final static String STR_TYPE = "value";
public final static String STR_STATE = "state";
public final static String STR_EXPIRE = "expire";
static {
KEYS.add(STR_UID);
KEYS.add(STR_CONFIRM);
KEYS.add(STR_TYPE);
}
// value: login,bind,...
public enum Type {
Login("login", "登陆"),
Bind("bind", "绑定");
Type(String type, String typename) {
this.type = type;
this.typename = typename;
}
private String type;
private String typename;
public String value() {
return type;
}
public String typename() {
return typename;
}
public static String get(String type) {
for (Type s : Type.values()) {
if (s.value().equals(type)) {
return s.typename();
}
}
return "--";
}
}
// 0-初始值 1-已扫码 2-确认 3-取消
public enum Confirm {
Scaning("0"),
Scaned("1"),
Confirmed("2"),
Cancel("3");
Confirm(String code) {
this.code = code;
}
private String code;
public String value() {
return code;
}
}
}
| [
"1372826124@qq.com"
] | 1372826124@qq.com |
7a5b82a76c50429a5c7c5fe1d044443bdfabe5bd | aa022454b738dedaf55dc6f02595af2a866b452d | /fugitive/src/libra/zz01/ZZ01_02Form.java | fec9efa68d6f0af5243ea49ff4925c7ca79ec966 | [] | no_license | pppiroto/typea-info-apps | 8e4f12a2b02fdca4409b70b6b6fff436cdb5a9a8 | f53e1403fdb807745c5bef5c278c3c9e626869a3 | refs/heads/master | 2021-01-23T22:38:37.516516 | 2011-08-26T13:24:18 | 2011-08-26T13:24:18 | 33,648,303 | 0 | 0 | null | null | null | null | SHIFT_JIS | Java | false | false | 2,258 | java | package libra.zz01;
import info.typea.fugitive.action.BeanActionForm;
import info.typea.fugitive.action.SelectOptionBean;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import libra.zz01.model.Department;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
/**
* Employee データ更新用Formクラス(サンプルプログラム)
*
* @author totec yagi
*/
public class ZZ01_02Form extends BeanActionForm {
private static final long serialVersionUID = 1L;
/**
* departments セレクトボックス表示用
*/
private List<SelectOptionBean> departments;
private String employee_id;
private FormFile upfile;
/* @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest) */
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
super.reset(mapping, request);
setUpfile(null);
}
/**
* @return Departmentのリスト
*/
public List getDepartments() {
return departments;
}
/**
* @param departments
*/
public void setDepartments(List departments) {
this.departments = new ArrayList<SelectOptionBean>();
for (int i=0; i<departments.size(); i++) {
Department dep = (Department)departments.get(i);
SelectOptionBean option = new SelectOptionBean();
option.setLabel(dep.getDepartment_name());
option.setValue(dep.getDepartment_id().toString());
this.departments.add(option);
}
}
/**
* @return Returns the employee_id.
*/
public String getEmployee_id() {
return employee_id;
}
/**
* @param employee_id The employee_id to set.
*/
public void setEmployee_id(String employee_id) {
this.employee_id = employee_id;
}
/**
* @return Returns the upfile.
*/
public FormFile getUpfile() {
return upfile;
}
/**
* @param upfile The upfile to set.
*/
public void setUpfile(FormFile upfile) {
this.upfile = upfile;
}
}
| [
"pppiroto@gmail.com@fa5f2700-41ee-11de-b910-bdabbcd8b4c7"
] | pppiroto@gmail.com@fa5f2700-41ee-11de-b910-bdabbcd8b4c7 |
44b346c13a6d0ced5c3ae1e41543306b0a5cf77d | 29196e2d4adfb14ddd7c2ca8c1e60f8c10c26dad | /src/main/java/it/csi/siac/siacfinser/frontend/webservice/MutuoService.java | ae9face1357c5710bad748be8b5647c2c42a3a38 | [] | no_license | unica-open/siacbilitf | bbeef5ceca40e9fb83d5b1176e7f54e8d84592bf | 85f3254c05c719a0016fe55cea1a105bcb6b89b2 | refs/heads/master | 2021-01-06T14:51:17.786934 | 2020-03-03T13:27:47 | 2020-03-03T13:27:47 | 241,366,581 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,915 | java | /*
*SPDX-FileCopyrightText: Copyright 2020 | CSI Piemonte
*SPDX-License-Identifier: EUPL-1.2
*/
package it.csi.siac.siacfinser.frontend.webservice;
import it.csi.siac.siacfinser.frontend.webservice.msg.AnnullaMutuo;
import it.csi.siac.siacfinser.frontend.webservice.msg.AnnullaMutuoResponse;
import it.csi.siac.siacfinser.frontend.webservice.msg.InserisceMutuo;
import it.csi.siac.siacfinser.frontend.webservice.msg.InserisceMutuoResponse;
import it.csi.siac.siacfinser.frontend.webservice.msg.RicercaMutuo;
import it.csi.siac.siacfinser.frontend.webservice.msg.RicercaMutuoPerChiave;
import it.csi.siac.siacfinser.frontend.webservice.msg.RicercaMutuoPerChiaveResponse;
import it.csi.siac.siacfinser.frontend.webservice.msg.RicercaMutuoResponse;
import it.csi.siac.siacfinser.frontend.webservice.msg.AggiornaMutuo;
import it.csi.siac.siacfinser.frontend.webservice.msg.AggiornaMutuoResponse;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.BindingType;
/**
* SI del servizio per la gestione dei mutui
*
* @author
*
*/
@WebService(targetNamespace = FINSvcDictionary.NAMESPACE, name = "MutuoService")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
public interface MutuoService extends CommonServiceInterface {
/**
*
* Operazione: Inserisce Mutuo
*
* Descrizione dell'operazione:
*
* Consente di inserire un nuovo mutuo con i dati specificati in input.
*
* @param request
* @return
*/
@WebMethod
@WebResult
InserisceMutuoResponse inserisceMutuo(@WebParam InserisceMutuo request);
/**
*
* Operazione : Aggiorna Mutuo
*
* Descrizione dell'operazione :
*
* Consente di Aggiornare :
* Consente di aggiornare alcuni dati di un Mutuo e le entità di secondo livello, con i dati specificati in input
* senza effettuare i controlli di correttezza formale dei codici e duplicazione del mutuo.
*
* Il servizio consente quindi di aggiornare un mutuo e, se l'input lo prevede, contemporaneamente:
* - Gestire il mutuo per:
* - Aggiornare un mutuo
*
* - Gestire le voci di mutuo legate al mutuo permettendo di
* - Inserire nuove voci di mutuo
* - Aggiornare le operazioni sulle voci di mutuo esistenti
* - Cancellare voci di mutuo esistenti
*
* @param request
* @return
*
*/
@WebMethod
@WebResult
AggiornaMutuoResponse aggiornaMutuo(@WebParam AggiornaMutuo request);
/**
*
* Operazione : Ricerca Mutuo
*
* Descrizione dell'operazione :
*
* Consente di ricercare più mutui attraverso una ricerca aperta.
* Questa operazione restituirà un elenco di oggetti 'mutui' immagine dell'entità.
*
* @param request
* @return
*
*/
@WebMethod
@WebResult
RicercaMutuoResponse ricercaMutuo(@WebParam RicercaMutuo request);
/**
*
* Operazione : Ricerca Mutuo Per Chiave
*
* Descrizione dell'operazione :
*
* Consente di ricercare un nuovo Mutuo e le entità di secondo livello (voci di mutuo) attraverso la sua chiave unica.
* Questa operazione così puntuale restituirà:
* <ul>
* <li>l'oggetto 'mutuo' completo anche di tutte le decodifiche e calcoli</li>
* <li>un elenco di voci di mutuo (impegni finanziati da mutuo)</li>
* </ul>
*
* @param request
* @return
*
*/
@WebMethod
@WebResult
RicercaMutuoPerChiaveResponse ricercaMutuoPerChiave(@WebParam RicercaMutuoPerChiave request);
/**
*
* Operazione : Annulla Mutuo
*
* Descrizione dell'operazione :
*
* Consente di annullare un mutuo con i dati specificati in input.
*
* @param request
* @return
*
*/
@WebMethod
@WebResult
AnnullaMutuoResponse annullaMutuo(@WebParam AnnullaMutuo request);
} | [
"michele.perdono@csi.it"
] | michele.perdono@csi.it |
ae223b9d18aee14e8d51c7c708d7326fb4a94b3f | 146fd9be4aa4ab77e982ea456f99b2f036db7460 | /android/native/mydemos/GMaps/src/com/spime/MapsActivity.java | 56909ff3b1dbbb063e1a328984d8b9790a076149 | [] | no_license | eliekozah/myexplore | 84b0be5c9f8d6b27ccdb62c3a96af150f1baa159 | 0ffe15240fbafe91852657c65b2047bcf63ab802 | refs/heads/master | 2020-05-29T22:02:14.187123 | 2016-06-24T11:00:10 | 2016-06-24T11:00:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 397 | java | package com.spime;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MapsActivity extends MapActivity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
| [
"selvaganesa@gmail.com"
] | selvaganesa@gmail.com |
a5163b35d756705233c27152de3cc65ded4b024e | b83e1faed524e7f9812a3d5f1d322b9809f75e39 | /etc/Other implementations/belote-android/src/belote/bean/announce/suit/ColorlessSuit.java | f1909cd2e207411ff977b23e0be16e842a501e15 | [
"MIT"
] | permissive | NikolayIT/BelotGameEngine | eb5854596facd464667758ad4224030d9fa6936f | c72ae9d41eeeb04b353471613d7878b918685858 | refs/heads/master | 2023-03-13T14:13:37.565035 | 2023-02-20T07:56:48 | 2023-02-20T07:56:48 | 8,382,361 | 48 | 11 | MIT | 2022-05-23T11:00:17 | 2013-02-23T21:38:36 | Java | UTF-8 | Java | false | false | 1,661 | java | /*
* Copyright (c) Dimitar Karamanov 2008-2014. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the source code must retain
* the above copyright notice and the following disclaimer.
*
* This software is provided "AS IS," without a warranty of any kind.
*/
package belote.bean.announce.suit;
/**
* TrumplessSuit class. The abstract base class of "all trump" and "not trump" announce suits.
* @author Dimitar Karamanov
*/
public abstract class ColorlessSuit extends AnnounceSuit {
/**
* SerialVersionUID
*/
private static final long serialVersionUID = -1853693277831872107L;
/**
* Game base points constant.
*/
private static final int GAME_BASE_POINTS = 26;
/**
* Constructor.
* @param type Type.
*/
protected ColorlessSuit(final int type) {
super(type);
}
/**
* Trump suit classes are Club, Diamond, Heart and Spade. If the objects is instance of some of them the result is true otherwise is false. This is the base
* class for AllTrump and NotTrump announce suits so the method result is always false.
* @return boolean true if is color suit false otherwise.
*/
public final boolean isTrumpSuit() {
return false;
}
/**
* Returns the game base points for that announce suit. The points are used in double and redouble calculation. For AllTrump and NotTrump announce suits the
* base points are the same.
* @return int belote game base points.
*/
public final int getBasePoints() {
return GAME_BASE_POINTS;
}
}
| [
"admin@nikolay.it"
] | admin@nikolay.it |
6d2622a610a7315fc9da6598cf6cce95894ee688 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XRENDERING-418-11-30-MOEAD-WeightedSum:TestLen:CallDiversity/org/xwiki/rendering/listener/chaining/AbstractChainingListener_ESTest_scaffolding.java | d25efd39826bbc26f769c6f2c35aa79eb1a57391 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 466 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Wed Apr 08 05:49:00 UTC 2020
*/
package org.xwiki.rendering.listener.chaining;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class AbstractChainingListener_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
| [
"pouria.derakhshanfar@gmail.com"
] | pouria.derakhshanfar@gmail.com |
c23883c269c08b16ee1303b5eea5a19ded02ff5f | 1682fb35af868eb9f82b90329b9327c179918a9c | /spring-boot-data-jpa-custom-repository/src/test/java/com/example/spring_boot_data_jpa_tests/user/UserRepositoryNonDataJpaAnnotationTest.java | 722361908a0fe6dc5d5bd2af7a151bd4b943fff6 | [] | no_license | simaosoares/spring-boot-examples | bf4f8305a8df123c99864a53c439204e0c8f71de | c49ffbbc75c9a41562de7dd1bde2f5a062c24364 | refs/heads/master | 2020-07-28T20:05:37.320191 | 2020-05-29T15:26:43 | 2020-05-29T15:26:43 | 209,520,828 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,298 | java | package com.example.spring_boot_data_jpa_tests.user;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.transaction.Transactional;
import java.util.List;
import static org.assertj.core.api.Java6Assertions.assertThat;
/**
* Data Jpa unit tests without the {@link DataJpaTest} annotation.
*
* Important: in order to use {@link TestEntityManager} to persist sample test data
* the {@link AutoConfigureTestEntityManager} must be added to the test class.
*/
@Transactional
@SpringBootTest
@RunWith(SpringRunner.class)
public class UserRepositoryNonDataJpaAnnotationTest {
@Autowired
protected UserRepository userRepository;
@Test
public void findDistinctNames_shouldReturnData() {
final List<String> allDistinctNames = userRepository.findAllDistinctNames();
assertThat(allDistinctNames.size()).isEqualTo(2);
}
}
| [
"s.soares@moliporex.pt"
] | s.soares@moliporex.pt |
6e3e53e3c3672bc48bbcb01a69df3cc0793cdcb4 | 4bc5e586527ed616fe10a0fc81145de8477e8f70 | /BasicArrayTest.java | a32eff04bff855bcdd9636ca44f592a07db8fa07 | [] | no_license | KimSeungTaek-95/java_practice | 5d4e2d77afad8d38fbeb67003b635b9906228f3f | a24d26ff2c4b61dbe4999b74c123932ce23a2446 | refs/heads/master | 2022-11-25T06:58:39.788087 | 2020-08-02T15:22:22 | 2020-08-02T15:22:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,278 | java | public class BasicArrayTest {
public static void main(String args[]) {
int[] scoreList; //데이터 타입으로 된 일차원 배열 선언
scoreList = new int[5]; //선언된 배열 변수에 5개의 정수를 저장할 수 있는 배열객체를 생성. 주소값 할당
scoreList[0] = 80;
scoreList[1] = 95;
scoreList[2] = 68;
scoreList[3] = 100;
scoreList[4] = 54;
System.out.println("socreList의 길이 = " + scoreList.length);
System.out.println("< scoreList 배열 요소 출력 >");
System.out.print(scoreList[0] + "\t");
System.out.print(scoreList[1] + "\t");
System.out.println(scoreList[2] + "\t");
//String 타입으로 된 일차원 배열 선언.
String nameList[];
nameList = new String[3];//3개의 문자열을 저장할 수 있는 배열 객체 생성
nameList[0] = "Java";
nameList[1] = "sql";
nameList[2] = "Servlet";
System.out.println("nameList 길이 = " + nameList.length);
System.out.println("< nameList 배열 요소 출력 >");
System.out.print(scoreList[0] + "\t");
System.out.print(scoreList[1] + "\t");
System.out.println(scoreList[2] + "\t");
}
}
| [
"0505zxc@gmail.com"
] | 0505zxc@gmail.com |
52cf39170e7edf0b0e2356aa84f6f6a642cee3a5 | d6d7dd10bb0dc0eb57f179166596c49d6185e13f | /cassandra-cql/src/main/java/org/springdata/cassandra/cql/spec/TableSpecification.java | 694d56fb71c95c450a2b635d2f2d1ac980bd9aa2 | [] | no_license | yangqiju/spring-data-cassandra | ec98ef616a084e688343e4efff0b040702d7eff8 | a08223838c2ded92932ac3a17c5efd834190223d | refs/heads/master | 2020-12-26T00:06:22.574092 | 2014-07-01T09:06:52 | 2014-07-01T09:06:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,387 | java | /*
* Copyright 2013 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.springdata.cassandra.cql.spec;
import static org.springdata.cassandra.cql.core.KeyPart.CLUSTERING;
import static org.springdata.cassandra.cql.core.KeyPart.PARTITION;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springdata.cassandra.cql.core.KeyPart;
import org.springdata.cassandra.cql.core.Ordering;
import org.springdata.cassandra.cql.option.TableOption;
import com.datastax.driver.core.DataType;
/**
* Builder class to support the construction of table specifications that have columns. This class can also be used as a
* standalone {@link TableDescriptor}, independent of {@link CreateTableSpecification}.
*
* @author Matthew T. Adams
* @author Alex Shvid
*/
public class TableSpecification<T extends WithOptionsSpecification<TableOption, T>> extends
WithOptionsSpecification<TableOption, T> implements TableDescriptor {
/**
* Ordered List of only those columns that comprise the partition key.
*/
private List<ColumnSpecification> partitionKeyColumns = new ArrayList<ColumnSpecification>();
/**
* Ordered List of only those columns that comprise the primary key that are not also part of the partition key.
*/
private List<ColumnSpecification> clusteringKeyColumns = new ArrayList<ColumnSpecification>();
/**
* List of only those columns that are not partition or primary key columns.
*/
private List<ColumnSpecification> nonKeyColumns = new ArrayList<ColumnSpecification>();
/**
* Adds the given non-key column to the table.
*
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
* @param type The data type of the column.
*/
public T column(String name, DataType type) {
return column(name, type, null, null);
}
/**
* Adds the given partition key column to the table.
*
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
* @param type The data type of the column.
* @return this
*/
public T partitionKeyColumn(String name, DataType type) {
return column(name, type, PARTITION, null);
}
/**
* Adds the given primary key column to the table with ascending ordering.
*
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
* @param type The data type of the column.
* @return this
*/
public T clusteringKeyColumn(String name, DataType type) {
return clusteringKeyColumn(name, type, null);
}
/**
* Adds the given primary key column to the table with the given ordering (<code>null</code> meaning ascending).
*
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
* @param type The data type of the column.
* @param ordering If the given {@link KeyPart} is {@link KeyPart#CLUSTERING}, then the given ordering is used, else
* ignored.
* @return this
*/
public T clusteringKeyColumn(String name, DataType type, Ordering ordering) {
return column(name, type, CLUSTERING, ordering);
}
/**
* Adds the given info as a new column to the table.
*
* @param name The column name; must be a valid unquoted or quoted identifier without the surrounding double quotes.
* @param type The data type of the column.
* @param keyPart Indicates key type. Null means that the column is not a key column.
* @param ordering If the given {@link KeyPart} is {@link KeyPart#CLUSTERING}, then the given ordering is used, else
* ignored.
* @return this
*/
@SuppressWarnings("unchecked")
protected T column(String name, DataType type, KeyPart keyPart, Ordering ordering) {
ColumnSpecification column = new ColumnSpecification().name(name).type(type).keyPart(keyPart)
.ordering(keyPart == CLUSTERING ? ordering : null);
if (keyPart == KeyPart.PARTITION) {
partitionKeyColumns.add(column);
}
if (keyPart == KeyPart.CLUSTERING) {
clusteringKeyColumns.add(column);
}
if (keyPart == null) {
nonKeyColumns.add(column);
}
return (T) this;
}
/**
* Returns an unmodifiable list of all columns. Order is important: partition key columns, clustering key columns, non
* key columns
*/
public List<ColumnSpecification> getAllColumns() {
ArrayList<ColumnSpecification> allKeyColumns = new ArrayList<ColumnSpecification>(partitionKeyColumns.size()
+ clusteringKeyColumns.size() + nonKeyColumns.size());
allKeyColumns.addAll(partitionKeyColumns);
allKeyColumns.addAll(clusteringKeyColumns);
allKeyColumns.addAll(nonKeyColumns);
return Collections.unmodifiableList(allKeyColumns);
}
/**
* Returns an unmodifiable list of all partition key columns.
*/
public List<ColumnSpecification> getPartitionKeyColumns() {
return Collections.unmodifiableList(partitionKeyColumns);
}
/**
* Returns an unmodifiable list of all primary key columns that are not also partition key columns.
*/
public List<ColumnSpecification> getClusteringKeyColumns() {
return Collections.unmodifiableList(clusteringKeyColumns);
}
/**
* Returns an unmodifiable list of all primary key columns that are not also partition key columns.
*/
public List<ColumnSpecification> getPrimaryKeyColumns() {
ArrayList<ColumnSpecification> primaryKeyColumns = new ArrayList<ColumnSpecification>(partitionKeyColumns.size()
+ clusteringKeyColumns.size());
primaryKeyColumns.addAll(partitionKeyColumns);
primaryKeyColumns.addAll(clusteringKeyColumns);
return Collections.unmodifiableList(primaryKeyColumns);
}
/**
* Returns an unmodifiable list of all non-key columns.
*/
public List<ColumnSpecification> getNonKeyColumns() {
return Collections.unmodifiableList(nonKeyColumns);
}
}
| [
"a@shvid.com"
] | a@shvid.com |
2271a5aaef7b98ed4ec69a1e05441e2f76551110 | fcdfceac19c283586b196650dc31355bc5b647a8 | /src/io/github/josehsantos/hack/ide/refactory/HackRefactoringSupportProvider.java | 8fbce2263a82822a86bbef5c080484f12c96aea2 | [
"MIT"
] | permissive | jhsx/hacklang-idea | 721f153f470b50d3aaf58618df7168bf7c68eac2 | 45d190444662c8ced0614c91f8fa7701f0936e95 | refs/heads/master | 2021-01-10T09:11:22.711843 | 2015-11-16T22:55:41 | 2015-11-16T22:55:42 | 46,169,344 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 520 | java | package io.github.josehsantos.hack.ide.refactory;
import com.intellij.lang.refactoring.RefactoringSupportProvider;
import com.intellij.psi.PsiElement;
import io.github.josehsantos.hack.lang.psi.HackVariableIdentifier;
/**
* Created by josesantos on 16/11/14.
*/
public class HackRefactoringSupportProvider extends RefactoringSupportProvider {
@Override
public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context) {
return context instanceof HackVariableIdentifier;
}
}
| [
"henrique_1609@me.com"
] | henrique_1609@me.com |
88a69a4e365ade76c459ce2e7609d5391d019a9f | a58c494ec79074390360c2d11b0b7900e6efbb23 | /app/src/main/java/com/thephoenixit/mygymclub/services/ServicesImpl.java | 54425d3e66868b1f06b78dcf1f8b6335c8c29156 | [] | no_license | ThePhoenix-IT/MyGymClub | 3d62646a95df0e18eb5ea5b99cc0e384321bbb57 | 17f2c744189551768b3580f24862dfe52af24583 | refs/heads/master | 2021-05-05T17:02:06.644993 | 2018-01-29T16:16:02 | 2018-01-29T16:16:02 | 117,338,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 314 | java | package com.thephoenixit.mygymclub.services;
import com.thephoenixit.mygymclub.models.Workout;
import java.util.Collection;
/**
* Created by root on 18/01/19.
*/
public class ServicesImpl implements IUserServices {
@Override
public Collection<Workout> getAllWorkouts() {
return null;
}
}
| [
"hamzajg@gmail.com"
] | hamzajg@gmail.com |
b3c0c084e7d93c87288cf73210a3e7075c9a7c00 | fd6d848aff383dd7f7910c0e6afa5eb97eb138bc | /Smarttech_Automation1/src/main/java/com/usa/student/myBaseClass.java | af94d4310accf2fa6b077288fab509d1ddd86e80 | [] | no_license | Mohammadhaque0301/Enamul | 8fc96e03c584c03e02c394be8ff4effbbad8e867 | f33c78d38a074d30c0510600c11647b56fa3d931 | refs/heads/master | 2023-01-06T14:51:52.982822 | 2020-10-30T23:51:24 | 2020-10-30T23:51:24 | 303,012,780 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 136 | java | package com.usa.student;
public class myBaseClass {
}
| [
"enamh@DESKTOP-9I829TP.lan"
] | enamh@DESKTOP-9I829TP.lan |
7aa9d740ba96616ede0613a5269a7aebf4cbcfb1 | dfe4f42d6ed899079866f96f5b308ca4303c5c15 | /Cars/src/Motorcycle.java | aaa9292377f30f859860355c7e3e00db51d7ebb0 | [] | no_license | cdehn/Cars | ee0a0a79737a17ca4483118f6fda41fdbc346a60 | 16114974a57784ab717dc1033ebcd063114f3f6b | refs/heads/master | 2016-09-06T18:14:30.089737 | 2014-12-07T18:54:05 | 2014-12-07T18:54:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java |
public class Motorcycle extends Vehicle implements VehicleInterface {
private boolean hasSideCar;
public Motorcycle(boolean hasSideCar) {
this.hasSideCar = hasSideCar;
}
public boolean gethasSideCar(){
return hasSideCar;
}
public void sethasSideCar(boolean sideCar){
this.hasSideCar = sideCar;
}
}
| [
"cdehn@udel.edu"
] | cdehn@udel.edu |
adaaa3a53952f962d67803fffb102a2346087a51 | 92fb8f20138bbe2ae6226b30ba628485cfa88084 | /src/controller/EditDuAnAdminController.java | f88257288e89b8c2f714920f28e7d36f145cc8c3 | [] | no_license | 2ongvinh/Aboutme | a4645a28ee339480bec38fa4b3623e199c0a2bb5 | 21cf7c2a20fcb3ae98256d475612842104899bb4 | refs/heads/master | 2021-01-13T14:05:34.620320 | 2016-12-11T19:11:46 | 2016-12-11T19:11:46 | 76,176,702 | 0 | 0 | null | 2016-12-11T19:09:47 | 2016-12-11T13:41:26 | JavaScript | UTF-8 | Java | false | false | 4,273 | java | package controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Timestamp;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
import library.CheckLoginLibrary;
import library.FileNameLibrary;
import library.RenameFileLibrary;
import model.bean.DanhMucTin;
import model.bean.DanhNgon;
import model.bean.DuAn;
import model.bean.Gioithieu;
import model.bean.TinTuc;
import model.bean.Users;
import model.dao.DanhMucTinDAO;
import model.dao.DanhNgonDAO;
import model.dao.DuAnDAO;
import model.dao.GioithieuDAO;
import model.dao.TinTucDAO;
import model.dao.UsersDAO;
/**
* Servlet implementation class EditCatAdminController
*/
// @WebServlet("/EditCatAdminController")
@MultipartConfig
public class EditDuAnAdminController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public EditDuAnAdminController() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
// response.getWriter().append("Served at:
// ").append(request.getContextPath());
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
// doGet(request, response);
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
if (!CheckLoginLibrary.CheckLogin(request, response)) {
return;
}
HttpSession session = request.getSession();
Users user = (Users) session.getAttribute("userInfo");
if (user.getIdCapbac() == 1) {
int idDA1 = Integer.parseInt(request.getParameter("id"));
DuAnDAO duanDAO = new DuAnDAO();
String tenduan = request.getParameter("tenduan");
String mota = request.getParameter("mota");
String link = request.getParameter("link");
String picture = "";
final String path = request.getServletContext().getRealPath("files");
File dirFile = new File(path);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
final Part filePart = request.getPart("hinhanh");
final String fileName = FileNameLibrary.getFileName(filePart);
if (!"".equals(fileName)) {
OutputStream out = null;
InputStream filecontent = null;
picture = RenameFileLibrary.renameFile(fileName);
String picture_old = duanDAO.getItemByID(idDA1).getHinhanhDuan();
if (!"".equals(picture_old)) {
String urlDelFile = path + File.separator + picture_old;
File delFile = new File(urlDelFile);
delFile.delete();
}
try {
out = new FileOutputStream(path + File.separator + picture);
filecontent = filePart.getInputStream();
int read = 0;
final byte[] bytes = new byte[1024];
while ((read = filecontent.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
} catch (FileNotFoundException fne) {
fne.printStackTrace();
} finally {
if (out != null) {
out.close();
}
if (filecontent != null) {
filecontent.close();
}
}
} else {
picture = duanDAO.getItemByID(idDA1).getHinhanhDuan();
}
DuAn objDA = new DuAn(idDA1, tenduan, mota, picture, link);
if (duanDAO.editItem(objDA) > 0) {
response.sendRedirect(request.getContextPath() + "/admin/duan?msg=2");
return;
} else {
response.sendRedirect(request.getContextPath() + "/admin/duan?msg=0");
return;
}
} else {
response.sendRedirect(request.getContextPath() + "/admin/duan?msg=0");
}
}
}
| [
"trannhatvinh88@gmail.com"
] | trannhatvinh88@gmail.com |
1403602a1aa39c89c51f79cda4502dceb5497fb6 | 6a10bb16aca4bf349072ce8efffed269910c7459 | /app/src/main/java/com/sportsv/vo/Mission.java | b01e05613be2ff63b88a07b2e3181f474faa5fc8 | [] | no_license | ishimsungbo/sportsv | 74c34865bdbbc76a012858cc5eda03feafd26eab | c873c719b7313f556d6065ff50ef773e51c0b0df | refs/heads/master | 2020-12-25T05:36:01.850207 | 2016-07-11T09:20:20 | 2016-07-11T09:20:20 | 59,982,456 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,731 | java | package com.sportsv.vo;
public class Mission {
private int missionid;
private int categoryid;
private int typeid;
private int sequence;
private String missionname;
private String description;
private String precon;
private String videoaddr;
private String fullyoutubeaddr;
private String youtubeaddr;
private String enabled;
private String feetype;
private int grade; //미션업로드점수
private int passgrade; //미션클리어점수
private String creationdate;
private String updatedate;
private String change_creationdate;
private String change_updatedate;
public Mission(){}
public Mission(int missionid, int categoryid, int typeid, int sequence, String missionname, String description, String precon, String videoaddr, String fullyoutubeaddr, String youtubeaddr, String enabled, String feetype, int grade, int passgrade, String creationdate, String updatedate, String change_creationdate, String change_updatedate) {
this.missionid = missionid;
this.categoryid = categoryid;
this.typeid = typeid;
this.sequence = sequence;
this.missionname = missionname;
this.description = description;
this.precon = precon;
this.videoaddr = videoaddr;
this.fullyoutubeaddr = fullyoutubeaddr;
this.youtubeaddr = youtubeaddr;
this.enabled = enabled;
this.feetype = feetype;
this.grade = grade;
this.passgrade = passgrade;
this.creationdate = creationdate;
this.updatedate = updatedate;
this.change_creationdate = change_creationdate;
this.change_updatedate = change_updatedate;
}
@Override
public String toString() {
return "Mission{" +
"missionid=" + missionid +
", categoryid=" + categoryid +
", typeid=" + typeid +
", sequence=" + sequence +
", missionname='" + missionname + '\'' +
", description='" + description + '\'' +
", precon='" + precon + '\'' +
", videoaddr='" + videoaddr + '\'' +
", fullyoutubeaddr='" + fullyoutubeaddr + '\'' +
", youtubeaddr='" + youtubeaddr + '\'' +
", enabled='" + enabled + '\'' +
", feetype='" + feetype + '\'' +
", grade=" + grade +
", passgrade=" + passgrade +
", creationdate='" + creationdate + '\'' +
", updatedate='" + updatedate + '\'' +
", change_creationdate='" + change_creationdate + '\'' +
", change_updatedate='" + change_updatedate + '\'' +
'}';
}
public int getMissionid() {
return missionid;
}
public void setMissionid(int missionid) {
this.missionid = missionid;
}
public int getCategoryid() {
return categoryid;
}
public void setCategoryid(int categoryid) {
this.categoryid = categoryid;
}
public int getTypeid() {
return typeid;
}
public void setTypeid(int typeid) {
this.typeid = typeid;
}
public int getSequence() {
return sequence;
}
public void setSequence(int sequence) {
this.sequence = sequence;
}
public String getMissionname() {
return missionname;
}
public void setMissionname(String missionname) {
this.missionname = missionname;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPrecon() {
return precon;
}
public void setPrecon(String precon) {
this.precon = precon;
}
public String getVideoaddr() {
return videoaddr;
}
public void setVideoaddr(String videoaddr) {
this.videoaddr = videoaddr;
}
public String getFullyoutubeaddr() {
return fullyoutubeaddr;
}
public void setFullyoutubeaddr(String fullyoutubeaddr) {
this.fullyoutubeaddr = fullyoutubeaddr;
}
public String getYoutubeaddr() {
return youtubeaddr;
}
public void setYoutubeaddr(String youtubeaddr) {
this.youtubeaddr = youtubeaddr;
}
public String getEnabled() {
return enabled;
}
public void setEnabled(String enabled) {
this.enabled = enabled;
}
public String getFeetype() {
return feetype;
}
public void setFeetype(String feetype) {
this.feetype = feetype;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public int getPassgrade() {
return passgrade;
}
public void setPassgrade(int passgrade) {
this.passgrade = passgrade;
}
public String getCreationdate() {
return creationdate;
}
public void setCreationdate(String creationdate) {
this.creationdate = creationdate;
}
public String getUpdatedate() {
return updatedate;
}
public void setUpdatedate(String updatedate) {
this.updatedate = updatedate;
}
public String getChange_creationdate() {
return change_creationdate;
}
public void setChange_creationdate(String change_creationdate) {
this.change_creationdate = change_creationdate;
}
public String getChange_updatedate() {
return change_updatedate;
}
public void setChange_updatedate(String change_updatedate) {
this.change_updatedate = change_updatedate;
}
}
| [
"ishimsungbo@gmail.com"
] | ishimsungbo@gmail.com |
4b85a1576d366f0c302f2893f499ebf3ff7a0a32 | a08d478e9df9299852c3dec90d1cf25637fe9731 | /app/src/test/java/sequality/AppTest.java | 68c63b1097973cc59755e8a3c1b6f6da948e9c5b | [] | no_license | m1m21a29/sequality | 5f5d958b443f2e84058ffdf7ab133eff68184c21 | ee9a5cb9150e8153f82d7f028e93b92481b4a0ae | refs/heads/main | 2023-06-16T07:45:15.277251 | 2021-07-12T06:48:20 | 2021-07-12T06:48:20 | 385,084,340 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 512 | java | /*
* This Java source file was generated by the Gradle 'init' task.
*/
package sequality;
import org.junit.Test;
import static org.junit.Assert.*;
public class AppTest {
@Test public void testAppHasAGreeting() {
App classUnderTest = new App();
assertNotNull("app should have a greeting", classUnderTest.getGreeting());
}
@Test public void testAppReternHelloWorld() {
App classUnderTest = new App();
assertEquals("Hello World!", classUnderTest.getGreeting());
}
}
| [
"m1m21a29@oit.ac.jp"
] | m1m21a29@oit.ac.jp |
7e0dfe1dcfdf003f238247771ebecb55bda356d4 | 5f9cbddbe98d3b1ee357aa5b077b9fd1abe7c43b | /src/day20_ForLoop/timer.java | 9a325c4ce2f6a3a45fada22834131e36c14c55b9 | [] | no_license | Chanidapaczaj20/JavaProgrmming2020_B21 | 7f3755570e39e6ad90d0bfc6ae0c262ec8bf58b7 | 37a23e75f878310f94cb966ea9389e8c9db05885 | refs/heads/master | 2023-03-01T23:55:00.840832 | 2021-02-02T04:29:26 | 2021-02-02T04:29:26 | 319,807,307 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,077 | java | package day20_ForLoop;
import java.util.Scanner;
public class timer {
public static void main(String[] args) throws InterruptedException {
Scanner scan = new Scanner(System.in);
System.out.println("please enter the number of minutes");
int minutes = scan.nextInt();
for (int i = minutes; i > 0; --i) {
if (i < 0) {
break;
}
for (int z = 59; z >= 0; --z) {
System.out.println((i - 1) + " minutes and " + z + " seconds left");
Thread.sleep(1000);
}
}
System.out.println();
System.err.println("\t\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *");
System.err.println("\t\t\t* *");
System.err.println("\t\t\t* Times is Up, Please take your seats! *");
System.err.println("\t\t\t* *");
System.err.println("\t\t\t* * * * * * * * * * * * * * * * * * * * * * * * * *");
}
} | [
"70244412+Chanidapaczaj20@users.noreply.github.com"
] | 70244412+Chanidapaczaj20@users.noreply.github.com |
38ae6e4e9632cb04cfab792fd86f390ede408e63 | 4106174f1c941dd01c5c3e545f2e09cc20a86df6 | /src/mathLib/statistics/Average.java | 98efe1efa3cef27fe63e293fca497a469a576133 | [
"MIT"
] | permissive | softish/Garage | 5eac24d1f44a983647b0bc19abe961a6c1509a57 | acd59067b815f5d6722a5d3b61d73eb5f433122e | refs/heads/master | 2021-01-17T17:33:12.590577 | 2016-07-31T16:31:28 | 2016-07-31T16:31:28 | 61,207,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,925 | java | package mathLib.statistics;
import mathLib.EmptyArrayException;
import mathLib.Sorter;
/**
* Created by softish on 2016-06-15.
*/
public class Average {
/**
* Calculates the arithmetic mean of a set of values.
*
* @param values the values
* @return the arithmetic mean
* @throws EmptyArrayException if values are em
*/
public static double arithmeticMean(double... values) {
double x = 0;
if(values == null || values.length == 0) {
throw new EmptyArrayException();
}
for(Double value : values) {
x += value;
}
return x / values.length;
}
public static double median(double... values) {
double x = 0;
Sorter sorter = new Sorter(values);
values = sorter.selectionSort();
if(values.length % 2 == 1) {
x = values[values.length / 2];
} else {
int lesser = (int) Math.floor(values.length / 2);
int greater = (int) Math.ceil(values.length / 2);
x = arithmeticMean(values[lesser], values[greater]);
}
return x;
}
public static double mode(double... values) {
// possible strategies: replace with bucketsortstyleapproach
double mode = 0;
int occurrences = 0;
int oldOccurrences = 0;
for(int i = 0; i < values.length; i++) {
for(int j = 0; j < values.length; j++) {
if(i != j) {
if(values[i] == values[j]) {
occurrences++;
// W: inefficient
if(occurrences > oldOccurrences) {
mode = values[j];
oldOccurrences = occurrences;
}
}
}
}
occurrences = 0;
}
return mode;
}
}
| [
"lazar.h.klincov@live.se"
] | lazar.h.klincov@live.se |
dce012081038598db38237819b35a4e3e12deca0 | 52f8641eb97c9d4edc197842771f849dba5ca0d0 | /Tree/B1991.java | 672e55bb5c6ea10d4aea17781969189b8c963089 | [] | no_license | hjy5421/Algorithm | 56405bc2465599c2123b7d53552b31398c30ff96 | 5900dee7b344026232ba7826e221c908dc364b92 | refs/heads/master | 2023-06-11T03:11:49.467361 | 2021-07-01T12:10:03 | 2021-07-01T12:10:03 | 288,932,513 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,712 | java | package Tree;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class B1991 {
static ArrayList<Character>[] tree;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
tree = new ArrayList[N];
for (int i = 0; i < N; i++) {
tree[i] = new ArrayList<>();
}
for (int i = 0; i < N; i++) {
String s = br.readLine();
StringTokenizer st = new StringTokenizer(s);
char root = st.nextToken().charAt(0);
char left = st.nextToken().charAt(0);
char right = st.nextToken().charAt(0);
tree[root - 'A'].add(left);
tree[root - 'A'].add(right);
}
preorder('A');
System.out.println();
order('A');
System.out.println();
postorder('A');
System.out.println();
}
public static void preorder(char node) {
if (node == '.')
return;
System.out.print(node);
preorder(tree[node - 'A'].get(0));
preorder(tree[node - 'A'].get(1));
}
public static void order(char node) {
if (node == '.')
return;
order(tree[node - 'A'].get(0));
System.out.print(node);
order(tree[node - 'A'].get(1));
}
public static void postorder(char node) {
if (node == '.')
return;
postorder(tree[node - 'A'].get(0));
postorder(tree[node - 'A'].get(1));
System.out.print(node);
}
}
| [
"hjy5421@naver.com"
] | hjy5421@naver.com |
83dc252ffecb1770b73ff5020c3abb10562c33d6 | fe8d56b8afa10b5af5fa75751d149442c3ca4c3b | /src/main/java/com/teammetallurgy/atum/world/biome/BiomeDriedRiver.java | 29f7019b671b5366c97bb7474ce09522e9de4ce3 | [] | no_license | RebelKeithy/Atum2 | b0fb4a16180b0ecde324a061e75dff15e19cad23 | 2073f4cfc0a50da3d7297044749bb6631c1338ad | refs/heads/master | 2023-05-25T19:15:21.698510 | 2018-12-05T05:46:26 | 2018-12-05T05:46:26 | 159,953,990 | 0 | 0 | null | 2018-12-05T18:40:24 | 2018-12-01T14:43:54 | Java | UTF-8 | Java | false | false | 481 | java | package com.teammetallurgy.atum.world.biome;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.world.biome.base.AtumBiome;
public class BiomeDriedRiver extends AtumBiome {
public BiomeDriedRiver(AtumBiomeProperties properties) {
super(properties);
this.topBlock = AtumBlocks.LIMESTONE_GRAVEL.getDefaultState();
this.fillerBlock = AtumBlocks.LIMESTONE_CRACKED.getDefaultState();
this.deadwoodRarity = -1;
}
} | [
"girafi0@gmail.com"
] | girafi0@gmail.com |
4f7ea765ec70c995407cc770be63217071b96cab | 1d1b2b52cbef74b9cfecb67575481a5c978b6780 | /app/src/main/java/com/juanmorales/mascotasrv/adapter/PagerAdapter.java | 1296982ccd814dc11570858976a6be6b13735490 | [] | no_license | solrac02/MascotasPersistencia | 227acde98b6f26bc3dcaae4e9c57a765114e31d1 | eb85ac39699f1dd9cff0d312aefa4192a12df06b | refs/heads/master | 2021-01-16T21:29:18.516061 | 2016-08-08T07:32:11 | 2016-08-08T07:32:11 | 65,182,409 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package com.juanmorales.mascotasrv.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.ArrayList;
/**
* Created by juan.morales on 02/08/2016.
*/
public class PagerAdapter extends FragmentPagerAdapter {
private ArrayList<Fragment> fragments;
public PagerAdapter(FragmentManager fm, ArrayList<Fragment> fragments){
super(fm);
this.fragments = fragments;
}
public Fragment getItem(int position){
return fragments.get(position);
}
public int getCount(){
return fragments.size();
}
}
| [
"solrac.jcma@gmail.com"
] | solrac.jcma@gmail.com |
0991f86b347de55117f13e31a312d9d4f636c16c | 097220d22e594c85a1b0ce65f7e656244c878fed | /src/main/java/com/dio/bootcamp/santander/entities/Empresa.java | b940ac841f87a322e6d1313c83981538aa165c5c | [] | no_license | luisEdumatos/dio_controlepontos | c634c876b49003d1dcf56d6bfd87e8e8fd6a3d70 | c65d87285c94ec447cbf697689cc0d5d5fcaa46e | refs/heads/master | 2023-06-21T16:33:33.124866 | 2021-07-22T18:43:46 | 2021-07-22T18:43:46 | 387,862,016 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package com.dio.bootcamp.santander.entities;
import lombok.*;
import org.hibernate.envers.Audited;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Entity
@Audited
public class Empresa {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String descricao;
private String cnpj;
private String endereco;
private String bairo;
private String cidade;
private String estado;
private String telefone;
}
| [
"luisedu.unifal@gmail.com"
] | luisedu.unifal@gmail.com |
548cc800c55dcf3c5b05a7093790ae1ed0fb59a2 | 27569fa7caf8a24a2d0c49adcea6e35ce0866050 | /estore/src/com/briup/dao/impl/IOrderDaoImpl.java | dcf3c634ab57217403fba68018cb0fffa6689391 | [] | no_license | zweros/java | 05dcd821907655152e899836f5471a29ce051883 | a17c03e3df7de900abb214720a51ed24d5e3b6a2 | refs/heads/master | 2020-03-27T04:35:49.538742 | 2019-02-01T14:29:14 | 2019-02-01T14:29:14 | 145,952,866 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,041 | java | package com.briup.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import com.briup.bean.Customer;
import com.briup.bean.OrderForm;
import com.briup.bean.OrderLine;
import com.briup.common.exception.OrderServiceException;
import com.briup.common.util.GetConnection;
import com.briup.dao.IOrderDao;
public class IOrderDaoImpl implements IOrderDao{
@Override
public void saveOrder(OrderForm order) throws OrderServiceException {
try {
Customer cust = order.getCus();
Connection conn = GetConnection.getConnection();
//保存订单的提交地址
String sql ="insert into tbl_shipaddress(adres,phoneNumber,shipuname,customer_id) values(?,?,?,?)";
PreparedStatement ps =conn.prepareStatement(sql);
ps.setString(1, order.getSadres().getAdres());
ps.setString(2, order.getSadres().getPhone());
ps.setString(3, order.getSadres().getShipuname());
ps.setLong(4, cust.getId());
ps.execute();
ps.close();
//获取提交地址的ID
sql ="select shipaddress_id from tbl_shipaddress where adres=? ";
ps=conn.prepareStatement(sql);
ps.setString(1,order.getSadres().getAdres() );
ResultSet set =ps.executeQuery();
long shipAdd_id =0;
while(set.next()){
shipAdd_id=set.getLong(1);
break;
}
ps.close();
//保存订单本身
String sql1 ="insert into tbl_orderform(cost,orderDate,customer_id,shipaddress_id) values(?,?,?,?)";
ps =conn.prepareStatement(sql1);
ps.setDouble(1, order.getCost());
ps.setDate(2, new java.sql.Date(order.getOrderdate().getTime()));
ps.setLong(3, cust.getId());
ps.setLong(4,shipAdd_id);
ps.execute();
sql1="select orderform_id from tbl_orderform where orderDate=?";
ps = conn.prepareStatement(sql1);
ps.setDate(1,new java.sql.Date(order.getOrderdate().getTime()));
ResultSet set1 =ps.executeQuery();
long orderform_id =0;
while(set1.next()){
orderform_id=set1.getLong("orderform_id");
}
//保存订单细节
String sql2 ="insert into tbl_orderline(num,book_id,orderform_id) values(?,?,?)";
ps =conn.prepareStatement(sql2);
for(OrderLine line : order.getLines()){
ps.setInt(1, line.getNum());
ps.setLong(2, line.getBook().getId());
ps.setLong(3, orderform_id);
ps.execute();
}
}
catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void delOrder(Long orderid) throws OrderServiceException {
// TODO Auto-generated method stub
}
@Override
public Map<Long, OrderForm> listAllOrder(Long customerid)
throws OrderServiceException {
// TODO Auto-generated method stub
return null;
}
@Override
public OrderForm findOrderById(Long orderid) throws OrderServiceException {
// TODO Auto-generated method stub
return null;
}
}
| [
"414356480@qq.com"
] | 414356480@qq.com |
8166ac28752d4a58f1d67d518b0414b59812ca64 | 8dc80ed8511b5f53be67ed7f015d9fd526c25bd2 | /KoreaProblem/problem/Korea/choi/Endless.java | e4fbe276cea478abb5b10b420b637646e6b8c3e5 | [] | no_license | ChoiWoongJin/Algorithm_Practice | 0315abd8460b56a969cad3af734e83c28d430ab6 | 0d20acab2a832edfc4a0a2151a7592e21ba2f551 | refs/heads/master | 2021-09-03T16:51:04.657791 | 2018-01-10T15:25:53 | 2018-01-10T15:25:53 | 103,385,800 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,952 | java | package problem.Korea.choi;
import java.util.Scanner;
// 너무 큰 값을 넣으면 OOME 발생
public class Endless {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String firstInput = sc.nextLine(); // 계속 변화함
String stringS = sc.nextLine(); // 불변
char[] charS = stringS.toCharArray(); // 불변
int repeatNumber = Integer.parseInt(sc.nextLine());
int min = Integer.parseInt(sc.next());
int max = Integer.parseInt(sc.next());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < repeatNumber; i++) {
for (char c : charS) {
if (c == '$') {
sb.append(firstInput);
} else {
sb.append(c);
}
}
firstInput = sb.toString();
sb.delete(0, sb.length()); // sb 초기화
}
sc.close();
System.out.println(firstInput.substring(min-1, max));
}
}
/*
* 문제 김지민이 Endless란 프로그램을 만들었다. 맨 처음 이 프로그램을 실행시킬 때는, 어떤 문자열을 입력으로 받는다. 그 이후에는 그
* 전 실행의 출력이 이번 실행의 입력이 된다.
*
* 처음에 입력되는 문자열은 알파벳 소문자로만 이루어져 있다.
*
* 이 Endless 프로그램이 하는 일은 다음과 같다. 어떤 문자열 S가 정의되어 있다. 이 문자열 S는 알파벳 소문자와 ‘$’로 이루어져
* 있다. 이제 S에서 ‘$’를 입력으로 들어온 문자열로 모두 바꾼 후에 출력한다.
*
* 예를 들어, 처음 입력이 “a”이고, 문자열 S가 “$meric$”라고 하자.
*
* 그럼 처음 실행될 때는 “america”가 출력된다. 그리고 그 다음 실행 될 때는 그 전의 출력된 문자열이 입력으로 쓰이므로,
* “americamericamerica”가 출력될 것이다.
*
* 처음 입력 문자열과, 문자열 S, 그리고 이 프로그램을 실행 시킬 횟수가 주어질 때, min번째 문자부터 max번째 문자까지 출력하는
* 프로그램을 작성하시오.
*
*
* 입력 첫째 줄에 이 프로그램의 처음 입력이 주어진다. 길이는 최대 50이다. 둘째 줄에는 문자열 S가 주어진다. 길이는 2보다 크거나
* 같고, 50보다 작거나 같고, 가장 첫 문자는 항상 ‘$’이다. 셋째 줄에는 실행 시킬 횟수가 주어지며, 1000000000보다 작거나
* 같은 자연수이다 마지막 줄에는 min과 max가 주어진다. min은1000000000보다 작거나 같은 자연수이고, max는 min보다
* 크거나 같고, min+99보다 작거나 같은 자연수이다.
*
* 출력 첫째 줄에 문제의 정답을 출력한다. 만약 해당하는 문자가 없을 때는 ‘-‘를 대신 출력한다.
*
* 예제 입력 abc $x$y$z$ 10 30 50 예제 출력 bcyabcxabcyabczabczab
*
* 문제출처 : https://www.acmicpc.net/problem/1055
*/ | [
"asus@DESKTOP-MPDMUUP"
] | asus@DESKTOP-MPDMUUP |
67578f39e3bb400510ac00ded85997f72385a2a7 | 4b4dc407080d4809ee945ff9a21276ec25404316 | /bateponto/src/main/java/com/projecto/bateponto/ServletInitializer.java | f0d6f8f5eba08dbd6f934f0404d0e406288bf229 | [] | no_license | kukibravo/bateponto | ca1692c6364ff8ce2c926f38fe8f357960402bfc | 099ed38abe8e15809493dd8c5c9bba392cf92b22 | refs/heads/master | 2023-03-23T19:57:21.241220 | 2021-03-21T20:14:37 | 2021-03-21T20:14:37 | 349,697,069 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package com.projecto.bateponto;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BatepontoApplication.class);
}
}
| [
"lazarodjanilson@gmail.com"
] | lazarodjanilson@gmail.com |
4c67718acd32a2ccce009a1892aa4bf1b0ee0619 | 5914e912a9bd6dbcdeac4dacc24400efaf2f7cb1 | /src/ExercJG/Java8_Livro/cap6/testeExerc05.java | 7d90016f7f4cc79f406430059b04e0435c403e02 | [] | no_license | AlexSouzaSilvax/CursoJava | ee4e98bb180c002f78a6dc7c39633d4ae270c92c | 0746cd1b641db80acb1a108242bc81aaf4d50609 | refs/heads/master | 2020-04-12T10:18:43.494218 | 2018-12-19T11:13:06 | 2018-12-19T11:13:06 | 162,425,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 595 | java | package ExercJG.Java8_Livro.cap6;
public class testeExerc05 {
public static void main(String[] args) {
int[] array1 = {10, 20, 30, 40, 50};
int[] array2 = {60, 70, 80, 10, 90};
System.out.println("Quantidade encontrada: " + Pag106Exerc05.buscarNumero(array1, array2, 10));
int[] array3 = Pag106Exerc05.gerarArray(12);
System.out.println("-----------------");
System.out.println("Valores gerados no Array:");
for (int i = 0; i < array3.length; i++) {
System.out.println(array3[i]);
}
}
}
| [
"alexsouza8045@gmail.com"
] | alexsouza8045@gmail.com |
1292ac957073aafdd7aa344dd5dfc7baf18329e5 | 36779e6fbd26233be5e636e8cc01e27fa5e0366b | /ccl-plugin/CoCons/src/org/cocons/argo/cognitive/critics/test/AllTest.java | 7e9a36b2cf281b19102edbd4ae4b45959ad7ddbe | [] | no_license | BackupTheBerlios/ccl-plugin | 0e01b1a010cb03cddc2528d41f14cca9a2858d37 | 9be0fac3a3c95c362b3defb956302976b55d7870 | refs/heads/master | 2016-09-06T15:22:47.637350 | 2003-07-12T18:48:29 | 2003-07-12T18:48:29 | 40,255,269 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 803 | java | package org.cocons.argo.cognitive.critics.test;
import junit.framework.TestSuite;
import junit.framework.Test;
/**
* Title: AllTest.java
* Description: The AllTest Class running all TestCase this package.
* Copyright: Copyright (c) 2001
* Company: TU-Berlin, CIS
* @author Philipp Schumacher, Fadi Chabarek
* @version 1.0
*/
public class AllTest {
/**
* Runs all test cases in this package.
*/
public static void main(String[] args) {
junit.swingui.TestRunner.run(AllTest.class);
}
/**
* Returns a test suite containing all test cases of this package.
*/
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TestCrSetToValueIn.class);
//suite.addTestSuite(org.cocons.argo.cognitive.critics.test.TestXXX.class);
return suite;
}
} | [
"fchabar"
] | fchabar |
141b4c38e332dc5fc871eb05e9cfa38a4896ed6e | 8b6b6b1ce0c40ff6bb8821ce9a647c1fb2ecfdb5 | /branches/trent-tests/src/org/alliance/launchers/OSInfo.java | 4cf8e3e0f4ee807466b8519af36802e07cd76cb1 | [] | no_license | DeathfireD/AllianceP2P | 601f955701d6be89d2bd8d747ee81cf981e72a31 | 9cfe7bc69e7f5a641e72f5255f7e888f1f880e9c | refs/heads/master | 2020-05-18T19:05:36.150536 | 2017-11-30T03:13:31 | 2017-11-30T03:13:31 | 10,271,468 | 6 | 7 | null | null | null | null | UTF-8 | Java | false | false | 804 | java | package org.alliance.launchers;
/**
* Created by IntelliJ IDEA.
* User: maciek
* Date: 2006-jun-07
* Time: 10:35:53
*/
public class OSInfo {
private static boolean supportsTrayIcon;
public static boolean supportsTrayIcon() {
return supportsTrayIcon;
}
public static boolean isLinux() {
return System.getProperty("os.name").toUpperCase().indexOf("LINUX") != -1;
}
public static boolean isWindows() {
return System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
}
public static boolean isMac() {
return System.getProperty("os.name").toUpperCase().indexOf("MAC") != -1;
}
/* This is set when starting alliance */
public static void setSupportsTrayIcon(boolean b) {
supportsTrayIcon = b;
}
}
| [
"DeathfireD@gmail.com"
] | DeathfireD@gmail.com |
13c28afa020b551ea759931e749194be9b49518b | a5d01febfd8d45a61f815b6f5ed447e25fad4959 | /Source Code/5.27.0/sources/com/iqoption/deposit/b/k.java | a9a9e85d2fb9174a2578eee5a4b66a6f09544e17 | [] | no_license | kkagill/Decompiler-IQ-Option | 7fe5911f90ed2490687f5d216cb2940f07b57194 | c2a9dbbe79a959aa1ab8bb7a89c735e8f9dbc5a6 | refs/heads/master | 2020-09-14T20:44:49.115289 | 2019-11-04T06:58:55 | 2019-11-04T06:58:55 | 223,236,327 | 1 | 0 | null | 2019-11-21T18:17:17 | 2019-11-21T18:17:16 | null | UTF-8 | Java | false | false | 3,371 | java | package com.iqoption.deposit.b;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.ContentLoadingProgressBar;
import androidx.databinding.ViewDataBinding;
import com.iqoption.core.ui.widget.time.TimeTextView;
/* compiled from: FragmentDepositCryptoRequisitesBinding */
public abstract class k extends ViewDataBinding {
@NonNull
public final ConstraintLayout cBA;
@NonNull
public final ScrollView cBB;
@NonNull
public final ContentLoadingProgressBar cBC;
@NonNull
public final View cBD;
@NonNull
public final TextView cBE;
@NonNull
public final TextView cBF;
@NonNull
public final TextView cBG;
@NonNull
public final TimeTextView cBH;
@NonNull
public final Barrier cBI;
@NonNull
public final View cBJ;
@NonNull
public final bj cBc;
@NonNull
public final TextView cBk;
@NonNull
public final CardView cBl;
@NonNull
public final TextView cBm;
@NonNull
public final ImageView cBn;
@NonNull
public final View cBo;
@NonNull
public final LinearLayout cBp;
@NonNull
public final LinearLayout cBq;
@NonNull
public final TextView cBr;
@NonNull
public final TextView cBs;
@NonNull
public final TextView cBt;
@NonNull
public final View cBu;
@NonNull
public final TextView cBv;
@NonNull
public final TextView cBw;
@NonNull
public final ImageView cBx;
@NonNull
public final CardView cBy;
@NonNull
public final ImageView cBz;
protected k(Object obj, View view, int i, TextView textView, CardView cardView, TextView textView2, ImageView imageView, View view2, LinearLayout linearLayout, LinearLayout linearLayout2, TextView textView3, TextView textView4, TextView textView5, View view3, TextView textView6, TextView textView7, ImageView imageView2, CardView cardView2, ImageView imageView3, ConstraintLayout constraintLayout, ScrollView scrollView, ContentLoadingProgressBar contentLoadingProgressBar, View view4, TextView textView8, TextView textView9, TextView textView10, TimeTextView timeTextView, Barrier barrier, bj bjVar, View view5) {
super(obj, view, i);
this.cBk = textView;
this.cBl = cardView;
this.cBm = textView2;
this.cBn = imageView;
this.cBo = view2;
this.cBp = linearLayout;
this.cBq = linearLayout2;
this.cBr = textView3;
this.cBs = textView4;
this.cBt = textView5;
this.cBu = view3;
this.cBv = textView6;
this.cBw = textView7;
this.cBx = imageView2;
this.cBy = cardView2;
this.cBz = imageView3;
this.cBA = constraintLayout;
this.cBB = scrollView;
this.cBC = contentLoadingProgressBar;
this.cBD = view4;
this.cBE = textView8;
this.cBF = textView9;
this.cBG = textView10;
this.cBH = timeTextView;
this.cBI = barrier;
this.cBc = bjVar;
setContainedBinding(this.cBc);
this.cBJ = view5;
}
}
| [
"yihsun1992@gmail.com"
] | yihsun1992@gmail.com |
dd85a438b0b3bf21e535dfb4c46deaa7d275ef73 | a5ee38ed3cebc9b7e3e3db96b936c63aae5b6154 | /spring_rest/src/main/java/org/springsource/cloudfoundry/mvc/web/WebMvcConfiguration.java | 1ddd74a1125662281cb86340af6c052682d8862c | [] | no_license | soen79/soen79-sandbox | 10e9618919f98079d0d24b2f300d586b63069881 | a15bcc8f4ea36a28ed1a2b1686912cc9018d2ffe | refs/heads/master | 2022-12-22T17:53:54.151982 | 2021-01-21T23:22:11 | 2021-01-21T23:22:11 | 14,345,123 | 0 | 0 | null | 2022-12-16T02:18:04 | 2013-11-12T21:08:29 | JavaScript | UTF-8 | Java | false | false | 2,639 | java | package org.springsource.cloudfoundry.mvc.web;
import org.apache.log4j.Logger;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import org.springsource.cloudfoundry.mvc.services.config.ServicesConfiguration;
@Configuration
@EnableWebMvc
@Import(ServicesConfiguration.class)
@ComponentScan
public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
static Logger log = Logger.getLogger(WebMvcConfiguration.class);
@Bean
public InternalResourceViewResolver internalResourceViewResolver() {
InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
internalResourceViewResolver.setViewClass(JstlView.class);
internalResourceViewResolver.setPrefix("/WEB-INF/views/");
internalResourceViewResolver.setSuffix(".jsp");
return internalResourceViewResolver;
}
@Bean
public MessageSource messageSource() {
String[] baseNames = "messages".split(",");
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
resourceBundleMessageSource.setBasenames(baseNames);
return resourceBundleMessageSource;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
log.debug("ADDING resourceHandlerRegistry" + registry.toString());
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
registry.addResourceHandler("/assets/**").addResourceLocations("/assets/").setCachePeriod(31556926);
registry.addResourceHandler("/css/**").addResourceLocations("/css/").setCachePeriod(31556926);
registry.addResourceHandler("/img/**").addResourceLocations("/img/").setCachePeriod(31556926);
registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(31556926);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("customers");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
| [
"billybustillo@gmail.com"
] | billybustillo@gmail.com |
b1d67bc1dd69290b186bd07cbca7550d33e91d90 | 710b1e5781d366b34ce5072d8f6ffae6ff66a5ae | /transport/src/main/java/io/netty/channel/embedded/EmbeddedChannel.java | 2346c6aeabbcc2ece8ffc24dc60b4e25d3a2b7d7 | [
"Apache-2.0",
"CC-PDDC",
"BSD-3-Clause",
"LGPL-2.1-only",
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | ColonelHou/netty-4.0 | eed6fc1e837064dfdc58783c3efe3c3dfb7555a8 | c87e99b26f4f5067f5fc6b40cdd093e0402d0b56 | refs/heads/master | 2022-10-17T10:44:55.543045 | 2019-07-19T11:31:43 | 2019-07-19T11:31:43 | 194,032,751 | 0 | 0 | Apache-2.0 | 2022-10-04T23:53:08 | 2019-06-27T06:05:59 | Java | UTF-8 | Java | false | false | 21,084 | java | /*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.channel.embedded;
import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.DefaultChannelConfig;
import io.netty.channel.DefaultChannelPipeline;
import io.netty.channel.EventLoop;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.ObjectUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.RecyclableArrayList;
import io.netty.util.internal.UnstableApi;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
import java.util.ArrayDeque;
import java.util.Queue;
/**
* Base class for {@link Channel} implementations that are used in an embedded fashion.
*/
public class EmbeddedChannel extends AbstractChannel {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(EmbeddedChannel.class);
private static final ChannelMetadata METADATA_NO_DISCONNECT = new ChannelMetadata(false);
private static final ChannelMetadata METADATA_DISCONNECT = new ChannelMetadata(true);
private final EmbeddedEventLoop loop = new EmbeddedEventLoop();
private final ChannelFutureListener recordExceptionListener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
recordException(future);
}
};
private final ChannelMetadata metadata;
private final ChannelConfig config;
private final SocketAddress localAddress = new EmbeddedSocketAddress();
private final SocketAddress remoteAddress = new EmbeddedSocketAddress();
private Queue<Object> inboundMessages;
private Queue<Object> outboundMessages;
private Throwable lastException;
private int state; // 0 = OPEN, 1 = ACTIVE, 2 = CLOSED
/**
* Create a new instance
*
* @param handlers the @link ChannelHandler}s which will be add in the {@link ChannelPipeline}
*/
public EmbeddedChannel(final ChannelHandler... handlers) {
this(false, handlers);
}
/**
* Create a new instance with the channel ID set to the given ID and the pipeline
* initialized with the specified handlers.
*
* @param hasDisconnect {@code false} if this {@link Channel} will delegate {@link #disconnect()}
* to {@link #close()}, {@link false} otherwise.
* @param handlers the {@link ChannelHandler}s which will be add in the {@link ChannelPipeline}
*/
public EmbeddedChannel(boolean hasDisconnect, final ChannelHandler... handlers) {
this(true, hasDisconnect, handlers);
}
/**
* Create a new instance with the pipeline initialized with the specified handlers.
*
* @param register {@code true} if this {@link Channel} is registered to the {@link EventLoop} in the
* constructor. If {@code false} the user will need to call {@link #register()}.
* @param hasDisconnect {@code false} if this {@link Channel} will delegate {@link #disconnect()}
* to {@link #close()}, {@link false} otherwise.
* @param handlers the {@link ChannelHandler}s which will be add in the {@link ChannelPipeline}
*/
public EmbeddedChannel(boolean register, boolean hasDisconnect, ChannelHandler... handlers) {
super(null);
metadata = metadata(hasDisconnect);
config = new DefaultChannelConfig(this);
setup(register, handlers);
}
/**
* Create a new instance with the channel ID set to the given ID and the pipeline
* initialized with the specified handlers.
*
* @param hasDisconnect {@code false} if this {@link Channel} will delegate {@link #disconnect()}
* to {@link #close()}, {@link false} otherwise.
* @param config the {@link ChannelConfig} which will be returned by {@link #config()}.
* @param handlers the {@link ChannelHandler}s which will be add in the {@link ChannelPipeline}
*/
public EmbeddedChannel(boolean hasDisconnect, final ChannelConfig config,
final ChannelHandler... handlers) {
super(null);
metadata = metadata(hasDisconnect);
this.config = ObjectUtil.checkNotNull(config, "config");
setup(true, handlers);
}
private static ChannelMetadata metadata(boolean hasDisconnect) {
return hasDisconnect ? METADATA_DISCONNECT : METADATA_NO_DISCONNECT;
}
private void setup(boolean register, final ChannelHandler... handlers) {
ObjectUtil.checkNotNull(handlers, "handlers");
ChannelPipeline p = pipeline();
p.addLast(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
for (ChannelHandler h: handlers) {
if (h == null) {
break;
}
pipeline.addLast(h);
}
}
});
if (register) {
ChannelFuture future = loop.register(this);
assert future.isDone();
}
}
/**
* Register this {@code Channel} on its {@link EventLoop}.
*/
public void register() throws Exception {
ChannelFuture future = loop.register(this);
assert future.isDone();
Throwable cause = future.cause();
if (cause != null) {
PlatformDependent.throwException(cause);
}
}
@Override
protected final DefaultChannelPipeline newChannelPipeline() {
return new EmbeddedChannelPipeline(this);
}
@Override
public ChannelMetadata metadata() {
return metadata;
}
@Override
public ChannelConfig config() {
return config;
}
@Override
public boolean isOpen() {
return state < 2;
}
@Override
public boolean isActive() {
return state == 1;
}
/**
* Returns the {@link Queue} which holds all the {@link Object}s that were received by this {@link Channel}.
*/
public Queue<Object> inboundMessages() {
if (inboundMessages == null) {
inboundMessages = new ArrayDeque<Object>();
}
return inboundMessages;
}
/**
* @deprecated use {@link #inboundMessages()}
*/
@Deprecated
public Queue<Object> lastInboundBuffer() {
return inboundMessages();
}
/**
* Returns the {@link Queue} which holds all the {@link Object}s that were written by this {@link Channel}.
*/
public Queue<Object> outboundMessages() {
if (outboundMessages == null) {
outboundMessages = new ArrayDeque<Object>();
}
return outboundMessages;
}
/**
* @deprecated use {@link #outboundMessages()}
*/
@Deprecated
public Queue<Object> lastOutboundBuffer() {
return outboundMessages();
}
/**
* Return received data from this {@link Channel}
*/
public Object readInbound() {
return poll(inboundMessages);
}
/**
* Read data from the outbound. This may return {@code null} if nothing is readable.
*/
public Object readOutbound() {
return poll(outboundMessages);
}
/**
* Write messages to the inbound of this {@link Channel}.
*
* @param msgs the messages to be written
*
* @return {@code true} if the write operation did add something to the inbound buffer
*/
public boolean writeInbound(Object... msgs) {
ensureOpen();
if (msgs.length == 0) {
return isNotEmpty(inboundMessages);
}
ChannelPipeline p = pipeline();
for (Object m: msgs) {
p.fireChannelRead(m);
}
p.fireChannelReadComplete();
runPendingTasks();
checkException();
return isNotEmpty(inboundMessages);
}
/**
* Write messages to the outbound of this {@link Channel}.
*
* @param msgs the messages to be written
* @return bufferReadable returns {@code true} if the write operation did add something to the outbound buffer
*/
public boolean writeOutbound(Object... msgs) {
ensureOpen();
if (msgs.length == 0) {
return isNotEmpty(outboundMessages);
}
RecyclableArrayList futures = RecyclableArrayList.newInstance(msgs.length);
try {
for (Object m: msgs) {
if (m == null) {
break;
}
futures.add(write(m));
}
// We need to call runPendingTasks first as a ChannelOutboundHandler may used eventloop.execute(...) to
// delay the write on the next eventloop run.
runPendingTasks();
flush();
int size = futures.size();
for (int i = 0; i < size; i++) {
ChannelFuture future = (ChannelFuture) futures.get(i);
if (future.isDone()) {
recordException(future);
} else {
// The write may be delayed to run later by runPendingTasks()
future.addListener(recordExceptionListener);
}
}
checkException();
return isNotEmpty(outboundMessages);
} finally {
futures.recycle();
}
}
/**
* Mark this {@link Channel} as finished. Any futher try to write data to it will fail.
*
* @return bufferReadable returns {@code true} if any of the used buffers has something left to read
*/
public boolean finish() {
return finish(false);
}
/**
* Mark this {@link Channel} as finished and release all pending message in the inbound and outbound buffer.
* Any further try to write data to it will fail.
*
* @return bufferReadable returns {@code true} if any of the used buffers has something left to read
*/
public boolean finishAndReleaseAll() {
return finish(true);
}
/**
* Mark this {@link Channel} as finished. Any further try to write data to it will fail.
*
* @param releaseAll if {@code true} all pending message in the inbound and outbound buffer are released.
* @return bufferReadable returns {@code true} if any of the used buffers has something left to read
*/
private boolean finish(boolean releaseAll) {
close();
try {
checkException();
return isNotEmpty(inboundMessages) || isNotEmpty(outboundMessages);
} finally {
if (releaseAll) {
releaseAll(inboundMessages);
releaseAll(outboundMessages);
}
}
}
/**
* Release all buffered inbound messages and return {@code true} if any were in the inbound buffer, {@code false}
* otherwise.
*/
public boolean releaseInbound() {
return releaseAll(inboundMessages);
}
/**
* Release all buffered outbound messages and return {@code true} if any were in the outbound buffer, {@code false}
* otherwise.
*/
public boolean releaseOutbound() {
return releaseAll(outboundMessages);
}
private static boolean releaseAll(Queue<Object> queue) {
if (isNotEmpty(queue)) {
for (;;) {
Object msg = queue.poll();
if (msg == null) {
break;
}
ReferenceCountUtil.release(msg);
}
return true;
}
return false;
}
private void finishPendingTasks(boolean cancel) {
runPendingTasks();
if (cancel) {
// Cancel all scheduled tasks that are left.
loop.cancelScheduledTasks();
}
}
@Override
public final ChannelFuture close() {
return close(newPromise());
}
@Override
public final ChannelFuture disconnect() {
return disconnect(newPromise());
}
@Override
public final ChannelFuture close(ChannelPromise promise) {
// We need to call runPendingTasks() before calling super.close() as there may be something in the queue
// that needs to be run before the actual close takes place.
runPendingTasks();
ChannelFuture future = super.close(promise);
// Now finish everything else and cancel all scheduled tasks that were not ready set.
finishPendingTasks(true);
return future;
}
@Override
public final ChannelFuture disconnect(ChannelPromise promise) {
ChannelFuture future = super.disconnect(promise);
finishPendingTasks(!metadata.hasDisconnect());
return future;
}
private static boolean isNotEmpty(Queue<Object> queue) {
return queue != null && !queue.isEmpty();
}
private static Object poll(Queue<Object> queue) {
return queue != null ? queue.poll() : null;
}
/**
* Run all tasks (which also includes scheduled tasks) that are pending in the {@link EventLoop}
* for this {@link Channel}
*/
public void runPendingTasks() {
try {
loop.runTasks();
} catch (Exception e) {
recordException(e);
}
try {
loop.runScheduledTasks();
} catch (Exception e) {
recordException(e);
}
}
/**
* Run all pending scheduled tasks in the {@link EventLoop} for this {@link Channel} and return the
* {@code nanoseconds} when the next scheduled task is ready to run. If no other task was scheduled it will return
* {@code -1}.
*/
public long runScheduledPendingTasks() {
try {
return loop.runScheduledTasks();
} catch (Exception e) {
recordException(e);
return loop.nextScheduledTask();
}
}
private void recordException(ChannelFuture future) {
if (!future.isSuccess()) {
recordException(future.cause());
}
}
private void recordException(Throwable cause) {
if (lastException == null) {
lastException = cause;
} else {
logger.warn(
"More than one exception was raised. " +
"Will report only the first one and log others.", cause);
}
}
/**
* Check if there was any {@link Throwable} received and if so rethrow it.
*/
public void checkException() {
Throwable t = lastException;
if (t == null) {
return;
}
lastException = null;
PlatformDependent.throwException(t);
}
/**
* Ensure the {@link Channel} is open and if not throw an exception.
*/
protected final void ensureOpen() {
if (!isOpen()) {
recordException(new ClosedChannelException());
checkException();
}
}
@Override
protected boolean isCompatible(EventLoop loop) {
return loop instanceof EmbeddedEventLoop;
}
@Override
protected SocketAddress localAddress0() {
return isActive()? localAddress : null;
}
@Override
protected SocketAddress remoteAddress0() {
return isActive()? remoteAddress : null;
}
@Override
protected void doRegister() throws Exception {
state = 1;
}
@Override
protected void doBind(SocketAddress localAddress) throws Exception {
// NOOP
}
@Override
protected void doDisconnect() throws Exception {
if (!metadata.hasDisconnect()) {
doClose();
}
}
@Override
protected void doClose() throws Exception {
state = 2;
}
@Override
protected void doBeginRead() throws Exception {
// NOOP
}
@Override
protected AbstractUnsafe newUnsafe() {
return new EmbeddedUnsafe();
}
@Override
public Unsafe unsafe() {
return ((EmbeddedUnsafe) super.unsafe()).wrapped;
}
@Override
protected void doWrite(ChannelOutboundBuffer in) throws Exception {
for (;;) {
Object msg = in.current();
if (msg == null) {
break;
}
ReferenceCountUtil.retain(msg);
outboundMessages().add(msg);
in.remove();
}
}
private final class EmbeddedUnsafe extends AbstractUnsafe {
// Delegates to the EmbeddedUnsafe instance but ensures runPendingTasks() is called after each operation
// that may change the state of the Channel and may schedule tasks for later execution.
final Unsafe wrapped = new Unsafe() {
@Override
public SocketAddress localAddress() {
return EmbeddedUnsafe.this.localAddress();
}
@Override
public SocketAddress remoteAddress() {
return EmbeddedUnsafe.this.remoteAddress();
}
@Override
public void register(EventLoop eventLoop, ChannelPromise promise) {
EmbeddedUnsafe.this.register(eventLoop, promise);
runPendingTasks();
}
@Override
public void bind(SocketAddress localAddress, ChannelPromise promise) {
EmbeddedUnsafe.this.bind(localAddress, promise);
runPendingTasks();
}
@Override
public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
EmbeddedUnsafe.this.connect(remoteAddress, localAddress, promise);
runPendingTasks();
}
@Override
public void disconnect(ChannelPromise promise) {
EmbeddedUnsafe.this.disconnect(promise);
runPendingTasks();
}
@Override
public void close(ChannelPromise promise) {
EmbeddedUnsafe.this.close(promise);
runPendingTasks();
}
@Override
public void closeForcibly() {
EmbeddedUnsafe.this.closeForcibly();
runPendingTasks();
}
@Override
public void deregister(ChannelPromise promise) {
EmbeddedUnsafe.this.deregister(promise);
runPendingTasks();
}
@Override
public void beginRead() {
EmbeddedUnsafe.this.beginRead();
runPendingTasks();
}
@Override
public void write(Object msg, ChannelPromise promise) {
EmbeddedUnsafe.this.write(msg, promise);
runPendingTasks();
}
@Override
public void flush() {
EmbeddedUnsafe.this.flush();
runPendingTasks();
}
@Override
public ChannelPromise voidPromise() {
return EmbeddedUnsafe.this.voidPromise();
}
@Override
public ChannelOutboundBuffer outboundBuffer() {
return EmbeddedUnsafe.this.outboundBuffer();
}
};
@Override
public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
safeSetSuccess(promise);
}
}
private final class EmbeddedChannelPipeline extends DefaultChannelPipeline {
EmbeddedChannelPipeline(EmbeddedChannel channel) {
super(channel);
}
@Override
protected void onUnhandledInboundException(Throwable cause) {
recordException(cause);
}
@Override
protected void onUnhandledInboundMessage(Object msg) {
inboundMessages().add(msg);
}
}
}
| [
"houningning@MacOS.local"
] | houningning@MacOS.local |
cfd4955c5d5ae2deba75ebfcd85a1bc7b0b3c6c1 | 8a5e0abebe1f6a82ea9f8c3b9aa541c769d49c42 | /src/main/java/com/builtbroken/armory/data/ranged/barrels/GunBarrel.java | f5646315168eb8c4f0cdb55d3c2f18fc67fc24c8 | [
"MIT"
] | permissive | BuiltBrokenModding/Armory | ba481309b7abdc90a09d67332f58a57eb39ca55b | 5da5053bce1841552fad03005e799c2bb5f10abe | refs/heads/master | 2022-06-16T04:03:29.575554 | 2022-06-03T13:42:42 | 2022-06-03T13:42:42 | 29,359,767 | 3 | 7 | null | null | null | null | UTF-8 | Java | false | false | 441 | java | package com.builtbroken.armory.data.ranged.barrels;
import com.builtbroken.mc.imp.transform.vector.Pos;
/**
* @see <a href="https://github.com/BuiltBrokenModding/VoltzEngine/blob/development/license.md">License</a> for what you can and can't do with the code.
* Created by Dark(DarkGuardsman, Robert) on 7/8/2018.
*/
public class GunBarrel
{
public int index;
public int group = 0;
public String name;
public Pos pos;
}
| [
"rseifert.phone@gmail.com"
] | rseifert.phone@gmail.com |
e9dbf8eb87539f4336fca0b0681b4513ddff6105 | 2ea49bfaa6bc1b9301b025c5b2ca6fde7e5bb9df | /contributions/marziopulcini/Java/Error Handling/2016-11-01.java | 5b93a725e56d0277bae110fc08f75f87ab997d4e | [] | no_license | 0x8801/commit | 18f25a9449f162ee92945b42b93700e12fd4fd77 | e7692808585bc7e9726f61f7f6baf43dc83e28ac | refs/heads/master | 2021-10-13T08:04:48.200662 | 2016-12-20T01:59:47 | 2016-12-20T01:59:47 | 76,935,980 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 212 | java | Throwing proper exceptions for unfinished code
Be as specific as possible when catching exceptions
The distinction between checked and unchecked exceptions
Throwing an `exception`
Careful Numeric Data Conversions | [
"marzio.pulcini@at-shopnet.com"
] | marzio.pulcini@at-shopnet.com |
87e7c9fd0955746053f942806a79b0975f5a5d86 | f6899a2cf1c10a724632bbb2ccffb7283c77a5ff | /glassfish/admin/util/src/main/java/com/sun/enterprise/admin/util/InstanceStateService.java | 8c83fdb94a1f5ffc94b3d5c64c82b24876250df5 | [] | no_license | Appdynamics/OSS | a8903058e29f4783e34119a4d87639f508a63692 | 1e112f8854a25b3ecf337cad6eccf7c85e732525 | refs/heads/master | 2023-07-22T03:34:54.770481 | 2021-10-28T07:01:57 | 2021-10-28T07:01:57 | 19,390,624 | 2 | 13 | null | 2023-07-08T02:26:33 | 2014-05-02T22:42:20 | null | UTF-8 | Java | false | false | 9,291 | java | /*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.enterprise.admin.util;
import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.Server;
import java.util.logging.Level;
import org.glassfish.api.Startup;
import org.glassfish.api.admin.*;
import org.glassfish.api.admin.ServerEnvironment;
import org.jvnet.hk2.annotations.Inject;
import org.jvnet.hk2.annotations.Scoped;
import org.jvnet.hk2.annotations.Service;
import org.jvnet.hk2.component.Singleton;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Future;
import java.util.logging.Logger;
/**
* This service is called at startup and parses the instance state file
* @author Vijay Ramachandran
*/
@Service
@Scoped(Singleton.class)
public class InstanceStateService implements Startup {
@Inject
private ServerEnvironment serverEnv;
@Inject
private Domain domain;
@Inject
private Logger logger;
@Inject
private CommandThreadPool cmdPool;
private InstanceStateFileProcessor stateProcessor;
private HashMap<String, InstanceState> instanceStates;
private final int MAX_RECORDED_FAILED_COMMANDS = 10;
public InstanceStateService() {}
/*
* Perform lazy-initialization for the object, since this InstanceStateService
* is not needed if there are not any instances.
*/
private void init() {
if (instanceStates != null) return;
instanceStates = new HashMap<String, InstanceState>();
File stateFile = new File(serverEnv.getConfigDirPath().getAbsolutePath(),
".instancestate");
try {
stateProcessor = new InstanceStateFileProcessor(instanceStates,
stateFile);
} catch (IOException ioe) {
logger.log(Level.INFO, "unable to read instance state file {0}, recreating", stateFile);
instanceStates = new HashMap<String, InstanceState>();
// Even though instances may already exist, do not populate the
// instancesStates array because it will be repopulated as it is
// used. Populating it early causes problems during instance
// creation.
try {
stateProcessor = InstanceStateFileProcessor.createNew(instanceStates, stateFile);
} catch (IOException ex) {
logger.log(Level.SEVERE, "unable to create instance state file " + stateFile, ex);
stateProcessor = null;
}
}
}
public synchronized void addServerToStateService(String instanceName) {
init();
instanceStates.put(instanceName, new InstanceState(InstanceState.StateType.NEVER_STARTED));
try {
stateProcessor.addNewServer(instanceName);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error while adding new server state to instance state: {0}", e.getLocalizedMessage());
}
}
public synchronized void addFailedCommandToInstance(String instance, String cmd, ParameterMap params) {
init();
String cmdDetails = cmd;
String defArg = params.getOne("DEFAULT");
if (defArg != null) cmdDetails += " " + defArg;
try {
InstanceState i = instanceStates.get(instance);
if (i != null && i.getState() != InstanceState.StateType.NEVER_STARTED &&
i.getFailedCommands().size() < MAX_RECORDED_FAILED_COMMANDS) {
i.addFailedCommands(cmdDetails);
stateProcessor.addFailedCommand(instance, cmdDetails);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error while adding failed command to instance state: {0}", e.getLocalizedMessage());
}
}
public synchronized void removeFailedCommandsForInstance(String instance) {
init();
try {
InstanceState i = instanceStates.get(instance);
if(i != null) {
i.removeFailedCommands();
stateProcessor.removeFailedCommands(instance);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error while removing failed commands from instance state: {0}", e.getLocalizedMessage());
}
}
public InstanceState.StateType getState(String instanceName) {
init();
InstanceState s = instanceStates.get(instanceName);
if (s == null)
return InstanceState.StateType.NEVER_STARTED;
return s.getState();
}
public List<String> getFailedCommands(String instanceName) {
init();
InstanceState s = instanceStates.get(instanceName);
if(s == null)
return new ArrayList<String>();
return s.getFailedCommands();
}
public synchronized InstanceState.StateType setState(String name, InstanceState.StateType newState, boolean force) {
init();
boolean updateXML = false;
InstanceState.StateType ret = newState;
InstanceState is = instanceStates.get(name);
InstanceState.StateType currState;
if (is == null || (currState = is.getState()) == null) {
instanceStates.put(name, new InstanceState(newState));
updateXML = true;
ret = newState;
} else if (!force && currState == InstanceState.StateType.RESTART_REQUIRED) {
// If current state is RESTART_REQUIRED, no updates to state is allowed because
// only an instance restart can move this instance out of RESTART_REQD state
updateXML = false;
ret = currState;
} else if (!force && currState == InstanceState.StateType.NEVER_STARTED &&
(newState == InstanceState.StateType.NOT_RUNNING ||
newState == InstanceState.StateType.RESTART_REQUIRED ||
newState == InstanceState.StateType.NO_RESPONSE)) {
// invalid state change
updateXML = false;
ret = currState;
} else if (!currState.equals(newState)) {
instanceStates.get(name).setState(newState);
updateXML = true;
ret = newState;
}
try {
if (updateXML) {
stateProcessor.updateState(name, newState.getDescription());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error while setting instance state: {0}", e.getLocalizedMessage());
}
return ret;
}
public synchronized void removeInstanceFromStateService(String name) {
init();
instanceStates.remove(name);
try {
stateProcessor.removeInstanceNode(name);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error while removing instance: {0}", e.getLocalizedMessage());
}
}
/*
* For now, this just submits the job directly to the pool. In the future
* it might be possible to avoid submitting the job
*/
public Future<InstanceCommandResult> submitJob(Server server, InstanceCommand ice, InstanceCommandResult r) {
return cmdPool.submitJob(ice, r);
}
@Override
public Lifecycle getLifecycle() {
return Startup.Lifecycle.SERVER;
}
}
| [
"srini@appdynamics.com"
] | srini@appdynamics.com |
d16f34bb9b6b82b88f356c70566305420923e145 | 19e11a630954c6bce9d9f73428e39c06bda3e842 | /src/CustomeClasses/RoundJTextField.java | bb14e5c1085d0d0de7db126d98db321805f0cada | [] | no_license | PETERMAKAU/Compmaster-V.0.0.1 | d07c8a4adfe30a13d5c458d69e981898728ca65e | 7a821b7e22bfb3ccb3efeabf26ce1623a8a93532 | refs/heads/master | 2023-08-25T19:50:56.996801 | 2021-11-03T07:06:59 | 2021-11-03T07:06:59 | 393,070,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,177 | 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 CustomeClasses;
import java.awt.Graphics;
import java.awt.Shape;
import java.awt.geom.RoundRectangle2D;
import javax.swing.JTextField;
/**
*
* @author peter
*/
public class RoundJTextField extends JTextField {
private Shape shape;
public RoundJTextField(int size) {
super(size);
setOpaque(false); // As suggested by @AVD in comment.
}
protected void paintComponent(Graphics g) {
g.setColor(getBackground());
g.fillRoundRect(0, 0, getWidth()-1, getHeight()-1, 15, 15);
super.paintComponent(g);
}
protected void paintBorder(Graphics g) {
g.setColor(getForeground());
g.drawRoundRect(0, 0, getWidth()-1, getHeight()-1, 1, 1);
}
public boolean contains(int x, int y) {
if (shape == null || !shape.getBounds().equals(getBounds())) {
shape = new RoundRectangle2D.Float(0, 0, getWidth()-1, getHeight()-1, 15, 15);
}
return shape.contains(x, y);
}
} | [
"mbakungu@gmail.com"
] | mbakungu@gmail.com |
5428f8afcd14a19bf1f1566b0ee5c2753e28bf12 | 8699f0e6291becf2cd19de0df01c9ec786d37ffe | /test/de/inetsoftware/jwebassembly/runtime/Structs.java | 286d76cd92f5b0bd9bfcd7dcd0de7344a8d054fe | [
"Apache-2.0"
] | permissive | hotsmile/JWebAssembly | 912627a994f834d6d12aab21cc2fff84400a0c92 | c029c48be5c22b263a023c7f90aa04041fab54ac | refs/heads/master | 2020-07-16T12:02:07.585386 | 2019-08-27T18:44:27 | 2019-08-27T18:44:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,416 | java | /*
* Copyright 2018 - 2019 Volker Berlin (i-net software)
*
* 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 de.inetsoftware.jwebassembly.runtime;
import static org.junit.Assume.assumeTrue;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runners.Parameterized.Parameters;
import de.inetsoftware.jwebassembly.ScriptEngine;
import de.inetsoftware.jwebassembly.WasmRule;
import de.inetsoftware.jwebassembly.api.annotation.Export;
public class Structs extends AbstractBaseTest {
@ClassRule
public static WasmRule rule = new WasmRule( TestClass.class, Abc.class );
public Structs( ScriptEngine script, String method, Object[] params ) {
super( rule, script, method, params );
}
@Parameters( name = "{0}-{1}" )
public static Collection<Object[]> data() {
ArrayList<Object[]> list = new ArrayList<>();
for( ScriptEngine script : ScriptEngine.testEngines() ) {
addParam( list, script, "isNull" );
addParam( list, script, "isNotNull" );
addParam( list, script, "isSame" );
addParam( list, script, "isNotSame" );
addParam( list, script, "simple" );
addParam( list, script, "callSuperMethod" );
//TODO addParam( list, script, "callVirtualMethod" );
addParam( list, script, "useGlobalObject" );
addParam( list, script, "multipleAssign" );
}
rule.setTestParameters( list );
return list;
}
@Test
public void test() {
assumeTrue( getScriptEngine() == ScriptEngine.SpiderMonkey || getScriptEngine() == ScriptEngine.SpiderMonkeyWat );
super.test();
}
static class TestClass {
@Export
static boolean isNull() {
Object val = null;
return val == null;
}
@Export
static boolean isNotNull() {
Object val = null;
return val != null;
}
@Export
static boolean isSame() {
Object val1 = null;
Object val2 = null;
return val1 == val2;
}
@Export
static boolean isNotSame() {
Object val1 = null;
Object val2 = null;
return val1 != val2;
}
@Export
static int simple() {
Abc val = new Abc2();
val.a = 63;
return val.a;
}
/**
* Call a method that is declared in the super class of the instance
*/
@Export
static int callSuperMethod() {
Abc2 val = new Abc2();
val.foo();
return val.a;
}
/**
* Call an overridden method
*/
@Export
static int callVirtualMethod() {
Abc val = new Abc2();
val.bar();
return val.a;
}
/**
* Access a object in a global/static variable.
*/
static Abc2 valGlobal;
@Export
static int useGlobalObject() {
valGlobal = new Abc2();
valGlobal.foo();
return valGlobal.a;
}
/**
* Assign multiple with a field. There are complex stack operation
*/
@Export
static int multipleAssign() {
Abc2 val = new Abc2();
for( int i = 0; i < 1_000; i++ ) {
val.a = 42;
// TODO
//val = val.abc = new Abc2();
}
return val.a;
}
}
static class Abc {
int a;
long b;
final void foo() {
a = 1;
}
void bar() {
a = 2;
}
}
static class Abc2 extends Abc {
Abc2 abc;
void bar() {
a = 3;
}
}
}
| [
"volker.berlin@googlemail.com"
] | volker.berlin@googlemail.com |
42aec56ca2b5ae1af7909a9c7bcf6d46d9e6e698 | 4aa23c91d62e24e2edc0acd5bf617a668955e07c | /dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/programrule/ShowErrorOnCompleteImplementer.java | 30c90a667cc7b3d6da71147935f28d171a2e9bb9 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | kas54/dhis2-core | f98bab4af13359b271c59a784e42468b2a7e03aa | ffc2b4b374d92ff8d3312694572cf1d9188fdf96 | refs/heads/master | 2022-12-19T02:07:55.742445 | 2020-09-19T10:47:19 | 2020-09-19T10:47:19 | 297,113,793 | 1 | 0 | BSD-3-Clause | 2020-09-20T16:11:21 | 2020-09-20T16:11:20 | null | UTF-8 | Java | false | false | 2,198 | java | /*
* Copyright (c) 2004-2020, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.tracker.programrule;
import lombok.extern.slf4j.Slf4j;
import org.hisp.dhis.rules.models.RuleActionErrorOnCompletion;
import org.springframework.stereotype.Component;
/**
* This implementer show errors on a completed enrollment calculated by Rule
* Engine.
*
* @Author Enrico Colasante
*/
@Slf4j
@Component
public class ShowErrorOnCompleteImplementer
extends ErrorWarningImplementer
{
@Override
public Class<RuleActionErrorOnCompletion> getActionClass()
{
return RuleActionErrorOnCompletion.class;
}
@Override
public boolean isWarning()
{
return false;
}
}
| [
"enrico.colasante@gmail.com"
] | enrico.colasante@gmail.com |
28efbf5d4a6e2430baf9a441006fd17b0d9d20d8 | f6c21b52c13013ccba9f5197833fadb9df892386 | /ComplexFragment/app/src/main/java/com/minu/appzoc8/complexfragment/FragmentOne.java | 4fdf31e088c59616844f4bb4b51eb8e8424b36cd | [] | no_license | abithpdm/androidstudioprojects | 0283ea0c58b5ac5d88c62172510bacb2bf368a24 | 78542043e3a6671e231fc427e81f9556d888aded | refs/heads/master | 2022-11-16T20:31:35.935505 | 2020-07-09T15:39:05 | 2020-07-09T15:39:05 | 278,395,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,298 | java | package com.minu.appzoc8.complexfragment;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by appzoc8 on 25/11/15.
*/
public class FragmentOne extends Fragment {
ListView PersonalDetails;
TextView mName,mPhone;
ImageView mDisplayImage;
String EXTRA_MESSAGE;
ArrayList<CustomList> personalList;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.fragmentone,container,false);
PersonalDetails=(ListView) view.findViewById(R.id.PersonalDetails);
mName=(TextView) view.findViewById(R.id.name);
mPhone=(TextView) view.findViewById(R.id.phone);
mDisplayImage=(ImageView) view.findViewById(R.id.image);
personalList=new ArrayList<>();
personalList.add(new CustomList("minu","5436739083",R.drawable.a1));
personalList.add(new CustomList("revathy","25541980",R.drawable.a2));
personalList.add(new CustomList("manu","765197886647",R.drawable.a3));
personalList.add(new CustomList("karan", "764317654", R.drawable.a4));
CustomArrayAdapter customArrayAdapter=new CustomArrayAdapter(getActivity(),R.layout.customview,personalList);
PersonalDetails.setAdapter(customArrayAdapter);
PersonalDetails.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(),SingleListItem.class);
intent.putExtra("NAME", personalList.get(position).getName());
intent.putExtra("IMAGE", personalList.get(position).getImage());
intent.putExtra("PHNNUM", personalList.get(position).getPhone());
getActivity().startActivity(intent);
}
});
return view;
}
}
| [
"abithpdm@gmail.com"
] | abithpdm@gmail.com |
50bbab953d6ab29737148f6bc63ec3bec84ab472 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/netty--netty/14158070bf8b3f831702061ffd657c84179fc639/before/EchoByteHandler.java | fbbded62e27c15410be2af0f551ba2c844e9c91f | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,932 | java | /*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.test.udt.util;
import com.yammer.metrics.core.Meter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelHandlerUtil;
import io.netty.channel.ChannelInboundByteHandlerAdapter;
import io.netty.channel.ChannelOption;
import io.netty.channel.udt.nio.NioUdtProvider;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
/**
* Handler implementation for the echo client. It initiates the ping-pong
* traffic between the echo client and server by sending the first message to
* the server on activation.
*/
public class EchoByteHandler extends ChannelInboundByteHandlerAdapter {
private static final InternalLogger log = InternalLoggerFactory.getInstance(EchoByteHandler.class);
private final ByteBuf message;
private final Meter meter;
public Meter meter() {
return meter;
}
public EchoByteHandler(final Meter meter, final int messageSize) {
this.meter = meter;
message = Unpooled.buffer(messageSize);
for (int i = 0; i < message.capacity(); i++) {
message.writeByte((byte) i);
}
}
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
log.info("ECHO active {}", NioUdtProvider.socketUDT(ctx.channel())
.toStringOptions());
ctx.write(message);
ctx.flush();
}
@Override
public void inboundBufferUpdated(final ChannelHandlerContext ctx,
final ByteBuf in) {
if (meter != null) {
meter.mark(in.readableBytes());
}
final ByteBuf out = ctx.nextOutboundByteBuffer();
out.discardReadBytes(); // FIXME
out.writeBytes(in);
ctx.flush();
}
@Override
public void exceptionCaught(final ChannelHandlerContext ctx,
final Throwable e) {
log.error("exception : {}", e.getMessage());
ctx.close();
}
@Override
public ByteBuf newInboundBuffer(final ChannelHandlerContext ctx) throws Exception {
return ChannelHandlerUtil.allocate(ctx,
ctx.channel().config().getOption(ChannelOption.SO_RCVBUF));
}
} | [
"fraczwojciech@gmail.com"
] | fraczwojciech@gmail.com |
7b0038f587b5ddf66c3a91b44d5fb46780863459 | c121537984f89448e591c19e669289ba4e0c767f | /exception/src/com/ustglobal/exception/first/TestD2.java | ed7cee9179bdc8838c2a07329439897c9852bb78 | [] | no_license | viharika-allam/USTGlobal-16Sep19-Viharika | 25a7a08dbec9dd20b50a82360c19f764961c1976 | 48899bdeabab04cc98dee20af95a73b9511eeb82 | refs/heads/master | 2023-01-08T21:15:19.594047 | 2019-12-24T07:11:12 | 2019-12-24T07:11:12 | 215,539,472 | 0 | 0 | null | 2023-01-07T17:42:56 | 2019-10-16T12:11:26 | Java | UTF-8 | Java | false | false | 500 | java | package com.ustglobal.exception.first;
public class TestD2 {
public static void main(String[] args) {
System.out.println("main started");
int[] a = {10,20,30};
int b = 10;
try {
System.out.println(b/0);
}catch(ArithmeticException ae) {
System.out.println("number is divided by zero");
}
try {
System.out.println(a[4]);
}
catch(ArrayIndexOutOfBoundsException ai)
{
System.out.println("index is not present");
}
System.out.println("main ended");
}
}
| [
"aruna.viharika@gmail.com"
] | aruna.viharika@gmail.com |
891b6e0fe643d33d0c1ed89527fea6ac0dc3745d | 94cf6f3a2cedca319ade4cd98fa002e284374988 | /src/com/cognixia/jump/MethodAssignment2.java | 01e0c1ce57b86c9b7fd712507d70402337cece4e | [] | no_license | jxxparker/JavaStatements | a3c0aac349a58f037341f2813cd865e8f0e19fb3 | 6fb707ca42d4ff01c9da537ef48d8cfb42e3e644 | refs/heads/master | 2022-10-28T00:16:10.244992 | 2020-06-15T19:41:37 | 2020-06-15T19:41:37 | 258,844,631 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,535 | java | package com.cognixia.jump;
public class MethodAssignment2 {
public static void main(String[] args) {
boolean gameOver = true;
int score = 800;
int levelCompleted = 5;
int bonus = 100;
int highScore = calculateScore(gameOver, score, levelCompleted, bonus);
System.out.println("Your final score was " + highScore);
score = 10000;
levelCompleted = 8;
bonus = 200;
highScore = calculateScore(gameOver, score, levelCompleted, bonus);
System.out.println("Your final score was " + highScore);
// Create a method called displayHighScorePosition
// it should a players name as a parameter, and a 2nd parameter as a position in the high score table
// You should display the players name along with a message like " managed to get into position " and the
// position they got and a further message " on the high score table".
//
// Create a 2nd method called calculateHighScorePosition
// it should be sent one argument only, the player score
// it should return an in
// the return data should be
// 1 if the score is >=1000
// 2 if the score is >=500 and < 1000
// 3 if the score is >=100 and < 500
// 4 in all other cases
// call both methods and display the results of the following
// a score of 1500, 900, 400 and 50
//
int highScorePosition = calculateHighScorePosition(1500);
displayHighScorePosition("Tim", highScorePosition);
highScorePosition = calculateHighScorePosition(900);
displayHighScorePosition("Bob", highScorePosition);
highScorePosition = calculateHighScorePosition(400);
displayHighScorePosition("Percy", highScorePosition);
highScorePosition = calculateHighScorePosition(50);
displayHighScorePosition("Gilbert", highScorePosition);
highScorePosition = calculateHighScorePosition(1000);
displayHighScorePosition("Louise", highScorePosition);
highScorePosition = calculateHighScorePosition(500);
displayHighScorePosition("Carol", highScorePosition);
highScorePosition = calculateHighScorePosition(100);
displayHighScorePosition("Frank", highScorePosition);
}
public static void displayHighScorePosition(String playerName, int highScorePosition) {
System.out.println(playerName + " managed to get into position "
+ highScorePosition + " on the high score table");
}
public static int calculateHighScorePosition(int playerScore) {
// if(playerScore >= 1000) {
//// return 1;
//// } else if(playerScore >= 500) {
//// return 2;
//// } else if(playerScore >= 100) {
//// return 3;
//// }
////
//// return 4;
int position = 4; // assuming position 4 will be returned
if(playerScore >= 1000) {
position = 1;
} else if(playerScore >= 500) {
position = 2;
} else if(playerScore >= 100) {
position = 3;
}
return position;
}
public static int calculateScore(boolean gameOver,int score, int levelCompleted, int bonus) {
if(gameOver) {
int finalScore = score + (levelCompleted * bonus);
finalScore += 2000;
return finalScore;
}
return -1;
}
} | [
"jihunpark@Jihuns-MacBook-Pro.local"
] | jihunpark@Jihuns-MacBook-Pro.local |
2cb9cf157e8a0d73a8852e0ff3fccc393db0b6c1 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/28/28_61490afd49d210fc4c09e0c7deabc5fed8dd611a/ViewFactory/28_61490afd49d210fc4c09e0c7deabc5fed8dd611a_ViewFactory_s.java | 8614fa3611a23b9d4bb2d793c48eefa23d2c9caf | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 21,158 | java | /**
*
*/
package edu.cmu.hcii.peer.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.media.MediaPlayer.OnVideoSizeChangedListener;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.VideoView;
import android.widget.LinearLayout.LayoutParams;
import edu.cmu.hcii.novo.kadarbra.R;
import edu.cmu.hcii.peer.MessageHandler;
import edu.cmu.hcii.peer.structure.Callout;
import edu.cmu.hcii.peer.structure.Cycle;
import edu.cmu.hcii.peer.structure.CycleNote;
import edu.cmu.hcii.peer.structure.ExecNote;
import edu.cmu.hcii.peer.structure.Reference;
import edu.cmu.hcii.peer.structure.Step;
import edu.cmu.hcii.peer.structure.StowageItem;
import edu.cmu.hcii.peer.util.FontManager.FontStyle;
/**
* @author Chris
*
*/
public class ViewFactory {
private static final String TAG = "ViewFactory";
/**
* Add a basic step
*
* @param context
* @param index
* @param s
*/
public static ViewGroup getNavigationStep(Context context, int curStepIndex, int index, Step s, int reps) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup newStep = (ViewGroup) inflater.inflate(R.layout.nav_item, null);
((TextView)newStep.findViewById(R.id.navItemNumber)).setText("STEP " + s.getNumber());
((TextView)newStep.findViewById(R.id.navItemText)).setText(s.getText());
//If a lone step, set a margin so that it matches those which are a the cycle
if (reps < 2) {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.setMargins(34, 0, 0, 0);
newStep.setLayoutParams(params);
}
final String step = String.valueOf(index);
newStep.setOnClickListener(new OnClickListener(){
//The step number sent will be 0 indexed.
//So step 1 will send over the index of 0.
@Override
public void onClick(View arg0) {
Intent intent = new Intent("command");
intent.putExtra("msg", MessageHandler.COMMAND_GO_TO_STEP);
intent.putExtra("str", step);
arg0.getContext().sendBroadcast(intent);
}
});
//Color it if it is the current step
if (index == curStepIndex) ((TextView)newStep.findViewById(R.id.navItemNumber)).setTextColor(context.getResources().getColor(R.color.main));
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)newStep.findViewById(R.id.navItemNumber)).setTypeface(fm.getFont(FontStyle.SELECTABLE));
((TextView)newStep.findViewById(R.id.navItemText)).setTypeface(fm.getFont(FontStyle.BODY));
return newStep;
}
public static ViewGroup getNavigationCycle(Context context, int curStepIndex, int index, Cycle c) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup newCycle = (ViewGroup) inflater.inflate(R.layout.nav_item_cycle, null);
((TextView)newCycle.findViewById(R.id.navCycleCount)).setText(c.getReps() + "x");
ViewGroup steps = (ViewGroup) newCycle.findViewById(R.id.navCycleSteps);
for (int j = 0; j < c.getNumChildren(); j++) {
//TODO this will break on cycles within cycles
steps.addView(getNavigationStep(context, curStepIndex, index, (Step)c.getChild(j), c.getReps()));
index++;
}
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)newCycle.findViewById(R.id.navCycleCount)).setTypeface(fm.getFont(FontStyle.BODY));
return newCycle;
}
/**
*
* @param context
* @param index
* @return
*/
public static View getCycleSelect(Context context, int index) {
final String rep = String.valueOf(index);
LayoutInflater inflater = LayoutInflater.from(context);
TextView newItem = (TextView)inflater.inflate(R.layout.cycle_select_item, null);
newItem.setText("CYCLE " + rep);
newItem.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("command");
intent.putExtra("msg", MessageHandler.COMMAND_CYCLE_NUMBER);
intent.putExtra("str", rep);
v.getContext().sendBroadcast(intent);
}
});
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
newItem.setTypeface(fm.getFont(FontStyle.SELECTABLE));
return newItem;
}
/**
*
* @param module
* @param items
* @return
*/
public static ViewGroup getStowageTable(Context context, String module, List<StowageItem> items) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup container = (ViewGroup)inflater.inflate(R.layout.stowage_table, null);
TableLayout table = (TableLayout)container.findViewById(R.id.stow_table);
//set table title
((TextView)container.findViewById(R.id.stow_table_title)).setText(module);
for (int i = 0; i < items.size(); i++) {
table.addView(getStowageRow(context, items.get(i)));
}
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)container.findViewById(R.id.stow_table_title)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)table.findViewById(R.id.binCodeHeader)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)table.findViewById(R.id.itemHeader)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)table.findViewById(R.id.quantityHeader)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)table.findViewById(R.id.itemCodeHeader)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)table.findViewById(R.id.notesHeader)).setTypeface(fm.getFont(FontStyle.HEADER));
return container;
}
public static ViewGroup getStowageRow(Context context, StowageItem item) {
LayoutInflater inflater = LayoutInflater.from(context);
TableRow row = (TableRow) inflater.inflate(R.layout.stowage_row, null);
((TextView)row.findViewById(R.id.stowNoteBinCode)).setText(item.getBinCode());
((TextView)row.findViewById(R.id.stowNoteItem)).setText(item.getName());
((TextView)row.findViewById(R.id.stowNoteQuantity)).setText(String.valueOf(item.getQuantity()));
((TextView)row.findViewById(R.id.stowNoteItemCode)).setText(item.getItemCode());
((TextView)row.findViewById(R.id.stowNoteNotes)).setText(item.getText());
try {
InputStream is = context.getAssets().open("procedures/references/" + item.getUrl());
Drawable d = Drawable.createFromStream(is, null);
((ImageView)row.findViewById(R.id.stowNoteImage)).setImageDrawable(d);
} catch(Exception e) {
Log.e(TAG, "Error adding reference image to stowage note", e);
}
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)row.findViewById(R.id.stowNoteBinCode)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)row.findViewById(R.id.stowNoteItem)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)row.findViewById(R.id.stowNoteQuantity)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)row.findViewById(R.id.stowNoteItemCode)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)row.findViewById(R.id.stowNoteNotes)).setTypeface(fm.getFont(FontStyle.BODY));
return row;
}
/**
*
* @param context
* @param note
* @return
*/
public static ViewGroup getExecutionNoteOverview(Context context, ExecNote note) {
if (note != null) {
Log.v(TAG, "Setting up overview execution note");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup noteView = (ViewGroup)inflater.inflate(R.layout.ex_note_overall, null);
((TextView)noteView.findViewById(R.id.exNoteNumber)).setText("Step " + note.getNumber());
((TextView)noteView.findViewById(R.id.exNoteText)).setText(note.getText());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)noteView.findViewById(R.id.exNoteNumber)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)noteView.findViewById(R.id.exNoteText)).setTypeface(fm.getFont(FontStyle.BODY));
return noteView;
}
return null;
}
/**
* Add the given execution note to the step page.
*
* @param note the note to display
*/
public static ViewGroup getExecutionNote(Context context, ExecNote note) {
if (note != null) {
Log.v(TAG, "Setting up execution note");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup noteView = (ViewGroup)inflater.inflate(R.layout.callout, null);
((TextView)noteView.findViewById(R.id.calloutTitle)).setText(R.string.ex_note_title);
((TextView)noteView.findViewById(R.id.calloutText)).setText(note.getText());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)noteView.findViewById(R.id.calloutTitle)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)noteView.findViewById(R.id.calloutText)).setTypeface(fm.getFont(FontStyle.BODY));
return noteView;
}
return null;
}
/**
* Add the given callout object to the step
* @param call the callout to render
*/
public static ViewGroup getCallout(Context context, Callout call) {
if (call != null) {
Log.v(TAG, "Setting up callout");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup callView = (ViewGroup)inflater.inflate(R.layout.callout, null);
String typeName = "";
int bg = 0;
int border = 0;
switch(call.getType()) {
case NOTE:
typeName = "NOTE";
bg = R.drawable.dot_bg_white;
border = R.drawable.border_white;
break;
case CAUTION:
typeName = "CAUTION";
bg = R.drawable.dot_bg_yellow;
border = R.drawable.border_yellow;
break;
case WARNING:
typeName = "WARNING";
bg = R.drawable.dot_bg_red;
border = R.drawable.border_red;
break;
default:
break;
}
((ViewGroup)callView.findViewById(R.id.calloutTable)).setBackgroundResource(border);
((ViewGroup)callView.findViewById(R.id.calloutHeader)).setBackgroundResource(bg);
((TextView)callView.findViewById(R.id.calloutTitle)).setText(typeName);
((TextView)callView.findViewById(R.id.calloutText)).setText(call.getText());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)callView.findViewById(R.id.calloutTitle)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)callView.findViewById(R.id.calloutText)).setTypeface(fm.getFont(FontStyle.BODY));
return callView;
}
return null;
}
/**
* Setup the give cycle note
*
* @param context
* @param note
* @return
*/
public static ViewGroup getCycleNote(Context context, CycleNote note) {
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup newNote = (ViewGroup)inflater.inflate(R.layout.cycle_note, null);
((TextView)newNote.findViewById(R.id.cycleNoteText)).setText(note.getText());
if (note.getReference() != null) {
newNote.addView(getReference(context, note.getReference()));
}
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)newNote.findViewById(R.id.cycleNoteText)).setTypeface(fm.getFont(FontStyle.HEADER));
return newNote;
}
/**
* Setup the reference view group corresponding to the given
* reference object.
*
* @param ref
* @return
*/
public static ViewGroup getReference(Context context, Reference ref) {
switch(ref.getType()) {
case IMAGE:
return getImageReference(context, ref);
case VIDEO:
return getVideoReference(context, ref);
case AUDIO:
return getAudioReference(context, ref);
case TABLE:
return getTableReference(context, ref);
default:
break;
}
return null;
}
/**
* Setup the given reference as an image reference
* @param ref the reference to render
*/
public static ViewGroup getImageReference(Context context, Reference ref) {
Log.v(TAG, "Setting up image view: " + ref.getUrl());
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup reference = (ViewGroup)inflater.inflate(R.layout.reference, null);
ImageView img = (ImageView)inflater.inflate(R.layout.image, null);
try {
InputStream is = context.getAssets().open("procedures/references/" + ref.getUrl());
Drawable d = Drawable.createFromStream(is, null);
img.setImageDrawable(d);
//img.setImageDrawable(Drawable.createFromPath(ref.getUrl()));
reference.addView(img, 0);
} catch (IOException e) {
Log.e(TAG, "Error loading image", e);
}
//TODO this last code gets repeated for every reference type
((TextView)reference.findViewById(R.id.referenceCaption)).setText(ref.getName() + ": " + ref.getDescription());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)reference.findViewById(R.id.referenceCaption)).setTypeface(fm.getFont(FontStyle.BODY));
return reference;
}
/**
* Setup the given reference as a video reference
*
* TODO: we should make our own media controller so it's stylized
*
* @param ref the reference to render
*/
public static ViewGroup getVideoReference(final Context context, Reference ref) {
Log.v(TAG, "Setting up video view: " + ref.getUrl());
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup reference = (ViewGroup)inflater.inflate(R.layout.reference_video, null);
final VideoView vid = (VideoView)reference.findViewById(R.id.referenceVideo);
//TODO for some reason this fucking thing doesn't work.
//vid.setVideoURI(Uri.parse("file:///android_asset/procedures/references/" + ref.getUrl()));
vid.setVideoURI(Uri.parse(Environment.getExternalStorageDirectory().toString() + "/" + ref.getUrl()));
vid.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
/*
* add media controller and set its position
* TODO this still isn't laying where we want it
* TODO probably should make this a custom videoview class
*/
MediaController mc = new MediaController(context);
vid.setMediaController(mc);
mc.setAnchorView(vid);
LayoutParams lp = new LinearLayout.LayoutParams(mp.getVideoWidth(), mp.getVideoHeight());
lp.gravity = Gravity.CENTER;
vid.setLayoutParams(lp);
}
});
mp.start();
}
});
((TextView)reference.findViewById(R.id.referenceCaption)).setText(ref.getName() + ": " + ref.getDescription());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)reference.findViewById(R.id.referenceCaption)).setTypeface(fm.getFont(FontStyle.BODY));
return reference;
}
/**
* Setup the given reference as an audio reference
* @param ref the reference to render
*/
public static ViewGroup getAudioReference(Context context, Reference ref) {
//TODO
return null;
}
/**
* Setup the given reference as a table reference
* @param ref the reference to render
*/
public static ViewGroup getTableReference(Context context, Reference ref) {
Log.v(TAG, "Setting up table view");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup reference = (ViewGroup)inflater.inflate(R.layout.reference, null);
TableLayout table = (TableLayout)inflater.inflate(R.layout.table, null);
List<List<String>> cells = ref.getTable();
for (int i = 0; i < cells.size(); i++) {
if (i==0) {
table.addView(getRow(context, cells.get(i), R.layout.table_header_row, R.layout.table_header_cell));
} else {
table.addView(getRow(context, cells.get(i), R.layout.table_row, R.layout.table_cell));
}
}
reference.addView(table, 0);
((TextView)reference.findViewById(R.id.referenceCaption)).setText(ref.getName() + ": " + ref.getDescription());
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)reference.findViewById(R.id.referenceCaption)).setTypeface(fm.getFont(FontStyle.BODY));
return reference;
}
/**
* Set up a table row with the given values.
*
* @param cells
* @param rowId
* @param cellId
* @return
*/
public static TableRow getRow(Context context, List<String> cells, int rowId, int cellId) {
FontManager fm = FontManager.getInstance(context.getAssets());
LayoutInflater inflater = LayoutInflater.from(context);
TableRow row = (TableRow)inflater.inflate(rowId, null);
for (int i = 0; i < cells.size(); i++) {
TextView t = (TextView)inflater.inflate(cellId, null);
t.setText(cells.get(i));
//Set up the custom fonts
t.setTypeface(fm.getFont(cellId == R.layout.table_header_cell ? FontStyle.HEADER : FontStyle.BODY));
row.addView(t);
}
return row;
}
/**
*
*/
public static ViewGroup getInput(Context context) {
Log.v(TAG, "Setting up input");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup input = (ViewGroup)inflater.inflate(R.layout.input, null);
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)input.findViewById(R.id.inputCommand)).setTypeface(fm.getFont(FontStyle.SELECTABLE));
((TextView)input.findViewById(R.id.inputValue)).setTypeface(fm.getFont(FontStyle.BODY));
((TextView)input.findViewById(R.id.inputConfirm)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)input.findViewById(R.id.inputRetry)).setTypeface(fm.getFont(FontStyle.HEADER));
((TextView)input.findViewById(R.id.inputInstruction)).setTypeface(fm.getFont(FontStyle.BODY));
return input;
}
/**
*
* @param container
*/
public static ViewGroup getTimer(Context context){
Log.v(TAG, "Setting up timer");
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup timer = (ViewGroup)inflater.inflate(R.layout.timer, null);
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
((TextView)timer.findViewById(R.id.timerTimeText)).setTypeface(fm.getFont(FontStyle.TIMER));
((TextView)timer.findViewById(R.id.timerStartText)).setTypeface(fm.getFont(FontStyle.SELECTABLE));
((TextView)timer.findViewById(R.id.timerStopText)).setTypeface(fm.getFont(FontStyle.SELECTABLE));
((TextView)timer.findViewById(R.id.timerResetText)).setTypeface(fm.getFont(FontStyle.SELECTABLE));
return timer;
}
/**
*
* @param context
* @return
*/
public static View getCallGround(Context context) {
TextView v = (TextView)LayoutInflater.from(context).inflate(R.layout.call_ground, null);
//Set up the custom fonts
FontManager fm = FontManager.getInstance(context.getAssets());
v.setTypeface(fm.getFont(FontStyle.BODY));
return v;
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
206636c05ebdf71d3d351ea74ec02a2dbdd289a7 | 3cb918d48afb3d85d5f0c1fbc6e284ebfa5d6355 | /src/main/java/com/wthfeng/learn/lang/SortTest.java | fb4f8ec1d6575fecc3e93c2c2dc3a814a8d92ac6 | [
"Apache-2.0"
] | permissive | wangtonghe/learn-sample | d1d9d70e07aae1a41da3fdb56dac9ca2b93cdb17 | 121b9e4ce32b0d86f8d1e1a098627ce5f5fd5115 | refs/heads/master | 2021-01-20T05:53:36.040204 | 2019-04-16T02:10:29 | 2019-04-16T02:10:29 | 89,820,448 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,206 | java | package com.wthfeng.learn.lang;
import java.util.Arrays;
/**
* 排序;练习
*
* @author wangtonghe
* @date 2017/8/16 09:22
*/
public class SortTest {
public int[] sort(int[] array) {
quickSort(array, 0, array.length - 1);
return array;
}
private void quickSort(int[] arr, int low, int high) {
if (low > high) {
return;
}
int base = arr[low];
int i = low;
int j = high;
while (i < j) {
while (arr[j] >= base && i < j) {
j--;
}
while (arr[i] <= base && i < j) {
i++;
}
// if (i < j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
// }
}
int tmp = arr[j];
arr[j] = arr[low];
arr[low] = tmp;
quickSort(arr, low, j - 1);
quickSort(arr, j + 1, high);
}
public static void main(String[] args) {
SortTest sortTest = new SortTest();
int[] arr = {6, 1, 2, 5, 4, 3, 9, 7, 10, 8};
sortTest.sort(arr);
Arrays.stream(arr).forEach(e -> System.out.print(e + " "));
}
}
| [
"wthfeng@126.com"
] | wthfeng@126.com |
160d42224547449ec5cdc0a49fae94651244cc01 | 7c4cb7516542776db2476e3b9f42d10af8bba921 | /ScoreBookServices/src/main/java/com/fun/learning/listeners/LoginSuccessEventListener.java | 9a3bf1a321d3987da7fb52ca4762284dd64f4a3a | [] | no_license | vikas2453/scoreBookServices | 7c752645b76f7620c96837dd71dea537404353a6 | 3c731aea398f1b41e7620a3a35119760a8c4d81d | refs/heads/master | 2020-06-02T05:32:17.373219 | 2019-10-14T18:15:12 | 2019-10-14T18:15:12 | 191,054,888 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,360 | java | package com.fun.learning.listeners;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
//import org.springframework.security.access.event.AuthorizedEvent;
//import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.stereotype.Component;
import com.fun.learning.model.User;
import com.fun.learning.repo.UserRepo;
import com.fun.learning.service.UserDetailsServiceJDBC;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Component
@Data
@Slf4j
@NoArgsConstructor
@AllArgsConstructor
public class LoginSuccessEventListener implements ApplicationListener<AuthenticationSuccessEvent> {
@Autowired
private UserDetailsServiceJDBC userDetailsService;
@Override
public void onApplicationEvent(AuthenticationSuccessEvent event) {
Object obj=event.getAuthentication().getPrincipal();
if(obj instanceof User) {
User user = (User) obj;
if (user.getLoginFailedAttempt() > 0) {
log.debug("updating login attempt for user:{})", user.getUsername());
userDetailsService.updateLoginAttempt(user, true);
}
}
}
}
| [
"M1052611@mindtree.com"
] | M1052611@mindtree.com |
d70eca9f1545a25152d96166be18746910e6ad5f | 0c006defa311877bed6b1e8240aa8e3195250d1b | /src/main/java/models/CsvEmpModel.java | a92673e219b4b47c49fc3e31cf5a79709d57cab4 | [] | no_license | PavlinPavlov/monthly-performance-reports | faff1681ca5a40535f5a47bcce967a2089995510 | 04a9517d91f1d22cd313abcba1059e553a55c39b | refs/heads/master | 2022-11-23T20:55:32.270785 | 2019-05-27T07:37:40 | 2019-05-27T07:37:40 | 188,677,710 | 0 | 0 | null | 2022-11-16T05:56:31 | 2019-05-26T12:04:10 | Java | UTF-8 | Java | false | false | 510 | java | package models;
public class CsvEmpModel {
private String name;
private double score;
public CsvEmpModel() {
}
public CsvEmpModel(String name, double score) {
this.name = name;
this.score = score;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
}
| [
"88pavlin888@gmail.com"
] | 88pavlin888@gmail.com |
04690385a289eaf5bedd9c9f701143ccd661f3f6 | 9d325779d668db4d887079f17e2bcf5e158c0955 | /modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/SignalEventReceivedCmd.java | 7d842173a8ec44955018cc3d0bb5fa15f577ed94 | [
"Apache-2.0"
] | permissive | 105032013072/Activiti-5.14 | d5981cf982dd920622cd7ea710bf2711f18e3803 | 34afdbfd4142e23b3594dd65500d38c4d5ec9a9b | refs/heads/master | 2022-12-23T01:21:35.472610 | 2019-06-06T12:52:46 | 2019-06-06T12:52:46 | 185,395,953 | 0 | 0 | null | 2022-12-16T00:39:08 | 2019-05-07T12:19:59 | Java | UTF-8 | Java | false | false | 3,670 | java | /* 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.activiti.engine.impl.cmd;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity;
import org.activiti.engine.runtime.Execution;
/**
* @author Daniel Meyer
* @author Joram Barrez
*/
public class SignalEventReceivedCmd implements Command<Void> {
protected final String eventName;
protected final String executionId;
protected final Serializable payload;
protected final boolean async;
public SignalEventReceivedCmd(String eventName, String executionId, Map<String, Object> processVariables) {
this.eventName = eventName;
this.executionId = executionId;
if (processVariables != null) {
if (processVariables instanceof Serializable){
this.payload = (Serializable) processVariables;
}
else{
this.payload = new HashMap<String, Object>(processVariables);
}
}
else{
this.payload = null;
}
this.async = false;
}
public SignalEventReceivedCmd(String eventName, String executionId, boolean async) {
this.eventName = eventName;
this.executionId = executionId;
this.async = async;
this.payload = null;
}
public Void execute(CommandContext commandContext) {
List<SignalEventSubscriptionEntity> signalEvents = null;
if(executionId == null) {
signalEvents = commandContext.getEventSubscriptionEntityManager()
.findSignalEventSubscriptionsByEventName(eventName);
} else {
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("Cannot find execution with id '" + executionId + "'", Execution.class);
}
if (execution.isSuspended()) {
throw new ActivitiException("Cannot throw signal event '" + eventName
+ "' because execution '" + executionId + "' is suspended");
}
signalEvents = commandContext.getEventSubscriptionEntityManager()
.findSignalEventSubscriptionsByNameAndExecution(eventName, executionId);
if(signalEvents.isEmpty()) {
throw new ActivitiException("Execution '"+executionId+"' has not subscribed to a signal event with name '"+eventName+"'.");
}
}
for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : signalEvents) {
// We only throw the event to globally scoped signals.
// Process instance scoped signals must be thrown within the process itself
if (signalEventSubscriptionEntity.isGlobalScoped()) {
signalEventSubscriptionEntity.eventReceived(payload, async);
}
}
return null;
}
}
| [
"1337893145@qq.com"
] | 1337893145@qq.com |
b0441987f276f89ed09e0c645f30f4c1b8767a89 | 5b13269ee82a20eb7689c8bba25a35b04e277086 | /src/main/java/com/rueggerllc/transaction/BackendTransactionServiceApplication.java | 6126eadd86b539be164a98d6254efd9a4d300108 | [] | no_license | rueggerc/BackendTransactionService | 55413ac2179cb0af44d20def4a1ac4f1697b9ca4 | 79399ed801ea4e5a9c68b965781da81205bd9278 | refs/heads/master | 2020-03-28T07:53:17.533891 | 2018-09-08T12:22:39 | 2018-09-08T12:22:39 | 147,930,322 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 356 | java | package com.rueggerllc.transaction;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BackendTransactionServiceApplication {
public static void main(String[] args) {
SpringApplication.run(BackendTransactionServiceApplication.class, args);
}
}
| [
"chris.ruegger@gmail.com"
] | chris.ruegger@gmail.com |
d86d97b63978fc95ed96dba217dfd388b7f744d6 | 03e99af26b6186328c8a8a6ffa4a40427188a9f9 | /src/main/java/SpringBoot/SpringBootGetStarted/controller/HelloController.java | b6e1701c9985f53ae649c28584d4fa52d1ee5a69 | [] | no_license | TyronneJeong/SpringBoot-GetStarted | 6746187d9203244fcf42c7296bec97cc4c09c918 | 6be759867090e0eb3d5bfae0dd1e9ce0cfa51b6e | refs/heads/main | 2023-08-27T14:42:13.823286 | 2021-11-06T06:48:38 | 2021-11-06T06:48:38 | 416,008,536 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,013 | java | package SpringBoot.SpringBootGetStarted.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
// ***********************************************************************************
// [패키지 압축 및 실행]
// gradlew 를 통해 패키지 압축이 가능하다.
// 압축된 패키지는 build/libs/{file_name}.jar 형태로 생성된다.
// java -jar {file_name} 으로 해당 jar 를 구동 시키면 서버 컨테이너를 포함하여 모두 기동 가능하다.
// [gradle]
// gradlew build : 패키지를 빌드한후 jar 로 압축 함
// gradlew clean : build 된 패키지를 삭제함
// gradlew clean build : 기존 생성된 build 패키지를 삭제후 재 빌드 함
// ***********************************************************************************
// STEP1. 기초적인 웹 서비스
@GetMapping("hello") // URL:localhost8080/hello
public String hello(Model model) {
// 1. 속성값<K, V> 정의 - data:Hello!!
model.addAttribute("data", "Hello!!");
// 2. 리다이렉트 될 페이지 정보
// viewResolver >> 리다이렉트 되는 파일의 이름
// default path : resources:template/{ViewName}.html
// spring-boot-devtools 설치시 HTML 파일의 경우 컴파일후 바로 확인 가능
return "hello";
}
// STEP2. MVC 호출 템플릿
@GetMapping("hello-mvc")
public String helloMvc(@RequestParam(value="name", required = true) String name, Model model){
model.addAttribute("name", name);
return "hello-template";
}
// STEP3. 리다이렉션 페이지 호출이 아닌 플레인 스트링 리턴
// @ResponseBody 지정시 리턴 값은 viewResolver 에 전달되는 것이 아니라 <HttpMessageConverter> 로 전달
@GetMapping("hello-string")
@ResponseBody
public String helloString(@RequestParam("name") String name){
return "hello "+name;
}
// STEP4. 클래스 객체를 <HttpMessageConverter> 로 전달
// HttpMessageConverter 는 객체를 [JSON Converter] 와 [String Converter] 중 하나로 처리함
// [JSON Converter] - 객체
// [String Converter] - 문자
// <K, V> 타입의 경우 JSON 형태로 변환하여 리턴 함
@GetMapping("hello-api")
@ResponseBody
public Hello helloApi(@RequestParam("name") String name){
Hello hello = new Hello();
hello.setName(name);
return hello;
}
// 전달되는 Hello Class
static class Hello {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
} | [
"maurois@nate.com"
] | maurois@nate.com |
fe9ff1a86edf0644d320ba0efc1b9232d91014ac | be18401eab59b6350c03c26b5b18f8021b02b6a7 | /src/main/java/it/thomasiommi/mongocktest/service/PersonService.java | a102254e4b9623cd00c73b336e0e961fe71a649d | [] | no_license | ThomasIommi/mongocktest | b974d8c585eaf49ed4ef91a0f06a09d64fd10d14 | 418f489d129b5755531755bde22a8dea975bf8a3 | refs/heads/master | 2023-01-07T19:07:42.007356 | 2020-11-08T22:51:35 | 2020-11-08T22:51:35 | 311,170,479 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | package it.thomasiommi.mongocktest.service;
import it.thomasiommi.mongocktest.model.Person;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public interface PersonService {
/**
* Insert a person into the repository
* @param p Person to insert
* @return Inserted person
*/
Person insert(Person p);
/**
* Search a person by id
* @param id UUID of the person to get
* @return {@code Optional} of the searched person
*/
Optional<Person> findById(UUID id);
/**
* Search all people
* @return {@code List} of all the people in the repository
*/
List<Person> findAll();
/**
* Updates a person on the repository
* @param p Person to update
* @return Updated person
*/
Person save(Person p);
}
| [
"ThomasIommi6R@gmail.com"
] | ThomasIommi6R@gmail.com |
93d300c870cffb7029e93b753497f84440cd7cf2 | 96cc1b7bb63c4d8629913619aae86cbe29b51ef4 | /wwy-parent/wwy-servie/src/main/java/wwy/service/impl/TestBeanInit.java | 75b883ced449f1bd78aa794650835f22080eef1f | [] | no_license | wwyhere/wwy | 8408961eb8446d700ad8141a4eefda2e701c23a1 | 86c19ea7f149f97e928e8fc636e15d5d9e4d74aa | refs/heads/master | 2016-09-06T11:44:32.611553 | 2015-10-01T15:02:10 | 2015-10-01T15:02:10 | 34,652,622 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,091 | java | package wwy.service.impl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@Order(Integer.MIN_VALUE + 1000)
@Configuration
public class TestBeanInit implements InitializingBean, DisposableBean, BeanDefinitionRegistryPostProcessor {
@SuppressWarnings("unused")
@Autowired
private TestBeanService testBeanService;
public void init() {
System.out.println("方法初始化!");
}
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("init1....");
}
@Override
public void destroy() throws Exception {
System.out.println("destroy1....");
}
// Start:手动注入bean例子
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory paramConfigurableListableBeanFactory)
throws BeansException {
Boolean bool = paramConfigurableListableBeanFactory.containsBean("codeBean");
System.out.println("是否包含codeBean:" + bool);
}
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry paramBeanDefinitionRegistry)
throws BeansException {
BeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
beanDefinition.setBeanClassName("test.CodeBean");
beanDefinition.setAutowireCandidate(true);
paramBeanDefinitionRegistry.registerBeanDefinition("codeBean", beanDefinition);
}
// End:手动注入bean例子
}
| [
"wwyhere@163.com"
] | wwyhere@163.com |
2f2f296d5ac02a4e1414f1da96cb62df8cb7853e | edfe439ac313805d38a6aa0ae4f8612313fd512c | /app/src/main/java/com/navlauncher/app/Destination.java | 9ee41d4ed7dc32a8d2f2aa8500b351f32d5aa630 | [] | no_license | scottkennedy/navlauncher | c65b59c2bc41b83e7d637e80ae6e015392b8ab64 | fbfb24d2a45e010b2b7717824b4b74575e77fad9 | refs/heads/master | 2023-01-11T09:28:45.491223 | 2015-10-22T04:51:26 | 2015-10-22T04:51:26 | 44,721,998 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 473 | java | package com.navlauncher.app;
public class Destination {
private final int mId;
private final String mAddress;
public Destination(final int id, final String address) {
super();
mId = id;
mAddress = address;
}
public int getId() {
return mId;
}
public String getAddress() {
return mAddress;
}
@Override
public String toString() {
return mAddress;
}
}
| [
"scott@squanda.com"
] | scott@squanda.com |
f3474571f53092ae2fa496f1d147a46228c39fdb | 8508251ba39604203b025c1368f2779cd6f75586 | /src/ejerciciosbasicos/Multas.java | 032d983fd696faa8dea05a1cab327c41621962d5 | [] | no_license | SaharaNitido/EjerciciosBasicos | 4b697a1503dcd1347f6f1195151d39088d4b6e8d | d43a1f6e2fb6fc6e8cf938f5343bcfddc3671187 | refs/heads/master | 2023-03-03T05:26:18.406066 | 2021-02-13T10:58:44 | 2021-02-13T10:58:44 | 330,947,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 284 | 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 ejerciciosbasicos;
/**
*
* @author Mulay
*/
public class Multas {
}
| [
"Mulay@DESKTOP-1DQT6OU.home"
] | Mulay@DESKTOP-1DQT6OU.home |
a5ae7c3f6c94075a0362dafce3770f65d4f53c1f | c932fa37e0c116d6452be374be840dcb5230f09a | /app/src/main/java/com/zhusr/rxjava2demo/frag/RxLifeFragment.java | 71d8619a9c06d2b699dfb997300d6a6c6a7f2cb7 | [] | no_license | 17722525963/RxJava2Demo | 5b418718b60e4929e0214b3dc64c4ef413f10ecb | 3533e85dbba839d61e512f712a4c5b0152b3cbdd | refs/heads/master | 2021-01-23T14:44:34.136135 | 2017-11-01T05:39:36 | 2017-11-01T05:39:36 | 102,696,613 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,125 | java | package com.zhusr.rxjava2demo.frag;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import com.jakewharton.rxbinding2.view.RxView;
import com.trello.rxlifecycle2.android.FragmentEvent;
import com.trello.rxlifecycle2.components.support.RxFragment;
import com.zhusr.rxjava2demo.R;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
/**
* Created by zhusr on 2017/10/12.
*/
public class RxLifeFragment extends RxFragment {
@BindView(R.id.test)
Button test;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.frag_rxlifefragment, null);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
RxView.clicks(test)
.throttleFirst(2000, TimeUnit.MILLISECONDS)
.compose(bindUntilEvent(FragmentEvent.PAUSE))
.subscribe(new Observer<Object>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull Object o) {
Toast.makeText(getActivity(), "clicked!" + System.currentTimeMillis(), Toast.LENGTH_SHORT).show();
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
@Override
public void onStart() {
super.onStart();
}
}
| [
"zhusr@szcatic.com"
] | zhusr@szcatic.com |
ab193cd25100ee692d0fd0a6e696550092c11f09 | 5cb0c96cc6613b99c8849ef07c3a2340f3fe21a2 | /haikuReview/20140213-xavi-someone/src/test/java/HaikuTest.java | 3a783ade0a141ed2e5aa7d42a98bc6e2a94a52cd | [] | no_license | novoda/dojos | 2e5a671025924df5674f55e9e8d89db51abf0dcf | 2e7391623b42617af1bbdad227e3e4701e89af2c | refs/heads/master | 2020-04-12T02:27:04.819306 | 2019-04-10T19:55:32 | 2019-04-10T19:55:32 | 6,509,909 | 68 | 20 | null | 2019-03-28T15:27:16 | 2012-11-02T17:34:28 | Java | UTF-8 | Java | false | false | 1,743 | java | import org.junit.Test;
import java.util.List;
import static org.fest.assertions.api.Assertions.assertThat;
public class HaikuTest {
private static final String INPUT_ONE = "happy purple frog/eating bugs in the marshes/get indigestion";
private static final String INPUT_TWO = "computer programs/the bugs try to eat my code/i will not let them";
@Test
public void testThatGivenStringWith3Lines_returnsValidForLineCount() {
String validFormatHaiku = "input/three/lines";
Haiku haiku = new Haiku(validFormatHaiku);
assertThat(haiku.isValidLineCount()).isTrue();
}
@Test
public void test_that_it_breaks_up_into_3_lines() {
Haiku haiku = new Haiku(INPUT_ONE);
List<Haiku.Line> lines = haiku.asLines();
assertThat(lines.size()).isEqualTo(3);
}
@Test
public void test_that_a_Line_should_have_at_least_one_word() {
Haiku.Line line = new Haiku.Line("hello");
assertThat(line).isNotNull();
}
@Test(expected = Haiku.Line.LineException.class)
public void test_that_a_line_should_fail_if_empty() {
Haiku.Line line = new Haiku.Line("");
}
@Test
public void test_that_a_line_should_split_into_words() {
Haiku.Line line = new Haiku.Line("hello world");
List<Haiku.Word> words = line.getWords();
assertThat(words.size()).isEqualTo(2);
assertThat(words).contains(Haiku.Word.from("hello"), Haiku.Word.from("world"));
}
// @Test
// public void test_that_a_word_hould_split_into_syllables() {
// Haiku.Word word = Haiku.Word.from("hello");
//
// List<Haiku.Syllable> syllables = word.getSyllables();
//
// assertThat(syllables).hasSize(2);
// }
}
| [
"xrigau@gmail.com"
] | xrigau@gmail.com |
abcd129f12e9bf0f7cb84756f694d6cf66d315dc | 8aeab86a2808cd0e6c61154814cfabbb80fdbc86 | /APR_gestion/src/com/apr_gestion/Login.java | 8f79b2c8dc3d13bff309be9f623ddbb0284488e9 | [] | no_license | EduardoLlancanao/gestion_ingreso_egreso | 874da49e5dd2fdf223516ca36459851b0fd9f435 | 352bc04aeb6339dd25500b34fab3a38c9eec85c1 | refs/heads/master | 2022-11-24T22:01:49.469373 | 2020-08-03T05:24:32 | 2020-08-03T05:24:32 | 270,868,284 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,651 | java | package com.apr_gestion;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.apr_gestion.model.MainDB;
/**
* Servlet implementation class Login
*/
@WebServlet("/Login")
public class Login extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// 1. get received JSON data from request
BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
String json = "";
if(br != null){
json = br.readLine();
// System.out.println(json);
}
JSONObject data= new JSONObject();
JSONParser parser = new JSONParser();
JSONObject res= new JSONObject();
Boolean pedido;
try {
data=(JSONObject) parser.parse(json);
System.out.println("correo "+data.get("correo"));
System.out.println("password "+data.get("pass"));
MainDB mb = new MainDB();
pedido = true;
// pedido = mb.User_Acceso(data.get("correo").toString(), data.get("pass").toString());
response.setContentType("application/json");
response.setHeader("Cache-Control", "nocache");
response.setCharacterEncoding("utf-8");
res.put("acceso", pedido);
PrintWriter out = response.getWriter();
out.print(res);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// doGet(request, response);
}
}
| [
"eduardo.llancanao2095@gmail.com"
] | eduardo.llancanao2095@gmail.com |
ffb38f6346c87996f1266c8fdcfd377f45c75b93 | 705a5ef754dd16516c99db5fe16209a32e3874d4 | /src/com/bjsxt/state/HomeContext.java | 110365d89d016c422a23ef77940bbdbcf3d48155 | [] | no_license | Lijiale96/pattern | adaff8673eb664dcfddb4d677969045b5ceb08e3 | 7f4efa834da874b3990dcc402663446aec5b40cd | refs/heads/master | 2021-01-04T00:28:44.470788 | 2020-02-20T11:26:48 | 2020-02-20T11:26:48 | 240,452,671 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 341 | java | package com.bjsxt.state;
/**
* 房间对象
*/
public class HomeContext {
//如果是银行系统,这个Context类就是账号。根据金额不同,切换不同的状态
private State state;
public void setState(State s){
System.out.println("修改状态!");
state = s;
state.handle();
}
}
| [
"ljl512@163.com"
] | ljl512@163.com |
1b9cf161b9d8897f903914939ed19b8833d0b3e6 | 9e1be169c7c5e7256e9faf3ee34b638461348656 | /src/main/java/com/food/controller/ReviewController.java | a50c50db1e2be9efb4aa3a4ae2d16bd9d73bb180 | [] | no_license | myqlrs/food | e0765cc6f6b68bd009bb5bb2f836d389cc1db094 | 50b9b0b8f7b69083bf80cf3ed9f0537abaf1dee3 | refs/heads/master | 2023-02-15T15:49:17.506555 | 2020-12-28T13:12:55 | 2020-12-28T13:12:55 | 323,368,581 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,323 | java | package com.food.controller;
import com.food.pojo.Review;
import com.food.service.ProductService;
import com.food.service.ReviewService;
import com.food.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
* @author 孟赟强
* @date 2020/12/20-16:21
* 评论模块controller
*/
@Controller
@RequestMapping("/review")
public class ReviewController {
@Autowired
private ReviewService reviewService;
@Autowired
private ProductService productService;
@RequestMapping("/list")
public String list(Model model, Page page){
PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询
List<Review> list= reviewService.list();
int total = (int) new PageInfo<>(list).getTotal();//总条数
page.setTotal(total);
model.addAttribute("totals",list.size());
model.addAttribute("list",list);
return "pinglunpage/pinglun";
}
@RequestMapping("/del")
public String del(int id){
reviewService.del(id);
return "redirect:list";
}
}
| [
"531353101@qq.com"
] | 531353101@qq.com |
1a9c327b1591e96bf943453e7b9a75b24fc12770 | 185f371f1b0ac5e0dfa276079855fb480efdb7a7 | /generated-archetype/some-artifact/src/main/java/com/company/client/SomeModule.java | 91831742ec9a48d2bff8abdff0fac9de761fbcfc | [
"Apache-2.0"
] | permissive | gwt-maven-plugin/gwt-maven-plugin | 3105b4eeef9de7646d72c44e3500d2f955823af2 | ac3b9481000059295e14ad6b83961add5eb133d1 | refs/heads/master | 2023-05-03T20:27:38.202748 | 2022-06-25T20:56:16 | 2022-06-25T20:56:16 | 1,820,568 | 76 | 91 | Apache-2.0 | 2023-04-17T19:45:47 | 2011-05-30T07:56:10 | Java | UTF-8 | Java | false | false | 5,467 | java | package com.company.client;
import com.company.shared.FieldVerifier;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class SomeModule implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network "
+ "connection and try again.";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
private final Messages messages = GWT.create(Messages.class);
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Button sendButton = new Button( messages.sendButton() );
final TextBox nameField = new TextBox();
nameField.setText( messages.nameField() );
final Label errorLabel = new Label();
// We can add style names to widgets
sendButton.addStyleName("sendButton");
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("errorLabelContainer").add(errorLabel);
// Focus the cursor on the name field when the app loads
nameField.setFocus(true);
nameField.selectAll();
// Create the popup dialog box
final DialogBox dialogBox = new DialogBox();
dialogBox.setText("Remote Procedure Call");
dialogBox.setAnimationEnabled(true);
final Button closeButton = new Button("Close");
// We can set the id of a widget by accessing its Element
closeButton.getElement().setId("closeButton");
final Label textToServerLabel = new Label();
final HTML serverResponseLabel = new HTML();
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.addStyleName("dialogVPanel");
dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
dialogVPanel.add(textToServerLabel);
dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
dialogVPanel.add(serverResponseLabel);
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
dialogVPanel.add(closeButton);
dialogBox.setWidget(dialogVPanel);
// Add a handler to close the DialogBox
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
sendButton.setEnabled(true);
sendButton.setFocus(true);
}
});
// Create a handler for the sendButton and nameField
class MyHandler implements ClickHandler, KeyUpHandler {
/**
* Fired when the user clicks on the sendButton.
*/
public void onClick(ClickEvent event) {
sendNameToServer();
}
/**
* Fired when the user types in the nameField.
*/
public void onKeyUp(KeyUpEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
sendNameToServer();
}
}
/**
* Send the name from the nameField to the server and wait for a response.
*/
private void sendNameToServer() {
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameField.getText();
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}
// Then, we send the input to the server.
sendButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
greetingService.greetServer(textToServer, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox.setText("Remote Procedure Call - Failure");
serverResponseLabel.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}
}
// Add a handler to send the name to the server
MyHandler handler = new MyHandler();
sendButton.addClickHandler(handler);
nameField.addKeyUpHandler(handler);
}
}
| [
"py.ricau@gmail.com"
] | py.ricau@gmail.com |
d7a2af68124ec261f1f6d303fb880309ae78685c | 42334c003699dcb437efd841e53e33838e8d7f2d | /C30aJavaFXEvents/EventProcessingFX/MouseEventHandler.java | 3d7cfe997e1b6263b6cdd10ae916ecaae066aeed | [] | no_license | CISC3115TY3FA18/SamplePrograms | 1d6953c7235d87da68dcf162afffbf76833c573a | 2afedfcfa9e8b2a458fc4ba1e61d0717e52e7dc2 | refs/heads/master | 2020-03-27T23:49:25.711525 | 2018-12-07T00:14:13 | 2018-12-07T00:14:13 | 147,349,702 | 0 | 7 | null | null | null | null | UTF-8 | Java | false | false | 1,066 | java | import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
public class MouseEventHandler implements EventHandler<MouseEvent> {
private StringBuilder sb = new StringBuilder();
private String tag;
public MouseEventHandler(StringBuilder sb, String tag) {
this.sb = sb;
this.tag = tag;
}
public void handle(MouseEvent e) {
sb.append("\n\t-> capured/bubbled at " + e.getSource().toString() + " with event tag as " + tag);
System.out.println(tag + ": mouse clicked: source -> target:" + e.getSource() + "->" + e.getTarget());
// if (e.getSource() instanceof javafx.scene.layout.Pane && tag.contains("filter")) {
// e.consume();
// System.out.println("\n\tevent is consumed at " + e.getSource().toString() + " no more capturing and bubbling");
// }
// if (e.getSource() instanceof javafx.scene.shape.Circle && tag.contains("handler")) {
// e.consume();
// System.out.println("\n\tevent is consumed at " + e.getSource().toString() + " no more bubbling");
// }
}
}
| [
"hui.chen@brooklyn.cuny.edu"
] | hui.chen@brooklyn.cuny.edu |
d2455e2f408521491c5c983a6a6e4e58a01707e9 | c5633ebd8c7911460c36dd052c04a7adfa2a86b6 | /ParseStarterProject/src/com/livejoints/bluetooth/BluetoothLeService.java | a7bb0512863cdb2cd19a31508f25683900d161d1 | [
"LicenseRef-scancode-unicode-mappings",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | hwswfun/LiveJointsAndroid | 428c17a623d87f8bd6bdcbdf3eb04064c1836861 | edfdf5f393bbd885f6644fa95e9c668e163447a1 | refs/heads/master | 2021-09-21T19:27:47.499757 | 2018-08-30T17:27:23 | 2018-08-30T17:27:23 | 43,042,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,508 | java | /*
* Copyright (C) 2013 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.livejoints.bluetooth;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import com.livejoints.analytics.ParseDataCollector;
import org.apache.commons.math3.stat.regression.RegressionResults;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import java.util.List;
import java.util.UUID;
/**
* Service for managing connection and data communication with a GATT server hosted on a
* given Bluetooth LE device.
*/
public class BluetoothLeService extends Service {
private final static String TAG = BluetoothLeService.class.getSimpleName();
private ParseDataCollector pdc = null;
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private String mBluetoothDeviceAddress;
private BluetoothGatt mBluetoothGatt;
private int mConnectionState = STATE_DISCONNECTED;
SimpleRegression regression = null;
private static final int STATE_DISCONNECTED = 0;
private static final int STATE_CONNECTING = 1;
private static final int STATE_CONNECTED = 2;
public final static String ACTION_GATT_CONNECTED =
"com.example.bluetooth.le.ACTION_GATT_CONNECTED";
public final static String ACTION_GATT_DISCONNECTED =
"com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
public final static String ACTION_GATT_SERVICES_DISCOVERED =
"com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
public final static String ACTION_DATA_AVAILABLE =
"com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
public final static String EXTRA_DATA =
"com.example.bluetooth.le.EXTRA_DATA";
public final static String SENSOR_SUMMARY_AVAILABLE =
"com.example.bluetooth.le.SENSOR_SUMMARY_AVAILABLE";
public final static UUID UUID_ANGLE_MEASUREMENT = UUID.fromString(RFduinoGattAttributes.ANGLE_MEASUREMENT_CHARACTERISTIC);
// Implements callback methods for GATT events that the app cares about. For example,
// connection change and services discovered.
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction);
Log.i(TAG, "Connected to GATT server.");
// Attempts to discover services after successful connection.
Log.i(TAG, "Attempting to start service discovery:" +
mBluetoothGatt.discoverServices());
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "Disconnected from GATT server.");
broadcastUpdate(intentAction);
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
} else {
Log.w(TAG, "onServicesDiscovered received: " + status);
}
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
//Log.d(TAG, "char changed" );
}
};
private void broadcastUpdate(final String action) {
final Intent intent = new Intent(action);
sendBroadcast(intent);
}
static int counter = 0;
private void broadcastUpdate(final String action,
final BluetoothGattCharacteristic characteristic) {
final Intent intent = new Intent(action);
if (UUID_ANGLE_MEASUREMENT.equals(characteristic.getUuid())) {
String s = new String(characteristic.getStringValue(0));
// should fix the null / 0 issue at sensor, not here....
if ((s == null) || (s.length() == 0)) s = "0";
if (s != null && s.length() > 0) {
Log.d(TAG, "new reading: " + s);
counter++;
if ((counter % 1) == 0) {
counter = 0;
//dc.add(angle);
int angle = Integer.parseInt(s);
int calibratedAngle = (int) (regression.predict(angle));
if (calibratedAngle < 0) calibratedAngle=0;
Log.d(TAG, "calibrated reading: " + calibratedAngle);
String calibratedAngleStr = ""+calibratedAngle;
intent.putExtra(EXTRA_DATA, calibratedAngleStr);
sendBroadcast(intent);
boolean newSensorSummaryAvailable = pdc.add(calibratedAngle);
if (newSensorSummaryAvailable==true) {
Log.d(TAG, "=======> new sensor summary available");
// need to broadcast that there is a new sensorsummary available
final Intent ssIntent = new Intent(SENSOR_SUMMARY_AVAILABLE);
sendBroadcast(ssIntent);
}
}
}
} else {
// For all other profiles, writes the data formatted in HEX.
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for(byte byteChar : data)
stringBuilder.append(String.format("%02X ", byteChar));
intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString());
sendBroadcast(intent);
}
}
}
public class LocalBinder extends Binder {
public BluetoothLeService getService() {
return BluetoothLeService.this;
}
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
@Override
public boolean onUnbind(Intent intent) {
// After using a given device, you should make sure that BluetoothGatt.close() is called
// such that resources are cleaned up properly. In this particular example, close() is
// invoked when the UI is disconnected from the Service.
close();
return super.onUnbind(intent);
}
private final IBinder mBinder = new LocalBinder();
/**
* Initializes a reference to the local Bluetooth adapter.
*
* @return Return true if the initialization is successful.
*/
public boolean initialize() {
// For API level 18 and above, get a reference to BluetoothAdapter through
// BluetoothManager.
if (mBluetoothManager == null) {
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
if (mBluetoothManager == null) {
Log.e(TAG, "Unable to initialize BluetoothManager.");
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
if (mBluetoothAdapter == null) {
Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
return false;
}
calibrateSensor();
pdc = new ParseDataCollector();
// dont keep tons of the readings around.
pdc.setRetainOnlyPrevious(true);
return true;
}
private void calibrateSensor() {
regression = new SimpleRegression();
// calibrate for standalone white version
// regression.addData(86, 0);
// regression.addData(68, 45);
// regression.addData(48, 90);
// regression.addData(28, 135);
// regression.addData(8, 180);
// calibrate red all in one version
regression.addData(94, 0);
regression.addData(75, 45);
regression.addData(56, 90);
regression.addData(36, 135);
regression.addData(17, 180);
RegressionResults rr = regression.regress();
}
/**
* Connects to the GATT server hosted on the Bluetooth LE device.
*
* @param address The device address of the destination device.
*
* @return Return true if the connection is initiated successfully. The connection result
* is reported asynchronously through the
* {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
* callback.
*/
public boolean connect(final String address) {
if (mBluetoothAdapter == null || address == null) {
Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
return false;
}
/* // Previously connected device. Try to reconnect.
if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
&& mBluetoothGatt != null) {
Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
if (mBluetoothGatt.connect()) {
mConnectionState = STATE_CONNECTING;
return true;
} else {
return false;
}
}*/
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if (device == null) {
Log.w(TAG, "Device not found. Unable to connect.");
return false;
}
// We want to directly connect to the device, so we are setting the autoConnect
// parameter to false.
//mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
Log.d(TAG, "Trying to create a new connection.");
mBluetoothDeviceAddress = address;
mConnectionState = STATE_CONNECTING;
return true;
}
/**
* Disconnects an existing connection or cancel a pending connection. The disconnection result
* is reported asynchronously through the
* {@code BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)}
* callback.
*/
public void disconnect() {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.disconnect();
}
/**
* After using a given BLE device, the app must call this method to ensure resources are
* released properly.
*/
public void close() {
if (mBluetoothGatt == null) {
return;
}
mBluetoothGatt.close();
mBluetoothGatt = null;
}
/**
* Request a read on a given {@code BluetoothGattCharacteristic}. The read result is reported
* asynchronously through the {@code BluetoothGattCallback#onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int)}
* callback.
*
* @param characteristic The characteristic to read from.
*/
public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.readCharacteristic(characteristic);
}
/**
* Enables or disables notification on a give characteristic.
*
* @param characteristic Characteristic to act on.
* @param enabled If true, enable notification. False otherwise.
*/
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
boolean enabled) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
try {
BluetoothGattDescriptor desc = characteristic.getDescriptors().get(0);
boolean test;
test = desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); // return value = true
test = mBluetoothGatt.writeDescriptor(desc); // return value = true
} catch (Exception e) {
Log.e(TAG,e.toString());
}
}
/**
* Enables or disables notification on a give characteristic.
*
* @param characteristic Characteristic to act on.
* @param enabled If true, enable notification. False otherwise.
*/
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, BluetoothGattDescriptor descriptor,
boolean enabled) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
boolean test;
test = descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); // return value = true
test = mBluetoothGatt.writeDescriptor(descriptor); // return value = true
}
/**
* Retrieves a list of supported GATT services on the connected device. This should be
* invoked only after {@code BluetoothGatt#discoverServices()} completes successfully.
*
* @return A {@code List} of supported services.
*/
public List<BluetoothGattService> getSupportedGattServices() {
if (mBluetoothGatt == null) return null;
return mBluetoothGatt.getServices();
}
}
| [
"nathan.tofte@gmail.com"
] | nathan.tofte@gmail.com |
23a279b12762cc9d2effded369ab67cabd8e4722 | 1d4d2163e988c1bd7bf67558f960a9d2890b51fa | /Orl-feed/src/test/java/com/bitcamp/orl/OrlFeedApplicationTests.java | 9b7fee8ea11bafd2303797bbd08cd56c1770b064 | [] | no_license | Ellie-Jung/Orullay | 7caa2a435e8199812ebe623479a2a252f0221c8a | f368ab57f2bbd8a04e7b43eee537ad9433e64b28 | refs/heads/main | 2023-08-23T03:39:06.269471 | 2021-10-04T11:08:41 | 2021-10-04T11:08:41 | 407,002,671 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package com.bitcamp.orl;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class OrlFeedApplicationTests {
@Test
void contextLoads() {
}
}
| [
"jssoyeon@gmail.com"
] | jssoyeon@gmail.com |
7511635e358a5ab847250181ab1adf7aad9a9dab | b83e06306fa03fd150dbc81a0802baa8427f6c5d | /product-backend/src/main/java/application/rest/ProductRest.java | 9217028b39a03734489fad99177f79652d67af6e | [] | no_license | sebChevre/microservices | 96d4ce2e8a77a938874de8d4e7d8a53f5602a92a | ab4c1d90c7d60d2167a9564d7fb8373e99775970 | refs/heads/master | 2021-01-10T04:10:04.996856 | 2015-10-27T11:18:42 | 2015-10-27T11:18:42 | 45,032,771 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,456 | java | package application.rest;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import domain.product.Product;
@Named
@Path("/")
public class ProductRest {
private static List<Product> products = new ArrayList<Product>();
static {
Product product1 = new Product();
product1.setId(1);
product1.setSku("abcd1");
product1.setDescription("Product1");
Product product2 = new Product();
product2.setId(2);
product2.setSku("abcd2");
product2.setDescription("Product2");
Product product3 = new Product();
product3.setId(3);
product3.setSku("abcd3");
product3.setDescription("Product3");
Product product4 = new Product();
product4.setId(4);
product4.setSku("abcd4");
product4.setDescription("Product4");
products.add(product1);
products.add(product2);
products.add(product3);
products.add(product4);
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Product> getProducts() {
return products;
}
@GET
@Path("product")
@Produces(MediaType.APPLICATION_JSON)
public Product getProduct(@QueryParam("id") long id) {
Product prod = null;
for (Product p : products) {
if (p.getId() == id)
prod = p;
}
return prod;
}
}
| [
"sce@GLOB_DEV_PRD009.ju.globaz.ch"
] | sce@GLOB_DEV_PRD009.ju.globaz.ch |
8095de27566faef7c29be060361e207ce86763a9 | 647eef4da03aaaac9872c8b210e4fc24485e49dc | /TestMemory/wandoujia/src/main/java/android/support/v7/widget/dp.java | c518eee15f0afe7a013c33e2ca69a3a881bf7f63 | [] | no_license | AlbertSnow/git_workspace | f2d3c68a7b6e62f41c1edcd7744f110e2bf7f021 | a0b2cd83cfa6576182f440a44d957a9b9a6bda2e | refs/heads/master | 2021-01-22T17:57:16.169136 | 2016-12-05T15:59:46 | 2016-12-05T15:59:46 | 28,154,580 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,605 | java | package android.support.v7.widget;
import android.content.Context;
import android.support.v7.b.c;
import android.support.v7.internal.view.menu.ac;
import android.support.v7.internal.view.menu.i;
import android.support.v7.internal.view.menu.m;
import android.support.v7.internal.view.menu.x;
import android.view.View;
import android.widget.ImageButton;
final class dp
implements x
{
m a;
private i b;
private dp(Toolbar paramToolbar)
{
}
public final void a(Context paramContext, i parami)
{
if ((this.b != null) && (this.a != null))
this.b.b(this.a);
this.b = parami;
}
public final void a(i parami, boolean paramBoolean)
{
}
public final boolean a(ac paramac)
{
return false;
}
public final void b(boolean paramBoolean)
{
int i;
int j;
if (this.a != null)
{
i locali = this.b;
i = 0;
if (locali != null)
j = this.b.size();
}
for (int k = 0; ; k++)
{
i = 0;
if (k < j)
{
if (this.b.getItem(k) != this.a)
continue;
i = 1;
}
if (i == 0)
c(this.a);
return;
}
}
public final boolean b()
{
return false;
}
public final boolean b(m paramm)
{
Toolbar.access$200(this.c);
if (Toolbar.access$300(this.c).getParent() != this.c)
this.c.addView(Toolbar.access$300(this.c));
this.c.mExpandedActionView = paramm.getActionView();
this.a = paramm;
if (this.c.mExpandedActionView.getParent() != this.c)
{
Toolbar.LayoutParams localLayoutParams = this.c.generateDefaultLayoutParams();
localLayoutParams.a = (0x800003 | 0x70 & Toolbar.access$400(this.c));
localLayoutParams.b = 2;
this.c.mExpandedActionView.setLayoutParams(localLayoutParams);
this.c.addView(this.c.mExpandedActionView);
}
Toolbar.access$500(this.c, true);
this.c.requestLayout();
paramm.e(true);
if ((this.c.mExpandedActionView instanceof c))
((c)this.c.mExpandedActionView).a();
return true;
}
public final boolean c(m paramm)
{
if ((this.c.mExpandedActionView instanceof c))
((c)this.c.mExpandedActionView).b();
this.c.removeView(this.c.mExpandedActionView);
this.c.removeView(Toolbar.access$300(this.c));
this.c.mExpandedActionView = null;
Toolbar.access$500(this.c, false);
this.a = null;
this.c.requestLayout();
paramm.e(false);
return true;
}
}
/* Location: C:\WorkSpace\WandDouJiaNotificationBar\WanDou1.jar
* Qualified Name: android.support.v7.widget.dp
* JD-Core Version: 0.6.0
*/ | [
"zhaojialiang@conew.com"
] | zhaojialiang@conew.com |
18ae7fce9de3b467ce21d018d429956e97a8be6a | 8a98a19a0db35676b2fe8b824e8d50aa7877ce45 | /remote/src/main/java/org/switchyard/remote/cluster/RoundRobinStrategy.java | 296976ac10db96b05a10fd03139fea177bd597f7 | [] | no_license | bverburg/core | 6fc35bca5903d9a30c1f49929019ab3f0efd7fcc | 71a30b6c0503c9c9f7625c4c3c46c48871d3b70b | refs/heads/master | 2020-06-04T18:11:56.360309 | 2013-02-05T21:10:50 | 2013-02-06T19:15:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,397 | java | /*
* JBoss, Home of Professional Open Source
* Copyright 2012 Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the @author tags. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package org.switchyard.remote.cluster;
import java.util.List;
import javax.xml.namespace.QName;
import org.switchyard.remote.RemoteEndpoint;
import org.switchyard.remote.RemoteRegistry;
/**
* Round Robin load balancing strategy. The algorithm used here is pretty naive in that the
* index is decoupled from the list of endpoints returned from the remote registry. This means
* there's potential for a given endpoint to be "skipped" in a given cycle if endpoints are
* removed between selections. This is not harmful, but it means this implementation does not
* guarantee completely uniform distribution in the event of cluster topology changes.
*/
public class RoundRobinStrategy extends BaseStrategy {
private int _endpointIdx;
/**
* Create a new RoundRobin strategy.
* @param registry remote registry
*/
public RoundRobinStrategy(RemoteRegistry registry) {
super(registry);
}
@Override
public RemoteEndpoint selectEndpoint(QName serviceName) {
if (getRegistry() == null) {
return null;
}
RemoteEndpoint selectedEp = null;
List<RemoteEndpoint> eps = getRegistry().getEndpoints(serviceName);
if (!eps.isEmpty()) {
_endpointIdx %= eps.size();
selectedEp = eps.get(_endpointIdx);
_endpointIdx++;
}
return selectedEp;
}
}
| [
"kbabo@redhat.com"
] | kbabo@redhat.com |
aead3b7255c0189a14f25af51fab134c88554d79 | 9d8621fab4ca11d5e45587584fb0acf3722496ec | /src/ch12/StringEx12.java | 9b91592bd41fcb13f2997e6250be35f90b8aa049 | [] | no_license | 99dabi/javasource | 423d37ac7bcd511620cef4e8274eddecd77122c5 | 9c6393f7b3038ceffdae8179980e2c070b00fd5a | refs/heads/master | 2023-04-20T06:59:31.190809 | 2021-05-04T06:13:35 | 2021-05-04T06:13:35 | 357,107,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 459 | java | package ch12;
public class StringEx12 {
public static void main(String[] args) {
String str1 ="AbZquartKgu";
//문자열 거꾸로 출력하기
for(int i=str1.length()-1;i>=0;i--) {
System.out.print(str1.charAt(i));
}System.out.println();
//str1 => StringBuilder 변경 후
//문자열을 거꾸로 출력하는 메소드를 찾아서
StringBuilder str2= new StringBuilder(str1);
System.out.println(str2.reverse());
}
}
| [
"99dabi@gmail.com"
] | 99dabi@gmail.com |
f5bb9c4300a3c13d6ed9db1106c34529243983ea | c81fa5782cbca4c675a33b211befc0b0234e4413 | /app/src/main/java/com/frontiertechnologypartners/beganretail/widgets/LoadingDialog.java | 013f522a1388c3b9d8e2284aef1da02396ecb2fb | [] | no_license | sunko8130/BeganRetail | 07c1525029c4f19d679f5efb43d95426b9dc0af9 | 561f3d1d41653c20c84d57d7c2cee7fbd53fef60 | refs/heads/master | 2023-03-27T18:13:09.509816 | 2021-03-26T14:37:05 | 2021-03-26T14:37:05 | 313,586,317 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,855 | java | package com.frontiertechnologypartners.beganretail.widgets;
import android.app.Dialog;
import android.content.Context;
import android.graphics.BlendMode;
import android.graphics.BlendModeColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import com.frontiertechnologypartners.beganretail.R;
import com.github.ybq.android.spinkit.SpinKitView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import butterknife.BindView;
import butterknife.ButterKnife;
public class LoadingDialog extends Dialog {
@BindView(R.id.cp_pbar)
SpinKitView circleLoading;
public LoadingDialog(@NonNull Context context) {
super(context);
}
public LoadingDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
}
protected LoadingDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.progress_bar);
ButterKnife.bind(this);
//Progress Bar Color
setColorFilter(circleLoading.getIndeterminateDrawable(),
ResourcesCompat.getColor(getContext().getResources(), R.color.md_white_1000, null));
}
@SuppressWarnings("deprecation")
private void setColorFilter(Drawable drawable, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
drawable.setColorFilter(new BlendModeColorFilter(color, BlendMode.SRC_ATOP));
} else {
drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}
}
}
| [
"sunko8130@gmail.com"
] | sunko8130@gmail.com |
6a314de8f7da8423abdcedcbc4c8ccf4c2225b23 | 7356ca3d08698d034fbd88120c0651657c59763f | /android-project/TinyChat/src/com/tiny/chat/view/HighlightView.java | f7ea5c91115959a596d129d8d445725832e3846a | [] | no_license | tiny2cui/project | 5eaf38996593020fafb7a1cc0a5e4a273ee8e403 | 45967c27e77f23fe6382980e367206dc57dfe0c3 | refs/heads/master | 2021-01-19T22:13:27.718430 | 2014-09-16T15:09:05 | 2014-09-16T15:09:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,303 | java | package com.tiny.chat.view;
import com.tiny.chat.R;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.RegionIterator;
import android.graphics.drawable.Drawable;
import android.view.View;
// This class is used by CropImage to display a highlighted cropping rectangle
// overlayed with the image. There are two coordinate spaces in use. One is
// image, another is screen. computeLayout() uses mMatrix to map from image
// space to screen space.
public class HighlightView {
@SuppressWarnings("unused")
private static final String TAG = "HighlightView";
View mContext; // The View displaying the image.
public static final int GROW_NONE = (1 << 0);
public static final int GROW_LEFT_EDGE = (1 << 1);
public static final int GROW_RIGHT_EDGE = (1 << 2);
public static final int GROW_TOP_EDGE = (1 << 3);
public static final int GROW_BOTTOM_EDGE = (1 << 4);
public static final int MOVE = (1 << 5);
public HighlightView(View ctx) {
mContext = ctx;
}
private void init() {
android.content.res.Resources resources = mContext.getResources();
// mResizeDrawableWidth =
// resources.getDrawable(R.drawable.gl_camera_crop_width);
// mResizeDrawableHeight =
// resources.getDrawable(R.drawable.gl_camera_crop_height);
mResizeDrawableDiagonal = resources
.getDrawable(R.drawable.picture_cut_button_normal);
mResizeDrawableDiagonal2 = resources
.getDrawable(R.drawable.picture_cut_button_normal);
}
public boolean mIsFocused;
boolean mHidden;
public boolean hasFocus() {
return mIsFocused;
}
public void setFocus(boolean f) {
mIsFocused = f;
}
public void setHidden(boolean hidden) {
mHidden = hidden;
}
public void draw(Canvas canvas) {
if (mHidden) {
return;
}
canvas.save();
Path path = new Path();
if (!hasFocus()) {
mOutlinePaint.setColor(0xFF000000);
canvas.drawRect(mDrawRect, mOutlinePaint);
} else {
Rect viewDrawingRect = new Rect();
mContext.getDrawingRect(viewDrawingRect);
if (mCircle) {
float width = mDrawRect.width();
float height = mDrawRect.height();
path.addCircle(mDrawRect.left + (width / 2), mDrawRect.top
+ (height / 2), width / 2, Path.Direction.CW);
mOutlinePaint.setColor(0xFFEF04D6);
} else {
path.addRect(new RectF(mDrawRect), Path.Direction.CW);
mOutlinePaint.setColor(0xFFFFFFFF);
}
Region region = new Region();
region.set(viewDrawingRect);
region.op(mDrawRect, Region.Op.DIFFERENCE);
RegionIterator iter = new RegionIterator(region);
Rect r = new Rect();
while (iter.next(r)) {
canvas.drawRect(r, hasFocus() ? mFocusPaint : mNoFocusPaint);
}
// canvas.clipPath(path, Region.Op.DIFFERENCE);//android 4.0 Support
// bad.java.lang.UnsupportedOperationException
// canvas.drawRect(viewDrawingRect, hasFocus() ? mFocusPaint :
// mNoFocusPaint);
canvas.restore();
canvas.drawPath(path, mOutlinePaint);
if (mMode == ModifyMode.Grow) {
if (mCircle) {
int width = mResizeDrawableDiagonal.getIntrinsicWidth();
int height = mResizeDrawableDiagonal.getIntrinsicHeight();
int d = (int) Math.round(Math.cos(/* 45deg */Math.PI / 4D)
* (mDrawRect.width() / 2D));
int x = mDrawRect.left + (mDrawRect.width() / 2) + d
- width / 2;
int y = mDrawRect.top + (mDrawRect.height() / 2) - d
- height / 2;
mResizeDrawableDiagonal.setBounds(x, y, x
+ mResizeDrawableDiagonal.getIntrinsicWidth(), y
+ mResizeDrawableDiagonal.getIntrinsicHeight());
mResizeDrawableDiagonal.draw(canvas);
} else {
// int left = mDrawRect.left + 1;
// int right = mDrawRect.right + 1;
// int top = mDrawRect.top + 4;
// int bottom = mDrawRect.bottom + 3;
//
// int widthWidth = mResizeDrawableWidth.getIntrinsicWidth()
// / 2;
// int widthHeight =
// mResizeDrawableWidth.getIntrinsicHeight() / 2;
// int heightHeight =
// mResizeDrawableHeight.getIntrinsicHeight() / 2;
// int heightWidth =
// mResizeDrawableHeight.getIntrinsicWidth() / 2;
//
// int xMiddle = mDrawRect.left + ((mDrawRect.right -
// mDrawRect.left) / 2);
// int yMiddle = mDrawRect.top + ((mDrawRect.bottom -
// mDrawRect.top) / 2);
//
// mResizeDrawableWidth.setBounds(left - widthWidth, yMiddle
// - widthHeight, left + widthWidth, yMiddle
// + widthHeight);
// mResizeDrawableWidth.draw(canvas);
//
// mResizeDrawableWidth.setBounds(right - widthWidth,
// yMiddle - widthHeight, right + widthWidth, yMiddle
// + widthHeight);
// mResizeDrawableWidth.draw(canvas);
//
// mResizeDrawableHeight.setBounds(xMiddle - heightWidth,
// top - heightHeight, xMiddle + heightWidth, top
// + heightHeight);
// mResizeDrawableHeight.draw(canvas);
//
// mResizeDrawableHeight.setBounds(xMiddle - heightWidth,
// bottom - heightHeight, xMiddle + heightWidth, bottom
// + heightHeight);
// mResizeDrawableHeight.draw(canvas);
}
}
if (mCircle) {
} else {
int left = mDrawRect.left + 1;
int right = mDrawRect.right + 1;
int top = mDrawRect.top + 4;
int bottom = mDrawRect.bottom + 3;
int widthWidth = mResizeDrawableDiagonal.getIntrinsicWidth() / 2;
int widthHeight = mResizeDrawableDiagonal.getIntrinsicHeight() / 2;
mResizeDrawableDiagonal2.setBounds(left - widthWidth, top
- widthHeight, left + widthWidth, top + widthHeight);
mResizeDrawableDiagonal2.draw(canvas);
mResizeDrawableDiagonal.setBounds(right - widthWidth, top
- widthHeight, right + widthWidth, top + widthHeight);
mResizeDrawableDiagonal.draw(canvas);
mResizeDrawableDiagonal.setBounds(left - widthWidth, bottom
- widthHeight, left + widthWidth, bottom + widthHeight);
mResizeDrawableDiagonal.draw(canvas);
mResizeDrawableDiagonal2
.setBounds(right - widthWidth, bottom - widthHeight,
right + widthWidth, bottom + widthHeight);
mResizeDrawableDiagonal2.draw(canvas);
}
}
}
public void setMode(ModifyMode mode) {
if (mode != mMode) {
mMode = mode;
mContext.invalidate();
}
}
// Determines which edges are hit by touching at (x, y).
public int getHit(float x, float y) {
Rect r = computeLayout();
final float hysteresis = 20F;
int retval = GROW_NONE;
if (mCircle) {
float distX = x - r.centerX();
float distY = y - r.centerY();
int distanceFromCenter = (int) Math.sqrt(distX * distX + distY
* distY);
int radius = mDrawRect.width() / 2;
int delta = distanceFromCenter - radius;
if (Math.abs(delta) <= hysteresis) {
if (Math.abs(distY) > Math.abs(distX)) {
if (distY < 0) {
retval = GROW_TOP_EDGE;
} else {
retval = GROW_BOTTOM_EDGE;
}
} else {
if (distX < 0) {
retval = GROW_LEFT_EDGE;
} else {
retval = GROW_RIGHT_EDGE;
}
}
} else if (distanceFromCenter < radius) {
retval = MOVE;
} else {
retval = GROW_NONE;
}
} else {
// verticalCheck makes sure the position is between the top and
// the bottom edge (with some tolerance). Similar for horizCheck.
boolean verticalCheck = (y >= r.top - hysteresis)
&& (y < r.bottom + hysteresis);
boolean horizCheck = (x >= r.left - hysteresis)
&& (x < r.right + hysteresis);
// Check whether the position is near some edge(s).
if ((Math.abs(r.left - x) < hysteresis) && verticalCheck) {
retval |= GROW_LEFT_EDGE;
}
if ((Math.abs(r.right - x) < hysteresis) && verticalCheck) {
retval |= GROW_RIGHT_EDGE;
}
if ((Math.abs(r.top - y) < hysteresis) && horizCheck) {
retval |= GROW_TOP_EDGE;
}
if ((Math.abs(r.bottom - y) < hysteresis) && horizCheck) {
retval |= GROW_BOTTOM_EDGE;
}
// Not near any edge but inside the rectangle: move.
if (retval == GROW_NONE && r.contains((int) x, (int) y)) {
retval = MOVE;
}
}
return retval;
}
// Handles motion (dx, dy) in screen space.
// The "edge" parameter specifies which edges the user is dragging.
public void handleMotion(int edge, float dx, float dy) {
Rect r = computeLayout();
if (edge == GROW_NONE) {
return;
} else if (edge == MOVE) {
// Convert to image space before sending to moveBy().
moveBy(dx * (mCropRect.width() / r.width()),
dy * (mCropRect.height() / r.height()));
} else {
if (((GROW_LEFT_EDGE | GROW_RIGHT_EDGE) & edge) == 0) {
dx = 0;
}
if (((GROW_TOP_EDGE | GROW_BOTTOM_EDGE) & edge) == 0) {
dy = 0;
}
// Convert to image space before sending to growBy().
float xDelta = dx * (mCropRect.width() / r.width());
float yDelta = dy * (mCropRect.height() / r.height());
growBy((((edge & GROW_LEFT_EDGE) != 0) ? -1 : 1) * xDelta,
(((edge & GROW_TOP_EDGE) != 0) ? -1 : 1) * yDelta);
}
}
// Grows the cropping rectange by (dx, dy) in image space.
void moveBy(float dx, float dy) {
Rect invalRect = new Rect(mDrawRect);
mCropRect.offset(dx, dy);
// Put the cropping rectangle inside image rectangle.
mCropRect.offset(Math.max(0, mImageRect.left - mCropRect.left),
Math.max(0, mImageRect.top - mCropRect.top));
mCropRect.offset(Math.min(0, mImageRect.right - mCropRect.right),
Math.min(0, mImageRect.bottom - mCropRect.bottom));
mDrawRect = computeLayout();
invalRect.union(mDrawRect);
invalRect.inset(-10, -10);
// mContext.invalidate(invalRect);
mContext.invalidate();
}
// Grows the cropping rectange by (dx, dy) in image space.
void growBy(float dx, float dy) {
if (mMaintainAspectRatio) {
if (dx != 0) {
dy = dx / mInitialAspectRatio;
} else if (dy != 0) {
dx = dy * mInitialAspectRatio;
}
}
// Don't let the cropping rectangle grow too fast.
// Grow at most half of the difference between the image rectangle and
// the cropping rectangle.
RectF r = new RectF(mCropRect);
if (dx > 0F && r.width() + 2 * dx > mImageRect.width()) {
float adjustment = (mImageRect.width() - r.width()) / 2F;
dx = adjustment;
if (mMaintainAspectRatio) {
dy = dx / mInitialAspectRatio;
}
}
if (dy > 0F && r.height() + 2 * dy > mImageRect.height()) {
float adjustment = (mImageRect.height() - r.height()) / 2F;
dy = adjustment;
if (mMaintainAspectRatio) {
dx = dy * mInitialAspectRatio;
}
}
r.inset(-dx, -dy);
// Don't let the cropping rectangle shrink too fast.
final float widthCap = 25F;
if (r.width() < widthCap) {
return;
// r.inset(-(widthCap - r.width()) / 2F, 0F);
}
float heightCap = mMaintainAspectRatio ? (widthCap / mInitialAspectRatio)
: widthCap;
if (r.height() < heightCap) {
return;
// r.inset(0F, -(heightCap - r.height()) / 2F);
}
// Put the cropping rectangle inside the image rectangle.
if (r.left < mImageRect.left) {
r.offset(mImageRect.left - r.left, 0F);
} else if (r.right > mImageRect.right) {
r.offset(-(r.right - mImageRect.right), 0);
}
if (r.top < mImageRect.top) {
r.offset(0F, mImageRect.top - r.top);
} else if (r.bottom > mImageRect.bottom) {
r.offset(0F, -(r.bottom - mImageRect.bottom));
}
mCropRect.set(r);
mDrawRect = computeLayout();
mContext.invalidate();
}
// Returns the cropping rectangle in image space.
public Rect getCropRect() {
return new Rect((int) mCropRect.left, (int) mCropRect.top,
(int) mCropRect.right, (int) mCropRect.bottom);
}
// Maps the cropping rectangle from image space to screen space.
private Rect computeLayout() {
RectF r = new RectF(mCropRect.left, mCropRect.top, mCropRect.right,
mCropRect.bottom);
mMatrix.mapRect(r);
return new Rect(Math.round(r.left), Math.round(r.top),
Math.round(r.right), Math.round(r.bottom));
}
public void invalidate() {
mDrawRect = computeLayout();
}
public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean circle,
boolean maintainAspectRatio) {
if (circle) {
maintainAspectRatio = true;
}
mMatrix = new Matrix(m);
mCropRect = cropRect;
mImageRect = new RectF(imageRect);
mMaintainAspectRatio = maintainAspectRatio;
mCircle = circle;
mInitialAspectRatio = mCropRect.width() / mCropRect.height();
mDrawRect = computeLayout();
mFocusPaint.setARGB(125, 50, 50, 50);
mNoFocusPaint.setARGB(125, 50, 50, 50);
mOutlinePaint.setStrokeWidth(3F);
mOutlinePaint.setStyle(Paint.Style.STROKE);
mOutlinePaint.setAntiAlias(true);
mMode = ModifyMode.None;
init();
}
public enum ModifyMode {
None, Move, Grow
}
private ModifyMode mMode = ModifyMode.None;
public Rect mDrawRect; // in screen space
public RectF mImageRect; // in image space
public RectF mCropRect; // in image space
public Matrix mMatrix;
private boolean mMaintainAspectRatio = false;
private float mInitialAspectRatio;
private boolean mCircle = false;
// private Drawable mResizeDrawableWidth;
// private Drawable mResizeDrawableHeight;
private Drawable mResizeDrawableDiagonal;
private Drawable mResizeDrawableDiagonal2;
private final Paint mFocusPaint = new Paint();
private final Paint mNoFocusPaint = new Paint();
private final Paint mOutlinePaint = new Paint();
}
| [
"tiny2cui@gmail.com"
] | tiny2cui@gmail.com |
3f537101d65118fc458d36b89a94570f4db9b978 | 2f2d00b7605fd4e619ab2301e239e1eb9f786950 | /l06/src/ro/unibuc/fmi/exception/PersonNotFoundException.java | 7ee8b7258d4b5c212ff2e829270e22cb4c9a4f35 | [] | no_license | FloaterTS/fmi | d7c7d1ed6301c3b84bfb53c7f80da5d957aaa656 | 72430f77a2bfbb28be6637a9c251b6e4b9426480 | refs/heads/master | 2022-06-11T07:35:35.633211 | 2020-05-12T06:23:41 | 2020-05-12T06:23:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 184 | java | package ro.unibuc.fmi.exception;
public class PersonNotFoundException extends RuntimeException {
public PersonNotFoundException(String message) {
super(message);
}
}
| [
"calin.constantinov@endava.com"
] | calin.constantinov@endava.com |
02f6d3b44ef9cbf16c861d8e1fb39fbea119edc0 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_498a22b3ea469dbe3eb6531aab87682a0ac38e59/CircuitChangeJobs/8_498a22b3ea469dbe3eb6531aab87682a0ac38e59_CircuitChangeJobs_s.java | 6f3a5dfaf2b1f922ef79356dcc7719996c10d74d | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 106,292 | java | /* -*- tab-width: 4 -*-
*
* Electric(tm) VLSI Design System
*
* File: CircuitChangeJobs.java
*
* Copyright (c) 2006 Sun Microsystems and Static Free Software
*
* Electric(tm) is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Electric(tm) 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 Electric(tm); see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, Mass 02111-1307, USA.
*/
package com.sun.electric.tool.user;
import com.sun.electric.database.IdMapper;
import com.sun.electric.database.constraint.Layout;
import com.sun.electric.database.geometry.DBMath;
import com.sun.electric.database.geometry.Dimension2D;
import com.sun.electric.database.geometry.EPoint;
import com.sun.electric.database.geometry.ERectangle;
import com.sun.electric.database.geometry.Orientation;
import com.sun.electric.database.geometry.Poly;
import com.sun.electric.database.geometry.PolyBase;
import com.sun.electric.database.geometry.PolyMerge;
import com.sun.electric.database.hierarchy.Cell;
import com.sun.electric.database.hierarchy.EDatabase;
import com.sun.electric.database.hierarchy.Export;
import com.sun.electric.database.hierarchy.Library;
import com.sun.electric.database.network.Netlist;
import com.sun.electric.database.network.Network;
import com.sun.electric.database.prototype.NodeProto;
import com.sun.electric.database.prototype.PortProto;
import com.sun.electric.database.text.Name;
import com.sun.electric.database.text.TextUtils;
import com.sun.electric.database.topology.ArcInst;
import com.sun.electric.database.topology.Connection;
import com.sun.electric.database.topology.Geometric;
import com.sun.electric.database.topology.NodeInst;
import com.sun.electric.database.topology.PortInst;
import com.sun.electric.database.variable.CodeExpression;
import com.sun.electric.database.variable.DisplayedText;
import com.sun.electric.database.variable.EditWindow_;
import com.sun.electric.database.variable.ElectricObject;
import com.sun.electric.database.variable.TextDescriptor;
import com.sun.electric.database.variable.UserInterface;
import com.sun.electric.database.variable.Variable;
import com.sun.electric.technology.ArcProto;
import com.sun.electric.technology.Layer;
import com.sun.electric.technology.PrimitiveNode;
import com.sun.electric.technology.Technology;
import com.sun.electric.technology.technologies.Schematics;
import com.sun.electric.tool.Job;
import com.sun.electric.tool.JobException;
import com.sun.electric.tool.io.FileType;
import com.sun.electric.tool.io.input.LibraryFiles;
import com.sun.electric.tool.user.dialogs.OpenFile;
import com.sun.electric.tool.user.ui.EditWindow;
import com.sun.electric.tool.user.ui.SizeListener;
import com.sun.electric.tool.user.ui.StatusBar;
import com.sun.electric.tool.user.ui.TopLevel;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JOptionPane;
/**
* Class for Jobs that make changes to the circuit.
*/
public class CircuitChangeJobs
{
// constructor, never used
CircuitChangeJobs() {}
/****************************** NODE TRANSFORMATION ******************************/
public static class RotateSelected extends Job
{
private Cell cell;
private int amount;
private boolean mirror;
private boolean mirrorH;
private List<Geometric> highs;
/**
* @param cell
* @param highs the highlighted objects (list of highlights)
* @param amount angle in tenth degrees to rotate
* @param mirror whether or not to mirror. if true, amount is ignored, and mirrorH is used.
* @param mirrorH if true, mirror horizontally (flip over X-axis), otherwise mirror
* vertically (flip over Y-axis). Ignored if mirror is false.
*/
public RotateSelected(Cell cell, List<Geometric> highs, int amount, boolean mirror, boolean mirrorH)
{
super("Rotate selected objects", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.amount = amount;
this.mirror = mirror;
this.mirrorH = mirrorH;
this.highs = highs;
startJob();
}
public boolean doIt() throws JobException
{
// disallow rotating if lock is on
if (cantEdit(cell, null, true, false, true) != 0) return false;
// figure out which nodes get rotated/mirrored
Set<Geometric> markObj = new HashSet<Geometric>();
int nicount = 0;
NodeInst theNi = null;
Rectangle2D selectedBounds = new Rectangle2D.Double();
for(Geometric geom : highs)
{
if (!(geom instanceof NodeInst)) continue;
NodeInst ni = (NodeInst)geom;
if (cantEdit(cell, ni, true, false, true) != 0)
{
return false;
}
markObj.add(ni);
if (nicount == 0)
{
selectedBounds.setRect(ni.getBounds());
} else
{
Rectangle2D.union(selectedBounds, ni.getBounds(), selectedBounds);
}
theNi = ni;
nicount++;
}
// must be at least 1 node
if (nicount <= 0)
{
System.out.println("Must select at least 1 node for rotation");
return false;
}
// if multiple nodes, find the center one
if (nicount > 1)
{
Point2D center = new Point2D.Double(selectedBounds.getCenterX(), selectedBounds.getCenterY());
theNi = null;
double bestdist = Integer.MAX_VALUE;
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst ni = it.next();
if (!markObj.contains(ni)) continue;
double dist = center.distance(ni.getTrueCenter());
// LINTED "bestdist" used in proper order
if (theNi == null || dist < bestdist)
{
theNi = ni;
bestdist = dist;
}
}
}
// see which nodes already connect to the main rotation/mirror node (theNi)
markObj.clear();
for(Geometric geom : highs)
{
if (!(geom instanceof ArcInst)) continue;
ArcInst ai = (ArcInst)geom;
markObj.add(ai);
}
spreadRotateConnection(theNi, markObj);
// now make sure that it is all connected
for(Geometric geom : highs)
{
if (!(geom instanceof NodeInst)) continue;
NodeInst ni = (NodeInst)geom;
spreadRotateConnection(ni, markObj);
}
// do the rotation/mirror
Orientation dOrient;
if (mirror)
{
// do mirroring
dOrient = mirrorH ? Orientation.Y : Orientation.X;
} else
{
// do rotation
dOrient = Orientation.fromAngle(amount);
}
AffineTransform trans = dOrient.rotateAbout(theNi.getAnchorCenter());
Point2D.Double tmpPt1 = new Point2D.Double(), tmpPt2 = new Point2D.Double();
// Rotate nodes in markObj
for (Geometric geom : markObj) {
if (!(geom instanceof NodeInst)) continue;
NodeInst ni = (NodeInst)geom;
trans.transform(ni.getAnchorCenter(), tmpPt1);
ni.rotate(dOrient);
ni.move(tmpPt1.getX() - ni.getAnchorCenterX(), tmpPt1.getY() - ni.getAnchorCenterY());
}
// Rotate arcs in markObj
for (Geometric geom : markObj) {
if (!(geom instanceof ArcInst)) continue;
ArcInst ai = (ArcInst)geom;
if (markObj.contains(ai.getHeadPortInst().getNodeInst()))
trans.transform(ai.getHeadLocation(), tmpPt1);
else
tmpPt1.setLocation(ai.getHeadLocation());
if (markObj.contains(ai.getTailPortInst().getNodeInst()))
trans.transform(ai.getTailLocation(), tmpPt2);
else
tmpPt2.setLocation(ai.getTailLocation());
ai.modify(tmpPt1.getX() - ai.getHeadLocation().getX(), tmpPt1.getY() - ai.getHeadLocation().getY(),
tmpPt2.getX() - ai.getTailLocation().getX(), tmpPt2.getY() - ai.getTailLocation().getY());
}
return true;
}
}
/**
* Helper method for rotation to mark selected nodes that need not be
* connected with an invisible arc.
*/
private static void spreadRotateConnection(NodeInst theNi, Set<Geometric> markObj)
{
if (markObj.contains(theNi)) return;
markObj.add(theNi);
for(Iterator<Connection> it = theNi.getConnections(); it.hasNext(); )
{
Connection con = it.next();
ArcInst ai = con.getArc();
if (!markObj.contains(ai)) continue;
int otherEnd = 1 - con.getEndIndex();
NodeInst ni = ai.getPortInst(otherEnd).getNodeInst();
if (markObj.contains(ni)) continue;
markObj.add(ni);
spreadRotateConnection(ni, markObj);
}
}
/****************************** NODE ALIGNMENT ******************************/
/**
* This class implement the command to align objects to the grid.
*/
public static class AlignObjects extends Job
{
private List<Geometric> list; // list of highlighted objects to align
private Dimension2D alignment;
public AlignObjects(List<Geometric> highs, Dimension2D alignment)
{
super("Align Objects", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.list = highs;
this.alignment = alignment;
startJob();
}
public boolean doIt() throws JobException
{
if (list.size() == 0)
{
System.out.println("Must select something before aligning it to the grid");
return false;
}
if (alignment.getWidth() <= 0 || alignment.getHeight() <= 0)
{
System.out.println("No alignment given: set Alignment Options first");
return false;
}
// first adjust the nodes
int adjustedNodes = 0;
for(Geometric geom : list)
{
if (!(geom instanceof NodeInst)) continue;
NodeInst ni = (NodeInst)geom;
Point2D [] points = ni.getTrace();
if (points != null)
{
AffineTransform transOut = ni.pureRotateOut();
Point2D [] newPoints = new Point2D[points.length];
boolean changed = false;
for(int i=0; i<points.length; i++)
{
if (points[i] == null) continue;
Point2D newPoint = new Point2D.Double(points[i].getX() + ni.getAnchorCenterX(), points[i].getY() + ni.getAnchorCenterY());
transOut.transform(newPoint, newPoint);
double oldX = newPoint.getX();
double oldY = newPoint.getY();
DBMath.gridAlign(newPoint, alignment);
if (oldX != newPoint.getX() || oldY != newPoint.getY()) changed = true;
newPoints[i] = newPoint;
}
if (changed)
{
adjustedNodes++;
ni.setTrace(newPoints);
}
continue;
}
Point2D center = new Point2D.Double(ni.getAnchorCenterX(), ni.getAnchorCenterY());
DBMath.gridAlign(center, alignment);
double bodyXOffset = center.getX() - ni.getAnchorCenterX();
double bodyYOffset = center.getY() - ni.getAnchorCenterY();
double portXOffset = bodyXOffset;
double portYOffset = bodyYOffset;
boolean mixedportpos = false;
boolean firstPort = true;
for(Iterator<PortInst> pIt = ni.getPortInsts(); pIt.hasNext(); )
{
PortInst pi = pIt.next();
Poly poly = pi.getPoly();
Point2D portCenter = new Point2D.Double(poly.getCenterX(), poly.getCenterY());
DBMath.gridAlign(portCenter, alignment);
double pXO = portCenter.getX() - poly.getCenterX();
double pYO = portCenter.getY() - poly.getCenterY();
if (firstPort)
{
firstPort = false;
portXOffset = pXO; portYOffset = pYO;
} else
{
if (portXOffset != pXO || portYOffset != pYO) mixedportpos = true;
}
}
if (!mixedportpos)
{
bodyXOffset = portXOffset; bodyYOffset = portYOffset;
}
// if a primitive has an offset, see if the node edges are aligned
if (bodyXOffset != 0 || bodyYOffset != 0)
{
if (!ni.isCellInstance())
{
AffineTransform transr = ni.rotateOut();
Technology tech = ni.getProto().getTechnology();
Poly [] polyList = tech.getShapeOfNode(ni);
for(int j=0; j<polyList.length; j++)
{
Poly poly = polyList[j];
poly.transform(transr);
Rectangle2D bounds = poly.getBox();
if (bounds == null) continue;
Point2D polyPoint1 = new Point2D.Double(bounds.getMinX(), bounds.getMinY());
Point2D polyPoint2 = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());
DBMath.gridAlign(polyPoint1, alignment);
DBMath.gridAlign(polyPoint2, alignment);
if (polyPoint1.getX() == bounds.getMinX() &&
polyPoint2.getX() == bounds.getMaxX()) bodyXOffset = 0;
if (polyPoint1.getY() == bounds.getMinY() &&
polyPoint2.getY() == bounds.getMaxY()) bodyYOffset = 0;
if (bodyXOffset == 0 && bodyYOffset == 0) break;
}
}
}
// move the node
if (bodyXOffset != 0 || bodyYOffset != 0)
{
// turn off all constraints on arcs
Map<ArcInst,Integer> constraints = new HashMap<ArcInst,Integer>();
for(Iterator<Connection> aIt = ni.getConnections(); aIt.hasNext(); )
{
Connection con = aIt.next();
ArcInst ai = con.getArc();
int constr = 0;
if (ai.isRigid()) constr |= 1;
if (ai.isFixedAngle()) constr |= 2;
constraints.put(ai, new Integer(constr));
}
ni.move(bodyXOffset, bodyYOffset);
adjustedNodes++;
// restore arc constraints
for(Iterator<Connection> aIt = ni.getConnections(); aIt.hasNext(); )
{
Connection con = aIt.next();
ArcInst ai = con.getArc();
Integer constr = constraints.get(ai);
if (constr == null) continue;
if ((constr.intValue() & 1) != 0) ai.setRigid(true);
if ((constr.intValue() & 2) != 0) ai.setFixedAngle(true);
}
}
}
// now adjust the arcs
int adjustedArcs = 0;
for(Geometric geom : list)
{
if (!(geom instanceof ArcInst)) continue;
ArcInst ai = (ArcInst)geom;
if (!ai.isLinked()) continue;
Point2D origHead = ai.getHeadLocation();
Point2D origTail = ai.getTailLocation();
Point2D arcHead = new Point2D.Double(origHead.getX(), origHead.getY());
Point2D arcTail = new Point2D.Double(origTail.getX(), origTail.getY());
DBMath.gridAlign(arcHead, alignment);
DBMath.gridAlign(arcTail, alignment);
double headXOff = arcHead.getX() - origHead.getX();
double headYOff = arcHead.getY() - origHead.getY();
double tailXOff = arcTail.getX() - origTail.getX();
double tailYOff = arcTail.getY() - origTail.getY();
if (headXOff == 0 && tailXOff == 0 && headYOff == 0 && tailYOff == 0) continue;
if (!ai.headStillInPort(arcHead, false))
{
if (!ai.headStillInPort(origHead, false)) continue;
headXOff = headYOff = 0;
}
if (!ai.tailStillInPort(arcTail, false))
{
if (!ai.tailStillInPort(origTail, false)) continue;
tailXOff = tailYOff = 0;
}
// make sure an arc does not change angle
int ang = ai.getAngle();
if (ang == 0 || ang == 1800)
{
// horizontal arc: both DY values must be the same
if (headYOff != tailYOff) headYOff = tailYOff = 0;
} else if (ang == 900 || ang == 2700)
{
// vertical arc: both DX values must be the same
if (headXOff != tailXOff) headXOff = tailXOff = 0;
}
if (headXOff != 0 || tailXOff != 0 || headYOff != 0 || tailYOff != 0)
{
int constr = 0;
if (ai.isRigid()) constr |= 1;
if (ai.isFixedAngle()) constr |= 2;
ai.setRigid(false);
ai.setFixedAngle(false);
ai.modify(headXOff, headYOff, tailXOff, tailYOff);
adjustedArcs++;
if ((constr & 1) != 0) ai.setRigid(true);
if ((constr & 2) != 0) ai.setFixedAngle(true);
}
}
// show results
if (adjustedNodes == 0 && adjustedArcs == 0) System.out.println("No adjustments necessary"); else
System.out.println("Adjusted " + adjustedNodes + " nodes and " + adjustedArcs + " arcs");
return true;
}
}
public static class AlignNodes extends Job
{
private NodeInst [] nis;
private double [] dCX;
private double [] dCY;
public AlignNodes(NodeInst [] nis, double [] dCX, double [] dCY)
{
super("Align objects", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.nis = nis;
this.dCX = dCX;
this.dCY = dCY;
startJob();
}
public boolean doIt() throws JobException
{
int numRemoved = 0;
for(int i=0; i<nis.length; i++)
{
NodeInst ni = nis[i];
int res = cantEdit(ni.getParent(), ni, true, false, true);
if (res < 0) return false;
if (res > 0)
{
numRemoved++;
nis[i] = null;
}
}
if (numRemoved > 0)
{
// make a smaller list
int newSize = nis.length - numRemoved;
if (newSize == 0) return true;
NodeInst [] nnis = new NodeInst[newSize];
double [] nCX = new double[newSize];
double [] nCY = new double[newSize];
int fill = 0;
for(int i=0; i<nis.length; i++)
{
if (nis[i] == null) continue;
nnis[fill] = nis[i];
nCX[fill] = dCX[i];
nCY[fill] = dCY[i];
fill++;
}
nis = nnis;
dCX = nCX;
dCY = nCY;
}
NodeInst.modifyInstances(nis, dCX, dCY, null, null);
return true;
}
}
/****************************** ARC MODIFICATION ******************************/
public enum ChangeArcEnum {
RIGID("Rigid"),
NONRIGID("Non-Rigid"),
FIXEDANGLE("Fixed-Angle"),
NONFIXEDANGLE("Not-Fixed-Angle"),
DIRECTIONAL("Directional"),
HEADEXTEND("extend the head end"),
TAILEXTEND("extend the tail end");
private String name;
ChangeArcEnum(String n) { name = n; }
public String toString() { return name; }
}
public static class ChangeArcProperties extends Job
{
private Cell cell;
private ChangeArcEnum how;
private List<ElectricObject> objList;
private boolean repaintContents, repaintAny;
public ChangeArcProperties(Cell cell, ChangeArcEnum how, List<Highlight2> highlighted)
{
super("Align objects", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.how = how;
this.objList = new ArrayList<ElectricObject>();
for(Highlight2 h : highlighted)
{
if (!h.isHighlightEOBJ()) continue;
objList.add(h.getElectricObject());
}
startJob();
}
public boolean doIt() throws JobException
{
// make sure changing arcs is allowed
if (CircuitChangeJobs.cantEdit(cell, null, true, false, true) != 0) return false;
int numSet = 0, numUnset = 0;
for(ElectricObject eobj : objList)
{
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
switch (how)
{
case RIGID:
if (!ai.isRigid())
{
ai.setRigid(true);
numSet++;
}
break;
case NONRIGID:
if (ai.isRigid())
{
ai.setRigid(false);
numSet++;
}
break;
case FIXEDANGLE:
if (!ai.isFixedAngle())
{
ai.setFixedAngle(true);
numSet++;
}
break;
case NONFIXEDANGLE:
if (ai.isFixedAngle())
{
ai.setFixedAngle(false);
numSet++;
}
break;
case DIRECTIONAL: // toggle directionality
if (ai.isHeadArrowed())
{
ai.setHeadArrowed(false);
ai.setBodyArrowed(false);
numUnset++;
} else
{
ai.setHeadArrowed(true);
ai.setBodyArrowed(true);
numSet++;
}
break;
case HEADEXTEND: // end-extend the head
if (ai.isHeadExtended())
{
ai.setHeadExtended(false);
numUnset++;
} else
{
ai.setHeadExtended(true);
numSet++;
}
break;
case TAILEXTEND: // end-extend the tail
if (ai.isTailExtended())
{
ai.setTailExtended(false);
numUnset++;
} else
{
ai.setTailExtended(true);
numSet++;
}
break;
}
}
}
repaintAny = false;
if (numSet == 0 && numUnset == 0) System.out.println("No changes were made"); else
{
String action = "";
repaintAny = true;
repaintContents = false;
action = how.toString();
switch (how)
{
case DIRECTIONAL:
case HEADEXTEND:
case TAILEXTEND:
repaintContents = true; break;
}
if (numUnset == 0) System.out.println("Made " + numSet + " arcs " + action); else
if (numSet == 0) System.out.println("Made " + numUnset + " arcs not " + action); else
System.out.println("Made " + numSet + " arcs " + action + "; and " + numUnset + " arcs not " + action);
}
fieldVariableChanged("repaintAny");
fieldVariableChanged("repaintContents");
return true;
}
public void terminateOK()
{
if (repaintAny)
{
if (repaintContents) EditWindow.repaintAllContents(); else
EditWindow.repaintAll();
}
}
}
public static class ToggleNegationJob extends Job
{
private Cell cell;
private List<ElectricObject> highlighted; // Can't use Highlight2 since it is not serializable
private int numSet;
public ToggleNegationJob(Cell cell, List<Highlight2> highlighted)
{
super("Toggle negation", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.highlighted = new ArrayList<ElectricObject>();
for(Highlight2 h : highlighted)
{
if (!h.isHighlightEOBJ()) continue;
this.highlighted.add(h.getElectricObject());
}
startJob();
}
public boolean doIt() throws JobException
{
// make sure negation is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
numSet = 0;
for(ElectricObject eobj : highlighted)
{
if (eobj instanceof PortInst)
{
PortInst pi = (PortInst)eobj;
for(Iterator<Connection> cIt = pi.getConnections(); cIt.hasNext(); )
{
Connection con = cIt.next();
con.setNegated(!con.isNegated());
}
}
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
for(int i=0; i<2; i++)
{
ai.setNegated(i, !ai.isNegated((i)));
}
}
}
fieldVariableChanged("numSet");
if (numSet == 0) System.out.println("No ports negated"); else
{
System.out.println("Negated " + numSet + " ports");
}
return true;
}
public void terminateOK()
{
if (numSet != 0)
{
EditWindow.repaintAllContents();
}
}
}
public static class RipTheBus extends Job
{
private Cell cell;
private List<ArcInst> list;
public RipTheBus(Cell cell, List<ArcInst> list)
{
super("Rip Bus", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.list = list;
startJob();
}
public boolean doIt() throws JobException
{
// make sure ripping arcs is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
for(ArcInst ai : list)
{
if (ai.getProto() != Schematics.tech().bus_arc) continue;
Netlist netList = ai.getParent().acquireUserNetlist();
if (netList == null)
{
System.out.println("Sorry, a deadlock aborted bus ripping (network information unavailable). Please try again");
break;
}
int busWidth = netList.getBusWidth(ai);
String netName = netList.getNetworkName(ai);
if (netName.length() == 0)
{
System.out.println("Bus " + ai.describe(true) + " has no name");
continue;
}
// determine length of stub wires
double stublen = (int)(ai.getLambdaLength() / 3 + 0.5);
double lowXBus = 0, lowYBus = 0;
int lowEnd = 1;
double sepX = 0, sepY = 0;
double lowX = 0, lowY = 0;
// determine location of individual signals
if (ai.getHeadLocation().getX() == ai.getTailLocation().getX())
{
lowX = ai.getHeadLocation().getX();
if (lowX < ai.getParent().getBounds().getCenterX()) lowX += stublen; else
lowX -= stublen;
if (ai.getLocation(0).getY() < ai.getLocation(1).getY()) lowEnd = 0;
lowY = (int)(ai.getLocation(lowEnd).getY());
double highy = (int)(ai.getLocation(1-lowEnd).getY());
if (highy-lowY >= busWidth-1)
{
// signals fit on grid
sepY = (int)((highy-lowY) / (busWidth-1));
lowY = (int)(((highy - lowY) - (sepY * (busWidth-1))) / 2 + lowY);
} else
{
// signals don't fit: just make them even
lowY = ai.getLocation(lowEnd).getY();
highy = ai.getLocation(1-lowEnd).getY();
sepY = (highy-lowY) / (busWidth-1);
}
lowXBus = ai.getTailLocation().getX(); lowYBus = lowY;
} else if (ai.getTailLocation().getY() == ai.getHeadLocation().getY())
{
lowY = ai.getTailLocation().getY();
if (lowY < ai.getParent().getBounds().getCenterY()) lowY += stublen; else
lowY -= stublen;
if (ai.getLocation(0).getX() < ai.getLocation(1).getX()) lowEnd = 0;
lowX = (int)(ai.getLocation(lowEnd).getX());
double highx = (int)(ai.getLocation(1-lowEnd).getX());
if (highx-lowX >= busWidth-1)
{
// signals fit on grid
sepX = (int)((highx-lowX) / (busWidth-1));
lowX = (int)(((highx - lowX) - (sepX * (busWidth-1))) / 2 + lowX);
} else
{
// signals don't fit: just make them even
lowX = ai.getLocation(lowEnd).getX();
highx = ai.getLocation(1-lowEnd).getX();
sepX = (highx-lowX) / (busWidth-1);
}
lowXBus = lowX; lowYBus = ai.getTailLocation().getY();
} else
{
System.out.println("Bus " + ai.describe(true) + " must be horizontal or vertical to be ripped out");
continue;
}
// copy names to a local array
String [] localStrings = new String[busWidth];
for(int i=0; i<busWidth; i++)
{
Network subNet = netList.getNetwork(ai, i);
localStrings[i] = subNet.getName();
}
double sxw = Schematics.tech().wirePinNode.getDefWidth();
double syw = Schematics.tech().wirePinNode.getDefHeight();
double sxb = Schematics.tech().busPinNode.getDefWidth();
double syb = Schematics.tech().busPinNode.getDefHeight();
ArcProto apW = Schematics.tech().wire_arc;
ArcProto apB = Schematics.tech().bus_arc;
NodeInst niBLast = null;
for(int i=0; i<busWidth; i++)
{
// make the wire pin
NodeInst niw = NodeInst.makeInstance(Schematics.tech().wirePinNode, new Point2D.Double(lowX, lowY), sxw, syw, ai.getParent());
if (niw == null) break;
// make the bus pin
NodeInst nib = NodeInst.makeInstance(Schematics.tech().busPinNode, new Point2D.Double(lowXBus, lowYBus), sxb, syb, ai.getParent());
if (nib == null) break;
// wire them
PortInst head = niw.getOnlyPortInst();
PortInst tail = nib.getOnlyPortInst();
ArcInst aiw = ArcInst.makeInstance(apW, head, tail);
if (aiw == null) break;
aiw.setName(localStrings[i]);
// wire to the bus pin
if (i == 0)
{
PortInst first = ai.getPortInst(lowEnd);
aiw = ArcInst.makeInstance(apB, first, tail);
} else
{
PortInst first = niBLast.getOnlyPortInst();
aiw = ArcInst.makeInstance(apB, first, tail);
}
if (aiw == null) break;
// advance to the next segment
niBLast = nib;
lowX += sepX; lowY += sepY;
lowXBus += sepX; lowYBus += sepY;
}
// wire up the last segment
PortInst head = niBLast.getOnlyPortInst();
PortInst tail = ai.getPortInst(1-lowEnd);
ArcInst aiw = ArcInst.makeInstance(apB, head, tail);
if (aiw == null) return false;
aiw.setName(netName);
// remove original arc
ai.kill();
}
return true;
}
}
/****************************** DELETE SELECTED OBJECTS ******************************/
public static class DeleteSelected extends Job
{
private Cell cell;
private List<DisplayedText> highlightedText;
private List<Geometric> highlighted;
private boolean reconstructArcsAndExports;
private List<Geometric> thingsToHighlight;
public DeleteSelected(Cell cell, List<DisplayedText> highlightedText, List<Geometric> highlighted, boolean reconstructArcsAndExports)
{
super("Delete selected objects", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.highlightedText = highlightedText;
this.highlighted = highlighted;
this.reconstructArcsAndExports = reconstructArcsAndExports;
startJob();
}
public boolean doIt() throws JobException
{
// make sure deletion is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
// delete the text
for(DisplayedText dt : highlightedText)
{
// deleting variable on object
Variable.Key key = dt.getVariableKey();
ElectricObject eobj = dt.getElectricObject();
// delete any reference to this Object in SizeListener
SizeListener.restorePreviousListener(eobj);
if (key == NodeInst.NODE_NAME)
{
// deleting the name of a node
NodeInst ni = (NodeInst)eobj;
ni.setName(null);
ni.move(0, 0);
} else if (key == ArcInst.ARC_NAME)
{
// deleting the name of an arc
ArcInst ai = (ArcInst)eobj;
ai.setName(null);
ai.modify(0, 0, 0, 0);
} else if (key == Export.EXPORT_NAME)
{
// deleting the name of an export
Export pp = (Export)eobj;
int errCode = cantEdit(cell, pp.getOriginalPort().getNodeInst(), true, true, true);
if (errCode < 0) return false;
if (errCode > 0) continue;
pp.kill();
} else
{
// deleting a variable
if (eobj.isParam(key)) {
if (eobj instanceof Cell)
((Cell)eobj).getCellGroup().delParam((Variable.AttrKey)key);
else if (eobj instanceof NodeInst)
((NodeInst)eobj).delParameter(key);
} else {
eobj.delVar(key);
}
}
}
if (cell != null)
{
thingsToHighlight = new ArrayList<Geometric>();
Set<ElectricObject> stuffToHighlight = new HashSet<ElectricObject>();
eraseObjectsInList(cell, highlighted, reconstructArcsAndExports, stuffToHighlight);
for(ElectricObject eObj : stuffToHighlight)
{
if (eObj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eObj;
// if (ai.isLinked())
thingsToHighlight.add(ai);
} else if (eObj instanceof Export)
{
Export e = (Export)eObj;
thingsToHighlight.add(e.getOriginalPort().getNodeInst());
}
}
fieldVariableChanged("thingsToHighlight");
}
return true;
}
public void terminateOK()
{
// remove highlighting, show only reconstructed objects
UserInterface ui = Job.getUserInterface();
EditWindow_ wnd = ui.getCurrentEditWindow_();
if (wnd != null)
{
wnd.clearHighlighting();
if (thingsToHighlight != null)
{
for(Geometric geom: thingsToHighlight)
wnd.addElectricObject(geom, cell);
}
wnd.finishedHighlighting();
}
}
}
public static class DeleteSelectedGeometry extends Job
{
private Cell cell;
private ERectangle bounds;
public DeleteSelectedGeometry(Cell cell, Rectangle2D bounds)
{
super("Delete selected geometry", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.bounds = ERectangle.fromLambda(bounds);
startJob();
}
public boolean doIt() throws JobException
{
if (cell == null)
{
System.out.println("No current cell");
return false;
}
if (bounds == null)
{
System.out.println("Nothing selected");
return false;
}
// disallow erasing if lock is on
if (cantEdit(cell, null, true, false, true) != 0) return false;
if (bounds == null)
{
System.out.println("Outline an area first");
return false;
}
// grid the area
double lX = Math.floor(bounds.getMinX());
double hX = Math.ceil(bounds.getMaxX());
double lY = Math.floor(bounds.getMinY());
double hY = Math.ceil(bounds.getMaxY());
// crop arcs that cross the area boundary
List<ArcInst> arcsInCell = new ArrayList<ArcInst>();
for(Iterator<ArcInst> aIt = cell.getArcs(); aIt.hasNext(); )
arcsInCell.add(aIt.next());
for(ArcInst ai : arcsInCell)
{
// if an end is inside, ignore
Point2D headPt = ai.getHeadLocation();
Point2D tailPt = ai.getTailLocation();
// if length is zero, ignore
if (tailPt.getX() == headPt.getX() &&
tailPt.getY() == headPt.getY()) continue;
// if the arc doesn't intersect the area, ignore
double halfWidth = ai.getLambdaBaseWidth() / 2;
double lXExt = lX - halfWidth;
double hXExt = hX + halfWidth;
double lYExt = lY - halfWidth;
double hYExt = hY + halfWidth;
Point2D tailPtAdj = new Point2D.Double(tailPt.getX(), tailPt.getY());
Point2D headPtAdj = new Point2D.Double(headPt.getX(), headPt.getY());
if (DBMath.clipLine(tailPtAdj, headPtAdj, lXExt, hXExt, lYExt, hYExt)) continue;
if (tailPtAdj.distance(headPt) + headPtAdj.distance(tailPt) <
headPtAdj.distance(headPt) + tailPtAdj.distance(tailPt))
{
Point2D swap = headPtAdj;
headPtAdj = tailPtAdj;
tailPtAdj = swap;
}
Name name = ai.getNameKey();
String newName = null;
if (!name.isTempname()) newName = name.toString();
if (!tailPt.equals(tailPtAdj))
{
// create a pin at this point
PrimitiveNode pin = ai.getProto().findPinProto();
NodeInst ni = NodeInst.makeInstance(pin, tailPtAdj, pin.getDefWidth(), pin.getDefHeight(), cell);
if (ni == null)
{
System.out.println("Error creating pin for shortening of "+ai);
continue;
}
ArcInst ai1 = ArcInst.makeInstanceBase(ai.getProto(), ai.getLambdaBaseWidth(),
ai.getTailPortInst(), ni.getOnlyPortInst(), ai.getTailLocation(),
tailPtAdj, newName);
if (ai1 == null)
{
System.out.println("Error shortening "+ai);
continue;
}
newName = null;
ai1.copyPropertiesFrom(ai);
}
if (!headPt.equals(headPtAdj))
{
// create a pin at this point
PrimitiveNode pin = ai.getProto().findPinProto();
NodeInst ni = NodeInst.makeInstance(pin, headPtAdj, pin.getDefWidth(), pin.getDefHeight(), cell);
if (ni == null)
{
System.out.println("Error creating pin for shortening of "+ai);
continue;
}
ArcInst ai1 = ArcInst.makeInstanceBase(ai.getProto(), ai.getLambdaBaseWidth(), ni.getOnlyPortInst(),
ai.getHeadPortInst(), headPtAdj, ai.getHeadLocation(), newName);
if (ai1 == null)
{
System.out.println("Error shortening "+ai);
continue;
}
ai1.copyPropertiesFrom(ai);
}
// delete any reference to this Object in SizeListener
SizeListener.restorePreviousListener(ai);
ai.kill();
}
// now remove nodes in the area
Set<NodeInst> nodesToDelete = new HashSet<NodeInst>();
for(Iterator<NodeInst> nIt = cell.getNodes(); nIt.hasNext(); )
{
NodeInst ni = nIt.next();
// special case for nodes with outline information: clip the outline
if (!ni.isCellInstance())
{
if (ni.getProto().getFunction() == PrimitiveNode.Function.NODE)
{
// first see if it is completely ignored
Rectangle2D pointBounds = ni.getBounds();
if (pointBounds.getMinX() > hX || pointBounds.getMaxX() < lX ||
pointBounds.getMinY() > hY || pointBounds.getMaxY() < lY) continue;
// if it cannot be modified, stop
int errorCode = cantEdit(cell, ni, true, false, true);
if (errorCode < 0) return false;
if (errorCode > 0) continue;
// if it is completely covered, delete it
if (pointBounds.getMinX() >= lX && pointBounds.getMaxX() <= hX &&
pointBounds.getMinY() >= lY && pointBounds.getMaxY() <= hY)
{
nodesToDelete.add(ni);
continue;
}
// crop it against the delete bounds
Layer lay = ni.getProto().getTechnology().getLayer(0);
PolyMerge merge = new PolyMerge();
PolyBase poly;
Point2D [] points = ni.getTrace();
if (points == null) poly = new PolyBase(pointBounds); else
{
double cX = pointBounds.getCenterX();
double cY = pointBounds.getCenterY();
Point2D [] newPoints = new Point2D[points.length];
for(int i=0; i<points.length; i++)
{
if (points[i] != null)
newPoints[i] = new Point2D.Double(points[i].getX()+cX, points[i].getY()+cY);
}
poly = new PolyBase(newPoints);
poly.transform(ni.rotateOut());
}
merge.addPolygon(lay, poly);
PolyBase polySub = new PolyBase((lX+hX)/2, (lY+hY)/2, hX-lX, hY-lY);
merge.subtract(lay, polySub);
List<PolyBase> resultingPolys = merge.getMergedPoints(lay, true);
if (resultingPolys != null)
{
// find the largest polygon
PolyBase largest = null;
double largestSize = 0;
for(PolyBase pb : resultingPolys)
{
double sz = pb.getArea();
if (sz >= largestSize)
{
largestSize = sz;
largest = pb;
}
}
if (largest != null)
ni.setTrace(largest.getPoints());
continue;
}
}
}
// if the node is outside of the area, ignore it
double cX = ni.getTrueCenterX();
double cY = ni.getTrueCenterY();
if (cX >= hX || cX <= lX || cY >= hY || cY <= lY) continue;
// if it cannot be modified, stop
int errorCode = cantEdit(cell, ni, true, false, true);
if (errorCode < 0) return false;
if (errorCode > 0) continue;
nodesToDelete.add(ni);
// delete any reference to this Object in SizeListener
SizeListener.restorePreviousListener(ni);
}
// delete the nodes
cell.killNodes(nodesToDelete);
return true;
}
}
public static class DeleteArcs extends Job
{
private Set<ArcInst> arcsToDelete;
public DeleteArcs(Set<ArcInst> arcsToDelete)
{
super("Delete arcs", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.arcsToDelete = arcsToDelete;
startJob();
}
public boolean doIt() throws JobException
{
for(ArcInst ai : arcsToDelete)
{
NodeInst h = ai.getHeadPortInst().getNodeInst();
NodeInst t = ai.getTailPortInst().getNodeInst();
ai.kill();
// also delete freed pin nodes
if (h.getProto().getFunction() == PrimitiveNode.Function.PIN &&
!h.hasConnections() && !h.hasExports())
{
h.kill();
}
if (t.getProto().getFunction() == PrimitiveNode.Function.PIN &&
!t.hasConnections() && !t.hasExports())
{
t.kill();
}
}
System.out.println("Deleted " + arcsToDelete.size() + " arcs");
return true;
}
}
/****************************** DELETE OBJECTS IN A LIST ******************************/
/**
* Method to delete all of the Geometrics in a list.
* @param cell the cell with the objects to be deleted.
* @param list a List of Geometric or Highlight objects to be deleted.
* @param reconstructArcsAndExports true to reconstruct arcs to deleted cell instances.
* @param stuffToHighlight a set of objects to select (arcs and exports) if reconstruction is done.
*/
public static void eraseObjectsInList(Cell cell, List<Geometric> list, boolean reconstructArcsAndExports,
Set<ElectricObject> stuffToHighlight)
{
// make sets of all of the arcs and nodes explicitly selected for deletion
Set<ArcInst> arcsToDelete = new HashSet<ArcInst>();
Set<NodeInst> nodesToDelete = new HashSet<NodeInst>();
if (cantEdit(cell, null, true, false, true) != 0) return;
for(Geometric geom : list)
{
if (geom instanceof ArcInst)
{
ArcInst ai = (ArcInst)geom;
arcsToDelete.add(ai);
} else if (geom instanceof NodeInst)
{
NodeInst ni = (NodeInst)geom;
if (cantEdit(cell, ni, true, false, true) != 0) continue;
nodesToDelete.add(ni);
}
}
// make a set of additional nodes to potentially delete
Set<NodeInst> alsoDeleteTheseNodes = new HashSet<NodeInst>();
// also (potentially) delete nodes on the end of deleted arcs
for(ArcInst ai : arcsToDelete)
{
alsoDeleteTheseNodes.add(ai.getHeadPortInst().getNodeInst());
alsoDeleteTheseNodes.add(ai.getTailPortInst().getNodeInst());
}
// also mark all nodes on the other end of arcs connected to erased nodes
for(NodeInst ni : nodesToDelete)
{
for(Iterator<Connection> sit = ni.getConnections(); sit.hasNext(); )
{
Connection con = sit.next();
ArcInst ai = con.getArc();
int otherEnd = 1 - con.getEndIndex();
NodeInst oNi = ai.getPortInst(otherEnd).getNodeInst();
alsoDeleteTheseNodes.add(oNi);
}
}
// reconnect hair to cells (if requested)
if (reconstructArcsAndExports)
{
for(NodeInst ni : nodesToDelete)
{
if (!ni.isCellInstance()) continue;
// make a map of recreated ports
Map<PortInst,PortInst> reassigned = new HashMap<PortInst,PortInst>();
// reconstruct exports to deleted cell instances
for(Iterator<Export> eIt = ni.getExports(); eIt.hasNext(); )
{
Export e = eIt.next();
AffineTransform trans = new AffineTransform();
Orientation orient = Orientation.IDENT;
PortInst pi = e.getOriginalPort();
NodeInst subNi;
PortProto subPP;
for(;;)
{
subNi = pi.getNodeInst();
subPP = pi.getPortProto();
trans = subNi.rotateOut(trans);
orient = orient.concatenate(subNi.getOrient());
if (!subNi.isCellInstance()) break;
trans = subNi.translateOut(trans);
pi = ((Export)subPP).getOriginalPort();
}
NodeProto subNp = subNi.getProto();
Point2D ctr = new Point2D.Double(subNi.getTrueCenter().getX(), subNi.getTrueCenter().getY());
trans.transform(ctr, ctr);
NodeInst eNi = NodeInst.makeInstance(subNp, ctr, subNi.getXSize(), subNi.getYSize(),
cell, orient, null);
pi = eNi.findPortInstFromProto(subPP);
reassigned.put(e.getOriginalPort(), pi);
e.move(pi);
if (stuffToHighlight != null) stuffToHighlight.add(e);
}
// reconstruct each connection to a deleted cell instance
for(Iterator<Connection> cIt = ni.getConnections(); cIt.hasNext(); )
{
Connection con = cIt.next();
ArcInst ai = con.getArc();
if (arcsToDelete.contains(ai)) continue;
// recreate them
int thisEnd = con.getEndIndex();
int otherEnd = 1 - thisEnd;
PortInst thisPi = ai.getPortInst(thisEnd);
PortInst otherPi = ai.getPortInst(otherEnd);
NodeInst otherNi = otherPi.getNodeInst();
if (otherNi == ni)
{
// special case: arc from node to itself gets preserved?
continue;
}
if (nodesToDelete.contains(otherNi)) continue;
// reconnect a piece of hair to a cell instance
PortInst alreadyPI = reassigned.get(thisPi);
if (alreadyPI == null)
{
PrimitiveNode pinNp = ai.getProto().findPinProto();
NodeInst pin = NodeInst.makeInstance(pinNp, con.getLocation(), pinNp.getDefWidth(), pinNp.getDefHeight(), cell);
alreadyPI = pin.getOnlyPortInst();
reassigned.put(thisPi, alreadyPI);
}
ArcInst newAI = ArcInst.makeInstanceBase(ai.getProto(), ai.getLambdaBaseWidth(), otherPi, alreadyPI,
ai.getConnection(otherEnd).getLocation(), con.getLocation(), ai.getName());
if (stuffToHighlight != null) stuffToHighlight.add(newAI);
alsoDeleteTheseNodes.remove(otherNi);
}
}
}
// now kill all of the arcs
for(ArcInst ai : arcsToDelete)
{
ai.kill();
}
// reconnect all nodes that are in the middle of two arcs
for(NodeInst ni : nodesToDelete)
{
// if (reconstructArcsAndExports && ni.isCellInstance()) continue;
// see if any arcs can be reconnected as a result of this kill
Reconnect re = Reconnect.erasePassThru(ni, false, false);
if (re != null) re.reconnectArcs();
}
// next kill all of the nodes
cell.killNodes(nodesToDelete);
// kill all pin nodes that touched an arc and no longer do
Set<NodeInst> deleteTheseNodes = new HashSet<NodeInst>();
for(NodeInst ni : alsoDeleteTheseNodes)
{
if (!ni.isLinked()) continue;
if (!ni.isCellInstance())
{
if (ni.getProto().getFunction() != PrimitiveNode.Function.PIN) continue;
if (ni.hasConnections() || ni.hasExports()) continue;
deleteTheseNodes.add(ni);
}
}
cell.killNodes(deleteTheseNodes);
// kill all unexported pin or bus nodes left in the middle of arcs
List<NodeInst> nodesToPassThru = new ArrayList<NodeInst>();
for(NodeInst ni : alsoDeleteTheseNodes)
{
if (!ni.isCellInstance())
{
if (ni.getProto().getFunction() != PrimitiveNode.Function.PIN) continue;
if (ni.hasExports()) continue;
if (!ni.isInlinePin()) continue;
nodesToPassThru.add(ni);
}
}
for(NodeInst ni : nodesToPassThru)
{
Reconnect re = Reconnect.erasePassThru(ni, false, false);
if (re != null)
{
re.reconnectArcs();
ni.kill();
}
}
int numArcsDeleted = arcsToDelete.size();
int numNodesDeleted = nodesToDelete.size();
String msg = "Deleted";
if (numNodesDeleted == 1) msg += " 1 node"; else
if (numNodesDeleted > 1) msg += " " + numNodesDeleted + " nodes";
if (numNodesDeleted > 0 && numArcsDeleted > 0) msg += " and";
if (numArcsDeleted == 1) msg += " 1 arc"; else
if (numArcsDeleted > 1) msg += " " + numArcsDeleted + " arcs";
System.out.println(msg);
}
/****************************** CLEAN-UP ******************************/
/**
* This class implements the changes needed to cleanup pins in a Cell.
*/
public static class CleanupChanges extends Job
{
private Cell cell;
private boolean justThis;
private Set<NodeInst> pinsToRemove;
private List<Reconnect> pinsToPassThrough;
private Map<NodeInst,EPoint> pinsToScale;
private List<NodeInst> textToMove;
private Set<ArcInst> arcsToKill;
private int zeroSize, negSize, overSizePins;
public CleanupChanges(Cell cell, boolean justThis, Set<NodeInst> pinsToRemove, List<Reconnect> pinsToPassThrough,
Map<NodeInst,EPoint> pinsToScale, List<NodeInst> textToMove, Set<ArcInst> arcsToKill,
int zeroSize, int negSize, int overSizePins)
{
super("Cleanup " + cell, User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.justThis = justThis;
this.pinsToRemove = pinsToRemove;
this.pinsToPassThrough = pinsToPassThrough;
this.pinsToScale = pinsToScale;
this.textToMove = textToMove;
this.arcsToKill = arcsToKill;
this.zeroSize = zeroSize;
this.negSize = negSize;
this.overSizePins = overSizePins;
startJob();
}
public boolean doIt() throws JobException
{
// make sure moving the node is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
// do the queued operations
cell.killNodes(pinsToRemove);
int pinsPassedThrough = 0;
for(;;)
{
boolean found = false;
for(Reconnect re : pinsToPassThrough)
{
if (!re.ni.isLinked()) continue;
List created = re.reconnectArcs();
if (created.size() > 0)
{
re.ni.kill();
pinsPassedThrough++;
found = true;
}
}
if (!found) break;
pinsToPassThrough = getPinsToPassThrough(cell);
}
for(NodeInst ni : pinsToScale.keySet())
{
EPoint scale = pinsToScale.get(ni);
ni.resize(scale.getX(), scale.getY());
}
for(NodeInst ni : textToMove)
{
ni.invisiblePinWithOffsetText(true);
}
cell.killArcs(arcsToKill);
// report what was cleaned
StringBuffer infstr = new StringBuffer();
if (!justThis) infstr.append("Cell " + cell.describe(true) + ":");
boolean spoke = false;
if ((pinsToRemove.size()+pinsPassedThrough) != 0)
{
int removed = pinsToRemove.size() + pinsPassedThrough;
infstr.append("Removed " + removed + " pins");
spoke = true;
}
if (arcsToKill.size() != 0)
{
if (spoke) infstr.append("; ");
infstr.append("Removed " + arcsToKill.size() + " duplicate arcs");
spoke = true;
}
if (pinsToScale.size() != 0)
{
if (spoke) infstr.append("; ");
infstr.append("Shrunk " + pinsToScale.size() + " pins");
spoke = true;
}
if (zeroSize != 0)
{
if (spoke) infstr.append("; ");
if (justThis)
{
infstr.append("Highlighted " + zeroSize + " zero-size pins");
} else
{
infstr.append("Found " + zeroSize + " zero-size pins");
}
spoke = true;
}
if (negSize != 0)
{
if (spoke) infstr.append("; ");
if (justThis)
{
infstr.append("Highlighted " + negSize + " negative-size pins");
} else
{
infstr.append("Found " + negSize + " negative-size pins");
}
spoke = true;
}
if (overSizePins != 0)
{
if (spoke) infstr.append("; ");
if (justThis)
{
infstr.append("Highlighted " + overSizePins + " oversize pins with arcs that don't touch");
} else
{
infstr.append("Found " + overSizePins + " oversize pins with arcs that don't touch");
}
spoke = true;
}
if (textToMove.size() != 0)
{
if (spoke) infstr.append("; ");
infstr.append("Moved text on " + textToMove.size() + " pins with offset text");
}
System.out.println(infstr.toString());
return true;
}
}
/**
* This class implements the changes needed to shorten selected arcs.
*/
public static class ShortenArcs extends Job
{
private Cell cell;
private List<ArcInst> selected;
public ShortenArcs(Cell cell, List<ArcInst> selected)
{
super("Shorten selected arcs", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.selected = selected;
startJob();
}
public boolean doIt() throws JobException
{
// make sure shortening is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
int l = 0;
double [] dX = new double[2];
double [] dY = new double[2];
for(ArcInst ai : selected)
{
for(int j=0; j<2; j++)
{
Poly portPoly = ai.getPortInst(j).getPoly();
double wid = ai.getLambdaBaseWidth();
portPoly.reducePortPoly(ai.getPortInst(j), wid, ai.getAngle());
Point2D closest = portPoly.closestPoint(ai.getLocation(1-j));
dX[j] = closest.getX() - ai.getLocation(j).getX();
dY[j] = closest.getY() - ai.getLocation(j).getY();
}
if (dX[0] != 0 || dY[0] != 0 || dX[1] != 0 || dY[1] != 0)
{
ai.modify(dX[ArcInst.HEADEND], dY[ArcInst.HEADEND], dX[ArcInst.TAILEND], dY[ArcInst.TAILEND]);
l++;
}
}
System.out.println("Shortened " + l + " arcs");
return true;
}
}
/****************************** MOVE SELECTED OBJECTS ******************************/
public static class ManyMove extends Job
{
private static final boolean verbose = true;
private Cell cell;
private List<ElectricObject> highlightedObjs;
private List<DisplayedText> highlightedText;
private double dX, dY;
private boolean updateStatusBar;
public ManyMove(Cell cell, List<ElectricObject> highlightedObjs, List<DisplayedText> highlightedText, double dX, double dY)
{
super("Move", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.highlightedObjs = highlightedObjs;
this.highlightedText = highlightedText;
this.dX = dX;
this.dY = dY;
startJob();
}
public boolean doIt() throws JobException
{
// get information about what is highlighted
if (highlightedObjs.size() + highlightedText.size() == 0) return false;
// make sure moving is allowed
if (cantEdit(cell, null, true, false, true) != 0) return false;
// special case if moving only one node
if (highlightedObjs.size() == 1 && highlightedText.size() == 0)
{
ElectricObject firstEObj = highlightedObjs.get(0);
if (firstEObj instanceof NodeInst || firstEObj instanceof PortInst)
{
NodeInst ni;
if (firstEObj instanceof PortInst) {
ni = ((PortInst)firstEObj).getNodeInst();
} else {
ni = (NodeInst)firstEObj;
}
// make sure moving the node is allowed
if (cantEdit(cell, ni, true, false, true) != 0) return false;
ni.move(dX, dY);
if (verbose) System.out.println("Moved node " + ni.describe(false) + " by (" + dX + "," + dY + ")");
updateStatusBar = true;
fieldVariableChanged("updateStatusBar");
return true;
}
}
// special case if moving diagonal fixed-angle arcs connected to single manhattan arcs
boolean found = false;
for(ElectricObject eobj : highlightedObjs)
{
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
if (ai.getHeadLocation().getX() != ai.getTailLocation().getX() &&
ai.getHeadLocation().getY() != ai.getTailLocation().getY())
{
if (ai.isFixedAngle() && !ai.isRigid())
{
int j;
for(j=0; j<2; j++)
{
NodeInst ni = ai.getPortInst(j).getNodeInst();
ArcInst oai = null;
for(Iterator<Connection> pIt = ni.getConnections(); pIt.hasNext(); )
{
Connection con = pIt.next();
if (con.getArc() == ai) continue;
if (oai == null) oai = con.getArc(); else
{
oai = null;
break;
}
}
if (oai == null) break;
if (oai.getHeadLocation().getX() != oai.getTailLocation().getX() &&
oai.getHeadLocation().getY() != oai.getTailLocation().getY()) break;
}
if (j >= 2) { found = true; break; }
}
}
}
}
if (found)
{
// meets the test: make the special move to slide other orthogonal arcs
for(ElectricObject eobj : highlightedObjs)
{
if (!(eobj instanceof ArcInst)) continue;
ArcInst ai = (ArcInst)eobj;
double [] deltaXs = new double[2];
double [] deltaYs = new double[2];
NodeInst [] niList = new NodeInst[2];
deltaXs[0] = deltaYs[0] = deltaXs[1] = deltaYs[1] = 0;
int arcangle = ai.getAngle();
int j;
for(j=0; j<2; j++)
{
NodeInst ni = ai.getPortInst(j).getNodeInst();
niList[j] = ni;
ArcInst oai = null;
for(Iterator<Connection> pIt = ni.getConnections(); pIt.hasNext(); )
{
Connection con = pIt.next();
if (con.getArc() != ai) { oai = con.getArc(); break; }
}
if (oai == null) break;
if (DBMath.doublesEqual(oai.getHeadLocation().getX(), oai.getTailLocation().getX()))
{
Point2D iPt = DBMath.intersect(oai.getHeadLocation(), 900,
new Point2D.Double(ai.getHeadLocation().getX()+dX, ai.getHeadLocation().getY()+dY), arcangle);
if (iPt != null)
{
deltaXs[j] = iPt.getX() - ai.getLocation(j).getX();
deltaYs[j] = iPt.getY() - ai.getLocation(j).getY();
}
} else if (DBMath.doublesEqual(oai.getHeadLocation().getY(), oai.getTailLocation().getY()))
{
Point2D iPt = DBMath.intersect(oai.getHeadLocation(), 0,
new Point2D.Double(ai.getHeadLocation().getX()+dX, ai.getHeadLocation().getY()+dY), arcangle);
if (iPt != null)
{
deltaXs[j] = iPt.getX() - ai.getLocation(j).getX();
deltaYs[j] = iPt.getY() - ai.getLocation(j).getY();
}
}
}
if (j < 2) continue;
NodeInst.modifyInstances(niList, deltaXs, deltaYs, null, null);
}
if (verbose) System.out.println("Moved multiple objects by (" + TextUtils.formatDouble(dX) +
"," + TextUtils.formatDouble(dY) + ")");
updateStatusBar = true;
fieldVariableChanged("updateStatusBar");
return true;
}
// special case if moving only arcs and they slide
boolean onlySlidable = true, foundArc = false;
for(ElectricObject eobj : highlightedObjs)
{
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
foundArc = true;
// see if the arc moves in its ports
if (ai.isSlidable())
{
Point2D newHead = new Point2D.Double(ai.getHeadLocation().getX()+dX, ai.getHeadLocation().getY()+dY);
Point2D newTail = new Point2D.Double(ai.getTailLocation().getX()+dX, ai.getTailLocation().getY()+dY);
if (ai.headStillInPort(newHead, true) && ai.tailStillInPort(newTail, true)) continue;
}
}
onlySlidable = false;
}
if (foundArc && onlySlidable)
{
for(ElectricObject eobj : highlightedObjs)
{
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
ai.modify(dX, dY, dX, dY);
if (verbose) System.out.println("Moved arc " + ai.describe(false) + " by (" + dX + "," + dY + ")");
}
}
updateStatusBar = true;
fieldVariableChanged("updateStatusBar");
return true;
}
// ignore arc motion if the nodes are locked
for(int i=0; i<highlightedObjs.size(); i++)
{
ElectricObject eobj = highlightedObjs.get(i);
if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
int errorCode = cantEdit(cell, ai.getHeadPortInst().getNodeInst(), true, false, true);
if (errorCode < 0) return false;
if (errorCode > 0)
{
highlightedObjs.remove(i);
i--;
continue;
}
errorCode = cantEdit(cell, ai.getTailPortInst().getNodeInst(), true, false, true);
if (errorCode < 0) return false;
if (errorCode > 0)
{
highlightedObjs.remove(i);
i--;
continue;
}
}
}
// make flag to track the nodes that move
Set<NodeInst> flag = new HashSet<NodeInst>();
// remember the location of every node and arc
Map<NodeInst,Point2D.Double> nodeLocation = new HashMap<NodeInst,Point2D.Double>();
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst ni = it.next();
nodeLocation.put(ni, new Point2D.Double(ni.getAnchorCenterX(), ni.getAnchorCenterY()));
}
Map<ArcInst,Point2D.Double> arcLocation = new HashMap<ArcInst,Point2D.Double>();
for(Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); )
{
ArcInst ai = it.next();
arcLocation.put(ai, new Point2D.Double(ai.getTrueCenterX(), ai.getTrueCenterY()));
}
// mark all nodes that want to move
for(ElectricObject eobj : highlightedObjs)
{
if (eobj instanceof PortInst) eobj = ((PortInst)eobj).getNodeInst();
if (eobj instanceof NodeInst)
{
NodeInst ni = (NodeInst)eobj;
flag.add(ni);
} else if (eobj instanceof ArcInst)
{
ArcInst ai = (ArcInst)eobj;
NodeInst ni1 = ai.getHeadPortInst().getNodeInst();
NodeInst ni2 = ai.getTailPortInst().getNodeInst();
flag.add(ni1);
flag.add(ni2);
Layout.setTempRigid(ai, true);
}
}
// count the number of nodes that will move
int numNodes = 0;
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst ni = it.next();
if (!flag.contains(ni)) continue;
// make sure moving the node is allowed
int errorCode = cantEdit(cell, ni, true, false, true);
if (errorCode < 0) return false;
if (errorCode > 0)
{
flag.remove(ni);
continue;
}
numNodes++;
}
// look at all nodes and move them appropriately
if (numNodes > 0)
{
NodeInst [] nis = new NodeInst[numNodes];
double [] dXs = new double[numNodes];
double [] dYs = new double[numNodes];
numNodes = 0;
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst ni = it.next();
if (!flag.contains(ni)) continue;
nis[numNodes] = ni;
dXs[numNodes] = dX;
dYs[numNodes] = dY;
numNodes++;
}
NodeInst.modifyInstances(nis, dXs, dYs, null, null);
}
flag = null;
// look at all arcs and move them appropriately
for(ElectricObject eobj : highlightedObjs)
{
if (!(eobj instanceof ArcInst)) continue;
ArcInst ai = (ArcInst)eobj;
Point2D pt = arcLocation.get(ai);
if (pt.getX() != ai.getTrueCenterX() ||
pt.getY() != ai.getTrueCenterY()) continue;
// see if the arc moves in its ports
boolean headInPort = false, tailInPort = false;
if (!ai.isRigid() && ai.isSlidable())
{
headInPort = ai.headStillInPort(
new Point2D.Double(ai.getHeadLocation().getX()+dX, ai.getHeadLocation().getY()+dY), true);
tailInPort = ai.tailStillInPort(
new Point2D.Double(ai.getTailLocation().getX()+dX, ai.getTailLocation().getY()+dY), true);
}
// if both ends slide in their port, move the arc
if (headInPort && tailInPort)
{
ai.modify(dX, dY, dX, dY);
continue;
}
// if neither end can slide in its port, move the nodes
if (!headInPort && !tailInPort)
{
for(int k=0; k<2; k++)
{
NodeInst ni;
if (k == 0) ni = ai.getHeadPortInst().getNodeInst(); else
ni = ai.getTailPortInst().getNodeInst();
Point2D nPt = nodeLocation.get(ni);
if (ni.getAnchorCenterX() != nPt.getX() || ni.getAnchorCenterY() != nPt.getY()) continue;
// fix all arcs that aren't sliding
for(ElectricObject oEObj : highlightedObjs)
{
if (oEObj instanceof ArcInst)
{
ArcInst oai = (ArcInst)oEObj;
Point2D aPt = arcLocation.get(oai);
if (aPt.getX() != oai.getTrueCenterX() ||
aPt.getY() != oai.getTrueCenterY()) continue;
if (oai.headStillInPort(
new Point2D.Double(ai.getHeadLocation().getX()+dX, ai.getHeadLocation().getY()+dY), true) ||
oai.tailStillInPort(
new Point2D.Double(ai.getTailLocation().getX()+dX, ai.getTailLocation().getY()+dY), true))
continue;
Layout.setTempRigid(oai, true);
}
}
ni.move(dX - (ni.getAnchorCenterX() - nPt.getX()),
dY - (ni.getAnchorCenterY() - nPt.getY()));
}
continue;
}
}
// also move selected text
moveSelectedText(cell, highlightedText);
if (verbose) System.out.println("Moved multiple objects by (" + TextUtils.formatDouble(dX) +
"," + TextUtils.formatDouble(dY) + ")");
updateStatusBar = true;
fieldVariableChanged("updateStatusBar");
return true;
}
public void terminateOK()
{
if (updateStatusBar) StatusBar.updateStatusBar();
}
/**
* Method to move the "numtexts" text objects described (as highlight strings)
* in the array "textlist", by "odx" and "ody". Geometry objects in "list" (NOGEOM-terminated)
* and the "total" nodes in "nodelist" have already been moved, so don't move any text that
* is on these objects.
*/
private void moveSelectedText(Cell cell, List<DisplayedText> highlightedText)
{
for(DisplayedText dt : highlightedText)
{
// disallow moving if lock is on
if (cell != null)
{
int errorCode = cantEdit(cell, null, true, true, true);
if (errorCode < 0) return;
if (errorCode > 0) continue;
}
// handle nodes that move with text
ElectricObject eobj = dt.getElectricObject();
if (dt.movesWithText())
{
NodeInst ni = null;
if (eobj instanceof NodeInst) ni = (NodeInst)eobj;
if (eobj instanceof Export) ni = ((Export)eobj).getOriginalPort().getNodeInst();
if (ni != null)
{
ni.move(dX, dY);
continue;
}
}
// moving variable on object
Variable.Key varKey = dt.getVariableKey();
TextDescriptor td = eobj.getTextDescriptor(varKey);
if (td == null) continue;
NodeInst ni = null;
if (eobj instanceof NodeInst) ni = (NodeInst)eobj; else
if (eobj instanceof PortInst) ni = ((PortInst)eobj).getNodeInst(); else
if (eobj instanceof Export && varKey == Export.EXPORT_NAME) ni = ((Export)eobj).getOriginalPort().getNodeInst();
if (ni != null)
{
Point2D curLoc = new Point2D.Double(ni.getAnchorCenterX()+td.getXOff(), ni.getAnchorCenterY()+td.getYOff());
AffineTransform rotateOut = ni.rotateOut();
rotateOut.transform(curLoc, curLoc);
curLoc.setLocation(curLoc.getX()+dX, curLoc.getY()+dY);
AffineTransform rotateIn = ni.rotateIn();
rotateIn.transform(curLoc, curLoc);
eobj.setOff(varKey, curLoc.getX()-ni.getAnchorCenterX(), curLoc.getY()-ni.getAnchorCenterY());
} else
{
eobj.setOff(varKey, td.getXOff()+dX, td.getYOff()+dY);
}
}
}
}
/**
* Store information of new arc to be created that reconnects
* two arcs that will be deleted
*/
private static class ReconnectedArc implements Serializable
{
/** port at other end of arc */ private PortInst [] reconPi;
/** coordinate at other end of arc */ private EPoint [] recon;
/** old arc insts that will be deleted */ private ArcInst [] reconAr;
/** prototype of new arc */ private ArcProto ap;
/** width of new arc */ private double wid;
/** true to make new arc have arrow on head */ private boolean directionalHead;
/** true to make new arc have arrow on tail */ private boolean directionalTail;
/** true to make new arc have arrow on body */ private boolean directionalBody;
/** true to extend the head of the new arc */ private boolean extendHead;
/** true to extend the tail of the new arc */ private boolean extendTail;
/** true to negate the head of the new arc */ private boolean negateHead;
/** true to negate the tail of the new arc */ private boolean negateTail;
/** the name to use on the reconnected arc */ private String arcName;
/** TextDescriptor for the reconnected arc name */ private TextDescriptor arcNameTD;
}
public static List<Reconnect> getPinsToPassThrough(Cell cell)
{
List<Reconnect> pinsToPassThrough = new ArrayList<Reconnect>();
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst ni = it.next();
if (ni.getFunction() != PrimitiveNode.Function.PIN) continue;
// if the pin is an export, save it
if (ni.hasExports()) continue;
// if the pin is connected to two arcs along the same slope, delete it
if (ni.isInlinePin())
{
Reconnect re = Reconnect.erasePassThru(ni, false, true);
if (re != null)
{
pinsToPassThrough.add(re);
}
}
}
return pinsToPassThrough;
}
/**
* This class handles deleting pins that are between two arcs,
* and reconnecting the arcs without the pin.
*/
public static class Reconnect implements Serializable
{
/** node in the center of the reconnect */ private NodeInst ni;
/** list of reconnected arcs */ private ArrayList<ReconnectedArc> reconnectedArcs;
/**
* Method to find a possible Reconnect through a given NodeInst.
* @param ni the NodeInst to examine.
* @param allowdiffs true to allow differences in the two arcs.
* If this is false, then different width arcs, or arcs that are not lined up
* precisely, will not be considered for reconnection.
* @param checkPermission true to check that the node can be changed.
* @return a Reconnect object that describes the reconnection to be done.
* Returns null if no reconnection can be found.
*/
public static Reconnect erasePassThru(NodeInst ni, boolean allowdiffs, boolean checkPermission)
{
// stop now if nothing connected to the node
if (!ni.hasConnections()) return null;
// disallow erasing if lock is on
Cell cell = ni.getParent();
if (checkPermission && cantEdit(cell, ni, true, false, true) != 0) return null;
Reconnect recon = new Reconnect();
recon.ni = ni;
recon.reconnectedArcs = new ArrayList<ReconnectedArc>();
// get all arcs connected to each portinst on node
for (Iterator<PortInst> it = ni.getPortInsts(); it.hasNext(); ) {
PortInst pi = it.next();
List<ArcInst> arcs = new ArrayList<ArcInst>();
for (Iterator<Connection> it2 = pi.getConnections(); it2.hasNext(); ) {
Connection conn = it2.next();
ArcInst ai = conn.getArc();
// ignore arcs that connect from the node to itself
if (ai.getHeadPortInst().getNodeInst() == ai.getTailPortInst().getNodeInst())
continue;
arcs.add(ai);
}
// go through all arcs on this portinst and see if any can be reconnected
while (arcs.size() > 1) {
ArcInst ai1 = arcs.remove(0);
for (ArcInst ai2 : arcs) {
ReconnectedArc ra = reconnectArcs(pi, ai1, ai2, allowdiffs);
// if reconnection to be made, add to list
if (ra != null) recon.reconnectedArcs.add(ra);
}
}
}
if (recon.reconnectedArcs.size() == 0) return null;
return recon;
}
/** Returns null if couldn't reconnect arcs together */
private static ReconnectedArc reconnectArcs(PortInst pi, ArcInst ai1, ArcInst ai2, boolean allowdiffs) {
// verify that the two arcs to merge have the same type
if (ai1.getProto() != ai2.getProto()) return null;
ReconnectedArc ra = new ReconnectedArc();
ra.ap = ai1.getProto();
ra.reconPi = new PortInst[2];
ra.recon = new EPoint[2];
ra.reconAr = new ArcInst[2];
ra.reconAr[0] = ai1;
ra.reconAr[1] = ai2;
Point2D [] orig = new Point2D[2]; // end points on port that will be deleted
Point2D [] delta = new Point2D[2]; // deltaX,Y of arc
// get end points of arcs
for (int i=0; i<2; i++) {
if (ai1.getPortInst(i) != pi) {
ra.reconPi[0] = ai1.getPortInst(i);
ra.recon[0] = ai1.getLocation(i);
} else {
orig[0] = ai1.getLocation(i);
}
if (ai2.getPortInst(i) != pi) {
ra.reconPi[1] = ai2.getPortInst(i);
ra.recon[1] = ai2.getLocation(i);
} else {
orig[1] = ai2.getLocation(i);
}
}
delta[0] = new Point2D.Double(ra.recon[0].getX() - orig[0].getX(),
ra.recon[0].getY() - orig[0].getY());
delta[1] = new Point2D.Double(ra.recon[1].getX() - orig[1].getX(),
ra.recon[1].getY() - orig[1].getY());
if (!allowdiffs)
{
// verify that the two arcs to merge have the same width
if (ai1.getLambdaBaseWidth() != ai2.getLambdaBaseWidth()) return null;
// verify that the two arcs have the same slope
if ((delta[1].getX()*delta[0].getY()) != (delta[0].getX()*delta[1].getY())) return null;
// verify that the angle between two arcs is obtuse
boolean zeroLength = false;
if (delta[0].getX() == 0 && delta[0].getY() == 0) zeroLength = true;
if (delta[1].getX() == 0 && delta[1].getY() == 0) zeroLength = true;
if (!zeroLength && delta[0].getX()*delta[1].getX() + delta[0].getY()*delta[1].getY() >= 0) return null;
if (orig[0].getX() != orig[1].getX() || orig[0].getY() != orig[1].getY())
{
// did not connect at the same location: be sure that angle is consistent
if (delta[0].getX() != 0 || delta[0].getY() != 0)
{
if (((orig[0].getX()-orig[1].getX())*delta[0].getY()) !=
(delta[0].getX()*(orig[0].getY()-orig[1].getY()))) return null;
} else if (delta[1].getX() != 0 || delta[1].getY() != 0)
{
if (((orig[0].getX()-orig[1].getX())*delta[1].getY()) !=
(delta[1].getX()*(orig[0].getY()-orig[1].getY()))) return null;
} else return null;
}
}
// ok to connect arcs
ra.wid = ai1.getLambdaBaseWidth();
ra.directionalHead = ai1.isHeadArrowed();
ra.directionalTail = ai1.isTailArrowed();
ra.directionalBody = ai1.isBodyArrowed();
ra.extendHead = ai1.isHeadExtended();
ra.extendTail = ai2.isTailExtended();
ra.negateHead = ai1.isHeadNegated();
ra.negateTail = ai2.isTailNegated();
if (ai1.getName() != null && !ai1.getNameKey().isTempname())
{
ra.arcName = ai1.getName();
ra.arcNameTD = ai1.getTextDescriptor(ArcInst.ARC_NAME);
}
if (ai2.getName() != null && !ai2.getNameKey().isTempname())
{
ra.arcName = ai2.getName();
ra.arcNameTD = ai2.getTextDescriptor(ArcInst.ARC_NAME);
}
return ra;
}
/**
* Method to implement the reconnection in this Reconnect.
* @return list of newly created ArcInst that reconnects.
*/
public List<ArcInst> reconnectArcs()
{
List<ArcInst> newArcs = new ArrayList<ArcInst>();
// reconnect the arcs
for (ReconnectedArc ra : reconnectedArcs)
{
if (!ra.reconPi[0].getNodeInst().isLinked() || !ra.reconPi[1].getNodeInst().isLinked()) continue;
ArcInst newAi = ArcInst.makeInstanceBase(ra.ap, ra.wid, ra.reconPi[0], ra.reconPi[1], ra.recon[0], ra.recon[1], null);
if (newAi == null) continue;
newAi.setHeadArrowed(ra.directionalHead);
newAi.setTailArrowed(ra.directionalTail);
newAi.setBodyArrowed(ra.directionalBody);
newAi.setHeadExtended(ra.extendHead);
newAi.setTailExtended(ra.extendTail);
newAi.setHeadNegated(ra.negateHead);
newAi.setTailNegated(ra.negateTail);
if (ra.arcName != null)
{
newAi.setName(ra.arcName);
newAi.setTextDescriptor(ArcInst.ARC_NAME, ra.arcNameTD);
}
newAi.copyVarsFrom(ra.reconAr[0]);
newAi.copyVarsFrom(ra.reconAr[1]);
newArcs.add(newAi);
}
return newArcs;
}
}
/**
* Method to spread circuitry.
* @param cell the cell in which spreading happens.
* @param ni the NodeInst about which spreading happens (may be null).
* @param direction the direction to spread: 'u' for up, 'd' for down, 'l' for left, 'r' for right.
* @param amount the distance to spread (negative values compact).
* @param lX the low X bound of the node (the edge of spreading).
* @param hX the high X bound of the node (the edge of spreading).
* @param lY the low Y bound of the node (the edge of spreading).
* @param hY the high Y bound of the node (the edge of spreading).
*/
public static void spreadCircuitry(Cell cell, NodeInst ni, char direction, double amount, double lX, double hX, double lY, double hY)
{
// disallow spreading if lock is on
if (cantEdit(cell, null, true, false, true) != 0) return;
// initialize a collection of Geometrics that have been seen
Set<Geometric> geomSeen = new HashSet<Geometric>();
// set "already done" flag for nodes manhattan connected on spread line
boolean mustBeHor = true;
if (direction == 'l' || direction == 'r') mustBeHor = false;
if (ni != null) manhattanTravel(ni, mustBeHor, geomSeen);
// set "already done" flag for nodes that completely cover spread node or are in its line
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst oNi = it.next();
Rectangle2D r = oNi.getBaseShape().getBounds2D();
if (direction == 'l' || direction == 'r')
{
if (r.getMinX() < lX && r.getMaxX() > hX)
geomSeen.add(oNi);
if (oNi.getTrueCenterX() == (lX+hX)/2)
geomSeen.add(oNi);
} else
{
if (r.getMinY() < lY && r.getMaxY() > hY)
geomSeen.add(oNi);
if (oNi.getTrueCenterY() == (lY+hY)/2)
geomSeen.add(oNi);
}
}
// mark those arcinsts that should stretch during spread
for(Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); )
{
ArcInst ai = it.next();
NodeInst no1 = ai.getTailPortInst().getNodeInst();
NodeInst no2 = ai.getHeadPortInst().getNodeInst();
double xC1 = no1.getTrueCenterX();
double yC1 = no1.getTrueCenterY();
double xC2 = no2.getTrueCenterX();
double yC2 = no2.getTrueCenterY();
// if one node is along spread line, make it "no1"
if (geomSeen.contains(no2))
{
NodeInst swapNi = no1; no1 = no2; no2 = swapNi;
double swap = xC1; xC1 = xC2; xC2 = swap;
swap = yC1; yC1 = yC2; yC2 = swap;
}
// if both nodes are along spread line, leave arc alone
if (geomSeen.contains(no2)) continue;
boolean i = true;
if (geomSeen.contains(no1))
{
// handle arcs connected to spread line
switch (direction)
{
case 'l': if (xC2 <= lX) i = false; break;
case 'r': if (xC2 >= hX) i = false; break;
case 'u': if (yC2 >= hY) i = false; break;
case 'd': if (yC2 <= lY) i = false; break;
}
} else
{
// handle arcs that cross the spread line
switch (direction)
{
case 'l': if (xC1 > lX && xC2 <= lX) i = false; else
if (xC2 > lX && xC1 <= lX) i = false;
break;
case 'r': if (xC1 < hX && xC2 >= hX) i = false; else
if (xC2 < hX && xC1 >= hX) i = false;
break;
case 'u': if (yC1 > hY && yC2 <= hY) i = false; else
if (yC2 > hY && yC1 <= hY) i = false;
break;
case 'd': if (yC1 < lY && yC2 >= lY) i = false; else
if (yC2 < lY && yC1 >= lY) i = false;
break;
}
}
if (!i) geomSeen.add(ai);
}
// now look at every nodeinst in the cell
boolean moved = false;
boolean again = true;
while (again)
{
again = false;
for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )
{
NodeInst oNi = it.next();
// ignore this nodeinst if it has been spread already
if (geomSeen.contains(oNi)) continue;
// make sure nodeinst is on proper side of requested spread
double xC1 = oNi.getTrueCenterX();
double yC1 = oNi.getTrueCenterY();
boolean doIt = false;
switch (direction)
{
case 'l': if (xC1 < lX) doIt = true; break;
case 'r': if (xC1 > hX) doIt = true; break;
case 'u': if (yC1 > hY) doIt = true; break;
case 'd': if (yC1 < lY) doIt = true; break;
}
if (!doIt) continue;
// set every connecting nodeinst to be "spread"
for(Iterator<ArcInst> aIt = cell.getArcs(); aIt.hasNext(); )
{
ArcInst ai = aIt.next();
if (geomSeen.contains(ai))
{
// make arc temporarily unrigid
Layout.setTempRigid(ai, false);
} else
{
// make arc temporarily rigid
Layout.setTempRigid(ai, true);
}
}
netTravel(oNi, geomSeen);
// move this nodeinst in proper direction to do spread
switch(direction)
{
case 'l':
oNi.move(-amount, 0);
break;
case 'r':
oNi.move(amount, 0);
break;
case 'u':
oNi.move(0, amount);
break;
case 'd':
oNi.move(0, -amount);
break;
}
// set loop iteration flag and node spread flag
moved = true;
again = true;
break;
}
}
if (!moved) System.out.println("Nothing changed");
}
/**
* Method to travel through the network, setting flags.
* @param ni the NodeInst from which to start traveling.
* @param geomSeen the HashSet bit to mark during travel.
*/
private static void netTravel(NodeInst ni, Set<Geometric> geomSeen)
{
if (geomSeen.contains(ni)) return;
geomSeen.add(ni);
for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); )
{
Connection con = it.next();
ArcInst ai = con.getArc();
if (geomSeen.contains(ai)) continue;
netTravel(ai.getHeadPortInst().getNodeInst(), geomSeen);
netTravel(ai.getTailPortInst().getNodeInst(), geomSeen);
}
}
/**
* Method to recursively travel along all arcs on a NodeInst.
* @param ni the NodeInst to examine.
* @param hor true to travel along horizontal arcs; false for vertical.
* @param geomSeen the HashSet used to mark nodes that are examined.
* This is called from "spread" to propagate along manhattan
* arcs that are in the correct orientation (along the spread line).
*/
private static void manhattanTravel(NodeInst ni, boolean hor, Set<Geometric> geomSeen)
{
geomSeen.add(ni);
for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); )
{
Connection con = it.next();
ArcInst ai = con.getArc();
int angle = ai.getAngle();
if (hor)
{
// only want horizontal arcs
if (angle != 0 && angle != 1800) continue;
} else
{
// only want vertical arcs
if (angle != 900 && angle != 2700) continue;
}
int otherEnd = 1 - con.getEndIndex();
NodeInst other = ai.getPortInst(otherEnd).getNodeInst();
if (geomSeen.contains(other)) continue;
manhattanTravel(other, hor, geomSeen);
}
}
/****************************** NODE AND ARC REPLACEMENT ******************************/
private static class PossibleVariables
{
private static Map<PrimitiveNode,List<Variable.Key>> posVarsMap = new HashMap<PrimitiveNode,List<Variable.Key>>();
private static void add(String varName, PrimitiveNode pn) {
List<Variable.Key> varKeys = posVarsMap.get(pn);
if (varKeys == null) {
varKeys = new ArrayList<Variable.Key>();
posVarsMap.put(pn, varKeys);
}
Variable.Key key = Variable.newKey(varName);
if (!varKeys.contains(key)) varKeys.add(key);
}
static
{
add("ATTR_length", Schematics.tech().transistorNode);
add("ATTR_length", Schematics.tech().transistor4Node);
add("ATTR_width", Schematics.tech().transistorNode);
add("ATTR_width", Schematics.tech().transistor4Node);
add("ATTR_area", Schematics.tech().transistorNode);
add("ATTR_area", Schematics.tech().transistor4Node);
add("SIM_spice_model", Schematics.tech().sourceNode);
add("SIM_spice_model", Schematics.tech().transistorNode);
add("SIM_spice_model", Schematics.tech().transistor4Node);
add("SCHEM_meter_type", Schematics.tech().meterNode);
add("SCHEM_diode", Schematics.tech().diodeNode);
add("SCHEM_capacitance", Schematics.tech().capacitorNode);
add("SCHEM_resistance", Schematics.tech().resistorNode);
add("SCHEM_inductance", Schematics.tech().inductorNode);
add("SCHEM_function", Schematics.tech().bboxNode);
}
/**
* Get an iterator over valid Variable Keys for the primitive node
* @param pn the PrimitiveNode to examine.
* @return an Iterator over the Variable Keys on the Primitive Node.
*/
public Iterator<Variable.Key> getPossibleVarKeys(PrimitiveNode pn) {
List<Variable.Key> varKeys = posVarsMap.get(pn);
if (varKeys == null)
varKeys = new ArrayList<Variable.Key>();
return varKeys.iterator();
}
/**
* Method to decide a PrimitiveNode has a Variable key.
* @param key the Variable key.
* @param pn the PrimitiveNode to examine.
* @return true if a Variable key exists on the primitive node.
*/
public static boolean validKey(Variable.Key key, PrimitiveNode pn) {
List varKeys = posVarsMap.get(pn);
if (varKeys == null) return false;
return varKeys.contains(key);
}
}
/**
* Method to replace node "oldNi" with a new one of type "newNp"
* and return the new node. Also removes any node-specific variables.
*/
public static NodeInst replaceNodeInst(NodeInst oldNi, NodeProto newNp, boolean ignorePortNames,
boolean allowMissingPorts)
{
// replace the node
NodeInst newNi = oldNi.replace(newNp, ignorePortNames, allowMissingPorts);
if (newNi != null)
{
if (newNp instanceof PrimitiveNode)
{
// remove variables that make no sense
for (Iterator<Variable> it = newNi.getVariables(); it.hasNext(); ) {
Variable var = it.next();
Variable.Key key = var.getKey();
if (key != NodeInst.TRACE && !PossibleVariables.validKey(key, (PrimitiveNode)newNp))
{
newNi.delVar(var.getKey());
}
}
}
// now inherit parameters that now do exist
inheritAttributes(newNi);
}
return newNi;
}
/****************************** INHERIT ATTRIBUTES ******************************/
/**
* Method to inherit all prototype attributes down to instance "ni".
*/
public static void inheritAttributes(NodeInst ni)
{
// ignore primitives
if (!ni.isCellInstance()) return;
Cell cell = (Cell)ni.getProto();
// first inherit parameters from this node's prototype
if (cell.isIcon())
{
for(Iterator<Variable> vIt = cell.getParameters(); vIt.hasNext(); )
{
Variable var = vIt.next();
inheritCellParameter(var, ni);
}
}
// inherit attributes from this node's prototype
for(Iterator<Variable> it = cell.getVariables(); it.hasNext(); )
{
Variable var = it.next();
if (!var.getTextDescriptor().isInherit()) continue;
inheritCellAttribute(var, ni);
}
// inherit directly from each port's prototype
for(Iterator<Export> it = cell.getExports(); it.hasNext(); )
{
Export pp = it.next();
inheritExportAttributes(pp, ni);
}
}
/**
* Method to add all inheritable export variables from export "pp" on cell "np"
* to instance "ni".
*/
private static void inheritExportAttributes(Export pp, NodeInst ni)
{
for(Iterator<Variable> it = pp.getVariables(); it.hasNext(); )
{
Variable var = it.next();
if (!var.getTextDescriptor().isInherit()) continue;
Variable.Key attrKey = var.getKey();
// see if the attribute is already there
PortInst pi = ni.findPortInstFromProto(pp);
Variable newVar = pi.getVar(attrKey);
if (newVar != null) continue;
// set the attribute
TextDescriptor td = TextDescriptor.getPortInstTextDescriptor().withDisplay(false);
Object value = inheritAddress(pp, var);
value = Variable.withCode(value, CodeExpression.Code.NONE);
pi.newVar(attrKey, value, td);
}
}
/**
* Method to add inheritable variable "var" from cell "np" to instance "ni".
* If "icon" is not NONODEINST, use the position of the variable from it.
*/
private static void inheritCellAttribute(Variable var, NodeInst ni)
{
// see if the attribute is already there
Variable.Key key = var.getKey();
Variable newVar = ni.getVar(key);
if (newVar != null)
{
// make sure visibility is OK
if (!var.getTextDescriptor().isInterior())
{
// parameter should be visible: make it so
if (!newVar.isDisplay())
{
ni.addVar(newVar.withDisplay(true));
}
} else
{
// parameter not normally visible: make it invisible if it has the default value
if (newVar.isDisplay())
{
if (var.describe(-1).equals(newVar.describe(-1)))
{
ni.addVar(newVar.withDisplay(false));
}
}
}
} else {
ni.addVar(var);
// newVar = ni.updateVar(var.getKey(), inheritAddress(np, var));
// updateInheritedVar(newVar, ni, np, icon);
}
}
/**
* Method to add parameter "var" to instance "ni".
*/
public static void inheritCellParameter(Variable var, NodeInst ni)
{
// see if the attribute is already there
Variable.Key key = var.getKey();
if (ni.isDefinedParameter(key))
{
Variable param = ni.getParameter(key);
// make sure visibility is OK
if (!var.isInterior())
{
// parameter should be visible: make it so
if (!param.isDisplay())
ni.addParameter(param.withDisplay(true));
} else
{
// parameter not normally visible: make it invisible if it has the default value
if (param.isDisplay())
{
if (var.describe(-1).equals(param.describe(-1)))
ni.addParameter(param.withDisplay(false));
}
}
} else
{
Cell cell = (Cell)ni.getProto();
Variable iconVar = cell.getParameter(var.getKey());
TextDescriptor td = iconVar.getTextDescriptor();
Rectangle2D bounds = cell.getBounds();
double xd = td.getXOff() - bounds.getCenterX();
double yd = td.getYOff() - bounds.getCenterY();
td = td.withOff(xd, yd);
Object value = inheritAddress(cell, var);
ni.addParameter(Variable.newInstance(var.getKey(), value, td));
// ni.newVar(var.getKey(), value, td);
}
}
/**
* Helper method to determine the proper value of an inherited Variable.
* Normally, it is simply "var.getObject()", but if it is a string with the "++" or "--"
* sequence in it, then it indicates an auto-increments/decrements of that numeric value.
* The returned object has the "++"/"--" removed, and the original variable is modified.
* @param addr the ElectricObject on which this Variable resides.
* @param var the Variable being examined.
* @return the Object in the Variable.
*/
private static Object inheritAddress(ElectricObject addr, Variable var)
{
// if it isn't a string, just return its address
Object obj = var.getObject();
if (!(obj instanceof String)) return obj;
if (var.isCode()) return obj;
String str = (String)obj;
int plusPlusPos = str.indexOf("++");
int minusMinusPos = str.indexOf("--");
if (plusPlusPos < 0 && minusMinusPos < 0) return obj;
// construct the proper inherited string and increment the variable
int incrPoint = Math.max(plusPlusPos, minusMinusPos);
String retVal = str.substring(0, incrPoint) + str.substring(incrPoint+2);
// increment the variable
int i = incrPoint-1;
for( ; i>=0; i--)
if (!TextUtils.isDigit(str.charAt(i))) break;
i++;
int curVal = TextUtils.atoi(str.substring(i));
if (str.charAt(incrPoint) == '+') curVal++; else curVal--;
String newIncrString = str.substring(0, i) + curVal + str.substring(incrPoint);
if (addr instanceof Cell)
{
((Cell)addr).getCellGroup().updateParam((Variable.AttrKey)var.getKey(), newIncrString);
} else
{
addr.newVar(var.getKey(), newIncrString);
}
return retVal;
}
/****************************** LIBRARY CHANGES ******************************/
/**
* This class implement the command to rename a technology.
*/
public static class RenameTechnology extends Job
{
private Technology tech;
private String newName;
public RenameTechnology(Technology tech, String newName)
{
super("Renaming " + tech, User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.tech = tech;
this.newName = newName;
startJob();
}
public boolean doIt() throws JobException
{
String oldName = tech.getTechName();
tech.setTechName(newName);
System.out.println("Technology '" + oldName + "' renamed to '" + newName + "'");
// mark all libraries for saving
for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )
{
Library oLib = it.next();
if (oLib.isHidden()) continue;
oLib.setChanged();
}
return true;
}
}
/**
* This class implement the command to rename a library.
*/
public static class RenameLibrary extends Job
{
private Library lib;
private String newName;
private IdMapper idMapper;
public RenameLibrary(Library lib, String newName)
{
super("Renaming " + lib, User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.lib = lib;
this.newName = newName;
startJob();
}
public boolean doIt() throws JobException
{
String oldName = lib.getName();
idMapper = lib.setName(newName);
if (idMapper == null) return false;
fieldVariableChanged("idMapper");
System.out.println("Library '" + oldName + "' renamed to '" + newName + "'");
return true;
}
public void terminateOK() {
User.fixStaleCellReferences(idMapper);
}
}
/**
* Method to implement the "Mark All Libraries for Saving" command.
*/
public static void markAllLibrariesForSavingCommand()
{
new MarkAllLibraries();
}
private static class MarkAllLibraries extends Job
{
MarkAllLibraries()
{
super("Making all libraries", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
startJob();
}
public boolean doIt() throws JobException
{
// mark all libraries as "changed"
for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )
{
Library lib = it.next();
if (lib.isHidden()) continue;
// do not mark readable dump files for saving
String ext = TextUtils.getExtension(lib.getLibFile());
if (ext.equals("txt")) continue;
lib.setChanged();
if (lib.getLibFile() != null && OpenFile.getOpenFileType(lib.getLibFile().getFile(), FileType.JELIB) == FileType.DELIB)
{
// set all cells as changed as well
for (Iterator<Cell> it2 = lib.getCells(); it2.hasNext(); )
{
it2.next().lowLevelSetRevisionDate(new Date());
}
}
}
System.out.println("All libraries now need to be saved");
return true;
}
}
/**
* Method to implement the "Mark All Libraries for Saving" command.
*/
public static void markCurrentLibForSavingCommand()
{
new MarkCurrentLibForSaving();
}
private static class MarkCurrentLibForSaving extends Job
{
MarkCurrentLibForSaving()
{
super("Making Current Lib", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
startJob();
}
public boolean doIt() throws JobException
{
Library lib = Library.getCurrent();
if (lib.isHidden()) return true;
// do not mark readable dump files for saving
String ext = TextUtils.getExtension(lib.getLibFile());
if (ext.equals("txt")) return true;
lib.setChanged();
if (lib.getLibFile() != null && OpenFile.getOpenFileType(lib.getLibFile().getFile(), FileType.JELIB) == FileType.DELIB)
{
// set all cells as changed as well
for (Iterator<Cell> it2 = lib.getCells(); it2.hasNext(); )
{
it2.next().lowLevelSetRevisionDate(new Date());
}
}
System.out.println("Library "+lib.getName()+" now needs to be saved");
return true;
}
}
/**
* This class implement the command to repair libraries.
*/
public static class CheckAndRepairJob extends Job
{
private boolean repair;
public CheckAndRepairJob(boolean repair)
{
super((repair ? "Repair Libraries" : "Check Libraries"), User.getUserTool(), (repair ? Job.Type.CHANGE : Job.Type.REMOTE_EXAMINE), null, null, Job.Priority.USER);
this.repair = repair;
startJob();
}
public boolean doIt() throws JobException
{
if (EDatabase.serverDatabase().checkInvariants())
{
ErrorLogger errorLogger = ErrorLogger.newInstance(repair ? "Repair Libraries" : "Check Libraries");
int errorCount = 0;
for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )
{
Library lib = it.next();
errorCount += lib.checkAndRepair(repair, errorLogger);
}
if (errorCount > 0) System.out.println("Found " + errorCount + " errors"); else
System.out.println("No errors found");
errorLogger.termLogging(true);
}
return true;
}
}
/**
* This class implement the command to reload a library
*/
public static class ReloadLibraryJob extends Job
{
private Library lib;
public ReloadLibraryJob(Library lib)
{
super("Reload Library " + lib.getName(), User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.lib = lib;
startJob();
}
public boolean doIt()
{
LibraryFiles.reloadLibrary(lib);
return true;
}
}
/****************************** DELETE UNUSED NODES ******************************/
// public static class RemoveUnusedLayers extends Job
// {
// private Library library;
//
// public RemoveUnusedLayers(Library lib)
// {
// super("Remove unused metal layers", null, Type.CHANGE, null, null, Priority.USER);
// library = lib;
// startJob();
// }
//
// public boolean doIt() throws JobException
// {
// // Only one library, the given one
// if (library != null)
// {
// cleanUnusedNodesInLibrary(library);
// return true;
// }
//
// // Checking all
// for (Iterator<Library> libIter = Library.getLibraries(); libIter.hasNext();)
// {
// Library lib = libIter.next();
// cleanUnusedNodesInLibrary(lib);
// }
// return true;
// }
//
// private void cleanUnusedNodesInLibrary(Library lib)
// {
// int action = -1;
// List<Geometric> list = new ArrayList<Geometric>();
//
// for (Iterator<Cell> cellsIter = lib.getCells(); cellsIter.hasNext();)
// {
// Cell cell = cellsIter.next();
// if (cell.getView() != View.LAYOUT) continue; // only layout
// list.clear();
// Technology tech = cell.getTechnology();
//
// for (int i = 0; i < cell.getNumArcs(); i++)
// {
// ArcInst ai = cell.getArc(i);
// ArcProto ap = ai.getProto();
// if (ap.isNotUsed())
// list.add(ai);
// }
// for (int i = 0; i < cell.getNumNodes(); i++)
// {
// NodeInst ni = cell.getNode(i);
// tech.cleanUnusedNodesInLibrary(ni, list);
// }
// if (action != 3 && list.size() > 0)
// {
// String [] options = {"Yes", "No", "Cancel", "Yes to All"};
//
// action = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
// "Remove unused nodes in " + cell.libDescribe(), "Warning",
// JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
// null, options, options[0]);
// if (action == 2) return; // cancel
// }
// if (action != 1) // 1 is No to this local modification
// {
// System.out.println("Removing " + list.size() + " unused nodes in " + cell.libDescribe());
// eraseObjectsInList(cell, list);
// }
// }
// }
// }
/****************************** DETERMINE ABILITY TO MAKE CHANGES ******************************/
/**
* Method to test whether a NodeInst can be modified in a cell.
* Throws an exception if not.
* @param cell the Cell in which the NodeInst resides.
* @param item the NodeInst (may be null).
* @param giveError true to print an error message if the modification is disallowed.
* @param allowInstanceChange true to allow a change to an instance when instances are locked
* (this allows exports to be created and deleted).
*/
public static void testEditable(Cell cell, NodeInst item, boolean giveError, boolean allowInstanceChange)
throws CantEditException
{
// if an instance is specified, check it
if (item != null)
{
if (item.isLocked())
{
CantEditException e = new CantEditException();
e.lockedNode = item;
throw e;
}
boolean complexNode = false;
if (!item.isCellInstance())
{
// see if a primitive is locked
if (((PrimitiveNode)item.getProto()).isLockedPrim() &&
User.isDisallowModificationLockedPrims())
{
CantEditException e = new CantEditException();
e.lockedPrim = item;
throw e;
}
PrimitiveNode.Function fun = item.getFunction();
if (fun != PrimitiveNode.Function.PIN && fun != PrimitiveNode.Function.CONTACT &&
fun != PrimitiveNode.Function.NODE && fun != PrimitiveNode.Function.CONNECT)
complexNode = true;
} else
{
// see if this type of cell is locked
complexNode = true;
if (!allowInstanceChange && cell.isInstancesLocked())
{
CantEditException e = new CantEditException();
e.lockedInstances = cell;
e.lockedExample = item;
throw e;
}
}
if (complexNode)
{
if (User.isDisallowModificationComplexNodes())
{
CantEditException e = new CantEditException();
e.lockedComplex = item;
throw e;
}
}
}
// check for general changes to the cell
if (cell.isAllLocked())
{
CantEditException e = new CantEditException();
e.lockedAll = cell;
e.lockedExample = item;
throw e;
}
}
/**
* Method to tell whether a NodeInst can be modified in a cell.
* WARNING: method may change the database if the user disables a cell lock,
* so method must be called inside of a Change job.
* @param cell the Cell in which the NodeInst resides.
* @param item the NodeInst (may be null).
* @param giveError true to print an error message if the modification is disallowed.
* @param allowInstanceChange true to allow a change to an instance when instances are locked
* (this allows exports to be created and deleted).
* @param insideJob true if this is being run inside of a job.
* @return positive if the edit CANNOT be done.
* Return negative if the edit CANNOT be done and the overall operation should be cancelled.
* Return zero if the operation CAN be done.
*/
public static int cantEdit(Cell cell, NodeInst item, boolean giveError, boolean allowInstanceChange, boolean insideJob)
{
String [] options = {"Yes", "No", "Always", "Cancel"};
// if an instance is specified, check it
if (item != null)
{
if (item.isLocked())
{
if (!giveError) return 1;
int ret = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
"Changes to locked " + item + " are disallowed. Change anyway?",
"Allow changes", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
if (ret == 1) return 1;
if (ret == 2)
{
if (insideJob) item.clearLocked(); else
new ClearNodeLocked(item);
}
if (ret == 3 || ret == -1) return -1; // -1 represents ESC or cancel
}
boolean complexNode = false;
if (!item.isCellInstance())
{
// see if a primitive is locked
if (((PrimitiveNode)item.getProto()).isLockedPrim() &&
User.isDisallowModificationLockedPrims())
{
if (!giveError) return 1;
int ret = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
"Changes to locked primitives (such as " + item + ") are disallowed. Change anyway?",
"Allow changes", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
if (ret == 1) return 1;
if (ret == 2) User.setDisallowModificationLockedPrims(false);
if (ret == 3) return -1;
}
PrimitiveNode.Function fun = item.getFunction();
if (fun != PrimitiveNode.Function.PIN && fun != PrimitiveNode.Function.CONTACT &&
fun != PrimitiveNode.Function.NODE && fun != PrimitiveNode.Function.CONNECT)
complexNode = true;
} else
{
// see if this type of cell is locked
complexNode = true;
if (!allowInstanceChange && cell.isInstancesLocked())
{
if (!giveError) return 1;
int ret = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
"Modification of instances in " + cell + " is disallowed. You cannot move " + item +
". Change anyway?",
"Allow changes", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
if (ret == 1) return 1;
if (ret == 2)
{
if (insideJob) cell.clearInstancesLocked(); else
new ClearCellLocked(cell, false);
}
if (ret == 3) return -1;
}
}
if (complexNode)
{
if (User.isDisallowModificationComplexNodes())
{
if (!giveError) return 1;
int ret = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
"Changes to complex nodes (such as " + item + ") are disallowed. Change anyway?",
"Allow changes", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
if (ret == 1) return 1;
if (ret == 2) User.setDisallowModificationComplexNodes(false);
if (ret == 3) return -1;
}
}
}
// check for general changes to the cell
if (cell.isAllLocked())
{
if (!giveError) return 1;
int ret = JOptionPane.showOptionDialog(TopLevel.getCurrentJFrame(),
"Modification of " + cell + " is disallowed. Change "+((item == null)? "" : item.toString())+" anyway?",
"Allow changes", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
if (ret == 1) return 1;
if (ret == 2)
{
if (insideJob) cell.clearAllLocked(); else
new ClearCellLocked(cell, true);
}
if (ret == 3) return -1;
}
return 0;
}
/**
* This class clears a node lock bit in a Job.
*/
public static class ClearNodeLocked extends Job
{
private NodeInst ni;
public ClearNodeLocked(NodeInst ni)
{
super("Clear locked state of " + ni.describe(false), User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.ni = ni;
startJob();
}
public boolean doIt()
{
ni.clearLocked();
return true;
}
}
/**
* This class clears a cell lock bit in a Job.
*/
public static class ClearCellLocked extends Job
{
private Cell cell;
private boolean all;
public ClearCellLocked(Cell cell, boolean all)
{
super("Clear locked state of " + cell.getName(), User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
this.cell = cell;
this.all = all;
startJob();
}
public boolean doIt()
{
if (all) cell.clearAllLocked(); else
cell.clearInstancesLocked();
return true;
}
}
}
| [
"yuzhongxing88@gmail.com"
] | yuzhongxing88@gmail.com |
d0062766e85b6eb2b61313029e57bc91818a6999 | e21b75f5f0092d2a35cecb53751f711120545166 | /dbflute-runtime/src/main/java/org/dbflute/exception/QueryDerivedReferrerInvalidColumnSpecificationException.java | 9aea44d5cad69e04154e4afe06dbc84e96f099c9 | [
"Apache-2.0"
] | permissive | tty-github/dbflute-core | 1f4dfcd5a878ee85572b56411c002506291fc002 | b8bc0a2f84630967a14aff97b13131d6dac5bfcd | refs/heads/master | 2021-01-16T20:52:35.290319 | 2016-03-18T13:55:57 | 2016-03-18T13:55:57 | 42,177,557 | 0 | 0 | null | 2015-09-09T12:41:14 | 2015-09-09T12:41:13 | null | UTF-8 | Java | false | false | 1,474 | java | /*
* Copyright 2014-2015 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.dbflute.exception;
/**
* The exception of when the column specification of query derived referrer is invalid.
* @author jflute
*/
public class QueryDerivedReferrerInvalidColumnSpecificationException extends RuntimeException {
/** The serial version UID for object serialization. (Default) */
private static final long serialVersionUID = 1L;
/**
* Constructor.
* @param msg The message of the exception. (NotNull)
*/
public QueryDerivedReferrerInvalidColumnSpecificationException(String msg) {
super(msg);
}
/**
* Constructor.
* @param msg The message of the exception. (NotNull)
* @param cause The cause of the exception. (NotNull)
*/
public QueryDerivedReferrerInvalidColumnSpecificationException(String msg, Throwable cause) {
super(msg, cause);
}
}
| [
"dbflute@gmail.com"
] | dbflute@gmail.com |
11b58b79b1d268b864a6b437f0dac3f73f75b178 | b6d206ddce72295a2315a2eea3042742cc3d6d1e | /demo/src/main/java/com/example/demo/Constraints/Geometry.java | 50c9e47d02c5fa37a86d9b310ee3d3964cc242fa | [] | no_license | juliehaga/case | 0666366bb6053497c6935e2b86203fdee27b2a90 | 953b582f54d2fe28d0776c3e0d7cf2451bed9a64 | refs/heads/master | 2020-07-25T20:15:35.335475 | 2019-09-18T21:58:11 | 2019-09-18T21:58:11 | 208,413,182 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 166 | java | package com.example.demo.Constraints;
import lombok.Data;
import java.util.List;
@Data
public class Geometry {
private List<List<List<Double>>> coordinates;
}
| [
"jul.haga@gmail.com"
] | jul.haga@gmail.com |
e5d3b65bcf2760b51dbf015580642fed38fb9e07 | 886a086a9c2da96df4c75a129b26835b37ff7e58 | /TimeClass/src/timeclass/tuna.java | 8a124c01cc3b02d80c1d187e823694802f2c5b07 | [] | no_license | sfrey5/LearningJava | 1f4c397036bcbeb2684734ed1d18bef84d7748c9 | 5cf91291e26f883580c654a428290d1af17a2858 | refs/heads/main | 2023-02-03T00:08:32.001860 | 2020-12-19T23:58:56 | 2020-12-19T23:58:56 | 322,956,963 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 840 | 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 timeclass;
/**
*
* @author Steven
*/
public class tuna {
private int hour;
private int minute;
private int second;
public void setTime(int h, int m, int s) {
hour = ((h >= 0 && h < 24) ? h : 0);
minute = ((m >= 0 && m < 60) ? m : 0);
second = ((s >= 0 && s < 60) ? s : 0);
}
public String toMilitary() {
return String.format("%02d:%02d:%02d", hour, minute, second);
}
public String toRegular() {
return String.format("%d:%02d:%02d %s", ((hour == 0 || hour == 12) ? 12 : hour % 12), minute, second, ((hour < 12) ? "AM" : "PM"));
}
}
| [
"noreply@github.com"
] | noreply@github.com |
fffd89ce3c406aead9d73b4897d91eff94f8c825 | 9432fa6727212ef467035e6d71b4a9f69c213223 | /app/src/main/java/com/technologies/pittu/zoloassignment/view/adapter/WordsAdapter.java | 4708a546fb0930c65521809ba9b247b87111e954 | [] | no_license | Harishpittu/ZoloAssignment | ec8e4841bcb0782741641bc2061d0cf7b308e209 | 5e8430b9af7fa68c02c76867d34c0afe629b7409 | refs/heads/master | 2021-01-01T17:07:19.271749 | 2017-07-26T08:26:22 | 2017-07-26T08:26:22 | 98,002,875 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,864 | java |
package com.technologies.pittu.zoloassignment.view.adapter;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.technologies.pittu.zoloassignment.R;
import com.technologies.pittu.zoloassignment.databinding.ItemWordBinding;
import com.technologies.pittu.zoloassignment.model.Word;
import com.technologies.pittu.zoloassignment.viewmodel.ItemAbacusViewModel;
import java.util.Collections;
import java.util.List;
public class WordsAdapter extends RecyclerView.Adapter<WordsAdapter.WordAdapterViewHolder> {
private List<Word> wordList = Collections.emptyList();
public WordsAdapter() {
}
@Override
public WordAdapterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemWordBinding itemWordBinding =
DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_word,
parent, false);
return new WordAdapterViewHolder(itemWordBinding);
}
@Override
public void onBindViewHolder(WordAdapterViewHolder holder, int position) {
holder.bindWord(wordList.get(position));
}
@Override
public int getItemCount() {
return wordList.size();
}
public void setWordList(List<Word> wordList) {
this.wordList = wordList;
notifyDataSetChanged();
}
public static class WordAdapterViewHolder extends RecyclerView.ViewHolder {
ItemWordBinding itemWordBinding;
public WordAdapterViewHolder(ItemWordBinding itemWordBinding) {
super(itemWordBinding.itemPeople);
this.itemWordBinding = itemWordBinding;
}
void bindWord(Word word) {
itemWordBinding.setAbacusViewModel(new ItemAbacusViewModel(word));
}
}
}
| [
"harish@stocksl.com"
] | harish@stocksl.com |
bafe71be03a7cfab6ba9f03a7cb3a043fb8fc7cd | be146064364e91e83396aae7b9c6cf20bfde9fcb | /Game.java | dcd406aff703df0f35cd243597fad275579f5223 | [] | no_license | rolyn2802/FBLA-Game | 2a065d807d43794b596c8304ab715ff8202bf471 | 087b891600c175679b2620f5a176a5f406cff319 | refs/heads/master | 2020-08-11T09:52:24.057159 | 2019-10-12T00:14:36 | 2019-10-12T00:14:36 | 214,544,385 | 0 | 0 | null | 2019-10-12T00:14:36 | 2019-10-11T23:25:40 | Java | UTF-8 | Java | false | false | 3,116 | java | package ca.wade.game;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import javax.swing.JFrame;
import gfx.Renderer;
public class Game extends Canvas implements Runnable{
private static final long serialVersionUID = 1L;
//Width and Height of box set
public static final int WIDTH = 640;
public static final int HEIGHT = WIDTH /4*3;
//Title
public static final String TITLE = "Gamer";
//Initializing game
private static Game game = new Game();
private boolean running = false;
private Thread thread;
private Renderer gfx;
public static Game getInstance() {
return game;
}
public void init() {
gfx = new Renderer();
}
public void tick() {
}
public void render() {
BufferStrategy bs = this.getBufferStrategy();
if(bs == null) {
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(new Color(0, 120, 255));
g.fillRect(0, 0, WIDTH, HEIGHT);
///////////////////////////////////////
gfx.renderBackground(g);
gfx.renderForeground(g);
g.dispose();
bs.show();
}
@Override
public void run() {
init();
long lastTime = System.nanoTime();
//60 Ticks in a second (Updates)
final double numTicks = 60.0;
double n = 1000000000 / numTicks;
double delta = 0;
int frames = 0;
int ticks = 0;
long timer = System.currentTimeMillis();
while(running) {
long currentTime = System.nanoTime();
delta += (currentTime - lastTime) / n;
lastTime = currentTime;
if(delta >= 1) {
ticks++;
delta--;
}
render();
frames++;
if(System.currentTimeMillis() - timer > 1000) {
timer += 1000;
System.out.println(ticks + " Ticks, FPS: " + frames);
ticks = 0;
frames = 0;
}
}
stop();
}
public static void main(String args[]) {
//Creates java frame
JFrame frame = new JFrame(TITLE);
//adds the game component
frame.add(game);
//sets frame size
frame.setSize(WIDTH, HEIGHT);
//Closes when you click the "x"
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//enables key and mouse input
frame.setFocusable(true);
//Creates window in center of screen
frame.setLocationRelativeTo(null);
//disables resizing of frame
frame.setResizable(false);
//Makes frame visible
frame.setVisible(true);
//"packs" all of these into the frame
frame.pack();
game.start();
}
private synchronized void start() {
if(running)
return;
else
running = true;
thread = new Thread(this);
thread.start();
}
private synchronized void stop() {
if(!running)
return;
else
running = false;
try {
thread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.exit(1);
}
//test
}
| [
"noreply@github.com"
] | noreply@github.com |
e9b40754589f2c9976ddc80dea876891f7434d44 | 0271a8d6fe08d82647adde66f385528cbeccfc2e | /pad/video/src/com/miui/video/widget/actionmode/ActionModeBottomMenuItem.java | bf5a8d7316719035e7e4f14ae0b82506e3ff7f08 | [] | no_license | eltld/MiuiVideo | 8ac9bb2e5b3545c0a18964e7bb5e014d2197988c | ce578e51833268bc65091d14d630e6bf6cf62af4 | refs/heads/master | 2020-05-29T11:06:37.612962 | 2015-03-06T01:47:07 | 2015-03-06T01:47:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,525 | java | package com.miui.video.widget.actionmode;
import android.content.Context;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.miui.video.R;
/**
*@author tangfuling
*
*/
public class ActionModeBottomMenuItem extends LinearLayout {
private Context mContext;
private ImageView mIcon;
private TextView mText;
private int mIconWidth;
private int mIconHeight;
private int mTextTopMargin;
private int mTextSize;
private boolean mIsLight;
private ActionModeItemClickListener mListener;
public ActionModeBottomMenuItem(Context context, boolean isLight) {
super(context);
this.mContext = context;
this.mIsLight = isLight;
init();
}
public void setIcon(int resId) {
mIcon.setImageResource(resId);
}
public void setText(int resId) {
mText.setText(resId);
}
protected void setActionModeItemClickListener(ActionModeItemClickListener listener) {
this.mListener = listener;
}
protected void setIsEnabled(boolean enabled) {
this.setEnabled(enabled);
mIcon.setEnabled(enabled);
if(enabled) {
if (mIsLight) {
mText.setTextColor(getResources().getColor(R.color.p_60_black));
} else {
mText.setTextColor(getResources().getColor(R.color.white));
}
} else {
if (mIsLight) {
mText.setTextColor(getResources().getColor(R.color.p_40_black));
} else {
mText.setTextColor(getResources().getColor(R.color.p_40_white));
}
}
}
//init
private void init() {
setOrientation(VERTICAL);
initDimen();
initView();
}
private void initDimen() {
mIconWidth = getResources().getDimensionPixelSize(R.dimen.action_mode_bottom_menu_item_icon_width);
mIconHeight = getResources().getDimensionPixelSize(R.dimen.action_mode_bottom_menu_item_icon_height);
mTextTopMargin = getResources().getDimensionPixelSize(R.dimen.action_mode_bottom_menu_item_text_top_margin);
mTextSize = getResources().getDimensionPixelSize(R.dimen.font_size_13);
}
private void initView() {
mIcon = new ImageView(mContext);
if (mIsLight) {
mIcon.setBackgroundResource(R.drawable.bottom_menu_item_bg_dark);
} else {
mIcon.setBackgroundResource(R.drawable.bottom_menu_item_bg_light);
}
LayoutParams iconParams = new LayoutParams(mIconWidth, mIconHeight);
iconParams.gravity = Gravity.CENTER_HORIZONTAL;
addView(mIcon, iconParams);
mText = new TextView(mContext);
if (mIsLight) {
mText.setTextColor(getResources().getColor(R.color.p_60_black));
} else {
mText.setTextColor(getResources().getColor(R.color.white));
}
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
LayoutParams textParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
textParams.gravity = Gravity.CENTER_HORIZONTAL;
textParams.topMargin = mTextTopMargin;
addView(mText, textParams);
this.setClickable(true);
this.setOnClickListener(mOnClickListener);
}
//UI callback
private OnClickListener mOnClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
if(mListener != null) {
mListener.onActionModeItemClick(ActionModeBottomMenuItem.this);
}
}
};
//self def class
public interface ActionModeItemClickListener {
public void onActionModeItemClick(ActionModeBottomMenuItem menuItem);
}
}
| [
"liuchao1@xiaomi.com"
] | liuchao1@xiaomi.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.