blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
132 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
28 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
352
e43cd8783af2e8a8b30b983fc61d5d7ddedd34df
e1dca1e3b75cba4d92e97c0b4928d8b2c6175761
/src/main/java/ru/langboost/config/AppInitializer.java
c6078f3480c702dce9cc5043c12644e94c7cf68f
[]
no_license
badprogrammist/langboost
8864647c79cd870bfb7b148f8d3223819025bd3f
e799cf383fde380f2b70303c303762afc3830831
refs/heads/master
2016-08-12T00:23:26.726919
2015-12-17T04:18:39
2015-12-17T04:18:39
47,684,132
0
0
null
null
null
null
UTF-8
Java
false
false
1,159
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 ru.langboost.config; import javax.servlet.Filter; import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; /** * * @author bad */ public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class[]{AppConfig.class}; } @Override protected Class<?>[] getServletConfigClasses() { return null; } @Override protected String[] getServletMappings() { return new String[]{"/"}; } @Override protected Filter[] getServletFilters() { CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); return new Filter[]{characterEncodingFilter}; } }
[ "badprogrammist@gmail.com" ]
badprogrammist@gmail.com
146132228ca0656c5563025a6d054dd24b2a542f
d7d3b7cf3730384bd872a9b037346c004bcb36e6
/src/main/java/com/jpmorgan/interviews/codes/model/Stock.java
9e5aca912e82ff62f5fb37414ee6e73d99aefcae
[ "Apache-2.0" ]
permissive
manishapadhi01/supersimplestock-1
a80464a512c132308bbc46709b6a6474ac1f1de2
ded0ab0bb30adefed6f80bdf7ba6f19afed7d5c7
refs/heads/master
2021-01-19T21:11:35.499171
2015-11-02T15:04:35
2015-11-02T15:04:35
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,331
java
package com.jpmorgan.interviews.codes.model; import com.jpmorgan.interviews.codes.api.model.Entity; import com.jpmorgan.interviews.codes.exception.SimpleStocksExceptionImpl; /** * Created by sadebayo on 27/10/2015. */ public abstract class Stock implements Entity, Cloneable { private double ZERO = 0.0; private String symbol; private String name; private String type; private String entityType; private double price; private double dividendYield; private double peRatio; private double lastDividendValue = ZERO; private double parValue = ZERO; private double marketPrice = ZERO; private long timeStamp; private int qty; /** * Default constructor for Stock. Sets default values. */ public Stock(){ this.entityType = "Stock"; this.type = "Stock"; this.price = price; this.dividendYield = ZERO; this.peRatio = ZERO; this.symbol = ""; this.name = "Stock"; } /** * Constructor for Stock * @params double lastDividendValue: Last dividend value. * double parValue: Par value for stock. * Sting symbol: Stock symbol. */ public Stock(double lastDividendValue, double parValue, String symbol){ this.lastDividendValue = lastDividendValue; this.parValue = parValue; this.symbol = symbol; this.timeStamp = System.currentTimeMillis(); } /** * Constructor for Stock * @params double lastDividendValue: Last dividend value. * double parValue: Par value for stock. * double price: Market price for stock * Sting symbol: Stock symbol. */ public Stock(double lastDividendValue, double parValue, double price, String symbol){ this.lastDividendValue = lastDividendValue; this.parValue = parValue; this.symbol = symbol; this.marketPrice = price; this.timeStamp = System.currentTimeMillis(); } /** * Method to set the name of entity (stock) * @return String entityType: Entity type. */ public void setEntityType(String entityType){ this.entityType = entityType; } /** * Method to set the name of entity (stock) * @params String name: Name of entity (stock). */ public void setName(String name){ this.name = name; } /** * Method to set the type of entity * @return String type: Type of entity. */ public void setType(String type){ this.type = type; } /** * Method to set the quantity of stock * @params int qty: Quantity of stock. */ public void setQuantity(int qty){ this.qty = qty; } /** * Method to get the name of entity (stock) * @return String name: Name of entity (stock). */ public String getName(){ return this.name; } /** * Method to get the type of stock * @return String type: Type of stock. */ public String getType(){ return this.type; } /** * Method to get the entity type (stock) * @return String entityType: Entity type. */ public String getEntityType(){ return this.entityType; } /** * Method to get the quantity of stock * @return int qty: Quantity of stock. */ public int getQuantity(){ return this.qty; } /** * Method compute the PE ratio for a stock * @params double price: Market price for stock * @return double PERatio : Stock's PE Ratio. * @throws SimpleStocksExceptionImpl sse */ public double computePERatio() throws Exception { if (this.getMarketValue() < ZERO) throw new SimpleStocksExceptionImpl("Negative Error: Stock maket price cannot be negative"); if (this.computeDividendYield() < ZERO) throw new SimpleStocksExceptionImpl("Negative Error: Stock yield in dividend cannot be negative"); if (this.computeDividendYield() == ZERO) throw new SimpleStocksExceptionImpl("Divide by Zero Error: Stock yield in dividend cannot be zero"); return this.getMarketValue() / this.computeDividendYield(); } /** * Abstract method for computing dividend yield * @return double PERatio : PE Ratio value for a stock. */ public abstract double computeDividendYield() throws Exception; /** * Method compute the dividend yield for a stock, given price * @params double price: Market price for stock * @return double dividendYield : Stock's dividend yield given price. * @throws SimpleStocksExceptionImpl sse */ public double computeDividendYield(double price) throws Exception{ this.setMarketValue(price); return computeDividendYield(); } /** * Method to compute the PE ratio for a stock, given price * @params double price: Market price for stock * @return double PERatio : Computed PE Ratio value for a stock. * @throws SimpleStocksExceptionImpl sse */ public double computePERatio(double price) throws Exception{ this.setMarketValue(price); return computePERatio(); } /** * Method to get computed stock's value per share. * @params double marketPrice: Stock's last dividend value / price. */ public double getValue() { return this.getMarketValue() * this.getQuantity(); } /** * Method to set the stock's last dividend value / price. * @params double marketPrice: Stock's last dividend value / price. */ public void setLastDividendValue(double lastDividendValue){ this.lastDividendValue = lastDividendValue; } /** * Method to set the stock's par value / price. * @params double marketPrice: Stock's par price. */ public void setParValue(double parValue){ this.parValue = parValue; } /** * Method to set the stock's market value / price. * @params double marketPrice: Stock's market price. */ public void setMarketValue(double price){ this.marketPrice = price; } /** * Method to set the stock symbol. * @params String symbol : Stock's symbol. */ public void setSymbol(String symbol){ this.symbol = symbol; } /** * Method to get the computed dividend yeild for stock, given price. * @return double dividendYield : Stock's dividend yield. */ public double getDividendYield(){ return this.dividendYield; } /** * Method to get the computed PE ratio for a stock * @return double PERatio : PE Ratio value for a stock. */ public double getPERatio(){ return this.getDividendYield(); } /** * Method to get the last dividend value for stock. * @return double lastDividendValue : Last dividend value for stock. */ public double getLastDividendValue(){ return this.lastDividendValue; } /** * Method to get the par value for stock * @return double parValue: Par value for stock. */ public double getParValue(){ return this.parValue; } /** * Method to get the market price for stock * @return double marketValue : Stock market price. */ public double getMarketValue(){ return this.marketPrice; } /** * Method to get the symbol for stock * @return String symbol : Stock symbol. */ public String getSymbol(){ return this.symbol; } /** * Method to set the timestamp for stock * @params long timeStamp : Timestamp for stock creation. */ public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } /** * Method to get the timestamp for stock creation * @return long timeStamp : Timestamp for stock creation. */ public long getTimeStamp() { return this.timeStamp; } /** * Method to clone a common stock * @return Stock stock: a copy of an instance of a common stock */ public Stock clone() { try { return (Stock) super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); throw new RuntimeException(); } } }
[ "solomoniyi@gmail.com" ]
solomoniyi@gmail.com
60f4fecd5cacb5b305578fbd9b736dd42d0c3dd8
f071803da7cc1c2174fbe4f7daf34c423fc51feb
/src/org/task/It11.java
e69a35fb6072142f96d86e63e01f9095d8efa915
[]
no_license
Charanbuddy/Iteration-Programs
fd88a26ffa1958d90475f8d925b2efd0136dca98
999c1764e75fa437f1115a436906942f4fab07bd
refs/heads/master
2023-02-21T02:08:59.103742
2021-01-27T16:38:44
2021-01-27T16:38:44
333,156,146
0
0
null
null
null
null
UTF-8
Java
false
false
486
java
package org.task; import java.util.Scanner; public class It11 { public static void main(String[] args) { // sum of Digits in a Number Scanner sc = new Scanner(System.in); System.out.println("Enter a Number: "); int number = sc.nextInt(); int revNumber = 0; int remainder = 0; while (number > 0) { remainder = number % 10; number = number / 10; revNumber = revNumber + remainder; } System.out.println("Sum of the given number: " + revNumber); } }
[ "charanbuddy@gmail.com" ]
charanbuddy@gmail.com
392f1aeabfe2c6b8a22eef6cb40709e77ec0ed0e
47615faf90f578bdad1fde4ef3edae469d995358
/practise/SCJP5.0 猛虎出閘/第一次練習/unit 8/FileInputStreamTest4.java
aa9493461fe49a6f2c5618a284375b096422a683
[]
no_license
hungmans6779/JavaWork-student-practice
dca527895e7dbb37aa157784f96658c90cbcf3bd
9473ca55c22f30f63fcd1d84c2559b9c609d5829
refs/heads/master
2020-04-14T01:26:54.467903
2018-12-30T04:52:38
2018-12-30T04:52:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
360
java
import java.io.*; public class FileInputStreamTest4 { public static void main(String argv[]) { FileInputStream fin; try { fin=new FileInputStream("FileInputStream.txt"); int i=fin.read(); while(i!=-1) { System.out.print((char)i); i=fin.read(); } fin.close(); } catch(IOException ioe) { ioe.printStackTrace(); } } }
[ "hungmans6779@msn.com" ]
hungmans6779@msn.com
0cae4a14c0507faf2acb424401b13163f3e8d94c
ddd5d8641ed49f3008070a6fd448d9e4f1020d60
/src/mailcore/java/org/larry/concurrency/IExecutorMBean.java
39d255368984c56cdfd05ad64591923a6d6baecb
[ "Apache-2.0" ]
permissive
lemmaworks/mailcore
61541020e702329a2a38abe26e21d64830bc9612
ae2399cb38a610b9846ad7681d855be909ca7138
refs/heads/master
2020-04-09T14:58:59.286521
2018-03-22T08:53:04
2018-03-22T08:53:04
22,341,549
0
0
null
null
null
null
UTF-8
Java
false
false
1,158
java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.larry.concurrency; public interface IExecutorMBean { /** * Get the current number of running tasks */ public int getActiveCount(); /** * Get the number of completed tasks */ public long getCompletedTasks(); /** * Get the number of tasks waiting to be executed */ public long getPendingTasks(); }
[ "larry.leqt@outlook.com" ]
larry.leqt@outlook.com
9755784a4702c1701699925aa637a38417b2885b
e21f10facb5db78e142da6be0e2e3299ef829431
/javaweb-05-cookie/src/main/java/com/csu/servlet/CookieDemo2.java
bc323d7552d995467dfcdf33efc2e6bd29f96f89
[]
no_license
so1esou1/Learn
5b98cd5285e9bc93fdc70b0542e4aa027e1bd0bf
02405826a973f9a56f0c234cfbf8c59be007be35
refs/heads/master
2023-05-04T02:38:58.810083
2021-05-17T14:29:24
2021-05-17T14:29:24
326,638,883
1
0
null
null
null
null
UTF-8
Java
false
false
1,054
java
package com.csu.servlet; /* 创建一个cookie顶替掉demo1中的cookie,设置有效时间为0,这样的话就相当于删除了一个cookie!!! */ import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; public class CookieDemo2 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //创建的cookie必须跟上一个cookie的名字一致 Cookie cookie = new Cookie("lastLoginTime", System.currentTimeMillis()+""); //设置有效期: cookie.setMaxAge(0); //添加cookie resp.addCookie(cookie); //之后访问cookie2就会清掉cookie } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doPost(req, resp); } }
[ "1402916604@qq.com" ]
1402916604@qq.com
0dd62f3a0b828b292ff1e5d4eec132c4974314c8
c2de664b3d9b21a41b82a52ba45374d85d42510f
/src/main/java/com/webshop/products/configuration/MongoConfiguration.java
d642ccd6c5d7e0566725d0753e62c5c824de5f65
[]
no_license
mradovic95/Product-Service
0720ee0f4daee8d7526bdb0b17b6f2b0ea8301d0
dd22499c5bd173704ccef783836de19fe2c99f5a
refs/heads/master
2020-05-25T15:35:54.277294
2019-05-21T16:10:06
2019-05-21T16:10:06
187,872,921
0
0
null
null
null
null
UTF-8
Java
false
false
394
java
package com.webshop.products.configuration; import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.config.EnableMongoAuditing; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; @Configuration @EnableMongoRepositories(basePackages = "com.webshop.products") @EnableMongoAuditing public class MongoConfiguration { }
[ "mihailo.radovic@gamecredits.com" ]
mihailo.radovic@gamecredits.com
660e2ef062bedd2bc669bf04087d018e6f0e10c2
7372cac00a934e9d833befcabf7b6342bbb91616
/haikudepotserver-core/src/main/java/org/haiku/haikudepotserver/dataobjects/Publisher.java
cfd43f71caaa51e56e620d9327189d581dc32317
[ "MIT" ]
permissive
KapiX/haikudepotserver
5903a60bc5f0732aa1371a198a3329ffcf653589
c338e59e37a5cccfbb6fc05046a9ff6f6f97791b
refs/heads/master
2022-11-05T17:41:36.032129
2020-06-21T11:07:01
2020-06-21T11:07:01
273,948,013
0
0
NOASSERTION
2020-06-21T17:00:33
2020-06-21T17:00:32
null
UTF-8
Java
false
false
461
java
/* * Copyright 2013-2018, Andrew Lindesay * Distributed under the terms of the MIT License. */ package org.haiku.haikudepotserver.dataobjects; import org.haiku.haikudepotserver.dataobjects.support.Coded; import org.haiku.haikudepotserver.dataobjects.support.MutableCreateAndModifyTimestamped; import org.haiku.haikudepotserver.dataobjects.auto._Publisher; public class Publisher extends _Publisher implements MutableCreateAndModifyTimestamped, Coded { }
[ "apl@lindesay.co.nz" ]
apl@lindesay.co.nz
a2bd5413d5933d8c7902acd38184343b5b778523
896333bd8e7be53784f2c56fe1ddaca8ea32e61b
/src/mmqa/MyCrawler.java
913229c3c1c5d1cd6b4946766b0939aa79abe9d7
[]
no_license
narendramohan/mmqa
6955583fc2df2f6ae88dd366850c96e9d7dfbae9
904e9838e9a1495fadab36b68bc83f59b96a6da9
refs/heads/master
2020-06-03T23:34:56.375061
2014-09-06T23:45:31
2014-09-06T23:45:31
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,850
java
package mmqa; import java.util.List; import java.util.regex.Pattern; import mmqa.crawler.Page; import mmqa.crawler.WebCrawler; import mmqa.parser.HtmlParseData; import mmqa.url.WebURL; public class MyCrawler extends WebCrawler { private final static Pattern FILTERS = Pattern.compile(".*(\\.(css|js|bmp|gif|jpe?g" + "|png|tiff?|mid|mp2|mp3|mp4" + "|wav|avi|mov|mpeg|ram|m4v|pdf" + "|rm|smil|wmv|swf|wma|zip|rar|gz))$"); /** * You should implement this function to specify whether * the given url should be crawled or not (based on your * crawling logic). */ @Override public boolean shouldVisit(WebURL url) { String href = url.getURL().toLowerCase(); return !FILTERS.matcher(href).matches() && href.startsWith("http://www.ics.uci.edu/"); } /** * This function is called when a page is fetched and ready * to be processed by your program. */ @Override public void visit(Page page) { String url = page.getWebURL().getURL(); System.out.println("URL: " + url); if (page.getParseData() instanceof HtmlParseData) { HtmlParseData htmlParseData = (HtmlParseData) page.getParseData(); String text = htmlParseData.getText(); String html = htmlParseData.getHtml(); List<WebURL> links = htmlParseData.getOutgoingUrls(); System.out.println("Text length: " + text.length()); System.out.println("Html length: " + html.length()); System.out.println("Number of outgoing links: " + links.size()); } } }
[ "narendramohan.prasad@gmail.com" ]
narendramohan.prasad@gmail.com
df0e0ef12e1b41942d56d6466e2b651adb48a51b
db7d652734cbd2bdc5ed5711b5379cfe924ee8db
/app/src/main/java/com/example/healthyeating/ui/home/HomeViewModel.java
e9576cd297c2d71dce0ce7ee6eabd55037689426
[]
no_license
piyushsud/HealthyEatingApp2
d0ecb276e30d9460cf6eca951c9bae8e7aac554c
97a026729b652448ec5f6a88a1bf1b0017851e90
refs/heads/master
2020-07-08T13:27:39.310482
2019-09-03T03:06:13
2019-09-03T03:06:13
203,688,551
0
0
null
null
null
null
UTF-8
Java
false
false
448
java
package com.example.healthyeating.ui.home; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; public class HomeViewModel extends ViewModel { private MutableLiveData<String> mText; public HomeViewModel() { mText = new MutableLiveData<>(); mText.setValue("This is home fragment"); } public LiveData<String> getText() { return mText; } }
[ "piyushsud@gmail.com" ]
piyushsud@gmail.com
d0ccdd7df23354b68c7b2da1db9bc412e9595198
9ec8c353d4a7144c058ce5f8665fe248af18bf25
/spring-06/src/main/java/com/xjm/config/MyConfig.java
bad8efa0ef206e108d3ed9c3a7b16be561e0ee15
[]
no_license
JianMin-Xie/spring-demo
0e7474008198d88858a560c13e0db8b923487735
c7be9d6ab90a83dc6f6d367d49fe03b8b258f8dc
refs/heads/master
2023-03-25T23:58:41.654041
2021-03-18T12:10:58
2021-03-18T12:10:58
348,021,321
0
0
null
null
null
null
UTF-8
Java
false
false
549
java
package com.xjm.config; import com.xjm.pojo.Dog; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration //代表这是一个配置类 @Import(MyConfig2.class) //导入合并其他配置类,类似于配置文件中的 inculde 标签 public class MyConfig { @Bean //通过方法注册一个bean,这里的返回值就Bean的类型,方法名就是bean的id! public Dog dog(){ return new Dog(); } }
[ "854377742@qq.com" ]
854377742@qq.com
067b7734057c66ef5354b3073b4c1fcf8229bead
8649c547c59cacb498c6f86db8094663356d2e28
/Camera Capture Intent Demo/MainActivity.java
7dda88afbda2cd3a2533012249ecdacbccb325c5
[]
no_license
basirsharif/AndroidDemos
6c400c2151b9d4e633430eb651be8b2979476ebe
4350491ffaef6dc4e9ee679247c962e9962cf1fc
refs/heads/master
2020-12-21T23:22:34.619418
2019-06-14T22:10:59
2019-06-14T22:10:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,176
java
package com.example.demo16; import android.content.Intent; import android.graphics.Bitmap; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { ImageView imageView1; private static final int REQUEST_CODE = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView1 = (ImageView) this.findViewById(R.id.imageView1); } public void captureImageCode(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, REQUEST_CODE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) { Bitmap photo = (Bitmap) data.getExtras().get("data"); imageView1.setImageBitmap(photo); } } }
[ "maunash@live.com" ]
maunash@live.com
738999ddac218a9955acab3c9f1f5c503e0fc1aa
4b0ca748c43c8d099b41551a330191d7c9793fed
/secondUber/src/main/java/com/app/comic/ui/Model/Request/PassengerInfoRequest.java
7eaee536b5b1d646c5d8b457261343c6b5e0ad94
[ "MIT" ]
permissive
imalpasha/secondUB
ce2d2757b98b65af07830d2bb73c98f3cbc87c6f
d900f1083fa5ed6d20d42dff0c54d4a901a54e88
refs/heads/master
2021-01-11T18:15:33.356116
2017-01-22T14:18:34
2017-01-22T14:18:34
79,524,098
0
1
null
null
null
null
UTF-8
Java
false
false
505
java
package com.app.comic.ui.Model.Request; /** * Created by Dell on 11/4/2015. */ public class PassengerInfoRequest { /*Local Data Send To Server*/ String username; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } /*Initiate Class*/ public PassengerInfoRequest() { } public PassengerInfoRequest(PassengerInfoRequest data) { username = data.getUsername(); } }
[ "imalpasha@gmail.com" ]
imalpasha@gmail.com
ee94a12c1fe2f5705a5ba2a0a135f60eb06a291f
bf6b3f130c515743c12f9e9137884023c677007a
/project1/src/Unit.java
c9fd09310e3132b36ffe8faf22b5fc4f6a102821
[]
no_license
lberezy/OOSD
e84f81765e57fc04f30e0b8f5bb055cd3a979d8d
ba2498f7caa201b029c8fb412ded28a07ee50bd2
refs/heads/master
2021-01-22T10:01:45.351370
2015-02-26T00:02:10
2015-02-26T00:02:10
31,338,797
0
0
null
null
null
null
UTF-8
Java
false
false
491
java
import org.newdawn.slick.Image; public abstract class Unit extends GameObject implements Drawable{ public Unit(double x, double y, Image sprite, World world) { super(x, y, sprite, world); // TODO Auto-generated constructor stub } private double fullShield; private double damage; private double firepower; public double getFullShield() { return fullShield; } public double getDamage() { return damage; } public double getFirepower() { return firepower; } }
[ "lberezy@56d1951d-bf66-49da-99e5-76cc4cbb8347" ]
lberezy@56d1951d-bf66-49da-99e5-76cc4cbb8347
b0b356d558be82e91cbf3ab64a1f99ea7c1cf951
41ed7ed84c4104c17e2fb976aec8dc0eab76b20b
/common/src/main/java/com/zyf/model/Point.java
822c7102943f8246f3271adf46240d62b0137420
[]
no_license
yinfang/XiWeiApp
6758e811ff938337debeae41e61e98b87aba9c8c
9dd3457b98bc0bc6e2ab5f0a06e4875953b4cd1a
refs/heads/master
2023-07-07T14:30:17.217544
2021-08-11T08:32:15
2021-08-11T08:32:15
294,651,276
0
0
null
null
null
null
UTF-8
Java
false
false
735
java
package com.zyf.model; import java.io.Serializable; public class Point implements Serializable { /** * */ private static final long serialVersionUID = -8252237310350864258L; public String name; public double longitude; public double latitude; /** * * @param latitude * 纬度 * @param longitude * 经度 */ public Point(double latitude, double longitude) { this.latitude = latitude; this.longitude = longitude; } /** * * @param latitude * 纬度 * @param longitude * 经度 * @param name * 地点的名称 */ public Point(double latitude, double longitude, String name) { this(latitude, longitude); this.name = name; } }
[ "lead_1_zyf@user.noreply.gitee.com" ]
lead_1_zyf@user.noreply.gitee.com
2ab0f03ec2cc543893967f065788702b802bbd97
10fc2fdfd75ef763c216b960365b6ae5bfd80015
/app/src/main/java/com/cmexpertise/beautyapp/revalAnimation/animation/ViewAnimationUtils.java
d9771d09facf573eace7c2330f3eebd6d0b650c1
[]
no_license
dream5535/mvvmandroiddream
648c87c15d15b3dec32e8f520b131045611990bd
043f53682c56e2008f52f0b06297e292ada8830d
refs/heads/master
2020-05-30T06:04:27.390224
2019-05-31T10:32:09
2019-05-31T10:32:09
189,571,741
0
1
null
null
null
null
UTF-8
Java
false
false
6,136
java
package com.cmexpertise.beautyapp.revalAnimation.animation; import android.annotation.TargetApi; import android.os.Build; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import com.nineoldandroids.animation.Animator; import com.nineoldandroids.animation.ObjectAnimator; import com.nineoldandroids.view.ViewHelper; import com.nineoldandroids.view.ViewPropertyAnimator; import java.lang.ref.WeakReference; import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static com.cmexpertise.beautyapp.revalAnimation.animation.RevealAnimator.CLIP_RADIUS; public class ViewAnimationUtils { private final static boolean LOLLIPOP_PLUS = SDK_INT >= LOLLIPOP; public static final int SCALE_UP_DURATION = 500; /** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo(new RevealAnimator.RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS,startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); } private static Animator.AnimatorListener getRevealFinishListener(RevealAnimator target){ if(SDK_INT >= 18){ return (Animator.AnimatorListener) new RevealAnimator.RevealFinishedJellyBeanMr2(target); }else if(SDK_INT >= 14){ return (Animator.AnimatorListener) new RevealAnimator.RevealFinishedIceCreamSandwich(target); }else { return (Animator.AnimatorListener) new RevealAnimator.RevealFinishedGingerbread(target); } } /** * Lifting view * * @param view The animation target * @param baseRotation initial Rotation X in 3D space * @param fromY initial Y position of view * @param duration aniamtion duration * @param startDelay start delay before animation begin */ @Deprecated public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay){ ViewHelper.setRotationX(view, baseRotation); ViewHelper.setTranslationY(view, fromY); ViewPropertyAnimator .animate(view) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(duration) .setStartDelay(startDelay) .rotationX(0) .translationY(0) .start(); } /** * Lifting view * * @param view The animation target * @param baseRotation initial Rotation X in 3D space * @param duration aniamtion duration * @param startDelay start delay before animation begin */ @Deprecated public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay){ ViewHelper.setRotationX(view, baseRotation); ViewHelper.setTranslationY(view, view.getHeight() / 3); ViewPropertyAnimator .animate(view) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(duration) .setStartDelay(startDelay) .rotationX(0) .translationY(0) .start(); } /** * Lifting view * * @param view The animation target * @param baseRotation initial Rotation X in 3D space * @param duration aniamtion duration */ @Deprecated public static void liftingFromBottom(View view, float baseRotation, int duration){ ViewHelper.setRotationX(view, baseRotation); ViewHelper.setTranslationY(view, view.getHeight() / 3); ViewPropertyAnimator .animate(view) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(duration) .rotationX(0) .translationY(0) .start(); } static class SimpleAnimationListener implements Animator.AnimatorListener{ @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } } }
[ "skywevasinfo@gmail.com" ]
skywevasinfo@gmail.com
c464a14aff43ab146f0f2b4f59daffec4d9018c1
9ae5965121f143fa5a5781b413d686311b734a2c
/src/main/java/com/xceptance/xlt/report/util/MinMaxValueSet.java
73e537ab33fe94a46006839e8a8894c9ca9bfe67
[ "EPL-2.0", "MIT", "EPL-1.0", "LGPL-2.0-or-later", "LicenseRef-scancode-unknown-license-reference", "MPL-2.0", "CDDL-1.1", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause" ]
permissive
andre-becker/XLT
41395ec5b673193412b26df35cc64e05ac55c9b4
174f9f467ab3094bcdbf80bcea818134a9d1180a
refs/heads/master
2022-04-21T09:20:03.443914
2020-03-12T09:48:41
2020-03-12T09:48:41
257,584,910
0
0
Apache-2.0
2020-04-21T12:14:39
2020-04-21T12:14:38
null
UTF-8
Java
false
false
9,200
java
package com.xceptance.xlt.report.util; import com.xceptance.common.util.ParameterCheckUtils; /** * A {@link MinMaxValueSet} maintains different statistics, like minimum, maximum, and count, for values generated at a * certain time. * <p> * A {@link MinMaxValueSet} is fixed-sized, but self-managing. If the distance between the smallest and greatest * time-stamp is greater than the value set size, two consecutive values are merged into one. This means the time period * for which values can be added to this set can be arbitrary long. */ public class MinMaxValueSet { /** * The default initial value set size. */ public static final int DEFAULT_SIZE = 1024; /** * The smallest time [s] for which a min/max value exists. */ private int firstSecond; /** * The biggest time [s] for which a min/max value exists. */ private int lastSecond; /** * The maximum time [ms] for which a value has been added to this set. */ private long maximumTime; /** * The minimum time [ms] for which a value has been added to this set. */ private long minimumTime; /** * The number of seconds a single min/max value represents. Always a power of 2. */ private int scale = 1; /** * The number of different min/max values that can be stored in this value set. */ private final int size; /** * The total number of values added to this value set. */ private long valueCount; /** * The min/max values maintained by this value set. */ private final MinMaxValue[] values; /** * Creates a {@link MinMaxValueSet} instance with a size of {@link #DEFAULT_SIZE}. */ public MinMaxValueSet() { this(DEFAULT_SIZE); } /** * Creates a {@link MinMaxValueSet} instance with the specified size. * * @param size * the size */ public MinMaxValueSet(final int size) { ParameterCheckUtils.isGreaterThan(size, 0, "size"); // double the size to have at least size min/max values even after shrinking this.size = size * 2; values = new MinMaxValue[this.size]; } /** * Adds a value for a certain time-stamp to this value set. * * @param time * the time-stamp * @param value * the value */ public void addOrUpdateValue(final long time, final int value) { // get the corresponding second int second = ((int) (time / 1000)) & ~(scale - 1); // check whether this is the first value added if (valueCount == 0) { // yes, that's easy firstSecond = lastSecond = second; values[0] = new MinMaxValue(value); // maintain statistics minimumTime = maximumTime = time; valueCount = 1; } else { // no, there are values in the set already // check whether we have to shrink the value set first if (second != firstSecond) { // decide on the way of shrinking if (second > firstSecond) { // repeat as long as the second falls after the current size while ((second - firstSecond) / scale >= size) { scale = scale * 2; shrink(); second = second & ~(scale - 1); firstSecond = firstSecond & ~(scale - 1); lastSecond = lastSecond & ~(scale - 1); } // maintain upper boundary if (second > lastSecond) { lastSecond = second; } } else { // repeat as long as the second still falls outside (before) the current size while ((lastSecond - second) / scale >= size) { scale = scale * 2; shrink(); second = second & ~(scale - 1); firstSecond = firstSecond & ~(scale - 1); lastSecond = lastSecond & ~(scale - 1); } // shift if necessary if (second < firstSecond) { final int indexDiff = (firstSecond - second) / scale; shift(indexDiff); // maintain lower boundary firstSecond = second; } } } // calculate final index and update value final int index = (second - firstSecond) / scale; final MinMaxValue item = values[index]; if (item == null) { values[index] = new MinMaxValue(value); } else { item.updateValue(value); } // maintain statistics valueCount++; if (time < minimumTime) { minimumTime = time; } if (time > maximumTime) { maximumTime = time; } } } /** * Returns the smallest second for which a min/max value exists in this set. * * @return the first second */ public long getFirstSecond() { if (valueCount == 0) { throw new IllegalStateException("No first second available as no values have been added so far."); } return firstSecond * 1000; } /** * Returns the maximum time [ms] for which a value has been added to this set. * * @return the maximum time */ public long getMaximumTime() { if (valueCount == 0) { throw new IllegalStateException("No maximum time available as no values have been added so far."); } return maximumTime; } /** * Returns the minimum time [ms] for which a value has been added to this set. * * @return the minimum time */ public long getMinimumTime() { if (valueCount == 0) { throw new IllegalStateException("No minimum time available as no values have been added so far."); } return minimumTime; } /** * Returns the number of seconds a single min/max value represents. Always a power of 2. * * @return the scale */ public int getScale() { return scale; } /** */ public int getSize() { return size / 2; } /** * Returns the total number of values added to this value set. * * @return the number of values */ public long getValueCount() { return valueCount; } /** * Returns the min/max values maintained by this set. * * @return the min/max values */ public MinMaxValue[] getValues() { MinMaxValue[] copy; if (valueCount == 0) { copy = new MinMaxValue[0]; } else { final int length = (lastSecond - firstSecond) / scale + 1; copy = new MinMaxValue[length]; System.arraycopy(values, 0, copy, 0, length); } return copy; } /** * Shifts the content of the min/max value array to the right for the specified number of elements. * * @param indexDiff * the destination index */ private void shift(final int indexDiff) { System.arraycopy(values, 0, values, indexDiff, size - indexDiff); for (int i = 0; i < indexDiff; i++) { values[i] = null; } } /** * Shrinks the min/max value array by merging two consecutive min/max values into one value. */ private void shrink() { final int offset = (firstSecond % scale > 0) ? 1 : 0; // loop over value pairs, skipping the first value if necessary int i, j; for (i = offset, j = offset; i < size - 1; i = i + 2, j++) { final MinMaxValue v1 = values[i]; final MinMaxValue v2 = values[i + 1]; MinMaxValue rv; if (v1 != null && v2 != null) { rv = v1.merge(v2); } else if (v1 != null && v2 == null) { rv = v1; } else if (v1 == null && v2 != null) { rv = v2; } else { rv = null; } // clear the old values values[i] = null; values[i + 1] = null; // set the new value values[j] = rv; } // check whether we have one last entry left to deal with if (i < size) { values[j] = values[i]; values[i] = null; } } }
[ "4639399+jowerner@users.noreply.github.com" ]
4639399+jowerner@users.noreply.github.com
bef6a345697c02deed6417042dedae957374ba30
20a32350a4eb0ac09df5dc1580235f7788bba285
/code/idea-plugin/src/net/kano/nully/plugin/psiToJimple/TypeListBuilder.java
78f174233f92e89b8d40e841a23b2626413af05d
[]
no_license
keithkml/nully
a2f503ebb55041aef0bcf2ede90bc76ff076d1c9
6ea921f83c5defc88d2f314b21d13c9d5709ba62
refs/heads/master
2020-12-24T12:00:54.891258
2005-07-04T01:09:23
2005-07-04T01:09:23
73,102,206
0
0
null
null
null
null
UTF-8
Java
false
false
3,314
java
/* Soot - a J*va Optimization Framework * Copyright (C) 2004 Jennifer Lhotak * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ package net.kano.nully.plugin.psiToJimple; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiClassType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiExpression; import com.intellij.psi.PsiJavaCodeReferenceElement; import com.intellij.psi.PsiMember; import com.intellij.psi.PsiRecursiveElementVisitor; import com.intellij.psi.PsiReferenceExpression; import com.intellij.psi.PsiType; import java.util.HashSet; import java.util.Set; public class TypeListBuilder extends PsiRecursiveElementVisitor { private Set<PsiClassType> list; public Set<PsiClassType> getList() { return list; } public TypeListBuilder(){ list = new HashSet<PsiClassType>(); } public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) { super.visitReferenceElement(psiJavaCodeReferenceElement); addReferencedElementType(psiJavaCodeReferenceElement.resolve()); } public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) { super.visitReferenceExpression(psiReferenceExpression); PsiElement referenced = psiReferenceExpression.resolve(); addReferencedElementType(referenced); } private void addReferencedElementType(PsiElement referenced) { if (referenced instanceof PsiClass) { addClassType((PsiClass) referenced); } else if (referenced instanceof PsiMember) { addClassType(((PsiMember) referenced).getContainingClass()); } } public void visitExpression(PsiExpression psiExpression) { super.visitExpression(psiExpression); PsiType type = psiExpression.getType(); if (type instanceof PsiClassType) { PsiClassType classType = (PsiClassType) type; list.add(classType); } } public void visitClass(PsiClass psiClass) { addClassType(psiClass); } private void addClassType(PsiClass psiClass) { list.add(psiClass.getManager().getElementFactory().createType(psiClass)); PsiClass superClass = psiClass.getSuperClass(); if (superClass != null) addClassType(superClass); for (PsiClassType type : psiClass.getImplementsListTypes()) { PsiClass cls = type.resolve(); if (cls != null) addClassType(cls); } PsiClass container = psiClass.getContainingClass(); if (container != null) addClassType(container); } }
[ "keithkml@a39d9cd8-1c04-efb7-b3e8-ca890007be23" ]
keithkml@a39d9cd8-1c04-efb7-b3e8-ca890007be23
58a2e926ab3bb711563ab63a5d8a637cc4a1a594
6ca5e17624a71d00cae80b0b647798fb881a1a13
/saasandroidlibrary/src/main/java/com/saasandroid/saasandroidlibrary/models/Authentication.java
0d2db5c9f6fdf835938cf185ff3e7b81fa122a87
[]
no_license
CosmicSky/SaaSAndroid
4ed421d1e0b31baf96fd193d2928f637e0a18498
8c82f713ce62c84acad9d07db0b11f03323021b1
refs/heads/master
2020-04-27T04:13:38.771883
2019-04-25T14:50:31
2019-04-25T14:50:31
174,046,978
0
0
null
null
null
null
UTF-8
Java
false
false
2,000
java
// // Authentication.java // SaaSAndroid // // Created by Tony Qi on 3/5/19. // Copyright © 2019 Tony Qi. All rights reserved. // package com.saasandroid.saasandroidlibrary.models; import android.content.Context; public interface Authentication { /** * Signs in the study participant into the app. * @param mContext the context from which the method is calling * @param studies the studies class * @param accountVerification the account verification class * @param email the email * @param password the password */ void signIn(Context mContext, final Class studies, final Class accountVerification, String email, String password); /** * Registers the study participant for the app. * @param mContext the context from which the method is calling * @param accountVerification the account verification class * @param newUser the study participant object * @param email the email * @param password the password */ void register(Context mContext, final Class accountVerification, StudyParticipant newUser, String email, String password); /** * Signs out the study participant from the app. */ void signOut(); /** * Determines whether or not the study participant is signed into the app. * @return true if study participant is signed in, false if not */ boolean isSignedIn(); /** * Determines whether or not the study participant has verified his or her account. * @return true if study participant has verified his or her account, false if not */ boolean isVerified(); /** * Resets the password for the study participant. * @param email the email */ void resetPassword(String email); /** * Sends verification link to the study participant's email */ void sendVerificationLink(); /** * Retrieves the user id of the study participant * @return user id */ String getUserId(); }
[ "tonyqi.2014@gmail.com" ]
tonyqi.2014@gmail.com
74471e8bb766310bb7ec9bddd7ac2cb6da3746b8
7fdadc951aa3cf21a68cd8c8c6bfdb7c68b33469
/ex04/src/module-info.java
29a5e56966e04361a0cd1464bcc68799c4ee2082
[]
no_license
sasakijindai/ex04
d3501664b47964807c086c6b80ca29c7e8ce6c8b
334473fc246047a68ad0c2388354c6e95e54463d
refs/heads/master
2023-02-15T08:24:20.872260
2021-01-15T13:06:54
2021-01-15T13:06:54
329,912,812
0
0
null
null
null
null
UTF-8
Java
false
false
15
java
module ex04 { }
[ "r201902968ev@jindai.jp" ]
r201902968ev@jindai.jp
321ae2132bde6c9c494dbad267e46e472e9f1d46
1c0829ebfecc950a27ec01156b367c8750da12ea
/Carrier.java
2a6cee86c8b234df7a1760c2222991ab361b9d73
[]
no_license
huizecui/Battleship
89581cd278054b1d986ecb13f02c5f9c85aa4d12
cfd245f22d624c961e46af43a3d0f1f48e33c7e8
refs/heads/master
2021-04-27T07:32:45.894150
2018-02-23T14:55:35
2018-02-23T14:55:35
122,634,710
0
0
null
null
null
null
UTF-8
Java
false
false
297
java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Carrier here. * * @author (your name) * @version (a version number or a date) */ public class Carrier extends Ship { public Carrier() { super(5); } }
[ "36163375+huizecui@users.noreply.github.com" ]
36163375+huizecui@users.noreply.github.com
cb17f245c8c61181fc41e3decd03d11aa5215812
571a262e5de1d86f0c74c42df3bd4eaf08a05ffb
/Labo 01/Ejercicio 05/src/com/ESDP/x00136319/Main.java
44ee2903555ac075a82c21a8c927c3af107e1eb0
[]
no_license
EduardoDominguez1/00136319_ESDP_POO
95fa71ecf7fd605bc8aaf3ef1576b1b12ee2eb1a
cee0b7b1dfafda397d27c136bb2541f0efaf1b3d
refs/heads/master
2023-08-27T03:37:06.866643
2020-06-12T01:44:48
2020-06-12T01:44:48
246,640,959
0
0
null
null
null
null
UTF-8
Java
false
false
1,426
java
package com.ESDP.x00136319; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { //Realiza un programa que reciba n letras por teclado y almacene en una lista solo las vocales, mayusculas o minusculas Scanner scan = new Scanner(System.in); System.out.println("Ingrese el total de letras que ingresara"); List<Character> vocales = Arrays.asList('a', 'e', 'i', 'o', 'u'); List<Character> vocalesMayu = Arrays.asList('A', 'E', 'I', 'O', 'U'); List<Character> LisVocalesMin = new ArrayList<>(); List<Character> LisVocalesMayu = new ArrayList<>(); int total = scan.nextInt(); scan.nextLine(); System.out.println("Ingrese letras 1 por 1"); for (int i = 0; i < total; i++) { char letra = scan.nextLine().charAt(0); if (Character.isAlphabetic(letra) && vocales.contains(letra)) { LisVocalesMin.add(letra); } else if(Character.isAlphabetic(letra) && vocalesMayu.contains(letra)) { LisVocalesMayu.add(letra); } } System.out.println("Vocales mayusculas ingresadas"); System.out.println(LisVocalesMayu); System.out.println("Vocales minusculas ingresadas"); System.out.println(LisVocalesMin); } }
[ "00136319@uca.edu.sv" ]
00136319@uca.edu.sv
3307eb86a7dd421bb708623040ba593725928292
3f90c2df80d9f96a760d1e04c2d5dbb9d7e88a24
/contrib/zebra/src/java/org/apache/hadoop/zebra/types/TypesUtils.java
4a56f0045ce5b0dcda05ec2c6d25ab6ff1f7b878
[ "Apache-2.0" ]
permissive
hirohanin/pig7hadoop21
d038ecc3400bcc7124ecce356f2a30533f6ee188
b595f515dde305dfcb0d965ce07c51f629d7a824
refs/heads/master
2021-01-25T03:54:55.074368
2010-11-02T12:19:26
2010-11-02T12:19:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,741
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with this * work for additional information regarding copyright ownership. The ASF * licenses this file to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package org.apache.hadoop.zebra.types; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import org.apache.pig.backend.executionengine.ExecException; import org.apache.pig.data.DataBag; import org.apache.pig.data.DefaultDataBag; import org.apache.pig.data.Tuple; import org.apache.pig.data.TupleFactory; import org.apache.hadoop.zebra.schema.Schema; import org.apache.hadoop.zebra.parser.ParseException; /** * Utility methods manipulating Table types (specifically, Tuple objects). */ public class TypesUtils { //static TupleFactory tf = ZebraTupleFactory.getInstance(); static TupleFactory tf = ZebraTupleFactory.getZebraTupleFactoryInstance(); /** * Create a tuple based on a schema * * @param schema * The schema that the tuple will conform to. * @return A suitable Tuple object that can be used to read or write a Table * with the same input or output schema. */ public static Tuple createTuple(Schema schema) throws IOException { Tuple tuple = tf.newTuple(schema.getNumColumns()); for (int i = 0; i < schema.getNumColumns(); ++i) { tuple.set(i, null); } return tuple; } /** * create a tuple based on number of columns */ public static Tuple createTuple(int size) throws IOException { Tuple tuple = tf.newTuple(size); for (int i = 0; i < size; ++i) { tuple.set(i, null); } return tuple; } /** * Create a PIG Bag object. * * @return A Pig DataBag object. */ public static DataBag createBag() { return new DefaultDataBag(); } public static DataBag createBag(Schema schema) { return new DefaultDataBag(); } /** * Reset the Tuple so that all fields are NULL field. This is different from * clearing the tuple, in which case the size of the tuple will become zero. * * @param tuple * Input tuple. */ public static void resetTuple(Tuple tuple) { try { int tupleSize = tuple.size(); for (int i = 0; i < tupleSize; ++i) { tuple.set(i, null); } } catch (Exception e) { throw new RuntimeException("Internal error: " + e.toString()); } } /** * Check whether the input row object is compatible with the expected schema * * @param tuple * Input Tuple object * @param schema * Table schema * @throws IOException */ public static void checkCompatible(Tuple tuple, Schema schema) throws IOException { // TODO: Add more rigorous checking. if (tuple.size() != schema.getNumColumns()) { throw new IOException("Incompatible Tuple object - number of fields"); } } /** * Reading a tuple from disk with projection. */ public static class TupleReader { private Tuple tuple; //@SuppressWarnings("unused") private Schema physical; private Projection projection; SubColumnExtraction.SubColumn subcolextractor = null; /** * Constructor - create a TupleReader than can parse the serialized Tuple * with the specified physical schema, and produce the Tuples based on the * projection. * * @param physical * The physical schema of on-disk data. * @param projection * The logical schema of tuples user expect. */ public TupleReader(Schema physical, Projection projection) throws IOException, ParseException { tuple = createTuple(physical); this.physical = physical; this.projection = projection; subcolextractor = new SubColumnExtraction.SubColumn(physical, projection); subcolextractor.dispatchSource(tuple); } public Schema getSchema() { return physical; } public Projection getprojction() { return projection; } /** * Read a tuple from the stream, and perform projection. * * @param in * The input stream * @param row * The input tuple that should conform to the projection schema. * @throws IOException */ public void get(DataInputStream in, Tuple row) throws IOException, ParseException { checkCompatible(row, projection.getSchema()); tuple.readFields(in); TypesUtils.resetTuple(row); try { subcolextractor.splitColumns(row); } catch (ExecException e) { // not going to happen. } } } /** * Writing a tuple to disk. */ public static class TupleWriter { private Schema physical; /** * The constructor * * @param physical * The physical schema of the tuple. */ public TupleWriter(Schema physical) { this.physical = physical; } /** * Write a tuple to the output stream. * * @param out * The output stream * @param row * The user tuple that should conform to the physical schema. * @throws IOException */ public void put(DataOutputStream out, Tuple row) throws IOException { checkCompatible(row, physical); row.write(out); } } /** * Checking and formatting an input tuple to conform to the input schema.<br> * * The current implementation always create a new tuple because PIG * expects Slice.next(tuple) always returning a brand new tuple. * * @param tuple * @throws IOException * */ public static void formatTuple(Tuple tuple, int ncols) throws IOException { Tuple one = createTuple(ncols); tuple.reference(one); return; /* * Dead code below. */ // int n = schema.getNumColumns(); // if (tuple.size() == n) return; // if (tuple.size() == 0) { // for (int i = 0; i < schema.getNumColumns(); ++i) { // tuple.append(null); // } // return; // } // throw new IOException("Tuple already formatted with " + tuple.size() // + " fields"); } }
[ "root@rohan-laptop.(none)" ]
root@rohan-laptop.(none)
227d1e780f1b7dcf7d90568e97f923bbec3b0f67
e5a06c9cecd19e8cc23dc1d456dda23a40e7cd9a
/sharedbusinesslayer/src/main/java/com/weddingcrashers/servermodels/ConnectionContainer.java
f645fa98a223b0914bf91bded75783a2cab26b18
[]
no_license
dmpliamplias/Dominion
84c30858cecf4224221f4661279d563ac0479013
33b73607495177269dc38f79273a1cedd48da824
refs/heads/master
2021-08-31T19:44:45.207415
2017-12-22T15:45:11
2017-12-22T15:45:11
104,478,952
0
0
null
null
null
null
UTF-8
Java
false
false
389
java
package com.weddingcrashers.servermodels; import java.io.Serializable; /** * @author Michel Schlatter * */ public class ConnectionContainer extends Container implements Serializable { int id; public ConnectionContainer(){ super(Methods.Connect); } public int getId() { return id; } public void setId(int id) { this.id = id; } }
[ "michel.schlatter@gmx.net" ]
michel.schlatter@gmx.net
60a0b4e8e9e21a8f9ccb688f4e96ed55fcd4ca1e
f7a3aa3b5f56c5ea0269f3b680a14bbafbc34890
/app/src/main/java/com/example/apple/project4/IslamicHistoryFragment.java
e87ea37a87a70ab9e86dc964ca507d76855a3809
[]
no_license
saarahasad/Arabiyah-Classes-Android-Application
b0bb15c9ccb3eef3b3d177fc792bd9d826c1f274
d7a01bb5bdd12bbf0efb69b82b24f371bff0d4bf
refs/heads/master
2020-05-21T18:13:03.136623
2019-05-11T12:22:37
2019-05-11T12:22:37
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,072
java
package com.example.apple.project4; /** * Created by apple on 09/05/17. */ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.ButterKnife; public class IslamicHistoryFragment extends Fragment { ViewGroup rootView; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { //returning our layout file rootView = (ViewGroup) inflater .inflate(R.layout.fragment_history, container, false); ButterKnife.bind(this, rootView); return rootView; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //you can set the title for your toolbar here for different fragments different titles getActivity().setTitle("Islamic History"); } }
[ "saarahasad26@gmail.com" ]
saarahasad26@gmail.com
d2b14c2203e931f65c9ef12c5f94f93e449e94ba
018de4cf7f899dcca6fa2f0d99a86721bde38e62
/app/src/main/java/com/gdcp/newsclient/skin/config/SkinConfig.java
c890c88c6b8a63b6cf6079ce0f3ca68aa68562ce
[]
no_license
zhangjiangli/NewsClient
97e700cd2f8d413ab5aaa8c04f9e3d2ad68969aa
619e73ed349529d8c35cc205da229f695567dd00
refs/heads/master
2020-12-03T03:45:26.206196
2017-06-29T11:00:37
2017-06-29T11:00:37
95,769,321
0
0
null
null
null
null
UTF-8
Java
false
false
1,679
java
package com.gdcp.newsclient.skin.config; import android.content.Context; import android.content.SharedPreferences; /** * Created by asus- on 2017/6/28. */ public class SkinConfig { private static SkinConfig mInstance; private Context mContext; private SkinConfig(Context mContext) { this.mContext = mContext; } public static SkinConfig getInstance(Context mContext) { if (mInstance == null) { synchronized (SkinConfig.class){ if (mInstance==null){ mInstance = new SkinConfig(mContext); } } } return mInstance; } //保存皮肤路径 public void setSkinResourcePath(String skinPath){ SharedPreferences sp=mContext.getSharedPreferences("skin_sharePref", mContext.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putString("skinPath",skinPath); editor.commit(); } //取出皮肤路径 public String getSkinResourcePath() { SharedPreferences sp = mContext.getSharedPreferences("skin_sharePref", mContext.MODE_PRIVATE); return sp.getString("skinPath", ""); } public void setSkinColor(String colorName){ SharedPreferences sp=mContext.getSharedPreferences("skin_sharePref", mContext.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); editor.putString("colorName",colorName); editor.commit(); } //取出皮肤路径 public String getSkinColor() { SharedPreferences sp = mContext.getSharedPreferences("skin_sharePref", mContext.MODE_PRIVATE); return sp.getString("colorName", ""); } }
[ "1776494277@qq.com" ]
1776494277@qq.com
35ce5dc1641689c1bd600478a18dcf330d3492e2
c702fb8c632e385951b8ad0edf35d3332728f670
/src/main/java/unitk/util/DateUtil.java
54b8b9f42d86c5654e5cfd7291d767e444483c6e
[]
no_license
chuanqingli/unitk
c865a84ffbea7044ecff284712632857584f8af6
be98a803116efa40f1f7797f9aa9a6c9ebb1f5ed
refs/heads/master
2020-04-30T08:31:17.276721
2019-03-23T02:46:35
2019-03-23T02:46:35
176,717,438
0
0
null
null
null
null
UTF-8
Java
false
false
4,149
java
package unitk.util; import java.util.*; import java.text.SimpleDateFormat; import java.sql.Timestamp; public final class DateUtil{ private DateUtil(){} private final static DateUtil __instance = new DateUtil(); public static DateUtil getInstance(){ return __instance; } private static Date __mindate = Timestamp.valueOf("1000-01-01 00:00:00.0"); //空或异常时,返回默认值;bthrow异常时是否抛出 private <T> T toData(Object oo,T cc,boolean isthrow){ return DataUtil.getInstance().toData(oo,cc,isthrow); } private String packTimeNumber(Object... args){ if(args==null||args.length<=0)return ""; StringBuilder buf = new StringBuilder(1024); for(Object obj : args){ if(obj instanceof Integer){ int nnn = Integer.parseInt(obj.toString()); if(nnn<10)buf.append(0); } buf.append(obj); } return buf.toString(); } public long getTime(Object oo,boolean isthrow){ if(oo==null)return 0; if(oo instanceof Date){ Date ttt = (Date)oo; return ttt.getTime(); } if(oo instanceof Number){ return toData(oo,0l,isthrow); } if(oo instanceof String){ return getTime00((String)oo,isthrow); } return 0; } private long getTime00(String oo,boolean isthrow){ if(oo==null||oo.length()<=0)return 0; String ssss = oo.trim().replaceAll("[^0-9]+",","); String[] ss = ssss.split(","); int[] dd = new int[]{1000,1,1,0,0,0,0}; int[] min = new int[]{1000,1,1,0,0,0,0}; int[] max = new int[]{9999,12,31,59,59,59,999};//999999 for(int i=0;i<ss.length&&i<min.length;i++){ dd[i]=toData(ss[i],0,isthrow); if(dd[i]<min[i]||dd[i]>max[i]){ if(isthrow)throw new RuntimeException("时间转换异常:" + i + "," + dd[i]); return 0; } } String sss = packTimeNumber(dd[0],"-",dd[1],"-",dd[2]," ",dd[3],":",dd[4],":",dd[5],".",dd[6]); try{ return java.sql.Timestamp.valueOf(sss).getTime(); }catch(Exception err){ if(isthrow)throw new RuntimeException("时间(" + sss + ")转换异常",err); } return 0; } //字符转日期 public Date toDate(CharSequence oo,boolean isthrow){ if(oo==null)return null; String ssss = oo.toString().trim().replaceAll("[^0-9]+",","); String[] ss = ssss.split(","); int[] dd = new int[]{1000,1,1,0,0,0,0}; int[] min = new int[]{1000,1,1,0,0,0,0}; int[] max = new int[]{9999,12,31,59,59,59,999};//999999 for(int i=0;i<ss.length&&i<min.length;i++){ dd[i]=toData(ss[i],0,isthrow); if(dd[i]<min[i]||dd[i]>max[i]){ if(isthrow)throw new RuntimeException("时间转换异常:" + i + "," + dd[i]); return __mindate; } } String sss = packTimeNumber(dd[0],"-",dd[1],"-",dd[2]," ",dd[3],":",dd[4],":",dd[5],".",dd[6]); try{ return java.sql.Timestamp.valueOf(sss); }catch(Exception err){ if(isthrow)throw new RuntimeException("时间(" + sss + ")转换异常",err); return __mindate; } } //数字转日期 public Date toDate(Number oo,boolean isthrow){ long ltime = toData(oo,0l,isthrow); try{ // return new Date(ltime); return new Timestamp(ltime); }catch(Exception err){ if(isthrow)throw new RuntimeException("时间long(" + ltime + ")转换异常",err); return __mindate; } } //yyyy-MM-dd HH:mm:ss.SSS public String format(Date oo,String panel){ SimpleDateFormat dateformatter = new SimpleDateFormat(panel); return dateformatter.format(oo); } public Date add(Date src,int field,int amount){ Calendar cc = Calendar.getInstance(); cc.setTime(src); cc.add(field,amount); return cc.getTime(); } }
[ "9915252@qq.com" ]
9915252@qq.com
e85c9ae2fe12669b1ceea73493ea891f26fa20b7
a15d03d874ce00787f76a1c2591d58cd15fc7559
/gpconnect-demonstrator-api/src/main/java/uk/gov/hscic/common/config/StartupConfig.java
26a8211bd35871538610068bee56ec4a2e6ba4de
[ "Apache-2.0" ]
permissive
dbould/gpconnect
07114aa5bf4b45227a06d4e8e64bf13fd9fc96b7
2d289570f165e6fb6a58e1a34b21e3b48b79f2e1
refs/heads/master
2021-01-23T00:56:33.688383
2017-04-13T09:29:34
2017-04-13T09:29:34
85,852,627
0
0
null
2017-03-22T16:43:00
2017-03-22T16:43:00
null
UTF-8
Java
false
false
984
java
package uk.gov.hscic.common.config; import java.io.IOException; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; @Component public class StartupConfig implements ApplicationListener<ContextRefreshedEvent> { private static final Logger LOG = Logger.getLogger(StartupConfig.class); @Value("${database.reset}") private boolean databaseReset; @Autowired private DatabaseRefresher databaseRefresher; @Override public void onApplicationEvent(ContextRefreshedEvent event) { try { if (databaseReset) { databaseRefresher.resetDatabase(); } } catch (IOException ex) { LOG.error("Cannot refresh db!"); } } }
[ "kris.bloe@answerdigital.com" ]
kris.bloe@answerdigital.com
fce220eeb1a0a7a76594b1e363deb7ab51daeb4e
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/7/7_2f542815a58ee55ee03ae89dbab36dfbe50a1841/Sketch/7_2f542815a58ee55ee03ae89dbab36dfbe50a1841_Sketch_s.java
a9bc974e9d465f7c975ce6d2468f6cdb641c6daf
[]
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
110,181
java
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* Part of the Processing project - http://processing.org Copyright (c) 2004-10 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package processing.app; import processing.app.debug.Compiler; import processing.app.debug.RunnerException; import processing.app.preproc.*; import processing.core.*; import java.awt.*; import java.awt.event.*; import java.beans.*; import java.io.*; import java.util.*; import java.util.zip.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; /** * Stores information about files in the current sketch */ public class Sketch { static private File tempBuildFolder; private Editor editor; private boolean foundMain = false; /** main pde file for this sketch. */ private File primaryFile; /** * Name of sketch, which is the name of main file * (without .pde or .java extension) */ private String name; /** true if any of the files have been modified. */ private boolean modified; /** folder that contains this sketch */ private File folder; /** data folder location for this sketch (may not exist yet) */ private File dataFolder; /** code folder location for this sketch (may not exist yet) */ private File codeFolder; private SketchCode current; private int currentIndex; /** * Number of sketchCode objects (tabs) in the current sketch. Note that this * will be the same as code.length, because the getCode() method returns * just the code[] array, rather than a copy of it, or an array that's been * resized to just the relevant files themselves. * http://dev.processing.org/bugs/show_bug.cgi?id=940 */ private int codeCount; private SketchCode[] code; /** Class name for the PApplet, as determined by the preprocessor. */ private String appletClassName; /** Class path determined during build. */ private String classPath; /** * This is *not* the "Processing" libraries path, this is the Java libraries * path, as in java.library.path=BlahBlah, which identifies search paths for * DLLs or JNILIBs. */ private String libraryPath; /** * List of library folders. */ private ArrayList<File> importedLibraries; /** * path is location of the main .pde file, because this is also * simplest to use when opening the file from the finder/explorer. */ public Sketch(Editor editor, String path) throws IOException { this.editor = editor; primaryFile = new File(path); // get the name of the sketch by chopping .pde or .java // off of the main file name String mainFilename = primaryFile.getName(); int suffixLength = getDefaultExtension().length() + 1; name = mainFilename.substring(0, mainFilename.length() - suffixLength); // lib/build must exist when the application is started // it is added to the CLASSPATH by default, but if it doesn't // exist when the application is started, then java will remove // the entry from the CLASSPATH, causing Runner to fail. // /* tempBuildFolder = new File(TEMP_BUILD_PATH); if (!tempBuildFolder.exists()) { tempBuildFolder.mkdirs(); Base.showError("Required folder missing", "A required folder was missing from \n" + "from your installation of Processing.\n" + "It has now been replaced, please restart \n" + "the application to complete the repair.", null); } */ tempBuildFolder = Base.getBuildFolder(); //Base.addBuildFolderToClassPath(); folder = new File(new File(path).getParent()); //System.out.println("sketch dir is " + folder); load(); } /** * Build the list of files. * <P> * Generally this is only done once, rather than * each time a change is made, because otherwise it gets to be * a nightmare to keep track of what files went where, because * not all the data will be saved to disk. * <P> * This also gets called when the main sketch file is renamed, * because the sketch has to be reloaded from a different folder. * <P> * Another exception is when an external editor is in use, * in which case the load happens each time "run" is hit. */ protected void load() { codeFolder = new File(folder, "code"); dataFolder = new File(folder, "data"); // get list of files in the sketch folder String list[] = folder.list(); // reset these because load() may be called after an // external editor event. (fix for 0099) codeCount = 0; code = new SketchCode[list.length]; String[] extensions = getExtensions(); for (String filename : list) { // Ignoring the dot prefix files is especially important to avoid files // with the ._ prefix on Mac OS X. (You'll see this with Mac files on // non-HFS drives, i.e. a thumb drive formatted FAT32.) if (filename.startsWith(".")) continue; // Don't let some wacko name a directory blah.pde or bling.java. if (new File(folder, filename).isDirectory()) continue; // figure out the name without any extension String base = filename; // now strip off the .pde and .java extensions for (String extension : extensions) { if (base.toLowerCase().endsWith("." + extension)) { base = base.substring(0, base.length() - (extension.length() + 1)); // Don't allow people to use files with invalid names, since on load, // it would be otherwise possible to sneak in nasty filenames. [0116] if (Sketch.isSanitaryName(base)) { code[codeCount++] = new SketchCode(new File(folder, filename), extension); } } } } // Remove any code that wasn't proper code = (SketchCode[]) PApplet.subset(code, 0, codeCount); // move the main class to the first tab // start at 1, if it's at zero, don't bother for (int i = 1; i < codeCount; i++) { //if (code[i].file.getName().equals(mainFilename)) { if (code[i].getFile().equals(primaryFile)) { SketchCode temp = code[0]; code[0] = code[i]; code[i] = temp; break; } } // sort the entries at the top sortCode(); // set the main file to be the current tab if (editor != null) { setCurrentCode(0); } } protected void replaceCode(SketchCode newCode) { for (int i = 0; i < codeCount; i++) { if (code[i].getFileName().equals(newCode.getFileName())) { code[i] = newCode; break; } } } protected void insertCode(SketchCode newCode) { // make sure the user didn't hide the sketch folder ensureExistence(); // add file to the code/codeCount list, resort the list //if (codeCount == code.length) { code = (SketchCode[]) PApplet.append(code, newCode); codeCount++; //} //code[codeCount++] = newCode; } protected void sortCode() { // cheap-ass sort of the rest of the files // it's a dumb, slow sort, but there shouldn't be more than ~5 files for (int i = 1; i < codeCount; i++) { int who = i; for (int j = i + 1; j < codeCount; j++) { if (code[j].getFileName().compareTo(code[who].getFileName()) < 0) { who = j; // this guy is earlier in the alphabet } } if (who != i) { // swap with someone if changes made SketchCode temp = code[who]; code[who] = code[i]; code[i] = temp; } } } boolean renamingCode; /** * Handler for the New Code menu option. */ public void handleNewCode() { // make sure the user didn't hide the sketch folder ensureExistence(); // if read-only, give an error if (isReadOnly()) { // if the files are read-only, need to first do a "save as". Base.showMessage("Sketch is Read-Only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save the sketch in another location,\n" + "and try again."); return; } renamingCode = false; editor.status.edit("Name for new file:", ""); } /** * Handler for the Rename Code menu option. */ public void handleRenameCode() { // make sure the user didn't hide the sketch folder ensureExistence(); if (currentIndex == 0 && editor.untitled) { Base.showMessage("Sketch is Untitled", "How about saving the sketch first \n" + "before trying to rename it?"); return; } // if read-only, give an error if (isReadOnly()) { // if the files are read-only, need to first do a "save as". Base.showMessage("Sketch is Read-Only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save the sketch in another location,\n" + "and try again."); return; } // ask for new name of file (internal to window) // TODO maybe just popup a text area? renamingCode = true; String prompt = (currentIndex == 0) ? "New name for sketch:" : "New name for file:"; String oldName = (current.isExtension("pde")) ? current.getPrettyName() : current.getFileName(); editor.status.edit(prompt, oldName); } /** * This is called upon return from entering a new file name. * (that is, from either newCode or renameCode after the prompt) * This code is almost identical for both the newCode and renameCode * cases, so they're kept merged except for right in the middle * where they diverge. */ protected void nameCode(String newName) { // make sure the user didn't hide the sketch folder ensureExistence(); // Add the extension here, this simplifies some of the logic below. if (newName.indexOf('.') == -1) { newName += "." + getDefaultExtension(); } // if renaming to the same thing as before, just ignore. // also ignoring case here, because i don't want to write // a bunch of special stuff for each platform // (osx is case insensitive but preserving, windows insensitive, // *nix is sensitive and preserving.. argh) if (renamingCode) { if (newName.equalsIgnoreCase(current.getFileName())) { // exit quietly for the 'rename' case. // if it's a 'new' then an error will occur down below return; } } newName = newName.trim(); if (newName.equals("")) return; int dot = newName.indexOf('.'); if (dot == 0) { Base.showWarning("Problem with rename", "The name cannot start with a period.", null); return; } String newExtension = newName.substring(dot+1).toLowerCase(); if (!validExtension(newExtension)) { Base.showWarning("Problem with rename", "\"." + newExtension + "\"" + "is not a valid extension.", null); return; } // Don't let the user create the main tab as a .java file instead of .pde if (!isDefaultExtension(newExtension)) { if (renamingCode) { // If creating a new tab, don't show this error if (current == code[0]) { // If this is the main tab, disallow Base.showWarning("Problem with rename", "The main .pde file cannot be .java file.\n" + "(It may be time for your to graduate to a\n" + "\"real\" programming environment)", null); return; } } } // dots are allowed for the .pde and .java, but not in the name // make sure the user didn't name things poo.time.pde // or something like that (nothing against poo time) String shortName = newName.substring(0, dot); String sanitaryName = Sketch.sanitizeName(shortName); if (!shortName.equals(sanitaryName)) { newName = sanitaryName + "." + newExtension; } // Make sure no .pde *and* no .java files with the same name already exist // http://dev.processing.org/bugs/show_bug.cgi?id=543 for (SketchCode c : code) { if (sanitaryName.equalsIgnoreCase(c.getPrettyName())) { Base.showMessage("Nope", "A file named \"" + c.getFileName() + "\" already exists\n" + "in \"" + folder.getAbsolutePath() + "\""); return; } } File newFile = new File(folder, newName); // if (newFile.exists()) { // yay! users will try anything // Base.showMessage("Nope", // "A file named \"" + newFile + "\" already exists\n" + // "in \"" + folder.getAbsolutePath() + "\""); // return; // } // File newFileHidden = new File(folder, newName + ".x"); // if (newFileHidden.exists()) { // // don't let them get away with it if they try to create something // // with the same name as something hidden // Base.showMessage("No Way", // "A hidden tab with the same name already exists.\n" + // "Use \"Unhide\" to bring it back."); // return; // } if (renamingCode) { if (currentIndex == 0) { // get the new folder name/location String folderName = newName.substring(0, newName.indexOf('.')); File newFolder = new File(folder.getParentFile(), folderName); if (newFolder.exists()) { Base.showWarning("Cannot Rename", "Sorry, a sketch (or folder) named " + "\"" + newName + "\" already exists.", null); return; } // unfortunately this can't be a "save as" because that // only copies the sketch files and the data folder // however this *will* first save the sketch, then rename // first get the contents of the editor text area if (current.isModified()) { current.setProgram(editor.getText()); try { // save this new SketchCode current.save(); } catch (Exception e) { Base.showWarning("Error", "Could not rename the sketch. (0)", e); return; } } if (!current.renameTo(newFile, newExtension)) { Base.showWarning("Error", "Could not rename \"" + current.getFileName() + "\" to \"" + newFile.getName() + "\"", null); return; } // save each of the other tabs because this is gonna be re-opened try { for (int i = 1; i < codeCount; i++) { code[i].save(); } } catch (Exception e) { Base.showWarning("Error", "Could not rename the sketch. (1)", e); return; } // now rename the sketch folder and re-open boolean success = folder.renameTo(newFolder); if (!success) { Base.showWarning("Error", "Could not rename the sketch. (2)", null); return; } // if successful, set base properties for the sketch File newMainFile = new File(newFolder, newName + ".pde"); String newMainFilePath = newMainFile.getAbsolutePath(); // having saved everything and renamed the folder and the main .pde, // use the editor to re-open the sketch to re-init state // (unfortunately this will kill positions for carets etc) editor.handleOpenUnchecked(newMainFilePath, currentIndex, editor.getSelectionStart(), editor.getSelectionStop(), editor.getScrollPosition()); // get the changes into the sketchbook menu // (re-enabled in 0115 to fix bug #332) editor.base.rebuildSketchbookMenus(); } else { // else if something besides code[0] if (!current.renameTo(newFile, newExtension)) { Base.showWarning("Error", "Could not rename \"" + current.getFileName() + "\" to \"" + newFile.getName() + "\"", null); return; } } } else { // creating a new file try { if (!newFile.createNewFile()) { // Already checking for IOException, so make our own. throw new IOException("createNewFile() returned false"); } } catch (IOException e) { Base.showWarning("Error", "Could not create the file \"" + newFile + "\"\n" + "in \"" + folder.getAbsolutePath() + "\"", e); return; } SketchCode newCode = new SketchCode(newFile, newExtension); //System.out.println("new code is named " + newCode.getPrettyName() + " " + newCode.getFile()); insertCode(newCode); } // sort the entries sortCode(); // set the new guy as current setCurrentCode(newName); // update the tabs editor.header.rebuild(); } /** * Remove a piece of code from the sketch and from the disk. */ public void handleDeleteCode() { // make sure the user didn't hide the sketch folder ensureExistence(); // if read-only, give an error if (isReadOnly()) { // if the files are read-only, need to first do a "save as". Base.showMessage("Sketch is Read-Only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save the sketch in another location,\n" + "and try again."); return; } // confirm deletion with user, yes/no Object[] options = { "OK", "Cancel" }; String prompt = (currentIndex == 0) ? "Are you sure you want to delete this sketch?" : "Are you sure you want to delete \"" + current.getPrettyName() + "\"?"; int result = JOptionPane.showOptionDialog(editor, prompt, "Delete", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result == JOptionPane.YES_OPTION) { if (currentIndex == 0) { // need to unset all the modified flags, otherwise tries // to do a save on the handleNew() // delete the entire sketch Base.removeDir(folder); // get the changes into the sketchbook menu //sketchbook.rebuildMenus(); // make a new sketch, and i think this will rebuild the sketch menu //editor.handleNewUnchecked(); //editor.handleClose2(); editor.base.handleClose(editor); } else { // delete the file if (!current.deleteFile()) { Base.showMessage("Couldn't do it", "Could not delete \"" + current.getFileName() + "\"."); return; } // remove code from the list removeCode(current); // just set current tab to the main tab setCurrentCode(0); // update the tabs editor.header.repaint(); } } } protected void removeCode(SketchCode which) { // remove it from the internal list of files // resort internal list of files for (int i = 0; i < codeCount; i++) { if (code[i] == which) { for (int j = i; j < codeCount-1; j++) { code[j] = code[j+1]; } codeCount--; code = (SketchCode[]) PApplet.shorten(code); return; } } System.err.println("removeCode: internal error.. could not find code"); } /** * Move to the previous tab. */ public void handlePrevCode() { int prev = currentIndex - 1; if (prev < 0) prev = codeCount-1; setCurrentCode(prev); } /** * Move to the next tab. */ public void handleNextCode() { setCurrentCode((currentIndex + 1) % codeCount); } /** * Sets the modified value for the code in the frontmost tab. */ public void setModified(boolean state) { //System.out.println("setting modified to " + state); //new Exception().printStackTrace(); current.setModified(state); calcModified(); } protected void calcModified() { modified = false; for (int i = 0; i < codeCount; i++) { if (code[i].isModified()) { modified = true; break; } } editor.header.repaint(); if (Base.isMacOS()) { // http://developer.apple.com/qa/qa2001/qa1146.html Object modifiedParam = modified ? Boolean.TRUE : Boolean.FALSE; editor.getRootPane().putClientProperty("windowModified", modifiedParam); } } public boolean isModified() { return modified; } /** * Save all code in the current sketch. */ public boolean save() throws IOException { // make sure the user didn't hide the sketch folder ensureExistence(); // first get the contents of the editor text area if (current.isModified()) { current.setProgram(editor.getText()); } // don't do anything if not actually modified //if (!modified) return false; if (isReadOnly()) { // if the files are read-only, need to first do a "save as". Base.showMessage("Sketch is read-only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save this sketch to another location."); // if the user cancels, give up on the save() if (!saveAs()) return false; } for (int i = 0; i < codeCount; i++) { if (code[i].isModified()) code[i].save(); } calcModified(); return true; } /** * Handles 'Save As' for a sketch. * <P> * This basically just duplicates the current sketch folder to * a new location, and then calls 'Save'. (needs to take the current * state of the open files and save them to the new folder.. * but not save over the old versions for the old sketch..) * <P> * Also removes the previously-generated .class and .jar files, * because they can cause trouble. */ protected boolean saveAs() throws IOException { String newParentDir = null; String newName = null; /* JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Save sketch folder as..."); if (isReadOnly() || isUntitled()) { // default to the sketchbook folder fc.setCurrentDirectory(new File(Preferences.get("sketchbook.path"))); } else { // default to the parent folder of where this was fc.setCurrentDirectory(folder.getParentFile()); } // can't do this, will try to save into itself by default //fc.setSelectedFile(folder); int result = fc.showSaveDialog(editor); if (result == JFileChooser.APPROVE_OPTION) { File selection = fc.getSelectedFile(); newParentDir = selection.getParent(); newName = selection.getName(); } */ // get new name for folder FileDialog fd = new FileDialog(editor, "Save sketch folder as...", FileDialog.SAVE); if (isReadOnly() || isUntitled()) { // default to the sketchbook folder fd.setDirectory(Preferences.get("sketchbook.path")); } else { // default to the parent folder of where this was fd.setDirectory(folder.getParent()); } String oldName = folder.getName(); fd.setFile(oldName); fd.setVisible(true); newParentDir = fd.getDirectory(); newName = fd.getFile(); // user canceled selection if (newName == null) return false; newName = Sketch.checkName(newName); File newFolder = new File(newParentDir, newName); // String newPath = newFolder.getAbsolutePath(); // String oldPath = folder.getAbsolutePath(); // if (newPath.equals(oldPath)) { // return false; // Can't save a sketch over itself // } // make sure there doesn't exist a tab with that name already // but ignore this situation for the first tab, since it's probably being // resaved (with the same name) to another location/folder. for (int i = 1; i < codeCount; i++) { if (newName.equalsIgnoreCase(code[i].getPrettyName())) { Base.showMessage("Nope", "You can't save the sketch as \"" + newName + "\"\n" + "because the sketch already has a tab with that name."); return false; } } // check if the paths are identical if (newFolder.equals(folder)) { // just use "save" here instead, because the user will have received a // message (from the operating system) about "do you want to replace?" return save(); } // check to see if the user is trying to save this sketch inside itself try { String newPath = newFolder.getCanonicalPath() + File.separator; String oldPath = folder.getCanonicalPath() + File.separator; if (newPath.indexOf(oldPath) == 0) { Base.showWarning("How very Borges of you", "You cannot save the sketch into a folder\n" + "inside itself. This would go on forever.", null); return false; } } catch (IOException e) { } // if the new folder already exists, then need to remove // its contents before copying everything over // (user will have already been warned) if (newFolder.exists()) { Base.removeDir(newFolder); } // in fact, you can't do this on windows because the file dialog // will instead put you inside the folder, but it happens on osx a lot. // now make a fresh copy of the folder newFolder.mkdirs(); // grab the contents of the current tab before saving // first get the contents of the editor text area if (current.isModified()) { current.setProgram(editor.getText()); } // save the other tabs to their new location for (int i = 1; i < codeCount; i++) { File newFile = new File(newFolder, code[i].getFileName()); code[i].saveAs(newFile); } // re-copy the data folder (this may take a while.. add progress bar?) if (dataFolder.exists()) { File newDataFolder = new File(newFolder, "data"); Base.copyDir(dataFolder, newDataFolder); } // re-copy the code folder if (codeFolder.exists()) { File newCodeFolder = new File(newFolder, "code"); Base.copyDir(codeFolder, newCodeFolder); } // copy custom applet.html file if one exists // http://dev.processing.org/bugs/show_bug.cgi?id=485 File customHtml = new File(folder, "applet.html"); if (customHtml.exists()) { File newHtml = new File(newFolder, "applet.html"); Base.copyFile(customHtml, newHtml); } // save the main tab with its new name File newFile = new File(newFolder, newName + ".pde"); code[0].saveAs(newFile); editor.handleOpenUnchecked(newFile.getPath(), currentIndex, editor.getSelectionStart(), editor.getSelectionStop(), editor.getScrollPosition()); // Name changed, rebuild the sketch menus //editor.sketchbook.rebuildMenusAsync(); editor.base.rebuildSketchbookMenus(); // Make sure that it's not an untitled sketch setUntitled(false); // let Editor know that the save was successful return true; } /** * Prompt the user for a new file to the sketch, then call the * other addFile() function to actually add it. */ public void handleAddFile() { // make sure the user didn't hide the sketch folder ensureExistence(); // if read-only, give an error if (isReadOnly()) { // if the files are read-only, need to first do a "save as". Base.showMessage("Sketch is Read-Only", "Some files are marked \"read-only\", so you'll\n" + "need to re-save the sketch in another location,\n" + "and try again."); return; } // get a dialog, select a file to add to the sketch String prompt = "Select an image or other data file to copy to your sketch"; //FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD); FileDialog fd = new FileDialog(editor, prompt, FileDialog.LOAD); fd.setVisible(true); String directory = fd.getDirectory(); String filename = fd.getFile(); if (filename == null) return; // copy the file into the folder. if people would rather // it move instead of copy, they can do it by hand File sourceFile = new File(directory, filename); // now do the work of adding the file boolean result = addFile(sourceFile); if (result) { editor.statusNotice("One file added to the sketch."); } } /** * Add a file to the sketch. * <p/> * .pde or .java files will be added to the sketch folder. <br/> * .jar, .class, .dll, .jnilib, and .so files will all * be added to the "code" folder. <br/> * All other files will be added to the "data" folder. * <p/> * If they don't exist already, the "code" or "data" folder * will be created. * <p/> * @return true if successful. */ public boolean addFile(File sourceFile) { String filename = sourceFile.getName(); File destFile = null; String codeExtension = null; boolean replacement = false; // if the file appears to be code related, drop it // into the code folder, instead of the data folder if (filename.toLowerCase().endsWith(".class") || filename.toLowerCase().endsWith(".jar") || filename.toLowerCase().endsWith(".dll") || filename.toLowerCase().endsWith(".jnilib") || filename.toLowerCase().endsWith(".so")) { //if (!codeFolder.exists()) codeFolder.mkdirs(); prepareCodeFolder(); destFile = new File(codeFolder, filename); } else { for (String extension : getExtensions()) { String lower = filename.toLowerCase(); if (lower.endsWith("." + extension)) { destFile = new File(this.folder, filename); codeExtension = extension; } } if (codeExtension == null) { prepareDataFolder(); destFile = new File(dataFolder, filename); } } // check whether this file already exists if (destFile.exists()) { Object[] options = { "OK", "Cancel" }; String prompt = "Replace the existing version of " + filename + "?"; int result = JOptionPane.showOptionDialog(editor, prompt, "Replace", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (result == JOptionPane.YES_OPTION) { replacement = true; } else { return false; } } // If it's a replacement, delete the old file first, // otherwise case changes will not be preserved. // http://dev.processing.org/bugs/show_bug.cgi?id=969 if (replacement) { boolean muchSuccess = destFile.delete(); if (!muchSuccess) { Base.showWarning("Error adding file", "Could not delete the existing '" + filename + "' file.", null); return false; } } // make sure they aren't the same file if ((codeExtension == null) && sourceFile.equals(destFile)) { Base.showWarning("You can't fool me", "This file has already been copied to the\n" + "location from which where you're trying to add it.\n" + "I ain't not doin nuthin'.", null); return false; } // in case the user is "adding" the code in an attempt // to update the sketch's tabs if (!sourceFile.equals(destFile)) { try { Base.copyFile(sourceFile, destFile); } catch (IOException e) { Base.showWarning("Error adding file", "Could not add '" + filename + "' to the sketch.", e); return false; } } if (codeExtension != null) { SketchCode newCode = new SketchCode(destFile, codeExtension); if (replacement) { replaceCode(newCode); } else { insertCode(newCode); sortCode(); } setCurrentCode(filename); editor.header.repaint(); if (editor.untitled) { // TODO probably not necessary? problematic? // Mark the new code as modified so that the sketch is saved current.setModified(true); } } else { if (editor.untitled) { // TODO probably not necessary? problematic? // If a file has been added, mark the main code as modified so // that the sketch is properly saved. code[0].setModified(true); } } return true; } /** * Add import statements to the current tab for all of packages inside * the specified jar file. */ public void importLibrary(String jarPath) { // make sure the user didn't hide the sketch folder ensureExistence(); String list[] = Compiler.packageListFromClassPath(jarPath); // import statements into the main sketch file (code[0]) // if the current code is a .java file, insert into current //if (current.flavor == PDE) { if (hasDefaultExtension(current)) { setCurrentCode(0); } // could also scan the text in the file to see if each import // statement is already in there, but if the user has the import // commented out, then this will be a problem. StringBuffer buffer = new StringBuffer(); for (int i = 0; i < list.length; i++) { buffer.append("import "); buffer.append(list[i]); buffer.append(".*;\n"); } buffer.append('\n'); buffer.append(editor.getText()); editor.setText(buffer.toString()); editor.setSelection(0, 0); // scroll to start setModified(true); } /** * Change what file is currently being edited. Changes the current tab index. * <OL> * <LI> store the String for the text of the current file. * <LI> retrieve the String for the text of the new file. * <LI> change the text that's visible in the text area * </OL> */ public void setCurrentCode(int which) { // if current is null, then this is the first setCurrent(0) if ((currentIndex == which) && (current != null)) { return; } // get the text currently being edited if (current != null) { current.setState(editor.getText(), editor.getSelectionStart(), editor.getSelectionStop(), editor.getScrollPosition()); } current = code[which]; currentIndex = which; editor.setCode(current); editor.header.rebuild(); } /** * Internal helper function to set the current tab based on a name. * @param findName the file name (not pretty name) to be shown */ protected void setCurrentCode(String findName) { for (int i = 0; i < codeCount; i++) { if (findName.equals(code[i].getFileName()) || findName.equals(code[i].getPrettyName())) { setCurrentCode(i); return; } } } /** * Cleanup temporary files used during a build/run. */ protected void cleanup() { // if the java runtime is holding onto any files in the build dir, we // won't be able to delete them, so we need to force a gc here System.gc(); // note that we can't remove the builddir itself, otherwise // the next time we start up, internal runs using Runner won't // work because the build dir won't exist at startup, so the classloader // will ignore the fact that that dir is in the CLASSPATH in run.sh Base.removeDescendants(tempBuildFolder); } /** * Preprocess, Compile, and Run the current code. * <P> * There are three main parts to this process: * <PRE> * (0. if not java, then use another 'engine'.. i.e. python) * * 1. do the p5 language preprocessing * this creates a working .java file in a specific location * better yet, just takes a chunk of java code and returns a * new/better string editor can take care of saving this to a * file location * * 2. compile the code from that location * catching errors along the way * placing it in a ready classpath, or .. ? * * 3. run the code * needs to communicate location for window * and maybe setup presentation space as well * run externally if a code folder exists, * or if more than one file is in the project * * X. afterwards, some of these steps need a cleanup function * </PRE> */ //protected String compile() throws RunnerException { /** * When running from the editor, take care of preparations before running * the build. */ public void prepare() { // make sure the user didn't hide the sketch folder ensureExistence(); current.setProgram(editor.getText()); // TODO record history here //current.history.record(program, SketchHistory.RUN); // if an external editor is being used, need to grab the // latest version of the code from the file. if (Preferences.getBoolean("editor.external")) { // history gets screwed by the open.. //String historySaved = history.lastRecorded; //handleOpen(sketch); //history.lastRecorded = historySaved; // set current to null so that the tab gets updated // http://dev.processing.org/bugs/show_bug.cgi?id=515 current = null; // nuke previous files and settings, just get things loaded load(); } // in case there were any boogers left behind // do this here instead of after exiting, since the exit // can happen so many different ways.. and this will be // better connected to the dataFolder stuff below. cleanup(); // // handle preprocessing the main file's code // return build(tempBuildFolder.getAbsolutePath()); } /** * Build all the code for this sketch. * * In an advanced program, the returned class name could be different, * which is why the className is set based on the return value. * A compilation error will burp up a RunnerException. * * Setting purty to 'true' will cause exception line numbers to be incorrect. * Unless you know the code compiles, you should first run the preprocessor * with purty set to false to make sure there are no errors, then once * successful, re-export with purty set to true. * * @param buildPath Location to copy all the .java files * @return null if compilation failed, main class name if not */ public String preprocess(String buildPath) throws RunnerException { return preprocess(buildPath, new PdePreprocessor()); } public String preprocess(String buildPath, PdePreprocessor preprocessor) throws RunnerException { // make sure the user didn't hide the sketch folder ensureExistence(); String[] codeFolderPackages = null; classPath = buildPath; // figure out the contents of the code folder to see if there // are files that need to be added to the imports if (codeFolder.exists()) { libraryPath = codeFolder.getAbsolutePath(); // get a list of .jar files in the "code" folder // (class files in subfolders should also be picked up) String codeFolderClassPath = Compiler.contentsToClassPath(codeFolder); // append the jar files in the code folder to the class path classPath += File.pathSeparator + codeFolderClassPath; // get list of packages found in those jars codeFolderPackages = Compiler.packageListFromClassPath(codeFolderClassPath); } else { libraryPath = ""; } // 1. concatenate all .pde files to the 'main' pde // store line number for starting point of each code bit StringBuffer bigCode = new StringBuffer(); int bigCount = 0; for (SketchCode sc : code) { if (sc.isExtension("pde")) { sc.setPreprocOffset(bigCount); bigCode.append(sc.getProgram()); bigCode.append('\n'); bigCount += sc.getLineCount(); } } // Note that the headerOffset isn't applied until compile and run, because // it only applies to the code after it's been written to the .java file. int headerOffset = 0; //PdePreprocessor preprocessor = new PdePreprocessor(); try { headerOffset = preprocessor.writePrefix(bigCode.toString(), buildPath, name, codeFolderPackages); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); String msg = "Build folder disappeared or could not be written"; throw new RunnerException(msg); } // 2. run preproc on that code using the sugg class name // to create a single .java file and write to buildpath String primaryClassName = null; try { final String className = preprocessor.write(); if (className == null) { throw new RunnerException("Could not find main class"); } // store this for the compiler and the runtime primaryClassName = className; } catch (antlr.RecognitionException re) { // re also returns a column that we're not bothering with for now // first assume that it's the main file int errorFile = 0; int errorLine = re.getLine() - 1; // then search through for anyone else whose preprocName is null, // since they've also been combined into the main pde. for (int i = 1; i < codeCount; i++) { if (code[i].isExtension("pde") && (code[i].getPreprocOffset() < errorLine)) { // keep looping until the errorLine is past the offset errorFile = i; } } errorLine -= code[errorFile].getPreprocOffset(); // System.out.println("i found this guy snooping around.."); // System.out.println("whatcha want me to do with 'im boss?"); // System.out.println(errorLine + " " + errorFile + " " + code[errorFile].getPreprocOffset()); String msg = re.getMessage(); if (msg.equals("expecting RCURLY, found 'null'")) { // This can be a problem since the error is sometimes listed as a line // that's actually past the number of lines. For instance, it might // report "line 15" of a 14 line program. Added code to highlightLine() // inside Editor to deal with this situation (since that code is also // useful for other similar situations). throw new RunnerException("Found one too many { characters " + "without a } to match it.", errorFile, errorLine, re.getColumn()); } if (msg.indexOf("expecting RBRACK") != -1) { System.err.println(msg); throw new RunnerException("Syntax error, " + "maybe a missing ] character?", errorFile, errorLine, re.getColumn()); } if (msg.indexOf("expecting SEMI") != -1) { System.err.println(msg); throw new RunnerException("Syntax error, " + "maybe a missing semicolon?", errorFile, errorLine, re.getColumn()); } if (msg.indexOf("expecting RPAREN") != -1) { System.err.println(msg); throw new RunnerException("Syntax error, " + "maybe a missing right parenthesis?", errorFile, errorLine, re.getColumn()); } if (msg.indexOf("preproc.web_colors") != -1) { throw new RunnerException("A web color (such as #ffcc00) " + "must be six digits.", errorFile, errorLine, re.getColumn(), false); } //System.out.println("msg is " + msg); throw new RunnerException(msg, errorFile, errorLine, re.getColumn()); } catch (antlr.TokenStreamRecognitionException tsre) { // while this seems to store line and column internally, // there doesn't seem to be a method to grab it.. // so instead it's done using a regexp // System.err.println("and then she tells me " + tsre.toString()); // TODO not tested since removing ORO matcher.. ^ could be a problem String mess = "^line (\\d+):(\\d+):\\s"; String[] matches = PApplet.match(tsre.toString(), mess); if (matches != null) { int errorLine = Integer.parseInt(matches[1]) - 1; int errorColumn = Integer.parseInt(matches[2]); int errorFile = 0; for (int i = 1; i < codeCount; i++) { if (code[i].isExtension("pde") && (code[i].getPreprocOffset() < errorLine)) { errorFile = i; } } errorLine -= code[errorFile].getPreprocOffset(); throw new RunnerException(tsre.getMessage(), errorFile, errorLine, errorColumn); } else { // this is bad, defaults to the main class.. hrm. String msg = tsre.toString(); throw new RunnerException(msg, 0, -1, -1); } } catch (RunnerException pe) { // RunnerExceptions are caught here and re-thrown, so that they don't // get lost in the more general "Exception" handler below. throw pe; } catch (Exception ex) { // TODO better method for handling this? System.err.println("Uncaught exception type:" + ex.getClass()); ex.printStackTrace(); throw new RunnerException(ex.toString()); } // grab the imports from the code just preproc'd importedLibraries = new ArrayList<File>(); for (String item : preprocessor.getExtraImports()) { // remove things up to the last dot int dot = item.lastIndexOf('.'); // http://dev.processing.org/bugs/show_bug.cgi?id=1145 String entry = (dot == -1) ? item : item.substring(0, dot); File libFolder = (File) Base.importToLibraryTable.get(entry); if (libFolder != null) { importedLibraries.add(libFolder); classPath += Compiler.contentsToClassPath(libFolder); libraryPath += File.pathSeparator + libFolder.getAbsolutePath(); } } // Finally, add the regular Java CLASSPATH String javaClassPath = System.getProperty("java.class.path"); // Remove quotes if any.. An annoying (and frequent) Windows problem if (javaClassPath.startsWith("\"") && javaClassPath.endsWith("\"")) { javaClassPath = javaClassPath.substring(1, javaClassPath.length() - 1); } classPath += File.pathSeparator + javaClassPath; // 3. then loop over the code[] and save each .java file for (SketchCode sc : code) { if (sc.isExtension("java")) { // no pre-processing services necessary for java files // just write the the contents of 'program' to a .java file // into the build directory. uses byte stream and reader/writer // shtuff so that unicode bunk is properly handled String filename = sc.getFileName(); //code[i].name + ".java"; try { Base.saveFile(sc.getProgram(), new File(buildPath, filename)); } catch (IOException e) { e.printStackTrace(); throw new RunnerException("Problem moving " + filename + " to the build folder"); } // sc.setPreprocName(filename); } else if (sc.isExtension("pde")) { // The compiler and runner will need this to have a proper offset sc.addPreprocOffset(headerOffset); } } foundMain = preprocessor.getFoundMain(); return primaryClassName; } public boolean getFoundMain() { return foundMain; } public ArrayList<File> getImportedLibraries() { return importedLibraries; } /** * Map an error from a set of processed .java files back to its location * in the actual sketch. * @param message The error message. * @param filename The .java file where the exception was found. * @param line Line number of the .java file for the exception (1-indexed) * @return A RunnerException to be sent to the editor, or null if it wasn't * possible to place the exception to the sketch code. */ // public RunnerException placeExceptionAlt(String message, // String filename, int line) { // String appletJavaFile = appletClassName + ".java"; // SketchCode errorCode = null; // if (filename.equals(appletJavaFile)) { // for (SketchCode code : getCode()) { // if (code.isExtension("pde")) { // if (line >= code.getPreprocOffset()) { // errorCode = code; // } // } // } // } else { // for (SketchCode code : getCode()) { // if (code.isExtension("java")) { // if (filename.equals(code.getFileName())) { // errorCode = code; // } // } // } // } // int codeIndex = getCodeIndex(errorCode); // // if (codeIndex != -1) { // //System.out.println("got line num " + lineNumber); // // in case this was a tab that got embedded into the main .java // line -= getCode(codeIndex).getPreprocOffset(); // // // lineNumber is 1-indexed, but editor wants zero-indexed // line--; // // // getMessage() will be what's shown in the editor // RunnerException exception = // new RunnerException(message, codeIndex, line, -1); // exception.hideStackTrace(); // return exception; // } // return null; // } /** * Map an error from a set of processed .java files back to its location * in the actual sketch. * @param message The error message. * @param filename The .java file where the exception was found. * @param line Line number of the .java file for the exception (0-indexed!) * @return A RunnerException to be sent to the editor, or null if it wasn't * possible to place the exception to the sketch code. */ public RunnerException placeException(String message, String dotJavaFilename, int dotJavaLine) { int codeIndex = 0; //-1; int codeLine = -1; // System.out.println("placing " + dotJavaFilename + " " + dotJavaLine); // System.out.println("code count is " + getCodeCount()); // first check to see if it's a .java file for (int i = 0; i < getCodeCount(); i++) { SketchCode code = getCode(i); if (code.isExtension("java")) { if (dotJavaFilename.equals(code.getFileName())) { codeIndex = i; codeLine = dotJavaLine; return new RunnerException(message, codeIndex, codeLine); } } } // If not the preprocessed file at this point, then need to get out if (!dotJavaFilename.equals(name + ".java")) { return null; } // if it's not a .java file, codeIndex will still be 0 // this section searches through the list of .pde files codeIndex = 0; for (int i = 0; i < getCodeCount(); i++) { SketchCode code = getCode(i); if (code.isExtension("pde")) { // System.out.println("preproc offset is " + code.getPreprocOffset()); // System.out.println("looking for line " + dotJavaLine); if (code.getPreprocOffset() <= dotJavaLine) { codeIndex = i; // System.out.println("i'm thinkin file " + i); codeLine = dotJavaLine - code.getPreprocOffset(); } } } // could not find a proper line number, so deal with this differently. // but if it was in fact the .java file we're looking for, though, // send the error message through. // this is necessary because 'import' statements will be at a line // that has a lower number than the preproc offset, for instance. // if (codeLine == -1 && !dotJavaFilename.equals(name + ".java")) { // return null; // } return new RunnerException(message, codeIndex, codeLine); } /** * Run the build inside the temporary build folder. * @return null if compilation failed, main class name if not * @throws RunnerException */ public String build() throws RunnerException { return build(tempBuildFolder.getAbsolutePath()); } /** * Preprocess and compile all the code for this sketch. * * In an advanced program, the returned class name could be different, * which is why the className is set based on the return value. * A compilation error will burp up a RunnerException. * * @return null if compilation failed, main class name if not */ public String build(String buildPath) throws RunnerException { // run the preprocessor String primaryClassName = preprocess(buildPath); // compile the program. errors will happen as a RunnerException // that will bubble up to whomever called build(). Compiler compiler = new Compiler(); if (compiler.compile(this, buildPath, primaryClassName, System.getProperty("sun.boot.class.path"))) { return primaryClassName; } return null; } protected boolean exportApplet() throws Exception { return exportApplet(new File(folder, "applet").getAbsolutePath()); } /** * Handle export to applet. */ public boolean exportApplet(String appletPath) throws RunnerException, IOException { // Make sure the user didn't hide the sketch folder ensureExistence(); // Reload the code when an external editor is being used if (Preferences.getBoolean("editor.external")) { // nuke previous files and settings load(); } File appletFolder = new File(appletPath); // Nuke the old applet folder because it can cause trouble if (Preferences.getBoolean("export.delete_target_folder")) { Base.removeDir(appletFolder); } // Create a fresh applet folder (needed before preproc is run below) appletFolder.mkdirs(); HashMap<String,Object> zipFileContents = new HashMap<String,Object>(); // build the sketch String foundName = build(appletFolder.getPath()); // (already reported) error during export, exit this function if (foundName == null) return false; // If name != exportSketchName, then that's weirdness // BUG unfortunately, that can also be a bug in the preproc :( if (!name.equals(foundName)) { Base.showWarning("Error during export", "Sketch name is " + name + " but the sketch\n" + "name in the code was " + foundName, null); return false; } int wide = PApplet.DEFAULT_WIDTH; int high = PApplet.DEFAULT_HEIGHT; String renderer = ""; // This matches against any uses of the size() function, whether numbers // or variables or whatever. This way, no warning is shown if size() isn't // actually used in the applet, which is the case especially for anyone // who is cutting/pasting from the reference. String sizeRegex = "(?:^|\\s|;)size\\s*\\(\\s*(\\S+)\\s*,\\s*(\\d+),?\\s*([^\\)]*)\\s*\\)"; String scrubbed = scrubComments(code[0].getProgram()); String[] matches = PApplet.match(scrubbed, sizeRegex); if (matches != null) { try { wide = Integer.parseInt(matches[1]); high = Integer.parseInt(matches[2]); // Adding back the trim() for 0136 to handle Bug #769 if (matches.length == 4) renderer = matches[3].trim(); } catch (NumberFormatException e) { // found a reference to size, but it didn't // seem to contain numbers final String message = "The size of this applet could not automatically be\n" + "determined from your code. You'll have to edit the\n" + "HTML file to set the size of the applet.\n" + "Use only numeric values (not variables) for the size()\n" + "command. See the size() reference for an explanation."; Base.showWarning("Could not find applet size", message, null); } } // else no size() command found // Grab the Javadoc-style description from the main code. // Originally tried to grab this with a regexp matcher, but it wouldn't // span over multiple lines for the match. This could prolly be forced, // but since that's the case better just to parse by hand. StringBuffer dbuffer = new StringBuffer(); String lines[] = PApplet.split(code[0].getProgram(), '\n'); for (int i = 0; i < lines.length; i++) { if (lines[i].trim().startsWith("/**")) { // this is our comment // some smartass put the whole thing on the same line //if (lines[j].indexOf("*/") != -1) break; for (int j = i+1; j < lines.length; j++) { if (lines[j].trim().endsWith("*/")) { // remove the */ from the end, and any extra *s // in case there's also content on this line // nah, don't bother.. make them use the three lines break; } int offset = 0; while ((offset < lines[j].length()) && ((lines[j].charAt(offset) == '*') || (lines[j].charAt(offset) == ' '))) { offset++; } // insert the return into the html to help w/ line breaks dbuffer.append(lines[j].substring(offset) + "\n"); } } } String description = dbuffer.toString(); // Add links to all the code StringBuffer sources = new StringBuffer(); for (int i = 0; i < codeCount; i++) { sources.append("<a href=\"" + code[i].getFileName() + "\">" + code[i].getPrettyName() + "</a> "); } // Copy the source files to the target, since we like // to encourage people to share their code for (int i = 0; i < codeCount; i++) { try { File exportedSource = new File(appletFolder, code[i].getFileName()); //Base.copyFile(code[i].getFile(), exportedSource); code[i].copyTo(exportedSource); } catch (IOException e) { e.printStackTrace(); // ho hum, just move on... } } // Use separate jarfiles whenever a library or code folder is in use. boolean separateJar = Preferences.getBoolean("export.applet.separate_jar_files") || codeFolder.exists() || (libraryPath.length() != 0); // Copy the loading gif to the applet String LOADING_IMAGE = "loading.gif"; // Check if the user already has their own loader image File loadingImage = new File(folder, LOADING_IMAGE); if (!loadingImage.exists()) { File skeletonFolder = new File(Base.getContentFile("lib"), "export"); loadingImage = new File(skeletonFolder, LOADING_IMAGE); } Base.copyFile(loadingImage, new File(appletFolder, LOADING_IMAGE)); // Create new .jar file FileOutputStream zipOutputFile = new FileOutputStream(new File(appletFolder, name + ".jar")); ZipOutputStream zos = new ZipOutputStream(zipOutputFile); ZipEntry entry; StringBuffer archives = new StringBuffer(); archives.append(name + ".jar"); // Add the manifest file addManifest(zos); // add the contents of the code folder to the jar // unpacks all jar files, unless multi jar files selected in prefs if (codeFolder.exists()) { String includes = Compiler.contentsToClassPath(codeFolder); String[] codeList = PApplet.splitTokens(includes, File.separator); String cp = ""; for (int i = 0; i < codeList.length; i++) { if (codeList[i].toLowerCase().endsWith(".jar") || codeList[i].toLowerCase().endsWith(".zip")) { if (separateJar) { File exportFile = new File(codeFolder, codeList[i]); String exportFilename = exportFile.getName(); Base.copyFile(exportFile, new File(appletFolder, exportFilename)); } else { cp += codeList[i] + File.pathSeparatorChar; //packClassPathIntoZipFile(cp, zos); } } } if (!separateJar) { packClassPathIntoZipFile(cp, zos, zipFileContents); } } // add contents of 'library' folders to the jar file // if a file called 'export.txt' is in there, it contains // a list of the files that should be exported. // otherwise, all files are exported. for (File libraryFolder : importedLibraries) { // in the list is a File object that points the // library sketch's "library" folder File exportSettings = new File(libraryFolder, "export.txt"); HashMap<String,String> exportTable = Base.readSettings(exportSettings); String appletList = (String) exportTable.get("applet"); String exportList[] = null; if (appletList != null) { exportList = PApplet.splitTokens(appletList, ", "); } else { exportList = libraryFolder.list(); } for (int i = 0; i < exportList.length; i++) { if (exportList[i].equals(".") || exportList[i].equals("..")) continue; exportList[i] = PApplet.trim(exportList[i]); if (exportList[i].equals("")) continue; File exportFile = new File(libraryFolder, exportList[i]); if (!exportFile.exists()) { System.err.println("File " + exportList[i] + " does not exist"); } else if (exportFile.isDirectory()) { System.err.println("Ignoring sub-folder \"" + exportList[i] + "\""); } else if (exportFile.getName().toLowerCase().endsWith(".zip") || exportFile.getName().toLowerCase().endsWith(".jar")) { if (separateJar) { String exportFilename = exportFile.getName(); Base.copyFile(exportFile, new File(appletFolder, exportFilename)); if (renderer.equals("OPENGL") && exportFilename.indexOf("natives") != -1) { // don't add these to the archives list } else { archives.append("," + exportFilename); } } else { String path = exportFile.getAbsolutePath(); packClassPathIntoZipFile(path, zos, zipFileContents); } } else { // just copy the file over.. prolly a .dll or something Base.copyFile(exportFile, new File(appletFolder, exportFile.getName())); } } } File bagelJar = Base.isMacOS() ? Base.getContentFile("core.jar") : Base.getContentFile("lib/core.jar"); if (separateJar) { Base.copyFile(bagelJar, new File(appletFolder, "core.jar")); archives.append(",core.jar"); } else { String bagelJarPath = bagelJar.getAbsolutePath(); packClassPathIntoZipFile(bagelJarPath, zos, zipFileContents); } if (dataFolder.exists()) { String dataFiles[] = Base.listFiles(dataFolder, false); int offset = folder.getAbsolutePath().length() + 1; for (int i = 0; i < dataFiles.length; i++) { if (Base.isWindows()) { dataFiles[i] = dataFiles[i].replace('\\', '/'); } File dataFile = new File(dataFiles[i]); if (dataFile.isDirectory()) continue; // don't export hidden files // skipping dot prefix removes all: . .. .DS_Store if (dataFile.getName().charAt(0) == '.') continue; entry = new ZipEntry(dataFiles[i].substring(offset)); zos.putNextEntry(entry); zos.write(Base.loadBytesRaw(dataFile)); zos.closeEntry(); } } // add the project's .class files to the jar // just grabs everything from the build directory // since there may be some inner classes // (add any .class files from the applet dir, then delete them) // TODO this needs to be recursive (for packages) String classfiles[] = appletFolder.list(); for (int i = 0; i < classfiles.length; i++) { if (classfiles[i].endsWith(".class")) { entry = new ZipEntry(classfiles[i]); zos.putNextEntry(entry); zos.write(Base.loadBytesRaw(new File(appletFolder, classfiles[i]))); zos.closeEntry(); } } // remove the .class files from the applet folder. if they're not // removed, the msjvm will complain about an illegal access error, // since the classes are outside the jar file. for (int i = 0; i < classfiles.length; i++) { if (classfiles[i].endsWith(".class")) { File deadguy = new File(appletFolder, classfiles[i]); if (!deadguy.delete()) { Base.showWarning("Could not delete", classfiles[i] + " could not \n" + "be deleted from the applet folder. \n" + "You'll need to remove it by hand.", null); } } } // close up the jar file zos.flush(); zos.close(); // // convert the applet template // @@sketch@@, @@width@@, @@height@@, @@archive@@, @@source@@ // and now @@description@@ File htmlOutputFile = new File(appletFolder, "index.html"); // UTF-8 fixes http://dev.processing.org/bugs/show_bug.cgi?id=474 PrintWriter htmlWriter = PApplet.createWriter(htmlOutputFile); InputStream is = null; // if there is an applet.html file in the sketch folder, use that File customHtml = new File(folder, "applet.html"); if (customHtml.exists()) { is = new FileInputStream(customHtml); } if (is == null) { if (renderer.equals("OPENGL")) { is = Base.getLibStream("export/applet-opengl.html"); } else { is = Base.getLibStream("export/applet.html"); } } BufferedReader reader = PApplet.createReader(is); String line = null; while ((line = reader.readLine()) != null) { if (line.indexOf("@@") != -1) { StringBuffer sb = new StringBuffer(line); int index = 0; while ((index = sb.indexOf("@@sketch@@")) != -1) { sb.replace(index, index + "@@sketch@@".length(), name); } while ((index = sb.indexOf("@@source@@")) != -1) { sb.replace(index, index + "@@source@@".length(), sources.toString()); } while ((index = sb.indexOf("@@archive@@")) != -1) { sb.replace(index, index + "@@archive@@".length(), archives.toString()); } while ((index = sb.indexOf("@@width@@")) != -1) { sb.replace(index, index + "@@width@@".length(), String.valueOf(wide)); } while ((index = sb.indexOf("@@height@@")) != -1) { sb.replace(index, index + "@@height@@".length(), String.valueOf(high)); } while ((index = sb.indexOf("@@description@@")) != -1) { sb.replace(index, index + "@@description@@".length(), description); } line = sb.toString(); } htmlWriter.println(line); } reader.close(); htmlWriter.flush(); htmlWriter.close(); return true; } /** * Replace all commented portions of a given String as spaces. * Utility function used here and in the preprocessor. */ static public String scrubComments(String what) { char p[] = what.toCharArray(); int index = 0; while (index < p.length) { // for any double slash comments, ignore until the end of the line if ((p[index] == '/') && (index < p.length - 1) && (p[index+1] == '/')) { p[index++] = ' '; p[index++] = ' '; while ((index < p.length) && (p[index] != '\n')) { p[index++] = ' '; } // check to see if this is the start of a new multiline comment. // if it is, then make sure it's actually terminated somewhere. } else if ((p[index] == '/') && (index < p.length - 1) && (p[index+1] == '*')) { p[index++] = ' '; p[index++] = ' '; boolean endOfRainbow = false; while (index < p.length - 1) { if ((p[index] == '*') && (p[index+1] == '/')) { p[index++] = ' '; p[index++] = ' '; endOfRainbow = true; break; } else { // continue blanking this area p[index++] = ' '; } } if (!endOfRainbow) { throw new RuntimeException("Missing the */ from the end of a " + "/* comment */"); } } else { // any old character, move along index++; } } return new String(p); } public boolean exportApplicationPrompt() throws IOException, RunnerException { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalStrut(6)); //Box panel = Box.createVerticalBox(); //Box labelBox = Box.createHorizontalBox(); // String msg = "<html>Click Export to Application to create a standalone, " + // "double-clickable application for the selected plaforms."; // String msg = "Export to Application creates a standalone, \n" + // "double-clickable application for the selected plaforms."; String line1 = "Export to Application creates double-clickable,"; String line2 = "standalone applications for the selected plaforms."; JLabel label1 = new JLabel(line1, SwingConstants.CENTER); JLabel label2 = new JLabel(line2, SwingConstants.CENTER); label1.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT); // label1.setAlignmentX(); // label2.setAlignmentX(0); panel.add(label1); panel.add(label2); int wide = label2.getPreferredSize().width; panel.add(Box.createVerticalStrut(12)); final JCheckBox windowsButton = new JCheckBox("Windows"); //windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); windowsButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.windows", windowsButton.isSelected()); } }); final JCheckBox macosxButton = new JCheckBox("Mac OS X"); //macosxButton.setMnemonic(KeyEvent.VK_M); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); final JCheckBox linuxButton = new JCheckBox("Linux"); //linuxButton.setMnemonic(KeyEvent.VK_L); linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux")); linuxButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected()); } }); JPanel platformPanel = new JPanel(); //platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS)); platformPanel.add(windowsButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(macosxButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(linuxButton); platformPanel.setBorder(new TitledBorder("Platforms")); //Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height); //platformPanel.setMaximumSize(goodIdea); wide = Math.max(wide, platformPanel.getPreferredSize().width); platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(platformPanel); // Box indentPanel = Box.createHorizontalBox(); // indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width)); final JCheckBox showStopButton = new JCheckBox("Show a Stop button"); //showStopButton.setMnemonic(KeyEvent.VK_S); showStopButton.setSelected(Preferences.getBoolean("export.application.stop")); showStopButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.stop", showStopButton.isSelected()); } }); showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen")); showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13)); // indentPanel.add(showStopButton); // indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT); final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)"); //fullscreenButton.setMnemonic(KeyEvent.VK_F); fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen")); fullScreenButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean sal = fullScreenButton.isSelected(); Preferences.setBoolean("export.application.fullscreen", sal); showStopButton.setEnabled(sal); } }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(fullScreenButton); optionPanel.add(showStopButton); // optionPanel.add(indentPanel); optionPanel.setBorder(new TitledBorder("Options")); wide = Math.max(wide, platformPanel.getPreferredSize().width); //goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); //optionPanel.setMaximumSize(goodIdea); panel.add(optionPanel); Dimension good; //label1, label2, platformPanel, optionPanel good = new Dimension(wide, label1.getPreferredSize().height); label1.setMaximumSize(good); good = new Dimension(wide, label2.getPreferredSize().height); label2.setMaximumSize(good); good = new Dimension(wide, platformPanel.getPreferredSize().height); platformPanel.setMaximumSize(good); good = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setMaximumSize(good); // JPanel actionPanel = new JPanel(); // optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); // optionPanel.add(Box.createHorizontalGlue()); // final JDialog frame = new JDialog(editor, "Export to Application"); // JButton cancelButton = new JButton("Cancel"); // cancelButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // frame.dispose(); // return false; // } // }); // Add the buttons in platform-specific order // if (PApplet.platform == PConstants.MACOSX) { // optionPanel.add(cancelButton); // optionPanel.add(exportButton); // } else { // optionPanel.add(exportButton); // optionPanel.add(cancelButton); // } String[] options = { "Export", "Cancel" }; final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, //JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); final JDialog dialog = new JDialog(editor, "Export Options", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { //If you were going to check something //before closing the window, you'd do //it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setResizable(false); Rectangle bounds = editor.getBounds(); dialog.setLocation(bounds.x + (bounds.width - dialog.getSize().width) / 2, bounds.y + (bounds.height - dialog.getSize().height) / 2); dialog.setVisible(true); Object value = optionPane.getValue(); if (value.equals(options[0])) { return exportApplication(); } else if (value.equals(options[1]) || value.equals(new Integer(-1))) { // closed window by hitting Cancel or ESC editor.statusNotice("Export to Application canceled."); } return false; } /** * Export to application via GUI. */ protected boolean exportApplication() throws IOException, RunnerException { if (Preferences.getBoolean("export.application.platform.windows")) { String windowsPath = new File(folder, "application.windows").getAbsolutePath(); if (!exportApplication(windowsPath, PConstants.WINDOWS)) { return false; } } if (Preferences.getBoolean("export.application.platform.macosx")) { String macosxPath = new File(folder, "application.macosx").getAbsolutePath(); if (!exportApplication(macosxPath, PConstants.MACOSX)) { return false; } } if (Preferences.getBoolean("export.application.platform.linux")) { String linuxPath = new File(folder, "application.linux").getAbsolutePath(); if (!exportApplication(linuxPath, PConstants.LINUX)) { return false; } } return true; } /** * Export to application without GUI. */ public boolean exportApplication(String destPath, int exportPlatform) throws IOException, RunnerException { // make sure the user didn't hide the sketch folder ensureExistence(); // fix for issue posted on the board. make sure that the code // is reloaded when exporting and an external editor is being used. if (Preferences.getBoolean("editor.external")) { // don't do from the command line if (editor != null) { // nuke previous files and settings load(); } } File destFolder = new File(destPath); if (Preferences.getBoolean("export.delete_target_folder")) { Base.removeDir(destFolder); } destFolder.mkdirs(); // build the sketch String foundName = build(destFolder.getPath()); // (already reported) error during export, exit this function if (foundName == null) return false; // if name != exportSketchName, then that's weirdness // BUG unfortunately, that can also be a bug in the preproc :( if (!name.equals(foundName)) { Base.showWarning("Error during export", "Sketch name is " + name + " but the sketch\n" + "name in the code was " + foundName, null); return false; } /// figure out where the jar files will be placed File jarFolder = new File(destFolder, "lib"); /// where all the skeleton info lives File skeletonFolder = new File(Base.getContentFile("lib"), "export"); /// on macosx, need to copy .app skeleton since that's /// also where the jar files will be placed File dotAppFolder = null; if (exportPlatform == PConstants.MACOSX) { dotAppFolder = new File(destFolder, name + ".app"); String APP_SKELETON = "skeleton.app"; //File dotAppSkeleton = new File(folder, APP_SKELETON); File dotAppSkeleton = new File(skeletonFolder, APP_SKELETON); Base.copyDir(dotAppSkeleton, dotAppFolder); String stubName = "Contents/MacOS/JavaApplicationStub"; // need to set the stub to executable // will work on osx or *nix, but just dies on windows, oh well.. if (Base.isWindows()) { File warningFile = new File(destFolder, "readme.txt"); PrintWriter pw = PApplet.createWriter(warningFile); pw.println("This application was created on Windows, which does not"); pw.println("properly support setting files as \"executable\","); pw.println("a necessity for applications on Mac OS X."); pw.println(); pw.println("To fix this, use the Terminal on Mac OS X, and from this"); pw.println("directory, type the following:"); pw.println(); pw.println("chmod +x " + dotAppFolder.getName() + "/" + stubName); pw.flush(); pw.close(); } else { File stubFile = new File(dotAppFolder, stubName); String stubPath = stubFile.getAbsolutePath(); Runtime.getRuntime().exec(new String[] { "chmod", "+x", stubPath }); } // set the jar folder to a different location than windows/linux jarFolder = new File(dotAppFolder, "Contents/Resources/Java"); } /// make the jar folder (windows and linux) if (!jarFolder.exists()) jarFolder.mkdirs(); /// on windows, copy the exe file if (exportPlatform == PConstants.WINDOWS) { Base.copyFile(new File(skeletonFolder, "application.exe"), new File(destFolder, this.name + ".exe")); } /// start copying all jar files Vector<String> jarListVector = new Vector<String>(); /// create the main .jar file HashMap<String,Object> zipFileContents = new HashMap<String,Object>(); FileOutputStream zipOutputFile = new FileOutputStream(new File(jarFolder, name + ".jar")); ZipOutputStream zos = new ZipOutputStream(zipOutputFile); ZipEntry entry; // add the manifest file so that the .jar can be double clickable addManifest(zos); // add the project's .class files to the jar // (just grabs everything from the build directory, // since there may be some inner classes) // TODO this needs to be recursive (for packages) String classfiles[] = destFolder.list(); for (int i = 0; i < classfiles.length; i++) { if (classfiles[i].endsWith(".class")) { entry = new ZipEntry(classfiles[i]); zos.putNextEntry(entry); zos.write(Base.loadBytesRaw(new File(destFolder, classfiles[i]))); zos.closeEntry(); } } // add the data folder to the main jar file if (dataFolder.exists()) { String dataFiles[] = Base.listFiles(dataFolder, false); int offset = folder.getAbsolutePath().length() + 1; for (int i = 0; i < dataFiles.length; i++) { if (Base.isWindows()) { dataFiles[i] = dataFiles[i].replace('\\', '/'); } File dataFile = new File(dataFiles[i]); if (dataFile.isDirectory()) continue; // don't export hidden files // skipping dot prefix removes all: . .. .DS_Store if (dataFile.getName().charAt(0) == '.') continue; entry = new ZipEntry(dataFiles[i].substring(offset)); zos.putNextEntry(entry); zos.write(Base.loadBytesRaw(dataFile)); zos.closeEntry(); } } // add the contents of the code folder to the jar if (codeFolder.exists()) { String includes = Compiler.contentsToClassPath(codeFolder); // Use tokens to get rid of extra blanks, which causes huge exports String[] codeList = PApplet.splitTokens(includes, File.separator); String cp = ""; for (int i = 0; i < codeList.length; i++) { if (codeList[i].toLowerCase().endsWith(".jar") || codeList[i].toLowerCase().endsWith(".zip")) { File exportFile = new File(codeFolder, codeList[i]); String exportFilename = exportFile.getName(); Base.copyFile(exportFile, new File(jarFolder, exportFilename)); jarListVector.add(exportFilename); } else { cp += codeList[i] + File.separatorChar; } } packClassPathIntoZipFile(cp, zos, zipFileContents); } zos.flush(); zos.close(); jarListVector.add(name + ".jar"); /// add core.jar to the jar destination folder File bagelJar = Base.isMacOS() ? Base.getContentFile("core.jar") : Base.getContentFile("lib/core.jar"); Base.copyFile(bagelJar, new File(jarFolder, "core.jar")); jarListVector.add("core.jar"); /// add contents of 'library' folders to the export // if a file called 'export.txt' is in there, it contains // a list of the files that should be exported. // otherwise, all files are exported. for (File libraryFolder : importedLibraries) { //System.out.println(libraryFolder + " " + libraryFolder.getAbsolutePath()); // in the list is a File object that points the // library sketch's "library" folder File exportSettings = new File(libraryFolder, "export.txt"); HashMap<String,String> exportTable = Base.readSettings(exportSettings); String commaList = null; String exportList[] = null; // first check to see if there's something like application.blargh if (exportPlatform == PConstants.MACOSX) { commaList = (String) exportTable.get("application.macosx"); } else if (exportPlatform == PConstants.WINDOWS) { commaList = (String) exportTable.get("application.windows"); } else if (exportPlatform == PConstants.LINUX) { commaList = (String) exportTable.get("application.linux"); } else { // next check to see if something for 'application' is specified commaList = (String) exportTable.get("application"); } if (commaList == null) { // otherwise just dump the whole folder exportList = libraryFolder.list(); } else { exportList = PApplet.splitTokens(commaList, ", "); } // add each item from the library folder / export list to the output for (int i = 0; i < exportList.length; i++) { if (exportList[i].equals(".") || exportList[i].equals("..")) continue; exportList[i] = PApplet.trim(exportList[i]); if (exportList[i].equals("")) continue; File exportFile = new File(libraryFolder, exportList[i]); if (!exportFile.exists()) { System.err.println("File " + exportList[i] + " does not exist"); } else if (exportFile.isDirectory()) { //System.err.println("Ignoring sub-folder \"" + exportList[i] + "\""); if (exportPlatform == PConstants.MACOSX) { // For OS X, copy subfolders to Contents/Resources/Java Base.copyDir(exportFile, new File(jarFolder, exportFile.getName())); } else { // For other platforms, just copy the folder to the same directory // as the application. Base.copyDir(exportFile, new File(destFolder, exportFile.getName())); } } else if (exportFile.getName().toLowerCase().endsWith(".zip") || exportFile.getName().toLowerCase().endsWith(".jar")) { //packClassPathIntoZipFile(exportFile.getAbsolutePath(), zos); Base.copyFile(exportFile, new File(jarFolder, exportList[i])); jarListVector.add(exportList[i]); } else if ((exportPlatform == PConstants.MACOSX) && (exportFile.getName().toLowerCase().endsWith(".jnilib"))) { // jnilib files can be placed in Contents/Resources/Java Base.copyFile(exportFile, new File(jarFolder, exportList[i])); } else { // copy the file to the main directory.. prolly a .dll or something Base.copyFile(exportFile, new File(destFolder, exportFile.getName())); } } } /// create platform-specific CLASSPATH based on included jars String jarList[] = new String[jarListVector.size()]; jarListVector.copyInto(jarList); StringBuffer exportClassPath = new StringBuffer(); if (exportPlatform == PConstants.MACOSX) { for (int i = 0; i < jarList.length; i++) { if (i != 0) exportClassPath.append(":"); exportClassPath.append("$JAVAROOT/" + jarList[i]); } } else if (exportPlatform == PConstants.WINDOWS) { for (int i = 0; i < jarList.length; i++) { if (i != 0) exportClassPath.append(","); exportClassPath.append(jarList[i]); } } else { for (int i = 0; i < jarList.length; i++) { if (i != 0) exportClassPath.append(":"); exportClassPath.append("$APPDIR/lib/" + jarList[i]); } } /// figure out run options for the VM String runOptions = Preferences.get("run.options"); if (Preferences.getBoolean("run.options.memory")) { runOptions += " -Xms" + Preferences.get("run.options.memory.initial") + "m"; runOptions += " -Xmx" + Preferences.get("run.options.memory.maximum") + "m"; } /// macosx: write out Info.plist (template for classpath, etc) if (exportPlatform == PConstants.MACOSX) { String PLIST_TEMPLATE = "template.plist"; File plistTemplate = new File(folder, PLIST_TEMPLATE); if (!plistTemplate.exists()) { plistTemplate = new File(skeletonFolder, PLIST_TEMPLATE); } File plistFile = new File(dotAppFolder, "Contents/Info.plist"); PrintWriter pw = PApplet.createWriter(plistFile); String lines[] = PApplet.loadStrings(plistTemplate); for (int i = 0; i < lines.length; i++) { if (lines[i].indexOf("@@") != -1) { StringBuffer sb = new StringBuffer(lines[i]); int index = 0; while ((index = sb.indexOf("@@vmoptions@@")) != -1) { sb.replace(index, index + "@@vmoptions@@".length(), runOptions); } while ((index = sb.indexOf("@@sketch@@")) != -1) { sb.replace(index, index + "@@sketch@@".length(), name); } while ((index = sb.indexOf("@@classpath@@")) != -1) { sb.replace(index, index + "@@classpath@@".length(), exportClassPath.toString()); } while ((index = sb.indexOf("@@lsuipresentationmode@@")) != -1) { sb.replace(index, index + "@@lsuipresentationmode@@".length(), Preferences.getBoolean("export.application.fullscreen") ? "4" : "0"); } lines[i] = sb.toString(); } // explicit newlines to avoid Windows CRLF pw.print(lines[i] + "\n"); } pw.flush(); pw.close(); } else if (exportPlatform == PConstants.WINDOWS) { File argsFile = new File(destFolder + "/lib/args.txt"); PrintWriter pw = PApplet.createWriter(argsFile); pw.println(runOptions); pw.println(this.name); pw.println(exportClassPath); pw.flush(); pw.close(); } else { File shellScript = new File(destFolder, this.name); PrintWriter pw = PApplet.createWriter(shellScript); // do the newlines explicitly so that windows CRLF // isn't used when exporting for unix pw.print("#!/bin/sh\n\n"); //ps.print("APPDIR=`dirname $0`\n"); pw.print("APPDIR=$(dirname \"$0\")\n"); // more posix compliant // another fix for bug #234, LD_LIBRARY_PATH ignored on some platforms //ps.print("LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$APPDIR\n"); pw.print("java " + Preferences.get("run.options") + " -Djava.library.path=\"$APPDIR\"" + " -cp \"" + exportClassPath + "\"" + " " + this.name + "\n"); pw.flush(); pw.close(); String shellPath = shellScript.getAbsolutePath(); // will work on osx or *nix, but just dies on windows, oh well.. if (!Base.isWindows()) { Runtime.getRuntime().exec(new String[] { "chmod", "+x", shellPath }); } } /// copy the source files to the target /// (we like to encourage people to share their code) File sourceFolder = new File(destFolder, "source"); sourceFolder.mkdirs(); for (int i = 0; i < codeCount; i++) { try { // Base.copyFile(code[i].getFile(), // new File(sourceFolder, code[i].file.getFileName())); code[i].copyTo(new File(sourceFolder, code[i].getFileName())); } catch (IOException e) { e.printStackTrace(); } } // move the .java file from the preproc there too String preprocFilename = this.name + ".java"; File preprocFile = new File(destFolder, preprocFilename); if (preprocFile.exists()) { preprocFile.renameTo(new File(sourceFolder, preprocFilename)); } /// remove the .class files from the export folder. for (int i = 0; i < classfiles.length; i++) { if (classfiles[i].endsWith(".class")) { File deadguy = new File(destFolder, classfiles[i]); if (!deadguy.delete()) { Base.showWarning("Could not delete", classfiles[i] + " could not \n" + "be deleted from the applet folder. \n" + "You'll need to remove it by hand.", null); } } } /// goodbye return true; } protected void addManifest(ZipOutputStream zos) throws IOException { ZipEntry entry = new ZipEntry("META-INF/MANIFEST.MF"); zos.putNextEntry(entry); String contents = "Manifest-Version: 1.0\n" + "Created-By: Processing " + Base.VERSION_NAME + "\n" + "Main-Class: " + name + "\n"; // TODO not package friendly zos.write(contents.getBytes()); zos.closeEntry(); } /** * Slurps up .class files from a colon (or semicolon on windows) * separated list of paths and adds them to a ZipOutputStream. */ protected void packClassPathIntoZipFile(String path, ZipOutputStream zos, HashMap<String,Object> zipFileContents) throws IOException { String[] pieces = PApplet.split(path, File.pathSeparatorChar); for (int i = 0; i < pieces.length; i++) { if (pieces[i].length() == 0) continue; // is it a jar file or directory? if (pieces[i].toLowerCase().endsWith(".jar") || pieces[i].toLowerCase().endsWith(".zip")) { try { ZipFile file = new ZipFile(pieces[i]); Enumeration<?> entries = file.entries(); while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); if (entry.isDirectory()) { // actually 'continue's for all dir entries } else { String entryName = entry.getName(); // ignore contents of the META-INF folders if (entryName.indexOf("META-INF") == 0) continue; // don't allow duplicate entries if (zipFileContents.get(entryName) != null) continue; zipFileContents.put(entryName, new Object()); ZipEntry entree = new ZipEntry(entryName); zos.putNextEntry(entree); byte buffer[] = new byte[(int) entry.getSize()]; InputStream is = file.getInputStream(entry); int offset = 0; int remaining = buffer.length; while (remaining > 0) { int count = is.read(buffer, offset, remaining); offset += count; remaining -= count; } zos.write(buffer); zos.flush(); zos.closeEntry(); } } } catch (IOException e) { System.err.println("Error in file " + pieces[i]); e.printStackTrace(); } } else { // not a .jar or .zip, prolly a directory File dir = new File(pieces[i]); // but must be a dir, since it's one of several paths // just need to check if it exists if (dir.exists()) { packClassPathIntoZipFileRecursive(dir, null, zos); } } } } /** * Continue the process of magical exporting. This function * can be called recursively to walk through folders looking * for more goodies that will be added to the ZipOutputStream. */ static protected void packClassPathIntoZipFileRecursive(File dir, String sofar, ZipOutputStream zos) throws IOException { String files[] = dir.list(); for (int i = 0; i < files.length; i++) { // ignore . .. and .DS_Store if (files[i].charAt(0) == '.') continue; File sub = new File(dir, files[i]); String nowfar = (sofar == null) ? files[i] : (sofar + "/" + files[i]); if (sub.isDirectory()) { packClassPathIntoZipFileRecursive(sub, nowfar, zos); } else { // don't add .jar and .zip files, since they only work // inside the root, and they're unpacked if (!files[i].toLowerCase().endsWith(".jar") && !files[i].toLowerCase().endsWith(".zip") && files[i].charAt(0) != '.') { ZipEntry entry = new ZipEntry(nowfar); zos.putNextEntry(entry); zos.write(Base.loadBytesRaw(sub)); zos.closeEntry(); } } } } /** * Make sure the sketch hasn't been moved or deleted by some * nefarious user. If they did, try to re-create it and save. * Only checks to see if the main folder is still around, * but not its contents. */ protected void ensureExistence() { if (folder.exists()) return; Base.showWarning("Sketch Disappeared", "The sketch folder has disappeared.\n " + "Will attempt to re-save in the same location,\n" + "but anything besides the code will be lost.", null); try { folder.mkdirs(); modified = true; for (int i = 0; i < codeCount; i++) { code[i].save(); // this will force a save } calcModified(); } catch (Exception e) { Base.showWarning("Could not re-save sketch", "Could not properly re-save the sketch. " + "You may be in trouble at this point,\n" + "and it might be time to copy and paste " + "your code to another text editor.", e); } } /** * Returns true if this is a read-only sketch. Used for the * examples directory, or when sketches are loaded from read-only * volumes or folders without appropriate permissions. */ public boolean isReadOnly() { String apath = folder.getAbsolutePath(); if (apath.startsWith(Base.getExamplesPath()) || apath.startsWith(Base.getLibrariesPath())) { return true; // canWrite() doesn't work on directories //} else if (!folder.canWrite()) { } else { // check to see if each modified code file can be written to for (int i = 0; i < codeCount; i++) { if (code[i].isModified() && code[i].fileReadOnly() && code[i].fileExists()) { //System.err.println("found a read-only file " + code[i].file); return true; } } //return true; } return false; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // Breaking out extension types in order to clean up the code, and make it // easier for other environments (like Arduino) to incorporate changes. /** * True if the specified extension should be hidden when shown on a tab. * For Processing, this is true for .pde files. (Broken out for subclasses.) */ public boolean hideExtension(String what) { return what.equals(getDefaultExtension()); } /** * True if the specified code has the default file extension. */ public boolean hasDefaultExtension(SketchCode code) { return code.getExtension().equals(getDefaultExtension()); } /** * True if the specified extension is the default file extension. */ public boolean isDefaultExtension(String what) { return what.equals(getDefaultExtension()); } /** * Check this extension (no dots, please) against the list of valid * extensions. */ public boolean validExtension(String what) { String[] ext = getExtensions(); for (int i = 0; i < ext.length; i++) { if (ext[i].equals(what)) return true; } return false; } /** * Returns the default extension for this editor setup. */ public String getDefaultExtension() { return "pde"; } /** * Returns a String[] array of proper extensions. */ public String[] getExtensions() { return new String[] { "pde", "java" }; } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // Additional accessors added in 0136 because of package work. // These will also be helpful for tool developers. /** * Returns the name of this sketch. (The pretty name of the main tab.) */ public String getName() { return name; } /** * Returns a file object for the primary .pde of this sketch. */ public File getPrimaryFile() { return primaryFile; } /** * Returns path to the main .pde file for this sketch. */ public String getMainFilePath() { return primaryFile.getAbsolutePath(); //return code[0].file.getAbsolutePath(); } /** * Returns the sketch folder. */ public File getFolder() { return folder; } /** * Returns the location of the sketch's data folder. (It may not exist yet.) */ public File getDataFolder() { return dataFolder; } /** * Create the data folder if it does not exist already. As a convenience, * it also returns the data folder, since it's likely about to be used. */ public File prepareDataFolder() { if (!dataFolder.exists()) { dataFolder.mkdirs(); } return dataFolder; } /** * Returns the location of the sketch's code folder. (It may not exist yet.) */ public File getCodeFolder() { return codeFolder; } /** * Create the code folder if it does not exist already. As a convenience, * it also returns the code folder, since it's likely about to be used. */ public File prepareCodeFolder() { if (!codeFolder.exists()) { codeFolder.mkdirs(); } return codeFolder; } public String getClassPath() { return classPath; } public String getLibraryPath() { return libraryPath; } public SketchCode[] getCode() { return code; } public int getCodeCount() { return codeCount; } public SketchCode getCode(int index) { return code[index]; } public int getCodeIndex(SketchCode who) { for (int i = 0; i < codeCount; i++) { if (who == code[i]) { return i; } } return -1; } public SketchCode getCurrentCode() { return current; } public void setUntitled(boolean u) { editor.untitled = u; } public boolean isUntitled() { return editor.untitled; } public String getAppletClassName2() { return appletClassName; } // ................................................................. /** * Convert to sanitized name and alert the user * if changes were made. */ static public String checkName(String origName) { String newName = sanitizeName(origName); if (!newName.equals(origName)) { String msg = "The sketch name had to be modified. Sketch names can only consist\n" + "of ASCII characters and numbers (but cannot start with a number).\n" + "They should also be less less than 64 characters long."; System.out.println(msg); } return newName; } /** * Return true if the name is valid for a Processing sketch. */ static public boolean isSanitaryName(String name) { return sanitizeName(name).equals(name); } /** * Produce a sanitized name that fits our standards for likely to work. * <p/> * Java classes have a wider range of names that are technically allowed * (supposedly any Unicode name) than what we support. The reason for * going more narrow is to avoid situations with text encodings and * converting during the process of moving files between operating * systems, i.e. uploading from a Windows machine to a Linux server, * or reading a FAT32 partition in OS X and using a thumb drive. * <p/> * This helper function replaces everything but A-Z, a-z, and 0-9 with * underscores. Also disallows starting the sketch name with a digit. */ static public String sanitizeName(String origName) { char c[] = origName.toCharArray(); StringBuffer buffer = new StringBuffer(); // can't lead with a digit, so start with an underscore if ((c[0] >= '0') && (c[0] <= '9')) { buffer.append('_'); } for (int i = 0; i < c.length; i++) { if (((c[i] >= '0') && (c[i] <= '9')) || ((c[i] >= 'a') && (c[i] <= 'z')) || ((c[i] >= 'A') && (c[i] <= 'Z'))) { buffer.append(c[i]); } else { buffer.append('_'); } } // let's not be ridiculous about the length of filenames. // in fact, Mac OS 9 can handle 255 chars, though it can't really // deal with filenames longer than 31 chars in the Finder. // but limiting to that for sketches would mean setting the // upper-bound on the character limit here to 25 characters // (to handle the base name + ".class") if (buffer.length() > 63) { buffer.setLength(63); } return buffer.toString(); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
a228ec68581971c8e936517a253074ab918b6376
dc1dbb7e5a4b95bf44170d2f51fd08b3814f2ac9
/data_defect4j/preprossed_method_corpus/Chart/4/org/jfree/chart/renderer/xy/StackedXYAreaRenderer_clone_640.java
0f9354ace1f2b77d444a88d9cd3b3ec23abad160
[]
no_license
hvdthong/NetML
dca6cf4d34c5799b400d718e0a6cd2e0b167297d
9bb103da21327912e5a29cbf9be9ff4d058731a5
refs/heads/master
2021-06-30T15:03:52.618255
2020-10-07T01:58:48
2020-10-07T01:58:48
150,383,588
1
1
null
2018-09-26T07:08:45
2018-09-26T07:08:44
null
UTF-8
Java
false
false
1,308
java
org jfree chart render stack area render link plot xyplot shown gener code stack area render demo1 stackedxyarearendererdemo1 java code program includ free chart jfreechart demo collect img src imag stack area render sampl stackedxyarearenderersampl png alt stack area render sampl stackedxyarearenderersampl png special note render handl neg data valu correctli fix point current workaround link stack area renderer2 stackedxyarearenderer2 stack area render stackedxyarearender area render xyarearender return clone render clone clone support except clonenotsupportedexcept render clone object clone clone support except clonenotsupportedexcept clone
[ "hvdthong@gmail.com" ]
hvdthong@gmail.com
1c10fb4a6205684dbeb0e3b3a26bb4f4c6ef76e9
39390e1c0bf53d7f2e44b5242f1fb2b47300aaf7
/trunk/EZMIS/jteap-gcht/com/jteap/gcht/gcxmgl/manager/GclxcxManager.java
114380fd2c7f274ec661100d0e7b78aff67b2199
[]
no_license
BGCX067/ezmis-svn-to-git
3e061173c86055de6a1c0204271b3d3276cea7cf
24b15ab52a8d750a0ce782a6b64226583c859e03
refs/heads/master
2021-01-11T11:08:51.702990
2015-12-28T14:08:08
2015-12-28T14:08:08
48,874,376
0
1
null
null
null
null
UTF-8
Java
false
false
295
java
package com.jteap.gcht.gcxmgl.manager; import com.jteap.core.dao.HibernateEntityDao; import com.jteap.gcht.gcxmgl.model.Wtd; /** * @author 王艺 * @version 创建时间:Jun 14, 2012 2:06:38 AM * 类说明 */ public class GclxcxManager extends HibernateEntityDao<Wtd>{ }
[ "you@example.com" ]
you@example.com
b2cce7c3a2751c9d97de386a789260000540367a
aa5b628458970c39025d50709d6fbb0fc55e969f
/src/main/java/com/togogotrain/moumoubicycle/entity/Admin.java
9f04abf4f65e252b824825156785c0d1285a2edf
[]
no_license
mizzzzzz/moumoubicycle
40c0d89ca5ea848b02696d24e9f6542cdab3474b
98642fd43e2c16c2f9d6b6fa7dd7eaf0fd4c86a2
refs/heads/master
2020-04-01T00:31:09.819810
2018-10-16T14:23:23
2018-10-16T14:23:23
152,700,310
0
0
null
2018-10-15T12:14:30
2018-10-12T05:51:03
Java
UTF-8
Java
false
false
2,436
java
package com.togogotrain.moumoubicycle.entity; public class Admin { /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column admin.id * * @mbg.generated */ private Long id; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column admin.password * * @mbg.generated */ private String password; /** * * This field was generated by MyBatis Generator. * This field corresponds to the database column admin.name * * @mbg.generated */ private String name; /** * This method was generated by MyBatis Generator. * This method returns the value of the database column admin.id * * @return the value of admin.id * * @mbg.generated */ public Long getId() { return id; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column admin.id * * @param id the value for admin.id * * @mbg.generated */ public void setId(Long id) { this.id = id; } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column admin.password * * @return the value of admin.password * * @mbg.generated */ public String getPassword() { return password; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column admin.password * * @param password the value for admin.password * * @mbg.generated */ public void setPassword(String password) { this.password = password == null ? null : password.trim(); } /** * This method was generated by MyBatis Generator. * This method returns the value of the database column admin.name * * @return the value of admin.name * * @mbg.generated */ public String getName() { return name; } /** * This method was generated by MyBatis Generator. * This method sets the value of the database column admin.name * * @param name the value for admin.name * * @mbg.generated */ public void setName(String name) { this.name = name == null ? null : name.trim(); } }
[ "627833449@qq.com" ]
627833449@qq.com
df81c0fbc20762f354390dbb213049d3a5705144
c5192d0d7f86145381381e90d15b6fa9b481fed6
/src/chatroom/Message.java
7c0f8ed73e74fbf51fc3983e58a1db54b89ca99f
[]
no_license
EthanCampana/Chatroom
f2baa99ee6ca2b3408126afbf0594d973d649f1a
d7ef4222a297c3390d26d32e22668efb12366142
refs/heads/master
2020-04-15T13:54:46.635340
2019-01-08T21:54:14
2019-01-08T21:54:14
164,736,145
0
0
null
null
null
null
UTF-8
Java
false
false
536
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 chatroom; /** * * @author ecampana */ public class Message { private String Message; public void sendMessage(String Message){ this.Message = Message; } public String ReceiveMessage(){ return this.Message; } }
[ "34409462+EthanCampana@users.noreply.github.com" ]
34409462+EthanCampana@users.noreply.github.com
01b2abc819e89a982587fa3ea68bf6398d451a4f
c0a21fa8664c80cc774488f315d344e96d197b9d
/OnetoOneUsingSpringBoot/src/main/java/com/onetoone/dao/LaptopDao.java
a85eda5f98684e619af9c765d1443d3534ce6efc
[]
no_license
Srinivasarao9160/SpringProgs
73e33d3e16c047c781883dff32985e1f2e60b6a7
a08e5c0607415552061868145a8838f1c6a239c2
refs/heads/master
2023-04-20T22:22:14.725348
2021-05-11T12:43:58
2021-05-11T12:43:58
366,374,773
0
0
null
null
null
null
UTF-8
Java
false
false
246
java
package com.onetoone.dao; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.onetoone.model.Laptop; public interface LaptopDao extends JpaRepository<Laptop, Integer> { }
[ "gandhamsrinu9@gmail.com" ]
gandhamsrinu9@gmail.com
04c691b6218af42f8c54e216ce1990a12ce62475
b19ce3ab28cf34d106478b765590de576ced0019
/AulaPOO6/src/aulapoo6/AulaPOO6.java
9c6b83d8e06fb4267f59b011804f1bcb9e0d10a9
[]
no_license
liaoliveiralps/projeto-net-beans-curso-em-video
a14d3b1d671bdf50b9b252ed6c7894b45a91c851
8d0faf77fd089fb46d26cc5dc827ec6e7b2835bc
refs/heads/main
2023-02-26T07:54:00.427213
2021-02-01T16:12:18
2021-02-01T16:12:18
335,006,398
0
0
null
null
null
null
UTF-8
Java
false
false
218
java
package aulapoo6; public class AulaPOO6 { public static void main(String[] args) { ControleRemoto c = new ControleRemoto(); c.ligar(); c.menosVolume(); c.abrirMenu(); } }
[ "liaoliveiralps@gmail.com" ]
liaoliveiralps@gmail.com
e92cd72937c93274a381fe878f60ee5c87c5bc77
de2712b8c4789b5f2043588dc3c8e125b13959bb
/app/src/main/java/halo/com/moneytracker/database/IExchangeManager.java
7559261cc8b36000f93abd5f886eb9489ab980b4
[]
no_license
tankorbox/MoneyTracker
9a7a47b2b5ba5e2638e235a67d0fc3d6073162bb
65c84fea355c1f7476967066fde8390dff936641
refs/heads/master
2021-08-07T04:13:36.622177
2017-11-07T13:27:31
2017-11-07T13:27:31
109,839,166
0
0
null
null
null
null
UTF-8
Java
false
false
550
java
package halo.com.moneytracker.database; import java.util.Date; import java.util.List; import halo.com.moneytracker.models.Exchange; /** * Created by HoVanLy on 7/27/2016. */ public interface IExchangeManager { void addOrUpdateExchange(Exchange exchange); List<Exchange> getExchangeYears(int year); List<Exchange> getExchangeMonths(int month, int year); List<Exchange> getExchangeDays(Date date); List<Exchange> getExchangesPlan(); long getMoneyTotal(List<Exchange> exchanges); void deleteExchange(String id); }
[ "tankorbox@gmail.com" ]
tankorbox@gmail.com
b817a860236e6bdfd415a726fdb2e970c7a45aa0
b35aef1f063e8d3e1b2e3ce351c7316086628d6c
/src/main/java/puzzles/poj/InsertSort.java
e051ef49149f1a5d1528549c7102a4cb4f50aeff
[]
no_license
Zhouchuanwen/algorithm4rdEdtion
eceb974cf2b301788648cbcfb572912796704d6b
d83911f365b64eb0b5cec10a8d6a02a957bb6f36
refs/heads/master
2020-07-26T21:48:55.724127
2017-03-12T07:40:25
2017-03-12T07:40:25
73,713,195
0
0
null
null
null
null
UTF-8
Java
false
false
484
java
package puzzles.poj; /** * Created by alan on 17/1/19. */ public class InsertSort { /** * 插入排序 * @param arr */ public static void insert(int arr[]){ int len=arr.length; int target; int j; for(int i=1;i<len;i++){ j=i; target=arr[i]; while (j>0 && target<arr[j-1]){ arr[j]=arr[j-1]; j--; } arr[j]=target; } } }
[ "2194999896@qq.com" ]
2194999896@qq.com
9824ff84ec57ed05a4cf069122d030f2ad3c3043
ca436b5501f1aa536e76ef1ce760c063f5149c85
/sgc/src/main/java/edu/uabc/app/service/DocumentosActualizarServiceJPA.java
46cc048b075b1340cfe1218b82b1d5f93ace3e0a
[]
no_license
LuisLalo/sgc
f698864bb23ab7a741a0a72a7cf2b09f6db63ff4
8e4f7d66dc49ae5418cf30c87791d2a716f555f1
refs/heads/master
2022-12-24T13:55:56.097323
2019-02-16T02:16:35
2019-02-16T02:16:35
170,736,717
0
0
null
null
null
null
UTF-8
Java
false
false
1,173
java
package edu.uabc.app.service; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import edu.uabc.app.model.DocumentoActualizar; import edu.uabc.app.repository.DocumentosActualizarRepository; @Service public class DocumentosActualizarServiceJPA implements IDocumentosActualizarService{ @Autowired private DocumentosActualizarRepository documentosActualizarRepo; @Override public void insertar(DocumentoActualizar documentoActualizar) { documentosActualizarRepo.save(documentoActualizar); } @Override public List<DocumentoActualizar> buscarTodas() { List<DocumentoActualizar> lista = documentosActualizarRepo.findAll(); return lista; } @Override public DocumentoActualizar buscarPorId(int id_documento) { Optional<DocumentoActualizar> optional = documentosActualizarRepo.findById(id_documento); if(optional.isPresent()) { return optional.get(); } return null; } @Override public void eliminar(int id_documento) { documentosActualizarRepo.deleteById(id_documento); } }
[ "UABC-16653387@UABC16653387" ]
UABC-16653387@UABC16653387
16993894a511014c3c8c5677adfaab954bb3a6da
1fdfe63dc42d0a83a643b233d59fec081be57fa1
/Java/Uri1059.java
0f9143ea1dcdc1179ed92239b273075a29c472d4
[]
no_license
brunoguerra86/urionline
ee533e0a8efe61056275eee7d567c1c78962b6f9
b7075a329695a12603129a6d471e3bff5b37dcb6
refs/heads/master
2023-07-17T12:22:48.975281
2021-08-19T23:59:41
2021-08-19T23:59:41
303,486,071
0
0
null
null
null
null
UTF-8
Java
false
false
151
java
public class Uri1059 { public static void main(String args[]) { for (int x = 2; x <= 100; x=x+2) System.out.println(x); } }
[ "brunoguerra@hotmail.com" ]
brunoguerra@hotmail.com
88694e822f7e5bdf806849a53b74e6df6c4609ad
1a98aaf1f74d11278fc85ea241abe4b5736a9854
/hybris/custom/shopping/shoppingfacades/src/com/shopping/facades/process/email/context/CustomerEmailContext.java
03be436569c1823bde27bff2ca8387888dbfe675
[]
no_license
ram0996/Ram
e85fc5de1945fed2835232bfed8f3cdd3144877d
2f1669207d691655e1c54768e03ac5bb24581afb
refs/heads/master
2022-04-28T06:22:56.611584
2022-03-22T03:13:43
2022-03-22T03:13:43
94,010,826
0
0
null
2022-03-22T03:15:24
2017-06-11T14:43:40
Java
UTF-8
Java
false
false
2,210
java
/* * Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. */ package com.shopping.facades.process.email.context; import de.hybris.platform.acceleratorservices.model.cms2.pages.EmailPageModel; import de.hybris.platform.acceleratorservices.process.email.context.AbstractEmailContext; import de.hybris.platform.basecommerce.model.site.BaseSiteModel; import de.hybris.platform.commercefacades.user.data.CustomerData; import de.hybris.platform.commerceservices.model.process.StoreFrontCustomerProcessModel; import de.hybris.platform.core.model.c2l.LanguageModel; import de.hybris.platform.core.model.user.CustomerModel; import de.hybris.platform.core.model.user.UserModel; import de.hybris.platform.servicelayer.dto.converter.Converter; import org.springframework.beans.factory.annotation.Required; /** * Velocity context for a customer email. */ public class CustomerEmailContext extends AbstractEmailContext<StoreFrontCustomerProcessModel> { private Converter<UserModel, CustomerData> customerConverter; private CustomerData customerData; @Override public void init(final StoreFrontCustomerProcessModel storeFrontCustomerProcessModel, final EmailPageModel emailPageModel) { super.init(storeFrontCustomerProcessModel, emailPageModel); customerData = getCustomerConverter().convert(getCustomer(storeFrontCustomerProcessModel)); } @Override protected BaseSiteModel getSite(final StoreFrontCustomerProcessModel storeFrontCustomerProcessModel) { return storeFrontCustomerProcessModel.getSite(); } @Override protected CustomerModel getCustomer(final StoreFrontCustomerProcessModel storeFrontCustomerProcessModel) { return storeFrontCustomerProcessModel.getCustomer(); } protected Converter<UserModel, CustomerData> getCustomerConverter() { return customerConverter; } @Required public void setCustomerConverter(final Converter<UserModel, CustomerData> customerConverter) { this.customerConverter = customerConverter; } public CustomerData getCustomer() { return customerData; } @Override protected LanguageModel getEmailLanguage(final StoreFrontCustomerProcessModel businessProcessModel) { return businessProcessModel.getLanguage(); } }
[ "venkat05.hybris@gmail.com" ]
venkat05.hybris@gmail.com
ca2911aacc4c5813a492e6b97601cb0c1d228897
2ab0c2a013b0aab91335150bf3d621d175b0e12c
/TutorialsPoint/01_Turorial/14_Date_Time/14-03_DateFormating_Using_printf/DateDemo.java
0a2a72a531f9d7be6e59633512dd54257c747c4f
[]
no_license
Tao4free/Java
489c5d70ab5426ec8cdb0093bef5d35e09a4d56a
a29d466d32c64b640981b446d9011fb4b22e9e33
refs/heads/master
2021-06-23T16:14:09.894724
2020-11-26T08:31:23
2020-11-26T08:31:23
166,929,332
0
0
null
null
null
null
UTF-8
Java
false
false
558
java
import java.util.*; public class DateDemo { public static void main(String[] args) { // Instantiate a Date object Date date = new Date(); // Display time and date String str = String.format("Current Date/Time : %tc", date); System.out.println(str); // Display time and date System.out.printf("%1$s %2$tB %2$td %2$tY\n", "Due date:", date); // Display time and date System.out.printf("%s %tB %<te %<tY\n", "Due date:", date); } }
[ "tao@tao.my.domain" ]
tao@tao.my.domain
9e2c263c3da067f3b327d614a798def752c1cbcc
7200bf3418dc1ea12d27b12589a39c4844d6474a
/oauth2-jwt-server/src/main/java/com/springcloud/oauth2jwtserver/Oauth2JwtServerApplication.java
fcec316a848a9e19a0f1fd7c83eecbc31e270594
[]
no_license
sx19990201/SpringCloudDemo
b001e03b9b04c1913285b1486189bef799827026
7c3f7b2ea634d2aeef21b5fef8cc9b815c9498d6
refs/heads/master
2022-11-24T04:23:10.144303
2020-08-03T10:03:58
2020-08-03T10:03:58
284,659,663
0
0
null
null
null
null
UTF-8
Java
false
false
354
java
package com.springcloud.oauth2jwtserver; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Oauth2JwtServerApplication { public static void main(String[] args) { SpringApplication.run(Oauth2JwtServerApplication.class, args); } }
[ "root" ]
root
47e619d08ac63624cc9e868e148dad8549709cd1
53927664a93c13e7f52084b1e0f1b8e78334e0cc
/src/main/java/org/fkit/controller/NoticeController.java
5eea80a9f9beabba820aea7779069ceed883845b
[]
no_license
lijintaowkd/assm
8c43bd76dd2d8d0563cbf9e5373ca72e07a44e30
41e6d6fa9bf5a0b73ee72ce3119ec8744fd5942a
refs/heads/mast
2021-07-21T00:14:57.826817
2017-10-29T12:05:27
2017-10-29T12:05:27
97,073,688
0
0
null
2017-07-13T07:22:51
2017-07-13T02:55:33
Java
UTF-8
Java
false
false
3,773
java
package org.fkit.controller; import java.util.List; import javax.servlet.http.HttpSession; import org.fkit.domain.Notice; import org.fkit.domain.User; import org.fkit.service.HrmService; import org.fkit.util.common.HrmConstants; import org.fkit.util.tag.PageModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; @Controller public class NoticeController { /** * 自动注入UserService * */ @Autowired @Qualifier("hrmService") private HrmService hrmService; /** * 处理/login请求 * */ @RequestMapping(value="/notice/selectNotice") public String selectNotice(Model model,Integer pageIndex, @ModelAttribute Notice notice){ PageModel pageModel = new PageModel(); if(pageIndex != null){ pageModel.setPageIndex(pageIndex); } /** 查询用户信息 */ List<Notice> notices = hrmService.findNotice(notice, pageModel); model.addAttribute("notices", notices); model.addAttribute("pageModel", pageModel); return "notice/notice"; } /** * 处理添加请求 * @param Integer id 要显示的公告id * @param Model model * */ @RequestMapping(value="/notice/previewNotice") public String previewNotice( Integer id,Model model){ Notice notice = hrmService.findNoticeById(id); model.addAttribute("notice", notice); // 返回 return "notice/previewNotice"; } /** * 处理删除公告请求 * @param String ids 需要删除的id字符串 * @param ModelAndView mv * */ @RequestMapping(value="/notice/removeNotice") public ModelAndView removeNotice(String ids,ModelAndView mv){ // 分解id字符串 String[] idArray = ids.split(","); for(String id : idArray){ // 根据id删除公告 hrmService.removeNoticeById(Integer.parseInt(id)); } // 设置客户端跳转到查询请求 mv.setViewName("redirect:/notice/selectNotice"); // 返回ModelAndView return mv; } /** * 处理添加请求 * @param String flag 标记, 1表示跳转到添加页面,2表示执行添加操作 * @param Notice notice 要添加的公告对象 * @param ModelAndView mv * */ @RequestMapping(value="/notice/addNotice") public ModelAndView addNotice( String flag, @ModelAttribute Notice notice, ModelAndView mv, HttpSession session){ if(flag.equals("1")){ mv.setViewName("notice/showAddNotice"); }else{ User user = (User) session.getAttribute(HrmConstants.USER_SESSION); notice.setUser(user); hrmService.addNotice(notice); mv.setViewName("redirect:/notice/selectNotice"); } // 返回 return mv; } /** * 处理添加请求 * @param String flag 标记, 1表示跳转到修改页面,2表示执行修改操作 * @param Notice notice 要添加的公告对象 * @param ModelAndView mv * */ @RequestMapping(value="/notice/updateNotice") public ModelAndView updateNotice( String flag, @ModelAttribute Notice notice, ModelAndView mv, HttpSession session){ if(flag.equals("1")){ Notice target = hrmService.findNoticeById(notice.getId()); mv.addObject("notice",target); mv.setViewName("notice/showUpdateNotice"); }else{ hrmService.modifyNotice(notice); mv.setViewName("redirect:/notice/selectNotice"); } // 返回 return mv; } }
[ "269500571@qq.com" ]
269500571@qq.com
95e6132af37cf17a2e077d6fc1b75ec227ba4a5c
8cd91b28a17be84a5bad5e1955e949c787af6e60
/day04_account_aop_txanno/src/main/java/com/itheima/service/impl/AccountServiceImpl.java
c0de6551202a556125a4247b1774f43edf5834fd
[]
no_license
cbxazm/ideaProject
79c1cd5ce35463b1b8327b813aa8dc2625726135
56c8a6f9682d16654d982f2e58621f707b6e4cfa
refs/heads/master
2022-12-24T08:55:58.738104
2019-12-28T05:32:17
2019-12-28T05:32:17
230,563,266
0
0
null
2022-12-15T23:46:02
2019-12-28T05:29:59
Java
UTF-8
Java
false
false
1,756
java
package com.itheima.service.impl; import com.itheima.dao.IAccountDao; import com.itheima.domain.Account; import com.itheima.service.IAccountService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * 账户的业务层实现类 * * 事务控制应该都是在业务层 */ @Service("accountService") public class AccountServiceImpl implements IAccountService{ @Autowired private IAccountDao accountDao; public List<Account> findAllAccount() { return accountDao.findAllAccount(); } public Account findAccountById(Integer accountId) { return accountDao.findAccountById(accountId); } public void saveAccount(Account account) { accountDao.saveAccount(account); } public void updateAccount(Account account) { accountDao.updateAccount(account); } public void deleteAccount(Integer acccountId) { accountDao.deleteAccount(acccountId); } public void transfer(String sourceName, String targetName, Float money) { System.out.println("transfer...."); //2.1根据名称查询转出账户 Account source = accountDao.findAccountByName(sourceName); //2.2根据名称查询转入账户 Account target = accountDao.findAccountByName(targetName); //2.3转出账户减钱 source.setMoney(source.getMoney()-money); //2.4转入账户加钱 target.setMoney(target.getMoney()+money); //2.5更新转出账户 accountDao.updateAccount(source); // int i=1/0; //2.6更新转入账户 accountDao.updateAccount(target); } }
[ "895001956@qq.com" ]
895001956@qq.com
d33f1e5fedef42fdea79ee88731caad11dcc4dc8
0e6cce5936e71c3548e538d37c574e191942c29b
/courseselect/src/net/xinqushi/common/QueryUtil.java
5631d6170363cf1753bb8bcf1cfee59543d49589
[]
no_license
yangli1168/accumulation
6294b585e949a5fc06f4fc1a38ba69c246f96b5d
2149a2fb6b76703fa7b234416e3afe8727461e8f
refs/heads/master
2020-04-06T04:43:01.021257
2017-07-31T03:04:05
2017-07-31T03:04:05
82,884,507
1
0
null
null
null
null
UTF-8
Java
false
false
481
java
package net.xinqushi.common; import org.hibernate.Query; import org.hibernate.Session; public class QueryUtil { public static Object getInfo(String hql, Object object){ Session session = HibernateUtil.openSession(); Query query = session.createQuery(hql).setProperties(object); session.beginTransaction(); object = null; if (query.list().size() > 0) { object = query.list().get(0); } session.getTransaction().commit(); session.close(); return object; } }
[ "350895216@qq.com" ]
350895216@qq.com
ce5fc2fa294287d0a5bf26cd84d308cf4e256c5f
727a1c38e65d9ffea086a2ba6d8c0da6f22f569a
/factory-method/src/main/java/com/yz/factory/method/Blacksmith.java
a1963e6da6fd996a52b5c35f6108d054c4fb5232
[]
no_license
leopard5/yz-design-patterns
e1a2d6cecea910e07540908d30b9d69effaedb2d
10514d809dab4a3473d91953a0928d9f8cf07821
refs/heads/master
2020-07-12T21:07:20.988027
2018-05-22T08:41:22
2018-05-22T08:41:22
94,283,863
1
0
null
null
null
null
UTF-8
Java
false
false
191
java
package com.yz.factory.method; /** * * The interface containing method for producing objects. * */ public interface Blacksmith { Weapon manufactureWeapon(WeaponType weaponType); }
[ "yazhong.qi@chinaredstar.com" ]
yazhong.qi@chinaredstar.com
00127cff007bb8fd17d66dad03f082771f9aa4cd
4a17741c3ed2dd723793dbdc990b01562bc9b10f
/DesignPatternsExercisesSolutions/src/com/orangeandbronze/strategy/alt/StudentService.java
8f857b4e57624a68bc87ffeb3c4e313826b66f05
[]
no_license
hukai9200/design-patterns-exercises
842612e4c37fe517fc68d69a0702c7e14e20cd5e
f64070fa3630b14b4fc36daf178e25d277a214eb
refs/heads/master
2021-01-08T06:21:28.526534
2014-07-21T22:55:10
2014-07-21T22:55:10
241,939,552
1
0
null
2020-02-20T16:56:40
2020-02-20T16:56:39
null
UTF-8
Java
false
false
376
java
package com.orangeandbronze.strategy.alt; import java.io.File; import java.util.List; /** * Use the Strategy pattern by adding a setter or constructor * that passes in the proper strategy for parsing * the file format */ public class StudentService { List<Student> getStudents(File file, FileFormat format) throws Exception { return format.unmarshal(file); } }
[ "calen@orangeandbronze.com" ]
calen@orangeandbronze.com
2c2d182dfc2030fc67de2b3f99316f9d4c56fc55
17233d2703ae21cb879b32cc71ee5d8949635a45
/src/main/java/com/mkm/springmvc/model/User.java
585dfe48970ef689b86a0c4d5b1e8826508b1a74
[]
no_license
mkm1997/spring-boot-mvc
443e1f41c1b4cc9199b74ba48b0f2b0d7b918a8e
4946de12d1aa09dc776f46c60cb7114059ad9d1e
refs/heads/main
2023-08-15T11:25:27.825457
2021-10-23T10:25:26
2021-10-23T10:25:26
400,077,631
0
0
null
null
null
null
UTF-8
Java
false
false
825
java
package com.mkm.springmvc.model; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class User { @Id private Long id; private String username; private String password; public User() { } public User(Long id, String username, String password) { this.id = id; this.username = username; this.password = password; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
[ "manismishra@paypal.com" ]
manismishra@paypal.com
3a51f7596c4ccb0715ae045a15023697737d8cb8
22267f91a967fdf4a998081b28a328c20d854c45
/src/nu/validator/datatype/AutocompleteDetailsAny.java
0c972a5b8140f332f6fde947158773b605ef487c
[ "MIT" ]
permissive
stevefaulkner/validator
30f747bd884f57d479e976ac760b0f38e06b846c
39263a6d2e10a039744417d89fd9df9596384780
refs/heads/master
2023-03-15T15:06:02.113075
2019-02-18T03:43:10
2019-02-18T03:43:10
172,508,582
1
0
MIT
2019-02-25T13:12:55
2019-02-25T13:12:54
null
UTF-8
Java
false
false
4,856
java
/* * Copyright (c) 2016 Mozilla Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ package nu.validator.datatype; import java.util.HashSet; public final class AutocompleteDetailsAny extends AbstractAutocompleteDetails { /** * The singleton instance. */ public static final AutocompleteDetailsAny THE_INSTANCE = new AutocompleteDetailsAny(); private AutocompleteDetailsAny() { super(); } private static final HashSet<String> allowedFieldnames = new HashSet<>(); private static final HashSet<String> allowedContactFieldnames = new HashSet<>(); static { allowedFieldnames.add("name"); allowedFieldnames.add("honorific-prefix"); allowedFieldnames.add("given-name"); allowedFieldnames.add("additional-name"); allowedFieldnames.add("family-name"); allowedFieldnames.add("honorific-suffix"); allowedFieldnames.add("nickname"); allowedFieldnames.add("organization-title"); allowedFieldnames.add("username"); allowedFieldnames.add("new-password"); allowedFieldnames.add("current-password"); allowedFieldnames.add("organization"); allowedFieldnames.add("street-address"); allowedFieldnames.add("address-line1"); allowedFieldnames.add("address-line2"); allowedFieldnames.add("address-line3"); allowedFieldnames.add("address-level4"); allowedFieldnames.add("address-level3"); allowedFieldnames.add("address-level2"); allowedFieldnames.add("address-level1"); allowedFieldnames.add("country"); allowedFieldnames.add("country-name"); allowedFieldnames.add("postal-code"); allowedFieldnames.add("cc-name"); allowedFieldnames.add("cc-given-name"); allowedFieldnames.add("cc-additional-name"); allowedFieldnames.add("cc-family-name"); allowedFieldnames.add("cc-number"); allowedFieldnames.add("cc-exp"); allowedFieldnames.add("cc-exp-month"); allowedFieldnames.add("cc-exp-year"); allowedFieldnames.add("cc-csc"); allowedFieldnames.add("cc-type"); allowedFieldnames.add("transaction-currency"); allowedFieldnames.add("transaction-amount"); allowedFieldnames.add("language"); allowedFieldnames.add("bday"); allowedFieldnames.add("bday-day"); allowedFieldnames.add("bday-month"); allowedFieldnames.add("bday-year"); allowedFieldnames.add("sex"); allowedFieldnames.add("url"); allowedFieldnames.add("photo"); allowedFieldnames.add("tel"); allowedFieldnames.add("tel-country-code"); allowedFieldnames.add("tel-national"); allowedFieldnames.add("tel-area-code"); allowedFieldnames.add("tel-local"); allowedFieldnames.add("tel-local-prefix"); allowedFieldnames.add("tel-local-suffix"); allowedFieldnames.add("tel-extension"); allowedFieldnames.add("email"); allowedFieldnames.add("impp"); allowedContactFieldnames.add("tel"); allowedContactFieldnames.add("tel-country-code"); allowedContactFieldnames.add("tel-national"); allowedContactFieldnames.add("tel-area-code"); allowedContactFieldnames.add("tel-local"); allowedContactFieldnames.add("tel-local-prefix"); allowedContactFieldnames.add("tel-local-suffix"); allowedContactFieldnames.add("tel-extension"); } @Override public HashSet<String> getAllowedFieldnames() { return allowedFieldnames; } @Override public HashSet<String> getAllowedContactFieldnames() { return allowedContactFieldnames; } @Override public String getName() { return "autocomplete detail tokens (any)"; } }
[ "mike@w3.org" ]
mike@w3.org
264f7e2ac60245065afb52a847ecbdb615b6ce5b
80217b8dbc784deb63c14065fdb89077f0ff032a
/src/test/java/com/hundsun/fintech/FintechApplicationTests.java
3c0ad1d0fda94ca70017d5b9abc96663bc63c847
[]
no_license
AtypicalCoder/fintech
dc03ad96dd73a66040f220e09bad002bc98aecb8
cbe0ef990f4f361acb7a7b1bc9c529509b40fb0c
refs/heads/master
2020-03-20T08:24:09.702601
2018-06-14T04:50:25
2018-06-14T04:50:25
137,307,687
0
0
null
null
null
null
UTF-8
Java
false
false
337
java
package com.hundsun.fintech; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class FintechApplicationTests { @Test public void contextLoads() { } }
[ "735181059@qq.com" ]
735181059@qq.com
1d9dee7e49e86326366aeecab43cf8a7295931e9
ac8e82c5260bd059dfc81d2f4e465164b3821801
/src/com/baloise/open/intellijstencil/completationProvider/IconUtil.java
bdf391e900d3e4d5d3d367fb495dc96708224f79
[ "MIT" ]
permissive
baloise/intellij-plugin-stencil-web-components
d18ab865f6e2d2f7e5d1a6555e03a3448fbd1c25
8582b9db063a8e07d983ee5d40084f3b109edc06
refs/heads/master
2020-09-09T14:00:34.095793
2019-12-06T13:43:02
2019-12-06T13:43:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
427
java
package com.baloise.open.intellijstencil.completationProvider; import com.intellij.codeInsight.lookup.LookupElementBuilder; import javax.swing.*; public class IconUtil { public static LookupElementBuilder addIcon(LookupElementBuilder lookupElement) { ImageIcon icon = new ImageIcon(IconUtil.class.getClassLoader().getResource("preview_icon.png").getFile()); return lookupElement.withIcon(icon); } }
[ "yannick@holzenkamp.me" ]
yannick@holzenkamp.me
4a4c165add6ac8cde2652eadf03ff9f34f1151b4
630184aa4fd1a56a8190229eb9c136b3fcba23c5
/DesignPattern/src/creationalPattern/abstractFactory/Tomato.java
def913bc685cd22f4bbc8c2d14ea177bf3f30299
[]
no_license
long-lang/DesignPattern
636806d33bf323b979b94d9fd4624386fba6ae81
2e4bd0d25ef10d63d2cad1eb3f8b54f3bc04f61f
refs/heads/master
2021-05-20T19:56:05.663609
2020-04-30T14:35:15
2020-04-30T14:35:15
252,398,556
0
0
null
null
null
null
UTF-8
Java
false
false
163
java
package creationalPattern.abstractFactory; public class Tomato extends Vegetable { public void create(){ System.out.println("create Tomato"); } }
[ "1065543493@qq.com" ]
1065543493@qq.com
add2b830a3bbff72cd411a8cbdc7fe136a1161da
b9e5f99d523f27d516dacb64efdcf1c386816a0f
/src/myrace/Participant.java
cd3ea4f6336e73711242536acc9995cf448c53bc
[]
no_license
nicolaslorenzo12/Race
0a1fcfb3a11826b30f9017d01a420d964a93fbbc
4a22605db3ad2bac2238d7b831c428e90df70c5a
refs/heads/main
2023-07-18T03:38:49.690137
2021-08-17T06:07:51
2021-08-17T06:07:51
395,602,364
0
0
null
null
null
null
UTF-8
Java
false
false
517
java
package myrace; public class Participant { private String name; private String lastName; private int status; public Participant(String name, String lastName){ this.name = name; this.lastName = lastName; } public String getStatus(int status){ this.status = status; String message = ""; if(status == 1){ message = "(Finisher)"; } else{ message = "(Not finisher)"; } return message; } }
[ "nicolaslorenzohermosilla@gmail.com" ]
nicolaslorenzohermosilla@gmail.com
904ce387f4505ab1ea8d137769296198edd7558e
7ec726373b8cbb764dfe098bf86c28685eae479f
/app/src/main/java/com/wwj/sb/activity/BaseActivity.java
ff032f2c600e807dca2e83c175a159917092a352
[]
no_license
XueBaoPeng/SimpleBeautyMusicPlayer
a41b4f7c3adec9344c315086f274196a46de9fcb
fe6bf796b6d181d264beb3d45e0f5868400572dc
refs/heads/master
2021-01-01T05:45:42.358164
2016-04-17T03:41:30
2016-04-17T03:41:30
56,417,545
0
0
null
null
null
null
UTF-8
Java
false
false
2,663
java
package com.wwj.sb.activity; import com.wwj.sb.adapter.MenuAdapter; import com.wwj.sb.utils.Settings; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.view.View; import android.view.WindowManager; public class BaseActivity extends Activity { public static final String BROADCASTRECEVIER_ACTON="com.wwj.music.commonrecevier"; private CommonRecevier commonRecevier; public float brightnesslevel=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置皮肤背景 Settings setting = new Settings(this, false); String brightness=setting.getValue(Settings.KEY_BRIGHTNESS); android.view.WindowManager.LayoutParams attributes = getWindow().getAttributes(); brightnesslevel=attributes.screenBrightness; if(brightness!=null&&brightness.equals("0")){//夜间模式 attributes.screenBrightness=Settings.KEY_DARKNESS; getWindow().setAttributes(attributes); } this.getWindow().setBackgroundDrawableResource( setting.getCurrentSkinResId()); commonRecevier=new CommonRecevier(); } /** * 设置正常模式和夜间模式 * */ public void setBrightness(View v) { Settings setting = new Settings(this, true); String brightness=setting.getValue(Settings.KEY_BRIGHTNESS); MenuAdapter.ViewHolder viewHolder=(MenuAdapter.ViewHolder)v.getTag(); WindowManager.LayoutParams attributes = getWindow().getAttributes(); if(brightness!=null&&brightness.equals("0")){//夜间模式 viewHolder.tv_title.setText(getResources().getString(R.string.darkness_title)); viewHolder.btn_menu.setBackgroundResource(R.drawable.btn_menu_darkness); attributes.screenBrightness=brightnesslevel; setting.setValue(Settings.KEY_BRIGHTNESS, "1"); getWindow().setAttributes(attributes); }else{//正常模式 viewHolder.tv_title.setText(getResources().getString(R.string.brightness_title)); viewHolder.btn_menu.setBackgroundResource(R.drawable.btn_menu_brightness); attributes.screenBrightness=Settings.KEY_DARKNESS; setting.setValue(Settings.KEY_BRIGHTNESS, "0"); getWindow().setAttributes(attributes); } } @Override protected void onStart() { super.onStart(); registerReceiver(commonRecevier, new IntentFilter(BROADCASTRECEVIER_ACTON)); } @Override protected void onStop() { super.onStop(); unregisterReceiver(commonRecevier); } public class CommonRecevier extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { finish(); } } }
[ "1971103949@qq.com" ]
1971103949@qq.com
74d89b5ca0f3a7b9caf343236bec1b167f4861d0
01b15b0fa554d431c26dd71185c5ee23dce0d850
/eureka-feign/src/test/java/org/lzhen/eurekafeign/EurekafeignApplicationTests.java
17e3886faa686a8ea3e171845206981b093dd156
[]
no_license
674728631/SpringCloudLearn
16889249750b5d3a3f5fbcd380ea8a927506dcec
211c8a00e70b952e2ad11d4dad39b50fe0c21f37
refs/heads/master
2020-04-14T20:20:35.275037
2019-01-16T01:51:11
2019-01-16T01:51:11
164,090,471
0
0
null
null
null
null
UTF-8
Java
false
false
344
java
package org.lzhen.eurekafeign; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class EurekafeignApplicationTests { @Test public void contextLoads() { } }
[ "13408458876@163.com" ]
13408458876@163.com
8cdf400797839435a559bb0ab5f07e50662b43fd
b5ba7a7f2aab92a36f0fc7b60e7cf297096dc6fa
/src/main/java/kts/project/service/PrivateAccountInCompanyService.java
048af160e297d1cb1ca3d99eb4d5cd6e867cf964
[]
no_license
amilivojevic/KTS-Real-Estate
ac1b151b88d9ce9c36f875f036e15f1a303a6f52
2804a426022e9e181c942efb6a205a870af3023e
refs/heads/master
2021-01-20T15:13:05.260561
2017-07-18T16:39:43
2017-07-18T16:39:43
90,736,827
0
0
null
null
null
null
UTF-8
Java
false
false
2,777
java
package kts.project.service; import kts.project.controller.dto.RegisterPrivateAccDTO; import kts.project.model.PrivateAccountInCompany; import kts.project.repository.PrivateAccountInCompanyRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** * This class represents Private Account in Company Service * */ @Service public class PrivateAccountInCompanyService { @Autowired PrivateAccountInCompanyRepository privateAccountInCompanyRepository; /** * This method is finding one Real Estate by its Id * @param id * @return RealEstate with specified id */ public PrivateAccountInCompany findById(Long id){ return privateAccountInCompanyRepository.findById(id); } /** * This method is finding all Private Accounts in Company * @return list of PrivateAccountInCompany */ public List<PrivateAccountInCompany> findAll(){ return privateAccountInCompanyRepository.findAll(); } /** * This method saves element to the database. * * @param p * element to be saved * @return Saved element */ public PrivateAccountInCompany save(PrivateAccountInCompany p){ return privateAccountInCompanyRepository.save(p); } /** * This method is checking if all required inputs for RegisterPrivateAccDTO are entered * @param registerPrivateAccDTO * @return true or false */ public boolean checkPrivateAccountInCompanyDTOInput(RegisterPrivateAccDTO registerPrivateAccDTO) { if (registerPrivateAccDTO == null) { return false; } if (registerPrivateAccDTO.getType().equals("") || registerPrivateAccDTO.getRole().equals("") || registerPrivateAccDTO.getUsername().equals("") || registerPrivateAccDTO.getPassword().equals("") || registerPrivateAccDTO.getEmail().equals("") || registerPrivateAccDTO.getName().equals("") || registerPrivateAccDTO.getSurname().equals("") || registerPrivateAccDTO.getBirthDate() == null || registerPrivateAccDTO.getPhoneNumber().equals("") || registerPrivateAccDTO.getAddress().equals("") || registerPrivateAccDTO.getCity().equals("") || registerPrivateAccDTO.getCountry().equals("") || registerPrivateAccDTO.getAccountNumber().equals("") || registerPrivateAccDTO.getImageUrl().equals("") || registerPrivateAccDTO.getCompanyId() < 0) { return false; } else { return true; } } }
[ "ninasimicns@gmail.com" ]
ninasimicns@gmail.com
ec462af8d6d85ecf45879ebbb200276b410898c0
834e62ccd183905ac635f3b56161634d8287280f
/Lab8/app/src/main/java/com/example/lab8/LuyenTap1.java
592626e6de3049e2d4397f6de1208915b6e5c9c7
[]
no_license
nhathuy157/Android
87a269f689a2b613ed65bf2335815e0191c39690
315400590f26707c0a96db0b3d2f219b365c2013
refs/heads/main
2023-08-21T01:48:19.252495
2021-10-19T04:42:49
2021-10-19T04:42:49
410,260,237
0
0
null
null
null
null
UTF-8
Java
false
false
1,801
java
package com.example.lab8; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; public class LuyenTap1 extends AppCompatActivity { String[] titles = new String[]{"Android","iOS","Window Phone"}; String[] contents = new String[]{"Đây là hệ điều hành Android", "Đây là hệ điều hành iOS", "Đây là hệ điều hành Window Phone"}; int[] imgs = new int[]{R.drawable.android,R.drawable.ios,R.drawable.windows_phone}; ListView lvMain; TextView txtDisplay; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_luyen_tap1); innitControl(); } private void innitControl(){ lvMain = findViewById(R.id.lvMain); txtDisplay = findViewById(R.id.txtDisplay); //ArrayAdapter<String> adapter = new ArrayAdapter<>(this, // android.R.layout.simple_list_item_1,arr); ArrayList<Product> list = new ArrayList<>(); for(int i=0; i< titles.length; i++){ list.add(new Product(imgs[i],titles[i],contents[i])); } MyListViewAdapter adapter = new MyListViewAdapter(list); lvMain.setAdapter(adapter); lvMain.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { txtDisplay.setText("Bạn chọn " + titles[i]); } }); } }
[ "nanhuycva01@gmail.com" ]
nanhuycva01@gmail.com
30d24ad15681826ce54ce8a71710b9c179355ff3
44c2b2dba38cb585a41fd030f1e2acd1fe53ed4e
/src/main/java/com/computershop/dao/product/Case.java
9a5550464b18fbf45f541a920eb9883261aa496e
[]
no_license
trongtuanit/ComputerShop_Server
18a4052dda40ac11e478ecdf87f062d31dc9a15f
bd73fda3915e5d5107f3181c600ad717cf380f3c
refs/heads/master
2023-07-23T22:11:38.288059
2021-08-21T06:14:18
2021-08-21T06:14:18
379,332,472
1
2
null
null
null
null
UTF-8
Java
false
false
2,598
java
package com.computershop.dao.product; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; import org.hibernate.annotations.Nationalized; import com.computershop.dao.Product; @Entity @Table(name = "Cases") public class Case extends Product { @Column(name = "dimensions") private String dimensions; @Column(name = "material") @Nationalized private String material; @Column(name = "type") @Nationalized private String type; @Column(name = "color") @Nationalized private String color; @Column(name = "weight") private String weight; @Column(name = "cooling_method") @Nationalized private String coolingMethod; public Case(Product product) { super(product.getId(), product.getName(), product.getBrand(), product.getProductImages(), product.getRatings(), product.getCategory(), product.getManufactures(), product.getDescription(), product.getPrice(), product.getSaleOff(), product.getAmount(), product.getQuantitySold(), product.getWarranty(), product.getCreateAt(), product.getUpdateAt(), product.getOrderItems()); } public Case(Product product, String dimensions, String material, String type, String color, String weight, String coolingMethod) { super(product.getId(), product.getName(), product.getBrand(), product.getProductImages(), product.getRatings(), product.getCategory(), product.getManufactures(), product.getDescription(), product.getPrice(), product.getSaleOff(), product.getAmount(), product.getQuantitySold(), product.getWarranty(), product.getCreateAt(), product.getUpdateAt(), product.getOrderItems()); this.dimensions = dimensions; this.material = material; this.type = type; this.color = color; this.weight = weight; this.coolingMethod = coolingMethod; } public Case() { super(); } public String getDimensions() { return dimensions; } public void setDimensions(String dimensions) { this.dimensions = dimensions; } public String getMaterial() { return material; } public void setMaterial(String material) { this.material = material; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public String getWeight() { return weight; } public void setWeight(String weight) { this.weight = weight; } public String getCoolingMethod() { return coolingMethod; } public void setCoolingMethod(String coolingMethod) { this.coolingMethod = coolingMethod; } }
[ "61158187+trongtuanit@users.noreply.github.com" ]
61158187+trongtuanit@users.noreply.github.com
d49634c384d9ee7ae54b23371cfd428f5b7c8e23
68271320eb9fe7d52570992af60ac7ae33305ee4
/methods/CommonMethods.java
0b4f3bf9972cfdaa50264268cd656c9cae6a3a37
[]
no_license
shaq5035/Seleuium
d00c7b5761b020ccb223d786e421ac361952928d
b0b0d72d668e82f2aee6a23d4d7810edaffe95eb
refs/heads/master
2020-05-29T10:20:07.610927
2019-05-28T20:08:02
2019-05-28T20:08:02
189,092,440
0
0
null
null
null
null
UTF-8
Java
false
false
2,192
java
package methods; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.Select; public class CommonMethods { public static WebDriver driver; public static void setUpDriver(String browser, String url) { if(browser.equalsIgnoreCase("chrome")) { System.setProperty("webdriver.chrome.driver", "src/driver/chromedriver"); driver=new ChromeDriver(); }else if (browser.equalsIgnoreCase("firefox")){ System.setProperty("webdriver.gecko.driver", "src/driver/geckodriver"); driver=new FirefoxDriver(); } else { System.out.println("browser given is wrong"); } driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); driver.manage().window().fullscreen(); driver.get(url); } public static void selectValueFromDD(WebElement element, String text) { Select select = new Select(element); List<WebElement> options = select.getOptions(); boolean isSelected=false; for (WebElement option : options) { String optionText = option.getText(); if (optionText.equals(text)) { select.selectByVisibleText(text); System.out.println("Option with text "+text+" is selected"); isSelected=true; break; } } if(!isSelected) { System.out.println("Option with text +"+text+"is not available"); } } public static void selectIndexValueFromDD(WebElement element, int index) { Select select = new Select(element); List<WebElement> options = select.getOptions(); for(WebElement option:options) { System.out.println(option.getText()); if (options.size() > index) { select.selectByIndex(index); }else { System.out.println("Invalid index has been passed"); } } } public static void sendText(WebElement element, String value) { element.clear(); element.sendKeys(value); } }
[ "shaq5035@gmail.com" ]
shaq5035@gmail.com
7fa98fa36508b6453fdbf2072dc477975b3c885c
b86f86816ec99ca2435171fb82e3dedb07fba76f
/src/main/java/com/eliasgago/geogson/writer/GalicianMunicipalityAreaGeojsonWriter.java
c0575848e6d5a32de982d04c40d3d75525741970
[]
no_license
eliasgago/geogson-data-transformer
e68b14de9e7e0ab05cd6a43a565d027877437574
078557e4796f00235cf6002b375b7f7c940c6aff
refs/heads/master
2021-01-23T05:24:42.410265
2018-01-25T06:45:57
2018-01-25T06:45:57
92,968,406
0
0
null
null
null
null
UTF-8
Java
false
false
1,645
java
package com.eliasgago.geogson.writer; import java.util.HashMap; import com.eliasgago.geogson.domain.Location; import com.github.filosganga.geogson.gson.GeometryAdapterFactory; import com.github.filosganga.geogson.model.Feature; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; public class GalicianMunicipalityAreaGeojsonWriter extends GalicianMunicipalityGeojsonWriter { @Override protected Feature getFeature(Location location) { Gson gson = new GsonBuilder() .registerTypeAdapterFactory(new GeometryAdapterFactory()) .create(); HashMap<String, JsonElement> data = new HashMap<String, JsonElement>(); if(location.getData() != null) { location.getData().forEach((key, value) -> { data.put(key, new JsonPrimitive(value.toString())); }); } ImmutableMap<String, JsonElement> properties = ImmutableMap.<String, JsonElement>builder() .put("name", location.getName() != null ? new JsonPrimitive(location.getName()) : new JsonPrimitive("")) .put("code", location.getCode() != null ? new JsonPrimitive(location.getCode()) : new JsonPrimitive("")) .put("postal_code", location.getPostalCode() != null ? new JsonPrimitive(location.getPostalCode()) : new JsonPrimitive("")) .putAll(data) .build(); String json = "{\"type\": \"Feature\"," + "\"properties\":" + gson.toJson(properties) + "," + "\"geometry\":" + gson.toJson(location.getArea()) + "}"; return gson.fromJson(json, Feature.class); } }
[ "egago@fidesol.org" ]
egago@fidesol.org
34cd68d3c4515254510cc5de77c260cb882c85dc
1f29aca970cd4d06749ce3e101c25b314dcea168
/src/main/java/com/getgreetapp/greetapp/repository/GangUserRepository.java
2dccb02e87f9d85e82fdcd9b40654f1330f6964a
[]
no_license
JonnyD/greetapp-api-java
6eb43ffeb9ae33096986c1ca9183022814ed2302
fdd621fa94a7d2b22ab5695ab3b43e181133fa14
refs/heads/master
2020-04-03T04:10:32.082393
2018-10-30T04:56:32
2018-10-30T04:56:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
824
java
package com.getgreetapp.greetapp.repository; import com.getgreetapp.greetapp.domain.GangUser; import org.springframework.data.jpa.repository.*; import org.springframework.stereotype.Repository; import java.util.List; /** * Spring Data repository for the GangUser entity. */ @SuppressWarnings("unused") @Repository public interface GangUserRepository extends JpaRepository<GangUser, Long> { @Query("select gang_user from GangUser gang_user where gang_user.user.login = ?#{principal.username}") List<GangUser> findByUserIsCurrentUser(); @Query("select gang_user from GangUser gang_user where gang_id = ?1") List<GangUser> findByGroup(Long groupId); @Query("select gang_user from GangUser gang_user where gang_id = ?1 and user_id = ?2") GangUser findByGangAndUser(Long gangId, Long userId); }
[ "dev@jonnydevine.com" ]
dev@jonnydevine.com
004cacb279d0d8d7015f7821fe0b3219ff124427
1b654344a055957fc3363566cb4619ec80aea8d2
/src/persistence/Service4Public.java
45df45a74096242351ba34a1d307a68d9eaef251
[]
no_license
hackertyper/online-shop
a901e36b0a3c5e17aa6c58d17cb06ebb0e536b30
c54f8614cfb1730e2edcd8a9f67594f65041b17b
refs/heads/master
2020-05-29T08:40:58.752023
2016-12-12T21:59:18
2016-12-12T21:59:18
69,943,970
0
2
null
2016-11-03T12:52:55
2016-10-04T07:47:20
Java
UTF-8
Java
false
false
1,347
java
package persistence; import model.visitor.*; public interface Service4Public extends Invoker, Anything, SubjInterface, Remote, AbstractPersistentProxi { public void accept(ServiceVisitor visitor) throws PersistenceException; public <R> R accept(ServiceReturnVisitor<R> visitor) throws PersistenceException; public <E extends model.UserException> void accept(ServiceExceptionVisitor<E> visitor) throws PersistenceException, E; public <R, E extends model.UserException> R accept(ServiceReturnExceptionVisitor<R, E> visitor) throws PersistenceException, E; public void initialize(final Anything This, final java.util.HashMap<String,Object> final$$Fields) throws PersistenceException; public void signalChanged(final boolean signal) throws PersistenceException; public void copyingPrivateUserAttributes(final Anything copy) throws PersistenceException; public void handleException(final Command command, final PersistenceException exception) throws PersistenceException; public void handleResult(final Command command) throws PersistenceException; public boolean hasChanged() throws PersistenceException; public void initializeOnCreation() throws PersistenceException; public void initializeOnInstantiation() throws PersistenceException; }
[ "bathke@his.de" ]
bathke@his.de
5f2d7de656c818627322fedeada3759fef2671e3
f152c2050103ecfbcc0bbd7387c020b2e285de8b
/TesteOlx/src/test/java/Elementos/elementos.java
ea26d2a729e552f3ec5f1f44e681ef9b377972f3
[]
no_license
Guilherme2309/Master
a1a311b4ac231aaa5aa7190601ab4e03aa058f4e
7c10efb338fd9ba002f8a3cdbcc73500d2a40eae
refs/heads/master
2023-08-22T18:06:19.145278
2021-10-21T20:16:03
2021-10-21T20:16:03
369,350,448
0
0
null
null
null
null
UTF-8
Java
false
false
5,725
java
package Elementos; import org.openqa.selenium.By; public class elementos { private By campoDepesquisa = By.name("q"); private By btnPesquisar = By.xpath("/html/body/div[2]/div[2]/form/div[2]/div[1]/div[3]/center/input[1]"); private By siteSelecionado = By.cssSelector("#rso > div:nth-child(1) > div > div > div > div.yuRUbf > a > h3 > span"); private By btnEntrar = By.xpath("/html/body/div/div[1]/div[1]/header/div[3]/a[4]"); private By campoEmail = By.xpath("/html/body/div[1]/div/div/div[1]/div[2]/form/div[1]/div[2]/input"); private By campoSenha = By.xpath("/html/body/div[1]/div/div/div[1]/div[2]/form/div[2]/div[2]/div/div/input"); private By btnLogar = By.xpath("/html/body/div[1]/div/div/div[1]/div[2]/form/button"); private By btnOlx = By.cssSelector("#main-page-content > div:nth-child(1) > div.sc-iNovjJ.jHNyQQ > header > div.sc-fEVUGC.hbuahQ > a > svg"); private By campoPesquisaOlx = By.id("searchtext"); private By btnLupa = By.cssSelector("#___gatsby > div.bigger-grid-style > div.iza-top > div.iza-container.container > div:nth-child(1) > div > div > div > div.searchButtonBox > button > svg"); private By intrumentoSelecionado = By.xpath("/html/body/div[1]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div[2]/div/div/div/div/div[3]/div/div/div[1]/div/span"); private By btnChat = By.cssSelector("#miniprofile > div > div > div.sc-eAudoH.fasAcL.sc-jTzLTM.iwtnNi > div > div > div.sc-hmzhuo.sc-12hn837-0.jBhsYi.sc-jTzLTM.iwtnNi > div"); private By campoDeConversa = By.xpath("/html/body/div[1]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div[2]/div/div/div/div/div[4]/div/div/div/div/div/div/div[3]/div[1]/div[4]/textarea"); private By btnEnviarMsg = By.xpath("/html/body/div[1]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div[2]/div/div/div/div/div[4]/div/div/div/div/div/div/div[3]/div[1]/div[4]/div[2]/div/svg"); private By fotosDaBateria = By.xpath("/html/body/div[1]/div[4]/div[2]/div/div[2]/div[1]/div[3]/div/div/div[3]/ul/li[2]/div/img"); private By btnConversas = By.xpath("/html/body/div/div[1]/div[1]/header/div[3]/a[3]"); private By btnYoutube = By.xpath("/html/body/div[1]/div/div[3]/footer/div/div[1]/div[2]/a[2]/svg/path"); private By btnCampoPesquisaYoutube = By.name("search_query"); private By btnLupaYout = By.xpath("/html/body/ytd-app/div/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/button/yt-icon"); private By videoIssoETudo = By.xpath("/html/body/ytd-app/div/ytd-page-manager/ytd-search/div[1]/ytd-two-column-search-results-renderer/div/ytd-section-list-renderer/div[2]/ytd-item-section-renderer/div[3]/ytd-video-renderer[1]/div[1]/div/div[1]/div/h3/a/yt-formatted-string"); public By getCampoDepesquisa() { return campoDepesquisa; } public void setCampoDepesquisa(By campoDepesquisa) { this.campoDepesquisa = campoDepesquisa; } public By getBtnPesquisar() { return btnPesquisar; } public void setBtnPesquisar(By btnPesquisar) { this.btnPesquisar = btnPesquisar; } public By getSiteSelecionado() { return siteSelecionado; } public void setSiteSelecionado(By siteSelecionado) { this.siteSelecionado = siteSelecionado; } public By getBtnEntrar() { return btnEntrar; } public void setBtnEntrar(By btnEntrar) { this.btnEntrar = btnEntrar; } public By getCampoEmail() { return campoEmail; } public void setCampoEmail(By campoEmail) { this.campoEmail = campoEmail; } public By getCampoSenha() { return campoSenha; } public void setCampoSenha(By campoSenha) { this.campoSenha = campoSenha; } public By getBtnLogar() { return btnLogar; } public void setBtnLogar(By btnLogar) { this.btnLogar = btnLogar; } public By getBtnOlx() { return btnOlx; } public void setBtnOlx(By btnOlx) { this.btnOlx = btnOlx; } public By getCampoPesquisaOlx() { return campoPesquisaOlx; } public void setCampoPesquisaOlx(By campoPesquisaOlx) { this.campoPesquisaOlx = campoPesquisaOlx; } public By getBtnLupa() { return btnLupa; } public void setBtnLupa(By btnLupa) { this.btnLupa = btnLupa; } public By getIntrumentoSelecionado() { return intrumentoSelecionado; } public void setIntrumentoSelecionado(By intrumentoSelecionado) { this.intrumentoSelecionado = intrumentoSelecionado; } public By getBtnChat() { return btnChat; } public void setBtnChat(By btnChat) { this.btnChat = btnChat; } public By getCampoDeConversa() { return campoDeConversa; } public void setCampoDeConversa(By campoDeConversa) { this.campoDeConversa = campoDeConversa; } public By getBtnEnviarMsg() { return btnEnviarMsg; } public void setBtnEnviarMsg(By btnEnviarMsg) { this.btnEnviarMsg = btnEnviarMsg; } public By getFotosDaBateria() { return fotosDaBateria; } public void setFotosDaBateria(By fotosDaBateria) { this.fotosDaBateria = fotosDaBateria; } public By getBtnConversas() { return btnConversas; } public void setBtnConversas(By btnConversas) { this.btnConversas = btnConversas; } public By getBtnYoutube() { return btnYoutube; } public void setBtnYoutube(By btnYoutube) { this.btnYoutube = btnYoutube; } public By getBtnCampoPesquisaYoutube() { return btnCampoPesquisaYoutube; } public void setBtnCampoPesquisaYoutube(By btnCampoPesquisaYoutube) { this.btnCampoPesquisaYoutube = btnCampoPesquisaYoutube; } public By getBtnLupaYout() { return btnLupaYout; } public void setBtnLupaYout(By btnLupaYout) { this.btnLupaYout = btnLupaYout; } public By getVideoIssoETudo() { return videoIssoETudo; } public void setVideoIssoETudo(By videoIssoETudo) { this.videoIssoETudo = videoIssoETudo; } }
[ "isley.vargas@RSI0036.rsinet.com.br" ]
isley.vargas@RSI0036.rsinet.com.br
4be83c1807776972bf8ed89ac3fb776bcf70d093
20da15b0d40e17d8eda2d4d9107d67f3a859bc44
/TodoListFragment/app/src/main/java/com/example/cursomovil/todolistfragment/SettingsActivity.java
67fd194e9fd90b8119f50951101411ec107c4dea
[]
no_license
hermes752/android
60012de5dd1063f2326d5c70322f95367698ae72
5b6a1dcd1d3c4d4ac1f1b9b5c13dd052dacc458f
refs/heads/master
2020-05-27T08:46:15.981845
2015-04-17T15:45:31
2015-04-17T15:45:31
32,402,305
0
0
null
null
null
null
UTF-8
Java
false
false
411
java
package com.example.cursomovil.todolistfragment; import android.os.Bundle; import android.preference.PreferenceActivity; /** * Created by cursomovil on 26/03/15. */ public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.userpreferences); } }
[ "hermes752@gmail.com" ]
hermes752@gmail.com
faf25d95c547afc3c25bb2af7591b22aed215490
cd1afde8c536e2ec6cf77fedc9c3ab721925ed46
/src/main/java/com/geoffgranum/plugin/builder/info/FieldAnnotationsInfoParser.java
fc72846fb60c797e64f24a4f6b43a737e2f30004
[]
no_license
ggranum/java-builder-gen
f217a75794c69222a58258e9e71fb89f4045a04b
49e6d083efa63d383c415c622542ae1e453fc676
refs/heads/master
2022-08-04T03:16:24.482136
2022-07-21T14:21:14
2022-07-21T14:21:14
35,840,736
0
0
null
2020-02-10T17:08:42
2015-05-18T20:27:06
Java
UTF-8
Java
false
false
1,620
java
package com.geoffgranum.plugin.builder.info; import com.intellij.psi.PsiAnnotation; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; /** * @author ggranum */ public class FieldAnnotationsInfoParser { public FieldAnnotationsInfoParser() { } public FieldAnnotationsInfo parse(PsiAnnotation[] annotations) { FieldAnnotationsInfo.Builder builder = new FieldAnnotationsInfo.Builder().hasNotNull(checkForAnnotationByName(annotations, "NotNull")) .hasNullable(checkForAnnotationByName(annotations, "Nullable")); return builder.build(); } private boolean checkForAnnotationByName(PsiAnnotation[] annotations, String name) { boolean result = false; for (PsiAnnotation annotation : annotations) { String qName = annotation.getQualifiedName(); if (qName != null && qName.contains(name)) { result = true; break; } } return result; } @NotNull private List<PsiAnnotation> annotationsInPackage(PsiAnnotation[] annotations, String packagePath) { List<PsiAnnotation> result = new ArrayList<>(); for (PsiAnnotation annotation : annotations) { if (annotationInPackage(annotation, packagePath)) { result.add(annotation); } } return result; } private boolean annotationInPackage(PsiAnnotation annotation, String packagePath) { String qName = annotation.getQualifiedName(); return qName != null && qName.startsWith(packagePath); } private List<PsiAnnotation> hibernateValidationConstraints(PsiAnnotation[] annotations) { return null; } }
[ "geoff.granum@gmail.com" ]
geoff.granum@gmail.com
75aaa14630e06d17071caaddda5a373a887890a1
c1cad119eb97c8b2c2c60995334f757b89b1b813
/webdriver/seleniumwebdriver/src/test/java/hurtmeplentyhardcore/page/CloudGoogleEstimationResultPage.java
18bd04288430739cfa99e2772b31cda4799d4b94
[]
no_license
Arnis1305/EpamHomeTasks
189555719e2b9e93d92e6328be1d5aa7e7a4f36b
1b2a6d36ad673fed68327934640559578e0e35b5
refs/heads/master
2023-02-24T10:21:17.952052
2021-01-24T19:18:45
2021-01-24T19:18:45
306,899,164
0
0
null
null
null
null
UTF-8
Java
false
false
3,060
java
package hurtmeplentyhardcore.page; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.util.ArrayList; public class CloudGoogleEstimationResultPage { private WebDriver driver; @FindBy(xpath = "//*[@id='compute']/md-list/md-list-item[2]/div") WebElement estimateVMClass; @FindBy(xpath = "//*[@id='compute']/md-list/md-list-item[3]/div") WebElement estimateInstanceType; @FindBy(xpath = "//*[@id='compute']/md-list/md-list-item[4]/div") WebElement estimateRegion; @FindBy(xpath = "//*[@id='compute']/md-list/md-list-item[5]/div") WebElement estimateAvailableSSD; @FindBy(xpath = "//*[@id='compute']/md-list/md-list-item[6]/div") WebElement estimateCommitmentTerm; @FindBy(xpath = "/html/body/md-content/md-card/div/md-card-content[2]/md-card/md-card-content/div/div/div/h2/b") WebElement estimateCoast; @FindBy(xpath = "//*[@id='email_quote']") WebElement emailEstimateButton; @FindBy(xpath = "//input[@ng-model='emailQuote.user.email']") WebElement emailEstimateInput; @FindBy(xpath = "//button[@ng-click='emailQuote.emailQuote(true); emailQuote.$mdDialog.hide()']") WebElement sendEmailButton; public CloudGoogleEstimationResultPage(WebDriver driver) { this.driver = driver; PageFactory.initElements(driver, this); } public TenMinuteMailPage emailEstimate() { emailEstimateButton.click(); new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(emailEstimateInput)); return new TenMinuteMailPage(driver); } public TenMinuteMailPage pasteEmailAndSendLetter() { ArrayList<String> chromeTabs = new ArrayList<>(driver.getWindowHandles()); driver.switchTo().window(chromeTabs.get(0)); driver.switchTo().frame(0); driver.switchTo().frame("myFrame"); new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(emailEstimateInput)); emailEstimateInput.click(); emailEstimateInput.sendKeys(Keys.CONTROL + "v"); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(sendEmailButton)); sendEmailButton.click(); return new TenMinuteMailPage(driver); } public String getEstimateVMClass() { return estimateVMClass.getText(); } public String getEstimateInstanceType() { return estimateInstanceType.getText(); } public String getEstimateRegion() { return estimateRegion.getText(); } public String getEstimateAvailableSSD() { return estimateAvailableSSD.getText(); } public String getEstimateCommitmentTerm() { return estimateCommitmentTerm.getText(); } public String getEstimateCoast() { return estimateCoast.getText(); } }
[ "python2503@gmail.com" ]
python2503@gmail.com
f91c2f67e907e90c4ad967db61716f88d1143302
2bb786973ce71e970177864e5d98398fd334750d
/linkwifi/src/androidTest/java/ys/com/linkwifi/ExampleInstrumentedTest.java
d9e8e12bcd23c70e5a45dd5267e9dd3cd66c4eab
[]
no_license
sengeiou/YSDemo
33406af4d21d161a5c590ea06a54a244cf5bb831
e7e2bd1e6905a805f79549516639e13b0973eca8
refs/heads/master
2022-11-30T00:54:56.152644
2020-07-16T03:59:27
2020-07-16T03:59:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
714
java
package ys.com.linkwifi; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("ys.com.linkwifi", appContext.getPackageName()); } }
[ "13714854975@163.com" ]
13714854975@163.com
9367029c4478705ecd7ad568c03c72fa33dcf459
0b85b8b4cf892281e983b9508e34bf53950e9aab
/app/src/androidTest/java/xuyihao/rongyiclient/ApplicationTest.java
f42459dd478a84a7c8743c04d3ac38713f56d9f8
[]
no_license
johnsonmoon/RongyiClient
996dd85ea214a95790a12ad8e28f38f12a583950
65a8095f6bbfa4832b41a4838e5f1ced11af150c
refs/heads/master
2021-01-11T05:51:08.864209
2016-10-10T11:45:12
2016-10-10T11:45:12
69,645,745
0
0
null
null
null
null
UTF-8
Java
false
false
351
java
package xuyihao.rongyiclient; 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); } }
[ "xuyh@uyunsoft.cn" ]
xuyh@uyunsoft.cn
6086f7c2252f724d765d5b1b33bc394cc3fcd5e5
a287ce936b222c59646f392ed9e00432608a44bd
/lesson5/mvakarchuk/src/jelementary/Group.java
2ad71c0893e7f22e3a33a7039d037474af8d50c8
[]
no_license
igorkorunets/homework
5d71a775425d52fc3e541706023a4a000751de05
a429f231f1015c67ca269cb10df1f0aef0e779d3
refs/heads/master
2021-01-12T16:14:18.791767
2016-12-01T00:35:03
2016-12-01T00:35:03
70,505,551
0
0
null
2016-10-10T16:10:46
2016-10-10T16:10:45
null
UTF-8
Java
false
false
776
java
package jelementary; import jelementary.people.Student; public class Group { String name; Student[] students; public Group(String name) { this.name = name; students = new Student[0]; } public String getName() { return name; } public Student[] getStudents() { return students; } public void addStudent(Student student) { Student[] tmp = new Student[students.length + 1]; System.arraycopy(students, 0, tmp, 0, students.length); tmp[students.length] = student; students = tmp; } public String toString() { String listOfStudents = " "; for (Student student : students) { listOfStudents += "\n" + student.getName(); } return "Group: " + name + ".\n" + "List of students: " + listOfStudents; } }
[ "dmitry404@gmail.com" ]
dmitry404@gmail.com
e7b95e139853ef756766055972c8a6bcebfc9c1e
5c004161242369206abe6f439ece39740db7e301
/app/src/main/java/com/example/lerningfiarbase/RegisterActivity.java
f58733d473518b832a8c29b4681c65fce6ddc147
[]
no_license
dakshay27/firebase
26f7a6be226b4b71344dad716b13e084676288c4
0a16ecffe823a5af7fdd5cac63281a1bd4bf96b6
refs/heads/master
2023-03-14T04:41:25.476695
2021-03-05T17:46:38
2021-03-05T17:46:38
344,874,547
0
0
null
null
null
null
UTF-8
Java
false
false
6,359
java
package com.example.lerningfiarbase; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.Task; import com.google.firebase.FirebaseException; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.PhoneAuthCredential; import com.google.firebase.auth.PhoneAuthProvider; import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.DocumentSnapshot; import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.QuerySnapshot; import com.rilixtech.widget.countrycodepicker.CountryCodePicker; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; public class RegisterActivity extends AppCompatActivity { FirebaseAuth auth; FirebaseFirestore firestore; EditText phoneNum,code; Button next; ProgressBar progressBar; TextView state; CountryCodePicker codePicker; ArrayList<ModelUser> mArrayList; String verificationId; PhoneAuthProvider.ForceResendingToken token; Boolean verificationInProgress = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); auth = FirebaseAuth.getInstance(); firestore = FirebaseFirestore.getInstance(); mArrayList = new ArrayList<>(); phoneNum = findViewById(R.id.phone); code = findViewById(R.id.codeEnter); progressBar = findViewById(R.id.progressBar); next= findViewById(R.id.nextBtn); state = findViewById(R.id.state); codePicker = findViewById(R.id.ccp); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!verificationInProgress){ if (!phoneNum.getText().toString().isEmpty() && phoneNum.getText().toString().length()==10){ String phoneNumber = "+"+codePicker.getSelectedCountryCode()+phoneNum.getText().toString(); progressBar.setVisibility(View.VISIBLE); state.setText("Sending OTP..."); state.setVisibility(View.VISIBLE); Log.d("TAG", "onClick: "+phoneNumber); requestOTP(phoneNumber); }else { phoneNum.setError("phone number is not valid"); } }else { String userOTP = code.getText().toString(); if (!userOTP.isEmpty() && userOTP.length() == 6){ PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, userOTP); verifyAuth(credential); }else{ code.setError("not valid OTP"); } } } }); } private void verifyAuth(PhoneAuthCredential credential) { auth.signInWithCredential(credential).addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()){ checkUser(); }else{ Toast.makeText(RegisterActivity.this,"Authentication is Failed",Toast.LENGTH_SHORT).show(); } } }); } private void checkUser() { DocumentReference docRef = firestore.collection("users").document(auth.getCurrentUser().getUid()); docRef.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { if (documentSnapshot.exists()){ startActivity(new Intent(getApplicationContext(), MainActivity.class)); Log.d("ddfsfbc", "onSuccess: exists"); }else{ startActivity(new Intent(getApplicationContext(), AddDetailActivity.class)); Log.d("ddfsfbc", "onSuccess: not exists"); } finish(); } }); } private void requestOTP(String phoneNumber) { PhoneAuthProvider.getInstance().verifyPhoneNumber(phoneNumber, 60L, TimeUnit.SECONDS, this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() { @Override public void onCodeSent(@NonNull String s, @NonNull PhoneAuthProvider.ForceResendingToken forceResendingToken) { super.onCodeSent(s, forceResendingToken); progressBar.setVisibility(View.GONE); state.setVisibility(View.GONE); code.setVisibility(View.VISIBLE); verificationId = s; token = forceResendingToken; next.setText("Verify"); // next.setEnabled(false); verificationInProgress = true; } @Override public void onCodeAutoRetrievalTimeOut(@NonNull String s) { super.onCodeAutoRetrievalTimeOut(s); Toast.makeText(RegisterActivity.this,"OTP is expired ",Toast.LENGTH_SHORT).show(); } @Override public void onVerificationCompleted(@NonNull PhoneAuthCredential phoneAuthCredential) { verifyAuth(phoneAuthCredential); } @Override public void onVerificationFailed(@NonNull FirebaseException e) { Toast.makeText(RegisterActivity.this,"Can not create Account " + e.getMessage(),Toast.LENGTH_SHORT).show(); Log.d("fail", "onVerificationFailed: "+e.getMessage()); } }); } }
[ "pdakshay0@gmail.com" ]
pdakshay0@gmail.com
ee68803ff6bfbed74a5daede95e52a205970187a
fb6804640ee3b471c22a273458e6587441487075
/src/main/java/com/example/game/controller/user/ClassController.java
2c77a904b8a16a501f7a5693ef1223d774a1a188
[]
no_license
Vzifeng/myGame
e811991c52c554edc02f350fe75a54ae030ea55e
58d60f80a2bc6c44f576087779aafafe0fc07ea7
refs/heads/master
2022-10-29T22:26:45.317259
2022-03-03T06:44:09
2022-03-03T06:44:09
195,146,975
1
0
null
2022-10-12T20:28:43
2019-07-04T01:12:25
JavaScript
UTF-8
Java
false
false
873
java
package com.example.game.controller.user; import com.example.game.po.Class; import com.example.game.response.CommonResponse; import com.example.game.service.ClassService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.List; import java.util.Map; /** * @ Author :yangyunlong. * @ Date :Created in 16:40 2019/6/21/0021 * @Version : $version$ */ @Controller public class ClassController { @Autowired ClassService classService; @RequestMapping(value = "/class") @ResponseBody public CommonResponse classList(){ List<Map<String,Object>> list = classService.classList(); return CommonResponse.create(list); } }
[ "1281084456@qq.com" ]
1281084456@qq.com
a13d10702ed4942de281c3dde723d94318174166
dede079ad5f55b6f17c12db86b0c9ef5c6b04ba4
/pagedemo/src/main/java/com/demo/study/entity/Stack.java
f7741672a384a9bbe85572c423f817efccde828a
[]
no_license
JiangLxx/study
89a37f2604b042cb19c057489e13a433ce72c70e
a9b742725303ab1a3c57e641a84a49b689387280
refs/heads/master
2021-07-17T03:15:44.934047
2018-10-18T02:24:00
2018-10-18T02:24:00
128,626,181
0
0
null
null
null
null
UTF-8
Java
false
false
865
java
package com.demo.study.entity; import java.util.Arrays; import java.util.EmptyStackException; public class Stack { public Object[] elements; public int size = 0; public static final int DEFAULT_INITIAL_CAPACITY = 16; public Stack() { elements = new Object[DEFAULT_INITIAL_CAPACITY]; } public void push(Object e) { ensureCapacity(); elements[size++] = e; } public Object pop() { if(size == 0) { throw new EmptyStackException(); } //********************************** //避免内存泄露,在移除栈时将此对象引用置空,方便GC回收 Object result = elements[--size]; elements[--size] = null; //********************************** return result; } private void ensureCapacity() { if(elements.length == size) { elements = Arrays.copyOf(elements, 2*size + 1); } } }
[ "1063484901@qq.com" ]
1063484901@qq.com
d84859c8620dfab865bbb811c0240caa954ddabf
6de7e8b1ef388fe1ab1b490d8db8085e2e3ae7be
/src/main/java/com/infosys/api/inventory/InventoryService.java
6de44cfc1aa3642a8f8500008e5969eaf7f69e78
[ "LicenseRef-scancode-dco-1.1", "Apache-2.0" ]
permissive
ciscld/inventoryservice-1
13653bda1a0d9c61ac767b623c7dbd0650cc30e7
fdc48aa77a672379a5c87b8ebd8074f2c85b4d6f
refs/heads/master
2022-11-29T23:00:36.809824
2020-08-14T08:40:56
2020-08-14T08:40:56
287,169,605
0
0
null
null
null
null
UTF-8
Java
false
false
1,123
java
package com.infosys.api.inventory; import lombok.Setter; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.time.Duration; @Service public class InventoryService { private final InventoryRepository repository; public InventoryService(InventoryRepository repository) { this.repository = repository; } public Flux<Inventory> getAllInventory() { return repository.findAll(); } public Mono<Inventory> findInventoryByName(String name) { return repository.findByName(name); } public Flux<InventoryEvent> getEvents(String inventoryId) { return Flux.<InventoryEvent>generate(sink -> sink.next(new InventoryEvent(inventoryId, "", 1)) ).delayElements(Duration.ofSeconds(1)); /* return repository.findById(inventoryId) .flatMapMany(e -> Flux.<InventoryEvent>generate(sink -> sink.next(new InventoryEvent(inventoryId, e.getName(), e.getQuantity()))) ).delayElements(Duration.ofSeconds(1)); */ } }
[ "sumitahuja17@gmail.com" ]
sumitahuja17@gmail.com
aefc02fcd3acb75a2ae5384e8ebc635b20d24b3e
d0eb880beb3164ce0bd71bd69c9b4d7501911a80
/task3/src/main/java/hu/gulyasm/storm/SensorData.java
fac51f982a7cd83d97f0bda64578075e3f52c520
[]
no_license
gulyasm/storm-workshop
843c08347259bf8cdfcdf9055ab96d8b526cb9d6
2550daf560d3e696dcff09794c74486414b23e93
refs/heads/master
2021-01-18T23:11:28.666205
2016-06-09T18:38:56
2016-06-09T18:38:56
39,037,925
0
0
null
null
null
null
UTF-8
Java
false
false
917
java
package hu.gulyasm.storm; public class SensorData { public final String ID; public final String sensorID; public final String type; public final long timestamp; public final float value; public final int locationCode; public SensorData(String id, String sensorID, String type, long timestamp, float value, int locationCode) { ID = id; this.sensorID = sensorID; this.type = type; this.timestamp = timestamp; this.value = value; this.locationCode = locationCode; } @Override public String toString() { return "SensorData{" + "ID='" + ID + '\'' + ", sensorID='" + sensorID + '\'' + ", type='" + type + '\'' + ", timestamp=" + timestamp + ", value=" + value + ", locationCode=" + locationCode + '}'; } }
[ "mgulyas86@gmail.com" ]
mgulyas86@gmail.com
2ebab6fa1f973d032a2320b2e1bb8366e2cbd239
bb7e5a90f2d52765bcbf3dde446b74afda63fd78
/src/main/java/com/linkedlogics/bio/expression/Index.java
f936a5d5fd42fc507e3c0bcc6d5d7c10474d4ddc
[]
no_license
rdavudov/bio-object-logic
8f57eef6cb6c0eb69ff7b7bb1ab841d1ac11270b
882731a9b3dca1e058f4f276444b33bdad5b21c4
refs/heads/master
2023-05-03T05:37:08.006660
2022-11-29T08:30:15
2022-11-29T08:30:15
169,060,497
3
1
null
2023-04-14T17:48:16
2019-02-04T10:17:45
Java
UTF-8
Java
false
false
663
java
package com.linkedlogics.bio.expression; import java.util.List; import com.linkedlogics.bio.BioObject; public class Index extends Expression { private Expression index ; public Index(Expression index) { this.index = index ; } @Override public Object getValue(Object source, BioObject... params) { int i = ((Number) index.getValue(params)).intValue() ; if (source instanceof Object[]) { Object[] array = (Object[]) source ; if (array.length > i) { return array[i] ; } } else if (source instanceof List) { List<Object> list = (List<Object>) source ; if (list.size() > i) { return list.get(i) ; } } return null; } }
[ "radjab@gmail.com" ]
radjab@gmail.com
0b332732a440020034098d88d6c3941b3b87b35e
a0fd04e2fbc2f651bb495c1f7415d94c03104bbd
/src/main/java/dao/UtilisateurCoDao.java
0e18a35281ba06f2900d82ac31ea905abbd37858
[]
no_license
ChrisYohann/ProjetWeb
b7a88c40e48012d28f8d9d41e118c9391f3ef632
2b4fe63a73f9518e9d202bb672b4f0f5f05fbf15
refs/heads/master
2016-09-06T10:48:54.600993
2015-04-30T06:59:51
2015-04-30T06:59:51
33,127,210
0
0
null
null
null
null
UTF-8
Java
false
false
463
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 dao; import beans.UtilisateurCoBean ; /** * * @author chris */ public interface UtilisateurCoDao { void creer( UtilisateurCoBean utilisateur ) throws DAOException; UtilisateurCoBean trouver( String login, String password ) throws DAOException; }
[ "i.nhyne@gmail.com" ]
i.nhyne@gmail.com
5f9cb876d5ceb029cbd112d676849fefd0a914ec
7501934503dfd7fd69c7ffeed20e97f257ee90bb
/3.3.1-ServiciosWeb/app/src/test/java/com/example/puga/lab331/ExampleUnitTest.java
97fdce8de875e5e3a9f1abc7e6a22150cfed9d67
[]
no_license
capugafl/TallerAplicacionesMoviles
472b358eb134ae95575dae7d7493f7f664bfc1d0
407eac41d780004b7a3a1fec415cae144d16c3af
refs/heads/master
2021-01-24T18:59:15.753743
2018-05-23T16:12:11
2018-05-23T16:12:11
122,382,840
0
0
null
null
null
null
UTF-8
Java
false
false
400
java
package com.example.puga.lab331; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
[ "capugafl@ittepic.edu.mx" ]
capugafl@ittepic.edu.mx
adc9eab3180c21b9719f95fbe6b06333581b2894
f67f55af40a480d77298094e8b2f4f337df2d8da
/dialogselect/src/androidTest/java/com/neandroid/dialogui/ExampleInstrumentedTest.java
45aa9b43eae86e5ea06f11f5fd47b03daf46ea52
[ "Apache-2.0" ]
permissive
Youngfellows/DialogSelect
aa766442f83bd29e16063ea443b04791869955a1
b990142fce1f19c8b0749cef401c3e7e46818fac
refs/heads/main
2023-03-10T22:22:32.121000
2021-02-25T07:22:41
2021-02-25T07:22:41
324,769,432
0
0
null
null
null
null
UTF-8
Java
false
false
754
java
package com.neandroid.dialogui; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumented test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); assertEquals("com.neandroid.dialogui.test", appContext.getPackageName()); } }
[ "hk20130120515@163.com" ]
hk20130120515@163.com
97d84dd1932d48a6700caa69d8de06b69e986d9a
e7effd0585b0ffa5f3b4f9f3dedab3f8b04ab881
/Ejer_JUnit_4/src/com/dam1/ejer_junit_4/Iguales.java
a3ae3a99c0d26368ff9e0bca38f1ce39f750a0c2
[]
no_license
alejandropalacio02/prueba-Git
e71e059b76725304a4b7168bc1160a005c00aa66
ca85c07f1d26c69b0f361c9d8afc44c39cc6626f
refs/heads/master
2023-04-01T20:38:59.649603
2021-04-15T08:08:18
2021-04-15T08:08:18
358,177,035
0
0
null
null
null
null
UTF-8
Java
false
false
345
java
package com.dam1.ejer_junit_4; public class Iguales { int x, y, z; public Iguales(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } public String miraIguales() { String result = "Dos iguales"; if (x == y && x == z) result = "Tres iguales"; if (x!=y && x!=z && y!=z) result="Distintos"; return result; } }
[ "aa20.aapalacio13@iespabloserrano.com" ]
aa20.aapalacio13@iespabloserrano.com
a57790374871232715f5fa9e53162419a64293e6
1c171196323f3ce6726407e94aca4dd09962a9e2
/Spring/myApp/src/test/java/com/example/myApp/DemoApplicationTests.java
fa360ea0ba6eef9a0560dd6e003cfc3e41188f8a
[]
no_license
andrea-claro/Coding-and-exploring
44b260b8a77b69c0e5b53317ca056f14ebf47590
d2e3ab350ae065e0285b7e3c1bb64cd6325d2cdf
refs/heads/master
2021-12-15T00:57:05.912577
2021-06-14T12:25:34
2021-06-14T12:25:34
234,073,231
0
0
null
null
null
null
UTF-8
Java
false
false
207
java
package com.example.myApp; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class DemoApplicationTests { @Test void contextLoads() { } }
[ "a.claro@almaviva.it" ]
a.claro@almaviva.it
712dbe2655ff88f412c189a9c4e4ec3c528a3839
7f5d457849dc42d1debcdaf51600be574febe3c0
/TAT/src/fr/ujf/enumeration/monitor/Verdict.java
ffd6c4bbd3bb296bc01d2697cf94122abe5cf02f
[]
no_license
GIODm2pgi/TAT
8e36fd37b56698918e7733ca84b71f634b21c5d7
318eea9cb5586ea98789fd89e6564e5b71eef7f7
refs/heads/master
2016-08-04T15:10:12.179947
2014-11-21T16:50:25
2014-11-21T16:50:25
null
0
0
null
null
null
null
UTF-8
Java
false
false
312
java
package fr.ujf.enumeration.monitor; public enum Verdict { TRUE("true"), CURRENTLY_TRUE("currently true"), CURRENTLY_FALSE("currently false"), FALSE("false"); private String verdictName; Verdict(String name) { this.verdictName = name; } public String getName() { return this.verdictName; } }
[ "pierre.odin@e.ujf-grenoble.fr" ]
pierre.odin@e.ujf-grenoble.fr
a8b6208603b25ba74ccdbab3a78949a347d2b5bc
1e0ca808750cba9f16a23edd875fed1b16cb17b2
/app/src/main/java/org/thingagora/tripmaster/AppCompatPreferenceActivity.java
f7d064033f605b769c88dff14a64940428794250
[ "BSD-2-Clause" ]
permissive
lyriarte/tripmaster
e9f1ead00071891fbf19beb28df282d3d18a19ea
fbc8119cb499edab71ddd48df876a8ab6bd13c4e
refs/heads/master
2020-04-24T04:10:40.106278
2019-08-25T21:32:40
2019-08-25T21:32:40
171,694,133
1
0
BSD-2-Clause
2019-02-20T15:04:06
2019-02-20T15:04:05
null
UTF-8
Java
false
false
2,999
java
package org.thingagora.tripmaster; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceActivity; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.Toolbar; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; /** * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls * to be used with AppCompat. */ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { private AppCompatDelegate mDelegate; @Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory(); getDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); getDelegate().onPostCreate(savedInstanceState); } public ActionBar getSupportActionBar() { return getDelegate().getSupportActionBar(); } public void setSupportActionBar(@Nullable Toolbar toolbar) { getDelegate().setSupportActionBar(toolbar); } @Override public MenuInflater getMenuInflater() { return getDelegate().getMenuInflater(); } @Override public void setContentView(@LayoutRes int layoutResID) { getDelegate().setContentView(layoutResID); } @Override public void setContentView(View view) { getDelegate().setContentView(view); } @Override public void setContentView(View view, ViewGroup.LayoutParams params) { getDelegate().setContentView(view, params); } @Override public void addContentView(View view, ViewGroup.LayoutParams params) { getDelegate().addContentView(view, params); } @Override protected void onPostResume() { super.onPostResume(); getDelegate().onPostResume(); } @Override protected void onTitleChanged(CharSequence title, int color) { super.onTitleChanged(title, color); getDelegate().setTitle(title); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); getDelegate().onConfigurationChanged(newConfig); } @Override protected void onStop() { super.onStop(); getDelegate().onStop(); } @Override protected void onDestroy() { super.onDestroy(); getDelegate().onDestroy(); } public void invalidateOptionsMenu() { getDelegate().invalidateOptionsMenu(); } private AppCompatDelegate getDelegate() { if (mDelegate == null) { mDelegate = AppCompatDelegate.create(this, null); } return mDelegate; } }
[ "luc.yriarte@thingagora.org" ]
luc.yriarte@thingagora.org
67f709b649829095fe78acfb2fa763e0249a2d01
f668103c26057d92a2c7228dcc28e80559e5da27
/app/src/main/java/sudosaints/com/testsample/AlphaForegroundColorSpan.java
31817ca97d6fd88783f5f21f5afec4887c210e74
[]
no_license
praseem/hhapp
2fecccd29bc9a8f1980df2dbdde68614fbcb6568
68d05a65f73f61f82eb857f87bc0272073cae959
refs/heads/master
2021-01-23T11:19:59.804355
2014-11-30T21:42:15
2014-11-30T21:42:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,044
java
package sudosaints.com.testsample; import android.graphics.Color; import android.os.Parcel; import android.text.TextPaint; import android.text.style.ForegroundColorSpan; public class AlphaForegroundColorSpan extends ForegroundColorSpan { private float mAlpha; public AlphaForegroundColorSpan(int color) { super(color); } public AlphaForegroundColorSpan(Parcel src) { super(src); mAlpha = src.readFloat(); } public void writeToParcel(Parcel dest, int flags) { super.writeToParcel(dest, flags); dest.writeFloat(mAlpha); } @Override public void updateDrawState(TextPaint ds) { ds.setColor(getAlphaColor()); } public void setAlpha(float alpha) { mAlpha = alpha; } public float getAlpha() { return mAlpha; } private int getAlphaColor() { int foregroundColor = getForegroundColor(); return Color.argb((int) (mAlpha * 255), Color.red(foregroundColor), Color.green(foregroundColor), Color.blue(foregroundColor)); } }
[ "codethat@outlook.com" ]
codethat@outlook.com
36356da1755784af201a70d24733d62fc334f8ee
656ff462d15bbc524f6c8dcce1f550053ac7966e
/app/src/main/java/com/cleanup/todoc/repositories/TaskDataRepository.java
1ad3a1e52e827714a8502bcbba48d7c521cd11c3
[]
no_license
JDR1304/Todoc
ba4b580b6134ab820588527a74a3f8de7a54965e
40f74443b9eee1dce3089ac787b22f891809d4c8
refs/heads/master
2023-08-19T12:48:11.374434
2021-10-12T11:33:03
2021-10-12T11:33:03
397,982,220
0
0
null
null
null
null
UTF-8
Java
false
false
709
java
package com.cleanup.todoc.repositories; import android.arch.lifecycle.LiveData; import com.cleanup.todoc.database.TaskDao; import com.cleanup.todoc.model.Task; import java.util.List; public class TaskDataRepository { private final TaskDao taskDao; public TaskDataRepository(TaskDao taskDao) { this.taskDao = taskDao; } // --- GET --- public LiveData<List<Task>> getTasks(){ return this.taskDao.getTasks(); } // --- CREATE --- public void createTask(Task task){ taskDao.insertTask(task); } // --- DELETE --- public void deleteTask(long taskId){ taskDao.deleteTask(taskId); } // --- UPDATE --- public void updateTask(Task task){ taskDao.updateTask(task); } }
[ "jerome.diazrey@gmail.com" ]
jerome.diazrey@gmail.com
0a3e99c8a34f5c4530867a7aa9903cec7140ab50
6352bb0827a798e91ecc26fbe9abd96cb74063ce
/src/main/java/com/anindoasaha/workflowengine/prianza/task/control/composite/AsyncWorkflowTask.java
2c76ac2d393583691d65c54f5d1f7bf4039cf209
[]
no_license
anindoasaha/workflow_engine
e5ece71bdab40ab4fdaa873acc4fb217e114889f
cd43d742780b98f126a8952c94a6f8153dc1c2f0
refs/heads/master
2020-04-21T18:36:26.492140
2019-04-11T04:36:27
2019-04-11T04:36:27
169,776,221
0
0
null
null
null
null
UTF-8
Java
false
false
3,663
java
package com.anindoasaha.workflowengine.prianza.task.control.composite; import com.anindoasaha.workflowengine.prianza.api.WorkflowInstanceEventListener; import com.anindoasaha.workflowengine.prianza.api.WorkflowService; import com.anindoasaha.workflowengine.prianza.bo.AbstractTask; import com.anindoasaha.workflowengine.prianza.bo.ActorType; import com.anindoasaha.workflowengine.prianza.bo.Workflow; import com.anindoasaha.workflowengine.prianza.bo.WorkflowInstance; import com.google.inject.Inject; import java.util.*; /** * Inbuilt task which references a workflow, * the workflow is not exclusive to the task and can be reused or ran independently. * The task does not wait for the reference workflow to finish. */ public class AsyncWorkflowTask extends AbstractTask { private String workflowId = null; private transient Workflow nestedWorkflow = null; private String nestedWorkflowInstanceId = null; @Inject private transient WorkflowService workflowService = null; /** * Variables to copy over from parent workflow instance to child * workflow instance at instance creation. * * keyInParent => keyInChild * */ private Map<String, String> parentInstanceVariablesMapping = null; /** * Variables to copy over from child workflow instance to parent * workflow instance at embedded instance completion. * * keyInChild => keyInParent */ private Map<String, String> childInstanceVariablesMapping = null; /** * Default constructor for serialization/deserialization purposes */ public AsyncWorkflowTask() { } public AsyncWorkflowTask(String workflowId, Map<String, String> parentInstanceVariablesMapping) { this.workflowId = workflowId; this.parentInstanceVariablesMapping = parentInstanceVariablesMapping; } @Override public ActorType getActorType() { return ActorType.SYSTEM; } @Override public Map<String, String> beforeAction(WorkflowInstance workflowInstance) { this.nestedWorkflow = workflowService.getWorkflowByWorkflowId(this.workflowId); Map<String, String> instanceVariables = copyOverParentVariables(workflowInstance.getInstanceVariables()); WorkflowInstance nestedWorkflowInstance = workflowService.createWorkflowInstance(this.nestedWorkflow, instanceVariables); nestedWorkflowInstance.setInstanceType(WorkflowInstance.InstanceType.WORKFLOW_INSTANCE_EMBEDDED); workflowService.updateWorkflowInstance(nestedWorkflowInstance, instanceVariables); nestedWorkflowInstanceId = nestedWorkflowInstance.getId(); return null; } @Override public Map<String, String> onAction(WorkflowInstance workflowInstance) { return null; } @Override public Object afterAction(WorkflowInstance workflowInstance) { return null; } @Override public Map<String, String> onSuccess(WorkflowInstance workflowInstance) { return null; } @Override public Map<String, String> onError(WorkflowInstance workflowInstance) { return null; } private Map<String, String> copyOverParentVariables(Map<String, String> instanceVariables) { Map<String, String> parentInstanceVariablesMapping = this.parentInstanceVariablesMapping; Map<String, String> childInstanceVariables = new HashMap<>(); for (Map.Entry<String, String> entry : parentInstanceVariablesMapping.entrySet()) { childInstanceVariables.put(entry.getValue(), instanceVariables.get(entry.getKey())); } return childInstanceVariables; } }
[ "anindoasaha@gmail.com" ]
anindoasaha@gmail.com
119a8fc74202facc194cace75cab8de0975ca7ba
3aadbb67f99ef121e32caf5f8afd1ce67b24afb0
/src/main/java/projet/cadre/dao/DataSourceProvider.java
72bb35301bdb9b5b2b36f40eb4c34f8d8e17b4a9
[]
no_license
chloepelletier/sascadre
bfdb04a1e7253e6718ef5c719b2cf369f58123c9
2e2484bcee3c6c165fdb3734559d8d02af9c3d7f
refs/heads/master
2021-01-20T15:41:40.710213
2017-05-09T20:30:24
2017-05-09T20:30:24
90,788,263
0
0
null
null
null
null
UTF-8
Java
false
false
592
java
package projet.cadre.dao; import javax.sql.DataSource; import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; public class DataSourceProvider { private static MysqlDataSource dataSource; public static DataSource getDataSource() { if (dataSource == null) { dataSource = new MysqlDataSource(); dataSource.setServerName("s54ham9zz83czkff.cbetxkdyhwsb.us-east-1.rds.amazonaws.com"); dataSource.setPort(3306); dataSource.setDatabaseName("gq399s1c0eutke3v"); dataSource.setUser("si32jxzhn8ed8v3p"); dataSource.setPassword("yhq28uf8am4ci5na"); } return dataSource; } }
[ "chloe.pelletier@hei.fr" ]
chloe.pelletier@hei.fr
fec25ee155acc791dc9578a54c454b7b98260aa1
289381c365427b69fa7e8674c9b484e0545e1f9c
/Futebol/src/br/com/k19/modelo/repositorios/TimeRepository.java
6cd2b4512c6bed86fde2a79c62aae6363ff95071
[]
no_license
allima/fute
1d560b00b48d2ce07fe5317fcf3d5cffeebea7c7
f1cfbcf9501833994097a47ffa9ae041ed264cdf
refs/heads/master
2021-01-10T14:30:33.363283
2015-05-27T16:45:34
2015-05-27T16:45:34
36,256,362
0
0
null
2015-05-27T16:45:34
2015-05-25T21:50:21
Java
UTF-8
Java
false
false
1,066
java
package br.com.k19.modelo.repositorios; import br.com.k19.modelo.entidades.Jogador; import br.com.k19.modelo.entidades.Time; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.Query; public class TimeRepository { private EntityManager manager; public TimeRepository(EntityManager manager) { this.manager = manager; } public void adiciona(Time time) { this.manager.persist(time); } public void remove(Long id) { Time time = this.procura(id); Query query = this.manager .createQuery("select x from Jogador x where x.time =:time"); query.setParameter("time", time); List<Jogador> jogadores = query.getResultList(); for (Jogador jogador : jogadores) { jogador.setTime(null); } this.manager.remove(time); } public Time atualiza(Time time) { return this.manager.merge(time); } public Time procura(Long id) { return this.manager.find(Time.class, id); } public List<Time> getLista() { Query query = this.manager.createQuery("select x from Time x"); return query.getResultList(); } }
[ "allima1991@gmail.com" ]
allima1991@gmail.com
3cf650dae6c1528866006e4c797608af674c224a
8877802a526939fddc6c8e8ae4c201b1d045d5ab
/src/main/java/com/example/ssm/service/IUserService.java
cfda29c670e7f483891502a31ca6675fa74d56d5
[]
no_license
calvinit/ssm-demo
73dbd637702ca671ab287a0e44b47d907f19facb
4c6eb34088217a5dacee23a4754f3eea39ed752b
refs/heads/main
2022-12-05T18:55:39.481986
2022-11-21T04:48:40
2022-11-21T04:48:40
238,739,238
0
0
null
2022-11-21T04:49:22
2020-02-06T16:58:49
Java
UTF-8
Java
false
false
1,058
java
package com.example.ssm.service; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.example.ssm.entity.User; import org.springframework.transaction.annotation.Transactional; import java.util.List; public interface IUserService extends IService<User> { @Transactional(readOnly = true, rollbackFor = Exception.class) IPage<User> selectPage(IPage<User> page); @Transactional(readOnly = true, rollbackFor = Exception.class) IPage<User> selectPage(IPage<User> page, Wrapper<User> queryWrapper); @Transactional(readOnly = true, rollbackFor = Exception.class) User selectByPrimaryKey(int id); /** * {@inheritDoc} */ @Override @Transactional(readOnly = true, rollbackFor = Exception.class) List<User> list(); /** * {@inheritDoc} */ @Override @Transactional(readOnly = true, rollbackFor = Exception.class) List<User> list(Wrapper<User> queryWrapper); }
[ "541298948@qq.com" ]
541298948@qq.com
c1a22fe178a0098b935fc875aa8e58d5fcbdb505
da5c94b2f9dfd86909a7f03fc6bfc127111e7575
/src/test/java/homeProject/testTest/SalaryCalculation.java
298e1ca57b46bc844b71e05297e2baf4156d59cb
[]
no_license
KatyaFedorova/Java-Gradle-TestNG
58a0ffb43cd8459ca3d9ba0b80cbed79a3f7b8de
de7869ec13ecfbbbe1ea471b69be721b1419c7d9
refs/heads/master
2021-01-25T14:10:38.795012
2018-03-26T04:09:06
2018-03-26T04:09:06
123,662,098
0
0
null
null
null
null
UTF-8
Java
false
false
764
java
package homeProject.testTest; import homeProject.baseAndCommonThings.BaseFunctions; import homeProject.baseAndCommonThings.PathAbstract; import homeProject.testPages.FinancesSite; import org.testng.annotations.Test; public class SalaryCalculation extends PathAbstract { @Test public void SalaryCalculation() { openURL("https://minfin.com.ua/currency/banks/kharkov/usd/"); String currentRate = FinancesSite.getCurrentUSDRates(); float currentUsd = Float.valueOf(currentRate); int currentSalaryInUSD = 300; System.out.println("Ваша зарплата в гривне равна " + currentUsd * currentSalaryInUSD + "/n" + "Текущий курс USD - " + currentRate); } }
[ "36183329+KatyaFedorova@users.noreply.github.com" ]
36183329+KatyaFedorova@users.noreply.github.com
48be5ea8f951093cb3e1a8e19c004b31e658df90
4b44fca699ada796f0d891917c644a09f370eced
/src/main/java/com/gmail/kirill/ked/telegram/service/impl/CityServiceImpl.java
5ec9c38746ed6367b048db0b14cdd7cebdb35514
[]
no_license
JediHardcode/test_task_OnTravelSolutions
e5244a2d6726c6f8a5dd0ed9cc2a8a511514616b
8c8442a33ac8ce5e8fcb6edd4726619ea43fcf9a
refs/heads/master
2022-09-04T09:47:37.481331
2019-06-18T20:48:32
2019-06-18T20:48:32
192,371,373
0
0
null
2019-06-18T20:48:33
2019-06-17T15:19:48
Java
UTF-8
Java
false
false
4,322
java
package com.gmail.kirill.ked.telegram.service.impl; import com.gmail.kirill.ked.telegram.repository.CityRepository; import com.gmail.kirill.ked.telegram.repository.model.Attraction; import com.gmail.kirill.ked.telegram.repository.model.City; import com.gmail.kirill.ked.telegram.service.CityService; import com.gmail.kirill.ked.telegram.service.converter.Converter; import com.gmail.kirill.ked.telegram.service.exception.CityServiceException; import com.gmail.kirill.ked.telegram.service.model.attraction.AttractionDTO; import com.gmail.kirill.ked.telegram.service.model.city.CityDTO; import com.gmail.kirill.ked.telegram.service.model.city.UpdateCityDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import javax.transaction.Transactional; import java.util.List; import java.util.stream.Collectors; @Service public class CityServiceImpl implements CityService { private final static Logger logger = LoggerFactory.getLogger(CityServiceImpl.class); private final static String ERROR_MESSAGE = "city with id {} doesnt exist in database"; private final CityRepository cityRepository; private final Converter<CityDTO, City> cityConverter; private final Converter<AttractionDTO, Attraction> attractionConverter; public CityServiceImpl(CityRepository cityRepository, @Qualifier("cityConverter") Converter<CityDTO, City> cityConverter, @Qualifier("attractionConverter") Converter<AttractionDTO, Attraction> attractionConverter) { this.cityRepository = cityRepository; this.cityConverter = cityConverter; this.attractionConverter = attractionConverter; } @Override @Transactional public void addCity(CityDTO city) { City savedCity = cityConverter.toEntity(city); cityRepository.persist(savedCity); logger.info("city with name {} successfully saved in database", city.getName()); } @Override @Transactional public CityDTO getByName(String name) { City city = cityRepository.getByName(name); if (city == null) { logger.info("not found city with this name {}", name); return null; } else { logger.info("city with name {} found", name); return cityConverter.toDTO(city); } } @Override @Transactional public void updateCity(UpdateCityDTO updateCityDTO) throws CityServiceException { City city = cityRepository.getById(updateCityDTO.getId()); if (city == null) { logger.info(ERROR_MESSAGE, updateCityDTO.getId()); throw new CityServiceException("not found city with current id"); } city.setName(updateCityDTO.getName()); cityRepository.merge(city); logger.info(" update successfully, city with id {} have name {}", city.getId(), city.getName()); } @Override @Transactional public void deleteCity(Long id) throws CityServiceException { City city = cityRepository.getById(id); if (city == null) { logger.info(ERROR_MESSAGE, id); throw new CityServiceException("not found city with current id"); } cityRepository.remove(city); logger.info("city with id {} deleted from database ", id); } @Override @Transactional public List<CityDTO> getAll() { List<City> cityList = cityRepository.findAll(); logger.info("count of founded cities is {}", cityList.size()); return getListOfDTOs(cityList); } @Override @Transactional public void addAttraction(AttractionDTO attractionDTO, Long cityId) throws CityServiceException { City city = cityRepository.getById(cityId); if (city == null) { logger.info(ERROR_MESSAGE, cityId); throw new CityServiceException("not found city with current id"); } city.getAttractions().add(attractionConverter.toEntity(attractionDTO)); cityRepository.merge(city); } private List<CityDTO> getListOfDTOs(List<City> cityList) { return cityList.stream() .map(cityConverter::toDTO) .collect(Collectors.toList()); } }
[ "derynem@gmail.com" ]
derynem@gmail.com
d55ea6d8d8376f74116b2619156088c6784452a9
8e80738a804636b14a75f23c767a8508b43f8184
/src/ProyectoFinal/Dato.java
1d6870c02529ee89fe4356a3ec25df8c7bf0bb53
[]
no_license
dmadi/ProyectoDamianJimenez
61e4d714e416a4ae62242160604f1279ea2a46c4
61a604f578991e1e69bced30671b93554137fc71
refs/heads/master
2016-08-07T05:07:48.969359
2014-04-24T19:09:38
2014-04-24T19:09:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,788
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 ProyectoFinal; import java.io.Serializable; /** * * @author Damian */ public class Dato implements Serializable { int numero; String pregunta; String respuestaC; String respuestaI; String respuestaI2; public int getNumero() { return numero; } public void setNumero(int numero) { this.numero = numero; } public String getPregunta() { return pregunta; } public void setPregunta(String pregunta) { this.pregunta = pregunta; } public String getRespuestaC() { return respuestaC; } public void setRespuestaC(String respuestaC) { this.respuestaC = respuestaC; } public String getRespuestaI() { return respuestaI; } public void setRespuestaI(String respuestaI) { this.respuestaI = respuestaI; } public String getRespuestaI2() { return respuestaI2; } public void setRespuestaI2(String respuestaI2) { this.respuestaI2 = respuestaI2; } @Override public String toString() { return "Dato (" + "numero=" + numero + ", pregunta=" + pregunta + ", respuesta1=" + respuestaC+ ", respuesta2=" + respuestaI+ ", respuesta3=" + respuestaI2 + ')'; } public Dato(int numero, String pregunta, String respuestaC, String respuestaI, String respuestaI2) { this.numero = numero; this.pregunta = pregunta; this.respuestaC = respuestaC; this.respuestaI = respuestaI; this.respuestaI2 = respuestaI2; } }
[ "Damian@Damian-PC" ]
Damian@Damian-PC
b2b5fd68cf44208e0f1880336244fd8da98cc034
f4e7943708ebd46fb82f5732f99ea4cf93fa18fc
/FindUniqueElement.java
a0a9139bbe5661afb7e1a6a6220417f86ba44c7d
[]
no_license
sundaresanm/ds-algo-interview-practice
089e50a4e80672883465f94642270e1501c28edc
544c0e4d5364f1a64e3edecc8ca3a33e434483a4
refs/heads/master
2022-12-16T22:36:11.774491
2020-09-19T07:51:23
2020-09-19T07:51:23
null
0
0
null
null
null
null
UTF-8
Java
false
false
770
java
/* */ import java.util.Arrays; public class FindUniqueElement { public static void main(String[] str){ int arr[] = { 6, 1, 1, 6, 8, 4, 10, 8, 4}; System.out.println("input array = " + Arrays.toString(arr)); System.out.println("unique element = " + method1(arr)); } /** Time Complexity: O(n) Space complexity: O(n) */ public static int method1(int[] ar){ int arSize = ar.length; int j; for(int i=0; i<arSize; i++){ for(j=0; j<arSize; j++){ if(i!=j && ar[i] == ar[j]){ ar[j] = -ar[j]; break; } } if(j == arSize) return ar[i]; } return -1; } }
[ "rajeevkumar@Rajeevs-MacBook-Pro-2.local" ]
rajeevkumar@Rajeevs-MacBook-Pro-2.local
95ecc137eb585e58033b12b38db30e320bf02b88
a096673f4c00c19d0871d83718bb820cfe4f3900
/oreon.engine/src/apps/oreonworlds/assets/plants/Bush01ClusterGroup.java
09f6ae5802501356abf265d3597d4cc0edb1cd3a
[ "MIT" ]
permissive
dentmaged/Oreon.Engine-OpenGL-Java
9980ec367054fbd0fbcf6aa380c0224a2320eebd
b3f11abbeff2a59bd525a4fe18d61494a02cd5eb
refs/heads/master
2021-01-22T07:47:35.493671
2017-05-19T19:35:13
2017-05-19T19:35:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,496
java
package apps.oreonworlds.assets.plants; import apps.oreonworlds.shaders.plants.BushShader; import apps.oreonworlds.shaders.plants.BushShadowShader; import engine.buffers.MeshVAO; import engine.configs.AlphaTestCullFaceDisable; import engine.math.Vec3f; import engine.scenegraph.components.RenderInfo; import modules.instancing.InstancedDataObject; import modules.instancing.InstancingObject; import modules.modelLoader.obj.Model; import modules.modelLoader.obj.OBJLoader; public class Bush01ClusterGroup extends InstancingObject{ public Bush01ClusterGroup(){ Model[] models = new OBJLoader().load("./res/oreonworlds/assets/plants/Bush_01","Bush_01.obj","Bush_01.mtl"); for (Model model : models){ InstancedDataObject object = new InstancedDataObject(); MeshVAO meshBuffer = new MeshVAO(); model.getMesh().setTangentSpace(false); model.getMesh().setInstanced(true); meshBuffer.addData(model.getMesh()); object.setRenderInfo(new RenderInfo(new AlphaTestCullFaceDisable(0.1f), BushShader.getInstance(), BushShadowShader.getInstance())); object.setMaterial(model.getMaterial()); object.setVao(meshBuffer); getObjectData().add(object); } addChild(new Bush01Cluster(12,new Vec3f(1218,0,-503),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(925,0,-1022),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(861,0,-1035),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(797,0,-1048),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1147,0,-469),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(1224,0,-279),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1303,0,-191),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1066,0,-1120),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1266,0,-1146),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1549,0,-1264),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1867,0,-1190),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1773,0,-1089),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1117,0,-737),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1162,0,-739),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1129,0,-697),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(976,0,-348),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(894,0,-94),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(836,0,-92),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(807,0,-195),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(755,0,208),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(930,0,293),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(920,0,231),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(611,0,997),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(555,0,1231),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(965,0,546),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(900,0,649),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(561,0,1406),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1181,0,-646),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(561,0,1406),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(988,0,-53),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1297,0,484),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(757,0,752),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(678,0,834),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(1607,0,-1256),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(1306,0,-1172),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(962,0,-1088),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(1093,0,-423),getObjectData())); addChild(new Bush01Cluster(20,new Vec3f(885,0,89),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(816,0,131),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(763,0,155),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(645,0,1010),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(438,0,1330),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(1728,0,-1214),getObjectData())); addChild(new Bush01Cluster(12,new Vec3f(992,0,-976),getObjectData())); } }
[ "fynnfluegge@gmx.de" ]
fynnfluegge@gmx.de
07981f23272c6949c784c00d8a183f79af9c6a61
072bc2ead5b9b029dfad810ac5fb9dfa40a93b9c
/app/src/main/java/com/power/bunkTech/data/LoginRepository.java
fb6f691d96bc2b0c76ca2a407c38b953124d77ee
[]
no_license
PakoBrandoon/bus-app
e52aedb19b3a3666654da24bba23f56816d7561c
98188f8b13453bf2a4b3d5a91ea4dd2876e7d63a
refs/heads/master
2023-08-05T07:29:37.263785
2021-09-16T12:32:29
2021-09-16T12:32:29
407,154,996
0
0
null
null
null
null
UTF-8
Java
false
false
1,706
java
package com.power.bunkTech.data; import com.power.bunkTech.data.model.LoggedInUser; /** * Class that requests authentication and user information from the remote data source and * maintains an in-memory cache of login status and user credentials information. */ public class LoginRepository { private static volatile LoginRepository instance; private LoginDataSource dataSource; // If user credentials will be cached in local storage, it is recommended it be encrypted // @see https://developer.android.com/training/articles/keystore private LoggedInUser user = null; // private constructor : singleton access private LoginRepository(LoginDataSource dataSource) { this.dataSource = dataSource; } public static LoginRepository getInstance(LoginDataSource dataSource) { if (instance == null) { instance = new LoginRepository(dataSource); } return instance; } public boolean isLoggedIn() { return user != null; } public void logout() { user = null; dataSource.logout(); } private void setLoggedInUser(LoggedInUser user) { this.user = user; // If user credentials will be cached in local storage, it is recommended it be encrypted // @see https://developer.android.com/training/articles/keystore } public Result<LoggedInUser> login(String username, String password) { // handle login Result<LoggedInUser> result = dataSource.login(username, password); if (result instanceof Result.Success) { setLoggedInUser(((Result.Success<LoggedInUser>) result).getData()); } return result; } }
[ "pako.motsilanyane@studentmail.biust.ac.bw" ]
pako.motsilanyane@studentmail.biust.ac.bw
b77d21490774c576f36bc4643615f10e5ac95f9f
8ce57f3d8730091c3703ad95f030841a275d8c65
/test/testsuite/ouroboros/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/ProxyExObjectwaitInterruptedException.java
74b2a44476bb9f9742b100cdcbf14bfbea2a3b28
[]
no_license
TanveerTanjeem/OpenArkCompiler
6c913ebba33eb0509f91a8f884a87ef8431395f6
6acb8e0bac4ed3c7c24f5cb0196af81b9bedf205
refs/heads/master
2022-11-17T21:08:25.789107
2020-07-15T09:00:48
2020-07-15T09:00:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,057
java
/* * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. * You may obtain a copy of Mulan PSL v1 at: * * http://license.coscl.org.cn/MulanPSL * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR * FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v1 for more details. * -@TestCaseID: ProxyExObjectwaitInterruptedException.java * -@TestCaseName: Exception in reflect Proxy: final void wait(*) * -@TestCaseType: Function Test * -@RequirementName: 补充重写类的父类方法 * -@Brief: * -#step1: Create three private classes to implement Runnable, run sampleField1 as a synchronization lock, Call wait(), * wait (millis), wait (millis, nanos) respectively * -#step2: Call the run of the use case, execute the start () method of the private class 1, and wait for 100 * milliseconds to interrupt * -#step3: Execute the start () method of private class 2 and wait for 100 milliseconds to interrupt * -#step4: Execute the start () method of private class 3 and wait for 100 milliseconds to interrupt * -#step5: Confirm whether all classes are successfully interrupted and InterruptedException is successfully caught * -@Expect:0\n * -@Priority: High * -@Source: ProxyExObjectwaitInterruptedException.java * -@ExecuteClass: ProxyExObjectwaitInterruptedException * -@ExecuteArgs: */ import java.lang.reflect.Proxy; import java.lang.reflect.Method; import java.lang.reflect.InvocationHandler; public class ProxyExObjectwaitInterruptedException { static int res = 99; private MyProxy8 proxy = new MyProxy8(new MyInvocationHandler7()); public static void main(String argv[]) { System.out.println(new ProxyExObjectwaitInterruptedException().run()); } private class ProxyExObjectwaitInterruptedException11 implements Runnable { // final void wait() private int remainder; private ProxyExObjectwaitInterruptedException11(int remainder) { this.remainder = remainder; } /** * Thread run fun */ public void run() { synchronized (proxy) { proxy.notifyAll(); try { proxy.wait(); ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; } catch (InterruptedException e1) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; } catch (IllegalMonitorStateException e2) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; } } } } private class ProxyExObjectwaitInterruptedException21 implements Runnable { // final void wait(long millis) private int remainder; long millis = 10000; private ProxyExObjectwaitInterruptedException21(int remainder) { this.remainder = remainder; } /** * Thread run fun */ public void run() { synchronized (proxy) { proxy.notifyAll(); try { proxy.wait(millis); ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; } catch (InterruptedException e1) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; } catch (IllegalMonitorStateException e2) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; } catch (IllegalArgumentException e3) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 5; } } } } private class ProxyExObjectwaitInterruptedException31 implements Runnable { // final void wait(long millis, int nanos) private int remainder; long millis = 10000; int nanos = 100; private ProxyExObjectwaitInterruptedException31(int remainder) { this.remainder = remainder; } /** * Thread run fun */ public void run() { synchronized (proxy) { proxy.notifyAll(); try { proxy.wait(millis, nanos); ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; } catch (InterruptedException e1) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; } catch (IllegalMonitorStateException e2) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; } catch (IllegalArgumentException e3) { ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 5; } } } } /** * sleep fun * * @param slpnum wait time */ public void sleep(int slpnum) { try { Thread.sleep(slpnum); } catch (InterruptedException e) { e.printStackTrace(); } } /** * main test fun * * @return status code */ public int run() { int result = 2; /*STATUS_FAILED*/ // check api normal // final void wait() Thread t1 = new Thread(new ProxyExObjectwaitInterruptedException11(1)); // final void wait(long millis) Thread t3 = new Thread(new ProxyExObjectwaitInterruptedException21(3)); // final void wait(long millis, int nanos) Thread t5 = new Thread(new ProxyExObjectwaitInterruptedException31(5)); t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.out.println(t.getName() + " : " + e.getMessage()); } }); t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.out.println(t.getName() + " : " + e.getMessage()); } }); t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.out.println(t.getName() + " : " + e.getMessage()); } }); t1.start(); sleep(1000); t1.interrupt(); sleep(1000); t3.start(); sleep(1000); t3.interrupt(); sleep(1000); t5.start(); sleep(1000); t5.interrupt(); sleep(1000); if (result == 2 && ProxyExObjectwaitInterruptedException.res == 96) { result = 0; } return result; } } class MyProxy8 extends Proxy { MyProxy8(InvocationHandler h) { super(h); } InvocationHandler getInvocationHandlerField() { return h; } } class MyInvocationHandler7 implements InvocationHandler { /** * invoke test * * @param proxy proxy test * @param method method for test * @param args object[] for test * @return any implementation * @throws Throwable exception */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return new Object(); // any implementation } } // EXEC:%maple %f %build_option -o %n.so // EXEC:%run %n.so %n %run_option | compare %f // ASSERT: scan 0\n
[ "fuzhou@huawei.com" ]
fuzhou@huawei.com
39a038b18d31fb84f5cfc1e845fd33a3d2c8856b
cbf2c453a014f82378d1a00c31c7488d394a8e3f
/module-1/14_Unit_Testing/student-exercise/java/src/test/java/com/techelevator/FrontTimesTest.java
ba6440f3c1c8c719a9afbdb8a6b95d5a205d0d78
[]
no_license
Ecothecoder/ethancornett-java
eb5cff65e5ee12f7bc444d5146e73efc42094682
17787b7a57a42d204029f2af9e105f5d4341235c
refs/heads/master
2021-07-16T02:11:24.442821
2019-12-20T19:46:34
2019-12-20T19:46:34
209,069,706
0
0
null
2020-10-13T18:22:06
2019-09-17T14:02:39
TSQL
UTF-8
Java
false
false
717
java
package com.techelevator; import org.junit.Test; import junit.framework.Assert; public class FrontTimesTest { @Test public void makeSureTheStringIsRepeating() { FrontTimes testMe = new FrontTimes(); String repeat = testMe.generateString("Chocolate", 3); String repeat2 = testMe.generateString("Ethan", 4); String repeat3 = testMe.generateString("Zombie", 1); String repeat4 = testMe.generateString("Ca", 2); String repeat5 = testMe.generateString("AllIwantforChristmasisyou", 3); Assert.assertEquals("ChoChoCho", repeat); Assert.assertEquals("EthEthEthEth", repeat2); Assert.assertEquals("Zom", repeat3); Assert.assertEquals("CaCa", repeat4); Assert.assertEquals("AllAllAll", repeat5); } }
[ "EthaneCornett@gmail.com" ]
EthaneCornett@gmail.com
0958be1b1aca302c605edae294e1f60ff03cf99b
5ca3901b424539c2cf0d3dda52d8d7ba2ed91773
/src_procyon/com/google/protos/BinExport/BinExport$Flowgraph$VertexOrBuilder.java
6710c7aa5659b17b3d8d34ae7d20387f9705e398
[]
no_license
fjh658/bindiff
c98c9c24b0d904be852182ecbf4f81926ce67fb4
2a31859b4638404cdc915d7ed6be19937d762743
refs/heads/master
2021-01-20T06:43:12.134977
2016-06-29T17:09:03
2016-06-29T17:09:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
517
java
package com.google.protos.BinExport; import com.google.protobuf.*; import java.util.*; public interface BinExport$Flowgraph$VertexOrBuilder extends MessageOrBuilder { boolean hasPrime(); long getPrime(); List getInstructionsList(); BinExport$Flowgraph$Vertex$Instruction getInstructions(final int p0); int getInstructionsCount(); List getInstructionsOrBuilderList(); BinExport$Flowgraph$Vertex$InstructionOrBuilder getInstructionsOrBuilder(final int p0); }
[ "manouchehri@riseup.net" ]
manouchehri@riseup.net
d6962cc7eadbb26a7f1b8b460f3be08f77e2e45d
065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be
/eclipseswt_cluster/56034/tar_1.java
763afd18fd2b597b69f160ebe82065a583165d35
[]
no_license
martinezmatias/GenPat-data-C3
63cfe27efee2946831139747e6c20cf952f1d6f6
b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4
refs/heads/master
2022-04-25T17:59:03.905613
2020-04-15T14:41:34
2020-04-15T14:41:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
35,522
java
package org.eclipse.swt.widgets; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved */ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import java.util.Vector; /** * Instances of this class represent a selectable user interface object * that represents an item in a table. * <dl> * <dt><b>Styles:</b></dt> * <dd>(none)</dd> * <dt><b>Events:</b></dt> * <dd>(none)</dd> * </dl> * <p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> */ public class TableItem extends SelectableItem { private static final int FIRST_COLUMN_IMAGE_INDENT = 2; // Space in front of image - first column only private static final int FIRST_COLUMN_TEXT_INDENT = 4; // Space in front of text - first column only private static final int TEXT_INDENT_NO_IMAGE = 2; // Space in front of item text when no item in the column has an image - first column only private static final int TEXT_INDENT = 6; // Space in front of item text - all other columns private static final int SELECTION_PADDING = 6; // Space behind text in a selected item private Vector dataLabels = new Vector(); // Original text set by the user. Items that don't // have a label are represented by a null slot private String[] trimmedLabels = new String[0]; // Text that is actually displayed, may be trimmed // to fit the column private Vector images = new Vector(); // Item images. Items that don't have an image // are represented by a null slot private Point selectionExtent; // Size of the rectangle drawn to indicate a // selected item. private int imageIndent = 0; // the factor by which the item image and check box, if any, // are indented. The multiplier is the image width. private int index; // index of the item in the parent widget /** * Constructs a new instance of this class given its parent * (which must be a <code>Table</code>) and a style value * describing its behavior and appearance. The item is added * to the end of the items maintained by its parent. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * for all SWT widget classes should include a comment which * describes the style constants which are applicable to the class. * </p> * * @param parent a composite control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TableItem(Table parent, int style) { this(parent, style, checkNull(parent).getItemCount()); } /** * Constructs a new instance of this class given its parent * (which must be a <code>Table</code>), a style value * describing its behavior and appearance, and the index * at which to place it in the items maintained by its parent. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * for all SWT widget classes should include a comment which * describes the style constants which are applicable to the class. * </p> * * @param parent a composite control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * @param index the index to store the receiver in its parent * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see SWT * @see Widget#checkSubclass * @see Widget#getStyle */ public TableItem(Table parent, int style, int index) { super(parent, style); parent.addItem(this, index); } /** * Calculate the size of the rectangle drawn to indicate a selected * item. This is also used to draw the selection focus rectangle. * The selection extent is calculated for the first column only (the * only column the selection is drawn in). */ void calculateSelectionExtent() { Table parent = getParent(); TableColumn column = parent.internalGetColumn(TableColumn.FIRST); GC gc = new GC(parent); String trimmedText = getText(gc, column); int gridLineWidth = parent.getGridLineWidth(); if (trimmedText != null) { selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight()); selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING; selectionExtent.x = Math.min( selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth); if (parent.getLinesVisible() == true) { selectionExtent.y -= gridLineWidth; } } gc.dispose(); } /** * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null. * Otherwise return 'table' */ static Table checkNull(Table table) { if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); return table; } protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } public void dispose() { if (isDisposed()) return; Table parent = getParent(); parent.removeItem(this); super.dispose(); } void doDispose() { dataLabels = null; trimmedLabels = null; images = null; selectionExtent = null; super.doDispose(); } /** * Draw the image of the receiver for column 'index' at * 'destinationPosition' using 'gc'. * Stretch/shrink the image to the fixed image size of the receiver's * parent. * @param gc - GC to draw on. * @param destinationPosition - position on the GC to draw at. * @param index - index of the image to draw * @return Answer the position where drawing stopped. */ Point drawImage(GC gc, Point destinationPosition, int index) { Table parent = getParent(); Image image = getImage(index); Rectangle sourceImageBounds; Point destinationImageExtent = parent.getImageExtent(); if (image != null) { sourceImageBounds = image.getBounds(); // full row select would obscure transparent images in all but the first column // so always clear the image area in this case. Fixes 1FYNITC if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) { gc.fillRectangle( destinationPosition.x, destinationPosition.y, destinationImageExtent.x, destinationImageExtent.y); } gc.drawImage( image, 0, 0, // source x, y sourceImageBounds.width, sourceImageBounds.height, // source width, height destinationPosition.x, destinationPosition.y, // destination x, y destinationImageExtent.x, destinationImageExtent.y); // destination width, height } if (((index == TableColumn.FIRST && // always add the image width for the first column parent.hasFirstColumnImage() == true) || // if any item in the first column has an image (index != TableColumn.FIRST && // add the image width if it's not the first column image != null)) && // only when the item actually has an image destinationImageExtent != null) { destinationPosition.x += destinationImageExtent.x; } return destinationPosition; } /** * Draw the label of the receiver for column 'index' at 'position' * using 'gc'. * The background color is set to the selection background color if * the item is selected and the text is drawn for the first column. * @param gc - GC to draw on. * @param position - position on the GC to draw at. * @param index - specifies which subitem text to draw */ void drawText(String label, GC gc, Point position, int index) { Table parent = getParent(); boolean drawSelection; int textOffset; int textHeight; if (label != null) { drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0); if (isSelected() == true && drawSelection == true) { gc.setBackground(getSelectionBackgroundColor()); gc.setForeground(getSelectionForegroundColor()); } textHeight = gc.stringExtent(label).y; textOffset = (parent.getItemHeight() - textHeight) / 2; // vertically center the text gc.drawString(label, position.x, position.y + textOffset); if (isSelected() == true && drawSelection == true) { gc.setBackground(parent.getBackground()); gc.setForeground(parent.getForeground()); } } } /** * Returns a rectangle describing the receiver's size and location * relative to its parent at a column in the table. * * @param index the index that specifies the column * @return the receiver's bounding column rectangle * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public Rectangle getBounds(int index) { checkWidget(); Rectangle itemBounds; Rectangle columnBounds; Rectangle checkboxBounds; Table parent = getParent(); TableColumn column; int itemIndex = parent.indexOf(this); int itemHeight = parent.getItemHeight(); int gridLineWidth = parent.getLinesVisible() ? parent.getGridLineWidth() : 0; int itemYPos; if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) { itemBounds = new Rectangle(0, 0, 0, 0); } else { column = parent.internalGetColumn(index); columnBounds = column.getBounds(); itemYPos = columnBounds.y + itemHeight * itemIndex; itemBounds = new Rectangle( columnBounds.x, itemYPos, columnBounds.width - gridLineWidth, itemHeight - gridLineWidth); if (index == TableColumn.FIRST) { if (isCheckable() == true) { checkboxBounds = getCheckboxBounds(); itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; // add checkbox start, width and space behind checkbox itemBounds.width -= itemBounds.x; } else { itemBounds.x += getImageIndentPixel(); } } } return itemBounds; } /** * Returns <code>true</code> if the receiver is checked, * and false otherwise. When the parent does not have * the <code>CHECK style, return false. * * @return the checked state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public boolean getChecked() { checkWidget(); return super.getChecked(); } /** * Answer the x position of the item check box */ int getCheckboxXPosition() { return getImageIndentPixel(); } /** * Answer the item labels set by the user. * These may not be the same as those drawn on the screen. The latter * may be trimmed to fit the column. Items that don't have a label are * represented by a null slot in the vector. * @return Vector - the item labels set by the user. */ Vector getDataLabels() { return dataLabels; } public Display getDisplay() { return super.getDisplay(); } /** * Return the position at which the string starts that is used * to indicate a truncated item text. * @param columnIndex - index of the column for which the position of * the truncation replacement should be calculated * @param columnWidth - width of the column for which the position of * the truncation replacement should be calculated * @return -1 when the item text is not truncated */ int getDotStartX(int columnIndex, int columnWidth) { GC gc; Table parent = getParent(); String label = getText(columnIndex); int dotStartX = -1; int maxWidth; if (label != null) { gc = new GC(parent); maxWidth = getMaxTextWidth(columnIndex, columnWidth); label = parent.trimItemText(label, maxWidth, gc); if (label.endsWith(Table.DOT_STRING) == true) { dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc); // add indents, margins and image width dotStartX += getImageStopX(columnIndex); dotStartX += getTextIndent(columnIndex); } gc.dispose(); } return dotStartX; } /** * Returns <code>true</code> if the receiver is grayed, * and false otherwise. When the parent does not have * the <code>CHECK style, return false. * * @return the grayed state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public boolean getGrayed() { checkWidget(); return super.getGrayed(); } public Image getImage() { checkWidget(); return getImage(0); } /** * Returns the item image of the column identified by 'columnIndex' or * null if no image has been set for that column. * * @param columnIndex - the column whose image should be returned * @return the item image */ public Image getImage(int columnIndex) { checkWidget(); Image image = null; Vector images = getImages(); int itemIndex = getParent().indexOf(this); if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) { image = (Image) images.elementAt(columnIndex); } return image; } /** * Returns a rectangle describing the size and location * relative to its parent of an image at a column in the * table. * * @param index the index that specifies the column * @return the receiver's bounding image rectangle * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public Rectangle getImageBounds(int index) { checkWidget(); Table parent = getParent(); int itemIndex = parent.indexOf (this); int imageWidth = 0; Point imageExtent = parent.getImageExtent(); Rectangle checkboxBounds; Rectangle imageBounds = getBounds(index); if (itemIndex == -1) { imageBounds = new Rectangle(0, 0, 0, 0); } else if (imageExtent != null) { if (index == TableColumn.FIRST || getImage(index) != null) { imageWidth = imageExtent.x; } } imageBounds.width = imageWidth; return imageBounds; } /** * Gets the image indent. * * @return the indent * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getImageIndent() { checkWidget(); int index = getParent().indexOf(this); if (index == -1) { return 0; } return imageIndent; } /** * Answer the number of pixels the image in the first column is * indented. Calculation starts at the column start and counts * all pixels except the check box. */ int getImageIndentPixel() { int indentPixel = FIRST_COLUMN_IMAGE_INDENT; Point imageExtent = getParent().getImageExtent(); if (imageExtent != null) { indentPixel += imageExtent.x * getImageIndent(); } return indentPixel; } /** * Answer the item images set by the user. Items that don't have an * image are represented by a null slot in the vector. */ Vector getImages() { return images; } /** * Calculate the x coordinate where the item image of column * 'columnIndex' stops. * @param columnIndex - the column for which the stop position of the * image should be calculated. */ int getImageStopX(int columnIndex) { int imageStopX = 0; Table parent = getParent(); Rectangle checkboxBounds; if (columnIndex == TableColumn.FIRST) { if (isCheckable() == true) { checkboxBounds = getCheckboxBounds(); imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; } else { imageStopX = getImageIndentPixel(); } } if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column parent.hasFirstColumnImage() == true) || // if any item in the first column has an image (columnIndex != TableColumn.FIRST && // add the image width if it's not the first column getImage(columnIndex) != null)) && // only when the item actually has an image parent.getImageExtent() != null) { imageStopX += parent.getImageExtent().x; } return imageStopX; } /** * Return the index of the item in its parent widget. */ int getIndex() { return index; } /** * Return the item extent in the specified column * The extent includes the actual width of the item including checkbox, * image and text. */ Point getItemExtent(TableColumn column) { Table parent = getParent(); int columnIndex = column.getIndex(); Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth()); GC gc = new GC(parent); String trimmedText = getText(gc, column); if (trimmedText != null && trimmedText.length() > 0) { extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex); } if (columnIndex == TableColumn.FIRST) { extent.x += SELECTION_PADDING; } gc.dispose(); return extent; } /** * Answer the maximum width in pixel of the text that fits in the * column identified by 'columnIndex' without trimming the text. * @param columnIndex - the column for which the maximum text width * should be calculated. * @param columnWidth - width of the column 'columnIndex' */ int getMaxTextWidth(int columnIndex, int columnWidth) { int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2; return columnWidth - itemWidth; } /** * Returns the receiver's parent, which must be a <code>Table</code>. * * @return the receiver's parent * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public Table getParent() { checkWidget(); return (Table) super.getSelectableParent(); } /** * Answer the width of the item required to display the complete contents. */ int getPreferredWidth(int index) { int size = getImageStopX(index); String text = getText(index); if (text != null) { size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1; } return size; } /** * Return the size of the rectangle drawn to indicate a selected item. * This is also used to draw the selection focus rectangle and drop * insert marker. * Implements SelectableItem#getSelectionExtent */ Point getSelectionExtent() { Table parent = getParent(); Point extent; if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) { // regular, first column, selection? if (selectionExtent == null) { calculateSelectionExtent(); } extent = selectionExtent; } else { extent = parent.getFullSelectionExtent(this); } return extent; } /** * Return the x position of the selection rectangle * Implements SelectableItem#getSelectionX */ int getSelectionX() { return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset(); } public String getText() { checkWidget(); return getText(0); } /** * Returns the item tezt of the column identified by 'columnIndex', * or null if no text has been set for that column. * * @param columnIndex - the column whose text should be returned * @return the item text or null if no text has been set for that column. */ public String getText(int columnIndex) { checkWidget(); int itemIndex = getParent().indexOf(this); Vector labels = getDataLabels(); String label = null; if (itemIndex == -1) { error(SWT.ERROR_CANNOT_GET_TEXT); } if (columnIndex >= 0 && columnIndex < labels.size()) { label = (String) labels.elementAt(columnIndex); } if (label == null) { label = ""; // label vector is initialized with null instead of empty Strings } return label; } /** * Answer the text that is going to be drawn in 'column'. This * text may be a trimmed copy of the original text set by the * user if it doesn't fit into the column. In that case the last * characters are replaced with Table.DOT_STRING. * A cached copy of the trimmed text is returned if available. * @param gc - GC to use for measuring the text extent * @param column - TableColumn for which the text should be returned */ String getText(GC gc, TableColumn column) { int columnIndex = column.getIndex(); String label = getTrimmedText(columnIndex); int maxWidth; if (label == null) { maxWidth = getMaxTextWidth(columnIndex, column.getWidth()); label = getParent().trimItemText(getText(columnIndex), maxWidth, gc); } return label; } /** * Answer the indent of the text in column 'columnIndex' in pixel. * This indent is used in front of and behind the item text. * @param columnIndex - specifies the column for which the indent * should be calculated. */ int getTextIndent(int columnIndex) { int textIndent; if (columnIndex == TableColumn.FIRST) { if (getParent().hasFirstColumnImage() == false) { textIndent = TEXT_INDENT_NO_IMAGE; } else { textIndent = FIRST_COLUMN_TEXT_INDENT; } } else { textIndent = TEXT_INDENT; } return textIndent; } /** * Answer the cached trimmed text for column 'columnIndex'. * Answer null if it hasn't been calculated yet. * @param columnIndex - specifies the column for which the * trimmed text should be answered. */ String getTrimmedText(int columnIndex) { String label = null; String labels[] = getTrimmedTexts(); if (columnIndex < labels.length) { label = labels[columnIndex]; } return label; } /** * Answer an array of cached trimmed labels. */ String [] getTrimmedTexts() { return trimmedLabels; } /** * Ensure that the image and label vectors have at least * 'newSize' number of elements. */ void growVectors(int newSize) { Vector images = getImages(); Vector labels = getDataLabels(); if (newSize > images.size()){ images.setSize(newSize); } if (newSize > labels.size()){ labels.setSize(newSize); } } /** * Insert 'column' into the receiver. */ void insertColumn(TableColumn column) { Vector data = getDataLabels(); Vector images = getImages(); String stringData[]; Image imageData[]; int index = column.getIndex(); if (index < data.size()) { data.insertElementAt(null, index); } else { data.addElement(null); } stringData = new String[data.size()]; data.copyInto(stringData); setText(stringData); if (index < images.size()) { images.insertElementAt(null, index); } else { images.addElement(null); } imageData = new Image[images.size()]; images.copyInto(imageData); setImage(imageData); } /** * Sets the image at an index. * * @param image the new image (or null) * * @exception SWTError(ERROR_THREAD_INVALID_ACCESS) * when called from the wrong thread * @exception SWTError(ERROR_WIDGET_DISPOSED) * when the widget has been disposed */ void internalSetImage(int columnIndex, Image image) { Vector images = getImages(); boolean imageWasNull = false; Table parent = getParent(); if (columnIndex >= 0 && columnIndex < parent.internalGetColumnCount()) { if (columnIndex >= images.size()) { growVectors(columnIndex + 1); } if (((Image) images.elementAt(columnIndex)) == null && image != null) { imageWasNull = true; } if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); images.setElementAt(image, columnIndex); reset(columnIndex); // new image may cause text to no longer fit in the column notifyImageChanged(columnIndex, imageWasNull); } } /** * Sets the widget text. * * The widget text for an item is the label of the * item or the label of the text specified by a column * number. * * @param index the column number * @param text the new text * */ void internalSetText(int columnIndex, String string) { Vector labels = getDataLabels(); Table parent = getParent(); String oldText; if (columnIndex >= 0 && columnIndex < parent.internalGetColumnCount()) { if (columnIndex >= labels.size()) { growVectors(columnIndex + 1); } oldText = (String) labels.elementAt(columnIndex); if (string.equals(oldText) == false) { labels.setElementAt(string, columnIndex); reset(columnIndex); notifyTextChanged(columnIndex, oldText == null); } } } /** * Answer whether the click at 'xPosition' on the receiver is a * selection click. * A selection click occurred when the click was behind the image * and before the end of the item text. * @return * true - 'xPosition' is a selection click. * false - otherwise */ boolean isSelectionHit(int xPosition) { int itemStopX = getImageStopX(TableColumn.FIRST); Point selectionExtent = getSelectionExtent(); if (selectionExtent != null) { itemStopX += selectionExtent.x; } return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX); } /** * The image for the column identified by 'columnIndex' has changed. * Notify the parent widget and supply redraw coordinates, if possible. * @param columnIndex - index of the column that has a new image. */ void notifyImageChanged(int columnIndex, boolean imageWasNull) { Table parent = getParent(); Rectangle changedColumnBounds; int redrawStartX = 0; int redrawWidth = 0; int columnCount = parent.internalGetColumnCount(); if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) { changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds(); redrawStartX = Math.max(0, getImageBounds(columnIndex).x); if (parent.getImageExtent() != null && imageWasNull == false) { redrawWidth = getImageStopX(columnIndex); } else { redrawWidth = changedColumnBounds.width; } redrawWidth += changedColumnBounds.x - redrawStartX; } parent.itemChanged(this, redrawStartX, redrawWidth); } /** * The label for the column identified by 'columnIndex' has changed. * Notify the parent widget and supply redraw coordinates, if possible. * @param columnIndex - index of the column that has a new label. */ void notifyTextChanged(int columnIndex, boolean textWasNull) { Table parent = getParent(); String text; Rectangle columnBounds; int redrawStartX = 0; int redrawWidth = 0; int columnCount = parent.internalGetColumnCount(); if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) { text = (String) getDataLabels().elementAt(columnIndex); columnBounds = parent.internalGetColumn(columnIndex).getBounds(); redrawStartX = columnBounds.x; if (getImage(columnIndex) != null) { redrawStartX += getImageStopX(columnIndex); } redrawStartX = Math.max(0, redrawStartX); // don't redraw if text changed from null to empty string if (textWasNull == false || text.length() > 0) { redrawWidth = columnBounds.x + columnBounds.width - redrawStartX; } } parent.itemChanged(this, redrawStartX, redrawWidth); } /** * Draw the receiver at 'paintPosition' in the column identified by * 'columnIndex' using 'gc'. * @param gc - GC to use for drawing * @param paintPosition - position where the receiver should be drawing. * @param column - the column to draw in */ void paint(GC gc, Point paintPosition, TableColumn column) { int columnIndex = column.getIndex(); String label = getText(gc, column); String oldLabel = getTrimmedText(columnIndex); if (label != null && label.equals(oldLabel) == false) { setTrimmedText(label, columnIndex); selectionExtent = null; // force a recalculation next time the selection extent is needed } if (columnIndex == TableColumn.FIRST) { paintPosition.x += getImageIndentPixel(); if (isCheckable() == true) { paintPosition = drawCheckbox(gc, paintPosition); } } paintPosition = drawImage(gc, paintPosition, columnIndex); paintPosition.x += getTextIndent(columnIndex); drawText(label, gc, paintPosition, columnIndex); } /** * Remove 'column' from the receiver. */ void removeColumn(TableColumn column) { Vector data = getDataLabels(); Vector images = getImages(); String stringData[]; Image imageData[]; int index = column.getIndex(); if (index < data.size()) { data.removeElementAt(index); stringData = new String[data.size()]; data.copyInto(stringData); setText(stringData); } if (index < images.size()) { images.removeElementAt(index); imageData = new Image[images.size()]; images.copyInto(imageData); setImage(imageData); } } /** * Reset the cached trimmed label for the sub item identified by * 'index'. * @param index - index of the label that should be reset. */ void reset(int index) { String trimmedLabels[] = getTrimmedTexts(); if (index >= 0 && index < trimmedLabels.length) { trimmedLabels[index] = null; } if (index == TableColumn.FIRST) { selectionExtent = null; } } /** * Sets the image for multiple columns in the Table. * * @param images the array of new images * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li> * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setImage(Image [] images) { checkWidget(); if (images == null) { error(SWT.ERROR_NULL_ARGUMENT); } if (getParent().indexOf(this) == -1) { return; } for (int i = 0; i < images.length; i++) { internalSetImage(i, images[i]); } } /** * Sets the receiver's image at a column. * * @param index the column index * @param image the new image * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setImage(int index, Image image) { checkWidget(); if (getParent().indexOf(this) != -1) { internalSetImage(index, image); } } public void setImage(Image image) { checkWidget(); setImage(0, image); } /** * Sets the image indent. * * @param indent the new indent * * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setImageIndent(int indent) { checkWidget(); Table parent = getParent(); TableColumn column; int index = parent.indexOf(this); if (index != -1 && indent >= 0 && indent != imageIndent) { imageIndent = indent; column = parent.internalGetColumn(TableColumn.FIRST); parent.redraw( 0, parent.getRedrawY(this), column.getWidth(), parent.getItemHeight(), false); } } /** * Sets the text for multiple columns in the table. * * @param strings the array of new strings * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the text is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setText(String [] strings) { checkWidget(); if (strings == null) { error(SWT.ERROR_NULL_ARGUMENT); } if (getParent().indexOf(this) == -1) { return; } for (int i = 0; i < strings.length; i++) { String string = strings[i]; if (string != null) { internalSetText(i, string); } } } /** * Sets the receiver's text at a column * * @param index the column index * @param string the new text * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the text is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setText (int index, String string) { checkWidget(); if (string == null) { error(SWT.ERROR_NULL_ARGUMENT); } if (getParent().indexOf(this) != -1) { internalSetText(index, string); } } public void setText(String text) { checkWidget(); if (text == null) { error(SWT.ERROR_NULL_ARGUMENT); } setText(0, text); } /** * Set the trimmed text of column 'columnIndex' to label. The trimmed * text is the one that is displayed in a column. It may be shorter than * the text originally set by the user via setText(...) to fit the * column. * @param label - the text label of column 'columnIndex'. May be trimmed * to fit the column. * @param columnIndex - specifies the column whose text label should be * set. */ void setTrimmedText(String label, int columnIndex) { String labels[] = getTrimmedTexts(); if (columnIndex < labels.length) { labels[columnIndex] = label; } } /** * Sets the checked state of the receiver. * * @param checked the new checked state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setChecked(boolean checked) { checkWidget(); super.setChecked(checked); } /** * Sets the grayed state of the receiver. * * @param checked the new grayed state * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setGrayed (boolean grayed) { checkWidget(); super.setGrayed(grayed); } /** * Set the index of this item in its parent widget to 'newIndex'. */ void setIndex(int newIndex) { index = newIndex; } }
[ "375833274@qq.com" ]
375833274@qq.com
8898c2d9a97a494e1e70c77d88d35229a72cd251
d74a7ac4b88aa2cc3bb06cec898a462312ae2759
/src/main/java/com/cczu/model/controller/PageWghglXjszController.java
327d2a305b8b73fbdd150e1d8fd481c1274ea448
[]
no_license
wuyufei2019/test110
74dbfd15af2dfd72640032a8207f7ad5aa5da604
8a8621370eb92e6071f517dbcae9d483ccc4db36
refs/heads/master
2022-12-21T12:28:37.800274
2019-11-18T08:33:53
2019-11-18T08:33:53
222,402,348
0
0
null
2022-12-16T05:03:11
2019-11-18T08:45:49
Java
UTF-8
Java
false
false
8,288
java
package com.cczu.model.controller; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.cczu.model.entity.YHPC_CheckPlanEntity; import com.cczu.model.entity.YHPC_CheckPlan_Time; import com.cczu.model.service.WghglXjszService; import com.cczu.model.service.YhpcCheckPlanService; import com.cczu.sys.comm.controller.BaseController; import com.cczu.sys.comm.mapper.JsonMapper; import com.cczu.sys.system.service.ShiroRealm.ShiroUser; import com.cczu.sys.system.utils.UserUtil; /** * 网格员巡检设置 * @author zpc * @date 2017/09/6 */ @Controller @RequestMapping("wghgl/xjsz") public class PageWghglXjszController extends BaseController{ @Autowired private WghglXjszService wghglXjszService; @Autowired private YhpcCheckPlanService yhpcCheckPlanService; /** * 默认页面 */ @RequestMapping(value="index") public String index(Model model) { if("0".equals(UserUtil.getCurrentShiroUser().getUsertype())){ return "wghgl/xjsz/index"; }else{ return "../error/403"; } } /** * list页面 */ @RequestMapping(value="list") @ResponseBody public Map<String, Object> getData(HttpServletRequest request) { Map<String, Object> map = getPageMap(request); map.put("bcname", request.getParameter("wghgl_xjsz_bcname")); map.put("xzqy", UserUtil.getCurrentShiroUser().getXzqy()); map.put("wgid", request.getParameter("wghgl_xjsz_wgid")); return wghglXjszService.dataGrid(map); } /** * 添加巡检班次任务设置跳转 * * @param model */ @RequestMapping(value = "create" , method = RequestMethod.GET) public String create(Model model) { model.addAttribute("action", "create"); return "wghgl/xjsz/form"; } /** * 添加信息 * @param request,model */ @RequestMapping(value = "create" ) @ResponseBody public String create(YHPC_CheckPlanEntity bcrw, HttpServletRequest request) { String datasuccess="success"; ShiroUser user = UserUtil.getCurrentShiroUser(); bcrw.setID1(Long.parseLong("0"));//安监为0 bcrw.setCreatetime(new Timestamp(System.currentTimeMillis()));//创建时间 bcrw.setUserid(user.getId().longValue());//建立人id long id = wghglXjszService.addInfo(bcrw); //添加任务时间 String[] start=request.getParameterValues("start"); String[] end=request.getParameterValues("end"); if(start!=null){ for(int i=0;i<start.length;i++){ YHPC_CheckPlan_Time sj = new YHPC_CheckPlan_Time(); sj.setID1(id); sj.setStarttime(start[i]); sj.setEndtime(end[i]); yhpcCheckPlanService.addxjbcsjInfo(sj); } } //添加检查点 // List<Map<String,Object>> list = wghglXjszService.getWgdByWgid(bcrw.getWgid()); // for (Map<String, Object> map : list) { // YHPC_CheckPlan_Point y2 = new YHPC_CheckPlan_Point(); // y2.setID1(id); // y2.setID2(Long.parseLong(map.get("id").toString())); // y2.setCheckpointtype("2"); // wghglXjszService.addxjbcjcdInfo(y2); // } return datasuccess; } /** * 删除巡检班次任务 * @param user * @param model * */ @RequestMapping(value = "delete/{ids}") @ResponseBody public String delete(@PathVariable("ids") String ids) { String datasuccess="删除成功"; //可以批量删除 String[] aids = ids.split(","); for(int i=0;i<aids.length;i++){ wghglXjszService.deleteInfo(Long.parseLong(aids[i])); //wghglXjszService.deletexjbcjcdInfo(Long.parseLong(aids[i])); yhpcCheckPlanService.deletexjbcsjInfo(Long.parseLong(aids[i]));//删除时间表信息 } return datasuccess; } /** * 修改页面跳转 * @param id,model */ @RequestMapping(value = "update/{id}", method = RequestMethod.GET) public String update(@PathVariable("id") Long id, Model model) { YHPC_CheckPlanEntity bcrw = wghglXjszService.findById(id); List<YHPC_CheckPlan_Time> rwsjlist = yhpcCheckPlanService.rwsjList(id); model.addAttribute("rwsjlist", JsonMapper.getInstance().toJson(rwsjlist)); model.addAttribute("bcrw", bcrw); model.addAttribute("action", "update"); return "wghgl/xjsz/form"; } /** * 修改 * @param request,model */ @RequestMapping(value = "update") @ResponseBody public String update(YHPC_CheckPlanEntity bcrw, HttpServletRequest request, Model model){ String datasuccess="success"; yhpcCheckPlanService.deletexjbcsjInfo(bcrw.getID());//删除时间表信息 //wghglXjszService.deletexjbcjcdInfo(bcrw.getID()); wghglXjszService.updateInfo(bcrw); //添加任务时间 String[] start=request.getParameterValues("start"); String[] end=request.getParameterValues("end"); if(start!=null){ for(int i=0;i<start.length;i++){ YHPC_CheckPlan_Time sj = new YHPC_CheckPlan_Time(); sj.setID1(bcrw.getID()); sj.setStarttime(start[i]); sj.setEndtime(end[i]); yhpcCheckPlanService.addxjbcsjInfo(sj); } } //添加检查点 // List<Map<String,Object>> list = wghglXjszService.getWgdByWgid(bcrw.getWgid()); // for (Map<String, Object> map : list) { // YHPC_CheckPlan_Point y2 = new YHPC_CheckPlan_Point(); // y2.setID1(bcrw.getID()); // y2.setID2(Long.parseLong(map.get("id").toString())); // y2.setCheckpointtype("2"); // wghglXjszService.addxjbcjcdInfo(y2); // } return datasuccess; } /** * 查看页面跳转 * @param id,model */ @RequestMapping(value = "view/{id}", method = RequestMethod.GET) public String view(@PathVariable("id") Long id, Model model) { YHPC_CheckPlanEntity bcrw = wghglXjszService.findById(id); String jcdnames = ""; List<YHPC_CheckPlan_Time> rwsjlist1 = yhpcCheckPlanService.rwsjList(id); List<YHPC_CheckPlan_Time> rwsjlist2 = new ArrayList<>(); if(bcrw.getType().equals("4")){ for (YHPC_CheckPlan_Time yct : rwsjlist1) { switch (yct.getStarttime()) { case "1": yct.setStarttime("一月初"); break; case "2": yct.setStarttime("二月初"); break; case "3": yct.setStarttime("三月初"); break; case "4": yct.setStarttime("四月初"); break; case "5": yct.setStarttime("五月初"); break; case "6": yct.setStarttime("六月初"); break; case "7": yct.setStarttime("七月初"); break; case "8": yct.setStarttime("八月初"); break; case "9": yct.setStarttime("九月初"); break; case "10": yct.setStarttime("十月初"); break; case "11": yct.setStarttime("十一月初"); break; case "12": yct.setStarttime("十二月初"); break; default: break; }; switch (yct.getEndtime()) { case "1": yct.setEndtime("一月末"); break; case "2": yct.setEndtime("二月末"); break; case "3": yct.setEndtime("三月末"); break; case "4": yct.setEndtime("四月末"); break; case "5": yct.setEndtime("五月末"); break; case "6": yct.setEndtime("六月末"); break; case "7": yct.setEndtime("七月末"); break; case "8": yct.setEndtime("八月末"); break; case "9": yct.setEndtime("九月末"); break; case "10": yct.setEndtime("十月末"); break; case "11": yct.setEndtime("十一月末"); break; case "12": yct.setEndtime("十二月末"); break; default: break; }; rwsjlist2.add(yct); } }else{ rwsjlist2 = rwsjlist1; } model.addAttribute("rwsjlist", rwsjlist2); //巡检点数据拼接 // List<Map<String,Object>> list2 = wghglXjszService.getidname2(bcrw.getID()); // if(list2.size()>0){ // for (Map<String, Object> map : list2) { // jcdnames = jcdnames + map.get("name") +" , "; // } // jcdnames = jcdnames.substring(0, jcdnames.length()-2); // } model.addAttribute("jcdnames", jcdnames); model.addAttribute("bcrw", bcrw); return "wghgl/xjsz/view"; } }
[ "wuyufei2019@sina.com" ]
wuyufei2019@sina.com
4bb915ae5312edf6ae93643a101fc4e784c6335a
01faa1318b24e2b0f0dd63abe1daa6df11f1e220
/android/app/src/main/java/com/smiles_21366/MainApplication.java
55ab3d30e01be4a86e26ba4403747463d9502f75
[]
no_license
crowdbotics-apps/smiles-21366
8c86f08b7fb10ec77dc4ba9bc09192b63443cba2
6d57fe1e1f9c5fd7a2a806734556638b1f536015
refs/heads/master
2022-12-28T17:24:06.222261
2020-10-11T18:00:08
2020-10-11T18:00:08
303,180,950
0
0
null
null
null
null
UTF-8
Java
false
false
2,689
java
package com.smiles_21366; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
[ "team@crowdbotics.com" ]
team@crowdbotics.com