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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bc26cd631f7e7e8909b0b060dbdef2f4a48997e2 | 357acd418a438aab82c3cdac8db073dd1b084d60 | /interior-device-gateway/src/main/java/com/konka/iot/interior/device/gateway/config/WebMvcConfig.java | bfb4a77147b742372c2f2e85d9115a00014be6cb | [] | no_license | xiexinyuan/kilink-v2 | bc6048004dc892f6235c65f2d33136897908c44d | 1013dde8097f78c962e9742284692d140657ccf4 | refs/heads/master | 2022-11-24T03:40:21.192321 | 2020-03-10T02:19:08 | 2020-03-10T02:19:08 | 216,464,120 | 0 | 2 | null | 2022-11-16T12:25:44 | 2019-10-21T02:47:52 | Java | UTF-8 | Java | false | false | 1,235 | java | package com.konka.iot.interior.device.gateway.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author xiexinyuan
* @version 1.0
* @createTime 2019-09-29 14:28
* @Description 配置拦截器
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
// @Autowired
// TuyaInterceptor tuyaInterceptor;
//
// // 配置拦截器
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(tuyaInterceptor)
// .addPathPatterns("/**")
// // 忽略swagger的请求
// .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
// }
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
| [
"[email protected]"
] | |
af2db553725c32d130c2df5fd478dbcb481be0a0 | 6b4b34c9ad78ed81eb019da8f5eb09e861ec630f | /Java OOP/classRoster/classRoster/src/main/java/com/dm/service/ClassRosterDuplicateIdException.java | bb8037e1f83a320100b265c9ffafc8d8ef0a318c | [] | no_license | janssenda/thenewcarag | 497440b3314491f9b87890505e48d4dd48396421 | beea1e1c777fd3bc332cc5e2ba7476926c706b85 | refs/heads/master | 2021-01-19T14:18:39.649854 | 2018-07-02T22:15:38 | 2018-07-02T22:15:38 | 100,893,528 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 531 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dm.service;
/**
*
* @author danimaetrix
*/
public class ClassRosterDuplicateIdException extends Exception {
public ClassRosterDuplicateIdException(String message) {
super(message);
}
public ClassRosterDuplicateIdException(String message,
Throwable cause) {
super(message, cause);
}
}
| [
"[email protected]"
] | |
d85b05ebdbb32381b66516b09db6a4c9fae1e0ad | 000c7ff03a7da1788bc596ce519751de515e846e | /greendaostudy/src/main/java/com/assassin/greendaostudy/app/GreenDaoApp.java | 9a1a405241a6aa4554f68ce8b21fc6a68934ee44 | [] | no_license | shaycormac/ShayPatrickCormacStudy | bd4faacd9d74781b3130f66590e6775cdf1fc099 | 4f4c685c45b079bc968a01c3bba4d60ffde4c856 | refs/heads/master | 2021-01-20T12:23:05.319732 | 2017-07-15T04:46:25 | 2017-07-15T04:46:25 | 90,359,265 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 701 | java | package com.assassin.greendaostudy.app;
import android.app.Application;
import com.assassin.greendaostudy.greendaohelper.DBManager;
import com.facebook.stetho.Stetho;
/**
* @Author: Shay-Patrick-Cormac
* @Email: [email protected]
* @Ltd: GoldMantis
* @Date: 2017/5/2 13:42
* @Version:
* @Description:
*/
public class GreenDaoApp extends Application
{
public static GreenDaoApp instance;
@Override
public void onCreate()
{
super.onCreate();
instance = this;
// GreenDaoHelper.intDatabase();
//初始化数据库
DBManager.INSTANCE.initDataBase();
//facebook调试数据库
Stetho.initializeWithDefaults(this);
}
}
| [
"[email protected]"
] | |
8a7a3ded885877d7965f9c5646bb17071b63c165 | f0d25d83176909b18b9989e6fe34c414590c3599 | /app/src/main/java/com/google/android/gms/internal/ya.java | b8f7773d374464f4623bd4ff40f817ef8ba5275b | [] | no_license | lycfr/lq | e8dd702263e6565486bea92f05cd93e45ef8defc | 123914e7c0d45956184dc908e87f63870e46aa2e | refs/heads/master | 2022-04-07T18:16:31.660038 | 2020-02-23T03:09:18 | 2020-02-23T03:09:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 578 | java | package com.google.android.gms.internal;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
final class ya extends ThreadLocal<CharsetDecoder> {
ya() {
}
/* access modifiers changed from: protected */
public final /* synthetic */ Object initialValue() {
CharsetDecoder newDecoder = Charset.forName("UTF8").newDecoder();
newDecoder.onMalformedInput(CodingErrorAction.REPORT);
newDecoder.onUnmappableCharacter(CodingErrorAction.REPORT);
return newDecoder;
}
}
| [
"[email protected]"
] | |
5a87fa25140c89b68c0bf47d513b38e2092c9834 | a339529563aacef12e1f587354bccfc68d1cd462 | /src/main/java/org/segrada/service/repository/NodeRepository.java | 8660938896946cf858b4f708ae39915f60a8dc62 | [
"Apache-2.0"
] | permissive | ronypik/segrada | e9ff9af4468d69eb325dff0867acf6c6a9353d25 | 2fa6f77b4d8c7dcf28f50a9597f855a3902d517c | refs/heads/master | 2020-04-21T23:58:15.682013 | 2018-04-20T12:50:10 | 2018-04-20T12:50:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,543 | java | package org.segrada.service.repository;
import org.segrada.model.prototype.INode;
import org.segrada.service.repository.prototype.CRUDRepository;
import org.segrada.service.repository.prototype.PaginatingRepositoryOrService;
import org.segrada.service.repository.prototype.SearchTermRepository;
import javax.annotation.Nullable;
import java.util.List;
/**
* Copyright 2015 Maximilian Kalus [[email protected]]
*
* 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.
*
* Node Repository
*/
public interface NodeRepository extends CRUDRepository<INode>, SearchTermRepository<INode>, PaginatingRepositoryOrService<INode> {
/**
* find by search terms, but also contain by tags (used in reference search)
* @param term to search for
* @param maximum to show
* @param returnWithoutTerm show list even without search
* @param tagIds list of tag ids to contain search in
* @return list of entities
*/
List<INode> findBySearchTermAndTags(@Nullable String term, int maximum, boolean returnWithoutTerm, @Nullable String[] tagIds);
}
| [
"[email protected]"
] | |
53487124473f00413091a959a05b7a270f1e4181 | 4299f856f23977ddbec27d2af67c962e8b36b5ed | /Aufgabe/src/SongTree1.java | fe46e31949859f599be4b6d2a915a34d39f76a49 | [] | no_license | Florian-S-A-W/Eprog2_SS2018 | 9ecfb24333a318d0b4225f928e5cc66e0fbcabfe | 91e0c6d161bc2af2bda461daf8393cbeb4665118 | refs/heads/master | 2020-03-13T16:35:48.898226 | 2018-06-17T20:36:55 | 2018-06-17T20:36:55 | 131,201,853 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 713 | java |
public class SongTree1 {
SongTreeNodable root;
public SongTree1() {
this.root = new SongTree1Null();
}
/**
* Adds a song to the binary tree
*
* @param song a new song that shall be added to the tree
* @throws IllegalArgumentException song == null
*
* Postcondition: The song is in the tree if it is not null
*/
public void add(Song song) throws IllegalArgumentException {
if(song == null) {
throw new IllegalArgumentException();
}
this.root = this.root.add(song);
}
public void print() {
this.root.print();
}
public String toString() {
return this.root.toString();
}
} | [
"[email protected]"
] | |
14429ebec3620fb5f7de32832f42aec9750213eb | c9a21954bb5f4de1893051405b5b95fcb1e8a973 | /app/src/main/java/com/tensor/dapavlov1/tensorfirststep/presentation/common/visual/SwitchGradient.java | e46f02307feb9c1b885eb13307871b0b1d4818fa | [] | no_license | CapitainMarkul/WeatherInfo | 37bbd106e69805cae26525431d7f5fb7ef393fd4 | b82527bd984d0ed9ec70a32d6430bb8158dbab03 | refs/heads/master | 2021-07-11T03:36:10.245119 | 2017-08-16T08:18:30 | 2017-08-16T08:18:30 | 100,246,270 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,363 | java | package com.tensor.dapavlov1.tensorfirststep.presentation.common.visual;
import android.graphics.drawable.Drawable;
import com.tensor.dapavlov1.tensorfirststep.App;
import com.tensor.dapavlov1.tensorfirststep.R;
/**
* Created by da.pavlov1 on 08.08.2017.
*/
public class SwitchGradient {
private static SwitchGradient instance;
private SwitchGradient() {
}
public static SwitchGradient getInstance() {
if (instance == null) {
instance = new SwitchGradient();
}
return instance;
}
public Drawable getBackgroung(String iconCode) {
if (iconCode.contains("c01d")) {
return App.getContext().getResources().getDrawable(R.drawable.background_gradient_cloud_sun, null);
} else if (iconCode.contains("c01n")) {
return App.getContext().getResources().getDrawable(R.drawable.background_gradient_night, null);
} else if (iconCode.contains("c02")
|| iconCode.contains("a")) {
return App.getContext().getResources().getDrawable(R.drawable.background_gradient_cloud_sun, null);
} else if (iconCode.contains("c04")) {
return App.getContext().getResources().getDrawable(R.drawable.background_gradient_cloud, null);
} else {
return App.getContext().getResources().getDrawable(R.drawable.background_gradient_rain, null);
}
// switch (iconCode.substring(0,1)){
// case
// case "t": return App.getContext().getResources().getDrawable(R.drawable.background_gradient_rain, null);
// case "d": return App.getContext().getResources().getDrawable(R.drawable.background_gradient_rain, null);
// case "s": return App.getContext().getResources().getDrawable(R.drawable.background_gradient_rain, null);
// }
}
// public ShapeDrawable createRandomGradient(int widthElement, int heightElement) {
// ShapeDrawable mDrawable = new ShapeDrawable(new RectShape());
// mDrawable.getPaint().setShader(new LinearGradient(0, 0, 0, 350,
// Color.rgb(genInt(), genInt(), genInt()), Color.parseColor("#80FFFFFF"),
// Shader.TileMode.REPEAT));
//
// return mDrawable;
// }
//
// private int genInt() {
// Random random = new Random();
// return random.nextInt(255);
// }
}
| [
"[email protected]"
] | |
da5211cf697d5935d226cae842f687d63a034316 | 034dd8550e48d4b7dfd26fae7bbbfe25a23706d0 | /subprojects/lensFlare/src/water/WaterRenderer.java | 560feeaa3c0ef9c221cc30ed2ab98ada1c2a03b4 | [] | no_license | dtrajko/lwjgl_game | 3182a970fc542dc1fb1e606f7c72349d8934e354 | 91e7e01930f411af3ddc545ce742c6eebf2f5d95 | refs/heads/master | 2021-05-12T03:02:43.863050 | 2020-05-01T23:36:35 | 2020-05-01T23:36:35 | 117,606,702 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,974 | java | package water;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import openglObjects.Vao;
import textures.Texture;
import utils.ICamera;
import utils.MyFile;
import utils.OpenGlUtils;
public class WaterRenderer {
private static final MyFile DUDV_MAP = new MyFile("res", "waterDUDV.png");
private static final MyFile NORMAL_MAP = new MyFile("res", "normal.png");
// private static final float WAVE_SPEED = 0.03f;
private Vao quad;
private WaterShader shader;
private WaterFrameBuffers fbos;
private float moveFactor = 0;
private Texture dudvTexture;
private Texture normalMap;
public WaterRenderer(WaterFrameBuffers fbos) {
this.shader = new WaterShader();
this.fbos = fbos;
this.quad = QuadGenerator.generateQuad();
this.normalMap = Texture.newTexture(NORMAL_MAP).create();
this.dudvTexture = Texture.newTexture(DUDV_MAP).anisotropic().create();
}
public void render(List<WaterTile> water, ICamera camera, Vector3f lightDir) {
prepareRender(camera, lightDir);
for (WaterTile tile : water) {
Matrix4f modelMatrix = createModelMatrix(tile.getX(), tile.getHeight(), tile.getZ(), WaterTile.TILE_SIZE);
shader.modelMatrix.loadMatrix(modelMatrix);
GL11.glDrawElements(GL11.GL_TRIANGLES, quad.getIndexCount(), GL11.GL_UNSIGNED_INT, 0);
}
finish();
}
public void cleanUp() {
quad.delete();
dudvTexture.delete();
normalMap.delete();
fbos.cleanUp();
shader.cleanUp();
}
private void prepareRender(ICamera camera, Vector3f lightDir) {
shader.start();
shader.projectionMatrix.loadMatrix(camera.getProjectionMatrix());
shader.viewMatrix.loadMatrix(camera.getViewMatrix());
shader.cameraPosition.loadVec3(camera.getPosition());
moveFactor += 0.0005f;
moveFactor %= 1;
shader.moveFactor.loadFloat(moveFactor);
shader.lightDirection.loadVec3(lightDir);
quad.bind(0);
bindTextures();
doRenderSettings();
}
private void bindTextures() {
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getReflectionTexture());
GL13.glActiveTexture(GL13.GL_TEXTURE1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionTexture());
dudvTexture.bindToUnit(2);
normalMap.bindToUnit(3);
GL13.glActiveTexture(GL13.GL_TEXTURE4);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionDepthTexture());
}
private void doRenderSettings() {
OpenGlUtils.enableDepthTesting(true);
OpenGlUtils.antialias(false);
OpenGlUtils.cullBackFaces(true);
OpenGlUtils.enableAlphaBlending();
}
private void finish() {
quad.unbind(0);
shader.stop();
}
private Matrix4f createModelMatrix(float x, float y, float z, float scale) {
Matrix4f modelMatrix = new Matrix4f();
Matrix4f.translate(new Vector3f(x, y, z), modelMatrix, modelMatrix);
Matrix4f.scale(new Vector3f(scale, scale, scale), modelMatrix, modelMatrix);
return modelMatrix;
}
}
| [
"[email protected]"
] | |
8a6983277255a94ebb2cb1359a4173a5b48638c0 | 82f559b5ccdab6f14e2965a3864e8cbf183c8201 | /app/src/main/java/org/android/framework/engine/http/HttpRequestCallBack.java | daef119d5e152c856f6f977b6ad86d0a38577538 | [] | no_license | shenyansycn/AndroidFrameWork | c88e7ba70c4eea4777949817b33a49add2ce0cfa | 4b470a776aa69ee0895f9089bce167cee9d92462 | refs/heads/master | 2016-09-12T19:50:33.910985 | 2016-05-03T09:40:58 | 2016-05-03T09:40:58 | 57,948,348 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 190 | java | package org.android.framework.engine.http;
/**
* Created by Administrator on 2014/5/21.
*/
public interface HttpRequestCallBack {
void onSuccess(Object object);
void onFail();
}
| [
"[email protected]"
] | |
d058c57be83905c8519ab5330bb47526245f667b | 82be31cdebaede7ba52c795d3af592189f6d2d11 | /HardwareService/src/main/java/com/auv/hardware/HardwareService.java | 3e53e9e57d1b1b1a6cdd5f4674ecea9380b68242 | [] | no_license | chaimengbing/kfc | 3d64551b9ebb3dd8f6d4d48f6784083de5d81a4d | 460f5d115ffaffdcaffc77c09c6c435daf2157ce | refs/heads/master | 2023-01-05T14:41:07.349103 | 2020-10-17T11:05:49 | 2020-10-17T11:05:49 | 304,856,934 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,665 | java | package com.auv.hardware;
import android.content.Context;
import android.util.Log;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.auv.annotation.SerialPortCommand;
import com.auv.constant.Constants;
import com.auv.model.AUVBoardCellInit;
import com.auv.model.AUVCabinetCellStatus;
import com.auv.model.AUVErrorCode;
import com.auv.model.AUVErrorRecover;
import com.auv.standard.hardware.model.BoardCellNo;
import com.auv.standard.hardware.utils.SerialPortUtils;
import com.auv.utils.AUVLogUtil;
import com.auv.utils.AliYunIotUtils;
import com.auv.utils.LinkkitUtils;
import com.auv.utils.SharedPreferenceHelper;
import com.auv.utils.ThreadPoolUtil;
import com.auv.utils.Utils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author LiChuang
* @version 1.0
* @ClassName HardwareService
* @Description 控制硬件插件类
* @since 2020/1/16 10:53
**/
public abstract class HardwareService {
private static final String TAG = HardwareService.class.getName();
private static List<AUVBoardCellInit> boardCellInitList;
/**
* 启动集联控制服务
*/
public void startCouplingTransaction(String serialPort, List<AUVBoardCellInit> boardCellInitList) {
HardwareService.boardCellInitList = boardCellInitList;
}
public static List<String> getSupportSerialPort() {
String[] allSerialPorts = SerialPortUtils.getAllDevices();
List<String> serialPortList = new ArrayList<>();
for (String serialPort : allSerialPorts) {
serialPortList.add( serialPort.substring( 0, serialPort.indexOf( "(" ) ).trim() );
}
return serialPortList;
}
/**
* 设置日志保存到本地
*
* @param open
*/
public abstract void saveLog(boolean open);
/*
查询所有格口状态
*/
public abstract Map<Integer, AUVCabinetCellStatus> getAllCellStatus();
/*
查询所有格口状态
*/
public abstract AUVCabinetCellStatus getCellStatus(int cellNo);
/**
* 关闭串口
*/
public abstract void stop();
public abstract boolean isStart();
public List<AUVBoardCellInit> getBoardCellInitList() {
return boardCellInitList;
}
public abstract void openDoor(int... cellNo);
public abstract void openAllDoor();
public abstract void openLight(int cellNo);
public abstract void openAllLight();
public abstract void closeLight(int cellNo);
public abstract void closeAllLight();
public abstract void openHeating(int cellNo);
public abstract void openAllHeating();
public abstract void closeHeating(int cellNo);
public abstract void closeAllHeating();
public abstract void openIndicatorLight(int cellNo);
public abstract void openAllIndicatorLight();
public abstract void closeIndicatorLight(int cellNo);
public abstract void closeAllIndicatorLight();
public abstract void openDisinfect(int cellNo);
public abstract void openAllDisinfect();
public abstract void closeDisinfect(int cellNo);
public abstract void closeAllDisinfect();
/**
* 将副柜的格子号转换为真实的控制板地址
*/
BoardCellNo convertCellNoToBoardCellNo(int cellNo) {
final BoardCellNo boardCellNo = new BoardCellNo();
--cellNo;
int index = 0;
for (final AUVBoardCellInit boardCellInit : HardwareService.boardCellInitList) {
final int oldIndex = index;
index += boardCellInit.getCellCount();
if (cellNo < index) {
boardCellNo.setBoardNo( boardCellInit.getBoardNo() );
/*
此算法为将2号,3号柜子的格子初始化为从1开始计算
*/
boardCellNo.setCellNo( cellNo - oldIndex + 1 );
break;
}
}
return boardCellNo;
}
/**
* 将真实的控制板地址转换为格子号
*/
BoardCellNo convertBoardCellNoToCellNo(int boardNo, int cellNo) {
BoardCellNo boardCellNo = new BoardCellNo();
int index = 0;
for (int i = 0; i < HardwareService.boardCellInitList.size(); i++) {
AUVBoardCellInit boardInfo = HardwareService.boardCellInitList.get( i );
if (boardNo > boardInfo.getBoardNo()) {
index += boardInfo.getCellCount();
} else if (boardNo == boardInfo.getBoardNo()) {
boardCellNo.setBoardNo( boardNo );
boardCellNo.setCellNo( index + cellNo );
break;
}
}
return boardCellNo;
}
/**
* 监听硬件执行结果
*/
public interface ResultListener {
//监听关门
void feedbackDoorClosedListener(int cellNo);
//错误结果监听回调
void onException(AUVErrorCode errorCode);
//监听执行结果
void onCommandResult(int cellNo, boolean success, String messageId);
void onExceptionRecover(AUVErrorRecover errorRecover);
//状态变更监听
void cellStatusChangedListener(int cellNo, SerialPortCommand serialPortCommand, boolean isOpen);
}
/**
* 监听日志
*/
public interface LogListener {
void showLog(String msg);
}
protected void syncResult(int command, String property, int cellNo, boolean success) {
JSONObject ansyReturn = new JSONObject();
JSONArray jsonArray = new JSONArray();
JSONObject operation = new JSONObject();
JSONObject unit = new JSONObject();
JSONArray operations = new JSONArray();
unit.put( "cellNo", cellNo );
operation.put( "command", command );
operation.put( "property", property );
if (success) {
operation.put( "msg", "success" );
} else {
operation.put( "msg", "fail" );
}
operations.add( operation );
unit.put( "operations", operations );
jsonArray.add( unit );
/*
* 获取云端发送的指令集合
*/
ThreadPoolUtil.executorService.execute( () -> {
if (success) {
ansyReturn.put( "success", jsonArray );
} else {
ansyReturn.put( "fail", jsonArray );
}
//异步返回的信息
ansyReturn.put( "timestamp", Utils.timestamp() );
LinkkitUtils.getInstance().publishByName( Constants.ANSY, ansyReturn.toJSONString() );
AUVLogUtil.d( TAG, "ansyResult::ansyReturn:" + ansyReturn.toJSONString() );
} );
}
/**
* 同步格子状态
*/
void syncCellStatus(Context context) {
List<AUVBoardCellInit> boardCellInits = InitHardwareService.hardwareService.getBoardCellInitList();
int cellTotal = 0;
if (boardCellInits != null) {
Log.d( TAG, "syncCellStatus::boardCellInits = " + boardCellInits.toString() );
for (AUVBoardCellInit cellInit : boardCellInits) {
cellTotal += cellInit.getCellCount();
AUVLogUtil.d( TAG, "syncCellStatus::cellTotal = " + cellTotal );
}
if (cellTotal > 0) {
for (int cellNo = 1; cellNo <= cellTotal; cellNo++) {
AUVCabinetCellStatus cellStatus = (AUVCabinetCellStatus) SharedPreferenceHelper.getInstance( context ).getCellStatus( String.valueOf( cellNo ), AUVCabinetCellStatus.class );
if (null != cellStatus) {
AUVLogUtil.d( TAG, "syncCellStatus::cellNo = " + cellNo + " , " + cellStatus.toString() );
if (cellStatus.isCellLightOpen()) {
InitHardwareService.hardwareService.openLight( cellNo );
}
if (cellStatus.isCellCleanseOpen()) {
InitHardwareService.hardwareService.openDisinfect( cellNo );
}
if (cellStatus.isCellHeatingOpen()) {
InitHardwareService.hardwareService.openHeating( cellNo );
}
SharedPreferenceHelper.getInstance( context ).putObject( String.valueOf( cellNo ), cellStatus, AUVCabinetCellStatus.class );
}
}
for (int cellNo = 1; cellNo <= cellTotal; cellNo++) {
AUVCabinetCellStatus cellStatus = (AUVCabinetCellStatus) SharedPreferenceHelper.getInstance( context ).getCellStatus( String.valueOf( cellNo ), AUVCabinetCellStatus.class );
if (null != cellStatus) {
AUVLogUtil.d( TAG, "syncCellStatus::cellNo = " + cellNo + " , " + cellStatus.toString() );
if (cellStatus.isCellLockOpen()) {
AUVCabinetCellStatus status = InitHardwareService.hardwareService.getCellStatus( cellNo );
if (null != status && AliYunIotUtils.getInstance().isConnected()) {
if (!status.isCellLockOpen()) {
saveCellStatus( context, cellNo, SerialPortCommand.COMMAND_CONTROL_DOOR, false );
syncResult( Constants.CLOSE, Constants.DOOR, cellNo, !status.isCellLockOpen() );
}
}
}
}
}
}
}
}
/**
* 同步格子状态
*/
public void sendCellStatus(Context context) {
List<AUVBoardCellInit> boardCellInits = InitHardwareService.hardwareService.getBoardCellInitList();
int cellTotal = 0;
if (boardCellInits != null) {
for (AUVBoardCellInit cellInit : boardCellInits) {
cellTotal += cellInit.getCellCount();
}
AUVLogUtil.d( TAG, "sendCellStatus::cellTotal:" + cellTotal );
if (cellTotal > 0) {
for (int cellNo = 1; cellNo <= cellTotal; cellNo++) {
AUVCabinetCellStatus cellStatus = (AUVCabinetCellStatus) SharedPreferenceHelper.getInstance( context ).getCellStatus( String.valueOf( cellNo ), AUVCabinetCellStatus.class );
if (null != cellStatus) {
AUVLogUtil.d( TAG, "sendCellStatus::cellNo:" + cellNo + " , " + cellStatus.toString() );
syncResult( cellStatus.isCellLightOpen() ? Constants.OPEN : Constants.CLOSE, Constants.LIGHT, cellNo, true );
syncResult( cellStatus.isCellCleanseOpen() ? Constants.OPEN : Constants.CLOSE, Constants.DISINFECT, cellNo, true );
syncResult( cellStatus.isCellHeatingOpen() ? Constants.OPEN : Constants.CLOSE, Constants.WARM, cellNo, true );
syncResult( cellStatus.isCellLockOpen() ? Constants.OPEN : Constants.CLOSE, Constants.DOOR, cellNo, true );
}
}
}
}
}
/**
* 保存格子状态
*/
synchronized void saveCellStatus(Context context, int cellNo, SerialPortCommand serialPortCommand, boolean isOpen) {
String cellNoStr;
try {
cellNoStr = String.valueOf( cellNo );
} catch (Exception e) {
e.printStackTrace();
return;
}
AUVCabinetCellStatus cellStatus = (AUVCabinetCellStatus) SharedPreferenceHelper.getInstance( context ).getCellStatus( cellNoStr, AUVCabinetCellStatus.class );
if (cellStatus == null) {
cellStatus = new AUVCabinetCellStatus();
}
switch (serialPortCommand) {
case COMMAND_CONTROL_LIGHT:
cellStatus.setCellLightOpen( isOpen );
break;
case COMMAND_CONTROL_DISINFECT_LIGHT:
cellStatus.setCellCleanseOpen( isOpen );
break;
case COMMAND_CONTROL_HEATING:
cellStatus.setCellHeatingOpen( isOpen );
break;
case COMMAND_CONTROL_DOOR:
cellStatus.setCellLockOpen( isOpen );
break;
default:
break;
}
SharedPreferenceHelper.getInstance( context ).putObject( cellNoStr, cellStatus, AUVCabinetCellStatus.class );
}
/**
* 硬件结果监听
*/
public abstract void setOnHardwareEventListener(ResultListener resultListener);
/**
* 获取发送日志
*/
public abstract void showLog(LogListener logListener);
}
| [
"[email protected]"
] | |
c1d6baafd2d6e43bb4142f55a74334fb2807a952 | 0b74e91d078f30a24c51bcb0e6c125adafece2d4 | /app/src/main/java/mymusic/com/mymusic/HomeMusic/MusicGrideAdapter.java | 040016f5200ee67f1411ed3bd816a1a3673c9226 | [] | no_license | wuyanhong3/MyMusic | b448fa63adc95ea8a0e96cdbb5f45beb3b9b80a1 | cd854e99cca9c2492134e45e6003d5db91828900 | refs/heads/master | 2021-05-04T07:09:18.922814 | 2016-10-26T03:22:24 | 2016-10-26T03:22:24 | 70,570,966 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,200 | java | package mymusic.com.mymusic.HomeMusic;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.util.LruCache;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import mymusic.com.mymusic.R;
/**
* Created by Administrator on 2016/9/8.
*
* 动态添加内容
*
*/
public class MusicGrideAdapter extends BaseAdapter{
Uri albumArtUri = Uri
.parse("content://media/external/audio/albumart");
private LayoutInflater layoutInflater;
private ArrayList<MusicBean> musicList=new ArrayList<>();
private Context context;
public MusicGrideAdapter(Context context){
this.context=context;
this.layoutInflater=LayoutInflater.from(context);
}
public void setMusicList(ArrayList<MusicBean> musicList){
this.musicList=musicList;
notifyDataSetChanged();
}
@Override
public int getCount() {
return musicList.size();
}
@Override
public Object getItem(int position) {
return musicList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
HolderView holderView;
if(convertView==null){
convertView=layoutInflater.inflate(R.layout.home_musiclist_layout,null);
holderView=new HolderView();
holderView.musicName= (TextView) convertView.findViewById(R.id.home_music_list_title);
holderView.musicPhoto= (ImageView) convertView.findViewById(R.id.home_music_list_picture);
holderView.musicSinger= (TextView) convertView.findViewById(R.id.home_music_list_singer);
convertView.setTag(holderView);
}else{
holderView= (HolderView) convertView.getTag();
}
MusicBean musicBean= (MusicBean) getItem(position);
holderView.musicName.setText(musicBean.getTitle());
// Bitmap icon=BitmapUtil.getArtwork(context,musicBean.getId(),musicBean.getAlbumid(),false,true);
Bitmap icon=decodeSampledBitmapFromResource(musicBean.getImage(),convertView.getResources(),3,110,110);
holderView.musicPhoto.setImageBitmap(icon == null ? BitmapFactory.decodeResource(convertView.getResources(),R.mipmap.music1):icon);
holderView.musicSinger.setText(musicBean.getArtist());
return convertView;
}
/**
* 设置载入图片大小,防止图片占用内存过大;
* */
public static int calculateInSampleSize(BitmapFactory.Options options,
int reqWidth, int reqHeight) {
// 源图片的高度和宽度
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
// 计算出实际宽高和目标宽高的比率
final int heightRatio = Math.round((float) height / (float) reqHeight);
final int widthRatio = Math.round((float) width / (float) reqWidth);
// 选择宽和高中最小的比率作为inSampleSize的值,这样可以保证最终图片的宽和高
// 一定都会大于等于目标的宽和高。
inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
}
return inSampleSize;
}
public static Bitmap decodeSampledBitmapFromResource(String name, Resources res, int resId,
int reqWidth, int reqHeight) {
// 第一次解析将inJustDecodeBounds设置为true,来获取图片大小
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
BitmapFactory.decodeFile(name,options);
// 调用上面定义的方法计算inSampleSize值
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// 使用获取到的inSampleSize值再次解析图片
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
// return BitmapFactory.decodeResource(res, resId, options);
return BitmapFactory.decodeFile(name,options);
}
class HolderView{
TextView musicName,musicSinger;
ImageView musicPhoto;
}
}
| [
"[email protected]"
] | |
9fc01c5b87362098176c5efb9243fb04f44a37f1 | 6f2fe0c5e99340c48b281f247e9a84a8b654c2c2 | /src/main/java/com/bigsea/sell/dao/OrderDetailDao.java | 182dcdf0f3010ecfcb5e02864c6fcdd09c5cf7e1 | [] | no_license | bigseaa/sell_test | b3b70a69108e9f1c486ced3d67989e8756c46c78 | 1f537a3b84142ef0dbb468fc760eee69442416a2 | refs/heads/master | 2020-03-27T23:49:30.811423 | 2018-09-15T13:38:53 | 2018-09-15T13:38:53 | 147,349,919 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 299 | java | package com.bigsea.sell.dao;
import com.bigsea.sell.dataobject.OrderDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface OrderDetailDao extends JpaRepository<OrderDetail, String> {
List<OrderDetail> findByOrOrderId(String orderId);
}
| [
"[email protected]"
] | |
6e686cbd44c09769b897d58f0dd2e8c54c623507 | 5aaebaafeb75c7616689bcf71b8dd5ab2c89fa3b | /src/ANXGallery/sources/com/miui/gallery/cloudcontrol/ProfileCache.java | 1626206502c45f3c3b6edc02686bcb1abebc9f1b | [] | no_license | gitgeek4dx/ANXGallery9 | 9bf2b4da409ab16492e64340bde4836d716ea7ec | af2e3c031d1857fa25636ada923652b66a37ff9e | refs/heads/master | 2022-01-15T05:23:24.065872 | 2019-07-25T17:34:35 | 2019-07-25T17:34:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,432 | java | package com.miui.gallery.cloudcontrol;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.util.Pair;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.miui.gallery.R;
import com.miui.gallery.cloudcontrol.FeatureProfile.Deserializer;
import com.miui.gallery.cloudcontrol.FeatureProfile.Status;
import com.miui.gallery.cloudcontrol.observers.FeatureStatusObserver;
import com.miui.gallery.cloudcontrol.observers.FeatureStrategyObserver;
import com.miui.gallery.cloudcontrol.strategies.BaseStrategy;
import com.miui.gallery.provider.GalleryContract.CloudControl;
import com.miui.gallery.util.GallerySamplingStatHelper;
import com.miui.gallery.util.Log;
import com.miui.gallery.util.SafeDBUtil;
import com.miui.gallery.util.SafeDBUtil.QueryHandler;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
import io.reactivex.subjects.PublishSubject;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
class ProfileCache {
private HashMap<String, FeatureProfile> mCloudCache = new HashMap<>();
private HashMap<String, Object> mCloudStrategyCache = new HashMap<>();
private volatile boolean mIsLoadFinished;
private HashMap<String, FeatureProfile> mLocalCache = new HashMap<>();
private HashMap<String, Object> mLocalStrategyCache = new HashMap<>();
private volatile boolean mPendingNotify;
private final PublishSubject<Pair<String, Status>> mStatusSubject = PublishSubject.create();
private final PublishSubject<String> mStrategySubject = PublishSubject.create();
private final Object mSyncLock = new Object();
ProfileCache() {
}
public static /* synthetic */ Object lambda$loadFromDB$3(ProfileCache profileCache, long j, Cursor cursor) {
if (cursor == null || cursor.isClosed()) {
Log.e("CloudControl.ProfileCache", "Fill cache failed with a null cursor.");
} else {
synchronized (profileCache.mSyncLock) {
while (cursor.moveToNext()) {
FeatureDBItem fromCursor = FeatureDBItem.fromCursor(cursor);
profileCache.mCloudCache.put(fromCursor.getName(), fromCursor);
}
}
Log.d("CloudControl.ProfileCache", "Load %d items from database, cost %d ms.", Integer.valueOf(cursor.getCount()), Long.valueOf(System.currentTimeMillis() - j));
}
return null;
}
static /* synthetic */ boolean lambda$registerStatusObserver$0(String str, Pair pair) throws Exception {
return !TextUtils.isEmpty((CharSequence) pair.first) && ((String) pair.first).equals(str);
}
public static /* synthetic */ Pair lambda$registerStrategyObserver$2(ProfileCache profileCache, Class cls, Merger merger, String str) throws Exception {
return new Pair(str, profileCache.queryStrategy(str, cls, merger));
}
private void loadFromDB(Context context) {
Context context2 = context;
SafeDBUtil.safeQuery(context2, CloudControl.URI, FeatureDBItem.PROJECTION, (String) null, (String[]) null, (String) null, (QueryHandler<T>) new QueryHandler(System.currentTimeMillis()) {
private final /* synthetic */ long f$1;
{
this.f$1 = r2;
}
public final Object handle(Cursor cursor) {
return ProfileCache.lambda$loadFromDB$3(ProfileCache.this, this.f$1, cursor);
}
});
}
private void loadFromLocalFile(Reader reader) {
try {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(FeatureProfile.class, new Deserializer());
ArrayList arrayList = (ArrayList) gsonBuilder.create().fromJson(reader, new TypeToken<ArrayList<FeatureProfile>>() {
}.getType());
synchronized (this.mSyncLock) {
Iterator it = arrayList.iterator();
while (it.hasNext()) {
FeatureProfile featureProfile = (FeatureProfile) it.next();
this.mLocalCache.put(featureProfile.getName(), featureProfile);
}
}
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e2) {
try {
Log.e("CloudControl.ProfileCache", "Failed to load from local file, errorClause: %s, errorMessage: %s.", e2.getCause(), e2.getMessage());
e2.printStackTrace();
Map generatorCommonParams = GallerySamplingStatHelper.generatorCommonParams();
generatorCommonParams.put("errorMsg", e2.getMessage());
GallerySamplingStatHelper.recordErrorEvent("cloud_control", "parse_local_file_failed", generatorCommonParams);
} finally {
try {
reader.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
}
}
private void notifyStatusChanged(String str, String str2) {
this.mStatusSubject.onNext(new Pair(str, Status.fromValue(str2)));
}
private void notifyStrategyChanged(String str) {
this.mStrategySubject.onNext(str);
}
/* access modifiers changed from: 0000 */
public void clearCloudCache() {
synchronized (this.mSyncLock) {
for (Entry key : this.mCloudCache.entrySet()) {
String str = (String) key.getKey();
notifyStatusChanged(str, this.mLocalCache.get(str) != null ? ((FeatureProfile) this.mLocalCache.get(str)).getStatus() : Status.UNAVAILABLE.getValue());
}
this.mCloudCache.clear();
this.mCloudStrategyCache.clear();
}
}
/* access modifiers changed from: 0000 */
public void insertToCloudCache(FeatureProfile featureProfile) {
String name = featureProfile.getName();
String status = featureProfile.getStatus();
String strategy = featureProfile.getStrategy();
FeatureProfile featureProfile2 = (FeatureProfile) this.mCloudCache.get(name);
synchronized (this.mSyncLock) {
if (Status.REMOVE.getValue().equals(status)) {
if (featureProfile2 != null) {
this.mCloudCache.remove(name);
this.mCloudStrategyCache.remove(name);
}
notifyStatusChanged(name, status);
} else if (featureProfile2 != null) {
if (featureProfile2.getStatus() != null && featureProfile2.getStatus().equals(Status.ENABLE.getValue())) {
status = Status.ENABLE.getValue();
}
if (!TextUtils.equals(featureProfile2.getStrategy(), strategy)) {
featureProfile2.setStrategy(strategy);
this.mCloudStrategyCache.remove(name);
notifyStrategyChanged(name);
}
if (!TextUtils.equals(featureProfile2.getStatus(), status)) {
featureProfile2.setStatus(status);
notifyStatusChanged(name, status);
}
} else {
FeatureProfile featureProfile3 = new FeatureProfile();
featureProfile3.setStrategy(strategy);
featureProfile3.setStatus(status);
featureProfile3.setName(name);
this.mCloudCache.put(name, featureProfile3);
notifyStatusChanged(name, status);
notifyStrategyChanged(name);
}
}
}
/* access modifiers changed from: 0000 */
public void load(Context context) {
loadFromDB(context);
loadFromLocalFile(new InputStreamReader(context.getResources().openRawResource(R.raw.cloud_control)));
this.mIsLoadFinished = true;
}
/* access modifiers changed from: 0000 */
public void notifyAfterLoadFinished() {
synchronized (this.mSyncLock) {
if (this.mPendingNotify) {
Log.d("CloudControl.ProfileCache", "Notify all feature status after cache load finished:");
for (Entry entry : this.mCloudCache.entrySet()) {
if (!TextUtils.isEmpty((CharSequence) entry.getKey()) && entry.getValue() != null) {
Log.d("CloudControl.ProfileCache", "Feature name: %s, feature status: %s", entry.getKey(), String.valueOf(((FeatureProfile) entry.getValue()).getStatus()));
notifyStatusChanged((String) entry.getKey(), ((FeatureProfile) entry.getValue()).getStatus());
notifyStrategyChanged((String) entry.getKey());
}
}
this.mPendingNotify = false;
}
}
}
/* access modifiers changed from: 0000 */
public Status queryStatus(String str) {
if (TextUtils.isEmpty(str)) {
return Status.UNAVAILABLE;
}
synchronized (this.mSyncLock) {
if (this.mIsLoadFinished) {
String str2 = null;
if (this.mCloudCache.get(str) != null) {
str2 = ((FeatureProfile) this.mCloudCache.get(str)).getStatus();
} else if (this.mLocalCache.get(str) != null) {
str2 = ((FeatureProfile) this.mLocalCache.get(str)).getStatus();
}
if (TextUtils.isEmpty(str2)) {
Status status = Status.UNAVAILABLE;
return status;
}
try {
Status fromValue = Status.fromValue(str2);
return fromValue;
} catch (Exception unused) {
return Status.UNAVAILABLE;
}
} else {
this.mPendingNotify = true;
Status status2 = Status.UNAVAILABLE;
return status2;
}
}
}
/* access modifiers changed from: 0000 */
/* JADX WARNING: Removed duplicated region for block: B:35:0x007d */
/* JADX WARNING: Removed duplicated region for block: B:49:0x00b1 A[ADDED_TO_REGION] */
/* JADX WARNING: Removed duplicated region for block: B:55:0x00bf */
public <T extends BaseStrategy> T queryStrategy(String str, Class<T> cls, Merger<T> merger) {
BaseStrategy baseStrategy;
Object obj;
BaseStrategy baseStrategy2 = null;
if (TextUtils.isEmpty(str)) {
return null;
}
synchronized (this.mSyncLock) {
if (this.mIsLoadFinished) {
Object obj2 = this.mCloudStrategyCache.get(str);
if (obj2 != null && cls.isAssignableFrom(obj2.getClass())) {
baseStrategy = (BaseStrategy) obj2;
} else if (this.mCloudCache.get(str) != null) {
String strategy = ((FeatureProfile) this.mCloudCache.get(str)).getStrategy();
try {
baseStrategy = (BaseStrategy) new Gson().fromJson(strategy, cls);
if (baseStrategy != null) {
try {
baseStrategy.doAdditionalProcessing();
this.mCloudStrategyCache.put(str, baseStrategy);
} catch (Exception e) {
e = e;
}
}
} catch (Exception e2) {
e = e2;
baseStrategy = null;
Log.e("CloudControl.ProfileCache", "Failed to deserialize strategy: %s", (Object) strategy);
e.printStackTrace();
obj = this.mLocalStrategyCache.get(str);
if (obj == null) {
}
if (this.mLocalCache.get(str) != null) {
}
if (merger == null) {
}
if (baseStrategy != null) {
}
return baseStrategy2;
}
} else {
baseStrategy = null;
}
obj = this.mLocalStrategyCache.get(str);
if (obj == null && cls.isAssignableFrom(obj.getClass())) {
baseStrategy2 = (BaseStrategy) obj;
} else if (this.mLocalCache.get(str) != null) {
String strategy2 = ((FeatureProfile) this.mLocalCache.get(str)).getStrategy();
try {
BaseStrategy baseStrategy3 = (BaseStrategy) new Gson().fromJson(strategy2, cls);
if (baseStrategy3 != null) {
try {
baseStrategy3.doAdditionalProcessing();
this.mLocalStrategyCache.put(str, baseStrategy3);
} catch (Exception e3) {
e = e3;
baseStrategy2 = baseStrategy3;
}
}
baseStrategy2 = baseStrategy3;
} catch (Exception e4) {
e = e4;
Log.e("CloudControl.ProfileCache", "Failed to deserialize strategy: %s", (Object) strategy2);
e.printStackTrace();
if (merger == null) {
}
if (baseStrategy != null) {
}
return baseStrategy2;
}
}
if (merger == null && baseStrategy != null && baseStrategy2 != null) {
T t = (BaseStrategy) merger.merge(baseStrategy2, baseStrategy);
return t;
} else if (baseStrategy != null) {
baseStrategy2 = baseStrategy;
}
} else {
this.mPendingNotify = true;
return null;
}
}
}
/* access modifiers changed from: 0000 */
public Status registerStatusObserver(String str, FeatureStatusObserver featureStatusObserver) {
if (!TextUtils.isEmpty(str)) {
if (featureStatusObserver != null) {
this.mStatusSubject.filter(new Predicate(str) {
private final /* synthetic */ String f$0;
{
this.f$0 = r1;
}
public final boolean test(Object obj) {
return ProfileCache.lambda$registerStatusObserver$0(this.f$0, (Pair) obj);
}
}).observeOn(AndroidSchedulers.mainThread()).subscribe((Observer<? super T>) featureStatusObserver);
}
return queryStatus(str);
}
throw new IllegalArgumentException("feature should not be empty or null.");
}
/* access modifiers changed from: 0000 */
public <T extends BaseStrategy> T registerStrategyObserver(String str, Class<T> cls, Merger<T> merger, FeatureStrategyObserver<T> featureStrategyObserver) {
if (!TextUtils.isEmpty(str)) {
if (featureStrategyObserver != null) {
this.mStrategySubject.filter(new Predicate(str) {
private final /* synthetic */ String f$0;
{
this.f$0 = r1;
}
public final boolean test(Object obj) {
return ((String) obj).equals(this.f$0);
}
}).map(new Function(cls, merger) {
private final /* synthetic */ Class f$1;
private final /* synthetic */ Merger f$2;
{
this.f$1 = r2;
this.f$2 = r3;
}
public final Object apply(Object obj) {
return ProfileCache.lambda$registerStrategyObserver$2(ProfileCache.this, this.f$1, this.f$2, (String) obj);
}
}).observeOn(AndroidSchedulers.mainThread()).subscribe((Observer<? super T>) featureStrategyObserver);
}
return queryStrategy(str, cls, merger);
}
throw new IllegalArgumentException("feature should not be empty or null.");
}
/* access modifiers changed from: 0000 */
public void unregisterStatusObserver(FeatureStatusObserver featureStatusObserver) {
if (!featureStatusObserver.isDisposed()) {
featureStatusObserver.dispose();
}
}
/* access modifiers changed from: 0000 */
public void unregisterStrategyObserver(FeatureStrategyObserver featureStrategyObserver) {
if (!featureStrategyObserver.isDisposed()) {
featureStrategyObserver.dispose();
}
}
}
| [
"[email protected]"
] | |
fa1bca4e1fae8402edf4f121f60ebc2fd1373d7a | fd98b84c6b786f7781df8862630fb0e7e73fa49d | /Check you typing speed! /Main.java | 165c98b155bef3847453df1dd1fa2e1c48dd2936 | [] | no_license | mohan1072/Playground | 8c55f4636e457c1cd02c559440bae3fab4d1af1a | 80832c4697a6b71c98f8b104ae74b4443d3a769c | refs/heads/master | 2022-11-13T06:16:03.309258 | 2020-07-11T11:46:56 | 2020-07-11T11:46:56 | 273,424,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 136 | java | #include<iostream>
int main()
{
int id,marks;
std::cin>>id>>marks;
if(marks>0)
std::cout<<id<<" is eligible for reward.";
} | [
"[email protected]"
] | |
bdef65a4e161ad51f5b2a8c34d74484c8e4e8036 | 7aa6236506768613a769cdbc7c65bfdddef8f22c | /src/edu/sjsu/assignment3/Main.java | 485de28e33edaf2cbd73e65109df72a7b5a6b4af | [] | no_license | fuelunit/YL_Assignment3 | 9582955f2b340e620e718954a950148cb1da1c84 | dc7ed3765d4830d3643f0570f07cac4a2b6864af | refs/heads/master | 2023-06-24T22:00:38.622842 | 2021-07-24T17:10:06 | 2021-07-24T17:10:06 | 383,597,871 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,540 | java | /*
Author : Yipeng Liu
Project : Assignment 3
Class : Main
Date : 07/06/2021
*/
package edu.sjsu.assignment3;
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
// Part 2 Tests:
System.out.println("=== Assignment 3 Part 2 Tests ===");
// startDate and endDate
LocalDate startDate = LocalDate.parse("2021-06-01");
LocalDate endDate = LocalDate.parse("2021-08-05");
// test dates
LocalDate testDate1 = LocalDate.parse("2021-06-05");
LocalDate testDate2 = LocalDate.parse("2021-07-01");
LocalDate testDate3 = LocalDate.parse("2021-08-15");
// Example 1
System.out.println("--- Example 1 ---");
Appointment appointment1 = new OnetimeAppointment("Class starts",
startDate);
System.out.println("Test Date 1 is "
+ appointment1.occursOn(testDate1)); // false
System.out.println("Test Date 2 is "
+ appointment1.occursOn(testDate2)); // false
System.out.println("Test Date 3 is "
+ appointment1.occursOn(testDate3)); // false
// Example 2
System.out.println("--- Example 2 ---");
Appointment appointment2 = new DailyAppointment("Class",
startDate, endDate);
System.out.println("Test Date 1 is "
+ appointment2.occursOn(testDate1)); // true
System.out.println("Test Date 2 is "
+ appointment2.occursOn(testDate2)); // true
System.out.println("Test Date 3 is "
+ appointment2.occursOn(testDate3)); // false (after the end date)
// Example 3
System.out.println("--- Example 3 ---");
Appointment appointment3 = new MonthlyAppointment("Meeting",
startDate, endDate);
System.out.println("Test Date 1 is "
+ appointment3.occursOn(testDate1)); // false (day of month not same)
System.out.println("Test Date 2 is "
+ appointment3.occursOn(testDate2)); // true
System.out.println("Test Date 3 is "
+ appointment3.occursOn(testDate3)); // false (after the end date)s
// Part 3 Tests:
System.out.println("=== Assignment 3 Part 3 Tests ===");
System.out.println("appointment1 compared to appointment 2: "
+ appointment1.compareTo(appointment2));
// Part 4 Tests:
System.out.println("=== Assignment 3 Part 4 Tests ===");
}
}
| [
"[email protected]"
] | |
d23fcdb149e9797eb886b96f74c719ee55e50ef7 | 0af85dca9fba982cce0152fdc2f7609448012776 | /app/src/main/java/com/example/dongle/location/Database/Model/Place.java | 0332202009c865bf8620714dfbe8baa25aeb7646 | [] | no_license | lehuynhdong/newbranch | 3f3522f7fa567b129bcc684787a8ba25e2322f8d | ebb1d8a80086c2a24beb3baa19e10445c33dca40 | refs/heads/master | 2021-08-23T03:00:08.489511 | 2017-12-02T19:30:43 | 2017-12-02T19:30:43 | 112,811,048 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,936 | java | package com.example.dongle.location.Database.Model;
import android.text.TextUtils;
/**
* Created by DongLe on 01-Dec-17.
*/
public class Place {
private String placeID;
private String categoryID;
private byte[] placeimg;
private String placeName;
private String placeAddress;
private String placePrice;
private String placeTime;
private String placeDescription;
private double placeLat;
private double placeLng;
public Place(Builder builder){
this.placeID= builder.placeID;
this.categoryID= builder.categoryID;
this.placeimg= builder.placeimg;
this.placeName= builder.placeName;
this.placeAddress= builder.placeAddress;
this.placePrice= builder.placePrice;
this.placeTime= builder.placeTime;
this.placeDescription= builder.placeDescription;
this.placeLat= builder.placeLat;
this.placeLng=builder.placeLng;
}
public String getCategoryID() {
return categoryID;
}
public double getPlaceLng() {
return placeLng;
}
public String getPlaceID() {
return placeID;
}
public byte[] getPlaceimg() {
return placeimg;
}
public String getPlaceName() {
return placeName;
}
public String getPlaceAddress() {
return placeAddress;
}
public String getPlacePrice() {
return placePrice;
}
public String getPlaceDescription() {
return placeDescription;
}
public double getPlaceLat() {
return placeLat;
}
public String getplaceTime() {
return placeTime;
}
public static class Builder{
private String placeID;
private String categoryID;
private byte[] placeimg;
private String placeName;
private String placeAddress;
private String placePrice;
private String placeTime;
private String placeDescription;
private double placeLat;
private double placeLng;
public Builder setPlaceID(String placeID) {
this.placeID = placeID;
return this;
}
public Builder setPlaceimg(byte[] placeimg) {
this.placeimg = placeimg;
return this;
}
public Builder setPlaceName(String placeName) {
this.placeName = placeName;
return this;
}
public Builder setPlaceAddress(String placeAddress) {
this.placeAddress = placeAddress;
return this;
}
public Builder setPlaceDescription(String placeDescription) {
this.placeDescription = placeDescription;
return this;
}
public Builder setPlaceLat(double placeLat) {
this.placeLat = placeLat;
return this;
}
public Builder setPlaceLng(double placeLng) {
this.placeLng = placeLng;
return this;
}
public Builder setCategoryID(String categoryID) {
this.categoryID = categoryID;
return this;
}
public Builder setPlacePrice(String placePrice) {
this.placePrice = placePrice;
return this;
}
public Builder setPlaceTime(String placeTime) {
this.placeTime = placeTime;
return this;
}
public Place build(){
return new Place(this);
}
}
public static boolean validateInput(String placeName, String placeTime, String placeAddress, String placePrice, String placeDescription, String CategoryID){
return (TextUtils.isEmpty(placeName)
|| TextUtils.isEmpty(placeTime)
|| TextUtils.isEmpty(placeAddress)
|| TextUtils.isEmpty(placePrice)
|| TextUtils.isEmpty(placeDescription)
|| TextUtils.isEmpty(CategoryID)) ? false : true ;
}
}
| [
"[email protected]"
] | |
7eeb0a97e499e9f2cb3d9d59c9f8644417d4222b | 12c766729bb082bf593578fa982981ef65c3fc9b | /SmartCity/src/sjtu/dclab/smartcity/ui/minzheng/CivilAffairHomeAty.java | 7f415bb8bb85d39fe1844d5dccd908a7c3045e7c | [] | no_license | m122469119/smartcity-android | 876ef5b64762ffe4562856d879d2426b88d1af17 | a89d55f28bb18370ba54b96fc268adc5f0c34456 | refs/heads/main | 2021-06-08T22:00:25.097541 | 2015-09-28T03:06:17 | 2015-09-28T03:06:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,613 | java | package sjtu.dclab.smartcity.ui.minzheng;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import sjtu.dclab.smartcity.R;
/**
* Created by hp on 2015/7/30.
*/
public class CivilAffairHomeAty extends Activity implements View.OnClickListener {
private ListView listView;
private ImageButton ib1,ib2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.civil_affair_home);
ib1 = (ImageButton)findViewById(R.id.civil_left);
ib1.setOnClickListener(this);
ib2 = (ImageButton)findViewById(R.id.civil_right);
this.ib2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(CivilAffairHomeAty.this, CivilAffairEditAty.class);
startActivity(intent);
}
});
listView = (ListView)findViewById(R.id.civil_affair_list);
SimpleAdapter adapter = new SimpleAdapter(this,getData(), R.layout.image_listitem,
new String[]{"title","info","img"},
new int[]{R.id.title, R.id.info, R.id.img});
listView.setAdapter(adapter);
}
private List<Map<String, Object>> getData(){
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", "高龄服务");
map.put("info", "example info...");
map.put("img", R.drawable.tmp_img);
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "助残服务");
map.put("info", "example info...");
map.put("img", R.drawable.tmp_img);
list.add(map);
return list;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.civil_left:
CivilMenuWindow menuPopupWindow = new CivilMenuWindow(CivilAffairHomeAty.this);
menuPopupWindow.showPopupWindow(ib1);
break;
default:
break;
}
}
}
| [
"[email protected]"
] | |
c503c4ab509d89f1dad1f1fd1b8c190b58643345 | 370636660b7707da92f58953c3fc41fac55e763d | /JavaStringFunctions/src/com/vaibhav/StringIntern.java | d31c22d5ece2f3507dac0fef4e6b4d54cc4f1399 | [] | no_license | rautvaibhav56/JavaStringFunctions | 90f2aa7de170b4a9f3165ea57908a021dc0536cf | 215e7cddbc1fdbb5a0ff3072a3356f646c1db2a8 | refs/heads/master | 2023-01-06T10:20:37.036972 | 2020-10-26T14:41:14 | 2020-10-26T14:41:14 | 305,065,923 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 646 | java | package com.vaibhav;
//StringIntern=>It can be used to return string from memory,
//if it is created by new keyword. It creates exact copy of heap string object in string constant pool
public class StringIntern {
static String s1 = "hello";
static String s2 = new String("hello");
public static void m() {
System.out.println(s1.equals(s2));// true =>why true???
System.out.println(s1 == s2);// false
String s3 = s2.intern();// It returns string from memory, if it is created by new keyword.
System.out.println(s1 == s3);// true
}
public static void main(String[] args) {
StringIntern.m();
}
}
| [
"krishna@timus"
] | krishna@timus |
26f635c863463ca9ab35e4f2b58bfbb63f8f8094 | 5d5b081ac5165a85698241accd60c3220204c1e3 | /src/main/java/io/tolgadurak/logx/core/worker/Worker.java | 6d480ed1fa549102cae20dc981c29d26505cdcc3 | [] | no_license | tolgadurak/logx-core | 44a06fd7b8dc962d77a2281c96efb481da013735 | 3a138b1b6ad1166bd1bfee485cc7d71fb2783d43 | refs/heads/master | 2021-07-04T02:39:29.370836 | 2017-09-25T21:44:03 | 2017-09-25T21:44:03 | 104,804,494 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package io.tolgadurak.logx.core.worker;
import java.util.concurrent.Callable;
public interface Worker extends Callable<Object> {
}
| [
"[email protected]"
] | |
34eee1826851b5a2cd7d776016ceee7568cf57ee | d73e0a733b9c3e3db13754ebcda9785f6b2beaba | /Symphonie/src15/fr/umlv/symphonie/GUI/menu/view/ItemView.java | d42a82fd842f51686cb1ac44a495ebcee7b30e18 | [] | no_license | BackupTheBerlios/notemanager | 1bc815fe6202719497cd136d6224c2b36804d0e3 | fd5d8f53408e1b4ae9505c0de9df324a4b2a8843 | refs/heads/master | 2020-12-24T15:22:58.994789 | 2005-03-26T12:55:01 | 2005-03-26T12:55:01 | 40,047,450 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 726 | java | /*
* Created on 19 mars 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package fr.umlv.symphonie.GUI.menu.view;
import fr.umlv.symphonie.GUI.GUICache;
import fr.umlv.symphonie.GUI.menu.AbstractGUIMenuItem;
/**
* @author everybody
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ItemView extends AbstractGUIMenuItem {
public ItemView(GUICache cache) {
super(cache,"view");
}
/* (non-Javadoc)
* @see fr.umlv.symphonie.GUI.menu.MenuItem#setAction()
*/
public void setAction() {
// TODO Auto-generated method stub
}
}
| [
"dalton"
] | dalton |
bc1245770467b73c29709477c7cf58f80fbfe264 | 47984d3b623e74e8029f3b8b7422893f1bfdfefa | /src/npc/Sugar.java | cc49d7f0744203b833e1c78809c0e8c4dfbdd017 | [] | no_license | SetosanMs/MapleStory2 | 71467682165a85f6b31ee16aecce009847ee27d9 | 311bd8fa3f832f2a34dee41d43e7daf9766044a3 | refs/heads/master | 2022-12-10T00:44:55.389534 | 2020-08-26T15:22:17 | 2020-08-26T15:22:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 656 | java | package npc;
import java.io.Serializable;
import map.MapleMap;
import map.PointMapName;
import map.UpdatedMapInfor;
import maplestory.Player;
public class Sugar extends Npc implements Serializable {
private static final long serialVersionUID = 1L;
public Sugar(String image, String name, PointMapName pointMapName) {
super(image, name, pointMapName);
}
public void clearEvent(Player player) {
}
public void requestQuest(Player player) {
}
@Override
public void normalEvent(Player player) {
if(process == 25) {
player.addUpdatedMap(new UpdatedMapInfor(new PointMapName(4, 9, "초보자의숲1"), MapleMap.MAP_PORTAL_STATE));
}
}
}
| [
"[email protected]"
] | |
01cc38b517d8b4a36dfa917275b7e0ec06b9a568 | 076c9b66d0c9803eb425f0eb4daf6731a8d6fae2 | /Java-Concurrency-Examples/src/main/java/com/bgaborg/synchronization/IntristicLocks.java | 9397e2cdfce4d1eb275c3ce2fccb3e70d848dac7 | [] | no_license | santos-samuel/AllGit | ac75b072ec052ffa2addfb1e14b19f648cfd41ca | 69d79f534091aa42eab2928041538cef22f15448 | refs/heads/master | 2022-08-16T15:09:15.746668 | 2017-06-23T06:37:56 | 2017-06-23T06:37:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,848 | java | package com.bgaborg.synchronization;
import java.util.ArrayList;
/**
* Intrinsic Locks and Synchronization
*
* Created by bg
*/
public class IntristicLocks {
String lastName = "";
int nameCount = 0;
ArrayList<String> nameList = new ArrayList<>();
/**
* Another way to create synchronized code is with synchronized statements. Unlike synchronized methods,
* synchronized statements must specify the object that provides the intrinsic lock:
*
* In this example, the addName method needs to synchronize changes to lastName and nameCount, but
* also needs to avoid synchronizing invocations of other objects' methods. (Invoking other objects'
* methods from synchronized code can create problems that are described in the section on Liveness.)
* Without synchronized statements, there would have to be a separate, unsynchronized method for the
* sole purpose of invoking nameList.add.
*
* @param name
*/
public void addName(String name) {
synchronized(this) {
lastName = name;
nameCount++;
}
nameList.add(name);
}
/**
* Synchronized statements are also useful for improving concurrency with fine-grained synchronization.
* Suppose, for example, class MsLunch has two instance fields, c1 and c2, that are never used together.
* All updates of these fields must be synchronized, but there's no reason to prevent an update of c1 from
* being interleaved with an update of c2 — and doing so reduces concurrency by creating unnecessary blocking.
* Instead of using synchronized methods or otherwise using the lock associated with this, we create
* two objects solely to provide locks.
*
* Use this idiom with extreme care. You must be absolutely sure that it really is safe to interleave access of the affected fields.
*/
private long c1 = 0;
private long c2 = 0;
private Object lock1 = new Object();
private Object lock2 = new Object();
public void inc1() {
synchronized(lock1) {
c1++;
}
}
public void inc2() {
synchronized(lock2) {
c2++;
}
}
/**
* Reentrant Synchronization
*
* Recall that a thread cannot acquire a lock owned by another thread. But a thread can acquire a lock
* that it already owns. Allowing a thread to acquire the same lock more than once enables
* reentrant synchronization. This describes a situation where synchronized code, directly or indirectly,
* invokes a method that also contains synchronized code, and both sets of code use the same lock.
* Without reentrant synchronization, synchronized code would have to take many additional precautions to
* avoid having a thread cause itself to block.
*/
}
| [
"[email protected]"
] | |
2d461c41a568b67241a4b0e9a03f7e272ac49f26 | 24d8cf871b092b2d60fc85d5320e1bc761a7cbe2 | /SQuirrel_SQL/rev4007-4212/base-branch-4007/test/src/net/sourceforge/squirrel_sql/fw/codereformat/AllTests.java | 99d682f2ae20544a81f461f06c1489591be78330 | [] | no_license | joliebig/featurehouse_fstmerge_examples | af1b963537839d13e834f829cf51f8ad5e6ffe76 | 1a99c1788f0eb9f1e5d8c2ced3892d00cd9449ad | refs/heads/master | 2016-09-05T10:24:50.974902 | 2013-03-28T16:28:47 | 2013-03-28T16:28:47 | 9,080,611 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 359 | java | package net.sourceforge.squirrel_sql.fw.codereformat;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite("SQL codereformat tests");
suite.addTestSuite(CodeReformatorTest.class);
return suite;
}
}
| [
"[email protected]"
] | |
8fc7bff3d960c9a4730fec484ad523ffab0495cb | 5b250ce87b680eff1d271dba7a4c131ffb1cc801 | /features/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/Checker.java | 1091c41eba5d4c7981a19c9cf6065c616d7d4b24 | [
"Apache-2.0"
] | permissive | onap-oof-pci-poc/ccsdk | 10ebb289f6756c3d4ec92113ccc42420c1318728 | e2f40351b0993bdb86a4cdf8f16177a8298b94e9 | refs/heads/master | 2020-03-29T17:28:01.410278 | 2019-05-16T16:15:13 | 2019-05-16T16:15:13 | 150,164,301 | 2 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,959 | java | /*******************************************************************************
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
* =================================================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
/**
* (c) highstreet technologies GmbH
*/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Steps to Monitor the connection to a network element during state connected
*/
abstract class Checker {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(Checker.class);
/**
* Check action.
* @return true if reachable, false if not
*/
abstract boolean isReachableOnce();
/**
* Procedure to check the connection of one mountpoint
* @return true if reachable, false if not
*/
boolean isConnected() {
return isReachableOnce();
}
}
| [
"[email protected]"
] | |
4520585cfed86ccde6651b5b5d71d359139b3c1e | cde7d4583d54c66ab20a45ee3d034602cda72c4a | /Gossip/JUnit/TestTemplate/src/cc/openhome/CalculatorPlusMinusTest.java | 640882492cea39c28ce5fcfcfb6c75e3b881d937 | [] | no_license | cherylautumn/cc | 21d53e97b25dc05a3c45ff8067c6fd88e48ca0e5 | c561f78c1dc3148c99e1c77613bdaaaa94fa0cf8 | refs/heads/master | 2021-01-22T00:03:52.845645 | 2013-08-15T06:21:16 | 2013-08-15T06:21:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,008 | java | package cc.openhome;
import cc.openhome.Calculator;
public class CalculatorPlusMinusTest extends TestCase {
public CalculatorPlusMinusTest(String name) {
super(name);
}
public void testPlus() {
Calculator calculator = new Calculator();
int expected = 5;
int result = calculator.plus(3, 2);
assertEquals(expected, result);
}
public void testMinus() {
Calculator calculator = new Calculator();
int expected = 1;
int result = calculator.minus(3, 2);
assertEquals(expected, result);
}
public static Test suite() {
TestSuite<Test> suite = new TestSuite<Test>();
suite.add(new CalculatorPlusMinusTest("testPlus"));
suite.add(new CalculatorPlusMinusTest("testMinus"));
return suite;
}
// http://openhome.cc/Gossip/JUnit/TestTemplate.html
public static void main(String[] args) {
TestRunner.run(suite());
}
}
| [
"[email protected]"
] | |
9fb98ee9d48e9010f99326c1cd661dec4f1e7d23 | c60f237cf92ac593072a5233db84c267727c3cc2 | /com/planet_ink/coffee_mud/Abilities/Common/ScrollScribing.java | bf54cde62e1e55a14d1e6adcd1db74bb8329737d | [
"Apache-2.0"
] | permissive | stefanludlow/CoffeeMud | f810feb10cd2187372c9795754f16029f89a978e | b124a84777a1093aac4d1364766e3a1ead0638b3 | refs/heads/master | 2021-01-18T18:59:14.235608 | 2017-03-31T23:10:59 | 2017-03-31T23:10:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,349 | java | package com.planet_ink.coffee_mud.Abilities.Common;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.Common.CraftingSkill.CraftParms;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.ItemCraftor.ItemKeyPair;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;
import java.util.*;
/*
Copyright 2008-2017 Bo Zimmerman
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.
*/
public class ScrollScribing extends SpellCraftingSkill implements ItemCraftor
{
@Override
public String ID()
{
return "ScrollScribing";
}
private final static String localizedName = CMLib.lang().L("Scroll Scribing");
@Override
public String name()
{
return localizedName;
}
private static final String[] triggerStrings = I(new String[] { "ENSCRIBE", "SCROLLSCRIBE", "SCROLLSCRIBING" });
@Override
public String[] triggerStrings()
{
return triggerStrings;
}
@Override
protected ExpertiseLibrary.SkillCostDefinition getRawTrainingCost()
{
return CMProps.getNormalSkillGainCost(ID());
}
@Override
public String supportedResourceString()
{
return "MISC";
}
@Override
public String parametersFormat()
{
return "SPELL_ID\tRESOURCE_NAME";
}
protected Ability theSpell = null;
protected Scroll fromTheScroll = null;
@Override
public boolean tick(Tickable ticking, int tickID)
{
if((affected!=null)&&(affected instanceof MOB)&&(tickID==Tickable.TICKID_MOB))
{
if((buildingI==null)
||(theSpell==null))
{
aborted=true;
unInvoke();
}
}
return super.tick(ticking,tickID);
}
@Override
public String parametersFile()
{
return "scribing.txt";
}
@Override
protected List<List<String>> loadRecipes()
{
return super.loadRecipes(parametersFile());
}
@Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if((buildingI!=null)&&(!aborted))
{
if(messedUp)
{
commonTell(mob,L("Something went wrong! @x1 explodes!",buildingI.name()));
buildingI.destroy();
}
else
{
int theSpellLevel=spellLevel(mob,theSpell);
if(fromTheScroll != null)
eraseFromScrollItem(fromTheScroll,theSpell,theSpellLevel);
buildingI=buildScrollItem((Scroll)buildingI, theSpell, theSpellLevel);
if(buildingI.secretIdentity().length()==0)
buildingI.setSecretIdentity(getBrand(mob));
}
}
buildingI=null;
}
}
super.unInvoke();
}
protected int spellLevel(MOB mob, Ability A)
{
int lvl=CMLib.ableMapper().qualifyingLevel(mob,A);
if(lvl<0)
lvl=CMLib.ableMapper().lowestQualifyingLevel(A.ID());
switch(lvl)
{
case 0:
return lvl;
case 1:
return lvl;
case 2:
return lvl + 1;
case 3:
return lvl + 1;
case 4:
return lvl + 2;
case 5:
return lvl + 2;
case 6:
return lvl + 3;
case 7:
return lvl + 3;
case 8:
return lvl + 4;
case 9:
return lvl + 4;
default:
return lvl + 5;
}
}
@Override
public boolean supportsDeconstruction()
{
return false;
}
@Override
public ItemKeyPair craftItem(String recipe)
{
return craftItem(recipe, 0, false);
}
protected void eraseFromScrollItem(Scroll buildingI, Ability theSpell, int level)
{
if(buildingI == null)
return;
StringBuilder newList=new StringBuilder();
for(Ability A : buildingI.getSpells())
{
if(!A.ID().equalsIgnoreCase(theSpell.ID()))
newList.append(A.ID()).append(";");
if(buildingI.isGeneric())
{
final String testName=L(" OF @x1",A.Name().toUpperCase());
if(buildingI.Name().toUpperCase().endsWith(testName))
buildingI.setName(buildingI.Name().substring(0,buildingI.Name().length()-testName.length()));
}
}
buildingI.setSpellList(newList.toString());
if(buildingI.isGeneric())
{
if(buildingI.getSpells().size()==1)
{
if(buildingI.name().toUpperCase().endsWith(L(" SCROLL")))
buildingI.setName(L("@x1 of @x2",buildingI.name(),buildingI.getSpells().get(0).name().toLowerCase()));
buildingI.setDisplayText(L("@x1 sits here.",buildingI.Name()));
}
}
if(buildingI.usesRemaining()>0)
buildingI.setUsesRemaining(buildingI.usesRemaining()-1);
buildingI.text();
}
protected Scroll buildScrollItem(Scroll buildingI, Ability theSpell, int level)
{
if(buildingI == null)
buildingI=(Scroll)CMClass.getItem("GenScroll");
StringBuilder newList=new StringBuilder();
for(Ability A : buildingI.getSpells())
{
newList.append(A.ID()).append(";");
final String testName=L(" OF @x1",A.Name().toUpperCase());
if(buildingI.Name().toUpperCase().endsWith(testName))
buildingI.setName(buildingI.Name().substring(0,buildingI.Name().length()-testName.length()));
}
newList.append(theSpell.ID());
buildingI.setSpellList(newList.toString());
if(buildingI.getSpells().size()==1)
{
if(buildingI.name().toUpperCase().endsWith(L(" SCROLL")))
buildingI.setName(L("@x1 of @x2",buildingI.name(),theSpell.name().toLowerCase()));
buildingI.setDisplayText(L("@x1 sits here.",buildingI.Name()));
buildingI.basePhyStats().setLevel(level);
buildingI.phyStats().setLevel(level);
buildingI.recoverPhyStats();
}
else
if(buildingI.basePhyStats().level() < level)
{
buildingI.basePhyStats().setLevel(level);
buildingI.phyStats().setLevel(level);
buildingI.recoverPhyStats();
}
buildingI.setDescription("");
buildingI.setUsesRemaining(buildingI.usesRemaining()+1);
buildingI.text();
return buildingI;
}
@Override
public String getDecodedComponentsDescription(final MOB mob, final List<String> recipe)
{
return "Not implemented";
}
@Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
return autoGenInvoke(mob,commands,givenTarget,auto,asLevel,0,false,new Vector<Item>(0));
}
@Override
protected boolean autoGenInvoke(final MOB mob, List<String> commands, Physical givenTarget, final boolean auto,
final int asLevel, int autoGenerate, boolean forceLevels, List<Item> crafted)
{
if(super.checkStop(mob, commands))
return true;
if(autoGenerate>0)
{
final Ability theSpell=super.getCraftableSpellRecipeSpell(commands);
if(theSpell==null)
return false;
final int level=spellLevel(mob,theSpell);
buildingI=buildScrollItem(null, theSpell, level);
crafted.add(buildingI);
return true;
}
randomRecipeFix(mob,addRecipes(mob,loadRecipes()),commands,0);
if(commands.size()<1)
{
commonTell(mob,L("Enscribe what? Enter \"enscribe list\" for a list, or \"enscribe stop\" to cancel."));
return false;
}
final List<List<String>> recipes=addRecipes(mob,loadRecipes());
final String pos=commands.get(commands.size()-1);
if(((commands.get(0))).equalsIgnoreCase("list"))
{
String mask=CMParms.combine(commands,1);
boolean allFlag=false;
if(mask.equalsIgnoreCase("all"))
{
allFlag=true;
mask="";
}
final StringBuffer buf=new StringBuffer(L("Scrolls you know how to enscribe:\n\r"));
final int colWidth=CMLib.lister().fixColWidth(25,mob.session());
buf.append(CMStrings.padRight(L("Spell"),colWidth)+" "+CMStrings.padRight(L("Spell"),colWidth)+" "+CMStrings.padRight(L("Spell"),colWidth));
int toggler=1;
final int toggleTop=3;
for(int r=0;r<recipes.size();r++)
{
final List<String> V=recipes.get(r);
if(V.size()>0)
{
final String spell=V.get(0);
final Ability A=mob.fetchAbility(spell);
if((A!=null)
&&((spellLevel(mob,A)>=0)||(allFlag))
&&((xlevel(mob)>=spellLevel(mob,A))||(allFlag))
&&((mask.length()==0)||mask.equalsIgnoreCase("all")||CMLib.english().containsString(spell,mask)))
{
buf.append(CMStrings.padRight(A.name(),colWidth)+((toggler!=toggleTop)?" ":"\n\r"));
if(++toggler>toggleTop)
toggler=1;
}
}
}
if(toggler!=1)
buf.append("\n\r");
commonTell(mob,buf.toString());
return true;
}
else
if((!auto)&&(commands.size()<2))
{
commonEmote(mob,L("You must specify what magic you wish to enscribe, and the paper to enscribe it in. You can specify the word \"from\" and another scroll name to move a spell from one scroll to another."));
return false;
}
else
{
buildingI=getTarget(mob,null,givenTarget,CMParms.parse(pos),Wearable.FILTER_UNWORNONLY);
commands.remove(pos);
if(buildingI==null)
return false;
if(!mob.isMine(buildingI))
{
commonTell(mob,L("You'll need to pick that up first."));
return false;
}
if((((buildingI.material()&RawMaterial.MATERIAL_MASK)!=RawMaterial.MATERIAL_PAPER))
&&(buildingI.material() != RawMaterial.RESOURCE_SILK))
{
commonTell(mob,L("@x1 isn't even made of paper or silk!",buildingI.name(mob)));
return false;
}
if((!(buildingI instanceof Scroll))||(!buildingI.isGeneric()))
{
commonTell(mob,L("There's can't enscribe magic on @x1!",buildingI.name(mob)));
return false;
}
if(((Scroll)buildingI).getSpells().size()>0)
{
int level=25;
for(final Ability A : ((Scroll)buildingI).getSpells())
{
int lvl=CMLib.ableMapper().qualifyingLevel(mob,A);
if(lvl<0)
lvl=CMLib.ableMapper().lowestQualifyingLevel(A.ID());
level -= lvl;
}
if(level <= 0)
{
commonTell(mob,L("You can only scribe on blank scrolls, or scroll with enough free space on it."));
return false;
}
}
String recipeName=CMParms.combine(commands,0);
theSpell=null;
fromTheScroll=null;
String ingredient="";
for(int r=0;r<recipes.size();r++)
{
final List<String> V=recipes.get(r);
if(V.size()>0)
{
final String spell=V.get(0);
final Ability A=mob.fetchAbility(spell);
if((A!=null)
&&(xlevel(mob)>=spellLevel(mob,A))
&&(A.name().equalsIgnoreCase(recipeName)))
{
theSpell=A;
ingredient=V.get(1);
}
}
}
int manaToLose=10;
int experienceToLose=0;
if(theSpell==null)
{
int x=CMParms.indexOfIgnoreCase(commands, "from");
if((x>0)&&(x<commands.size()-1))
{
recipeName=CMParms.combine(commands,0,x);
String otherScrollName=CMParms.combine(commands,x+1,commands.size());
Item scrollFromI=getTarget(mob,null,givenTarget,CMParms.parse(otherScrollName),Wearable.FILTER_UNWORNONLY);
if(scrollFromI==null)
return false;
if(!mob.isMine(scrollFromI))
{
commonTell(mob,L("You'll need to pick that up first."));
return false;
}
if(!(scrollFromI instanceof Scroll))
{
commonTell(mob,L("@x1 is not a scroll!",scrollFromI.name(mob)));
return false;
}
if((!(scrollFromI instanceof Scroll))||(((Scroll)scrollFromI).getSpells().size()==0))
{
commonTell(mob,L("@x1 has no spells on it!",scrollFromI.name(mob)));
return false;
}
if(scrollFromI.usesRemaining() <=0)
{
commonTell(mob,L("@x1 has no magical charge left in it.",scrollFromI.name(mob)));
return false;
}
ingredient="";
for(Ability A : ((Scroll)scrollFromI).getSpells())
{
if((A!=null)
&&(xlevel(mob)>=spellLevel(mob,A))
&&(A.name().equalsIgnoreCase(recipeName)))
theSpell=A;
}
if(theSpell==null)
{
commonTell(mob,L("You can't enscribe the spell '@x1' from the scroll @x2!",recipeName,scrollFromI.name(mob)));
return false;
}
fromTheScroll=(Scroll)scrollFromI;
}
else
if(theSpell==null)
{
commonTell(mob,L("You don't know how to enscribe '@x1'. Try \"enscribe list\" for a list.",recipeName));
return false;
}
manaToLose+=spellLevel(mob,theSpell)*10;
}
else
{
manaToLose+=CMLib.ableMapper().qualifyingLevel(mob,theSpell)*10;
manaToLose-=CMLib.ableMapper().qualifyingClassLevel(mob,theSpell)*5;
experienceToLose+=10+CMLib.ableMapper().qualifyingLevel(mob,theSpell);
experienceToLose-=CMLib.ableMapper().qualifyingClassLevel(mob,theSpell);
if(experienceToLose < CMLib.ableMapper().qualifyingLevel(mob,theSpell))
experienceToLose = CMLib.ableMapper().qualifyingLevel(mob,theSpell);
}
if(buildingI!=null)
{
for(final Ability spell: ((Scroll)buildingI).getSpells())
{
if(spell.ID().equals(theSpell.ID()))
{
mob.tell(L("That spell is already scribed onto @x1.",buildingI.name()));
return false;
}
}
}
final int resourceType=(ingredient.length()==0) ? -1 : RawMaterial.CODES.FIND_IgnoreCase(ingredient);
int[][] data = null;
if(resourceType>0)
{
final int[] pm={resourceType};
data=fetchFoundResourceData(mob,
1,ingredient,pm,
0,null,null,
bundling,
-1,
null);
if(data==null)
return false;
}
if(manaToLose<10)
manaToLose=10;
if(mob.curState().getMana()<manaToLose)
{
commonTell(mob,L("You need at least @x1 mana to accomplish that.",""+manaToLose));
}
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
mob.curState().adjMana(-manaToLose, mob.maxState());
if((resourceType>0)&&(data != null))
CMLib.materials().destroyResourcesValue(mob.location(),data[0][FOUND_AMT],data[0][FOUND_CODE],0,null);
playSound=null;
if(experienceToLose > 0)
{
experienceToLose=getXPCOSTAdjustment(mob,experienceToLose);
CMLib.leveler().postExperience(mob,null,null,-experienceToLose,false);
commonTell(mob,L("You lose @x1 experience points for the effort.",""+experienceToLose));
}
int duration=CMLib.ableMapper().qualifyingLevel(mob,theSpell)*5;
if(duration<10)
duration=10;
messedUp=!proficiencyCheck(mob,0,auto);
String msgStr;
if(fromTheScroll != null)
{
msgStr=L("<S-NAME> start(s) transscribing @x1 from @x2 to @x3.",theSpell.name(),fromTheScroll.name(),buildingI.name());
displayText=L("You are transscribing @x1 from @x2 to @x3",theSpell.name(),fromTheScroll.name(),buildingI.name());
verb=L("transscribing @x1 from @x2 to @x3",theSpell.name(),fromTheScroll.name(),buildingI.name());
}
else
{
msgStr=L("<S-NAME> start(s) scribing @x1 onto @x2.",theSpell.name(),buildingI.name());
displayText=L("You are scribing @x1 onto @x2",theSpell.name(),buildingI.name());
verb=L("scribing @x1 onto @x2",theSpell.name(),buildingI.name());
}
final CMMsg msg=CMClass.getMsg(mob,buildingI,this,getActivityMessageType(),msgStr);
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
buildingI=(Item)msg.target();
beneficialAffect(mob,mob,asLevel,duration);
}
}
return true;
}
}
| [
"[email protected]"
] | |
7cb59af0467d18464ec35e7d1994bdb53c8c1c7b | de4f98bb7f2ce0c084b6ad52b6db4e2f277989bc | /app/src/main/java/com/dummyapp/swipeableview/ImageTypeBig.java | 6253c01d2067e0448dc8c7904d4fb6c7b4ddc95d | [] | no_license | ashutosh1234ojha/dumbapp | 112d7a7090877ac92d8c68282158609d4f7a71b4 | 3e90365497c68cdb5e588301ed2faf59b9699e03 | refs/heads/master | 2020-03-11T19:07:07.135908 | 2019-03-05T11:01:42 | 2019-03-05T11:01:42 | 130,197,711 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,193 | java | package com.dummyapp.swipeableview;
import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.dummyapp.R;
import com.mindorks.placeholderview.PlaceHolderView;
import com.mindorks.placeholderview.annotations.Layout;
import com.mindorks.placeholderview.annotations.LongClick;
import com.mindorks.placeholderview.annotations.NonReusable;
import com.mindorks.placeholderview.annotations.Resolve;
import com.mindorks.placeholderview.annotations.View;
/**
* Created by cl-macmini-86 on 7/12/17.
*/
@NonReusable
@Layout(R.layout.gallery_item_big)
public class ImageTypeBig {
@View(R.id.imageView)
private ImageView imageView;
private int mUrl;
private Context mContext;
private PlaceHolderView mPlaceHolderView;
public ImageTypeBig(Context context, PlaceHolderView placeHolderView, int url) {
mContext = context;
mPlaceHolderView = placeHolderView;
mUrl = url;
}
@Resolve
private void onResolved() {
Glide.with(mContext).load(mUrl).into(imageView);
}
@LongClick(R.id.imageView)
private void onLongClick(){
mPlaceHolderView.removeView(this);
}
} | [
"[email protected]"
] | |
b7de75e4bb8c783260ef539e3a7b8b0b31b7e96b | a5de8b4b139977cf70343704fae3db301f423e2d | /Studmark.java | 0a6f6c9931468416f04b922afa2c7c7d35209c29 | [
"Apache-2.0"
] | permissive | sandhya1425/JavaAssignmentSubmission | 5188bf66d2503360f6e411cb91a608f5a099475d | 4e522d77fc0c48b9693588ae0782386722da3d57 | refs/heads/main | 2022-12-28T10:22:41.225280 | 2020-10-15T08:02:27 | 2020-10-15T08:02:27 | 303,643,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,088 | java | package pk;
import java.util.*;
class StudDemo
{
int sub1,sub2,sub3,sub4,sub5;
float per,total;
Scanner sc=new Scanner(System.in);
public void calculate_Stud_Grade()
{
System.out.println("Enter the Sub1,Sub2,Sub3,sub4,Sub5 marks:");
sub1=sc.nextInt();
sub2=sc.nextInt();
sub3=sc.nextInt();
sub4=sc.nextInt();
sub5=sc.nextInt();
total=sub1+sub2+sub3+sub4+sub5;
System.out.println("Total Subject marks:" +total);
per=(total/500)*100;
System.out.println("percentage of student:" +per);
if(per>= 90)
{
System.out.println("\n Grade A");
}
else if(per>= 80)
{
System.out.println("\n Grade B");
}
else if(per>= 70)
{
System.out.println("\n Grade C");
}
else if(per>= 60)
{
System.out.println("\n Grade D");
}
else if(per>= 40)
{
System.out.println("\n Grade E");
}
else
{
System.out.println("\n Fail");
}
}
}
public class Studmark
{
public static void main(String[] args)
{
StudDemo sd=new StudDemo();
sd.calculate_Stud_Grade();
}
}
| [
"[email protected]"
] | |
203c618230d41b16df5ee38acafce7dc7a80cbfb | ea9b205432bdb52334d39406f1ff0026e6da65f9 | /src/multiworld/worldgen/populators/SapplingPopulator.java | a8e079fc9c4b314c89bbe303551485b9f845f36e | [] | no_license | wysohn/multiworld | 316903d6f938d064f9e774756cfb4ed73f182bf7 | d5443f9aae1c5aeb61447e3c93905382191f8e49 | refs/heads/master | 2020-04-14T10:15:30.534640 | 2019-01-02T03:56:29 | 2019-01-02T03:56:29 | 163,781,914 | 0 | 0 | null | 2019-01-02T01:52:08 | 2019-01-02T01:52:08 | null | UTF-8 | Java | false | false | 1,068 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package multiworld.worldgen.populators;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.generator.BlockPopulator;
/**
*
* @author Fernando
*/
public class SapplingPopulator extends BlockPopulator
{
@Override
public void populate(World world, Random random, Chunk chunk)
{
// Add random glowstone
for (int i = 0; i < 64; i++)
{
// pick out a random point
int x = random.nextInt(14) + 1;
int y = random.nextInt(250) + 3;
int z = random.nextInt(14) + 1;
Block mainBlock = chunk.getBlock(x, y, z);
//skip if the block is air
if (mainBlock.getType() != Material.AIR)
{
continue;
}
if (mainBlock.getRelative(BlockFace.DOWN).getType() != Material.GRASS)
{
continue;
}if (mainBlock.getLightLevel() <9)
{
continue;
}
mainBlock.setType(Material.SAPLING);
}
}
}
| [
"[email protected]"
] | |
510f0f21dbfaad3dbf68d9fc980a0c09fbc6e1c6 | 752769cdbde5709ec894e46509ea26d072f63860 | /jsf-demos/mservice/src/main/java/com/jsf/service/OrderRestService.java | c30595d7fa608a11b20fa82df0e1eedcd9a0a3f7 | [
"BSD-3-Clause"
] | permissive | cjg208/JSF | dca375b472d16e2a7cb9ac56e939b63d60cc86cf | 693041b6bb6a1b753d3be072c8ee7d879622e6b5 | refs/heads/master | 2023-01-01T08:39:47.925873 | 2020-10-27T08:35:08 | 2020-10-27T08:35:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,177 | java | package com.jsf.service;
import com.jsf.model.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
* Description: Feign方式实现,自带负载均衡
* User: xujunfei
* Date: 2018-02-27
* Time: 10:27
*/
// 如果接入网关(目前默认使用nacos),FeignClient设置为nc-gateway
@FeignClient(value = "ms-provider", fallback = OrderRestServiceHystrix.class)
public interface OrderRestService {
/**
* 下单服务
*
* @param userId
* @param productId
* @return
*/
@GetMapping("/order")
String order(@RequestParam("userId") Integer userId, @RequestParam("productId") Integer productId);
/**
* GET请求多个参数
*
* @param map
* @return
*/
@GetMapping("/get")
String get(@RequestParam Map<String, Object> map);
/**
* POST请求多个参数
*
* @param user
* @return
*/
@PostMapping("/post")
String post(@RequestBody User user);
@GetMapping("/getUserById/{id}")
User getUserById(@PathVariable("id") Integer id);
}
| [
"[email protected]"
] | |
95c77bea3d6e6d6715cb2dfebaa50367b6f15e36 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/3/3_cf6a01a765a05054de476d06078174754e55f70e/GroupCalculationUtil/3_cf6a01a765a05054de476d06078174754e55f70e_GroupCalculationUtil_s.java | b0ee313b623923e25b83c5bfabc3b21d8dba2152 | [] | 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 | 16,840 | java | /*******************************************************************************
* Copyright (c) 2004, 2005 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.data.engine.executor.transform.group;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.eclipse.birt.data.engine.api.IGroupDefinition;
import org.eclipse.birt.data.engine.api.ISortDefinition;
import org.eclipse.birt.data.engine.cache.CachedList;
import org.eclipse.birt.data.engine.cache.ICachedObject;
import org.eclipse.birt.data.engine.cache.ICachedObjectCreator;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.executor.BaseQuery;
import org.eclipse.birt.data.engine.executor.cache.ResultSetCache;
import org.eclipse.birt.data.engine.executor.cache.SortSpec;
import org.eclipse.birt.data.engine.executor.transform.ResultSetPopulator;
import org.eclipse.birt.data.engine.i18n.ResourceConstants;
import org.eclipse.birt.data.engine.impl.DataEngineSession;
import org.eclipse.birt.data.engine.odi.IQuery;
import org.eclipse.birt.data.engine.odi.IResultClass;
import org.eclipse.birt.data.engine.script.ScriptEvalUtil;
import com.ibm.icu.text.Collator;
/**
* The instance of this class is used by CachedResultSet to deal with
* group-related data transformation operations.
*/
public class GroupCalculationUtil
{
private BaseQuery query;
private IResultClass rsMeta;
/**
* Group definitions. Each entry has name of key column plus interval
* information. groupKeys[0] is the highest group level
*/
private GroupBy[] groupDefs;
/** data rows holds real data */
private ResultSetCache smartCache;
private GroupInformationUtil groupInformationUtil;
/*
* groups[level] is an ArrayList of GroupInfo objects at the specified
* level. Level is a 0-based group index, with 0 denoting the outermost
* group, etc. Example: Row GroupKey1 GroupKey2 GroupKey3 Column4 Column5 0:
* CHINA BEIJING 2003 Cola $100 1: CHINA BEIJING 2003 Pizza $320 2: CHINA
* BEIJING 2004 Cola $402 3: CHINA SHANGHAI 2003 Cola $553 4: CHINA SHANGHAI
* 2003 Pizza $223 5: CHINA SHANGHAI 2004 Cola $226 6: USA CHICAGO 2004
* Pizza $133 7: USA NEW YORK 2004 Cola $339 8: USA NEW YORK 2004 Cola $297
*
* groups: (parent, child) LEVEL 0 LEVEL 1 LEVEL 2
* ============================================ 0: -,0 0,0 0,0 1: -,2 0,2
* 0,2 2: 1,4 1,3 3: 1,5 1,5 4: 2,6 5: 3,7
*/
private ResultSetPopulator resultPopoulator;
/**
*
* @param query
* @param rsMeta
* @throws DataException
*/
GroupCalculationUtil(
BaseQuery query,
ResultSetPopulator resultPopoulator) throws DataException
{
this.query = query;
this.resultPopoulator = resultPopoulator;
this.rsMeta = resultPopoulator.getResultSetMetadata( );
groupInformationUtil = new GroupInformationUtil( this );
this.initGroupSpec( );
}
/**
* @param inputStream
* @param rsMeta
* @param rsCache
* @throws DataException
*/
/* GroupCalculationUtil( InputStream inputStream, IResultClass rsMeta,
ResultSetCache rsCache ) throws DataException
{
try
{
this.groupInformationUtil.readGroupsFromStream( inputStream );
}
catch ( IOException e )
{
throw new DataException( ResourceConstants.RD_LOAD_ERROR,
e,
"Group Info" );
}
this.rsMeta = rsMeta;
this.smartCache = rsCache;
this.initGroupSpec( );
}*/
/**
*
* @return
*/
public GroupInformationUtil getGroupInformationUtil( )
{
return this.groupInformationUtil;
}
/**
* @param inputStream
* @throws DataException
*/
public void doSave( OutputStream outputStream ) throws DataException
{
try
{
this.groupInformationUtil.saveGroupsToStream( outputStream );
}
catch ( IOException e )
{
throw new DataException( ResourceConstants.RD_SAVE_ERROR,
e,
"Group Information" );
}
}
/**
* Everytime in CachedResultSet the result set cache changed, it must be
* reset to GroupCalculationUtil. Set the value of smartCache.
*
* @param rsc
*/
public void setResultSetCache( ResultSetCache rsc )
{
this.smartCache = rsc;
}
/**
* Gets group count
*
* @return number of groupKeys
*/
int getGroupCount( )
{
return groupDefs.length;
}
/**
* Sort the group array according to the values in sortKeys[] of
* GroupBoundaryInfo intances. within them.
*
* @param groupArray
*/
void sortGroupBoundaryInfos( List[] groupArray )
{
for ( int i = 0; i < groupArray.length; i++ )
{
Object[] toBeSorted = new Object[groupArray[i].size( )];
for ( int j = 0; j < toBeSorted.length; j++ )
{
toBeSorted[j] = groupArray[i].get( j );
}
Arrays.sort( toBeSorted, new GroupBoundaryInfoComparator( ) );
groupArray[i].clear( );
for ( int j = 0; j < toBeSorted.length; j++ )
{
groupArray[i].add( toBeSorted[j] );
}
}
}
public BaseQuery getQuery( )
{
return this.query;
}
/**
* This method is used to filter out the GroupBoundaryInfo instances that
* are marked as "not accepted" from GroupBoundaryInfos.
*
* @param groupArray
* @return
*/
List[] filterGroupBoundaryInfos( List[] groupArray )
{
List[] result = new List[groupArray.length];
for ( int i = 0; i < result.length; i++ )
{
result[i] = new CachedList( resultPopoulator.getSession( )
.getTempDir( ),
DataEngineSession.getCurrentClassLoader( ),
GroupBoundaryInfo.getCreator( ) );
}
for ( int i = 0; i < groupArray.length; i++ )
{
for ( int j = 0; j < groupArray[i].size( ); j++ )
{
if ( ( (GroupBoundaryInfo) groupArray[i].get( j ) ).isAccpted( ) )
{
result[i].add( groupArray[i].get( j ) );
}
}
}
return result;
}
/**
*
* @return
*/
GroupBy[] getGroupDefn( )
{
return this.groupDefs;
}
ResultSetCache getResultSetCache( )
{
return this.smartCache;
}
ResultSetPopulator getResultSetPopoulator( )
{
return resultPopoulator;
}
/**
* Performs data transforms and starts the iterator
*/
private void initGroupSpec( ) throws DataException
{
// Set up the GroupDefs structure
IQuery.GroupSpec[] groupSpecs = query.getGrouping( );
if ( groupSpecs != null )
{
groupDefs = new GroupBy[groupSpecs.length];
for ( int i = 0; i < groupSpecs.length; ++i )
{
int keyIndex = groupSpecs[i].getKeyIndex( );
String keyColumn = groupSpecs[i].getKeyColumn( );
// Convert group key name to index for faster future access
// assume priority of keyColumn is higher than keyIndex
if ( keyColumn != null )
keyIndex = rsMeta.getFieldIndex( keyColumn );
if ( keyIndex < 1 || keyIndex > rsMeta.getFieldCount( ) )
{
// Invalid group key name
throw new DataException( ResourceConstants.INVALID_GROUP_KEY_COLUMN,
keyColumn );
}
groupDefs[i] = GroupBy.newInstance( groupSpecs[i],
keyIndex,
keyColumn,
rsMeta.getFieldValueClass( keyIndex ) );
}
}
else
{
groupDefs = new GroupBy[0];
}
}
/**
* Sort data rows by group information and sort specification
*
* @throws DataException
*/
public SortSpec getSortSpec( ) throws DataException
{
assert groupDefs != null;
// Create an array of column indexes. We first sort by Group keys, then
// sort keys
int groupCount = 0;
int sortCount = 0;
for ( int i = 0; i < groupDefs.length; i++ )
{
// When group column is rowid, sort on it should not
// take effect.
if ( groupDefs[i].getColumnIndex( ) >= 0 )
{
groupCount++;
}
}
if ( query.getOrdering( ) != null )
{
sortCount = query.getOrdering( ).length;
}
boolean doGroupSort = false;
for( int i = 0; i < groupCount; i++ )
{
if( groupDefs[i].getGroupSpec( ).getSortDirection( ) != IQuery.NO_SORT_BEFORE_GROUPING )
{
doGroupSort = true;
break;
}
}
if( !doGroupSort )
groupCount = 0;
int[] sortKeyIndexes = new int[groupCount + sortCount];
String[] sortKeyColumns = new String[groupCount + sortCount];
boolean[] sortAscending = new boolean[groupCount + sortCount];
Comparator[] comparator = new Comparator[groupCount + sortCount];
for ( int i = 0; i < groupCount; i++ )
{
int index = groupDefs[i].getColumnIndex( );
if ( index >= 0 )
{
sortKeyIndexes[i] = groupDefs[i].getColumnIndex( );
sortKeyColumns[i] = groupDefs[i].getColumnName( );
sortAscending[i] = groupDefs[i].getGroupSpec( )
.getSortDirection( ) != IGroupDefinition.SORT_DESC;
//TODO:support collation sort in grouping. At current stage
//we only support collation sort in sort definition.
comparator[i] = null;
}
}
for ( int i = 0; i < sortCount; i++ )
{
int keyIndex = query.getOrdering( )[i].getIndex( );
String keyName = query.getOrdering( )[i].getField( );
// If sort key name exist (not null) then depend on key name, else
// depend on key index
if ( keyName != null )
keyIndex = rsMeta.getFieldIndex( keyName );
// if ( keyIndex < 1 || keyIndex > rsMeta.getFieldCount( ) )
// // Invalid sort key name
// throw new DataException( ResourceConstants.INVALID_KEY_COLUMN,
// keyName );
sortKeyIndexes[groupCount + i] = keyIndex;
sortKeyColumns[groupCount + i] = keyName;
sortAscending[groupCount + i] = query.getOrdering( )[i].isAscendingOrder( );
comparator[groupCount + i] = query.getOrdering( )[i].getComparator( );
}
return new SortSpec( sortKeyIndexes, sortKeyColumns, sortAscending, comparator );
}
}
/**
* Structure to hold a group instance with its startIndex, endIndex, filter
* result, sortKeys and Sort directions.
*
*/
final class GroupBoundaryInfo implements ICachedObject
{
// The start index and end index of a Group
private int startIndex;
private int endIndex;
// Used by Group sorting
private Object[] sortKeys;
private boolean[] sortDirections;
// Used by Group filtering
private boolean accept = true;
private Collator[] comparator;
/**
*
* @return
*/
public static ICachedObjectCreator getCreator()
{
return new GroupBoundaryInfoCreator();
}
/**
* @param start
* The start index of a group
* @param end
* The end index of a group
*/
GroupBoundaryInfo( int start, int end )
{
this.startIndex = start;
this.endIndex = end;
sortKeys = new Object[0];
}
/*
* (non-Javadoc)
* @see org.eclipse.birt.data.engine.cache.ICachedObject#getFieldValues()
*/
public Object[] getFieldValues()
{
ArrayList fields = new ArrayList();
fields.add( new Integer(startIndex) ); //idx 0
fields.add( new Integer(endIndex) ); //idx 1
if(sortKeys != null)
{
fields.add( new Integer(sortKeys.length) ); //idx 2
for(int i=0;i<sortKeys.length;i++)
fields.add(sortKeys[i]);
}
else
{
fields.add(null);
}
if ( sortDirections != null)
{
fields.add( new Integer( sortDirections.length ) ); //idx 2 + n + 1
for ( int i = 0; i < sortDirections.length; i++ )
fields.add( new Boolean( sortDirections[i] ) );
}
else
{
fields.add(null);
}
if ( this.comparator!= null )
{
fields.add( new Integer( comparator.length ) ); //idx 2 + n + 1 + n + 1
for ( int i = 0; i < comparator.length; i++ )
fields.add( new Integer( comparator[i].getStrength() ) );
}
else
{
fields.add( null );
}
fields.add( new Boolean( accept ) );
return fields.toArray( );
}
/**
* Return the start index.
*
* @return
*/
int getStartIndex( )
{
return this.startIndex;
}
/**
* Return the end index.
*
* @return
*/
int getEndIndex( )
{
return this.endIndex;
}
/**
* Detect whether the given GroupBoundaryInfo consists of the startIdx and
* endIdx that included in current GroupBoundaryInfo instance.
*
* @param gbi
* @return
*/
boolean isInBoundary( GroupBoundaryInfo gbi )
{
if ( gbi.getStartIndex( ) >= this.getStartIndex( )
&& gbi.getEndIndex( ) <= this.getEndIndex( ) )
return true;
else
return false;
}
/**
* Set the sort conditions
*
* @param sortKeys
* @param sortOrderings
*/
void setSortCondition( Object[] sortKeys, boolean[] sortOrderings, int[] sortStrength )
{
this.sortKeys = sortKeys;
this.sortDirections = sortOrderings;
this.comparator = new Collator[this.sortKeys.length];
for( int i = 0; i < this.comparator.length; i++ )
{
this.comparator[i] = sortStrength[i] == ISortDefinition.ASCII_SORT_STRENGTH
? null : Collator.getInstance( );
}
}
/**
* Return the sort keys array.
*
* @return
*/
Object[] getSortKeys( )
{
return this.sortKeys;
}
/**
* Return the sort direction array.
*
* @return
*/
boolean[] getSortDirection( )
{
return this.sortDirections;
}
/**
* Return the sort strength;
* @return
*/
Comparator[] getCollarComparator()
{
return this.comparator;
}
/**
* Set the filter value of GroupBoundaryInfo.
*
* @param accept
*/
void setAccepted( boolean accept )
{
this.accept = accept;
}
/**
* Return whether the GroupBoundaryInfo intance is accpeted or not.
*
* @return
*/
boolean isAccpted( )
{
return this.accept;
}
}
/**
* The Comparator instance which is used to compare two GroupBoundaryInfo
* instance.
*
*/
final class GroupBoundaryInfoComparator implements Comparator
{
/**
*
*/
public int compare( Object o1, Object o2 )
{
Object[] sortKeys1 = ( (GroupBoundaryInfo) o1 ).getSortKeys( );
Object[] sortKeys2 = ( (GroupBoundaryInfo) o2 ).getSortKeys( );
boolean[] sortDirection = ( (GroupBoundaryInfo) o1 ).getSortDirection( );
Comparator[] comparator = ( (GroupBoundaryInfo) o1 ).getCollarComparator( );
int result = 0;
for ( int i = 0; i < sortKeys1.length; i++ )
{
try
{
result = ScriptEvalUtil.compare( sortKeys1[i], sortKeys2[i], comparator[i] );
}
catch ( DataException e )
{
result = 0;
}
if ( result != 0 )
{
if ( sortDirection[i] == false )
{
result = result * -1;
break;
}
}
}
return result;
}
}
/**
* A creator class implemented ICachedObjectCreator. This class is used to
* create GroupBoundaryInfo object.
*
* @author Administrator
*
*/
class GroupBoundaryInfoCreator implements ICachedObjectCreator
{
/*
* (non-Javadoc)
* @see org.eclipse.birt.data.engine.cache.ICachedObjectCreator#createInstance(java.lang.Object[])
*/
public ICachedObject createInstance( Object[] fields )
{
GroupBoundaryInfo groupBoundaryInfo = new GroupBoundaryInfo( ( (Integer) fields[0] ).intValue( ),
( (Integer) fields[1] ).intValue( ) );
Object[] sortKeys = null;
int sortKeysTotalLength = 1;
if ( fields[2] != null )
{
sortKeys = new Object[( (Integer) fields[2] ).intValue( )];
System.arraycopy( fields, 3, sortKeys, 0, sortKeys.length );
sortKeysTotalLength = sortKeys.length + 1;
}
boolean[] sortDirections = null;
if ( fields[2 + sortKeysTotalLength] != null )
{
sortDirections = new boolean[( (Integer) fields[2 + sortKeysTotalLength] ).intValue( )];
for ( int i = 0; i < sortDirections.length; i++ )
{
sortDirections[i] = ( (Boolean) fields[3 + sortKeysTotalLength + i ] ).booleanValue( );
}
}
int[] sortStrength = null;
if ( fields[2 + sortKeysTotalLength*2] != null )
{
sortStrength = new int[( (Integer) fields[2 + sortKeysTotalLength*2] ).intValue( )];
for ( int i = 0; i < sortStrength.length; i++ )
{
sortStrength[i] = ( (Integer) fields[3 + sortKeysTotalLength*2 + i ] ).intValue( );
}
}
groupBoundaryInfo.setSortCondition( sortKeys, sortDirections, sortStrength );
groupBoundaryInfo.setAccepted( ( (Boolean) fields[fields.length - 1] ).booleanValue( ) );
return groupBoundaryInfo;
}
}
| [
"[email protected]"
] | |
f27b71afde0e9a6c2f27014a71f28fbb5cb4f100 | 5b039aad1ab378767fe67a2828308eea83b23f15 | /src/oop/exercise/grocery/ReadyMadeCake.java | 8d285d40a8dd42dd87284b7049221e614ca104c3 | [] | no_license | trungquangphan/JavaPF | 94d1fbee486bd85ea519abd6129a1c8a0b64f269 | d115039ced3a84ee1c73235e81d590d77e5f7644 | refs/heads/master | 2020-03-28T17:26:54.559324 | 2019-04-08T02:38:13 | 2019-04-08T02:38:13 | 148,791,077 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,299 | java | package oop.exercise.grocery;
public class ReadyMadeCake extends Cake {
private final String[] SUPPORTED_DISCOUNT_CONDITIONS = {"NameOfCustomerCondition"};
public int quantity;
public ReadyMadeCake(String name, double rate,int quantity) {
super(name, rate);
this.quantity = quantity;
}
public ReadyMadeCake(Cake cake){
super(cake);
if (cake instanceof ReadyMadeCake) {
this.quantity = ((ReadyMadeCake) cake).quantity;
}
}
public double calcPrice () {
return rate * quantity;
}
@Override public double getPrice() {
return calcPrice();
}
@Override public double getDiscount(DiscountCondition[] discountConditions) {
double discountAmount = 0;
if(quantity > 5){
discountAmount += DISCOUNT_IN_PERCENT/100*this.getPrice();
}
discountAmount += this.getBaseDiscount(discountConditions);
return discountAmount;
}
@Override public String getInfo() {
return toString() + ", price: " + getPrice();
}
@Override public String[] getSupportedDiscountConditions() {
return SUPPORTED_DISCOUNT_CONDITIONS;
}
public String toString () {
return super.toString() + "\t" + quantity +" (eggs)";
}
} | [
"[email protected]"
] | |
897666a81fad54690ec8ced344412ffff290f2c4 | fab52656ee6219135cd5e532ba0a8666ac53a9b7 | /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java | 6eacbbaeafb8bb2de4ce677f3f8529a7f3820c89 | [
"LicenseRef-scancode-warranty-disclaimer",
"IJG",
"Zlib",
"NCSA",
"LicenseRef-scancode-unknown-license-reference",
"blessing",
"BSD-3-Clause",
"ISC",
"Libpng",
"BSL-1.0",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"JSON",
"curl",
"OpenSSL",
"MIT"
] | permissive | leejing397/GeoMap | ee4ae2ce2d4fde8a79025b466df12ccae1f42366 | d94d3f275234ad4434858e08a6b42e72c44dc6db | refs/heads/master | 2021-04-26T21:51:31.524079 | 2018-03-07T05:47:19 | 2018-03-07T05:47:19 | 124,166,780 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,450 | java | package com.mapbox.mapboxsdk.maps;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;
import timber.log.Timber;
/**
* Settings for the user location and bearing tracking of a MapboxMap.
*
* @deprecated use location layer plugin from
* https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
*/
@Deprecated
public final class TrackingSettings {
private final MyLocationView myLocationView;
private final UiSettings uiSettings;
private final FocalPointChangeListener focalPointChangedListener;
private final CameraZoomInvalidator zoomInvalidator;
private LocationEngine locationSource;
private LocationEngineListener myLocationListener;
private boolean locationChangeAnimationEnabled = true;
private boolean isCustomLocationSource;
private boolean myLocationEnabled;
private boolean dismissLocationTrackingOnGesture = true;
private boolean dismissBearingTrackingOnGesture = true;
private MapboxMap.OnMyLocationTrackingModeChangeListener onMyLocationTrackingModeChangeListener;
private MapboxMap.OnMyBearingTrackingModeChangeListener onMyBearingTrackingModeChangeListener;
TrackingSettings(@NonNull MyLocationView myLocationView, UiSettings uiSettings,
FocalPointChangeListener focalPointChangedListener, CameraZoomInvalidator zoomInvalidator) {
this.myLocationView = myLocationView;
this.focalPointChangedListener = focalPointChangedListener;
this.uiSettings = uiSettings;
this.zoomInvalidator = zoomInvalidator;
}
void initialise(MapboxMapOptions options) {
locationSource = Mapbox.getLocationEngine();
setMyLocationEnabled(options.getLocationEnabled());
}
void onSaveInstanceState(Bundle outState) {
outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, getMyLocationTrackingMode());
outState.putInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, getMyBearingTrackingMode());
outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, isDismissLocationTrackingOnGesture());
outState.putBoolean(MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, isDismissBearingTrackingOnGesture());
outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, isMyLocationEnabled());
outState.putBoolean(MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, isLocationChangeAnimationEnabled());
outState.putBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE, isCustomLocationSource());
}
void onRestoreInstanceState(Bundle savedInstanceState) {
try {
setMyLocationEnabled(
savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED),
savedInstanceState.getBoolean(MapboxConstants.STATE_USING_CUSTOM_LOCATION_SOURCE)
);
} catch (SecurityException ignore) {
// User did not accept location permissions
}
// noinspection ResourceType
setMyLocationTrackingMode(savedInstanceState.getInt(
MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE));
// noinspection ResourceType
setMyBearingTrackingMode(savedInstanceState.getInt(
MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE));
setDismissLocationTrackingOnGesture(savedInstanceState.getBoolean(
MapboxConstants.STATE_MY_LOCATION_TRACKING_DISMISS, true));
setDismissBearingTrackingOnGesture(savedInstanceState.getBoolean(
MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true));
setLocationChangeAnimationEnabled(savedInstanceState.getBoolean(
MapboxConstants.STATE_LOCATION_CHANGE_ANIMATION_ENABLED, true));
}
/**
* <p>
* Set the current my location tracking mode.
* </p>
* <p>
* Will enable my location if not active.
* </p>
* See {@link MyLocationTracking} for different values.
*
* @param myLocationTrackingMode The location tracking mode to be used.
* @throws SecurityException if no suitable permission is present
* @see MyLocationTracking
*/
@UiThread
public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) {
myLocationView.setLocationChangeAnimationEnabled(isLocationChangeAnimationEnabled());
myLocationView.setMyLocationTrackingMode(myLocationTrackingMode);
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
zoomInvalidator.zoomTo(2.0);
focalPointChangedListener.onFocalPointChanged(myLocationView.getCenter());
} else {
focalPointChangedListener.onFocalPointChanged(null);
}
if (onMyLocationTrackingModeChangeListener != null) {
onMyLocationTrackingModeChangeListener.onMyLocationTrackingModeChange(myLocationTrackingMode);
}
}
/**
* Returns the current user location tracking mode.
*
* @return The current user location tracking mode.
* One of the values from {@link MyLocationTracking.Mode}.
* @see MyLocationTracking.Mode
*/
@UiThread
@MyLocationTracking.Mode
public int getMyLocationTrackingMode() {
return myLocationView.getMyLocationTrackingMode();
}
/**
* <p>
* Set the current my bearing tracking mode.
* </p>
* Shows the direction the user is heading.
* <p>
* When location tracking is disabled the direction of {@link MyLocationView} is rotated. When
* location tracking is enabled the {@link MapView} is rotated based on the bearing value.
* </p>
* See {@link MyBearingTracking} for different values.
*
* @param myBearingTrackingMode The bearing tracking mode to be used.
* @throws SecurityException if no suitable permission is present
* @see MyBearingTracking
*/
@UiThread
public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) {
myLocationView.setMyBearingTrackingMode(myBearingTrackingMode);
if (onMyBearingTrackingModeChangeListener != null) {
onMyBearingTrackingModeChangeListener.onMyBearingTrackingModeChange(myBearingTrackingMode);
}
}
/**
* Returns the current user bearing tracking mode.
* See {@link MyBearingTracking} for possible return values.
*
* @return the current user bearing tracking mode.
* @see MyBearingTracking
*/
@UiThread
@MyBearingTracking.Mode
public int getMyBearingTrackingMode() {
return myLocationView.getMyBearingTrackingMode();
}
/**
* Returns if all tracking modes will be dismissed when a gesture occurs.
*
* @return True to indicate that location and bearing tracking will be dismissed.
*/
public boolean isAllDismissTrackingOnGesture() {
return dismissLocationTrackingOnGesture && dismissBearingTrackingOnGesture;
}
/**
* Set the dismissal of the tracking modes if a gesture occurs.
*
* @param dismissTrackingOnGesture True to dismiss all the tracking modes.
*/
public void setDismissAllTrackingOnGesture(boolean dismissTrackingOnGesture) {
dismissLocationTrackingOnGesture = dismissTrackingOnGesture;
dismissBearingTrackingOnGesture = dismissTrackingOnGesture;
}
/**
* Set the dismissal of the tracking modes if a gesture occurs.
*
* @param dismissLocationTrackingOnGesture True to dismiss the location tracking mode.
*/
public void setDismissLocationTrackingOnGesture(boolean dismissLocationTrackingOnGesture) {
this.dismissLocationTrackingOnGesture = dismissLocationTrackingOnGesture;
}
/**
* Returns if the location tracking will be disabled when a gesture occurs
*
* @return True if location tracking will be disabled.
*/
public boolean isDismissLocationTrackingOnGesture() {
return dismissLocationTrackingOnGesture;
}
/**
* Set the dismissal of the bearing tracking modes if a gesture occurs.
*
* @param dismissBearingTrackingOnGesture True to dimsiss the bearinf tracking mode
*/
public void setDismissBearingTrackingOnGesture(boolean dismissBearingTrackingOnGesture) {
this.dismissBearingTrackingOnGesture = dismissBearingTrackingOnGesture;
}
/**
* Returns if bearing will disabled when a gesture occurs
*
* @return True if bearing tracking will be disabled
*/
public boolean isDismissBearingTrackingOnGesture() {
return dismissBearingTrackingOnGesture;
}
/**
* Returns if location tracking is disabled
*
* @return True if location tracking is disabled.
*/
public boolean isLocationTrackingDisabled() {
return myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE;
}
/**
* Returns if bearing tracking disabled
*
* @return True if bearing tracking is disabled.
*/
public boolean isBearingTrackingDisabled() {
return myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE;
}
/**
* Returns if rotate gesture are currently enabled.
*
* @return True if rotate gestures are currently enabled.
*/
public boolean isRotateGestureCurrentlyEnabled() {
// rotate gestures are recognised if:
// The user settings are enabled AND;
// EITHER bearing tracking is dismissed on gesture OR there is no bearing tracking
return uiSettings.isRotateGesturesEnabled()
&& (dismissBearingTrackingOnGesture
|| myLocationView.getMyBearingTrackingMode() == MyBearingTracking.NONE
|| myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE);
}
/**
* Returns if scroll gesture are currently enabled.
*
* @return True if scroll gestures are currently enabled.
*/
public boolean isScrollGestureCurrentlyEnabled() {
return uiSettings.isScrollGesturesEnabled()
&& (dismissLocationTrackingOnGesture
|| myLocationView.getMyLocationTrackingMode() == MyLocationTracking.TRACKING_NONE);
}
/**
* Returns whether location change animation is applied for {@link MyLocationTracking#TRACKING_FOLLOW}.
*
* @return True if animation is applied, false otherwise.
*/
public boolean isLocationChangeAnimationEnabled() {
return locationChangeAnimationEnabled;
}
/**
* Set whether location change animation should be applied for {@link MyLocationTracking#TRACKING_FOLLOW}.
*
* @param locationChangeAnimationEnabled True if animation should be applied, false otherwise.
*/
public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) {
this.locationChangeAnimationEnabled = locationChangeAnimationEnabled;
myLocationView.setLocationChangeAnimationEnabled(locationChangeAnimationEnabled);
}
/**
* Reset the tracking modes as necessary. Location tracking is reset if the map center is changed and not from
* location, bearing tracking if there is a rotation.
*
* @param translate true if translation
* @param rotate true if rotation
* @param isFromLocation true if from location
*/
void resetTrackingModesIfRequired(boolean translate, boolean rotate, boolean isFromLocation) {
// if tracking is on, and we should dismiss tracking with gestures, and this is a scroll action, turn tracking off
if (translate && !isLocationTrackingDisabled() && isDismissLocationTrackingOnGesture() && !isFromLocation) {
setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
}
// reset bearing tracking only on rotate
if (rotate && !isBearingTrackingDisabled() && isDismissBearingTrackingOnGesture()) {
setMyBearingTrackingMode(MyBearingTracking.NONE);
}
}
/**
* Reset the tracking modes as necessary. Animated camera position changes can reset the underlying tracking modes.
*
* @param currentCameraPosition the current camera position
* @param targetCameraPosition the changed camera position
* @param isFromLocation true if from location
*/
void resetTrackingModesIfRequired(CameraPosition currentCameraPosition, CameraPosition targetCameraPosition,
boolean isFromLocation) {
if (currentCameraPosition.target != null) {
resetTrackingModesIfRequired(!currentCameraPosition.target.equals(targetCameraPosition.target), false,
isFromLocation);
}
}
Location getMyLocation() {
return myLocationView.getLocation();
}
void setOnMyLocationChangeListener(@Nullable final MapboxMap.OnMyLocationChangeListener listener) {
if (listener != null) {
myLocationListener = new LocationEngineListener() {
@Override
public void onConnected() {
// Nothing
}
@Override
public void onLocationChanged(Location location) {
if (listener != null) {
listener.onMyLocationChange(location);
}
}
};
locationSource.addLocationEngineListener(myLocationListener);
} else {
locationSource.removeLocationEngineListener(myLocationListener);
myLocationListener = null;
}
}
public boolean isCustomLocationSource() {
return isCustomLocationSource;
}
void setOnMyLocationTrackingModeChangeListener(MapboxMap.OnMyLocationTrackingModeChangeListener listener) {
this.onMyLocationTrackingModeChangeListener = listener;
}
void setOnMyBearingTrackingModeChangeListener(MapboxMap.OnMyBearingTrackingModeChangeListener listener) {
this.onMyBearingTrackingModeChangeListener = listener;
}
MyLocationView getMyLocationView() {
return myLocationView;
}
boolean isMyLocationEnabled() {
return myLocationEnabled;
}
void setMyLocationEnabled(boolean locationEnabled) {
setMyLocationEnabled(locationEnabled, isCustomLocationSource());
}
private void setMyLocationEnabled(boolean locationEnabled, boolean isCustomLocationSource) {
if (!PermissionsManager.areLocationPermissionsGranted(myLocationView.getContext())) {
Timber.e("Could not activate user location tracking: "
+ "user did not accept the permission or permissions were not requested.");
return;
}
myLocationEnabled = locationEnabled;
this.isCustomLocationSource = isCustomLocationSource;
myLocationView.setEnabled(locationEnabled, isCustomLocationSource);
}
void setLocationSource(LocationEngine locationSource) {
if (this.locationSource != null && this.locationSource.equals(locationSource)) {
// this source is already active
return;
}
this.isCustomLocationSource = locationSource != null;
if (locationSource == null) {
locationSource = Mapbox.getLocationEngine();
}
this.locationSource = locationSource;
myLocationView.setLocationSource(locationSource);
}
void update() {
if (!myLocationView.isEnabled()) {
return;
}
myLocationView.update();
}
void onStart() {
myLocationView.onStart();
}
void onStop() {
myLocationView.onStop();
}
interface CameraZoomInvalidator {
void zoomTo(double zoomLevel);
}
}
| [
"[email protected]"
] | |
119c23820ec24349b0b82c4dd1ccef2846fa6c97 | 5f2dd097c5ce9583bc1343d7b02b26f8d1a555c3 | /src/main/java/com/neusoft/library/modules/sys/dao/RoleDao.java | 84bb95d6c47dedc5c72fde9a31ed77c10dcfb804 | [
"Apache-2.0"
] | permissive | tangjianTT/library | cfcdea388126fafa9f630b8a56077ad666f95f8d | 4360ac3d6e59f2b3c3ca17b29f79ee5aaed938fd | refs/heads/master | 2022-12-25T03:42:05.508451 | 2020-01-03T01:27:43 | 2020-01-03T01:27:44 | 229,746,099 | 0 | 0 | Apache-2.0 | 2022-12-16T05:11:27 | 2019-12-23T12:14:16 | JavaScript | UTF-8 | Java | false | false | 711 | java | package com.neusoft.library.modules.sys.dao;
import com.neusoft.library.common.persistence.CrudDao;
import com.neusoft.library.common.persistence.annotation.MyBatisDao;
import com.neusoft.library.modules.sys.entity.Role;
/**
* 角色DAO接口
*
*/
@MyBatisDao
public interface RoleDao extends CrudDao<Role> {
public Role getByName(Role role);
public Role getByEnname(Role role);
/**
* 维护角色与菜单权限关系
* @param role
* @return
*/
public int deleteRoleMenu(Role role);
public int insertRoleMenu(Role role);
/**
* 维护角色与公司部门关系
* @param role
* @return
*/
public int deleteRoleOffice(Role role);
public int insertRoleOffice(Role role);
}
| [
"1329025765.com"
] | 1329025765.com |
2357886cab20d9e898204ad4ed908c26ec64c648 | cd8843d24154202f92eaf7d6986d05a7266dea05 | /saaf-base-5.0/3001_saaf-equotation-model/src/main/java/com/sie/watsons/base/pos/supplierinfo/model/entities/EquPosSupplierInfoEntity_HI.java | ce1a2df3d03e449abdd6d416c1723e65c69daaf1 | [] | no_license | lingxiaoti/tta_system | fbc46c7efc4d408b08b0ebb58b55d2ad1450438f | b475293644bfabba9aeecfc5bd6353a87e8663eb | refs/heads/master | 2023-03-02T04:24:42.081665 | 2021-02-07T06:48:02 | 2021-02-07T06:48:02 | 336,717,227 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,631 | java | package com.sie.watsons.base.pos.supplierinfo.model.entities;
import com.alibaba.fastjson.annotation.JSONField;
import javax.persistence.*;
import java.sql.Clob;
import java.util.Date;
/**
* EquPosSupplierInfoEntity_HI Entity Object
* Tue Oct 29 17:34:55 CST 2019 Auto Generate
*/
@Entity
@Table(name="equ_pos_supplier_info")
public class EquPosSupplierInfoEntity_HI {
private Integer id;
private Integer supplierId;
private String supplierNumber;
private String supplierName;
private String supplierShortName;
private String supplierType;
private String supplierStatus;
private String homeUrl;
private String companyPhone;
private String companyFax;
private Integer supplierFileId;
private String blacklistFlag;
private Integer versionNum;
@JSONField(format="yyyy-MM-dd HH:mm:ss")
private Date creationDate;
private Integer createdBy;
private Integer lastUpdatedBy;
@JSONField(format="yyyy-MM-dd HH:mm:ss")
private Date lastUpdateDate;
private Integer lastUpdateLogin;
private String attributeCategory;
private String attribute1;
private String attribute2;
private String attribute3;
private String attribute4;
private String attribute5;
private String attribute6;
private String attribute7;
private String attribute8;
private String attribute9;
private String attribute10;
private String country;
private String majorCustomer;
private String loginAccount;
private Clob companyDescription;
private String cooperativeProject;
private String agentLevel;
private Integer sourceId;
private Integer operatorUserId;
private String supplierFileName;
private String supplierFilePath;
private String whetherSign;
private String remark;
public void setSupplierId(Integer supplierId) {
this.supplierId = supplierId;
}
@Id
@SequenceGenerator(name = "EQU_POS_SUPPLIER_INFO_S", sequenceName = "EQU_POS_SUPPLIER_INFO_S", allocationSize = 1)
@GeneratedValue(generator = "EQU_POS_SUPPLIER_INFO_S", strategy = GenerationType.SEQUENCE)
@Column(name="id", nullable=false, length=22)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name="supplier_id", nullable=false, length=22)
public Integer getSupplierId() {
return supplierId;
}
public void setSupplierNumber(String supplierNumber) {
this.supplierNumber = supplierNumber;
}
@Column(name="supplier_number", nullable=true, length=50)
public String getSupplierNumber() {
return supplierNumber;
}
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
@Column(name="supplier_name", nullable=false, length=200)
public String getSupplierName() {
return supplierName;
}
public void setSupplierShortName(String supplierShortName) {
this.supplierShortName = supplierShortName;
}
@Column(name="supplier_short_name", nullable=true, length=200)
public String getSupplierShortName() {
return supplierShortName;
}
public void setSupplierType(String supplierType) {
this.supplierType = supplierType;
}
@Column(name="supplier_type", nullable=true, length=50)
public String getSupplierType() {
return supplierType;
}
public void setSupplierStatus(String supplierStatus) {
this.supplierStatus = supplierStatus;
}
@Column(name="supplier_status", nullable=true, length=30)
public String getSupplierStatus() {
return supplierStatus;
}
public void setHomeUrl(String homeUrl) {
this.homeUrl = homeUrl;
}
@Column(name="home_url", nullable=true, length=200)
public String getHomeUrl() {
return homeUrl;
}
public void setCompanyPhone(String companyPhone) {
this.companyPhone = companyPhone;
}
@Column(name="company_phone", nullable=true, length=100)
public String getCompanyPhone() {
return companyPhone;
}
public void setCompanyFax(String companyFax) {
this.companyFax = companyFax;
}
@Column(name="company_fax", nullable=true, length=100)
public String getCompanyFax() {
return companyFax;
}
public void setSupplierFileId(Integer supplierFileId) {
this.supplierFileId = supplierFileId;
}
@Column(name="supplier_file_id", nullable=true, length=22)
public Integer getSupplierFileId() {
return supplierFileId;
}
public void setBlacklistFlag(String blacklistFlag) {
this.blacklistFlag = blacklistFlag;
}
@Column(name="blacklist_flag", nullable=true, length=1)
public String getBlacklistFlag() {
return blacklistFlag;
}
public void setVersionNum(Integer versionNum) {
this.versionNum = versionNum;
}
@Version
@Column(name="version_num", nullable=true, length=22)
public Integer getVersionNum() {
return versionNum;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
@Column(name="creation_date", nullable=false, length=7)
public Date getCreationDate() {
return creationDate;
}
public void setCreatedBy(Integer createdBy) {
this.createdBy = createdBy;
}
@Column(name="created_by", nullable=false, length=22)
public Integer getCreatedBy() {
return createdBy;
}
public void setLastUpdatedBy(Integer lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}
@Column(name="last_updated_by", nullable=false, length=22)
public Integer getLastUpdatedBy() {
return lastUpdatedBy;
}
public void setLastUpdateDate(Date lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}
@Column(name="last_update_date", nullable=false, length=7)
public Date getLastUpdateDate() {
return lastUpdateDate;
}
public void setLastUpdateLogin(Integer lastUpdateLogin) {
this.lastUpdateLogin = lastUpdateLogin;
}
@Column(name="last_update_login", nullable=true, length=22)
public Integer getLastUpdateLogin() {
return lastUpdateLogin;
}
public void setAttributeCategory(String attributeCategory) {
this.attributeCategory = attributeCategory;
}
@Column(name="attribute_category", nullable=true, length=30)
public String getAttributeCategory() {
return attributeCategory;
}
public void setAttribute1(String attribute1) {
this.attribute1 = attribute1;
}
@Column(name="attribute1", nullable=true, length=240)
public String getAttribute1() {
return attribute1;
}
public void setAttribute2(String attribute2) {
this.attribute2 = attribute2;
}
@Column(name="attribute2", nullable=true, length=240)
public String getAttribute2() {
return attribute2;
}
public void setAttribute3(String attribute3) {
this.attribute3 = attribute3;
}
@Column(name="attribute3", nullable=true, length=240)
public String getAttribute3() {
return attribute3;
}
public void setAttribute4(String attribute4) {
this.attribute4 = attribute4;
}
@Column(name="attribute4", nullable=true, length=240)
public String getAttribute4() {
return attribute4;
}
public void setAttribute5(String attribute5) {
this.attribute5 = attribute5;
}
@Column(name="attribute5", nullable=true, length=240)
public String getAttribute5() {
return attribute5;
}
public void setAttribute6(String attribute6) {
this.attribute6 = attribute6;
}
@Column(name="attribute6", nullable=true, length=240)
public String getAttribute6() {
return attribute6;
}
public void setAttribute7(String attribute7) {
this.attribute7 = attribute7;
}
@Column(name="attribute7", nullable=true, length=240)
public String getAttribute7() {
return attribute7;
}
public void setAttribute8(String attribute8) {
this.attribute8 = attribute8;
}
@Column(name="attribute8", nullable=true, length=240)
public String getAttribute8() {
return attribute8;
}
public void setAttribute9(String attribute9) {
this.attribute9 = attribute9;
}
@Column(name="attribute9", nullable=true, length=240)
public String getAttribute9() {
return attribute9;
}
public void setAttribute10(String attribute10) {
this.attribute10 = attribute10;
}
@Column(name="attribute10", nullable=true, length=240)
public String getAttribute10() {
return attribute10;
}
public void setCountry(String country) {
this.country = country;
}
@Column(name="country", nullable=true, length=20)
public String getCountry() {
return country;
}
public void setMajorCustomer(String majorCustomer) {
this.majorCustomer = majorCustomer;
}
@Column(name="major_customer", nullable=true, length=200)
public String getMajorCustomer() {
return majorCustomer;
}
public void setLoginAccount(String loginAccount) {
this.loginAccount = loginAccount;
}
@Column(name="login_account", nullable=true, length=30)
public String getLoginAccount() {
return loginAccount;
}
public void setCompanyDescription(Clob companyDescription) {
this.companyDescription = companyDescription;
}
@Column(name="company_description", nullable=true)
public Clob getCompanyDescription() {
return companyDescription;
}
public void setCooperativeProject(String cooperativeProject) {
this.cooperativeProject = cooperativeProject;
}
@Column(name="cooperative_project", nullable=true, length=240)
public String getCooperativeProject() {
return cooperativeProject;
}
public void setAgentLevel(String agentLevel) {
this.agentLevel = agentLevel;
}
@Column(name="agent_level", nullable=true, length=20)
public String getAgentLevel() {
return agentLevel;
}
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
@Column(name="source_id", nullable=true, length=22)
public Integer getSourceId() {
return sourceId;
}
public void setOperatorUserId(Integer operatorUserId) {
this.operatorUserId = operatorUserId;
}
@Transient
public Integer getOperatorUserId() {
return operatorUserId;
}
@Column(name="supplier_file_name", nullable=true, length=100)
public String getSupplierFileName() {
return supplierFileName;
}
public void setSupplierFileName(String supplierFileName) {
this.supplierFileName = supplierFileName;
}
@Column(name="supplier_file_path", nullable=true, length=240)
public String getSupplierFilePath() {
return supplierFilePath;
}
public void setSupplierFilePath(String supplierFilePath) {
this.supplierFilePath = supplierFilePath;
}
@Column(name="whether_sign", nullable=true, length=1)
public String getWhetherSign() {
return whetherSign;
}
public void setWhetherSign(String whetherSign) {
this.whetherSign = whetherSign;
}
public String getRemark() {
return remark;
}
@Column(name="remark", nullable=true, length=240)
public void setRemark(String remark) {
this.remark = remark;
}
}
| [
"[email protected]"
] | |
01e9ec67c1d0e17c03a31b67f87a2b96992b2535 | 49145a8f8c4747388dcb38c2d19e7331ed03833b | /src/leetcode/editor/cn/solved/P72EditDistance.java | 651c7243c74f8d77cf30ef7ea4abc1555dc69d54 | [] | no_license | Samaritan123/problems | e43d356a9bb62c4990be9d553fe2c13b1af570b5 | 50e9d46ff5439c67f6aa7d9e217e7a494ef23cbb | refs/heads/master | 2023-02-14T00:42:24.922431 | 2021-01-11T08:25:46 | 2021-01-11T08:25:46 | 327,801,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,207 | java | //给你两个单词 word1 和 word2,请你计算出将 word1 转换成 word2 所使用的最少操作数 。
//
// 你可以对一个单词进行如下三种操作:
//
//
// 插入一个字符
// 删除一个字符
// 替换一个字符
//
//
//
//
// 示例 1:
//
//
//输入:word1 = "horse", word2 = "ros"
//输出:3
//解释:
//horse -> rorse (将 'h' 替换为 'r')
//rorse -> rose (删除 'r')
//rose -> ros (删除 'e')
//
//
// 示例 2:
//
//
//输入:word1 = "intention", word2 = "execution"
//输出:5
//解释:
//intention -> intention (删除 't')
//inention -> enention (将 'i' 替换为 'e')
//enention -> exention (将 'n' 替换为 'x')
//exention -> exection (将 'n' 替换为 'c')
//exection -> execution (插入 'u')
//
//
//
//
// 提示:
//
//
// 0 <= word1.length, word2.length <= 500
// word1 和 word2 由小写英文字母组成
//
// Related Topics 字符串 动态规划
// 👍 1279 👎 0
package leetcode.editor.cn.solved;
//Java:编辑距离
public class P72EditDistance {
public static void main(String[] args) {
Solution solution = new P72EditDistance().new Solution();
// TO TEST
System.out.println(solution.minDistance("intention", "execution"));
}
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
public int minDistance(String word1, String word2) {
int l1 = word1.length(), l2 = word2.length();
int[][] dp = new int[l1 + 1][l2 + 1];
for (int i = 0; i <= l1; i ++) {
for (int j = 0; j <= l2; j ++) {
if (i == 0) {
dp[i][j] = j;
} else if (j == 0) {
dp[i][j] = i;
} else {
int k = word1.charAt(i - 1)==word2.charAt(j - 1)?0:1;
dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i - 1][j - 1] + k);
dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + 1);
}
}
}
return dp[l1][l2];
}
}
//leetcode submit region end(Prohibit modification and deletion)
} | [
"[email protected]"
] | |
835cc2c0a1c0acbc359532a1b679605e230bac2b | 9c293634aab32be7e54784c97b02f146cbf894c0 | /app/src/main/java/com/loveuu/vv/common/AppUpdate.java | 14fb4b82d63bdaf3e6725bb4a5e81090412fcc4c | [] | no_license | loveuu715/ZFDemo | a620bb516cedf0dfd757943c3325626cf264ed6c | ffcb30326fa6a6220fc9f5f4ea8bc8be5732bdde | refs/heads/master | 2021-01-12T14:25:07.966557 | 2016-10-12T06:00:34 | 2016-10-12T06:00:34 | 69,013,550 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 98 | java | package com.loveuu.vv.common;
/**
* Created by VV on 2016/10/8.
*/
public class AppUpdate {
}
| [
"[email protected]"
] | |
f9b85e1f1089ec2934fb8730a71a22f60f30a7d8 | 645688cff9ce86e6b9ba91347671d283cff42025 | /src/test/java/runner/TestRunner.java | 42323ba79bcf805b10c92ebeceda6618d4856bc3 | [] | no_license | fdhgh/RegresInAPITests | cdb1ffc396dd450f15e3508355848db7bf93bbf7 | 76c48c00d0723b4b38b7d3be1a9dce79a5b3f929 | refs/heads/master | 2022-12-03T23:22:06.007936 | 2020-08-23T19:40:22 | 2020-08-23T19:40:22 | 289,106,998 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 328 | java | package runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/java/features"},
glue = {"stepdefinitions"},
plugin = { "pretty", "html:target/htmlreports" })
public class TestRunner {
}
| [
"[email protected]"
] | |
f3eff46e2d4d380cf72eb26ad1041ab87bf996dd | 0dc2334811cb71a5501565f2bcfb9ed56935f172 | /springTestApp/src/main/java/com/aud/demo/controller/test.java | ab94701fac0d3208ecd82602bd48a1dd44a5a35f | [] | no_license | audenberg/journal | c4c6c716a2a9ac9d54d64634ecdcf631f2b54be3 | 0a07eb5226db3569d2d79718e2c9724e236f7ac4 | refs/heads/master | 2022-07-13T06:00:34.054949 | 2019-09-05T07:28:44 | 2019-09-05T07:28:44 | 201,191,171 | 0 | 0 | null | 2022-06-30T20:19:18 | 2019-08-08T06:18:42 | Java | UTF-8 | Java | false | false | 511 | java | package com.aud.demo.controller;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class test {
@RequestMapping(value="/test" ,method = RequestMethod.GET)
public String registration() {
return new BCryptPasswordEncoder().encode("password");
}
}
| [
"[email protected]"
] | |
1c7cbf825034995d487a68b00ef6e675714ea0d5 | 9208ba403c8902b1374444a895ef2438a029ed5c | /sources/com/google/android/gms/internal/cast/zzcm.java | b8aca1571bb8ffe2c1e932567fc14898f7f9fe74 | [] | no_license | MewX/kantv-decompiled-v3.1.2 | 3e68b7046cebd8810e4f852601b1ee6a60d050a8 | d70dfaedf66cdde267d99ad22d0089505a355aa1 | refs/heads/main | 2023-02-27T05:32:32.517948 | 2021-02-02T13:38:05 | 2021-02-02T13:44:31 | 335,299,807 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,254 | java | package com.google.android.gms.internal.cast;
import android.text.TextUtils;
import androidx.annotation.NonNull;
public class zzcm {
private final String namespace;
protected final zzdg zzvq;
private zzdl zzvr;
protected zzcm(String str, String str2, String str3) {
zzcu.zzo(str);
this.namespace = str;
this.zzvq = new zzdg(str2);
setSessionLabel(str3);
}
public void zza(long j, int i) {
}
public void zzdc() {
}
public void zzn(@NonNull String str) {
}
public final void setSessionLabel(String str) {
if (!TextUtils.isEmpty(str)) {
this.zzvq.zzt(str);
}
}
public final String getNamespace() {
return this.namespace;
}
public final void zza(zzdl zzdl) {
this.zzvr = zzdl;
if (this.zzvr == null) {
zzdc();
}
}
/* access modifiers changed from: protected */
public final void zza(String str, long j, String str2) throws IllegalStateException {
Object[] objArr = {str, null};
this.zzvr.zza(this.namespace, str, j, null);
}
/* access modifiers changed from: protected */
public final long zzde() {
return this.zzvr.zzl();
}
}
| [
"[email protected]"
] | |
9a30c75abaea5bb966eab836450e4783c603e0e9 | ae35d831bab14899f961a0b8784903708149a907 | /core/src/lando/systems/trainjam2016/TrainJam2016.java | bd63b2297c383e8d7cee31cf66899a9f2c233cb3 | [] | no_license | mtolly/trainjam-2016 | 854bb799ba5a078cc3a079796dede96307a0e364 | 4139862536d0be3c378bc828163c555369699439 | refs/heads/master | 2021-01-18T07:29:31.471383 | 2016-03-13T22:00:33 | 2016-03-13T22:00:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 736 | java | package lando.systems.trainjam2016;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import lando.systems.trainjam2016.screens.BaseScreen;
import lando.systems.trainjam2016.screens.MenuScreen;
import lando.systems.trainjam2016.utils.Assets;
public class TrainJam2016 extends ApplicationAdapter {
public static TrainJam2016 game;
public BaseScreen screen;
@Override
public void create() {
Assets.load();
game = this;
screen = new MenuScreen();
}
@Override
public void dispose() {
Assets.dispose();
}
@Override
public void render() {
float dt = Math.min(Gdx.graphics.getDeltaTime(), 1f / 30f);
Assets.tween.update(dt);
screen.update(dt);
screen.render(Assets.batch);
}
}
| [
"[email protected]"
] | |
cabce43e1d2e479b0ac1cd8f9d79d71a391ab16b | b5bf4b8634e2b64deb4e116efb39d5fa2881d677 | /YServer/idea_springboot_mayi_server/mayi/src/main/java/cn/yaoling/mayi/repository/MayiUserRepository.java | eedb2b38095e0a86848a8cfbb38ff620071d9f27 | [] | no_license | It-Life/YL_MaYi | 4979ace1e32de2f61daf749b93016a01792c0281 | 6e5014b8b114a0274a2f0e3335079873938431e5 | refs/heads/master | 2023-02-14T23:09:39.423087 | 2021-01-14T16:03:28 | 2021-01-14T16:03:28 | 314,970,190 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 356 | java | package cn.yaoling.mayi.repository;
import cn.yaoling.mayi.dataobject.MayiUser;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/*
* DAO 层
* */
public interface MayiUserRepository extends JpaRepository<MayiUser,Integer> {
MayiUser findByUserUuid(String userUuid);
MayiUser findByUserPhone(String phone);
}
| [
"[email protected]"
] | |
287d6006729e0ba83ac5e09bade24167e43e3584 | 46ac6e444560ee26c6a37477a192d55fc63def43 | /app/src/main/java/innovvapp/hack/tourism/Fragments/HotelFragment.java | 16c1af4afa8a155d091d512a2023537f5778ef22 | [] | no_license | yasharoraa/Rajasthan-Tourism-App-Padharo_Sa | c45352a1a157de1ee1b6486fbc1e4eafc8db4cbe | b318de5d998df6dfc30deb92a58af0870bcbe6ab | refs/heads/master | 2020-03-13T15:55:59.775766 | 2018-04-26T17:09:38 | 2018-04-26T17:09:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,071 | java | package innovvapp.hack.tourism.Fragments;
import android.annotation.SuppressLint;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import innovvapp.hack.tourism.Adapters.HotelsAdapter;
import innovvapp.hack.tourism.Models.SecondModel;
import innovvapp.hack.tourism.R;
/**
* Created by Yash Arora on 17-03-2018.
*/
@SuppressLint("ValidFragment")
public class HotelFragment extends Fragment {
@BindView(R.id.card_view)
RecyclerView hotelsRecyclerView;
@BindView(R.id.image_upper)
ImageView upperImageView;
@BindView(R.id.upper_text_view)
TextView upperTextView;
private HotelsAdapter hotelsAdapter;
private List<SecondModel> modelsList;
Unbinder unbinder;
private int FragmentType;
@SuppressLint("ValidFragment")
public HotelFragment(int fragmentType) {
FragmentType = fragmentType;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View rootView= inflater.inflate(R.layout.fragent_home,container,false);
unbinder = ButterKnife.bind(this,rootView);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
modelsList = new ArrayList<>();
hotelsAdapter = new HotelsAdapter(getContext(),modelsList,FragmentType);
hotelsRecyclerView.setLayoutManager(mLayoutManager);
hotelsRecyclerView.setItemAnimator(new DefaultItemAnimator());
hotelsRecyclerView.addItemDecoration(new GridSpacingItemDecoration(1,dpToPx(10),true));
hotelsRecyclerView.setAdapter(hotelsAdapter);
if (FragmentType == 1){
upperImageView.setImageResource(R.drawable.hotel);
upperTextView.setText(R.string.title_hotels_toolbar);
}else if (FragmentType == 2){
upperImageView.setImageResource(R.drawable.bus);
upperTextView.setText(R.string.title_travel);
}else {
upperImageView.setImageResource(R.drawable.mahal);
upperTextView.setText(R.string.title_places);
}
prepareList();
return rootView;
}
private void prepareList(){
if (FragmentType == 1){
SecondModel a = new SecondModel("Hotel Sunshine",true,false,R.drawable.rated_sunshine,2,3,1,5,R.string.igsif,2.5);
modelsList.add(a);
a = new SecondModel("Hotel Marigold",true,false,R.drawable.rated_marigold,2,3,1,5,R.string.igsif,4.1);
modelsList.add(a);
a = new SecondModel("Hotel Casa Bella",false,false,R.drawable.rated_casa_bella,2,3,1,5,R.string.igsif,1.0);
modelsList.add(a);
}else if (FragmentType == 2){
SecondModel a = new SecondModel("Ola",true,false,R.drawable.rated_ola,2,3,1,5,R.string.igsif,2.5);
modelsList.add(a);
a = new SecondModel("Uber",true,false,R.drawable.rated_uber,2,3,1,5,R.string.igsif,4.1);
modelsList.add(a);
a = new SecondModel("Jugnoo",false,false,R.drawable.rated_jugnoo,2,3,1,5,R.string.igsif,1.0);
modelsList.add(a);
}else if (FragmentType == 3){
SecondModel a = new SecondModel("Hawa Mahal",true,false,R.drawable.rated_hawamahal,2,3,1,5,R.string.igsif,2.5);
modelsList.add(a);
a = new SecondModel("City Palace",true,false,R.drawable.rated_city_palace,2,3,1,5,R.string.igsif,4.1);
modelsList.add(a);
a = new SecondModel("Buddha Temple",false,false,R.drawable.rated_buddha_temple,2,3,1,5,R.string.igsif,1.0);
modelsList.add(a);
}
}
public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount;
private int spacing;
private boolean includeEdge;
public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
this.spanCount = spanCount;
this.spacing = spacing;
this.includeEdge = includeEdge;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view); // item position
int column = position % spanCount; // item column
if (includeEdge) {
outRect.left = spacing - column * spacing / spanCount; // spacing - column * ((1f / spanCount) * spacing)
outRect.right = (column + 1) * spacing / spanCount; // (column + 1) * ((1f / spanCount) * spacing)
if (position < spanCount) { // top edge
outRect.top = spacing;
}
outRect.bottom = spacing; // item bottom
} else {
outRect.left = column * spacing / spanCount; // column * ((1f / spanCount) * spacing)
outRect.right = spacing - (column + 1) * spacing / spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing)
if (position >= spanCount) {
outRect.top = spacing; // item top
}
}
}
}
/**
* Converting dp to pixel
*/
private int dpToPx(int dp) {
Resources r = getResources();
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()));
}
}
| [
"[email protected]"
] | |
acddb2e00ec27f5e3f6c0022a5ec7ca5523c5277 | be4e632a932764e33f70a1c656b5b07e0d31899a | /tomcat/examples/spring-mvc-showcase/src/test/java/org/springframework/samples/mvc/views/ViewsControllerTests.java | dc5864eb43ed722288b2b9a4e3bd84cd6efa0acb | [
"Apache-2.0"
] | permissive | kubesphere/s2i-java-container | 5de26b8befea1ce4cc1319392c722a4fe0dda04e | ebac872596e06892a35722728f9f1bc0d73b33d5 | refs/heads/master | 2023-01-03T20:17:18.284393 | 2021-09-13T13:03:22 | 2021-09-13T13:03:22 | 173,876,756 | 14 | 26 | Apache-2.0 | 2022-12-16T15:23:45 | 2019-03-05T05:00:35 | Shell | UTF-8 | Java | false | false | 1,847 | java | package org.springframework.samples.mvc.views;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.samples.mvc.AbstractContextControllerTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
@RunWith(SpringJUnit4ClassRunner.class)
public class ViewsControllerTests extends AbstractContextControllerTests {
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = webAppContextSetup(this.wac).alwaysExpect(status().isOk()).build();
}
@Test
public void htmlView() throws Exception {
this.mockMvc.perform(get("/views/html"))
.andExpect(view().name(containsString("views/html")))
.andExpect(model().attribute("foo", "bar"))
.andExpect(model().attribute("fruit", "apple"))
.andExpect(model().size(2));
}
@Test
public void viewName() throws Exception {
this.mockMvc.perform(get("/views/viewName"))
.andExpect(view().name(containsString("views/viewName")))
.andExpect(model().attribute("foo", "bar"))
.andExpect(model().attribute("fruit", "apple"))
.andExpect(model().size(2));
}
@Test
public void uriTemplate() throws Exception {
this.mockMvc.perform(get("/views/pathVariables/bar/apple"))
.andExpect(view().name(containsString("views/html")));
}
}
| [
"[email protected]"
] | |
0b1f22bb2f6a0fbc0f2acf128f3330c7d1a675be | 7ad92fdcde0ddb852fa2cae5700442a9875ae8c1 | /android-studio/BabyBox/app/src/main/java/com/babybox/viewmodel/NewCommentVM.java | 2ba5b621156b81750ab55d7a4a3b42afa1471359 | [] | no_license | mybabybox/BB-Android | 0a12b85cdca31e27bcddd4435008a18f49d83382 | 8d76123a26c97a0b7a5dd3746c962dabd6d589bd | refs/heads/master | 2021-01-21T04:37:00.929265 | 2016-04-17T14:20:58 | 2016-04-17T14:20:58 | 41,082,515 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package com.babybox.viewmodel;
import com.babybox.app.AppController;
public class NewCommentVM {
public Long postId;
public String body;
public String deviceType;
public NewCommentVM(Long postId, String body) {
this.postId = postId;
this.body = body;
this.deviceType = AppController.DeviceType.ANDROID.name();
}
}
| [
"[email protected]"
] | |
2b4495a79c21fbab3f5a19fa9b03462d85fdf8da | 99758bcfdbf5be794dca6d3570de4881916fe260 | /aplikasi-penjualan-tb/src/main/java/net/smktarunabhakti/penjualan/domain/penjualan.java | cfbb5c8d7393c839841ab8c873a9b1c5aed22a45 | [] | no_license | ditomahenr/aplikasi-penjualan-tb | 41052c55949f3351e5c143d2b6d238644b737c74 | 0e0fae84a755cf1f55d66018251d3dfd7acc79e7 | refs/heads/master | 2021-01-25T10:43:44.781196 | 2014-05-14T06:28:29 | 2014-05-14T06:28:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,982 | java | package net.smktarunabhakti.penjualan.domain;
import com.sun.xml.internal.bind.v2.schemagen.xmlschema.Import;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javassist.bytecode.analysis.Util;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
@Entity
@Table(name = "trx_jual_header")
public class penjualan implements Serializable{
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid" ,strategy = "uuid2")
private String id;
@Column(name = "waktu_transaksi")
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date tgl;
@Column(nullable = false)
private String kasir;
@Column(name = "n_Struk" ,nullable =false)
private String noStruk;
//import org.hibernate.annotations.Cascade;
//import org.hibernate.annotations.CascadeType;
//Import java.Util.list
@OneToMany(mappedBy = "header")
@Cascade(value = CascadeType.ALL)
private List<PenjualanDetail> listPenjualanDetail;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getKasir() {
return kasir;
}
public void setKasir(String kasir) {
this.kasir = kasir;
}
public String getNoStruk() {
return noStruk;
}
public void setNoStruk(String noStruk) {
this.noStruk = noStruk;
}
public Date getTgl() {
return tgl;
}
public void setTgl(Date tgl) {
this.tgl = tgl;
}
}
| [
"[email protected]"
] | |
8f0abddb24e6c8ec9b77573a35887dfda0881ced | b3d4b22a8fbfb54b04de58e27cebac300e4a0c98 | /starsky/src/main/java/com/huaiwang/starsky/service/common/HttpClientService.java | ff78bf17b2073191945d4d2e666157d7cd7c0eeb | [] | no_license | glaylee2017/test | 3e40fb006e387d8b39d95fdf813ae39a5e81a45e | 5f524e1bf7d3753343aa6f7e02e702d333f4421e | refs/heads/master | 2021-01-19T22:41:29.039943 | 2017-04-28T01:15:46 | 2017-04-28T01:15:46 | 88,845,820 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,878 | java | package com.huaiwang.starsky.service.common;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class HttpClientService {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientService.class);
@Autowired(required=false)
private CloseableHttpClient httpClient;
@Autowired(required=false)
private RequestConfig requestConfig;
/**
* 执行get请求
*
* @param url
* @return
* @throws Exception
*/
public String doGet(String url,Map<String, String> params,String encode) throws Exception {
LOGGER.info("执行GET请求,URL = {}", url);
if(null != params){
URIBuilder builder = new URIBuilder(url);
for (Map.Entry<String, String> entry : params.entrySet()) {
builder.setParameter(entry.getKey(), entry.getValue());
}
url = builder.build().toString();
}
// 创建http GET请求
HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(requestConfig);
CloseableHttpResponse response = null;
try {
// 执行请求
response = httpClient.execute(httpGet);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
if(encode == null){
encode = "UTF-8";
}
return EntityUtils.toString(response.getEntity(), encode);
}
} finally {
if (response != null) {
response.close();
}
// 此处不能关闭httpClient,如果关闭httpClient,连接池也会销毁
}
return null;
}
public String doGet(String url, String encode) throws Exception{
return this.doGet(url, null, encode);
}
public String doGet(String url) throws Exception{
return this.doGet(url, null, null);
}
/**
* 带参数的get请求
*
* @param url
* @param params
* @return
* @throws Exception
*/
public String doGet(String url, Map<String, String> params) throws Exception {
return this.doGet(url, params, null);
}
/**
* 执行POST请求
*
* @param url
* @param params
* @return
* @throws Exception
*/
public String doPost(String url, Map<String, String> params,String encode) throws Exception {
// 创建http POST请求
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
if (null != params) {
// 设置2个post参数,一个是scope、一个是q
List<NameValuePair> parameters = new ArrayList<NameValuePair>(0);
for (Map.Entry<String, String> entry : params.entrySet()) {
parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
// 构造一个form表单式的实体
UrlEncodedFormEntity formEntity = null;
if(encode!=null){
formEntity = new UrlEncodedFormEntity(parameters,encode);
}else{
formEntity = new UrlEncodedFormEntity(parameters);
}
// 将请求实体设置到httpPost对象中
httpPost.setEntity(formEntity);
}
CloseableHttpResponse response = null;
try {
// 执行请求
response = httpClient.execute(httpPost);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
} finally {
if (response != null) {
response.close();
}
}
return null;
}
/**
* 执行POST请求
*
* @param url
* @param params
* @return
* @throws Exception
*/
public String doPost(String url, Map<String, String> params) throws Exception {
// 创建http POST请求
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
if (null != params) {
// 设置2个post参数,一个是scope、一个是q
List<NameValuePair> parameters = new ArrayList<NameValuePair>(0);
for (Map.Entry<String, String> entry : params.entrySet()) {
parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
// 构造一个form表单式的实体
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(parameters);
// 将请求实体设置到httpPost对象中
httpPost.setEntity(formEntity);
}
CloseableHttpResponse response = null;
try {
// 执行请求
response = httpClient.execute(httpPost);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
} finally {
if (response != null) {
response.close();
}
}
return null;
}
public String doPostJson(String url, String json) throws Exception {
// 创建http POST请求
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
if(null != json){
//设置请求体为 字符串
StringEntity stringEntity = new StringEntity(json,"UTF-8");
httpPost.setEntity(stringEntity);
}
CloseableHttpResponse response = null;
try {
// 执行请求
response = httpClient.execute(httpPost);
// 判断返回状态是否为200
if (response.getStatusLine().getStatusCode() == 200) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
} finally {
if (response != null) {
response.close();
}
}
return null;
}
}
| [
"[email protected]"
] | |
356a1a0fe85a247d766e6947f7cf7d9c884c1fca | 60b5001f249ad192b48b6faef714648a44517799 | /src/main/java/com/study/context/AnnotationApplicationContext.java | 499b3c63f96b82a93e0235d48d6be51d99030aee | [] | no_license | chengchen901/spring-custom-study | e52e153cf53b7d9a98fe8bc3412bb9b1d001f6f8 | 5af406ddf24baefb50f309a9a2b5eb1cbffc0179 | refs/heads/master | 2023-07-13T22:51:00.641109 | 2021-08-15T09:44:23 | 2021-08-15T09:44:23 | 396,005,308 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 554 | java | package com.study.context;
import com.study.beans.BeanDefinitionRegistry;
import java.util.Set;
public class AnnotationApplicationContext extends AbstractApplicationContext {
private ClassPathBeanDefinitionScanner scanner;
public AnnotationApplicationContext(String... basePackages) throws Exception {
this.scanner = new ClassPathBeanDefinitionScanner((BeanDefinitionRegistry) this.beanFactory);
scanner.scan(basePackages);
}
@Override
public Resource getResource(String location) {
return null;
}
}
| [
"[email protected]"
] | |
83ae9cc4c0e7a8ae354df0c5c4a6e413dca96736 | 60401f6f68e1f2691e9c52e8858bd18ccfd6076b | /src/main/java/com/twg/entity/User.java | d966a625663a44dd27b33dbcb4a115eeae546cdf | [] | no_license | tenvin/myspringboot | 328a3a7902ec575ef46abeb234f16e6234fbccb2 | d058c381df869a75c8370b9befc2100d78e4cbea | refs/heads/master | 2020-12-30T22:33:42.505278 | 2018-07-05T13:07:59 | 2018-07-05T13:07:59 | 86,518,792 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 689 | java | package com.twg.entity;
import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Min;
/**
* Created by twg on 2017/6/15.
*/
@Entity
@Data
public class User {
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
@NotBlank(message = "用户名不能为空")
private String name;
@Min(value = 18,message = "年龄应该大与18")
private Integer age;
public User(String name, Integer age) {
this.name = name;
this.age = age;
}
}
| [
"[email protected]"
] | |
3416a34a5f6351876e405fe08bc204b310881ae8 | ebf8f13cb265a0d637db2e3f54843ab0ac3cbaa8 | /app/src/main/java/com/example/simpleweather/MainActivity.java | 65136564ac6234e9e300f0bff383e7ace5588e1d | [] | no_license | IcedCrescent/AnotherWeatherApp | 0c14fd64c15fa6f26d577340784c378e803cd08b | 5eb15fde46ac32077e515662832391035d0be443 | refs/heads/master | 2020-04-05T11:32:45.495329 | 2018-11-09T09:20:32 | 2018-11-09T09:20:32 | 156,838,639 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,989 | java | package com.example.simpleweather;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONObject;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
Typeface weatherFont;
TextView cityField;
TextView updateField;
TextView detailsField;
TextView currentTemperatureField;
TextView weatherIcon;
Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
handler = new Handler();
weatherFont = Typeface.createFromAsset(getAssets(), "fonts/weathericons-regular-webfont.ttf");
cityField = findViewById(R.id.city_field);
updateField = findViewById(R.id.update_field);
detailsField = findViewById(R.id.detail_field);
currentTemperatureField = findViewById(R.id.current_temperature_field);
weatherIcon = findViewById(R.id.weather_icon);
weatherIcon.setTypeface(weatherFont);
updateWeatherData(new CityPreference(this).getCity());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.weather, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.change_city) {
showInputDialog();
}
return false;
}
private void showInputDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Change city");
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(input);
builder.setPositiveButton("Go", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changeCity(input.getText().toString());
}
});
builder.show();
}
private void changeCity(String city) {
updateWeatherData(city);
new CityPreference(this).setCity(city);
}
private void updateWeatherData(final String city) {
new Thread() {
@Override
public void run() {
final JSONObject json = RemoteFetch.getJSON(MainActivity.this, city);
if (json == null) {
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, getString(R.string.place_not_found), Toast.LENGTH_LONG).show();
}
});
} else {
handler.post(new Runnable() {
@Override
public void run() {
renderWeather(json);
}
});
}
}
}.start();
}
private void renderWeather(JSONObject json) {
try {
cityField.setText(json.getString("name").toUpperCase(Locale.US) +
", " +
json.getJSONObject("sys").getString("country"));
JSONObject details = json.getJSONArray("weather").getJSONObject(0);
JSONObject main = json.getJSONObject("main");
detailsField.setText(
details.getString("description").toUpperCase(Locale.US) +
"\n" + "Humidity: " + main.getString("humidity") + "%" +
"\n" + "Pressure: " + main.getString("pressure") + " hPa");
currentTemperatureField.setText(
String.format("%.2f", main.getDouble("temp"))+ " ℃");
DateFormat df = DateFormat.getDateTimeInstance();
String updatedOn = df.format(new Date(json.getLong("dt")*1000));
updateField.setText("Last update: " + updatedOn);
setWeatherIcon(details.getInt("id"),
json.getJSONObject("sys").getLong("sunrise") * 1000,
json.getJSONObject("sys").getLong("sunset") * 1000);
}catch(Exception e){
Log.e("SimpleWeather", "One or more fields not found in the JSON data");
}
}
private void setWeatherIcon(int actualId, long sunrise, long sunset) {
int id = actualId / 100;
String icon = "";
if(actualId == 800){
long currentTime = new Date().getTime();
if(currentTime>=sunrise && currentTime<sunset) {
icon = getString(R.string.weather_sunny);
} else {
icon = getString(R.string.weather_clear_night);
}
} else {
switch(id) {
case 2 : icon = getString(R.string.weather_thunder);
break;
case 3 : icon = getString(R.string.weather_drizzle);
break;
case 7 : icon = getString(R.string.weather_foggy);
break;
case 8 : icon = getString(R.string.weather_cloudy);
break;
case 6 : icon = getString(R.string.weather_snowy);
break;
case 5 : icon = getString(R.string.weather_rainy);
break;
}
}
weatherIcon.setText(icon);
}
}
| [
"[email protected]"
] | |
e436a8fb4c942bb0f8152be8d30187432df24925 | 30bb4fbe263bdcc3dcd3813c5ec8ec8e45b60827 | /Helloworld.java | 35bc99c654ecf1903a65cebb3def4954dbe32ee1 | [] | no_license | keerthikambala/keerthi | be9d72a3b795c90e3d8323a7e3f78897def9ef66 | 57cc676ed6ffee75d17861aab211859350052d2c | refs/heads/master | 2021-01-02T18:45:39.622052 | 2020-03-12T04:36:01 | 2020-03-12T04:36:01 | 239,749,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 602 | java |
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Helloworld extends HttpServlet{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//System.out.println("hello");
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
String s1=request.getParameter("t1");
String s2=request.getParameter("t2");
pw.println(s1+""+s2);
}
}
| [
"[email protected]"
] | |
216f37493a2c037106bb76f0f3cf9fbbdd74f4e7 | 4a31d38738cf8951a114aa71cb2cde7e7124edf0 | /src/main/java/io/izzel/kether/common/api/Quest.java | 703d0d61aa0906860fa9c83344fda1b308ffcb5d | [] | no_license | Bkm016/KetherX | e866058e52f24445995811260f61076bc79b1e14 | a8589495f006498ac198fc8bf8f3c29e4b2ef0d4 | refs/heads/master | 2023-02-20T11:31:06.545826 | 2021-01-26T14:24:04 | 2021-01-26T14:24:04 | 333,083,963 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 485 | java | package io.izzel.kether.common.api;
import java.util.List;
import java.util.Map;
import java.util.Optional;
public interface Quest {
String getId();
Optional<Block> getBlock(String label);
Map<String, Block> getBlocks();
Optional<Block> blockOf(QuestAction<?> action);
interface Block {
String getLabel();
List<QuestAction<?>> getActions();
int indexOf(QuestAction<?> action);
Optional<QuestAction<?>> get(int i);
}
}
| [
"[email protected]"
] | |
9d446c881a8b5b9e074abc178dd5d32686d25202 | 2a74479f87a504638deacf92eec25e4da71f0036 | /src/main/java/com/bulky/signup/SignupController.java | ae04d0d4829210d0a219d47d50b9d3de25655e27 | [] | no_license | mefrasa/bulky | e610b94b718b88e9efc465eb3ad5dd00b9791ce4 | f77ce1a20266c16f6929e6ac6849e11f688b3e9f | refs/heads/master | 2020-04-05T00:40:42.869471 | 2018-10-31T16:27:58 | 2018-10-31T16:27:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,412 | java | package com.bulky.signup;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.bulky.account.*;
import com.bulky.support.web.*;
@Controller
class SignupController {
private static final String SIGNUP_VIEW_NAME = "signup/signup";
@Autowired
private AccountService accountService;
@GetMapping("signup")
String signup(Model model, @RequestHeader(value = "X-Requested-With", required = false) String requestedWith) {
model.addAttribute(new SignupForm());
if (Ajax.isAjaxRequest(requestedWith)) {
return SIGNUP_VIEW_NAME.concat(" :: signupForm");
}
return SIGNUP_VIEW_NAME;
}
@PostMapping("signup")
String signup(@Valid @ModelAttribute SignupForm signupForm, Errors errors, RedirectAttributes ra) {
if (errors.hasErrors()) {
return SIGNUP_VIEW_NAME;
}
Account account = accountService.save(signupForm.createAccount());
accountService.signin(account);
// see /WEB-INF/i18n/messages.properties and /WEB-INF/views/homeSignedIn.html
MessageHelper.addSuccessAttribute(ra, "signup.success");
return "redirect:/";
}
}
| [
"[email protected]"
] | |
23a8b4593e1ed27cb01bf174e10115c4dc210f24 | ccdd03ac63692de726ecab697105fe4222313ae9 | /src/project/ComboProj.java | 9b308525c3169dcaed20186c8231dcddb0b84992 | [] | no_license | mathewacarter29/ComboProj | 8c991534336dbd2666d271bab788072aa6a6a73b | 06de96e7fca1a94e1218f69d74501e92a21603cc | refs/heads/master | 2023-04-30T10:20:33.413283 | 2021-05-10T22:39:55 | 2021-05-10T22:39:55 | 366,192,876 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,678 | java | package project;
public class ComboProj {
static double factorial(int x) {
double result = 1;
for (int i = 1; i <= x; i++) {
result *= i;
}
return result;
}
static double choose(int n, int r) {
return (factorial(n) / (factorial(r) * factorial(n - r)));
}
public static void main(String[] args) {
System.out.println("This program will find the number of strategically different poker hands.\n");
//Case 1: Pocket Pair (both of the player's cards are the same denomination)
//Step 1: Choose a denomination for the pocket pair - we can do this in (13 choose 1) ways
double step1 = choose(13, 1);
//Step 2: Make both cards of the chosen denomination - we can do this in (1) way
double step2 = 1;
//Total outcomes = (13 choose 1) * (1) by Multiplication Principle
double case1 = step1 * step2;
//Case 2: Suited Cards (both of the player's cards are the same suit)
//Step 1: Choose the first card from any of the 13 denominations - we can do this (13 choose 1) ways
//*Note: We do not choose the suit in the first step since suited cards of the same denomination
// play the same.
step1 = choose(13, 1);
//Step 2: Choose the second card from the remaining 12 denominations - we can do this (12 choose 1) ways
step2 = choose(12, 1);
//Total outcomes = (13 choose 1) * (12 choose 1) by the Multiplication Principle
double case2 = step1 * step2;
//Step 3: To eliminate hand repeats (like K-Q and Q-K), we must un-order the hand. To do this,
// we will divide the total arrangements by 2!.
case2 = case2 / factorial(2);
//Case 3: Unsuited Cards (both of the player's cards are different suits)
//Step 1: Choose the first card from any of the 13 denominations - we can do this (13 choose 1) ways
//*Note: We do not choose the suit in the first step since unsuited cards of the same denomination
// play the same.
step1 = choose(13, 1);
//Step 2: Choose the second card from the remaining 12 denominations - we can do this (12 choose 1) ways
step2 = choose(12, 1);
//Total outcomes = (13 choose 1) * (12 choose 1) by the Multiplication Principle
double case3 = step1 * step2;
//Step 3: To eliminate hand repeats (like 8-7 and 7-8), we must un-order the hand. To do this,
// we will divide the total arrangements by 2!.
case3 = case3 / factorial(2);
//Since all cases are disjoint, we can find the total number of strategically different
// poker starting hands by the Addition Principle
double total = case1 + case2 + case3;
System.out.println("The total number of strategically different poker hands is: " + (int)total);
}
}
| [
"[email protected]"
] | |
6ab15a1e846fdbf80b991ec25f2f8164c1f226fa | c548d09d6f80c939f694d7404043f50a040f0e0c | /src/main/java/org/projectodd/vertx/jgroups/VertxAddress.java | cbe9229d7ae81dd3153de9c94454b339d53efbc2 | [] | no_license | bobmcwhirter/vertx-infinispan-module | b63b4a9348d8210a9b3465fefdb2c665aab75275 | 7ab8eb85a45af3196217be479665c0bdbb68e3ec | refs/heads/master | 2020-05-20T07:21:59.361293 | 2013-07-12T21:07:22 | 2013-07-12T21:07:22 | 11,319,971 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,252 | java | package org.projectodd.vertx.jgroups;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.jgroups.Address;
import org.jgroups.PhysicalAddress;
public class VertxAddress implements PhysicalAddress {
private String address;
public VertxAddress() {
}
public VertxAddress(String address) {
this.address = address;
}
@Override
public int size() {
return this.address.getBytes().length;
}
@Override
public void writeTo(DataOutput out) throws Exception {
out.writeUTF( this.address );
}
@Override
public void readFrom(DataInput in) throws Exception {
this.address = in.readUTF();
}
@Override
public int compareTo(Address o) {
return this.address.compareTo( ((VertxAddress)o).address );
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(this.address);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.address = in.readUTF();
}
public String toString() {
return this.address;
}
}
| [
"[email protected]"
] | |
0caa0afba7b51d8318f9e817d809ceaf9bc309bf | 09a07b5f4718e2d691f25a6c2fa9f203ba0be9cd | /chapter1/src/main/java/com/smart/dao/LoginLogDao.java | 0c70e53491fad8d1c3b5252502842415c4602baa | [] | no_license | kqyang0000/chapter | fd07abeeff2071142d277ef3dd694859af921d6a | c0cc2d01b4a81a1a8cfa123841ba74faba7b0530 | refs/heads/master | 2020-05-23T06:09:29.915444 | 2019-05-22T15:51:54 | 2019-05-22T15:51:54 | 186,661,821 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 632 | java | package com.smart.dao;
import com.smart.domain.LoginLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
/**
* Created by kqyang on 2019/5/15.
*/
@Repository
public class LoginLogDao {
@Autowired
private JdbcTemplate jdbcTemplate;
public void insertLoginLog(LoginLog loginLog) {
String sqlStr = "INSERT INTO t_login_log(user_id,ip,login_datetime) VALUES(?,?,?)";
jdbcTemplate.update(sqlStr, new Object[]{loginLog.getUserId(), loginLog.getIp(), loginLog.getLoginDatetime()});
}
}
| [
"[email protected]"
] | |
d76909662524ee859d05830b31fbfda785c5cc33 | c5c7d57fd248a7a2e26e99347d0823d3318ae984 | /EjercicioInterfaces/src/com/yan/EjercicioInterfaces/Jeans.java | 7c3c119a5a56aaee2a6b598240cf36541ce2a350 | [] | no_license | YancarloOjeda/EjercicioINterfaces | 677c4ab202b47a5d4d48a2ebc9296e5dbbc58ea8 | 5e1935a39e5031cfa0da41a8fe36c4d1910e77ce | refs/heads/master | 2022-11-14T14:17:07.725769 | 2020-06-25T22:06:15 | 2020-06-25T22:06:15 | 275,023,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 990 | java | package com.yan.EjercicioInterfaces;
public class Jeans extends Ropa implements IDevolucion {
private String corte;
private String genero;
public Jeans(int id, double precio, String talla, String color, String corte, String genero) {
super(id, precio, talla, color);//super clase o clase padre (Ropa)
// TODO Auto-generated constructor stub
this.corte = corte;
this.genero = genero;
}
public String getCorte() {
return corte;
}
public void setCorte(String corte) {
this.corte = corte;
}
public String getGenero() {
return genero;
}
public void setGenero(String genero) {
this.genero = genero;
}
@Override
public void mostrarDatos(String nombreClase) {
// TODO Auto-generated method stub
super.mostrarDatos(nombreClase);
System.out.println("corte = " + corte);
System.out.println("genero = " + genero);
}
@Override
public void hacerDevolucion() {
// TODO Auto-generated method stub
System.out.println("Devolución de Jeans");
}
}
| [
"[email protected]"
] | |
e8d5b2dc53908900da4984f792d4ea6bfafdeea0 | bcbfbe91899c043d309fd43ec5b2bd20f4cd0f0e | /app/src/main/java/com/martins/cubeit/CubeWare/CubeData/SubCubeType.java | 0d25865a08fca628b982c83fccbb8cc9fad6016c | [] | no_license | maartins/CubeIt | 8b86be90d3208f4bd789533a21c61f13c66e9871 | 3d34258918bdc72e24e63b2caac5301babadafeb | refs/heads/master | 2021-06-27T07:38:21.998314 | 2020-12-23T14:42:00 | 2020-12-23T14:42:00 | 196,358,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 108 | java | package com.martins.cubeit.CubeWare.CubeData;
public enum SubCubeType {
Corner,
Edge,
Center
}
| [
"[email protected]"
] | |
e82a26e0fff6021188dd21668ba293bce8d7e247 | 7a3234d282fda192fed2c0aacc57c79477a27074 | /net/minecraft/world/storage/MapInfo.java | 62e0cee502af3c91a1b03604ef96130890efe363 | [] | no_license | mjuniper/mod-design | 88a70724730492f9637f210410bcb128b7f7fe8d | 9106cbffb1eb8113add8da7cfbb2bf37e9f1b38c | refs/heads/master | 2021-01-10T06:46:12.944366 | 2016-10-03T21:59:05 | 2016-10-03T21:59:05 | 44,486,038 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,274 | java | package net.minecraft.world.storage;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class MapInfo
{
/** Reference for EntityPlayer object in MapInfo */
public final EntityPlayer entityplayerObj;
public int[] field_76209_b;
public int[] field_76210_c;
/**
* updated by x = mod(x*11,128) +1 x-1 is used to index field_76209_b and field_76210_c
*/
private int currentRandomNumber;
private int ticksUntilPlayerLocationMapUpdate;
/**
* a cache of the result from getPlayersOnMap so that it is not resent when nothing changes
*/
private byte[] lastPlayerLocationOnMap;
public int field_82569_d;
private boolean field_82570_i;
/** reference in MapInfo to MapData object */
final MapData mapDataObj;
public MapInfo(MapData par1MapData, EntityPlayer par2EntityPlayer)
{
this.mapDataObj = par1MapData;
this.field_76209_b = new int[128];
this.field_76210_c = new int[128];
this.entityplayerObj = par2EntityPlayer;
for (int i = 0; i < this.field_76209_b.length; ++i)
{
this.field_76209_b[i] = 0;
this.field_76210_c[i] = 127;
}
}
/**
* returns a 1+players*3 array, of x,y, and color . the name of this function may be partially wrong, as there is a
* second branch to the code here
*/
public byte[] getPlayersOnMap(ItemStack par1ItemStack)
{
byte[] abyte;
if (!this.field_82570_i)
{
abyte = new byte[] {(byte)2, this.mapDataObj.scale};
this.field_82570_i = true;
return abyte;
}
else
{
int i;
int j;
if (--this.ticksUntilPlayerLocationMapUpdate < 0)
{
this.ticksUntilPlayerLocationMapUpdate = 4;
abyte = new byte[this.mapDataObj.playersVisibleOnMap.size() * 3 + 1];
abyte[0] = 1;
i = 0;
for (Iterator iterator = this.mapDataObj.playersVisibleOnMap.values().iterator(); iterator.hasNext(); ++i)
{
MapCoord mapcoord = (MapCoord)iterator.next();
abyte[i * 3 + 1] = (byte)(mapcoord.iconSize << 4 | mapcoord.iconRotation & 15);
abyte[i * 3 + 2] = mapcoord.centerX;
abyte[i * 3 + 3] = mapcoord.centerZ;
}
boolean flag = !par1ItemStack.isOnItemFrame();
if (this.lastPlayerLocationOnMap != null && this.lastPlayerLocationOnMap.length == abyte.length)
{
for (j = 0; j < abyte.length; ++j)
{
if (abyte[j] != this.lastPlayerLocationOnMap[j])
{
flag = false;
break;
}
}
}
else
{
flag = false;
}
if (!flag)
{
this.lastPlayerLocationOnMap = abyte;
return abyte;
}
}
for (int k = 0; k < 1; ++k)
{
i = this.currentRandomNumber++ * 11 % 128;
if (this.field_76209_b[i] >= 0)
{
int l = this.field_76210_c[i] - this.field_76209_b[i] + 1;
j = this.field_76209_b[i];
byte[] abyte1 = new byte[l + 3];
abyte1[0] = 0;
abyte1[1] = (byte)i;
abyte1[2] = (byte)j;
for (int i1 = 0; i1 < abyte1.length - 3; ++i1)
{
abyte1[i1 + 3] = this.mapDataObj.colors[(i1 + j) * 128 + i];
}
this.field_76210_c[i] = -1;
this.field_76209_b[i] = -1;
return abyte1;
}
}
return null;
}
}
}
| [
"[email protected]"
] | |
741441f303ea0d470980da00863fd1c50474ec00 | b23f4fb8323a223abb26da107b589245142fce33 | /src/com/leozzy/nine/HorrorShow.java | b20b08202f369b296be0cc6cee2fd89b62d421c2 | [] | no_license | leozhiyu/thinking-in-java | d9f61ccf6657026ae223c36aeb2a5e9a62c24b20 | 72440f4b4a11022adfa14dd839770843f59079db | refs/heads/master | 2021-09-08T02:27:34.035030 | 2018-03-06T00:54:58 | 2018-03-06T00:54:58 | 112,142,580 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,512 | java | package com.leozzy.nine;
/**
* Created by Leo
*/
interface Monster{
void menace();
}
interface DangerousMonster extends Monster{
void destroy();
}
interface Lethal{
void kill();
}
class DragonZilla implements DangerousMonster{
@Override
public void menace(){
System.out.println("DragonZilla.menace()");
}
@Override
public void destroy(){
System.out.println("DragonZilla.destroy()");
}
}
interface Vampire extends DangerousMonster,Lethal{
void drinkBlood();
}
class VeryBadVampire implements Vampire{
@Override
public void menace() {
System.out.println("VeryBanVampire.menace()");
}
@Override
public void destroy() {
System.out.println("VeryBanVampire.destroy()");
}
@Override
public void kill() {
System.out.println("VeryBanVampire.kill()");
}
@Override
public void drinkBlood() {
System.out.println("VeryBanVampire.drinkBlood()");
}
}
public class HorrorShow {
static void u(Monster b){
b.menace();
}
static void v(DangerousMonster d){
d.menace();
d.destroy();
}
static void w(Lethal l){
l.kill();
}
public static void main(String[] args) {
DangerousMonster barney = new DragonZilla();
u(barney);
v(barney);
Vampire vlad = new VeryBadVampire();
u(vlad);
v(vlad);
w(vlad);
}
}
| [
"[email protected]"
] | |
45f4aa7c7057cdffc0cdf763d4cdc8bf004a0a2a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/9/9_f316941c0477e728135b13c2cb5f2300d7ecb1c1/VersionUtils/9_f316941c0477e728135b13c2cb5f2300d7ecb1c1_VersionUtils_t.java | cc36547eee94ad6b4f97c255e0a715976345d5fd | [] | 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 | 3,326 | java | /**
* Flexmojos is a set of maven goals to allow maven users to compile, optimize and test Flex SWF, Flex SWC, Air SWF and Air SWC.
* Copyright (C) 2008-2012 Marvin Froeder <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sonatype.flexmojos.compatibilitykit;
import java.util.Arrays;
public class VersionUtils
{
public static int[] splitVersion( String version, int size )
{
int[] versions = splitVersion( version );
if ( versions.length != size )
{
int[] temp = new int[size];
Arrays.fill( temp, 0 );
System.arraycopy( versions, 0, temp, 0, Math.min( versions.length, size ) );
versions = temp;
}
return versions;
}
public static int[] splitVersion( String version )
{
if ( version == null || version.trim().equals( "" ) )
{
return new int[0];
}
int endIndex = version.indexOf( '-' );
if ( endIndex != -1 )
{
version = version.substring( 0, endIndex );
}
String[] versionsStr = version.split( "\\." );
int[] versions = new int[versionsStr.length];
for ( int i = 0; i < versionsStr.length; i++ )
{
try
{
versions[i] = new Integer( versionsStr[i] );
}
catch ( NumberFormatException e )
{
versions[i] = 0;
}
}
return versions;
}
public static boolean isMinVersionOK( int[] fdkVersion, int[] minVersion )
{
return isVersionOK( fdkVersion, minVersion );
}
public static boolean isMaxVersionOK( int[] fdkVersion, int[] maxVersion )
{
return isVersionOK( maxVersion, fdkVersion );
}
private static boolean isVersionOK( int[] fdkVersion, int[] minVersion )
{
int lenght = getSmaller( fdkVersion.length, minVersion.length );
int result = 0;
for ( int i = 0; i < lenght; i++ )
{
result = fdkVersion[i] - minVersion[i];
if ( result != 0 )
{
return result > -1;
}
}
return result > -1;
}
private static int getSmaller( int... integers )
{
if ( integers.length == 0 )
{
return 0;
}
int smaller = Integer.MAX_VALUE;
for ( int integer : integers )
{
if ( integer < smaller )
{
smaller = integer;
}
}
return smaller;
}
}
| [
"[email protected]"
] | |
c0a54f169ee28598b1964d7953fac8aa88321249 | ba1319482b0912f5d22e5a4f99b011e0010f47c3 | /src/main/java/com/oleg/currencygetter/CurrencyGetterApplication.java | 34eb2624452c98b6349c21ef8794182a00ab82fe | [] | no_license | Olegidse/currency-getter | bc292e34af16c1430167b490fbda9de24f682e4c | ce978c792593d6301231eca6fd33f2d7865eafa5 | refs/heads/master | 2023-07-18T02:42:59.494919 | 2021-09-06T11:16:50 | 2021-09-06T11:16:50 | 403,622,254 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package com.oleg.currencygetter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
public class CurrencyGetterApplication {
public static void main(String[] args) {
SpringApplication.run(CurrencyGetterApplication.class, args);
}
}
| [
"[email protected]"
] | |
5c9a552bfea5bcf7489b7a9c20fc5ce81a1e82aa | 3b91ed788572b6d5ac4db1bee814a74560603578 | /com/tencent/mm/plugin/emoji/ui/v2/EmojiStoreV2RewardUI$9.java | 8dea8dba5025c9ad9d9cd97d62fbb3e6c13f3895 | [] | no_license | linsir6/WeChat_java | a1deee3035b555fb35a423f367eb5e3e58a17cb0 | 32e52b88c012051100315af6751111bfb6697a29 | refs/heads/master | 2020-05-31T05:40:17.161282 | 2018-08-28T02:07:02 | 2018-08-28T02:07:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 452 | java | package com.tencent.mm.plugin.emoji.ui.v2;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
class EmojiStoreV2RewardUI$9 implements OnClickListener {
final /* synthetic */ EmojiStoreV2RewardUI iqC;
EmojiStoreV2RewardUI$9(EmojiStoreV2RewardUI emojiStoreV2RewardUI) {
this.iqC = emojiStoreV2RewardUI;
}
public final void onClick(DialogInterface dialogInterface, int i) {
}
}
| [
"[email protected]"
] | |
26620403dbdd08cae5a092db9cbc089e99c121fe | 53049a66095fed43c48eceaf9fadbfdde3e64919 | /ClasseAbstraite2/src/metier/Forme.java | eb317fa7c93cac793ef4a360c1d89126c2673c52 | [] | no_license | GOthmane/ProjetsJSE | 77f5a1a33c96ad779e3c2762fa9f49400eeb6676 | 3f68f349fe1697327e91d53810e6e9d08cae67ca | refs/heads/master | 2021-01-20T13:22:44.029839 | 2017-05-07T05:59:24 | 2017-05-07T05:59:24 | 90,481,817 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 254 | java | package metier;
public abstract class Forme {
public abstract float perimetre();
public abstract float surface();
public float coefficientEtalement() {
float lePerimetre = perimetre();
return 16 * surface() / (lePerimetre * lePerimetre);
}
}
| [
"[email protected]"
] | |
9da651265bf6bbff98fa17a37624bdedb3b084b0 | 6698b2d5ffeb6825f79834feac90e1021868fc9b | /src/main/java/com/faceit/irs/validation_xml/ValidationXmlApplication.java | 498d68891234561d4d9383637291f51049d4ef1a | [] | no_license | AlexanderSV91/ValidationXML | f248dc9d3e09f5f573bec441b60a8452bfb7e30e | 09d41deff2015bd210445a54e59362f5903d2114 | refs/heads/master | 2023-07-24T11:23:29.327146 | 2021-08-25T09:12:45 | 2021-08-25T09:12:45 | 354,870,255 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | package com.faceit.irs.validation_xml;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ValidationXmlApplication {
public static void main(String[] args) {
SpringApplication.run(ValidationXmlApplication.class, args);
}
}
| [
"[email protected]"
] | |
c958b41fd948aee61c7513fc12d592d82f330e19 | 7bbdf3ea46bfac622f7656f40a8e2ff050680002 | /src/com/company/ScannerFactory.java | f24d83b5828d33eebce15c6d0e7d8f913b446f32 | [] | no_license | larryngo97/Exam-Creator-Taker-Grader | 0e6b5aaf4393260405771ff5ef783fc94d83aa1d | e5b22bb1d3071444a3963ca206edbcda72382ade | refs/heads/master | 2020-03-14T21:27:52.408976 | 2018-05-02T22:35:25 | 2018-05-02T22:35:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 362 | java | package com.company;
import java.util.Scanner;
public class ScannerFactory {
private static Scanner keyboardScanner;
public static Scanner getKeyboardScanner()
{
if(keyboardScanner == null)
{
keyboardScanner = new Scanner(System.in);
return keyboardScanner;
}
return keyboardScanner;
}
}
| [
"[email protected]"
] | |
f26067e597528d32673cef7e3d4336bc68c06a63 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/24/24_dd19cb38c7586ac69792bf88bbfed0e31d1b063f/JidePopup/24_dd19cb38c7586ac69792bf88bbfed0e31d1b063f_JidePopup_s.java | 9116f9a6b2139ac831a0a41d32ba56fc2fd97532 | [] | 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 | 97,985 | java | /*
* @(#)JidePopup.java 2/24/2005
*
* Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
*/
package com.jidesoft.popup;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.PopupUI;
import com.jidesoft.plaf.UIDefaultsLookup;
import com.jidesoft.swing.*;
import com.jidesoft.utils.PortingUtils;
import com.jidesoft.utils.SecurityUtils;
import com.jidesoft.utils.SystemInfo;
import sun.awt.EmbeddedFrame;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleValue;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
/**
* <code>JidePopup</code> is a popup window which can be resized, dragged and autohide if time out.
* <p/>
* JidePopup uses JWindow as the container in order to show itself. By default, JidePopup is not
* focusable which means no component in the JidePopup will get focus. For example, if you put a
* JTextField in JidePopup and the JTextField becomes not editable, this is a result of
* non-focusable JWindow. So if you want components in JidePopup to be able to receive focus, you
* can either call setFocusable(true) or you can call {@link #setDefaultFocusComponent(java.awt.Component)}
* to set a child component as the default focus component.
*/
public class JidePopup extends JComponent implements Accessible, WindowConstants {
/**
* @see #getUIClassID
* @see #readObject
*/
private static final String uiClassID = "JidePopupUI";
/**
* The <code>JRootPane</code> instance that manages the content pane and optional menu bar for
* this Popup, as well as the glass pane.
*
* @see javax.swing.JRootPane
* @see javax.swing.RootPaneContainer
*/
private JRootPane rootPane;
/**
* If <code>true</code> then calls to <code>add</code> and <code>setLayout</code> cause an
* exception to be thrown.
*/
private boolean rootPaneCheckingEnabled = false;
/**
* Bound property name.
*/
public final static String CONTENT_PANE_PROPERTY = "contentPane";
/**
* Bound property name.
*/
public final static String MENU_BAR_PROPERTY = "JMenuBar";
/**
* Bound property name.
*/
public final static String LAYERED_PANE_PROPERTY = "layeredPane";
/**
* Bound property name.
*/
public final static String ROOT_PANE_PROPERTY = "rootPane";
/**
* Bound property name.
*/
public final static String GLASS_PANE_PROPERTY = "glassPane";
/**
* Bound property name.
*/
public final static String VISIBLE_PROPERTY = "visible";
public final static String TRANSIENT_PROPERTY = "transient";
/**
* Constrained property name indicated that this frame has
* selected status.
*/
/**
* Constrained property name indicating that the popup is attachable.
*/
public final static String ATTACHABLE_PROPERTY = "attachable";
private boolean _attachable = true;
/**
* Bound property name for gripper.
*/
public final static String MOVABLE_PROPERTY = "movable";
/**
* If the gripper should be shown. Gripper is something on divider to indicate it can be
* dragged.
*/
private boolean _movable = false;
/**
* Bound property name for if the popup is detached.
*/
public final static String DETACHED_PROPERTY = "detached";
protected boolean _detached;
protected ResizableWindow _window;
protected ResizablePanel _panel;
protected ResizableSupport _resizableSupport;
private ComponentAdapter _componentListener;
private WindowAdapter _windowListener;
private ComponentAdapter _ownerComponentListener;
private HierarchyListener _hierarchyListener;
/**
* Bound property name for resizable.
*/
public final static String RESIZABLE_PROPERTY = "resizable";
private boolean _resizable = true;
// /**
// * Bound property name for movable.
// */
// public final static String MOVABLE_PROPERTY = "movable";
//
// private boolean _movable;
/**
* Bound property name for owner.
*/
public final static String OWNER_PROPERTY = "owner";
private Component _owner;
private Border _popupBorder;
private boolean _transient = true;
private int _timeout = 0;
private Timer _timer;
private Component _defaultFocusComponent;
/**
* Hides the popup when the owner is moved.
*/
public static final int DO_NOTHING_ON_MOVED = -1;
/**
* Hides the popup when the owner is moved.
*/
public static final int HIDE_ON_MOVED = 0;
/**
* Moves the popup along with owner when the owner is moved.
*/
public static final int MOVE_ON_MOVED = 1;
private int _defaultMoveOperation = HIDE_ON_MOVED;
/**
* The distance between alert and screen border.
*/
public int DISTANCE_TO_SCREEN_BORDER = 10;
private List<Component> _excludedComponents;
private int _gripperLocation = SwingConstants.NORTH;
public static final String PROPERTY_GRIPPER_LOCATION = "gripperLocation";
private ComponentAdapter _popupResizeListener;
protected Dimension _previousSize;
protected Component _actualOwner;
protected Point _actualOwnerLocation;
/**
* Key used to indicate a light weight popup should be used.
*/
public static final int LIGHT_WEIGHT_POPUP = 0;
/*
* Key used to indicate a heavy weight Popup should be used.
*/
public static final int HEAVY_WEIGHT_POPUP = 2;
private int _popupType = HEAVY_WEIGHT_POPUP;
private ActionListener _escapeActionListener;
/**
* Creates a Popup.
*/
public JidePopup() {
_excludedComponents = new ArrayList<Component>();
setRootPane(createRootPane());
setLayout(new BorderLayout());
setRootPaneCheckingEnabled(true);
setFocusable(false);
updateUI();
}
/**
* Called by the constructor to set up the <code>JRootPane</code>.
*
* @return a new <code>JRootPane</code>
*
* @see javax.swing.JRootPane
*/
protected JRootPane createRootPane() {
JRootPane pane = new JRootPane();
// by default, the subclass BorderLayout cause memory leak if isPopupVolatile in AbstractComboBox.
pane.getContentPane().setLayout(new BorderLayout());
return pane;
}
/**
* Returns the look-and-feel object that renders this component.
*
* @return the <code>PopupUI</code> object that renders this component
*/
public PopupUI getUI() {
return (PopupUI) ui;
}
/**
* Sets the UI delegate for this <code>Popup</code>.
*
* @param ui the UI delegate
*/
public void setUI(PopupUI ui) {
boolean checkingEnabled = isRootPaneCheckingEnabled();
try {
setRootPaneCheckingEnabled(false);
super.setUI(ui);
}
finally {
setRootPaneCheckingEnabled(checkingEnabled);
}
}
/**
* Notification from the <code>UIManager</code> that the look and feel has changed. Replaces the
* current UI object with the latest version from the <code>UIManager</code>.
*
* @see javax.swing.JComponent#updateUI
*/
@Override
public void updateUI() {
if (UIDefaultsLookup.get(uiClassID) == null) {
LookAndFeelFactory.installJideExtension();
}
setUI((PopupUI) UIManager.getUI(this));
invalidate();
}
/**
* Returns the name of the look-and-feel class that renders this component.
*
* @return the string "PopupUI"
*
* @see javax.swing.JComponent#getUIClassID
* @see javax.swing.UIDefaults#getUI
*/
@Override
public String getUIClassID() {
return uiClassID;
}
/**
* Returns whether calls to <code>add</code> and <code>setLayout</code> cause an exception to be
* thrown.
*
* @return <code>true</code> if <code>add</code> and <code>setLayout</code> are checked
*
* @see #addImpl
* @see #setLayout
* @see #setRootPaneCheckingEnabled
*/
protected boolean isRootPaneCheckingEnabled() {
return rootPaneCheckingEnabled;
}
/**
* Determines whether calls to <code>add</code> and <code>setLayout</code> cause an exception to
* be thrown.
*
* @param enabled a boolean value, <code>true</code> if checking is to be enabled, which cause
* the exceptions to be thrown
*
* @see #addImpl
* @see #setLayout
* @see #isRootPaneCheckingEnabled
*/
protected void setRootPaneCheckingEnabled(boolean enabled) {
rootPaneCheckingEnabled = enabled;
}
/**
* Ensures that, by default, children cannot be added directly to this component. Instead,
* children must be added to its content pane. For example:
* <pre>
* thisComponent.getContentPane().add(child)
* </pre>
* An attempt to add to directly to this component will cause a runtime exception to be thrown.
* Subclasses can disable this behavior.
*
* @param comp the <code>Component</code> to be added
* @param constraints the object containing the constraints, if any
* @param index the index
*
* @throws Error if called with <code>isRootPaneChecking</code> <code>true</code>
* @see #setRootPaneCheckingEnabled
*/
@Override
protected void addImpl(Component comp, Object constraints, int index) {
if (isRootPaneCheckingEnabled()) {
getContentPane().add(comp, constraints, index);
}
else {
super.addImpl(comp, constraints, index);
}
}
/**
* Removes the specified component from this container.
*
* @param comp the component to be removed
*
* @see #add
*/
@Override
public void remove(Component comp) {
int oldCount = getComponentCount();
super.remove(comp);
if (oldCount == getComponentCount()) {
// Client mistake, but we need to handle it to avoid a
// common object leak in client applications.
getContentPane().remove(comp);
}
}
/**
* Ensures that, by default, the layout of this component cannot be set. Instead, the layout of
* its content pane should be set. For example:
* <pre>
* thisComponent.getContentPane().setLayout(new GridLayout(1,2))
* </pre>
* An attempt to set the layout of this component will cause an runtime exception to be thrown.
* Subclasses can disable this behavior.
*
* @param manager the <code>LayoutManager</code>
*
* @throws Error if called with <code>isRootPaneChecking</code> <code>true</code>
* @see #setRootPaneCheckingEnabled
*/
@Override
public void setLayout(LayoutManager manager) {
if (isRootPaneCheckingEnabled()) {
getContentPane().setLayout(manager);
}
else {
super.setLayout(manager);
}
}
//////////////////////////////////////////////////////////////////////////
/// Property Methods
//////////////////////////////////////////////////////////////////////////
/**
* Returns the current <code>JMenuBar</code> for this <code>Popup</code>, or <code>null</code>
* if no menu bar has been set.
*
* @return the <code>JMenuBar</code> used by this Popup.
*
* @see #setJMenuBar
*/
public JMenuBar getJMenuBar() {
return getRootPane().getJMenuBar();
}
/**
* Sets the <code>menuBar</code> property for this <code>Popup</code>.
*
* @param m the <code>JMenuBar</code> to use in this Popup.
*
* @see #getJMenuBar
*/
public void setJMenuBar(JMenuBar m) {
JMenuBar oldValue = getJMenuBar();
getRootPane().setJMenuBar(m);
firePropertyChange(MENU_BAR_PROPERTY, oldValue, m);
}
// implements javax.swing.RootPaneContainer
/**
* Returns the content pane for this Popup.
*
* @return the content pane
*/
public Container getContentPane() {
return getRootPane().getContentPane();
}
/**
* Sets this <code>Popup</code>'s <code>contentPane</code> property.
*
* @param c the content pane for this popup.
*
* @throws java.awt.IllegalComponentStateException
* (a runtime exception) if the content pane parameter is <code>null</code>
* @see javax.swing.RootPaneContainer#getContentPane
*/
public void setContentPane(Container c) {
Container oldValue = getContentPane();
getRootPane().setContentPane(c);
firePropertyChange(CONTENT_PANE_PROPERTY, oldValue, c);
}
/**
* Returns the layered pane for this popup.
*
* @return a <code>JLayeredPane</code> object
*
* @see javax.swing.RootPaneContainer#setLayeredPane
* @see javax.swing.RootPaneContainer#getLayeredPane
*/
public JLayeredPane getLayeredPane() {
return getRootPane().getLayeredPane();
}
/**
* Sets this <code>Popup</code>'s <code>layeredPane</code> property.
*
* @param layered the <code>JLayeredPane</code> for this popup
*
* @throws java.awt.IllegalComponentStateException
* (a runtime exception) if the layered pane parameter is <code>null</code>
* @see javax.swing.RootPaneContainer#setLayeredPane
*/
public void setLayeredPane(JLayeredPane layered) {
JLayeredPane oldValue = getLayeredPane();
getRootPane().setLayeredPane(layered);
firePropertyChange(LAYERED_PANE_PROPERTY, oldValue, layered);
}
/**
* Returns the glass pane for this popup.
*
* @return the glass pane
*
* @see javax.swing.RootPaneContainer#setGlassPane
*/
public Component getGlassPane() {
return getRootPane().getGlassPane();
}
/**
* Sets this <code>Popup</code>'s <code>glassPane</code> property.
*
* @param glass the glass pane for this popup
*
* @see javax.swing.RootPaneContainer#getGlassPane
*/
public void setGlassPane(Component glass) {
Component oldValue = getGlassPane();
getRootPane().setGlassPane(glass);
firePropertyChange(GLASS_PANE_PROPERTY, oldValue, glass);
}
/**
* Returns the <code>rootPane</code> object for this popup.
*
* @return the <code>rootPane</code> property
*
* @see javax.swing.RootPaneContainer#getRootPane
*/
@Override
public JRootPane getRootPane() {
return rootPane;
}
/**
* Sets the <code>rootPane</code> property for this <code>Popup</code>. This method is called by
* the constructor.
*
* @param root the new <code>JRootPane</code> object
*/
protected void setRootPane(JRootPane root) {
if (rootPane != null) {
rootPane.removeAll();
remove(rootPane);
}
JRootPane oldValue = getRootPane();
rootPane = root;
if (rootPane != null) {
boolean checkingEnabled = isRootPaneCheckingEnabled();
try {
setRootPaneCheckingEnabled(false);
add(rootPane, BorderLayout.CENTER);
}
finally {
setRootPaneCheckingEnabled(checkingEnabled);
}
}
firePropertyChange(ROOT_PANE_PROPERTY, oldValue, root);
}
/**
* Makes the component visible or invisible. Overrides <code>Component.setVisible</code>.
*
* @param visible true to make the component visible; false to make it invisible
*/
@Override
public void setVisible(boolean visible) {
boolean old = isVisible();
if (visible != old) {
super.setVisible(visible);
firePropertyChange(VISIBLE_PROPERTY, old, visible);
}
}
/**
* Gets the <code>AccessibleContext</code> associated with this <code>Popup</code>. For popups,
* the <code>AccessibleContext</code> takes the form of an <code>AccessiblePopup</code> object.
* A new <code>AccessiblePopup</code> instance is created if necessary.
*
* @return an <code>AccessiblePopup</code> that serves as the <code>AccessibleContext</code> of
* this <code>Popup</code>
*
* @see com.jidesoft.popup.JidePopup.AccessiblePopup
*/
@Override
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessiblePopup();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the <code>Popup</code> class. It provides an
* implementation of the Java Accessibility API appropriate to popup user-interface elements.
*/
protected class AccessiblePopup extends AccessibleJComponent
implements AccessibleValue {
/**
* Get the accessible name of this object.
*
* @return the localized name of the object -- can be <code>null</code> if this object does
* not have a name
*
* @see #setAccessibleName
*/
@Override
public String getAccessibleName() {
if (accessibleName != null) {
return accessibleName;
}
else {
return getName();
}
}
/**
* Get the role of this object.
*
* @return an instance of AccessibleRole describing the role of the object
*
* @see javax.accessibility.AccessibleRole
*/
@Override
public AccessibleRole getAccessibleRole() {
return AccessibleRole.SWING_COMPONENT; // use a generic one since there is no specific one to choose
}
/**
* Gets the AccessibleValue associated with this object. In the implementation of the Java
* Accessibility API for this class, returns this object, which is responsible for
* implementing the <code>AccessibleValue</code> interface on behalf of itself.
*
* @return this object
*/
@Override
public AccessibleValue getAccessibleValue() {
return this;
}
//
// AccessibleValue methods
//
/**
* Get the value of this object as a Number.
*
* @return value of the object -- can be <code>null</code> if this object does not have a
* value
*/
public Number getCurrentAccessibleValue() {
if (isVisible()) {
return 1;
}
else {
return 0;
}
}
/**
* Set the value of this object as a Number.
*
* @return <code>true</code> if the value was set
*/
public boolean setCurrentAccessibleValue(Number n) {
if (n instanceof Integer) {
if (n.intValue() == 0)
setVisible(true);
else
setVisible(false);
return true;
}
else {
return false;
}
}
/**
* Get the minimum value of this object as a Number.
*
* @return Minimum value of the object; <code>null</code> if this object does not have a
* minimum value
*/
public Number getMinimumAccessibleValue() {
return Integer.MIN_VALUE;
}
/**
* Get the maximum value of this object as a Number.
*
* @return Maximum value of the object; <code>null</code> if this object does not have a
* maximum value
*/
public Number getMaximumAccessibleValue() {
return Integer.MAX_VALUE;
}
}
/**
* Shows the popup. By default, it will show right below the owner.
*/
public void showPopup() {
//David: To account for a popup within a popup, let the caller specify an owner
// different from the RootPaneContainer(Applet) or ContentContainer.
// showPopup(new Insets(0, 0, 0, 0));
showPopup(new Insets(0, 0, 0, 0), null);
}
/**
* Shows the popup. By default, it will show right below the owner after considering the
* insets.
*
* @param owner the popup window's owner; if unspecified, it will default to the
* RootPaneContainer(Applet) or ContentContainer
*/
public void showPopup(Component owner) {
showPopup(new Insets(0, 0, 0, 0), owner);
}
/**
* Shows the popup. By default, it will show right below the owner after considering the
* insets.
*
* @param insets the popup's insets RootPaneContainer(Applet) or ContentContainer
*/
public void showPopup(Insets insets) {
showPopup(insets, null);
}
protected Insets _insets = null;
/**
* Shows the popup. By default, it will show right below the owner after considering the insets.
* Please note, if the owner is not displayed (isShowing returns false), the popup will not be
* displayed either.
*
* @param insets the popup's insets
* @param owner the popup window's owner; if unspecified, it will default to the
* RootPaneContainer(Applet) or ContentContainer
*/
public void showPopup(Insets insets, Component owner) {
_insets = insets;
Component actualOwner = (owner != null) ? owner : getOwner();
if (actualOwner != null && actualOwner.isShowing()) {
Point point = actualOwner.getLocationOnScreen();
internalShowPopup(point.x, point.y, actualOwner);
}
else {
showPopup(SwingConstants.CENTER);
}
}
/**
* Calculates the popup location.
*
* @param point owner is top-left coordinate relative to screen.
* @param size the size of the popup window.
* @param owner the owner
*
* @return new popup location. By default, it will return the coordinate of the bottom-left
* corner of owner.
*/
protected Point getPopupLocation(Point point, Dimension size, Component owner) {
Component actualOwner = (owner != null) ? owner : getOwner();
Dimension ownerSize = actualOwner != null ? actualOwner.getSize() : new Dimension(0, 0);
Dimension screenSize = PortingUtils.getScreenSize(owner);
if (size.width == 0) {
size = this.getPreferredSize();
}
Point p = new Point(point.x + _insets.left, point.y + ownerSize.height - _insets.bottom);
int left = p.x + size.width;
int bottom = p.y + size.height;
if (left > screenSize.width) {
p.x -= left - screenSize.width; // move left so that the whole popup can fit in
}
if (bottom > screenSize.height) {
p.y = point.y + _insets.top - size.height; // flip to upward
if (isResizable()) {
setupResizeCorner(Resizable.UPPER_RIGHT);
}
}
else {
if (isResizable()) {
setupResizeCorner(Resizable.LOWER_RIGHT);
}
}
return p;
}
/**
* Setup Resizable's ResizeCorner.
*
* @param corner the corner.
*/
public void setupResizeCorner(int corner) {
switch (corner) {
case Resizable.UPPER_RIGHT:
if (_resizableSupport != null) {
_resizableSupport.getResizable().setResizableCorners(Resizable.UPPER_RIGHT);
JideSwingUtilities.setRecursively(this, new JideSwingUtilities.Handler() {
public boolean condition(Component c) {
return c instanceof JideScrollPane;
}
public void action(Component c) {
Resizable.ResizeCorner corner = new Resizable.ResizeCorner(Resizable.UPPER_RIGHT);
corner.addMouseListener(_resizableSupport.getResizable().getMouseInputAdapter());
corner.addMouseMotionListener(_resizableSupport.getResizable().getMouseInputAdapter());
((JideScrollPane) c).setScrollBarCorner(JideScrollPane.VERTICAL_TOP, corner);
((JideScrollPane) c).setScrollBarCorner(JideScrollPane.VERTICAL_BOTTOM, null);
}
public void postAction(Component c) {
}
});
}
break;
case Resizable.LOWER_RIGHT:
if (_resizableSupport != null) {
_resizableSupport.getResizable().setResizableCorners(Resizable.LOWER_RIGHT);
JideSwingUtilities.setRecursively(this, new JideSwingUtilities.Handler() {
public boolean condition(Component c) {
return c instanceof JideScrollPane;
}
public void action(Component c) {
Resizable.ResizeCorner corner = new Resizable.ResizeCorner(Resizable.LOWER_RIGHT);
corner.addMouseListener(_resizableSupport.getResizable().getMouseInputAdapter());
corner.addMouseMotionListener(_resizableSupport.getResizable().getMouseInputAdapter());
((JideScrollPane) c).setScrollBarCorner(JideScrollPane.VERTICAL_BOTTOM, corner);
((JideScrollPane) c).setScrollBarCorner(JideScrollPane.VERTICAL_TOP, null);
}
public void postAction(Component c) {
}
});
}
break;
default:
if (_resizableSupport != null) {
_resizableSupport.getResizable().setResizableCorners(corner);
}
break;
}
}
public static Component getTopLevelAncestor(Component component) {
if (component == null) {
return null;
}
for (Component p = component; p != null; p = p.getParent()) {
if (p instanceof Window || p instanceof Applet) {
return p;
}
}
return null;
}
/**
* Shows the popup at the specified location relative to the screen. The valid locations are:
* <ul> <li>{@link SwingConstants#CENTER} <li>{@link SwingConstants#SOUTH} <li>{@link
* SwingConstants#NORTH} <li>{@link SwingConstants#WEST} <li>{@link SwingConstants#EAST}
* <li>{@link SwingConstants#NORTH_EAST} <li>{@link SwingConstants#NORTH_WEST} <li>{@link
* SwingConstants#SOUTH_EAST} <li>{@link SwingConstants#SOUTH_WEST} </ul> The actual location
* will be based on the main screen bounds. Say if the location is SwingConstants.SOUTH_EAST,
* the popup will appear at the south west corner of main screen with 10 pixels to the border.
* The 10 pixel is the default value. You can change it by setting {@link
* #DISTANCE_TO_SCREEN_BORDER}.
*
* @param location the new location.
*/
public void showPopup(int location) {
showPopup(location, null);
}
/**
* Shows the popup at the specified location relative to the owner. The valid locations are:
* <ul> <li>{@link SwingConstants#CENTER} <li>{@link SwingConstants#SOUTH} <li>{@link
* SwingConstants#NORTH} <li>{@link SwingConstants#WEST} <li>{@link SwingConstants#EAST}
* <li>{@link SwingConstants#NORTH_EAST} <li>{@link SwingConstants#NORTH_WEST} <li>{@link
* SwingConstants#SOUTH_EAST} <li>{@link SwingConstants#SOUTH_WEST} </ul> The actual location
* will be based on the owner's bounds. Say if the location is SwingConstants.SOUTH_EAST, the
* popup will appear at the south west corner of owner with 10 pixels to the border. The 10
* pixel is the default value. You can change it by setting {@link #DISTANCE_TO_SCREEN_BORDER}.
*
* @param location the new location
* @param owner the popup window's owner; if unspecified, it will default to the
* RootPaneContainer(Applet) or ContentContainer
*/
public void showPopup(int location, Component owner) {
setDetached(true);
Rectangle screenDim = getDisplayScreenBounds(owner);
// Get the bounds of the splash window
Dimension actualSize = getSize();
Dimension size = actualSize.width == 0 ? getPreferredSize() : actualSize;
Point displayLocation = getDisplayStartLocation(screenDim, size, location);
internalShowPopup(displayLocation.x, displayLocation.y, owner);
}
protected Point getDisplayStartLocation(Rectangle screenDim, Dimension size, int location) {
switch (location) {
case SwingConstants.CENTER:
return new Point(screenDim.x + (screenDim.width - size.width) / 2,
screenDim.y + (screenDim.height - size.height) / 2);
case SwingConstants.SOUTH:
return new Point(screenDim.x + (screenDim.width - size.width) / 2,
screenDim.y + screenDim.height - size.height - DISTANCE_TO_SCREEN_BORDER);
case SwingConstants.NORTH:
return new Point(screenDim.x + (screenDim.width - size.width) / 2,
screenDim.y + DISTANCE_TO_SCREEN_BORDER);
case SwingConstants.EAST:
return new Point(screenDim.x + screenDim.width - size.width - DISTANCE_TO_SCREEN_BORDER,
screenDim.y + (screenDim.height - size.height) / 2);
case SwingConstants.WEST:
return new Point(screenDim.x + DISTANCE_TO_SCREEN_BORDER,
screenDim.y + (screenDim.height - size.height) / 2);
case SwingConstants.SOUTH_WEST:
return new Point(screenDim.x + DISTANCE_TO_SCREEN_BORDER,
screenDim.y + screenDim.height - size.height - DISTANCE_TO_SCREEN_BORDER);
case SwingConstants.NORTH_EAST:
return new Point(screenDim.x + screenDim.width - size.width - DISTANCE_TO_SCREEN_BORDER,
screenDim.y + DISTANCE_TO_SCREEN_BORDER);
case SwingConstants.NORTH_WEST:
return new Point(screenDim.x + DISTANCE_TO_SCREEN_BORDER,
screenDim.y + DISTANCE_TO_SCREEN_BORDER);
case SwingConstants.SOUTH_EAST:
default:
return new Point(screenDim.x + screenDim.width - size.width - DISTANCE_TO_SCREEN_BORDER,
screenDim.y + screenDim.height - size.height - DISTANCE_TO_SCREEN_BORDER);
}
}
protected Rectangle getDisplayScreenBounds(Component owner) {
Rectangle screenDim;
if (owner != null && owner.isShowing()) {
screenDim = owner.getBounds();
Point p = owner.getLocationOnScreen();
screenDim.x = p.x;
screenDim.y = p.y;
}
else {
screenDim = PortingUtils.getLocalScreenBounds();
}
return screenDim;
}
public void packPopup() {
if (_popupType == LIGHT_WEIGHT_POPUP) {
if (_panel == null) {
return;
}
_panel.setSize(_panel.getPreferredSize());
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if (_window == null) {
return;
}
_window.pack();
}
}
//David: To account for a popup within a popup, let the caller specify an owner
// different from the RootPaneContainer(Applet) or ContentContainer.
protected void internalShowPopup(int x, int y) {
internalShowPopup(x, y, null);
}
protected void internalShowPopup(int x, int y, Component owner) {
_actualOwner = owner != null ? owner : getOwner();
if (_actualOwner != null) {
try {
_actualOwnerLocation = _actualOwner.getLocationOnScreen();
}
catch (IllegalComponentStateException e) {
return;
}
}
createWindow(_actualOwner, x, y);
showPopupImmediately();
}
protected void createWindow(Component owner, int x, int y) {
if (_popupType == LIGHT_WEIGHT_POPUP) {
if (_panel == null) {
_panel = createLightweightPopupContainer(owner);
_resizableSupport = _panel;
installListeners();
installBorder();
}
if (_previousSize != null) {
_panel.setSize(_previousSize);
_previousSize = null;
}
else {
packPopup();
}
if (_insets != null) {
Point p = getPopupLocation(new Point(x, y), _panel.getSize(), owner);
x = p.x;
y = p.y;
}
JRootPane rootPane = JideSwingUtilities.getOutermostRootPane(owner);
JLayeredPane layeredPane;
if (rootPane != null)
layeredPane = rootPane.getLayeredPane();
else {
return; // has to have layer pane
}
Point p = new Point(x, y);
SwingUtilities.convertPointFromScreen(p, layeredPane);
layeredPane.add(_panel, JLayeredPane.PALETTE_LAYER);
if (SystemInfo.isJdk15Above()) {
layeredPane.setComponentZOrder(_panel, 0);
}
_panel.setLocation(p.x, p.y);
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if (_window == null) {
//noinspection deprecation
_window = createPopupContainer(owner);
_resizableSupport = _window;
installListeners();
installBorder();
}
if (_previousSize != null) {
_window.setSize(_previousSize);
_previousSize = null;
}
else {
packPopup();
}
if (_insets != null) {
Point p = getPopupLocation(new Point(x, y), _window.getSize(), owner);
x = p.x;
y = p.y;
}
_window.setLocation(x, y);
}
}
/**
* Shows the popup at the specified x and y coordinates.
*
* @param x the x position. It is screen position.
* @param y the y position. It is screen position.
*/
public void showPopup(int x, int y) {
showPopup(x, y, null);
}
/**
* Shows the popup at the specified x and y coordinates.
*
* @param x the x position. It is screen position.
* @param y the y position. It is screen position.
* @param owner the popup window's owner; if unspecified, it will default to the
* RootPaneContainer(Applet) or ContentContainer
*/
public void showPopup(int x, int y, Component owner) {
internalShowPopup(x, y, owner);
}
/**
* @deprecated use {@link #createHeavyweightPopupContainer(java.awt.Component)} instead.
*/
protected ResizableWindow createPopupContainer() {
//noinspection deprecation
return createPopupContainer(null);
}
protected static Frame getFrame(Component c) {
Component w = c;
while (!(w instanceof Frame) && (w != null)) {
w = w.getParent();
}
return (Frame) w;
}
/**
* @param owner the owner for this popup container. It will be used to find the top level
* ancestor and use it as the parent for this popup window.
*
* @return a ResizableWindow.
*
* @deprecated use {@link #createHeavyweightPopupContainer(java.awt.Component)} instead.
*/
protected ResizableWindow createPopupContainer(Component owner) {
return createHeavyweightPopupContainer(owner);
}
/**
* @param owner the owner for this popup container. It will be used to find the top level
* ancestor and use it as the parent for this popup window.
*
* @return a ResizableWindow.
*/
protected ResizableWindow createHeavyweightPopupContainer(Component owner) {
ResizableWindow container;
Component topLevelAncestor = getTopLevelAncestor(owner);
if (topLevelAncestor instanceof Frame) {
container = new ResizableWindow((Frame) topLevelAncestor);
}
else if (topLevelAncestor instanceof Window) {
container = new ResizableWindow((Window) topLevelAncestor);
}
else {
Frame frame = getFrame(owner);
container = new ResizableWindow(frame);
}
((Component) container).setName("JidePopup");
container.getContentPane().add(this);
return container;
}
/**
* Creates lightweight container for the popup.
*
* @param owner the owner for this popup container. This parameter is not used in this method.
* It was there mainly because the corresponding {@link #createHeavyweightPopupContainer(java.awt.Component)}
* has this parameter.
*
* @return a ResizablePanel
*/
protected ResizablePanel createLightweightPopupContainer(Component owner) {
ResizablePanel panel = new ResizablePanel() {
@Override
protected Resizable createResizable() {
return new Resizable(this) {
@Override
public void resizing(int resizeCorner, int newX, int newY, int newW, int newH) {
setBounds(newX, newY, newW, newH);
}
};
}
};
panel.setVisible(false);
panel.setOpaque(false);
panel.setLayout(new BorderLayout());
panel.add(this);
return panel;
}
protected void installListeners() {
//David: Adding the MouseEventHandler synchronously causes a strange
// initialization sequence if the popup owner is a tree/table editor:
//
// - The editor gets moved to its initial location based on the cell location,
// generating a COMPONENT_MOVED ComponentEvent.
// - You add the MouseEventHandler, which includes a ComponentEvent listener on
// the owner's hierarcy, including the editor.
// - ComponentEvent is asynchronous. The ComponentEvent generated from moving
// the editor to its initial position was placed on the event queue. So the
// ComponentEvent gets handled by the MouseEventHandler's ComponentEvent
// listener, even though it happened before the listener was added.
//
// I fixed it by calling addMouseEventHandler asynchronously, guaranteeing that
// any previously-generated event it may listen for has been removed from the
// event queue before the listener is added.
//
// This causes a couple of minor problems:
//
// - It is possible that hidePopupImmediately can be called synchronously before
// the asynchronous call to addMouseEventHandler is executed. This can cause
// NPEs because the listener handler methods dereference _window, which is set
// to null in hidePopupImmediately. So I added null checks on _window in the
// listener handler methods.
//
// - The removeMouseEventHandler method is called from hidePopupImmediately.
// That means it could be called before addMouseEventHandler is executed
// asynchronously; that would result in the listener not getting removed. So
// I changed the removeMouseEventHandler to an asynchronous call, as well.
//
// This issue appeared in the 1.8.3 release because you changed the
// COMPONENT_MOVED handler to hide the popup instead of moving it. Since you
// made this an option in the 1.8.4 release, all of this asynchronous code is
// needed.
//
// addMouseEventHandler()
SwingUtilities.invokeLater(new Runnable() {
public void run() {
addMouseEventHandler();
}
});
_componentListener = new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
hidePopup();
}
};
_escapeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
hidePopupImmediately(true);
Component owner = getActualOwner();
if (owner != null) {
owner.requestFocus();
}
}
};
registerKeyboardAction(_escapeActionListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
if (_popupType == HEAVY_WEIGHT_POPUP) {
_window.addComponentListener(_componentListener);
_windowListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
hidePopup();
}
};
_window.addWindowListener(_windowListener);
}
Component owner = getActualOwner();
if (owner != null) {
_ownerComponentListener = new ComponentAdapter() {
@Override
public void componentHidden(ComponentEvent e) {
ancestorHidden();
}
@Override
public void componentMoved(ComponentEvent e) {
if (_actualOwnerLocation == null || _actualOwner == null || !_actualOwner.getLocationOnScreen().equals(_actualOwnerLocation)) {
ancestorMoved();
}
}
};
owner.addComponentListener(_ownerComponentListener);
_hierarchyListener = new HierarchyListener() {
public void hierarchyChanged(HierarchyEvent e) {
ancestorHidden();
}
};
owner.addHierarchyListener(_hierarchyListener);
}
_popupResizeListener = new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
removeComponentListener(_popupResizeListener);
contentResized();
addComponentListener(_popupResizeListener);
}
};
addComponentListener(_popupResizeListener);
}
protected void contentResized() {
// pack is good enough to replace all code above
packPopup();
}
protected void installBorder() {
if (getPopupBorder() != null) {
if (isResizable()) {
_resizableSupport.getResizable().setResizableCorners(Resizable.ALL);
}
else {
_resizableSupport.getResizable().setResizableCorners(Resizable.NONE);
}
_resizableSupport.setBorder(getPopupBorder());
}
else {
if (isDetached()) {
if (isResizable()) {
_resizableSupport.getResizable().setResizableCorners(Resizable.ALL);
}
else {
_resizableSupport.getResizable().setResizableCorners(Resizable.NONE);
}
_resizableSupport.setBorder(UIDefaultsLookup.getBorder("Resizable.resizeBorder"));
}
else {
if (isResizable()) {
_resizableSupport.getResizable().setResizableCorners(Resizable.RIGHT | Resizable.LOWER | Resizable.LOWER_RIGHT);
}
else {
_resizableSupport.getResizable().setResizableCorners(Resizable.NONE);
}
_resizableSupport.setBorder(UIDefaultsLookup.getBorder("PopupMenu.border"));
}
}
}
protected void showPopupImmediately() {
if (_popupType == LIGHT_WEIGHT_POPUP) {
if (_panel == null) {
return;
}
firePopupMenuWillBecomeVisible();
if (!_panel.isVisible()) {
packPopup();
_panel.setVisible(true);
}
firePropertyChange("visible", Boolean.FALSE, Boolean.TRUE);
if (isFocusable() || getDefaultFocusComponent() != null) {
// only allow window to have focus when there is a default focus component.
if (getDefaultFocusComponent() != null) {
Runnable runnable = new Runnable() {
public void run() {
getDefaultFocusComponent().requestFocus();
}
};
SwingUtilities.invokeLater(runnable);
}
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if (_window == null) {
return;
}
firePopupMenuWillBecomeVisible();
// only when the focus cycle root is true, the component in JidePopup won't request focus automatically.
if (!isFocusable() && getDefaultFocusComponent() == null) {
_window.setFocusableWindowState(false);
}
else {
setFocusCycleRoot(true);
}
if (!_window.isVisible()) {
_window.pack();
_window.setVisible(true);
}
firePropertyChange("visible", Boolean.FALSE, Boolean.TRUE);
if (isFocusable() || getDefaultFocusComponent() != null) {
// only allow window to have focus when there is a default focus component.
_window.setFocusable(true);
if (getDefaultFocusComponent() != null) {
Runnable runnable = new Runnable() {
public void run() {
getDefaultFocusComponent().requestFocus();
}
};
SwingUtilities.invokeLater(runnable);
}
}
}
if (getTimeout() != 0) {
startTimeoutTimer();
}
}
protected void movePopup() {
if (isPopupVisible()) {
if (!isDetached() && _actualOwner != null) {
if (_insets != null) {
showPopup(_insets, _actualOwner);
}
else if (_actualOwnerLocation != null) {
Point newLocation = _actualOwner.getLocationOnScreen();
Point p = null;
if (_popupType == LIGHT_WEIGHT_POPUP) {
p = _panel.getLocationOnScreen();
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
p = _window.getLocationOnScreen();
}
if (p != null) {
p.x += newLocation.x - _actualOwnerLocation.x;
p.y += newLocation.y - _actualOwnerLocation.y;
showPopup(p.x, p.y, _actualOwner);
}
}
}
}
}
private boolean _isDragging = false;
/**
* Mouse location related the frame it drags.
*/
private double _relativeX,
_relativeY;
private Point _startPoint;
private Window _currentWindow;
private JPanel _currentPanel;
protected void endDragging() {
_isDragging = false;
if (_popupType == LIGHT_WEIGHT_POPUP) {
_currentPanel = null;
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if (_currentWindow instanceof JWindow && ((JWindow) _currentWindow).getGlassPane() != null) {
((JWindow) _currentWindow).getGlassPane().setVisible(false);
((JWindow) _currentWindow).getGlassPane().setCursor(Cursor.getDefaultCursor());
}
else
if (_currentWindow instanceof JDialog && ((JDialog) _currentWindow).getGlassPane() != null) {
((JDialog) _currentWindow).getGlassPane().setVisible(false);
((JDialog) _currentWindow).getGlassPane().setCursor(Cursor.getDefaultCursor());
}
_currentWindow = null;
}
_relativeX = 0;
_relativeY = 0;
}
protected void beginDragging(JComponent f, int mouseX, int mouseY, double relativeX, double relativeY) {
_relativeX = relativeX;
_relativeY = relativeY;
Component owner = getActualOwner();
if (_popupType == LIGHT_WEIGHT_POPUP) {
_currentPanel = _panel;
_isDragging = true;
if (isDetached() && owner != null) {
_startPoint = owner.getLocationOnScreen();
_startPoint.y += owner.getHeight();
}
else {
_startPoint = _currentPanel.getLocationOnScreen();
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if (f.getTopLevelAncestor() instanceof JWindow)
_currentWindow = (JWindow) f.getTopLevelAncestor();
if (f.getTopLevelAncestor() instanceof JDialog)
_currentWindow = (JDialog) f.getTopLevelAncestor();
if (_currentWindow instanceof JWindow && ((JWindow) _currentWindow).getGlassPane() != null) {
((JWindow) _currentWindow).getGlassPane().setVisible(true);
((JWindow) _currentWindow).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
else
if (_currentWindow instanceof JDialog && ((JDialog) _currentWindow).getGlassPane() != null) {
((JDialog) _currentWindow).getGlassPane().setVisible(true);
((JDialog) _currentWindow).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
_isDragging = true;
if (isDetached() && owner != null) {
_startPoint = owner.getLocationOnScreen();
_startPoint.y += owner.getHeight();
}
else {
_startPoint = _currentWindow.getLocationOnScreen();
}
}
}
protected boolean isDragging() {
return _isDragging;
}
static void convertPointToScreen(Point p, Component c, boolean startInFloat) {
int x, y;
do {
if (c instanceof JComponent) {
x = c.getX();
y = c.getY();
}
else
if (c instanceof java.applet.Applet || (startInFloat ? c instanceof Window : c instanceof JFrame)) {
try {
Point pp = c.getLocationOnScreen();
x = pp.x;
y = pp.y;
}
catch (IllegalComponentStateException icse) {
x = c.getX();
y = c.getY();
}
}
else {
x = c.getX();
y = c.getY();
}
p.x += x;
p.y += y;
if ((startInFloat ? c instanceof Window : c instanceof JFrame) || c instanceof java.applet.Applet)
break;
c = c.getParent();
}
while (c != null);
}
protected void drag(JComponent f, int newX, int newY, int mouseModifiers) {
if (_popupType == LIGHT_WEIGHT_POPUP) {
int x = newX - (int) (_currentPanel.getWidth() * _relativeX);
int y = newY - (int) (_currentPanel.getHeight() * _relativeY);
Rectangle bounds = new Rectangle(x, y, _currentPanel.getWidth(), _currentPanel.getHeight());
Rectangle screenBounds = PortingUtils.getScreenBounds(_currentPanel);
if (bounds.y + bounds.height > screenBounds.y + screenBounds.height) {
bounds.y = screenBounds.y + screenBounds.height - bounds.height;
}
if (bounds.y < screenBounds.y) {
bounds.y = screenBounds.y;
}
if (isAttachable() && isWithinAroundArea(new Point(x, y), _startPoint)) {
Point p = new Point(_startPoint);
SwingUtilities.convertPointFromScreen(p, _currentPanel.getParent());
_currentPanel.setLocation(p);
setDetached(false);
}
else {
Point p = new Point(x, y);
SwingUtilities.convertPointFromScreen(p, _currentPanel.getParent());
_currentPanel.setLocation(p);
setDetached(true);
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
int x = newX - (int) (_currentWindow.getWidth() * _relativeX);
int y = newY - (int) (_currentWindow.getHeight() * _relativeY);
Rectangle bounds = new Rectangle(x, y, _currentWindow.getWidth(), _currentWindow.getHeight());
Rectangle screenBounds = PortingUtils.getScreenBounds(_currentWindow);
if (bounds.y + bounds.height > screenBounds.y + screenBounds.height) {
bounds.y = screenBounds.y + screenBounds.height - bounds.height;
}
if (bounds.y < screenBounds.y) {
bounds.y = screenBounds.y;
}
if (isAttachable() && isWithinAroundArea(new Point(x, y), _startPoint)) {
_currentWindow.setLocation(_startPoint);
setDetached(false);
}
else {
_currentWindow.setLocation(x, y);
setDetached(true);
}
}
}
final int AROUND_SIZE = 10;
boolean isWithinAroundArea(Point p, Point newPoint) {
Rectangle rect = new Rectangle(p.x - AROUND_SIZE, p.y - AROUND_SIZE, p.x + AROUND_SIZE, p.y + AROUND_SIZE);
return rect.contains(newPoint);
}
static boolean isAncestorOf(Component component, Object ancestor) {
if (component == null) {
return false;
}
for (Component p = component; p != null; p = p.getParent()) {
if (p == ancestor) {
return true;
}
}
return false;
}
// private AWTEventListener _awtEventListener = new AWTEventListener() {
// public void eventDispatched(AWTEvent event) {
// if (event instanceof MouseEvent) {
// if (event.getID() == MouseEvent.MOUSE_PRESSED) {
// MouseEvent e = (MouseEvent) event;
// Object source = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
// if (!isAncestorOf((Container) source, JidePopup.this.getTopLevelAncestor())) { // todo: add a flag to not hidepopup in some cases
// hidePopup();
// }
// else {
// Point point = SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), JidePopup.this);
//
// Rectangle startingBounds = JidePopup.this.getTopLevelAncestor().getBounds();
// _relativeX = (double) point.x / startingBounds.width;
// _relativeY = (double) point.y / startingBounds.height;
//
// Point screenPoint = new Point(e.getX(), e.getY());
// JidePopup.convertPointToScreen(screenPoint, (Component) e.getSource(), true);
//
// // drag on gripper
// if (source == JidePopup.this.getUI().getGripper()) {
// beginDragging(JidePopup.this, screenPoint.x, screenPoint.y, _relativeX, _relativeY);
// e.consume();
// }
// }
// }
// else if (event.getID() == MouseEvent.MOUSE_DRAGGED) {
// if (isDragging()) {
// MouseEvent e = (MouseEvent) event;
// Point screenPoint = e.getPoint();
// convertPointToScreen(screenPoint, ((Component) e.getSource()), true);
// drag(null, screenPoint.x, screenPoint.y, e.getModifiersEx());
// e.consume();
// }
// }
// else if (event.getID() == MouseEvent.MOUSE_RELEASED) {
// if (isDragging()) {
// MouseEvent e = (MouseEvent) event;
// endDragging();
// e.consume();
// }
// }
// else if (event.getID() == MouseEvent.MOUSE_ENTERED) {
// if (_window.isAncestorOf(((Component) event.getSource())) && getTimeout() != 0) {
// stopTimeoutTimer();
// }
// }
// else if (event.getID() == MouseEvent.MOUSE_EXITED) {
// if (_window.isAncestorOf(((Component) event.getSource())) && getTimeout() != 0) {
// startTimeoutTimer();
// }
// }
// }
// else if (event instanceof WindowEvent) {
// WindowEvent e = (WindowEvent) event;
// if (e.getSource() != JidePopup.this.getTopLevelAncestor() && isAncestorOf(getOwner(), e.getWindow())) {
// if (e.getID() == WindowEvent.WINDOW_CLOSING || e.getID() == WindowEvent.WINDOW_ICONIFIED) {
// hidePopup();
// }
// }
// }
// else if (event instanceof ComponentEvent) {
// ComponentEvent e = (ComponentEvent) event;
// if (e.getID() == ComponentEvent.COMPONENT_HIDDEN && isAncestorOf(getOwner(), e.getSource())) {
// hidePopup();
// }
// else if (e.getID() == ComponentEvent.COMPONENT_MOVED && isAncestorOf(getOwner(), e.getSource())) {
// movePopup();
// }
// }
// }
// };
private AWTEventListener _awtEventListener;
protected void handleMousePressed(MouseEvent e) {
Component c = e.getComponent();
if (c == null) {
return;
}
Component component = SwingUtilities.getDeepestComponentAt(c, e.getX(), e.getY());
if (!isClickOnPopup(e)) {
if (isExcludedComponent(component)) {
return;
}
ancestorHidden();
}
else if (isPopupVisible()) {
Point point = SwingUtilities.convertPoint(component, e.getPoint(), this);
Rectangle startingBounds = null;
if (_popupType == LIGHT_WEIGHT_POPUP) {
startingBounds = _panel.getBounds();
Container parent = _panel.getParent();
if (SystemInfo.isJdk15Above()) {
if (parent.getComponentZOrder(_panel) != 0) {
parent.setComponentZOrder(_panel, 0);
parent.repaint();
}
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
startingBounds = _window.getBounds();
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow() != _window) {
_window.toFront();
}
}
if (startingBounds != null) {
_relativeX = (double) point.x / startingBounds.width;
_relativeY = (double) point.y / startingBounds.height;
Point screenPoint = new Point(e.getX(), e.getY());
convertPointToScreen(screenPoint, component, true);
// drag on gripper
if (isAncestorOf(component, getUI().getGripper())) {
beginDragging(this, screenPoint.x, screenPoint.y, _relativeX, _relativeY);
e.consume();
}
}
}
}
protected void handleMouseReleased(MouseEvent e) {
if (isDragging()) {
endDragging();
e.consume();
}
}
protected void handleMouseDragged(MouseEvent e) {
if (isDragging()) {
Point screenPoint = e.getPoint();
convertPointToScreen(screenPoint, ((Component) e.getSource()), true);
drag(null, screenPoint.x, screenPoint.y, e.getModifiersEx());
e.consume();
}
}
protected void handleMouseEntered(MouseEvent e) {
if (_popupType == LIGHT_WEIGHT_POPUP) {
if ((_panel != null) &&
_panel.isAncestorOf(((Component) e.getSource())) && getTimeout() != 0) {
stopTimeoutTimer();
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if ((_window != null) &&
_window.isAncestorOf(((Component) e.getSource())) && getTimeout() != 0) {
stopTimeoutTimer();
}
}
}
protected void handleMouseExited(MouseEvent e) {
if (_popupType == LIGHT_WEIGHT_POPUP) {
if ((_panel != null) &&
_panel.isAncestorOf(((Component) e.getSource())) && getTimeout() != 0) {
startTimeoutTimer();
}
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
if ((_window != null) &&
_window.isAncestorOf(((Component) e.getSource())) && getTimeout() != 0) {
startTimeoutTimer();
}
}
}
private static boolean checkedUnpostPopup;
private static boolean unpostPopup;
private static boolean doUnpostPopupOnDeactivation() {
if (!checkedUnpostPopup) {
unpostPopup = (Boolean) java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
String pKey = "sun.swing.unpostPopupsOnWindowDeactivation";
String value = System.getProperty(pKey, "true");
return Boolean.valueOf(value);
}
}
);
checkedUnpostPopup = true;
}
return unpostPopup;
}
protected void handleWindowEvent(WindowEvent e) {
Component owner = getActualOwner();
if (e.getSource() != getTopLevelAncestor() && isAncestorOf(owner, e.getWindow())) { // check if it's embeded in browser
if (e.getID() == WindowEvent.WINDOW_CLOSING || e.getID() == WindowEvent.WINDOW_ICONIFIED) {
hidePopup(true);
}
// The cases for window deactivated are too complex. Let's not consider it for now.
// One case the code below didn't consider is an dialog is shown while in another thread, alert is showing and the owner is the frame.
// At the end, frame received deactivated event and cause alert to hide immediately.
//
// 1/2/07: we have to put this code back because combobox's popup not hiding when the window is deactivated.
// But I also copied the code from MenuSelectionManager to check doUnpostPopupOnDeactivation. Hopefully that addresses the issue above.
else if (isTransient() && e.getID() == WindowEvent.WINDOW_DEACTIVATED
&& !(e.getWindow() instanceof EmbeddedFrame)) {
// TODO: don't why DEACTIVATED event is fired when popup is showing only if the applet is in browser mode.
// so the best solution is to find out why. For now just skip the case if the frame is a EmbeddedFrame.
if (doUnpostPopupOnDeactivation()) {
if (e.getOppositeWindow() != getTopLevelAncestor()) {
hidePopup(true);
}
}
}
}
}
/**
* This method will process component event. By default, if popup's ancestor is hidden, we will
* hide the popup as well if the popup is transient (isTransient returns true). If popup's
* ancestor is moved, we will either move or hide the popup depending on {@link
* #getDefaultMoveOperation()} value.
*
* @param e the ComponentEvent.
*/
protected void handleComponentEvent(ComponentEvent e) {
Component owner = getActualOwner();
if (e.getID() == ComponentEvent.COMPONENT_HIDDEN && isAncestorOf(owner, e.getSource())) {
ancestorHidden();
}
else
if (e.getID() == ComponentEvent.COMPONENT_MOVED && isAncestorOf(owner, e.getSource())) {
// this line is for Linux because the jframe moves when combobox is shown inside JidePopup
// System.out.println("_actualOwnerLocation " + _actualOwnerLocation + " _actualOwner " + _actualOwner + " _actualOwner.getLocationOnScreen() " + (_actualOwner != null ? _actualOwner.getLocationOnScreen() : null));
if (_actualOwnerLocation == null || _actualOwner == null || !_actualOwner.getLocationOnScreen().equals(_actualOwnerLocation)) {
ancestorMoved();
}
}
}
/**
* This method will process component hidden event for the popup's ancestor. By default we will
* hide the popup immediately. You can override this to customize the behavior.
*/
protected void ancestorHidden() {
if (isTransient()) {
hidePopupImmediately(true);
}
}
/**
* This method will process component moved event for the popup's ancestor. By default we will
* move the popup if getDefaultMoveOperation() is MOVE_ON_MOVED, or hide the popup if
* getDefaultMoveOperation() is HIDE_ON_MOVED. You can override this to customize the behavior.
*/
protected void ancestorMoved() {
if (getDefaultMoveOperation() == MOVE_ON_MOVED) {
movePopup();
}
else if (getDefaultMoveOperation() == HIDE_ON_MOVED) {
if (isTransient()) {
hidePopupImmediately(true);
}
}
}
public void hidePopup() {
hidePopup(false);
}
public void hidePopup(boolean cancelled) {
if (!isPopupVisible()) {
return;
}
hidePopupImmediately(cancelled);
}
public boolean isPopupVisible() {
if (_popupType == LIGHT_WEIGHT_POPUP) {
return _panel != null && _panel.isVisible();
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
return _window != null && _window.isShowing();
}
return false;
}
public Rectangle getPopupBounds() {
if (_popupType == LIGHT_WEIGHT_POPUP) {
return isPopupVisible() ? _panel.getBounds() : null;
}
else if (_popupType == HEAVY_WEIGHT_POPUP) {
return isPopupVisible() ? _window.getBounds() : null;
}
return null;
}
public void hidePopupImmediately(boolean cancelled) {
Component owner = getActualOwner();
if (owner != null) {
owner.removeHierarchyListener(_hierarchyListener);
_hierarchyListener = null;
owner.removeComponentListener(_ownerComponentListener);
_ownerComponentListener = null;
}
if (_escapeActionListener != null) {
unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
_escapeActionListener = null;
}
if (_window != null) {
_window.removeWindowListener(_windowListener);
_windowListener = null;
_window.removeComponentListener(_componentListener);
_componentListener = null;
_window.getContentPane().remove(this);
if (cancelled) {
firePopupMenuCanceled(); // will cause hidePopupImmediately called again.
}
firePopupMenuWillBecomeInvisible();
}
if (_panel != null) {
_panel.remove(this);
if (cancelled) {
firePopupMenuCanceled(); // will cause hidePopupImmediately called again.
}
firePopupMenuWillBecomeInvisible();
}
if (_popupResizeListener != null) {
removeComponentListener(_popupResizeListener);
_popupResizeListener = null;
}
if (_window != null) {
_previousSize = _window.getSize();
_window.setVisible(false);
firePropertyChange("visible", Boolean.TRUE, Boolean.FALSE);
_window.removeAll();
_window.dispose();
_window = null;
}
if (_panel != null) {
_previousSize = _panel.getSize();
_panel.setVisible(false);
firePropertyChange("visible", Boolean.TRUE, Boolean.FALSE);
_panel = null;
}
_actualOwner = null;
//<syd_0034>
//David: There are synchronous events which can result in a call to
// hidePopupImmediately. Because I made the call to addMouseEventHandler
// asynchronous, this can result in a situation where hidePopupImmediately
// gets called before addMouseEventHandler is executed. In that situation, the
// mouseEventHandler would be added after it was removed, resulting in the
// handler hanging around. So I call the removeMouseEventHandler method
// asynchronously, as well, to insure that it happens after
// addMouseEventHandler.
// removeMouseEventHandler();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
removeMouseEventHandler();
}
});
//</syd_0034>
// comment out because bug report on http://www.jidesoft.com/forum/viewtopic.php?p=10333#10333.
if (owner != null && owner.isShowing()) {
for (Container p = owner.getParent(); p != null; p = p.getParent()) {
if (p instanceof JPopupMenu) break;
if (p instanceof Window) {
if (!((Window) p).isFocused()) {
boolean success = owner.requestFocusInWindow();
if (!success) {
owner.requestFocus();
}
break;
}
}
}
}
_resizableSupport = null;
_owner = null;
_actualOwner = null;
_actualOwnerLocation = null;
}
/**
* Hides the popup immediately (compare to {@link #hidePopup()} could use animation to hide the
* popup).
*/
public void hidePopupImmediately() {
hidePopupImmediately(false);
}
/**
* Add an entry to global event queue.
*/
private void addMouseEventHandler() {
if (SecurityUtils.isAWTEventListenerDisabled() || "true".equals(SecurityUtils.getProperty("jide.disableAWTEventListener", "false"))) {
return;
}
if (_awtEventListener == null) {
_awtEventListener = new AWTEventListener() {
public void eventDispatched(AWTEvent event) {
if ("sun.awt.UngrabEvent".equals(event.getClass().getName())) {
// this is really a hack so that it can detect event when closing the windows in Eclise RCP env.
// Popup should be canceled in case of ungrab event
hidePopupImmediately(true);
return;
}
if (event instanceof MouseEvent) {
if (event.getID() == MouseEvent.MOUSE_PRESSED) {
handleMousePressed((MouseEvent) event);
}
else if (event.getID() == MouseEvent.MOUSE_DRAGGED) {
handleMouseDragged((MouseEvent) event);
}
else if (event.getID() == MouseEvent.MOUSE_RELEASED) {
handleMouseReleased((MouseEvent) event);
}
else if (event.getID() == MouseEvent.MOUSE_ENTERED) {
handleMouseEntered((MouseEvent) event);
}
else if (event.getID() == MouseEvent.MOUSE_EXITED) {
handleMouseExited((MouseEvent) event);
}
}
else if (event instanceof WindowEvent) {
handleWindowEvent((WindowEvent) event);
}
else if (event instanceof ComponentEvent) {
handleComponentEvent((ComponentEvent) event);
}
}
};
}
try {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
Toolkit.getDefaultToolkit().addAWTEventListener(_awtEventListener, AWTEvent.MOUSE_EVENT_MASK
| AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK);
return null;
}
}
);
}
catch (SecurityException e) {
throw new RuntimeException(e);
}
}
/**
* Add an entry to global event queue.
*/
private void removeMouseEventHandler() {
if (SecurityUtils.isAWTEventListenerDisabled() || "true".equals(SecurityUtils.getProperty("jide.disableAWTEventListener", "false"))) {
return;
}
try {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
Toolkit.getDefaultToolkit().removeAWTEventListener(_awtEventListener);
_awtEventListener = null;
return null;
}
}
);
}
catch (SecurityException e) {
throw new RuntimeException(e);
}
}
public Component getOwner() {
return _owner;
}
public void setOwner(Component owner) {
if (_owner != owner) {
Component old = _owner;
_owner = owner;
firePropertyChange(OWNER_PROPERTY, old, _owner);
removeExcludedComponent(old);
addExcludedComponent(_owner);
}
}
/**
* Checks if the popup is movable. If yes, it will show the gripper so that user can grab it and
* move the popup. If the popup is attached to its owner, moving it will detach from the owner.
*
* @return true if gripper is visible
*/
public boolean isMovable() {
return _movable;
}
/**
* Sets the movable attribute.
*
* @param movable true or false.
*/
public void setMovable(boolean movable) {
boolean old = _movable;
if (old != movable) {
_movable = movable;
firePropertyChange(MOVABLE_PROPERTY, old, _movable);
}
}
/**
* Checks if the popup is resizable. By default, resizable option is true.
* <p/>
* Depending on the detached/attached mode, the resizing behavior may be different. If a popup
* is detached to a component, it only allows you to resize from bottom, bottom right and right
* It obviously doesn't make sense to resize from top and top side is aligned with the attached
* component.
* <p/>
* (Notes: in the future we will allow resize from different corner if the popup is shown above
* owner due to not enough space on the screen).
*
* @return if the popup is resizable.
*/
public boolean isResizable() {
return _resizable;
}
/**
* Sets the resizable option.
*
* @param resizable true or false.
*/
public void setResizable(boolean resizable) {
if (_resizable != resizable) {
boolean old = _resizable;
_resizable = resizable;
firePropertyChange(RESIZABLE_PROPERTY, old, _resizable);
}
}
/**
* Checks if the popup is attachable. By default, attachable option is true.
*
* @return if the popup is attachable.
*/
public boolean isAttachable() {
return _attachable;
}
/**
* Sets the attachable option.
*
* @param attachable true or false.
*/
public void setAttachable(boolean attachable) {
if (_attachable != attachable) {
boolean old = _attachable;
_attachable = attachable;
firePropertyChange(ATTACHABLE_PROPERTY, old, _attachable);
}
}
/**
* Checks if the popup is detached.
* <p/>
* A popup has detached and attached mode. When a popup is in attached, it will act like it's
* part of the owner (which can be set using {@link #setOwner(java.awt.Component)}. When owner
* is moved, the popup will be moved. If the owner is hidden, the popup will hidden. In the
* other word, it is attached with the owner. In detached mode, popup becomes an indenpendent
* floating window. It will stay at the same location regardless if owner is moved. It could
* still be visible when owner is hidden.
* <p/>
*
* @return true if it's detacted. Otherwise false.
*/
public boolean isDetached() {
return _detached;
}
/**
* Changes the popup's detached mode.
*
* @param detached true or false.
*/
public void setDetached(boolean detached) {
if (_detached != detached) {
boolean old = _detached;
_detached = detached;
firePropertyChange("detacted", old, _detached);
if (_resizableSupport != null) { // todo: check property change
if (_detached) {
if (getPopupBorder() == null) {
_resizableSupport.setBorder(UIDefaultsLookup.getBorder("Resizable.resizeBorder"));
}
else {
_resizableSupport.setBorder(getPopupBorder());
}
if (isResizable()) {
_resizableSupport.getResizable().setResizableCorners(Resizable.ALL);
}
else {
_resizableSupport.getResizable().setResizableCorners(Resizable.NONE);
}
}
else {
if (getPopupBorder() == null) {
_resizableSupport.setBorder(UIDefaultsLookup.getBorder("PopupMenu.border"));
}
else {
_resizableSupport.setBorder(getPopupBorder());
}
if (isResizable()) {
_resizableSupport.getResizable().setResizableCorners(Resizable.RIGHT | Resizable.LOWER | Resizable.LOWER_RIGHT);
}
else {
_resizableSupport.getResizable().setResizableCorners(Resizable.NONE);
}
}
}
}
}
/**
* Gets the popup border set by {@link #setPopupBorder(javax.swing.border.Border)}.
*
* @return the border for this popup.
*/
public Border getPopupBorder() {
return _popupBorder;
}
/**
* Sets the border for this popup. Please note a non-empty border is needed if you want the
* popup to be resizable.
*
* @param popupBorder the border for the popup.
*/
public void setPopupBorder(Border popupBorder) {
_popupBorder = popupBorder;
}
/**
* Checks if the popup is transient.
*
* @return true if transient.
*
* @see #setTransient(boolean)
*/
public boolean isTransient() {
return _transient;
}
/**
* Sets the transient attribute. If a popup is transient, it will hide automatically when mouse
* is clicked outside the popup. Otherwise, it will stay visible until timeout or hidePopup() is
* called.
*
* @param isTransient true or false.
*/
public void setTransient(boolean isTransient) {
boolean old = _transient;
if (old != isTransient) {
_transient = isTransient;
firePropertyChange(TRANSIENT_PROPERTY, old, isTransient);
}
}
/**
* Gets the time out value, in milliseconds.
*
* @return the time out value, in milliseconds.
*/
public int getTimeout() {
return _timeout;
}
/**
* Sets the time out value, in milliseconds. If you don't want the popup hide after the time
* out, set the value to 0. By default it's 0 meaning it will never time out.
* <p/>
* Typically, you call setTimeOut before the popup is visible. But if you do call setTimeOut
* when popup is already visible (which means the timer is running), we will restart the timer
* using the new time out value you just set, even the new time out value is the same as the old
* one. In the other word, this setTimeOut call will always restart the timer if the timer is
* running.
*
* @param timeout new time out value, in milliseconds. 0 if you don't want popup automatically
* hides.
*/
public void setTimeout(int timeout) {
_timeout = timeout;
if (_timer != null && _timer.isRunning()) {
startTimeoutTimer(); // this call will restart the timer.
}
}
private void stopTimeoutTimer() {
if (_timer != null) {
_timer.stop();
_timer = null;
// System.out.println("stop");
}
}
private void startTimeoutTimer() {
stopTimeoutTimer();
_timer = new Timer(getTimeout(), new ActionListener() {
public void actionPerformed(ActionEvent e) {
hidePopup();
}
});
_timer.setRepeats(false);
_timer.start();
// System.out.println("start");
}
/**
* Gets the default focus component.
*
* @return the default focus component.
*/
public Component getDefaultFocusComponent() {
return _defaultFocusComponent;
}
/**
* Sets the default focus component. Default focus component should be a child component on this
* popup. It will get focus when popup is shown. By setting a non-null component as default
* focus component, the JWindow that contains the JidePopup will be set focusable. Otherwise the
* JWindow will be non-focusable.
*
* @param defaultFocusComponent the default focus component.
*/
public void setDefaultFocusComponent(Component defaultFocusComponent) {
_defaultFocusComponent = defaultFocusComponent;
}
/**
* Adds a <code>PopupMenu</code> listener which will listen to notification messages from the
* popup portion of the combo box.
* <p/>
* For all standard look and feels shipped with Java 2, the popup list portion of combo box is
* implemented as a <code>JPopupMenu</code>. A custom look and feel may not implement it this
* way and will therefore not receive the notification.
*
* @param l the <code>PopupMenuListener</code> to add
*/
public void addPopupMenuListener(PopupMenuListener l) {
listenerList.add(PopupMenuListener.class, l);
}
/**
* Removes a <code>PopupMenuListener</code>.
*
* @param l the <code>PopupMenuListener</code> to remove
*
* @see #addPopupMenuListener
* @since 1.4
*/
public void removePopupMenuListener(PopupMenuListener l) {
listenerList.remove(PopupMenuListener.class, l);
}
/**
* Returns an array of all the <code>PopupMenuListener</code>s added to this JComboBox with
* addPopupMenuListener().
*
* @return all of the <code>PopupMenuListener</code>s added or an empty array if no listeners
* have been added
*/
public PopupMenuListener[] getPopupMenuListeners() {
return listenerList.getListeners(PopupMenuListener.class);
}
/**
* Notifies <code>PopupMenuListener</code>s that the popup portion of the combo box will become
* visible.
* <p/>
* This method is public but should not be called by anything other than the UI delegate.
*
* @see #addPopupMenuListener
*/
public void firePopupMenuWillBecomeVisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1]).popupMenuWillBecomeVisible(e);
}
}
}
/**
* Notifies <code>PopupMenuListener</code>s that the popup portion of the combo box has become
* invisible.
* <p/>
* This method is public but should not be called by anything other than the UI delegate.
*
* @see #addPopupMenuListener
*/
public void firePopupMenuWillBecomeInvisible() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1]).popupMenuWillBecomeInvisible(e);
}
}
}
/**
* Notifies <code>PopupMenuListener</code>s that the popup portion of the combo box has been
* canceled.
* <p/>
* This method is public but should not be called by anything other than the UI delegate.
*
* @see #addPopupMenuListener
*/
public void firePopupMenuCanceled() {
Object[] listeners = listenerList.getListenerList();
PopupMenuEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PopupMenuListener.class) {
if (e == null)
e = new PopupMenuEvent(this);
((PopupMenuListener) listeners[i + 1]).popupMenuCanceled(e);
}
}
}
/**
* Gets the default operation when the owner is moved. The valid values are either {@link
* #HIDE_ON_MOVED}, {@link #MOVE_ON_MOVED} or {@link #DO_NOTHING_ON_MOVED}.
*
* @return the default operation when the owner is moved.
*/
public int getDefaultMoveOperation() {
return _defaultMoveOperation;
}
/**
* Sets the default operation when the owner is moved. The valid could be either {@link
* #HIDE_ON_MOVED}, {@link #MOVE_ON_MOVED} or {@link #DO_NOTHING_ON_MOVED}.
*
* @param defaultMoveOperation the default operation when the owner is moved.
*/
public void setDefaultMoveOperation(int defaultMoveOperation) {
_defaultMoveOperation = defaultMoveOperation;
}
/**
* Adds a component as excluded component. If a component is an excluded component or descendant
* of an excluded component, clicking on it will not hide the popup.
* <p/>
* For example, AbstractComboBox uses JidePopup to display the popup. If you want to show a
* JDialog from the popup, you will have to add the dialog as excluded component. See below for
* an example.
* <pre><code>
* JDialog dialog =new JDialog((Frame) JideSwingUtilities.getWindowForComponent(this), true);
* dialog.add(new JTable(10, 4));
* dialog.pack();
* Container ancestorOfClass = SwingUtilities.getAncestorOfClass(JidePopup.class, this); // try
* to find the JidePopup
* if(ancestorOfClass instanceof JidePopup) {
* ((JidePopup) ancestorOfClass).addExcludedComponent(dialog);
* }
* dialog.setVisible(true);
* if(ancestorOfClass instanceof JidePopup) {
* ((JidePopup) ancestorOfClass).removeExcludedComponent(dialog);
* }
* </code></pre>
*
* @param component the component should be excluded.
*/
public void addExcludedComponent(Component component) {
if (component != null && !_excludedComponents.contains(component)) {
_excludedComponents.add(component);
}
}
/**
* Removes a component from the excluded component list. If a component is an excluded
* component, clicking on it will not hide the popup.
*
* @param component the component was excluded before.
*/
public void removeExcludedComponent(Component component) {
_excludedComponents.remove(component);
}
/**
* Removes all excluded components that were added before.
*/
public void removeAllExcludedComponents() {
_excludedComponents.clear();
}
/**
* Checks if a component is an excluded component. If a component is an excluded component,
* clicking on it will not hide the popup. By default, owner is always the excluded component.
*
* @param component a component.
*
* @return true if the component is an excluded component.
*/
public boolean isExcludedComponent(Component component) {
boolean contain = _excludedComponents.contains(component);
if (!contain) {
for (Component c : _excludedComponents) {
if (c instanceof Container) {
if (((Container) c).isAncestorOf(component)) {
return true;
}
}
}
}
return contain;
}
public int getGripperLocation() {
return _gripperLocation;
}
/**
* Sets the gripper location. The valid values are {@link SwingConstants#NORTH}, {@link
* SwingConstants#SOUTH}, {@link SwingConstants#EAST}, and {@link SwingConstants#WEST}.
*
* @param gripperLocation the new gripper location.
*/
public void setGripperLocation(int gripperLocation) {
int old = _gripperLocation;
if (old != gripperLocation) {
_gripperLocation = gripperLocation;
firePropertyChange(PROPERTY_GRIPPER_LOCATION, old, gripperLocation);
}
}
public int getPopupType() {
return _popupType;
}
public void setPopupType(int popupType) {
if (popupType != LIGHT_WEIGHT_POPUP && popupType != HEAVY_WEIGHT_POPUP) {
throw new IllegalArgumentException("invalid popup type. It must be JidePopup.HEAVY_WEIGHT_POPUP or JidePopup.LIGHT_WEIGHT_POPUP.");
}
_popupType = popupType;
}
/**
* Checks if the mouse event is on the popup. By default, we will check if popup is an ancestor
* of the clicked component. If it returns true, the popup will not be hidden. If false, the
* popup will be hidden as we consider the mouse click is outside the popup.
*
* @param e
*
* @return true or false.
*/
public boolean isClickOnPopup(MouseEvent e) {
Component c = e.getComponent();
if (c == null) {
return false;
}
Component component = SwingUtilities.getDeepestComponentAt(c, e.getX(), e.getY());
return getPopupType() == HEAVY_WEIGHT_POPUP ? isAncestorOf(component, _window) : isAncestorOf(component, _panel);
}
/**
* Gets the actual owner. User can set owner using {@link #setOwner(java.awt.Component)} method.
* But when one of the showPopup methods with owner parameter is called, the actual owner will
* be changed to this component.
*
* @return the actual owner.
*/
protected Component getActualOwner() {
if (_actualOwner != null) {
return _actualOwner;
}
else {
return getOwner();
}
}
}
| [
"[email protected]"
] | |
f78623564c8be845781f1836c3a93ba080581bc4 | 63c73fd213d1c145797f248569976efeac748b1c | /src/main/java/com/demiurg/spring/mvc_hibernate_aop/service/EmployeeServiceImpl.java | 4998e65e7cc1fd50faf1086f056d1938b65dfc9d | [] | no_license | john-alp/spring_mvc_hibernate_aop | 017890163161d99d998d901d6fdb76bb3949407f | 127d096835da872b2fca5c03d5df03b65d816423 | refs/heads/master | 2023-03-29T23:52:17.982489 | 2021-04-01T09:07:38 | 2021-04-01T09:07:38 | 353,040,845 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,235 | java | package com.demiurg.spring.mvc_hibernate_aop.service;
import com.demiurg.spring.mvc_hibernate_aop.dao.EmployeeDAO;
import com.demiurg.spring.mvc_hibernate_aop.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
// @Service специализированный компоненнт
@Service //отмечает класс, содержащий бизнес логику. Соединительное звено между Controller и DAO
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
private EmployeeDAO employeeDAO;
@Override
@Transactional
public List<Employee> getAllEmployees() {
return employeeDAO.getAllEmployees();
}
@Override
@Transactional
public void saveEmployee(Employee employee) {
employeeDAO.saveEmployee(employee);
}
@Override
@Transactional
public Employee getEmployee(int id) {
return employeeDAO.getEmployee(id);
}
@Override
@Transactional
public void deleteEmployee(int id) {
employeeDAO.deleteEmployee(id);
}
}
| [
"[email protected]"
] | |
6ff11f9e37ef74db0a98604d7cc0b5e8c994bfc0 | 53f777e288003fec9d74521fb3caf0f4042634de | /示例19/src/main/java/com/github/yeecode/mybatisdemo/DemoApplication.java | 381100624a78ab904cf5b861c4179813832e332f | [] | no_license | caojx-git/MyBatisDemo | 297656f058d3a4c51a5a373d36bb92de8f28e370 | 0fa8f41d10f81eb0fb73e8edfdb1573d2fed87a9 | refs/heads/master | 2023-03-10T20:54:58.789483 | 2021-02-23T02:41:57 | 2021-02-23T02:41:57 | 341,405,428 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 843 | java | package com.github.yeecode.mybatisdemo;
import com.github.yeecode.mybatisdemo.model.ProxyHandler;
import com.github.yeecode.mybatisdemo.model.User;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cglib.proxy.Enhancer;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) throws Exception {
Enhancer enhancer = new Enhancer();
// 设置enhancer的回调对象
enhancer.setCallback(new ProxyHandler<>());
// 设置enhancer对象的父类
enhancer.setSuperclass(User.class);
// 创建代理对象,实际为User的子类
User user = (User) enhancer.create();
// 通过代理对象调用目标方法
String ans = user.sayHello("易哥");
System.out.println(ans);
}
}
| [
"[email protected]"
] | |
1be6a03c7a3b33517bb610d3d4eebdbf02cd8002 | 27d08bee1ef74c394639dcfdbdc59d7d732c0f1b | /Session4/src/ProblemStatement.java | 334758ad1e625906e8e50edf08ec61af1b7245fe | [] | no_license | chubbycbit/april27th | eb4ea68ed4746bc49a4dd8bd2f04d28ef73fc3c9 | 00daf4079c3f51fb56fdbd898c1fa4262a166e91 | refs/heads/master | 2022-06-04T20:03:20.168884 | 2020-05-01T03:33:31 | 2020-05-01T03:33:31 | 259,779,976 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 598 | java |
public class ProblemStatement {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] demRegionVotes = {126,32,230,21,200};
int[] repRegionVotes = {152,85,121,215,13};
int demVotes=0;
int repVotes=0;
for(int i=0;i<demRegionVotes.length;i++)
{
demVotes+=demRegionVotes[i];
repVotes+=repRegionVotes[i];
}
if(demVotes > repVotes)
{
System.out.println(">> Democratic Party Won by "+(demVotes-repVotes)+" votes");
}else {
System.out.println(">> Republican Party Won by "+(repVotes-demVotes)+" votes");
}
}
}
| [
"[email protected]"
] | |
a8e38be56f2f4a93363591638147f8ccec2d1a79 | cc77882fe8fa8e4127968cb3c8f8a5537a1e652e | /src/java/entities/Customer.java | 60360296e294cd9cc7e17eab6743d3a583a1d70b | [] | no_license | andrewabreu/EntityClassRestFulWS | 87eb88b1069ee2f933ce01c2d28b58abdb8a02c7 | b456957f95d71e466bb4b1f702fee424b5e2331e | refs/heads/master | 2020-03-07T06:16:02.600549 | 2018-03-29T16:18:59 | 2018-03-29T16:18:59 | 127,317,070 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,431 | 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 entities;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Andrew
*/
@Entity
@Table(name = "CUSTOMER")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Customer.findAll", query = "SELECT c FROM Customer c")
, @NamedQuery(name = "Customer.findByCustomerId", query = "SELECT c FROM Customer c WHERE c.customerId = :customerId")
, @NamedQuery(name = "Customer.findByName", query = "SELECT c FROM Customer c WHERE c.name = :name")
, @NamedQuery(name = "Customer.findByAddressline1", query = "SELECT c FROM Customer c WHERE c.addressline1 = :addressline1")
, @NamedQuery(name = "Customer.findByAddressline2", query = "SELECT c FROM Customer c WHERE c.addressline2 = :addressline2")
, @NamedQuery(name = "Customer.findByCity", query = "SELECT c FROM Customer c WHERE c.city = :city")
, @NamedQuery(name = "Customer.findByState", query = "SELECT c FROM Customer c WHERE c.state = :state")
, @NamedQuery(name = "Customer.findByPhone", query = "SELECT c FROM Customer c WHERE c.phone = :phone")
, @NamedQuery(name = "Customer.findByFax", query = "SELECT c FROM Customer c WHERE c.fax = :fax")
, @NamedQuery(name = "Customer.findByEmail", query = "SELECT c FROM Customer c WHERE c.email = :email")
, @NamedQuery(name = "Customer.findByCreditLimit", query = "SELECT c FROM Customer c WHERE c.creditLimit = :creditLimit")})
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "CUSTOMER_ID")
private Integer customerId;
@Size(max = 30)
@Column(name = "NAME")
private String name;
@Size(max = 30)
@Column(name = "ADDRESSLINE1")
private String addressline1;
@Size(max = 30)
@Column(name = "ADDRESSLINE2")
private String addressline2;
@Size(max = 25)
@Column(name = "CITY")
private String city;
@Size(max = 2)
@Column(name = "STATE")
private String state;
// @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
@Size(max = 12)
@Column(name = "PHONE")
private String phone;
// @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
@Size(max = 12)
@Column(name = "FAX")
private String fax;
// @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
@Size(max = 40)
@Column(name = "EMAIL")
private String email;
@Column(name = "CREDIT_LIMIT")
private Integer creditLimit;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customerId")
private Collection<PurchaseOrder> purchaseOrderCollection;
@JoinColumn(name = "DISCOUNT_CODE", referencedColumnName = "DISCOUNT_CODE")
@ManyToOne(optional = false)
private DiscountCode discountCode;
@JoinColumn(name = "ZIP", referencedColumnName = "ZIP_CODE")
@ManyToOne(optional = false)
private MicroMarket zip;
public Customer() {
}
public Customer(Integer customerId) {
this.customerId = customerId;
}
public Integer getCustomerId() {
return customerId;
}
public void setCustomerId(Integer customerId) {
this.customerId = customerId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddressline1() {
return addressline1;
}
public void setAddressline1(String addressline1) {
this.addressline1 = addressline1;
}
public String getAddressline2() {
return addressline2;
}
public void setAddressline2(String addressline2) {
this.addressline2 = addressline2;
}
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 String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getCreditLimit() {
return creditLimit;
}
public void setCreditLimit(Integer creditLimit) {
this.creditLimit = creditLimit;
}
@XmlTransient
public Collection<PurchaseOrder> getPurchaseOrderCollection() {
return purchaseOrderCollection;
}
public void setPurchaseOrderCollection(Collection<PurchaseOrder> purchaseOrderCollection) {
this.purchaseOrderCollection = purchaseOrderCollection;
}
public DiscountCode getDiscountCode() {
return discountCode;
}
public void setDiscountCode(DiscountCode discountCode) {
this.discountCode = discountCode;
}
public MicroMarket getZip() {
return zip;
}
public void setZip(MicroMarket zip) {
this.zip = zip;
}
@Override
public int hashCode() {
int hash = 0;
hash += (customerId != null ? customerId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Customer)) {
return false;
}
Customer other = (Customer) object;
if ((this.customerId == null && other.customerId != null) || (this.customerId != null && !this.customerId.equals(other.customerId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entities.Customer[ customerId=" + customerId + " ]";
}
}
| [
"[email protected]"
] | |
69e5f63eddef60443847746a2a3f72d560f91d88 | 3912d75b574a5ecde6932541972e0fd0ccf7cbac | /src/main/java/Fasti/FastiCaldavConnector/StandardActions/FastiCaldavActionSetTodoList.java | 738f045c685eadf7bcab68ec800026cf5b7271f1 | [] | no_license | toha/java-fasti | 738d0eea971fd6da4625b7fdf4f2b04da7d34d96 | 70ca9e32f8d6e87ea2d31481a95bc6b311715ae2 | refs/heads/master | 2021-01-10T02:44:30.910474 | 2007-12-28T20:04:22 | 2007-12-28T20:04:22 | 51,787,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 880 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Fasti.FastiCaldavConnector.StandardActions;
import Fasti.FastiConnector.FastiAction.FastiTodoListAction;
import Fasti.FastiConnector.FastiAction.TodoListActions.FastiActionSetTodoList;
public class FastiCaldavActionSetTodoList extends FastiActionSetTodoList {
public FastiCaldavActionSetTodoList() {
super();
this.setName(FastiCaldavActionSetTodoList.class.getName());
}
@Override
public void saveState() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Boolean runAction() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void undoAction() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
| [
"[email protected]"
] | |
8635cf2a72b7f91d4b53bef404bf3665d3b0d6ba | 7b4cd475780f28b9032ce617b1bc12443968b853 | /src/main/java/ru/papont/hotel/web/rest/util/HeaderUtil.java | b544cc716f3f56c98eb0df211e740e33b1fbbb69 | [] | no_license | papont/hotel-jhipster-svc | 5cd5a856b4c4c969c391c22f34eb0ca91d399e4e | 0446ae75ebee6ac6eb4469fc25ae10afc9e4eef4 | refs/heads/master | 2021-09-04T03:40:28.011482 | 2018-01-15T11:46:02 | 2018-01-15T11:46:02 | 117,539,212 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,612 | java | package ru.papont.hotel.web.rest.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
/**
* Utility class for HTTP headers creation.
*/
public final class HeaderUtil {
private static final Logger log = LoggerFactory.getLogger(HeaderUtil.class);
private static final String APPLICATION_NAME = "roomserviceApp";
private HeaderUtil() {
}
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-roomserviceApp-alert", message);
headers.add("X-roomserviceApp-params", param);
return headers;
}
public static HttpHeaders createEntityCreationAlert(String entityName, String param) {
return createAlert(APPLICATION_NAME + "." + entityName + ".created", param);
}
public static HttpHeaders createEntityUpdateAlert(String entityName, String param) {
return createAlert(APPLICATION_NAME + "." + entityName + ".updated", param);
}
public static HttpHeaders createEntityDeletionAlert(String entityName, String param) {
return createAlert(APPLICATION_NAME + "." + entityName + ".deleted", param);
}
public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) {
log.error("Entity processing failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
headers.add("X-roomserviceApp-error", "error." + errorKey);
headers.add("X-roomserviceApp-params", entityName);
return headers;
}
}
| [
"[email protected]"
] | |
883e3c3bea4056ae87225599ad729ec8a7d4b43a | 0e77082bfadf3033c81f7ab7d6a83ad97737dfed | /HBTeamProjectTeam1/src/com/team1/lms/jobsupport/ConsultingBBSRepleAdd.java | 35d31e28fd3864ac6b78475893f708397463e867 | [] | no_license | andaseul/2017_Framework | 520cc657eb51c2cc520c34e01cf345ceff6bab17 | 18d8f38c9ac0f18b855d979af7fa892bda56537f | refs/heads/master | 2021-01-22T02:17:30.564775 | 2017-06-02T03:48:58 | 2017-06-02T03:48:58 | 92,348,282 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,129 | java | package com.team1.lms.jobsupport;
import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.team1.admin.dao.JobSupportDAO;
@WebServlet("/hb/consulting_repleadd.hb")
public class ConsultingBBSRepleAdd extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
int idx =Integer.parseInt((String) req.getParameter("idx"));
String title = (String) req.getParameter("title");
String username = (String) req.getParameter("username");
String memo = (String) req.getParameter("memo");
try {
JobSupportDAO dao= new JobSupportDAO();
dao.consulting_reple(idx, title, username, memo);
} catch(SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
resp.sendRedirect("consulting_bbs.hb?page=1");
}
}
| [
"[email protected]"
] | |
7197152cf7426dc3c018cf6a0efbab2db18f8df5 | 3d70c78b1effa7107bf0993dc42a6ce74a8c1c99 | /src/rumman/freemarker/PrintCode.java | 469027061618b48e21a43a968dfa03e67419bdc8 | [] | no_license | Rumman123/java-project | b0684cf2794d05a1353d73d61bbebe417810bfbf | 46f24cda7d29c7cc47780d41614db26640e01ee9 | refs/heads/master | 2020-04-04T13:25:08.500276 | 2014-09-11T05:44:27 | 2014-09-11T05:44:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,742 | java | package rumman.freemarker;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class PrintCode {
public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.setClassForTemplateLoading(PrintCode.class, "/");
try {
Template template = cfg.getTemplate("code.ftl");
BufferedReader br = new BufferedReader(new InputStreamReader(PrintCode.class.getClassLoader().getResourceAsStream("codes.csv")));
String[] header = br.readLine().split(";");
String line;
for (int i = 0; (line = br.readLine()) != null; i++) {
Map<String, Object> data = new HashMap<String, Object>();
List<ValueHolder> statements = new ArrayList<ValueHolder>();
data.put("title", "Responsive Layout Example");
String[] content=line.split(";");
for (int j = 0; j < header.length && j < content.length; j++) {
statements.add(new ValueHolder(header[j], content[j]));
}
data.put("statements", statements);
Writer out = new OutputStreamWriter(System.out);
template.process(data, out);
out.flush();
Writer file = new FileWriter(new File("content.html"));
template.process(data, file);
file.flush();
file.close();
}
}
catch (IOException e) {
e.printStackTrace();
} catch (TemplateException e) {
e.printStackTrace();
}
}
}
| [
"rumman pathan@rumman"
] | rumman pathan@rumman |
aa8d7a01aa75897805a158a05342005283690159 | 91eb69c48269fd732692104c1faec4dda22abe76 | /src/main/java/algorithm/catAndMouse/CatAndMouse.java | 1ccf7a5bae876b71605d7ef760504348de4ae9b9 | [] | no_license | hwlee8042/hackerrank | 3ed803ed62a3edf6b54bb270c722a44adc05dcd6 | 49f2bb7037e2483b38c97624841225d3a71ac8b7 | refs/heads/master | 2020-11-28T16:17:17.832889 | 2020-03-05T10:29:30 | 2020-03-05T10:29:30 | 229,865,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 649 | java | package algorithm.catAndMouse;
/*
If cat A catches the mouse first, print Cat A
If cat B catches the mouse first, print Cat B.
If both cats reach the mouse at the same time, print `Mouse C` as the two cats fight and mouse escapes.
*/
public class CatAndMouse {
public String catAndMouse(int x, int y, int z) {
String result = "";
int betweenXZ = Math.abs(x-z);
int betweenYZ = Math.abs(y-z);
if(betweenXZ < betweenYZ) {
result = "Cat A";
}else if(betweenXZ > betweenYZ) {
result = "Cat B";
}else {
result = "Mouse C";
}
return result;
}
}
| [
"[email protected]"
] | |
66e33ac3776d299b9e55139c56d24474df21482d | b643d5b615a13779ef51590d9b8f851315f28afb | /cloud2021/cloud-consumer-feign-hystrix-order80/src/main/java/com/sun/service/PaymentFallbackService.java | af5c1155e74c04f558681bc48508c2711b47d9f2 | [] | no_license | s-gwei/studySpringcloud | 1191cd816835213c1598e1cfd536099e64be7dd6 | 995cd5fe58a14e698e89fc6d1493c04ba2d0e9c1 | refs/heads/master | 2023-06-21T08:15:28.211071 | 2021-07-19T02:53:50 | 2021-07-19T02:53:50 | 326,900,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 503 | java | package com.sun.service;
import org.springframework.stereotype.Component;
/**
* @auther zzyy
* @create 2020-02-20 18:22
*/
@Component
public class PaymentFallbackService implements PaymentHystrixService{
public String paymentInfo_OK(Integer id) {
return "-----PaymentFallbackService fall back-paymentInfo_OK ,o(╥﹏╥)o";
}
public String paymentInfo_TimeOut(Integer id) {
return "-----PaymentFallbackService fall back-paymentInfo_TimeOut ,o(╥﹏╥)o";
}
}
| [
"[email protected]"
] | |
1a1b5c685319e61c4d4aa75fb9151619372939b1 | 2069cd986c9a58aea5b9081d9a3602669c08397e | /COP/Basic programming/Assignment3/Var_arg.java | cd94dc0942aef1e4646f2e04b5b2849ad661633d | [] | no_license | ReshmaJagade/COP | 1db833c785c06316be75f4103c35f986136b100f | 4c4a392a959cd8dc4e0129538ca0e3ba0585fb16 | refs/heads/main | 2023-08-17T14:29:14.238744 | 2021-09-30T05:36:39 | 2021-09-30T05:36:39 | 371,013,746 | 1 | 1 | null | 2021-07-25T10:57:11 | 2021-05-26T11:44:53 | Java | UTF-8 | Java | false | false | 428 | java | //4.Write a function /method which takes variable no of int numbers as an argument and
//returns the sum of these arguments as an output.
public class Var_arg {
public static void sum(int...a)
{
int sum=0;
for(int i=0;i<a.length;i++)
{
sum=sum+a[i];
}
System.out.println("Sum of "+a.length+" Elements: "+sum);
}
public static void main(String[] args)
{
int a=10;
sum();
sum(a);
sum(a,a,a,a,a);
}
}
| [
"[email protected]"
] | |
a85cc1076c6ebce210a4512252a1aedade95301b | 2f7f0fdf789321fc777502a6ca92b3cfd1a6e05d | /src/edu/nyu/cs/addressbook/search/impl/ContactField.java | abf199451dbbcd6e5615e496284495d2e4590a91 | [] | no_license | elevenlee/AddressBookLib | 71df3cd089a2ba74bc9c788fa04ccd9e8247c8a9 | 181424888873628dde4b976bcd0611e2d0cb38b9 | refs/heads/master | 2016-09-05T17:30:24.456675 | 2015-05-31T18:27:09 | 2015-05-31T18:27:09 | 27,344,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,062 | java | package edu.nyu.cs.addressbook.search.impl;
import edu.nyu.cs.addressbook.ContactEntry;
import edu.nyu.cs.addressbook.builder.Builder;
import edu.nyu.cs.addressbook.component.util.State;
import edu.nyu.cs.addressbook.search.SearchCriteria;
import edu.nyu.cs.addressbook.utils.ParameterChecker;
/**
* @author shenli
* <p>
* The {@code ContactField} class represents criteria information.
* <p>
* The specified criteria is the element should match the specified contact entry fields. {@code ContactField}
* are constant; their value could not be changed after they are created. Because {@code ContactField} objects
* are immutable they could be shared.
*/
public class ContactField implements SearchCriteria {
private final String firstName;
private final String lastName;
private final short areaCode;
private final short prefix;
private final short lineNumber;
private final String username;
private final String domain;
private final int zipCode;
private final State state;
private final String city;
private final String street;
private final String note;
private volatile int hashCode;
/**
* @author shenli
* <p>
* The {@code ContactFieldBuilder} class represents building contact matcher criteria information.
* <p>
* {@code ContactFieldBuilder} objects are not constant; their values could be changed after they are
* created. The {@code ContactFieldBuilder} object is not thread-safe. To use it concurrently, user must
* surround each method invocation with external synchronization of the users' choosing.
*/
public static class ContactFieldBuilder implements Builder<ContactField> {
private String firstName = "";
private String lastName = "";
private short areaCode = 0;
private short prefix = 0;
private short lineNumber = 0;
private String username = "";
private String domain = "";
private int zipCode = 0;
private State state = State.NONE;
private String city = "";
private String street = "";
private String note = "";
/**
* Initializes a newly created {@code ContactFieldBuilder} object so that it records contact matcher
* criteria information.
*/
public ContactFieldBuilder() {
}
/**
* Returns this {@code ContactFieldBuilder} with specified first name.
* <p>
* @param str the first name
* @return this {@code {@code ContactFieldBuilder}} with specified first name
*/
public ContactFieldBuilder firstName(String str) {
ParameterChecker.nullCheck(str, "first name");
firstName = str.trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified last name.
* <p>
* @param str the last name
* @return this {@code ContactFieldBuilder} with specified last name
*/
public ContactFieldBuilder lastName(String str) {
ParameterChecker.nullCheck(str, "last name");
lastName = str.trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified area code.
* <p>
* @param val the area code
* @return this {@code ContactFieldBuilder} with specified area code
*/
public ContactFieldBuilder areaCode(int val) {
areaCode = (short) val;
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified prefix.
* <p>
* @param val the prefix
* @return this {@code ContactFieldBuilder} with specified prefix
*/
public ContactFieldBuilder prefix(int val) {
prefix = (short) val;
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified line number.
* <p>
* @param val the line number
* @return this {@code ContactFieldBuilder} with specified line number
*/
public ContactFieldBuilder lineNumber(int val) {
lineNumber = (short) val;
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified user name.
* <p>
* @param str the user name
* @return this {@code ContactFieldBuilder} with specified user name
*/
public ContactFieldBuilder username(String str) {
ParameterChecker.nullCheck(str, "user name");
username = str.toLowerCase().trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified domain.
* <p>
* @param str the domain
* @return this {@code ContactFieldBuilder} with specified domain
*/
public ContactFieldBuilder domain(String str) {
ParameterChecker.nullCheck(str, "domain");
domain = str.toLowerCase().trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified zip code.
* <p>
* @param val the zip code
* @return this {@code ContactFieldBuilder} with specified zip code
*/
public ContactFieldBuilder zipCode(int val) {
zipCode = val;
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified state.
* <p>
* @param val the state
* @return this {@code ContactFieldBuilder} with specified state
*/
public ContactFieldBuilder state(State val) {
ParameterChecker.nullCheck(val, "state");
state = val;
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified city.
* <p>
* @param str the city
* @return this {@code ContactFieldBuilder} with specified city
*/
public ContactFieldBuilder city(String str) {
ParameterChecker.nullCheck(str, "city");
city = str.trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified street.
* <p>
* @param str the street
* @return this {@code ContactFieldBuilder} with specified street
*/
public ContactFieldBuilder street(String str) {
ParameterChecker.nullCheck(str, "street");
street = str.trim();
return this;
}
/**
* Returns this {@code ContactFieldBuilder} with specified note.
* <p>
* @param str the note
* @return this {@code ContactFieldBuilder} with specified note
*/
public ContactFieldBuilder note(String str) {
ParameterChecker.nullCheck(str, "note");
note = str;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ContactField build() {
return new ContactField(this);
}
}
/**
* Initializes a newly created {@code ContactField} object so that it records contact matcher criteria
* information.
* <p>
* @param builder the builder pattern object
*/
private ContactField(ContactFieldBuilder builder) {
assert builder != null;
this.firstName = builder.firstName;
this.lastName = builder.lastName;
this.areaCode = builder.areaCode;
this.prefix = builder.prefix;
this.lineNumber = builder.lineNumber;
this.username = builder.username;
this.domain = builder.domain;
this.zipCode = builder.zipCode;
this.state = builder.state;
this.city = builder.city;
this.street = builder.street;
this.note = builder.note;
}
/**
* {@inheritDoc}
*/
@Override
public boolean matchCondition(ContactEntry element) {
if (element == null) {
return false;
}
boolean result = true;
if (!firstName.equals("")) {
result = result && firstName.equals(element.getFirstName());
}
if (!lastName.equals("")) {
result = result && lastName.equals(element.getLastName());
}
if (areaCode != 0) {
result = result && element.containsAreaCode(areaCode);
}
if (prefix != 0) {
result = result && element.containsPrefix(prefix);
}
if (lineNumber != 0) {
result = result && element.containsLineNumber(lineNumber);
}
if (!username.equals("")) {
result = result && element.containsUsername(username);
}
if (!domain.equals("")) {
result = result && element.containsDomain(domain);
}
if (zipCode != 0) {
result = result && element.containsZipcode(zipCode);
}
if (state != State.NONE) {
result = result && element.containsState(state);
}
if (!city.equals("")) {
result = result && element.containsCity(city);
}
if (!street.equals("")) {
result = result && element.containsStreet(street);
}
if (!note.equals("")) {
result = result && element.getNote().contains(note);
}
return result;
}
/**
* Compares the specified object with this {@code ContactField} for equality. Returns true if and only if
* the specified object is also a {@code ContactField} object, both objects have the same first name, last
* name, area code, prefix, line number, user name, domain, zipcode, state, city, street, and note.
* <p>
* This implementation first checks if the specified object is this {@code ContactField}. If so, it returns
* true; if not, it checks if the specified object is a {@code ContactField} object. If not, it returns
* false; if so, it iterates over both {@code ContactField} objects, comparing corresponding fields. If
* any comparison returns false, this method returns false. Otherwise it returns true when the iterations
* complete.
* <p>
* @param o the object to be compared for equality with this {@code ContactField} object
* @return true if the specified object is equal to this {@code ContactField} object
*/
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (! (o instanceof ContactField)) {
return false;
}
ContactField cf = (ContactField) o;
return firstName.equals(cf.firstName)
&& lastName.equals(cf.lastName)
&& areaCode == cf.areaCode
&& prefix == cf.prefix
&& lineNumber == cf.lineNumber
&& username.equals(cf.username)
&& domain.equals(cf.domain)
&& zipCode == cf.zipCode
&& state == cf.state
&& city.equals(cf.city)
&& street.equals(cf.street)
&& note.equals(cf.note);
}
/**
* Returns the hash code value for this {@code ContactField} object.
* <p>
* @return the hash code value for this {@code ContactField} object
*/
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
final int prime = 31;
result = 17;
result = result * prime + firstName.hashCode();
result = result * prime + lastName.hashCode();
result = result * prime + areaCode;
result = result * prime + prefix;
result = result * prime + lineNumber;
result = result * prime + username.hashCode();
result = result * prime + domain.hashCode();
result = result * prime + zipCode;
result = result * prime + state.ordinal();
result = result * prime + city.hashCode();
result = result * prime + street.hashCode();
result = result * prime + note.hashCode();
hashCode = result;
}
return result;
}
/**
* Return string representation of this {@code ContactField} object.
* <p>
* @return a string representation of this {@code ContactField} object
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (!firstName.equals("")) {
sb.append("first name: " + firstName + "\n");
}
if (!lastName.equals("")) {
sb.append("last name: " + lastName + "\n");
}
if (areaCode != 0) {
sb.append("area code: " + areaCode + "\n");
}
if (prefix != 0) {
sb.append("prefix: " + prefix + "\n");
}
if (lineNumber != 0) {
sb.append("line number: " + lineNumber + "\n");
}
if (!username.equals("")) {
sb.append("user name: " + username + "\n");
}
if (!domain.equals("")) {
sb.append("domain: " + domain + "\n");
}
if (zipCode != 0) {
sb.append(String.format("zipcode: %05d\n", zipCode));
}
if (state != State.NONE) {
sb.append("state: " + state.name() + "\n");
}
if (!city.equals("")) {
sb.append("city: " + city + "\n");
}
if (!street.equals("")) {
sb.append("street: " + street + "\n");
}
if (!note.equals("")) {
sb.append("note: " + note + "\n");
}
return sb.toString();
}
}
| [
"[email protected]"
] | |
57bbbf07afa8638d786bc253ba8c9f89d5d71703 | c14cc8445883f0894d773e7f1025e6666775de03 | /src/test/java/pageObjects/WikiPage.java | 8af1b025ef384adba78707f807d923b35decb3f1 | [] | no_license | ViktoriiaLozova/qavlozova2018 | e7ade7800cf7c46050ac708439f68a1af5216ade | 147c57508d9e477042ed8692db06dd18e6db11d0 | refs/heads/master | 2020-03-14T15:52:48.975293 | 2018-10-30T08:50:28 | 2018-10-30T08:50:28 | 131,686,231 | 0 | 0 | null | 2018-10-30T08:50:29 | 2018-05-01T07:10:50 | Java | UTF-8 | Java | false | false | 1,217 | java | package pageObjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import utils.ScreenShotUtils;
import java.io.IOException;
import java.util.List;
public class WikiPage extends BasePage {
@FindBy(xpath = "//span[@id='Did_you_know...']/../following-sibling::*//img")
WebElement firstScreen;
@FindBy(xpath = "//div[@id='mp-itn']")
WebElement secondScreen;
@FindBy(tagName = "a")
List<WebElement> linkElements;
public WikiPage(WebDriver webDriver) {
super(webDriver);
}
public void takeScreenShotFirst() throws IOException {
ScreenShotUtils.createScreenShotFromElement(webDriver, firstScreen, "First_screenshot.png");
}
public void takeScreenShotSecond() throws IOException {
ScreenShotUtils.createScreenShotFromElement(webDriver, secondScreen, "Second_screenshot.png");
}
public void printLinkList() {
List<WebElement> linkListElements = linkElements;
System.out.println(linkListElements.size());
for (int i = 0; i < linkListElements.size(); i++) {
System.out.println(linkListElements.get(i).getText());
}
}
}
| [
"[email protected]"
] | |
b0dc7bf3bfcaf5cacb37139ca77d0f3387c36867 | 15ad82ce783b7f267e499b61ac7216ceaa8f9b3b | /src/Main.java | e4cdea638f139f3afcfc40770fa9f7f9256ed73d | [] | no_license | GCL-sh/GitTest | a124c89b63b7c4e29f836b48e9cb2486e8ae0bff | 9f8a3a447e656f82c7171251e1b9ddb6ae72d1c7 | refs/heads/master | 2023-01-20T10:39:05.465999 | 2020-11-16T11:52:10 | 2020-11-16T11:52:10 | 313,271,834 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 165 | java | public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
System.out.println("Hello World!");
}
}
| [
"[email protected]"
] | |
d5d91a2b4ce4377d9f9914bfd894f45cef01d489 | 7bfe481206302df408b5936ddf683bc82f84ee2a | /src/com/scp/ObjectCreationWays/ObjectCreation.java | 1de35d907b333f3eee38689b4daaf607a07b4026 | [] | no_license | amarghorpade/basics | 30c04dc1c2a3872aa024f4d8ada0fd6b8159d6e3 | 71546999673bb370f4505a2ef8db89cfafae4033 | refs/heads/master | 2021-05-08T13:00:22.959768 | 2018-02-02T14:03:35 | 2018-02-02T14:03:35 | 116,041,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 435 | java | package com.scp.ObjectCreationWays;
import java.io.Serializable;
public class ObjectCreation implements Cloneable, Serializable {
private int id = 20;
String name = "amar";
public static void main(String[] args) {
ObjectCreation obc = new ObjectCreation();
System.out.println(obc.id);
}
@Override
public Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
}
| [
"[email protected]"
] | |
dbffdd7e3b0a931ee11444053cc39a5a3330fd50 | d5142ee90dbb94366c33b07f048d904138f23750 | /bytebank-herdado/src/Administrador.java | 7cfd9b3efcaede4ce64eda7d8e1f1088be9902c9 | [] | no_license | devlucasrezende/estudos-alura | f4b41f8151dead5198d23b64ddc665332cd40a45 | 6197530fdc2918fa20876d3fb9c95c2422b8b8ab | refs/heads/master | 2023-04-12T04:59:20.157670 | 2021-05-10T17:20:26 | 2021-05-10T17:20:26 | 362,951,884 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 502 | java |
public class Administrador extends Funcionario implements Autenticavel {
private AutenticacaoUtil autenticador;
@Override
public double getBonificacao() {
return 50;
}
public Administrador () {
this.autenticador = new AutenticacaoUtil();
}
@Override
public void setSenha(int senha) {
this.autenticador.setSenha(senha);;
}
@Override
public boolean autentica(int senha) {
return this.autenticador.autentica(senha);
//delegando a chamada para a autenticacao util
}
}
| [
"[email protected]"
] | |
a210f39b8ee326782a4066759bf5517080a87205 | 9866428a4a7428ee4fcb5896d5cc6749478cc623 | /kafkaapi/KafkaMessageConsumer.java | 39ca1c220b591d10e1619ec2f19e0596ab262168 | [] | no_license | RaghavanKasthuri/Coding | 69b9f9fc6f3dde1268895232a6101aa31d262729 | b4df770b2a40a2f1f2d70719d5910984e12c7712 | refs/heads/master | 2023-08-17T14:47:21.041790 | 2022-05-19T07:16:01 | 2022-05-19T07:16:01 | 173,283,210 | 1 | 1 | null | 2023-08-04T19:31:57 | 2019-03-01T10:30:03 | HTML | UTF-8 | Java | false | false | 2,306 | java | package kafkaapi;
//import java.util.Properties;
import java.util.*;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.ConsumerRecord;
public class KafkaMessageConsumer {
public static void main(String[] args) {
final int giveUp = 100; int noRecordsCount = 0;
Properties properties = new Properties();
properties.put("bootstrap.servers", "localhost:9092");
properties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
properties.put("group.id", "test-group");
System.out.println("About to initialize Kafka Consumer");
final KafkaConsumer<Long, String> kafkaConsumer =
new KafkaConsumer<>(properties);
TopicPartition tp = new TopicPartition("Kafka-Partition", 1);
Long startOffset = 0L;
Long endOffset = 2L;
//KafkaConsumer kafkaConsumer = new KafkaConsumer(properties);
List<TopicPartition> topics = Arrays.asList(tp);
//topics.add("Kafka-Test");
kafkaConsumer.assign(topics);
kafkaConsumer.seek(tp, startOffset);
//kafkaConsumer.subscribe(topics);
final ConsumerRecords<Long, String> consumerRecords =
kafkaConsumer.poll(100000);
// The number 100000 is the time up until which the listener listens to the Kafka topic
//ConsumerRecords records = kafkaConsumer.poll(1000000000);
System.out.println("Number of Records = " + consumerRecords.count());
consumerRecords.forEach(record -> {
if (record.offset() <= endOffset) {
//System.out.printf("Consumer Record:(%d, %s, %d, %d)\n",
// record.key(), record.value(),
// record.partition(), record.offset());
System.out.println("Kafka Partition ID = " + record.partition() + "Record Value" + record.value());
}
});
kafkaConsumer.commitAsync();
kafkaConsumer.close();
}
} | [
"[email protected]"
] | |
ab7209d07092c87dd271f3148966c70f73843f9a | 254b9f28b4cc31eeef33e32baaa0e4c4998f2583 | /reservation.hotel.webapp/src/wshotelmetier/Hotel.java | f282f088d733f9b62b2189f1e9abcef38021e2cc | [] | no_license | cosmos2028/reservation_hotel | d587024dd32300b2b85248d20f38bdb9a9744682 | 7a279eeffba9486efb89810b7a7a940328723a8a | refs/heads/master | 2020-03-17T15:49:49.959784 | 2018-06-04T17:18:54 | 2018-06-04T17:18:54 | 133,725,687 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 7,963 | java |
package wshotelmetier;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Classe Java pour hotel complex type.
*
* <p>Le fragment de schéma suivant indique le contenu attendu figurant dans cette classe.
*
* <pre>
* <complexType name="hotel">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="adresse" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="avisclientsurhotels" type="{http://ws/}avisclientsurhotel" maxOccurs="unbounded" minOccurs="0"/>
* <element name="chambres" type="{http://ws/}chambre" maxOccurs="unbounded" minOccurs="0"/>
* <element name="codeHotel" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="codePostal" type="{http://www.w3.org/2001/XMLSchema}int"/>
* <element name="courriel" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="nomHotel" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="services" type="{http://ws/}service" maxOccurs="unbounded" minOccurs="0"/>
* <element name="telephone" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="ville" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "hotel", propOrder = {
"adresse",
"avisclientsurhotels",
"chambres",
"codeHotel",
"codePostal",
"courriel",
"nomHotel",
"services",
"telephone",
"ville"
})
public class Hotel {
protected String adresse;
@XmlElement(nillable = true)
protected List<Avisclientsurhotel> avisclientsurhotels;
@XmlElement(nillable = true)
protected List<Chambre> chambres;
protected int codeHotel;
protected int codePostal;
protected String courriel;
protected String nomHotel;
@XmlElement(nillable = true)
protected List<Service> services;
protected String telephone;
protected String ville;
/**
* Obtient la valeur de la propriété adresse.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAdresse() {
return adresse;
}
/**
* Définit la valeur de la propriété adresse.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAdresse(String value) {
this.adresse = value;
}
/**
* Gets the value of the avisclientsurhotels property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the avisclientsurhotels property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getAvisclientsurhotels().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Avisclientsurhotel }
*
*
*/
public List<Avisclientsurhotel> getAvisclientsurhotels() {
if (avisclientsurhotels == null) {
avisclientsurhotels = new ArrayList<Avisclientsurhotel>();
}
return this.avisclientsurhotels;
}
/**
* Gets the value of the chambres property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the chambres property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getChambres().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Chambre }
*
*
*/
public List<Chambre> getChambres() {
if (chambres == null) {
chambres = new ArrayList<Chambre>();
}
return this.chambres;
}
/**
* Obtient la valeur de la propriété codeHotel.
*
*/
public int getCodeHotel() {
return codeHotel;
}
/**
* Définit la valeur de la propriété codeHotel.
*
*/
public void setCodeHotel(int value) {
this.codeHotel = value;
}
/**
* Obtient la valeur de la propriété codePostal.
*
*/
public int getCodePostal() {
return codePostal;
}
/**
* Définit la valeur de la propriété codePostal.
*
*/
public void setCodePostal(int value) {
this.codePostal = value;
}
/**
* Obtient la valeur de la propriété courriel.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCourriel() {
return courriel;
}
/**
* Définit la valeur de la propriété courriel.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCourriel(String value) {
this.courriel = value;
}
/**
* Obtient la valeur de la propriété nomHotel.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNomHotel() {
return nomHotel;
}
/**
* Définit la valeur de la propriété nomHotel.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNomHotel(String value) {
this.nomHotel = value;
}
/**
* Gets the value of the services property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the services property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getServices().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Service }
*
*
*/
public List<Service> getServices() {
if (services == null) {
services = new ArrayList<Service>();
}
return this.services;
}
/**
* Obtient la valeur de la propriété telephone.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTelephone() {
return telephone;
}
/**
* Définit la valeur de la propriété telephone.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTelephone(String value) {
this.telephone = value;
}
/**
* Obtient la valeur de la propriété ville.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVille() {
return ville;
}
/**
* Définit la valeur de la propriété ville.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVille(String value) {
this.ville = value;
}
}
| [
"[email protected]"
] | |
48c760d11192d54dfe65eae4892b31f47b72e0f8 | a58ce51a9c4369481b13c7b1ad3dfab1b3b09bb1 | /src/main/java/uk/co/minty_studios/metrocore/commands/notescommands/NotesRemoveCommand.java | 3f9e412b861e7a3bceb64df29ddad4793cc4ebb8 | [] | no_license | MintyMonster/MetroCore | 78bccba55c87e757420ce40a899dc418e98292ef | 11d8bd190ec28b8e5ecc2c0440238bccd2542b5d | refs/heads/master | 2023-05-10T06:42:01.585472 | 2023-05-09T17:16:19 | 2023-05-09T17:16:19 | 356,717,893 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,188 | java | package uk.co.minty_studios.metrocore.commands.notescommands;
import uk.co.minty_studios.metrocore.MetroCore;
import uk.co.minty_studios.metrocore.commands.ChildCommand;
import uk.co.minty_studios.metrocore.database.NotesDatabase;
import org.bukkit.entity.Player;
public class NotesRemoveCommand extends ChildCommand {
private final MetroCore plugin;
private final NotesDatabase notesDatabase;
public NotesRemoveCommand(String command, MetroCore plugin, NotesDatabase notesDatabase) {
super(command);
this.plugin = plugin;
this.notesDatabase = notesDatabase;
}
@Override
public String getPermission(){ return "metrocore.admin"; }
@Override
public String getDescription() {
return "Remove a note";
}
@Override
public String getSyntax() {
return "&e/notes remove <id>";
}
@Override
public void perform(Player player, String[] args) {
if(!(args.length > 1)){
plugin.sendWithPrefix(player, "&cUsage: &e/notes remove <id>");
return;
}
notesDatabase.removeNote(args[1]);
plugin.sendWithPrefix(player, "&aNote removed.");
}
}
| [
"[email protected]"
] | |
530cb557e9c103f26b4b8be9c24835efae5694e5 | 865002790a0879cf468f6364da5c7848a1d5b93a | /Development/librarymanagement/src/main/java/library/cse/cu/librarymanagement/rowmapper/RoleRowMapper.java | 9f822f6fe841c0c458bc7e554698226f45b57715 | [] | no_license | ShakibZzaman/cu-cse-325-326 | da95e9e2e3af2c83e24b5199995ecbb5bafb92e6 | d97e5b9c8d0459973f238bcbb12b28d1eddab9b9 | refs/heads/master | 2020-06-18T08:59:42.463440 | 2019-07-07T18:09:40 | 2019-07-07T18:09:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 718 | 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 library.cse.cu.librarymanagement.rowmapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import library.cse.cu.librarymanagement.domain.Role;
import org.springframework.jdbc.core.RowMapper;
/**
*
* @author Agent47
*/
public class RoleRowMapper implements RowMapper<Role>{
@Override
public Role mapRow(ResultSet rs, int i) throws SQLException {
Role role = new Role();
role.setId(rs.getInt("id"));
role.setRolename(rs.getString("rolename"));
return role;
}
}
| [
"[email protected]"
] | |
ee237bceaaf54d8524eff0b20520ca882d62186e | 4e37a52b082afb74242d380733703ca5141e1f7e | /src/votingapp/editVoterdetails.java | db1eefcd24acec41caca6a986660fd82ee2a4b2f | [] | no_license | anjali7528/Voting-app | caee038c7fc131580a1b6ec127564706ca5ceba5 | 880ec66ca9fe274da1d73ccddce649379ccd0b3a | refs/heads/master | 2022-12-28T10:48:27.715511 | 2020-10-17T18:30:04 | 2020-10-17T18:30:04 | 304,943,644 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,326 | 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 votingapp;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
/**
*
* @author lenovo
*/
public class editVoterdetails extends javax.swing.JFrame {
/**
* Creates new form editVoterdetails
*/
public editVoterdetails() {
initComponents();
try{
String q1="select * from tbvoter";
myconnection obj=new myconnection();
PreparedStatement pst=obj.db.prepareStatement(q1);
ResultSet rs = pst.executeQuery();
while(rs.next())
{
c1.add(""+rs.getInt("id"));
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
c1 = new java.awt.Choice();
button1 = new java.awt.Button();
label1 = new java.awt.Label();
label2 = new java.awt.Label();
label3 = new java.awt.Label();
label4 = new java.awt.Label();
label5 = new java.awt.Label();
label6 = new java.awt.Label();
label7 = new java.awt.Label();
label8 = new java.awt.Label();
label9 = new java.awt.Label();
t1 = new java.awt.TextField();
t2 = new java.awt.TextField();
t3 = new java.awt.TextField();
t4 = new java.awt.TextField();
t5 = new java.awt.TextField();
t6 = new java.awt.TextField();
t7 = new java.awt.TextField();
t8 = new java.awt.TextField();
t9 = new java.awt.TextField();
button2 = new java.awt.Button();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
button1.setLabel("edit");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button1ActionPerformed(evt);
}
});
label1.setText("fname");
label2.setText("lname");
label3.setText("age");
label4.setText("email");
label5.setText("contact");
label6.setText("aadhaar");
label7.setText("gender");
label8.setText("address");
label9.setText("city");
button2.setLabel("update");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(58, 58, 58)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(c1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 147, Short.MAX_VALUE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(57, 57, 57))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(100, 100, 100)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(t1, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
.addComponent(t3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(t9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(c1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(t9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(18, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed
// TODO add your handling code here:
try
{
String r =c1.getSelectedItem();
int m = Integer.parseInt(r);
String q="select * from tbvoter where id=?";
myconnection obj=new myconnection();
PreparedStatement pst=obj.db.prepareStatement(q);
pst.setInt(1,m);
ResultSet rs=pst.executeQuery();
if(rs.next())
{
t1.setText(rs.getString("fname"));
t2.setText(rs.getString("lname"));
t3.setText(rs.getString("age"));
t4.setText(rs.getString("email"));
t5.setText(rs.getString("contact"));
t6.setText(rs.getString("aadhaar"));
t7.setText(rs.getString("gender"));
t8.setText(rs.getString("address"));
t9.setText(rs.getString("city"));
}
else
{
System.out.println("id does not exist !!!");
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}//GEN-LAST:event_button1ActionPerformed
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed
// TODO add your handling code here:
try{
int age;
String fn,ln,con,add,acard,gen,em,city;
String i=c1.getSelectedItem();
int n = Integer.parseInt(i);
fn=t1.getText();
ln=t2.getText();
age=Integer.parseInt(t3.getText());
if(age<18)
{
JOptionPane.showMessageDialog(this,"Age should be greater than 18");
}
em=t4.getText();
con=t5.getText();
acard=t6.getText();
gen=t7.getText();
add=t8.getText();
city=t9.getText();
if(con.length() != 10)
{
JOptionPane.showMessageDialog(this,"enter correct contact no.");
}
if(t1.getText().length()==0||t2.getText().length()==0||t6.getText().length()==0||t7.getText().length()==0||t4.getText().length()==0||t8.getText().length()==0||t9.getText().length()==0)
{
JOptionPane.showMessageDialog(this,"please fill data");
}
String q="update tbvoter set fname=?,lname=?,age=?,email=?,contact=?,aadhaar=?,gender=?,address=?,city=? where id=?";
myconnection obj =new myconnection();
PreparedStatement pst=obj.db.prepareStatement(q);
pst.setString(1,fn);
pst.setString(2,ln);
pst.setInt(3,age);
pst.setString(4,em);
pst.setString(5,con);
pst.setString(6,acard);
pst.setString(7,gen);
pst.setString(8,add);
pst.setString(9,city);
pst.setInt(10,n);
pst.executeUpdate();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}//GEN-LAST:event_button2ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(editVoterdetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(editVoterdetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(editVoterdetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(editVoterdetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new editVoterdetails().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private java.awt.Button button1;
private java.awt.Button button2;
private java.awt.Choice c1;
private java.awt.Label label1;
private java.awt.Label label2;
private java.awt.Label label3;
private java.awt.Label label4;
private java.awt.Label label5;
private java.awt.Label label6;
private java.awt.Label label7;
private java.awt.Label label8;
private java.awt.Label label9;
private java.awt.TextField t1;
private java.awt.TextField t2;
private java.awt.TextField t3;
private java.awt.TextField t4;
private java.awt.TextField t5;
private java.awt.TextField t6;
private java.awt.TextField t7;
private java.awt.TextField t8;
private java.awt.TextField t9;
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
] | |
800c08da2325d3b44c52a40e68b6f8779ffecb57 | a9cfd746a50e2bea486fcabe56797d3e4462a336 | /src/main/java/com/example/gpstrackerserver/util/CoordinateConverter.java | 37eca0a2ddac12dcb82cb59b473258e6e0093974 | [] | no_license | makewheels/gps-tracker-server | c8fba9d474bd7618ce7c142241940860270c13d0 | afb44121675027507030f31525287c253c507b66 | refs/heads/master | 2023-03-24T13:30:35.771582 | 2021-03-23T14:18:32 | 2021-03-23T14:18:32 | 289,930,806 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,632 | java | package com.example.gpstrackerserver.util;
import java.math.BigDecimal;
import java.util.Arrays;
/**
* 坐标转换工具
*
* @Author makewheels
* @Time 2021.03.21 22:56:36
*/
public class CoordinateConverter {
/**
* nmea原始数据转为gps经纬度
*
* @param nmea
* @return
*/
public static String[] nmeaToGps(String nmea) {
String[] array = nmea.split(",");
String NS = array[1];
String EW = array[3];
String nmeaLatitude = array[0];
String nmeaLongitude = array[2];
BigDecimal latitude = new BigDecimal(nmeaLatitude.substring(2));
latitude = latitude.divide(new BigDecimal(60), 16, BigDecimal.ROUND_HALF_UP);
latitude = latitude.add(new BigDecimal(nmeaLatitude.substring(0, 2)));
BigDecimal longitude = new BigDecimal(nmeaLongitude.substring(2));
longitude = longitude.divide(new BigDecimal(60), 16, BigDecimal.ROUND_HALF_UP);
longitude = longitude.add(new BigDecimal(nmeaLongitude.substring(0, 3)));
String latitudeString;
if (NS.equals("S"))
latitudeString = "-" + latitude.toString();
else
latitudeString = latitude.toString();
String longitudeString;
if (EW.equals("W"))
longitudeString = "-" + longitude.toString();
else
longitudeString = longitude.toString();
return new String[]{latitudeString, longitudeString};
}
public static void main(String[] args) {
String[] s = nmeaToGps("4635.37934,N,12507.84738,E");
System.out.println(Arrays.toString(s));
}
}
| [
"makewheels"
] | makewheels |
1057c5cbc7067e34f6a7b607a37c5864bac9bef5 | 55203668667963b8bfdd6b87cbb4b488a226f31b | /src/main/java/com/lrn/pattern/strategy/Context.java | 0dfe18a27a1c6d241f643098fb7339ff494309f9 | [] | no_license | dengwei729/design | db3a5ee3dca69df4595a33412ccee0bf9fbb4785 | 65972df26652733c922ee0482fddcefb64b2e939 | refs/heads/master | 2023-03-02T12:28:33.115139 | 2023-02-21T09:15:38 | 2023-02-21T09:15:38 | 223,953,853 | 0 | 0 | null | 2022-06-17T03:19:40 | 2019-11-25T13:21:38 | Java | UTF-8 | Java | false | false | 293 | java | package com.lrn.pattern.strategy;
/**
* 锦囊
* Created by dengwei on 16/11/6.
*/
public class Context {
private IStrategy strategy;
public Context(IStrategy strategy) {
this.strategy = strategy;
}
public void operate() {
this.strategy.operate();
}
}
| [
"[email protected]"
] | |
11680450d5bc47d69a540dda5ef2afe6c4dcf5ed | 1abc25e5f4fc1ed08175684b9ac956c5274c8b3d | /monitron/src/main/java/net/fortytwo/smsn/monitron/events/MonitronEvent.java | ec04283d113fef21bf1e32ee4fac8ef46f24313e | [
"MIT"
] | permissive | JeffreyBenjaminBrown/smsn | d2420b73a91a554e12e6d039de8402ce816be226 | e4ecb2affbb8f4f2b6f8bfc012dd33d100c0fbbd | refs/heads/master | 2021-01-14T13:08:35.341690 | 2016-08-13T19:16:49 | 2016-08-13T19:16:49 | 63,748,191 | 0 | 0 | null | 2016-07-20T03:45:28 | 2016-07-20T03:45:26 | null | UTF-8 | Java | false | false | 1,894 | java | package net.fortytwo.smsn.monitron.events;
import net.fortytwo.rdfagents.model.Dataset;
import net.fortytwo.smsn.SemanticSynchrony;
import net.fortytwo.smsn.monitron.Context;
import net.fortytwo.smsn.monitron.ontologies.Universe;
import org.openrdf.model.IRI;
import org.openrdf.model.Literal;
import org.openrdf.model.Resource;
import org.openrdf.model.Value;
import org.openrdf.model.ValueFactory;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.LinkedList;
public abstract class MonitronEvent {
private static final DatatypeFactory DATATYPE_FACTORY;
static {
try {
DATATYPE_FACTORY = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new ExceptionInInitializerError(e);
}
}
private final Context context;
protected final ValueFactory valueFactory;
public MonitronEvent(final Context context) {
this.context = context;
this.valueFactory = context.getValueFactory();
}
public Dataset toRDF() {
return new Dataset(new LinkedList<>());
}
protected IRI coinEventIRI() {
return valueFactory.createIRI(Universe.NAMESPACE + "event-" + SemanticSynchrony.createRandomKey());
}
protected Literal toLiteral(final Date d) {
GregorianCalendar c = new GregorianCalendar();
c.setTime(d);
return valueFactory.createLiteral(DATATYPE_FACTORY.newXMLGregorianCalendar(c));
}
protected void addStatement(final Dataset d,
final Resource subject,
final IRI predicate,
final Value object) {
d.getStatements().add(valueFactory.createStatement(subject, predicate, object));
}
}
| [
"[email protected]"
] | |
f629283d534feb42018ff7b1715e8ddab6d59217 | 2628973a49bab6e47f5efbdf9515886fce14a1f1 | /app/src/main/java/com/example/moviesearch/ui/callback/IItemClick.java | 94f51412416496e05690045d734f5b1cdd63f00b | [] | no_license | droiddevgeeks/MovieSearch | ea2c1f71338ebaeb1676f7a9bb90035cd619e78e | d82fd534bdf49b7b978ee4f0df2ac183f02ddff2 | refs/heads/master | 2020-05-20T11:41:27.615982 | 2019-05-08T07:32:35 | 2019-05-08T07:32:35 | 185,555,184 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 171 | java | package com.example.moviesearch.ui.callback;
public interface IItemClick<T> {
void onItemClick(T item, int position);
void onFavClick(T item,boolean selected);
}
| [
"[email protected]"
] | |
b8fd549fd0c017bbebf62ea0a537a345b9d09b06 | 319b6fac5f0e8872bdc569b11c9adde66e8eefef | /src/main/java/com/bhuwan/spring/di/dependson/A.java | 66854bf909f18316011965edf13eb738c2232fd0 | [] | no_license | bhuwang/spring_playground | 2613a40706d424bee44a6cb9db76c75538483319 | 5a2a8bbbdcb43310e6d177e49d06eed61cb0c2e1 | refs/heads/master | 2021-01-20T21:01:01.238271 | 2016-06-13T04:25:47 | 2016-06-13T04:25:47 | 60,771,327 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 178 | java | /**
*
*/
package com.bhuwan.spring.di.dependson;
/**
* @author bhuwan
*
*/
public class A {
public A() {
System.out.println("A object created.....");
}
}
| [
"[email protected]"
] | |
739de9136d959c9df1d92cc8bd3e7b55496c14d7 | 630e08722bec5ab15acc30ae072b8f037b9e4740 | /modules/lib-sip/src/main/java/de/fhg/fokus/ims/core/media/StreamMedia2.java | 121a8c264c5caef4ebe9ac95b773d159569c9e81 | [
"Apache-2.0"
] | permissive | fhg-fokus-nubomedia/signaling-plane | f54feef2b77cca498501523bbd06fd203dedeba1 | 2ab48dfde4556bd6920d6cbaa1d80a8646ba737f | refs/heads/master | 2021-01-10T11:28:03.998041 | 2016-01-08T11:44:57 | 2016-01-29T21:41:18 | 49,268,585 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 417 | java | package de.fhg.fokus.ims.core.media;
import javax.ims.core.media.StreamMedia;
public interface StreamMedia2 extends StreamMedia
{
int HOLDSTATE_NONE = 0;
int HOLDSTATE_LOCAL = 1;
int HOLDSTATE_REMOTE = 2;
boolean isTelephoneEventEnabled();
void setTelephoneEventEnabled(boolean enabled);
void startTelephoneEvent(int number, int volume);
void stopTelephoneEvent();
void setHoldState(int state);
}
| [
"[email protected]"
] | |
7b8c83293169e2776912625ed99a4f70025d7a0b | d8341d5608cbea48e57c85842228663e212e21a5 | /guoyw-framework-test/src/main/java/com/guoyw/framework/test/swagger/SwaggerConfig.java | de2e1a4b3773bc6f1e3579ee1824abf9be9d3661 | [] | no_license | guoywcode/guoyw-framework | 68eab66d7b5b0b3012edefa2cdaf81cd91eb1e7c | 6b2d62c431e7b96cc53b511f07206fa01336855f | refs/heads/master | 2022-03-04T23:05:13.117300 | 2020-01-02T03:38:56 | 2020-01-02T03:38:56 | 228,567,685 | 0 | 0 | null | 2022-02-09T22:21:16 | 2019-12-17T08:20:30 | Java | UTF-8 | Java | false | false | 694 | java | package com.guoyw.framework.test.swagger;
import com.guoyw.framework.starter.swagger.SpringFoxSwagger2DocketFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author: guoyw
* create: 2020-01-02 09:46
**/
@Configuration
@EnableSwagger2
@Profile({"test", "local"})
public class SwaggerConfig{
@Bean
public SpringFoxSwagger2DocketFactoryBean swaggerTest(){
return new SpringFoxSwagger2DocketFactoryBean(
"com.guoyw.framework.test",
"guoyw-framework-test"
);
}
}
| [
"[email protected]"
] | |
59df8fb538c47c08514d6b55273778ec0349b9c1 | 220058babba52bc4d4a6c2151038eec1fcb4276b | /src/commons/org/codehaus/groovy/grails/compiler/injection/GrailsAwareClassLoader.java | a87436db4b3a5a2de29f86232267dacf04753bc6 | [
"Apache-2.0"
] | permissive | lpicanco/grails | dca9bba5cc94f0eae0299b27f977c7b1fed75490 | 5da5e9d52e55668822ff309906b737b81aadf32a | refs/heads/master | 2021-01-02T23:13:01.047223 | 2008-06-13T01:20:34 | 2008-06-13T01:20:34 | 41,914 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,525 | java | /* Copyright 2006-2007 Graeme Rocher
*
* 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.codehaus.groovy.grails.compiler.injection;
import groovy.lang.GroovyClassLoader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.Phases;
import java.security.CodeSource;
/**
* A class loader that is aware of Groovy sources and injection operations
*
* @author Graeme Rocher
* @since 0.6
* <p/>
* Created: Jul 27, 2007
* Time: 8:57:15 AM
*/
public class GrailsAwareClassLoader extends GroovyClassLoader {
public GrailsAwareClassLoader() {
}
public GrailsAwareClassLoader(ClassLoader loader) {
super(loader);
}
public GrailsAwareClassLoader(GroovyClassLoader parent) {
super(parent);
}
public GrailsAwareClassLoader(ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath) {
super(parent, config, useConfigurationClasspath);
}
public GrailsAwareClassLoader(ClassLoader loader, CompilerConfiguration config) {
super(loader, config);
}
private static final Log LOG = LogFactory.getLog(GrailsAwareClassLoader.class);
private ClassInjector[] classInjectors = new ClassInjector[0];
public void setClassInjectors(ClassInjector[] classInjectors) {
this.classInjectors = classInjectors;
}
/**
* @see groovy.lang.GroovyClassLoader#createCompilationUnit(org.codehaus.groovy.control.CompilerConfiguration, java.security.CodeSource)
*/
protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) {
CompilationUnit cu = super.createCompilationUnit(config, source);
cu.addPhaseOperation(new GrailsAwareInjectionOperation(getResourceLoader(), classInjectors), Phases.CONVERSION);
return cu;
}
}
| [
"rhyolight@1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d"
] | rhyolight@1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d |
369f4af5765cae76428da4833095c5f5daf1bdfb | 806396b340d280884de0e95e360901ba628d5523 | /s28/src/Solution.java | c5b162a241d4795ef123499480731fbfb3f6217f | [] | no_license | yztz/leetCode | f4970ac231c3255e4f28e0fc98bea52321544e3e | 93a9ebac439e70dc7b3bfefdc4007b2ded2f4b05 | refs/heads/master | 2023-08-23T07:38:35.611294 | 2021-10-15T05:21:31 | 2021-10-15T05:21:31 | 384,322,407 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,045 | java | import java.util.*;
/* https://leetcode-cn.com/problems/the-k-weakest-rows-in-a-matrix/ 3ms */
public class Solution {
public int[] kWeakestRows(int[][] mat, int k) {
Map<Integer, List<Integer>> combatNum = new HashMap<>();
int len = mat[0].length;
for (int i = 0; i < mat.length; i++) {
int[] row = mat[i];
int count = 0;
while (count < len && row[count] != 0) count++;
combatNum.putIfAbsent(count, new ArrayList<>());
combatNum.get(count).add(i);
}
List<Integer> res = new ArrayList<>();
int combat = 0;
while (res.size() < k) {
if (combatNum.containsKey(combat)) {
List<Integer> list = combatNum.get(combat);
int t = 0;
while (res.size() < k && t < list.size()) {
res.add(list.get(t));
t++;
}
}
combat++;
}
return res.stream().mapToInt(o -> o).toArray();
}
}
| [
"[email protected]"
] | |
8a62976f48ffb5a061496d54c49a1a09d1f105b3 | 3342c590783311655449bdd055ca219d642a55c8 | /source/src/main/java/scalalabEdit/scalalabEditor.java | 04be2c402f6597eb9f0d79d2e5193d8f687be0a4 | [
"MIT"
] | permissive | scalalab/scalalab | d173ef4fa9807b5b77148e9828ae5c82e49d2290 | a2b977435884698b4e3c07788048c9f3dd733e7c | refs/heads/master | 2021-01-02T09:38:52.134472 | 2015-07-19T21:24:40 | 2015-07-19T21:24:59 | 39,220,384 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,329 | java | package scalalabEdit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import scalaExec.Interpreter.GlobalValues;
import scalaExec.scalaLab.StreamGobbler;
public class scalalabEditor extends JFrame {
public scalainterpreter.EditorPane jeditorPane;
String editedFileName;
static String editingFileInPane;
static JFrame currentFrame = null;
private String currentFileName; // the full path name
public scalalabEditor() {
currentFrame = this;
editedFileName = "Untitled";
editingFileInPane = "Untitled";
jeditorPane = new scalainterpreter.EditorPane();
jeditorPane.init();
JMenuBar mainJMenuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('F');
fileMenu.setToolTipText("File editing operations");
fileMenu.setFont(GlobalValues.uifont);
JMenuItem saveEditorTextJMenuItem = new JMenuItem("Save Editor Text ");
saveEditorTextJMenuItem.addActionListener(new saveEditorTextAction());
saveEditorTextJMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));
saveEditorTextJMenuItem.setFont(GlobalValues.uifont);
JMenuItem saveAsEditorTextJMenuItem = new JMenuItem("Save As Editor Text to File");
saveAsEditorTextJMenuItem.addActionListener(new saveAsEditorTextAction());
saveAsEditorTextJMenuItem.setFont(GlobalValues.uifont);
JMenuItem loadEditorTextJMenuItem = new JMenuItem("Load File to Editor");
loadEditorTextJMenuItem.addActionListener(new loadEditorTextAction());
loadEditorTextJMenuItem.setAccelerator(KeyStroke.getKeyStroke("ctrl L"));
loadEditorTextJMenuItem.setFont(GlobalValues.uifont);
JMenuItem exitJMenuItem = new JMenuItem("Exit");
exitJMenuItem.setFont(GlobalValues.uifont);
exitJMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int userOption = JOptionPane.CANCEL_OPTION;
if (jeditorPane.editorTextSaved() == false)
userOption = JOptionPane.showConfirmDialog(null, "File: " + scalalabEditor.editingFileInPane + " not saved. Proceed? ",
"Warning: Exit without Save?", JOptionPane.CANCEL_OPTION);
else userOption = JOptionPane.YES_OPTION;
if (userOption == JOptionPane.YES_OPTION) {
// save size and location of edit frame
GlobalValues.editFrameLocX = String.valueOf(currentFrame.getLocation().x);
GlobalValues.editFrameLocY = String.valueOf(currentFrame.getLocation().y);
GlobalValues.editFrameSizeX = String.valueOf(currentFrame.getSize().width);
GlobalValues.editFrameSizeY = String.valueOf(currentFrame.getSize().height);
dispose();
}
}
});
fileMenu.add(saveEditorTextJMenuItem);
fileMenu.add(saveAsEditorTextJMenuItem);
fileMenu.add(loadEditorTextJMenuItem);
fileMenu.add(exitJMenuItem);
mainJMenuBar.add(fileMenu);
setJMenuBar(mainJMenuBar);
setTitle("ScalaLab Editor, File: " + editedFileName);
setLocation(Integer.parseInt(GlobalValues.editFrameLocX), Integer.parseInt(GlobalValues.editFrameLocY));
setSize(Integer.parseInt(GlobalValues.editFrameSizeX), Integer.parseInt(GlobalValues.editFrameSizeY));
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
add(jeditorPane);
setVisible(true);
}
public scalalabEditor(int fileType) {
this();
}
public static void loadFile(String loadFileName, scalainterpreter.EditorPane ep) {
File loadFile = new File(loadFileName);
{
FileReader fr = null;
try {
fr = new FileReader(loadFile);
ep.getPane().read(fr, null);
ep.updateDocument();
} catch (FileNotFoundException ex) {
System.out.println("file " + loadFileName + " not found");
Logger.getLogger(scalalabEditor.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
System.out.println("cannot close file " + loadFileName);
} finally {
try {
fr.close();
} catch (IOException ex) {
System.out.println("cannot close file " + loadFileName);
}
}
}
}
public static void updateTitle() {
currentFrame.setTitle("ScalaLab Editor, File: " + scalalabEditor.editingFileInPane);
}
class saveEditorTextAction extends AbstractAction {
public saveEditorTextAction() {
super("Save Editor Text");
}
public void actionPerformed(ActionEvent e) {
String saveFileName = scalalabEditor.editingFileInPane;
if (saveFileName == null) { // not file specified thus open a FileChooser it
javax.swing.JFileChooser chooser = new JFileChooser(new File(GlobalValues.workingDir));
int retVal = chooser.showSaveDialog(GlobalValues.scalalabMainFrame);
if (retVal == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
saveFileName = selectedFile.getAbsolutePath();
scalalabEditor.editingFileInPane = saveFileName;
scalaExec.gui.ConsoleKeyHandler.updateModeStatusInfo();
updateTitle();
}
}
File saveFile = new File(saveFileName);
try {
FileWriter fw = new FileWriter(saveFile);
jeditorPane.getPane().write(fw);
GlobalValues.editingFileInPane = saveFileName;
GlobalValues.editorTextSaved = true;
} catch (FileNotFoundException ex) {
System.out.println("Cannot open file " + saveFile + " for saving editor text " + ex.getMessage());
} catch (Exception ex) {
System.out.println("Exception writing editor's text " + ex.getMessage());
}
}
}
class saveAsEditorTextAction extends AbstractAction {
public saveAsEditorTextAction() {
super("Save As Editor Text");
}
public void actionPerformed(ActionEvent e) {
javax.swing.JFileChooser chooser = new JFileChooser(new File(GlobalValues.workingDir));
int retVal = chooser.showSaveDialog(GlobalValues.scalalabMainFrame);
if (retVal == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
String saveFileName = selectedFile.getAbsolutePath();
File saveFile = new File(saveFileName);
try {
FileWriter fw = new FileWriter(saveFile);
jeditorPane.getPane().write(fw);
scalalabEditor.editingFileInPane = saveFileName;
GlobalValues.editorTextSaved = true;
scalaExec.gui.ConsoleKeyHandler.updateModeStatusInfo();
updateTitle();
// test whether we should update the ScalaPane's recent file information
if (GlobalValues.scalalabMainFrame.recentPaneFiles.contains(saveFileName) == false) {
GlobalValues.scalalabMainFrame.recentPaneFiles.add(saveFileName);
GlobalValues.scalalabMainFrame.updateRecentPaneFilesMenu();
}
} catch (FileNotFoundException ex) {
System.out.println("Cannot open file " + saveFile + " for saving editor text " + ex.getMessage());
} catch (Exception ex) {
System.out.println("Exception writing editor's text " + ex.getMessage());
}
}
}
}
class loadEditorTextAction extends AbstractAction {
public loadEditorTextAction() {
super("Load Editor Text");
}
public void actionPerformed(ActionEvent e) {
int userOption = JOptionPane.CANCEL_OPTION;
if (jeditorPane.editorTextSaved() == false)
userOption = JOptionPane.showConfirmDialog(null, "File: " + scalalabEditor.editingFileInPane + " not saved. Proceed? ",
"Warning: Exit without Save?", JOptionPane.CANCEL_OPTION);
else userOption = JOptionPane.YES_OPTION;
if (userOption == JOptionPane.YES_OPTION) {
javax.swing.JFileChooser chooser = new JFileChooser(new File(GlobalValues.workingDir));
int retVal = chooser.showOpenDialog(GlobalValues.scalalabMainFrame);
if (retVal == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
String loadFileName = selectedFile.getAbsolutePath();
try {
scalalabEditor.loadFile(loadFileName, jeditorPane);
scalalabEditor.editingFileInPane = loadFileName;
GlobalValues.scalalabMainFrame.recentPaneFiles.add(loadFileName);
if (GlobalValues.scalalabMainFrame.recentPaneFiles.contains(loadFileName) == false) {
GlobalValues.scalalabMainFrame.recentPaneFiles.add(loadFileName);
GlobalValues.scalalabMainFrame.updateRecentPaneFilesMenu();
}
scalaExec.gui.ConsoleKeyHandler.updateModeStatusInfo();
updateTitle();
} catch (Exception ex) {
System.out.println("Exception reading editor's text " + ex.getMessage());
}
}
}
}
}
}
| [
"[email protected]"
] | |
10ed64de550810fbcb2639e51b36fc2ecd7ac777 | 96f14c28283fb98f80a6a92be824a7116107038f | /war/src/main/java/com/magenta/calculator/data/DAOFactory.java | 4f90d485f92a90b48e7103fb672666b81ad8e6ae | [] | no_license | alex-koh/distance-calculator | abe28bcd2e07af1839bc8d15874d8127a49faf23 | e0eb0d23c6beab88246ab7ed2f1aeed50476c8bb | refs/heads/master | 2021-01-19T21:28:18.290749 | 2014-11-12T23:12:12 | 2014-11-12T23:12:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 212 | java | package com.magenta.calculator.data;
/**
* Created by alex on 10/29/14.
*/
public interface DAOFactory {
public CityDAO getCityDao() throws Exception;
public DistanceDAO getDistanceDao() throws Exception;
}
| [
"[email protected]"
] | |
b1ce9c24b9b5fad0219d49b3f31fd6c0f7e15e58 | 5a977f125c69b319fcb54dfacd8fb73e40505ceb | /app/src/main/java/com/machamasisuraj/socialapp/GUI/BannerActivity.java | 7fc0373794ed75873aef74640a448e83d87f9652 | [] | no_license | sjnyos/androidtripbook | 95a9199f343593f40fd42a0a8c93872a9455c0d5 | 80f273e87d08f6641d2c995ee977191afbca0af7 | refs/heads/master | 2022-11-27T05:16:28.922679 | 2020-08-11T05:14:58 | 2020-08-11T05:14:58 | 286,651,174 | 0 | 0 | null | 2020-08-11T05:31:21 | 2020-08-11T05:10:12 | Java | UTF-8 | Java | false | false | 3,866 | java | package com.machamasisuraj.socialapp.GUI;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.machamasisuraj.socialapp.BLL.BannerBll;
import com.machamasisuraj.socialapp.BLL.ImageUpload;
import com.machamasisuraj.socialapp.Model.BannerItem;
import com.machamasisuraj.socialapp.R;
import com.machamasisuraj.socialapp.AndroidPermisson.LinkPermisson;
import com.machamasisuraj.socialapp.AndroidPermisson.StoragePath;
import static android.app.Activity.RESULT_OK;
public class BannerActivity extends Fragment {
private Context mContext;
public BannerActivity( Context mContext) {
this.mContext = mContext;
}
private ImageView bannerImage;
private EditText bannerName,desc;
private Button upload,save;
private String imagepath="";
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = inflater.inflate(R.layout.activity_banner,container,false);
bannerImage= view.findViewById(R.id.imageView2banner);
bannerName=view.findViewById(R.id.editTextbanner);
desc=view.findViewById(R.id.editTextdesc);
upload=view.findViewById(R.id.uploadbutton2);
save=view.findViewById(R.id.buttonsave);
upload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
BrowseImage();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(mContext, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UploadImageAndSaveData();
}
});
return view;
}
private void BrowseImage() throws Exception {
// checkPermissionForReadExtertalStorage();
LinkPermisson linkPermisson= new LinkPermisson(mContext);
linkPermisson.requestPermissionForReadExtertalStorage();
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 0);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (data == null) {
Toast.makeText(mContext, "Please select an image ", Toast.LENGTH_SHORT).show();
}
}
Uri uri = data.getData();
bannerImage.setImageURI(uri);
StoragePath storagePath= new StoragePath(mContext);
imagepath = storagePath.getRealPathFromUri(uri);
}
private void UploadImageAndSaveData(){
ImageUpload imageUpload = new ImageUpload(imagepath,mContext);
String getmageName= imageUpload.uploadFile();
if(!getmageName.equals("Error")){
SaveData(getmageName);
}
}
private void SaveData(String setimageName){
BannerItem bannerItem= new BannerItem(bannerName.getText().toString(),setimageName,desc.getText().toString());
BannerBll bannerBll= new BannerBll();
if(bannerBll.InsertBanner(bannerItem)){
Toast.makeText(mContext, "Data Inserted Successfuly", Toast.LENGTH_SHORT).show();
}
}
}
| [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.