blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
09fab7f9b10ace5b3523ab6e45b12f441d46c73e
541b2c0ceac53b935d79fd2cab9ded8d82c09e03
/src/main/java/com/bbs/starter/interceptor/BeforeActionInterceptor.java
0006f0744e44abf8bf07bf57aa13bbd1f5320910
[]
no_license
wwwkim/Springboot-Mybatis-BBS
bb58def3e23dcc6c16cfdc280d7027e25355a407
b8918f55dcc712fcbbcabe0412de54e364834b33
refs/heads/master
2023-03-27T19:26:36.916729
2020-09-01T05:43:59
2020-09-01T05:43:59
280,653,803
0
0
null
2021-03-31T22:10:10
2020-07-18T12:39:31
CSS
UTF-8
Java
false
false
1,284
java
package com.bbs.starter.interceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; import com.bbs.starter.dto.Member; import com.bbs.starter.service.MemberService; @Component("beforeActionInterceptor") public class BeforeActionInterceptor implements HandlerInterceptor { @Autowired MemberService memberService; public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { boolean isLogined = false; long loginedMemberId = 0; Member loginedMember = null; HttpSession session = request.getSession(); if (session.getAttribute("loginedMemberId") != null) { isLogined = true; loginedMemberId = (long) session.getAttribute("loginedMemberId"); loginedMember = memberService.getOne(loginedMemberId); } request.setAttribute("isLogined", isLogined); request.setAttribute("loginedMemberId", loginedMemberId); request.setAttribute("loginedMember", loginedMember); return HandlerInterceptor.super.preHandle(request, response, handler); } }
deed1e08efad7b70727f54f0d06fe5393a565354
51f5beac483cada010f9a41f5718273450a697c1
/pushlibrary/src/main/java/com/believer/mypublisher/googlecode/mp4parser/boxes/mp4/objectdescriptors/DecoderSpecificInfo.java
5ffef8d95b9ae3f0853ea8041e529ce1904823b1
[]
no_license
zkbqhuang/streampusher
c24e9123faf0988c583307fb9174ee10e4c07dd0
ec7d21874c43392a25932caebbbf17148969ccb6
refs/heads/master
2021-09-14T07:06:51.827446
2018-05-09T08:42:36
2018-05-09T08:42:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,249
java
/* * Copyright 2011 castLabs, Berlin * * 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.believer.mypublisher.googlecode.mp4parser.boxes.mp4.objectdescriptors; import com.believer.mypublisher.coremedia.iso.Hex; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; /** * abstract class DecoderSpecificInfo extends BaseDescriptor : bit(8) * tag=DecSpecificInfoTag * { * // empty. To be filled by classes extending this class. * } */ @Descriptor(tags = 0x05) public class DecoderSpecificInfo extends BaseDescriptor { byte[] bytes; @Override public void parseDetail(ByteBuffer bb) throws IOException { if (sizeOfInstance > 0) { bytes = new byte[sizeOfInstance]; bb.get(bytes); } } public int serializedSize() { return bytes.length; } public ByteBuffer serialize() { ByteBuffer out = ByteBuffer.wrap(bytes); return out; } @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("DecoderSpecificInfo"); sb.append("{bytes=").append(bytes == null ? "null" : Hex.encodeHex(bytes)); sb.append('}'); return sb.toString(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DecoderSpecificInfo that = (DecoderSpecificInfo) o; if (!Arrays.equals(bytes, that.bytes)) { return false; } return true; } @Override public int hashCode() { return bytes != null ? Arrays.hashCode(bytes) : 0; } }
0947b7346c63bc525bb7a735c8c4fb008c50022d
01aeac2759b1990ddd505788ded8fd9d9a1423b5
/runner/src/test/java/com/frocate/taskrunner/AbstractTaskTest.java
8138d90b9cb36067bc1cb5bce28cc88f194f6d89
[]
no_license
dmitrymurashenkov/frocate
46fca89aee1f6834d89691521c5986202ba59f9a
823a67bcaad05bc1f26a149cba82804b1f393eff
refs/heads/master
2021-01-12T11:45:19.933604
2016-10-30T11:51:22
2016-10-30T11:51:22
72,290,449
0
0
null
null
null
null
UTF-8
Java
false
false
7,069
java
package com.frocate.taskrunner; import com.frocate.taskrunner.executable.Executable; import com.frocate.taskrunner.executable.ExecutableType; import com.frocate.taskrunner.junit.TaskProgress; import com.frocate.taskrunner.result.ProgressListener; import com.frocate.taskrunner.result.TestResult; import org.junit.Test; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; public class AbstractTaskTest { @Test public void run_shouldAddErrorIfExceptionThrown() { try (Env env = new EnvImpl("build1")) { Task task = new StubTask() { @Override protected void runTests(Executable executableOnHost, Env env, ProgressListener listener) { progress = new TaskProgress(Arrays.asList( new TestResult("test1", true, null) ), new ArrayList<>(), 2, null, 0); throw new RuntimeException("Error"); } }; TaskResult result = task.run(buildExecutable(), env, ProgressListener.STUB); assertEquals(2, result.getTotalTests()); assertEquals(Arrays.asList( new TestResult("test1", true, null), new TestResult("Tests should finish without exceptions", false, "Unexpected exception: Error") ), result.getTests()); } } @Test public void run_shouldCreateEmptyLogFiles_ifNoneReturnedByTask() { try (Env env = new EnvImpl("build1")) { Task task = new StubTask(); TaskResult result = task.run(buildExecutable(), env, ProgressListener.STUB); assertEquals("", FileUtils.readContent(result.getExecutableLog())); assertEquals("", FileUtils.readContent(result.getTestLog())); } } @Test public void run_returnLogFilesSetByImpl() { try (Env env = new EnvImpl("build1")) { Task task = new StubTask() { @Override protected void runTests(Executable executableOnHost, Env env, ProgressListener listener) { executableLog = FileUtils.createTmpFileWithContent("executableLog"); testLog = FileUtils.createTmpFileWithContent("testLog"); } }; TaskResult result = task.run(buildExecutable(), env, ProgressListener.STUB); assertEquals("executableLog", FileUtils.readContent(result.getExecutableLog())); assertEquals("testLog", FileUtils.readContent(result.getTestLog())); } } @Test public void awaitTestsComplete_shouldReturnLastAvailableProgressFile() { try (Env env = new EnvImpl("build1")) { VM testVM = env.createVM("tests"); testVM.start(); ProcessFuture future = testVM.runCommand("sleep 0"); copyTaskProgressToVM(testVM, new TestResult("test1")); AbstractTask task = new StubTask(); Listener listener = new Listener(); TaskProgress progress = task.awaitTestsComplete(env, testVM, future, 1, listener); assertTrue(listener.progressList.size() > 0); assertEquals(Arrays.asList(new TestResult("test1")), progress.getTests()); assertEquals(1, progress.getTotalTests()); } } @Test public void awaitTestsComplete_shouldAddReturnErrorIfTimeout() { try (Env env = new EnvImpl("build1")) { VM testVM = env.createVM("tests"); testVM.start(); ProcessFuture future = testVM.runCommand("sleep 5"); copyTaskProgressToVM(testVM, new TestResult("test1")); AbstractTask task = new StubTask(); Listener listener = new Listener(); TaskProgress progress = task.awaitTestsComplete(env, testVM, future, 1, listener); assertTrue(listener.progressList.size() > 0); assertEquals(Arrays.asList( new TestResult("test1"), new TestResult("Tests should finish in 1 seconds", false, "Tests timed out") ), progress.getTests()); assertEquals(1, progress.getTotalTests()); } } @Test public void awaitTestsComplete_shouldAddReturnErrorIfNoProgressFileProduced() { try (Env env = new EnvImpl("build1")) { VM testVM = env.createVM("tests"); testVM.start(); ProcessFuture future = testVM.runCommand("sleep 0"); AbstractTask task = new StubTask(); Listener listener = new Listener(); TaskProgress progress = task.awaitTestsComplete(env, testVM, future, 1, listener); assertTrue(listener.progressList.size() > 0); assertEquals(Arrays.asList( new TestResult("Tests should finish without errors", false, "Tests failed to produce results, seems some internal error") ), progress.getTests()); assertEquals(0, progress.getTotalTests()); } } private Executable buildExecutable() { File jarPath = new File(System.getProperty("mock-executable-jar-path", JarRunnerTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "../mock-jar/mock-executable.jar")); return new Executable(jarPath, ExecutableType.JAR); } private void copyTaskProgressToVM(VM vm, TestResult testResult) { TaskProgress progress = new TaskProgress(Arrays.asList(testResult), new ArrayList<>(), 1, null, 0); File tmp = FileUtils.createTmpFile(); progress.save(tmp); vm.copyFromHost(tmp, AbstractTask.PROGRESS_FILE_IN_VM); } static class Listener implements ProgressListener { private List<TaskProgress> progressList = new ArrayList<>(); @Override public void onProgress(String buildId, TaskProgress progress) { progressList.add(progress); } } static class StubTask extends AbstractTask { @Override protected void runTests(Executable executableOnHost, Env env, ProgressListener listener) { } @Override public String getId() { return null; } @Override public String getName() { return null; } @Override public String getShortDescription() { return null; } @Override public String getDescription() { return null; } @Override public Collection<String> getTags() { return null; } } }
e90f62cad6ad9b44967dcc658a81311854c06429
3be625511c617eb28d9e73525a16e3ea08bdea5b
/auth-app/src/main/java/com/broad/security/auth/client/domain/OAuthToken.java
9d461c87d07120213fc0ae42f067c4618a8e13fc
[]
no_license
Yuedecky/auth-around
e6f0797b43f748e0a89d7d862b9773f0b9629d86
53c03ad70d4dddc2faed0bd17be1d409e2a66669
refs/heads/master
2020-04-20T07:04:43.315328
2019-07-04T14:29:32
2019-07-04T14:29:32
168,701,888
0
1
null
null
null
null
UTF-8
Java
false
false
421
java
package com.broad.security.auth.client.domain; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; @Data public class OAuthToken { @JsonProperty("access_token") private String accessToken; @JsonProperty("token_type") private String tokenType; @JsonProperty("expires_in") private String expiresIn; @JsonProperty("refresh_token") private String refreshToken; }
[ "yzy091633" ]
yzy091633
4ff570106ae1dd945c8b42957c307185e7d8e72b
f4625b429364037d154a99739b827e1fb0b979e1
/build/app/generated/source/buildConfig/debug/com/example/calculadora_simples/BuildConfig.java
f35c9c24ae45fdb49bdf9d888e3978dc9b3c03f3
[]
no_license
gaabipacheco/trabalho3
3a00437283473578f824f167c7644150c2429703
2a1187669807906381fb847a49749dc55ecd1c4d
refs/heads/master
2023-06-25T13:12:04.876296
2021-07-24T20:14:46
2021-07-24T20:14:46
389,191,366
0
0
null
null
null
null
UTF-8
Java
false
false
429
java
/** * Automatically generated file. DO NOT MODIFY */ package com.example.calculadora_simples; public final class BuildConfig { public static final boolean DEBUG = Boolean.parseBoolean("true"); public static final String APPLICATION_ID = "com.example.calculadora_simples"; public static final String BUILD_TYPE = "debug"; public static final int VERSION_CODE = 1; public static final String VERSION_NAME = "1.0.0"; }
85b22ff504c9e7f63b524c3c596815ccfb816733
2439358c701013d381ab8b74305c56c5628d79db
/src/NodeWindow.java
262e66dbd2338140f3489482b672dc0a734a8a3f
[]
no_license
JordanTFA/Jordans-Sound-Control
ab45d0f92b627831eaca04b5138d21b4a8758c64
bd89c4013f111f64207402f915112bb5cf6ae0d3
refs/heads/master
2018-11-08T15:49:10.887513
2018-10-15T22:36:47
2018-10-15T22:36:47
125,776,389
0
0
null
null
null
null
UTF-8
Java
false
false
2,050
java
import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ColorPicker; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.stage.Modality; import javafx.stage.Stage; public class NodeWindow { public static void display(){ Stage window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle("Node Selection"); window.setMinWidth(250); window.setMinHeight(355); window.setResizable(false); final Circle preview = new Circle(); final Label instr = new Label("Select a colour and a name for the node"); final ColorPicker colourPicker = new ColorPicker(Color.GREEN); final Button ok = new Button("Okay"); final TextField chooseName = new TextField(); final Label lbl = new Label(); preview.setFill(colourPicker.getValue()); preview.setRadius(75); VBox vbox = new VBox(preview, instr, chooseName, colourPicker, ok); vbox.setAlignment(Pos.CENTER); vbox.setPadding(new Insets(10,10,10,10)); colourPicker.setOnAction( e -> preview.setFill(colourPicker.getValue()) ); chooseName.textProperty().addListener((observable) -> { StackPane stack = new StackPane(); lbl.setText(""); String content = chooseName.getText(); if(content.length() < 3){ lbl.setText(content.substring(0,content.length())); }else{ lbl.setText(content.substring(0,3)); } lbl.setStyle("-fx-font:56 arial;"); stack.getChildren().addAll(preview, lbl); vbox.getChildren().add(0, stack); }); ok.setOnAction(e -> { // Get name & Colour then create node Node node = new Node(lbl.getText(), colourPicker.getValue(), 0.0, 0.0, 0.0, ""); Main.addNode(node); window.close(); }); Scene scene = new Scene(vbox); window.setScene(scene); window.showAndWait(); } }
e58a33fb80c349948b7b4d4ca12a4e2eb1ed231f
ed3cb95dcc590e98d09117ea0b4768df18e8f99e
/project_1_2/src/b/g/i/e/Calc_1_2_16845.java
c41d07661c9e9f4d7bdd8675e0c887b56b5715f5
[]
no_license
chalstrick/bigRepo1
ac7fd5785d475b3c38f1328e370ba9a85a751cff
dad1852eef66fcec200df10083959c674fdcc55d
refs/heads/master
2016-08-11T17:59:16.079541
2015-12-18T14:26:49
2015-12-18T14:26:49
48,244,030
0
0
null
null
null
null
UTF-8
Java
false
false
134
java
package b.g.i.e; public class Calc_1_2_16845 { /** @return the sum of a and b */ public int add(int a, int b) { return a+b; } }
3701eae8c4894145d82685561a97789a3deea01f
341048676cf6922f696e3e59b862f00f1b356f03
/android/src/main/java/com/lwansbrough/RCTCamera/RCTCameraViewFinder.java
a52048aab3048f5cae62d9acbc721e6b3ea2b93d
[ "MIT" ]
permissive
javiercf/react-cam-fd
95039fb5e7e6fc66942f9144654573556320d637
3d2147c5d3e3f305af3aafe79bd66a1fa93e136f
refs/heads/master
2021-01-22T13:30:35.067748
2017-08-18T03:30:19
2017-08-18T03:30:19
100,669,329
0
0
null
null
null
null
UTF-8
Java
false
false
6,834
java
/** * Created by Fabrice Armisen ([email protected]) on 1/3/16. */ package com.lwansbrough.RCTCamera; import android.content.Context; import android.graphics.SurfaceTexture; import android.graphics.Matrix; import android.graphics.RectF; import android.hardware.Camera; import android.util.Log; import android.view.TextureView; import android.util.DisplayMetrics; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; import java.util.List; class RCTCameraViewFinder extends TextureView implements TextureView.SurfaceTextureListener { private int _cameraType; private SurfaceTexture _surfaceTexture; private boolean _isStarting; private boolean _isStopping; private Camera _camera; public RCTCameraViewFinder(Context context, int type) { super(context); this.setSurfaceTextureListener(this); this._cameraType = type; } @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { _surfaceTexture = surface; startCamera(); } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { } @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { _surfaceTexture = null; stopCamera(); return true; } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) { } private Camera.FaceDetectionListener faceDetectionListener = new Camera.FaceDetectionListener() { @Override public void onFaceDetection(Camera.Face[] faces, Camera camera) { if (faces.length > 0) { Matrix matrix = new Matrix(); boolean frontCamera = (getCameraType() == RCTCameraModule.RCT_CAMERA_TYPE_FRONT); int height = getHeight(); int width = getWidth(); matrix.setScale(frontCamera ? -1 : 1, 1); matrix.postRotate(RCTCamera.getInstance().getOrientation()); matrix.postScale(width / 2000f, height / 2000f); matrix.postTranslate(width / 2f, height / 2f); double pixelDensity = getPixelDensity(); for (Camera.Face face : faces) { RectF faceRect = new RectF(face.rect); matrix.mapRect(faceRect); WritableMap faceEvent; faceEvent = Arguments.createMap(); faceEvent.putInt("faceID", face.id); faceEvent.putBoolean("isFrontCamera", frontCamera); faceEvent.putDouble("x", faceRect.left / pixelDensity); faceEvent.putDouble("y", faceRect.top / pixelDensity); faceEvent.putDouble("h", faceRect.height() / pixelDensity); faceEvent.putDouble("w", faceRect.width() / pixelDensity); ((ReactContext) getContext()).getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("CameraFaceDetected", faceEvent); } } } private int getCameraType() { return _cameraType; } }; public double getPixelDensity() { DisplayMetrics dm = getContext().getResources().getDisplayMetrics(); return dm.density; } public double getRatio() { int width = RCTCamera.getInstance().getPreviewWidth(this._cameraType); int height = RCTCamera.getInstance().getPreviewHeight(this._cameraType); return ((float) width) / ((float) height); } public void setCameraType(final int type) { if (this._cameraType == type) { return; } new Thread(new Runnable() { @Override public void run() { stopPreview(); _cameraType = type; startPreview(); } }).start(); } public void setCaptureQuality(String captureQuality) { RCTCamera.getInstance().setCaptureQuality(_cameraType, captureQuality); } public void setTorchMode(int torchMode) { RCTCamera.getInstance().setTorchMode(_cameraType, torchMode); } public void setFlashMode(int flashMode) { RCTCamera.getInstance().setTorchMode(_cameraType, flashMode); } private void startPreview() { if (_surfaceTexture != null) { startCamera(); } } private void stopPreview() { if (_camera != null) { stopCamera(); } } synchronized private void startCamera() { if (!_isStarting) { _isStarting = true; try { _camera = RCTCamera.getInstance().acquireCameraInstance(_cameraType); Camera.Parameters parameters = _camera.getParameters(); // set autofocus List<String> focusModes = parameters.getSupportedFocusModes(); if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) { parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); } // set picture size // defaults to max available size Camera.Size optimalPictureSize = RCTCamera.getInstance().getBestPictureSize(_cameraType, Integer.MAX_VALUE, Integer.MAX_VALUE); parameters.setPictureSize(optimalPictureSize.width, optimalPictureSize.height); _camera.setParameters(parameters); _camera.setPreviewTexture(_surfaceTexture); _camera.startPreview(); if(parameters.getMaxNumDetectedFaces() > 0) { _camera.setFaceDetectionListener(faceDetectionListener); _camera.startFaceDetection(); } } catch (NullPointerException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); stopCamera(); } finally { _isStarting = false; } } } synchronized private void stopCamera() { if (!_isStopping) { _isStopping = true; try { if (_camera != null) { _camera.stopPreview(); RCTCamera.getInstance().releaseCameraInstance(_cameraType); _camera = null; } } catch (Exception e) { e.printStackTrace(); } finally { _isStopping = false; } } } }
6fe760cb3bbcce9db9cca84dbc126294dbaabb86
7edc6fcdff878c9b9aa8448a34c03e5cd41eba49
/src/main/java/com/deng/o2o/service/impl/ShopServiceImpl.java
924f7b8c8f6907ed48b1dbc57cc2196305f1defd
[]
no_license
dengcong139/o2o
178cf255557dee9d23f3d499c5e776a449d5b462
9c3201226e98428a42c310d7a872d924f79c18ee
refs/heads/master
2020-03-24T20:23:10.895275
2018-07-31T07:01:16
2018-07-31T07:01:16
142,975,366
0
0
null
null
null
null
UTF-8
Java
false
false
5,660
java
package com.deng.o2o.service.impl; import java.util.Date; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.deng.o2o.dao.ShopDao; import com.deng.o2o.dto.ImageHolder; import com.deng.o2o.dto.ShopExecution; import com.deng.o2o.entity.Shop; import com.deng.o2o.enums.ShopStateEnum; import com.deng.o2o.exceptions.ProductCategoryOperationException; import com.deng.o2o.service.ShopService; import com.deng.o2o.util.ImageUtil; import com.deng.o2o.util.PageCalculator; import com.deng.o2o.util.PathUtil; @Service public class ShopServiceImpl implements ShopService { @Autowired private ShopDao shopDao; /*@Transactional//添加事务的相关操作 @Override public ShopExecution addShop(ShopRegisterVo shopRegisterVo, MultipartFile file, String fileName) throws Exception { //空值判断 if(!StringUtils.isEmpty(shopRegisterVo)) { return new ShopExecution(ShopStateEnum.NULL_SHOP);//将枚举类型作为参数进行传递,可以进行检查 } //String addShopImg = addShopImg(Long.parseLong(UUID.randomUUID().toString()), file.getInputStream(), fileName); //shopRegisterVo.setShopImg(addShopImg); shopDao.insertShop(shopRegisterVo); return new ShopExecution(ShopStateEnum.CHECK,new Shop()); }*/ @Override @Transactional//添加事务的相关操作 public ShopExecution addShop(Shop shop, ImageHolder thumbnail) {//添加店铺方法的返回值为dto中的一个具体类,可以收集相关信息 //空值判断 if(shop == null) { return new ShopExecution(ShopStateEnum.NULL_SHOP);//将枚举类型作为参数进行传递,可以进行检查 } try { //给店赋值初始值 shop.setEnableStatus(0);//0表示店铺审核中 shop.setCreateTime(new Date()); shop.setLastEditTime(new Date()); //1.添加店铺信息 int effectedNum=shopDao.insertShop(shop); //throw new ShopOperationException("店铺创建失败!"); /* * Spring默认对RuntimeException进行事务回滚 * 使用RuntimeException来维持事务的原子性, * 保证1.添加店铺信息;2.图片处理;3.处理完图片之后添加到店铺; * 这三个操作要么全部成功执行,要么全部执行失败 * */ if(effectedNum <=0) { throw new ProductCategoryOperationException("店铺创建失败!"); }else { if(thumbnail !=null) { //2.存储图片 try { addShopImg(shop, thumbnail ); }catch(Exception e) { throw new ProductCategoryOperationException("addShopImg error:" + e.getMessage()); } //3.更新店铺的图片地址 effectedNum=shopDao.updateShop(shop); if(effectedNum <=0) { throw new ProductCategoryOperationException("更新图片地址失败!"); } } } }catch(Exception e) { throw new ProductCategoryOperationException("addShop error:" + e.getMessage()); } return new ShopExecution(ShopStateEnum.CHECK,shop); }//除了shop的判断,还需要对category以及area等做判断(后期添加) private void addShopImg(Shop shop, ImageHolder thumbnail) { //获取shop图片目录的相对值路径 String dest = PathUtil.getShopImagePath(shop.getShopId()); String shopImgAddr =ImageUtil.generateThumbnail( thumbnail,dest); shop.setShopImg(shopImgAddr); } /*private String addShopImg(Long id, InputStream shopImgInputStream,String fileName) { //获取shop图片目录的相对值路径 String dest = PathUtil.getShopImagePath(id); return ImageUtil.generateThumbnail(shopImgInputStream, fileName,dest); }*/ /* * 通过id查找店铺信息 * */ @Override public Shop getByShopId(Long shopId) { return shopDao.queryByShopId(shopId); } /* * 根据传入的店铺信息,以及图片流来修改店铺信息 * */ @Override public ShopExecution modifyShop(Shop shop, ImageHolder thumbnail) throws ProductCategoryOperationException { if(shop ==null ||shop.getShopId() ==null) { return new ShopExecution(ShopStateEnum.NULL_SHOP); }else { //1.判断是否需要处理图片 try { if(thumbnail.getImage() !=null && thumbnail.getImageName() != null && !"" .equals(thumbnail.getImageName())) { //如果图片不为空先获取shop之前的地址 Shop tempShop = shopDao.queryByShopId(shop.getShopId()); if(tempShop.getShopImg() !=null) { //如果之前的图片地址不为空,需要使用工具类将之前的图片地址删除掉 ImageUtil.deleteFileOrPath(tempShop.getShopImg()); } //生成新的图片 addShopImg(shop, thumbnail); } //2.更新店铺信息 shop.setLastEditTime(new Date()); int effectedNum = shopDao.updateShop(shop); if(effectedNum <=0) { return new ShopExecution(ShopStateEnum.INNER_ERROR); }else { shop = shopDao.queryByShopId(shop.getShopId()); return new ShopExecution(ShopStateEnum.SUCCESS,shop); }}catch(Exception e) { throw new ProductCategoryOperationException("modifyShop error:" + e.getMessage()); } } } /* * 根据shopCondition分页返回相应店铺列表 * */ @Override public ShopExecution getShopList(Shop shopCondition, int pageIndex, int pageSize) { int rowIndex = PageCalculator.calculateRowIndex(pageIndex, pageSize); List<Shop> shopList = shopDao.queryShopList(shopCondition, rowIndex, pageSize); int count = shopDao.queryShopCount(shopCondition); ShopExecution se=new ShopExecution(); if(shopList!=null) { se.setShopList(shopList); se.setCount(count); }else { se.setState(ShopStateEnum.INNER_ERROR.getState()); } return se; } }
e1c0e4a6683b07698e349e9a9346158fb071fd91
d197d0cffd9ba7d7120ce73036d74d959a57e35b
/app/src/main/java/com/example/addresschangedialog/AddressItemView.java
bb773cdab01bd4e865f71be6a0e853cda9d82f52
[]
no_license
CasWen/AddressDialog
a38614599b7ba837c375148a8da2acdf03a15212
7a4e0a41658fc08c3fa9abd929611f367b514ca3
refs/heads/master
2020-07-06T16:53:28.765539
2019-08-19T02:59:04
2019-08-19T02:59:04
203,084,152
1
0
null
null
null
null
UTF-8
Java
false
false
122
java
package com.example.addresschangedialog; /** * Created by zhongwenjie on 2019/8/16. */ interface AddressItemView { }
01ef9c627889cf592c16f413ac8e39dec20c7f53
79b2f1664f8896507fce63e0ec9f5057c02cecb8
/src/main/java/com/spring/starter/exception/GlobalExceptionHandler.java
d6f2d829ce5b308c353cb8d1b6e6b567ad5327fd
[]
no_license
mattruddy/SpringAuthStarter
5947ab948e7a749a49686a59c59a18665816f46f
39e57b3409d65ee7f3a79bd7804f2c3ed2bb51f8
refs/heads/master
2021-04-13T23:51:20.927770
2020-03-22T14:23:05
2020-03-22T14:23:05
249,195,854
2
0
null
null
null
null
UTF-8
Java
false
false
1,424
java
package com.spring.starter.exception; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; @ControllerAdvice public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler(ServiceException.class) protected ResponseEntity<Error> handleServiceException(ServiceException e) { Error error = createError(e.getMessage(), e.code); return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST); } @Override protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { Error error = createError(ex.getBindingResult().getFieldError().getDefaultMessage(), 400); return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST); } private Error createError(String message, int code) { Error error = new Error(); error.setCode(code); error.setMessage(message); return error; } }
8bf2709bf1585b45f4694e4baa58e590ebe8ab41
0706a1e05ca4177eb7ea51a8cbf1cf9e11eae8b7
/myboard/src/main/java/tommy/spring/web/common/BeforeAdvice.java
00f241fe2a96c391025b2a6b7789f27b5ee1a311
[]
no_license
woongpark-9/springExam2
bb75b4581899f81f57870bd81462b19f6406a7e3
8e0bacf3319e41990be002a4ec4f2bf7d7343809
refs/heads/master
2023-03-20T06:58:19.257439
2021-03-19T11:18:44
2021-03-19T11:18:44
347,916,664
0
0
null
null
null
null
UHC
Java
false
false
661
java
package tommy.spring.web.common; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Service; @Service @Aspect public class BeforeAdvice { @Pointcut("execution(* tommy.spring.web..*Impl.*(..))") public void allPointcut() { } @Before("allPointcut()") public void beforeLog(JoinPoint joinPoint) { String method = joinPoint.getSignature().getName(); Object[] args = joinPoint.getArgs(); // System.out.println("[사전처리] : "+method + "() 메서드의 args 정보 : "+args[0].toString()); } }
f0c719f6ed8d6276ad6da7abe8a48abc956a83e1
f6e44733e10d0e9ac681c6e79e71f018381172a2
/app/src/androidTest/java/com/example/android/simpleblog/ApplicationTest.java
146787611808ab4872c628f7c5de16e0180f6d0e
[]
no_license
TingaZ/Simple_Blog
20edaf1f1ad25119333e274e76e62f7da2e678bb
1f7f9cd5601ddee04e6576c085025e416a1bb347
refs/heads/master
2020-06-15T14:00:53.191882
2016-12-01T11:42:18
2016-12-01T11:42:18
75,287,172
0
0
null
null
null
null
UTF-8
Java
false
false
361
java
package com.example.android.simpleblog; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
289c704b31b2b8afe34858981e0199978ed316bb
6de79f6ab24f48e37cdaa406df2f5ae0cc6bc674
/tree/NonEmptyTree.java
68f600efeee6a9443f998b061630b95dd9dacece
[]
no_license
Wllmgong/Object_oriented
72de509ed11f58a7d90135e1d5fbf0e8fe0c3b11
b5ea01416cef197783c35f4b6b2b14cee0844ae0
refs/heads/master
2021-01-23T10:44:04.784406
2017-05-31T21:57:52
2017-05-31T21:57:52
93,088,328
0
0
null
null
null
null
UTF-8
Java
false
false
8,626
java
package tree; /** * * @author William Gong Name:William * Gong Section:0303 ID:113510311 Directory * ID:wgong1 * Honor Code:I pledge on my honor that i have not give or * received any unauthorized assistance on this assignment * * The purpose of the project is to create a polymorphic tree that uses * a emptytree class and a nonempty class. When a subtree is empty, the * emptytree class is called, and when the tree is not empty, then * nonemptytree is called This is the NonEmptyTree class for the tree * interface. This class serves for the values that contains a key and a * value. Its a data storage that finds the value by matching the key it * finds. The empty tree acts like the base case that ends the recursion * calls in the methods The values stored in left are smaller than the * root, and the values stored in right are larger than the root * @param <K> * @param <V> */ @SuppressWarnings("unchecked") public class NonEmptyTree<K extends Comparable<K>, V> implements Tree<K, V> { private K key; // the key that points to the value private V value; // the value to be stored private Tree<K, V> left; // left subtree private Tree<K, V> right;// right subtree /** * the constructor for the nonemptytree class that creates a new * nonemptytree with the given key and value * * @param newKey * @param newVal */ public NonEmptyTree(K newKey, V newVal) { key = newKey; value = newVal; left = EmptyTree.getInstance();// set the left subtree as empty right = EmptyTree.getInstance();// set the right subtree as empty } /** * it adds a new nonempty tree to the original tree and either becomes the * root, left subtree or the right subtree if the key equals to an already * existing tree, the value is replaced */ public NonEmptyTree<K, V> add(K keyToAdd, V valueToAdd) { if (keyToAdd == null || valueToAdd == null) throw new NullPointerException(); // check for null if (key.equals(keyToAdd)) { value = valueToAdd;// when the key is equal already existing tree, // it replaces the new value return this; } if (key.compareTo(keyToAdd) > 0) { // if the keytoadd is less than the key, then its added to the left left = left.add(keyToAdd, valueToAdd); return this; } else { // if the keytoadd is more than the key, then its added to the right right = right.add(keyToAdd, valueToAdd); return this; } } /** * returns the size of the nonemptytree */ public int size() { return 1 + left.size() + right.size(); // adds the left subtree size and right subtree size // plus the current tree } /** * it goes through the tree and finds the key and returns the value the key * points to */ public V lookup(K keyToLookFor) { if (keyToLookFor == null) throw new NullPointerException(); // check if the keytolookfor is null and returns the null exception if // it is null if (key.equals(keyToLookFor)) return value; // finds the key in the tree and returns the value in that tree if (key.compareTo(keyToLookFor) > 0) return left.lookup(keyToLookFor); // if key to look for is less than the key, then to // looks in the left tree else return right.lookup(keyToLookFor); // if key to look for is more than the key, then to // looks in the right tree } /** * it returns the string form of the tree, which contains the key and the * value */ public String toString() { String str = ""; if (!left.toString().equals("")) { str = str + left.toString() + " "; } // first finds the left subtree's keys and values until it reaches to // the end, then it adds the string form of the subtree to string str = str + key.toString() + "+" + value.toString(); // adds the root key and value to the string if (!(right.toString().equals(""))) { str = str + " " + right.toString(); } // finds the right sub tree substring and adds to the string return str; } /** * this method copies a new tree of the current tree and returns the new * tree */ public Tree<K, V> copy() { NonEmptyTree<K, V> one = new NonEmptyTree<K, V>(key, value); // creates a new nonemptytree with the same values one.left = this.left.copy(); // copies the left subtree one.right = this.right.copy(); // copies the right subtree return (Tree<K, V>) one; // return the new tree } /** * this method copies the subtree that's below the given key */ public Tree<K, V> subTree(K keyOfSubTree) { if (keyOfSubTree == null) throw new NullPointerException(); if (key == keyOfSubTree) { return this.copy(); } // first finds the key, then create a copy of the subtree if (key.compareTo(keyOfSubTree) > 0) // finds the key by checking left if its less than the current return left.subTree(keyOfSubTree); else // finds the key by checking the right if its more than the current return right.subTree(keyOfSubTree); } /** * this method removes the subtree of the given key, it copies the tree * until it reaches the key, then it just set the subtree as empty trees */ public Tree<K, V> removeSubTree(K keyOfSubTree) { if (keyOfSubTree == null) throw new NullPointerException(); NonEmptyTree<K, V> one = new NonEmptyTree<K, V>(key, value); if (key.equals(keyOfSubTree)) return EmptyTree.getInstance(); // finds the keyofsubtree within the tree, then it sets it as a // emptytree one.left = this.left.removeSubTree(keyOfSubTree); // copies left subtree one.right = this.right.removeSubTree(keyOfSubTree); // copites right subtree return (Tree<K, V>) one; } /** * It finds the tree at the most left for the given level. I used a helper * method for this to create a counter that counts the level as the method * goes through every level */ public K leftMostAtLevel(int level) { return leftMostAtLevel(level, 0); } public K leftMostAtLevel(int level, int count) { if (level - 1 == count) return key; // finds the level and returns the key if (count > level) return null; // if the level goes past the given level, then null is returned if (left.leftMostAtLevel(level, count + 1) == null) // first check if going left reaches null, if it doesnt, keep going // left return right.leftMostAtLevel(level, count + 1); return left.leftMostAtLevel(level, count + 1); // if going left reaches null, then go right } /** * finds the max value, since the tree is sorted in order, the max value * should be at the end of right side */ public K max() throws EmptyTreeException { try { return right.max();// return the max value recursively } catch (EmptyTreeException k) { return key; } // it keeps going right until right before it reaches the end, since // the empty tree returns an exception } /** * finds the min value, since the tree is sorted in order, the min value * should be at the end of left side */ public K min() throws EmptyTreeException { try { return left.min();// return the min value recursively } catch (EmptyTreeException k) { return key; } } /** * the method deletes a leaf from the tree, and takes a value from the tree * to balance the tree after the leaf has been deleted.Then it deletes * recursively until the key is deleted and the tree has balanced by being * replaced. * */ public Tree<K, V> delete(K keyToDelete) { if (keyToDelete == null) throw new NullPointerException(); // checks for null if (key.compareTo(keyToDelete) > 0) left = left.delete(keyToDelete); // looks for the key in the tree, if its smaller than the current key // checks left first else if (key.compareTo(keyToDelete) < 0) right = right.delete(keyToDelete); // if its the current is greater than it checks right else // if the key is equal try { // this try block catches the exception from the max method value = lookup(left.max());// finds the value, and replaces the // current value key = left.max(); // replaces the key with max left = left.delete(key); // then recursively deletes until it reaches the end } catch (EmptyTreeException k) { try { value = lookup(right.min()); key = right.min(); right = right.delete(key); // same done previously except with right min } catch (EmptyTreeException e) { return EmptyTree.getInstance(); // if both max and min has an exception then it returns the // empty tree } } return this; // return the tree after it has been deteled } }
df0629b4a4b108b679a1b3e9723f365ecdba4ddc
ff5047c91cd445d61f0e6891ed40d5ee2a78f888
/PINApp/src/PINFrame1.java
51bff92643d8ce47f9ca5cb553be59784b6fa3db
[]
no_license
bmcveigh/Java
1bf604dd78e3fac9bc097082620c7c4bdd15a7bc
fe16fcf49819609311622aae9ddcaf314f3341d3
refs/heads/master
2020-04-06T05:25:50.834689
2014-07-31T20:09:46
2014-07-31T20:09:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,264
java
import javax.swing.JFrame; import javax.swing.JTextField; import java.awt.FlowLayout; import javax.swing.JLabel; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.JOptionPane; public class PINFrame1 extends JFrame { /** * */ private static final long serialVersionUID = -11240989827984138L; private JTextField pinField = new JTextField(4); private JLabel pinLabel = new JLabel("PIN:"); private String userPIN = ""; public PINFrame1() { super("PIN Entry"); setLayout(new FlowLayout()); add(pinLabel); add(pinField); PINListener listener = new PINListener(); pinField.addActionListener(listener); } private class PINListener implements ActionListener { public void actionPerformed(ActionEvent e) { userPIN = pinField.getText(); if (userPIN.equals("1234")) { JOptionPane.showMessageDialog( PINFrame1.this, "Correct PIN!"); } else { JOptionPane.showMessageDialog( PINFrame1.this, "Sorry, try again."); } } } }
df8c081c36732c2d4208c1c34290cf5ae4e1214f
e3d52991a192a58fd3096947ccddbb9529521a8b
/app/src/main/java/com/example/woojinkim/pushnotitest/MyFirebaseInstanceIDService.java
f0fd39cfff68c775b95ea7635910f4cc7e97b105
[]
no_license
94imain/PushNoti_test
803a710bcda204f2a5ac3ec6b61c0aa2e9310c66
327bccfa5bdcdf1ff073f598a9dfbc5493c98daa
refs/heads/master
2021-07-15T12:14:00.346294
2017-10-19T09:00:52
2017-10-19T09:00:52
105,349,359
0
0
null
null
null
null
UTF-8
Java
false
false
857
java
package com.example.woojinkim.pushnotitest; import android.util.Log; import com.google.firebase.iid.FirebaseInstanceId; import com.google.firebase.iid.FirebaseInstanceIdService; public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService { private static final String TAG = "MyFirebaseIIDService"; @Override public void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken); sendRegistrationToServer(refreshedToken); } private void sendRegistrationToServer(String token) { // 내 푸쉬 서버로 토컨을 보내서 저장해 둔다. 실 서비스 시 직접 코딩을 해야 된다. // 테스트 시에는비워 놔도 동작 확인이 된다. } }
f93fc29894c93d472e9cd91c4e6e5c5fe4d33bed
8e1140921e1aa96005eda0cf00b83ad6fee929be
/Target/Leviathan/src/stuffplotter/signals/CalendarAuthorizedEvent.java
9a5544377067490ae4482192fc44c501b1ff81d5
[]
no_license
TylerPadfoot/CS410---TeamVersion
c1d11b5f950ae3566596b144c424b160807be94e
755bab253b0c94adc0a688d46515341facebbbc1
refs/heads/master
2021-01-23T18:12:32.395591
2014-11-04T05:04:50
2014-11-04T05:04:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
575
java
package stuffplotter.signals; import com.google.gwt.event.shared.GwtEvent; /** * Event that gets fired when an google calendar is successfully authorized. */ public class CalendarAuthorizedEvent extends GwtEvent<CalendarAuthorizedEventHandler> { public static Type<CalendarAuthorizedEventHandler> TYPE = new Type<CalendarAuthorizedEventHandler>(); @Override public Type<CalendarAuthorizedEventHandler> getAssociatedType() { return TYPE; } @Override protected void dispatch(CalendarAuthorizedEventHandler handler) { handler.onCalendarAuthorized(this); } }
4b2249409fab0777b3ddc1f403d04a9672ebb10b
8a75472e8144e3823d5e6764b17d62ad1da72dd7
/src/cn/it/shop/model/Sorder.java
be9cb4d94c5c960b66393bf1965cb5d229667d4f
[]
no_license
berrong-chen/MyStoryshop
a6255286f815126e005e5e4db80f8aba50413063
df927c296e6d11c140833fe95c0bea35c9b5ea37
refs/heads/master
2021-01-23T05:15:06.465146
2017-03-27T04:35:10
2017-03-27T04:35:10
86,291,718
0
0
null
null
null
null
UTF-8
Java
false
false
2,061
java
package cn.it.shop.model; import java.math.BigDecimal; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; @Entity public class Sorder implements java.io.Serializable { // Fields private Integer id; private Forder forder; private Product product; private String name; private BigDecimal price; private Integer number; // Constructors /** default constructor */ public Sorder() { } /** minimal constructor */ public Sorder(Integer number) { this.number = number; } /** full constructor */ public Sorder(Forder forder, Product product, String name, BigDecimal price, Integer number) { this.forder = forder; this.product = product; this.name = name; this.price = price; this.number = number; } // Property accessors @Id @GeneratedValue @Column(name = "id", unique = true, nullable = false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "fid") public Forder getForder() { return this.forder; } public void setForder(Forder forder) { this.forder = forder; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "pid") public Product getProduct() { return this.product; } public void setProduct(Product product) { this.product = product; } @Column(name = "name", length = 20) public String getName() { return this.name; } public void setName(String name) { this.name = name; } @Column(name = "price", precision = 8) public BigDecimal getPrice() { return this.price; } public void setPrice(BigDecimal price) { this.price = price; } @Column(name = "number", nullable = false) public Integer getNumber() { return this.number; } public void setNumber(Integer number) { this.number = number; } }
53959867ca335cb9a71d493298c23b5db8b1a6bf
6dc89699f9e02e6c3f7feec166ebaeb21e692ba0
/android/src/main/java/cn/waitwalker/flutter_socket_plugin/jt808_sdk/oksocket/core/iocore/interfaces/IStateSender.java
5484e7473e066a5340ed941c2d23420294b0ac36
[ "MIT" ]
permissive
waitwalker/flutter_socket_plugin
8ea06de03a5c87a9b875f4da1d76bc1466b5353c
2630ed27ccc8b7348f78dfbd679dcede40ec2cef
refs/heads/master
2023-07-06T06:23:53.668503
2023-06-29T01:11:03
2023-06-29T01:11:03
203,282,893
16
11
null
null
null
null
UTF-8
Java
false
false
302
java
package cn.waitwalker.flutter_socket_plugin.jt808_sdk.oksocket.core.iocore.interfaces; import java.io.Serializable; /** * Created by xuhao on 2017/5/17. */ public interface IStateSender { void sendBroadcast(String action, Serializable serializable); void sendBroadcast(String action); }
49e5ae96c001f2f03fd940de373a2adf02f081d5
4bb83687710716d91b5da55054c04f430474ee52
/dsrc/sku.0/sys.server/compiled/game/script/conversation/padawan_the_ring_02.java
49254e9d762ed4b448701eb66c3265347aad7505
[]
no_license
geralex/SWG-NGE
0846566a44f4460c32d38078e0a1eb115a9b08b0
fa8ae0017f996e400fccc5ba3763e5bb1c8cdd1c
refs/heads/master
2020-04-06T11:18:36.110302
2018-03-19T15:42:32
2018-03-19T15:42:32
157,411,938
1
0
null
2018-11-13T16:35:01
2018-11-13T16:35:01
null
UTF-8
Java
false
false
24,330
java
package script.conversation; import script.*; import script.base_class.*; import script.combat_engine.*; import java.util.Arrays; import java.util.Hashtable; import java.util.Vector; import script.base_script; import script.library.ai_lib; import script.library.chat; import script.library.jedi_trials; import script.library.utils; public class padawan_the_ring_02 extends script.base_script { public padawan_the_ring_02() { } public static String c_stringFile = "conversation/padawan_the_ring_02"; public boolean padawan_the_ring_02_condition__defaultCondition(obj_id player, obj_id npc) throws InterruptedException { return true; } public boolean padawan_the_ring_02_condition_isTrialPlayer(obj_id player, obj_id npc) throws InterruptedException { obj_id trialPlayer = getObjIdObjVar(npc, jedi_trials.PADAWAN_TRIAL_PLAYER_OBJVAR); if (player == trialPlayer) { String trialName = jedi_trials.getJediTrialName(player); if (trialName != null && trialName.equals("the_ring")) { return !hasObjVar(player, "jedi_trials.padawan_trials.temp.spokeToTarget_01"); } } return false; } public void padawan_the_ring_02_action_spokeToNpc(obj_id player, obj_id npc) throws InterruptedException { setObjVar(player, "jedi_trials.padawan_trials.temp.spokeToTarget_01", true); stopCombat(npc); setInvulnerable(npc, true); messageTo(player, "handleSetBeginLoc", null, 1, false); return; } public void padawan_the_ring_02_action_npcAttacks(obj_id player, obj_id npc) throws InterruptedException { dictionary webster = new dictionary(); webster.put("player", player); messageTo(npc, "handleQuestStartAttack", webster, 1, false); return; } public int padawan_the_ring_02_handleBranch1(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_711691ff")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "wave_on_dismissing"); string_id message = new string_id(c_stringFile, "s_83f28a20"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_443c85ef"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 2); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_21")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "point_accusingly"); string_id message = new string_id(c_stringFile, "s_f42e101f"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_24"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 10); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch2(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_443c85ef")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "laugh"); string_id message = new string_id(c_stringFile, "s_4f77458a"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_e4815789"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 3); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch3(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_e4815789")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "flex_biceps"); string_id message = new string_id(c_stringFile, "s_80764fc6"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_d38d76e0"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_157b6369"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 4); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch4(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_d38d76e0")) { doAnimationAction(player, "shake_head_no"); if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "rub_chin_thoughtful"); string_id message = new string_id(c_stringFile, "s_cdc241bf"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_759ab6bb"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 5); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } if (response.equals("s_157b6369")) { doAnimationAction(player, "threaten_combat"); if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "slit_throat"); padawan_the_ring_02_action_npcAttacks(player, npc); string_id message = new string_id(c_stringFile, "s_19"); utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch5(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_759ab6bb")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "shake_head_disgust"); string_id message = new string_id(c_stringFile, "s_860ae378"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_8514b7c5"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_36ab201c"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 6); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch6(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_8514b7c5")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "belly_laugh"); padawan_the_ring_02_action_spokeToNpc(player, npc); string_id message = new string_id(c_stringFile, "s_cd72f93"); utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } if (response.equals("s_36ab201c")) { doAnimationAction(player, "threaten_combat"); if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "slit_throat"); padawan_the_ring_02_action_npcAttacks(player, npc); string_id message = new string_id(c_stringFile, "s_77a2c8a3"); utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch10(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_24")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { string_id message = new string_id(c_stringFile, "s_26"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_cec4328"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 11); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int padawan_the_ring_02_handleBranch11(obj_id player, obj_id npc, string_id response) throws InterruptedException { if (response.equals("s_cec4328")) { if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "laugh"); string_id message = new string_id(c_stringFile, "s_4f77458a"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_e4815789"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 3); npcSpeak(player, message); npcSetConversationResponses(player, responses); } else { utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); chat.chat(npc, player, message); npcEndConversation(player); } return SCRIPT_CONTINUE; } } return SCRIPT_DEFAULT; } public int OnInitialize(obj_id self) throws InterruptedException { if ((!isMob(self)) || (isPlayer(self))) { detachScript(self, "conversation.padawan_the_ring_02"); } setCondition(self, CONDITION_CONVERSABLE); return SCRIPT_CONTINUE; } public int OnAttach(obj_id self) throws InterruptedException { setCondition(self, CONDITION_CONVERSABLE); return SCRIPT_CONTINUE; } public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException { if (!isIncapacitated(self)) { int menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, null); menu_info_data menuInfoData = menuInfo.getMenuItemById(menu); menuInfoData.setServerNotify(false); setCondition(self, CONDITION_CONVERSABLE); } else { clearCondition(self, CONDITION_CONVERSABLE); } return SCRIPT_CONTINUE; } public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException { clearCondition(self, CONDITION_CONVERSABLE); detachScript(self, "conversation.padawan_the_ring_02"); return SCRIPT_CONTINUE; } public boolean npcStartConversation(obj_id player, obj_id npc, String convoName, string_id greetingId, prose_package greetingProse, string_id[] responses) throws InterruptedException { Object[] objects = new Object[responses.length]; System.arraycopy(responses, 0, objects, 0, responses.length); return npcStartConversation(player, npc, convoName, greetingId, greetingProse, objects); } public int OnStartNpcConversation(obj_id self, obj_id player) throws InterruptedException { obj_id npc = self; if (ai_lib.isInCombat(npc) || ai_lib.isInCombat(player)) { return SCRIPT_OVERRIDE; } if (padawan_the_ring_02_condition_isTrialPlayer(player, npc)) { doAnimationAction(npc, "threaten"); string_id message = new string_id(c_stringFile, "s_6a1562ad"); int numberOfResponses = 0; boolean hasResponse = false; boolean hasResponse0 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse0 = true; } boolean hasResponse1 = false; if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { ++numberOfResponses; hasResponse = true; hasResponse1 = true; } if (hasResponse) { int responseIndex = 0; string_id responses[] = new string_id[numberOfResponses]; if (hasResponse0) { responses[responseIndex++] = new string_id(c_stringFile, "s_711691ff"); } if (hasResponse1) { responses[responseIndex++] = new string_id(c_stringFile, "s_21"); } utils.setScriptVar(player, "conversation.padawan_the_ring_02.branchId", 1); npcStartConversation(player, npc, "padawan_the_ring_02", message, responses); } else { chat.chat(npc, player, message); } return SCRIPT_CONTINUE; } if (padawan_the_ring_02_condition__defaultCondition(player, npc)) { doAnimationAction(npc, "threaten"); string_id message = new string_id(c_stringFile, "s_ce804243"); chat.chat(npc, player, message); return SCRIPT_CONTINUE; } chat.chat(npc, "Error: All conditions for OnStartNpcConversation were false."); return SCRIPT_CONTINUE; } public int OnNpcConversationResponse(obj_id self, String conversationId, obj_id player, string_id response) throws InterruptedException { if (!conversationId.equals("padawan_the_ring_02")) { return SCRIPT_CONTINUE; } obj_id npc = self; int branchId = utils.getIntScriptVar(player, "conversation.padawan_the_ring_02.branchId"); if (branchId == 1 && padawan_the_ring_02_handleBranch1(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 2 && padawan_the_ring_02_handleBranch2(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 3 && padawan_the_ring_02_handleBranch3(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 4 && padawan_the_ring_02_handleBranch4(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 5 && padawan_the_ring_02_handleBranch5(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 6 && padawan_the_ring_02_handleBranch6(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 10 && padawan_the_ring_02_handleBranch10(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } if (branchId == 11 && padawan_the_ring_02_handleBranch11(player, npc, response) == SCRIPT_CONTINUE) { return SCRIPT_CONTINUE; } chat.chat(npc, "Error: Fell through all branches and responses for OnNpcConversationResponse."); utils.removeScriptVar(player, "conversation.padawan_the_ring_02.branchId"); return SCRIPT_CONTINUE; } }
c254425b3693a33eea491abc5ff5e8f66776d2ea
d199c1810a953a35108d3cd205f9f1ff88dbd55a
/src/entidades/Terror.java
cea195c4a6de4d59a0e753b4159cc622748dd2ec
[]
no_license
sivianicast/2ParcialParte2
f31ac3e93ee7826b4cde0c1c06b9d6fa7970a3a4
85ce14674133cf3917cce74232b429d9826381b4
refs/heads/master
2020-11-26T19:36:37.380550
2019-12-20T04:09:20
2019-12-20T04:09:20
229,187,774
0
0
null
null
null
null
UTF-8
Java
false
false
2,170
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 entidades; import java.util.ArrayList; /** * * @author siviany */ public class Terror extends Pelicula { public Terror() { } public Terror(String id, String genero, String duracion, String director, String casa, String productor, String protagonistas) { super(id, genero, duracion, director, casa, productor, protagonistas); } @Override public String getCasa() { return casa; } @Override public void setCasa(String casa) { this.casa = casa; } @Override public String getId() { return id; } @Override public void setId(String id) { this.id = id; } @Override public String getGenero() { return genero; } @Override public void setGenero(String genero) { this.genero = genero; } @Override public double getPrecio() { return precio; } @Override public void setPrecio(double precio) { this.precio = precio+(precio*10/100); } @Override public String getDuracion() { return duracion; } @Override public void setDuracion(String duracion) { this.duracion = duracion; } @Override public String getDirector() { return director; } @Override public void setDirector(String director) { this.director = director; } @Override public String getProductor() { return productor; } @Override public void setProductor(String productor) { this.productor = productor; } @Override public String getProtagonistas() { return protagonistas; } @Override public void setProtagonistas(String protagonistas) { this.protagonistas = protagonistas; } @Override public ArrayList<Pelicula> getListaPeliculas() { return listaPeliculas; } @Override public void setListaPeliculas(Object x) { listaPeliculas.add((Pelicula)x); } }
d9f37477d9ffb67271daafc38ca88118be3c4686
69a4f2d51ebeea36c4d8192e25cfb5f3f77bef5e
/methods/Method_29986.java
e54e95c87254f313c5652b280d70a7545ea124fe
[]
no_license
P79N6A/icse_20_user_study
5b9c42c6384502fdc9588430899f257761f1f506
8a3676bc96059ea2c4f6d209016f5088a5628f3c
refs/heads/master
2020-06-24T08:25:22.606717
2019-07-25T15:31:16
2019-07-25T15:31:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
800
java
@AfterPermissionGranted(REQUEST_CODE_CAPTURE_IMAGE_PERMISSION) private void pickOrCaptureImage(){ if (mImageUris.size() >= Broadcast.MAX_IMAGES_SIZE) { ToastUtils.show(R.string.broadcast_send_add_image_too_many,getActivity()); return; } if (EffortlessPermissions.hasPermissions(this,PERMISSIONS_CAPTURE_IMAGE)) { pickOrCaptureImageWithPermission(); } else if (EffortlessPermissions.somePermissionPermanentlyDenied(this,PERMISSIONS_CAPTURE_IMAGE)) { ToastUtils.show(R.string.broadcast_send_capture_image_permission_permanently_denied_message,getActivity()); pickImage(); } else { EffortlessPermissions.requestPermissions(this,R.string.broadcast_send_capture_image_permission_request_message,REQUEST_CODE_CAPTURE_IMAGE_PERMISSION,PERMISSIONS_CAPTURE_IMAGE); } }
3f7da4d1baa50c3686614e549e88a14c99fba844
ab7ff1ef7c3d4ca3ed82ed277eb5a3c0ceceab15
/BSP/src/main/java/com/mbs/bsp/exceptionhandler/ApiExceptionHandler.java
8bd2886df48172d3ea09dc00e5811fae22caab14
[]
no_license
sharmarvind/MSB
f27b3d96c38d3263ce6ecf325334a768fa644e23
7053db514d1707c6be9e08999a626060d7e01975
refs/heads/master
2020-03-19T02:52:20.891509
2018-06-01T05:19:01
2018-06-01T05:19:01
135,670,144
0
0
null
null
null
null
UTF-8
Java
false
false
1,306
java
package com.mbs.bsp.exceptionhandler; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; public class ApiExceptionHandler extends ResponseEntityExceptionHandler{ @Override protected ResponseEntity<Object> handleHttpMessageNotReadable(HttpMessageNotReadableException ex, HttpHeaders headers, HttpStatus status, WebRequest request) { String error = "Malformed JSON request"; return buildResponseEntity(new ApiError(HttpStatus.BAD_REQUEST, error, ex)); } @Override protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request ) { String error = "Invaild Request PAram"; return buildResponseEntity(new ApiError(HttpStatus.BAD_REQUEST, error, ex)); } private ResponseEntity<Object> buildResponseEntity(ApiError apierror) { return new ResponseEntity<>(apierror, apierror.getStatus()); } }
a589074752002b31a950d047dbf651446c591092
797075bb77f0766cc5d9664e40b1af765bedccde
/app/src/main/java/xoapit/controldev/About.java
145836d755fded84ce3cd29360f4151e3c6b9837
[]
no_license
xoapit/Control-Electric-Devices
2531587a280281258a3be91d9256ecd35f213d8a
38862a926468d0ed94ed6e11c9e2a1e4743e0b49
refs/heads/master
2021-07-16T19:03:35.446541
2017-04-18T11:39:46
2017-04-18T11:39:46
88,615,936
1
1
null
2021-06-21T20:09:51
2017-04-18T11:10:37
Java
UTF-8
Java
false
false
432
java
package xoapit.controldev; import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; public class About extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_about); } }
bcbb2e6565ba2af556e464f2d8e97b038bea6c9a
e75461eec5614d258c028a324ece2e8a7670f4d6
/sem6/podstawy_jezyka_java/java-crud-homework/src/main/java/crud/crud/ContactManager.java
772d3c1d631f155fb31aa4e25909e555209d539b
[]
no_license
d33tah/studies
ac864e252a870d4e5e64aa3ba1c6fceca5e0fa2a
85809aec5ae5e3d87fd00af7844c7ba630c373e1
refs/heads/master
2021-01-01T19:24:50.872885
2013-12-20T19:34:38
2013-12-20T19:34:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
945
java
package crud.crud; import java.util.List; import org.hibernate.Session; import org.hibernate.Transaction; public class ContactManager { Session session; public ContactManager(Session session) { this.session = session; } public void create(String name, String email) { Transaction tx = session.beginTransaction(); Contact myContact = new Contact(name, email); session.save(myContact); session.flush(); tx.commit(); } @SuppressWarnings("unchecked") public List<Contact> read() { return session.createQuery("from Contact").list(); } public void delete(Contact contact) { Transaction tx = session.beginTransaction(); session.delete(contact); session.flush(); tx.commit(); } public void update(Contact contact, String name, String email) { Transaction tx = session.beginTransaction(); contact.setName(name); contact.setEmail(email); session.save(contact); session.flush(); tx.commit(); } }
08298ca963ea477364fe49ec03e2e9b1ceafb883
c13c2a87ade0af685bbd882ea8f9d9ba1f04e180
/app/src/main/java/com/example/ril1/login1.java
05ba00f9b0fd2f25fe4116e14defb98efd303d98
[]
no_license
Abhilash-0111/RIL1
1dbedee6c2d4d99978e7e2100a1357450335bf46
9e9959ff8ec3b0fbf5c5138c3018bf5d2e724f6d
refs/heads/master
2023-06-05T15:54:14.793484
2021-06-22T08:31:39
2021-06-22T08:31:39
379,197,482
0
0
null
null
null
null
UTF-8
Java
false
false
1,944
java
package com.example.ril1; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.Toast; public class login1 extends AppCompatActivity implements AdapterView.OnItemSelectedListener { private String[] company = {"Company1","Company2","Company3"}; String selectedcomp = null ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login1); Button b1 = (Button)findViewById(R.id.b1) ; Spinner spin = (Spinner) findViewById(R.id.spin); spin.setOnItemSelectedListener(this); //Creating the ArrayAdapter instance having the country list ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,company); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //Setting the ArrayAdapter data on the Spinner spin.setAdapter(aa); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), Login2.class); intent.putExtra("name", selectedcomp); startActivity(intent); } }); } public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) { Toast.makeText(getApplicationContext(),company[position] , Toast.LENGTH_LONG).show(); selectedcomp = company[position] ; } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } @Override public void onPointerCaptureChanged(boolean hasCapture) { } }
3b094f029554d2a6cfce12a3ef04444fcfa7c1ff
fbf7ad0dc9e5b7ac88aa99f77347c15ebe4b521a
/JavaWork/JSP06_ServletInitParam/src/com/lec/servlet/InitServlet.java
d80f6a5e0a321e1f3081de03554b53c806218c5d
[]
no_license
GoForWalk/JavaPractice
d86a361f20c9a4e085754814083233595e3bd0de
3d838769821193263d4c55195f069ddac67fe041
refs/heads/master
2023-05-14T03:01:14.406318
2020-06-22T05:21:34
2020-06-22T05:21:34
259,175,380
0
0
null
2021-06-07T18:48:41
2020-04-27T01:41:18
Java
UTF-8
Java
false
false
1,409
java
package com.lec.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = {"/initS"}, initParams = { @WebInitParam(name = "id", value = "test11"), @WebInitParam(name = "pw", value = "1000"), @WebInitParam(name = "local", value = "busan"), } ) public class InitServlet extends HttpServlet { private static final long serialVersionUID = 1L; public InitServlet() { super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ServletConfig의 메소드를 사용합니다. String id = getInitParameter("id"); String pw = getInitParameter("pw"); String local = getInitParameter("local"); response.setContentType("text/html charset=utf-8"); PrintWriter out = response.getWriter(); out.println("id: " + id + "<br>"); out.println("pw: " + pw + "<br>"); out.println("local: " + local + "<br>"); out.close(); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }
57eb43904f7aa8fcb8ac58327332e749bcc0b8f0
5d4220ff341263d00b89aad6acbd270dd58e9b46
/src/main/java/com/lhp/spring5_demo19/bean/User.java
62ddb3c640129585d8f55f9d64739166564de79c
[]
no_license
peng-ge/spring5_demo
6881e2cce557675011c749b7f884de21079f10aa
371d720abb23e7aed0c2e42f4f9e28e052deb346
refs/heads/master
2023-03-19T09:59:47.771088
2021-03-10T15:36:41
2021-03-10T15:36:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,137
java
package com.lhp.spring5_demo19.bean; /** * @author 53137 */ public class User { private int id; private String name; private String sex; public User() { } public User(int id, String name, String sex) { this.id = id; this.name = name; this.sex = sex; } public User(int id) { this.id = id; } public User(int id, String name) { this.id = id; this.name = name; } public User(String name, String sex) { this.name = name; this.sex = sex; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public int getId() { return id; } public void setId(int id) { this.id = id; } @Override public String toString() { return "User{" + "id=" + id + ", name='" + name + '\'' + ", sex='" + sex + '\'' + '}'; } }
8766a7d47a2a20807b72ba02402c836ac8f930e0
6785b72ff85308d6aea01f9f2af8fa67e806e10f
/SumaPares.java
b1ac3a0d169b7f0a68d6b3c4fddf71397f85b808
[]
no_license
arkaitzgl/Ejercicios-Java
2d69ce98064f73757df406a80c4d77360615e2c3
9ab263142e68917791da9336ae9757fa3325bd1d
refs/heads/master
2020-05-22T05:04:00.876813
2017-03-12T12:19:52
2017-03-12T12:19:52
84,673,005
0
0
null
null
null
null
UTF-8
Java
false
false
437
java
package proyecto1; import java.util.Scanner; public class SumaPares { public static void main(String[] args) { // TODO Auto-generated method stub int i; int resultado=0; Scanner teclado = new Scanner(System.in); for (i=1; i<=10; i++){ System.out.println("Introduce un numero:"); int a= teclado.nextInt(); if (a%2==0) resultado=resultado+a;} System.out.println(resultado); } }
597ebc537fc77813179bc2e62390cbdab106ca4d
4bf68f8a687249c15bf14550b75a48a796517a0e
/src/PhotoQuiz.java
06df89bf71fdc65422341feb985d0f2c910ae78e
[]
no_license
LucasKhattar/EclipseLucasLvl1
b6ff986fc4a721830a76c93f1d2a2ac7f15d24c1
feffe6668df9b0a80a0006378aa3066afd12e79b
refs/heads/master
2020-04-04T07:19:29.047537
2017-08-04T02:56:39
2017-08-04T02:56:39
46,099,354
0
0
null
null
null
null
UTF-8
Java
false
false
1,722
java
// Copyright Wintriss Technical Schools 2013 import java.awt.Component; import java.awt.Frame; import java.net.MalformedURLException; import java.net.URL; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; public class PhotoQuiz { public static void main(String[] args) throws Exception { Frame quizWindow = new Frame(); quizWindow.setVisible(true); String guy = "http://www.corrie.net/kabin/archive/1999/briggs_johnny2.jpg"; Component image; image = createImage(guy); quizWindow.add(image); quizWindow.pack(); String name = JOptionPane.showInputDialog(null, "What is this mans name?"); if (name.equals("Mike Baldwin")) { System.out.println("Correct!"); } else { System.out.println("Incorrect!"); } quizWindow.remove(image); String starwars = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Star_Wars_Logo.svg/2000px-Star_Wars_Logo.svg.png"; image = createImage(starwars); quizWindow.add(image); quizWindow.pack(); String war = JOptionPane.showInputDialog(null, "What is the title of this new episode in the series?"); if (war.equalsIgnoreCase("The Force Awakens")) { JOptionPane.showMessageDialog(null, "Corrcet!"); } else { JOptionPane.showMessageDialog(null, "Incorrect!"); } } private static Component createImage(String imageUrl) throws MalformedURLException { URL url = new URL(imageUrl); Icon icon = new ImageIcon(url); JLabel imageLabel = new JLabel(icon); return imageLabel; } /* OPTIONAL */ // *14. add scoring to your quiz // *15. make something happen when mouse enters image (imageComponent.addMouseMotionListener()) }
7f144d5a7a5fbe15628743bd4b311b3ee3b04272
eb66c7ad741fbabd5b45d935a036cabad18ded54
/src/javainterview/NonRepeated.java
c4b72c8820b7c0df89dc397d698877bf0e7b6172
[]
no_license
ashokreddy1994/webdriver
cbfb30431256501c6532727394cde212af9dab79
dc98b4fefeb525441e956d2d49f3af842d04f084
refs/heads/master
2020-03-28T10:54:57.925542
2019-02-03T10:26:00
2019-02-03T10:26:00
148,158,717
0
0
null
null
null
null
UTF-8
Java
false
false
407
java
package javainterview; public class NonRepeated { public static void main(String[] args) { String s="helloh" ; int len=s.length(); for(int i=0;i<len;i++) { for(int j=i+1;j<len;j++) { if(!(s.charAt(i)==s.charAt(j))) { System.out.print(s.charAt(i)); } } } } }
79bfbd82e53992a62b1a3636085d683f870b6ab5
2bcb01f53707121184e95b2bbadf6e7ae4f70469
/src/main/java/org/vertx/java/core/impl/BlockingAction.java
220b9dd97275e190faf88827100b2106db20defe
[ "Apache-2.0" ]
permissive
yeison/vert.x
14fff1084621bff55e4051eaf751dd3107d9122d
3cf2ffabaf2b01773b237c7f9b5ecd645329de31
refs/heads/master
2021-01-21T01:26:47.185308
2012-03-01T20:27:41
2012-03-01T20:27:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,904
java
/* * Copyright 2011-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.vertx.java.core.impl; import org.vertx.java.core.logging.Logger; import org.vertx.java.core.logging.impl.LoggerFactory; /** * <p>Internal class used to run specific blocking actions on the worker pool.</p> * * <p>This class shouldn't be used directlty from user applications.</p> * * @author <a href="http://tfox.org">Tim Fox</a> */ public abstract class BlockingAction<T> extends SynchronousAction<T> { private static final Logger log = LoggerFactory.getLogger(BlockingAction.class); /** * Run the blocking action using a thread from the worker pool. */ protected void run() { final Context context = VertxInternal.instance.getContext(); Runnable runner = new Runnable() { public void run() { try { final T result = action(); context.execute(new Runnable() { public void run() { setResult(result); } }); } catch (final Exception e) { context.execute(new Runnable() { public void run() { setException(e); } }); } catch (Throwable t) { VertxInternal.instance.reportException(t); } } }; VertxInternal.instance.getBackgroundPool().execute(runner); } }
9fc9bddf038ffc94cc6dbc157e5b9d4fed6b5e8a
6d1ddb37e1ee9af2cf7c5e3d60212eb55796f974
/WuyiProject/commonapi/src/main/java/com/danmo/commonapi/base/cache/ACache.java
b7af515ef40ed02fa50a17908537914e2cb351b3
[]
no_license
zhuyu3126/WuyiProject
4519bf80dca310a6943b7aba530c8f47a66e62bc
ca2783e7833a41a92888081adc56d9da2ec1da33
refs/heads/master
2020-08-02T18:42:07.551582
2019-09-28T08:13:42
2019-09-28T08:13:42
211,467,030
1
0
null
null
null
null
UTF-8
Java
false
false
25,113
java
package com.danmo.commonapi.base.cache; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.PixelFormat; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import org.json.JSONArray; import org.json.JSONObject; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.RandomAccessFile; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; /* * 轻量级缓存框架 内存缓存的 * */ public class ACache { public static final int TIME_MINUTE = 60; public static final int TIME_HOUR = 60 * 60; public static final int TIME_DAY = TIME_HOUR * 24; public static final int TIME_WEEK = TIME_DAY * 7; private static final int MAX_SIZE = 1000 * 1000 * 50; // 50 mb private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量 private static Map<String, ACache> mInstanceMap = new HashMap<String, ACache>(); private ACacheManager mCache; private ACache(File cacheDir, long max_size, int max_count) { if (!cacheDir.exists() && !cacheDir.mkdirs()) { throw new RuntimeException("can't make dirs in " + cacheDir.getAbsolutePath()); } mCache = new ACacheManager(cacheDir, max_size, max_count); } public static ACache get(Context ctx) { return get(ctx, "ACache"); } public static ACache get(Context ctx, String cacheName) { File f = new File(ctx.getCacheDir(), cacheName); return get(f, MAX_SIZE, MAX_COUNT); } public static ACache get(File cacheDir) { return get(cacheDir, MAX_SIZE, MAX_COUNT); } public static ACache get(Context ctx, long max_zise, int max_count) { File f = new File(ctx.getCacheDir(), "ACache"); return get(f, max_zise, max_count); } public static ACache get(File cacheDir, long max_zise, int max_count) { ACache manager = mInstanceMap.get(cacheDir.getAbsoluteFile() + myPid()); if (manager == null) { manager = new ACache(cacheDir, max_zise, max_count); mInstanceMap.put(cacheDir.getAbsolutePath() + myPid(), manager); } return manager; } private static String myPid() { return "_" + android.os.Process.myPid(); } // ======================================= // ============ String数据 读写 ============== // ======================================= /** * 保存 String数据 到 缓存中 * * @param key 保存的key * @param value 保存的String数据 */ public void put(String key, String value) { File file = mCache.newFile(key); BufferedWriter out = null; try { out = new BufferedWriter(new FileWriter(file), 1024); out.write(value); } catch (IOException e) { e.printStackTrace(); } finally { if (out != null) { try { out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } mCache.put(file); } } /** * 保存 String数据 到 缓存中 * * @param key 保存的key * @param value 保存的String数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, String value, int saveTime) { put(key, Utils.newStringWithDateInfo(saveTime, value)); } /** * 读取 String数据 * * @param key * @return String 数据 */ public String getAsString(String key) { File file = mCache.get(key); if (!file.exists()) return null; boolean removeFile = false; BufferedReader in = null; try { in = new BufferedReader(new FileReader(file)); String readString = ""; String currentLine; while ((currentLine = in.readLine()) != null) { readString += currentLine; } if (!Utils.isDue(readString)) { return Utils.clearDateInfo(readString); } else { removeFile = true; return null; } } catch (IOException e) { e.printStackTrace(); return null; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } if (removeFile) remove(key); } } // ======================================= // ============= JSONObject 数据 读写 ============== // ======================================= /** * 保存 JSONObject数据 到 缓存中 * * @param key 保存的key * @param value 保存的JSON数据 */ public void put(String key, JSONObject value) { put(key, value.toString()); } /** * 保存 JSONObject数据 到 缓存中 * * @param key 保存的key * @param value 保存的JSONObject数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, JSONObject value, int saveTime) { put(key, value.toString(), saveTime); } /** * 读取JSONObject数据 * * @param key * @return JSONObject数据 */ public JSONObject getAsJSONObject(String key) { String JSONString = getAsString(key); try { JSONObject obj = new JSONObject(JSONString); return obj; } catch (Exception e) { e.printStackTrace(); return null; } } // ======================================= // ============ JSONArray 数据 读写 ============= // ======================================= /** * 保存 JSONArray数据 到 缓存中 * * @param key 保存的key * @param value 保存的JSONArray数据 */ public void put(String key, JSONArray value) { put(key, value.toString()); } /** * 保存 JSONArray数据 到 缓存中 * * @param key 保存的key * @param value 保存的JSONArray数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, JSONArray value, int saveTime) { put(key, value.toString(), saveTime); } /** * 读取JSONArray数据 * * @param key * @return JSONArray数据 */ public JSONArray getAsJSONArray(String key) { String JSONString = getAsString(key); try { JSONArray obj = new JSONArray(JSONString); return obj; } catch (Exception e) { e.printStackTrace(); return null; } } // ======================================= // ============== byte 数据 读写 ============= // ======================================= /** * 保存 byte数据 到 缓存中 * * @param key 保存的key * @param value 保存的数据 */ public void put(String key, byte[] value) { File file = mCache.newFile(key); FileOutputStream out = null; try { out = new FileOutputStream(file); out.write(value); } catch (Exception e) { e.printStackTrace(); } finally { if (out != null) { try { out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } } mCache.put(file); } } /** * 保存 byte数据 到 缓存中 * * @param key 保存的key * @param value 保存的数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, byte[] value, int saveTime) { put(key, Utils.newByteArrayWithDateInfo(saveTime, value)); } /** * 获取 byte 数据 * * @param key * @return byte 数据 */ public byte[] getAsBinary(String key) { RandomAccessFile RAFile = null; boolean removeFile = false; try { File file = mCache.get(key); if (!file.exists()) return null; RAFile = new RandomAccessFile(file, "r"); byte[] byteArray = new byte[(int) RAFile.length()]; RAFile.read(byteArray); if (!Utils.isDue(byteArray)) { return Utils.clearDateInfo(byteArray); } else { removeFile = true; return null; } } catch (Exception e) { e.printStackTrace(); return null; } finally { if (RAFile != null) { try { RAFile.close(); } catch (IOException e) { e.printStackTrace(); } } if (removeFile) remove(key); } } // ======================================= // ============= 序列化 数据 读写 =============== // ======================================= /** * 保存 Serializable数据 到 缓存中 * * @param key 保存的key * @param value 保存的value */ public void put(String key, Serializable value) { put(key, value, -1); } /** * 保存 Serializable数据到 缓存中 * * @param key 保存的key * @param value 保存的value * @param saveTime 保存的时间,单位:秒 */ public void put(String key, Serializable value, int saveTime) { ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(value); byte[] data = baos.toByteArray(); if (saveTime != -1) { put(key, data, saveTime); } else { put(key, data); } } catch (Exception e) { e.printStackTrace(); } finally { try { oos.close(); } catch (IOException e) { } } } /** * 读取 Serializable数据 * * @param key * @return Serializable 数据 */ public Object getAsObject(String key) { byte[] data = getAsBinary(key); if (data != null) { ByteArrayInputStream bais = null; ObjectInputStream ois = null; try { bais = new ByteArrayInputStream(data); ois = new ObjectInputStream(bais); Object reObject = ois.readObject(); return reObject; } catch (Exception e) { e.printStackTrace(); return null; } finally { try { if (bais != null) bais.close(); } catch (IOException e) { e.printStackTrace(); } try { if (ois != null) ois.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; } // ======================================= // ============== bitmap 数据 读写 ============= // ======================================= /** * 保存 bitmap 到 缓存中 * * @param key 保存的key * @param value 保存的bitmap数据 */ public void put(String key, Bitmap value) { put(key, Utils.Bitmap2Bytes(value)); } /** * 保存 bitmap 到 缓存中 * * @param key 保存的key * @param value 保存的 bitmap 数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, Bitmap value, int saveTime) { put(key, Utils.Bitmap2Bytes(value), saveTime); } /** * 读取 bitmap 数据 * * @param key * @return bitmap 数据 */ public Bitmap getAsBitmap(String key) { if (getAsBinary(key) == null) { return null; } return Utils.Bytes2Bimap(getAsBinary(key)); } // ======================================= // ============= drawable 数据 读写 ============= // ======================================= /** * 保存 drawable 到 缓存中 * * @param key 保存的key * @param value 保存的drawable数据 */ public void put(String key, Drawable value) { put(key, Utils.drawable2Bitmap(value)); } /** * 保存 drawable 到 缓存中 * * @param key 保存的key * @param value 保存的 drawable 数据 * @param saveTime 保存的时间,单位:秒 */ public void put(String key, Drawable value, int saveTime) { put(key, Utils.drawable2Bitmap(value), saveTime); } /** * 读取 Drawable 数据 * * @param key * @return Drawable 数据 */ public Drawable getAsDrawable(String key) { if (getAsBinary(key) == null) { return null; } return Utils.bitmap2Drawable(Utils.Bytes2Bimap(getAsBinary(key))); } /** * 获取缓存文件 * * @param key * @return value 缓存的文件 */ public File file(String key) { File f = mCache.newFile(key); if (f.exists()) return f; return null; } /** * 移除某个key * * @param key * @return 是否移除成功 */ public boolean remove(String key) { return mCache.remove(key); } /** * 清除所有数据 */ public void clear() { mCache.clear(); } /** * @author 杨福海(michael) www.yangfuhai.com * @version 1.0 * @title 时间计算工具类 */ private static class Utils { private static final char mSeparator = ' '; /** * 判断缓存的String数据是否到期 * * @param str * @return true:到期了 false:还没有到期 */ private static boolean isDue(String str) { return isDue(str.getBytes()); } /** * 判断缓存的byte数据是否到期 * * @param data * @return true:到期了 false:还没有到期 */ private static boolean isDue(byte[] data) { String[] strs = getDateInfoFromDate(data); if (strs != null && strs.length == 2) { String saveTimeStr = strs[0]; while (saveTimeStr.startsWith("0")) { saveTimeStr = saveTimeStr .substring(1, saveTimeStr.length()); } long saveTime = Long.valueOf(saveTimeStr); long deleteAfter = Long.valueOf(strs[1]); if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) { return true; } } return false; } private static String newStringWithDateInfo(int second, String strInfo) { return createDateInfo(second) + strInfo; } private static byte[] newByteArrayWithDateInfo(int second, byte[] data2) { byte[] data1 = createDateInfo(second).getBytes(); byte[] retdata = new byte[data1.length + data2.length]; System.arraycopy(data1, 0, retdata, 0, data1.length); System.arraycopy(data2, 0, retdata, data1.length, data2.length); return retdata; } private static String clearDateInfo(String strInfo) { if (strInfo != null && hasDateInfo(strInfo.getBytes())) { strInfo = strInfo.substring(strInfo.indexOf(mSeparator) + 1, strInfo.length()); } return strInfo; } private static byte[] clearDateInfo(byte[] data) { if (hasDateInfo(data)) { return copyOfRange(data, indexOf(data, mSeparator) + 1, data.length); } return data; } private static boolean hasDateInfo(byte[] data) { return data != null && data.length > 15 && data[13] == '-' && indexOf(data, mSeparator) > 14; } private static String[] getDateInfoFromDate(byte[] data) { if (hasDateInfo(data)) { String saveDate = new String(copyOfRange(data, 0, 13)); String deleteAfter = new String(copyOfRange(data, 14, indexOf(data, mSeparator))); return new String[]{saveDate, deleteAfter}; } return null; } private static int indexOf(byte[] data, char c) { for (int i = 0; i < data.length; i++) { if (data[i] == c) { return i; } } return -1; } private static byte[] copyOfRange(byte[] original, int from, int to) { int newLength = to - from; if (newLength < 0) throw new IllegalArgumentException(from + " > " + to); byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; } private static String createDateInfo(int second) { String currentTime = System.currentTimeMillis() + ""; while (currentTime.length() < 13) { currentTime = "0" + currentTime; } return currentTime + "-" + second + mSeparator; } /* * Bitmap → byte[] */ private static byte[] Bitmap2Bytes(Bitmap bm) { if (bm == null) { return null; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); } /* * byte[] → Bitmap */ private static Bitmap Bytes2Bimap(byte[] b) { if (b.length == 0) { return null; } return BitmapFactory.decodeByteArray(b, 0, b.length); } /* * Drawable → Bitmap */ private static Bitmap drawable2Bitmap(Drawable drawable) { if (drawable == null) { return null; } // 取 drawable 的长宽 int w = drawable.getIntrinsicWidth(); int h = drawable.getIntrinsicHeight(); // 取 drawable 的颜色格式 Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; // 建立对应 bitmap Bitmap bitmap = Bitmap.createBitmap(w, h, config); // 建立对应 bitmap 的画布 Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, w, h); // 把 drawable 内容画到画布中 drawable.draw(canvas); return bitmap; } /* * Bitmap → Drawable */ @SuppressWarnings("deprecation") private static Drawable bitmap2Drawable(Bitmap bm) { if (bm == null) { return null; } return new BitmapDrawable(bm); } } /** * @author 杨福海(michael) www.yangfuhai.com * @version 1.0 * @title 缓存管理器 */ public class ACacheManager { private final AtomicLong cacheSize; private final AtomicInteger cacheCount; private final long sizeLimit; private final int countLimit; private final Map<File, Long> lastUsageDates = Collections .synchronizedMap(new HashMap<File, Long>()); protected File cacheDir; private ACacheManager(File cacheDir, long sizeLimit, int countLimit) { this.cacheDir = cacheDir; this.sizeLimit = sizeLimit; this.countLimit = countLimit; cacheSize = new AtomicLong(); cacheCount = new AtomicInteger(); calculateCacheSizeAndCacheCount(); } /** * 计算 cacheSize和cacheCount */ private void calculateCacheSizeAndCacheCount() { new Thread(new Runnable() { @Override public void run() { int size = 0; int count = 0; File[] cachedFiles = cacheDir.listFiles(); if (cachedFiles != null) { for (File cachedFile : cachedFiles) { size += calculateSize(cachedFile); count += 1; lastUsageDates.put(cachedFile, cachedFile.lastModified()); } cacheSize.set(size); cacheCount.set(count); } } }).start(); } private void put(File file) { int curCacheCount = cacheCount.get(); while (curCacheCount + 1 > countLimit) { long freedSize = removeNext(); cacheSize.addAndGet(-freedSize); curCacheCount = cacheCount.addAndGet(-1); } cacheCount.addAndGet(1); long valueSize = calculateSize(file); long curCacheSize = cacheSize.get(); while (curCacheSize + valueSize > sizeLimit) { long freedSize = removeNext(); curCacheSize = cacheSize.addAndGet(-freedSize); } cacheSize.addAndGet(valueSize); Long currentTime = System.currentTimeMillis(); file.setLastModified(currentTime); lastUsageDates.put(file, currentTime); } private File get(String key) { File file = newFile(key); Long currentTime = System.currentTimeMillis(); file.setLastModified(currentTime); lastUsageDates.put(file, currentTime); return file; } private File newFile(String key) { return new File(cacheDir, key.hashCode() + ""); } private boolean remove(String key) { File image = get(key); return image.delete(); } private void clear() { lastUsageDates.clear(); cacheSize.set(0); File[] files = cacheDir.listFiles(); if (files != null) { for (File f : files) { f.delete(); } } } /** * 移除旧的文件 * * @return */ private long removeNext() { if (lastUsageDates.isEmpty()) { return 0; } Long oldestUsage = null; File mostLongUsedFile = null; Set<Entry<File, Long>> entries = lastUsageDates.entrySet(); synchronized (lastUsageDates) { for (Entry<File, Long> entry : entries) { if (mostLongUsedFile == null) { mostLongUsedFile = entry.getKey(); oldestUsage = entry.getValue(); } else { Long lastValueUsage = entry.getValue(); if (lastValueUsage < oldestUsage) { oldestUsage = lastValueUsage; mostLongUsedFile = entry.getKey(); } } } } long fileSize = calculateSize(mostLongUsedFile); if (mostLongUsedFile.delete()) { lastUsageDates.remove(mostLongUsedFile); } return fileSize; } private long calculateSize(File file) { return file.length(); } } }
157eec36045b18737975785e099b9e4870a2a698
d7386d61c61a5d4873eea525c78fc2e60c8808d9
/springcoresandbox/src/main/java/by/epam/rosspekh/springcoresandbox/exercise1/Client.java
446213381ec6c6e40444ace240290fb4ad607f4b
[]
no_license
peekhovsky/java-templates-2019
e57f30eb3b7b0155fbb6e08cda61774081c13783
314fb3ab00b019428c1554cf5a4ad87c62afa7dc
refs/heads/master
2021-07-12T22:53:03.825243
2019-08-19T13:39:19
2019-08-19T13:39:19
163,118,802
0
0
null
2020-07-01T18:41:48
2018-12-26T00:08:57
Java
UTF-8
Java
false
false
306
java
package by.epam.rosspekh.springcoresandbox.exercise1; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @Data @AllArgsConstructor @NoArgsConstructor @Slf4j public class Client { private String id; private String fullName; }
26fa275e8cca939294a09a7eec12641efeeb6d97
23bcf8dbee07b800585df29c5237db74600c4931
/dripop-dao/src/main/java/com/dripop/entity/TWarehouseYk.java
c37cf3a653f2fe974d9e734de4e36890b21c5360
[]
no_license
chaolm/myWeb
cdb5ce3f28ff97104f487b4e1f1b736129d04b34
366ded1e0ef04dedc872e7cd26d0c5bef817878b
refs/heads/master
2022-07-25T19:09:05.065025
2019-04-30T06:09:17
2019-04-30T06:09:17
184,199,647
0
0
null
2022-06-29T17:20:49
2019-04-30T05:49:59
Java
UTF-8
Java
false
false
2,016
java
package com.dripop.entity; import javax.persistence.*; import java.io.Serializable; import java.util.Date; /** * Created by liyou on 2018/3/8. */ @Entity @Table(name = "t_warehouse_yk") public class TWarehouseYk implements Serializable { @Id @GeneratedValue private Long id; @Column(name = "yc_org_id") private Long ycOrgId; @Column(name = "yr_org_id") private Long yrOrgId; @Column(name = "status") private Integer status; public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } @Column(name = "img_urls") private String imgUrls; @Column(name = "goods_names") private String goodsNames; private String imeis; private Long creator; @Column(name = "create_time") private Date createTime; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getYcOrgId() { return ycOrgId; } public void setYcOrgId(Long ycOrgId) { this.ycOrgId = ycOrgId; } public Long getYrOrgId() { return yrOrgId; } public void setYrOrgId(Long yrOrgId) { this.yrOrgId = yrOrgId; } public String getImgUrls() { return imgUrls; } public void setImgUrls(String imgUrls) { this.imgUrls = imgUrls; } public String getGoodsNames() { return goodsNames; } public void setGoodsNames(String goodsNames) { this.goodsNames = goodsNames; } public String getImeis() { return imeis; } public void setImeis(String imeis) { this.imeis = imeis; } public Long getCreator() { return creator; } public void setCreator(Long creator) { this.creator = creator; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } }
8a643f908a795ea09a8c6a6323815e7d8ae62116
bbc6370dfc0fa847d2f9cc830ef471dd4b27e5d4
/src/main/java/org/vinh/tdd/leetcode/slidingwindow/NumberOfInsland.java
8c18d45ff1be389407d65909251c1e2821465be7
[ "Apache-2.0" ]
permissive
viinhpham/tdd-algorithms
092c4be4aec8dcca78867167e361e2fc28dd28d8
ec2dfbab5868f786c81689f18005ae98d8e96e5b
refs/heads/master
2023-01-08T01:02:39.750602
2022-12-25T05:02:10
2022-12-25T05:02:10
231,548,598
0
0
Apache-2.0
2022-11-11T04:54:49
2020-01-03T08:50:29
Java
UTF-8
Java
false
false
623
java
package org.vinh.tdd.leetcode.slidingwindow; /** * Author : Vinh Pham. * Date: 7/6/21. * Time : 4:28 PM. */ public class NumberOfInsland { public int numIslands(char[][] grid) { int count = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { dfs(grid, i, j); count++; } } return count; } private void dfs(char[][] grid, int i, int j) { if (i < 0 || j < 0 || j >= grid[0].length || i >= grid.length || grid[i][j] == '0') { return; } grid[i][j] = '0'; dfs(grid, i, j - 1); dfs(grid, i, j + 1); dfs(grid, i - 1, j); dfs(grid, i + 1, j); } }
f85711e1a18cda644e1545a923a7b6b0433d6293
397e7a5c6f973f17b0a81ae4edeea02fcc437c11
/android/app/src/main/java/com/karangandhi/stackoverflowclone/Firebase/FirebaseAuthService.java
33e3e276611f5519b5685010b2d3bda7beda8cbe
[]
no_license
Karan-Gandhi/StackOverflow-Clone
b6fbd648cf23d1426157dea1312f565f7ecc8ca5
260295857f4eb0b01348a345c7d8f7d2626075fc
refs/heads/master
2023-01-02T01:09:20.525398
2020-10-16T18:47:29
2020-10-16T18:47:29
294,978,421
0
0
null
null
null
null
UTF-8
Java
false
false
6,220
java
package com.karangandhi.stackoverflowclone.Firebase; import com.google.cloud.firestore.QueryDocumentSnapshot; import com.google.cloud.firestore.WriteResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseAuthException; import com.google.firebase.auth.FirebaseToken; import com.google.firebase.auth.UserRecord; import com.google.firebase.database.utilities.Pair; import com.karangandhi.stackoverflowclone.Components.User; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; import static com.karangandhi.stackoverflowclone.Firebase.FirebaseService.app; public class FirebaseAuthService { public static FirebaseAuth auth; public static ArrayList<User> users; // initialize the service public static void Init() throws ExecutionException, InterruptedException { auth = FirebaseAuth.getInstance(app); // just populate the users in the local storage so it minimise the checks to the online database List<QueryDocumentSnapshot> users = FirestoreService.getCollectionSnapshot("users"); for (QueryDocumentSnapshot user : users) { FirebaseAuthService.users.add(user.toObject(User.class)); } } public static Pair<UserRecord, WriteResult> createUser(User user) throws FirebaseAuthException, ExecutionException, InterruptedException { UserRecord.CreateRequest request = new UserRecord.CreateRequest() .setEmail(user.email) .setUid(user.id.toString()) .setDisplayName(user.displayName) .setPassword(user.password) .setEmailVerified(false) .setPhotoUrl(user.profilePic); UserRecord record = auth.createUser(request); WriteResult result = FirestoreService.addData("users", user.id.toString(), user); users.add(user); return new Pair<>(record, result); } public static String signInWithEmailAndPassword(String email, String password) throws FirebaseAuthException { User found = null; try { for (User user : FirebaseAuthService.users) { if (user.email.equalsIgnoreCase(email) && user.password.equals(password) && user.password.equals(password)) { found = user; break; } } if (found == null) { List<QueryDocumentSnapshot> users = FirestoreService.getCollectionSnapshot("users"); for (QueryDocumentSnapshot userDocumentSnapshot : users) { User user = userDocumentSnapshot.toObject(User.class); if (user.email.equalsIgnoreCase(email) && user.password.equals(password) && user.password.equals(password)) { found = user; break; } } } } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } return found == null ? null : auth.createCustomToken(found.id.toString()); } public static String signInWithUsernameAndPassword(String username, String password) throws FirebaseAuthException { User found = null; try { for (User user : FirebaseAuthService.users) { if (user.username.equalsIgnoreCase(username) && user.password.equals(password)) { found = user; break; } } // check the database for the user in case it is not updated in the local storage if (found == null) { List<QueryDocumentSnapshot> users = FirestoreService.getCollectionSnapshot("users"); for (QueryDocumentSnapshot userDocumentSnapshot : users) { User user = userDocumentSnapshot.toObject(User.class); if (user.username.equalsIgnoreCase(username) && user.password.equals(password)) { found = user; break; } } } } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } return found == null ? null : auth.createCustomToken(found.id.toString()); } public static Pair<UserRecord, WriteResult> updateUser(User user) throws FirebaseAuthException { UserRecord.UpdateRequest request = new UserRecord.UpdateRequest(user.id.toString()) .setEmail(user.email) .setPassword(user.password) .setDisplayName(user.displayName) .setPhotoUrl(user.profilePic); WriteResult result = null; try { result = FirestoreService.addData("users", user.id.toString(), user); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } for (User u : FirebaseAuthService.users) { if (u.id.toString().equals(user.id.toString())) { FirebaseAuthService.users.remove(u); } } FirebaseAuthService.users.add(user); return new Pair<>(auth.updateUser(request), result); } public static Pair<FirebaseToken, User> verifyToken(String token) throws FirebaseAuthException, ExecutionException, InterruptedException { FirebaseToken firebaseToken = auth.verifyIdToken(token); User user = getUser(UUID.fromString(firebaseToken.getUid())); return new Pair(firebaseToken, user); } public static void deleteUser(User user) throws FirebaseAuthException, ExecutionException, InterruptedException { auth.deleteUser(user.id.toString()); FirebaseAuthService.users.remove(user); FirestoreService.deleteData("users", user.id.toString()); } public static User getUser(UUID id) throws ExecutionException, InterruptedException { return FirestoreService.readData("users", id.toString()).toObject(User.class); } }
2bc2dfa26d3ab83614466ae0c34f95b4eebf0dc0
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/XWIKI-13288-13-9-FEMO-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/store/hibernate/query/HqlQueryExecutor_ESTest.java
293b0299609d8724c93f8b0fba099d64e85a82c1
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
574
java
/* * This file was automatically generated by EvoSuite * Sun Apr 05 10:04:57 UTC 2020 */ package com.xpn.xwiki.store.hibernate.query; import org.junit.Test; import static org.junit.Assert.*; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true) public class HqlQueryExecutor_ESTest extends HqlQueryExecutor_ESTest_scaffolding { @Test public void notGeneratedAnyTest() { // EvoSuite did not generate any tests } }
f938f70625b6bd4e316d5f52dd09e1d1a18f0bfb
a2472eb27dfb197fb6c0ddeb1ff3f22b5cdea066
/src/main/java/eu/trentorise/smartcampus/roveretoexplorer/controller/SyncController.java
da00b3b462c4789645eb2efec31053e85453a6df
[]
no_license
smartcommunitylab/smartcampus.vas.roveretoexplorer.web
5c66e6acc336d4727348cff796414890772ce726
16bec8efb068b94c3973773d86eb13ebcc0ce708
refs/heads/master
2021-01-17T13:13:13.645681
2016-06-27T11:33:16
2016-06-27T11:33:16
15,761,650
0
0
null
null
null
null
UTF-8
Java
false
false
3,933
java
/******************************************************************************* * Copyright 2012-2013 Trento RISE * * 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 eu.trentorise.smartcampus.roveretoexplorer.controller; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import eu.iescities.pilot.rovereto.roveretoexplorer.custom.data.model.BaseDTObject; import eu.iescities.pilot.rovereto.roveretoexplorer.custom.data.model.ExplorerObject; import eu.trentorise.smartcampus.presentation.common.util.Util; import eu.trentorise.smartcampus.presentation.data.BasicObject; import eu.trentorise.smartcampus.presentation.data.SyncData; import eu.trentorise.smartcampus.presentation.data.SyncDataRequest; @Controller public class SyncController extends AbstractObjectController { @RequestMapping(method = RequestMethod.POST, value = "/sync") public ResponseEntity<SyncData> synchronize(HttpServletRequest request, @RequestParam long since, @RequestBody Map<String,Object> obj) throws Exception{ try { String userId = null; try { userId = getUserId(); } catch (SecurityException e) { } // no change through sync is supported! obj.put("updated",Collections.<String,Object>emptyMap()); obj.put("deleted",Collections.<String,Object>emptyMap()); SyncDataRequest syncReq = Util.convertRequest(obj, since); Map<String, Object> exclude = new HashMap<String, Object>(); if (syncReq.getSyncData().getExclude() != null) { exclude.putAll(syncReq.getSyncData().getExclude()); } // don't write anymore // SyncData result = storage.getSyncData(syncReq.getSince(), userId, syncReq.getSyncData().getInclude(), exclude); SyncData result = storage.getSyncData(syncReq.getSince(), userId); filterResult(result, userId); // storage.cleanSyncData(syncReq.getSyncData(), userId); return new ResponseEntity<SyncData>(result,HttpStatus.OK); } catch (Exception e) { e.printStackTrace(); throw e; } } private void filterResult(SyncData result, String userId) { if (result.getUpdated() != null) { List<BasicObject> list; list = result.getUpdated().get(ExplorerObject.class.getName()); if (list != null && !list.isEmpty()) { for (Iterator<BasicObject> iterator = list.iterator(); iterator.hasNext();) { ExplorerObject obj = (ExplorerObject) iterator.next(); if (!checkDate(obj)) { iterator.remove(); continue; } obj.filterUserData(userId); } } } } private boolean checkDate(BaseDTObject obj) { long ref = System.currentTimeMillis()-24*60*60*1000; if (obj.getFromTime() == null || obj.getFromTime() == 0) { return true; } if (obj.getToTime() == null || obj.getToTime() == 0) { return true; } return (obj.getFromTime() > ref || obj.getToTime() > ref); } }
37f690f9dbaf54070acd1de953c29074941562ec
78b989e34803b9d53f1a43d0fae4e3d01f0bc7e0
/UWS-MPTT_dp-1.0.0/src/dataprotect/ui/multiRenderTable/MyDefaultTableModelForTabX1.java
2800a4173523effc533c7347957f05b914a8f8cb
[]
no_license
zhbaics/UWS-MTPP_dp
e2104c7e241a20f3f3ba9c6a26ab56177a46cbd6
11e7264ddfbd639016906bd29cac916b69b03860
refs/heads/master
2016-09-05T16:01:29.568782
2014-10-30T01:14:11
2014-10-30T01:14:11
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,135
java
/* * MyDefaultTableModelForTabX1.java * * Created on 2008/8�/�20, ��morning��11:46 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package dataprotect.ui.multiRenderTable; import javax.swing.table.*; /** * * @author Administrator */ public class MyDefaultTableModelForTabX1 extends DefaultTableModel{ Object[] label = null; public MyDefaultTableModelForTabX1(Object[] header,int colNum,Object[] _label ){ super( header,colNum ); label = _label; } public MyDefaultTableModelForTabX1( Object[][] data,Object[] header,Object[] _label ){ super( data,header ); label = _label; } @Override public Object getValueAt(int row, int col){ return super.getValueAt(row,col); } @Override public boolean isCellEditable(int row, int col){ if( col==0 ){ return true; }else{ return false; } } }
b03794578d870d32e59feae30a8b4c42cd289be1
fc91d1f5af7836ce26c6641673072fe3f8f6237a
/src/main/java/org/bitmarte/architecture/utils/testingframework/selenium/service/evaluator/I_ContentEvaluator.java
25c20e0c52fa9ab4cdab6efac55679d4f4fe29de
[]
no_license
bitmarte/selenium-rfc-client
b0efad8c795a506e7e406eab2fc5d12685d0a7c0
9733a94dde8dc26f12532e1b38b378684e49b645
refs/heads/master
2022-02-08T03:39:34.998806
2020-01-16T14:39:36
2020-01-16T14:39:36
48,165,976
3
1
null
2022-02-01T00:57:54
2015-12-17T09:46:24
Java
UTF-8
Java
false
false
409
java
package org.bitmarte.architecture.utils.testingframework.selenium.service.evaluator; import org.bitmarte.architecture.utils.testingframework.selenium.service.evaluator.exceptions.ContentEvaluatorException; /** * This is the content evaluator interface * * @author bitmarte */ public interface I_ContentEvaluator { public boolean evaluate(String str1, String str2) throws ContentEvaluatorException; }
1f1e42a5dc0b6f1f86f6fe55b72eac2e75b7dc84
d46b64fa976eef5389e198203bc896d2521be7dd
/app/src/main/java/de/koelle/christian/trickytripper/ui/model/ParticipantRow.java
662c215320a3ae4d68655776bb5f99f1faeec3d1
[ "Apache-2.0" ]
permissive
koelleChristian/trickytripper
5dbdbea7e61250ac4b9a00ed05c139c867c901ee
287b843ebf6aea4f4276551511535a966109df73
refs/heads/master
2021-11-26T01:07:09.083418
2020-01-20T22:18:23
2020-01-20T22:18:23
3,173,086
46
22
Apache-2.0
2022-12-30T09:42:07
2012-01-13T18:03:45
Java
UTF-8
Java
false
false
1,093
java
package de.koelle.christian.trickytripper.ui.model; import de.koelle.christian.trickytripper.model.Amount; import de.koelle.christian.trickytripper.model.Participant; public class ParticipantRow { private Participant participant; private int amountOfPaymentLines; private Amount sumPaid; private Amount sumSpent; private Amount balance; public int getAmountOfPaymentLines() { return amountOfPaymentLines; } public void setAmountOfPaymentLines(int amountOfPaymentLines) { this.amountOfPaymentLines = amountOfPaymentLines; } public Amount getSumPaid() { return sumPaid; } public void setSumPaid(Amount moneyPaid) { this.sumPaid = moneyPaid; } public Amount getSumSpent() { return sumSpent; } public void setSumSpent(Amount moneySpent) { this.sumSpent = moneySpent; } public Participant getParticipant() { return participant; } public void setParticipant(Participant participant) { this.participant = participant; } public Amount getBalance() { return balance; } public void setBalance(Amount balance) { this.balance = balance; } }
d61419791ac9ea695820498464e175feb607bc17
e45779e5f07da4e737d0e20cb26a1b0db3785652
/wlst-naked/src/wlst/WLSTInterpreterWrapper.java
958289c06bf9fc46bbbcd150119855e3b2e75730
[]
no_license
brunacastelo/wlst-naked
2b52310a5fafa67696178bd574b28a9fba433109
5e064f1a7b67264ee1c5faf4cdfcbd94a7ba573d
refs/heads/master
2021-01-01T16:41:11.526079
2017-07-21T01:33:32
2017-07-21T01:33:32
97,887,633
0
0
null
null
null
null
UTF-8
Java
false
false
3,142
java
package wlst; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import weblogic.management.scripting.utils.WLSTInterpreter; public class WLSTInterpreterWrapper extends WLSTInterpreter { // For interpreter stdErr and stdOut private ByteArrayOutputStream baosErr = new ByteArrayOutputStream(); private ByteArrayOutputStream baosOut = new ByteArrayOutputStream(); private PrintStream stdErr = new PrintStream(baosErr); private PrintStream stdOut = new PrintStream(baosOut); // For redirecting JVM stderr/stdout when calling dumpStack() static PrintStream errSaveStream = System.err; static PrintStream outSaveStream = System.out; public WLSTInterpreterWrapper() { setErr(stdErr); setOut(stdOut); } // Wrapper function for the WLSTInterpreter.exec() // This will throw an Exception if a failure or exception occurs in // The WLST command or if the response contains the dumpStack() command public String exec1(String command) throws Exception { String output = null; try { output = exec2(command); } catch (Exception e) { throw e; // try { // synchronized (this) { // stdErr.flush(); // baosErr.reset(); // e.printStackTrace(stdErr); // output = baosErr.toString(); // baosErr.reset(); // } // } catch (Exception ex) { // output = null; // } // if (output == null) { // throw new WLSTException(e); // } // // if (!output.contains(" dumpStack() ")) { // // A real exception any way // throw new WLSTException(output); // } } if (output.length() != 0) { if (output.contains(" dumpStack() ")) { // redirect the JVM stderr for the duration of this next call synchronized (this) { System.setErr(stdErr); System.setOut(stdOut); String _return = exec2("dumpStack()"); System.setErr(errSaveStream); System.setOut(outSaveStream); throw new WLSTException(_return); } } } System.out.println(stripCRLF(output)); return stripCRLF(output); } private String exec2(String command) { // Call down to the interpreter exec method exec(command); String err = baosErr.toString(); String out = baosOut.toString(); if (err.length() == 0 && out.length() == 0) { return ""; } baosErr.reset(); baosOut.reset(); StringBuffer buf = new StringBuffer(""); if (err.length() != 0) { buf.append(err); } if (out.length() != 0) { buf.append(out); } return buf.toString(); } // Utility to remove the end of line sequences from the result if any. // Many of the response are terminated with either \r or \n or both and // some responses can contain more than one of them i.e. \n\r\n private String stripCRLF(String line) { if (line == null || line.length() == 0) { return line; } int offset = line.length(); while (true && offset > 0) { char c = line.charAt(offset - 1); // Check other EOL terminators here if (c == '\r' || c == '\n') { offset--; } else { break; } } return line.substring(0, offset); } }
[ "Bruna@DESKTOP-I3L7NV0" ]
Bruna@DESKTOP-I3L7NV0
ba1addd5b7b030723bcb5b4507cf3c3ab4f0929b
b092ea5176896a93ba3c016fa4b1ad1d9a67233b
/Java/Unidad4_Hilos/src/ServidorTelnet/HiloCliente.java
d045fe7b1a7a93f17946a6db1d7d5552567d78bf
[]
no_license
Wolfteinter/Analisis-De-Imagenes-Onder
8b03d0da36001c5132719cfb9a702cc663e1e183
b6408f085ae1777ad0e93285ee79bb71f87cddac
refs/heads/master
2020-04-18T09:34:49.029322
2020-03-05T05:44:29
2020-03-05T05:44:29
167,439,189
0
0
null
null
null
null
UTF-8
Java
false
false
1,354
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 ServidorTelnet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.Socket; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author wolfteinter */ class HiloCliente extends Thread{ private Socket cliente; private PrintWriter salida; private BufferedReader entrada; public HiloCliente(Socket s){ cliente=s; } public void run(){ while(true){ try { entrada = new BufferedReader(new InputStreamReader(cliente.getInputStream())); String respuesta = entrada.readLine(); System.out.println("Respuesta: "+respuesta); } catch (IOException ex) { ex.printStackTrace(); } } /* try { salida = new PrintWriter(cliente.getOutputStream()); System.out.println("Cliente: "+cliente.getInetAddress().getHostName() +" Puerto: "+cliente.getPort()); salida.print("Hola cliente"); } catch (IOException ex) { ex.printStackTrace(); }*/ } }
0ee1c209f6c94c30e26deefa1e7eb91b0fa39269
1a67284e9e84ca7c96312208f54a1ec5cf76039f
/src/main/java/model/command/LessThanCommand.java
37d2c1f881e90b206c711742e6db563564badb8c
[]
no_license
Stigmag/Brainfuck-Compiler
f7a8fc6d67b3254a671da7b6661ef33994669a6c
5a06461528df5e761ba9acbb4a2b3d1e53b28909
refs/heads/master
2022-12-07T13:30:26.340518
2020-08-20T10:27:47
2020-08-20T10:27:47
282,603,275
0
0
null
null
null
null
UTF-8
Java
false
false
249
java
package model.command; import model.compiler.Memory; public class LessThanCommand extends Command { @Override public void execute(Memory memory) { int pointer = memory.getPointer() - 1; memory.setPointer(pointer); } }
00c3662a69321479b838c789e304cb287d488bc9
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/JetBrains--intellij-community/1e937add5f846a026373c06f978efdf6cff2dada/before/StartStopMacroRecordingAction.java
ecfa422e8e79992ebf3487349d66f044616cda54
[]
no_license
fracz/refactor-extractor
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
dd5e82bfcc376e74a99e18c2bf54c95676914272
refs/heads/master
2021-01-19T06:50:08.211003
2018-11-30T13:00:57
2018-11-30T13:00:57
87,353,478
0
0
null
null
null
null
UTF-8
Java
false
false
1,989
java
/* * Copyright 2000-2009 JetBrains s.r.o. * * 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.intellij.ide.actionMacro.actions; import com.intellij.ide.IdeBundle; import com.intellij.ide.actionMacro.ActionMacroManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DataConstants; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.DumbAware; /** * @author max */ public class StartStopMacroRecordingAction extends AnAction implements DumbAware { public void update(AnActionEvent e) { boolean editorAvailable = e.getDataContext().getData(DataConstants.EDITOR) != null; boolean isRecording = ActionMacroManager.getInstance().isRecording(); e.getPresentation().setEnabled(editorAvailable || isRecording); e.getPresentation().setText(isRecording ? IdeBundle.message("action.stop.macro.recording") : IdeBundle.message("action.start.macro.recording")); } public void actionPerformed(AnActionEvent e) { if (!ActionMacroManager.getInstance().isRecording() ) { final ActionMacroManager manager = ActionMacroManager.getInstance(); manager.startRecording(IdeBundle.message("macro.noname")); } else { ActionMacroManager.getInstance().stopRecording(PlatformDataKeys.PROJECT.getData(e.getDataContext())); } } }
4be8e9ce946d02317af8b5a5c0a82b6e619de4a5
3bd6322ca11cfadf32b5d71d07414af053191a12
/subprojects/base-services/src/main/java/org/gradle/internal/jvm/GroovyJpmsWorkarounds.java
e8a5f43bece46a513005650774bcafb05bdc413d
[ "BSD-3-Clause", "LGPL-2.1-or-later", "MIT", "CPL-1.0", "Apache-2.0", "LGPL-2.1-only", "LicenseRef-scancode-mit-old-style" ]
permissive
marcphilipp/gradle
e706e7ea71db777aa7bd32407c84ddf55f822a1c
23dc56a658b7c6216f34232615c36712b6fe47e6
refs/heads/master
2020-04-01T20:48:43.434773
2018-10-18T13:24:20
2018-10-19T08:32:13
153,621,663
0
0
Apache-2.0
2018-10-22T08:34:44
2018-10-18T12:40:07
Groovy
UTF-8
Java
false
false
1,204
java
/* * Copyright 2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.gradle.internal.jvm; import java.util.Arrays; import java.util.Collections; import java.util.List; public class GroovyJpmsWorkarounds { /** * These JVM arguments should be passed to any process that will be using Groovy on Java 9+ to avoid noisy illegal access warnings that the user can't do anything about. */ public static final List<String> SUPPRESS_COMMON_GROOVY_WARNINGS = Collections.unmodifiableList(Arrays.asList( "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED" )); }
e81296fcc1d695e1f6c701327d182e009dffafda
a3671ab5489b469f687f5ea4d0e30109cc4d5516
/day22demo_account/src/com/itheima/service/AccountService.java
486fde7b92b68ffedcbafc957fcac0941c38054e
[]
no_license
liujianbo2017/zuoye
deb87db7cf1f00d5eeccfc9d7e742ed3fc21fd20
b98291090c78379b8ed63acfc9c7699e3f3684f3
refs/heads/master
2021-07-20T06:38:57.732566
2017-10-30T15:51:18
2017-10-30T15:51:18
102,965,939
2
0
null
null
null
null
GB18030
Java
false
false
903
java
package com.itheima.service; import java.sql.Connection; import java.sql.SQLException; import com.itheima.c3p0utils.C3P0Utils; import com.itheima.dao.AccountDao; /* * 业务层,转户数据业务层 * 调用dao层out in 实现转账 * 被wep调用,传递账户名和金额 */ public class AccountService { /* * 定义方法,实现转账 web调用,传入账户名和金额 调用dao */ public void transfer(String outaname, String inaname, double menoy) { AccountDao dao = new AccountDao(); Connection conn = null; try { conn = C3P0Utils.getConnection(); conn.setAutoCommit(false); dao.in(conn, inaname, menoy); dao.out(conn, outaname, menoy); conn.commit(); } catch (Exception ex) { ex.printStackTrace(); try { conn.rollback(); } catch (SQLException e) { e.printStackTrace(); } } finally { C3P0Utils.relase(null, null, conn); } } }
1cf752e13b136b3822b590eae461c494c688d4b5
580cca5d24c8933aad3b3747a5156bc0842bcd9e
/sample/src/main/java/com/cc/bean/PieData.java
36b7e470c0679008d186308c3b2febab557630a1
[ "Apache-2.0" ]
permissive
lichengcai/GoodView
9571db8b7d3fed1bb277998948597c3ea3401691
161e260c25fe49dfd114ca91d124bfc920636ccb
refs/heads/master
2021-01-19T21:41:36.818770
2017-12-25T10:08:47
2017-12-25T10:08:47
88,689,334
0
0
null
null
null
null
UTF-8
Java
false
false
95
java
package com.cc.bean; /** * Created by lichengcai on 2017/4/19. */ public class PieData { }
b29370d0abd559cd835b172e247a4825e25be6bd
53d677a55e4ece8883526738f1c9d00fa6560ff7
/com/tencent/tencentmap/mapsdk/maps/a/gh$6.java
8dff54e7ee89eefd5bd6461343c013685d4a4fde
[]
no_license
0jinxing/wechat-apk-source
544c2d79bfc10261eb36389c1edfdf553d8f312a
f75eefd87e9b9ecf2f76fc6d48dbba8e24afcf3d
refs/heads/master
2020-06-07T20:06:03.580028
2019-06-21T09:17:26
2019-06-21T09:17:26
193,069,132
9
4
null
null
null
null
UTF-8
Java
false
false
1,103
java
package com.tencent.tencentmap.mapsdk.maps.a; import com.tencent.map.lib.gl.JNI; import com.tencent.matrix.trace.core.AppMethodBeat; import javax.microedition.khronos.opengles.GL10; class gh$6 implements gm.a { gh$6(gh paramgh, int paramInt1, String paramString, double paramDouble1, double paramDouble2, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6, boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4, int paramInt2, int paramInt3) { } public void a(GL10 paramGL10) { AppMethodBeat.i(99045); if (gh.a(this.q) != 0L) gh.b(this.q).nativeUpdateMarkerInfo(gh.a(this.q), this.a, this.b, this.c, this.d, this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l, this.m, this.n, this.o, this.p); AppMethodBeat.o(99045); } } /* Location: C:\Users\Lin\Downloads\dex-tools-2.1-SNAPSHOT\dex-tools-2.1-SNAPSHOT\classes8-dex2jar.jar * Qualified Name: com.tencent.tencentmap.mapsdk.maps.a.gh.6 * JD-Core Version: 0.6.2 */
30993dd7b6c62a9f2b74b0a706196833af25dac4
f5c76939a348907be051f148a513300ebe73e995
/JavaBook/src/p296/P296.java
16194e7b2a5e369f5af8df7575f9977db5acf4c9
[]
no_license
parksuoh/Java
c5820fe5f8ce3acfbe756034693edd83c10b49ba
f27c295f8aedd24ae7479868f6efcc3f114ef1ba
refs/heads/master
2023-01-02T03:48:31.207408
2020-10-27T00:39:05
2020-10-27T00:39:05
259,795,658
0
0
null
null
null
null
UHC
Java
false
false
335
java
package p296; public class P296 { public static void main(String[] args) { int r = 10; Calculator calculator = new Calculator(); System.out.println("원면적 : " +calculator.arearCircle(r)); System.out.println(); Computer computer = new Computer(); System.out.println("원면적 : "+computer.arearCircle(r)); } }
3a54c62d9d74ea39700c2b83797cb4f6a18f44f3
39eb39c6543fffe2248f55b33f11177ffcd169e3
/src/main/java/com/google/gson/emul/com/google/gson/JsonParseException.java
7e9c8b66307aace7e2f5096d233168c4f4ebf8f3
[ "Apache-2.0" ]
permissive
akbertram/gson-gwt
becb0cbc96a1004c43414cd7d66e6e9c62997241
eb79a39ed180dbfb01927a0bcd68b9bccacdfb20
refs/heads/master
2021-01-18T23:14:20.482653
2016-07-12T10:33:55
2016-07-12T10:33:55
1,640,086
1
0
null
2013-07-10T22:53:49
2011-04-20T11:41:26
Java
UTF-8
Java
false
false
1,678
java
/* * Copyright (C) 2011 bedatadriven * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.gson; public final class JsonParseException extends RuntimeException { /** * Creates exception with the specified message. If you are wrapping another exception, consider * using {@link #JsonParseException(String, Throwable)} instead. * * @param msg error message describing a possible cause of this exception. */ public JsonParseException(String msg) { super(msg); } /** * Creates exception with the specified message and cause. * * @param msg error message describing what happened. * @param cause root exception that caused this exception to be thrown. */ public JsonParseException(String msg, Throwable cause) { super(msg, cause); } /** * Creates exception with the specified cause. Consider using * {@link #JsonParseException(String, Throwable)} instead if you can describe what happened. * * @param cause root exception that caused this exception to be thrown. */ public JsonParseException(Throwable cause) { super(cause); } }
a0bc23c582a5e3ca9ba38ed58ab673a7929d6a20
1038cdbc4ad63c775674593b29cf6dfe29442265
/src/br/com/hugotiyoda/calc/inteface/Display.java
db6066c584667df5f938762aef746c22eb0eeb7d
[]
no_license
HugoTiyoda/CalculadoraJAVA
896b7690fc340277d61f786ab2b41656487d7308
fcfac710cecb921dc3ebfcb58ca72ed530307908
refs/heads/master
2023-07-12T12:54:15.091590
2021-08-11T14:56:25
2021-08-11T14:56:25
395,022,911
0
0
null
null
null
null
UTF-8
Java
false
false
747
java
package br.com.hugotiyoda.calc.inteface; import br.com.hugotiyoda.calc.memory.Memory; import br.com.hugotiyoda.calc.memory.MemoryListener; import javax.swing.*; import java.awt.*; public class Display extends JPanel implements MemoryListener { private final JLabel label; public Display(){ Memory.getInstance().addListener(this); setBackground(Color.darkGray); label = new JLabel(Memory.getInstance().getTextoAtual()); label.setForeground(Color.white); label.setFont(new Font("Arial",Font.PLAIN,30)); setLayout(new FlowLayout(FlowLayout.RIGHT,10,20)); add(label); } @Override public void valorAlterado(String novoValor) { label.setText(novoValor); } }
9d400cb119715a9faf7e1ef5e221259c220d6e50
3268e3f40e9d80f55bc6f660286904ede9fa6bb2
/src/main/java/com/example/mybatis/generator/demo/controller/ArticleController.java
b8d49868253a7416a5dec46c83cbbb41e9963ffb
[]
no_license
bys-eric-he/springboot-mybatis-generator-cache-demo
70c6751251a8a2e2c6620e2cc9a58589321775db
4e4f34bc7ed8764f13e4fcb5041a10957a2716b6
refs/heads/master
2022-06-27T13:57:48.949486
2020-05-13T09:33:45
2020-05-13T09:33:45
224,630,029
1
2
null
2022-06-21T02:20:09
2019-11-28T10:39:04
Java
UTF-8
Java
false
false
2,543
java
package com.example.mybatis.generator.demo.controller; import com.example.mybatis.generator.demo.pojo.Article; import com.example.mybatis.generator.demo.pojo.ArticleExample; import com.example.mybatis.generator.demo.service.ArticleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @Api(tags = "ArticleController", description = "文章管理接口") @RestController @RequestMapping("/api/v1") public class ArticleController { @Autowired private ArticleService articleService; @GetMapping("/list") @ApiOperation(value = "获取文章列表") public List<Article> articleList(){ ArticleExample articleExample = new ArticleExample(); return articleService.selectByExample(articleExample); } @GetMapping("/list/all") @ApiOperation(value = "获取文章列表包含文章内容") public List<Article> selectByExampleWithBLOBs(){ ArticleExample articleExample = new ArticleExample(); articleExample.createCriteria() .andIdIsNotNull() .andAuthorIsNotNull(); return articleService.selectByExampleWithBLOBs(articleExample); } @PostMapping("/add") @ApiOperation(value = "添加文章") public Integer addArticle(@RequestBody Article article) { System.out.println(article.toString()); return articleService.addArticle(article); } @GetMapping("/get") @ApiOperation(value = "根据ID获取文章") public Article getArticle(@RequestParam("id") Integer id) { Long start = System.currentTimeMillis(); Article article = articleService.getArticle(id); Long end = System.currentTimeMillis(); System.out.println("耗时:"+(end-start)); return article; } /** * 更新一篇文章 * * @param contetnt * @param id * @return */ @GetMapping("/refresh") @ApiOperation(value = "更新文章") public Integer update(@RequestParam("content") String contetnt, @RequestParam("id") Integer id) { return articleService.updateContentById(contetnt, id); } /** * 删除一篇文章 * * @param id * @return */ @GetMapping("/remove") @ApiOperation(value = "删除文章") public Integer remove(@RequestParam("id") Integer id) { return articleService.removeArticleById(id); } }
284de03bad36b37e534660c38a490d2a47ff9992
130f06f9910f8d650736d3a23a32398200396bea
/Purdue Robot Code/src/org/usfirst/frc/team5822/robot/commands/AutoBlueRetrievalZoneGear.java
a5eaf29d109ca694bf3b23d9b38278d081245d70
[]
no_license
SICPRobotics/2017-Robot-Code
740621bc545ca19e51cd70d954c1c6cb90f499c4
71a451f7b0feee591802608f8139ab6616360376
refs/heads/master
2021-01-09T05:28:50.123122
2017-12-14T22:29:36
2017-12-14T22:29:36
80,773,694
0
1
null
null
null
null
UTF-8
Java
false
false
657
java
package org.usfirst.frc.team5822.robot.commands; import edu.wpi.first.wpilibj.command.CommandGroup; public class AutoBlueRetrievalZoneGear extends CommandGroup { //turn angle close but not quite right public AutoBlueRetrievalZoneGear() { addSequential(new DriveForward(60)); addSequential(new TurnLeftFast(-60)); addSequential(new TurnRightSlow(-60)); addSequential(new ResetEncoder()); addSequential(new ResetGyro()); addSequential(new DriveForward(63)); addSequential(new WaitForPilot()); addSequential(new DriveSlow(4)); //Need the stuff that lets the human player take up gear } }
31bfff5f0d3e53e4d45011d4a13945b2287c334a
ef59f22001e9de67bc555c0929ad9d8adf5f98de
/src/lab/sortpackage/BubbleSort.java
49c78a3bf1df7091e06ba9f74149385f3dd305b5
[]
no_license
voleynik/lab-java
b846aac2bafb82d8d841c1ef0645a6767bd005ae
f055bd19f61a807d2d1dec9b01ea1787b99e18aa
refs/heads/master
2021-01-21T17:45:58.823354
2018-04-06T12:53:04
2018-04-06T12:53:04
91,983,985
0
0
null
null
null
null
UTF-8
Java
false
false
1,334
java
package lab.sortpackage; public class BubbleSort { public static void sort(int array[]) { printNumbers(array, 0);// print original unsorted array int n = array.length;// array length for (int i = 0; i < n - 1; i++) {// outer loop i <----- n - 1 int next = 0;// next element int numberOfSwaps = 0; for (int prev = 0; prev < n - 1; prev++) {// inner loop j <----- n - 1 next = prev + 1; if (array[prev] > array[next]) { swapNumbers(prev, next, array); numberOfSwaps++; } } if(numberOfSwaps < 1) break; printNumbers(array, i + 1); } } private static void swapNumbers(int prev, int next, int[] array) { int temp; temp = array[prev];// move current to temp array[prev] = array[next];// move next to previous array[next] = temp; } private static void printNumbers(int[] input, int swapNumber) { for (int i = 0; i < input.length; i++) { if(i != 0) System.out.print(", "); System.out.print(input[i]); } if(swapNumber < 1){ System.out.println(" - unsorted array ~~~~~~~~~~~"); }else{ System.out.println(" - swapNumber # " + swapNumber); } } public static void main(String[] args) { int[] input1 = { 9, 8, 7, 6, 5, 4, 3, 2, 1 }; sort(input1); int[] input2 = { 1, 2, 9, 8, 7, 6, 5, 4, 3 }; sort(input2); System.out.println("The end"); } }
684e8af7213ffd2ad40b982f4d26f773e542b7df
180e78725121de49801e34de358c32cf7148b0a2
/dataset/protocol1/commons-lang/learning/7268/AbstractCircuitBreaker.java
b2e5ed3852902492a5e2d0a622db2ef4fc8eb1a6
[]
no_license
ASSERT-KTH/synthetic-checkstyle-error-dataset
40e8d1e0a7ebe7f7711def96a390891a6922f7bd
40c057e1669584bfc6fecf789b5b2854660222f3
refs/heads/master
2023-03-18T12:50:55.410343
2019-01-25T09:54:39
2019-01-25T09:54:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,983
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.lang3.concurrent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.concurrent.atomic.AtomicReference; /** * Base class for circuit breakers. * * @param <T> the type of the value monitored by this circuit breaker * @since 3.5 */ public abstract class AbstractCircuitBreaker<T> implements CircuitBreaker<T> { /** * The name of the <em>open</em> property as it is passed to registered * change listeners. */ public static final String PROPERTY_NAME = "open"; /** The current state of this circuit breaker. */ protected final AtomicReference<State> state = new AtomicReference<>(State.CLOSED); /** An object for managing change listeners registered at this instance. */ private final PropertyChangeSupport changeSupport; /** * Creates an {@code AbstractCircuitBreaker}. It also creates an internal {@code PropertyChangeSupport}. */ public AbstractCircuitBreaker() { changeSupport = new PropertyChangeSupport (this); } /** * {@inheritDoc} */ @Override public boolean isOpen() { return isOpen(state.get()); } /** * {@inheritDoc} */ @Override public boolean isClosed() { return !isOpen(); } /** * {@inheritDoc} */ @Override public abstract boolean checkState(); /** * {@inheritDoc} */ @Override public abstract boolean incrementAndCheckState(T increment); /** * {@inheritDoc} */ @Override public void close() { changeState(State.CLOSED); } /** * {@inheritDoc} */ @Override public void open() { changeState(State.OPEN); } /** * Converts the given state value to a boolean <em>open</em> property. * * @param state the state to be converted * @return the boolean open flag */ protected static boolean isOpen(final State state) { return state == State.OPEN; } /** * Changes the internal state of this circuit breaker. If there is actually a change * of the state value, all registered change listeners are notified. * * @param newState the new state to be set */ protected void changeState(final State newState) { if (state.compareAndSet(newState.oppositeState(), newState)) { changeSupport.firePropertyChange(PROPERTY_NAME, !isOpen(newState), isOpen(newState)); } } /** * Adds a change listener to this circuit breaker. This listener is notified whenever * the state of this circuit breaker changes. If the listener is * <strong>null</strong>, it is silently ignored. * * @param listener the listener to be added */ public void addChangeListener(final PropertyChangeListener listener) { changeSupport.addPropertyChangeListener(listener); } /** * Removes the specified change listener from this circuit breaker. * * @param listener the listener to be removed */ public void removeChangeListener(final PropertyChangeListener listener) { changeSupport.removePropertyChangeListener(listener); } /** * An internal enumeration representing the different states of a circuit * breaker. This class also contains some logic for performing state * transitions. This is done to avoid complex if-conditions in the code of * {@code CircuitBreaker}. */ protected enum State { CLOSED { /** * {@inheritDoc} */ @Override public State oppositeState() { return OPEN; } }, OPEN { /** * {@inheritDoc} */ @Override public State oppositeState() { return CLOSED; } }; /** * Returns the opposite state to the represented state. This is useful * for flipping the current state. * * @return the opposite state */ public abstract State oppositeState(); } }
3978f3ce6d504a70478930858475c2750a47f204
fb18b9c0f81a9883845ec93c0acd15b2fa4a0d9e
/breakfast/src/main/java/zjut/jianlu/breakfast/widget/AbstractWheelAdapter.java
476659261b5769180e8c64855c1e4ddcf4c3b3e4
[]
no_license
lucky5237/FinalDesign
afe9ad996c1e7b4fc9308275db03a1b4eee4125c
543d95d9e7cad95f6602628f1e513e677c6f7b6a
refs/heads/master
2021-01-21T13:44:13.989810
2016-04-25T15:47:00
2016-04-25T15:47:00
53,399,642
3
0
null
null
null
null
UTF-8
Java
false
false
2,090
java
/* * Copyright 2011 Yuri Kanivets * * 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 zjut.jianlu.breakfast.widget; import android.database.DataSetObserver; import android.view.View; import android.view.ViewGroup; import java.util.LinkedList; import java.util.List; /** * Abstract Wheel adapter. */ public abstract class AbstractWheelAdapter implements WheelViewAdapter { // Observers private List<DataSetObserver> datasetObservers; @Override public View getEmptyItem(View convertView, ViewGroup parent) { return null; } @Override public void registerDataSetObserver(DataSetObserver observer) { if (datasetObservers == null) { datasetObservers = new LinkedList<DataSetObserver>(); } datasetObservers.add(observer); } @Override public void unregisterDataSetObserver(DataSetObserver observer) { if (datasetObservers != null) { datasetObservers.remove(observer); } } /** * Notifies observers about data changing */ protected void notifyDataChangedEvent() { if (datasetObservers != null) { for (DataSetObserver observer : datasetObservers) { observer.onChanged(); } } } /** * Notifies observers about invalidating data */ protected void notifyDataInvalidatedEvent() { if (datasetObservers != null) { for (DataSetObserver observer : datasetObservers) { observer.onInvalidated(); } } } }
4d96be00fa0e97becfc35ec3ebdd804efdde8059
b117564b5f75e0aea556d0f266ddc1915e8be97f
/prac_admin_pos/app/src/main/java/com/example/prac_admin_pos/model/JobApp.java
a658988b438592629b61bc3f73fcfcf0c9c47f68
[]
no_license
BryanGarro25/lab_05-06
0fd922174d0aa6bc3df5d31704bd31061537c33f
2602ac4d0e87835b14be16b81966743efbeafdb0
refs/heads/master
2022-06-20T11:45:33.602133
2020-05-13T02:13:56
2020-05-13T02:13:56
258,636,625
0
0
null
null
null
null
UTF-8
Java
false
false
5,553
java
package com.example.prac_admin_pos.model; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Objects; public class JobApp implements Serializable { private String name; private String lastName; private String address1; private String address2; private String city; private String state; private int postalCode; private String country; private String emailAddress; private int areaCode; private String phoneNumber; private String position; private String date; public JobApp(String name, String lastName, String address1, String address2, String city, String state, int postalCode, String country, String emailAddress, int areaCode, String phoneNumber, String position, String date){ this.name = name; this.lastName = lastName; this.address1 = address1; this.address2 = address2; this.city = city; this.state= state; this.postalCode = postalCode; this.country = country; this.emailAddress = emailAddress; this.areaCode = areaCode; this.phoneNumber = phoneNumber; this.position = position; this.date = date; } public JobApp(){ this.name = ""; this.lastName = ""; this.address1 = ""; this.address2 = ""; this.city = ""; this.state= ""; this.postalCode = 0; this.country = ""; this.emailAddress = ""; this.areaCode = 0; this.phoneNumber = ""; this.position = ""; this.date = ""; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getAddress1() { return address1; } public void setAddress1(String address1) { this.address1 = address1; } public String getAddress2() { return address2; } public void setAddress2(String address2) { this.address2 = address2; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getPostalCode() { return postalCode; } public void setPostalCode(int postalCode) { this.postalCode = postalCode; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } public int getAreaCode() { return areaCode; } public void setAreaCode(int areaCode) { this.areaCode = areaCode; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } @Override public String toString() { return "JobApp{" + "name='" + name + '\'' + ", lastName='" + lastName + '\'' + ", address1='" + address1 + '\'' + ", address2='" + address2 + '\'' + ", city='" + city + '\'' + ", state='" + state + '\'' + ", postalCode=" + postalCode + ", country='" + country + '\'' + ", emailAddress='" + emailAddress + '\'' + ", areaCode=" + areaCode + ", phoneNumber='" + phoneNumber + '\'' + ", position='" + position + '\'' + ", date=" + date + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof JobApp)) return false; JobApp jobApp = (JobApp) o; return getPostalCode() == jobApp.getPostalCode() && getAreaCode() == jobApp.getAreaCode() && getName().equals(jobApp.getName()) && getLastName().equals(jobApp.getLastName()) && getAddress1().equals(jobApp.getAddress1()) && Objects.equals(getAddress2(), jobApp.getAddress2()) && getCity().equals(jobApp.getCity()) && Objects.equals(getState(), jobApp.getState()) && getCountry().equals(jobApp.getCountry()) && getEmailAddress().equals(jobApp.getEmailAddress()) && getPhoneNumber().equals(jobApp.getPhoneNumber()) && getPosition().equals(jobApp.getPosition()) && getDate().equals(jobApp.getDate()); } @Override public int hashCode() { return Objects.hash(getName(), getLastName(), getAddress1(), getAddress2(), getCity(), getState(), getPostalCode(), getCountry(), getEmailAddress(), getAreaCode(), getPhoneNumber(), getPosition(), getDate()); } }
1006dc0bcfe59b3258fc63598c57acf8f2446e44
e276dcad2fb03afb438b38064a3186b18e9f2f1a
/src/Main.java
d23f50a441d573ae89e287b979af5f9688da21d3
[]
no_license
daknerz/final-project
f08c534143aea2d6884580f522b10948882550a1
a7df66845fcf84a28ea80fb6ad8ecc542e01c656
refs/heads/master
2020-04-29T01:42:53.961815
2019-03-15T03:55:52
2019-03-15T03:55:52
175,739,467
0
0
null
null
null
null
UTF-8
Java
false
false
5,360
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Methods list = new Methods(); String[] name = {"Reana Salada", "Danijel Carlos", "Jessie Lagrosas", "Rangie Obispo", "Raymond Inson", "Hanniel Estareja", "Allan Calacat", "Lance Parantar"}; Student[] s = new Student[name.length]; for(int i = 0; i < name.length; i++) { String[] parts = name[i].split(" "); s[i] = new Student(parts[0], parts[1]); } list.sortFirstName(s); Scanner butang = new Scanner(System.in); int i = 0; String choice = ""; boolean repeater = true; System.out.println(" ______________________________________________________________________"); System.out.println("| Welcome to Attendance Checker |"); System.out.println("| Welcome to Attendance Checker Teacher! |"); System.out.println("| This is an Attendace Checker in Java! |"); System.out.println("| HAS UNLIMITED SESSIONS!!!! |"); System.out.println("| Has the standard 3 late's is equals to 1 absent |"); System.out.println("| Indicates AF if the student is beyond 8 absences in the students log |"); System.out.println("| God Bless, and have a good day! |"); while (repeater) { System.out.println("| Please enter a number: |"); System.out.println("|______________________________________________________________________|"); list.menu(); choice = butang.nextLine(); switch (choice) { case "1": { System.out.println(" ______________________________________________________________________________"); System.out.println("| New Session |"); System.out.println("| Please enter (p) for present, (a) for absent, (l) for late, (e) for excused. |"); System.out.println("|______________________________________________________________________________|"); System.out.println((i + 1) + " Session: "); i++; for(int j = 0; j < s.length; j++) { //go through each student while(true) { System.out.println(""); System.out.println("_______________________"); System.out.println("Name: " + name[j]); System.out.println("Status: "); String input = butang.nextLine(); if(input.equalsIgnoreCase("p")) { s[j].numPresent(); break; }else if(input.equalsIgnoreCase("a")) { s[j].numAbsent(); break; }else if(input.equalsIgnoreCase("l")) { s[j].numLate(); break; }else if(input.equalsIgnoreCase("e")) { s[j].numExcused(); break; }else { System.out.println("Error, please try again"); System.out.println("_______________________"); System.out.println(""); } } }break; } case "2": { boolean valid = false; while(!valid) { System.out.println(" _________________________________"); System.out.println("| Search by: |"); System.out.println("| [1] First name |"); System.out.println("| [2] Last name |"); System.out.println("| To search, please enter number: |"); System.out.println("|_________________________________|"); switch(butang.nextLine()) { case "1": System.out.println("Please enter first name ex.Carlos:"); String fName = butang.nextLine(); while(!list.searchFirstName(s,fName)) { if(s[i].getAbsent() == 9) System.out.println(""); System.out.print("Error, please try again: "); fName = butang.nextLine(); } valid = true; break; case "2": System.out.println("Please enter last name ex.Carlos:"); String lName = butang.nextLine(); while(!list.searchLastName(s,lName)) { if(s[i].getAbsent() == 9) System.out.println(""); System.out.print("Error, please try again: "); lName = butang.nextLine(); } valid = true; break; default: System.out.println(""); System.out.println("Error, please try again."); } }break; } case "3": { list.print(s); break; } case "4": { System.out.println(" ____________________________________________________________ "); System.out.println("| Thank you for using the Attendance Checker :) |"); System.out.println("| |"); System.out.println("| |"); System.out.println("| |"); System.out.println("| |"); System.out.println("| |"); System.out.println("| Special thanks to Odyssey2061 and friends |"); System.out.println("| And Sissy for MORAL SUPPORT <3 |"); System.out.println("|____________________________________________________________|"); repeater = false; break; } } } } }
31320a72c553466be218ab2544c4d382bbba8177
cee4fd78b2eae85036e94dbae2daa4653a5426e5
/src/main/java/com/openx/audience/xdi/lucene/LoadGroupHandler.java
ed70cbfa85fae2625c8e96187ffca642fc615d44
[]
no_license
henryzhao81/Lucene-MapReduce
6cb26b8fdca8f3c6f48a680e04b65e17389af86e
114047c1ff141848cb406f96f9545c250233948c
refs/heads/master
2022-05-27T18:07:49.416836
2019-07-17T21:45:07
2019-07-17T21:45:07
197,461,475
0
0
null
2022-05-20T21:03:10
2019-07-17T20:55:01
Java
UTF-8
Java
false
false
1,211
java
package com.openx.audience.xdi.lucene; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CountDownLatch; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class LoadGroupHandler { FileSystem remoteFileSystem = null; int loadNum = -1; String localPath = null; LoadHandler[] handlers; public LoadGroupHandler(FileSystem remoteFileSystem, int loadNum, String localPath) { handlers = new LoadHandler[loadNum]; for(int i = 0; i < loadNum; i++) { handlers[i] = new LoadHandler(remoteFileSystem, this, localPath, i); } } private ConcurrentLinkedQueue<Path> queue = new ConcurrentLinkedQueue<Path>(); public void execute() { if(handlers != null && handlers.length > 0) { CountDownLatch latch = new CountDownLatch(handlers.length); for(LoadHandler handler : handlers) { handler.setLatch(latch); handler.start(); } try { latch.await(); }catch(InterruptedException ex) { ex.printStackTrace(); } } } public void addPath(Path path) { this.queue.offer(path); } public Path getPath() { return this.queue.poll(); } }
660e043288291478f51875f266d523ddcc8925d1
4af63f589a13bfe66872dc86861ffff231025b9d
/code/iaas/model/src/main/java/io/cattle/platform/core/constants/LabelConstants.java
375bc9c9059b5db5db135a79bcbfeb45f0915cbf
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
cglewis/cattle
0601f3bdb1d6cda97bcecc7d64637437637959b3
b0eddd38e1a2fb6f7b00174277e7d52488259cff
refs/heads/master
2023-04-08T02:57:18.805367
2015-05-27T22:54:16
2015-05-27T22:54:16
36,400,338
0
0
Apache-2.0
2023-04-04T00:23:07
2015-05-27T22:45:02
Java
UTF-8
Java
false
false
418
java
package io.cattle.platform.core.constants; public class LabelConstants { public static final String HOST_TYPE = "host"; public static final String CONTAINER_TYPE = "container"; public static final String INPUT_LABEL_KEY = "key"; public static final String INPUT_LABEL_VALUE = "value"; public static final String INPUT_LABEL = "label"; public static final String INPUT_LABELS = "labels"; }
047597837969f10a76525211a278e7ca015884a1
44e8a17c4c05c3e680cd721447f877d2ba79929f
/MainActivity.java
d4d84c2314895e5582ad78792dd8141354050992
[]
no_license
C-Preetham/Android_Tip_Calculator
b3003898a135503f4849e66afaa7b234a94cadd9
4d319a77aed144c6b7310697f411e7ae013989f8
refs/heads/master
2021-01-01T16:59:17.297310
2017-07-21T17:30:23
2017-07-21T17:30:23
97,971,744
0
0
null
null
null
null
UTF-8
Java
false
false
2,270
java
package com.revannthco.basiccalculator; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.ImageButton; public class MainActivity extends AppCompatActivity { EditText et; TextView tp; TextView tt; TextView totalA; ImageButton ib1,ib2,ib3; float finalbillamt=0; float tippercent=0; float initialbill=0; float tipamt=0; float DEFAULT_P=15; float BAD_P=10; float EXCELLENT_P=20; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et=(EditText)findViewById(R.id.etBamount); tp=(TextView)findViewById(R.id.tvll1); tt=(TextView)findViewById(R.id.tvll2); totalA=(TextView)findViewById(R.id.Result); ib1=(ImageButton)findViewById(R.id.ibBad); ib2=(ImageButton)findViewById(R.id.ibGood); ib3=(ImageButton)findViewById(R.id.ibExcellent); setValues(); } public void onClick(View view) { switch(view.getId()){ case R.id.ibBad: tippercent=BAD_P; break; case R.id.ibGood: tippercent=DEFAULT_P; break; case R.id.ibExcellent: tippercent=EXCELLENT_P; break; } calculateFinal(); setValues(); } public void setValues() { tp.setText(getString(R.string.main_msg_tippercent,tippercent)); tt.setText(getString(R.string.main_msg_tiptotal,tipamt)); totalA.setText(getString(R.string.main_msg_billtotalresult,finalbillamt)); } public void onTextChanged() { calculateFinal(); setValues(); } private void calculateFinal() { if(tippercent==0) tippercent=DEFAULT_P; if(!et.getText().toString().equals("")&&!et.getText().toString().equals(".")) initialbill=Float.valueOf(et.getText().toString()); else finalbillamt=0; tipamt=(tippercent*initialbill)/100; finalbillamt=initialbill+tipamt; } }
3ec4e795eb2305b0889cd52e56550485eb8d7418
5e038d0fb8f43ff998aa6f8bf4dbc66ddbccd4b1
/src/main/java/ria/lang/compiler/code/NewExpr.java
aa947269740948c7332377cba3d8164c1a0622e2
[ "BSD-3-Clause" ]
permissive
rialang/ria
b5bc773942729ab8d25df05f0f60a7c85264f034
565f7fc29d860e12e6cbd5db2ee7542be6ef73f6
refs/heads/master
2023-08-16T23:09:10.410025
2023-08-15T18:12:43
2023-08-15T18:12:43
129,551,104
7
0
NOASSERTION
2023-09-14T17:32:53
2018-04-14T20:13:50
Java
UTF-8
Java
false
false
743
java
package ria.lang.compiler.code; import ria.lang.compiler.Context; import ria.lang.compiler.JavaType; import ria.lang.compiler.RiaType; public final class NewExpr extends JavaExpr { private RiaType.ClassBinding extraArgs; public NewExpr(JavaType.Method init, Code[] args, RiaType.ClassBinding extraArgs, int line) { super(null, init, args, line); type = init.classType; this.extraArgs = extraArgs; } @Override public void gen(Context context) { String name = method.classType.javaType.className(); context.typeInsn(NEW, name); context.insn(DUP); genCall(context, extraArgs.getCaptures(), INVOKESPECIAL); context.forceType(name); } }
627cd6e0399044e381742f0890ba56a31826bc59
2ea0745f0cc7df36326a9bf9e8fdd0f35181cb45
/app/src/main/java/com/example/heads_up/services/CategoryService.java
87746288a760556fb528aced0cb830ab32e47b98
[]
no_license
JoseRFelix/heads-up-clone
a023010171431c9ee04218363c5851739be707a2
a5ce65e50b93cce649887025230644f03b059b50
refs/heads/master
2022-02-21T07:50:58.917141
2019-08-07T06:29:24
2019-08-07T06:29:24
198,276,540
1
0
null
null
null
null
UTF-8
Java
false
false
329
java
package com.example.heads_up.services; import com.example.heads_up.models.Category; import java.util.List; import retrofit2.Call; import retrofit2.http.GET; public interface CategoryService { String API_ROUTE = "/Jfelix61/heads-up-json-server/categories"; @GET(API_ROUTE) Call<List<Category>> getCategories(); }
49fca432e1e3fc2ca91edf514e6f4c41efe54ecf
4d6c1170033a4c9289da786ccb9b920e6da55a58
/objectLesson/Main3.java
07ca73fe8d5af8a9849782e6aabc92e5d0d8bb86
[]
no_license
sfniwrunvms/javalessons
7d6edac41f8eecac240c17efa46a16f5d182ca80
ab54ca2286e7ebbaecde11b650c1cdd41678f837
refs/heads/master
2020-06-24T10:17:06.835887
2019-08-21T03:36:32
2019-08-21T03:36:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
655
java
import java.util.*; public class Main3{ public static void main(String[] args){ Empty e=new Empty(); e.name="さぶ"; System.out.println(e); List<Empty> list=new ArrayList<>(); Empty e2=new Empty(); e2.name="ヒロ"; list.add(e); list.add(e2); System.out.println(list); if(e.equals(e2)){ System.out.println("同じです"); }else{ System.out.println("二つは同じではありません"); } Empty e3=new Empty(); e3.name="ヒロ"; list.add(e); list.add(e2); list.add(e3); if(e.equals(e3)){ System.out.println("同じです"); }else{ System.out.println("二つは同じではありません"); } } }
47f0c1f0ac0546b20957c637889bbd7cd5e723f4
d27d705c91a17545e07d448b36801444a9a286da
/app/src/main/java/com/example/justeat/ShowFoodItemFragment.java
8317832fa713f9cb2c9d96cf4e2332e97fcba4e6
[]
no_license
SharmaPrateek196/online-food-ordering-android-app
682761231ee72a20f8e51ce2ba35a8e4add7fcfd
9c41d4e0e644a78d836d1a915557c05c2a96c87a
refs/heads/master
2020-08-02T23:40:50.266226
2019-09-28T19:31:38
2019-09-28T19:31:38
211,548,716
1
0
null
null
null
null
UTF-8
Java
false
false
4,692
java
package com.example.justeat; import android.app.ProgressDialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.android.volley.DefaultRetryPolicy; import com.android.volley.Request; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.dto.Customer; import com.dto.FoodItem; import org.json.JSONArray; import org.json.JSONObject; import java.util.ArrayList; public class ShowFoodItemFragment extends Fragment { View v; // TextView tvFoodName,tvFoodCat,tvFoodPrice; // Button btnFoodUpdate,btnFoodDelete; // ImageView ivFoodItem; RecyclerView rcv; RecyclerView.Adapter adapter; RecyclerView.LayoutManager mgr; ArrayList<FoodItem> flist; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { v = inflater.inflate(R.layout.show_food_item_fragment,container,false); return v; } @Override public void onResume() { super.onResume(); loadData(); } public void loadData() { // tvFoodName = v.findViewById(R.id.txtFoodName); // tvFoodCat = v.findViewById(R.id.txtFoodCat); // tvFoodPrice = v.findViewById(R.id.txtFoodPrice); // btnFoodDelete = v.findViewById(R.id.btnFoodDelete); // btnFoodUpdate = v.findViewById(R.id.btnFoodUpdate); // ivFoodItem = v.findViewById(R.id.imgFoodItem); rcv = v.findViewById(R.id.show_food_recycle); flist = new ArrayList<>(); mgr = new LinearLayoutManager(getActivity()); rcv.setLayoutManager(mgr); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setTitle("CONNECTING TO SERVER"); pd.setMessage("Downloading Food Items"); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.show(); StringRequest srq = new StringRequest(Request.Method.GET, ServerAddress.MYSERVER + "/GetAllFoodItems.jsp", new Response.Listener<String>() { @Override public void onResponse(String response) { if(response.trim().equals("no")) { pd.dismiss(); Toast.makeText(getActivity(), "No food Items to display", Toast.LENGTH_SHORT).show(); } else { try { pd.dismiss(); JSONArray arr = new JSONArray(response.trim()); for (int i = 0; i < arr.length(); i++) { JSONObject obj = arr.getJSONObject(i); FoodItem f = new FoodItem(); f.setId(obj.getInt("id")); f.setItemName(obj.getString("itemName")); f.setItemPrice(obj.getInt("itemPrice")); f.setImg_path(obj.getString("img_path")); f.setCategoryID(obj.getInt("categoryID")); flist.add(f); } adapter = new ShowFoodItemAdapter(flist, getActivity()); rcv.setAdapter(adapter); } catch (Exception ex) { ex.printStackTrace(); } } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(getActivity(), "Volley Error : "+error.getMessage(), Toast.LENGTH_SHORT).show(); } }); srq.setRetryPolicy(new DefaultRetryPolicy( 0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); AppController.getInstance().addToRequestQueue(srq,"Get_Food_Items"); } }
42968b56d241ab5ecfe34572411f0014a3548ff8
4ad5b64226a10a72b5b5d21bb58156666cff408e
/starting-point/src/main/java/bezier/curves/pkg3d/camera/Point4.java
d3e721147be7909da77907d8cffde8c586c5d6e4
[]
no_license
angrajales/Computer-Graphics-2020-1
5a59eaa737893b4c5441af73a04f4b860a672cf4
ae0a03272e5079790ae2d2a54c15b9298b7a8f1e
refs/heads/master
2020-12-20T21:05:43.720248
2020-05-25T16:44:43
2020-05-25T16:44:43
236,210,084
3
2
null
2020-05-25T16:44:45
2020-01-25T18:17:02
Java
UTF-8
Java
false
false
1,027
java
package bezier.curves.pkg3d.camera; public class Point4 { double x, y, z,w; public Point4(double x, double y, double z, double w){ this.x=x; this.y=y; this.z=z; this.w=w; } public double magnitude(){ return Math.sqrt( Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) + Math.pow(w,2)); } public void normalize(){ x = x/w; y = y/w; z = z/w; w = 1; } public void normalize2(){ double m= magnitude(); x = x/m; y= y/m; z= z/m; } public static Point4 crossProduct(Point4 v1, Point4 v2){ double x1, y1,z1; x1 = ((v1.y*v2.z)-(v2.y*v1.z)); y1 =-((v1.x*v2.z)-(v2.x*v1.z)); z1 =((v1.x*v2.y)-(v2.x*v1.y)); Point4 vector = new Point4(x1, y1, z1,1); return vector; } public static double dotProduct(Point4 v1, Point4 v2){ return ((v1.x*v2.x)+(v1.y*v2.y)+(v1.z*v2.z)); } }
542b39f7fa87ccd8443657891a59500e8c83dee0
e72d1f146161a1e6e973fc3d5543a87424555726
/app/src/androidTest/java/com/book/android/android_book/ApplicationTest.java
33f0729037b5c9833828ee564bd2acb92f3d8e56
[]
no_license
NCharvy/android-book
1acebe5f1d38a9e7c665efc1fd3580295cc0e4a9
752322751e2b4612ed91e52bd173232aadf61c26
refs/heads/master
2021-08-23T22:14:19.892560
2016-06-05T14:46:34
2016-06-05T14:46:34
113,363,468
0
0
null
null
null
null
UTF-8
Java
false
false
360
java
package com.book.android.android_book; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
b8592fd75451ad8065de688b948804342d031de7
98d313cf373073d65f14b4870032e16e7d5466f0
/gradle-open-labs/example/src/main/java/se/molybden/Class26467.java
c385029cfa738251023d5587b4fbdcb75ff02ba0
[]
no_license
Molybden/gradle-in-practice
30ac1477cc248a90c50949791028bc1cb7104b28
d7dcdecbb6d13d5b8f0ff4488740b64c3bbed5f3
refs/heads/master
2021-06-26T16:45:54.018388
2016-03-06T20:19:43
2016-03-06T20:19:43
24,554,562
0
0
null
null
null
null
UTF-8
Java
false
false
110
java
public class Class26467{ public void callMe(){ System.out.println("called"); } }
43c5a76ec1de44c6be95febe51f627c46d866599
564dc3efb78c7f01f3548723a08de4a0ab14d513
/LC206-01.java
2d24c7c54c34c90cc7b28c59a7f5f38908796316
[]
no_license
kellyli02111/leetcode
d9037f26d623c98a785886a1a1a5b1632d6d3b18
16bba905fcc1f35452b70bb65c37446edae86cc5
refs/heads/master
2020-04-01T00:34:05.702258
2019-03-28T06:53:14
2019-03-28T06:53:14
152,702,528
1
0
null
null
null
null
UTF-8
Java
false
false
920
java
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode reverseList(ListNode head) { if (head == null) return null; ListNode current = head; ListNode move = head; while (current.next != null) { move = current.next; current.next = move.next; move.next = head; head = move; //printLinkedList(head); } return head; } public void printLinkedList(ListNode head) { if (head == null) System.out.println("NULL"); ListNode current = head; while (current != null) { System.out.print(current.val + " -> "); current = current.next; } System.out.println("NULL"); } }
6a1c08e3fe91b6c386f542b39375bd2b15f840d3
363fb43e223efdf2b0c86988332f64dff71105ef
/src/main/java/com/warmcompany/udong/document/model/Document.java
b3827aedf691c13372802cca5ce6c0abf941b618
[]
no_license
udong/server
c5dd5d9ec90d895591f9465e7696866b0cd52969
c390176af12346ff877b65a1f11f857bd6eb1a0c
refs/heads/master
2021-01-10T02:03:56.618057
2015-12-26T05:51:59
2015-12-26T05:51:59
45,329,194
0
0
null
null
null
null
UTF-8
Java
false
false
2,344
java
package com.warmcompany.udong.document.model; import java.util.Date; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import org.springframework.format.annotation.DateTimeFormat; import com.warmcompany.udong.board.model.Board; /** * 2015. 12. 18. * Copyright by joyhan / HUFS * Document */ @Entity @Table(name = "Document") public class Document { @Id @GeneratedValue @Column(name="id") private int id; @Column(name="board_id") private int boardId; @Column(name="author_id") private int authorId; private String title; private String contents; @Column(name="reg_date") private Date regDate; @Column(name="mod_date") private Date modDate; private int hits; @Column(name="comment_count") private int commentCount; private int type; @ManyToOne @JoinColumn(name = "boardId") private Board board; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getBoardId() { return boardId; } public void setBoardId(int boardId) { this.boardId = boardId; } public int getAuthorId() { return authorId; } public void setAuthorId(int authorId) { this.authorId = authorId; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getContents() { return contents; } public void setContents(String contents) { this.contents = contents; } public Date getRegDate() { return regDate; } public void setRegDate(Date regDate) { this.regDate = regDate; } public Date getModDate() { return modDate; } public void setModDate(Date modDate) { this.modDate = modDate; } public int getHits() { return hits; } public void setHits(int hits) { this.hits = hits; } public int getCommentCount() { return commentCount; } public void setCommentCount(int commentCount) { this.commentCount = commentCount; } public int getType() { return type; } public void setType(int type) { this.type = type; } public Board getBoard() { return board; } public void setBoard(Board board) { this.board = board; } }
78aaba477097e40369e026f45b0e01dca40cad61
bdab2ff8c3d7b88b5357079d118e286958c3dce3
/ClassRoom/POM/Page/MyHomePage.java
5baa5c63b4323218cc895b5af6acab5898d98ea8
[]
no_license
subbulakshmi230386/Assignments_Week7
63cf917479e05392e6ef0a8669397cb8aa54c567
8aa679c2e5a28824d1827a358760803a6c91ae0c
refs/heads/main
2023-04-12T10:24:45.218552
2021-04-30T19:26:48
2021-04-30T19:26:48
361,218,242
0
0
null
null
null
null
UTF-8
Java
false
false
286
java
package page; import org.openqa.selenium.By; import Base.ProjectCommonMethods; public class MyHomePage extends ProjectCommonMethods { public MyLeadPage clickLead() { driver.findElement(By.linkText("Leads")).click(); return new MyLeadPage(); } }
4a5d771049a93334b385aac2898ff79f72714d84
7313922fba5cbeacdf12a2b6571439e644c8a8b7
/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/Scan.java
bd4cfac5d0cb4356cb58248646269819b4b06e1c
[ "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
wyx94/Linkis
5a6cfce100a5074f575dcbca680e1355088b4b45
503f72d927c700c248239d22188641eb7ffb78fb
refs/heads/master
2023-03-05T07:29:39.034649
2023-02-25T13:50:26
2023-02-25T13:50:26
216,470,125
0
0
Apache-2.0
2019-10-21T03:28:42
2019-10-21T03:28:42
null
UTF-8
Java
false
false
1,057
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.linkis.jobhistory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.mybatis.spring.annotation.MapperScan; @EnableAutoConfiguration @MapperScan("org.apache.linkis.jobhistory.dao") public class Scan {}
9e42801f3e2900a95e37569c317eda79d99586fa
15a7cb66fc9b5904a9720c0ef357c86b78dc11f6
/v2429/Objects/src/xevolution/vrcg/devdemov2400/designerscripts/LS_cla_task_v2_execution.java
5a3022cdb24b6c64d4631299496c4dc3b03221e1
[]
no_license
VB6Hobbyst7/vrcg
2c09bb52a0d11c573feb7c64bdb62f9c610646f6
c61acf00fc2a6a464fdd538470a276bd15a3f802
refs/heads/main
2023-04-17T19:03:03.611634
2021-05-11T17:36:07
2021-05-11T17:36:07
null
0
0
null
null
null
null
UTF-8
Java
false
false
624
java
package xevolution.vrcg.devdemov2400.designerscripts; import anywheresoftware.b4a.objects.TextViewWrapper; import anywheresoftware.b4a.objects.ImageViewWrapper; import anywheresoftware.b4a.BA; public class LS_cla_task_v2_execution{ public static void LS_general(java.util.LinkedHashMap<String, anywheresoftware.b4a.keywords.LayoutBuilder.ViewWrapperAndAnchor> views, int width, int height, float scale) { anywheresoftware.b4a.keywords.LayoutBuilder.setScaleRate(0.3); //BA.debugLineNum = 2;BA.debugLine="AutoScaleAll"[CLA_TASK_V2_Execution/General script] anywheresoftware.b4a.keywords.LayoutBuilder.scaleAll(views); } }
3d006946672c39f4163039f24a0ea8ab89094ba5
dea04aa4c94afd38796e395b3707d7e98b05b609
/Participant results/P7/Interaction-7/ArrayIntList_ES_2_AlreadyValued_Test.java
e2962e65da7298d6c34adeb43caa948f215d9583
[]
no_license
PdedP/InterEvo-TR
aaa44ef0a4606061ba4263239bafdf0134bb11a1
77878f3e74ee5de510e37f211e907547674ee602
refs/heads/master
2023-04-11T11:51:37.222629
2023-01-09T17:37:02
2023-01-09T17:37:02
486,658,497
0
0
null
null
null
null
UTF-8
Java
false
false
1,259
java
/* * This file was automatically generated by EvoSuite * Tue Dec 14 12:20:46 GMT 2021 */ package com.org.apache.commons.collections.primitives; import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.runtime.EvoAssertions.*; import com.org.apache.commons.collections.primitives.ArrayIntList; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.junit.runner.RunWith; @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) public class ArrayIntList_ES_2_AlreadyValued_Test extends ArrayIntList_ES_2_AlreadyValued_Test_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { ArrayIntList arrayIntList0 = new ArrayIntList(); // Undeclared exception! try { arrayIntList0.set(192, 1283); fail("Expecting exception: IndexOutOfBoundsException"); } catch(IndexOutOfBoundsException e) { // // Should be at least 0 and less than 0, found 192 // verifyException("com.org.apache.commons.collections.primitives.ArrayIntList", e); } } }
667d3456a4b211c5cda86c23cf664a29d646394e
0ae199a25f8e0959734f11071a282ee7a0169e2d
/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Mutate.java
fc488d901fceeb7c64bdde08c42e1e72e12436c2
[ "Apache-2.0" ]
permissive
lishuai12/onosfw-L3
314d2bc79424d09dcd8f46a4c467bd36cfa9bf1b
e60902ba8da7de3816f6b999492bec2d51dd677d
refs/heads/master
2021-01-10T08:09:56.279267
2015-11-06T02:49:00
2015-11-06T02:49:00
45,652,234
0
1
null
2016-03-10T22:30:45
2015-11-06T01:49:10
Java
UTF-8
Java
false
false
2,850
java
/* * Copyright 2015 Open Networking Laboratory * * 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.onosproject.ovsdb.rfc.operations; import static com.google.common.base.Preconditions.checkNotNull; import java.util.List; import org.onosproject.ovsdb.rfc.notation.Condition; import org.onosproject.ovsdb.rfc.notation.Mutation; import org.onosproject.ovsdb.rfc.schema.TableSchema; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; /** * mutate operation.Refer to RFC 7047 Section 5.2. */ public final class Mutate implements Operation { @JsonIgnore private final TableSchema tableSchema; private final String op; private final List<Condition> where; private final List<Mutation> mutations; /** * Constructs a Mutate object. * @param schema TableSchema entity * @param where the List of Condition entity * @param mutations the List of Mutation entity */ public Mutate(TableSchema schema, List<Condition> where, List<Mutation> mutations) { checkNotNull(schema, "TableSchema cannot be null"); checkNotNull(mutations, "mutations cannot be null"); checkNotNull(where, "where cannot be null"); this.tableSchema = schema; this.op = Operations.MUTATE.op(); this.where = where; this.mutations = mutations; } /** * Returns the mutations member of mutate operation. * @return the mutations member of mutate operation */ public List<Mutation> getMutations() { return mutations; } /** * Returns the where member of mutate operation. * @return the where member of mutate operation */ public List<Condition> getWhere() { return where; } @Override public String getOp() { return op; } @Override public TableSchema getTableSchema() { return tableSchema; } /** * For the use of serialization. * @return the table member of update operation */ @JsonProperty public String getTable() { return tableSchema.name(); } }
9e43556216074fd82d45af818c04e7939f342ca0
e57bb383435097f67173b49854dd5bea482f1c6b
/cse12final/src/AList.java
ba451287590032eb6744974b555757f17b1ca905
[]
no_license
CSE12-SP21-Assignments/cse12-sp21-final-coding
2973a311e9280d5d3f7261e32dc526a41911229d
a85fb10c3a437e2f04d073e747a7dc53b922e531
refs/heads/master
2023-05-12T07:50:32.348623
2021-06-07T04:58:09
2021-06-07T04:58:09
374,509,179
0
0
null
null
null
null
UTF-8
Java
false
false
1,337
java
public class AList<E> implements GenList<E> { E[] elements; int size; @SuppressWarnings("unchecked") public AList() { this.elements = (E[]) new Object[2]; this.size = 0; } public void add(E s) { expandCapacity(); this.elements[this.size] = s; this.size += 1; } public E get(int index) { if (index >= this.size) { throw new IndexOutOfBoundsException(); } return this.elements[index]; } public int size() { return this.size; } @SuppressWarnings("unchecked") private void expandCapacity() { int currentCapacity = this.elements.length; if (this.size < currentCapacity) { return; } E[] expanded = (E[]) new Object[currentCapacity * 2]; for (int i = 0; i < this.size; i += 1) { expanded[i] = this.elements[i]; } this.elements = expanded; } // Assumes a valid index is given public void remove(int index) { for (int i = index; i < this.size - 1; i++) { this.elements[i] = this.elements[i + 1]; } this.elements[size] = null; this.size -= 1; return; } // Assumes a valid index is given public void insert(int index, E s) { expandCapacity(); for (int i = this.size; i > index; i--) { this.elements[i] = this.elements[i - 1]; } this.elements[index] = s; this.size += 1; return; } public void prepend(E s) { this.insert(0, s); return; } }
815d0ff7595694024d55282cfd09d6f6c26099ff
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/2/2_f00aadd83d6d0751e8961fd2acb926993529e964/ForumRssPage/2_f00aadd83d6d0751e8961fd2acb926993529e964_ForumRssPage_t.java
68277fa738a4da7ef3bd7600ebd7fc5c9b39e136
[]
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
2,324
java
package com.mick88.convoytrucking.forum; import java.util.List; import android.os.AsyncTask; import android.os.Bundle; import android.widget.ListView; import com.mick88.convoytrucking.ConvoyTruckingApp; import com.mick88.convoytrucking.R; import com.mick88.convoytrucking.base.BaseFragment; import com.mick88.convoytrucking.forum.rss.RssItem; import com.mick88.convoytrucking.forum.rss.RssPostAdapter; import com.mick88.convoytrucking.forum.rss.RssReader; import com.mick88.convoytrucking.interfaces.OnDownloadListener; import com.mick88.convoytrucking.interfaces.RefreshListener; import com.mick88.util.FontApplicator; import com.mick88.util.HttpUtils; public class ForumRssPage extends BaseFragment { private static final String RSS_FEED_URL = "http://www.forum.convoytrucking.net/index.php?action=.xml;type=rss"; AsyncTask<?, ?, ?> downloadTask=null; @Override public void onCreate(Bundle arg0) { super.onCreate(arg0); downloadData(null); } @Override protected int selectLayout() { return R.layout.list; } @Override public boolean refresh(final RefreshListener listener) { if (downloadTask != null) return false; downloadData(new OnDownloadListener() { @Override public void onDownloadFinished() { listener.onRefreshFinished(); } }); return true; } @Override protected void downloadData(final OnDownloadListener listener) { downloadTask = new AsyncTask<Void, Void, List<RssItem>>() { @Override protected List<RssItem> doInBackground(Void... params) { try { return new RssReader(RSS_FEED_URL).read(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } } protected void onPostExecute(List<RssItem> result) { downloadTask = null; ListView listView = (ListView) findViewById(R.id.listView); HttpUtils webHandler = new HttpUtils(); listView.setAdapter(new RssPostAdapter(activity, result, new FontApplicator(activity.getAssets(), ConvoyTruckingApp.FONT_ROBOTO_LIGHT), webHandler, webHandler)); if (listener != null) listener.onDownloadFinished(); }; protected void onCancelled() { downloadTask = null; }; }.execute(); } }
a707384af3bca0174ab490cadf0394fc95c6117b
d8791c43308faddb381b64cd82c3ffba3d2f937e
/src/test/java/com/nurkiewicz/rxjava/Contenedor.java
bee5e477e15940e77b2d103cb7cb1d61a0277532
[]
no_license
alcastelo/rxjava-workshop
45365c614230aacf1a686db5e7560c2b34541473
728f9f3397838d307c847323c63a15fd0e610558
refs/heads/master
2021-01-19T22:16:40.837240
2017-04-21T19:12:59
2017-04-21T19:12:59
88,784,606
0
0
null
2017-04-19T19:48:24
2017-04-19T19:48:23
null
UTF-8
Java
false
false
683
java
package com.nurkiewicz.rxjava; import io.reactivex.Flowable; import org.reactivestreams.Subscriber; /** * Created by angel on 20/04/17. */ public class Contenedor extends Flowable<Contenedor> { String Uri; String Html; public Contenedor(String uri, String html) { Uri = uri; Html = html; } public String getUri() { return Uri; } public void setUri(String uri) { Uri = uri; } public String getHtml() { return String.valueOf(Html); } public void setHtml(String html) { Html = html; } @Override protected void subscribeActual(Subscriber<? super Contenedor> s) { } }
19756f9129a157c8a39ea1cf9b251b4de87a4c29
a96b426f37c2aa8e021a61ec26369fc9deb7c138
/src/main/java/org/lu/designpattern/abstractFactory/WheelerFactory.java
648da0ecc1a4e3f0c6f3edda5455769e27fc09fd
[]
no_license
popwar/CoreJava
dc8e70a9639a136f48338529e2d52d6b4a5b2c4a
5c31f2312e1ddfb6015feada3dc947c70557f78b
refs/heads/master
2020-05-18T08:57:39.496714
2015-11-13T01:48:10
2015-11-13T01:48:10
33,644,095
0
0
null
null
null
null
UTF-8
Java
false
false
438
java
package org.lu.designpattern.abstractFactory; public class WheelerFactory extends AbstractFactory<Wheeler> { @Override public Wheeler createObject(Wheeler wheeler) { Wheeler returnWheeler = null; try { returnWheeler = wheeler.getClass().newInstance(); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); throw new RuntimeException("get instance failed"); } return returnWheeler; } }
cd35f512a59fdf57f4d18b45ae15bb984b0487ab
b1e893c53101766f7705f85571cf7bf9f30e82dc
/glen-system/src/main/java/com/glen/glensystem/dao/SysUserDao.java
beb2345713f7b8abde9b390ab08d4e858107c988
[]
no_license
gjen1996/microservice
c8d737f9b28243dffa1b9c51d44a46b46210025e
1c5f037e08ea641fa65bc39c7276b80beaf8d7d6
refs/heads/master
2022-09-21T16:17:18.762361
2020-12-03T01:32:04
2020-12-03T01:32:04
192,289,308
1
4
null
2022-09-01T23:35:49
2019-06-17T06:40:20
Java
UTF-8
Java
false
false
320
java
package com.glen.glensystem.dao; import com.baomidou.mybatisplus.mapper.BaseMapper; import com.glen.glensystem.entity.SysUserEntity; /** * @author Glen * @create 2019/6/28 10:32 * @Description */ public interface SysUserDao extends BaseMapper<SysUserEntity> { SysUserEntity findByUsername(String username); }
4c42cc637735c617460dafa944fd6ebcb06600af
b6ce561710a885cbad633c123623849e5fadc606
/GroceryList.java
15e4d1baeff3a0e905be354b323607be4d97e236
[]
no_license
edpedron/training
33bdd8141f64f5a7bd22256f5cada4d16778b110
27e99e3ff5448cb9865e0b602a8f9172e6151ca4
refs/heads/master
2021-07-14T02:23:30.545972
2017-10-16T18:08:48
2017-10-16T18:08:48
106,284,093
0
0
null
null
null
null
UTF-8
Java
false
false
559
java
import java.util.Scanner; public class GroceryList { public static void main(String[] args) { // declare array of 5 double [] prices = new double[5]; Scanner in = new Scanner(System.in); System.out.println("Enter 5 prices: "); prices[0] = in.nextDouble(); prices[1] = in.nextDouble(); prices[2] = in.nextDouble(); prices[4] = in.nextDouble(); prices[5] = in.nextDouble(); double total = prices[0]+prices[1]+prices[2]+prices[3]+prices[4]; System.out.println("The total for all 5 items is: $%5.2f", total); System.out.println(); } }
ebf2907e9de127c05c58bd1f29b44739356ab3f1
29a6693b6ad4eb1244d39f26bb1ab3e3eef6be62
/src/ro/uvt/Main.java
dc0f20da3e834cdcfeaac43f145b0ebdb195a571
[]
no_license
Kwolok/SPLab1
ea4e732e61d75ae8e25febc41ed2d76f11ddb031
73b7690db13e974232ac0e887dbb91b29028daa5
refs/heads/master
2023-01-02T02:21:53.092432
2020-10-27T07:46:22
2020-10-27T07:46:22
301,991,917
0
0
null
null
null
null
UTF-8
Java
false
false
478
java
package ro.uvt; import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { // System.out.println("Hi!"); Cuprins cuprins = new Cuprins(); List<Autor> autori = Arrays.asList(new Autor("Ion Barbu")); Carte c = new Carte(autori, cuprins, "CarteX"); c.createCapitol("Introducere", Arrays.asList(new Paragraf(), new Imagine(), new Tabel(), new Tabel())); c.render(); } }
dd56197ad6a2bdb9d6168e1d10b5a5756749a100
3b4d5e2746cfc1dfa4ae14a1e3d363b96f038f83
/connectedCars/src/main/java/connectedCars/carSimulator/carSimulator10/CarSimulator10.java
ad3dff1fe2e1e7dd31684f7fa66171694229c307
[]
no_license
salmadoma/IoT-ConnectedCar
2777c107c4a31ce8791c69aa99f73027bba3e356
630060b0307cc1879ce64f409d10a6f599fb0547
refs/heads/master
2020-05-03T10:28:46.362934
2019-03-30T15:53:40
2019-03-30T15:53:40
178,579,010
0
0
null
null
null
null
UTF-8
Java
false
false
804
java
package connectedCars.carSimulator.carSimulator10; import java.net.URISyntaxException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @SpringBootApplication public class CarSimulator10 { public static void main(String[] args) { SpringApplication.run(CarSimulator10.class); } @Bean public CarSimulator carSimulator() throws InterruptedException, URISyntaxException { String journeysFile = "src/main/java/connectedCars/carSimulator/carSimulator10/file.csv"; int VIN = 10; CarSimulator carSimulator = new CarSimulator(journeysFile,VIN); carSimulator.processInputFile(); return carSimulator; } }
ba895cb477466dd44c4dac9ba31a5d64ed03b113
99a8722d0d16e123b69e345df7aadad409649f6c
/jpa/deferred/src/main/java/example/repo/Customer717Repository.java
01f9935a1915e5ebcf8c0dbdb8e8beb0f153465c
[ "Apache-2.0" ]
permissive
spring-projects/spring-data-examples
9c69a0e9f3e2e73c4533dbbab00deae77b2aacd7
c4d1ca270fcf32a93c2a5e9d7e91a5592b7720ff
refs/heads/main
2023-09-01T14:17:56.622729
2023-08-22T16:51:10
2023-08-24T19:48:04
16,381,571
5,331
3,985
Apache-2.0
2023-08-25T09:02:19
2014-01-30T15:42:43
Java
UTF-8
Java
false
false
280
java
package example.repo; import example.model.Customer717; import java.util.List; import org.springframework.data.repository.CrudRepository; public interface Customer717Repository extends CrudRepository<Customer717, Long> { List<Customer717> findByLastName(String lastName); }
4773ccdb55db1221027db189c106fed5602fba02
18221be1271d97d1c8453b6684788ad265d848c8
/src/nl/strohalm/cyclos/entities/accounts/guarantees/Guarantee.java
a1704577621e579c5df01e756616961226f7dca6
[]
no_license
zemuldo/Cyclos_3.7
0a4cfd5630007ba15d22d43c204949f1baa1a10d
b10a5c3eb0263079cead93491db1acaead9452e5
refs/heads/master
2021-06-16T09:55:00.426309
2017-03-16T07:47:02
2017-03-16T07:47:02
85,166,722
4
4
null
null
null
null
UTF-8
Java
false
false
9,118
java
/* This file is part of Cyclos (www.cyclos.org). A project of the Social Trade Organisation (www.socialtrade.org). Cyclos is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Cyclos 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 Cyclos; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package nl.strohalm.cyclos.entities.accounts.guarantees; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Map; import nl.strohalm.cyclos.entities.Entity; import nl.strohalm.cyclos.entities.Relationship; import nl.strohalm.cyclos.entities.accounts.loans.Loan; import nl.strohalm.cyclos.entities.customization.fields.PaymentCustomField; import nl.strohalm.cyclos.entities.customization.fields.PaymentCustomFieldValue; import nl.strohalm.cyclos.entities.members.Element; import nl.strohalm.cyclos.entities.members.Member; import nl.strohalm.cyclos.entities.settings.LocalSettings; import nl.strohalm.cyclos.services.accounts.guarantees.GuaranteeFeeVO; import nl.strohalm.cyclos.utils.CustomFieldsContainer; import nl.strohalm.cyclos.utils.Period; import nl.strohalm.cyclos.utils.StringValuedEnum; import nl.strohalm.cyclos.utils.guarantees.GuaranteesHelper; public class Guarantee extends Entity implements CustomFieldsContainer<PaymentCustomField, PaymentCustomFieldValue> { public static enum Relationships implements Relationship { CERTIFICATION("certification"), GUARANTEE_TYPE("guaranteeType"), LOAN("loan"), PAYMENT_OBLIGATIONS("paymentObligations"), LOGS("logs"), BUYER("buyer"), SELLER("seller"), ISSUER("issuer"), CUSTOM_VALUES("customValues"); private final String name; private Relationships(final String name) { this.name = name; } public String getName() { return name; } } public static enum Status implements StringValuedEnum { PENDING_ISSUER("PI"), PENDING_ADMIN("PA"), ACCEPTED("A"), REJECTED("R"), WITHOUT_ACTION("WA"), CANCELLED("C"); private final String value; private Status(final String value) { this.value = value; } public String getValue() { return value; } } private static final long serialVersionUID = 3906916142405683801L; private Status status; private BigDecimal amount; private GuaranteeFeeVO creditFeeSpec; private GuaranteeFeeVO issueFeeSpec; private Period validity; private Calendar registrationDate; private Certification certification; private GuaranteeType guaranteeType; private Loan loan; private Collection<PaymentObligation> paymentObligations; private Collection<GuaranteeLog> logs; private Member buyer; private Member seller; /** * If the guarantee type's model is 'with payment obligation' this issuer must be equals to the issuer of the certification. */ private Member issuer; private Collection<PaymentCustomFieldValue> customValues; /** * Change the guarantee's status and adds a new guarantee log to it * @param status the new guarantee's status * @param by the author of the change * @return the new GuaranteeLog added to this Guarantee */ public GuaranteeLog changeStatus(final Status status, final Element by) { setStatus(status); if (logs == null) { logs = new ArrayList<GuaranteeLog>(); } final GuaranteeLog log = getNewLog(status, by); logs.add(log); return log; } public BigDecimal getAmount() { return amount; } public Member getBuyer() { return buyer; } public Certification getCertification() { return certification; } public BigDecimal getCreditFee() { return isNullFee(creditFeeSpec) ? null : GuaranteesHelper.calculateFee(validity, amount, creditFeeSpec); } public GuaranteeFeeVO getCreditFeeSpec() { return creditFeeSpec; } public Class<PaymentCustomField> getCustomFieldClass() { return PaymentCustomField.class; } public Class<PaymentCustomFieldValue> getCustomFieldValueClass() { return PaymentCustomFieldValue.class; } public Collection<PaymentCustomFieldValue> getCustomValues() { return customValues; } public GuaranteeType getGuaranteeType() { return guaranteeType; } public BigDecimal getIssueFee() { return isNullFee(issueFeeSpec) ? null : GuaranteesHelper.calculateFee(validity, amount, issueFeeSpec); } public GuaranteeFeeVO getIssueFeeSpec() { return issueFeeSpec; } public Member getIssuer() { return issuer; } public Loan getLoan() { return loan; } public Collection<GuaranteeLog> getLogs() { return logs; } public GuaranteeLog getNewLog(final Status status, final Element by) { final GuaranteeLog log = new GuaranteeLog(); log.setGuarantee(this); log.setDate(Calendar.getInstance()); log.setStatus(status); log.setBy(by); // TODO: should I add the created log to the logs' collection? return log; } public Collection<PaymentObligation> getPaymentObligations() { return paymentObligations; } public Calendar getRegistrationDate() { return registrationDate; } public Member getSeller() { return seller; } public Status getStatus() { return status; } public Period getValidity() { return validity; } public void setAmount(final BigDecimal amount) { this.amount = amount; } public void setBuyer(final Member buyer) { this.buyer = buyer; } public void setCertification(final Certification certification) { this.certification = certification; } public void setCreditFeeSpec(final GuaranteeFeeVO creditFeeSpec) { this.creditFeeSpec = creditFeeSpec; } public void setCustomValues(final Collection<PaymentCustomFieldValue> customValues) { this.customValues = customValues; } public void setGuaranteeType(final GuaranteeType guaranteeType) { this.guaranteeType = guaranteeType; } public void setIssueFeeSpec(final GuaranteeFeeVO issueFeeSpec) { this.issueFeeSpec = issueFeeSpec; } public void setIssuer(final Member issuer) { this.issuer = issuer; } public void setLoan(final Loan loan) { this.loan = loan; } public void setLogs(final Collection<GuaranteeLog> logs) { this.logs = logs; } public void setPaymentObligations(final Collection<PaymentObligation> paymentObligations) { this.paymentObligations = paymentObligations; } public void setRegistrationDate(final Calendar issueDate) { registrationDate = issueDate; } public void setSeller(final Member seller) { this.seller = seller; } public void setStatus(final Status status) { this.status = status; } public void setValidity(final Period validity) { this.validity = validity; } @Override public String toString() { return "G: " + getId() + " - " + status; } @Override protected void appendVariableValues(final Map<String, Object> variables, final LocalSettings localSettings) { final String pattern = getGuaranteeType().getCurrency().getPattern(); variables.put("amount", localSettings.getUnitsConverter(pattern).toString(getAmount())); variables.put("buyer_member", getBuyer().getName()); variables.put("buyer_login", getBuyer().getUsername()); if (getSeller() != null) { variables.put("seller_member", getSeller().getName()); variables.put("seller_login", getSeller().getUsername()); } if (getIssuer() != null) { variables.put("issuer_member", getIssuer().getName()); variables.put("issuer_login", getIssuer().getUsername()); } } private boolean isNullFee(final GuaranteeFeeVO feeSpec) { return feeSpec == null || feeSpec.getType() == null || feeSpec.getFee() == null; } }
fc39e93d98fc22cddc3e4a17071bb4961ac49d98
12306986dbfbaba8ecbc7f8a20503dfe6af4a1c1
/src/test/java/dev/huh/commonutils/CommonUtilsApplicationTests.java
84b3b2f93514c43dd340102fdcd1387d497de506
[]
no_license
junhuhdev/common-utils
63b648b3efa8c3fe622a6417593c0c1690ee9607
dda989577ac7b8d1d20980a3905acf310d1ef503
refs/heads/master
2023-07-08T16:38:05.009813
2021-08-13T10:21:02
2021-08-13T10:21:02
395,607,392
0
0
null
null
null
null
UTF-8
Java
false
false
216
java
package dev.huh.commonutils; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class CommonUtilsApplicationTests { @Test void contextLoads() { } }
45809e7f564fa388cdd0bd2c61102cc3b539069d
bae29405842e2662b8dfc8909ee38fe5c71469a2
/base-parent/base-security-app/src/main/java/com/base/security/app/exception/AuthExceptionEntryPoint.java
df30b4a21b660116a26a0240392bb1ab1d28eae7
[]
no_license
BISSKKP/Springsecurity-oauth2.0
26c8c05df4c99769038b1d0349141e884fd1f663
6ee36ab7745153c7e534431e6d06781448392d21
refs/heads/master
2023-02-03T03:12:32.896158
2020-12-22T09:45:33
2020-12-22T09:45:33
279,559,935
0
2
null
2020-07-14T11:14:39
2020-07-14T10:56:26
Java
UTF-8
Java
false
false
1,581
java
package com.base.security.app.exception; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.oauth2.common.exceptions.InvalidTokenException; import org.springframework.security.web.AuthenticationEntryPoint; import com.base.common.ajax.AjaxJson; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; /** * 授权码 失效 时 返回自定义消息 * @author lqq * */ @Slf4j public class AuthExceptionEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { log.info("访问此资源需要完全的身份验证"); Throwable cause = authException.getCause(); AjaxJson j=new AjaxJson(); j.setSuccess(false); if(cause instanceof InvalidTokenException) { j.setErrorCode("401"); j.setMsg("无效的token"); }else{ j.setErrorCode("401"); j.setMsg("访问此资源需要完全的身份验证"); } j.put("path", request.getServletPath()); j.put("data", authException.getMessage()); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); response.setContentType("application/json;charset=UTF-8"); response.getWriter().write(new ObjectMapper().writeValueAsString(j)); } }
ac00002da3f819912b557deddc625f0370478591
ea5a965df058eaec721f2bd609505bf5ac3b7611
/src/test/java/keywords/WatchList.java
3af716c2ed32bef216121510ed2f4aa47cf6de40
[]
no_license
scerios/IMDB
3e1e28622dabe2aa830e04a1caec67da1159f8bc
273da323af75b72698c7e6e228bb77cdc7417a5c
refs/heads/master
2020-04-16T23:43:02.770547
2019-01-30T09:53:19
2019-01-30T09:53:19
166,022,911
0
0
null
null
null
null
UTF-8
Java
false
false
1,881
java
package keywords; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class WatchList { private static long sumOfMoviesAdded = 1; private static String convertedSum; private static WebDriverWait waitDriver; private static WebElement button; private static WebElement added; public static void addToWatchlist(WebDriver driver) { waitDriver = new WebDriverWait(driver, Log.WAIT_TIMEOUT); waitDriver.until(ExpectedConditions.presenceOfElementLocated(By.className("ribbonize"))); try { added = driver.findElement(By.className("wl-ribbon standalone retina inWL")); } catch (NoSuchElementException e) { System.out.println("There is no element like that."); } button = driver.findElement(By.className("ribbonize")); if (added == null) { setSumOfMoviesAdded(); button.click(); } } public static void getWatchlistPage(WebDriver driver) { waitDriver = new WebDriverWait(driver, Log.WAIT_TIMEOUT); waitDriver.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Watchlist"))); button = driver.findElement(By.linkText("Watchlist")); button.click(); } private static void setSumOfMoviesAdded() { sumOfMoviesAdded++; } public static String convertSumOfMoviesAddedToString() { return convertedSum = String.valueOf(sumOfMoviesAdded); } public static String getActualSumOfMoviesAdded(WebDriver driver) { waitDriver = new WebDriverWait(driver, Log.WAIT_TIMEOUT); waitDriver.until(ExpectedConditions.elementToBeClickable(By.className("count"))); button = driver.findElement(By.className("count")); return button.getText(); } }
15579c919f12cc78b565ca13b9253f8b18bc55b6
c38815f32153fa1701d4747089f899777e96ca28
/viewgroup1/src/main/java/com/konvy/viewgroup1/view/Viewgroup1.java
78197f9f0bab5af86830ff664f0b5bffe4f679a0
[]
no_license
weijiechenlun/first-app
8f3a396ee247a7af85f713dce46c8fa48a9286d9
737ce1871dd81739593bb177939823875f64fa9f
refs/heads/master
2021-01-10T02:14:26.955332
2015-10-13T06:54:18
2015-10-13T06:54:18
44,157,375
0
0
null
null
null
null
UTF-8
Java
false
false
4,077
java
package com.konvy.viewgroup1.view; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; /** * Created by Administrator on 2015/10/8. */ public class Viewgroup1 extends ViewGroup { public Viewgroup1(Context context, AttributeSet attrs) { super(context, attrs); } @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new MarginLayoutParams(getContext(), attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //measureChildren(widthMeasureSpec, heightMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); //用于计算左边两个child的高度 int lHeight = 0; //用于计算右边两个child的高度,取左右两边高度的最大值 int rHeight = 0; //用于计算上边两个child的宽度 int tWidth = 0; //用于计算下边两个child的宽度,取上下两边宽度的最大值 int bWidth = 0; int count = getChildCount(); int cWidth = 0; int cHeight = 0; MarginLayoutParams cParams = null; for(int i = 0; i < count; i++){ View child = getChildAt(i); measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); cWidth = child.getMeasuredWidth(); cHeight = child.getMeasuredHeight(); cParams = (MarginLayoutParams) child.getLayoutParams(); if(i == 0 || i == 1){ tWidth += cWidth + cParams.leftMargin + cParams.rightMargin; } if(i == 2 || i == 3){ bWidth += cWidth + cParams.leftMargin + cParams.rightMargin; } if(i == 0 || i == 2){ lHeight += cHeight + cParams.topMargin + cParams.bottomMargin; } if(i == 1 || i == 3){ rHeight += cHeight + cParams.topMargin + cParams.bottomMargin; } } int width = Math.max(tWidth,bWidth); int height = Math.max(lHeight,rHeight); //如果是wrap_content设置为我们计算的值,否则:直接设置为父容器计算的值 setMeasuredDimension(widthMode == MeasureSpec.EXACTLY ? widthSize : width, heightMode == MeasureSpec.EXACTLY ? heightSize : height); } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { if(changed){ int count = getChildCount(); int cWidth = 0; int cHeight = 0; MarginLayoutParams cParams = null; for(int i = 0; i < count; i++){ View child = getChildAt(i); cWidth = child.getMeasuredWidth(); cHeight = child.getMeasuredHeight(); cParams = (MarginLayoutParams) child.getLayoutParams(); int cl = 0, ct = 0, cr = 0, cb = 0; switch (i){ case 0: cl = cParams.leftMargin; ct = cParams.topMargin; break; case 1: cl = getMeasuredWidth() - cWidth - cParams.rightMargin; ct = cParams.topMargin; break; case 2: cl = cParams.leftMargin; ct = getMeasuredHeight() - cHeight - cParams.bottomMargin; break; case 3: cl = getMeasuredWidth() - cWidth - cParams.rightMargin; ct = getMeasuredHeight() - cHeight - cParams.bottomMargin; break; } child.layout(cl, ct, cl + cWidth, ct + cHeight); } } } }
dd35084daa3a7131ea12f4ec2bc67704db575e07
d2d50026e72ba633995351a7e2466052d1027e32
/src/test/java/command/DeleteCommandTest.java
111d0ae5f31822b09e806643adfcfa0c4fd6621c
[]
no_license
Cary-Xx/duke
d2b3fddd2f3d4bb6dc59ac27ba84e5bb33571470
f97c95fa6499813ebaeff90fd976b6bfaf943b3c
refs/heads/master
2020-07-15T08:03:50.661683
2019-09-30T12:17:46
2019-09-30T13:56:21
205,518,049
0
0
null
2019-09-26T10:19:01
2019-08-31T08:32:35
Java
UTF-8
Java
false
false
1,526
java
package command; import org.junit.jupiter.api.Test; import task.Task; import task.TaskList; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteCommandTest { @Test public void testDelete_succesfullyDelete() { TaskList taskList = new TaskList(); taskList.addTask(new Task("todo borrow book")); DeleteCommand deleteCommand = new DeleteCommand("delete 1"); deleteCommand.executeCommand(taskList, null); assertEquals(taskList.getTasks().size(), 0); } @Test public void testDelete_EmptyEntry_returnEmptyMessage() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); TaskList taskList = new TaskList(); DeleteCommand deleteCommand = new DeleteCommand("delete"); String result = deleteCommand.executeCommand(taskList, null); assertEquals(result, "☹ OOPS!!! You cannot delete an empty entry.\n"); } @Test public void testDelete_Outofbound_outofboundMessage() { TaskList taskList = new TaskList(); taskList.addTask(new Task("todo borrow book")); DeleteCommand deleteCommand = new DeleteCommand("delete 2"); String result = deleteCommand.executeCommand(taskList, null); assertEquals(result, "☹ OOPS!!! Out of range, the task does not exist.\n"); } }
226ae2d394588f9d539b0f2f0c3ef426303fe045
79da31368dd81ee236798487cdc4fdeb39f0545f
/MiniOpdrachtenWeek2/opdracht3.java
809e9eaa6265c1cb6f9c9ff973e09862196ad65c
[]
no_license
tessievh/TraineeshipOefeningen
765f83952f9c0a1070573826e984b803b3d36746
02784cd13c818b9f895439e3b64484a7b7212045
refs/heads/master
2022-11-29T22:23:32.350843
2020-07-31T08:07:23
2020-07-31T08:07:23
280,388,397
0
0
null
null
null
null
UTF-8
Java
false
false
452
java
package MiniOpdrachtenWeek2; import java.util.Scanner; public class opdracht3 { public static void main(String[] args) { // Opdracht 3 Scanner sc = new Scanner(System.in); int i = sc.nextInt(); // Vergelijk cijfer met 6 if (i > 6) { System.out.println("Getal hoger dan 6"); } if (i == 6) { System.out.println("Getal gelijk aan 6"); } if (i < 6) { System.out.println("Getal lager dan 6"); } } }
2d880a1da99127308664a30d6efec590ca3b99d4
94bebceb987c7bd1b7902644ef92539a0f6aec89
/app/src/main/java/com/example/llcgs/android_kotlin/utils/ClickableMovementMethod.java
a19f26eb7b3c4c863d73e5e70ae2d699783e64c7
[]
no_license
AppleNet/Android_Kotlin_MVP
281ca99ae568f6b80df2c321f6addee0188fa0bf
decc276ec1089bae9f3ecf87a0a0412ad15e9896
refs/heads/master
2021-06-14T21:25:43.712588
2020-06-24T02:59:48
2020-06-24T02:59:48
91,753,755
3
1
null
null
null
null
UTF-8
Java
false
false
2,353
java
/* * Copyright (c) 2016 Zhang Hai <[email protected]> * All Rights Reserved. */ package com.example.llcgs.android_kotlin.utils; import android.text.Layout; import android.text.Selection; import android.text.Spannable; import android.text.method.BaseMovementMethod; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.view.MotionEvent; import android.widget.TextView; /** * A movement method that traverses links in the text buffer and fires clicks. Unlike * {@link LinkMovementMethod}, this will not consume touch events outside {@link ClickableSpan}s. */ public class ClickableMovementMethod extends BaseMovementMethod { private static ClickableMovementMethod sInstance; public static ClickableMovementMethod getInstance() { if (sInstance == null) { sInstance = new ClickableMovementMethod(); } return sInstance; } @Override public boolean canSelectArbitrarily() { return false; } @Override public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { int action = event.getActionMasked(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length > 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); } else { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); } return true; } else { Selection.removeSelection(buffer); } } return false; } @Override public void initialize(TextView widget, Spannable text) { Selection.removeSelection(text); } }
02a49c99740aff86a1e24110228eefac4d62cc0f
4992205d4a487b7e3cf7f0b47e1fe73c56ea8f47
/src/main/java/com/somnus/designPatterns/simpleFactory/ChartFactory.java
2272762be472efef0b8eea88627f0547e73c682e
[]
no_license
love-sang/J2SE
bb4f8299bd3971bf3182d6fa544e87c6aafcd532
1beb3982311b8fd74ac4354aaac9c4d340ffbb69
refs/heads/master
2020-12-24T05:23:53.791188
2016-06-08T09:26:21
2016-06-08T09:26:21
60,252,274
0
0
null
null
null
null
UTF-8
Java
false
false
959
java
package com.somnus.designPatterns.simpleFactory; /** * @Title: ChartFactory.java * @Package com.somnus.designPatterns.simpleFactory * @Description: TODO * @author Somnus * @date 2015年6月25日 上午11:19:25 * @version V1.0 */ public class ChartFactory { //静态工厂方法 public static Chart getChart(String type) { Chart chart = null; if (type.equalsIgnoreCase("histogram")) { chart = new HistogramChart(); System.out.println("初始化设置柱状图!"); } else if (type.equalsIgnoreCase("pie")) { chart = new PieChart(); System.out.println("初始化设置饼状图!"); } else if (type.equalsIgnoreCase("line")) { chart = new LineChart(); System.out.println("初始化设置折线图!"); } return chart; } }
7e873d92ce5d6fbc7ff246d38a85791aa0664ed5
61919600f624f17a625b8ca34a2d42c1e3b674cd
/Introduction/src/Alerts.java
b933bfb03501e0f7bfb27aa016222676476792ac
[]
no_license
ajithkallur/selenium-training
74ccbc08aa7f1f372e31d30c47c3a24bf051d8c8
77e93557dcb681f9a73ca5cd76a2e59d2cf4fe59
refs/heads/master
2023-05-05T19:10:48.707913
2021-05-27T15:58:22
2021-05-27T15:58:22
371,428,844
0
0
null
null
null
null
UTF-8
Java
false
false
956
java
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Alerts { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "C:\\Users\\ajith.kumarreddy\\Desktop\\Selenium\\chromedriver.exe"); WebDriver driver =new ChromeDriver(); driver.get("https://rahulshettyacademy.com/AutomationPractice/"); String text="Rahul"; driver.findElement(By.id("name")).sendKeys(text); driver.findElement(By.cssSelector("[id='alertbtn']")).click(); System.out.println(driver.switchTo().alert().getText()); // click on alert ok driver.switchTo().alert().accept(); driver.findElement(By.id("confirmbtn")).click(); System.out.println(driver.switchTo().alert().getText()); // click on alert cancel driver.switchTo().alert().dismiss(); } }
1fefefda4961d578ac24a5f4f267e2ace2e95232
8d8992f389a9e8345cbcfc5c5b8dd64dcca9159a
/app/src/main/java/com/example/lx/listfragment/DataOptimizeLvActivity.java
c9bf21785650a58ec9937eac597ab76b6e5a700b
[]
no_license
lxg2012/ListFragment
7bc33041c05463de6024e1df1fd6a6f36e776d6a
d29ada68c671f57b97c9ea9cea1d7de0ac57d743
refs/heads/master
2020-04-11T03:18:44.041098
2018-03-08T01:58:37
2018-03-08T01:58:37
124,323,081
0
0
null
null
null
null
UTF-8
Java
false
false
1,902
java
package com.example.lx.listfragment; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import com.plattysoft.leonids.ParticleSystem; import com.plattysoft.leonids.modifiers.ScaleModifier; /** * @author LX * 复杂数据流在ListView中的应用 */ public class DataOptimizeLvActivity extends AppCompatActivity { private ListView listView; private ListAdapter listAdapter; private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_data_optimize_lv); imageView = (ImageView) findViewById(R.id.imageView); // listView = (ListView) findViewById(R.id.listview); imageView.postDelayed(new Runnable() { @Override public void run() { new ParticleSystem(DataOptimizeLvActivity.this, 500, R.mipmap.bg_demo, 5000) .setAcceleration(0.00003f, 270) .addModifier(new ScaleModifier(0, 1.2f, 1000, 4000)) .setFadeOut(5000) .setRotationSpeedRange(0, 180) .emit(imageView, 50); } }, 2000); } private class ListAdapter extends BaseAdapter { @Override public int getCount() { return 0; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { return null; } } }
196f2eaad197bedf9d13daf264768e516ddf9927
5148293c98b0a27aa223ea157441ac7fa9b5e7a3
/Method_Scraping/xml_scraping/NicadOutputFile_t1_beam/Nicad_t1_beam3531.java
b27671876d3804398d2a1f04fa794f206a700df9
[]
no_license
ryosuke-ku/TestCodeSeacherPlus
cfd03a2858b67a05ecf17194213b7c02c5f2caff
d002a52251f5461598c7af73925b85a05cea85c6
refs/heads/master
2020-05-24T01:25:27.000821
2019-08-17T06:23:42
2019-08-17T06:23:42
187,005,399
0
0
null
null
null
null
UTF-8
Java
false
false
453
java
// clone pairs:13266:80% // 19426:beam/sdks/java/core/src/main/java/org/apache/beam/sdk/io/range/ByteKeyRange.java public class Nicad_t1_beam3531 { public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ByteKeyRange)) { return false; } ByteKeyRange other = (ByteKeyRange) o; return Objects.equals(startKey, other.startKey) && Objects.equals(endKey, other.endKey); } }
85a77774933b915e13868f737148d9350a99b9bb
647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4
/com.tencent.mm/classes.jar/com/tencent/tencentmap/mapsdk/maps/model/UrlTileProvider.java
eed04d2f3305087f5218d021ec74f47da7f21621
[]
no_license
tsuzcx/qq_apk
0d5e792c3c7351ab781957bac465c55c505caf61
afe46ef5640d0ba6850cdefd3c11badbd725a3f6
refs/heads/main
2022-07-02T10:32:11.651957
2022-02-01T12:41:38
2022-02-01T12:41:38
453,860,108
36
9
null
2022-01-31T09:46:26
2022-01-31T02:43:22
Java
UTF-8
Java
false
false
2,219
java
package com.tencent.tencentmap.mapsdk.maps.model; import com.tencent.map.tools.net.NetManager; import com.tencent.map.tools.net.NetRequest.NetRequestBuilder; import com.tencent.map.tools.net.NetResponse; import com.tencent.map.tools.net.exception.NetErrorException; import java.net.URL; public abstract class UrlTileProvider implements TileProvider { private final int mHeight; private final int mWidth; public UrlTileProvider() { this(256, 256); } public UrlTileProvider(int paramInt1, int paramInt2) { this.mWidth = paramInt1; this.mHeight = paramInt2; } public final Tile getTile(int paramInt1, int paramInt2, int paramInt3) { Object localObject2 = null; Object localObject1 = getTileUrl(paramInt1, paramInt2, paramInt3); Tile localTile = NO_TILE; if (localObject1 == null) {} NetResponse localNetResponse; do { while ((localObject1 == null) || (localObject1.length == 0)) { return localTile; localNetResponse = requestTileData(((URL)localObject1).toString()); localObject1 = localObject2; if (localNetResponse != null) { if (!localNetResponse.available()) { break; } localObject1 = localNetResponse.data; } } return new Tile(this.mWidth, this.mHeight, (byte[])localObject1); localObject1 = localObject2; } while (!(localNetResponse.exception instanceof NetErrorException)); if (localNetResponse.statusCode == 404) { return NO_TILE; } return new Tile(this.mWidth, this.mHeight, null); } public abstract URL getTileUrl(int paramInt1, int paramInt2, int paramInt3); protected NetResponse requestTileData(String paramString) { try { paramString = NetManager.getInstance().builder().url(paramString).doGet(); return paramString; } catch (Exception paramString) {} return null; } } /* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes11.jar * Qualified Name: com.tencent.tencentmap.mapsdk.maps.model.UrlTileProvider * JD-Core Version: 0.7.0.1 */
bbc31f197ba3990bed7b9c756a6ce10b62adb1dc
8af1164bac943cef64e41bae312223c3c0e38114
/results-java/haifengl--smile/5a41c8abc9b1045ef354081220d08f28da44414c/before/MultivariateGaussianDistribution.java
765ef9dc71fd00936115a80f81138a3012a1d71b
[]
no_license
fracz/refactor-extractor
3ae45c97cc63f26d5cb8b92003b12f74cc9973a9
dd5e82bfcc376e74a99e18c2bf54c95676914272
refs/heads/master
2021-01-19T06:50:08.211003
2018-11-30T13:00:57
2018-11-30T13:00:57
87,353,478
0
0
null
null
null
null
UTF-8
Java
false
false
11,372
java
/******************************************************************************* * Copyright (c) 2010 Haifeng Li * * 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 smile.stat.distribution; import smile.math.matrix.CholeskyDecomposition; import smile.math.Math; /** * Multivariate Gaussian distribution. * * @see GaussianDistribution * * @author Haifeng Li */ public class MultivariateGaussianDistribution extends AbstractMultivariateDistribution implements MultivariateExponentialFamily { private static final double LOG2PIE = Math.log(2 * Math.PI * Math.E); double[] mu; double[][] sigma; boolean diagonal; private int dim; private double[][] sigmaInv; private double[][] sigmaL; private double sigmaDet; private double pdfConstant; private int numParameters; /** * Constructor. The distribution will have a diagonal covariance matrix of * the same variance. * * @param mean mean vector. * @param var variance. */ public MultivariateGaussianDistribution(double[] mean, double var) { if (var <= 0) { throw new IllegalArgumentException("Variance is not positive: " + var); } mu = new double[mean.length]; sigma = new double[mu.length][mu.length]; for (int i = 0; i < mu.length; i++) { mu[i] = mean[i]; sigma[i][i] = var; } diagonal = true; numParameters = mu.length + 1; init(); } /** * Constructor. The distribution will have a diagonal covariance matrix. * Each element has different variance. * * @param mean mean vector. * @param var variance vector. */ public MultivariateGaussianDistribution(double[] mean, double[] var) { if (mean.length != var.length) { throw new IllegalArgumentException("Mean vector and covariance matrix have different dimension"); } mu = new double[mean.length]; sigma = new double[mu.length][mu.length]; for (int i = 0; i < mu.length; i++) { if (var[i] <= 0) { throw new IllegalArgumentException("Variance is not positive: " + var[i]); } mu[i] = mean[i]; sigma[i][i] = var[i]; } diagonal = true; numParameters = 2 * mu.length; init(); } /** * Constructor. * * @param mean mean vector. * @param cov covariance matrix. */ public MultivariateGaussianDistribution(double[] mean, double[][] cov) { if (mean.length != cov.length) { throw new IllegalArgumentException("Mean vector and covariance matrix have different dimension"); } mu = new double[mean.length]; sigma = new double[mean.length][mean.length]; for (int i = 0; i < mu.length; i++) { mu[i] = mean[i]; System.arraycopy(cov[i], 0, sigma[i], 0, mu.length); } diagonal = false; numParameters = mu.length + mu.length * (mu.length + 1) / 2; init(); } /** * Constructor. Mean and covariance will be estimated from the data by MLE. * @param data the training data. */ public MultivariateGaussianDistribution(double[][] data) { this(data, false); } /** * Constructor. Mean and covariance will be estimated from the data by MLE. * @param data the training data. * @param diagonal true if covariance matrix is diagonal. */ public MultivariateGaussianDistribution(double[][] data, boolean diagonal) { this.diagonal = diagonal; mu = Math.colMeans(data); if (diagonal) { sigma = new double[data[0].length][data[0].length]; for (int i = 0; i < data.length; i++) { for (int j = 0; j < mu.length; j++) { sigma[j][j] += (data[i][j] - mu[j]) * (data[i][j] - mu[j]); } } for (int j = 0; j < mu.length; j++) { sigma[j][j] /= (data.length - 1); } } else { sigma = Math.cov(data, mu); } numParameters = mu.length + mu.length * (mu.length + 1) / 2; init(); } /** * Initialize the object. */ private void init() { dim = mu.length; CholeskyDecomposition cholesky = new CholeskyDecomposition(sigma); sigmaInv = cholesky.inverse().array(); sigmaDet = cholesky.det(); sigmaL = cholesky.getL(); pdfConstant = (dim * Math.log(2 * Math.PI) + Math.log(sigmaDet)) / 2.0; } /** * Returns true if the covariance matrix is diagonal. * @return true if the covariance matrix is diagonal */ public boolean isDiagonal() { return diagonal; } @Override public int npara() { return numParameters; } @Override public double entropy() { return (dim * LOG2PIE + Math.log(sigmaDet)) / 2; } @Override public double[] mean() { return mu; } @Override public double[][] cov() { return sigma; } /** * Returns the scatter of distribution, which is defined as |&Sigma;|. */ public double scatter() { return sigmaDet; } @Override public double logp(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } double[] v = x.clone(); Math.minus(v, mu); double result = Math.xax(sigmaInv, v) / -2.0; return result - pdfConstant; } @Override public double p(double[] x) { return Math.exp(logp(x)); } /** * Algorithm from Alan Genz (1992) Numerical Computation of * Multivariate Normal Probabilities, Journal of Computational and * Graphical Statistics, pp. 141-149. * * The difference between returned value and the true value of the * CDF is less than 0.001 in 99.9% time. The maximum number of iterations * is set to 10000. */ @Override public double cdf(double[] x) { if (x.length != dim) { throw new IllegalArgumentException("Sample has different dimension."); } int Nmax = 10000; double alph = GaussianDistribution.getInstance().quantile(0.999); double errMax = 0.001; double[] v = x.clone(); Math.minus(v, mu); double p = 0.0; double varSum = 0.0; // d is always zero double[] f = new double[dim]; f[0] = GaussianDistribution.getInstance().cdf(v[0] / sigmaL[0][0]); double[] y = new double[dim]; double err = 2 * errMax; int N; for (N = 1; err > errMax && N <= Nmax; N++) { double[] w = Math.random(dim - 1); for (int i = 1; i < dim; i++) { y[i - 1] = GaussianDistribution.getInstance().quantile(w[i - 1] * f[i - 1]); double q = 0.0; for (int j = 0; j < i; j++) { q += sigmaL[i][j] * y[j]; } f[i] = GaussianDistribution.getInstance().cdf((v[i] - q) / sigmaL[i][i]) * f[i - 1]; } double del = (f[dim - 1] - p) / N; p += del; varSum = (N - 2) * varSum / N + del * del; err = alph * Math.sqrt(varSum); } return p; } /** * Generate a random multivariate Gaussian sample. */ public double[] rand() { double[] spt = new double[mu.length]; for (int i = 0; i < mu.length; i++) { double u, v, q; do { u = Math.random(); v = 1.7156 * (Math.random() - 0.5); double x = u - 0.449871; double y = Math.abs(v) + 0.386595; q = x * x + y * (0.19600 * y - 0.25472 * x); } while (q > 0.27597 && (q > 0.27846 || v * v > -4 * Math.log(u) * u * u)); spt[i] = v / u; } double[] pt = new double[sigmaL.length]; // pt = sigmaL * spt for (int i = 0; i < pt.length; i++) { for (int j = 0; j <= i; j++) { pt[i] += sigmaL[i][j] * spt[j]; } } Math.plus(pt, mu); return pt; } @Override public MultivariateMixture.Component M(double[][] x, double[] posteriori) { int n = x[0].length; double alpha = 0.0; double[] mean = new double[n]; double[][] cov = new double[n][n]; for (int k = 0; k < x.length; k++) { alpha += posteriori[k]; for (int i = 0; i < n; i++) { mean[i] += x[k][i] * posteriori[k]; } } for (int i = 0; i < mean.length; i++) { mean[i] /= alpha; } if (diagonal) { for (int k = 0; k < x.length; k++) { for (int i = 0; i < n; i++) { cov[i][i] += (x[k][i] - mean[i]) * (x[k][i] - mean[i]) * posteriori[k]; } } for (int i = 0; i < cov.length; i++) { cov[i][i] /= alpha; } } else { for (int k = 0; k < x.length; k++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cov[i][j] += (x[k][i] - mean[i]) * (x[k][j] - mean[j]) * posteriori[k]; } } } for (int i = 0; i < cov.length; i++) { for (int j = 0; j < cov[i].length; j++) { cov[i][j] /= alpha; } // make sure the covariance matrix is positive definite. cov[i][i] *= 1.00001; } } MultivariateMixture.Component c = new MultivariateMixture.Component(); c.priori = alpha; MultivariateGaussianDistribution g = new MultivariateGaussianDistribution(mean, cov); g.diagonal = diagonal; c.distribution = g; return c; } @Override public String toString() { StringBuilder builder = new StringBuilder("Multivariate Gaussian Distribution:\nmu = ["); for (int i = 0; i < mu.length; i++) { builder.append(mu[i]).append(" "); } builder.setCharAt(builder.length() - 1, ']'); builder.append("\nSigma = [\n"); for (int i = 0; i < sigma.length; i++) { builder.append('\t'); for (int j = 0; j < sigma[i].length; j++) { builder.append(sigma[i][j]).append(" "); } builder.append('\n'); } builder.append("\t]"); return builder.toString(); } }