blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
332
content_id
stringlengths
40
40
detected_licenses
listlengths
0
50
license_type
stringclasses
2 values
repo_name
stringlengths
7
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
557 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
684M
star_events_count
int64
0
77.7k
fork_events_count
int64
0
48k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
82 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
5.41M
extension
stringclasses
11 values
content
stringlengths
7
5.41M
authors
listlengths
1
1
author
stringlengths
0
161
3b66b72270d43cddaa6a511f754972619fd6c2fd
d2d2f11495409ac44552ce85e1457dd710a1fc39
/BlogDemo/src/main/java/com/example/blog/BlogDemo/repository/UserRepository.java
d2eadf0d643de8908c5011b7b2b7af7420723e36
[]
no_license
challahemanth/BlogUsingJWT
72975d2d0f90faff207b892451af9032df07ac6e
5ea14b8368236a777d6d2e4c69846cea62e8e1b1
refs/heads/main
2023-02-17T18:24:00.656643
2021-01-21T12:21:42
2021-01-21T12:21:42
331,618,923
0
0
null
null
null
null
UTF-8
Java
false
false
367
java
package com.example.blog.BlogDemo.repository; import com.example.blog.BlogDemo.model.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; @Repository public interface UserRepository extends JpaRepository<User,Long> { Optional<User> findByUserName(String userName); }
c4dd6d7f91d6ab3ab6aa8b251b8958c00b0a6b59
b8cde457bb3af0023a54fe0ea4de660680cff624
/MaterialMe/app/src/main/java/com/example/android/materialme/Sport.java
6380310b0e348fe4cd8ecc43e048843e4dede1df
[ "Apache-2.0" ]
permissive
osaetinevbuoma/google_android_fundamentals
bc4b5e1377e49015a1f6216a9a05601bc9d74431
cb7c3aba6a200320f759ded1923748990bf055c8
refs/heads/master
2020-05-16T04:16:20.774872
2019-05-10T12:18:44
2019-05-10T12:18:44
182,744,055
0
0
null
null
null
null
UTF-8
Java
false
false
1,701
java
/* * Copyright (C) 2018 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.materialme; /** * Data model for each row of the RecyclerView */ class Sport { // Member variables representing the title and information about the sport. private String title; private String info; private final int imageResource; /** * Constructor for the Sport data model. * * @param title The name if the sport. * @param info Information about the sport. */ Sport(String title, String info, int imageResource) { this.title = title; this.info = info; this.imageResource = imageResource; } /** * Gets the title of the sport. * * @return The title of the sport. */ String getTitle() { return title; } /** * Gets the info about the sport. * * @return The info about the sport. */ String getInfo() { return info; } /** * Get the image resource ID of the sport * * @return The image resource ID of the sport. */ public int getImageResource() { return imageResource; } }
b3f08510dbeddad75d3d0c066619d2be470f26fa
f16070a9c35d065e2b004eea5c4ad0e09d5a9c74
/.metadata/.plugins/org.jboss.ide.eclipse.as.core/Test/deploy/cxf-rt/ws/rm/target/generated/src/main/java/org/apache/cxf/ws/rm/manager/SourcePolicyType.java
0ff2ec938cc4f90654741f857ee2d04d32d82563
[]
no_license
NoorAshrafi/jpbm668
c797710b9c011e17c748ca91e6c8fa1e908e3889
7dbaeb8df4fb926da354dca75db7bffec8fd9810
refs/heads/master
2021-05-31T15:14:53.790959
2016-05-23T14:35:36
2016-05-23T14:35:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,790
java
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2013.11.25 at 09:44:24 AM CET // package org.apache.cxf.ws.rm.manager; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; /** * RM source configuration properties. * Used for configuring an RM source. * * * <p>Java class for SourcePolicyType complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="SourcePolicyType"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="sequenceTerminationPolicy" type="{http://cxf.apache.org/ws/rm/manager}SequenceTerminationPolicyType" minOccurs="0"/> * &lt;element name="retryPolicy" type="{http://cxf.apache.org/ws/rm/manager}RetryPolicyType" minOccurs="0"/> * &lt;/sequence> * &lt;attribute name="sequenceExpiration" type="{http://www.w3.org/2001/XMLSchema}duration" default="PT0S" /> * &lt;attribute name="acksTo" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="includeOffer" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" /> * &lt;attribute name="offeredSequenceExpiration" type="{http://www.w3.org/2001/XMLSchema}duration" default="PT0S" /> * &lt;attribute name="maxSequences" type="{http://www.w3.org/2001/XMLSchema}int" default="0" /> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "SourcePolicyType", propOrder = { "sequenceTerminationPolicy", "retryPolicy" }) public class SourcePolicyType { protected SequenceTerminationPolicyType sequenceTerminationPolicy; protected RetryPolicyType retryPolicy; @XmlAttribute(name = "sequenceExpiration") protected Duration sequenceExpiration; @XmlAttribute(name = "acksTo") protected String acksTo; @XmlAttribute(name = "includeOffer") protected Boolean includeOffer; @XmlAttribute(name = "offeredSequenceExpiration") protected Duration offeredSequenceExpiration; @XmlAttribute(name = "maxSequences") protected Integer maxSequences; /** * Gets the value of the sequenceTerminationPolicy property. * * @return * possible object is * {@link SequenceTerminationPolicyType } * */ public SequenceTerminationPolicyType getSequenceTerminationPolicy() { return sequenceTerminationPolicy; } /** * Sets the value of the sequenceTerminationPolicy property. * * @param value * allowed object is * {@link SequenceTerminationPolicyType } * */ public void setSequenceTerminationPolicy(SequenceTerminationPolicyType value) { this.sequenceTerminationPolicy = value; } public boolean isSetSequenceTerminationPolicy() { return (this.sequenceTerminationPolicy!= null); } /** * Gets the value of the retryPolicy property. * * @return * possible object is * {@link RetryPolicyType } * */ public RetryPolicyType getRetryPolicy() { return retryPolicy; } /** * Sets the value of the retryPolicy property. * * @param value * allowed object is * {@link RetryPolicyType } * */ public void setRetryPolicy(RetryPolicyType value) { this.retryPolicy = value; } public boolean isSetRetryPolicy() { return (this.retryPolicy!= null); } /** * Sets the value of the sequenceExpiration property. * * @param value * allowed object is * {@link Duration } * */ public void setSequenceExpiration(Duration value) { this.sequenceExpiration = value; } public boolean isSetSequenceExpiration() { return (this.sequenceExpiration!= null); } /** * Gets the value of the acksTo property. * * @return * possible object is * {@link String } * */ public String getAcksTo() { return acksTo; } /** * Sets the value of the acksTo property. * * @param value * allowed object is * {@link String } * */ public void setAcksTo(String value) { this.acksTo = value; } public boolean isSetAcksTo() { return (this.acksTo!= null); } /** * Gets the value of the includeOffer property. * * @return * possible object is * {@link Boolean } * */ public boolean isIncludeOffer() { if (includeOffer == null) { return true; } else { return includeOffer; } } /** * Sets the value of the includeOffer property. * * @param value * allowed object is * {@link Boolean } * */ public void setIncludeOffer(boolean value) { this.includeOffer = value; } public boolean isSetIncludeOffer() { return (this.includeOffer!= null); } public void unsetIncludeOffer() { this.includeOffer = null; } /** * Sets the value of the offeredSequenceExpiration property. * * @param value * allowed object is * {@link Duration } * */ public void setOfferedSequenceExpiration(Duration value) { this.offeredSequenceExpiration = value; } public boolean isSetOfferedSequenceExpiration() { return (this.offeredSequenceExpiration!= null); } /** * Gets the value of the maxSequences property. * * @return * possible object is * {@link Integer } * */ public int getMaxSequences() { if (maxSequences == null) { return 0; } else { return maxSequences; } } /** * Sets the value of the maxSequences property. * * @param value * allowed object is * {@link Integer } * */ public void setMaxSequences(int value) { this.maxSequences = value; } public boolean isSetMaxSequences() { return (this.maxSequences!= null); } public void unsetMaxSequences() { this.maxSequences = null; } /** * Gets the value of the sequenceExpiration property. * */ public Duration getSequenceExpiration() { if (null == sequenceExpiration) { try { return DatatypeFactory.newInstance().newDuration("PT0S"); } catch (DatatypeConfigurationException _x) { } } return sequenceExpiration; } /** * Gets the value of the offeredSequenceExpiration property. * */ public Duration getOfferedSequenceExpiration() { if (null == offeredSequenceExpiration) { try { return DatatypeFactory.newInstance().newDuration("PT0S"); } catch (DatatypeConfigurationException _x) { } } return offeredSequenceExpiration; } }
b5a5e7625eb869543feeb99ef89be68493507a30
1e1ff4a6e6932c63522c5b76b356cc011f85556d
/SinchonBeer/src/main/java/com/bitcamp/sc/review/controller/ReviewController.java
9f7f96a3e0c520ad0e4b5605cf00669f6cfe2553
[]
no_license
Gamaspin/sinchonbeer
99587456caba178c497f8cc43efac1f81b91406b
e19669551555a576c0ec11cc18342fe08b767c34
refs/heads/main
2023-08-27T18:34:37.570480
2021-10-23T09:42:28
2021-10-23T09:42:28
400,465,091
0
0
null
2021-10-05T03:29:02
2021-08-27T09:59:43
JavaScript
UTF-8
Java
false
false
5,685
java
package com.bitcamp.sc.review.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.bitcamp.sc.member.domain.LoginInfo; import com.bitcamp.sc.review.domain.ReviewVO; import com.bitcamp.sc.review.service.ReviewService; @Controller @RequestMapping("/review") public class ReviewController { @Autowired ReviewService reviewService; // 01-1. 메인 화면 @RequestMapping("") public String reviewMain(Model model, HttpServletRequest request) { try { model.addAttribute("reviewMain", reviewService.listAllReview()); HttpSession session = request.getSession(); LoginInfo loginInfo = (LoginInfo) session.getAttribute("loginInfo"); System.out.println("로그인정보 : " + loginInfo); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return "review/reviewMain"; } // 01-2. 메인 화면 @RequestMapping("/") public String reviewMain2(Model model, HttpServletRequest request) { try { model.addAttribute("reviewMain", reviewService.listAllReview()); HttpSession session = request.getSession(); LoginInfo loginInfo = (LoginInfo) session.getAttribute("loginInfo"); System.out.println("로그인정보 : " + loginInfo); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return "review/reviewMain"; } // 02-1. 쓰기 화면 @RequestMapping(value = "/write", method = RequestMethod.GET) public String goToWrite(HttpServletRequest request, Model model) throws Exception { model.addAttribute("order_idx", request.getParameter("order_idx")); return "review/writing"; } // 02-2. 쓰기 실행 컨트롤러 @ResponseBody @RequestMapping(value = "/write.do", method = RequestMethod.POST) public int ajaxinsert_Review(HttpServletRequest request) throws Exception { System.out.println(request.getParameter("title")); int check = 0; ReviewVO vo = new ReviewVO(); vo.setTitle(request.getParameter("title")); vo.setName(request.getParameter("author")); vo.setContents(request.getParameter("content")); vo.setOidx(Integer.parseInt(request.getParameter("order_idx"))); try { check = reviewService.insertReview(vo); } catch (Exception e) { // TODO: handle exception } return check; } // 03. 상세 보기 화면 @RequestMapping(value = "/view", method = RequestMethod.GET) public String goToView(HttpServletRequest request, Model model) throws Exception { /* System.out.println(request.getParameter("idx")); */ int idx = 0; ReviewVO vo = new ReviewVO(); if( request.getParameter("idx") != null) { idx = Integer.parseInt(request.getParameter("idx")); } try { vo = reviewService.readReview(idx); String content = vo.getContents(); model.addAttribute("view", vo); } catch (Exception e) { e.printStackTrace(); // TODO: handle exception } return "review/view"; } // 04. 게시글 삭제 @ResponseBody @RequestMapping("delete.do") public int delete(HttpServletRequest request, Model model) throws Exception { System.out.println("idx: " + request.getParameter("idx")); int idx = 0; int check = 0; if( request.getParameter("idx") != null) { idx = Integer.parseInt(request.getParameter("idx")); } try { reviewService.deleteReview(idx); check = 1; } catch (Exception e) { e.printStackTrace(); // TODO: handle exception } return check; } // 05-1. 수정화면 @RequestMapping(value = "/modify", method = RequestMethod.GET) public String goToModify(HttpServletRequest request, Model model) throws Exception { int idx; ReviewVO vo = new ReviewVO(); if(!"".equals(request.getParameter("idx")) && request.getParameterMap().containsKey("idx")) { idx = Integer.parseInt(request.getParameter("idx")); try { vo = reviewService.readReview(idx); System.out.println("write : " + vo.toString()); model.addAttribute("view", vo); } catch (Exception e) { e.printStackTrace(); // TODO: handle exception } } return "review/modify"; } // 05-2. 수정 실행 컨트롤러 @ResponseBody @RequestMapping(value = "/modify.do", method = RequestMethod.POST) public int ajaxmodify_Review(HttpServletRequest request) throws Exception { int check = 0; ReviewVO vo = new ReviewVO(); vo.setIdx(Integer.parseInt(request.getParameter("idx"))); vo.setTitle(request.getParameter("title")); vo.setName(request.getParameter("author")); vo.setContents(request.getParameter("content")); try { check = reviewService.updateReview(vo); } catch (Exception e) { // TODO: handle exception } return check; } // 06. 게시글 좋아요 @ResponseBody @RequestMapping("like.do") public int like(HttpServletRequest request, Model model) throws Exception { System.out.println("idx: " + request.getParameter("idx")); int idx = 0; int check = 0; ReviewVO vo = new ReviewVO(); vo.setLikes(Integer.parseInt(request.getParameter("likes"))); if( request.getParameter("idx") != null) { idx = Integer.parseInt(request.getParameter("idx")); } try { reviewService.likeReview(idx); check = 1; } catch (Exception e) { e.printStackTrace(); // TODO: handle exception } return check; } }
c195023b4723a9d68c9614adc792f58c5dacbc3e
cf7bac70e184327148e0bb6772127960111ff827
/src/main/java/com/zhanghe/rpc/core/client/loadbalance/LoadBalanceService.java
fc36bf98e04f7e24d2375f01df007c0eb54acb64
[]
no_license
SmallBoyO/NettyRpc
a40a47016ff7e3f8b3cc46b04ed0eaf1a0abe120
97b28449f6031088cc3a2549e68e8c700ff2c792
refs/heads/master
2023-07-06T11:28:56.696461
2023-02-10T09:26:05
2023-02-10T09:26:05
177,139,458
1
0
null
2023-04-17T19:42:43
2019-03-22T12:51:21
Java
UTF-8
Java
false
false
1,050
java
package com.zhanghe.rpc.core.client.loadbalance; public class LoadBalanceService { public String name; public Object service; public int weight; public LoadBalanceService(String name, Object service) { this.name = name; this.service = service; } public LoadBalanceService(String name, Object service,int weight) { this.name = name; this.service = service; this.weight = weight; } public static LoadBalanceService of(String name,Object service){ return new LoadBalanceService(name, service); } public static LoadBalanceService of(String name,Object service,int weight){ return new LoadBalanceService(name, service, weight); } public String getName() { return name; } public void setName(String name) { this.name = name; } public Object getService() { return service; } public void setService(Object service) { this.service = service; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } }
c9581a60c6fb35eca0ad9d127ee2d837f414aa43
d38d6abdc26971f07188cfc25f6c8562d7746196
/mantis-tests/src/test/java/ru/stqa/pft/mantis/appmanager/RegistrationHelper.java
d2de471cad655fa29f02b60bf69208f40156033a
[ "Apache-2.0" ]
permissive
GalinaPo/java_training
3a1acd5e7e491a24a30a7f854459a64ae8f2aaa0
c0f2245de1810e5b06cf63a18081135f4d9e1af6
refs/heads/master
2021-01-25T09:32:29.035237
2017-08-24T13:25:50
2017-08-24T13:25:50
93,849,135
1
0
null
null
null
null
UTF-8
Java
false
false
792
java
package ru.stqa.pft.mantis.appmanager; import org.openqa.selenium.By; /** * Created by gpodmorina on 04.08.2017. */ public class RegistrationHelper extends HelperBase { public RegistrationHelper(ApplicationManager app) { super(app); } public void start(String username, String email) { wd.get(app.getProperty("web.baseUrl") + "/signup_page.php"); type(By.name("username"), username); type(By.name("email"), email); click(By.cssSelector("input[value='Зарегистрироваться']")); } public void finish(String confirmationLink, String password) { wd.get(confirmationLink); type(By.name("password"), password); type(By.name("password_confirm"), password); click(By.cssSelector("span.submit-button button[type='submit']")); } }
10e603634cd7b7f63a29bfed1a9f7572ddb216b9
697932a0928573a68dd32003602aaa88822d02b1
/app/src/main/java/com/ayoka/Model/Category.java
3ff02b6620cda23ba8b39e5b5403ba589a171dab
[]
no_license
Codeamon/VDFReport
1d1d430bd711e0702caeefd0559590da2af119a8
94bf2ea46325e4c44b3013a2c7727e6550524f85
refs/heads/master
2016-09-13T01:55:24.036899
2016-06-09T06:36:18
2016-06-09T06:36:18
56,970,596
1
0
null
null
null
null
UTF-8
Java
false
false
1,572
java
package com.ayoka.Model; /** * Created by Ahmet&Korcan on 1.5.2016. */ public class Category { private String title, desc; private int id,maincategoryId,type,projectId; private String categoryName; public Category(){ } public Category(String title, String desc, int id, int maincategoryId, int type) { this.title = title; this.desc = desc; this.id = id; this.maincategoryId = maincategoryId; this.type = type; this.categoryName=title; this.projectId=projectId; } public String getCategoryName() { return categoryName; } public void setCategoryName(String categoryName) { this.categoryName = categoryName; } public int getProjectId() { return projectId; } public void setProjectId(int projectId) { this.projectId = projectId; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getMaincategoryId() { return maincategoryId; } public void setMaincategoryId(int maincategoryId) { this.maincategoryId = maincategoryId; } public int getType() { return type; } public void setType(int type) { this.type = type; } }
e32e3588d2fd278fa8972bfcc5fd8fe85621d267
6e57bdc0a6cd18f9f546559875256c4570256c45
/external/subsampling-scale-image-view/library/src/main/java/com/davemorrissey/labs/subscaleview/decoder/SkiaImageRegionDecoder.java
eebe2bb5a58935f10cfb6d8cd49caa3e9bcde063
[ "Apache-2.0" ]
permissive
dongdong331/test
969d6e945f7f21a5819cd1d5f536d12c552e825c
2ba7bcea4f9d9715cbb1c4e69271f7b185a0786e
refs/heads/master
2023-03-07T06:56:55.210503
2020-12-07T04:15:33
2020-12-07T04:15:33
134,398,935
2
1
null
2022-11-21T07:53:41
2018-05-22T10:26:42
null
UTF-8
Java
false
false
6,411
java
package com.davemorrissey.labs.subscaleview.decoder; import android.content.ContentResolver; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.*; import android.net.Uri; import android.os.Build; import android.support.annotation.Keep; import android.text.TextUtils; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import java.io.InputStream; import java.util.List; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /** * Default implementation of {@link com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder} * using Android's {@link android.graphics.BitmapRegionDecoder}, based on the Skia library. This * works well in most circumstances and has reasonable performance due to the cached decoder instance, * however it has some problems with grayscale, indexed and CMYK images. * * A {@link ReadWriteLock} is used to delegate responsibility for multi threading behaviour to the * {@link BitmapRegionDecoder} instance on SDK &gt;= 21, whilst allowing this class to block until no * tiles are being loaded before recycling the decoder. In practice, {@link BitmapRegionDecoder} is * synchronized internally so this has no real impact on performance. */ public class SkiaImageRegionDecoder implements ImageRegionDecoder { private BitmapRegionDecoder decoder; private final ReadWriteLock decoderLock = new ReentrantReadWriteLock(true); private static final String FILE_PREFIX = "file://"; private static final String ASSET_PREFIX = FILE_PREFIX + "/android_asset/"; private static final String RESOURCE_PREFIX = ContentResolver.SCHEME_ANDROID_RESOURCE + "://"; private final Bitmap.Config bitmapConfig; @Keep @SuppressWarnings("unused") public SkiaImageRegionDecoder() { this(null); } @SuppressWarnings({"WeakerAccess", "SameParameterValue"}) public SkiaImageRegionDecoder(Bitmap.Config bitmapConfig) { Bitmap.Config globalBitmapConfig = SubsamplingScaleImageView.getPreferredBitmapConfig(); if (bitmapConfig != null) { this.bitmapConfig = bitmapConfig; } else if (globalBitmapConfig != null) { this.bitmapConfig = globalBitmapConfig; } else { this.bitmapConfig = Bitmap.Config.RGB_565; } } @Override public Point init(Context context, Uri uri) throws Exception { String uriString = uri.toString(); if (uriString.startsWith(RESOURCE_PREFIX)) { Resources res; String packageName = uri.getAuthority(); if (context.getPackageName().equals(packageName)) { res = context.getResources(); } else { PackageManager pm = context.getPackageManager(); res = pm.getResourcesForApplication(packageName); } int id = 0; List<String> segments = uri.getPathSegments(); int size = segments.size(); if (size == 2 && segments.get(0).equals("drawable")) { String resName = segments.get(1); id = res.getIdentifier(resName, "drawable", packageName); } else if (size == 1 && TextUtils.isDigitsOnly(segments.get(0))) { try { id = Integer.parseInt(segments.get(0)); } catch (NumberFormatException ignored) { } } decoder = BitmapRegionDecoder.newInstance(context.getResources().openRawResource(id), false); } else if (uriString.startsWith(ASSET_PREFIX)) { String assetName = uriString.substring(ASSET_PREFIX.length()); decoder = BitmapRegionDecoder.newInstance(context.getAssets().open(assetName, AssetManager.ACCESS_RANDOM), false); } else if (uriString.startsWith(FILE_PREFIX)) { decoder = BitmapRegionDecoder.newInstance(uriString.substring(FILE_PREFIX.length()), false); } else { InputStream inputStream = null; try { ContentResolver contentResolver = context.getContentResolver(); inputStream = contentResolver.openInputStream(uri); decoder = BitmapRegionDecoder.newInstance(inputStream, false); } finally { if (inputStream != null) { try { inputStream.close(); } catch (Exception e) { /* Ignore */ } } } } return new Point(decoder.getWidth(), decoder.getHeight()); } @Override public Bitmap decodeRegion(Rect sRect, int sampleSize) { getDecodeLock().lock(); try { if (decoder != null && !decoder.isRecycled()) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = sampleSize; options.inPreferredConfig = bitmapConfig; Bitmap bitmap = decoder.decodeRegion(sRect, options); if (bitmap == null) { throw new RuntimeException("Skia image decoder returned null bitmap - image format may not be supported"); } return bitmap; } else { throw new IllegalStateException("Cannot decode region after decoder has been recycled"); } } finally { getDecodeLock().unlock(); } } @Override public synchronized boolean isReady() { return decoder != null && !decoder.isRecycled(); } @Override public synchronized void recycle() { decoderLock.writeLock().lock(); try { decoder.recycle(); decoder = null; } finally { decoderLock.writeLock().unlock(); } } /** * Before SDK 21, BitmapRegionDecoder was not synchronized internally. Any attempt to decode * regions from multiple threads with one decoder instance causes a segfault. For old versions * use the write lock to enforce single threaded decoding. */ private Lock getDecodeLock() { if (Build.VERSION.SDK_INT < 21) { return decoderLock.writeLock(); } else { return decoderLock.readLock(); } } }
585de8d0dcce63b2303d9a045061f274cde308f6
84fef71eb4d7407c3bdc899405405e8a8ca558c5
/changgou-parent/changgou-service-api/changgou-service-goods-api/src/main/java/com/changgou/goods/feign/SpuFeign.java
e92bd8f698de24550a3d66e5e3406b8893c8964c
[]
no_license
lijiaze12/mall-project
6094ad1874e8ffb0ac9af1da921ca4d25734820c
978d663931894e34f7692b20a6e403df1a287cd0
refs/heads/master
2023-06-05T15:44:12.281313
2021-06-23T01:58:24
2021-06-23T01:58:24
379,454,522
0
0
null
null
null
null
UTF-8
Java
false
false
1,061
java
package com.changgou.goods.feign; import com.changgou.goods.pojo.Sku; import com.changgou.goods.pojo.Spu; import entity.Result; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @FeignClient(name="goods",path="/spu") public interface SpuFeign { /*** * 根据审核状态查询Spu * @param status * @return */ @GetMapping("/status/{status}") Result<List<Spu>> findByStatus(@PathVariable(name = "status") String status); /*** * 根据SpuID查询Spu信息 * @param id * @return */ @GetMapping("/{id}") public Result<Spu> findById(@PathVariable(name = "id") Long id); /*** * 增加spu的销量 * @param * @return */ @GetMapping("/addSaleNum") public Result addSaleNum(@RequestParam(name="id") Long id, @RequestParam(name="saleNum") Integer saleNum); }
cfaeac9b4b72884fe0a5754ffadd7223e4159a5a
290d61f2990b92cba8983a270f73653ab729cf62
/src/main/java/com/jongwon/book/springboot/config/auth/CustomOAuth2UserService.java
cd83d9351d1c5bf6f71efa7eb5077fb6d604136c
[]
no_license
bluesinger75/freelec-springboot2-webservice_20201111
1ec38e9989556595f861bbca2bf0f1116f0cd3b6
e0a98a3fc281a21a3b7cad20e9f24043676fcb62
refs/heads/master
2023-02-12T18:56:43.297216
2021-01-12T06:05:52
2021-01-12T06:05:52
311,900,222
0
0
null
null
null
null
UTF-8
Java
false
false
2,765
java
package com.jongwon.book.springboot.config.auth; import com.jongwon.book.springboot.config.auth.dto.OAuthAttributes; import com.jongwon.book.springboot.config.auth.dto.SessionUser; import com.jongwon.book.springboot.domain.user.User; import com.jongwon.book.springboot.domain.user.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; import org.springframework.security.oauth2.client.userinfo.OAuth2UserService; import org.springframework.security.oauth2.core.OAuth2AuthenticationException; import org.springframework.security.oauth2.core.user.DefaultOAuth2User; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; import javax.servlet.http.HttpSession; import java.util.Collections; @RequiredArgsConstructor @Service public class CustomOAuth2UserService implements OAuth2UserService<OAuth2UserRequest, OAuth2User> { private final UserRepository userRepository; private final HttpSession httpSession; @Override public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException { OAuth2UserService delegate = new DefaultOAuth2UserService(); OAuth2User oAuth2User = delegate.loadUser(userRequest); // 로그인 서비스 구분하는 코드 String registrationId = userRequest.getClientRegistration().getRegistrationId(); // OAuth2 로그인 진행 시 키가 되는 필드값 String userNameAttributeName = userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUserNameAttributeName(); // OAuth2UserService를 통해 가져온 OAuth2User의 attribute를 담을 클래스 OAuthAttributes attributes = OAuthAttributes.of(registrationId, userNameAttributeName, oAuth2User.getAttributes()); // 세션에 사용자 정보를 저장하기 위한 Dto 클래스 User user = saveOrUpdate(attributes); httpSession.setAttribute("user", new SessionUser(user)); return new DefaultOAuth2User( Collections.singleton(new SimpleGrantedAuthority(user.getRoleKey())), attributes.getAttributes(), attributes.getNameAttributeKey()); } private User saveOrUpdate(OAuthAttributes attributes) { User user = userRepository.findByEmail(attributes.getEmail()) .map(entity -> entity.update(attributes.getName(), attributes.getPicture())) .orElse(attributes.toEntity()); return userRepository.save(user); } }
f54e5d9e363cadfafad381a6dd4fc63451bcda26
fe2fa121fabe8772f4d9958f1d09bc6498ac4ec8
/src/main/java/com/sdys/appgame/server/TypeService.java
fa4fd97ddb83535e35b128bd64235a018478b869
[]
no_license
zhuangjialin/app-game
fc787f1dda46edf212ab509516f1bbed915542fc
d3577eaa4eaa7c9f9970a27bd2b5034bc19e182a
refs/heads/master
2022-07-18T01:01:04.317470
2020-04-19T04:17:48
2020-04-19T04:17:48
248,537,187
0
0
null
2022-06-21T03:01:17
2020-03-19T15:24:46
Java
UTF-8
Java
false
false
530
java
package com.sdys.appgame.server; import com.sdys.appgame.entity.Type; import java.util.List; import java.util.Map; public interface TypeService { int deleteByPrimaryKey(Integer id); int insert(Type record); int insertSelective(Type record); int deleteType(Integer id); Type selectByPrimaryKey(Integer id); List<Type> selectByParam(Type record); int updateByPrimaryKeySelective(Type record); int updateByPrimaryKey(Type record); List<Map> findTypesList(Map<String, String> map); }
42427323a39cac05d9a3433ca38d7c2ab9cd1667
fdfbcaca59bdccafca014ae02777faa2c653b180
/src/main/java/org/kivio/c3faces/script/property/OnmouseoutMethod.java
4c3e4a3d7c232a7fade32b3124e69115d13bdd6d
[ "Apache-2.0" ]
permissive
rollinhand/c3faces
e3c9333fab5598923586cd4e8bfb177a70780494
20f36a439310b5cffdb90fe088e7aa661efb19b4
refs/heads/master
2021-09-21T02:06:34.735772
2018-08-19T08:11:04
2018-08-19T08:11:04
115,291,365
0
0
null
2017-12-24T23:03:55
2017-12-24T23:03:55
null
UTF-8
Java
false
false
1,089
java
/** Copyright 2015 Martin Linha Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **/ package org.kivio.c3faces.script.property; import org.kivio.c3faces.script.MethodBlock; /** * Objects represents Onmouseout .js event and javascript function to be evaluated when this .js event is fired. Can be used only at places which defines * C3.js. * * @author Martin Linha */ public class OnmouseoutMethod extends MethodBlock { public OnmouseoutMethod(String body, String... params) { super(body, params); } @Override public String getName() { return "onmouseout"; } }
c63a7984baae39101ef81d37e4b4f3df1d7dd031
2958e0708bc8fa0ad6d34474eaaac76a2adb9160
/src/zajecia8Kolekcje/Zad10.java
67c12733c0ca3b8e468a5645b75a08dd0d08aee0
[]
no_license
lisiasty86/Szkolenie
21df836cd02bdaf87fbc740444a0482a2c136e12
6a7d7e6a1e09b80e921d99b80f1ad8c70e5f0028
refs/heads/master
2020-06-13T17:24:08.152925
2019-08-03T15:58:31
2019-08-03T15:58:31
194,730,752
0
0
null
null
null
null
UTF-8
Java
false
false
2,552
java
package zajecia8Kolekcje; import java.util.Arrays; import java.util.LinkedList; import java.util.List; public class Zad10 { public static void main(String[] args) { LinkedList<Integer> listWithoutAdditionalElement = new LinkedList<>(Arrays.asList(1,2,3,4,5,6,7,8,9)); System.out.println("Second solution final table: " + addExstraElement(listWithoutAdditionalElement)); } public static LinkedList<Integer> addExstraElement (LinkedList<Integer> list) { /** * * First solution * * */ long startTimeFirstSolution = System.nanoTime(); /**Start counting duration for first solution*/ LinkedList<Integer> listWithAdditionalElement = new LinkedList<>(); int temp; for (int i=0;i<list.size()+1;i++) { if (i <= 1) { listWithAdditionalElement.add(list.get(i)); } else if (i==2) { listWithAdditionalElement.add(22); } else if (i<=list.size()-2) { //max 7 listWithAdditionalElement.add(list.get(i-1)); } else { listWithAdditionalElement.add(list.get(i-1)); } } long endTimeFirstSolution = System.nanoTime(); long finalDurationFirstSolution = endTimeFirstSolution - startTimeFirstSolution; /**Duration for the first solution*/ /** * * Second solution * * */ long startTimeSecondSolution = System.nanoTime(); /**Start counting duration for second solution*/ LinkedList<Integer> listFirstPart = new LinkedList<>(); LinkedList<Integer> listSecondPart = new LinkedList<>(); LinkedList<Integer> listFinalPart = new LinkedList<>(); for (int j=0;j<2;j++){ listFirstPart.add(list.get(j)); } for (int k=2;k<list.size();k++){ listSecondPart.add(list.get(k)); } listFinalPart.addAll(listFirstPart); listFinalPart.add(22); listFinalPart.addAll(listSecondPart); long endTimeSecondSolution = System.nanoTime(); long finalDurationSecondSolution = endTimeSecondSolution - startTimeSecondSolution; /**Duration for the second solution*/ System.out.println("Duration for first solution: " + finalDurationFirstSolution); System.out.println("Duration for second solution: " + finalDurationSecondSolution); System.out.println("Second solution final table: " + listFinalPart); return listWithAdditionalElement; } }
f9b64f32cedf138e69d3b85eeeffe4f6e52a2ad2
0f5f41c54681dbb048159006e15ba6825bea77a9
/src/main/java/com/rcmcode/springsecurity/model/ApplicationUserRole.java
1e524d164e2d72872dfb9763926f86237585409d
[]
no_license
rcmohanraj/SpringSecurity
2e9ee31b953e013513b740b6dfe9e92d7d6e1d15
c3ca76c48f56c5ba6d4ee7ff11e13bc024f0182a
refs/heads/master
2023-03-29T21:12:44.490640
2020-09-05T05:06:45
2020-09-05T05:06:45
283,364,440
0
0
null
2021-03-31T22:15:56
2020-07-29T01:10:37
Java
UTF-8
Java
false
false
1,300
java
package com.rcmcode.springsecurity.model; import com.google.common.collect.Sets; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import java.util.Set; import java.util.stream.Collectors; public enum ApplicationUserRole { STUDENT(Sets.newHashSet()), ADMIN(Sets.newHashSet(ApplicationUserPermission.COURSE_READ, ApplicationUserPermission.COURSE_WRITE, ApplicationUserPermission.STUDENT_READ, ApplicationUserPermission.STUDENT_WRITE)), ADMINTRAINEE(Sets.newHashSet(ApplicationUserPermission.COURSE_READ, ApplicationUserPermission.STUDENT_READ)); private final Set<ApplicationUserPermission> permissions; ApplicationUserRole(Set<ApplicationUserPermission> permissions) { this.permissions = permissions; } public Set<ApplicationUserPermission> getPermissions() { return permissions; } public Set<GrantedAuthority> getGrantedAuthorities() { Set<GrantedAuthority> permissions = getPermissions().stream() .map(permission -> new SimpleGrantedAuthority(permission.getPermission())) .collect(Collectors.toSet()); permissions.add(new SimpleGrantedAuthority("ROLE_" + this.name())); return permissions; } }
a665e4f7db0da748c33f7ef7e87ba9fd87416e90
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/30/30_41209a60213e025fb22db2e5721a5a05172dce88/CustomChooserComposite/30_41209a60213e025fb22db2e5721a5a05172dce88_CustomChooserComposite_s.java
37a3340110b32d4c8fe3c728057513649bab83a7
[]
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
15,170
java
/*********************************************************************** * Copyright (c) 2006 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Actuate Corporation - initial API and implementation ***********************************************************************/ package org.eclipse.birt.core.ui.swt.custom; import java.util.Vector; import org.eclipse.birt.core.ui.utils.UIHelper; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.ACC; import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleControlAdapter; import org.eclipse.swt.accessibility.AccessibleControlEvent; import org.eclipse.swt.accessibility.AccessibleControlListener; import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; /** * CustomChooserComposite */ public abstract class CustomChooserComposite extends Composite { /** * This event occurs when the selection is set. */ public static final int SELECTION_EVENT = 1; /** * This event occures when the dropdown is about to show. */ public static final int DROPDOWN_EVENT = 2; private Composite cmpDropDown = null; private Composite cmpContent = null; private ICustomChoice cnvSelection = null; private Button btnDown = null; private Object iCurrentValue = null; private Vector vSelectionListeners = new Vector( ); private Vector vDropDownListeners = new Vector( ); private boolean bEnabled = true; private boolean bJustFocusLost = false; private ICustomChoice popupSelection; private ICustomChoice[] popupCanvases; private Object[] items; private Listener canvasListener = new Listener( ) { public void handleEvent( Event event ) { if ( event.widget == cnvSelection ) { handleEventCanvasSelection( event ); } else { handleEventCanvasPopup( event ); } } }; private AccessibleListener accessibleListener = new AccessibleAdapter( ) { public void getHelp( AccessibleEvent e ) { e.result = getToolTipText( ); } }; private AccessibleControlListener accessibleControlListener = new AccessibleControlAdapter( ) { public void getChildAtPoint( AccessibleControlEvent e ) { Point testPoint = toControl( new Point( e.x, e.y ) ); if ( getBounds( ).contains( testPoint ) ) { e.childID = ACC.CHILDID_SELF; } } public void getLocation( AccessibleControlEvent e ) { Rectangle location = getBounds( ); Point pt = toDisplay( new Point( location.x, location.y ) ); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; } public void getChildCount( AccessibleControlEvent e ) { e.detail = 0; } public void getRole( AccessibleControlEvent e ) { e.detail = ACC.ROLE_COMBOBOX; } public void getState( AccessibleControlEvent e ) { e.detail = ACC.STATE_NORMAL; } }; public CustomChooserComposite( Composite parent, int style ) { super( parent, style ); } protected CustomChooserComposite( Composite parent, int style, Object choiceValue ) { this( parent, style ); iCurrentValue = choiceValue; } private void initControls( ) { // THE LAYOUT OF THIS COMPOSITE (FILLS EVERYTHING INSIDE IT) FillLayout flMain = new FillLayout( ); flMain.marginHeight = 0; flMain.marginWidth = 0; setLayout( flMain ); // THE LAYOUT OF THE INNER COMPOSITE (ANCHORED NORTH AND ENCAPSULATES // THE CANVAS + BUTTON) cmpContent = new Composite( this, SWT.BORDER ); GridLayout glContentInner = new GridLayout( ); glContentInner.verticalSpacing = 0; glContentInner.horizontalSpacing = 0; glContentInner.marginHeight = 0; glContentInner.marginWidth = 0; glContentInner.numColumns = 2; cmpContent.setLayout( glContentInner ); final int iSize = 17; // THE CANVAS cnvSelection = createChoice( cmpContent, null ); GridData gdCNVSelection = new GridData( GridData.FILL_BOTH ); gdCNVSelection.heightHint = iSize; cnvSelection.setLayoutData( gdCNVSelection ); cnvSelection.setValue( iCurrentValue ); cnvSelection.addListener( SWT.KeyDown, canvasListener ); cnvSelection.addListener( SWT.Traverse, canvasListener ); cnvSelection.addListener( SWT.FocusIn, canvasListener ); cnvSelection.addListener( SWT.FocusOut, canvasListener ); cnvSelection.addListener( SWT.MouseDown, canvasListener ); // THE BUTTON btnDown = new Button( cmpContent, SWT.ARROW | SWT.DOWN ); GridData gdBDown = new GridData( GridData.FILL ); gdBDown.verticalAlignment = GridData.BEGINNING; gdBDown.widthHint = iSize - 1; gdBDown.heightHint = iSize; btnDown.setLayoutData( gdBDown ); btnDown.addListener( SWT.Selection, new Listener( ) { public void handleEvent( Event event ) { toggleDropDown( ); } } ); layout( ); initAccessible( ); } protected abstract ICustomChoice createChoice( Composite parent, Object choiceValue ); public void setItems( Object[] items ) { this.items = items == null ? new Object[0] : items; if ( cmpContent == null ) { initControls( ); } if ( findChoiceIndex( iCurrentValue ) == -1 ) { setChoiceValue( null ); } } public Object[] getItems( ) { return items; } public int getItemCount( ) { return items.length; } public Object getItem( int index ) { if ( index >= 0 && index < items.length ) { return items[index]; } return null; } public void setEnabled( boolean bState ) { btnDown.setEnabled( bState ); cnvSelection.setEnabled( bState ); this.bEnabled = bState; } public boolean isEnabled( ) { return this.bEnabled; } private void createDropDownComponent( int iXLoc, int iYLoc ) { if ( !bEnabled ) { return; } int shellWidth = this.getSize( ).x; Shell shell = new Shell( this.getShell( ), SWT.NONE ); shell.setLayout( new FillLayout( SWT.FILL ) ); if ( ( getStyle( ) & SWT.RIGHT_TO_LEFT ) != 0 ) { iXLoc -= shellWidth; } shell.setLocation( iXLoc, iYLoc ); cmpDropDown = new Composite( shell, SWT.NONE ); GridLayout gl = new GridLayout( ); gl.horizontalSpacing = 0; gl.verticalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; cmpDropDown.setLayout( gl ); Listener listenerCmpDropDown = new Listener( ) { public void handleEvent( Event event ) { handleEventCmpDropDown( event ); } }; cmpDropDown.addListener( SWT.KeyDown, listenerCmpDropDown ); cmpDropDown.addListener( SWT.FocusOut, listenerCmpDropDown ); final int choiceHigh = 18; popupCanvases = new ICustomChoice[this.items.length]; for ( int iC = 0; iC < items.length; iC++ ) { ICustomChoice cnv = createChoice( cmpDropDown, items[iC] ); GridData gd = new GridData( GridData.FILL_HORIZONTAL ); gd.heightHint = choiceHigh; cnv.setLayoutData( gd ); cnv.addListener( SWT.MouseDown, canvasListener ); cnv.addListener( SWT.MouseEnter, canvasListener ); cnv.addListener( SWT.KeyDown, canvasListener ); popupCanvases[iC] = cnv; if ( cnvSelection.getValue( ).equals( cnv.getValue( ) ) ) { cnv.notifyListeners( SWT.FocusIn, new Event( ) ); popupSelection = cnv; } } shell.setSize( shellWidth, choiceHigh * items.length ); shell.layout( ); shell.open( ); } void handleEventCmpDropDown( Event event ) { switch ( event.type ) { case SWT.KeyDown : { keyPressed( new KeyEvent( event ) ); break; } case SWT.FocusOut : { Control cTmp = Display.getCurrent( ).getCursorControl( ); if ( cTmp != null ) { if ( cTmp.equals( cnvSelection ) || cTmp.equals( btnDown ) ) { bJustFocusLost = true; } } if ( !isPopupControl( cTmp ) ) { cmpDropDown.getShell( ).close( ); } break; } } } public void select( int index ) { setChoiceValue( items[index] ); } public int getChoiceIndex( ) { return findChoiceIndex( iCurrentValue ); } /** * Returns the current selected choice * */ public Object getChoiceValue( ) { return iCurrentValue; } /** * Sets the value as selected choice, and redraws UI. * * @param iValue * value as selected choice */ public void setChoiceValue( Object iValue ) { iCurrentValue = iValue; cnvSelection.setValue( iCurrentValue ); cnvSelection.redraw( ); } public void addListener( int eventType, Listener listener ) { switch ( eventType ) { case SELECTION_EVENT : vSelectionListeners.add( listener ); break; case DROPDOWN_EVENT : vDropDownListeners.add( listener ); break; } } public void removeListener( int eventType, Listener listener ) { switch ( eventType ) { case SELECTION_EVENT : vSelectionListeners.remove( listener ); break; case DROPDOWN_EVENT : vDropDownListeners.remove( listener ); break; } } private void toggleDropDown( ) { // fix for Linux, since it not send the event correctly to other than // current shell. if ( bJustFocusLost ) { bJustFocusLost = false; return; } if ( cmpDropDown == null || cmpDropDown.isDisposed( ) || !cmpDropDown.isVisible( ) ) { fireDropDownEvent( ); Point pLoc = UIHelper.getScreenLocation( this ); createDropDownComponent( pLoc.x, pLoc.y + this.getSize( ).y ); } else { cmpDropDown.getShell( ).close( ); } } private void fireSelectionEvent( ) { Event e = new Event( ); e.widget = this; e.data = this.iCurrentValue; e.type = SELECTION_EVENT; for ( int i = 0; i < vSelectionListeners.size( ); i++ ) { ( (Listener) vSelectionListeners.get( i ) ).handleEvent( e ); } } private void fireDropDownEvent( ) { Event e = new Event( ); e.widget = this; e.type = DROPDOWN_EVENT; for ( int i = 0; i < vDropDownListeners.size( ); i++ ) { ( (Listener) vDropDownListeners.get( i ) ).handleEvent( e ); } } void keyPressed( KeyEvent event ) { if ( cmpDropDown != null && !cmpDropDown.getShell( ).isDisposed( ) ) { if ( event.keyCode == SWT.ESC ) { cmpDropDown.getShell( ).close( ); } else if ( event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR ) { ICustomChoice currentControl = popupSelection == null ? popupCanvases[findChoiceIndex( ( cnvSelection ).getValue( ) )] : popupSelection; setChoiceValue( currentControl.getValue( ) ); fireSelectionEvent( ); cmpDropDown.getShell( ).close( ); } else if ( event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN ) { ICustomChoice currentControl = popupSelection == null ? popupCanvases[findChoiceIndex( ( cnvSelection ).getValue( ) )] : popupSelection; int styleIndex = findChoiceIndex( currentControl.getValue( ) ); if ( styleIndex >= 0 ) { currentControl.notifyListeners( SWT.FocusOut, new Event( ) ); currentControl.redraw( ); if ( event.keyCode == SWT.ARROW_UP ) { if ( styleIndex > 0 ) { styleIndex--; // !only redraw, don't change selection // setChoiceValue( items[styleIndex] ); // fireSelectionEvent( ); } } else if ( event.keyCode == SWT.ARROW_DOWN ) { if ( styleIndex < items.length - 1 ) { styleIndex++; // !only redraw, don't change selection // setChoiceValue( items[styleIndex] ); // fireSelectionEvent( ); } } popupSelection = popupCanvases[styleIndex]; popupSelection.notifyListeners( SWT.FocusIn, new Event( ) ); popupSelection.redraw( ); } } } } private boolean isPopupControl( Object control ) { return control != null && control instanceof Control && ( (Control) control ).getShell( ) == cmpDropDown.getShell( ); } void handleEventCanvasSelection( Event event ) { switch ( event.type ) { case SWT.FocusIn : { cnvSelection.redraw( ); break; } case SWT.FocusOut : { cnvSelection.redraw( ); break; } case SWT.KeyDown : { // At this point the widget may have been disposed. // If so, do not continue. if ( isDisposed( ) ) break; if ( event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN ) { toggleDropDown( ); } break; } case SWT.Traverse : { switch ( event.detail ) { case SWT.TRAVERSE_ESCAPE : getShell( ).close( ); break; case SWT.TRAVERSE_RETURN : case SWT.TRAVERSE_TAB_NEXT : case SWT.TRAVERSE_TAB_PREVIOUS : case SWT.TRAVERSE_ARROW_PREVIOUS : case SWT.TRAVERSE_ARROW_NEXT : event.doit = true; cnvSelection.redraw( ); } break; } case SWT.MouseDown : toggleDropDown( ); break; } } void handleEventCanvasPopup( Event event ) { switch ( event.type ) { case SWT.MouseDown : setChoiceValue( ( (ICustomChoice) event.widget ).getValue( ) ); this.cmpDropDown.getShell( ).close( ); fireSelectionEvent( ); break; case SWT.MouseEnter : if ( popupSelection != null ) { // Redraw the selection canvas in popup popupSelection.notifyListeners( SWT.FocusOut, new Event( ) ); popupSelection.redraw( ); // popupSelection = null; } popupSelection = (ICustomChoice) event.widget; popupSelection.notifyListeners( SWT.FocusIn, event ); popupSelection.redraw( ); break; } } private int findChoiceIndex( Object value ) { if ( items != null ) { for ( int i = 0; i < items.length; i++ ) { if ( items[i].equals( value ) ) { return i; } } } return -1; } void initAccessible( ) { getAccessible( ).removeAccessibleListener( accessibleListener ); getAccessible( ).addAccessibleListener( accessibleListener ); getAccessible( ).removeAccessibleControlListener( accessibleControlListener ); getAccessible( ).addAccessibleControlListener( accessibleControlListener ); } }
984e235b58af9e2ec437b764a5dea2a3642301c0
940c15187b58a9c2fd08ce0a84cf2f7176b10d11
/keepfit/src/main/java/uk/ac/strath/keepfit/view/Toaster.java
fb0129d2a2bc35a971d853c4adfa3cb3dc2c9210
[ "MIT" ]
permissive
PaulBryden/ContextualTriggers
7a7e02c28430bded17359badf730eadd20b838a7
422a27189fbfd45c2ce7b34ecd47de7c60d6b228
refs/heads/master
2020-08-13T03:22:00.702878
2019-10-13T21:39:45
2019-10-13T21:39:45
214,896,503
1
0
null
null
null
null
UTF-8
Java
false
false
1,245
java
package uk.ac.strath.keepfit.view; import android.app.Activity; import android.content.Context; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.Toast; public class Toaster { static void makeMagicToast(Context context, String text) { makeMagicToast(context, text, Toast.LENGTH_SHORT); } public static void makeMagicToast(Context context, String text, int duration) { Toast t = Toast.makeText(context, text, duration); if (softKeyboardShown(context)) { t.setGravity(Gravity.CENTER, 0, 0); } t.show(); } private static boolean softKeyboardShown(Context context) { // Hacky solution based on this Stackoverflow answer: https://stackoverflow.com/a/4737265 Activity activity = (Activity) context; final View content = activity.findViewById(android.R.id.content); int heightDiff = content.getRootView().getHeight() - content.getHeight(); DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); float dp = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, metrics); return heightDiff > dp; } }
f4f59b8dba9da2e49ebfd16f2fa8261041521ddb
1c931494fafca7505a7df68d19542ba4ef05cce2
/src/test/java/com/liuyun/site/test/util/NumberUtilsTest.java
c2aba8f73743d9f34c27998f2e764976965164a3
[]
no_license
liuyun073/wzd
3cc9ccbfdda2c5f93d64af86681dcd1870759bb5
24497c148040bada8ed48a29c7079ae347787cc9
refs/heads/master
2020-05-31T21:12:25.874657
2014-09-19T13:47:26
2014-09-19T13:47:26
24,152,224
0
1
null
null
null
null
UTF-8
Java
false
false
1,444
java
package com.liuyun.site.test.util; import com.liuyun.site.tool.Utils; import com.liuyun.site.util.DateUtils; import com.liuyun.site.util.NumberUtils; import java.util.Calendar; import java.util.Date; import org.apache.log4j.Logger; import org.junit.Test; public class NumberUtilsTest { private Logger logger = Logger.getLogger(NumberUtilsTest.class); @Test public void testCompare() { double a = 1.0E-012D; double b = 2.0E-012D; for (int i = 0; i < 50; ++i) { this.logger.info("BigDecimal:" + NumberUtils.compare(b, a)); } for (int i = 0; i < 50; ++i) this.logger.info("Double:" + (b - a > 0.0D)); } @Test public void testFormat2() { double d = 3343.5554999999999D; double f2 = NumberUtils.ceil(d); this.logger.info(Double.valueOf(f2)); this.logger.info(Double.valueOf(Math.ceil(d))); } @Test public void testCash() { double cashfee = Utils.getCashFeeForZRZB(12110.0D, -32030.0D, 0.003D, 500000.0D); Date d = Calendar.getInstance().getTime(); d = DateUtils.rollDay(d, -15); this.logger.info(Long.valueOf(d.getTime() / 1000L)); this.logger.info(Double.valueOf(cashfee)); } @Test public void testDateRoll() { Calendar cal = Calendar.getInstance(); cal.set(2012, 11, 20, 23, 59, 59); Date d = cal.getTime(); this.logger.info(DateUtils.dateStr4(d)); d = DateUtils.rollDay(d, 12); this.logger.info(DateUtils.dateStr4(d)); this.logger.info(Long.valueOf(d.getTime() / 1000L)); } }
eacb463f8515a5c79c382ef28962e454ac70fca3
c681d1a9bc8c2114100cb3062bd21c2834cf5279
/src/main/java/com/example/survey/repository/QuestionRepository.java
98f6a88e20ba1751ca3b6dc9a34604237b8fd156
[]
no_license
rk-nk-sd/SurveyRest
606cad911120a8a1574889dac6452f19cb696033
0d834b7c8456a6ecdae7f6826a478b85d9c93913
refs/heads/master
2023-08-20T11:45:32.208338
2021-10-01T09:57:41
2021-10-01T09:57:41
412,085,787
0
0
null
null
null
null
UTF-8
Java
false
false
289
java
package com.example.survey.repository; import com.example.survey.entity.Question; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface QuestionRepository extends JpaRepository<Question, Integer> { }
39405bc9123a9d535474d226b308367d93281081
a06cf834b073acd44b2d18429243b19f6de3ff9e
/symall-admin/src/main/java/com/yima/modules/sys/service/impl/SysRoleServiceImpl.java
46aede386a9a69df4cdc96ea36065546da63fed4
[ "Apache-2.0" ]
permissive
faxiaozhi/symall
41837ccc532dbc0d156adce7d07deac21c9cfc3f
bb32fbe21f64c8f655f8aa35f588d6c49069af28
refs/heads/master
2022-12-22T15:34:26.393555
2020-04-17T11:17:26
2020-04-17T11:17:26
253,667,329
0
0
Apache-2.0
2022-12-16T15:00:01
2020-04-07T02:31:20
JavaScript
UTF-8
Java
false
false
3,722
java
/** * Copyright (c) 2016-2019 谷粒开源 All rights reserved. * * https://www.guli.cloud * * 版权所有,侵权必究! */ package com.yima.modules.sys.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yima.common.exception.RRException; import com.yima.common.utils.Constant; import com.yima.common.utils.PageUtils; import com.yima.common.utils.Query; import com.yima.modules.sys.dao.SysRoleDao; import com.yima.modules.sys.entity.SysRoleEntity; import com.yima.modules.sys.service.SysRoleMenuService; import com.yima.modules.sys.service.SysRoleService; import com.yima.modules.sys.service.SysUserRoleService; import com.yima.modules.sys.service.SysUserService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; /** * 角色 * * @author Mark [email protected] */ @Service("sysRoleService") public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService { @Autowired private SysRoleMenuService sysRoleMenuService; @Autowired private SysUserService sysUserService; @Autowired private SysUserRoleService sysUserRoleService; @Override public PageUtils queryPage(Map<String, Object> params) { String roleName = (String)params.get("roleName"); Long createUserId = (Long)params.get("createUserId"); IPage<SysRoleEntity> page = this.page( new Query<SysRoleEntity>().getPage(params), new QueryWrapper<SysRoleEntity>() .like(StringUtils.isNotBlank(roleName),"role_name", roleName) .eq(createUserId != null,"create_user_id", createUserId) ); return new PageUtils(page); } @Override @Transactional(rollbackFor = Exception.class) public void saveRole(SysRoleEntity role) { role.setCreateTime(new Date()); this.save(role); //检查权限是否越权 checkPrems(role); //保存角色与菜单关系 sysRoleMenuService.saveOrUpdate(role.getRoleId(), role.getMenuIdList()); } @Override @Transactional(rollbackFor = Exception.class) public void update(SysRoleEntity role) { this.updateById(role); //检查权限是否越权 checkPrems(role); //更新角色与菜单关系 sysRoleMenuService.saveOrUpdate(role.getRoleId(), role.getMenuIdList()); } @Override @Transactional(rollbackFor = Exception.class) public void deleteBatch(Long[] roleIds) { //删除角色 this.removeByIds(Arrays.asList(roleIds)); //删除角色与菜单关联 sysRoleMenuService.deleteBatch(roleIds); //删除角色与用户关联 sysUserRoleService.deleteBatch(roleIds); } @Override public List<Long> queryRoleIdList(Long createUserId) { return baseMapper.queryRoleIdList(createUserId); } /** * 检查权限是否越权 */ private void checkPrems(SysRoleEntity role){ //如果不是超级管理员,则需要判断角色的权限是否超过自己的权限 if(role.getCreateUserId() == Constant.SUPER_ADMIN){ return ; } //查询用户所拥有的菜单列表 List<Long> menuIdList = sysUserService.queryAllMenuId(role.getCreateUserId()); //判断是否越权 if(!menuIdList.containsAll(role.getMenuIdList())){ throw new RRException("新增角色的权限,已超出你的权限范围"); } } }
dfa0a52fea9d748aaa509bb6eb5d9a27ab589742
567429dcb0ef3f2216a555469764d1336625a778
/src/array03/Coin.java
92c706aac70bf8657f637e07f97951d15d7d927e
[]
no_license
star1606/JavaStudyNew3
73af9b6a01aa0ef6e74d89e20a5a92c5703c2fc3
0a0b0688a6f6f9fad6e2eff2575bdae81de072d8
refs/heads/master
2021-05-24T07:29:29.310793
2020-04-29T03:22:41
2020-04-29T03:22:41
253,450,493
0
0
null
null
null
null
UHC
Java
false
false
1,105
java
package array03; //남은 동전의 개수를 구하는 프로그램(500, 100, 50, 10) //2680 public class Coin { public static void main(String[] args) { int money = 43324324; int count = 0; System.out.println("시작 금액:" +money); int coin[] = {500, 100, 50, 10, 1}; for (int i = 0; i < coin.length; i++) { count = money/coin[i]; money= money%coin[i]; System.out.println(coin[i]+"원 개수 :" +count); System.out.println("남은 금액:" + money); } /* int coin[] = {500, 100, 50, 10}; count = money/500; money= money%500; System.out.println("500원 개수 :" +count); System.out.println("남은 금액:" + money); count = money/100; money = money%100; System.out.println("100원 개수 :" +count); System.out.println("남은 금액: " + money); count = money/50; money = money%50; System.out.println("50원 개수 : " +count); System.out.println("남은 금액 : " +money); count = money/10; money = money%10; System.out.println("10원 개수:" +count); System.out.println("남은 금액:" +money); */ } }
db11fdc9c0e2455f252e543d7e214a31ea8216b2
905226f62537b783aa8ec1689c1de91a910600ba
/3_Spring/sp45_security/src/main/java/com/example/security/service/UserAuthenticationService.java
4c5473ab21043e5aaefe916445eb13a130cb08ba
[]
no_license
bejpark/ion_developer_course
16093754d562ded8930efc091ab8bbbeb4d10c56
2441ac92b4527e1c9a88ab2a0154e50e15148635
refs/heads/master
2023-08-27T03:13:33.343079
2021-10-29T03:24:30
2021-10-29T03:24:30
400,416,632
0
0
null
null
null
null
UTF-8
Java
false
false
1,656
java
package com.example.security.service; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import com.example.security.model.dto.UserDTO; //로그인 처리 클래스 public class UserAuthenticationService implements UserDetailsService { private SqlSessionTemplate sqlSession; public UserAuthenticationService() { } public UserAuthenticationService( SqlSessionTemplate sqlSession) { this.sqlSession=sqlSession; } @Override public UserDetails loadUserByUsername(String userid) throws UsernameNotFoundException { //사용자 아이디 확인 Map<String,Object> user=sqlSession.selectOne( "user.selectUser", userid); //아이디가 없으면 예외 발생 if(user==null) throw new UsernameNotFoundException(userid); //사용권한 목록 List<GrantedAuthority> authority=new ArrayList<>(); authority.add(new SimpleGrantedAuthority( user.get("AUTHORITY").toString())); //필드명은 대문자로 return new UserDTO(user.get("USERNAME").toString(), user.get("PASSWORD").toString(), (Integer)Integer.valueOf(user.get("ENABLED").toString())==1, true,true,true,authority, user.get("USERNAME").toString()); } }
bac670d222c21d8ad00001409e2ddd9e1093197d
dc3ac366f069b6a05bd4b6a9f1f7256dcc0d62ba
/src/TABLA_MANEJO/Render.java
adf400e6558ae33b091c6df2d595ef98abcce8a2
[]
no_license
kenny2312/lib_Validacion_java
a5da1942d21dbb361cd90c8b7aeab694dc140c00
9fa5b8108c51cf1afd151697157a365e4a08b1e9
refs/heads/master
2020-06-19T17:02:33.186272
2019-07-14T04:35:22
2019-07-14T04:35:22
196,794,095
0
0
null
null
null
null
UTF-8
Java
false
false
1,494
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 TABLA_MANEJO; import java.awt.Component; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JTable; import javax.swing.UIManager; import javax.swing.table.DefaultTableCellRenderer; public class Render extends DefaultTableCellRenderer{ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if(value instanceof JButton){ JButton btn = (JButton)value; if(isSelected){ btn.setForeground(table.getSelectionForeground()); btn.setBackground(table.getSelectionBackground()); }else{ btn.setForeground(table.getForeground()); btn.setBackground(UIManager.getColor("Button.background")); } return btn; } if(value instanceof JCheckBox){ JCheckBox ch = (JCheckBox)value; return ch; } return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); //To change body of generated methods, choose Tools | Templates. } }
64ea4468e9c4c89a423dcc78cf3e2df451750017
81a0056bb0ab18f60ad9555ee8313ed4617b6432
/zgshopping/src/main/java/com/zhuguang/jack/pojo/Product.java
31296d065250fec2ffd364f86bdee9d317df5062
[]
no_license
zg-jack/zg-shopping
b4e33d31e4d90b66cb1f11e48398205ade64dac3
ffe4e07b64fb8ded3a44b359b3bfb29e44605aca
refs/heads/master
2020-03-31T00:02:53.608889
2018-10-05T13:17:37
2018-10-05T13:17:37
151,723,260
2
0
null
null
null
null
UTF-8
Java
false
false
3,061
java
package com.zhuguang.jack.pojo; import java.math.BigDecimal; import java.util.Date; public class Product { private Integer id; private Integer categoryId; private String name; private String subtitle; private String mainImage; private String subImages; private String detail; private BigDecimal price; private Integer stock; private Integer status; private Date createTime; private Date updateTime; public Product(Integer id, Integer categoryId, String name, String subtitle, String mainImage, String subImages, String detail, BigDecimal price, Integer stock, Integer status, Date createTime, Date updateTime) { this.id = id; this.categoryId = categoryId; this.name = name; this.subtitle = subtitle; this.mainImage = mainImage; this.subImages = subImages; this.detail = detail; this.price = price; this.stock = stock; this.status = status; this.createTime = createTime; this.updateTime = updateTime; } public Product() { super(); } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getCategoryId() { return categoryId; } public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public String getSubtitle() { return subtitle; } public void setSubtitle(String subtitle) { this.subtitle = subtitle == null ? null : subtitle.trim(); } public String getMainImage() { return mainImage; } public void setMainImage(String mainImage) { this.mainImage = mainImage == null ? null : mainImage.trim(); } public String getSubImages() { return subImages; } public void setSubImages(String subImages) { this.subImages = subImages == null ? null : subImages.trim(); } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail == null ? null : detail.trim(); } public BigDecimal getPrice() { return price; } public void setPrice(BigDecimal price) { this.price = price; } public Integer getStock() { return stock; } public void setStock(Integer stock) { this.stock = stock; } public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } }
b632428553b2e7c342c68f9698949dc604042558
89b52a3a37595068e2e438d61f411dac69df0d45
/src/main/java/edu/generalpuzzle/infra/engines/trivial/TrivialIterativeEngineStrategy.java
edf5c92354c64d8a11ad4b1a15ce2f110cce805e
[]
no_license
shahart/puzzles-edu
e2d308385cb47d62570b9e6c0c7bd27866d0a63d
a0ff153b12aeb3e8013351c644a4d37d2ff9551a
refs/heads/master
2023-07-20T05:37:10.300368
2023-07-13T18:14:57
2023-07-13T18:14:57
111,853,074
0
0
null
null
null
null
UTF-8
Java
false
false
12,970
java
package edu.generalpuzzle.infra.engines.trivial; import edu.generalpuzzle.infra.ICellPart; import edu.generalpuzzle.infra.IGrid; import edu.generalpuzzle.infra.IPart; import edu.generalpuzzle.infra.Parts; import java.io.*; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import edu.generalpuzzle.infra.engines.EngineStrategy; import edu.generalpuzzle.main.Main; /** * Created by IntelliJ IDEA. * Date: 04/09/2008 */ public final class TrivialIterativeEngineStrategy extends TrivialEngineStrategy { public TrivialIterativeEngineStrategy(Parts parts, IGrid grid) { super(parts, grid); } @Override public void solve() { preSolve(); putIterative(partsAmount); postSolve(); } // load private void setState(DataInputStream fis, MyStack s) { try { int n = fis.readInt(); while (n-- > 0) s.push(fis.readInt()); partsIndices = new ArrayList<Integer>(); n = fis.read(); while (n-- > 0) partsIndices.add(fis.read()); for (n=0; n<solution.length; n++) solution[n] = fis.read(); triedParts = fis.readInt(); // Long // triedParts = 0; // since byte was wrote and not int - TODO write long totalNodes = 0; for (n=0; n<partsAmount; n++) { branches[n] = fis.readInt(); totalNodes += branches[n]; updates[n] = fis.readInt(); } uniqueSolutions = fis.readInt(); startTime -= fis.readInt()*1000; n = fis.readInt(); int gridState[] = new int[n]; for (int j=0; j<n; j++) gridState[j] = fis.readInt(); IGrid.Memento memento = new IGrid.Memento(); memento.state = gridState; // grid.setState(gridState); grid.setMemento(memento); partsInSolution = fis.read(); for (IPart part: parts.getParts()) part.rotate(fis.read()); for (IPart part: parts.getParts()) for (ICellPart cell :part.getCells()) { cell.setGridCellId(fis.readInt()); cell.setGridCell(grid.get(cell.getGridCellId())); } if (fis.read() != 255) System.out.println("error: invalid load"); } catch (IOException e) { System.out.println("error: load error- " +e.getMessage()); } } // save private void getState(int address, int oldCellIndex, int partIndex, int r, int i, int leftParts, MyStack s) { // TODO disable when there are engines (>1) if (getEngineId() > 1) return; try { new File("saves").mkdir(); File file = new java.io.File(Main.FILE_NAME); file.delete(); file.createNewFile(); FileOutputStream os = new FileOutputStream(file); DataOutputStream fos = new DataOutputStream(os); // local of putIterative fos.write(address); fos.writeInt(oldCellIndex); fos.write(partIndex); fos.write(r); fos.write(i); fos.write(leftParts); int head = s.getHead(); fos.writeInt(head); int data[] = s.getData(); for (int j=0; j<head;j++) fos.writeInt(data[j]); // more, global variables fos.write(partsIndices.size()); for (int j: partsIndices) fos.write(j); for (int j: solution) fos.write(j); fos.writeInt((int)triedParts); // TODO Long for (int n=0;n< partsAmount; n++) { fos.writeInt((int)branches[n]); fos.writeInt((int)updates[n]); } fos.writeInt(uniqueSolutions); Date end = Calendar.getInstance().getTime(); int elapsedTime = (int)((end.getTime() - startTime) / 1000); fos.writeInt(elapsedTime); // pairs of cellId, partId in that cellId IGrid.Memento memento = grid.createMemento(); int gridState[] = memento.state; fos.writeInt(gridState.length); for (int aGridState : gridState) fos.writeInt(aGridState); fos.write(partsInSolution); for (IPart part: parts.getParts()) fos.write(part.getRotationIndex()); for (IPart part: parts.getParts()) for (ICellPart cell: part.getCells()) fos.writeInt(cell.getGridCellId()); fos.write(255); // very basic validation for loading fos.flush(); fos.close(); } catch (IOException e) { System.out.println("error: save error- " +e.getMessage()); } } // Iterative - same speed as recursive, but better! public void putIterative(int leftParts) { final int ADDR_FORWARD = 10; final int ADDR_BACKWARD = 20; final int ADDR_STOP = 30; // for (int i=0; i< partsAmount*2; i++) solutionSoFarBuffer.append(' '); int address; // Entry point for each "call" // entry start int oldCellIndex = 999; int partIndex = 999; int r = 0; int i = fromPart; // loop, start with 0 // int leftParts; // entry stop final int ENTRY_SIZE = 6; // 5 ints + address = state // Stack<Integer> s = new Stack<Integer>(); // very slow, 15 times slower than "my" stack MyStack s = new MyStack((leftParts+1) * ENTRY_SIZE); // 1st call into s.push(address = ADDR_STOP); address = ADDR_FORWARD; try { File file = new java.io.File("saves/state_puz.bin"); FileInputStream is = new FileInputStream(file); DataInputStream fis = new DataInputStream(is); s.pop(); address = fis.read(); oldCellIndex = fis.readInt(); partIndex = fis.read(); r = fis.read(); i = fis.read(); leftParts = fis.read(); setState(fis, s); fis.close(); file.delete(); if (id == 0) System.out.println("\nLOADED"); } catch (IOException e) { if (id == 0) System.out.println("\nerror: Load-file not found- restarting"); } while (true) { if (toSave) { getState(address, /**/ oldCellIndex, partIndex, r,i, leftParts, s); toSave = false; } if (inPause >= 1) pause(); switch(address) { case ADDR_FORWARD: if (leftParts == partsInSolution) { // normally ==0 // The base case address = s.pop(); solved(); break; } oldCellIndex = grid.getCurrCellIndex(); boolean canPut = false; int newR=0, newI=0; for (; i<leftParts && ! canPut; i++, r=0) { // note the r=0 ! partIndex = partsIndices.get(i); currPart = parts.getParts().get(partIndex); if (leftParts == partsAmount) { if (i == toPart) return; // if (lastSolution.length() <= 2) lastSolution = "" + (char)currPart.getId() + rotationChar(r); } // 5.8 M, 21 sec, genAll false - REGULAR, no X limit // for 5 10 6- genAll true (because tha'ts why X in the quarter) 10.9M, 45 sec // for 5 6 10 - much more, as in 3x20 vs. 20x3 //if (! (currPart.getId() == 'X' && grid.getClass().getName().endsWith("Grid2D") && (oldCellIndex % ((Grid2D)grid).getColumns() >= ((Grid2D)grid).getColumns()/2 || oldCellIndex / ((Grid2D)grid).getColumns() >= (((Grid2D)grid).getRows()-2)/2))) // knuth 28M branches, 4.1 G updates, with S- 902K, 309M , little bigger as we can't do the X quarter jo // solutionSoFarBuffer.setCharAt((partsAmount - leftParts)*2+1, (char)(currPart.getId())); for (; r< currPart.getTotalRotations() ; r++) { if (! GENERATE_BY_ALL && currPart == unique) { //.getId() == parts.getUnique()) { int newLocation = implied[uniqueInImplied[r]][ (oldCellIndex) ]; if (newLocation < oldCellIndex) // if (uniqsFound[oldCellIndex][r] != -1) continue; } // ++ updates[partsAmount - leftParts]; // TODO is that correct? if (possibleRotations[partIndex][r][grid.getCurrCellIndex()] != null) {// process, r, gridCell currPart.rotate(r); ++ updates[partsAmount - leftParts]; // TODO is that correct? if (canPut = grid.newCanPut(currPart)) { //canPut(currPart)) { // if (grid.isStranded() && leftParts != partsInSolution+1) { // no parts size 1 and no partWithPlaceHolderExist // TODO not only isStranded,but hole< 5. when seedgehing, stop if size>=5 if (rollback(leftParts)) { grid.removeLast(currPart); grid.setCurrCellIndex(oldCellIndex); canPut = false; } else { if (trace) grid.show(implied[0]); track(leftParts, i, partIndex); s.push(oldCellIndex); s.push(partIndex); s.push(r); s.push(i); s.push(leftParts); // putRecursive(leftParts-1); // the recurse newR=0; newI=0; --leftParts; s.push(ADDR_BACKWARD); // where should I return? address = ADDR_FORWARD; // Make another "call" break; } } } } } if (! canPut) address = s.pop(); else { r = newR; i = newI; } break; case ADDR_BACKWARD: // "Compute" and return leftParts = s.pop(); i = s.pop(); r = s.pop(); partIndex = s.pop(); oldCellIndex = s.pop(); address = s.pop(); backTrack(leftParts, oldCellIndex, i, partIndex); // next? //if (r+1 < currPart.getTotalRotations() //|| i+1<leftParts) { if (r+1 < currPart.getTotalRotations()) r++; else if (i+1<leftParts) { r=0; i++; } else break; s.push(address); address = ADDR_FORWARD; //} break; case ADDR_STOP: // The final return value - in our case, no value return; } } } private final class MyStack { private final int[] data; private int head = 0; public MyStack(int size) { data = new int[size]; } public boolean isEmpty() { return head == 0; } public void push(int x) { data[head++] = x; } public int pop() { return data[--head]; } public int[] getData() { return data; } public int getHead() { return head; } } }
0543681d88254ec29c58d5f81dd70aeebd18084c
ab164796fc7eee6ea1a2bc2d318724d7f40f1100
/Additional_Projects_Pack/D11_P1_REP_Stack/Main.java
cb85dfa3e8d04dcd19d8d0d4c3d48ae02cb8b905
[ "MIT" ]
permissive
alvenplay/BoP
9c15a82b7926c7479db1212c60c6d3eaed59b0ac
4c6c3750bc679ba836b357b3b11d84d4afb0bf4f
refs/heads/master
2021-04-26T16:43:37.089740
2016-02-07T22:01:15
2016-02-07T22:01:15
49,975,573
0
0
null
null
null
null
UTF-8
Java
false
false
276
java
package Additional_Projects_Pack.D11_P1_REP_Stack; public class Main { public static void main(String[] args) { Stack stack = new Stack(); for(int i=0; i<10; i++) { stack.push(i); } for(int i=0; i<10; i++) { System.out.println(stack.pull());; } } }
fe99518a8cf85be7e2b0e37ee22622ff1af516be
a85249ce6bc2b53c911184267f22229e7c23f848
/streams/src/test/java/net/reliqs/emonlight/streams/client/ReceiverConfig.java
9c2db659bf187c3d597f5574a7f65f8fb1a2bef4
[]
no_license
sermore/emonlight-spring
26ba1a2da932330e5a74d08a01029955da95e321
ed7ba37dc2a6539dc2858a437935375fc10991b6
refs/heads/master
2021-01-18T23:33:55.480438
2018-10-23T07:54:29
2018-10-23T07:54:29
87,115,197
0
0
null
null
null
null
UTF-8
Java
false
false
2,137
java
package net.reliqs.emonlight.streams.client; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.common.serialization.DoubleDeserializer; import org.apache.kafka.common.serialization.LongDeserializer; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.kafka.annotation.EnableKafka; import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; import org.springframework.kafka.core.ConsumerFactory; import org.springframework.kafka.core.DefaultKafkaConsumerFactory; import java.util.HashMap; import java.util.Map; @Configuration @EnableKafka public class ReceiverConfig { @Value("${kafka.bootstrap.servers}") private String bootstrapServers; @Bean public Map<String, Object> consumerConfigs() { Map<String, Object> props = new HashMap<>(); // list of host:port pairs used for establishing the initial connections // to the Kakfa cluster props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, LongDeserializer.class); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, DoubleDeserializer.class); // consumer groups allow a pool of processes to divide the work of // consuming and processing records props.put(ConsumerConfig.GROUP_ID_CONFIG, "helloworld"); return props; } @Bean public ConsumerFactory<Long, Double> consumerFactory() { return new DefaultKafkaConsumerFactory<>(consumerConfigs()); } @Bean public ConcurrentKafkaListenerContainerFactory<Long, Double> kafkaListenerContainerFactory() { ConcurrentKafkaListenerContainerFactory<Long, Double> factory = new ConcurrentKafkaListenerContainerFactory<>(); factory.setConsumerFactory(consumerFactory()); factory.setBatchListener(true); return factory; } @Bean public Receiver receiver() { return new Receiver(); } }
2ba95943e4e15d4a58eea6276a9788778abd3d15
a9aedd670e8ad916ea669f55fba0306973576528
/org/sqlite/core/DB.java
8ffe832c1f98bdcd702cdc4c4c431c2a8aab2eb8
[]
no_license
shaddoxac/DatabaseCheckers
8d0456fe56d1e0684ba675fb2ae1c4126110b2fd
d97e3c5a7b457abdb853d53fd15a5b64082506eb
refs/heads/master
2016-09-05T16:03:28.006580
2015-04-15T22:36:59
2015-04-15T22:36:59
33,272,858
0
1
null
null
null
null
UTF-8
Java
false
false
39,728
java
/* * Copyright (c) 2007 David Crawshaw <[email protected]> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ package org.sqlite.core; import java.sql.BatchUpdateException; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.sqlite.Function; import org.sqlite.SQLiteConnection; import org.sqlite.SQLiteErrorCode; /* * This class is the interface to SQLite. It provides some toBinaryString functions * used by other parts of the driver. The goal of the toBinaryString functions here * are not only to provide functionality, but to handle contractual * differences between the JDBC specification and the SQLite C API. * * The process of moving SQLite weirdness into this class is incomplete. * You'll still find lots of code in Stmt and PrepStmt that are doing * implicit contract conversions. Sorry. * * The subclass, NativeDB, provides the actual access to SQLite functions. */ public abstract class DB implements Codes { /** The JDBC Connection that 'owns' this database instance. */ SQLiteConnection conn = null; /** The "begin;"and "commit;" statement handles. */ long begin = 0; long commit = 0; /** Tracer for statements to avoid unfinalized statements on db close. */ private final Map<Long, CoreStatement> stmts = new HashMap<Long, CoreStatement>(); // WRAPPER FUNCTIONS //////////////////////////////////////////// /** * Aborts any pending operation and returns at its earliest opportunity. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/interrupt.html">http://www.sqlite.org/c3ref/interrupt.html</a> */ public abstract void interrupt() throws SQLException; /** * Sets a <a href="http://www.sqlite.org/c3ref/busy_handler.html">busy handler</a> that sleeps * for a specified amount of time when a table is locked. * @param ms Time to sleep in milliseconds. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/busy_timeout.html">http://www.sqlite.org/c3ref/busy_timeout.html</a> */ public abstract void busy_timeout(int ms) throws SQLException; /** * Return English-language text that describes the error as either UTF-8 or UTF-16. * @return Error description in English. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/errcode.html">http://www.sqlite.org/c3ref/errcode.html</a> */ abstract String errmsg() throws SQLException; /** * Returns the value for SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C * preprocessor macros that are associated with the library. * @return Compile-time SQLite version information. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/libversion.html">http://www.sqlite.org/c3ref/libversion.html</a> * @see <a href="http://www.sqlite.org/c3ref/c_source_id.html">http://www.sqlite.org/c3ref/c_source_id.html</a> */ public abstract String libversion() throws SQLException; /** * @return Number of rows that were changed, inserted or deleted by the last * SQL statement * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/changes.html">http://www.sqlite.org/c3ref/changes.html</a> */ public abstract int changes() throws SQLException; /** * @return Number of row changes caused by INSERT, UPDATE or DELETE statements * since the database connection was opened. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/total_changes.html">http://www.sqlite.org/c3ref/total_changes.html</a> */ public abstract int total_changes() throws SQLException; /** * Enables or disables the sharing of the database cache and schema data structures between * connections to the same database. * @param enable True to enable; false otherwise. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/enable_shared_cache.html">http://www.sqlite.org/c3ref/enable_shared_cache.html</a> * @see org.sqlite.SQLiteErrorCode */ public abstract int shared_cache(boolean enable) throws SQLException; /** * Enables or disables loading of SQLite extensions. * @param enable True to enable; false otherwise. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/load_extension.html">http://www.sqlite.org/c3ref/load_extension.html</a> */ public abstract int enable_load_extension(boolean enable) throws SQLException; /** * Executes an SQL statement using the process of compiling, evaluating, and destroying the * prepared statement object. * @param sql SQL statement to be executed. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/exec.html">http://www.sqlite.org/c3ref/exec.html</a> */ public final synchronized void exec(String sql) throws SQLException { long pointer = 0; try { pointer = prepare(sql); switch (step(pointer)) { case SQLITE_DONE: ensureAutoCommit(); return; case SQLITE_ROW: return; default: throwex(); } } finally { finalize(pointer); } } /** * Creates an SQLite interface to a database for the given connection. * @param conn The connection. * @param file The database. * @param openFlags File opening configurations * (<a href="http://www.sqlite.org/c3ref/c_open_autoproxy.html">http://www.sqlite.org/c3ref/c_open_autoproxy.html</a>) * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/open.html">http://www.sqlite.org/c3ref/open.html</a> */ public final synchronized void open(SQLiteConnection conn, String file, int openFlags) throws SQLException { this.conn = conn; _open(file, openFlags); } /** * Closes a database connection and finalizes any remaining statements before * the closing operation. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/close.html">http://www.sqlite.org/c3ref/close.html</a> */ public final synchronized void close() throws SQLException { // finalize any remaining statements before closing db synchronized (stmts) { Iterator<Map.Entry<Long, CoreStatement>> i = stmts.entrySet().iterator(); while (i.hasNext()) { Map.Entry<Long, CoreStatement> entry = i.next(); CoreStatement stmt = entry.getValue(); finalize(entry.getKey().longValue()); if (stmt != null) { stmt.pointer = 0; } i.remove(); } } // remove memory used by user-defined functions free_functions(); // clean up commit object if (begin != 0) { finalize(begin); begin = 0; } if (commit != 0) { finalize(commit); commit = 0; } _close(); } /** * Complies the an SQL statement. * @param stmt The SQL statement to compile. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/prepare.html">http://www.sqlite.org/c3ref/prepare.html</a> */ public final synchronized void prepare(CoreStatement stmt) throws SQLException { if (stmt.pointer != 0) { finalize(stmt); } stmt.pointer = prepare(stmt.sql); stmts.put(new Long(stmt.pointer), stmt); } /** * Destroys a statement. * @param stmt The statement to destroy. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/finalize.html">http://www.sqlite.org/c3ref/finalize.html</a> */ public final synchronized int finalize(CoreStatement stmt) throws SQLException { if (stmt.pointer == 0) { return 0; } int rc = SQLITE_ERROR; try { rc = finalize(stmt.pointer); } finally { stmts.remove(new Long(stmt.pointer)); stmt.pointer = 0; } return rc; } /** * Creates an SQLite interface to a database with the provided open flags. * @param filename The database to open. * @param openFlags File opening configurations * (<a href="http://www.sqlite.org/c3ref/c_open_autoproxy.html">http://www.sqlite.org/c3ref/c_open_autoproxy.html</a>) * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/open.html">http://www.sqlite.org/c3ref/open.html</a> */ protected abstract void _open(String filename, int openFlags) throws SQLException; /** * Closes the SQLite interface to a database. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/close.html">http://www.sqlite.org/c3ref/close.html</a> */ protected abstract void _close() throws SQLException; /** * Complies, evaluates, executes and commits an SQL statement. * @param sql An SQL statement. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/exec.html">http://www.sqlite.org/c3ref/exec.html</a> */ public abstract int _exec(String sql) throws SQLException; /** * Complies an SQL statement. * @param sql An SQL statement. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/prepare.html">http://www.sqlite.org/c3ref/prepare.html</a> */ protected abstract long prepare(String sql) throws SQLException; /** * Destroys a prepared statement. * @param stmt Pointer to the statement pointer. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/finalize.html">http://www.sqlite.org/c3ref/finalize.html</a> */ protected abstract int finalize(long stmt) throws SQLException; /** * Evaluates a statement. * @param stmt Pointer to the statement. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/step.html">http://www.sqlite.org/c3ref/step.html</a> */ public abstract int step(long stmt) throws SQLException; /** * Sets a prepared statement object back to its initial state, * ready to be re-executed. * @param stmt Pointer to the statement. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/reset.html">http://www.sqlite.org/c3ref/reset.html</a> */ public abstract int reset(long stmt) throws SQLException; /** * Reset all bindings on a prepared statement (reset all host parameters to NULL). * @param stmt Pointer to the statement. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/clear_bindings.html">http://www.sqlite.org/c3ref/clear_bindings.html</a> */ public abstract int clear_bindings(long stmt) throws SQLException; // TODO remove? /** * @param stmt Pointer to the statement. * @return Number of parameters in a prepared SQL. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_parameter_count.html">http://www.sqlite.org/c3ref/bind_parameter_count.html</a> */ abstract int bind_parameter_count(long stmt) throws SQLException; /** * @param stmt Pointer to the statement. * @return Number of columns in the result set returned by the prepared statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_count.html">http://www.sqlite.org/c3ref/column_count.html</a> */ public abstract int column_count(long stmt) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return Datatype code for the initial data type of the result column. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract int column_type(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return Declared type of the table column for prepared statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_decltype.html">http://www.sqlite.org/c3ref/column_decltype.html</a> */ public abstract String column_decltype(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return Original text of column name which is the declared in the CREATE TABLE statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_database_name.html">http://www.sqlite.org/c3ref/column_database_name.html</a> */ public abstract String column_table_name(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col The number of column. * @return Name assigned to a particular column in the result set of a SELECT statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_name.html">http://www.sqlite.org/c3ref/column_name.html</a> */ public abstract String column_name(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return Value of the column as text data type in the result set of a SELECT statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract String column_text(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return BLOB value of the column in the result set of a SELECT statement * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract byte[] column_blob(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return DOUBLE value of the column in the result set of a SELECT statement * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract double column_double(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return LONG value of the column in the result set of a SELECT statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract long column_long(long stmt, int col) throws SQLException; /** * @param stmt Pointer to the statement. * @param col Number of column. * @return INT value of column in the result set of a SELECT statement. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/column_blob.html">http://www.sqlite.org/c3ref/column_blob.html</a> */ public abstract int column_int(long stmt, int col) throws SQLException; /** * Binds NULL value to prepared statements with the pointer to the statement object and the * index of the SQL parameter to be set to NULL. * @param stmt Pointer to the statement. * @param pos The index of the SQL parameter to be set to NULL. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException */ abstract int bind_null(long stmt, int pos) throws SQLException; /** * Binds int value to prepared statements with the pointer to the statement object, the index of * the SQL parameter to be set and the value to bind to the parameter. * @param stmt Pointer to the statement. * @param pos The index of the SQL parameter to be set. * @param v Value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ abstract int bind_int(long stmt, int pos, int v) throws SQLException; /** * Binds long value to prepared statements with the pointer to the statement object, the index * of the SQL parameter to be set and the value to bind to the parameter. * @param stmt Pointer to the statement. * @param pos The index of the SQL parameter to be set. * @param v Value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ abstract int bind_long(long stmt, int pos, long v) throws SQLException; /** * Binds double value to prepared statements with the pointer to the statement object, the index * of the SQL parameter to be set and the value to bind to the parameter. * @param stmt Pointer to the statement. * @param pos Index of the SQL parameter to be set. * @param v Value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ abstract int bind_double(long stmt, int pos, double v) throws SQLException; /** * Binds text value to prepared statements with the pointer to the statement object, the index * of the SQL parameter to be set and the value to bind to the parameter. * @param stmt Pointer to the statement. * @param pos Index of the SQL parameter to be set. * @param v value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ abstract int bind_text(long stmt, int pos, String v) throws SQLException; /** * Binds blob value to prepared statements with the pointer to the statement object, the index * of the SQL parameter to be set and the value to bind to the parameter. * @param stmt Pointer to the statement. * @param pos Index of the SQL parameter to be set. * @param v Value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ abstract int bind_blob(long stmt, int pos, byte[] v) throws SQLException; /** * Sets the result of an SQL function as NULL with the pointer to the SQLite database context. * @param context Pointer to the SQLite database context. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_null(long context) throws SQLException; /** * Sets the result of an SQL function as text data type with the pointer to the SQLite database * context and the the result value of String. * @param context Pointer to the SQLite database context. * @param val Result value of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_text(long context, String val) throws SQLException; /** * Sets the result of an SQL function as blob data type with the pointer to the SQLite database * context and the the result value of byte array. * @param context Pointer to the SQLite database context. * @param val Result value of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_blob(long context, byte[] val) throws SQLException; /** * Sets the result of an SQL function as double data type with the pointer to the SQLite * database context and the the result value of double. * @param context Pointer to the SQLite database context. * @param val Result value of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_double(long context, double val) throws SQLException; /** * Sets the result of an SQL function as long data type with the pointer to the SQLite database * context and the the result value of long. * @param context Pointer to the SQLite database context. * @param val Result value of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_long(long context, long val) throws SQLException; /** * Sets the result of an SQL function as int data type with the pointer to the SQLite database * context and the the result value of int. * @param context Pointer to the SQLite database context. * @param val Result value of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_int(long context, int val) throws SQLException; /** * Sets the result of an SQL function as an error with the pointer to the SQLite database * context and the the error of String. * @param context Pointer to the SQLite database context. * @param err Error result of an SQL function. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/result_blob.html">http://www.sqlite.org/c3ref/result_blob.html</a> */ public abstract void result_error(long context, String err) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate in bytes data type. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract int value_bytes(Function f, int arg) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate in text data type. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract String value_text(Function f, int arg) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate in blob data type. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract byte[] value_blob(Function f, int arg) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate in double data type * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract double value_double(Function f, int arg) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate in long data type. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract long value_long(Function f, int arg) throws SQLException; /** * Accesses the parameter values on the function or aggregate in int data type with the function * object and the parameter value. * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter value of the given SQLite function or aggregate. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract int value_int(Function f, int arg) throws SQLException; /** * @param f SQLite function object. * @param arg Pointer to the parameter of the SQLite function or aggregate. * @return Parameter datatype of the function or aggregate in int data type. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/value_blob.html">http://www.sqlite.org/c3ref/value_blob.html</a> */ public abstract int value_type(Function f, int arg) throws SQLException; /** * Create a user defined function with given function name and the function object. * @param name The function name to be created. * @param f SQLite function object. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/create_function.html">http://www.sqlite.org/c3ref/create_function.html</a> */ public abstract int create_function(String name, Function f) throws SQLException; /** * De-registers a user defined function * @param name Name of the function to de-registered. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException */ public abstract int destroy_function(String name) throws SQLException; /** * Unused as we use the user_data pointer to store a single word. * @throws SQLException */ abstract void free_functions() throws SQLException; /** * @param dbName Database name to be backed up. * @param destFileName Target backup file name. * @param observer ProgressObserver object. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * */ public abstract int backup(String dbName, String destFileName, ProgressObserver observer) throws SQLException; /** * @param dbName Database name for restoring data. * @param sourceFileName Source file name. * @param observer ProgressObserver object. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * */ public abstract int restore(String dbName, String sourceFileName, ProgressObserver observer) throws SQLException; public static interface ProgressObserver { public void progress(int remaining, int pageCount); } /** * Returns an array describing the attributes (not null, primary key and auto increment) of columns. * @param stmt Pointer to the statement. * @return Column attribute array.<br/> * index[col][0] = true if column constrained NOT NULL;<br/> * index[col][1] = true if column is part of the primary key; <br/> * index[col][2] = true if column is auto-increment. * @throws SQLException */ abstract boolean[][] column_metadata(long stmt) throws SQLException; // COMPOUND FUNCTIONS //////////////////////////////////////////// /** * Returns an array of column names in the result set of the SELECT statement. * @param stmt Stmt object. * @return String array of column names. * @throws SQLException */ public final synchronized String[] column_names(long stmt) throws SQLException { String[] names = new String[column_count(stmt)]; for (int i = 0; i < names.length; i++) { names[i] = column_name(stmt, i); } return names; } /** * Bind values to prepared statements * @param stmt Pointer to the statement. * @param pos Index of the SQL parameter to be set to NULL. * @param v Value to bind to the parameter. * @return <a href="http://www.sqlite.org/c3ref/c_abort.html">Result Codes</a> * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/bind_blob.html">http://www.sqlite.org/c3ref/bind_blob.html</a> */ final synchronized int sqlbind(long stmt, int pos, Object v) throws SQLException { pos++; if (v == null) { return bind_null(stmt, pos); } else if (v instanceof Integer) { return bind_int(stmt, pos, ((Integer) v).intValue()); } else if (v instanceof Short) { return bind_int(stmt, pos, ((Short) v).intValue()); } else if (v instanceof Long) { return bind_long(stmt, pos, ((Long) v).longValue()); } else if (v instanceof Float) { return bind_double(stmt, pos, ((Float) v).doubleValue()); } else if (v instanceof Double) { return bind_double(stmt, pos, ((Double) v).doubleValue()); } else if (v instanceof String) { return bind_text(stmt, pos, (String) v); } else if (v instanceof byte[]) { return bind_blob(stmt, pos, (byte[]) v); } else { throw new SQLException("unexpected param type: " + v.getClass()); } } /** * Submits a batch of commands to the database for execution. * @see java.sql.Statement#executeBatch() * @param stmt Pointer of Stmt object. * @param count Number of SQL statements. * @param vals Array of parameter values. * @return Array of the number of rows changed or inserted or deleted for each command if all * commands execute successfully; * @throws SQLException */ final synchronized int[] executeBatch(long stmt, int count, Object[] vals) throws SQLException { if (count < 1) { throw new SQLException("count (" + count + ") < 1"); } final int params = bind_parameter_count(stmt); int rc; int[] changes = new int[count]; try { for (int i = 0; i < count; i++) { reset(stmt); for (int j = 0; j < params; j++) { if (sqlbind(stmt, j, vals[(i * params) + j]) != SQLITE_OK) { throwex(); } } rc = step(stmt); if (rc != SQLITE_DONE) { reset(stmt); if (rc == SQLITE_ROW) { throw new BatchUpdateException("batch entry " + i + ": query returns results", changes); } throwex(); } changes[i] = changes(); } } finally { ensureAutoCommit(); } reset(stmt); return changes; } /** * @see <a href="http://www.sqlite.org/c_interface.html#sqlite_exec">http://www.sqlite.org/c_interface.html#sqlite_exec</a> * @param stmt Stmt object. * @param vals Array of parameter values. * @return True if a row of ResultSet is ready; false otherwise. * @throws SQLException */ public final synchronized boolean execute(CoreStatement stmt, Object[] vals) throws SQLException { if (vals != null) { final int params = bind_parameter_count(stmt.pointer); if (params != vals.length) { throw new SQLException("assertion failure: param count (" + params + ") != value count (" + vals.length + ")"); } for (int i = 0; i < params; i++) { if (sqlbind(stmt.pointer, i, vals[i]) != SQLITE_OK) { throwex(); } } } int statusCode = step(stmt.pointer); switch (statusCode) { case SQLITE_DONE: reset(stmt.pointer); ensureAutoCommit(); return false; case SQLITE_ROW: return true; case SQLITE_BUSY: case SQLITE_LOCKED: case SQLITE_MISUSE: throw newSQLException(statusCode); default: finalize(stmt); throw newSQLException(statusCode); } } /** * Executes the given SQL statement using the one-step query execution interface. * @param sql SQL statement to be executed. * @return True if a row of ResultSet is ready; false otherwise. * @throws SQLException * @see <a href="http://www.sqlite.org/c3ref/exec.html">http://www.sqlite.org/c3ref/exec.html</a> */ final synchronized boolean execute(String sql) throws SQLException { int statusCode = _exec(sql); switch (statusCode) { case SQLITE_OK: return false; case SQLITE_DONE: ensureAutoCommit(); return false; case SQLITE_ROW: return true; default: throw newSQLException(statusCode); } } /** * Execute an SQL INSERT, UPDATE or DELETE statement with the Stmt object and an array of * parameter values of the SQL statement.. * @param stmt Stmt object. * @param vals Array of parameter values. * @return Number of database rows that were changed or inserted or deleted by the most * recently completed SQL. * @throws SQLException */ public final synchronized int executeUpdate(CoreStatement stmt, Object[] vals) throws SQLException { if (execute(stmt, vals)) { throw new SQLException("query returns results"); } reset(stmt.pointer); return changes(); } /** * Throws SQLException with error message. * @throws SQLException */ final void throwex() throws SQLException { throw new SQLException(errmsg()); } /** * Throws SQLException with error code. * @param errorCode Error code to be passed. * @throws SQLException */ public final void throwex(int errorCode) throws SQLException { throw newSQLException(errorCode); } /** * Throws SQL Exception with error code and message. * @param errorCode Error code to be passed. * @param errorMessage Error message to be passed. * @throws SQLException */ final void throwex(int errorCode, String errorMessage) throws SQLException { throw newSQLException(errorCode, errorMessage); } /** * Throws formated SQLException with error code and message. * @param errorCode Error code to be passed. * @param errorMessage Error message to be passed. * @return Formated SQLException with error code and message. * @throws SQLException */ public static SQLException newSQLException(int errorCode, String errorMessage) throws SQLException { SQLiteErrorCode code = SQLiteErrorCode.getErrorCode(errorCode); SQLException e = new SQLException(String.format("%s (%s)", code, errorMessage), null, code.code); return e; } /** * Throws SQL Exception with error code. * @param errorCode Error code to be passed. * @return SQLException with error code and message. * @throws SQLException */ private SQLException newSQLException(int errorCode) throws SQLException { return newSQLException(errorCode, errmsg()); } /** * SQLite and the JDBC API have very different ideas about the meaning * of auto-commit. Under JDBC, when executeUpdate() returns in * auto-commit mode (the default), the programmer assumes the data has * been written to disk. In SQLite however, a call to sqlite3_step() * with an INSERT statement can return SQLITE_OK, and yet the data is * still in limbo. * * This limbo appears when another statement on the database is active, * e.g. a SELECT. SQLite auto-commit waits until the final read * statement finishes, and then writes whatever updates have already * been OKed. So if a program crashes before the reads are complete, * data is lost. E.g: * * select begins * insert * select continues * select finishes * * Works as expected, however * * select beings * insert * select continues * crash * * Results in the data never being written to disk. * * As a solution, we call "commit" after every statement in auto-commit * mode. * @throws SQLException */ final void ensureAutoCommit() throws SQLException { if (!conn.getAutoCommit()) { return; } if (begin == 0) { begin = prepare("begin;"); } if (commit == 0) { commit = prepare("commit;"); } try { if (step(begin) != SQLITE_DONE) { return; // assume we are in a transaction } if (step(commit) != SQLITE_DONE) { reset(commit); throwex(); } //throw new SQLException("unable to auto-commit"); } finally { reset(begin); reset(commit); } } }
713e581ea147c8aa556eb3b432e33a100fa07189
c474b03758be154e43758220e47b3403eb7fc1fc
/apk/decompiled/com.tinder_2018-07-26_source_from_JADX/sources/com/tinder/superlike/p421e/C15081c.java
8629eac698354fa700ceb286a93a7b4466fbd677
[]
no_license
EstebanDalelR/tinderAnalysis
f80fe1f43b3b9dba283b5db1781189a0dd592c24
941e2c634c40e5dbf5585c6876ef33f2a578b65c
refs/heads/master
2020-04-04T09:03:32.659099
2018-11-23T20:41:28
2018-11-23T20:41:28
155,805,042
0
0
null
2018-11-18T16:02:45
2018-11-02T02:44:34
null
UTF-8
Java
false
false
872
java
package com.tinder.superlike.p421e; import com.tinder.api.TinderApi; import com.tinder.domain.superlike.SuperlikeStatus; import com.tinder.superlike.p418a.C15066a; import javax.inject.Inject; import rx.Observable; import rx.Single; /* renamed from: com.tinder.superlike.e.c */ public class C15081c { /* renamed from: a */ private final TinderApi f46932a; /* renamed from: b */ private final C15066a f46933b; @Inject public C15081c(TinderApi tinderApi, C15066a c15066a) { this.f46932a = tinderApi; this.f46933b = c15066a; } @Deprecated /* renamed from: a */ public Single<SuperlikeStatus> m56830a() { Observable superLikeStatus = this.f46932a.getSuperLikeStatus(); C15066a c15066a = this.f46933b; c15066a.getClass(); return superLikeStatus.k(C18192d.m65965a(c15066a)).a(); } }
e65e7f977e6b6b792f74f0fc8c3c4f76d5cf15c3
ab0714655c503775427e7b728e078deee40d8876
/src/main/java/ugly/ExpandService.java
80eb351ee21c1beccde5c45fd2cb9943c846afd8
[]
no_license
ajmalbabu/ugly-numbers
8683fd977004a2f9612c9a614bde71433499a4a8
6c8aa4d5fd5d1c33a9ecc20ec18dfc36b42d6217
refs/heads/master
2016-08-12T07:22:55.558982
2015-10-24T14:28:03
2015-10-24T14:28:03
44,854,342
0
0
null
null
null
null
UTF-8
Java
false
false
926
java
package ugly; import java.util.List; /** * Service to expand the provided expandable request. */ class ExpandService { /** * @param expandable The method fully expands the request * and returns with the ExpandedList. * @return The completely expanded list. */ public ExpandedList expand(Expandable expandable) { ExpandedList expandedList = new ExpandedList(); List<ExpandableElement> expandableElements = expandable.expand(); for (int i = 0; i < expandableElements.size(); i++) { ExpandableElement expandableElement = expandableElements.get(i); if (expandableElement.fullyExpanded()) { expandedList = expandedList.add(expandableElement.getExpanded()); } else { expandableElements.addAll(expandableElement.expand()); } } return expandedList; } }
cdeafa82a5183420f8d1dedb678e082b1ea82e5b
7b73756ba240202ea92f8f0c5c51c8343c0efa5f
/classes/android/support/v4/view/MotionEventCompatEclair.java
2b0cd2aed0e048b13e41aa80a1cb4526df29e2fc
[]
no_license
meeidol-luo/qooq
588a4ca6d8ad579b28dec66ec8084399fb0991ef
e723920ac555e99d5325b1d4024552383713c28d
refs/heads/master
2020-03-27T03:16:06.616300
2016-10-08T07:33:58
2016-10-08T07:33:58
null
0
0
null
null
null
null
UTF-8
Java
false
false
949
java
package android.support.v4.view; import android.view.MotionEvent; class MotionEventCompatEclair { public static int findPointerIndex(MotionEvent paramMotionEvent, int paramInt) { return paramMotionEvent.findPointerIndex(paramInt); } public static int getPointerCount(MotionEvent paramMotionEvent) { return paramMotionEvent.getPointerCount(); } public static int getPointerId(MotionEvent paramMotionEvent, int paramInt) { return paramMotionEvent.getPointerId(paramInt); } public static float getX(MotionEvent paramMotionEvent, int paramInt) { return paramMotionEvent.getX(paramInt); } public static float getY(MotionEvent paramMotionEvent, int paramInt) { return paramMotionEvent.getY(paramInt); } } /* Location: E:\apk\QQ_91\classes-dex2jar.jar!\android\support\v4\view\MotionEventCompatEclair.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
10189155ba15a13d949aab12b25af3d12d1963dd
041e10a4069b3f4e453092ad9a4ffd9bdb504569
/src/main/java/org/fasttrackit/Car.java
f16f5fd6d4f74c0b56578c5d232a37681c8a8bd9
[]
no_license
JuliaKinga/RacingGameExperiments
83095410edb10f9e97a3f6c9d964dbbc6b4b7831
94c70ec2cd7ae147fcc1131b9b93b42e36a11d43
refs/heads/master
2021-08-12T05:42:54.320674
2017-11-14T13:44:14
2017-11-14T13:44:14
110,695,379
0
0
null
null
null
null
UTF-8
Java
false
false
164
java
package org.fasttrackit; public class Car { String name; String color; int doorCount; double mileage; double fuelLevel; Engine engine; }
2a3251b0dc6c80e81b0053c9b45ea26803c7a1d1
acddb911a1994b7ee54e20ab551331c51e77321f
/app/src/main/java/com/littleant/carrepair/request/excute/service/order/OrderQueryOneCmd.java
ebfd26d26e405c1f9df948e8e7ed94ca8b891b76
[]
no_license
sghuang/CarProject
13a9782202dce1369c0d1aed1a928c981bb2662f
3182eb62f77640c55d0ff90a2950fad5b50908ce
refs/heads/master
2021-07-20T01:10:05.581752
2018-10-22T03:10:03
2018-10-22T03:10:03
137,007,470
0
1
null
null
null
null
UTF-8
Java
false
false
887
java
package com.littleant.carrepair.request.excute.service.order; import android.content.Context; import com.littleant.carrepair.request.constant.InterfaceConstant; import com.littleant.carrepair.request.constant.ParamsConstant; import com.littleant.carrepair.request.excute.BaseRequestCmd; import com.littleant.carrepair.request.excute.service.ordercar.BaseOrderCarCmd; import com.mh.core.tools.MHLogUtil; public class OrderQueryOneCmd extends BaseRequestCmd { public OrderQueryOneCmd(Context context, String id) { super(context); params.put(ParamsConstant.ID, id); MHLogUtil.logI(getClass().getSimpleName() + this.params.toString()); } @Override protected String getInterfaceName() { return InterfaceConstant.SERVICE_ORDER; } @Override protected RequestMethod getRequestMethod() { return RequestMethod.GET; } }
8b57bf17a48ace4278cb39cdaac03f2d0e7d786a
22863578e89a878927c14242371ce4322a7c7df7
/src/ar/edu/unlam/pb2/eva03/interfaces/Terrestre.java
4fc984ab675711ad01a3950ef939d22970efe74f
[]
no_license
MarcelaGonzalezz/MarcelaGonzalezEda03Recuperatorio
8139c6fd44dc46a5d565798ca4f6c17abdf48e6a
6e3339c4404027fdbaacdddd4c90ddfa77b86750
refs/heads/master
2023-01-27T13:37:29.645748
2020-12-09T13:12:51
2020-12-09T13:12:51
319,932,696
0
0
null
null
null
null
UTF-8
Java
false
false
101
java
package ar.edu.unlam.pb2.eva03.interfaces; public interface Terrestre { Double getVelocidad(); }
90340f031aeb343df7ae7d28e62a24f82e810cea
fb331c33af08510530de28741ca76da2af45766b
/src/main/java/in/jegan/dto/CartItemDTO.java
4d7b69f36afc3b87a67f83253c95bb2089ee56ae
[]
no_license
csys-fresher-batch-2021/groceryapp-jegan
fbd0c99f912accc4b4f8dc6d1f299ca0c6a47a3e
bd2a4b9cce7fb8ca3eec4c2b2f96b5dece95ac42
refs/heads/main
2023-05-26T03:30:29.177120
2021-06-04T06:39:15
2021-06-04T06:39:15
364,535,864
0
0
null
2021-06-04T06:39:16
2021-05-05T10:13:18
Java
UTF-8
Java
false
false
955
java
package in.jegan.dto; public class CartItemDTO { private String vegetableName; private Integer vegetablePrice ; private Integer vegetableQuantity ; private Integer totalPrice; @Override public String toString() { return "CartItemDTO [vegetableName=" + vegetableName + ", vegetablePrice=" + vegetablePrice + ", vegetableQuantity=" + vegetableQuantity + ", totalPrice=" + totalPrice + "]"; } public String getVegetableName() { return vegetableName; } public Integer getVegetablePrice() { return vegetablePrice; } public Integer getVegetableQuantity() { return vegetableQuantity; } public Integer getTotalPrice() { return totalPrice; } public CartItemDTO(String vegetableName, Integer vegetablePrice, Integer vegetableQuantity, Integer totalPrice) { super(); this.vegetableName = vegetableName; this.vegetablePrice = vegetablePrice; this.vegetableQuantity = vegetableQuantity; this.totalPrice = totalPrice; } }
0cd38f3a7011bef9e544617ce084a812a8dc2081
677f2597bb95609bd2d5bb1005dd6ffb708efba5
/src/test/java/de/ksbrwsk/qrcode/model/QrCodeVCardTest.java
2eda16bd0ecac8755d305cd4982f7448d30a2f38
[]
no_license
yadsyah/qrcode-generator
aea76bf32833543942fc84534e25c39dd33183ac
ae2298ee8a91899d238c5ed41ff05478ad1d7a71
refs/heads/master
2022-12-16T01:52:52.066198
2020-09-16T08:41:36
2020-09-16T08:41:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,960
java
package de.ksbrwsk.qrcode.model; import de.ksbrwsk.qrcode.utils.TestUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.validation.BindingResult; import static org.junit.Assert.*; @RunWith(SpringRunner.class) public class QrCodeVCardTest { @Test public void thatQrCodeVCardIsValid() { QrCodeVCard qrCodeVCard = new QrCodeVCard(); qrCodeVCard.setName("Chuck"); qrCodeVCard.setLastname("Norris"); BindingResult bindingResult = TestUtils.createBindingResult(qrCodeVCard); assertFalse(bindingResult.hasErrors()); } @Test public void thatQrCodeVCardIsNotValidNameNull() { QrCodeVCard qrCodeVCard = new QrCodeVCard(); qrCodeVCard.setLastname("Norris"); BindingResult bindingResult = TestUtils.createBindingResult(qrCodeVCard); assertTrue(bindingResult.hasErrors()); } @Test public void thatQrCodeVCardIsNotValidNameEmpty() { QrCodeVCard qrCodeVCard = new QrCodeVCard(); qrCodeVCard.setLastname("Norris"); qrCodeVCard.setName(""); BindingResult bindingResult = TestUtils.createBindingResult(qrCodeVCard); assertTrue(bindingResult.hasErrors()); } @Test public void thatQrCodeVCardIsNotValidLastNameNull() { QrCodeVCard qrCodeVCard = new QrCodeVCard(); qrCodeVCard.setName("Chuck"); qrCodeVCard.setLastname(null); BindingResult bindingResult = TestUtils.createBindingResult(qrCodeVCard); assertTrue(bindingResult.hasErrors()); } @Test public void thatQrCodeVCardIsNotValidLastNameEmpty() { QrCodeVCard qrCodeVCard = new QrCodeVCard(); qrCodeVCard.setLastname(""); qrCodeVCard.setName("Chuck"); BindingResult bindingResult = TestUtils.createBindingResult(qrCodeVCard); assertTrue(bindingResult.hasErrors()); } }
d9f5e2adefe192290c773aa38dd015db30d58cb4
6d4fefb85ce9598c6bc933a94546dc508395ff69
/packages/apps/Contacts/src/com/android/contacts/AttachImage.java
1c6573f6a63abe4fb3512c06321165f379a3c5c1
[ "Apache-2.0" ]
permissive
fantomgs/miaoxiaoming
3f972dfb6fc425708afed8b7e9761ed17f764026
0b50b3974463ff8db877ac42932bf31c8af41b74
refs/heads/master
2021-01-10T12:10:22.079688
2012-09-16T18:24:52
2012-09-16T18:24:52
49,789,144
0
0
null
null
null
null
UTF-8
Java
false
false
10,030
java
/* * Copyright (c) 2011, Code Aurora Forum. All rights reserved. * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts; import com.google.android.collect.Maps; import android.app.Activity; import android.content.ContentProviderOperation; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Intent; import android.content.OperationApplicationException; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.RemoteException; import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.CommonDataKinds.Photo; import android.widget.Toast; import com.android.contacts.model.ExchangeSource; import com.android.contacts.model.GoogleSource; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.HashMap; /** * Provides an external interface for other applications to attach images * to contacts. It will first present a contact picker and then run the * image that is handed to it through the cropper to make the image the proper * size and give the user a chance to use the face detector. */ public class AttachImage extends Activity { private static final int REQUEST_PICK_CONTACT = 1; private static final int REQUEST_CROP_PHOTO = 2; private static final String RAW_CONTACT_URIS_KEY = "raw_contact_uris"; public AttachImage() { } private Long[] mRawContactIds; private ContentResolver mContentResolver; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (icicle != null) { mRawContactIds = toClassArray(icicle.getLongArray(RAW_CONTACT_URIS_KEY)); } else { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(Contacts.CONTENT_ITEM_TYPE); startActivityForResult(intent, REQUEST_PICK_CONTACT); } mContentResolver = getContentResolver(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mRawContactIds != null && mRawContactIds.length != 0) { outState.putLongArray(RAW_CONTACT_URIS_KEY, toPrimativeArray(mRawContactIds)); } } private static long[] toPrimativeArray(Long[] in) { if (in == null) { return null; } long[] out = new long[in.length]; for (int i = 0; i < in.length; i++) { out[i] = in[i]; } return out; } private static Long[] toClassArray(long[] in) { if (in == null) { return null; } Long[] out = new Long[in.length]; for (int i = 0; i < in.length; i++) { out[i] = in[i]; } return out; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { if (resultCode != RESULT_OK) { finish(); return; } if (requestCode == REQUEST_PICK_CONTACT) { // A contact was picked. Launch the cropper to get face detection, the right size, etc. // TODO: get these values from constants somewhere Intent myIntent = getIntent(); Intent intent = new Intent("com.android.camera.action.CROP", myIntent.getData()); if (myIntent.getStringExtra("mimeType") != null) { intent.setDataAndType(myIntent.getData(), myIntent.getStringExtra("mimeType")); } intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 96); intent.putExtra("outputY", 96); intent.putExtra("return-data", true); startActivityForResult(intent, REQUEST_CROP_PHOTO); // while they're cropping, convert the contact into a raw_contact final long contactId = ContentUris.parseId(result.getData()); final ArrayList<Long> rawContactIdsList = ContactsUtils.queryForAllRawContactIds( mContentResolver, contactId); mRawContactIds = new Long[rawContactIdsList.size()]; mRawContactIds = rawContactIdsList.toArray(mRawContactIds); if (mRawContactIds == null || rawContactIdsList.isEmpty()) { Toast.makeText(this, R.string.contactSavedErrorToast, Toast.LENGTH_LONG).show(); } } else if (requestCode == REQUEST_CROP_PHOTO) { final Bundle extras = result.getExtras(); if (extras != null && mRawContactIds != null) { Bitmap photo = extras.getParcelable("data"); if (photo != null) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); photo.compress(Bitmap.CompressFormat.JPEG, 75, stream); final ContentValues imageValues = new ContentValues(); imageValues.put(Photo.PHOTO, stream.toByteArray()); imageValues.put(RawContacts.Data.IS_SUPER_PRIMARY, 1); // attach the photo to every raw contact for (Long rawContactId : mRawContactIds) { // exchange and google only allow one image, so do an update rather than insert boolean shouldUpdate = false; final Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); final Uri rawContactDataUri = Uri.withAppendedPath(rawContactUri, RawContacts.Data.CONTENT_DIRECTORY); updatePhoto(imageValues, rawContactDataUri, true); } } } finish(); } } /** * Inserts a photo on the raw contact. * @param values the photo values * @param assertAccount if true, will check to verify if the account is Google or exchange, * no photos exist (Google and exchange only take one picture) */ private void insertPhoto(ContentValues values, Uri rawContactDataUri, boolean assertAccount) { ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(); if (assertAccount) { // make sure for Google and exchange, no pictures exist operations.add(ContentProviderOperation.newAssertQuery(rawContactDataUri) .withSelection(Photo.MIMETYPE + "=? AND " + RawContacts.ACCOUNT_TYPE + " IN (?,?)", new String[] {Photo.CONTENT_ITEM_TYPE, GoogleSource.ACCOUNT_TYPE, ExchangeSource.ACCOUNT_TYPE}) .withExpectedCount(0).build()); } // insert the photo values.put(Photo.MIMETYPE, Photo.CONTENT_ITEM_TYPE); operations.add(ContentProviderOperation.newInsert(rawContactDataUri) .withValues(values).build()); try { mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations); } catch (RemoteException e) { throw new IllegalStateException("Problem querying raw_contacts/data", e); } catch (OperationApplicationException e) { // the account doesn't allow multiple photos, so update if (assertAccount) { updatePhoto(values, rawContactDataUri, false); } else { throw new IllegalStateException("Problem inserting photo into raw_contacts/data", e); } } } /** * Tries to update the photo on the raw_contact. If no photo exists, and allowInsert == true, * then will try to {@link #updatePhoto(ContentValues, boolean)} */ private void updatePhoto(ContentValues values, Uri rawContactDataUri, boolean allowInsert) { ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(); values.remove(Photo.MIMETYPE); // check that a photo exists operations.add(ContentProviderOperation.newAssertQuery(rawContactDataUri) .withSelection(Photo.MIMETYPE + "=?", new String[] { Photo.CONTENT_ITEM_TYPE }).withExpectedCount(1).build()); // update that photo operations.add(ContentProviderOperation.newUpdate(rawContactDataUri).withSelection(Photo.MIMETYPE + "=?", new String[] { Photo.CONTENT_ITEM_TYPE}).withValues(values).build()); try { mContentResolver.applyBatch(ContactsContract.AUTHORITY, operations); } catch (RemoteException e) { throw new IllegalStateException("Problem querying raw_contacts/data", e); } catch (OperationApplicationException e) { if (allowInsert) { // they deleted the photo between insert and update, so insert one insertPhoto(values, rawContactDataUri, false); } else { throw new IllegalStateException("Problem inserting photo raw_contacts/data", e); } } } }
1d0ef4097f45fcf9d6a5645e4eff1c1e51e13171
ca491acbdfb900b112151620b93345a1a318cdf0
/SaranPrasad/src/utilitySet/SnippetGenerator.java
69e1057ecd0746ea61f57e11f6bc5b6726d518ea
[]
no_license
Patelvishal95/IR-Project
0f3e36de32cd9cfdbfa9cd4b855823cde078747c
dc33f3195a858e524706fe96de082f10e5275173
refs/heads/master
2020-03-30T08:13:55.900533
2018-04-26T02:18:38
2018-04-26T02:18:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,283
java
package utilitySet; import java.io.File; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import ranker.LuceneIndexerAndSearch.RUN_TYPE; public class SnippetGenerator { private static int SLIDING_WINDOW_LENGTH = 30; private static String SNIPPET_SUMMARIES_PARENT_FOLDER = "./output/snippet_summaries/"; public void generateSnippetSummaries(String directoryPath) { File directory = new File(directoryPath); if (!directory.isDirectory()) { System.out.println("Given path does not correspond to a directory"); return; } String outputPath = SNIPPET_SUMMARIES_PARENT_FOLDER + directory.getName() + "/"; for (File file : directory.listFiles()) { FileUtility fu = new FileUtility(); String fileContent = cleanDocContent(fu.textFileToString(file)); String snippetText = extractMostSignificantSentence(fileContent); fu.writeStringToFile(snippetText, outputPath + file.getName() + ".txt"); } } /** * Assign a significance factor to words in text and extract sentences which have most number of * such significant words * * @param content * @return */ private String extractMostSignificantSentence(String content) { String contentCaseFolded = content.toLowerCase(); String words[] = contentCaseFolded.split(" "); // number of sentences in document d int sd = words.length / SLIDING_WINDOW_LENGTH; // record term frequencies HashMap<String, Integer> freq = new HashMap<String, Integer>(); for (String word : words) { if (freq.containsKey(word)) freq.put(word, freq.get(word) + 1); else freq.put(word, 1); } // flags corresponding to significant words in the content boolean sigWords[] = new boolean[words.length]; for (int i = 0; i < words.length; i++) { String word = words[i]; int fdw = freq.get(word); // frequency of the word in the document boolean cond = (sd < 25) && (fdw >= 7 - (0.1 * (25 - sd))); cond = cond || (sd >= 25 && sd <= 40) && (fdw >= 7); cond = cond || (fdw >= (7 + 0.1 * (sd - 40))); sigWords[i] = cond ? true : false; } // finding window with maximum significant words int maxSigLen = -1; int maxWindowId = -1; for (int i = 0; i < sd; i++) { int start = i * sd; int end = start + SLIDING_WINDOW_LENGTH; // find significant words count in current window int sigLen = 0; for (int j = start; j < end; j++) if (sigWords[j]) sigLen++; if (sigLen > maxSigLen) { maxSigLen = sigLen; maxWindowId = i; } } // if no significant words found, return the first window of words in the doc int start = 0, end = 0; if (maxWindowId == -1) end = Math.min(words.length, SLIDING_WINDOW_LENGTH); else { start = maxWindowId * sd; end = Math.min(words.length, maxWindowId * sd + SLIDING_WINDOW_LENGTH); } // rebuild snippet with required limits StringBuilder snippetText = new StringBuilder(); String[] origWords = content.split(" "); for (int i = start; i < end; i++) { String word = origWords[i]; snippetText.append(word + " "); } return snippetText.toString(); } /** * Returns the snippet corresponding to the docID with the given query terms highlighted (if * present) * * @param docID * @param runType * @param querySet * @return */ public String getQueryHighlightedHTMLSnippet(String docID, RUN_TYPE runType, String queryInput) { String[] querySet = queryInput.split(" "); String snippetFolderPath = SNIPPET_SUMMARIES_PARENT_FOLDER + "CACM/"; if (runType.equals(RUN_TYPE.CACM_STEMMED_CORPUS)) snippetFolderPath = SNIPPET_SUMMARIES_PARENT_FOLDER + "CACM_STEM/"; FileUtility fu = new FileUtility(); String fileContent = fu.textFileToString(snippetFolderPath + docID + ".html.txt"); String words[] = fileContent.split(" "); for (String query : querySet) { for (int i = 0; i < words.length; i++) { String word = words[i]; if (augmentedWord(word).equals(augmentedWord(query))) words[i] = "<b>" + words[i] + "</b>"; } } // rebuild snippet with highlighted query matches StringBuilder htmlSnippet = new StringBuilder(); for (String word : words) htmlSnippet.append(word + " "); return htmlSnippet.toString(); } /** * case folds, cleans, removes punctuations in a string, making it suitable for comparison * * @param word * @return */ private String augmentedWord(String word) { return word.replace(",", "").toLowerCase(); } /** * parse the document to extract only the required content. All xml tags and trailing numbers in the * doc are cleaned out. * * @param docContent * @return */ private String cleanDocContent(String docContent) { Document doc = Jsoup.parse(docContent); // extract content from the pre tag String mainContent = doc.select("pre").text(); // replace line breaks with space mainContent = mainContent.replace(System.getProperty("line.separator"), " "); // ensure a space after comma mainContent = mainContent.replace(",", ", "); // replace multiple spaces with a single space mainContent = mainContent.replaceAll("[ ]+", " "); // clean trailing numbers String regex = "([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9] ([AaPp][Mm])"; final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(mainContent); if (matcher.find()) mainContent = mainContent.substring(0, matcher.start()); return mainContent.trim(); } // Test public static void main(String args[]) { FileUtility fu = new FileUtility(); String CACM_DOC_LOCATION = "./input/CACM/CACM-1811.html"; String content = fu.textFileToString(CACM_DOC_LOCATION); SnippetGenerator sg = new SnippetGenerator(); sg.generateSnippetSummaries("./input/CACM"); String query = "processors, computational problem"; System.out.println( sg.getQueryHighlightedHTMLSnippet("CACM-1811.html", RUN_TYPE.CACM, query)); } }
29f64fc0a9da0ca00bd575ae6ca3c76de483f793
c6543ef4a1b2f827ac0cad2c302d36f1f64b6547
/code/mywork/libraceo/src/com/mm/MMChat.java
86c405e97e16b8328005e37806f6c3a3ca33b68d
[]
no_license
designreuse/project
4936de1d75cd13a0b36be57a5046cd23c9d9e0dc
ea0eb7c4c5e0d06a1f9bb8904baf6eae44c1980f
refs/heads/master
2021-01-17T22:12:54.964474
2016-01-26T11:59:58
2016-01-26T11:59:58
null
0
0
null
null
null
null
GB18030
Java
false
false
3,350
java
package com.mm; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /*** * 24个小时,每个时间点对应一个客流数据,求相邻两个小时内客流数据之和最大的时间段和客流总和 * * @author zhang * */ public class MMChat { public static void main(String[] args) { MMChat.sortMap(); } public static void sortMap() { int max = 0;// 最大流量总和 String maxBeginHourStr = "";// 时间段-起 String maxEndHourStr = "";// 时间段-止 for (String key : tempMap.keySet()) { int beginHour = Integer.parseInt(key.split("\\:")[0]); int endHour = beginHour + 1;// 取一小时以后的数据 String beginHourStr = beginHour + ":00";// 时间段-起 String endHourStr = endHour + ":00";// 时间段-止 if (tempMap.containsKey(beginHourStr) && tempMap.containsKey(endHourStr)) { int temp = tempMap.get(beginHourStr) + tempMap.get(endHourStr); if (temp > max) {// 如果大于存储的最大值,替换总和,起始、终止 max = temp; maxBeginHourStr = beginHourStr; maxEndHourStr = endHourStr; } } } System.out.println(String.format("[%s]-[%s]流量最大为:[%s]", new Object[] { maxBeginHourStr, maxEndHourStr, max })); } public static void sortList() { int max = 0;// 最大流量总和 int beginHour = 0;// 时间段-起 int endHour = 0;// 时间段-止 for (int i = 0; i < tempList.size() - 1; i++) { int temp = tempList.get(i) + tempList.get(i + 1); if (temp > max) { max = temp; beginHour = i + 1;// list索引从0开始,所以时间+1 endHour = i + 1 + 1; } } System.out.println(String.format("[%s]-[%s]流量最大为:[%s]", new Object[] { beginHour, endHour, max })); } public static final List<Integer> tempList = new ArrayList<Integer>(); static { tempList.add(100000); tempList.add(200000); tempList.add(300000); tempList.add(400000); tempList.add(500000); tempList.add(600000); tempList.add(700000); tempList.add(800000); tempList.add(900000); tempList.add(1000000); tempList.add(1100000); tempList.add(1200000); tempList.add(1300000); tempList.add(1400000); tempList.add(1500000); tempList.add(1600000); tempList.add(1700000); tempList.add(1800000); tempList.add(1900000); tempList.add(2000000); tempList.add(210000); tempList.add(2200000); tempList.add(2300000); tempList.add(2400000); } public static final Map<String, Integer> tempMap = new HashMap<String, Integer>(); static { tempMap.put("0:00", 10000); tempMap.put("1:00", 100000); tempMap.put("2:00", 200000); tempMap.put("3:00", 300000); tempMap.put("4:00", 400000); tempMap.put("5:00", 500000); tempMap.put("6:00", 600000); tempMap.put("7:00", 700000); tempMap.put("8:00", 800000); tempMap.put("9:00", 900000); tempMap.put("10:00", 1000000); tempMap.put("11:00", 1100000); tempMap.put("12:00", 1200000); tempMap.put("13:00", 1300000); tempMap.put("14:00", 1400000); tempMap.put("15:00", 1500000); tempMap.put("16:00", 160000000); tempMap.put("17:00", 1700000); tempMap.put("18:00", 1800000); tempMap.put("19:00", 1900000); tempMap.put("20:00", 2000000); tempMap.put("21:00", 2100000); tempMap.put("22:00", 2200000); tempMap.put("23:00", 2300000); tempMap.put("24:00", 2300000); } }
c3d5b80e02a9d239f739a97e4711b00fdeff3c49
f1ab67476d54ca5ade49d21f2019f32fd6b6c90d
/wanma/src/main/java/.svn/pristine/37/376f79431621f787fd956a7b5c898eeed280ebe7.svn-base
d801435db4a2fb4bf9355df2d389b7195f396bae
[]
no_license
wang-shun/eichong.web
4578f63ed717cba921872a0767814a6b808d1b64
08dbcabb8c1868a0ea755a2d7faecefc51c3c144
refs/heads/master
2020-04-02T12:19:22.702237
2018-04-02T06:14:01
2018-04-02T06:14:01
null
0
0
null
null
null
null
UTF-8
Java
false
false
573
package com.wanma.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.wanma.dao.CmsElectricPileMapper; import com.wanma.service.ElectricPileService; @Service public class ElectricPileServiceImpl implements ElectricPileService{ /** * 根据费率id查询智能桩的编码 * @param rateId * @return */ public List<String> getEpCodesByRateId(int rateId){ return epMapper.getEpCodesByRateId(rateId); } @Autowired CmsElectricPileMapper epMapper; }
d994c2738881652d7e437ab8f577722b8d1a220f
e8f5b23ae322e94c4e0d1dabbb0a427607b0a842
/src/org/pnm/dun/unit/MonsterFactory.java
d8fc69453f1c60c9ce9e7c76ded1f370b57d36ad
[]
no_license
PhilMeyer/dun-craw
ea07db93beb121d7654a17947d53749ea814c0ad
4ccf225ffd9807dfb3dc19f94af8e08b721dee2f
refs/heads/master
2016-09-05T16:08:23.465123
2013-04-04T21:48:59
2013-04-04T21:48:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
758
java
package org.pnm.dun.unit; public class MonsterFactory { public static Unit fennblade(){ Unit unit = new Monster("Grunt", "T_U_FennOfficer", 7, 5, 11, 13, 4); unit.addWep(new Weapon("Club",4,3)); return unit; } public static Unit grunt(){ Unit unit = new Monster("Grunt", "T_U_KrielWarrior", 7, 4, 12, 13, 4); unit.addWep(new Weapon("Club",9,4)); return unit; } public static Unit mulg(){ Unit unit = new Monster("Mulg", "T_B_Mulg", 10, 7, 14, 10, 5); unit.base=3; unit.addWep(new Weapon("D",3,5)); return unit; } public static Unit generic(int def, int arm, int mat, int pow) { Unit unit = new Monster("Grunt", "T_U_KrielWarrior", 7, 4, def, arm, 4); unit.addWep(new Weapon("Club",pow,mat)); return unit; } }
0457d58accbfe3ee042eff260ba9064ed6876d87
14d29e9370318874d73b6e45393d0fd71faa9f69
/src/main/java/adsd/app/bouwapp/BouwappApplication.java
310b144324fddded4d87573335032d527f720391
[]
no_license
alenaSavachenko/spring-boot-plus-mysql_connection
1ed5141b93098b13146f73182310691c5f206612
8496f77813ce3206cfb7282e3bd4405340147acb
refs/heads/master
2022-12-10T19:25:46.131985
2020-09-09T12:42:39
2020-09-09T12:42:39
294,073,447
0
0
null
null
null
null
UTF-8
Java
false
false
311
java
package adsd.app.bouwapp; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class BouwappApplication { public static void main(String[] args) { SpringApplication.run(BouwappApplication.class, args); } }
6077d843d9b69b0ca851dd4dc073d25925175079
7aa751122b45663aa91581c447630659ee45db33
/app/src/test/java/com/jiangkang/ktools/SystemActivityTest.java
d94daa13d17a6221e97e1af6e0d3aefabe2babab
[ "MIT" ]
permissive
maliangxue/KTools
bfa7597ab2a8ed6a711fe8ef52ff7b7018ee2aa7
712783d537c3c2ba5308ab8e6b08d9eb36ad8935
refs/heads/master
2020-07-18T14:26:52.720630
2019-08-10T16:21:56
2019-08-10T16:21:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
863
java
package com.jiangkang.ktools; import android.support.v7.app.AppCompatActivity; import android.widget.Button; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import static org.junit.Assert.assertNotNull; /** * Created by jiangkang on 2018/1/30. * description: */ @RunWith(RobolectricTestRunner.class) public class SystemActivityTest { private AppCompatActivity activity; @Before public void setUp() { activity = Robolectric.buildActivity(SystemActivity.class).create().get(); } @Test public void validateButtonContent() { Button button = activity.findViewById(R.id.btn_open_contacts); assertNotNull("open contacts not null",button); } }
80ed9040af10c27ee67eb41fb9a205ac157f3060
962dc2d4fb0ce4665d94bf483160e1e0c3458fe3
/TomRiddlesDiary.java
b3de256fec83905c4f7b4efb10b8bd0d5967f8dd
[]
no_license
iAnneLouise/9354B-1-Repo
6ef541b2475ec2bd2f2718200d22370f11695583
bfc680090ee68f48e5f00f3eb5a2a7779e6ddbd7
refs/heads/master
2021-08-30T13:08:05.681406
2017-12-18T04:05:25
2017-12-18T04:05:25
114,523,523
0
0
null
null
null
null
UTF-8
Java
false
false
482
java
package com.codeforces; import java.util.*; public class TomRiddlesDiary{ public static void main(String[] args){ Scanner in = new Scanner(System.in); ArrayList<String> list = new ArrayList(); String string; int list = in.nextInt(); for(int i = 0; i < list; i++){ string = in.next(); boolean exist = list.contains(string); if (exist == true){ System.out.println("YES"); }else if(exist == false) System.out.println("NO"); list.add(string); } } }
3da4a9c3b08224aaf217aebb6ee64a7c810a2ef0
e334222f858e71e748f2859935730359f5b88e0e
/app/src/main/java/com/app/rum_a/ui/postauth/adapter/SwipeViewAdapter.java
7023c5b385269d1256aa9e9641a145df76a29ed8
[]
no_license
ArisChoice/Demo-Ru
d9741264140f84af382d180d15977e2f7fa2f3de
75b31f63d9b05732389bc353feecd570e3c45f1c
refs/heads/master
2020-03-30T22:34:40.771292
2018-10-06T08:15:51
2018-10-06T08:15:51
151,671,696
0
0
null
null
null
null
UTF-8
Java
false
false
4,712
java
package com.app.rum_a.ui.postauth.adapter; import android.content.Context; import android.content.res.Resources; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import com.app.rum_a.R; import com.app.rum_a.model.resp.PropertyListResponseModel; import com.app.rum_a.utils.CommonUtils; import com.app.rum_a.utils.ImageUtility; import com.app.rum_a.utils.Log4Android; import com.app.rum_a.utils.appinterface.SwipeOperation; import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; /** * Created by tarun on 15/6/15. */ public class SwipeViewAdapter extends BaseAdapter { private Context context; private LayoutInflater inflater; // private ArrayList<UserData> users; private ImageUtility imageUtility; SwipeOperation swipeOperation; Resources res; ArrayList<PropertyListResponseModel.ResultBean> propertyLst; // int imageLst[] = {R.drawable.sample_property, R.drawable.sample_property2, R.drawable.sample_property3, // R.drawable.sample_property, R.drawable.sample_property2, R.drawable.sample_property_4, R.drawable.sample_property3};//For tem use public SwipeViewAdapter(Context context, ArrayList<PropertyListResponseModel.ResultBean> propertyLst, SwipeOperation swipeOperation) { this.context = context; // this.users = users; inflater = LayoutInflater.from(context); imageUtility = new ImageUtility(context); res = context.getResources(); this.swipeOperation = swipeOperation; this.propertyLst = propertyLst; // Log.e("setAdapter,", users.size() + ""); // Log4Android.e(this, "setAdapter" + users.size() + ""); } public void updateAdapter(ArrayList<PropertyListResponseModel.ResultBean> propertyList) { propertyList.addAll(propertyList); notifyDataSetChanged(); } @Override public int getCount() { return propertyLst.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { swipeOperation.performSwipe(position); Log.e("position", "position " + position); Log.e("view", "in"); Log4Android.e(this, "getViewCalled"); ViewHolder viewHolder; if (convertView == null) { Log.e("convert", "in"); convertView = inflater.inflate(R.layout.swipe_item_layout, parent, false); viewHolder = new ViewHolder(convertView); convertView.setTag(viewHolder); } else { Log.e("convert", "out"); viewHolder = (ViewHolder) convertView.getTag(); } PropertyListResponseModel.ResultBean positionData = propertyLst.get(position); // viewHolder.imgPropertyImage.setImageResource(imageLst[position]);//For tem use demo list String currencySymbol = CommonUtils.getCurrencySymbol(positionData.getCurrency()); viewHolder.txtPropertyName.setText(positionData.getName() + " " + currencySymbol + " " + positionData.getPrice()); if (positionData.getDistanceType().equals(context.getString(R.string.str_miles))) viewHolder.txtDistance.setText(String.format("%.2f", positionData.getDistance()) + " " + context.getString(R.string.str_miles)); else viewHolder.txtDistance.setText(String.format("%.2f", positionData.getDistance()) + " " + context.getString(R.string.str_km)); try { new ImageUtility(context).LoadImage(CommonUtils.getValidUrl(positionData.getPropertyImageList().get(0).getImageURL()), viewHolder.imgPropertyImage); } catch (Exception e) { e.printStackTrace(); } return convertView; } /** * This class contains all butterknife-injected Views & Layouts from layout file 'swipe_item_layout.xml' * for easy to all layout elements. * * @author ButterKnifeZelezny, plugin for Android Studio by Avast Developers (http://github.com/avast) */ static class ViewHolder { @BindView(R.id.imgpropertyImage) ImageView imgPropertyImage; @BindView(R.id.txtPropertyName) TextView txtPropertyName; @BindView(R.id.txtDistance) TextView txtDistance; /*@BindView(R.id.txtNoOfPics) TextView txtNoOfPics; */ ViewHolder(View view) { ButterKnife.bind(this, view); } } }
bb52c288349af22ed6938ec60b6b546249fc834c
1877f5b1fef9f0eb1413b4a4571b00fc31fc7a43
/app/src/main/java/com/gcme/hascomamharic/yehiwotTiyakewochTabClass/YehiwotTiyake7.java
3ef710dabfede7afcd0a2eb5a5245291febd559a
[]
no_license
CruSea/Hascom
7baa165da6a40d86ff97266f24a5a0a6fb2ef8d8
bb67f582a88f53be5d0fae09a7dbab54ddca1ceb
refs/heads/master
2021-01-03T07:42:41.471343
2020-02-25T09:49:58
2020-02-25T09:49:58
239,986,038
0
0
null
null
null
null
UTF-8
Java
false
false
4,344
java
package com.gcme.hascomamharic.yehiwotTiyakewochTabClass; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import com.google.android.material.tabs.TabLayout; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentEight; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentEleven; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentFourteen; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentNine; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentSeven; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentTen; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentThirteen; import com.gcme.hascomamharic.yehiwotTiyakewochFragment.FragmentTwelve; import com.gcme.hascomamharic.R; /** * Created by buty on 12/29/15. */ public class YehiwotTiyake7 extends AppCompatActivity { private Toolbar toolbar; private TabLayout tabLayout; private ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_yehiwottiyake7); toolbar = (Toolbar) findViewById(R.id.toolbar13); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); viewPager = (ViewPager) findViewById(R.id.viewpager13); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs13); tabLayout.setupWithViewPager(viewPager); } private void setupViewPager(ViewPager viewPager) { ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter); } class ViewPagerAdapter extends FragmentPagerAdapter { public ViewPagerAdapter(FragmentManager manager) { super(manager); } @Override public Fragment getItem(int position) { Fragment fragment = null; if (position == 0) { fragment = new FragmentFourteen(); } if (position == 1) { fragment = new FragmentThirteen(); } if (position == 2) { fragment = new FragmentTwelve(); } if (position == 3) { fragment = new FragmentEleven(); } if (position == 4) { fragment = new FragmentTen(); } if (position == 5) { fragment = new FragmentNine(); } if (position == 6) { fragment = new FragmentEight(); } if (position == 7) { fragment = new FragmentSeven(); } return fragment; } @Override public int getCount() { return 8; } @Override public CharSequence getPageTitle(int position) { if (position == 0) { return getResources().getString(R.string.kesus_melakek); } if (position == 1) { return getResources().getString(R.string.yecampus_life_tesnsion); } if (position == 2) { return getResources().getString(R.string.yewust_alem); } if (position == 3) { return getResources().getString(R.string.egziabher_biqu_director_new); } if (position == 4) { return getResources().getString(R.string.limola_yalchale_hiwot); } if (position == 5) { return getResources().getString(R.string.bechink_sinikebeb); } if (position == 6) { return getResources().getString(R.string.yehiwote_alama_mndnew); } if (position == 7) { return getResources().getString(R.string.hiwot_lemin_kebad_hone); } return null; } } @Override public boolean onSupportNavigateUp() { onBackPressed(); return true; } }
ef971d3c85ff7649116d22bee0c1647c727e6c7f
cd6519764ed1a69e6691fa531ad794770da2b783
/java/robomuss/rc/block/render/TileEntityRenderFlatTrack.java
af4e3cd339f5e8a041dff2c89c4ea553c2034447
[]
no_license
klmDF14J/Modjam4
561150e0cc50eafdca81e1b8303c021bef093f12
d6fde7fe504a35bd1524e336724f3e4319a5a1fc
refs/heads/master
2021-01-21T00:43:43.907227
2014-06-23T19:04:33
2014-06-23T19:04:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,696
java
package robomuss.rc.block.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import robomuss.rc.block.model.ModelFlatTrack; import robomuss.rc.block.te.TileEntityFlatTrack; public class TileEntityRenderFlatTrack extends TileEntitySpecialRenderer { private ModelFlatTrack model; public TileEntityRenderFlatTrack() { this.model = new ModelFlatTrack(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { GL11.glPushMatrix(); int colour = ((TileEntityFlatTrack) te).colour; //GL11.glColor4f(ColourUtil.getRed(colour), ColourUtil.getGreen(colour), ColourUtil.getBlue(colour), ColourUtil.getAlpha(colour)); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); ResourceLocation textures = (new ResourceLocation("rc:textures/models/colour_" + colour + ".png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); switch(((TileEntityFlatTrack) te).direction){ case 1: GL11.glRotatef(180f, -180f, 0f, 0f); break; case 2: GL11.glRotatef(180f, 180f, 0f, 180f); break; case 3: GL11.glRotatef(180f, 0f, 0f, 180f); break; default: GL11.glRotatef(180f, -180f, 0f, 180f); break; } this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } }
84354760821b89783687c82e7c3de64be47bd8fb
06bc7a15d7c69f371d4c2814f01852de382c992c
/application_android/app/src/main/java/com/example/koboard/model/Message.java
2dd3a386469cdf2fe5f79fa07569c7c3f1bd7572
[]
no_license
ColinTr/IFT604_Internet_et_mobilite
6761aada9e40e872415e5b585927dbfa0f9a1d17
0938fde2e8496761dcd88d980bb3f7b9e391d908
refs/heads/master
2023-02-01T01:51:42.627875
2020-12-07T11:11:15
2020-12-07T11:11:15
322,633,005
1
1
null
null
null
null
UTF-8
Java
false
false
1,029
java
package com.example.koboard.model; public class Message { public static final int MESSAGE_TYPE = 0; public static final int LOG_TYPE = 1; private int type; private String message; private String user; public Message() { } public Message(int type, String message, String user){ this.type = type; this.message = message; this.user = user; } public Message(int type, String user, int i){ this.type = type; this.user = user; } public Message(int type, String message){ this.type = type; this.message = message; } public int getType() { return type; } public void setType(int type) { this.type = type; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } }
87e82eca631cee8a91580072e17ccb93c73b4c46
3d4bcd1b9ada5b54ba91949a3d60366ea5181afd
/src/main/java/com/mealcome/model/dataTotal.java
c2e1adf47c13ff490cc392d59e52cc3b27de686a
[]
no_license
linssky/mealcomeAPIWatch
b94cc540fb8986e9a12c4ccb2ba3779b18f99101
3c12f8f88340b6c61f8452c1bcd65b8c02b90598
refs/heads/master
2021-06-23T03:48:26.821915
2019-09-27T02:05:30
2019-09-27T02:05:30
211,213,855
0
0
null
2021-06-04T02:12:53
2019-09-27T01:46:56
Java
UTF-8
Java
false
false
191
java
package com.mealcome.model; /** * Created by wuchaolin on 2019/5/14. */ public class dataTotal { private double mTotalTime; private double mMaxTime; private double mMinTime; }
f480759da7414d095d06835320bbe27ee93be083
5bb96d3e3efd8807b2cbb18bc49083c8af692ed9
/src/main/java/club/jming/voiceprintrecognition/utils/FFT.java
4e959517ca3124161b3ca4afb1107e64e24bb1ad
[]
no_license
Jmingx/Voiceprint_Recognition
48dcd071c946d49375ff19a679ef5f80eb2112c7
e546360434b6ba74578f42764d2420f58eee3920
refs/heads/master
2023-08-25T01:46:01.725303
2021-10-29T09:37:48
2021-10-29T09:37:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,578
java
package club.jming.voiceprintrecognition.utils; /************************************************************************* * Compilation: javac FFT.java Execution: java FFT N Dependencies: Complex.java * * Compute the FFT and inverse FFT of a length N complex sequence. Bare bones * implementation that runs in O(N log N) time. Our goal is to optimize the * clarity of the code, rather than performance. * * Limitations ----------- - assumes N is a power of 2 * * - not the most memory efficient algorithm (because it uses an object type for * representing complex numbers and because it re-allocates memory for the * subarray, instead of doing in-place or reusing a single temporary array) * *************************************************************************/ public class FFT { // compute the FFT of x[], assuming its length is a power of 2 //快速傅里叶变换 public static Complex[] fft(Complex[] x) { int N = x.length; // base case if (N == 1) { return new Complex[]{x[0]}; } // radix 2 Cooley-Tukey FFT if (N % 2 != 0) { throw new RuntimeException("N is not a power of 2"); } // fft of even terms Complex[] even = new Complex[N / 2]; for (int k = 0; k < N / 2; k++) { even[k] = x[2 * k]; } Complex[] q = fft(even); // fft of odd terms Complex[] odd = even; // reuse the array for (int k = 0; k < N / 2; k++) { odd[k] = x[2 * k + 1]; } Complex[] r = fft(odd); // combine Complex[] y = new Complex[N]; for (int k = 0; k < N / 2; k++) { double kth = -2 * k * Math.PI / N; Complex wk = new Complex(Math.cos(kth), Math.sin(kth)); y[k] = q[k].plus(wk.times(r[k])); y[k + N / 2] = q[k].minus(wk.times(r[k])); } return y; } // compute the inverse FFT of x[], assuming its length is a power of 2 //快速傅里叶反变换 public static Complex[] ifft(Complex[] x) { int N = x.length; Complex[] y = new Complex[N]; // take conjugate for (int i = 0; i < N; i++) { y[i] = x[i].conjugate(); } // compute forward FFT y = fft(y); // take conjugate again for (int i = 0; i < N; i++) { y[i] = y[i].conjugate(); } // divide by N for (int i = 0; i < N; i++) { y[i] = y[i].times(1.0 / N); } return y; } // compute the circular convolution of x and y public static Complex[] cconvolve(Complex[] x, Complex[] y) { // should probably pad x and y with 0s so that they have same length // and are powers of 2 if (x.length != y.length) { throw new RuntimeException("Dimensions don't agree"); } int N = x.length; // compute FFT of each sequence Complex[] a = fft(x); Complex[] b = fft(y); // point-wise multiply Complex[] c = new Complex[N]; for (int i = 0; i < N; i++) { c[i] = a[i].times(b[i]); } // compute inverse FFT return ifft(c); } // compute the linear convolution of x and y public static Complex[] convolve(Complex[] x, Complex[] y) { Complex ZERO = new Complex(0, 0); Complex[] a = new Complex[2 * x.length]; for (int i = 0; i < x.length; i++) { a[i] = x[i]; } for (int i = x.length; i < 2 * x.length; i++) { a[i] = ZERO; } Complex[] b = new Complex[2 * y.length]; for (int i = 0; i < y.length; i++) { b[i] = y[i]; } for (int i = y.length; i < 2 * y.length; i++) { b[i] = ZERO; } return cconvolve(a, b); } // display an array of Complex numbers to standard output public static void show(Complex[] x, String title) { System.out.println(title); System.out.println("-------------------"); for (int i = 0; i < x.length; i++) { System.out.println(x[i]); } System.out.println(); } /********************************************************************* * Test client and sample execution * * % java FFT 4 x ------------------- -0.03480425839330703 * 0.07910192950176387 0.7233322451735928 0.1659819820667019 * * y = fft(x) ------------------- 0.9336118983487516 -0.7581365035668999 + * 0.08688005256493803i 0.44344407521182005 -0.7581365035668999 - * 0.08688005256493803i * * z = ifft(y) ------------------- -0.03480425839330703 0.07910192950176387 * + 2.6599344570851287E-18i 0.7233322451735928 0.1659819820667019 - * 2.6599344570851287E-18i * * c = cconvolve(x, x) ------------------- 0.5506798633981853 * 0.23461407150576394 - 4.033186818023279E-18i -0.016542951108772352 * 0.10288019294318276 + 4.033186818023279E-18i * * d = convolve(x, x) ------------------- 0.001211336402308083 - * 3.122502256758253E-17i -0.005506167987577068 - 5.058885073636224E-17i * -0.044092969479563274 + 2.1934338938072244E-18i 0.10288019294318276 - * 3.6147323062478115E-17i 0.5494685269958772 + 3.122502256758253E-17i * 0.240120239493341 + 4.655566391833896E-17i 0.02755001837079092 - * 2.1934338938072244E-18i 4.01805098805014E-17i * *********************************************************************/ }
cdcb048888e3ce728f170765701e5e93c4fc690c
2a037fa36ccf96fb3cb2365c12c6fefe71075fc7
/src/main/java/com/gmail/nossr50/Database.java
0ac7dbc12ae05a7957cf39b8bee70d43914cb0cf
[]
no_license
Kabyl/mcMMO-Tekkit
5cedcc378d9aad4766d01a2e5a7efe257b9898ac
0068a3f07aa5405ea632cd5aa6b6085c9ce7bb83
refs/heads/master
2021-01-15T19:19:18.163595
2012-02-04T15:45:37
2012-02-04T15:45:37
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,983
java
/* This file is part of mcMMO. mcMMO is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. mcMMO 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 mcMMO. If not, see <http://www.gnu.org/licenses/>. */ package com.gmail.nossr50; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.ArrayList; import java.sql.PreparedStatement; import com.gmail.nossr50.config.LoadProperties; public class Database { private mcMMO plugin; private String connectionString; public Database(mcMMO instance) { this.plugin = instance; this.connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass; // Load the driver instance try { Class.forName("com.mysql.jdbc.Driver"); DriverManager.getConnection(connectionString); } catch (ClassNotFoundException e) { plugin.getServer().getLogger().warning(e.getLocalizedMessage()); } catch (SQLException e) { plugin.getServer().getLogger().warning(e.getLocalizedMessage()); System.out.println("SQLException: " + e.getMessage()); System.out.println("SQLState: " + e.getSQLState()); System.out.println("VendorError: " + e.getErrorCode()); } } //Create the DB structure public void createStructure() { Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL," + "`hudtype` varchar(50) NOT NULL DEFAULT ''," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," + "`user` varchar(40) NOT NULL," + "`lastlogin` int(32) unsigned NOT NULL," + "`party` varchar(100) NOT NULL DEFAULT ''," + "PRIMARY KEY (`id`)," + "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL," + "`taming` int(32) unsigned NOT NULL DEFAULT '0'," + "`mining` int(32) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0'," + "`repair` int(32) unsigned NOT NULL DEFAULT '0'," + "`unarmed` int(32) unsigned NOT NULL DEFAULT '0'," + "`herbalism` int(32) unsigned NOT NULL DEFAULT '0'," + "`excavation` int(32) unsigned NOT NULL DEFAULT '0'," + "`archery` int(32) unsigned NOT NULL DEFAULT '0'," + "`swords` int(32) unsigned NOT NULL DEFAULT '0'," + "`axes` int(32) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL," + "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + "`repair` int(10) unsigned NOT NULL DEFAULT '0'," + "`unarmed` int(10) unsigned NOT NULL DEFAULT '0'," + "`herbalism` int(10) unsigned NOT NULL DEFAULT '0'," + "`excavation` int(10) unsigned NOT NULL DEFAULT '0'," + "`archery` int(10) unsigned NOT NULL DEFAULT '0'," + "`swords` int(10) unsigned NOT NULL DEFAULT '0'," + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL," + "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + "`repair` int(10) unsigned NOT NULL DEFAULT '0'," + "`unarmed` int(10) unsigned NOT NULL DEFAULT '0'," + "`herbalism` int(10) unsigned NOT NULL DEFAULT '0'," + "`excavation` int(10) unsigned NOT NULL DEFAULT '0'," + "`archery` int(10) unsigned NOT NULL DEFAULT '0'," + "`swords` int(10) unsigned NOT NULL DEFAULT '0'," + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "spawn` (`user_id` int(10) NOT NULL," + "`x` int(64) NOT NULL DEFAULT '0'," + "`y` int(64) NOT NULL DEFAULT '0'," + "`z` int(64) NOT NULL DEFAULT '0'," + "`world` varchar(50) NOT NULL DEFAULT ''," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"skills2`"); Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"experience2`"); checkDatabaseStructure(); } public void checkDatabaseStructure() { String sql = "SELECT * FROM `mcmmo_experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30"; ResultSet rs = null; HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>(); try { Connection conn = DriverManager.getConnection(connectionString); PreparedStatement stmt = conn.prepareStatement(sql); if (stmt.executeQuery() != null) { stmt.executeQuery(); rs = stmt.getResultSet(); while (rs.next()) { ArrayList<String> Col = new ArrayList<String>(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { Col.add(rs.getString(i)); } Rows.put(rs.getRow(), Col); } } conn.close(); } catch (SQLException ex) { System.out.println("Updating mcMMO MySQL tables..."); Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); } } // write query public boolean Write(String sql) { try { Connection conn = DriverManager.getConnection(connectionString); PreparedStatement stmt = conn.prepareStatement(sql); stmt.executeUpdate(); conn.close(); return true; } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); return false; } } // Get Int // only return first row / first field public Integer GetInt(String sql) { ResultSet rs = null; Integer result = 0; try { Connection conn = DriverManager.getConnection(connectionString); PreparedStatement stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql); if (stmt.executeQuery() != null) { stmt.executeQuery(); rs = stmt.getResultSet(); if (rs.next()) { result = rs.getInt(1); } else { result = 0; } } conn.close(); } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } return result; } // read query public HashMap<Integer, ArrayList<String>> Read(String sql) { ResultSet rs = null; HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>(); try { Connection conn = DriverManager.getConnection(connectionString); PreparedStatement stmt = conn.prepareStatement(sql); if (stmt.executeQuery() != null) { stmt.executeQuery(); rs = stmt.getResultSet(); while (rs.next()) { ArrayList<String> Col = new ArrayList<String>(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { Col.add(rs.getString(i)); } Rows.put(rs.getRow(), Col); } } conn.close(); } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } return Rows; } }
2bb60b02be4d7a76df0e21bcb69f011e37c9db73
81bd5dcb31b1d1dd4f2e8edd96257af1ab8800b9
/spring3-Example/src/main/java/cn/zw/demo/loosely_coupled/CsvOutputGenerator.java
09185a5946790e29acfdcc152565937f5db9477e
[]
no_license
zenvzenv/mycode
22a110345500f02ef8373dd349344d83ebd1f05e
d7686d9bc2efce70e96f59a4393f5e22bf0faf2c
refs/heads/master
2021-09-21T16:49:07.514435
2018-08-29T05:15:00
2018-08-29T05:15:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
202
java
package cn.zw.demo.loosely_coupled; public class CsvOutputGenerator implements IOutputGenerator{ public void generateOutput() { System.out.println("Creating CsvOutputGenerator Output ..."); } }
46650cb0e4be8bd7cbe03952efb2085e87212f05
c2bc17ac50f9fe8629362fe2e1da707d0ad44113
/Korttipeli/Korttipeli.java
177df85b3455ca6b8e0cc1b3428e414b4ef88106
[]
no_license
bekshoi/ltdns20
a1b56d8aa271b7edb921c5ec8209da2746b51cb9
c338c4fd1f1fe84dce14a5917c07409d0b45ba66
refs/heads/master
2023-02-09T07:31:43.431108
2020-12-29T07:30:15
2020-12-29T07:30:15
306,302,237
0
0
null
null
null
null
ISO-8859-1
Java
false
false
1,545
java
/******************************************* Nimi:Korttipeli Tekija: Pvm: Kuvaus: Kahden pelaajan korttipeli. Riippuvuudet: - *********************************************/ /* Otetaan mukaan kirjastot, jotka sisältävät tarvittavat valmiit luokat. */ import java.util.*; public class Korttipeli { // Pääohjelma, jota kutsutaan ohjelman suorituksen alkaessa. public static void main(String [ ] args) { // Käytettävä korttipakka. Korttipakka Pakka = new Korttipakka(); // Pelaajille vedettävät kortit Pelikortti Kortti1, Kortti2; // Alustetaan pakka. Pakka.alustaPakka(); // Sekoitetaan pakka ja vedetään kortti ensimmäiselle pelaajalle. Pakka.sekoitaPakka(); System.out.println("Vedetään ensimmäiselle pelaajalle kortti."); Kortti1 = Pakka.paljastaPaallimmainenKortti(); System.out.println("Ensimmäisen pelaajan kortti on " + Kortti1.kerroMaa() + " " + Kortti1.kerroSilmaluku() + "."); // Sekoitetaan pakka ja vedetään kortti toiselle pelaajalle. Pakka.sekoitaPakka(); System.out.println("Vedetään toiselle pelaajalle kortti." ); Kortti2 = Pakka.paljastaPaallimmainenKortti(); System.out.println("Toisen pelaajan kortti on " + Kortti2.kerroMaa() + " " + Kortti2.kerroSilmaluku() + "."); // Katsotaan, kumpi pelaajista voitti. if (Kortti1.kerroSilmaluku() > Kortti2.kerroSilmaluku()) System.out.println("Ensimmäinen pelaaja voitti."); else if (Kortti2.kerroSilmaluku() > Kortti1.kerroSilmaluku()) System.out.println("Toinen pelaaja voitti."); else System.out.println("Tasapeli."); } }
79e5a20a4ca0e3757c05da4cbde66c1a371424ca
456150b7e8d420d4880dbfd7b4a3ebe14250705e
/mutationProject/src/main/java/m2/ila/fr/istic/ila/vv/mutation/operator/ComparisonOperator.java
4042db886171c71fd203a069d831b4c8a1a41c4a
[]
no_license
czbirka/ILA-VV-TP-MutationTesting
8e0224423e0b0d868be6f5168a7687df4968c5b2
984f8850b37bb1c1724f089dd7f5e8b01d94535f
refs/heads/master
2021-05-15T21:37:59.364092
2017-12-22T22:07:13
2017-12-22T22:07:13
106,533,557
0
0
null
null
null
null
UTF-8
Java
false
false
4,968
java
package m2.ila.fr.istic.ila.vv.mutation.operator; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; import org.apache.maven.shared.invoker.DefaultInvocationRequest; import org.apache.maven.shared.invoker.DefaultInvoker; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; import javassist.CannotCompileException; import javassist.CtClass; import javassist.CtMethod; import javassist.NotFoundException; import javassist.bytecode.BadBytecode; import javassist.bytecode.CodeAttribute; import javassist.bytecode.CodeIterator; import javassist.bytecode.MethodInfo; import javassist.bytecode.Opcode; import m2.ila.fr.istic.ila.vv.mutation.loader.PropertiesLoader; import m2.ila.fr.istic.ila.vv.mutation.mutation.Mutation; public class ComparisonOperator implements MutationOperator { private List<Mutation> mutations; private Properties properties = new Properties(); public ComparisonOperator() throws IOException { PropertiesLoader propertiesLoader; propertiesLoader = PropertiesLoader.getInstance(); this.properties=propertiesLoader.getProperties(); mutations = new ArrayList<Mutation>(); } @Override public void checkMutate(CtMethod method) throws NotFoundException, CannotCompileException, IOException, BadBytecode, MavenInvocationException { CtClass classMethod = method.getDeclaringClass(); if (classMethod.isFrozen()) { classMethod.defrost(); } // On récupère les parametres MethodInfo methodInfo = method.getMethodInfo(); CodeAttribute attributs = methodInfo.getCodeAttribute(); if (attributs != null) { // On itère sur les paramètres CodeIterator iterator = attributs.iterator(); int previousOpCode = -1; int lastCode = -2; int actualCode = -2; String modif = ""; while (iterator.hasNext()) { // position de l'itérateur int pos = iterator.next(); lastCode = actualCode; actualCode = iterator.byteAt(pos); // switch (iterator.byteAt(pos)) { //on remplace > par >= case Opcode.IFLE: if(lastCode == Opcode.DCMPL) { iterator.writeByte(Opcode.IFLT, pos); previousOpCode = Opcode.IFLE; modif = "> remplacé par >="; } break; //on remplace >= par > case Opcode.IFLT: if(lastCode == Opcode.DCMPL) { iterator.writeByte(Opcode.IFLE, pos); previousOpCode = Opcode.IFLT; modif = ">= remplacé par >"; } break; //on remplace < par <= case Opcode.IFGE: if(lastCode == Opcode.DCMPG) { iterator.writeByte(Opcode.IFGT, pos); previousOpCode = Opcode.IFGE; modif = "< remplacé par <="; } break; //on remplace <= par < case Opcode.IFGT: if(lastCode == Opcode.DCMPG) { iterator.writeByte(Opcode.IFGE, pos); previousOpCode = Opcode.IFGT; modif = "<= remplacé par <"; } break; //on remplace == par != case Opcode.IFNE: if(lastCode == Opcode.DCMPL) { iterator.writeByte(Opcode.IFEQ, pos); previousOpCode = Opcode.IFNE; modif = "== remplacé par !="; } break; //on remplace != par == case Opcode.IFEQ: if(lastCode == Opcode.DCMPL) { iterator.writeByte(Opcode.IFNE, pos); previousOpCode = Opcode.IFEQ; modif = "!= remplacé par =="; } break; default: break; } // Switch if(!modif.equals("")) { // On génère le nouveau .class dans le repertoire de la classe if (classMethod.isFrozen()) { classMethod.defrost(); } classMethod.writeFile(properties.getProperty("TARGET_DIRECTORY")); // Lancer les tests InvocationRequest request = new DefaultInvocationRequest(); request.setPomFile(new File(properties.getProperty("PROJECT_DIRECTORY") + "/pom.xml")); request.setGoals(Arrays.asList("test")); Invoker invoker = new DefaultInvoker(); invoker.setMavenHome(new File("/usr/share/maven")); InvocationResult result = invoker.execute(request); // Remettre comme c'etait if (classMethod.isFrozen()) { classMethod.defrost(); } iterator.writeByte(previousOpCode, pos); //classMethod.writeFile(Properties.TARGET_CLASSPATH); classMethod.writeFile(properties.getProperty("TARGET_DIRECTORY")); //stockage résultat Mutation mutation = new Mutation(classMethod, method, modif); if ( result.getExitCode() == 0 ) { mutation.setMutationFound(false); } else { mutation.setMutationFound(true);; } mutations.add(mutation); modif=""; }//if modif } // while } // if } @Override public List<Mutation> getMutations() { return mutations; } }
3fb9e34f7c27883dbee80f1557dcfc8289b46139
9c5cc34c808a06fdd8de0e2bacfe84e1b2a8ff89
/adapters/RecyclerViewAdapterAllFeeds.java
16fd4dee74914d6f14c8bf86c2c44248a37dc441
[]
no_license
aaronxie666/premier
bf17febec8d02e331c171868b1fa57009d78e9be
7813a41daf35bc835103f290742f3f8d443b619f
refs/heads/main
2022-12-31T13:21:43.650767
2020-10-21T09:16:37
2020-10-21T09:16:37
305,969,601
0
0
null
null
null
null
UTF-8
Java
false
false
54,503
java
package icn.premierandroid.adapters; import android.app.Dialog; import android.app.DownloadManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.graphics.Color; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; import com.parse.DeleteCallback; import com.parse.FindCallback; import com.parse.ParseException; import com.parse.ParseInstallation; import com.parse.ParseObject; import com.parse.ParsePush; import com.parse.ParseQuery; import com.parse.ParseUser; import com.parse.SaveCallback; import com.parse.SendCallback; import com.squareup.picasso.MemoryPolicy; import com.squareup.picasso.Picasso; import org.joda.time.DateTime; import org.joda.time.Days; import org.joda.time.Hours; import org.joda.time.Minutes; import org.joda.time.Months; import org.joda.time.Seconds; import org.joda.time.chrono.GregorianChronology; import org.json.JSONArray; import java.util.ArrayList; import java.util.Collections; import java.util.List; import icn.premierandroid.AllLoginActivity; import icn.premierandroid.CommentsActivity; import icn.premierandroid.R; import icn.premierandroid.TagsActivity; import icn.premierandroid.fragments.StreetStyleFragment; import icn.premierandroid.interfaces.UserType; import icn.premierandroid.interfaces.isCurrentUserProfile; import icn.premierandroid.misc.CustomFontTextView; import icn.premierandroid.models.AllFeedsDataModel; import icn.premierandroid.models.SuggestedUsersDataModel; import icn.premierandroid.models.TagsModel; import static icn.premierandroid.misc.CONSTANTS.LOADED_POSTS; import static icn.premierandroid.misc.CONSTANTS.TOTAL_POSTS; import static java.lang.String.valueOf; /** * Developer: Bradley Wilson * Company: International Celebrity Network * Association: The Adapter for the recyclerviews inside StreetstyleHomeFragment, * StreetStyleSearchFragment and StreetStyleProfileFragment */ public class RecyclerViewAdapterAllFeeds extends RecyclerView.Adapter<RecyclerViewHolderAllFeeds> { // recyclerview adapter private ArrayList<AllFeedsDataModel> previousPostsList; private Context context; private AllFeedsDataModel model; private ArrayList<TextView> tags = new ArrayList<>(); private ArrayList<View> shadows = new ArrayList<>(); private int count = 0, count1 = 0, count2=0, count3=0; private String time = "less than a minute ago"; private ArrayList<ImageView> like_icons = new ArrayList<>(); private boolean liked = false; private JSONArray likingArray; private int transitionTime = 700; private TransitionDrawable transition; private boolean profile; private ArrayList<String> allLikes; private ArrayList<String> allTags; private ArrayList<ParseObject> likesListUsers; private ArrayList<SuggestedUsersDataModel> userLikes; private ArrayList<TagsModel> userTags; private RecyclerView dialog_recycler; private Dialog likesDialog; private ArrayList<TextView> number_of_likes_list = new ArrayList<>(); private ArrayList<TextView> number_of_likes_image_list = new ArrayList<>(); private ArrayList<TextView> number_of_tags_list = new ArrayList<>(); private ArrayList<TextView> number_of_tags_image_list = new ArrayList<>(); private ArrayList<String> imageIds = new ArrayList<>(); private ArrayList<Integer> likesAmount = new ArrayList<>(); private ArrayList<Integer> tagsAmount = new ArrayList<>(); private int lastVisibleItem, totalItemCount; private boolean loading; private OnLoadMoreListener onLoadMoreListener; private ArrayList<String> objectIds = new ArrayList<>(); private JSONArray peopleVoted; private Dialog tagsDialog; private RecyclerView tags_dialog_recycler; private JSONArray tagsArray; private Boolean search; public RecyclerViewAdapterAllFeeds(Context context, final ArrayList<AllFeedsDataModel> previousPostsList, final boolean profile, RecyclerView recyclerView, Boolean search) { this.context = context; this.previousPostsList = previousPostsList; this.profile = profile; this.search = search; if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) { // final LinearLayoutManager linearLayoutManager = (LinearLayoutManager)recyclerView.getLayoutManager(); // recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { // @Override // public void onScrolled(RecyclerView recyclerView, int dx, int dy) { // super.onScrolled(recyclerView, dx, dy); // if (getItemCount() <= TOTAL_POSTS) { // if (getItemCount() > LOADED_POSTS - 2) { // totalItemCount = getItemCount(); // lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition(); // if (!loading && totalItemCount <= (lastVisibleItem + visibleThreshold)) { // if (onLoadMoreListener != null) { // onLoadMoreListener.onLoadMore(); // } // loading = true; // } // } // } // } // }); // } final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { totalItemCount = linearLayoutManager.getItemCount(); if (totalItemCount > TOTAL_POSTS) { totalItemCount = TOTAL_POSTS; } lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition(); if (!loading && totalItemCount <= (lastVisibleItem + LOADED_POSTS)) { if (onLoadMoreListener != null) { onLoadMoreListener.onLoadMore(); } loading = true; recyclerView.removeOnScrollListener(this); } } }; recyclerView.addOnScrollListener(scrollListener); } } @Override public int getItemCount() { return (null != previousPostsList ? previousPostsList.size() : 0); } @Override public int getItemViewType(int position) { return previousPostsList.get(position) != null ? 1 : 0; } @Override public void onBindViewHolder(final RecyclerViewHolderAllFeeds holder, int position) { if(holder != null) { model = previousPostsList.get(position); objectIds.add(model.getCurrentUser()); final int positionFinal = position; if (model != null) { if (model.getFeeds()) { if (holder.row_container.indexOfChild(holder.user_name) == -1) { holder.row_container.addView(holder.user_name); } if (holder.row_container.indexOfChild(holder.profile_image) == -1) { holder.row_container.addView(holder.profile_image); } if (model.getProfile_url() != null) { if (model.getProfile_url().isEmpty()) { Picasso.with(context).load(R.drawable.profile_nopic).into(holder.profile_image); } else { Picasso.with(context).load(model.getProfile_url()).placeholder(R.drawable.profile_nopic).into(holder.profile_image); } } else { Picasso.with(context).load(R.drawable.profile_nopic).into(holder.profile_image); } Log.e("objectid", objectIds.toString()); // if (search && !profile) { // Collections.reverse(objectIds); // Log.e("objectIds_REVE", objectIds.toString()); // } holder.user_name.setText(model.getUsername()); holder.user_name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.e("model_current", "" + model.getCurrentUser()); if (objectIds.get(positionFinal) == ParseUser.getCurrentUser().getObjectId()) { StreetStyleFragment.setObjectId(objectIds.get(positionFinal)); StreetStyleFragment.type = isCurrentUserProfile.type.yes; StreetStyleFragment.bottomBar.selectTabAtPosition(3); } else { StreetStyleFragment.setObjectId(objectIds.get(positionFinal)); StreetStyleFragment.type = isCurrentUserProfile.type.no; StreetStyleFragment.bottomBar.selectTabAtPosition(3); } } }); holder.uploadedImage.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { final AlertDialog diaBox = ReportDialog(holder.getAdapterPosition()); diaBox.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { diaBox.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.BLACK); diaBox.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLACK); } }); diaBox.show(); return false; } }); } else { holder.row_container.removeView(holder.user_name); holder.row_container.removeView(holder.profile_image); } imageIds.add(model.getImageId()); addShadowViews(holder); getTagInformation(model, holder); addLikeIcons(holder); System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"+liked); // setting title Log.d("created_at", "" + model.getCreated_at()); how_long_ago(model.getCreated_at()); holder.createdAt.setText(time); likesAmount.add(model.getLikes()); tagsAmount.add(model.getTagSize()); Log.e("tags size", "" + tagsAmount.size()); number_of_likes_list.add(holder.number_of_likes); number_of_likes_image_list.add(holder.likesImage); number_of_tags_list.add(holder.number_of_tags); number_of_tags_image_list.add(holder.tagsImage); // if (search) { // Picasso.with(context).load(model.getImage()).fit().memoryPolicy(MemoryPolicy.NO_CACHE).centerCrop().into(holder.uploadedImage); // } else { Picasso.with(context).load(model.getImage()).into(holder.uploadedImage); // } holder.caption.setText(model.getCaption()); holder.number_of_likes.setText(valueOf(model.getLikes())); if (likesAmount.get(position) > 0) { number_of_likes_image_list.get(position).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showLikesUsersDialog(); populateRecyclerView(imageIds.get(holder.getAdapterPosition())); } }); number_of_likes_list.get(position).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showLikesUsersDialog(); populateRecyclerView(imageIds.get(holder.getAdapterPosition())); } }); } else { Log.e("no likes", "no likes"); } if (tagsAmount.get(position) > 0) { number_of_tags_image_list.get(position).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTagsUsersDialog(); populateTagsRecyclerView(imageIds.get(holder.getAdapterPosition()));} }); number_of_tags_list.get(position).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTagsUsersDialog(); populateTagsRecyclerView(imageIds.get(holder.getAdapterPosition())); } }); } else { Log.e("no tags", "no tags"); } holder.number_of_comments.setText(model.getComments()); for ( int i = 0; i <= like_icons.size(); i++) { final int finalI = i; holder.uploadedImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { makeShadowLayout(shadows); makeTags(tags); makeLikeIcons(); doesUserLikeThisImage(finalI); } }); if (profile) { holder.uploadedImage.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { final AlertDialog diaBox = AskOption(holder.getAdapterPosition()); diaBox.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { diaBox.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(Color.BLACK); diaBox.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.BLACK); } }); diaBox.show(); return false; } }); } holder.number_of_comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GoToComments(model.getImages(finalI-1), model.getCurrentUser()); } }); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GoToComments(model.getImages(finalI-1), model.getCurrentUser()); } }); } holder.number_of_tags.setText(model.getTags()); for (int i = 0; i < tags.size(); i++) { final int finalI = i; tags.get(i).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent tagIntent = new Intent(context, TagsActivity.class); String text = getFirstWord(tags.get(finalI).getText().toString()); tagIntent.putExtra("tag", text); context.startActivity(tagIntent); } }); } like_icons.get(position).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId", imageIds.get(holder.getAdapterPosition())); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { for (ParseObject j : objects) { likingArray = j.getJSONArray("peopleVoted"); if (likingArray != null) { Log.e("liking array", "!= null"); System.out.println("000000000000000000000000000000000000000000"+liked); if (likingArray.toString().contains(ParseUser.getCurrentUser().getObjectId())) { System.out.println("-------------------------------------------------------------remove"); String likesNew = j.getString("likes"); int likesTotal = Integer.valueOf(likesNew) - 1; String finalLikes = valueOf(likesTotal); ArrayList<String> user_array = new ArrayList<>(); user_array.add(ParseUser.getCurrentUser().getObjectId()); j.removeAll("peopleVoted", user_array); j.put("likes", finalLikes); transition = (TransitionDrawable) like_icons.get(holder.getAdapterPosition()).getBackground(); transition.reverseTransition(transitionTime); j.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { removeCurrentUserLikes(); } }); } else { System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++add"+ likingArray); likingArray.put(ParseUser.getCurrentUser().getObjectId()); Log.e("liking array", "doesn't contain new user"); j.put("peopleVoted", likingArray); String likes = j.getString("likes"); int totalLikes = Integer.valueOf(likes) + 1; likes = valueOf(totalLikes); j.put("likes", likes); j.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { notifyUser(imageIds.get(holder.getAdapterPosition())); addLikesToUser(); transition = (TransitionDrawable) like_icons.get(holder.getAdapterPosition()).getBackground(); transition.startTransition(transitionTime); } else { Log.e("failed", "failed" + e.getMessage()); } } }); } } else { Log.e("liking array", "is null"); JSONArray new_like_array = new JSONArray(); new_like_array.put(ParseUser.getCurrentUser().getObjectId()); j.put("peopleVoted", new_like_array); String likes = j.getString("likes"); int totalLikes = Integer.valueOf(likes) + 1; likes = valueOf(totalLikes); j.put("likes", likes); j.saveEventually(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { notifyUser(imageIds.get(holder.getAdapterPosition())); addLikesToUser(); transition = (TransitionDrawable) like_icons.get(holder.getAdapterPosition()).getBackground(); transition.startTransition(transitionTime); } else { Log.e("failed", "failed" + e.getMessage()); } } }); } } } else { Log.e("failed", "failed" + e.getMessage()); } } }); Log.e("imageID", model.getImageId() + " selected"); } }); } } else { ((ProgressViewHolder) holder).container.setVisibility(View.VISIBLE); } } private String getFirstWord(String text) { if (text.indexOf(' ') > -1) { // Check if there is more than one word. return text.substring(0, text.indexOf(" -")); // Extract words before dash } else { return text; // Text is the first word itself. } } private void populateTagsRecyclerView(String imageId) { Log.e("imageId", imageId); ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId", imageId); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { allTags = new ArrayList<>(); userTags = new ArrayList<>(); for (ParseObject j : objects) { tagsArray = j.getJSONArray("tagName"); if (tagsArray!= null) { if (tagsArray.length() != 0) { if (allTags != null) { for (int i = 0; i < tagsArray.length(); i++) { allTags.add(tagsArray.optString(i)); Log.e("alltags", allTags.toString()); } } } else { Log.e("no tags", "no tags"); } userTags.add(new TagsModel(allTags)); } else { Log.e("No tags", "No tags"); } } RecyclerViewAdapterDialog adapter = new RecyclerViewAdapterDialog(context, null, userTags, tagsDialog); tags_dialog_recycler.setAdapter(adapter);// set adapter on recyclerview adapter.notifyDataSetChanged();// Notify the adapter } else { Log.e("failed", "failed" + e.getMessage()); } } }); } private void showTagsUsersDialog() { tagsDialog = new Dialog(context, android.R.style.Theme_Holo_Light_Dialog_NoActionBar); tagsDialog.setContentView(R.layout.recycler_view); tagsDialog.setCancelable(true); tags_dialog_recycler = (RecyclerView) tagsDialog.findViewById(R.id.dialog_recyclerview); tags_dialog_recycler.setHasFixedSize(true); LinearLayoutManager mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); tags_dialog_recycler.setLayoutManager(mLayoutManager); tags_dialog_recycler.setBackgroundColor(Color.WHITE); tagsDialog.show(); } public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener){ this.onLoadMoreListener = onLoadMoreListener; } public interface OnLoadMoreListener { void onLoadMore(); } public void setLoaded() { loading = false; } private void showLikesUsersDialog() { likesDialog = new Dialog(context, android.R.style.Theme_Holo_Light_Dialog_NoActionBar); likesDialog.setContentView(R.layout.recycler_view); likesDialog.setCancelable(true); dialog_recycler = (RecyclerView) likesDialog.findViewById(R.id.dialog_recyclerview); dialog_recycler.setHasFixedSize(true); LinearLayoutManager mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); dialog_recycler.setLayoutManager(mLayoutManager); dialog_recycler.setBackgroundColor(Color.WHITE); likesDialog.show(); } private void populateRecyclerView(String imageId) { count3 = 0; Log.e("imageId", imageId); ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId", imageId); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { allLikes = new ArrayList<>(); likesListUsers = new ArrayList<>(); userLikes = new ArrayList<>(); for (ParseObject j : objects) { peopleVoted = j.getJSONArray("peopleVoted"); if (peopleVoted != null) { if (peopleVoted.length() != 0) { if (allLikes != null) { for (int i = 0; i < peopleVoted.length(); i++) { allLikes.add(peopleVoted.optString(i)); Log.e("alllikes", allLikes.toString()); } } } else { Log.e("no likes", "no likes"); } getUserDetails(); } else { Log.e("No Likes", "No likes"); } } } else { Log.e("failed", "failed" + e.getMessage()); } } }); } private void getUserDetails() { ParseQuery<ParseObject> query = ParseQuery.getQuery("_User"); try { query.whereEqualTo("objectId", allLikes.get(count3)); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { for (ParseObject j : objects) { Log.d("user_id", "" + j.get("name")); likesListUsers.add(j); if (allLikes.size() == 1) { count3 = 1; } else { count3++; } if (count3 < peopleVoted.length()) { getUserDetails(); } else { int z = 0; for (ParseObject ignored : likesListUsers) { if (z < peopleVoted.length()) { ParseUser theUser = (ParseUser) likesListUsers.get(z); String user_name = theUser.getUsername(); String objectId = theUser.getObjectId(); Log.e("user_name", user_name); String profile_picture = (String) theUser.get("profilePicture"); if (profile_picture != null) { if (profile_picture.isEmpty()) { Log.e("profile_pic_url", "is null"); } else { if (AllLoginActivity.userType != UserType.userType.instagramUser) { profile_picture = profile_picture.replace("http", "https"); } if (profile_picture.startsWith("httpss")) { profile_picture = profile_picture.replace("httpss", "https"); } } } else { profile_picture = "R.drawable.profile_nopic"; } Log.e("profile", "profilepic" + profile_picture); userLikes.add(new SuggestedUsersDataModel(user_name, profile_picture, objectId)); z++; } } RecyclerViewAdapterDialog adapter = new RecyclerViewAdapterDialog(context, userLikes, null, likesDialog); dialog_recycler.setAdapter(adapter);// set adapter on recyclerview adapter.notifyDataSetChanged();// Notify the adapter } } } else { Log.e("failed", "failed" + e.getMessage()); } } }); } catch (IndexOutOfBoundsException e) { Log.e("failed", "failed " + e.getMessage()); } } private void removeCurrentUserLikes() { ParseQuery<ParseObject> followUser = ParseQuery.getQuery("Follow"); followUser.whereEqualTo("user", ParseUser.getCurrentUser()); followUser.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { if (objects.size() > 0) { int likes = objects.get(0).getInt("likes"); int totalLikes = likes - 1; if (likes != 0) { objects.get(0).put("likes", totalLikes); objects.get(0).saveEventually(); liked = false; } else { objects.get(0).put("likes", 0); objects.get(0).saveEventually(); liked = false; } } else { Log.e("failed", "no objects match"); } } else { Log.e("failed", "failed " + e.getMessage()); } } }); } private void doesUserLikeThisImage(final int position) { try { ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId", model.getImages(position)); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { for (ParseObject j : objects) { JSONArray likingArray = j.getJSONArray("peopleVoted"); liked = likingArray != null && likingArray.toString().contains(ParseUser.getCurrentUser().getObjectId()); } } else { Log.e("failed", "failed" + e.getMessage()); } } }); } catch (IndexOutOfBoundsException e) { Log.e("indexoutofbounds", e.getMessage()); } } private AlertDialog AskOption(final int i) { return new AlertDialog.Builder(context) //set message, title, and icon .setTitle("Delete") .setMessage("Do you want to Delete") .setPositiveButton("Delete", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { previousPostsList.remove(i); notifyDataSetChanged(); removePostFromParse(); removeLikesFromUser(); dialog.dismiss(); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .create(); } private AlertDialog ReportDialog(final int i) { return new AlertDialog.Builder(context) //set message, title, and icon .setTitle("Report Photo") .setMessage("This photo will be reported and reviewed within 24 hours for objectionable content. If the post is found to be unsuitable, it will be deleted.") .setPositiveButton("Report", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { addReportedImage(i); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .create(); } private void addReportedImage(final int i) { ParseObject reportedImage = new ParseObject("ReportedImages"); reportedImage.put("userID", ParseUser.getCurrentUser()); reportedImage.put("imageID", imageIds.get(i)); reportedImage.saveInBackground(); } private void removeLikesFromUser() { ParseQuery<ParseUser> points_query = ParseUser.getQuery(); points_query.whereEqualTo("objectId", ParseUser.getCurrentUser().getObjectId()); points_query.findInBackground(new FindCallback<ParseUser>() { @Override public void done(List<ParseUser> objects, ParseException e) { if (e == null) { if (objects != null) { for (ParseUser j : objects) { int totalPoints; int points = j.getInt("points"); if (points >= 200) { totalPoints = points - 200; j.put("points", totalPoints); } else { totalPoints = 0; j.put("points", totalPoints); } j.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { Log.e("success", "successfully removed points"); } else { Log.e("failed", "failed" + e.getMessage()); } } }); } } else { Log.e("objects", "is null"); } } else { Log.e("failed", "failed" + e.getMessage()); } } }); } private void removePostFromParse() { ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId", model.getImageId()); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { objects.get(0).deleteInBackground(new DeleteCallback() { @Override public void done(ParseException e) { if (e == null) { Toast.makeText(context, "Post Successfully Deleted", Toast.LENGTH_SHORT).show(); Log.e("delete success", "successfully deleted post"); updateUserPosts(); } else { Log.e("failed", "failed" + e.getMessage()); } } }); } }); } private void updateUserPosts() { ParseQuery<ParseUser> query = ParseUser.getQuery(); query.whereEqualTo("objectId", ParseUser.getCurrentUser().getObjectId()); query.findInBackground(new FindCallback<ParseUser>() { @Override public void done(List<ParseUser> objects, ParseException e) { int posts = objects.get(0).getInt("posts"); int newposts = posts - 1; objects.get(0).put("posts", newposts); objects.get(0).saveInBackground(); } }); } private void addLikesToUser() { ParseQuery<ParseObject> followUser = ParseQuery.getQuery("Follow"); followUser.whereEqualTo("user", ParseUser.getCurrentUser()); followUser.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { if (objects.size() > 0) { int likes = objects.get(0).getInt("likes"); int totalLikes = likes + 1; if (likes == 0) { objects.get(0).put("likes", 1); objects.get(0).saveEventually(); liked = true; } else { objects.get(0).put("likes", totalLikes); objects.get(0).saveEventually(); liked = true; } } else { Log.e("failed", "no objects match"); } } else { Log.e("failed", "failed " + e.getMessage()); } } }); } private void notifyUser(final String imageId) { final ParseUser parseUser = (ParseUser) ParseUser.createWithoutData("_User", model.getCurrentUser()); ParseObject notifications = new ParseObject("Notifications"); notifications.put("action", "comment"); notifications.put("actionUser", ParseUser.getCurrentUser()); notifications.put("receivedUser", parseUser); notifications.put("photoLiked", imageId); notifications.saveInBackground(); ParseQuery<ParseInstallation> parseQueryInstallation = ParseQuery.getQuery(ParseInstallation.class); parseQueryInstallation.whereEqualTo("user", parseUser); //sends Push Notification of Friend Request ParsePush push = new ParsePush(); push.setMessage(ParseUser.getCurrentUser().getUsername() + " has liked one of your photos."); push.setQuery(parseQueryInstallation); push.sendInBackground(new SendCallback() { @Override public void done(ParseException e) { if (e == null){ Log.e("SAVE SUCCESS", ""); }else{ Log.e("ERROR", e.getMessage()); } } }); } @Override public RecyclerViewHolderAllFeeds onCreateViewHolder(ViewGroup viewGroup, int viewType) { RecyclerViewHolderAllFeeds holder; LayoutInflater mInflater = LayoutInflater.from(viewGroup.getContext()); if (viewType == 1) { // This method will inflate the custom layout and return as viewholde ViewGroup mainGroup = (ViewGroup) mInflater.inflate(R.layout.feed_and_search_feed_item_row, viewGroup, false); holder = new RecyclerViewHolderAllFeeds(mainGroup); } else { ViewGroup mainGroup = (ViewGroup) mInflater.inflate(R.layout.progress_item, viewGroup, false); holder = new ProgressViewHolder(mainGroup); } return holder; } private void GoToComments(String objectId, String userId) { Log.e("comments click", "comments clicked"); final Intent i = new Intent(context, CommentsActivity.class); i.putExtra("imageId", objectId); i.putExtra("selectedUser", userId); Log.e("selectedUserPrev", "" + userId); context.startActivity(i); } private String how_long_ago(String created_at) { DateTime sinceGraduation = new DateTime(created_at, GregorianChronology.getInstance()); DateTime currentDate = new DateTime(); //current date Months diffInMonths = Months.monthsBetween(sinceGraduation, currentDate); Days diffInDays = Days.daysBetween(sinceGraduation, currentDate); Hours diffInHours = Hours.hoursBetween(sinceGraduation, currentDate); Minutes diffInMinutes = Minutes.minutesBetween(sinceGraduation, currentDate); Seconds seconds = Seconds.secondsBetween(sinceGraduation, currentDate); Log.d("since grad", "before if " + sinceGraduation); if (diffInDays.isGreaterThan(Days.days(31))) { time = diffInMonths.getMonths() + " months ago"; if (diffInMonths.getMonths() == 1) { time = diffInMonths.getMonths() + " month ago"; } else { time = diffInMonths.getMonths() + " months ago"; } return time; } else if (diffInHours.isGreaterThan(Hours.hours(24))) { if (diffInDays.getDays() == 1) { time = diffInDays.getDays() + " day ago"; } else { time = diffInDays.getDays() + " days ago"; } return time; } else if (diffInMinutes.isGreaterThan(Minutes.minutes(60))) { if (diffInHours.getHours() == 1) { time = diffInHours.getHours() + " hour ago"; } else { time = diffInHours.getHours() + " hours ago"; } return time; } else if (seconds.isGreaterThan(Seconds.seconds(60))) { if (diffInMinutes.getMinutes() == 1) { time = diffInMinutes.getMinutes() + " minute ago"; } else { time = diffInMinutes.getMinutes() + " minutes ago"; } return time; } else if (seconds.isLessThan(Seconds.seconds(60))) { return time; } Log.d("since grad", "" + sinceGraduation); return time; } private void addLikeIcons(final RecyclerViewHolderAllFeeds mainHolder) { ImageView likes = new ImageView(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { params.addRule(RelativeLayout.ALIGN_PARENT_END); } else { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } params.setMargins(0, 0, 0, 40); likes.setLayoutParams(params); likes.setBackgroundResource(R.drawable.like_transition); mainHolder.imageContainer.addView(likes); likes.setVisibility(View.INVISIBLE); like_icons.add(likes); //add by chang start ParseQuery<ParseObject> query = ParseQuery.getQuery("FashionFeed"); query.whereEqualTo("objectId",imageIds.get(mainHolder.getAdapterPosition())); // query.findInBackground(new FindCallback<ParseObject>() { // @Override // public void done(List<ParseObject> objects, ParseException e) { List<ParseObject> objects = null; try { objects = query.find(); // if(e==null){ for(ParseObject j :objects){ likingArray = j.getJSONArray("peopleVoted"); if(likingArray!=null){ if(likingArray.toString().contains(ParseUser.getCurrentUser().getObjectId())){ transition = (TransitionDrawable) like_icons.get(mainHolder.getAdapterPosition()).getBackground(); transition.startTransition(transitionTime); liked = true; }else { liked = false; } }else { liked = false; } // } } } catch (ParseException e) { e.printStackTrace(); } // } // }); //add by chang end } private void makeLikeIcons() { if (count1 == 0) { for (int i = 0; i < like_icons.size(); i++) { if (like_icons.get(i).getVisibility() == View.INVISIBLE) { like_icons.get(i).setVisibility(View.VISIBLE); } else { like_icons.get(i).setVisibility(View.INVISIBLE); } } count1 = 1; } else { for (int i = 0; i < like_icons.size(); i++) { if (like_icons.get(i).getVisibility() == View.INVISIBLE) { like_icons.get(i).setVisibility(View.VISIBLE); } else { like_icons.get(i).setVisibility(View.INVISIBLE); } } count1 = 0; } } private void getTagInformation(AllFeedsDataModel model, RecyclerViewHolderAllFeeds mainHolder) { if (model.getTagSize() == 0) { Log.e("No tags", "no tags for this image"); } else { for (int o = 0; o < model.getTagSize(); o++) { CustomFontTextView tag = new CustomFontTextView(context); Resources r = context.getResources(); float height = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, r.getDisplayMetrics()); DisplayMetrics displayMetrics = r.getDisplayMetrics(); float width = displayMetrics.widthPixels / displayMetrics.density; float x = width - Float.parseFloat(model.getXpoints(o)) / 100 * width; float y = height - Float.parseFloat(model.getYpoints(o)) / 100 * height; Log.e("getPointX", "" + model.getXpoints(o) + "" + model.getYpoints(o)); Log.e("x", "x" + x + "y" + y); tag.setX(x); tag.setY(y); Log.e("x", "" + tag.getX()); Log.e("y", "" + tag.getY()); tag.setText(model.getTagName(o) + " - " + model.getTagClothing(o)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tag.setLayoutParams(params); tag.setMaxLines(2); tag.setTextSize(11); tag.setClickable(true); tag.setHintTextColor(Color.WHITE); tag.setTextColor(Color.WHITE); tag.setBackgroundResource(R.drawable.tags_rounded_corners); mainHolder.imageContainer.addView(tag); tag.setVisibility(View.INVISIBLE); tags.add(tag); } } } private void addShadowViews(RecyclerViewHolderAllFeeds mainHolder) { View shadowView = new View(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 40); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); shadowView.setLayoutParams(params); shadowView.setBackgroundResource(R.drawable.gradient1); mainHolder.imageContainer.addView(shadowView); shadowView.setVisibility(View.INVISIBLE); shadows.add(shadowView); } private void makeTags(ArrayList<TextView> tags) { if (count == 0) { for (int i = 0; i < tags.size(); i++) { if (tags.get(i).getVisibility() == View.INVISIBLE) { tags.get(i).setVisibility(View.VISIBLE); } else { tags.get(i).setVisibility(View.INVISIBLE); } } count = 1; } else { for (int i = 0; i < tags.size(); i++) { if (tags.get(i).getVisibility() == View.INVISIBLE) { tags.get(i).setVisibility(View.VISIBLE); } else { tags.get(i).setVisibility(View.INVISIBLE); } } count = 0; } } private void makeShadowLayout(ArrayList<View> shadows) { if (count2 == 0) { for (int i = 0; i < shadows.size(); i++) { if (shadows.get(i).getVisibility() == View.INVISIBLE) { shadows.get(i).setVisibility(View.VISIBLE); } else { shadows.get(i).setVisibility(View.INVISIBLE); } } count2 = 1; } else { for (int i = 0; i < shadows.size(); i++) { if (shadows.get(i).getVisibility() == View.INVISIBLE) { shadows.get(i).setVisibility(View.VISIBLE); } else { shadows.get(i).setVisibility(View.INVISIBLE); } } count2 = 0; } } public void update(ArrayList<AllFeedsDataModel> updatesList) { previousPostsList.clear(); previousPostsList.addAll(updatesList); } }
2f55cf88de1e6075cb1aee38a815262c69dcbb48
99899dbe4f22295e628832dc9d2fe85e49dfef04
/codeforces/round/round656/f/Solution.java
9f2fa3082631654c7d5b2c8f36194a4cbef623c0
[]
no_license
judyzhoubaby/sq-code-solutions
ceae5dbd9090969a86117f0d910f7451c857279f
112ba5153775a06cdbad9df7dafe75681620b335
refs/heads/master
2022-12-01T07:31:27.640576
2020-08-13T06:56:32
2020-08-13T06:56:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,106
java
package codeforces.round.round656.f; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solution { static final FS sc = new FS(); static final PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) { } static class FS { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while(!st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch(Exception ignored) {} } return st.nextToken(); } int[] nextArray(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++) { a[i] = nextInt(); } return a; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } } }
b1371a6f0b36e0f4c091fafc7a428a490e9b4aa1
3111724510b79b28f97b391da2f4093e6e11f850
/src/com/mttl/vlms/user/dao/UserDao.java
96fb49d3a6308ca26b772af036141ae980d4cc84
[]
no_license
tanbinh123/ToyotaMyanmar
0dfe387f37b2fd20cd9c82680a269e9ee022e46c
9c341295dfbd079a2ca535fb99d73d8b17366e37
refs/heads/master
2023-05-29T14:06:46.545811
2020-03-30T03:15:00
2020-03-30T03:15:00
null
0
0
null
null
null
null
UTF-8
Java
false
false
357
java
package com.mttl.vlms.user.dao; import java.util.Date; import com.mttl.vlms.exception.DAOException; import com.mttl.vlms.user.dto.User; /** * UserDao * * * */ public interface UserDao { User findUser(String userId) throws DAOException; int updateRecoveryCode(Integer userId, String recoveryCode, Date recoveryCodeTime) throws DAOException; }
0dbc5c09c1903de167c17bb3b29e3db953d584f9
ec47599d333eae8513050ddf5aa4e815c31280d7
/intro/src/intro/HelloWord.java
5483ef273ae56af3ee4e7a9877c0dce272004601
[]
no_license
ddenizz99/JavaPlayStoreProject
c29d8d0dfd479a45b561fbeadccfe13bbaa486c8
99bdc1cc570efdd3dab92d821cd2fc80e00304f1
refs/heads/master
2023-04-16T16:34:10.559119
2021-05-02T20:09:49
2021-05-02T20:09:49
363,739,632
0
0
null
null
null
null
UTF-8
Java
false
false
74
java
package intro; public interface HelloWord { public void getMessage(); }
cc5a6a05c63b09ceed4a670f8f0bd0cd88e22519
06b961d50e568842e6f538052d3459e44d7f0b28
/Android/Search/app/src/main/java/com/example/search/ImageResultAdapter.java
284e3ae86fb1657fcd2aaf107ec4d3e6fad73ab5
[]
no_license
samydevv/Search-Engine-
6c08faf62cd26f8650870689745ab85c757dacf2
825bb471d1f6429c5780021e5f56eeac3f42c04f
refs/heads/master
2022-10-28T14:55:14.667271
2020-06-14T01:25:33
2020-06-14T01:25:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,799
java
package com.example.search; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import java.util.ArrayList; public class ImageResultAdapter extends RecyclerView.Adapter<ImageResultAdapter.ImageResultViewHolder> { private ArrayList<ImageResult> ArrayList; public static class ImageResultViewHolder extends RecyclerView.ViewHolder { public ImageView Image; public ImageResultViewHolder(@NonNull View itemView) { super(itemView); Image = itemView.findViewById(R.id.image_iv); } } public ImageResultAdapter(ArrayList<ImageResult> arrayList) { ArrayList = arrayList; } @NonNull @Override public ImageResultViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.image_item, parent, false); ImageResultAdapter.ImageResultViewHolder imageResultViewHolder = new ImageResultViewHolder(view); return imageResultViewHolder; } @Override public void onBindViewHolder(@NonNull ImageResultViewHolder holder, int position) { ImageResult imageResult = ArrayList.get(position); if (imageResult.getImageURL() != null) { Glide.with(holder.Image.getContext()) .load(imageResult.getImageURL()) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(holder.Image); } } @Override public int getItemCount() { return ArrayList.size(); } }
2dc00bbd3e8ce946e0e4a798dea3e6fcf6b056df
22dc9e37b6e14878c9aae01d310ad1cba0c6b43e
/src/main/java/com/hoolai/bi/excel/AbstractWriter.java
fb15398b07c5f1578ed57c445c4ce9c9f938a13c
[]
no_license
Ksssssssss/excelutil
a51f1ea7b6b257acaa80a551fd78fab59dda8973
c01f626979591559842a71de8c0464abab2e3d50
refs/heads/master
2021-08-06T15:34:12.182370
2020-08-24T06:35:59
2020-08-24T06:35:59
213,542,989
0
0
null
null
null
null
UTF-8
Java
false
false
787
java
package com.hoolai.bi.excel; import com.alibaba.excel.ExcelWriter; import com.hoolai.bi.entiy.QueryInfo; /** * @description: * @author: Ksssss(chenlin @ hoolai.com) * @time: 2019-10-16 10:10 */ public abstract class AbstractWriter { public abstract void write(int index, ExcelWriter excelWriter, QueryInfo info); public abstract ExcelDatas produceDatas(QueryInfo info); public static class CategoryWriter{ public CategoryWriter() {} public void categoryWrite(int index, ExcelWriter excelWriter, QueryInfo info, AbstractWriter[] writers){ if (writers.length<=0){ return; } for (AbstractWriter writer:writers) { writer.write(index, excelWriter, info); } } } }
751f5374144e485dc75fc48b4e2872698eddc240
99c63774ee82050778dedc04ee91e7e22357f265
/src/com/original/sort/TestGuess2.java
d429bf46b809d7b0876e18519d7de5273fd0d633
[]
no_license
jueqingsizhe66/TestGtk
f1746e5898cde9033601cea8a956f3d18c6eadf1
09c1625b26df3726b95cf51856c644436e651dab
refs/heads/master
2021-01-23T16:43:29.454239
2015-03-25T01:49:17
2015-03-25T01:49:17
29,845,235
0
0
null
null
null
null
GB18030
Java
false
false
2,029
java
/** * */ package com.original.sort; /** * @author 叶昭良 * @time 2015年2月27日下午12:54:06 * @version com.original.sortTestGuess2 V1.0 */ import java.util.*; public class TestGuess2 { /** * @param args */ public static int count = 0; public static int p=0;//平的次数 public static int q=0;//你赢的次数 public static int r=0;//电脑赢的次数 public static String[] result=new String[50]; public static void main(String[] args) { /* for(int i =0 ; i < 10; i++) { System.out.println(Math.random()); }*/ // TODO Auto-generated method stub System.out.println("你想和电脑猜拳嘛?想的话输入 0 1 2 0代表石头 1代表剪刀 2代表布"); Scanner sr = new Scanner(System.in); Random rand = new Random(System.currentTimeMillis()); int i = 0; int j = 0; while(true){ System.out.println("你想好了,出什么?(0石头,1剪刀,2布)"); i = sr.nextInt();//i存储你出的值~ j存储电脑出的值 //如何产生正确的随机数? // int j = (int)Math.random()*3%3; j = Math.abs(rand.nextInt()%3); if(i == j){ p++; result[count] = "你出的:"+i+" 电脑出的"+j+"\n两者打平\n"; System.out.println("两者打平!"); }else if((i-j) == -1 || (i-j)==2){ q++; result[count] ="你出的:"+i+" 电脑出的"+j+"\n恭喜你赢了\n"; System.out.println("恭喜你赢了!"); }else{ r++; result[count] = "你出的:"+i+" 电脑出的"+j+"\n电脑赢了\n"; System.out.println("两者打平!"); } System.out.println("还想再来吗? a再来 n不来(其实你输入a都是不来)"); String k = sr.next(); if(k.equals("a")){ } else{ break; } count++; } System.out.println("打平了"+p+"次"+"你赢了"+q+"次"+"电脑赢了"+r+"次"); System.out.println("记录清单"); for(int i1 = 0 ; i1<count;i1++){ System.out.println(result[i1]); } } }
e6d9b8073554c54510177bbeebc0740e578db6ce
af606a04ed291e8c9b1e500739106a926e205ee2
/aliyun-java-sdk-miniapplcdp/src/main/java/com/aliyuncs/miniapplcdp/model/v20200113/UpdateResourceContentResponse.java
467a01dc97ec250a28b6b9558cd96fa4cdcd9560
[ "Apache-2.0" ]
permissive
xtlGitHub/aliyun-openapi-java-sdk
a733f0a16c8cc493cc28062751290f563ab73ace
f60c71de2c9277932b6549c79631b0f03b11cc36
refs/heads/master
2023-09-03T13:56:50.071024
2021-11-10T11:53:25
2021-11-10T11:53:25
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,840
java
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.aliyuncs.miniapplcdp.model.v20200113; import java.util.Map; import com.aliyuncs.AcsResponse; import com.aliyuncs.miniapplcdp.transform.v20200113.UpdateResourceContentResponseUnmarshaller; import com.aliyuncs.transform.UnmarshallerContext; /** * @author auto create * @version */ public class UpdateResourceContentResponse extends AcsResponse { private String requestId; private Data data; public String getRequestId() { return this.requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public Data getData() { return this.data; } public void setData(Data data) { this.data = data; } public static class Data { private String moduleId; private String createTime; private Integer revision; private String modifiedTime; private String resourceType; private String description; private String schemaVersion; private String appId; private String scope; private String resourceId; private Map<Object,Object> content; private String resourceName; public String getModuleId() { return this.moduleId; } public void setModuleId(String moduleId) { this.moduleId = moduleId; } public String getCreateTime() { return this.createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public Integer getRevision() { return this.revision; } public void setRevision(Integer revision) { this.revision = revision; } public String getModifiedTime() { return this.modifiedTime; } public void setModifiedTime(String modifiedTime) { this.modifiedTime = modifiedTime; } public String getResourceType() { return this.resourceType; } public void setResourceType(String resourceType) { this.resourceType = resourceType; } public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public String getSchemaVersion() { return this.schemaVersion; } public void setSchemaVersion(String schemaVersion) { this.schemaVersion = schemaVersion; } public String getAppId() { return this.appId; } public void setAppId(String appId) { this.appId = appId; } public String getScope() { return this.scope; } public void setScope(String scope) { this.scope = scope; } public String getResourceId() { return this.resourceId; } public void setResourceId(String resourceId) { this.resourceId = resourceId; } public Map<Object,Object> getContent() { return this.content; } public void setContent(Map<Object,Object> content) { this.content = content; } public String getResourceName() { return this.resourceName; } public void setResourceName(String resourceName) { this.resourceName = resourceName; } } @Override public UpdateResourceContentResponse getInstance(UnmarshallerContext context) { return UpdateResourceContentResponseUnmarshaller.unmarshall(this, context); } @Override public boolean checkShowJsonItemName() { return false; } }
ef5acab82bd3105b8a9f05c181d0645599b18604
6d43482edcf03700fcc83cc5896ec5a36793d9b6
/src/main/java/seedu/address/ui/InventoryPanel.java
46efde4a4eebcfbe9264a7d612071b90a42dcba8
[ "MIT" ]
permissive
shanecsj/main
5463ce8cd1d3a231b0fc1f4202b8dac2a1611263
bda6d656b7771203aeeedb1b51cc5a0f4ad14d9c
refs/heads/master
2021-01-07T18:16:50.687161
2020-04-13T13:24:24
2020-04-13T13:24:24
241,780,121
0
1
NOASSERTION
2020-04-12T05:41:29
2020-02-20T03:02:33
Java
UTF-8
Java
false
false
1,376
java
package seedu.address.ui; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.layout.Region; // import seedu.address.commons.core.LogsCenter; import seedu.address.model.ingredient.Ingredient; /** * Panel containing the list of ingredients. */ public class InventoryPanel extends UiPart<Region> { private static final String FXML = "InventoryPanel.fxml"; @FXML private ListView<Ingredient> inventoryListView; public InventoryPanel(ObservableList<Ingredient> ingredientList) { super(FXML); inventoryListView.setItems(ingredientList); inventoryListView.setCellFactory(listView -> new IngredientListViewCell()); } /** * Custom {@code ListCell} displays the graphics of a {@code UniqueIngredientList} using {@code IngredientCard}. */ static class IngredientListViewCell extends ListCell<Ingredient> { @Override protected void updateItem(Ingredient ingredient, boolean isEmpty) { super.updateItem(ingredient, isEmpty); if (isEmpty || ingredient == null) { setGraphic(null); setText(null); } else { setGraphic(new IngredientCard(ingredient, getIndex() + 1).getRoot()); } } } }
2765aa87da05f17b16932be0144b7a889ed3c8de
6ff7c0f40a85af119013c4aa1c423dda2860be13
/src/catchup_8/FunInterface.java
ca8d62f999b3949d111b590c3decab13384a159f
[]
no_license
juno1985/Softcits201909
89a6691ec6f380d6b8326b2bb6d156f3b306b7d4
a8d19f7b00ac2cf19aea4857866c4df63c80e792
refs/heads/master
2021-06-21T05:12:29.066975
2021-05-09T08:17:44
2021-05-09T08:17:44
211,429,217
1
5
null
null
null
null
UTF-8
Java
false
false
210
java
package catchup_8; @FunctionalInterface public interface FunInterface { static void foo(){ System.out.println("foo"); } default void bar(){ System.out.println("bar"); } void test(); // void test2(); }
9c09f5133ec113aaf07aa9288d724e2f97759897
edae0e9f74f11c28d7a2dbb352ec3236a3a9ad29
/FileIO.java
71ec4d0231a1e41440e6cb372d09a76decf31a79
[]
no_license
namrepus317/MarkX
4f3d98e9c7ccf72e747ffc574aa1076bf85636a8
2ba99cf762a9ca71e956e8d0c9adf6f9a7a197ee
refs/heads/master
2021-09-01T01:25:27.222096
2017-12-24T04:22:26
2017-12-24T04:22:26
115,239,436
0
0
null
null
null
null
UTF-8
Java
false
false
1,498
java
package com.example.christopher.markx; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.util.Log; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; public class FileIO { private String fileName; private FileInputStream fis; private FileOutputStream fos; private ObjectInputStream ois; private ObjectOutputStream oos; private Context appContext; public void writeSaveData(Object object){ try{ fos = appContext.openFileOutput(fileName, Context.MODE_PRIVATE); oos = new ObjectOutputStream(fos); oos.writeObject(object); oos.close(); fos.close(); } catch (Exception e){ e.printStackTrace(); } } public Object getSaveData(){ Object obj = null; try{ fis = appContext.openFileInput(fileName); ois = new ObjectInputStream(fis); obj = ois.readObject(); ois.close(); fis.close(); } catch(Exception e){ e.printStackTrace(); } return obj; } public FileIO(Context context, String fileName){ this.appContext = context; this.fileName = fileName; } }
2357c86c939529293cd4b7ceff2f43970eb48294
1981d027d424150606f0da6c83f5785961cc0304
/src/test/java/net/onedaybeard/kbdluv/component/ComponentB.java
c558462b102ed7511e35d732631775dacc0f3681
[]
no_license
junkdog/kbdluv
0a32f668372e4c9d89bb55ca98400495c6c4614a
830e4fb62cc767e15dff2d194ab0043ecda54ad7
refs/heads/master
2021-01-21T04:47:08.105402
2016-07-28T00:30:27
2016-07-28T00:30:27
53,223,111
6
0
null
null
null
null
UTF-8
Java
false
false
120
java
package net.onedaybeard.kbdluv.component; import com.artemis.Component; public class ComponentB extends Component { }
da22aef88859c253ae1a87434dc40bde48fa8150
cdc955a72f75451d0f38c6a89358a96c7adf7c68
/base_cpu-master/src/ventanas/Adjuntos.java
9092b21333ac911bf4e983815b3273263e05048d
[]
no_license
crocha2/netcpu
d90ad4dda84eaec953f94ae4c810c27c8fc4694f
ba97036dd64510d1a45461112e0ca5f859f7d5c2
refs/heads/master
2021-01-23T00:48:36.449548
2018-01-16T21:15:34
2018-01-16T21:15:34
92,842,465
0
0
null
null
null
null
UTF-8
Java
false
false
21,049
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 ventanas; import clasesPrincipales.Entradas; import clasesPrincipales.imagen; import conMySql.conector; import conMySql.entradaMySql; import java.awt.HeadlessException; import java.awt.Image; import java.io.FileInputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import reportes.GenerarReportes; /** * * @author Administrador */ public class Adjuntos extends javax.swing.JFrame { private FileInputStream fis; private int longitudBytes; ArrayList<Entradas> entrada; entradaMySql dbEntrada = new entradaMySql(); /** * Creates new form Adjuntos */ public Adjuntos() { initComponents(); this.setLocationRelativeTo(null); this.setResizable(false); this.setTitle("CPU System Service S.A.S - ADJUNTAR"); CargarCmbEntrada(); txtIdEntrada.setEnabled(false); txtCliente.setEnabled(false); txtFecha.setEnabled(false); txtModelo.setEnabled(false); txtSerie.setEnabled(false); btnSeleccionar.setVisible(false); btnGuardar.setVisible(false); lblFoto.setVisible(false); } public void CargarCmbEntrada() { try { Connection cnx = DriverManager.getConnection("jdbc:mysql://69.73.129.251:3306/cpusysc1_cpudb", "cpusysc1_root", "c8020123496"); Statement st = cnx.createStatement(); ResultSet rs = st.executeQuery("SELECT numero FROM entradas ORDER BY numero DESC"); while (rs.next()) { this.cmbEntradas.addItem(rs.getString("numero")); } } catch (Exception e) { } } public void limpiar() { txtIdEntrada.setText(""); txtCliente.setText(""); txtFecha.setText(""); txtModelo.setText(""); txtSerie.setText(""); lblFoto.setText(null); btnSeleccionar.setVisible(false); btnGuardar.setVisible(false); lblFoto.setVisible(false); } public void habilitar() { btnSeleccionar.setVisible(true); btnGuardar.setVisible(true); lblFoto.setVisible(true); } public boolean validarImagen(int id) throws SQLException { boolean respuesta = false; conector obj = new conector(); imagen ima = new imagen(); //Connection cn = DriverManager.getConnection("jdbc:mysql://69.73.129.251:3306/cpusysc1_cpudb", "cpusysc1_root", "c8020123496"); PreparedStatement pst = obj.con.prepareStatement("Select id_entra From imagenes Where id_entra = ?"); pst.setInt(1, ima.getId_entra()); ResultSet rs = pst.executeQuery(); if (rs.next()) { int id_en = rs.getInt("id_entra"); int id_entrada = id; if (id_en == id_entrada) { respuesta = true; } else { respuesta = false; } //boolean res = respuesta; } return respuesta; } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jSeparator7 = new javax.swing.JSeparator(); jLabel13 = new javax.swing.JLabel(); txtCliente = new javax.swing.JTextField(); cmbEntradas = new javax.swing.JComboBox(); btnBusca = new javax.swing.JButton(); jLabel14 = new javax.swing.JLabel(); txtIdEntrada = new javax.swing.JTextField(); jLabel15 = new javax.swing.JLabel(); txtSerie = new javax.swing.JTextField(); txtModelo = new javax.swing.JTextField(); jLabel16 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); btnGuardar = new javax.swing.JButton(); txtFecha = new javax.swing.JTextField(); jLabel18 = new javax.swing.JLabel(); lblFoto = new javax.swing.JLabel(); btnSeleccionar = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); jPanel2.setBackground(new java.awt.Color(0, 153, 102)); jPanel2.setLayout(null); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 255, 255)); jLabel2.setText("ADJUNTAR ENTRADA"); jPanel2.add(jLabel2); jLabel2.setBounds(10, 11, 280, 29); jPanel2.add(jSeparator7); jSeparator7.setBounds(10, 41, 420, 10); jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel13.setForeground(new java.awt.Color(255, 255, 255)); jLabel13.setText("Fecha"); jPanel2.add(jLabel13); jLabel13.setBounds(290, 60, 60, 14); jPanel2.add(txtCliente); txtCliente.setBounds(30, 140, 290, 30); cmbEntradas.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cmbEntradasActionPerformed(evt); } }); jPanel2.add(cmbEntradas); cmbEntradas.setBounds(30, 80, 160, 30); btnBusca.setBackground(new java.awt.Color(255, 255, 255)); btnBusca.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnBusca.setForeground(new java.awt.Color(255, 255, 255)); btnBusca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/lupa2.png"))); // NOI18N btnBusca.setBorder(null); btnBusca.setBorderPainted(false); btnBusca.setContentAreaFilled(false); btnBusca.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnBusca.setIconTextGap(-1); btnBusca.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); btnBusca.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnBusca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBuscaActionPerformed(evt); } }); jPanel2.add(btnBusca); btnBusca.setBounds(200, 70, 33, 33); jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel14.setForeground(new java.awt.Color(255, 255, 255)); jLabel14.setText("ID"); jPanel2.add(jLabel14); jLabel14.setBounds(350, 120, 60, 14); jPanel2.add(txtIdEntrada); txtIdEntrada.setBounds(350, 140, 70, 30); jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel15.setForeground(new java.awt.Color(255, 255, 255)); jLabel15.setText("SERIE"); jPanel2.add(jLabel15); jLabel15.setBounds(240, 180, 60, 14); jPanel2.add(txtSerie); txtSerie.setBounds(240, 200, 180, 30); jPanel2.add(txtModelo); txtModelo.setBounds(30, 200, 180, 30); jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel16.setForeground(new java.awt.Color(255, 255, 255)); jLabel16.setText("CLIENTE"); jPanel2.add(jLabel16); jLabel16.setBounds(30, 120, 60, 14); jLabel17.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel17.setForeground(new java.awt.Color(255, 255, 255)); jLabel17.setText("MODELO"); jPanel2.add(jLabel17); jLabel17.setBounds(30, 180, 60, 14); btnGuardar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N btnGuardar.setText("GUARDAR"); btnGuardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGuardarActionPerformed(evt); } }); jPanel2.add(btnGuardar); btnGuardar.setBounds(300, 300, 120, 40); jPanel2.add(txtFecha); txtFecha.setBounds(290, 80, 130, 30); jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel18.setForeground(new java.awt.Color(255, 255, 255)); jLabel18.setText("ENTRADAS"); jPanel2.add(jLabel18); jLabel18.setBounds(30, 60, 60, 14); lblFoto.setBackground(new java.awt.Color(204, 204, 204)); lblFoto.setForeground(new java.awt.Color(204, 204, 204)); lblFoto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); lblFoto.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { lblFotoMouseClicked(evt); } }); jPanel2.add(lblFoto); lblFoto.setBounds(30, 260, 260, 240); btnSeleccionar.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N btnSeleccionar.setText("Seleccionar..."); btnSeleccionar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSeleccionarActionPerformed(evt); } }); jPanel2.add(btnSeleccionar); btnSeleccionar.setBounds(300, 260, 120, 30); jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jButton1.setText("GENERAR"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel2.add(jButton1); jButton1.setBounds(303, 463, 120, 40); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 448, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 535, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void cmbEntradasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbEntradasActionPerformed // TODO add your handling code here: }//GEN-LAST:event_cmbEntradasActionPerformed private void btnBuscaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscaActionPerformed //(FECHA, ELEMENTO, POTENCIA, MARCA, MODELO, SERIE, EMPRESA, NIT, PERSONA_REMITE, CIUDAD, DIRECCION, NOMBRE_CONTACTO, TELEFONO_CONTACTO, CORREO, MOTIVO, TARJETA_RED, PARRILLA, BASES_PLASTICAS, CONECTOR_ORIGI, GARANTIA, ESTADO_CARCASA, OBSERVACIONES) try { String guardar = cmbEntradas.getSelectedItem().toString(); Connection cn = DriverManager.getConnection("jdbc:mysql://69.73.129.251:3306/cpusysc1_cpudb", "cpusysc1_root", "c8020123496"); Statement st = cn.createStatement(); //PreparedStatement pst = cn.prepareStatement("SELECT numero, fecha, elemento, potencia, marca, modelo, serie, empresa, nit, persona_remite, ciudad, direccion, contacto, telefono, correo, motivo, parrilla, bases_plas, conector_ori, garantia, estado_car, observaciones, tarjeta FROM entradas where numero = ? ORDER BY 2"); PreparedStatement pst = cn.prepareStatement("Select * from entradas where numero = ?"); pst.setString(1, guardar); //pst.setString(1, CMBID.getName()); ResultSet rs = pst.executeQuery(); if (rs.next()) { txtFecha.setText(rs.getString("fecha").trim()); txtCliente.setText(rs.getString("empresa").trim()); txtModelo.setText(rs.getString("modelo").trim()); txtSerie.setText(rs.getString("serie").trim()); txtIdEntrada.setText(rs.getString("id_entra")); habilitar(); //pst.setString(1, CMBID.getName()); //String guardar = txtBuscar.getText(); } else { JOptionPane.showMessageDialog(null, "No existe la remision"); } cn.close(); st.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "error:" + ex.getMessage()); } // TODO add your handling code here: }//GEN-LAST:event_btnBuscaActionPerformed private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGuardarActionPerformed if (txtIdEntrada.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Debe seleccionar un registro"); } try { boolean respuesta = false; conector obj = new conector(); //imagen ima = new imagen(); int id = Integer.parseInt(txtIdEntrada.getText()); PreparedStatement pst = obj.con.prepareStatement("Select id_entra From imagenes Where id_entra = ?"); pst.setInt(1, id); ResultSet rs = pst.executeQuery(); if (rs.next()) { int id_en_db = rs.getInt("id_entra"); //int id_entrada = Integer.parseInt(txtIdEntrada.getText()); if (id_en_db == id) { respuesta = true; } else { respuesta = false; } //boolean res = respuesta; if (respuesta == true) { JOptionPane.showMessageDialog(this, "Este registro ya tiene imagen asignada"); } else { try { imagen ima = new imagen(this.cmbEntradas.getSelectedItem().toString(), this.fis, this.longitudBytes, Integer.parseInt(txtIdEntrada.getText())); // imagen ima = new imagen(this.fis, this.longitudBytes, Integer.parseInt(txtIdEntrada.getText())); //ima.setNombre(this.txtNombreImagen.getText()); //ima.setImagen(this.fis); //ima.setImagen(this.longitudBytes); dbEntrada.adjuntarImagenINSERT(ima); limpiar(); lblFoto.setText(null); } catch (NumberFormatException | HeadlessException e) { JOptionPane.showMessageDialog(this, "error" + e.getMessage()); } } } } catch (SQLException | NumberFormatException e) { JOptionPane.showMessageDialog(this, "error" + e.getMessage()); } //Connection cn = DriverManager.getConnection("jdbc:mysql://69.73.129.251:3306/cpusysc1_cpudb", "cpusysc1_root", "c8020123496"); }//GEN-LAST:event_btnGuardarActionPerformed private void lblFotoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblFotoMouseClicked // TODO add your handling code here: }//GEN-LAST:event_lblFotoMouseClicked private void btnSeleccionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSeleccionarActionPerformed if (txtIdEntrada.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Debes seleccionar un registro ENTRADAS"); } else { JFileChooser se = new JFileChooser(); se.setFileSelectionMode(JFileChooser.FILES_ONLY); // seleccionar solo archivos.. int estado = se.showOpenDialog(null);// mostrar el cuadro de archivo.. if (estado == JFileChooser.APPROVE_OPTION) { // si el usuario selecciono el archivo y dio ACEPTAR.. try { fis = new FileInputStream(se.getSelectedFile()); this.longitudBytes = (int) se.getSelectedFile().length(); //Dimenciona la imagen a la dimencion del label "lblFoto" /* Image icono = ImageIO.read(se.getSelectedFile()).getScaledInstance(lblFoto.getWidth(), lblFoto.getHeight(), Image.SCALE_DEFAULT); lblFoto.setIcon(new ImageIcon(icono)); lblFoto.updateUI(); */ Image icono = ImageIO.read(se.getSelectedFile()).getScaledInstance(lblFoto.getWidth(), lblFoto.getHeight(), Image.SCALE_DEFAULT); lblFoto.setIcon(new ImageIcon(icono)); lblFoto.updateUI(); } catch (Exception e) { System.out.println("error" + e); } } } // TODO add your handling code here: }//GEN-LAST:event_btnSeleccionarActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed if (txtIdEntrada.getText().isEmpty()) { JOptionPane.showMessageDialog(this, "Debe seleccionar un registro"); } else { String nume = txtIdEntrada.getText(); int id = Integer.parseInt(nume); GenerarReportes g = new GenerarReportes(); g.reporteIMAGEN(id); } // TODO add your handling code here: }//GEN-LAST:event_jButton1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Adjuntos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Adjuntos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Adjuntos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Adjuntos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Adjuntos().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnBusca; private javax.swing.JButton btnGuardar; private javax.swing.JButton btnSeleccionar; private javax.swing.JComboBox cmbEntradas; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel2; private javax.swing.JSeparator jSeparator7; private javax.swing.JLabel lblFoto; private javax.swing.JTextField txtCliente; private javax.swing.JTextField txtFecha; private javax.swing.JTextField txtIdEntrada; private javax.swing.JTextField txtModelo; private javax.swing.JTextField txtSerie; // End of variables declaration//GEN-END:variables }
[ "“[email protected]”" ]
40812f7d91d7c44a2282e3cea1f685986ad791c4
5cc19bf2c6569aa96e2d2cefbbdf6e7d6c277f0c
/18/cn/com/cnc/fcc/domain/QmsInspectionDetails.java
ee348ce4e21eb68318de9018cb6a8d3363a1701e
[]
no_license
MicroRefact/coolweatherMs
3e5f5a163bdebe4cf5557764f2a5e9cf50d40040
c647d3801648cf49f363b6802e2b07e013d454d6
refs/heads/main
2023-05-01T14:27:43.427774
2021-05-26T00:23:54
2021-05-26T00:23:54
370,861,247
0
0
null
null
null
null
UTF-8
Java
false
false
6,614
java
import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import javax.persistence; import javax.validation.constraints; import java.io.Serializable; import java.time.ZonedDateTime; import java.util.Objects; @Entity @Table(name = "qms_inspection_details") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class QmsInspectionDetails implements Serializable{ private long serialVersionUID; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(name = "inspection_id") private Integer inspectionId; @Size(max = 1) @Column(name = "inspection_diff", length = 1) private String inspectionDiff; @Size(max = 10) @Column(name = "place_diff", length = 10) private String placeDiff; @Size(max = 40) @Column(name = "test_value", length = 40) private String testValue; @Size(max = 1) @Column(name = "flag_status", length = 1) private String flagStatus; @Size(max = 10) @Column(name = "comp_pkid", length = 10) private String compPkid; @Size(max = 200) @Column(name = "remark", length = 200) private String remark; @Size(max = 20) @Column(name = "reserve_first", length = 20) private String reserveFirst; @Size(max = 20) @Column(name = "reserve_second", length = 20) private String reserveSecond; @Size(max = 20) @Column(name = "reserve_third", length = 20) private String reserveThird; @Size(max = 10) @Column(name = "make_user", length = 10) private String makeUser; @Column(name = "make_time") private ZonedDateTime makeTime; @Size(max = 10) @Column(name = "modify_user", length = 10) private String modifyUser; @Column(name = "modify_time") private ZonedDateTime modifyTime; public QmsInspectionDetails inspectionDiff(String inspectionDiff){ this.inspectionDiff = inspectionDiff; return this; } public String getTestValue(){ return testValue; } public Long getId(){ return id; } public QmsInspectionDetails remark(String remark){ this.remark = remark; return this; } public QmsInspectionDetails reserveFirst(String reserveFirst){ this.reserveFirst = reserveFirst; return this; } public String getMakeUser(){ return makeUser; } public void setCompPkid(String compPkid){ this.compPkid = compPkid; } public String getPlaceDiff(){ return placeDiff; } public QmsInspectionDetails reserveSecond(String reserveSecond){ this.reserveSecond = reserveSecond; return this; } public void setReserveFirst(String reserveFirst){ this.reserveFirst = reserveFirst; } public QmsInspectionDetails modifyUser(String modifyUser){ this.modifyUser = modifyUser; return this; } public void setReserveThird(String reserveThird){ this.reserveThird = reserveThird; } public QmsInspectionDetails modifyTime(ZonedDateTime modifyTime){ this.modifyTime = modifyTime; return this; } public String getReserveThird(){ return reserveThird; } public void setRemark(String remark){ this.remark = remark; } public ZonedDateTime getMakeTime(){ return makeTime; } @Override public int hashCode(){ return Objects.hashCode(getId()); } public String getRemark(){ return remark; } public void setId(Long id){ this.id = id; } public String getReserveFirst(){ return reserveFirst; } public void setReserveSecond(String reserveSecond){ this.reserveSecond = reserveSecond; } public QmsInspectionDetails testValue(String testValue){ this.testValue = testValue; return this; } public void setTestValue(String testValue){ this.testValue = testValue; } public void setMakeTime(ZonedDateTime makeTime){ this.makeTime = makeTime; } public String getReserveSecond(){ return reserveSecond; } public void setPlaceDiff(String placeDiff){ this.placeDiff = placeDiff; } public void setMakeUser(String makeUser){ this.makeUser = makeUser; } public QmsInspectionDetails placeDiff(String placeDiff){ this.placeDiff = placeDiff; return this; } public void setInspectionId(Integer inspectionId){ this.inspectionId = inspectionId; } public QmsInspectionDetails reserveThird(String reserveThird){ this.reserveThird = reserveThird; return this; } public ZonedDateTime getModifyTime(){ return modifyTime; } public String getCompPkid(){ return compPkid; } public void setFlagStatus(String flagStatus){ this.flagStatus = flagStatus; } public String getModifyUser(){ return modifyUser; } public void setModifyTime(ZonedDateTime modifyTime){ this.modifyTime = modifyTime; } public QmsInspectionDetails makeTime(ZonedDateTime makeTime){ this.makeTime = makeTime; return this; } public QmsInspectionDetails inspectionId(Integer inspectionId){ this.inspectionId = inspectionId; return this; } public QmsInspectionDetails makeUser(String makeUser){ this.makeUser = makeUser; return this; } public Integer getInspectionId(){ return inspectionId; } public void setInspectionDiff(String inspectionDiff){ this.inspectionDiff = inspectionDiff; } public QmsInspectionDetails flagStatus(String flagStatus){ this.flagStatus = flagStatus; return this; } @Override public boolean equals(Object o){ if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } QmsInspectionDetails qmsInspectionDetails = (QmsInspectionDetails) o; if (qmsInspectionDetails.getId() == null || getId() == null) { return false; } return Objects.equals(getId(), qmsInspectionDetails.getId()); } public String getInspectionDiff(){ return inspectionDiff; } @Override public String toString(){ return "QmsInspectionDetails{" + "id=" + getId() + ", inspectionId=" + getInspectionId() + ", inspectionDiff='" + getInspectionDiff() + "'" + ", placeDiff='" + getPlaceDiff() + "'" + ", testValue='" + getTestValue() + "'" + ", flagStatus='" + getFlagStatus() + "'" + ", compPkid='" + getCompPkid() + "'" + ", remark='" + getRemark() + "'" + ", reserveFirst='" + getReserveFirst() + "'" + ", reserveSecond='" + getReserveSecond() + "'" + ", reserveThird='" + getReserveThird() + "'" + ", makeUser='" + getMakeUser() + "'" + ", makeTime='" + getMakeTime() + "'" + ", modifyUser='" + getModifyUser() + "'" + ", modifyTime='" + getModifyTime() + "'" + "}"; } public String getFlagStatus(){ return flagStatus; } public QmsInspectionDetails compPkid(String compPkid){ this.compPkid = compPkid; return this; } public void setModifyUser(String modifyUser){ this.modifyUser = modifyUser; } }
a794f96b1b46376bd4872aac8f5b5b0f9d600581
499b752380efa2a2ad6644234a0cb3850aced56d
/app/src/main/java/libwy/symbio/com/mybuying/di/modules/AppModule.java
da1d21e447fca4b386b4d2644870038bd97b5c8d
[]
no_license
wilbyang/MyBuying
cfa073c718a4657991b40e86e02ace6de050d9fd
65ee61dce2a3e66c6670e394f0bfa34cc1088db4
refs/heads/master
2021-01-15T15:42:38.260971
2016-09-20T12:54:26
2016-09-20T12:54:26
52,656,514
0
0
null
null
null
null
UTF-8
Java
false
false
421
java
package libwy.symbio.com.mybuying.di.modules; import android.app.Application; import javax.inject.Singleton; import dagger.Module; import dagger.Provides; @Module public class AppModule { Application mApplication; public AppModule(Application application) { mApplication = application; } @Provides @Singleton Application providesApplication() { return mApplication; } }
3e2b166a9321ec2e9de1a821795a442c195af422
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/10/10_3ee88c338f06bdff3401aaa55a2dcd05d5de1c25/Warrior/10_3ee88c338f06bdff3401aaa55a2dcd05d5de1c25_Warrior_s.java
39ee1fc13354ed43ffc4457ee0368038f80e4d08
[]
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
14,870
java
package fr.utbm.vi51.agent; import java.util.List; import org.janusproject.kernel.status.Status; import org.janusproject.kernel.status.StatusFactory; import fr.utbm.vi51.configs.Consts; import fr.utbm.vi51.environment.Direction; import fr.utbm.vi51.environment.DropFood; import fr.utbm.vi51.environment.EatFood; import fr.utbm.vi51.environment.Food; import fr.utbm.vi51.environment.InsectBody; import fr.utbm.vi51.environment.KillEnemy; import fr.utbm.vi51.environment.Message; import fr.utbm.vi51.environment.Move; import fr.utbm.vi51.environment.Perception; import fr.utbm.vi51.environment.Pheromone; import fr.utbm.vi51.environment.Side; import fr.utbm.vi51.environment.Square; import fr.utbm.vi51.environment.WorldObject; import fr.utbm.vi51.util.PathFinder; import fr.utbm.vi51.util.Point3D; enum WarriorBehaviour { GO_HOME, PATROL, FIGHT, } /** * @author Top-K * */ public class Warrior extends Ant { private WarriorBehaviour currentBehaviour; private Point3D lastPosition; private Point3D relativeStartingPointPosition; // Remembers the position of private static final int attackPoints = 1; public Warrior(Point3D position, int speed, Side side) { super(side.getWarriorTexture(), position, speed, side); currentBehaviour = WarriorBehaviour.PATROL; } @Override public Status activate(Object... params) { lastTime = this.getTimeManager().getCurrentDate().getTime(); return StatusFactory.ok(this); } @Override public Status live() { super.live(); InsectBody body = this.getBody(); //If their is no body, the agent is waiting to die if (body == null) { return null; } // If an action is already planned, wait for it to be resolved if (body.getAction() != null) { return null; } // Worker will only act every ANTACTIONDELAY milliseconds if (this.getTimeManager().getCurrentDate().getTime() - lastTime < Consts.ANTACTIONDELAY && lastTime != 0) { return null; } if (relativeStartingPointPosition != null) { relativeStartingPointPosition.x -= body.getPosition().x - lastPosition.x; relativeStartingPointPosition.y -= body.getPosition().y - lastPosition.y; } lastPosition = new Point3D(body.getPosition()); Perception currentPerception = this.getBody().getPerception(); /*if (dropPheromoneIfNeeded()) { return null; }*/ if (body.isHungry()) { if (body.getCarriedObject() instanceof Food) { body.setAction(new EatFood(body)); lastTime = this.getTimeManager().getCurrentDate().getTime(); return null; } currentBehaviour = WarriorBehaviour.GO_HOME; } switch (currentBehaviour) { case GO_HOME: goHome(); break; case PATROL: patrol(); break; case FIGHT: fight(); break; default: break; } if (movementPath != null && !movementPath.isEmpty()) { lastTime = this.getTimeManager().getCurrentDate().getTime(); Move m = new Move(body, movementPath.removeFirst()); body.setAction(m); return null; } /* * If after behavior functions, no action has been defined and movement * path is empty, the worker doesn't know what to do, so move randomly . */ if (body.getAction() == null && (movementPath == null || movementPath.isEmpty())) { Square[][][] perceivedMap = currentPerception.getPerceivedMap(); // Find a crossable square int x; int y; do { x = (int) Math.floor(Math.random() * perceivedMap.length); y = (int) Math.floor(Math.random() * perceivedMap[0].length); } while (!perceivedMap[x][y][0].getLandType().isCrossable()); movementPath = PathFinder.findPath(currentPerception .getPositionInPerceivedMap(), new Point3D(x, y, 0), perceivedMap); } return null; } private void goHome() { Perception currentPerception = this.getBody().getPerception(); Square[][][] perceivedMap = currentPerception.getPerceivedMap(); Pheromone currentBestPheromone = null; Point3D currentBestPheromonePositionInPerceivedMap = null; // If the body is carrying food and we are on the queen's square, drop // the food // If the body is hungry and there is food on the same square, eat it for (WorldObject wo : perceivedMap[currentPerception .getPositionInPerceivedMap().x][currentPerception .getPositionInPerceivedMap().y][0].getObjects()) { if (this.getBody().isHungry() && wo instanceof Food) { this.getBody().setAction(new EatFood(this.getBody())); return; } if (!this.getBody().isHungry() && wo.getTexturePath().equals( this.getBody().getSide().getQueenTexture())) { if (this.getBody().getCarriedObject() != null) { this.getBody().setAction(new DropFood(this.getBody())); } currentBehaviour = WarriorBehaviour.PATROL; relativeStartingPointPosition = new Point3D(0, 0, 0); return; } } // Look for the queen, for home pheromones, or if hungry for food for (int i = 0; i < perceivedMap.length; ++i) { for (int j = 0; j < perceivedMap[0].length; ++j) { List<WorldObject> objects = perceivedMap[i][j][0].getObjects(); synchronized (objects) { for (WorldObject wo : objects) { if (wo.getTexturePath().equals( this.getBody().getSide().getQueenTexture())) { movementPath = PathFinder.findPath( currentPerception .getPositionInPerceivedMap(), new Point3D(i, j, 0), perceivedMap); return; } else if (wo instanceof Pheromone) { Pheromone p = (Pheromone) wo; if (p.getMessage() == Message.HOME && p.getSide().equals( this.getBody().getSide())) { currentBestPheromone = Pheromone .closestToSubject(p, currentBestPheromone); if (currentBestPheromone == p) { currentBestPheromonePositionInPerceivedMap = new Point3D( i, j, 0); } } } else if (this.getBody().isHungry() && wo instanceof Food) { movementPath = PathFinder.findPath( currentPerception .getPositionInPerceivedMap(), new Point3D(i, j, 0), perceivedMap); return; } } } } } if (currentBestPheromone != null && currentBestPheromonePositionInPerceivedMap != null) { movementPath = PathFinder.findPath( //TODO c'était ici que currentBestPheromoneblbla était null currentPerception.getPositionInPerceivedMap(), currentBestPheromonePositionInPerceivedMap, perceivedMap); } } private void patrol() { Perception p = this.getBody().getPerception(); Square[][][] perceivedMap = p.getPerceivedMap(); Point3D positionInPerceivedMap = p.getPositionInPerceivedMap(); InsectBody enemyBody = null; Point3D enemyPositionInPerceivedMap = null; for (int i = 0; i < perceivedMap.length && enemyBody == null; ++i) { for (int j = 0; j < perceivedMap[0].length && enemyBody == null; ++j) { List<WorldObject> objectsPerceived = perceivedMap[i][j][0] .getObjects(); for (WorldObject wo : objectsPerceived) { if (wo instanceof InsectBody) { InsectBody ib = (InsectBody) wo; if (!ib.getSide().equals(this.getBody().getSide())) { enemyBody = ib; enemyPositionInPerceivedMap = new Point3D(i,j,0); break; } } } } } if(enemyBody != null && movementPath != null) { if(movementPath.size() == 0) { this.getBody().setAction(new KillEnemy(this.getBody(),Direction.NONE)); lastTime = this.getTimeManager().getCurrentDate().getTime(); return; } else if(movementPath.size() == 1) { this.getBody().setAction(new KillEnemy(this.getBody(),movementPath.getFirst())); lastTime = this.getTimeManager().getCurrentDate().getTime(); return; } } if (relativeStartingPointPosition != null && Point3D.euclidianDistance(new Point3D(0, 0, 0), relativeStartingPointPosition) > 20) { currentBehaviour = WarriorBehaviour.GO_HOME; } else if (enemyBody != null) { movementPath = PathFinder.findPath(positionInPerceivedMap, enemyPositionInPerceivedMap, perceivedMap); } else if (relativeStartingPointPosition != null && Point3D.euclidianDistance(new Point3D(0, 0, 0), relativeStartingPointPosition) > 10) { currentBehaviour = WarriorBehaviour.GO_HOME; } else { this.getBody().setAction( new Move(this.getBody(), Direction.random())); lastTime = this.getTimeManager().getCurrentDate().getTime(); } } private void fight() { Perception currentPerception = this.getBody().getPerception(); Square[][][] perceivedMap = currentPerception.getPerceivedMap(); Point3D positionInPerceivedMap = currentPerception .getPositionInPerceivedMap(); //If on the same square as the enemy, then attack him /*for (WorldObject wo : perceivedMap[positionInPerceivedMap.x][positionInPerceivedMap.y][0].getObjects()) { if (wo.getTexturePath().equals("img/Ants/warrior.png") && ((InsectBody) wo).getSide() != this.getBody().getSide()) { InsectBody enemy = ((InsectBody) wo); enemy.setHealthPoints(enemy.getHealthPoints() - this.attackPoints); //if the enemy has no HP then he dies if (enemy.getHealthPoints() <= 0) { this.getBody().setAction(new KillEnemy(this.getBody())); } } }*/ /*for (int i = 0; i < perceivedMap.length; ++i) { for (int j = 0; j < perceivedMap[0].length; ++j) { List<WorldObject> objectsPerceived = perceivedMap[i][j][0] .getObjects(); synchronized (objectsPerceived) { for (WorldObject wo : objectsPerceived) { if (wo.getTexturePath().equals("img/Ants/warrior.png") && ((InsectBody) wo).getSide() != this .getBody().getSide()) { //if the enemy is not on the same square then try to reach it if (Point3D.euclidianDistance(this.getBody() .getPosition(), wo.getPosition()) != 0) { System.out.println("enemy side :" + ((InsectBody) wo).getSide()); System.out.println("side :" + this.getBody().getSide()); System.out.println("enemy pos : " + wo.getPosition()); System.out.println("pos : " + this.getBody().getPosition()); movementPath = PathFinder.findPath( currentPerception .getPositionInPerceivedMap(), new Point3D(i, j, 0), perceivedMap); return; } else { //else fight the enemy System.out.println("FIGHT"); InsectBody enemy = ((InsectBody) wo); enemy.setHealthPoints(enemy.getHealthPoints() - this.attackPoints); System.out.println("HP :" + enemy.getHealthPoints()); if (enemy.getHealthPoints() <= 0) { //enemy dies ! this.getBody().setAction( new KillEnemy(this.getBody())); } } } } } } }*/ } }
d5d0700edf5b7a56754731bda5ac62111ed55f34
92367a62e594d049cf1f1cf84871694c8798707f
/gof_demo/src/main/java/cn/vobile/obserble/PaperObservable.java
2cc5112724b3615b42be4ff4d288ecf2735653cc
[]
no_license
hpulzl/lzl_workspace
5c363b0c5e285e5ec231bed382fe9d28fbd655fa
bd28a29285d93800d54743a0d20c34981296027f
refs/heads/master
2021-01-21T12:16:42.631846
2018-08-29T08:47:35
2018-08-29T08:47:35
102,059,694
7
0
null
null
null
null
UTF-8
Java
false
false
969
java
package cn.vobile.obserble; import java.util.Observable; /** * 学习使用java的观察者模式,此类为主题,可以注册、删除、通知观察者 */ public class PaperObservable extends Observable{ private String date; private String title; private String content; public void todayNewsChange(){ setChanged(); notifyObservers(); } public void setTodayNews(String date,String title,String content){ this.date = date; this.title = title; this.content = content; } public void getObserversCount(){ int count = super.countObservers(); System.out.println("当前订阅者:"+count); } @Override public String toString() { return "PaperObservable{" + "date='" + date + '\'' + ", title='" + title + '\'' + ", content='" + content + '\'' + '}'; } }
d1b8b0cb960f0634341679c50a4e5a5db32d2295
d39de0c7fd741e4c27396482fa26677f386fbc26
/src/com/java4s/Customer.java
e04dce6db9c09d796ea010cb4c73705be650a5cb
[]
no_license
gauravbang3/RestExmp
af612e84a7a462781c10cebeff723b43b291bbfa
6f12bd97cee1c6efe963800379cbe74de75cf878
refs/heads/master
2021-01-02T22:54:16.425961
2017-08-05T11:05:19
2017-08-05T11:05:19
99,417,159
0
0
null
null
null
null
UTF-8
Java
false
false
546
java
package com.java4s; public class Customer { private int custNo; private String custName; private String custCountry; public int getCustNo() { return custNo; } public void setCustNo(int custNo) { this.custNo = custNo; } public String getCustName() { return custName; } public void setCustName(String custName) { this.custName = custName; } public String getCustCountry() { return custCountry; } public void setCustCountry(String custCountry) { this.custCountry = custCountry; } }
0fc097b4c381c950f678d7c9291a2bffe5b7b872
687627ea526c6d8737fc53ae871d30bdafddcfdb
/src/ATMApp.java
fbaa8265a503f14ae5e9709d946a9716c4dcb598
[]
no_license
aymehai/ATM
ded94398fc9071213ad11526242e213f23d7f986
5031506505c2d894d5e79e79c6a11f31b8b4a094
refs/heads/master
2021-01-25T06:23:57.516817
2017-06-06T20:29:26
2017-06-06T20:29:26
93,561,077
0
0
null
null
null
null
UTF-8
Java
false
false
3,242
java
import java.util.Random; import java.util.Scanner; import java.lang.Math; public class ATMApp { public static void main(String[] args) { //program Scanner keyboard = new Scanner(System.in); System.out.println("Hello would you like to create an account? yes/no"); String userInput = keyboard.nextLine(); if (userInput.equals("yes")) { // prompts user for name System.out.println("What is your name?"); String name = keyboard.nextLine(); // prompts user for deposit amount System.out.println("How much would you like to deposit?"); double deposit = keyboard.nextDouble(); // rounds user deposit to two decimal places deposit = Math.round(deposit * 100.0) / 100.0; // prompts user for a user name System.out.println("Please enter a user name for your account."); String userName = keyboard.next(); // creates object ATM ATM user1 = new ATM(name, deposit, userName); int userNumber = 0; System.out.println(user1.userInformation()); do { // prompts user for number choices System.out.println("Please type 1 of the 4 options"); System.out.println("1. Withdraw"); System.out.println("2. Deposit"); System.out.println("3. Check Balance"); System.out.println("4. Quit"); userNumber = keyboard.nextInt(); if (userNumber < 4 && userNumber >= 1) { // prompts user for user name System.out.println("In order to continue please enter your account number"); int userAccountNumber = keyboard.nextInt(); if (userAccountNumber == user1.getAccountNumber()) { // prompts user for pin for (int i = 1; i < 4; i++) { System.out.println("What is your pin"); int userPin = keyboard.nextInt(); if (userPin == user1.getPin()) { // checks user number choice if (userNumber == 1) { // prompts user how much to withdraw System.out.println("How much would you like to withdraw?"); double money = keyboard.nextDouble(); user1.withdraw(money); System.out.println(user1.receipt()); } else if (userNumber == 2) { // prompts user how much to deposit System.out.println("How much would you like to deposit?"); double money = keyboard.nextDouble(); user1.withdraw(money); System.out.println(user1.receipt()); } else if (userNumber == 3) { // gets user balance System.out.println("Here is your balance: " + user1.getBalance()); System.out.println("Thank you for using the ATM"); break; } } else { System.out.println("sorry wrong pin"); } } System.out.println("you have no been locked out of your account"); break; } else { System.out.println("userName does not exist"); } } else if (userNumber == 4) { System.out.println("Have a great day! Thank you for using ATM."); } else { System.out.println("please enter a valid pin."); userNumber = 5; } } while (userNumber > 4 && userNumber < 1); } else if (userInput.equals("no")) { System.out.println("ok have a great day..."); } else { System.out.println("please restart program and enter a valid value."); } } }
8ff940f533d2ea41fd3d025064d47012fabf4eee
e5db40fbdab51104d433ab57cfaae2fe40f50012
/parent/service1/src/main/java/com/wuhen/StartService1.java
bad6044efa3de4aab27e863b92c86da8db14052e
[]
no_license
wuhen808/springcloud-learn
80ea3cf8f8be4cf866f85834aae40d71f1de72d1
a69947f493b2c39350fdd2cceb0612912a5f35d9
refs/heads/master
2021-01-22T21:37:58.788158
2017-06-11T09:01:23
2017-06-11T09:01:23
85,454,024
0
0
null
null
null
null
UTF-8
Java
false
false
389
java
package com.wuhen; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication @EnableDiscoveryClient public class StartService1 { public static void main(String[] args) { SpringApplication.run(StartService1.class, args); } }
a65867d50c6a282bcf17a34d6a5fe570a17ab894
e24573b91faa8b4d273f743453260f9bc31808be
/zuul-sample/src/main/java/com/netflix/zuul/sample/Bootstrap.java
10e7e26c4e7cbc95c0a2a4bb02eeba5a442822a2
[ "Apache-2.0" ]
permissive
candrews/zuul
bf35196c0f6e24a920dcd3cdff9f04dfbc9ea6a4
2193f0bdec12bab1550c56ac1b6b73d0141aa2f7
refs/heads/2.1
2023-04-07T04:11:22.534172
2018-05-03T22:48:49
2018-05-03T22:48:49
132,301,984
0
1
Apache-2.0
2023-04-04T01:35:49
2018-05-06T03:02:15
Java
UTF-8
Java
false
false
2,298
java
/* * Copyright 2018 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.netflix.zuul.sample; import com.google.inject.Injector; import com.netflix.config.ConfigurationManager; import com.netflix.governator.InjectorBuilder; import com.netflix.zuul.netty.server.BaseServerStartup; import com.netflix.zuul.netty.server.Server; /** * Bootstrap * * Author: Arthur Gonigberg * Date: November 20, 2017 */ public class Bootstrap { public static void main(String[] args) { new Bootstrap().start(); } public void start() { System.out.println("Zuul Sample: starting up."); long startTime = System.currentTimeMillis(); int exitCode = 0; Server server = null; try { ConfigurationManager.loadCascadedPropertiesFromResources("application"); Injector injector = InjectorBuilder.fromModule(new ZuulSampleModule()).createInjector(); BaseServerStartup serverStartup = injector.getInstance(BaseServerStartup.class); server = serverStartup.server(); long startupDuration = System.currentTimeMillis() - startTime; System.out.println("Zuul Sample: finished startup. Duration = " + startupDuration + " ms"); server.start(true); } catch (Throwable t) { t.printStackTrace(); System.err.println("###############"); System.err.println("Zuul Sample: initialization failed. Forcing shutdown now."); System.err.println("###############"); exitCode = 1; } finally { // server shutdown if (server != null) server.stop(); System.exit(exitCode); } } }
14be6e4ff78440c83a506ad4ccac6168d6c3d767
221af9b9cc64e7c599bf03941c9b1f3112d4ece5
/DesignPatterns/src/patterns/structural/composite/standard/LeafA.java
ac56341a1e002a8fa2347fa997f6d01e10a4d92b
[]
no_license
elifbasak/design-patterns
15c41a764a5700aec4d6d33556cd6a84dbe1ad28
d664eb204085b85fd9b66a6007afabe770e1e55d
refs/heads/master
2021-05-29T06:09:15.392723
2014-12-26T20:24:11
2014-12-26T20:24:11
null
0
0
null
null
null
null
UTF-8
Java
false
false
252
java
package patterns.structural.composite.standard; /** * Example of leaf component class * * @author Tomek * */ public class LeafA extends AbstractComponent { @Override public void operation() { System.out.println( "LeafA.operation()" ); } }
36f1937af0e35d3ba23bc4ac239316793c09990b
35bd1669ee3b6b1bc24ea94a3b96ce027921ad14
/src/main/groovy/io/github/endron/lyortisTownGen/PersonRepository.java
3428774287220cefe74d4a3a2ad8653bf08427e8
[ "MIT" ]
permissive
Endron/lyortisTownGen
ba826a14a45bd911394b0a5c61f640075738d13b
8abed1fd65cac36e2bfdec3168be4c7e618d5118
refs/heads/master
2020-03-27T04:52:07.226813
2015-07-17T13:22:59
2015-07-17T13:22:59
27,544,037
0
0
null
null
null
null
UTF-8
Java
false
false
1,499
java
/* * The MIT License (MIT) * * Copyright (c) 2014 Tobias Kremer * * 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 io.github.endron.lyortisTownGen; import io.github.endron.lyortisTownGen.entities.Person; import org.springframework.data.repository.CrudRepository; /** * Repository to access {@link Person}-Entities in the db. */ public interface PersonRepository extends CrudRepository<Person, Long> { /* * no implementation needed at this time. */ }
bdb79e2bb15c96297083f3d5f51bbdcd9ccfd6e4
b5bcf403fc2c0046921345631012b077ea6584a4
/src/com/cwa/battleimpl/filer/InitMapTaskFilter.java
7b8130d1ab9115f44ad1b54ba11143be61a31dc2
[]
no_license
mmgame/cwa2_2101wow_battle_server
f3900f8842dd3aeaa16d0631f8ed192df6c0a4fd
788e7db9d5ddcbcbd35fe6d2a0322804be827f72
refs/heads/master
2021-01-22T04:40:17.085374
2015-08-06T03:14:21
2015-08-06T03:14:21
40,281,761
0
0
null
null
null
null
UTF-8
Java
false
false
1,244
java
package com.cwa.battleimpl.filer; import com.cwa.battle.IBattleGround; import com.cwa.battle.filter.ABattleFilter; import com.cwa.prototype.BattlePrototype; import com.cwa.prototype.BattlemapPrototype; import com.cwa.simuiation.map.Point; import com.cwa.simuiationimpl.map.AreaMgr; /** * 初始化地图 * * @author mausmars * */ public class InitMapTaskFilter extends ABattleFilter { public InitMapTaskFilter() { super("InitMapTaskFilter"); } @Override public boolean doWork(Object context) throws Exception { if (logger.isInfoEnabled()) { logger.info("InitMapTaskFilter doWork!"); } IBattleGround battleGround = (IBattleGround) context; BattlePrototype battlePrototype = battleGround.getSimuiation().getProtpyeMgr().getBattlePrototype(); BattlemapPrototype battlemapPrototype = battleGround.getSimuiation().getProtpyeMgr() .getBattlemapPrototype(battlePrototype.getMap()); Point p = new Point(battlemapPrototype.getMapArea().size()); int index = 0; for (int v : battlemapPrototype.getMapArea()) { p.setCoordinate(index, v); index++; } AreaMgr areaMgr = (AreaMgr) battleGround.getSimuiation().getAreaMgr(); areaMgr.setPoint(p); return true; } }
c825f6d8408b58bd5f63f3fe50d3e4adb359dcb3
9b94fdaea53528e17582a1f2a918c83b82066e05
/Java_Home/src/OrderLineItem.java
381b9769a08f7e656877eef02c3e9db05eee26ec
[]
no_license
swapkarnewar/swapkarnewar
b7ceb018c7b93de6f29611dacb7c4fe44b31d6e3
c2fce4f596d858615479c37b65fac5541584bab6
refs/heads/master
2021-12-14T10:04:58.069640
2021-12-02T06:26:06
2021-12-02T06:26:06
96,796,031
0
0
null
null
null
null
UTF-8
Java
false
false
240
java
public class OrderLineItem { public OrderLineItem(String orderId, String doli) { setExtendedAttributes(); } private void setExtendedAttributes() { // TODO Auto-generated method stub } }
f9f74d15b5d35a3625e0dae0289b5be591d58212
37c7b4513e18160647eb6762d57faa1c7912d64b
/src/javaapplication2/NewJFrame.java
d48beee1cfaa76ba1594aaa50e35f9a777b51c74
[]
no_license
johnlfreire/TesteCertficadoDigital
848aaee9829267999c22ecb58cb35c0aaa472062
76116104e5fae0e8d2a6f1f29d924aeb3d28c3a6
refs/heads/master
2021-02-09T01:50:54.247018
2020-03-01T21:19:11
2020-03-01T21:19:11
244,225,127
0
0
null
null
null
null
UTF-8
Java
false
false
3,245
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 javaapplication2; /** * * @author johnpc */ public class NewJFrame extends javax.swing.JFrame { /** * Creates new form NewJFrame */ public NewJFrame() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables }
485331edeff89caf6d0e8a2c4f1725e22f4ce46d
7388b98827856776b976b08878abc4f42c6ba9b5
/src/sorting/StringSorting.java
305e148a95c197015a29692c879a7886e7052ca3
[]
no_license
deepeshsatija1012/dsAlgoOld
8296407d3d18896cbe882dde200c3e2ac195ffaf
431bb6029236da21dd35454d0d25c8bb74bb80cd
refs/heads/master
2020-05-28T01:30:32.608405
2019-05-27T12:58:45
2019-05-27T12:58:45
188,843,248
0
0
null
null
null
null
UTF-8
Java
false
false
4,281
java
package sorting; import java.util.Arrays; /** * Sorts the array if the range of array is know. * @author pc * */ public class StringSorting { private static final int R = 256; public static void keyIndexSort(String[] arr, int d){ int[] count = new int[R+1]; //find frequecny of each key for(int i=0;i<arr.length;i++){ count[charAt(arr[i],d)+1]++; } //find cumulative sum, ie, number of key leass than at index in range for(int i=0;i<R;i++){ count[i+1]+=count[i]; } //copy the String[] aux = new String[arr.length]; for(int i=0;i<arr.length;i++){ // we are copying the value at count index to auxilarry arraya and increamenting the count vvalue to copy the next //value to next index //This count basically contains the indices where the value is supposed tobe copied in auxillary array aux[count[charAt(arr[i],d)]++] = arr[i]; } for(int i=0;i<aux.length;i++){ arr[i] = aux[i]; } } public static void LSDSort(String[] arr, int W){ String[] aux = new String[arr.length]; for(int d=W-1;d>=0;d--){ int[] count = new int[256+1]; for(int i=0;i<arr.length;i++){ count[arr[i].charAt(d)+1]++; } for(int i=0;i<256;i++){ count[i+1]+=count[i]; } for(int i=0;i<arr.length;i++){ aux[count[arr[i].charAt(d)]++] = arr[i]; } for(int i=0;i<arr.length;i++){ arr[i] = aux[i]; } } } public static void MSDSort(String[] arr){ String[] aux = new String[arr.length]; MSDSort(arr, aux, 0, arr.length, 0); } private static int charAt(String s, int d){ if(d<s.length()) return s.charAt(d); return -1; } private static void MSDSort(String[] arr, String[]aux, int lo, int hi, int d){ if(hi<=lo) return; int[] count = new int[256+2]; for(int i=lo;i<hi;i++){ count[charAt(arr[i], d)+2]++; } for(int i=0;i<256+1;i++){ count[i+1]+=count[i]; } for(int i=lo;i<hi;i++){ aux[count[charAt(arr[i], d)+1]++] = arr[i]; } for(int i =lo;i<hi;i++){ arr[i] = aux[i]; } for(int i=0;i<256;i++){ MSDSort(arr, aux, lo+count[i], lo+count[i]-1, d+1); } } public static void radixQuickSort3Way(String[] arr, int lo, int hi, int d){ if(hi<=lo) return; int lt=lo, gt=hi; int v = charAt(arr[lo],d); int i=lo+1; while(i<=gt){ int t = charAt(arr[i], d); if(t<v) exch(arr, i++, lt++); else if(t>v) exch(arr, i, gt--); else i++; } radixQuickSort3Way(arr, lo, lt-1, d); if(v>=0) radixQuickSort3Way(arr, lt, gt, d+1); radixQuickSort3Way(arr, gt+1, hi, d); } private static void exch(String[] arr, int i, int j){ String temp = arr[i]; arr[i]=arr[j]; arr[j] = temp; } public static void main(String[] args) { System.out.println("==================KeyIndex Sort==================================="); String[] arr = new String[]{"Namita", "Kanika", "Deepes", "Sudesh", "Ashoka", "Mudias"}; System.out.println("Before Sort"); System.out.println(Arrays.toString(arr)); System.out.println("After Sort"); keyIndexSort(arr, 1); System.out.println(Arrays.toString(arr)); System.out.println("==================LSDSort==================================="); String[] strArr = new String[]{"Namita", "Kanika", "Deepes", "Sudesh", "Ashoka", "Mudias"}; System.out.println("Before Sort"); System.out.println(Arrays.toString(strArr)); LSDSort(strArr, strArr[0].length()); System.out.println("After Sort"); System.out.println(Arrays.toString(strArr)); System.out.println("==================MSDSort==================================="); String[] strArr1 = new String[]{"Namita", "Kanika", "Deepes", "Sudesh", "Ashoka", "Mudias"}; System.out.println("Before Sort"); System.out.println(Arrays.toString(strArr1)); MSDSort(strArr1); System.out.println("After Sort"); System.out.println(Arrays.toString(strArr1)); System.out.println("==================3WayRadixSort==================================="); String[] strArr2 = new String[]{"Namita", "Kanika", "Deepesh", "Sudesh", "Ashok", "Manav", "Anay"}; System.out.println("Before Sort"); System.out.println(Arrays.toString(strArr2)); radixQuickSort3Way(strArr2, 0, strArr2.length-1, 0); System.out.println("After Sort"); System.out.println(Arrays.toString(strArr2)); } }
851b0f65c050032923a53c097253f4eee87efe6c
852c382f0dcb93f5118a9265e84892fcdf56de73
/prototypes/recsys-prototype/trunk/dspace-oai/dspace-oai-api/src/main/java/org/dspace/app/oai/DSpaceRecordFactory.java
589f0d99afb2144816b0a1d12a249c0a1a2783e7
[]
no_license
DSpace-Labs/dspace-sandbox
101a0cf0c371a52fb78bf02d394deae1e8157d25
a17fe69a08fb629f7da574cfc95632dc0e9118a8
refs/heads/master
2020-05-17T21:33:34.009260
2009-04-17T13:43:32
2009-04-17T13:43:32
32,347,896
0
4
null
null
null
null
UTF-8
Java
false
false
4,400
java
/* * DSpaceRecordFactory.java * * Version: $Revision: 2548 $ * * Date: $Date: 2008-01-15 23:39:24 +0000 (Tue, 15 Jan 2008) $ * * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts * Institute of Technology. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * - Neither the name of the Hewlett-Packard Company nor the name of the * Massachusetts Institute of Technology nor the names of their * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ package org.dspace.app.oai; import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; import org.apache.log4j.Logger; import org.dspace.content.DCDate; import org.dspace.uri.ObjectIdentifier; import org.dspace.search.HarvestedItemInfo; import ORG.oclc.oai.server.catalog.RecordFactory; import ORG.oclc.oai.server.verb.CannotDisseminateFormatException; /** * Implementation of the OAICat RecordFactory base class for DSpace items. * * @author Robert Tansley * @version $Revision: 2548 $ */ public class DSpaceRecordFactory extends RecordFactory { /** log4j category */ private static Logger log = Logger.getLogger(DSpaceRecordFactory.class); public DSpaceRecordFactory(Properties properties) { // We don't use the OAICat properties; pass on up super(properties); } public String fromOAIIdentifier(String identifier) { // Our local identifier is actually the same as the OAI one (the URI) return identifier; } public String quickCreate(Object nativeItem, String schemaURL, String metadataPrefix) throws IllegalArgumentException, CannotDisseminateFormatException { // Not supported return null; } public String getOAIIdentifier(Object nativeItem) { String h = DSpaceOAICatalog.OAI_ID_PREFIX + ((HarvestedItemInfo) nativeItem).identifier.getCanonicalForm(); return h; } public String getDatestamp(Object nativeItem) { Date d = ((HarvestedItemInfo) nativeItem).datestamp; // Return as ISO8601 return new DCDate(d).toString(); } public Iterator getSetSpecs(Object nativeItem) { HarvestedItemInfo hii = (HarvestedItemInfo) nativeItem; List<String> setSpecs = new LinkedList<String>(); // Convert the canonical form xyz:123.456/789 to the OAI-friendly // xyz_123.456/789 for (ObjectIdentifier identifier : hii.collectionIdentifiers) { String uri = identifier.getCanonicalForm(); setSpecs.add(uri.replaceFirst(":", "_").replace('/', '_')); } return setSpecs.iterator(); } public boolean isDeleted(Object nativeItem) { HarvestedItemInfo hii = (HarvestedItemInfo) nativeItem; return hii.withdrawn; } public Iterator getAbouts(Object nativeItem) { // Nothing in the about section for now return new LinkedList().iterator(); } }
8787a35264762501ac1b0f83a500765c69eecf85
29ac2ff3b4923d5bf1ddffbe5ea76645f215af53
/Assignment3/src/main/java/bgu/spl/server/tokenizer/FixedSeparatorMessageTokenizer.java
540375fbd561dc1054087b0320e08a9e164b091b
[]
no_license
maayanco/SPL-Assignment3-Server
7c9c1558d74245cbf4ac8315921fc39ce87c1ae3
a046af4bcb876f7fa3077da5af088cf396227bab
refs/heads/master
2020-12-11T06:02:32.849607
2016-01-27T00:26:59
2016-01-27T00:26:59
49,319,636
0
0
null
null
null
null
UTF-8
Java
false
false
3,036
java
package bgu.spl.server.tokenizer; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; import java.util.Vector; import bgu.spl.passive.StringMessage; public class FixedSeparatorMessageTokenizer implements MessageTokenizer<StringMessage> { private final String _messageSeparator; private final StringBuffer _stringBuf = new StringBuffer(); /** * the fifo queue, which holds data coming from the socket. Access to the * queue is serialized, to ensure correct processing order. */ private final Vector<ByteBuffer> _buffers = new Vector<ByteBuffer>(); private final CharsetDecoder _decoder; private final CharsetEncoder _encoder; public FixedSeparatorMessageTokenizer(String separator, Charset charset) { this._messageSeparator = separator; this._decoder = charset.newDecoder(); this._encoder = charset.newEncoder(); } /** * Add some bytes to the message. Bytes are converted to chars, and appended * to the internal StringBuffer. Complete messages can be retrieved using * the nextMessage() method. * * @param bytes * an array of bytes to be appended to the message. */ public synchronized void addBytes(ByteBuffer bytes) { _buffers.add(bytes); } /** * Is there a complete message ready?. * * @return true the next call to nextMessage() will not return null, false * otherwise. */ public synchronized boolean hasMessage() { while (_buffers.size() > 0) { ByteBuffer bytes = _buffers.remove(0); CharBuffer chars = CharBuffer.allocate(bytes.remaining()); this._decoder.decode(bytes, chars, false); // false: more bytes may // follow. Any unused // bytes are kept in the // decoder. chars.flip(); this._stringBuf.append(chars); } return this._stringBuf.indexOf(this._messageSeparator) > -1; } /** * Get the next complete message if it exists, advancing the tokenizer to * the next message. * * @return the next complete message, and null if no complete message exist. */ public synchronized StringMessage nextMessage() { String message = null; int messageEnd = this._stringBuf.indexOf(this._messageSeparator); if (messageEnd > -1) { message = this._stringBuf.substring(0, messageEnd); this._stringBuf.delete(0, messageEnd + this._messageSeparator.length()); } return new StringMessage(message); } /** * Convert the String message into bytes representation, taking care of * encoding and framing. * * @return a ByteBuffer with the message content converted to bytes, after * framing information has been added. */ public ByteBuffer getBytesForMessage(StringMessage msg) throws CharacterCodingException { StringBuilder sb = new StringBuilder(msg.getMessage()); sb.append(this._messageSeparator); ByteBuffer bb = this._encoder.encode(CharBuffer.wrap(sb)); return bb; } }
2634bd0255c6b3b2dbec3fcdab47b010db8f471f
0ac05e3da06d78292fdfb64141ead86ff6ca038f
/OSWE/oswe/openCRX/rtjar/rt.jar.src/javax/print/attribute/standard/JobMediaSheetsSupported.java
5a0cd1d1c14f12fd733c483fa75ad78f1e234eb5
[]
no_license
qoo7972365/timmy
31581cdcbb8858ac19a8bb7b773441a68b6c390a
2fc8baba4f53d38dfe9c2b3afd89dcf87cbef578
refs/heads/master
2023-07-26T12:26:35.266587
2023-07-17T12:35:19
2023-07-17T12:35:19
353,889,195
7
1
null
null
null
null
UTF-8
Java
false
false
2,588
java
/* */ package javax.print.attribute.standard; /* */ /* */ import javax.print.attribute.Attribute; /* */ import javax.print.attribute.SetOfIntegerSyntax; /* */ import javax.print.attribute.SupportedValuesAttribute; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public final class JobMediaSheetsSupported /* */ extends SetOfIntegerSyntax /* */ implements SupportedValuesAttribute /* */ { /* */ private static final long serialVersionUID = 2953685470388672940L; /* */ /* */ public JobMediaSheetsSupported(int paramInt1, int paramInt2) { /* 68 */ super(paramInt1, paramInt2); /* 69 */ if (paramInt1 > paramInt2) /* 70 */ throw new IllegalArgumentException("Null range specified"); /* 71 */ if (paramInt1 < 0) { /* 72 */ throw new IllegalArgumentException("Job K octets value < 0 specified"); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean equals(Object paramObject) { /* 97 */ return (super.equals(paramObject) && paramObject instanceof JobMediaSheetsSupported); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public final Class<? extends Attribute> getCategory() { /* 112 */ return (Class)JobMediaSheetsSupported.class; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public final String getName() { /* 125 */ return "job-media-sheets-supported"; /* */ } /* */ } /* Location: /Users/timmy/timmy/OSWE/oswe/openCRX/rt.jar!/javax/print/attribute/standard/JobMediaSheetsSupported.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */
[ "t0984456716" ]
t0984456716
d299f59e62e9dc73bcc647ac2df2dc4db7e260dd
260b53ac4440df2b9f84d0fda2f3f34444493ff8
/src/mandelbrot/Mandelbrot.java
56d64f1bc4942046e9aeece7c31afe7e411246f1
[]
no_license
BusinessJoe/mandelbrot-sandbox
7bd5483c9e1a492236055a470c55ed2f5b50153d
8436f3f6ca5c9395ee5c0959ff2dd022935882ab
refs/heads/master
2020-12-13T15:40:02.603618
2020-01-17T03:31:34
2020-01-17T03:31:34
234,460,552
0
0
null
null
null
null
UTF-8
Java
false
false
1,704
java
package src.mandelbrot; public class Mandelbrot { private double leftBound, lowerBound; private double rightBound, upperBound; private int maxIterations; private int height; private int width; private int[][] iterationCounts; public Mandelbrot(int width, int height, double leftBound, double lowerBound, double rightBound, double upperBound, int maxIterations) { this.leftBound = leftBound; this.lowerBound = lowerBound; this.rightBound = rightBound; this.upperBound = upperBound; this.width = width; this.height = height; this.maxIterations = maxIterations; iterationCounts = new int[width][height]; } private int countIterations(ComplexNumber z, ComplexNumber c) { int iterations = 0; while (z.real() * z.real() + z.imaginary() * z.imaginary() <= 2*2 && iterations < maxIterations) { z.mandelbrotIteration(c); iterations++; } return iterations; } public void countAllIterations() { double xIncrement = (rightBound - leftBound) / width; double yIncrement = (upperBound - lowerBound) / height; for (int xIdx = 0; xIdx < width; xIdx++) { for (int yIdx = 0; yIdx < height; yIdx++) { double x = leftBound + xIdx * xIncrement; double y = upperBound - yIdx * yIncrement; ComplexNumber c = new ComplexNumber(x, y); iterationCounts[xIdx][yIdx] = countIterations(new ComplexNumber(0, 0), c); } } } public int[][] getIterationCounts() { return iterationCounts; } }
931f9a3190b6424b08dccdcb48f99eae325dbd91
1f9b94c373cbbe68685635e353dcc6d87517b68e
/src/main/java/com/quanpv/nlp/rule/Rule15.java
64eea5e01b41f500dec849e7f8aa83adf820763e
[]
no_license
QuanLab/NLP
89f54848bee5d643142ed6dd16ecf5927273d0d8
004419f6f70ddc483564d8965a4d67b03d5ef8d1
refs/heads/master
2021-01-18T17:59:16.208217
2017-05-14T10:31:58
2017-05-14T10:31:58
86,832,148
0
0
null
null
null
null
UTF-8
Java
false
false
740
java
package com.quanpv.nlp.rule; public class Rule15 { /** * Nếu bắt đầu bằng r, m, x, h, d, v, s thì sau đó là nguyên âm * bắt đầu bằng q sau đó phải là u * @param s * @return */ public static boolean isValid(String s) { char[] chars = s.toCharArray(); char start = chars[0]; if( start=='r'||start=='m'||start=='x'||start=='h'||start=='d'||start=='đ' ||start=='v'||start=='s'||start=='l') { if(!CharHelper.isNguyenAm(chars[1])){ return false; } } if( start=='q') { if(chars[1]!='u'){ return false; } } return true; } }
96de34dddc897903356d9874fb68bd6448ea6f02
1f3997e0156642e8dfe9fb853182db99b4290a37
/combatSpatiale/src/be/jl/cs/model/vaisseau/composant/CompositionAlliage.java
2bad1ff2956250e366681c5f3d7d28070141369e
[]
no_license
JLffeguor/jerome-lengele
cdd0ad75848af7490ee07f413da1ccc733f395e2
9170bc6746e3e78211792c4e92742459d02ccf2a
refs/heads/master
2021-01-19T08:21:53.779049
2017-02-06T14:21:05
2017-02-06T14:21:05
34,114,707
0
0
null
null
null
null
ISO-8859-2
Java
false
false
945
java
package be.jl.cs.model.vaisseau.composant; import javax.persistence.Entity; import javax.persistence.OneToOne; import be.jl.cs.model.BaseEntity; /** * * @author jerronimo31 * Cette class permer de gerer les élément composé de plusieur élémént en tenant compte du pourcentage de composition de chacun des éléments */ @Entity public class CompositionAlliage extends BaseEntity{ @OneToOne private ElementUnivers element; private Double pourcentage; public CompositionAlliage(){} public CompositionAlliage(ElementUnivers e, Double p){ this.element = e; this.pourcentage = p; } public ElementUnivers getElement() { return element; } public void setElement(ElementUnivers element) { this.element = element; } public Double getPourcentage() { return pourcentage; } public void setPourcentage(Double pourcentage) { this.pourcentage = pourcentage; } }
307355da6bffece5030858e5e1f25a8e63139cb4
1af8b4b50d7156cdbea635088ac36739d16653bf
/src/main/java/OneSignal.java
7f870073935796929e05793012e83b3b03e2d302
[]
no_license
yashim/Ridesharing
58e6d49bcf8556dd8809e52cb16fd15d6a02b0fd
93e05eb056f3d533956ea9e1d9f8543cf6d7d3e9
refs/heads/master
2021-01-10T01:13:16.076804
2015-09-11T06:44:44
2015-09-11T06:44:44
39,653,072
0
1
null
null
null
null
UTF-8
Java
false
false
6,189
java
import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; import java.util.Map; /** * Author: shim. * Creation date: 8/26/15. */ public class OneSignal { private final static String registerUrl = "https://onesignal.com/api/v1/players"; private final static String pushUrl = "https://onesignal.com/api/v1/notifications"; private final static String appId = "32fed59e-3b83-11e5-b5c8-9f93493279d9"; public static void registerDevice(String identifier, int deviceType) { String message = "{\"app_id\" : \"" + appId + "\", \"identifier\":\"" + identifier + "\", \"device_type\":" + deviceType + "}"; try { URL u = new URL(registerUrl); HttpURLConnection conn = (HttpURLConnection)u.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Content-Length", ""+message.length()); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); DataOutputStream wr = new DataOutputStream(os); wr.writeBytes (message); wr.flush (); wr.close (); InputStream is = conn.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); while((line = rd.readLine()) != null) { response.append(line); response.append('\r'); } rd.close(); }catch(IOException e){ e.printStackTrace(); } } public static void sendPush(String token, String message){ PushMessage pushMessage = new PushMessage(); pushMessage.setIos(true); Map<String, String> data = new HashMap<>(); data.put("en", message); pushMessage.setContents(data); pushMessage.setIncludeIosTokens(new String[]{token}); String pushMessageString = pushMessage.build(); System.out.println(pushMessageString); try { URL u = new URL(pushUrl); HttpURLConnection conn = (HttpURLConnection)u.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Content-Length", ""+pushMessageString.length()); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); DataOutputStream wr = new DataOutputStream(os); wr.writeBytes (pushMessageString); wr.flush (); wr.close (); InputStream is = conn.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); while((line = rd.readLine()) != null) { response.append(line); response.append('\r'); } rd.close(); }catch(IOException e){ e.printStackTrace(); } } } class PushMessage{ @SerializedName("app_id") private final String appId = "32fed59e-3b83-11e5-b5c8-9f93493279d9"; @SerializedName("contents") private Map<String,String> contents; @SerializedName("isIos") private boolean isIos; @SerializedName("include_ios_tokens") private String[] includeIosTokens; @SerializedName("isAndroid") private boolean isAndroid; @SerializedName("include_android_reg_ids") private String[] includeAndroidRegIds; @SerializedName("isWP") private boolean isWP; @SerializedName("include_wp_uris") private String[] includeWpUris; public PushMessage(){ } public PushMessage(Map<String, String> contents, boolean isIos, String[] includeIosTokens, boolean isAndroid, String[] includeAndroidRegIds, boolean isWP, String[] includeWpUris) { this.contents = contents; this.isIos = isIos; this.includeIosTokens = includeIosTokens; this.isAndroid = isAndroid; this.includeAndroidRegIds = includeAndroidRegIds; this.isWP = isWP; this.includeWpUris = includeWpUris; } public Map<String, String> getContents() { return contents; } public void setContents(Map<String, String> contents) { this.contents = contents; } public boolean isIos() { return isIos; } public void setIos(boolean isIos) { this.isIos = isIos; } public String[] getIncludeIosTokens() { return includeIosTokens; } public void setIncludeIosTokens(String[] includeIosTokens) { this.includeIosTokens = includeIosTokens; } public boolean isAndroid() { return isAndroid; } public void setAndroid(boolean isAndroid) { this.isAndroid = isAndroid; } public String[] getIncludeAndroidRegIds() { return includeAndroidRegIds; } public void setIncludeAndroidRegIds(String[] includeAndroidRegIds) { this.includeAndroidRegIds = includeAndroidRegIds; } public boolean isWP() { return isWP; } public void setWP(boolean isWP) { this.isWP = isWP; } public String[] getIncludeWpUris() { return includeWpUris; } public void setIncludeWpUris(String[] includeWpUris) { this.includeWpUris = includeWpUris; } public String build(){ Gson gson = new Gson(); return gson.toJson(this); } } //curl --include \ // --request POST \ // --header "Content-Type: application/json" \ // --data-binary '{"app_id" : "32fed59e-3b83-11e5-b5c8-9f93493279d9", // "identifier":"ce777617da7f548fe7a9ab6febb56cf39fba6d382000c0395666288d961ee566", // "device_type":0}' \ // https://onesignal.com/api/v1/players
d19763c4fbc6dd6b81c7d899c02ec16bae6595f1
ec70eb23deee0c42e37d7babceee8daae63eeeb9
/ciit/RegisterCust.java
c13694b79be9ea6f82c1b6c0c4346333a5029e92
[]
no_license
Shashank-Marwade/BillingSys
14829465511b8290b0aec11ca067144e89f379af
32f341b24640ecc13b445186397f06d8b91f733e
refs/heads/main
2023-06-14T23:10:26.051779
2021-07-05T03:15:35
2021-07-05T03:15:35
382,999,538
0
0
null
null
null
null
UTF-8
Java
false
false
900
java
package com.ciit; import java.sql.*; public class RegisterCust { public int Register(String v1,String v2,String v3,String v4,String v5,String v6) throws SQLException { int id=0; int v_5=Integer.parseInt(v5); int v_4=Integer.parseInt(v4); Connection con=MyOracleConnection.getConnection(); Statement st=con.createStatement(); String sql="SELECT MAX(ID)+1 FROM CUSTOMER_MAST"; System.out.println(sql); ResultSet rs = st.executeQuery(sql); while(rs.next()) { id=rs.getInt(1); } sql="INSERT INTO CUSTOMER_MAST(ID,ADDRESS,MTYPE,SALARY,USERNAME,PASSWORD,GENDER) VALUES("+id+",'"+v2+"',"+v_4+","+v_5+",'"+v1+"','"+v6+"','"+v3+"')"; System.out.println(sql); st.executeQuery(sql); return id; } }
e5ff20bd4930eb6559fd8aca62d765b9e53b377c
d555d7bffaa3f416648ea7bc7fb1c61805fcdb2f
/app/src/main/java/com/github/antego/solfeggio/GraphicUtils.java
36744527f42e5952adf37c29b6e581eaaa955db0
[]
no_license
antego/solfeggio
4e8b27669dd14e91d8fbfef83e86a1494f3516a5
fe02f729321f1bc46191e36dc937834d68626b0f
refs/heads/master
2021-01-15T14:49:47.842376
2018-07-21T09:52:16
2018-07-21T09:52:16
68,321,723
2
1
null
null
null
null
UTF-8
Java
false
false
332
java
package com.github.antego.solfeggio; import android.opengl.GLES20; public class GraphicUtils { public static int loadShader(int type, String shaderCode){ int shader = GLES20.glCreateShader(type); GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); return shader; } }
a6a3206fd70304dd9e26848156b778009cc7038c
bce850ef0d3e0360fe6746cbef86fac8b2e44c62
/ThesisTest/android/app/src/main/java/com/thesistest/MainApplication.java
f10f25b6d20ac40141f2aaccd1fd2ad25ad114a1
[]
no_license
nickcobbett/experimental
1d98e55855b20751cf84135aa28e5f6c8007ca75
1ca41b4dca32d5506c2109d5a7579e5e27e69aed
refs/heads/master
2021-01-19T10:49:34.683718
2017-02-17T18:42:24
2017-02-17T18:42:24
82,219,817
0
0
null
2017-02-16T19:50:14
2017-02-16T19:50:14
null
UTF-8
Java
false
false
1,031
java
package com.thesistest; import android.app.Application; import android.util.Log; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; 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() { return Arrays.<ReactPackage>asList( new MainReactPackage() ); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } }
e25eb6260f0ce3b77b250521b8c4f2af9917ef73
513c1eb639ae80c0c3e9eb0a617cd1d00e2bc034
/src/net/demilich/metastone/game/cards/concrete/warrior/CommandingShout.java
3b97585bd11de76abccf3d7e11356a3b9c7dbc65
[ "MIT" ]
permissive
hillst/MetaStone
a21b63a1d2d02646ee3b6226261b4eb3304c175a
5882d834d32028f5f083543f0700e59ccf1aa1fe
refs/heads/master
2021-05-28T22:05:42.911637
2015-06-05T00:58:06
2015-06-05T00:58:06
36,316,023
0
0
null
null
null
null
UTF-8
Java
false
false
1,143
java
package net.demilich.metastone.game.cards.concrete.warrior; import net.demilich.metastone.game.GameTag; import net.demilich.metastone.game.cards.Rarity; import net.demilich.metastone.game.cards.SpellCard; import net.demilich.metastone.game.entities.heroes.HeroClass; import net.demilich.metastone.game.spells.ApplyTagSpell; import net.demilich.metastone.game.spells.DrawCardSpell; import net.demilich.metastone.game.spells.MetaSpell; import net.demilich.metastone.game.spells.desc.SpellDesc; import net.demilich.metastone.game.targeting.EntityReference; import net.demilich.metastone.game.targeting.TargetSelection; public class CommandingShout extends SpellCard { public CommandingShout() { super("Commanding Shout", Rarity.RARE, HeroClass.WARRIOR, 2); setDescription("Your minions can't be reduced below 1 Health this turn. Draw a card."); SpellDesc commanding = ApplyTagSpell.create(EntityReference.FRIENDLY_CHARACTERS, GameTag.CANNOT_REDUCE_HP_BELOW_1); setSpell(MetaSpell.create(DrawCardSpell.create(), commanding)); setTargetRequirement(TargetSelection.NONE); } @Override public int getTypeId() { return 366; } }
2304309a41bfe8938c0069017d144f811317fc25
0207203c7c4790c35bcb7b5c21d3d66757f658d8
/docroot/WEB-INF/src/vn/dtt/duongbien/dao/vrcb/model/impl/TempDangerousGoodsItemsImpl.java
62d135b3c028bc1bbd56fc11bf67aef24e18b283
[]
no_license
longdm10/DuongBoDoanhNghiepApp-portlet
930a0628a34a76dbd9e7e96febcd13206366b954
512b03be6cd6d7e2aa9043ab0a9480de5518ce84
refs/heads/master
2021-01-21T13:44:15.439969
2016-04-28T17:39:15
2016-04-28T17:39:15
54,985,320
0
0
null
null
null
null
UTF-8
Java
false
false
1,498
java
/** * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. * * 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. */ package vn.dtt.duongbien.dao.vrcb.model.impl; /** * The extended model implementation for the TempDangerousGoodsItems service. Represents a row in the &quot;TEMP_DANGEROUS_GOODS_ITEMS&quot; database table, with each column mapped to a property of this class. * * <p> * Helper methods and all application logic should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link vn.dtt.duongbien.dao.vrcb.model.TempDangerousGoodsItems} interface. * </p> * * @author longdm */ public class TempDangerousGoodsItemsImpl extends TempDangerousGoodsItemsBaseImpl { /* * NOTE FOR DEVELOPERS: * * Never reference this class directly. All methods that expect a temp dangerous goods items model instance should use the {@link vn.dtt.duongbien.dao.vrcb.model.TempDangerousGoodsItems} interface instead. */ public TempDangerousGoodsItemsImpl() { } }
ea2de537ed6d259166b10d9a5538a7dedd518265
c66123ace7d2c870b7f6b1620cb34a8a1fb05994
/src/main/java/big/repositories/JPAMyClass92Repository.java
b71a5115a150940c986c1e8ea944f4e1910082fb
[]
no_license
jtrentes/jtr_test
843fada2c6533dcc09796b32df3b2acb0570083e
1f25f588297cbf86b199bad0b59275d55cef35a1
refs/heads/master
2020-04-18T07:43:28.087451
2013-08-06T09:27:29
2013-08-06T09:27:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,460
java
package big.repositories; import javax.persistence.TypedQuery; import big.repositories.criteria.MyClass92Criteria; import big.domain.MyClass92; import javax.persistence.EntityManager; import java.util.List; import org.springframework.stereotype.Repository; import javax.persistence.PersistenceContext; @Repository(value = "myclass92Repository") public class JPAMyClass92Repository implements MyClass92Repository { @PersistenceContext private EntityManager entityManager; public List<MyClass92> findAll () { final String hql = "select e from MyClass92 e order by id"; TypedQuery<MyClass92> query = this.entityManager.createQuery(hql, MyClass92.class); return query.getResultList(); } public List<MyClass92> findByCriteria (MyClass92Criteria myClass92Criteria) { javax.persistence.criteria.CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); javax.persistence.criteria.CriteriaQuery<MyClass92> c = cb.createQuery(MyClass92.class); javax.persistence.criteria.Root<MyClass92> emp = c.from(MyClass92.class); c.select(emp); List<javax.persistence.criteria.Predicate> criteria = new java.util.ArrayList<javax.persistence.criteria.Predicate>(); if (myClass92Criteria.getId()!=null ){ javax.persistence.criteria.Expression<Long> p = emp.get("id"); javax.persistence.criteria.Expression<Long> val = cb.parameter(Long.class, "id"); criteria.add(cb.equal(p,val)); } if (criteria.size()==1) { c.where(criteria.get(0)); }else { c.where(cb.and(criteria.toArray(new javax.persistence.criteria.Predicate[0]))); } javax.persistence.TypedQuery<MyClass92> q = this.entityManager.createQuery(c); if (myClass92Criteria.getId()!=null ){ q.setParameter("id", myClass92Criteria.getId()); } return new java.util.ArrayList<MyClass92>(q.getResultList()); } public MyClass92 findById (Long id) { return this.entityManager.find (MyClass92.class, id); } public EntityManager getEntityManager () { return this.entityManager; } public MyClass92 save (MyClass92 myclass92) { if (myclass92.getId() != null) { return this.entityManager.merge(myclass92); } else { this.entityManager.persist(myclass92); return myclass92; } } public void setEntityManager (EntityManager myEntityManager) { this.entityManager = myEntityManager; } public void unsetEntityManager () { this.entityManager = null; } }
0a83d1b3fd60445813fab38612fcded734468468
0af3919d0fd1722f3df643583f96f30a856b2be9
/src/org/first/project/daoAndimpl/RentLogDao.java
eaa238915174f3d4ba4faddd4d6ddb5fda2b4465
[]
no_license
y1x2c3/BookSystem
31b8f8bceeece5f976e7cd9c0bd6b39c2818971f
9b934d9aaa9e390e1001dfb79c053c4b8457181d
refs/heads/master
2020-07-12T15:09:04.885620
2019-10-11T07:57:35
2019-10-11T07:57:35
204,847,302
2
0
null
null
null
null
UTF-8
Java
false
false
1,306
java
package org.first.project.daoAndimpl; /** * 借阅表功能接口 * @author 追风 * @date 2019-8-6 16:32 */ import java.util.List; import org.first.project.model.RentLog; public interface RentLogDao { /** * 借阅一览表 * * @return */ public List<RentLog> getAllRentLog(); /** * 根据isbn和图书证查看借阅信息 * * @param isbn * @param bookCard * @return */ public RentLog getRentLogByIsbnAndBookCard(String isbn, long bookCard); /** * 显示读者信息同步显示未归还的书籍 可能借了多本 * @param bookCard * @return */ public List<RentLog> getRentLogByBookCard(long bookCard); /** * 是否存在该读者 * * @param bookCard * @return */ public boolean isExistReader(long bookCard); /** * 是否存在该图书 * * @param isbn * @return */ public boolean isExistBook(String isbn); /** * 新增借阅 * * @param log * @return */ public int addRentLog(RentLog log); /** * 更新借阅表 * * @param log * @return */ public int updateRentLog(RentLog log); /** * 借阅归还删除 * * @param isbn * @param bookCard * @return */ public int deleteRentLog(String isbn, long bookCard); }
080f16ff31fe968524c200e6f0b244c48b3351ba
476aeb80302d1507948fb2e9ec9a402a1260060f
/src/java/proverbs/utils/Constants.java
65960593b5e536d3a33b0a4e7189f5cba290e836
[]
no_license
soumyaukil/proverb_application
e943a7fa41828207fe17363b0c8abf77b4f375d4
70424f299cdd7c690b9ac3c62f6d19e1eae83d33
refs/heads/master
2021-09-01T20:00:02.551707
2017-12-28T13:41:47
2017-12-28T13:41:47
115,626,895
0
0
null
null
null
null
UTF-8
Java
false
false
981
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 proverbs.utils; /** * * @author soumukil */ public class Constants { public static final String TAG_LOOKUP_STRING = "glyphicon-tag"; public static final String PROVERB_LOOKUP_STRING = "okul-baslik"; public static final String PROVERB_BODY_LOOKUP_STRING = "div.media-body"; public static final String HREF_TAG = "href"; public static final String HIPERLINK_TAG = "a[href]"; public static final String HREF_TAG_LOOKUP_STRING = "atasozleri-sozlugu"; public static final String ORIGIN_LANGUAGE = "TURKISH"; public static final String CRAWL_URL = "http://www.atasozleri.gen.tr"; public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1"; }
9baaca12f8dfa036f22fe9b1aa9905a567bb9095
d5fc2ad147becb33c2647ca02c572caa7ff6d409
/hibernate/AlunoInserir.java
e8c8b7a4701db8d1947c8770ecbe547118cba6be
[]
no_license
Armindo86/SistemaEscolar
944c81634e8ff2c17b2d8789c51b29998f6550b9
04dad26d2f3b166fb52c01aa73d34717cdbe3790
refs/heads/master
2023-08-23T20:05:34.283731
2021-10-03T03:37:12
2021-10-03T03:37:12
412,966,915
0
0
null
null
null
null
UTF-8
Java
false
false
1,076
java
package TrabalhoBanco.hibernate; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Scanner; import TrabalhoBanco.control.ModelController; import TrabalhoBanco.model.Aluno; public class AlunoInserir { Scanner ler = new Scanner(System.in); private ModelController modelCtr = new ModelController(); public void close() { modelCtr.close(); } public void clean() { modelCtr.deleteAll(); } public void inserts() { Aluno teste = new Aluno("everton",1,2,2015,2020); modelCtr.insert(teste); teste = new Aluno("joao",1,2,2015,2018); modelCtr.insert(teste); teste = new Aluno("roberto",1,2,2013,2019); modelCtr.insert(teste); teste = new Aluno("jeison",1,2,2014,2021); modelCtr.insert(teste); teste = new Aluno("everton",1,2,2015,2020); modelCtr.insert(teste); } public static void main(String[] args) { AlunoInserir ex = new AlunoInserir(); ex.clean(); ex.inserts(); ex.close(); } }
36f74363b15e865a1748060b59d06ce0e61f38bb
165e9bd5be617563b8b7060624fdeee4e814621e
/src/test/java/ca/usask/cs/srlab/simcad/index/TestMemoryIndexByCommonsCollection.java
f297b2d670486851614486fdd73c397b75490140
[]
no_license
pombredanne/ca.usask.cs.srlab.simLib
cc2b02ecbb735d50cb51538bc63bcaf0fe82009c
4678b391dce44bf12b2522aaadf4f25e2690ea5c
refs/heads/master
2020-12-02T15:53:49.231281
2013-02-01T18:08:49
2013-02-01T18:08:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
330
java
package ca.usask.cs.srlab.simcad.index; import org.junit.Before; import ca.usask.cs.srlab.simcad.index.memory.MemoryCloneIndexByCommonsCollection; public class TestMemoryIndexByCommonsCollection extends AbstractMemoryIndexTest { @Before public void setup(){ supersetup(new MemoryCloneIndexByCommonsCollection()); } }
51c4163dc8453b06d2fef48bd7eccea7972f1d60
065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be
/ant_cluster/5749/src_1.java
9ee10a68f86098556c48e72dcc60c1221cd5554b
[]
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
7,833
java
/* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE file. */ package org.apache.tools.ant.taskdefs.optional.sound; import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.sound.sampled.DataLine; import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.Project; /** * This class is designed to be used by any AntTask that requires audio output. * It implements the BuildListener interface to listen for BuildEvents and could * be easily extended to provide audio output upon any specific build events * occuring. I have only tested this with .WAV and .AIFF sound file formats. * Both seem to work fine. * * @author Nick Pellow * @version $Revision$, $Date$ */ public class AntSoundPlayer implements LineListener, BuildListener { private File fileSuccess = null; private int loopsSuccess = 0; private Long durationSuccess = null; private File fileFail = null; private int loopsFail = 0; private Long durationFail = null; public AntSoundPlayer() { } /** * @param fileFail The feature to be added to the BuildFailedSound attribute * @param loopsFail The feature to be added to the BuildFailedSound * attribute * @param durationFail The feature to be added to the BuildFailedSound * attribute */ public void addBuildFailedSound( File fileFail, int loopsFail, Long durationFail ) { this.fileFail = fileFail; this.loopsFail = loopsFail; this.durationFail = durationFail; } /** * @param loops the number of times the file should be played when the build * is successful * @param duration the number of milliseconds the file should be played when * the build is successful * @param file The feature to be added to the BuildSuccessfulSound attribute */ public void addBuildSuccessfulSound( File file, int loops, Long duration ) { this.fileSuccess = file; this.loopsSuccess = loops; this.durationSuccess = duration; } /** * Fired after the last target has finished. This event will still be thrown * if an error occured during the build. * * @param event Description of Parameter * @see BuildEvent#getException() */ public void buildFinished( BuildEvent event ) { if( event.getException() == null && fileSuccess != null ) { // build successfull! play( event.getProject(), fileSuccess, loopsSuccess, durationSuccess ); } else if( event.getException() != null && fileFail != null ) { play( event.getProject(), fileFail, loopsFail, durationFail ); } } /** * Fired before any targets are started. * * @param event Description of Parameter */ public void buildStarted( BuildEvent event ) { } /** * Fired whenever a message is logged. * * @param event Description of Parameter * @see BuildEvent#getMessage() * @see BuildEvent#getPriority() */ public void messageLogged( BuildEvent event ) { } /** * Fired when a target has finished. This event will still be thrown if an * error occured during the build. * * @param event Description of Parameter * @see BuildEvent#getException() */ public void targetFinished( BuildEvent event ) { } /** * Fired when a target is started. * * @param event Description of Parameter * @see BuildEvent#getTarget() */ public void targetStarted( BuildEvent event ) { } /** * Fired when a task has finished. This event will still be throw if an * error occured during the build. * * @param event Description of Parameter * @see BuildEvent#getException() */ public void taskFinished( BuildEvent event ) { } /** * Fired when a task is started. * * @param event Description of Parameter * @see BuildEvent#getTask() */ public void taskStarted( BuildEvent event ) { } /** * This is implemented to listen for any line events and closes the clip if * required. * * @param event Description of Parameter */ public void update( LineEvent event ) { if( event.getType().equals( LineEvent.Type.STOP ) ) { Line line = event.getLine(); line.close(); } else if( event.getType().equals( LineEvent.Type.CLOSE ) ) { /* * There is a bug in JavaSound 0.90 (jdk1.3beta). * It prevents correct termination of the VM. * So we have to exit ourselves. */ //System.exit(0); } } /** * Plays the file for duration milliseconds or loops. * * @param project Description of Parameter * @param file Description of Parameter * @param loops Description of Parameter * @param duration Description of Parameter */ private void play( Project project, File file, int loops, Long duration ) { Clip audioClip = null; AudioInputStream audioInputStream = null; try { audioInputStream = AudioSystem.getAudioInputStream( file ); } catch( UnsupportedAudioFileException uafe ) { project.log( "Audio format is not yet supported: " + uafe.getMessage(), Project.MSG_INFO ); } catch( IOException ioe ) { ioe.printStackTrace(); } if( audioInputStream != null ) { AudioFormat format = audioInputStream.getFormat(); DataLine.Info info = new DataLine.Info( Clip.class, format, AudioSystem.NOT_SPECIFIED ); try { audioClip = (Clip)AudioSystem.getLine( info ); audioClip.addLineListener( this ); audioClip.open( audioInputStream ); } catch( LineUnavailableException e ) { project.log( "The sound device is currently unavailable", Project.MSG_INFO ); return; } catch( IOException e ) { e.printStackTrace(); } if( duration != null ) { playClip( audioClip, duration.longValue() ); } else { playClip( audioClip, loops ); } audioClip.drain(); audioClip.close(); } else { project.log( "Can't get data from file " + file.getName(), Project.MSG_INFO ); } } private void playClip( Clip clip, int loops ) { clip.loop( loops ); while( clip.isRunning() ) { } } private void playClip( Clip clip, long duration ) { long currentTime = System.currentTimeMillis(); clip.loop( Clip.LOOP_CONTINUOUSLY ); try { Thread.sleep( duration ); } catch( InterruptedException e ) { } } }
1d3a8a60979d7454597b9e4e41b0b1b42178513e
8a41f9ccbb9066c86f4ef39a73c6d5a8fa35a0c9
/app/src/main/java/com/outsource/monitor/utils/EnvironmentUtils.java
13a1be22b6305bfa10ed0f5aa99e9d05bb28c0f0
[]
no_license
MonitorApp/MyMonitor
d64fc5d83613299789a5b3bb71e6d7e887286104
c5e367dcb70b6cb3786c6912fd73482a177f9d2e
refs/heads/master
2020-06-14T03:07:27.625020
2017-06-24T07:21:41
2017-06-24T07:21:41
75,514,174
0
0
null
null
null
null
UTF-8
Java
false
false
14,542
java
package com.outsource.monitor.utils; import android.Manifest; import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; import android.os.AsyncTask; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.support.v4.content.ContextCompat; import android.telephony.TelephonyManager; import android.text.TextUtils; import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; /** * Environment utility class * * @author hao.xiong * @version 1.0.0 */ public class EnvironmentUtils { private static final String TAG = "EnvironmentUtils"; private static String mPackageName; private static String mSDCardPath; private static String mSecondSDCardPath; private static String mSecondSDCardValidFolder; static { String path = "sdcard"; File pathFile = new File(path); if (!pathFile.exists() || !pathFile.canWrite()) { pathFile = Environment.getExternalStorageDirectory(); } try { path = pathFile.getCanonicalPath(); } catch (Exception ignored) { path = pathFile.getAbsolutePath(); } mSDCardPath = path; } /** * 初始化系统环境 * * @param context 系统环境上下文 */ public static void init(Context context) { Network.init(context); mPackageName = context.getPackageName(); resetAsyncTaskDefaultExecutor(); } /** * 判断手机系统是否是魅族 * @return true - 是 */ public static boolean isFlymeOs() { String displayId = android.os.Build.DISPLAY; return displayId.contains("Flyme"); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void resetAsyncTaskDefaultExecutor() { if (SDKVersionUtils.hasHoneycomb()) { try { Method setDefaultExecutorMethod = AsyncTask.class.getMethod("setDefaultExecutor", Executor.class); ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newCachedThreadPool(); setDefaultExecutorMethod.invoke(null, threadPoolExecutor); final Field defaultHandler = ThreadPoolExecutor.class.getDeclaredField("defaultHandler"); defaultHandler.setAccessible(true); defaultHandler.set(null, new ThreadPoolExecutor.DiscardOldestPolicy()); } catch (Exception e) { e.printStackTrace(); } } } /** * 获取包名 * * @return 包名 */ public static String getPackageName() { return mPackageName; } /** * 存储信息 */ public static class Storage { /** * 外部存储是否可读写 * * @return 可读写返回true, 否则返回false */ public static boolean isExternalStorageWritable() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_MOUNTED.equals(state); } /** * 外部存储是否可读 * * @return 可读返回true, 否则返回false */ public static boolean isExternalStorageReadable() { String state = Environment.getExternalStorageState(); return Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state); } /** * 获取目录可用字节数,目录不存在返回0 * * @param path 目录文件 * @return 字节数 */ public static long getUsableSpace(File path) { if (SDKVersionUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); } /** * 获取外部目录缓存路径 * * @param context context * @return 外部存储换成路径 */ public static File getExternalCacheDir(Context context) { File file = null; if (SDKVersionUtils.hasFroyo()) { file = context.getExternalCacheDir(); } if (file == null) { final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/"; file = new File(Environment.getExternalStorageDirectory().getPath() + cacheDir); } file.mkdirs(); if (file.isDirectory()) { return file; } return null; } /** * 获取SDCard路径 * * @return sdcard路径,不为空 */ public static String getSDCardPath() { return mSDCardPath; } /** * 获取缓存路径 * * @param context context * @return 存储路径 */ public static String getCachePath(Context context) { File file = null; if (isExternalStorageWritable()) { file = getExternalCacheDir(context); } return file != null ? file.getAbsolutePath() : context.getCacheDir().getAbsolutePath(); } /** * 判断是否路径是否可写 * @param path path * @param context context * @return writable */ public static boolean isWritablePath(Context context, String path) { if (!new File(path).canWrite()) { return false; } String filePathPrefix = path + File.separator; int i = 0; while (FileUtils.fileExists(filePathPrefix + i)) { i++; } File testFile = FileUtils.createFile(filePathPrefix + i); if (testFile != null) { testFile.delete(); return true; } return false; } /** * 得到可用路径 * @param context context * @return writablePath */ public static String getWritablePath(Context context) { return mSDCardPath + File.separator + "monitor"; } } /** * 网络信息 */ public static class Network { /** * 无网络 */ public static final int NETWORK_INVALID = -1; /** * 2G网络 */ public static final int NETWORK_2G = 0; /** * wap网络 */ public static final int NETWORK_WAP = 1; /** * wifi网络 */ public static final int NETWORK_WIFI = 2; /** * 3G和3G以上网络,或统称为快速网络 */ public static final int NETWORK_3G = 3; private static final int[] NETWORK_MATCH_TABLE = {NETWORK_2G // NETWORK_TYPE_UNKNOWN , NETWORK_2G // NETWORK_TYPE_GPRS , NETWORK_2G // NETWORK_TYPE_EDGE , NETWORK_3G // NETWORK_TYPE_UMTS , NETWORK_2G // NETWORK_TYPE_CDMA , NETWORK_3G // NETWORK_TYPE_EVDO_O , NETWORK_3G // NETWORK_TYPE_EVDO_A , NETWORK_2G // NETWORK_TYPE_1xRTT , NETWORK_3G // NETWORK_TYPE_HSDPA , NETWORK_3G // NETWORK_TYPE_HSUPA , NETWORK_3G // NETWORK_TYPE_HSPA , NETWORK_2G // NETWORK_TYPE_IDEN , NETWORK_3G // NETWORK_TYPE_EVDO_B , NETWORK_3G // NETWORK_TYPE_LTE , NETWORK_3G // NETWORK_TYPE_EHRPD , NETWORK_3G // NETWORK_TYPE_HSPAP }; private static String mIMEI = ""; private static String mIMSI = ""; private static String mWifiMac = ""; private static NetworkInfo mNetworkInfo; private static int mDefaultNetworkType; private static ConnectivityManager mConnectManager; /** * 初始化默认网络参数 * * @param context 上下文环境 */ public static void init(final Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int permissionCheck = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE); if(permissionCheck == PackageManager.PERMISSION_GRANTED) { mIMEI = telephonyManager.getDeviceId(); } if (mIMEI == null) { mIMEI = ""; } if(permissionCheck == PackageManager.PERMISSION_GRANTED) { mIMSI = telephonyManager.getSubscriberId(); } if (mIMSI == null) { mIMSI = ""; } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { mWifiMac = ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo().getMacAddress(); } catch (Exception e) { //有些机型调用getConnectionInfo方法会报异常 e.printStackTrace(); } if (mWifiMac == null) { mWifiMac = ""; } return null; } }.execute(); mDefaultNetworkType = NETWORK_MATCH_TABLE[telephonyNetworkType(context)]; mConnectManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); mNetworkInfo = mConnectManager.getActiveNetworkInfo(); } /** * 获取IMEI串号 * * @return IMEI串号。<b>有可能为空值</b> */ public static String imei() { return mIMEI; } /** * 获取IMSI移动用户识别码 * * @return IMSI移动用户识别码。<b>有可能为空值</b> */ public static String imsi() { return mIMSI; } /** * 获取Wifi Mac地址 * * @return Wifi Mac地址 */ public static String wifiMac() { return mWifiMac; } /** * 获取网络类型 * * @return 网络类型 */ public static int type() { int networkType = mDefaultNetworkType; if (mConnectManager == null) { //当还未来得及初始化时,另一线程请求网络时通用参数中取此值时先运行到这儿,那么如不做处理将崩溃 return NETWORK_WAP; } mNetworkInfo = mConnectManager.getActiveNetworkInfo(); if (!networkConnected(mNetworkInfo)) { networkType = NETWORK_INVALID; } else if (isWifiNetwork(mNetworkInfo)) { networkType = NETWORK_WIFI; } else if (isWapNetwork(mNetworkInfo)) { networkType = NETWORK_WAP; } return networkType; } /** * 是否存在有效的网络连接. * * @return 存在有效的网络连接返回true,否则返回false */ public static boolean isNetWorkAvailable() { return networkConnected(mConnectManager.getActiveNetworkInfo()); } /** * 获取本机IPv4地址 * * @return 本机IPv4地址 */ public static String ipv4() { return ipAddress(true); } /** * 获取本机IPv6地址 * * @return 本机IPv6地址 */ public static String ipv6() { return ipAddress(false); } private static String ipAddress(boolean useIPv4) { try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface netInterface = en.nextElement(); for (Enumeration<InetAddress> iNetEnum = netInterface.getInetAddresses(); iNetEnum.hasMoreElements();) { InetAddress inetAddress = iNetEnum.nextElement(); if (inetAddress instanceof Inet4Address && !inetAddress.isLoopbackAddress()) { return inetAddress.getHostAddress(); } } } } catch (Exception e) { e.printStackTrace(); } return ""; } /** * 直接从系统函数里得到的network type * * @param context context * @return net type */ private static int telephonyNetworkType(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int networkType = telephonyManager.getNetworkType(); if (networkType < 0 || networkType >= NETWORK_MATCH_TABLE.length) { networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; } return networkType; } private static boolean networkConnected(NetworkInfo networkInfo) { return networkInfo != null && networkInfo.isConnected(); } private static boolean isMobileNetwork(NetworkInfo networkInfo) { return networkInfo.getType() == ConnectivityManager.TYPE_MOBILE; } @SuppressWarnings("deprecation") private static boolean isWapNetwork(NetworkInfo networkInfo) { return isMobileNetwork(networkInfo) && !TextUtils.isEmpty(android.net.Proxy.getDefaultHost()); } private static boolean isWifiNetwork(NetworkInfo networkInfo) { return networkInfo.getType() == ConnectivityManager.TYPE_WIFI; } } }
56b2e1fdbb70a5f1813cad8dd4abeb77fc3dec79
7a63a62866db4a891a5399fa769a0d3ee86e74dd
/exercises/Print_60.java
817c591c9e4bde2f2f1683cc36e7f6aece8e6b00
[]
no_license
huijuanl/JianzhiOffer
38c73eb234bdecba696bf02ca0c731904a700b26
860c6e147be80e482bc20350373ea827751e0216
refs/heads/master
2020-03-24T23:01:50.936271
2018-08-24T08:50:32
2018-08-24T08:50:32
143,114,735
1
0
null
null
null
null
UTF-8
Java
false
false
1,226
java
package JianzhiOffer; import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; //从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。 public class Print_60 { public static class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) { ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); if(pRoot==null) return res; Queue<TreeNode>queue = new LinkedList<TreeNode>(); queue.add(pRoot); while (!queue.isEmpty()){ int size = queue.size(); ArrayList<Integer> tmp = new ArrayList<Integer>(); for(int i =0;i<size;i++){ TreeNode cur = queue.poll(); tmp.add(cur.val); if(cur.left!=null) queue.add(cur.left); if(cur.right!=null) queue.add(cur.right); } res.add(tmp); } return res; } }