blob_id stringlengths 40 40 | __id__ int64 225 39,780B | directory_id stringlengths 40 40 | path stringlengths 6 313 | content_id stringlengths 40 40 | detected_licenses list | license_type stringclasses 2
values | repo_name stringlengths 6 132 | repo_url stringlengths 25 151 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 70 | visit_date timestamp[ns] | revision_date timestamp[ns] | committer_date timestamp[ns] | github_id int64 7.28k 689M ⌀ | star_events_count int64 0 131k | fork_events_count int64 0 48k | gha_license_id stringclasses 23
values | gha_fork bool 2
classes | gha_event_created_at timestamp[ns] | gha_created_at timestamp[ns] | gha_updated_at timestamp[ns] | gha_pushed_at timestamp[ns] | gha_size int64 0 40.4M ⌀ | gha_stargazers_count int32 0 112k ⌀ | gha_forks_count int32 0 39.4k ⌀ | gha_open_issues_count int32 0 11k ⌀ | gha_language stringlengths 1 21 ⌀ | gha_archived bool 2
classes | gha_disabled bool 1
class | content stringlengths 7 4.37M | src_encoding stringlengths 3 16 | language stringclasses 1
value | length_bytes int64 7 4.37M | extension stringclasses 24
values | filename stringlengths 4 174 | language_id stringclasses 1
value | entities list | contaminating_dataset stringclasses 0
values | malware_signatures list | redacted_content stringlengths 7 4.37M | redacted_length_bytes int64 7 4.37M | alphanum_fraction float32 0.25 0.94 | alpha_fraction float32 0.25 0.94 | num_lines int32 1 84k | avg_line_length float32 0.76 99.9 | std_line_length float32 0 220 | max_line_length int32 5 998 | is_vendor bool 2
classes | is_generated bool 1
class | max_hex_length int32 0 319 | hex_fraction float32 0 0.38 | max_unicode_length int32 0 408 | unicode_fraction float32 0 0.36 | max_base64_length int32 0 506 | base64_fraction float32 0 0.5 | avg_csv_sep_count float32 0 4 | is_autogen_header bool 1
class | is_empty_html bool 1
class | shard stringclasses 16
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
718a775fedea5b7ddb2683bd540e6b5e1365dbb2 | 24,739,011,682,682 | 046f6e4447c65782a335b4147c1d4cfbdbd64287 | /app/src/main/java/com/launch/alititlewithlist/view/cell/Content_1_ItemView.java | 1830748e160076a56b7e17ac7d48a8c3f8acbf74 | [] | no_license | sovwcwsfm/AliTitleWithList | https://github.com/sovwcwsfm/AliTitleWithList | 7c2edd265dce32e41fc4f4b8f0168d5acb0efa84 | 05488cbc36e21ca39f487864345e5dcadd1223f2 | refs/heads/master | 2020-03-21T12:04:45.112000 | 2018-09-10T07:21:36 | 2018-09-10T07:21:36 | 138,534,647 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.launch.alititlewithlist.view.cell;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.launch.alititlewithlist.R;
import com.launch.alititlewithlist.adapter.ItemViewFactory;
import com.launch.alititlewithlist.model.IndexContentModel;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 首页广告类型1
* 用到的数据 Name、Image、ImageLink
* Created by Junnan on 2018/3/14.
*/
public class Content_1_ItemView extends ItemViewFactory<IndexContentModel, Content_1_ItemView.Content_1_ViewHolder> {
public Content_1_ItemView(Context context, IndexContentModel data) {
super(context, data);
}
@Override
public Content_1_ViewHolder onCreateViewHolder(Context context, ViewGroup parent) {
return new Content_1_ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_index_ad_contentl1, parent, false));
}
@Override
public void onBindViewHolder(Context context, Content_1_ViewHolder holder, IndexContentModel data) {
}
static class Content_1_ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.image1)
ImageView image1;
@BindView(R.id.tvTip1)
TextView tvTip1;
@BindView(R.id.llBtn1)
LinearLayout llBtn1;
@BindView(R.id.image2)
ImageView image2;
@BindView(R.id.tvTip2)
TextView tvTip2;
@BindView(R.id.llBtn2)
LinearLayout llBtn2;
@BindView(R.id.image3)
ImageView image3;
@BindView(R.id.tvTip3)
TextView tvTip3;
@BindView(R.id.llBtn3)
LinearLayout llBtn3;
@BindView(R.id.image4)
ImageView image4;
@BindView(R.id.tvTip4)
TextView tvTip4;
@BindView(R.id.llBtn4)
LinearLayout llBtn4;
Content_1_ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
}
| UTF-8 | Java | 2,142 | java | Content_1_ItemView.java | Java | [
{
"context": "页广告类型1\n * 用到的数据 Name、Image、ImageLink\n * Created by Junnan on 2018/3/14.\n */\n\npublic class Content_1_ItemVie",
"end": 609,
"score": 0.7355895042419434,
"start": 603,
"tag": "USERNAME",
"value": "Junnan"
}
] | null | [] | package com.launch.alititlewithlist.view.cell;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.launch.alititlewithlist.R;
import com.launch.alititlewithlist.adapter.ItemViewFactory;
import com.launch.alititlewithlist.model.IndexContentModel;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 首页广告类型1
* 用到的数据 Name、Image、ImageLink
* Created by Junnan on 2018/3/14.
*/
public class Content_1_ItemView extends ItemViewFactory<IndexContentModel, Content_1_ItemView.Content_1_ViewHolder> {
public Content_1_ItemView(Context context, IndexContentModel data) {
super(context, data);
}
@Override
public Content_1_ViewHolder onCreateViewHolder(Context context, ViewGroup parent) {
return new Content_1_ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_index_ad_contentl1, parent, false));
}
@Override
public void onBindViewHolder(Context context, Content_1_ViewHolder holder, IndexContentModel data) {
}
static class Content_1_ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.image1)
ImageView image1;
@BindView(R.id.tvTip1)
TextView tvTip1;
@BindView(R.id.llBtn1)
LinearLayout llBtn1;
@BindView(R.id.image2)
ImageView image2;
@BindView(R.id.tvTip2)
TextView tvTip2;
@BindView(R.id.llBtn2)
LinearLayout llBtn2;
@BindView(R.id.image3)
ImageView image3;
@BindView(R.id.tvTip3)
TextView tvTip3;
@BindView(R.id.llBtn3)
LinearLayout llBtn3;
@BindView(R.id.image4)
ImageView image4;
@BindView(R.id.tvTip4)
TextView tvTip4;
@BindView(R.id.llBtn4)
LinearLayout llBtn4;
Content_1_ViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
}
| 2,142 | 0.692817 | 0.672495 | 75 | 27.213333 | 25.889145 | 127 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52 | false | false | 9 |
692e15c6cc9b7ae1341c11dd397dfe817b76256b | 22,462,678,969,199 | 3c50b8498801f21410eb70e25d1647d80e2bc335 | /src/main/java/io/choerodon/devops/app/service/SendNotificationService.java | 621713557fe37241090490e9bc843a348ed13b96 | [] | no_license | dzoverflow/devops-service | https://github.com/dzoverflow/devops-service | 18f1db8d9e8b3ed3a93ca55e89825292b8b05e00 | 5193875a9e70323eed76727826c365a3c3cdb411 | refs/heads/master | 2023-08-25T21:17:48.772000 | 2021-11-11T03:13:31 | 2021-11-11T03:13:31 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.choerodon.devops.app.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.hzero.boot.message.entity.Receiver;
import io.choerodon.devops.api.vo.DevopsUserPermissionVO;
import io.choerodon.devops.app.eventhandler.payload.DevopsEnvUserPayload;
import io.choerodon.devops.infra.dto.*;
import io.choerodon.devops.infra.dto.iam.ProjectDTO;
/**
* 发送通知的服务
*
* @author zmf
* @since 12/5/19
*/
public interface SendNotificationService {
/**
* 发送通知
*
* @param sendSettingCode 通知code
* @param receivers 目标用户
* @param params 参数映射
*/
void sendNotices(String sendSettingCode, List<Receiver> receivers, Map<String, String> params, Long projectId);
/**
* 创建应用服务发送webhook通知
*/
void sendWhenAppServiceCreate(AppServiceDTO appServiceDTO);
/**
* 当应用服务创建失败后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceFailure(Long appServiceId);
/**
* 当应用服务启用后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceEnabled(Long appServiceId);
/**
* 当应用服务停用后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceDisabled(Long appServiceId);
// WebHookJsonSendDTO getWebHookJsonSendDTO(JSONObject JSONObject, String code, Long createdBy, Date lastUpdateDate);
/**
* 删除应用服务通知
*/
void sendWhenAppServiceDelete(List<DevopsUserPermissionVO> devopsUserPermissionVOS, AppServiceDTO appServiceDTO);
/**
* 当持续集成失败后
*
* @param gitlabPipelineId gitlab的pipeline的id(GitLab存的id)
* @param appServiceDTO 持续集成流水线所属的应用服务
* @param pipelineOperatorUserName pipeline操作者的用户名(正常情况下,pipeline中包含的用户名是猪齿鱼中用户的登录名)
*/
void sendWhenCDFailure(Long gitlabPipelineId, AppServiceDTO appServiceDTO, String pipelineOperatorUserName);
/**
* 当有合并请求需要审核时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
*/
void sendWhenMergeRequestAuditEvent(Integer gitlabProjectId, Long mergeRequestId);
/**
* 当合并请求被关闭时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
* @param userLoginName iam_user login_name
*/
void sendWhenMergeRequestClosed(Integer gitlabProjectId, Long mergeRequestId, String userLoginName);
/**
* 当合并请求被通过时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
* @param userLoginName iam_user login_name
*/
void sendWhenMergeRequestPassed(Integer gitlabProjectId, Long mergeRequestId, String userLoginName);
/**
* 当创建实例失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenInstanceCreationFailure(AppServiceInstanceDTO appServiceInstanceDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建网络失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenServiceCreationFailure(DevopsServiceDTO devopsServiceDTO, Long creatorId, DevopsEnvironmentDTO devopsEnvironmentDTO, @Nullable Long resourceCommandId);
/**
* 当创建域名失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenIngressCreationFailure(DevopsIngressDTO devopsIngressDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建证书失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenCertificationCreationFailure(CertificationDTO certificationDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建用户时,将用户的默认随机密码发送给用户
*
* @param userId 猪齿鱼用户id
* @param password 密码
*/
void sendForUserDefaultPassword(String userId, String password);
/**
* 创建环境成功发送webhook
*/
void sendWhenEnvCreate(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 启用环境发送webhook
*/
void sendWhenEnvEnable(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
void sendWhenEnvDisable(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 删除环境发送webhook
*/
void sendWhenEnvDelete(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 创建环境失败发送消息
*/
void sendWhenCreateEnvFailed(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 分配权限发送webhook json
*/
void sendWhenEnvUpdatePermissions(DevopsEnvUserPayload devopsEnvUserPayload, ProjectDTO projectDTO);
void sendWhenCreateCluster(DevopsClusterDTO devopsClusterDTO, ProjectDTO iamProject);
/**
* 激活集群发送webhook
*/
void sendWhenActivateCluster(DevopsClusterDTO devopsClusterDTO);
/**
* 删除集群
*/
void sendWhenDeleteCluster(DevopsClusterDTO devopsClusterDTO);
/**
* 组件安装失败发送webhook
*/
void sendWhenResourceInstallFailed(DevopsClusterResourceDTO devopsClusterResourceDTO, String value, String type, Long clusterId, String payload);
void sendWhenCDSuccess(AppServiceDTO appServiceDTO, String pipelineOperatorUserName);
void sendWhenAppServiceVersion(AppServiceVersionDTO appServiceVersionDTO, AppServiceDTO appServiceDTO, ProjectDTO projectDTO);
void sendWhenCreateClusterFail(DevopsClusterDTO devopsClusterDTO, ProjectDTO iamProject, String error);
/**
* 创建PVC资源成功或者失败webhook json 通知
*/
void sendWhenPVCResource(DevopsPvcDTO devopsPvcDTO, DevopsEnvironmentDTO devopsEnvironmentDTO, String code);
void sendWhenServiceCreationSuccessOrDelete(DevopsServiceDTO devopsServiceDTO, DevopsEnvironmentDTO devopsEnvironmentDTO, String code);
/**
* 实例创建成功 删除发送webhook json
*/
void sendWhenInstanceSuccessOrDelete(AppServiceInstanceDTO appServiceInstanceDTO, String value);
/**
* 域名创建 删除 发送webhook 通知
*/
void sendWhenIngressSuccessOrDelete(DevopsIngressDTO devopsIngressDTO, String code);
void sendWhenCertSuccessOrDelete(CertificationDTO certificationDTO, String code);
void sendWhenConfigMap(DevopsConfigMapDTO devopsConfigMapDTO, String value);
void sendWhenSecret(DevopsSecretDTO devopsSecretDTO, String code);
void sendPipelineAuditMassage(String type, List<Long> auditUser, Long pipelineRecordId, String stageName, Long stageId,Long detailsUserId);
void sendCdPipelineNotice(Long pipelineRecordId, String type, Long userId, String email, HashMap<String, String> params);
void sendCiPipelineNotice(Long pipelineRecordId, String type, Long userId, String email, HashMap<String, String> params);
void sendCdPipelineNotice(Long pipelineRecordId, String type, List<Receiver> receivers, @Nullable Map<String, String> params);
/**
* 实例状态变更发送webhook josn
*/
void sendInstanceStatusUpdate(AppServiceInstanceDTO appServiceInstanceDTO, DevopsEnvCommandDTO devopsEnvCommandDTO, String currentStatus);
/**
* 发送API测试告警通知
* @param type
* @param userIds
* @param params
*/
void sendApiTestWarningMessage(Set<Long> userIds, Map<String, String> params, Long projectId);
}
| UTF-8 | Java | 8,326 | java | SendNotificationService.java | Java | [
{
"context": ".dto.iam.ProjectDTO;\n\n/**\n * 发送通知的服务\n *\n * @author zmf\n * @since 12/5/19\n */\npublic interface SendNotifi",
"end": 476,
"score": 0.9997049570083618,
"start": 473,
"tag": "USERNAME",
"value": "zmf"
},
{
"context": "用户时,将用户的默认随机密码发送给用户\n *\n * @param userId... | null | [] | package io.choerodon.devops.app.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.hzero.boot.message.entity.Receiver;
import io.choerodon.devops.api.vo.DevopsUserPermissionVO;
import io.choerodon.devops.app.eventhandler.payload.DevopsEnvUserPayload;
import io.choerodon.devops.infra.dto.*;
import io.choerodon.devops.infra.dto.iam.ProjectDTO;
/**
* 发送通知的服务
*
* @author zmf
* @since 12/5/19
*/
public interface SendNotificationService {
/**
* 发送通知
*
* @param sendSettingCode 通知code
* @param receivers 目标用户
* @param params 参数映射
*/
void sendNotices(String sendSettingCode, List<Receiver> receivers, Map<String, String> params, Long projectId);
/**
* 创建应用服务发送webhook通知
*/
void sendWhenAppServiceCreate(AppServiceDTO appServiceDTO);
/**
* 当应用服务创建失败后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceFailure(Long appServiceId);
/**
* 当应用服务启用后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceEnabled(Long appServiceId);
/**
* 当应用服务停用后,发送消息
*
* @param appServiceId 应用服务id
*/
void sendWhenAppServiceDisabled(Long appServiceId);
// WebHookJsonSendDTO getWebHookJsonSendDTO(JSONObject JSONObject, String code, Long createdBy, Date lastUpdateDate);
/**
* 删除应用服务通知
*/
void sendWhenAppServiceDelete(List<DevopsUserPermissionVO> devopsUserPermissionVOS, AppServiceDTO appServiceDTO);
/**
* 当持续集成失败后
*
* @param gitlabPipelineId gitlab的pipeline的id(GitLab存的id)
* @param appServiceDTO 持续集成流水线所属的应用服务
* @param pipelineOperatorUserName pipeline操作者的用户名(正常情况下,pipeline中包含的用户名是猪齿鱼中用户的登录名)
*/
void sendWhenCDFailure(Long gitlabPipelineId, AppServiceDTO appServiceDTO, String pipelineOperatorUserName);
/**
* 当有合并请求需要审核时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
*/
void sendWhenMergeRequestAuditEvent(Integer gitlabProjectId, Long mergeRequestId);
/**
* 当合并请求被关闭时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
* @param userLoginName iam_user login_name
*/
void sendWhenMergeRequestClosed(Integer gitlabProjectId, Long mergeRequestId, String userLoginName);
/**
* 当合并请求被通过时
*
* @param gitlabProjectId gitlab项目id
* @param mergeRequestId 合并请求的id
* @param userLoginName iam_user login_name
*/
void sendWhenMergeRequestPassed(Integer gitlabProjectId, Long mergeRequestId, String userLoginName);
/**
* 当创建实例失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenInstanceCreationFailure(AppServiceInstanceDTO appServiceInstanceDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建网络失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenServiceCreationFailure(DevopsServiceDTO devopsServiceDTO, Long creatorId, DevopsEnvironmentDTO devopsEnvironmentDTO, @Nullable Long resourceCommandId);
/**
* 当创建域名失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenIngressCreationFailure(DevopsIngressDTO devopsIngressDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建证书失败后
*
* @param creatorId 资源创建者的id
* @param resourceCommandId 资源的command id (不为null时校验command的commandType是不是create)
*/
void sendWhenCertificationCreationFailure(CertificationDTO certificationDTO, Long creatorId, @Nullable Long resourceCommandId);
/**
* 当创建用户时,将用户的默认随机密码发送给用户
*
* @param userId 猪齿鱼用户id
* @param password 密码
*/
void sendForUserDefaultPassword(String userId, String password);
/**
* 创建环境成功发送webhook
*/
void sendWhenEnvCreate(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 启用环境发送webhook
*/
void sendWhenEnvEnable(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
void sendWhenEnvDisable(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 删除环境发送webhook
*/
void sendWhenEnvDelete(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 创建环境失败发送消息
*/
void sendWhenCreateEnvFailed(DevopsEnvironmentDTO devopsEnvironmentDTO, Long organizationId);
/**
* 分配权限发送webhook json
*/
void sendWhenEnvUpdatePermissions(DevopsEnvUserPayload devopsEnvUserPayload, ProjectDTO projectDTO);
void sendWhenCreateCluster(DevopsClusterDTO devopsClusterDTO, ProjectDTO iamProject);
/**
* 激活集群发送webhook
*/
void sendWhenActivateCluster(DevopsClusterDTO devopsClusterDTO);
/**
* 删除集群
*/
void sendWhenDeleteCluster(DevopsClusterDTO devopsClusterDTO);
/**
* 组件安装失败发送webhook
*/
void sendWhenResourceInstallFailed(DevopsClusterResourceDTO devopsClusterResourceDTO, String value, String type, Long clusterId, String payload);
void sendWhenCDSuccess(AppServiceDTO appServiceDTO, String pipelineOperatorUserName);
void sendWhenAppServiceVersion(AppServiceVersionDTO appServiceVersionDTO, AppServiceDTO appServiceDTO, ProjectDTO projectDTO);
void sendWhenCreateClusterFail(DevopsClusterDTO devopsClusterDTO, ProjectDTO iamProject, String error);
/**
* 创建PVC资源成功或者失败webhook json 通知
*/
void sendWhenPVCResource(DevopsPvcDTO devopsPvcDTO, DevopsEnvironmentDTO devopsEnvironmentDTO, String code);
void sendWhenServiceCreationSuccessOrDelete(DevopsServiceDTO devopsServiceDTO, DevopsEnvironmentDTO devopsEnvironmentDTO, String code);
/**
* 实例创建成功 删除发送webhook json
*/
void sendWhenInstanceSuccessOrDelete(AppServiceInstanceDTO appServiceInstanceDTO, String value);
/**
* 域名创建 删除 发送webhook 通知
*/
void sendWhenIngressSuccessOrDelete(DevopsIngressDTO devopsIngressDTO, String code);
void sendWhenCertSuccessOrDelete(CertificationDTO certificationDTO, String code);
void sendWhenConfigMap(DevopsConfigMapDTO devopsConfigMapDTO, String value);
void sendWhenSecret(DevopsSecretDTO devopsSecretDTO, String code);
void sendPipelineAuditMassage(String type, List<Long> auditUser, Long pipelineRecordId, String stageName, Long stageId,Long detailsUserId);
void sendCdPipelineNotice(Long pipelineRecordId, String type, Long userId, String email, HashMap<String, String> params);
void sendCiPipelineNotice(Long pipelineRecordId, String type, Long userId, String email, HashMap<String, String> params);
void sendCdPipelineNotice(Long pipelineRecordId, String type, List<Receiver> receivers, @Nullable Map<String, String> params);
/**
* 实例状态变更发送webhook josn
*/
void sendInstanceStatusUpdate(AppServiceInstanceDTO appServiceInstanceDTO, DevopsEnvCommandDTO devopsEnvCommandDTO, String currentStatus);
/**
* 发送API测试告警通知
* @param type
* @param userIds
* @param params
*/
void sendApiTestWarningMessage(Set<Long> userIds, Map<String, String> params, Long projectId);
}
| 8,326 | 0.727273 | 0.726602 | 238 | 30.336134 | 39.290401 | 168 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533613 | false | false | 9 |
44a8180f6bcfdd439918c8f08a49934a56c4bd2c | 27,041,114,109,988 | 05d4ed896128c86b30b6735401a1c71b866427e4 | /src/main/java/main.java | 9e3eedc520e34bf9b0d7c8d7be98b14e7732395d | [] | no_license | MavenOfCode/16-binary-tree | https://github.com/MavenOfCode/16-binary-tree | 4d68fbd32ee26687f53228cb25a8c2f385126a80 | 41075752c6bfed5f0b042030c06627400bed6278 | refs/heads/master | 2020-03-24T20:05:23.985000 | 2018-08-13T05:02:14 | 2018-08-13T05:02:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class main {
public static void main(String[] args) {
//wiring up a tree from lab README
BinaryTree myTestTree = new BinaryTree();
myTestTree.add(53);
myTestTree.add(18);
myTestTree.add(12);
myTestTree.add(24);
myTestTree.add(75);
myTestTree.add(66);
myTestTree.add(99);
System.out.println(myTestTree.toString());
//this should return 7
int size = myTestTree.size();
System.out.println(size);
//this should return false, since the tree doesn't contain the value 4
boolean contains= myTestTree.contains(4);
System.out.println(contains);
}
}
| UTF-8 | Java | 688 | java | main.java | Java | [] | null | [] |
public class main {
public static void main(String[] args) {
//wiring up a tree from lab README
BinaryTree myTestTree = new BinaryTree();
myTestTree.add(53);
myTestTree.add(18);
myTestTree.add(12);
myTestTree.add(24);
myTestTree.add(75);
myTestTree.add(66);
myTestTree.add(99);
System.out.println(myTestTree.toString());
//this should return 7
int size = myTestTree.size();
System.out.println(size);
//this should return false, since the tree doesn't contain the value 4
boolean contains= myTestTree.contains(4);
System.out.println(contains);
}
}
| 688 | 0.601744 | 0.577035 | 24 | 27.625 | 19.351599 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.583333 | false | false | 9 |
0c2aa023fd86a51d7db046b08c257e0d6f7b1424 | 12,953,621,416,466 | c6df724027caef955b9e8a9df6f8cec200194a15 | /src/main/java/com/repository/equipment/ComputerRepository.java | c8469764af6e1d017f3fe44eea220210d5462ba0 | [] | no_license | kay1997/SchoolManagementSystem | https://github.com/kay1997/SchoolManagementSystem | 1a23f5cb32f172b6bfa2511e61723299052b7d4b | 30521cc29968b6b5e2a4e5feb3dc058665e2d660 | refs/heads/master | 2022-05-10T20:28:47.327000 | 2019-09-28T13:21:46 | 2019-09-28T13:21:46 | 181,853,870 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.repository.equipment;
import com.domain.equipment.Computer;
import com.repository.IRepository;
import java.util.Set;
public interface ComputerRepository extends IRepository<Computer, String> {
Set<Computer> getAll();
}
| UTF-8 | Java | 241 | java | ComputerRepository.java | Java | [] | null | [] | package com.repository.equipment;
import com.domain.equipment.Computer;
import com.repository.IRepository;
import java.util.Set;
public interface ComputerRepository extends IRepository<Computer, String> {
Set<Computer> getAll();
}
| 241 | 0.788382 | 0.788382 | 11 | 20.818182 | 22.94982 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 9 |
ad7381dec8e32aeb13ef782a00a0440bbe28f78d | 28,054,726,396,587 | 917a4da4cfb0178318aab9b6fb29733bce6e632f | /Android/main/src/main/java/com/appbuilder/core/xmlconfiguration/ConfigDAO.java | ca67cdb935ba509e9bea5f6e354f34dcd26d1118 | [] | no_license | iBuildApp-Network/Marketplace | https://github.com/iBuildApp-Network/Marketplace | 5f33692dee7640fefc7c83266692066eee9b318c | e8c317de9b58c2008f494e4101486fe784d55698 | refs/heads/master | 2021-09-01T23:35:41.750000 | 2017-12-29T07:02:14 | 2017-12-29T07:02:14 | 109,104,352 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /****************************************************************************
* *
* Copyright (C) 2014-2015 iBuildApp, Inc. ( http://ibuildapp.com ) *
* *
* This file is part of iBuildApp. *
* *
* This Source Code Form is subject to the terms of the iBuildApp License. *
* You can obtain one at http://ibuildapp.com/license/ *
* *
****************************************************************************/
package com.appbuilder.core.xmlconfiguration;
import android.util.Log;
import java.io.*;
/**
* Created with IntelliJ IDEA.
* User: macbookpro
* Date: 18.11.14
* Time: 13:13
* To change this template use File | Settings | File Templates.
*/
public class ConfigDAO {
private static final String LOG_TAG = ConfigDAO.class.getCanonicalName();
public static AppConfigure getConfig( String cachePath, String cacheFileName) {
// DEserialization
File userCache = new File(cachePath + File.separator + cacheFileName);
if (userCache.exists()) {
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(userCache));
AppConfigure filter = (AppConfigure) ois.readObject();
ois.close();
return filter;
} catch (Exception e) {
Log.e(LOG_TAG, "", e);
return null;
}
} else {
return null;
}
}
public static void setConfig(String cachePath, String cacheFileName, AppConfigure config ) {
// serialization
File cachePathFile = new File(cachePath);
if ( !cachePathFile.exists() )
cachePathFile.mkdirs();
File cache = new File(cachePath + File.separator + cacheFileName);
if (cache.exists()) {
cache.delete();
}
try {
cache.createNewFile();
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cache));
oos.writeObject(config);
oos.close();
} catch (Exception e) {
Log.e(LOG_TAG, "", e);
cache.delete();
}
}
}
| UTF-8 | Java | 2,486 | java | ConfigDAO.java | Java | [
{
"context": "io.*;\n\n/**\n * Created with IntelliJ IDEA.\n * User: macbookpro\n * Date: 18.11.14\n * Time: 13:13\n * To change thi",
"end": 926,
"score": 0.9995598793029785,
"start": 916,
"tag": "USERNAME",
"value": "macbookpro"
}
] | null | [] | /****************************************************************************
* *
* Copyright (C) 2014-2015 iBuildApp, Inc. ( http://ibuildapp.com ) *
* *
* This file is part of iBuildApp. *
* *
* This Source Code Form is subject to the terms of the iBuildApp License. *
* You can obtain one at http://ibuildapp.com/license/ *
* *
****************************************************************************/
package com.appbuilder.core.xmlconfiguration;
import android.util.Log;
import java.io.*;
/**
* Created with IntelliJ IDEA.
* User: macbookpro
* Date: 18.11.14
* Time: 13:13
* To change this template use File | Settings | File Templates.
*/
public class ConfigDAO {
private static final String LOG_TAG = ConfigDAO.class.getCanonicalName();
public static AppConfigure getConfig( String cachePath, String cacheFileName) {
// DEserialization
File userCache = new File(cachePath + File.separator + cacheFileName);
if (userCache.exists()) {
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(userCache));
AppConfigure filter = (AppConfigure) ois.readObject();
ois.close();
return filter;
} catch (Exception e) {
Log.e(LOG_TAG, "", e);
return null;
}
} else {
return null;
}
}
public static void setConfig(String cachePath, String cacheFileName, AppConfigure config ) {
// serialization
File cachePathFile = new File(cachePath);
if ( !cachePathFile.exists() )
cachePathFile.mkdirs();
File cache = new File(cachePath + File.separator + cacheFileName);
if (cache.exists()) {
cache.delete();
}
try {
cache.createNewFile();
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(cache));
oos.writeObject(config);
oos.close();
} catch (Exception e) {
Log.e(LOG_TAG, "", e);
cache.delete();
}
}
}
| 2,486 | 0.462993 | 0.455752 | 68 | 35.558823 | 29.612886 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false | 9 |
d05fc33f61d8ad07cc2f55fcad42b39403a01037 | 11,184,094,845,106 | a3decc18c136c82c3c48d398f5e873f5b79d3082 | /source.java | a03c2dff7e0e52ba32715487aa127a9fbb3a67bd | [] | no_license | annamarie0408/TeachersApplePurchase | https://github.com/annamarie0408/TeachersApplePurchase | 6aa8cabaadbcc80c129fd8f238b44c92cf11c772 | 34772bdcafd9aa97615d2a1173e8ba2a7209791b | refs/heads/master | 2020-04-27T14:01:13.324000 | 2019-03-07T17:50:00 | 2019-03-07T17:50:00 | 174,393,230 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner; //importing the scanner
public class Project1
{
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
//Defining Variables
int numApples, totalNumStudents, leftOverApplesStudents, lefOverApplesTeacher;
double applePrice = 0.00, amount = 0.00, discount,total, salesTax;
final double applePie = 10.00, appleCobbler = 15.00, gallonAppleCider = 8.00;
String teachersLastName, teachersSalutation, dayOfWeek, teacherChoice;
//Asking input for the amount of apples picked
//If the amount is more than 200, it will ask the user to input another number
System.out.print("How many apples were collected? ");
numApples = input.nextInt();
if (numApples > 200){
System.out.print("Error! You can only order 200 apples for the students, please re-enter a number less than 200 ");
numApples = input.nextInt();
}
//Asking the day of the week
//Will check the input to make sure it is correct. If the word is spelt wrong or just not a date
//the program will ask for another input
System.out.print("What is the day of the week? ");
dayOfWeek = input.next();
if ( dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") ||
dayOfWeek.equalsIgnoreCase("Wednesday") || dayOfWeek.equalsIgnoreCase("Thursday") ||
dayOfWeek.equalsIgnoreCase("Friday") || dayOfWeek.equalsIgnoreCase("Saturday") ||
dayOfWeek.equalsIgnoreCase("Sunday")) {
dayOfWeek = Character.toString(dayOfWeek.charAt(0)).toUpperCase()+dayOfWeek.substring(1); //making the first letter capital, regardless what the user typed in
}
else {
System.out.print("Error! Incorrect Wording!! Please enter a day of the week: ");
dayOfWeek = input.next();
dayOfWeek = Character.toString(dayOfWeek.charAt(0)).toUpperCase()+dayOfWeek.substring(1); //making the first letter capital, regardless what the user typed in
}
//Asking the amount of students
System.out.print("How many students are there? ");
totalNumStudents = input.nextInt();
//Asking for the Teachers last name
System.out.print("Hello, please enter the teachers last name: ");
teachersLastName = input.next();
teachersLastName = Character.toString(teachersLastName.charAt(0)).toUpperCase()+teachersLastName.substring(1); //making the first letter capital, regardless what the user typed in
//Asking for the salutation of the teacher
System.out.print("Please enter the teachers salutation: ");
teachersSalutation = input.next();
teachersSalutation = Character.toString(teachersSalutation.charAt(0)).toUpperCase()+teachersSalutation.substring(1); //making the first letter capital, regardless what the user typed in
//Math to find the amount of apples the students have and the teacher
leftOverApplesStudents = numApples / totalNumStudents;
lefOverApplesTeacher = numApples - (leftOverApplesStudents * totalNumStudents);
//Printing to the console the results at the moment
System.out.println(teachersSalutation + " " + teachersLastName + ", you have " + leftOverApplesStudents +
" apples per a student with " + lefOverApplesTeacher + " left over for you");
System.out.println(" "); //creating an empty line just for clearer reading
//menu and choices
System.out.println("Would you like to order the following? ");
System.out.println("Apple Pie: $" + applePie);
System.out.println("Apple Cobbler: $" + appleCobbler);
System.out.println("Gallon of Apple Cider: $" + gallonAppleCider);
System.out.println(" ");
System.out.print("Please enter either Apple Pie, Apple Cobbler, Apple Cider or None.");
input.nextLine(); //extra line so that we can grab the users full input
teacherChoice = input.nextLine();
teacherChoice = Character.toString(teacherChoice.charAt(0)).toUpperCase()+teacherChoice.substring(1); //making the first letter capital, regardless what the user typed in
//Switch statement that will take the number of apples collected and find the amount to pay for them.
switch (numApples/50){
case 0: applePrice = 10.00;
break;
case 1: applePrice = 15.00;
break;
case 2: applePrice = 20.00;
break;
case 3: applePrice = 30.00;
break;
}
//if-else if statement to find the discount of the items, if there is one!
if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
amount = applePie;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
discount = 2.00;
amount = applePie - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
discount = 3.00;
amount = applePie - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
amount = appleCobbler;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
discount = 2.00;
amount = appleCobbler - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
discount = 3.00;
amount = appleCobbler - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale, today " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
amount = gallonAppleCider;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
discount = 2.00;
amount = gallonAppleCider - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
discount = 3.00;
amount = gallonAppleCider - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("None")) {
amount = applePrice;
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("None"))
{
amount = applePrice;
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("None"))
{
amount = applePrice;
}
//math to find the sales tax and total!
salesTax = (applePrice + amount) * 0.07;
total = salesTax + applePrice;
//final system print out.
System.out.println(" ");
System.out.printf("Your total today (collection plus teacher item): $%4.2f", total);
System.out.println(" ");
}
}
| UTF-8 | Java | 9,839 | java | source.java | Java | [] | null | [] | import java.util.Scanner; //importing the scanner
public class Project1
{
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
//Defining Variables
int numApples, totalNumStudents, leftOverApplesStudents, lefOverApplesTeacher;
double applePrice = 0.00, amount = 0.00, discount,total, salesTax;
final double applePie = 10.00, appleCobbler = 15.00, gallonAppleCider = 8.00;
String teachersLastName, teachersSalutation, dayOfWeek, teacherChoice;
//Asking input for the amount of apples picked
//If the amount is more than 200, it will ask the user to input another number
System.out.print("How many apples were collected? ");
numApples = input.nextInt();
if (numApples > 200){
System.out.print("Error! You can only order 200 apples for the students, please re-enter a number less than 200 ");
numApples = input.nextInt();
}
//Asking the day of the week
//Will check the input to make sure it is correct. If the word is spelt wrong or just not a date
//the program will ask for another input
System.out.print("What is the day of the week? ");
dayOfWeek = input.next();
if ( dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") ||
dayOfWeek.equalsIgnoreCase("Wednesday") || dayOfWeek.equalsIgnoreCase("Thursday") ||
dayOfWeek.equalsIgnoreCase("Friday") || dayOfWeek.equalsIgnoreCase("Saturday") ||
dayOfWeek.equalsIgnoreCase("Sunday")) {
dayOfWeek = Character.toString(dayOfWeek.charAt(0)).toUpperCase()+dayOfWeek.substring(1); //making the first letter capital, regardless what the user typed in
}
else {
System.out.print("Error! Incorrect Wording!! Please enter a day of the week: ");
dayOfWeek = input.next();
dayOfWeek = Character.toString(dayOfWeek.charAt(0)).toUpperCase()+dayOfWeek.substring(1); //making the first letter capital, regardless what the user typed in
}
//Asking the amount of students
System.out.print("How many students are there? ");
totalNumStudents = input.nextInt();
//Asking for the Teachers last name
System.out.print("Hello, please enter the teachers last name: ");
teachersLastName = input.next();
teachersLastName = Character.toString(teachersLastName.charAt(0)).toUpperCase()+teachersLastName.substring(1); //making the first letter capital, regardless what the user typed in
//Asking for the salutation of the teacher
System.out.print("Please enter the teachers salutation: ");
teachersSalutation = input.next();
teachersSalutation = Character.toString(teachersSalutation.charAt(0)).toUpperCase()+teachersSalutation.substring(1); //making the first letter capital, regardless what the user typed in
//Math to find the amount of apples the students have and the teacher
leftOverApplesStudents = numApples / totalNumStudents;
lefOverApplesTeacher = numApples - (leftOverApplesStudents * totalNumStudents);
//Printing to the console the results at the moment
System.out.println(teachersSalutation + " " + teachersLastName + ", you have " + leftOverApplesStudents +
" apples per a student with " + lefOverApplesTeacher + " left over for you");
System.out.println(" "); //creating an empty line just for clearer reading
//menu and choices
System.out.println("Would you like to order the following? ");
System.out.println("Apple Pie: $" + applePie);
System.out.println("Apple Cobbler: $" + appleCobbler);
System.out.println("Gallon of Apple Cider: $" + gallonAppleCider);
System.out.println(" ");
System.out.print("Please enter either Apple Pie, Apple Cobbler, Apple Cider or None.");
input.nextLine(); //extra line so that we can grab the users full input
teacherChoice = input.nextLine();
teacherChoice = Character.toString(teacherChoice.charAt(0)).toUpperCase()+teacherChoice.substring(1); //making the first letter capital, regardless what the user typed in
//Switch statement that will take the number of apples collected and find the amount to pay for them.
switch (numApples/50){
case 0: applePrice = 10.00;
break;
case 1: applePrice = 15.00;
break;
case 2: applePrice = 20.00;
break;
case 3: applePrice = 30.00;
break;
}
//if-else if statement to find the discount of the items, if there is one!
if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
amount = applePie;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
discount = 2.00;
amount = applePie - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Pie"))
{
discount = 3.00;
amount = applePie - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
amount = appleCobbler;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
discount = 2.00;
amount = appleCobbler - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Cobbler"))
{
discount = 3.00;
amount = appleCobbler - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale, today " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
amount = gallonAppleCider;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
discount = 2.00;
amount = gallonAppleCider - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("Apple Cider"))
{
discount = 3.00;
amount = gallonAppleCider - discount;
System.out.printf("Great choice, " + teachersSalutation + " " + teachersLastName + " - " + teacherChoice +
" is an excellent choice and is on sale today, " + dayOfWeek + " for $%4.2f", amount);
}
else if (dayOfWeek.equalsIgnoreCase("Monday") || dayOfWeek.equalsIgnoreCase("Tuesday") || dayOfWeek.equalsIgnoreCase("Wednesday") && teacherChoice.equalsIgnoreCase("None")) {
amount = applePrice;
}
else if (dayOfWeek.equalsIgnoreCase("Thursday") || dayOfWeek.equalsIgnoreCase("Friday") && teacherChoice.equalsIgnoreCase("None"))
{
amount = applePrice;
}
else if (dayOfWeek.equalsIgnoreCase("Saturday") || dayOfWeek.equalsIgnoreCase("Sunday") && teacherChoice.equalsIgnoreCase("None"))
{
amount = applePrice;
}
//math to find the sales tax and total!
salesTax = (applePrice + amount) * 0.07;
total = salesTax + applePrice;
//final system print out.
System.out.println(" ");
System.out.printf("Your total today (collection plus teacher item): $%4.2f", total);
System.out.println(" ");
}
}
| 9,839 | 0.625978 | 0.61551 | 203 | 47.467979 | 50.602699 | 193 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.837438 | false | false | 9 |
db529ff64846ca13a1a03b3f2405a77792e5fd09 | 3,779,571,239,237 | 2670ce041ba7dc36a52cc21cdd2eec90c2164c81 | /src/main/java/src/KVStoreServerHandler.java | b141b744e7f2305668e4c9b629f767ea7b933075 | [] | no_license | abhangs/Tribbler | https://github.com/abhangs/Tribbler | 00c5eb04d4592140f3bbb40cc0d5fd3da1005891 | 3a8890eb7481a9a71c16d2ad480f184b32483b62 | refs/heads/master | 2021-01-18T14:05:31.679000 | 2014-07-14T04:12:13 | 2014-07-14T04:12:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package src;
import include.KeyValueStore.GetListResponse;
import include.KeyValueStore.GetResponse;
import include.KeyValueStore.KVStoreStatus;
import include.KeyValueStore.KeyValueStore;
import org.apache.thrift.TException;
import redis.clients.jedis.Jedis;
import sun.awt.CausedFocusEvent;
import sun.org.mozilla.javascript.internal.ast.NewExpression;
import javax.tools.JavaCompiler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.ExecutionException;
//This class implements the key-value backend server
//REDIS (open source) key-value store used for persistent storage
//JEDIS: Using open source JEDIS as java client for REDIS
public class KVStoreServerHandler implements KeyValueStore.Iface {
private String _storageServer;
private int _storageServerPort;
private static Jedis jedis;
private static GetResponse response;
private static GetListResponse listResponse;
public KVStoreServerHandler(String storageServer, int storageServerPort)
{
_storageServer = storageServer;
_storageServerPort = storageServerPort;
jedis = new Jedis(_storageServer,_storageServerPort);
response = new GetResponse();
listResponse = new GetListResponse();
}
@Override
public GetResponse Get(String key) throws TException {
try
{
String value = jedis.get(key);
if(value.isEmpty())
{
throw new NullPointerException();
}
response.setValue(value);
response.setStatus(KVStoreStatus.OK);
return response;
}
catch(Exception ex)
{
if(ex.getClass()== NullPointerException.class)
{
response.setStatus(KVStoreStatus.EITEMNOTFOUND);
response.setValue(null);
return response;
}
response.setStatus(KVStoreStatus.EPUTFAILED);
response.setValue(null);
return response;
}
}
@Override
public GetListResponse GetList(String key) throws TException {
try
{
List<String> values = jedis.lrange(key,0,-1);
if(values.isEmpty())
{
throw new NullPointerException();
}
listResponse.setValues(values);
listResponse.setStatus(KVStoreStatus.OK);
return listResponse;
}
catch(Exception ex)
{
if(ex.getClass()==NullPointerException.class)
{
listResponse.setValues(null);
listResponse.setStatus(KVStoreStatus.EITEMNOTFOUND);
return listResponse;
}
listResponse.setValues(null);
listResponse.setStatus(KVStoreStatus.EPUTFAILED);
return listResponse;
}
}
@Override
public KVStoreStatus Put(String key, String value) throws TException {
try
{
if(!jedis.set(key,value).equals("OK"))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch (Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
@Override
public KVStoreStatus AddToList(String key, String value) throws TException {
try
{
if(!(jedis.lpush(key,value)>0))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch (Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
@Override
public KVStoreStatus RemoveFromList(String key, String value) throws TException {
try
{
if(!(jedis.lrem(key,1,value)>0))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch(Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
}
| UTF-8 | Java | 4,072 | java | KVStoreServerHandler.java | Java | [] | null | [] | package src;
import include.KeyValueStore.GetListResponse;
import include.KeyValueStore.GetResponse;
import include.KeyValueStore.KVStoreStatus;
import include.KeyValueStore.KeyValueStore;
import org.apache.thrift.TException;
import redis.clients.jedis.Jedis;
import sun.awt.CausedFocusEvent;
import sun.org.mozilla.javascript.internal.ast.NewExpression;
import javax.tools.JavaCompiler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.ExecutionException;
//This class implements the key-value backend server
//REDIS (open source) key-value store used for persistent storage
//JEDIS: Using open source JEDIS as java client for REDIS
public class KVStoreServerHandler implements KeyValueStore.Iface {
private String _storageServer;
private int _storageServerPort;
private static Jedis jedis;
private static GetResponse response;
private static GetListResponse listResponse;
public KVStoreServerHandler(String storageServer, int storageServerPort)
{
_storageServer = storageServer;
_storageServerPort = storageServerPort;
jedis = new Jedis(_storageServer,_storageServerPort);
response = new GetResponse();
listResponse = new GetListResponse();
}
@Override
public GetResponse Get(String key) throws TException {
try
{
String value = jedis.get(key);
if(value.isEmpty())
{
throw new NullPointerException();
}
response.setValue(value);
response.setStatus(KVStoreStatus.OK);
return response;
}
catch(Exception ex)
{
if(ex.getClass()== NullPointerException.class)
{
response.setStatus(KVStoreStatus.EITEMNOTFOUND);
response.setValue(null);
return response;
}
response.setStatus(KVStoreStatus.EPUTFAILED);
response.setValue(null);
return response;
}
}
@Override
public GetListResponse GetList(String key) throws TException {
try
{
List<String> values = jedis.lrange(key,0,-1);
if(values.isEmpty())
{
throw new NullPointerException();
}
listResponse.setValues(values);
listResponse.setStatus(KVStoreStatus.OK);
return listResponse;
}
catch(Exception ex)
{
if(ex.getClass()==NullPointerException.class)
{
listResponse.setValues(null);
listResponse.setStatus(KVStoreStatus.EITEMNOTFOUND);
return listResponse;
}
listResponse.setValues(null);
listResponse.setStatus(KVStoreStatus.EPUTFAILED);
return listResponse;
}
}
@Override
public KVStoreStatus Put(String key, String value) throws TException {
try
{
if(!jedis.set(key,value).equals("OK"))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch (Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
@Override
public KVStoreStatus AddToList(String key, String value) throws TException {
try
{
if(!(jedis.lpush(key,value)>0))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch (Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
@Override
public KVStoreStatus RemoveFromList(String key, String value) throws TException {
try
{
if(!(jedis.lrem(key,1,value)>0))
{
throw new Exception();
}
return KVStoreStatus.OK;
}
catch(Exception ex)
{
return KVStoreStatus.EPUTFAILED;
}
}
}
| 4,072 | 0.592829 | 0.591601 | 158 | 24.772152 | 21.649948 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.417722 | false | false | 9 |
4c0a62cf721cba199aac7f91c371c70332127f9d | 3,779,571,236,539 | 81757a3d66f1b0615de3608d9cc36a21c0238306 | /src/test/java/compose/bridge/PageTest.java | be605018684ce96b2078a9cea45156973938fbe8 | [] | no_license | jinstrame/paterns | https://github.com/jinstrame/paterns | 6145e71e0f7dbf7d4831ada9b6b3cf325880c6e4 | fb7047ba51cdfcbc7ea02f04f817376e14d39c4a | refs/heads/master | 2021-03-22T02:09:37.545000 | 2017-11-22T17:15:12 | 2017-11-22T17:15:12 | 111,373,574 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package compose.bridge;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
@RunWith(Parameterized.class)
public class PageTest {
@Parameter
public Theme inputParam;
@Parameter(1)
public String expectedResult;
@Parameters(name = "{0}")
public static Collection params() {
return Arrays.asList(
new Object[][] {
{Theme.DARK, "Homepage Content in DARK"},
{Theme.LIGHT, "Homepage Content in LIGHT"}
}
);
}
@Test
public void should_get_content_in_corresponding_theme() throws Exception {
//given
String expected = expectedResult;
HomePage homePage = new HomePage(inputParam, "");
//when
String actual = homePage.getContent();
//then
assertThat(actual, is(expected));
}
} | UTF-8 | Java | 1,142 | java | PageTest.java | Java | [] | null | [] | package compose.bridge;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
@RunWith(Parameterized.class)
public class PageTest {
@Parameter
public Theme inputParam;
@Parameter(1)
public String expectedResult;
@Parameters(name = "{0}")
public static Collection params() {
return Arrays.asList(
new Object[][] {
{Theme.DARK, "Homepage Content in DARK"},
{Theme.LIGHT, "Homepage Content in LIGHT"}
}
);
}
@Test
public void should_get_content_in_corresponding_theme() throws Exception {
//given
String expected = expectedResult;
HomePage homePage = new HomePage(inputParam, "");
//when
String actual = homePage.getContent();
//then
assertThat(actual, is(expected));
}
} | 1,142 | 0.637478 | 0.635727 | 48 | 22.8125 | 20.33947 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.458333 | false | false | 9 |
f7e8e6a96ec1de8b0e05f2fdda536fafc5af73d8 | 1,537,598,317,546 | 1946b53423645b2cb8c381eb6c27b34f4d198e34 | /spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java | 6da41a7abac9f504a9992d87aaed52105da8276a | [
"Apache-2.0"
] | permissive | spring-projects/spring-framework | https://github.com/spring-projects/spring-framework | e0bf18593af55a5cddd57efbb86ebe5da8a8f38e | 759e3d4aa6e4e8154f6428e496275bcd89431bba | refs/heads/main | 2023-09-03T07:44:34.908000 | 2023-09-03T00:32:01 | 2023-09-03T00:32:01 | 1,148,753 | 56,403 | 43,516 | Apache-2.0 | false | 2023-09-14T15:45:05 | 2010-12-08T04:04:45 | 2023-09-14T13:57:45 | 2023-09-14T15:45:03 | 197,376 | 53,106 | 36,868 | 1,183 | Java | false | false | /*
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://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.springframework.test.web.reactive.server;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Mono;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseCookie;
import org.springframework.http.client.reactive.ClientHttpRequest;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
/**
* Container for request and response details for exchanges performed through
* {@link WebTestClient}.
*
* <p>Note that a decoded response body is not exposed at this level since the
* body may not have been decoded and consumed yet. Subtypes
* {@link EntityExchangeResult} and {@link FluxExchangeResult} provide access
* to a decoded response entity and a decoded (but not consumed) response body
* respectively.
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 5.0
* @see EntityExchangeResult
* @see FluxExchangeResult
*/
public class ExchangeResult {
private static final Log logger = LogFactory.getLog(ExchangeResult.class);
private static final List<MediaType> PRINTABLE_MEDIA_TYPES = List.of(
MediaType.parseMediaType("application/*+json"), MediaType.APPLICATION_XML,
MediaType.parseMediaType("text/*"), MediaType.APPLICATION_FORM_URLENCODED);
private final ClientHttpRequest request;
private final ClientHttpResponse response;
private final Mono<byte[]> requestBody;
private final Mono<byte[]> responseBody;
private final Duration timeout;
@Nullable
private final String uriTemplate;
@Nullable
private final Object mockServerResult;
/** Ensure single logging, e.g. for expectAll. */
private boolean diagnosticsLogged;
/**
* Create an instance with an HTTP request and response along with promises
* for the serialized request and response body content.
*
* @param request the HTTP request
* @param response the HTTP response
* @param requestBody capture of serialized request body content
* @param responseBody capture of serialized response body content
* @param timeout how long to wait for content to materialize
* @param uriTemplate the URI template used to set up the request, if any
* @param serverResult the result of a mock server exchange if applicable.
*/
ExchangeResult(ClientHttpRequest request, ClientHttpResponse response,
Mono<byte[]> requestBody, Mono<byte[]> responseBody, Duration timeout, @Nullable String uriTemplate,
@Nullable Object serverResult) {
Assert.notNull(request, "ClientHttpRequest is required");
Assert.notNull(response, "ClientHttpResponse is required");
Assert.notNull(requestBody, "'requestBody' is required");
Assert.notNull(responseBody, "'responseBody' is required");
this.request = request;
this.response = response;
this.requestBody = requestBody;
this.responseBody = responseBody;
this.timeout = timeout;
this.uriTemplate = uriTemplate;
this.mockServerResult = serverResult;
}
/**
* Copy constructor to use after body is decoded and/or consumed.
*/
ExchangeResult(ExchangeResult other) {
this.request = other.request;
this.response = other.response;
this.requestBody = other.requestBody;
this.responseBody = other.responseBody;
this.timeout = other.timeout;
this.uriTemplate = other.uriTemplate;
this.mockServerResult = other.mockServerResult;
this.diagnosticsLogged = other.diagnosticsLogged;
}
/**
* Return the method of the request.
*/
public HttpMethod getMethod() {
return this.request.getMethod();
}
/**
* Return the URI of the request.
*/
public URI getUrl() {
return this.request.getURI();
}
/**
* Return the original URI template used to prepare the request, if any.
*/
@Nullable
public String getUriTemplate() {
return this.uriTemplate;
}
/**
* Return the request headers sent to the server.
*/
public HttpHeaders getRequestHeaders() {
return this.request.getHeaders();
}
/**
* Return the raw request body content written through the request.
* <p><strong>Note:</strong> If the request content has not been consumed
* for any reason yet, use of this method will trigger consumption.
* @throws IllegalStateException if the request body has not been fully written.
*/
@Nullable
public byte[] getRequestBodyContent() {
return this.requestBody.block(this.timeout);
}
/**
* Return the HTTP status code as an {@link HttpStatusCode} value.
*/
public HttpStatusCode getStatus() {
return this.response.getStatusCode();
}
/**
* Return the response headers received from the server.
*/
public HttpHeaders getResponseHeaders() {
return this.response.getHeaders();
}
/**
* Return response cookies received from the server.
*/
public MultiValueMap<String, ResponseCookie> getResponseCookies() {
return this.response.getCookies();
}
/**
* Return the raw request body content written to the response.
* <p><strong>Note:</strong> If the response content has not been consumed
* yet, use of this method will trigger consumption.
* @throws IllegalStateException if the response has not been fully read.
*/
@Nullable
public byte[] getResponseBodyContent() {
return this.responseBody.block(this.timeout);
}
/**
* Return the result from the mock server exchange, if applicable, for
* further assertions on the state of the server response.
* @since 5.3
* @see org.springframework.test.web.servlet.client.MockMvcWebTestClient#resultActionsFor(ExchangeResult)
*/
@Nullable
public Object getMockServerResult() {
return this.mockServerResult;
}
/**
* Execute the given Runnable, catch any {@link AssertionError}, log details
* about the request and response at ERROR level under the class log
* category, and after that re-throw the error.
*/
public void assertWithDiagnostics(Runnable assertion) {
try {
assertion.run();
}
catch (AssertionError ex) {
if (!this.diagnosticsLogged && logger.isErrorEnabled()) {
this.diagnosticsLogged = true;
logger.error("Request details for assertion failure:\n" + this);
}
throw ex;
}
}
@Override
public String toString() {
return "\n" +
"> " + getMethod() + " " + getUrl() + "\n" +
"> " + formatHeaders(getRequestHeaders(), "\n> ") + "\n" +
"\n" +
formatBody(getRequestHeaders().getContentType(), this.requestBody) + "\n" +
"\n" +
"< " + formatStatus(getStatus()) + "\n" +
"< " + formatHeaders(getResponseHeaders(), "\n< ") + "\n" +
"\n" +
formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n" +
formatMockServerResult();
}
private String formatStatus(HttpStatusCode statusCode) {
String result = statusCode.toString();
if (statusCode instanceof HttpStatus status) {
result += " " + status.getReasonPhrase();
}
return result;
}
private String formatHeaders(HttpHeaders headers, String delimiter) {
return headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.collect(Collectors.joining(delimiter));
}
@Nullable
private String formatBody(@Nullable MediaType contentType, Mono<byte[]> body) {
return body
.map(bytes -> {
if (contentType == null) {
return bytes.length + " bytes of content (unknown content-type).";
}
Charset charset = contentType.getCharset();
if (charset != null) {
return new String(bytes, charset);
}
if (PRINTABLE_MEDIA_TYPES.stream().anyMatch(contentType::isCompatibleWith)) {
return new String(bytes, StandardCharsets.UTF_8);
}
return bytes.length + " bytes of content.";
})
.defaultIfEmpty("No content")
.onErrorResume(ex -> Mono.just("Failed to obtain content: " + ex.getMessage()))
.block(this.timeout);
}
private String formatMockServerResult() {
return (this.mockServerResult != null ?
"\n====================== MockMvc (Server) ===============================\n" +
this.mockServerResult + "\n" : "");
}
}
| UTF-8 | Java | 9,052 | java | ExchangeResult.java | Java | [
{
"context": "umed) response body\n * respectively.\n *\n * @author Rossen Stoyanchev\n * @author Sam Brannen\n * @since 5.0\n * @see Enti",
"end": 1976,
"score": 0.9998733997344971,
"start": 1959,
"tag": "NAME",
"value": "Rossen Stoyanchev"
},
{
"context": "tively.\n *\n * @author R... | null | [] | /*
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://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.springframework.test.web.reactive.server;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Mono;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseCookie;
import org.springframework.http.client.reactive.ClientHttpRequest;
import org.springframework.http.client.reactive.ClientHttpResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
/**
* Container for request and response details for exchanges performed through
* {@link WebTestClient}.
*
* <p>Note that a decoded response body is not exposed at this level since the
* body may not have been decoded and consumed yet. Subtypes
* {@link EntityExchangeResult} and {@link FluxExchangeResult} provide access
* to a decoded response entity and a decoded (but not consumed) response body
* respectively.
*
* @author <NAME>
* @author <NAME>
* @since 5.0
* @see EntityExchangeResult
* @see FluxExchangeResult
*/
public class ExchangeResult {
private static final Log logger = LogFactory.getLog(ExchangeResult.class);
private static final List<MediaType> PRINTABLE_MEDIA_TYPES = List.of(
MediaType.parseMediaType("application/*+json"), MediaType.APPLICATION_XML,
MediaType.parseMediaType("text/*"), MediaType.APPLICATION_FORM_URLENCODED);
private final ClientHttpRequest request;
private final ClientHttpResponse response;
private final Mono<byte[]> requestBody;
private final Mono<byte[]> responseBody;
private final Duration timeout;
@Nullable
private final String uriTemplate;
@Nullable
private final Object mockServerResult;
/** Ensure single logging, e.g. for expectAll. */
private boolean diagnosticsLogged;
/**
* Create an instance with an HTTP request and response along with promises
* for the serialized request and response body content.
*
* @param request the HTTP request
* @param response the HTTP response
* @param requestBody capture of serialized request body content
* @param responseBody capture of serialized response body content
* @param timeout how long to wait for content to materialize
* @param uriTemplate the URI template used to set up the request, if any
* @param serverResult the result of a mock server exchange if applicable.
*/
ExchangeResult(ClientHttpRequest request, ClientHttpResponse response,
Mono<byte[]> requestBody, Mono<byte[]> responseBody, Duration timeout, @Nullable String uriTemplate,
@Nullable Object serverResult) {
Assert.notNull(request, "ClientHttpRequest is required");
Assert.notNull(response, "ClientHttpResponse is required");
Assert.notNull(requestBody, "'requestBody' is required");
Assert.notNull(responseBody, "'responseBody' is required");
this.request = request;
this.response = response;
this.requestBody = requestBody;
this.responseBody = responseBody;
this.timeout = timeout;
this.uriTemplate = uriTemplate;
this.mockServerResult = serverResult;
}
/**
* Copy constructor to use after body is decoded and/or consumed.
*/
ExchangeResult(ExchangeResult other) {
this.request = other.request;
this.response = other.response;
this.requestBody = other.requestBody;
this.responseBody = other.responseBody;
this.timeout = other.timeout;
this.uriTemplate = other.uriTemplate;
this.mockServerResult = other.mockServerResult;
this.diagnosticsLogged = other.diagnosticsLogged;
}
/**
* Return the method of the request.
*/
public HttpMethod getMethod() {
return this.request.getMethod();
}
/**
* Return the URI of the request.
*/
public URI getUrl() {
return this.request.getURI();
}
/**
* Return the original URI template used to prepare the request, if any.
*/
@Nullable
public String getUriTemplate() {
return this.uriTemplate;
}
/**
* Return the request headers sent to the server.
*/
public HttpHeaders getRequestHeaders() {
return this.request.getHeaders();
}
/**
* Return the raw request body content written through the request.
* <p><strong>Note:</strong> If the request content has not been consumed
* for any reason yet, use of this method will trigger consumption.
* @throws IllegalStateException if the request body has not been fully written.
*/
@Nullable
public byte[] getRequestBodyContent() {
return this.requestBody.block(this.timeout);
}
/**
* Return the HTTP status code as an {@link HttpStatusCode} value.
*/
public HttpStatusCode getStatus() {
return this.response.getStatusCode();
}
/**
* Return the response headers received from the server.
*/
public HttpHeaders getResponseHeaders() {
return this.response.getHeaders();
}
/**
* Return response cookies received from the server.
*/
public MultiValueMap<String, ResponseCookie> getResponseCookies() {
return this.response.getCookies();
}
/**
* Return the raw request body content written to the response.
* <p><strong>Note:</strong> If the response content has not been consumed
* yet, use of this method will trigger consumption.
* @throws IllegalStateException if the response has not been fully read.
*/
@Nullable
public byte[] getResponseBodyContent() {
return this.responseBody.block(this.timeout);
}
/**
* Return the result from the mock server exchange, if applicable, for
* further assertions on the state of the server response.
* @since 5.3
* @see org.springframework.test.web.servlet.client.MockMvcWebTestClient#resultActionsFor(ExchangeResult)
*/
@Nullable
public Object getMockServerResult() {
return this.mockServerResult;
}
/**
* Execute the given Runnable, catch any {@link AssertionError}, log details
* about the request and response at ERROR level under the class log
* category, and after that re-throw the error.
*/
public void assertWithDiagnostics(Runnable assertion) {
try {
assertion.run();
}
catch (AssertionError ex) {
if (!this.diagnosticsLogged && logger.isErrorEnabled()) {
this.diagnosticsLogged = true;
logger.error("Request details for assertion failure:\n" + this);
}
throw ex;
}
}
@Override
public String toString() {
return "\n" +
"> " + getMethod() + " " + getUrl() + "\n" +
"> " + formatHeaders(getRequestHeaders(), "\n> ") + "\n" +
"\n" +
formatBody(getRequestHeaders().getContentType(), this.requestBody) + "\n" +
"\n" +
"< " + formatStatus(getStatus()) + "\n" +
"< " + formatHeaders(getResponseHeaders(), "\n< ") + "\n" +
"\n" +
formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n" +
formatMockServerResult();
}
private String formatStatus(HttpStatusCode statusCode) {
String result = statusCode.toString();
if (statusCode instanceof HttpStatus status) {
result += " " + status.getReasonPhrase();
}
return result;
}
private String formatHeaders(HttpHeaders headers, String delimiter) {
return headers.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.collect(Collectors.joining(delimiter));
}
@Nullable
private String formatBody(@Nullable MediaType contentType, Mono<byte[]> body) {
return body
.map(bytes -> {
if (contentType == null) {
return bytes.length + " bytes of content (unknown content-type).";
}
Charset charset = contentType.getCharset();
if (charset != null) {
return new String(bytes, charset);
}
if (PRINTABLE_MEDIA_TYPES.stream().anyMatch(contentType::isCompatibleWith)) {
return new String(bytes, StandardCharsets.UTF_8);
}
return bytes.length + " bytes of content.";
})
.defaultIfEmpty("No content")
.onErrorResume(ex -> Mono.just("Failed to obtain content: " + ex.getMessage()))
.block(this.timeout);
}
private String formatMockServerResult() {
return (this.mockServerResult != null ?
"\n====================== MockMvc (Server) ===============================\n" +
this.mockServerResult + "\n" : "");
}
}
| 9,036 | 0.722492 | 0.720614 | 290 | 30.213793 | 26.888578 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.655172 | false | false | 9 |
f02df4062e471caadf8040304732d1160a5b1812 | 5,111,011,118,618 | 7b54178248e76f318c7b971b8fc69f48cc235d2d | /src/test/java/org/springframework/social/evernote/api/impl/ClientStoreMethodInterceptorTest.java | 0a6474cd4d6f1c809223e6c9f763b1a7008e022d | [
"Apache-2.0"
] | permissive | ttddyy/spring-social-evernote | https://github.com/ttddyy/spring-social-evernote | 394d91cb0a31a5001199f8e38142d02c917381bb | a6811f99d8fc3c1a2660a73ac33320427b226854 | refs/heads/master | 2021-03-12T22:37:27.418000 | 2020-12-08T02:04:56 | 2020-12-08T02:04:56 | 15,123,256 | 6 | 5 | Apache-2.0 | false | 2020-12-08T02:02:02 | 2013-12-12T00:39:43 | 2020-12-06T19:50:55 | 2020-12-08T02:02:01 | 840 | 8 | 4 | 0 | Java | false | false | package org.springframework.social.evernote.api.impl;
import com.evernote.clients.UserStoreClient;
import com.evernote.edam.type.User;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.social.evernote.api.StoreClientHolder;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* @author Tadaya Tsuyukubo
*/
public class ClientStoreMethodInterceptorTest {
@Test
public void testInvoke() throws Throwable {
User user = mock(User.class);
// underlying store client
UserStoreClient client = mock(UserStoreClient.class);
when(client.getUser()).thenReturn(user);
// invoked interface method
Method getUserMethod = ReflectionUtils.findMethod(UserStoreClient.class, "getUser");
MethodInvocation invocation = mock(MethodInvocation.class);
when(invocation.getThis()).thenReturn(client);
when(invocation.getMethod()).thenReturn(getUserMethod);
when(invocation.getArguments()).thenReturn(new Object[]{});
ClientStoreMethodInterceptor interceptor = new ClientStoreMethodInterceptor();
Object result = interceptor.invoke(invocation);
assertThat(result, is(instanceOf(User.class)));
assertThat((User) result, is(sameInstance(user)));
}
@Test
public void testGetStoreClient() throws Throwable {
// underlying store client
UserStoreClient client = mock(UserStoreClient.class);
// invoked interface method
Method method = ReflectionUtils.findMethod(StoreClientHolder.class, "getStoreClient");
MethodInvocation invocation = mock(MethodInvocation.class);
when(invocation.getThis()).thenReturn(client);
when(invocation.getMethod()).thenReturn(method);
when(invocation.getArguments()).thenReturn(new Object[]{}); // dummy value
ClientStoreMethodInterceptor interceptor = new ClientStoreMethodInterceptor();
Object result = interceptor.invoke(invocation);
assertThat(result, is(instanceOf(UserStoreClient.class)));
assertThat((UserStoreClient) result, is(sameInstance(client)));
}
private interface Foo {
String echo();
}
private class Bar {
public String echo() {
return "bar";
}
}
@Test
public void testInterceptorChain() throws Throwable {
MethodInterceptor stubAdvice = mock(MethodInterceptor.class);
when(stubAdvice.invoke(argThat(any(MethodInvocation.class)))).thenReturn("modified");
Bar bar = new Bar();
ProxyFactory proxyFactory = new ProxyFactory(bar);
proxyFactory.addInterface(Foo.class);
proxyFactory.addAdvice(new ClientStoreMethodInterceptor());
proxyFactory.addAdvice(stubAdvice);
Foo foo = (Foo) proxyFactory.getProxy();
String result = foo.echo();
verify(stubAdvice).invoke(argThat(any(MethodInvocation.class)));
assertThat(result, is("bar")); // even though stub advice has called, the stub result should be ignored.
}
}
| UTF-8 | Java | 3,180 | java | ClientStoreMethodInterceptorTest.java | Java | [
{
"context": "t static org.mockito.Mockito.when;\n\n/**\n * @author Tadaya Tsuyukubo\n */\npublic class ClientStoreMethodInterceptorTest",
"end": 747,
"score": 0.9998550415039062,
"start": 731,
"tag": "NAME",
"value": "Tadaya Tsuyukubo"
}
] | null | [] | package org.springframework.social.evernote.api.impl;
import com.evernote.clients.UserStoreClient;
import com.evernote.edam.type.User;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.social.evernote.api.StoreClientHolder;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Method;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* @author <NAME>
*/
public class ClientStoreMethodInterceptorTest {
@Test
public void testInvoke() throws Throwable {
User user = mock(User.class);
// underlying store client
UserStoreClient client = mock(UserStoreClient.class);
when(client.getUser()).thenReturn(user);
// invoked interface method
Method getUserMethod = ReflectionUtils.findMethod(UserStoreClient.class, "getUser");
MethodInvocation invocation = mock(MethodInvocation.class);
when(invocation.getThis()).thenReturn(client);
when(invocation.getMethod()).thenReturn(getUserMethod);
when(invocation.getArguments()).thenReturn(new Object[]{});
ClientStoreMethodInterceptor interceptor = new ClientStoreMethodInterceptor();
Object result = interceptor.invoke(invocation);
assertThat(result, is(instanceOf(User.class)));
assertThat((User) result, is(sameInstance(user)));
}
@Test
public void testGetStoreClient() throws Throwable {
// underlying store client
UserStoreClient client = mock(UserStoreClient.class);
// invoked interface method
Method method = ReflectionUtils.findMethod(StoreClientHolder.class, "getStoreClient");
MethodInvocation invocation = mock(MethodInvocation.class);
when(invocation.getThis()).thenReturn(client);
when(invocation.getMethod()).thenReturn(method);
when(invocation.getArguments()).thenReturn(new Object[]{}); // dummy value
ClientStoreMethodInterceptor interceptor = new ClientStoreMethodInterceptor();
Object result = interceptor.invoke(invocation);
assertThat(result, is(instanceOf(UserStoreClient.class)));
assertThat((UserStoreClient) result, is(sameInstance(client)));
}
private interface Foo {
String echo();
}
private class Bar {
public String echo() {
return "bar";
}
}
@Test
public void testInterceptorChain() throws Throwable {
MethodInterceptor stubAdvice = mock(MethodInterceptor.class);
when(stubAdvice.invoke(argThat(any(MethodInvocation.class)))).thenReturn("modified");
Bar bar = new Bar();
ProxyFactory proxyFactory = new ProxyFactory(bar);
proxyFactory.addInterface(Foo.class);
proxyFactory.addAdvice(new ClientStoreMethodInterceptor());
proxyFactory.addAdvice(stubAdvice);
Foo foo = (Foo) proxyFactory.getProxy();
String result = foo.echo();
verify(stubAdvice).invoke(argThat(any(MethodInvocation.class)));
assertThat(result, is("bar")); // even though stub advice has called, the stub result should be ignored.
}
}
| 3,170 | 0.775786 | 0.775786 | 99 | 31.121212 | 27.252382 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.565657 | false | false | 9 |
5abd5ff0db4213992f1cc767a432c3f0ff15b321 | 17,248,588,700,956 | 9dc2f30d16ff7cacfa092ee94108d740c09df806 | /eureka-consumer/src/test/java/ThreadLocalRandomTest.java | 4c10cc0e766ab7ca67b2fdaaf5b7ba553ad6d562 | [] | no_license | GrandKai/springcloud-practice | https://github.com/GrandKai/springcloud-practice | a81dd53a6121575ffffec84d6e451a8258a11d8f | 19c460f49218756c64e9c8372e5dde751ae91a05 | refs/heads/master | 2022-07-02T18:28:50.529000 | 2019-05-22T08:41:26 | 2019-05-22T08:41:26 | 185,739,415 | 0 | 0 | null | false | 2022-06-21T01:09:00 | 2019-05-09T06:27:45 | 2019-05-22T08:41:56 | 2022-06-21T01:08:59 | 61 | 0 | 0 | 4 | Java | false | false | import java.util.concurrent.ThreadLocalRandom;
/**
* @Author: zyn
* @Description:
* @Date: Created in 2019-05-13 14:14
* @Modified By:
*/
public class ThreadLocalRandomTest {
public static void main(String[] args) {
int a = ThreadLocalRandom.current().nextInt(3000);
try {
Thread.sleep(a);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(a);
}
}
| UTF-8 | Java | 421 | java | ThreadLocalRandomTest.java | Java | [
{
"context": "til.concurrent.ThreadLocalRandom;\n\n/**\n * @Author: zyn\n * @Description:\n * @Date: Created in 2019-05-13 ",
"end": 67,
"score": 0.9996297359466553,
"start": 64,
"tag": "USERNAME",
"value": "zyn"
}
] | null | [] | import java.util.concurrent.ThreadLocalRandom;
/**
* @Author: zyn
* @Description:
* @Date: Created in 2019-05-13 14:14
* @Modified By:
*/
public class ThreadLocalRandomTest {
public static void main(String[] args) {
int a = ThreadLocalRandom.current().nextInt(3000);
try {
Thread.sleep(a);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(a);
}
}
| 421 | 0.643705 | 0.605701 | 23 | 17.304348 | 17.099287 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.217391 | false | false | 9 |
c1ac1ddae487d3cb139b1677c34af5342702b3b7 | 16,501,264,412,478 | 4745ad8cf5e65efa05073285f85a34597e4e2144 | /leetcode/subsetI.java | 03c659c95dda06edaacff996c2bc7cb658c83e6e | [] | no_license | skong03/leetcode | https://github.com/skong03/leetcode | 58b8a06b5f12f2f1b6f80193faf64f924c8229b8 | e0eb18c7e743c74af9b9f9f13559a1d478ffa949 | refs/heads/master | 2020-06-05T02:03:26.331000 | 2013-11-20T22:35:18 | 2013-11-20T22:35:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Solution {
public ArrayList<ArrayList<Integer>> subsets(int[] S) {
// Start typing your Java solution below
// DO NOT write main() function
Arrays.sort(S);
ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> level = new ArrayList<Integer>();
res.add(new ArrayList<Integer>());
dfs(res, level, S, 0);
return res;
}
private void dfs(ArrayList<ArrayList<Integer>> res, ArrayList<Integer> level, int[] S, int pos){
for(int i=pos; i<S.length; i++){
if(!level.contains(S[i])){
level.add(S[i]);
res.add(new ArrayList<Integer>(level));
dfs(res, level, S, i+1);
level.remove(level.size()-1);
}
}
}
}
public class Solution {
public ArrayList<ArrayList<Integer>> subsets(int[] S) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> tmp = new ArrayList<Integer>();
Arrays.sort(S);
res.add(tmp);
subImp(res, S, 0);
return res;
}
private void subImp(ArrayList<ArrayList<Integer>> res, int[] s, int pos){
if(pos == s.length)
return;
ArrayList<ArrayList<Integer>> resCopy = (ArrayList<ArrayList<Integer>>)res.clone();
for(ArrayList<Integer> ex : resCopy){
ArrayList<Integer> tmp = new ArrayList<Integer>(ex);
tmp.add(s[pos]);
res.add(tmp);
}
subImp(res, s, pos+1);
}
} | UTF-8 | Java | 1,730 | java | subsetI.java | Java | [] | null | [] | public class Solution {
public ArrayList<ArrayList<Integer>> subsets(int[] S) {
// Start typing your Java solution below
// DO NOT write main() function
Arrays.sort(S);
ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> level = new ArrayList<Integer>();
res.add(new ArrayList<Integer>());
dfs(res, level, S, 0);
return res;
}
private void dfs(ArrayList<ArrayList<Integer>> res, ArrayList<Integer> level, int[] S, int pos){
for(int i=pos; i<S.length; i++){
if(!level.contains(S[i])){
level.add(S[i]);
res.add(new ArrayList<Integer>(level));
dfs(res, level, S, i+1);
level.remove(level.size()-1);
}
}
}
}
public class Solution {
public ArrayList<ArrayList<Integer>> subsets(int[] S) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> tmp = new ArrayList<Integer>();
Arrays.sort(S);
res.add(tmp);
subImp(res, S, 0);
return res;
}
private void subImp(ArrayList<ArrayList<Integer>> res, int[] s, int pos){
if(pos == s.length)
return;
ArrayList<ArrayList<Integer>> resCopy = (ArrayList<ArrayList<Integer>>)res.clone();
for(ArrayList<Integer> ex : resCopy){
ArrayList<Integer> tmp = new ArrayList<Integer>(ex);
tmp.add(s[pos]);
res.add(tmp);
}
subImp(res, s, pos+1);
}
} | 1,730 | 0.543931 | 0.54104 | 56 | 29.910715 | 25.392826 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.696429 | false | false | 9 |
58d682bf8838a22ebfd26f6894b34a33f243f515 | 18,657,337,987,998 | ef5bea450f69e1d16dee0cd15e9076da2a427e8f | /app/src/main/java/cn/longmaster/hospital/doctor/ui/college/GuideLiteratureActivity.java | 8fd2721c2a13046db67f52b1005e30f7fd29389a | [] | no_license | chengsoft618/Internet_Hospital_Doctor | https://github.com/chengsoft618/Internet_Hospital_Doctor | c9e37e8ce80bf3c303f799406644f1adf4cb10df | b6486de17b2246113bcee26d0ec3f2586828d5f7 | refs/heads/master | 2021-02-07T20:55:11.939000 | 2020-01-16T09:10:08 | 2020-01-16T09:10:08 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.longmaster.hospital.doctor.ui.college;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import java.util.ArrayList;
import java.util.List;
import cn.longmaster.doctorlibrary.util.log.Logger;
import cn.longmaster.doctorlibrary.viewinject.FindViewById;
import cn.longmaster.doctorlibrary.viewinject.OnClick;
import cn.longmaster.hospital.doctor.R;
import cn.longmaster.hospital.doctor.core.ExtraDataKeyConfig;
import cn.longmaster.hospital.doctor.core.entity.college.DepartmentInfo;
import cn.longmaster.hospital.doctor.core.entity.college.DiseaseInfo;
import cn.longmaster.hospital.doctor.core.entity.college.GuideDataInfo;
import cn.longmaster.hospital.doctor.core.entity.college.YearInfo;
import cn.longmaster.hospital.doctor.core.requests.BaseResult;
import cn.longmaster.hospital.doctor.core.requests.DefaultResultCallback;
import cn.longmaster.hospital.doctor.core.requests.OnResultListener;
import cn.longmaster.hospital.doctor.core.requests.college.DepartmentListRequester;
import cn.longmaster.hospital.doctor.core.requests.college.GetGuideDataRequester;
import cn.longmaster.hospital.doctor.core.requests.college.GetYearRequester;
import cn.longmaster.hospital.doctor.ui.PDFViewActivity;
import cn.longmaster.hospital.doctor.ui.base.NewBaseActivity;
import cn.longmaster.hospital.doctor.ui.college.adapter.DepartmentAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.DiseaseAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.GuideLiteratureAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.YearAdapter;
import cn.longmaster.hospital.doctor.ui.user.BrowserActivity;
import cn.longmaster.hospital.doctor.view.AppActionBar;
import cn.longmaster.utils.LibCollections;
import cn.longmaster.utils.ToastUtils;
/**
* 指南文库activity
* <p>
* Created by W·H·K on 2018/3/23.
*/
public class GuideLiteratureActivity extends NewBaseActivity {
@FindViewById(R.id.activity_guide_literature_bar)
private AppActionBar mAppActionBar;
@FindViewById(R.id.activity_guide_literature_srl)
private SmartRefreshLayout activityGuideLiteratureSrl;
@FindViewById(R.id.activity_guide_literature_rv)
private RecyclerView mRecyclerView;
@FindViewById(R.id.activity_guide_literature_department_img)
private ImageView mDepartmentImg;
@FindViewById(R.id.activity_guide_literature_disease_img)
private ImageView mDiseaseImg;
@FindViewById(R.id.activity_guide_literature_year_img)
private ImageView mYearImg;
@FindViewById(R.id.activity_guide_literature_view)
private View mScreenView;
@FindViewById(R.id.activity_guide_literature_department_tv)
private TextView mDepartmentTv;
@FindViewById(R.id.activity_guide_literature_disease_tv)
private TextView mDiseaseTv;
@FindViewById(R.id.activity_guide_literature_year_tv)
private TextView mYearTv;
@FindViewById(R.id.activity_guide_empty_view)
private LinearLayout mEmptyView;
private boolean mIsOpenScreen = false;
private PopupWindow mPopupWindow;
private List<GuideDataInfo> mGuideDataInfos = new ArrayList<>();
private GuideLiteratureAdapter mAdapter;
private int mDepartmentId = 0;
private int mPageIndex = 1;
private int mPageSize = 20;
private String mDiseaseName = "疾病";
private DepartmentAdapter mDepartmentAdapter;
private List<DepartmentInfo> mDepartmentInfos = new ArrayList<>();
private String mDepartmentStr = "科室";
private String mYearStr = "年份";
private DiseaseAdapter mDiseaseAdapter;
private List<DiseaseInfo> mDiseaseInfos = new ArrayList<>();
private ProgressDialog mProgressDialog;
private List<YearInfo> mYearInfos = new ArrayList<>();
private YearAdapter mYearAdapter;
private int mDepartmentPosition = -1;
@Override
protected void initDatas() {
}
@Override
protected int getContentViewId() {
return R.layout.activity_guide_literature;
}
@Override
protected void initViews() {
initView();
initData();
initListener();
}
private void initView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(getThisActivity());
mRecyclerView.setLayoutManager(layoutManager);
mAdapter = new GuideLiteratureAdapter(R.layout.item_guide_literature, mGuideDataInfos);
mRecyclerView.setAdapter(mAdapter);
}
private void initData() {
String moduleTitle = getIntent().getStringExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_COLLEGE_TAB_NAME);
mAppActionBar.setTitle(moduleTitle);
showProgressDialog();
activityGuideLiteratureSrl.autoRefresh();
}
private void initListener() {
mAdapter.setOnItemClickListener((adapter, view, position) -> {
GuideDataInfo guideDataInfo = (GuideDataInfo) adapter.getItem(position);
if (null == guideDataInfo) {
return;
}
if (guideDataInfo.getContentUrl().endsWith(".pdf")) {
PDFViewActivity.startActivity(getThisActivity(), guideDataInfo.getContentUrl(), guideDataInfo.getMaterialName());
} else {
Intent intent = new Intent(getThisActivity(), BrowserActivity.class);
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_TITLE, guideDataInfo.getMaterialName());
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_TITLE_NAME, true);
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_LOADING_URL, guideDataInfo.getContentUrl());
startActivity(intent);
}
});
activityGuideLiteratureSrl.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
mPageIndex++;
getGuideData(mDepartmentId, mDiseaseName, mYearStr, mPageIndex, mPageSize, true, refreshLayout);
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
mPageIndex = MIN_PAGE_INDEX_1;
getGuideData(mDepartmentId, mDiseaseName, mYearStr, mPageIndex, mPageSize, false, refreshLayout);
}
});
}
private void getGuideData(int departmentId, String diseaseName, String year, int pageIndex, int pageSize, final boolean isLoadMore, RefreshLayout refreshLayout) {
GetGuideDataRequester requester = new GetGuideDataRequester(new DefaultResultCallback<List<GuideDataInfo>>() {
@Override
public void onSuccess(List<GuideDataInfo> guideDataInfos, BaseResult baseResult) {
if (baseResult.isFinish()) {
activityGuideLiteratureSrl.finishLoadMoreWithNoMoreData();
}
if (isLoadMore) {
mAdapter.addData(guideDataInfos);
} else {
if (LibCollections.isEmpty(guideDataInfos)) {
mEmptyView.setVisibility(View.VISIBLE);
} else {
mEmptyView.setVisibility(View.GONE);
}
mGuideDataInfos = guideDataInfos;
mAdapter.setNewData(guideDataInfos);
}
}
@Override
public void onFail(BaseResult result) {
super.onFail(result);
ToastUtils.showShort(R.string.no_network_connection);
}
@Override
public void onFinish() {
dismissProgressDialog();
if (isLoadMore) {
refreshLayout.finishLoadMore();
} else {
refreshLayout.finishRefresh();
}
}
});
requester.departmentId = departmentId;
requester.diseaseName = diseaseName.contains("疾病") ? "" : mDiseaseName;
requester.year = year.contains("年份") ? "" : mYearStr;
requester.pageIndex = pageIndex;
requester.pageSize = pageSize;
requester.doPost();
}
@OnClick({R.id.activity_guide_literature_screen_view})
public void onClick(View view) {
switch (view.getId()) {
case R.id.activity_guide_literature_screen_view:
setScreenArrowIcon();
showDialog();
break;
}
}
private void showDialog() {
View contentView = LayoutInflater.from(getThisActivity()).inflate(R.layout.dialog_guide_literature_screen, null);
mPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
displayView(contentView, mPopupWindow);
mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
setScreenArrowIcon();
}
});
mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
mPopupWindow.showAsDropDown(mScreenView);
}
private void displayView(View contentView, final PopupWindow popupWindow) {
final RecyclerView departmentRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_department_recycler_view);
final RecyclerView diseaseRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_disease_recycler_view);
final RecyclerView yearRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_year_recycler_view);
final TextView determineVtn = contentView.findViewById(R.id.dialog_guide_literature_determine_tv);
final TextView departmentAllTv = contentView.findViewById(R.id.dialog_guide_literature_department_all_tv);
final TextView diseaseAllTv = contentView.findViewById(R.id.dialog_guide_literature_disease_all_tv);
final TextView yearAllTv = contentView.findViewById(R.id.dialog_guide_literature_year_all_tv);
departmentRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
diseaseRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
yearRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
setViewBackground(departmentAllTv, diseaseAllTv, yearAllTv);
if (mDepartmentInfos.size() > 0) {
displayScreenView(departmentRecyclerView, diseaseRecyclerView, yearRecyclerView, mDepartmentInfos, departmentAllTv, diseaseAllTv, yearAllTv);
} else {
final DepartmentListRequester requester = new DepartmentListRequester((baseResult, departmentInfos) -> {
Logger.logD(Logger.COMMON, "GuideLiteratureActivity->DepartmentListRequester()->baseResult:" + baseResult + ",guideDataInfos:" + departmentInfos);
if (baseResult.getCode() == OnResultListener.RESULT_SUCCESS && departmentInfos.size() > 0) {
mDepartmentInfos = departmentInfos;
displayScreenView(departmentRecyclerView, diseaseRecyclerView, yearRecyclerView, departmentInfos, departmentAllTv, diseaseAllTv, yearAllTv);
}
});
requester.ownType = 0;
requester.doPost();
}
if (mYearInfos.size() > 0) {
displayYearView(mYearInfos, yearRecyclerView, yearAllTv);
} else {
GetYearRequester yearRequester = new GetYearRequester((baseResult, yearInfos) -> {
Logger.logD(Logger.COMMON, "GuideLiteratureActivity->DepartmentListRequester()->baseResult:" + baseResult + ",yearInfos:" + yearInfos);
if (baseResult.getCode() == OnResultListener.RESULT_SUCCESS && yearInfos.size() > 0) {
mYearInfos = yearInfos;
displayYearView(yearInfos, yearRecyclerView, yearAllTv);
}
});
yearRequester.doPost();
}
determineVtn.setOnClickListener(v -> {
showProgressDialog();
boolean isselectDepartment = false;
for (int i = 0; i < mDepartmentInfos.size(); i++) {
if (mDepartmentInfos.get(i).isSelected()) {
isselectDepartment = true;
mDepartmentStr = mDepartmentInfos.get(i).getDepartmentName();
mDepartmentId = mDepartmentInfos.get(i).getDepartmentId();
}
}
if (!isselectDepartment) {
mDepartmentStr = getString(R.string.medical_college_department);
mDepartmentId = 0;
}
boolean isselectDisease = false;
for (int i = 0; i < mDiseaseInfos.size(); i++) {
if (mDiseaseInfos.get(i).isSelected()) {
isselectDisease = true;
mDiseaseName = mDiseaseInfos.get(i).getDiseaseName();
}
}
if (!isselectDisease) {
mDiseaseName = getString(R.string.medical_college_disease);
}
boolean isselectYea = false;
for (int i = 0; i < mYearInfos.size(); i++) {
if (mYearInfos.get(i).isSelected()) {
isselectYea = true;
mYearStr = mYearInfos.get(i).getMatYear();
}
}
if (!isselectYea) {
mYearStr = getString(R.string.medical_college_year);
}
mDepartmentTv.setText(mDepartmentStr);
mDiseaseTv.setText(mDiseaseName);
mYearTv.setText(mYearStr);
popupWindow.dismiss();
activityGuideLiteratureSrl.autoRefresh();
});
}
private void displayDiseaseView(RecyclerView diseaseRecyclerView, List<DepartmentInfo> departmentInfos) {
if (mDiseaseAdapter != null && mDepartmentPosition != -1 && mDiseaseInfos != null) {
mDiseaseInfos.clear();
for (String str : departmentInfos.get(mDepartmentPosition).getDiseases()) {
DiseaseInfo diseaseInfo = new DiseaseInfo();
diseaseInfo.setDiseaseName(str);
if (mDiseaseName.equals(str)) {
diseaseInfo.setSelected(true);
}
mDiseaseInfos.add(diseaseInfo);
}
mDiseaseAdapter.notifyDataSetChanged();
}
}
private void setViewBackground(TextView departmentAllTv, TextView diseaseAllTv, TextView yearAllTv) {
mDepartmentTv.setText(mDepartmentStr);
mDiseaseTv.setText(mDiseaseName);
mYearTv.setText(mYearStr);
if (mDepartmentStr.contains(getString(R.string.medical_college_department))) {
departmentAllTv.setBackgroundResource(R.color.color_ebeff0);
departmentAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
departmentAllTv.setBackgroundResource(R.color.white);
departmentAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
if (mDiseaseName.contains(getString(R.string.medical_college_disease))) {
diseaseAllTv.setBackgroundResource(R.color.color_ebeff0);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
diseaseAllTv.setBackgroundResource(R.color.white);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
if (mYearStr.contains(getString(R.string.medical_college_year))) {
yearAllTv.setBackgroundResource(R.color.color_ebeff0);
yearAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
yearAllTv.setBackgroundResource(R.color.white);
yearAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
}
private void displayYearView(final List<YearInfo> yearInfos, RecyclerView yearRecyclerView, final TextView yearAllTv) {
mYearAdapter = new YearAdapter(getThisActivity(), yearInfos);
yearRecyclerView.setAdapter(mYearAdapter);
mYearAdapter.setOnItemClickListener((view, position) -> {
for (int i = 0; i < yearInfos.size(); i++) {
if (i == position) {
yearInfos.get(i).setSelected(true);
} else {
yearInfos.get(i).setSelected(false);
}
}
yearAllTv.setBackgroundResource(R.color.color_white);
yearAllTv.setTextColor(getCompatColor(R.color.color_666666));
mYearAdapter.notifyDataSetChanged();
});
}
private void displayScreenView(RecyclerView departmentRecyclerView, final RecyclerView diseaseRecyclerView, RecyclerView yearRecyclerView, final List<DepartmentInfo> departmentInfos, final TextView departmentAllTv, final TextView diseaseAllTv, final TextView yearAllTv) {
mDepartmentAdapter = new DepartmentAdapter(getThisActivity(), departmentInfos);
departmentRecyclerView.setAdapter(mDepartmentAdapter);
mDiseaseAdapter = new DiseaseAdapter(getThisActivity(), mDiseaseInfos);
diseaseRecyclerView.setAdapter(mDiseaseAdapter);
displayDiseaseView(diseaseRecyclerView, departmentInfos);
mDepartmentAdapter.setOnItemClickListener((view, position) -> {
mDiseaseInfos.clear();
for (String str : departmentInfos.get(position).getDiseases()) {
DiseaseInfo diseaseInfo = new DiseaseInfo();
diseaseInfo.setDiseaseName(str);
mDiseaseInfos.add(diseaseInfo);
}
mDiseaseAdapter.notifyDataSetChanged();
for (int i = 0; i < departmentInfos.size(); i++) {
if (i == position) {
departmentInfos.get(i).setSelected(true);
} else {
departmentInfos.get(i).setSelected(false);
}
}
departmentAllTv.setBackgroundResource(R.color.color_white);
departmentAllTv.setTextColor(getCompatColor(R.color.color_666666));
mDepartmentAdapter.notifyDataSetChanged();
});
mDiseaseAdapter.setOnItemClickListener((view, position) -> {
for (int i = 0; i < mDiseaseInfos.size(); i++) {
if (i == position) {
mDiseaseInfos.get(i).setSelected(true);
} else {
mDiseaseInfos.get(i).setSelected(false);
}
}
diseaseAllTv.setBackgroundResource(R.color.color_white);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_666666));
mDiseaseAdapter.notifyDataSetChanged();
});
departmentAllTv.setOnClickListener(v -> {
departmentAllTv.setBackgroundResource(R.color.color_ebeff0);
departmentAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
for (int i = 0; i < departmentInfos.size(); i++) {
departmentInfos.get(i).setSelected(false);
}
mDepartmentAdapter.notifyDataSetChanged();
if (mDiseaseAdapter != null) {
mDiseaseInfos.clear();
mDiseaseAdapter.notifyDataSetChanged();
}
});
diseaseAllTv.setOnClickListener(v -> {
diseaseAllTv.setBackgroundResource(R.color.color_ebeff0);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
if (mDiseaseInfos.size() > 0) {
for (int i = 0; i < mDiseaseInfos.size(); i++) {
mDiseaseInfos.get(i).setSelected(false);
}
mDiseaseAdapter.notifyDataSetChanged();
}
});
yearAllTv.setOnClickListener(v -> {
yearAllTv.setBackgroundResource(R.color.color_ebeff0);
yearAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
if (mYearInfos.size() > 0) {
for (int i = 0; i < mYearInfos.size(); i++) {
mYearInfos.get(i).setSelected(false);
}
mYearAdapter.notifyDataSetChanged();
}
});
}
private void setScreenArrowIcon() {
if (mIsOpenScreen) {
mIsOpenScreen = false;
mDepartmentImg.setImageResource(R.drawable.ic_recommend_expert_down);
mDiseaseImg.setImageResource(R.drawable.ic_recommend_expert_down);
mYearImg.setImageResource(R.drawable.ic_recommend_expert_down);
} else {
mIsOpenScreen = true;
mDepartmentImg.setImageResource(R.drawable.ic_recommend_expert_up);
mDiseaseImg.setImageResource(R.drawable.ic_recommend_expert_up);
mYearImg.setImageResource(R.drawable.ic_recommend_expert_up);
}
}
private void showProgressDialog() {
if (mProgressDialog == null) {
mProgressDialog = createProgressDialog(getString(R.string.loading));
} else if (!mProgressDialog.isShowing()) {
mProgressDialog.show();
}
}
private void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
}
| UTF-8 | Java | 21,816 | java | GuideLiteratureActivity.java | Java | [
{
"context": "stUtils;\n\n/**\n * 指南文库activity\n * <p>\n * Created by W·H·K on 2018/3/23.\n */\npublic class GuideLiteratureAct",
"end": 2444,
"score": 0.9980114102363586,
"start": 2439,
"tag": "NAME",
"value": "W·H·K"
}
] | null | [] | package cn.longmaster.hospital.doctor.ui.college;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import java.util.ArrayList;
import java.util.List;
import cn.longmaster.doctorlibrary.util.log.Logger;
import cn.longmaster.doctorlibrary.viewinject.FindViewById;
import cn.longmaster.doctorlibrary.viewinject.OnClick;
import cn.longmaster.hospital.doctor.R;
import cn.longmaster.hospital.doctor.core.ExtraDataKeyConfig;
import cn.longmaster.hospital.doctor.core.entity.college.DepartmentInfo;
import cn.longmaster.hospital.doctor.core.entity.college.DiseaseInfo;
import cn.longmaster.hospital.doctor.core.entity.college.GuideDataInfo;
import cn.longmaster.hospital.doctor.core.entity.college.YearInfo;
import cn.longmaster.hospital.doctor.core.requests.BaseResult;
import cn.longmaster.hospital.doctor.core.requests.DefaultResultCallback;
import cn.longmaster.hospital.doctor.core.requests.OnResultListener;
import cn.longmaster.hospital.doctor.core.requests.college.DepartmentListRequester;
import cn.longmaster.hospital.doctor.core.requests.college.GetGuideDataRequester;
import cn.longmaster.hospital.doctor.core.requests.college.GetYearRequester;
import cn.longmaster.hospital.doctor.ui.PDFViewActivity;
import cn.longmaster.hospital.doctor.ui.base.NewBaseActivity;
import cn.longmaster.hospital.doctor.ui.college.adapter.DepartmentAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.DiseaseAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.GuideLiteratureAdapter;
import cn.longmaster.hospital.doctor.ui.college.adapter.YearAdapter;
import cn.longmaster.hospital.doctor.ui.user.BrowserActivity;
import cn.longmaster.hospital.doctor.view.AppActionBar;
import cn.longmaster.utils.LibCollections;
import cn.longmaster.utils.ToastUtils;
/**
* 指南文库activity
* <p>
* Created by W·H·K on 2018/3/23.
*/
public class GuideLiteratureActivity extends NewBaseActivity {
@FindViewById(R.id.activity_guide_literature_bar)
private AppActionBar mAppActionBar;
@FindViewById(R.id.activity_guide_literature_srl)
private SmartRefreshLayout activityGuideLiteratureSrl;
@FindViewById(R.id.activity_guide_literature_rv)
private RecyclerView mRecyclerView;
@FindViewById(R.id.activity_guide_literature_department_img)
private ImageView mDepartmentImg;
@FindViewById(R.id.activity_guide_literature_disease_img)
private ImageView mDiseaseImg;
@FindViewById(R.id.activity_guide_literature_year_img)
private ImageView mYearImg;
@FindViewById(R.id.activity_guide_literature_view)
private View mScreenView;
@FindViewById(R.id.activity_guide_literature_department_tv)
private TextView mDepartmentTv;
@FindViewById(R.id.activity_guide_literature_disease_tv)
private TextView mDiseaseTv;
@FindViewById(R.id.activity_guide_literature_year_tv)
private TextView mYearTv;
@FindViewById(R.id.activity_guide_empty_view)
private LinearLayout mEmptyView;
private boolean mIsOpenScreen = false;
private PopupWindow mPopupWindow;
private List<GuideDataInfo> mGuideDataInfos = new ArrayList<>();
private GuideLiteratureAdapter mAdapter;
private int mDepartmentId = 0;
private int mPageIndex = 1;
private int mPageSize = 20;
private String mDiseaseName = "疾病";
private DepartmentAdapter mDepartmentAdapter;
private List<DepartmentInfo> mDepartmentInfos = new ArrayList<>();
private String mDepartmentStr = "科室";
private String mYearStr = "年份";
private DiseaseAdapter mDiseaseAdapter;
private List<DiseaseInfo> mDiseaseInfos = new ArrayList<>();
private ProgressDialog mProgressDialog;
private List<YearInfo> mYearInfos = new ArrayList<>();
private YearAdapter mYearAdapter;
private int mDepartmentPosition = -1;
@Override
protected void initDatas() {
}
@Override
protected int getContentViewId() {
return R.layout.activity_guide_literature;
}
@Override
protected void initViews() {
initView();
initData();
initListener();
}
private void initView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(getThisActivity());
mRecyclerView.setLayoutManager(layoutManager);
mAdapter = new GuideLiteratureAdapter(R.layout.item_guide_literature, mGuideDataInfos);
mRecyclerView.setAdapter(mAdapter);
}
private void initData() {
String moduleTitle = getIntent().getStringExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_COLLEGE_TAB_NAME);
mAppActionBar.setTitle(moduleTitle);
showProgressDialog();
activityGuideLiteratureSrl.autoRefresh();
}
private void initListener() {
mAdapter.setOnItemClickListener((adapter, view, position) -> {
GuideDataInfo guideDataInfo = (GuideDataInfo) adapter.getItem(position);
if (null == guideDataInfo) {
return;
}
if (guideDataInfo.getContentUrl().endsWith(".pdf")) {
PDFViewActivity.startActivity(getThisActivity(), guideDataInfo.getContentUrl(), guideDataInfo.getMaterialName());
} else {
Intent intent = new Intent(getThisActivity(), BrowserActivity.class);
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_TITLE, guideDataInfo.getMaterialName());
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_TITLE_NAME, true);
intent.putExtra(ExtraDataKeyConfig.EXTRA_DATA_KEY_LOADING_URL, guideDataInfo.getContentUrl());
startActivity(intent);
}
});
activityGuideLiteratureSrl.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
mPageIndex++;
getGuideData(mDepartmentId, mDiseaseName, mYearStr, mPageIndex, mPageSize, true, refreshLayout);
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
mPageIndex = MIN_PAGE_INDEX_1;
getGuideData(mDepartmentId, mDiseaseName, mYearStr, mPageIndex, mPageSize, false, refreshLayout);
}
});
}
private void getGuideData(int departmentId, String diseaseName, String year, int pageIndex, int pageSize, final boolean isLoadMore, RefreshLayout refreshLayout) {
GetGuideDataRequester requester = new GetGuideDataRequester(new DefaultResultCallback<List<GuideDataInfo>>() {
@Override
public void onSuccess(List<GuideDataInfo> guideDataInfos, BaseResult baseResult) {
if (baseResult.isFinish()) {
activityGuideLiteratureSrl.finishLoadMoreWithNoMoreData();
}
if (isLoadMore) {
mAdapter.addData(guideDataInfos);
} else {
if (LibCollections.isEmpty(guideDataInfos)) {
mEmptyView.setVisibility(View.VISIBLE);
} else {
mEmptyView.setVisibility(View.GONE);
}
mGuideDataInfos = guideDataInfos;
mAdapter.setNewData(guideDataInfos);
}
}
@Override
public void onFail(BaseResult result) {
super.onFail(result);
ToastUtils.showShort(R.string.no_network_connection);
}
@Override
public void onFinish() {
dismissProgressDialog();
if (isLoadMore) {
refreshLayout.finishLoadMore();
} else {
refreshLayout.finishRefresh();
}
}
});
requester.departmentId = departmentId;
requester.diseaseName = diseaseName.contains("疾病") ? "" : mDiseaseName;
requester.year = year.contains("年份") ? "" : mYearStr;
requester.pageIndex = pageIndex;
requester.pageSize = pageSize;
requester.doPost();
}
@OnClick({R.id.activity_guide_literature_screen_view})
public void onClick(View view) {
switch (view.getId()) {
case R.id.activity_guide_literature_screen_view:
setScreenArrowIcon();
showDialog();
break;
}
}
private void showDialog() {
View contentView = LayoutInflater.from(getThisActivity()).inflate(R.layout.dialog_guide_literature_screen, null);
mPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
displayView(contentView, mPopupWindow);
mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
setScreenArrowIcon();
}
});
mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
mPopupWindow.showAsDropDown(mScreenView);
}
private void displayView(View contentView, final PopupWindow popupWindow) {
final RecyclerView departmentRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_department_recycler_view);
final RecyclerView diseaseRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_disease_recycler_view);
final RecyclerView yearRecyclerView = contentView.findViewById(R.id.dialog_guide_literature_year_recycler_view);
final TextView determineVtn = contentView.findViewById(R.id.dialog_guide_literature_determine_tv);
final TextView departmentAllTv = contentView.findViewById(R.id.dialog_guide_literature_department_all_tv);
final TextView diseaseAllTv = contentView.findViewById(R.id.dialog_guide_literature_disease_all_tv);
final TextView yearAllTv = contentView.findViewById(R.id.dialog_guide_literature_year_all_tv);
departmentRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
diseaseRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
yearRecyclerView.setLayoutManager(new LinearLayoutManager(getThisActivity()));
setViewBackground(departmentAllTv, diseaseAllTv, yearAllTv);
if (mDepartmentInfos.size() > 0) {
displayScreenView(departmentRecyclerView, diseaseRecyclerView, yearRecyclerView, mDepartmentInfos, departmentAllTv, diseaseAllTv, yearAllTv);
} else {
final DepartmentListRequester requester = new DepartmentListRequester((baseResult, departmentInfos) -> {
Logger.logD(Logger.COMMON, "GuideLiteratureActivity->DepartmentListRequester()->baseResult:" + baseResult + ",guideDataInfos:" + departmentInfos);
if (baseResult.getCode() == OnResultListener.RESULT_SUCCESS && departmentInfos.size() > 0) {
mDepartmentInfos = departmentInfos;
displayScreenView(departmentRecyclerView, diseaseRecyclerView, yearRecyclerView, departmentInfos, departmentAllTv, diseaseAllTv, yearAllTv);
}
});
requester.ownType = 0;
requester.doPost();
}
if (mYearInfos.size() > 0) {
displayYearView(mYearInfos, yearRecyclerView, yearAllTv);
} else {
GetYearRequester yearRequester = new GetYearRequester((baseResult, yearInfos) -> {
Logger.logD(Logger.COMMON, "GuideLiteratureActivity->DepartmentListRequester()->baseResult:" + baseResult + ",yearInfos:" + yearInfos);
if (baseResult.getCode() == OnResultListener.RESULT_SUCCESS && yearInfos.size() > 0) {
mYearInfos = yearInfos;
displayYearView(yearInfos, yearRecyclerView, yearAllTv);
}
});
yearRequester.doPost();
}
determineVtn.setOnClickListener(v -> {
showProgressDialog();
boolean isselectDepartment = false;
for (int i = 0; i < mDepartmentInfos.size(); i++) {
if (mDepartmentInfos.get(i).isSelected()) {
isselectDepartment = true;
mDepartmentStr = mDepartmentInfos.get(i).getDepartmentName();
mDepartmentId = mDepartmentInfos.get(i).getDepartmentId();
}
}
if (!isselectDepartment) {
mDepartmentStr = getString(R.string.medical_college_department);
mDepartmentId = 0;
}
boolean isselectDisease = false;
for (int i = 0; i < mDiseaseInfos.size(); i++) {
if (mDiseaseInfos.get(i).isSelected()) {
isselectDisease = true;
mDiseaseName = mDiseaseInfos.get(i).getDiseaseName();
}
}
if (!isselectDisease) {
mDiseaseName = getString(R.string.medical_college_disease);
}
boolean isselectYea = false;
for (int i = 0; i < mYearInfos.size(); i++) {
if (mYearInfos.get(i).isSelected()) {
isselectYea = true;
mYearStr = mYearInfos.get(i).getMatYear();
}
}
if (!isselectYea) {
mYearStr = getString(R.string.medical_college_year);
}
mDepartmentTv.setText(mDepartmentStr);
mDiseaseTv.setText(mDiseaseName);
mYearTv.setText(mYearStr);
popupWindow.dismiss();
activityGuideLiteratureSrl.autoRefresh();
});
}
private void displayDiseaseView(RecyclerView diseaseRecyclerView, List<DepartmentInfo> departmentInfos) {
if (mDiseaseAdapter != null && mDepartmentPosition != -1 && mDiseaseInfos != null) {
mDiseaseInfos.clear();
for (String str : departmentInfos.get(mDepartmentPosition).getDiseases()) {
DiseaseInfo diseaseInfo = new DiseaseInfo();
diseaseInfo.setDiseaseName(str);
if (mDiseaseName.equals(str)) {
diseaseInfo.setSelected(true);
}
mDiseaseInfos.add(diseaseInfo);
}
mDiseaseAdapter.notifyDataSetChanged();
}
}
private void setViewBackground(TextView departmentAllTv, TextView diseaseAllTv, TextView yearAllTv) {
mDepartmentTv.setText(mDepartmentStr);
mDiseaseTv.setText(mDiseaseName);
mYearTv.setText(mYearStr);
if (mDepartmentStr.contains(getString(R.string.medical_college_department))) {
departmentAllTv.setBackgroundResource(R.color.color_ebeff0);
departmentAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
departmentAllTv.setBackgroundResource(R.color.white);
departmentAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
if (mDiseaseName.contains(getString(R.string.medical_college_disease))) {
diseaseAllTv.setBackgroundResource(R.color.color_ebeff0);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
diseaseAllTv.setBackgroundResource(R.color.white);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
if (mYearStr.contains(getString(R.string.medical_college_year))) {
yearAllTv.setBackgroundResource(R.color.color_ebeff0);
yearAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
} else {
yearAllTv.setBackgroundResource(R.color.white);
yearAllTv.setTextColor(getCompatColor(R.color.color_666666));
}
}
private void displayYearView(final List<YearInfo> yearInfos, RecyclerView yearRecyclerView, final TextView yearAllTv) {
mYearAdapter = new YearAdapter(getThisActivity(), yearInfos);
yearRecyclerView.setAdapter(mYearAdapter);
mYearAdapter.setOnItemClickListener((view, position) -> {
for (int i = 0; i < yearInfos.size(); i++) {
if (i == position) {
yearInfos.get(i).setSelected(true);
} else {
yearInfos.get(i).setSelected(false);
}
}
yearAllTv.setBackgroundResource(R.color.color_white);
yearAllTv.setTextColor(getCompatColor(R.color.color_666666));
mYearAdapter.notifyDataSetChanged();
});
}
private void displayScreenView(RecyclerView departmentRecyclerView, final RecyclerView diseaseRecyclerView, RecyclerView yearRecyclerView, final List<DepartmentInfo> departmentInfos, final TextView departmentAllTv, final TextView diseaseAllTv, final TextView yearAllTv) {
mDepartmentAdapter = new DepartmentAdapter(getThisActivity(), departmentInfos);
departmentRecyclerView.setAdapter(mDepartmentAdapter);
mDiseaseAdapter = new DiseaseAdapter(getThisActivity(), mDiseaseInfos);
diseaseRecyclerView.setAdapter(mDiseaseAdapter);
displayDiseaseView(diseaseRecyclerView, departmentInfos);
mDepartmentAdapter.setOnItemClickListener((view, position) -> {
mDiseaseInfos.clear();
for (String str : departmentInfos.get(position).getDiseases()) {
DiseaseInfo diseaseInfo = new DiseaseInfo();
diseaseInfo.setDiseaseName(str);
mDiseaseInfos.add(diseaseInfo);
}
mDiseaseAdapter.notifyDataSetChanged();
for (int i = 0; i < departmentInfos.size(); i++) {
if (i == position) {
departmentInfos.get(i).setSelected(true);
} else {
departmentInfos.get(i).setSelected(false);
}
}
departmentAllTv.setBackgroundResource(R.color.color_white);
departmentAllTv.setTextColor(getCompatColor(R.color.color_666666));
mDepartmentAdapter.notifyDataSetChanged();
});
mDiseaseAdapter.setOnItemClickListener((view, position) -> {
for (int i = 0; i < mDiseaseInfos.size(); i++) {
if (i == position) {
mDiseaseInfos.get(i).setSelected(true);
} else {
mDiseaseInfos.get(i).setSelected(false);
}
}
diseaseAllTv.setBackgroundResource(R.color.color_white);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_666666));
mDiseaseAdapter.notifyDataSetChanged();
});
departmentAllTv.setOnClickListener(v -> {
departmentAllTv.setBackgroundResource(R.color.color_ebeff0);
departmentAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
for (int i = 0; i < departmentInfos.size(); i++) {
departmentInfos.get(i).setSelected(false);
}
mDepartmentAdapter.notifyDataSetChanged();
if (mDiseaseAdapter != null) {
mDiseaseInfos.clear();
mDiseaseAdapter.notifyDataSetChanged();
}
});
diseaseAllTv.setOnClickListener(v -> {
diseaseAllTv.setBackgroundResource(R.color.color_ebeff0);
diseaseAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
if (mDiseaseInfos.size() > 0) {
for (int i = 0; i < mDiseaseInfos.size(); i++) {
mDiseaseInfos.get(i).setSelected(false);
}
mDiseaseAdapter.notifyDataSetChanged();
}
});
yearAllTv.setOnClickListener(v -> {
yearAllTv.setBackgroundResource(R.color.color_ebeff0);
yearAllTv.setTextColor(getCompatColor(R.color.color_45aef8));
if (mYearInfos.size() > 0) {
for (int i = 0; i < mYearInfos.size(); i++) {
mYearInfos.get(i).setSelected(false);
}
mYearAdapter.notifyDataSetChanged();
}
});
}
private void setScreenArrowIcon() {
if (mIsOpenScreen) {
mIsOpenScreen = false;
mDepartmentImg.setImageResource(R.drawable.ic_recommend_expert_down);
mDiseaseImg.setImageResource(R.drawable.ic_recommend_expert_down);
mYearImg.setImageResource(R.drawable.ic_recommend_expert_down);
} else {
mIsOpenScreen = true;
mDepartmentImg.setImageResource(R.drawable.ic_recommend_expert_up);
mDiseaseImg.setImageResource(R.drawable.ic_recommend_expert_up);
mYearImg.setImageResource(R.drawable.ic_recommend_expert_up);
}
}
private void showProgressDialog() {
if (mProgressDialog == null) {
mProgressDialog = createProgressDialog(getString(R.string.loading));
} else if (!mProgressDialog.isShowing()) {
mProgressDialog.show();
}
}
private void dismissProgressDialog() {
if (mProgressDialog != null && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
}
}
}
| 21,816 | 0.653172 | 0.648903 | 466 | 45.751072 | 33.222141 | 275 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.740343 | false | false | 9 |
40162ec18ceb5dee34f70d18b0214456b4814a12 | 11,751,030,589,662 | 21d70bfeb8139da4c458351463d3059ddeabcdf3 | /数据库mySql,JDBC阶段/day1901/代码/day19/src/cn/itcast/demo01_jdbc操作事务/Demo01JDBCTransaction.java | 9b7d5f6b5d299678d7086e18526dc9c5d2c1c35a | [] | no_license | Zhangxb1111/techSource | https://github.com/Zhangxb1111/techSource | 92322e1fba28da1fa067b629c7926bbde34c3014 | 9e3e690ea380323ff857249a699f62414eb8bfd2 | refs/heads/master | 2023-01-20T00:18:50.703000 | 2020-11-17T12:57:47 | 2020-11-17T12:57:47 | 299,050,652 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.itcast.demo01_jdbc操作事务;
import cn.itcast.utils.DruidUtils;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
/*
使用jdbc模拟转账操作
在转账的过程中,要保证所有的操作是一组操作,这组操作要么都成功要么都失败。
如果要把多个操作看成是同一组可以使用事务。
步骤:
1. 在转账之前开启事务
2. 进行转账。
3. 如果转账过程中没有问题,那么就提交事务
4. 如果转账过程中遇到了问题,那么就回滚事物。
jdbc操作事务需要使用Connection连接对象里面的方法进行操作。
void setAutoCommit(boolean autoCommit) : 可以开启事务。 如果是false,表示设置了事务的手动提交,也就是相当于开始事务。
如果是true,表示事务是自动提交,每执行一句,就生效一句。
void commit(): 提交事务。 让这个事务内的操作全部都生效
void rollback(): 回滚事物。 上这个事物内的操作全部失效。
*/
public class Demo01JDBCTransaction {
public static void main(String[] args) {
Connection con = null;
Statement st = null;
try {
//获取一个连接
con = DruidUtils.getConnection();
//使用连接对象开启事务
con.setAutoCommit(false); //设置事务手动提交,也就是开启事务
//获取一个sql语句执行者对象
st = con.createStatement();
//开始执行sql
//给jack的钱减去100
int row1 = st.executeUpdate("UPDATE account SET money=money-100 WHERE name='jack'");
System.out.println("row1:" + row1);
//停电了
//System.out.println(10 / 0);
//给rose的钱加上100
int row2 = st.executeUpdate("UPDATE account SET money=money+100 WHERE name='rose'");
System.out.println("row2:" + row2);
//提交事务
con.commit();
System.out.println("转账成功");
} catch (Exception e) {
//如果转账过程出现异常,会被这个catch捕获到,那么就在这里面回滚事物
try {
if(con != null) {
con.rollback();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
System.out.println("转账失败");
} finally {
//释放资源
DruidUtils.close(con, st);
}
}
}
| UTF-8 | Java | 2,695 | java | Demo01JDBCTransaction.java | Java | [
{
"context": "e(\"UPDATE account SET money=money-100 WHERE name='jack'\");\n System.out.println(\"row1:\" + row1",
"end": 1186,
"score": 0.9091501832008362,
"start": 1182,
"tag": "NAME",
"value": "jack"
},
{
"context": "e(\"UPDATE account SET money=money+100 WHERE name='ro... | null | [] | package cn.itcast.demo01_jdbc操作事务;
import cn.itcast.utils.DruidUtils;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
/*
使用jdbc模拟转账操作
在转账的过程中,要保证所有的操作是一组操作,这组操作要么都成功要么都失败。
如果要把多个操作看成是同一组可以使用事务。
步骤:
1. 在转账之前开启事务
2. 进行转账。
3. 如果转账过程中没有问题,那么就提交事务
4. 如果转账过程中遇到了问题,那么就回滚事物。
jdbc操作事务需要使用Connection连接对象里面的方法进行操作。
void setAutoCommit(boolean autoCommit) : 可以开启事务。 如果是false,表示设置了事务的手动提交,也就是相当于开始事务。
如果是true,表示事务是自动提交,每执行一句,就生效一句。
void commit(): 提交事务。 让这个事务内的操作全部都生效
void rollback(): 回滚事物。 上这个事物内的操作全部失效。
*/
public class Demo01JDBCTransaction {
public static void main(String[] args) {
Connection con = null;
Statement st = null;
try {
//获取一个连接
con = DruidUtils.getConnection();
//使用连接对象开启事务
con.setAutoCommit(false); //设置事务手动提交,也就是开启事务
//获取一个sql语句执行者对象
st = con.createStatement();
//开始执行sql
//给jack的钱减去100
int row1 = st.executeUpdate("UPDATE account SET money=money-100 WHERE name='jack'");
System.out.println("row1:" + row1);
//停电了
//System.out.println(10 / 0);
//给rose的钱加上100
int row2 = st.executeUpdate("UPDATE account SET money=money+100 WHERE name='rose'");
System.out.println("row2:" + row2);
//提交事务
con.commit();
System.out.println("转账成功");
} catch (Exception e) {
//如果转账过程出现异常,会被这个catch捕获到,那么就在这里面回滚事物
try {
if(con != null) {
con.rollback();
}
} catch (SQLException e1) {
e1.printStackTrace();
}
System.out.println("转账失败");
} finally {
//释放资源
DruidUtils.close(con, st);
}
}
}
| 2,695 | 0.540253 | 0.524557 | 71 | 26.816902 | 22.710865 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.309859 | false | false | 9 |
46f40f8ead09deff6ea385bdf4ec549c7b37742f | 21,698,174,811,132 | 35e3740a3eac7ffc9a49719c693e40ec0a7f8a67 | /src/main/java/org/zerhusen/rest/PersonRestController.java | 6bcb96071847e44780db2671f720a6d01a764651 | [
"MIT"
] | permissive | lany192/spring-boot-security-jwt-demo | https://github.com/lany192/spring-boot-security-jwt-demo | 924ac8f726e04b04088ca5818b77da619326519f | 275cb32927048cf9c0387869b7bc85c3a2b70960 | refs/heads/master | 2020-09-24T17:46:41.979000 | 2019-12-04T09:59:11 | 2019-12-04T09:59:11 | 225,810,783 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.zerhusen.rest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zerhusen.eniity.Person;
import org.zerhusen.eniity.Result;
@RestController
@RequestMapping("/api")
public class PersonRestController {
@GetMapping("/person")
public Result getPerson() {
Result result = new Result();
result.setCode(200);
result.setMsg("请求成功!");
result.setData(new Person("John Doe1", "john.doe@test.org"));
return result;
}
}
| UTF-8 | Java | 617 | java | PersonRestController.java | Java | [
{
"context": "setMsg(\"请求成功!\");\n result.setData(new Person(\"John Doe1\", \"john.doe@test.org\"));\n return result;\n ",
"end": 553,
"score": 0.9506092071533203,
"start": 544,
"tag": "NAME",
"value": "John Doe1"
},
{
"context": "\");\n result.setData(new Person(\"J... | null | [] | package org.zerhusen.rest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zerhusen.eniity.Person;
import org.zerhusen.eniity.Result;
@RestController
@RequestMapping("/api")
public class PersonRestController {
@GetMapping("/person")
public Result getPerson() {
Result result = new Result();
result.setCode(200);
result.setMsg("请求成功!");
result.setData(new Person("<NAME>", "<EMAIL>"));
return result;
}
}
| 604 | 0.739703 | 0.733114 | 21 | 27.904762 | 20.516903 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.571429 | false | false | 9 |
d996f867eb4165bac80f137b26bf002205a943f1 | 21,698,174,813,831 | d71e879b3517cf4fccde29f7bf82cff69856cfcd | /ExtractedJars/Shopkick_com.shopkick.app/javafiles/com/bumptech/glide/request/SingleRequest$1.java | f0fffe6a884e127bbd4555fcecef2a414ecc7df3 | [
"MIT"
] | permissive | Andreas237/AndroidPolicyAutomation | https://github.com/Andreas237/AndroidPolicyAutomation | b8e949e072d08cf6c6166c3f15c9c63379b8f6ce | c1ed10a2c6d4cf3dfda8b8e6291dee2c2a15ee8a | refs/heads/master | 2020-04-10T02:14:08.789000 | 2019-05-16T19:29:11 | 2019-05-16T19:29:11 | 160,739,088 | 5 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) annotate safe
package com.bumptech.glide.request;
// Referenced classes of package com.bumptech.glide.request:
// SingleRequest
class SingleRequest$1
implements com.bumptech.glide.util.pool.tory
{
public SingleRequest create()
{
return new SingleRequest();
// 0 0:new #9 <Class SingleRequest>
// 1 3:dup
// 2 4:invokespecial #17 <Method void SingleRequest()>
// 3 7:areturn
}
public volatile Object create()
{
return ((Object) (create()));
// 0 0:aload_0
// 1 1:invokevirtual #22 <Method SingleRequest create()>
// 2 4:areturn
}
SingleRequest$1()
{
// 0 0:aload_0
// 1 1:invokespecial #13 <Method void Object()>
// 2 4:return
}
}
| UTF-8 | Java | 955 | java | SingleRequest$1.java | Java | [
{
"context": "// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.\n// Jad home page: http://www.kpdus.com/jad.html\n",
"end": 61,
"score": 0.9996318817138672,
"start": 45,
"tag": "NAME",
"value": "Pavel Kouznetsov"
}
] | null | [] | // Decompiled by Jad v1.5.8g. Copyright 2001 <NAME>.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) annotate safe
package com.bumptech.glide.request;
// Referenced classes of package com.bumptech.glide.request:
// SingleRequest
class SingleRequest$1
implements com.bumptech.glide.util.pool.tory
{
public SingleRequest create()
{
return new SingleRequest();
// 0 0:new #9 <Class SingleRequest>
// 1 3:dup
// 2 4:invokespecial #17 <Method void SingleRequest()>
// 3 7:areturn
}
public volatile Object create()
{
return ((Object) (create()));
// 0 0:aload_0
// 1 1:invokevirtual #22 <Method SingleRequest create()>
// 2 4:areturn
}
SingleRequest$1()
{
// 0 0:aload_0
// 1 1:invokespecial #13 <Method void Object()>
// 2 4:return
}
}
| 945 | 0.588482 | 0.547644 | 38 | 24.131578 | 22.098072 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.789474 | false | false | 9 |
eb0698cf07289d179c32d2f0f82b7d28aaa4c4dd | 2,156,073,601,691 | be5eaa509d6a04eff37ccb5186ad88684469e268 | /src/dao/impl/AddressDAO.java | 810908d6bd3edac4a6f21d2c34d0203a022fdb8f | [] | no_license | dang3tion/SoftwareEngineering_Project | https://github.com/dang3tion/SoftwareEngineering_Project | 9de7d4fc2cbe1bad935e8957b4d361e7513c3191 | bcf83e01321f85359f83d7ef655cee747ab25528 | refs/heads/master | 2023-07-10T21:50:55.656000 | 2021-08-22T05:46:14 | 2021-08-22T05:46:14 | 368,703,004 | 0 | 0 | null | false | 2021-06-28T15:41:22 | 2021-05-19T00:43:00 | 2021-06-28T13:21:27 | 2021-06-28T15:41:21 | 71,753 | 0 | 0 | 0 | HTML | false | false | package dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import connection.AccessDatabase;
import connection.SinglePool;
import dao.IAddressDAO;
import mapper.AddressMapper;
import model.AddressDetail;
public class AddressDAO extends AbstractDAO<AddressDetail> implements IAddressDAO{
private static AddressDAO ins = new AddressDAO();
public AddressDAO() {
}
public static AddressDAO getInstance() {
if (ins == null) {
ins = new AddressDAO();
}
return ins;
}
@Override
public boolean insertAddress(AddressDetail address, String id) {
AccessDatabase ac = AccessDatabase.getInstance();
String query = "INSERT INTO DIACHI VALUES(?,?,?,?,?,?,?,'1')";
try (ResultSet rs = ac.executeQuery(query, address.getTitle(), address.getAddress(), address.getAddress(),
address.getCity(), address.getDistrict(), address.getState(), id)) {
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
}
| UTF-8 | Java | 1,110 | java | AddressDAO.java | Java | [] | null | [] | package dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import connection.AccessDatabase;
import connection.SinglePool;
import dao.IAddressDAO;
import mapper.AddressMapper;
import model.AddressDetail;
public class AddressDAO extends AbstractDAO<AddressDetail> implements IAddressDAO{
private static AddressDAO ins = new AddressDAO();
public AddressDAO() {
}
public static AddressDAO getInstance() {
if (ins == null) {
ins = new AddressDAO();
}
return ins;
}
@Override
public boolean insertAddress(AddressDetail address, String id) {
AccessDatabase ac = AccessDatabase.getInstance();
String query = "INSERT INTO DIACHI VALUES(?,?,?,?,?,?,?,'1')";
try (ResultSet rs = ac.executeQuery(query, address.getTitle(), address.getAddress(), address.getAddress(),
address.getCity(), address.getDistrict(), address.getState(), id)) {
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
}
| 1,110 | 0.738739 | 0.737838 | 44 | 24.227272 | 24.319712 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.704545 | false | false | 9 |
bb2e7a427efc4a669a4f6849739247237f5a931c | 30,434,138,320,206 | 5d091ee94b2a9aaafb81cec95c58a484a9e2eeb3 | /app/src/main/java/com/example/mymovieapp/MyMovieUtil.java | cd19fc1b75a458a95c8933a28f9975984d6d36d7 | [] | no_license | applexp/mymoviedbdemo | https://github.com/applexp/mymoviedbdemo | 731a70093d460860ed1d62ac209e9944e8eb9295 | 44fd5555fed59e43e8955343ec3b73227f0f0b4f | refs/heads/master | 2020-07-02T14:27:37.160000 | 2019-08-09T23:56:27 | 2019-08-09T23:56:27 | 201,555,932 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.mymovieapp;
public class MyMovieUtil {
public static final String API_KEY = "";
public static final String THE_MOVIE_BASE_URL = "https://api.themoviedb.org";
public static final String MOVIE_POPULAR_URL = "/3/movie/popular?api_key=";
public static final String MOVIE_TOP_RATE_URL = "/3/movie/top_rated?api_key=";
public static final String THE_MOVIE_IMAGE_URL = "https://image.tmdb.org/t/p/w500";
public static final String GENRE_URL = "/3/genre/movie/list?api_key=";
}
| UTF-8 | Java | 516 | java | MyMovieUtil.java | Java | [] | null | [] | package com.example.mymovieapp;
public class MyMovieUtil {
public static final String API_KEY = "";
public static final String THE_MOVIE_BASE_URL = "https://api.themoviedb.org";
public static final String MOVIE_POPULAR_URL = "/3/movie/popular?api_key=";
public static final String MOVIE_TOP_RATE_URL = "/3/movie/top_rated?api_key=";
public static final String THE_MOVIE_IMAGE_URL = "https://image.tmdb.org/t/p/w500";
public static final String GENRE_URL = "/3/genre/movie/list?api_key=";
}
| 516 | 0.709302 | 0.697674 | 10 | 50.599998 | 32.711468 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.7 | false | false | 9 |
e77a3039e1f0bfebd5a31bf7c6b7b2ac912a8419 | 28,217,935,186,121 | 1a045d891bd6cbb54a429b0f87afd8d333bc61b5 | /src/main/com/urlshortner/dao/UrlDataService.java | f1ebcfcf3a5c0346800e760f42dd53bbe28918d1 | [] | no_license | koolabhipal/url-shortner | https://github.com/koolabhipal/url-shortner | 5160e3606f0dc94ddda401e2d5bc8e740386c924 | 363b7216f9d13f928276770af2bf20f5ac50b2cb | refs/heads/master | 2021-01-19T05:57:51.996000 | 2016-07-28T08:52:20 | 2016-07-28T08:52:20 | 64,332,555 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.com.urlshortner.dao;
import com.google.common.collect.Iterables;
import main.com.urlshortner.model.Url;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class UrlDataService {
public static List<Url> storedUrls = new ArrayList<Url>();
public static Map<Url, Integer> redirectionStatistics = new HashMap<>();
public void persistUrl(Url url){
storedUrls.add(url);
}
public Url getUrl(Integer id){
return Iterables.getOnlyElement(
storedUrls.stream()
.filter(url -> url.id().equals(id))
.collect(Collectors.toList())
);
}
public void registerRedirection(Url url) {
Integer currentCount = redirectionStatistics.get(url);
redirectionStatistics.put(url, currentCount == null ? 1 : currentCount + 1);
}
public List<String> retreiveStatistic(String userName){
return redirectionStatistics.entrySet()
.stream()
.filter(entry -> entry.getKey().userName().equals(userName))
.map(entry -> "\"" + entry.getKey().fullUrl() + "\"" + ":" + "\"" + entry.getValue() + "\"")
.collect(Collectors.toList());
}
}
| UTF-8 | Java | 1,366 | java | UrlDataService.java | Java | [] | null | [] | package main.com.urlshortner.dao;
import com.google.common.collect.Iterables;
import main.com.urlshortner.model.Url;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class UrlDataService {
public static List<Url> storedUrls = new ArrayList<Url>();
public static Map<Url, Integer> redirectionStatistics = new HashMap<>();
public void persistUrl(Url url){
storedUrls.add(url);
}
public Url getUrl(Integer id){
return Iterables.getOnlyElement(
storedUrls.stream()
.filter(url -> url.id().equals(id))
.collect(Collectors.toList())
);
}
public void registerRedirection(Url url) {
Integer currentCount = redirectionStatistics.get(url);
redirectionStatistics.put(url, currentCount == null ? 1 : currentCount + 1);
}
public List<String> retreiveStatistic(String userName){
return redirectionStatistics.entrySet()
.stream()
.filter(entry -> entry.getKey().userName().equals(userName))
.map(entry -> "\"" + entry.getKey().fullUrl() + "\"" + ":" + "\"" + entry.getValue() + "\"")
.collect(Collectors.toList());
}
}
| 1,366 | 0.637628 | 0.636164 | 43 | 30.767443 | 26.376379 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.418605 | false | false | 9 |
0736499bc8d97c3b3903d23c399bb8832a6f22ca | 29,489,245,501,428 | d4c37433bb9c1295e17708cfddf31e0507e6e811 | /src/tiles/HighLowTile.java | ca9e5c43df1a55b6af8cdf803b70563d558f7692 | [] | no_license | KramPiotr/WeatherApp2019 | https://github.com/KramPiotr/WeatherApp2019 | b4b0be27bec1fc99b4a1726a9cdfea54726363b2 | 3cdda95642eda93d76e7f1347dc408543eef5087 | refs/heads/master | 2022-12-28T20:47:44.638000 | 2019-05-21T14:05:39 | 2019-05-21T14:05:39 | 304,180,231 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tiles;
import util.AutoSizeText;
import javafx.geometry.Insets;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Line;
import settings.Settings;
import skeletons.WeatherScene;
import java.text.NumberFormat;
import static javafx.geometry.Pos.CENTER_LEFT;
public class HighLowTile extends Tile{
AutoSizeText label;
double high;
double low;
AutoSizeText lowValue;
AutoSizeText highValue;
NumberFormat nf;
HBox hbox;
Line divider;
Line horizLine;
public HighLowTile(WeatherScene parent){
super(parent);
//Create number format for temperature
nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(1);
nf.setMaximumFractionDigits(1);
//Set prefered size of tile
this.setPrefSize(300, 125);
//Set text in label and value
label = new AutoSizeText("Low/High:", Settings.getFadedPrimary());
low = parent.getLow();
high = parent.getHigh();
if(Settings.isCelsius()){
lowValue = new AutoSizeText(nf.format(low)+"°C",Settings.getPrimary());
highValue = new AutoSizeText(nf.format(high)+"°C",Settings.getPrimary());
}
else{
lowValue = new AutoSizeText(nf.format(low*9.0/5.0+32.0)+"°F",Settings.getPrimary());
highValue = new AutoSizeText(nf.format(high*9.0/5.0+32.0)+"°F",Settings.getPrimary());
}
lowValue.setSize(110,40);
highValue.setSize(100,40);
//Position label and value
hbox = new HBox();
hbox.setPadding(new Insets(10, 0, 10, 10));
hbox.setSpacing(10);
divider = new Line();
divider.setStartX(0);
divider.setEndX(0);
divider.setStartY(20);
divider.setEndY(125);
divider.setStrokeWidth(5);
label.setTextWidth(150-15);
hbox.setAlignment(CENTER_LEFT);
VBox values = new VBox();
horizLine = new Line();
horizLine.setStartX(10);
horizLine.setEndX(110);
horizLine.setStartY(0);
horizLine.setEndY(0);
horizLine.setStrokeWidth(3);
values.getChildren().addAll(lowValue,horizLine,highValue);
hbox.getChildren().addAll(label, divider, values);
hbox.setMinSize(this.getPrefWidth(), this.getPrefHeight());
hbox.setPrefSize(300,125);
hbox.setMaxWidth(300);
this.getChildren().addAll(hbox);
update();
}
@Override
public void update(){
low = ((WeatherScene) parent).getLow();
high = ((WeatherScene) parent).getHigh();
if(Settings.isCelsius()){
lowValue.setText(nf.format(low)+"°C");
highValue.setText(nf.format(high)+"°C");
}
else{
lowValue.setText(nf.format(low*9.0/5.0+32.0)+"°F");
highValue.setText(nf.format(high*9.0/5.0+32.0)+"°F");
}
lowValue.setFill(Settings.getPrimary());
highValue.setFill(Settings.getPrimary());
lowValue.resizeText();
highValue.resizeText();
hbox.setBackground(new Background(new BackgroundFill(Settings.getSecondary(), null, null)));
hbox.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;"
+ "-fx-border-width: 5;" + "-fx-border-insets: -1;"
+ "-fx-border-radius: 0;" + "-fx-border-color: " + Settings.colorString(Settings.getTertiary()) + ";");
label.setFill(Settings.getFadedPrimary());
divider.setStroke(Settings.getFadedPrimary());
horizLine.setStroke(Settings.getFadedPrimary());
}
}
| UTF-8 | Java | 3,739 | java | HighLowTile.java | Java | [] | null | [] | package tiles;
import util.AutoSizeText;
import javafx.geometry.Insets;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Line;
import settings.Settings;
import skeletons.WeatherScene;
import java.text.NumberFormat;
import static javafx.geometry.Pos.CENTER_LEFT;
public class HighLowTile extends Tile{
AutoSizeText label;
double high;
double low;
AutoSizeText lowValue;
AutoSizeText highValue;
NumberFormat nf;
HBox hbox;
Line divider;
Line horizLine;
public HighLowTile(WeatherScene parent){
super(parent);
//Create number format for temperature
nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(1);
nf.setMaximumFractionDigits(1);
//Set prefered size of tile
this.setPrefSize(300, 125);
//Set text in label and value
label = new AutoSizeText("Low/High:", Settings.getFadedPrimary());
low = parent.getLow();
high = parent.getHigh();
if(Settings.isCelsius()){
lowValue = new AutoSizeText(nf.format(low)+"°C",Settings.getPrimary());
highValue = new AutoSizeText(nf.format(high)+"°C",Settings.getPrimary());
}
else{
lowValue = new AutoSizeText(nf.format(low*9.0/5.0+32.0)+"°F",Settings.getPrimary());
highValue = new AutoSizeText(nf.format(high*9.0/5.0+32.0)+"°F",Settings.getPrimary());
}
lowValue.setSize(110,40);
highValue.setSize(100,40);
//Position label and value
hbox = new HBox();
hbox.setPadding(new Insets(10, 0, 10, 10));
hbox.setSpacing(10);
divider = new Line();
divider.setStartX(0);
divider.setEndX(0);
divider.setStartY(20);
divider.setEndY(125);
divider.setStrokeWidth(5);
label.setTextWidth(150-15);
hbox.setAlignment(CENTER_LEFT);
VBox values = new VBox();
horizLine = new Line();
horizLine.setStartX(10);
horizLine.setEndX(110);
horizLine.setStartY(0);
horizLine.setEndY(0);
horizLine.setStrokeWidth(3);
values.getChildren().addAll(lowValue,horizLine,highValue);
hbox.getChildren().addAll(label, divider, values);
hbox.setMinSize(this.getPrefWidth(), this.getPrefHeight());
hbox.setPrefSize(300,125);
hbox.setMaxWidth(300);
this.getChildren().addAll(hbox);
update();
}
@Override
public void update(){
low = ((WeatherScene) parent).getLow();
high = ((WeatherScene) parent).getHigh();
if(Settings.isCelsius()){
lowValue.setText(nf.format(low)+"°C");
highValue.setText(nf.format(high)+"°C");
}
else{
lowValue.setText(nf.format(low*9.0/5.0+32.0)+"°F");
highValue.setText(nf.format(high*9.0/5.0+32.0)+"°F");
}
lowValue.setFill(Settings.getPrimary());
highValue.setFill(Settings.getPrimary());
lowValue.resizeText();
highValue.resizeText();
hbox.setBackground(new Background(new BackgroundFill(Settings.getSecondary(), null, null)));
hbox.setStyle("-fx-padding: 10;" + "-fx-border-style: solid inside;"
+ "-fx-border-width: 5;" + "-fx-border-insets: -1;"
+ "-fx-border-radius: 0;" + "-fx-border-color: " + Settings.colorString(Settings.getTertiary()) + ";");
label.setFill(Settings.getFadedPrimary());
divider.setStroke(Settings.getFadedPrimary());
horizLine.setStroke(Settings.getFadedPrimary());
}
}
| 3,739 | 0.618601 | 0.594479 | 130 | 27.700001 | 24.993429 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.769231 | false | false | 9 |
52b64002c061a133b28fb0a56ce6241449fa52ae | 18,270,790,935,361 | 742b02760be8b8208ab7f0c9a812020daf62fe53 | /src/main/java/br/com/escola/notas/Notas.java | e072189878463a6920b79ff393872832bd8dfa9a | [] | no_license | PrebibajT/escolaHBSIS | https://github.com/PrebibajT/escolaHBSIS | 98477187459e7feb445d2d95da377aee991531c7 | 013194af4ca366ed0148db9cb5aebeab4a01b052 | refs/heads/master | 2021-01-02T20:06:34.808000 | 2020-02-28T11:54:40 | 2020-02-28T11:54:40 | 239,779,507 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.escola.notas;
import br.com.escola.aluno.Alunos;
import br.com.escola.materia.Materia;
import javax.persistence.*;
@Entity
@Table(name = "seg_notas")
public class Notas {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn (name = "id_materia", referencedColumnName="id")
private Materia materia;
@ManyToOne
@JoinColumn (name = "id_aluno", referencedColumnName="id")
private Alunos aluno;
@Column(name = "nota_1")
private Double nota1;
@Column(name = "nota_2")
private Double nota2;
@Column(name = "nota_3")
private Double nota3;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Materia getMateria() {
return materia;
}
public void setMateria(Materia materia) {
this.materia = materia;
}
public Alunos getAluno() {
return aluno;
}
public void setAluno(Alunos aluno) {
this.aluno = aluno;
}
public Double getNota1() {
return nota1;
}
public void setNota1(Double nota1) {
this.nota1 = nota1;
}
public Double getNota2() {
return nota2;
}
public void setNota2(Double nota2) {
this.nota2 = nota2;
}
public Double getNota3() {
return nota3;
}
public void setNota3(Double nota3) {
this.nota3 = nota3;
}
@Override
public String toString() {
return "Notas{" +
"id=" + id +
", materia=" + materia +
", aluno=" + aluno +
", nota_1=" + nota1 +
", nota_2=" + nota2 +
", nota_3=" + nota3 +
'}';
}
}
| UTF-8 | Java | 1,790 | java | Notas.java | Java | [] | null | [] | package br.com.escola.notas;
import br.com.escola.aluno.Alunos;
import br.com.escola.materia.Materia;
import javax.persistence.*;
@Entity
@Table(name = "seg_notas")
public class Notas {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn (name = "id_materia", referencedColumnName="id")
private Materia materia;
@ManyToOne
@JoinColumn (name = "id_aluno", referencedColumnName="id")
private Alunos aluno;
@Column(name = "nota_1")
private Double nota1;
@Column(name = "nota_2")
private Double nota2;
@Column(name = "nota_3")
private Double nota3;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Materia getMateria() {
return materia;
}
public void setMateria(Materia materia) {
this.materia = materia;
}
public Alunos getAluno() {
return aluno;
}
public void setAluno(Alunos aluno) {
this.aluno = aluno;
}
public Double getNota1() {
return nota1;
}
public void setNota1(Double nota1) {
this.nota1 = nota1;
}
public Double getNota2() {
return nota2;
}
public void setNota2(Double nota2) {
this.nota2 = nota2;
}
public Double getNota3() {
return nota3;
}
public void setNota3(Double nota3) {
this.nota3 = nota3;
}
@Override
public String toString() {
return "Notas{" +
"id=" + id +
", materia=" + materia +
", aluno=" + aluno +
", nota_1=" + nota1 +
", nota_2=" + nota2 +
", nota_3=" + nota3 +
'}';
}
}
| 1,790 | 0.546927 | 0.530168 | 94 | 18.042553 | 15.948665 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.319149 | false | false | 9 |
a2af7c50e33620104f76e6875e08d4b3037ca8e8 | 5,866,925,381,414 | db1b226364cdd206b46c4c31967cee4a2ecc0681 | /1_Thread/src/线程通信/SleepAndWait.java | 5045cbf082600c0818e39fcac9630df36c109c37 | [] | no_license | IWantFight/JavaSE | https://github.com/IWantFight/JavaSE | 5db62e5d6f7c6e7201e3347cba8d9473f6554cbb | d5d50950df01736d70b1b63573a6f55df268f672 | refs/heads/master | 2021-02-27T22:44:13.421000 | 2020-03-17T16:31:51 | 2020-03-17T16:31:51 | 245,641,155 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package 线程通信;
/*
sleep与wait相同点:
都可以让当前线程进入阻塞状态
不同点:
两个方法声明的位置不一样,sleep在Thread中声明的静态方法,object中声明方法wait
调用的范围不同,sleep可以在任意场景下调用。wait必须使用在同步方法或者同步代码块中
如果两个方法都是用在同步方法或者代码块中,sleep不会释放同步监视器,而wait会释放。
*/
public class SleepAndWait {
public static void main(String[] args) {
}
}
| UTF-8 | Java | 576 | java | SleepAndWait.java | Java | [] | null | [] | package 线程通信;
/*
sleep与wait相同点:
都可以让当前线程进入阻塞状态
不同点:
两个方法声明的位置不一样,sleep在Thread中声明的静态方法,object中声明方法wait
调用的范围不同,sleep可以在任意场景下调用。wait必须使用在同步方法或者同步代码块中
如果两个方法都是用在同步方法或者代码块中,sleep不会释放同步监视器,而wait会释放。
*/
public class SleepAndWait {
public static void main(String[] args) {
}
}
| 576 | 0.701863 | 0.701863 | 14 | 22 | 20.479956 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.071429 | false | false | 9 |
431b1bcb3b2b2f8707350860bd155a4d189139f6 | 31,662,498,964,247 | 73dbf2bb4976e269f839cf266f97c5fdbea449cf | /app/src/main/java/com/jju/feng/anti_theft/service/GPSService.java | 4d4c237cc4eae8b0596411756fba0de5e411a92b | [] | no_license | gitFeng220/Anti_theft | https://github.com/gitFeng220/Anti_theft | 191c5cebe5a8365fc3c2ccfbc3542cd99320bc89 | 8c65e8cbcbaab8abd0a4d257f5f9d8198de7b8ac | refs/heads/master | 2021-01-13T14:46:20.014000 | 2016-12-20T07:11:12 | 2016-12-20T07:11:12 | 76,551,422 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jju.feng.anti_theft.service;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.os.PowerManager;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.jju.feng.anti_theft.app.MyApplication;
import java.util.List;
public class GPSService extends Service {
private PowerManager.WakeLock m_wklk;
private LocationService locationService;
private int count = 0; //控制发送短信的次数
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
//申请WakeLock可以让进程持续执行即使手机进入睡眠模式
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
m_wklk = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, GPSService.class.getName());
m_wklk.acquire();
locationService = ((MyApplication) getApplication()).locationService;
//获取locationservice实例,建议应用中只初始化1个location实例,然后使用,可以参考其他示例的activity,都是通过此种方式获取locationservice实例的
locationService.registerListener(mListener);
//注册监听
locationService.setLocationOption(locationService.getDefaultLocationClientOption());
locationService.start();// 定位SDK
}
/**
* 发送短信的方法
*
* @param message 要发送的内容
*/
private void sendSms(final String message) {
new Thread() {
@Override
public void run() {
super.run();
// SmsManager.getDefault().sendTextMessage(sp.getString("safenumber", ""), null, "1235", null, null);
//获取短信管理器
SharedPreferences sp = getSharedPreferences("config", MODE_PRIVATE);
String phonenumber = sp.getString("safenumber", "");
android.telephony.SmsManager smsManager = android.telephony.SmsManager.getDefault();
//拆分短信内容(手机短信长度限制)
List<String> divideContents = smsManager.divideMessage(message);
for (String text : divideContents) {
smsManager.sendTextMessage(phonenumber, null, text, null, null);
}
//停止服务
stopSelf();
}
}.start();
}
/*****
* copy funtion to you project
* 定位结果回调,重写onReceiveLocation方法,可以直接拷贝如下代码到自己工程中修改
*
*/
private BDLocationListener mListener = new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
StringBuffer sb = new StringBuffer(256);
sb.append("time : ");
/**
* 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间;
* location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变
*/
sb.append(location.getTime());
sb.append("\nlatitude : ");// 纬度
sb.append(location.getLatitude());
sb.append(";lontitude : ");// 经度
sb.append(location.getLongitude());
sb.append("\naddr : ");// 地址信息
sb.append(location.getAddrStr());
sb.append(location.getLocationDescribe());// 位置语义化信息
count++;
if (count == 1) {
sendSms(sb.toString());
}
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
if (m_wklk != null) {
m_wklk.release();
m_wklk = null;
}
locationService.unregisterListener(mListener); //注销掉监听
locationService.stop(); //停止定位服务
}
}
| UTF-8 | Java | 4,344 | java | GPSService.java | Java | [] | null | [] | package com.jju.feng.anti_theft.service;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.os.PowerManager;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.jju.feng.anti_theft.app.MyApplication;
import java.util.List;
public class GPSService extends Service {
private PowerManager.WakeLock m_wklk;
private LocationService locationService;
private int count = 0; //控制发送短信的次数
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
//申请WakeLock可以让进程持续执行即使手机进入睡眠模式
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
m_wklk = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, GPSService.class.getName());
m_wklk.acquire();
locationService = ((MyApplication) getApplication()).locationService;
//获取locationservice实例,建议应用中只初始化1个location实例,然后使用,可以参考其他示例的activity,都是通过此种方式获取locationservice实例的
locationService.registerListener(mListener);
//注册监听
locationService.setLocationOption(locationService.getDefaultLocationClientOption());
locationService.start();// 定位SDK
}
/**
* 发送短信的方法
*
* @param message 要发送的内容
*/
private void sendSms(final String message) {
new Thread() {
@Override
public void run() {
super.run();
// SmsManager.getDefault().sendTextMessage(sp.getString("safenumber", ""), null, "1235", null, null);
//获取短信管理器
SharedPreferences sp = getSharedPreferences("config", MODE_PRIVATE);
String phonenumber = sp.getString("safenumber", "");
android.telephony.SmsManager smsManager = android.telephony.SmsManager.getDefault();
//拆分短信内容(手机短信长度限制)
List<String> divideContents = smsManager.divideMessage(message);
for (String text : divideContents) {
smsManager.sendTextMessage(phonenumber, null, text, null, null);
}
//停止服务
stopSelf();
}
}.start();
}
/*****
* copy funtion to you project
* 定位结果回调,重写onReceiveLocation方法,可以直接拷贝如下代码到自己工程中修改
*
*/
private BDLocationListener mListener = new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation location) {
// TODO Auto-generated method stub
if (null != location && location.getLocType() != BDLocation.TypeServerError) {
StringBuffer sb = new StringBuffer(256);
sb.append("time : ");
/**
* 时间也可以使用systemClock.elapsedRealtime()方法 获取的是自从开机以来,每次回调的时间;
* location.getTime() 是指服务端出本次结果的时间,如果位置不发生变化,则时间不变
*/
sb.append(location.getTime());
sb.append("\nlatitude : ");// 纬度
sb.append(location.getLatitude());
sb.append(";lontitude : ");// 经度
sb.append(location.getLongitude());
sb.append("\naddr : ");// 地址信息
sb.append(location.getAddrStr());
sb.append(location.getLocationDescribe());// 位置语义化信息
count++;
if (count == 1) {
sendSms(sb.toString());
}
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
if (m_wklk != null) {
m_wklk.release();
m_wklk = null;
}
locationService.unregisterListener(mListener); //注销掉监听
locationService.stop(); //停止定位服务
}
}
| 4,344 | 0.590088 | 0.587506 | 119 | 31.554623 | 27.092651 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.529412 | false | false | 9 |
c2edb0b2be1ad98d6cbeb5bc85509eb3aa132d23 | 21,964,462,816,358 | c41c33fd4f90300c667ab4e6fa53a23abcb69615 | /hw5/ShapeIcon.java | 78c7f7cab9e603b692ba71c967d3a8e4072dea7b | [] | no_license | XiaofanLinUS/CS151 | https://github.com/XiaofanLinUS/CS151 | f166dbb7545e79e445419253e8e5b0c20dc043b6 | fa12c45dcad987423910a09ff122d0689f1acf7d | refs/heads/master | 2021-06-08T13:13:33.158000 | 2016-12-16T22:25:45 | 2016-12-16T22:25:45 | 66,685,875 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;
/**
* An icon that contains a moveable shape.
*/
public class ShapeIcon implements Icon
{
/**
* Construct a shape icon with a given shape, width and height
*
* @param shape
* the shape
* @param width
* the width
* @param height
* the height
*/
public ShapeIcon(MoveableShape shape, int width, int height)
{
this.shape = shape;
this.width = width;
this.height = height;
}
/**
* Get the width of this icon
*
* @return the width
*/
public int getIconWidth()
{
return width;
}
/**
* Get the height of this icon
*
* @return the height
*/
public int getIconHeight()
{
return height;
}
/**
* Paint the dial
*
* @param c
* the component
* @param g
* the graphics context
* @param x
* the left of the bounding rectangle
* @param y
* the top of the bounding rectangle
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
Graphics2D g2 = (Graphics2D) g;
shape.draw(g2);
}
private int width;
private int height;
private MoveableShape shape;
}
| UTF-8 | Java | 1,343 | java | ShapeIcon.java | Java | [] | null | [] | import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;
/**
* An icon that contains a moveable shape.
*/
public class ShapeIcon implements Icon
{
/**
* Construct a shape icon with a given shape, width and height
*
* @param shape
* the shape
* @param width
* the width
* @param height
* the height
*/
public ShapeIcon(MoveableShape shape, int width, int height)
{
this.shape = shape;
this.width = width;
this.height = height;
}
/**
* Get the width of this icon
*
* @return the width
*/
public int getIconWidth()
{
return width;
}
/**
* Get the height of this icon
*
* @return the height
*/
public int getIconHeight()
{
return height;
}
/**
* Paint the dial
*
* @param c
* the component
* @param g
* the graphics context
* @param x
* the left of the bounding rectangle
* @param y
* the top of the bounding rectangle
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
Graphics2D g2 = (Graphics2D) g;
shape.draw(g2);
}
private int width;
private int height;
private MoveableShape shape;
}
| 1,343 | 0.556217 | 0.552494 | 70 | 18.185715 | 15.965403 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 9 |
1e7816db1a0e6133ad204ab49903a4055b2dce24 | 33,663,953,718,920 | b6ce061794720099d70d4dca0abc6f498e8a8634 | /src/main/java/com/sb/ecommerce/infrastructure/api/endpoint/BackScratcherEndpoint.java | 6f7376483c07127a79f082a3a29db461227c851d | [] | no_license | marianoguk/sb-ecommerce-api | https://github.com/marianoguk/sb-ecommerce-api | a2936ae881e0c7ec30c4bb486ee7ba9abfc6ff76 | cd628e074115a24f5ec8a498000ce2fc7e50d525 | refs/heads/main | 2023-06-06T05:27:17.596000 | 2021-06-20T21:56:36 | 2021-06-20T21:56:36 | 377,533,807 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sb.ecommerce.infrastructure.api.endpoint;
import com.sb.ecommerce.domain.service.BackScratcherService;
import com.sb.ecommerce.infrastructure.api.dto.BackScratcherDto;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import java.util.List;
@RestController
@RequestMapping("/api/v1/back-scratcher")
public class BackScratcherEndpoint implements BackScratcherResource {
private final BackScratcherService service;
public BackScratcherEndpoint(BackScratcherService service) {
this.service = service;
}
@GetMapping(value = "/{id}")
public ResponseEntity<BackScratcherDto> findById(@PathVariable Long id) {
var res = service.findById(id);
if (res.isPresent()) {
return ResponseEntity.status(HttpStatus.OK).body(res.get());
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
@GetMapping
public ResponseEntity<List<BackScratcherDto>> findAll() {
return ResponseEntity.status(HttpStatus.OK).body(service.findAll());
}
@PostMapping
public ResponseEntity<BackScratcherDto> create(@RequestBody BackScratcherDto dto) {
return ResponseEntity.status(HttpStatus.CREATED).body(service.create(dto));
}
@PutMapping
public ResponseEntity<BackScratcherDto> update(@RequestBody BackScratcherDto dto) {
return ResponseEntity.status(HttpStatus.OK).body(service.update(dto));
}
@DeleteMapping("/{id}")
public ResponseEntity<BackScratcherDto> delete(@PathVariable Long id) {
service.delete(id);
return ResponseEntity.status(HttpStatus.OK).build();
}
} | UTF-8 | Java | 1,718 | java | BackScratcherEndpoint.java | Java | [] | null | [] | package com.sb.ecommerce.infrastructure.api.endpoint;
import com.sb.ecommerce.domain.service.BackScratcherService;
import com.sb.ecommerce.infrastructure.api.dto.BackScratcherDto;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import java.util.List;
@RestController
@RequestMapping("/api/v1/back-scratcher")
public class BackScratcherEndpoint implements BackScratcherResource {
private final BackScratcherService service;
public BackScratcherEndpoint(BackScratcherService service) {
this.service = service;
}
@GetMapping(value = "/{id}")
public ResponseEntity<BackScratcherDto> findById(@PathVariable Long id) {
var res = service.findById(id);
if (res.isPresent()) {
return ResponseEntity.status(HttpStatus.OK).body(res.get());
}
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
@GetMapping
public ResponseEntity<List<BackScratcherDto>> findAll() {
return ResponseEntity.status(HttpStatus.OK).body(service.findAll());
}
@PostMapping
public ResponseEntity<BackScratcherDto> create(@RequestBody BackScratcherDto dto) {
return ResponseEntity.status(HttpStatus.CREATED).body(service.create(dto));
}
@PutMapping
public ResponseEntity<BackScratcherDto> update(@RequestBody BackScratcherDto dto) {
return ResponseEntity.status(HttpStatus.OK).body(service.update(dto));
}
@DeleteMapping("/{id}")
public ResponseEntity<BackScratcherDto> delete(@PathVariable Long id) {
service.delete(id);
return ResponseEntity.status(HttpStatus.OK).build();
}
} | 1,718 | 0.732829 | 0.732247 | 50 | 33.380001 | 29.646511 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.34 | false | false | 9 |
a00831762e28852c36acdc4496d6057b2932f405 | 12,094,627,965,206 | 035ca542395855eb6a03cb5580a018c56445ff96 | /src/test/java/com/gasstove/gs/test/TestConfiguration.java | 8f018d5476824d9f74a78fe656076237e287058d | [] | no_license | gasstove/rest-api | https://github.com/gasstove/rest-api | 8ece4544852b0369080a17e7cc42b960ec31e155 | 508a6cd474a7f87657573a4cd3e468094448dd9b | refs/heads/master | 2021-01-10T18:10:12.873000 | 2015-10-01T14:35:58 | 2015-10-01T14:35:58 | 30,510,924 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gasstove.gs.test;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class TestConfiguration {
private static final String SERVER_BASE_URI = "http://localhost:50000";
private static final String REST_API_PATH = "/gs-rest-api";
// public static final String db = "jdbc:sqlite:" + Configuration.testDB;
public static Integer user_id = 36;
public static Integer event_id = 1;
public static Integer media_id = 15;
public static Integer mediaevent_id = 1;
public static Integer userevent_id = 1;
public static boolean doprint = false;
public static void printout(String response,String expected,String methodname){
if(TestConfiguration.doprint) {
System.out.println(methodname);
System.out.println(response);
System.out.println(expected);
}
}
// standard response values per test
// public static String expectedResponseStatus = "OK";
// public static int expectedResponseCode = 200;
public static HttpURLConnection sendRequest(String uri, String method, int number) {
return sendRequest(uri,method,Integer.toString(number));
}
public static HttpURLConnection sendRequest(String uri, String method, String data) {
HttpURLConnection conn = null;
try {
String url = TestConfiguration.SERVER_BASE_URI + TestConfiguration.REST_API_PATH + uri;
// Construct Http Connection object
URL requestUrl = new URL(url);
conn = (HttpURLConnection) requestUrl.openConnection();
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.setRequestProperty("X-Requested-With", "XMLHttpRequest");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestMethod(method);
if(method.equals("POST") || method.equals("PUT")){
byte[] outputBytes = data.getBytes();
conn.setFixedLengthStreamingMode(outputBytes.length);
conn.connect();
OutputStream os = conn.getOutputStream();
os.write(outputBytes);
os.flush();
os.close();
}
else{
conn.connect();
}
// return response
return conn;
}
catch (Exception exp) {
if(conn!=null)
conn.disconnect();
exp.printStackTrace();
return null;
}
}
} | UTF-8 | Java | 2,667 | java | TestConfiguration.java | Java | [] | null | [] | package com.gasstove.gs.test;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class TestConfiguration {
private static final String SERVER_BASE_URI = "http://localhost:50000";
private static final String REST_API_PATH = "/gs-rest-api";
// public static final String db = "jdbc:sqlite:" + Configuration.testDB;
public static Integer user_id = 36;
public static Integer event_id = 1;
public static Integer media_id = 15;
public static Integer mediaevent_id = 1;
public static Integer userevent_id = 1;
public static boolean doprint = false;
public static void printout(String response,String expected,String methodname){
if(TestConfiguration.doprint) {
System.out.println(methodname);
System.out.println(response);
System.out.println(expected);
}
}
// standard response values per test
// public static String expectedResponseStatus = "OK";
// public static int expectedResponseCode = 200;
public static HttpURLConnection sendRequest(String uri, String method, int number) {
return sendRequest(uri,method,Integer.toString(number));
}
public static HttpURLConnection sendRequest(String uri, String method, String data) {
HttpURLConnection conn = null;
try {
String url = TestConfiguration.SERVER_BASE_URI + TestConfiguration.REST_API_PATH + uri;
// Construct Http Connection object
URL requestUrl = new URL(url);
conn = (HttpURLConnection) requestUrl.openConnection();
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
conn.setRequestProperty("X-Requested-With", "XMLHttpRequest");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestMethod(method);
if(method.equals("POST") || method.equals("PUT")){
byte[] outputBytes = data.getBytes();
conn.setFixedLengthStreamingMode(outputBytes.length);
conn.connect();
OutputStream os = conn.getOutputStream();
os.write(outputBytes);
os.flush();
os.close();
}
else{
conn.connect();
}
// return response
return conn;
}
catch (Exception exp) {
if(conn!=null)
conn.disconnect();
exp.printStackTrace();
return null;
}
}
} | 2,667 | 0.610049 | 0.60405 | 82 | 31.536585 | 26.143225 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.670732 | false | false | 9 |
a1b3f7e5e5cd8c95bcd0f5cb299091138914ef51 | 30,691,836,366,441 | 7486d11cfc3044d80763ff8bf8a4e1e296b686f6 | /src/main/java/com/nssol/service/bagging/Impl/TOrderDetailServiceImpl.java | fd695e854888bd5b87bc8a48807528098ead59af | [] | no_license | yuanshuangqi/NSSOL_RFID | https://github.com/yuanshuangqi/NSSOL_RFID | e215ec092f0defe5e698770e16e79c9cfcaa05e0 | 50268b15947bd3206bd5a4a957aa003ae59f3d15 | refs/heads/master | 2022-07-03T16:08:20.881000 | 2020-03-02T05:25:33 | 2020-03-02T05:25:33 | 244,287,373 | 0 | 0 | null | false | 2022-06-29T17:59:38 | 2020-03-02T05:23:48 | 2020-03-02T05:27:45 | 2022-06-29T17:59:38 | 2,112 | 0 | 0 | 3 | Java | false | false | package com.nssol.service.bagging.Impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nssol.dao.master.TOrderDetailDao;
import com.nssol.model.TOrderDetail;
import com.nssol.service.bagging.TOrderDetailService;
@Service
@Transactional
public class TOrderDetailServiceImpl implements TOrderDetailService {
@Autowired
private TOrderDetailDao orderDetailDao;
@Override
public TOrderDetail getOrderDetailBySku(TOrderDetail tOrdDetail) {
TOrderDetail orderDetail = orderDetailDao.selectByskuCode(tOrdDetail);
return orderDetail;
}
public List<TOrderDetail> getOrderDetailListBysku(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectOrderDetailBysku(tOrdDetail);
return orderDetailList;
}
public List<TOrderDetail> getSkuListByOrderNo(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectSkuListByOrderNo(tOrdDetail);
return orderDetailList;
}
public TOrderDetail getOrderDetailListByPoSku(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectOrderDetailBysku(tOrdDetail);
if(orderDetailList!=null && orderDetailList.size()>0) {
return orderDetailList.get(0);
}
return null;
}
}
| UTF-8 | Java | 1,383 | java | TOrderDetailServiceImpl.java | Java | [] | null | [] | package com.nssol.service.bagging.Impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nssol.dao.master.TOrderDetailDao;
import com.nssol.model.TOrderDetail;
import com.nssol.service.bagging.TOrderDetailService;
@Service
@Transactional
public class TOrderDetailServiceImpl implements TOrderDetailService {
@Autowired
private TOrderDetailDao orderDetailDao;
@Override
public TOrderDetail getOrderDetailBySku(TOrderDetail tOrdDetail) {
TOrderDetail orderDetail = orderDetailDao.selectByskuCode(tOrdDetail);
return orderDetail;
}
public List<TOrderDetail> getOrderDetailListBysku(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectOrderDetailBysku(tOrdDetail);
return orderDetailList;
}
public List<TOrderDetail> getSkuListByOrderNo(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectSkuListByOrderNo(tOrdDetail);
return orderDetailList;
}
public TOrderDetail getOrderDetailListByPoSku(TOrderDetail tOrdDetail) {
List<TOrderDetail> orderDetailList = orderDetailDao.selectOrderDetailBysku(tOrdDetail);
if(orderDetailList!=null && orderDetailList.size()>0) {
return orderDetailList.get(0);
}
return null;
}
}
| 1,383 | 0.823572 | 0.822126 | 46 | 29.065218 | 30.346121 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.195652 | false | false | 9 |
4e4814dea42595268ebfc4b45509eb3fb7658ad6 | 29,162,827,997,449 | 01dbed862ed901dcdce9b7d6f11f1b72a7d1e443 | /core/src/main/java/org/emaginniss/agni/connections/AutoDiscoveryConnection.java | ec55e619a11a29b3da40cad771964a8b46dc7456 | [
"Apache-2.0"
] | permissive | emaginniss/agni | https://github.com/emaginniss/agni | 585035b06397fd17d5589e6013dc02d1a18d3a90 | 63999be4480267cab250345193832d9c08a2a9ee | refs/heads/master | 2020-04-02T04:42:55.726000 | 2019-05-17T13:19:51 | 2019-05-17T13:19:51 | 39,846,477 | 1 | 0 | Apache-2.0 | false | 2019-04-09T23:39:01 | 2015-07-28T16:53:16 | 2019-04-09T23:19:33 | 2019-04-09T23:39:00 | 176 | 0 | 0 | 3 | Java | false | false | /*
* Copyright (c) 2015, Eric A Maginniss
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ERIC A MAGINNISS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.emaginniss.agni.connections;
import lombok.extern.slf4j.Slf4j;
import org.emaginniss.agni.Configuration;
import org.emaginniss.agni.Envelope;
import org.emaginniss.agni.Factory;
import org.emaginniss.agni.Node;
import org.emaginniss.agni.annotations.Component;
import java.io.IOException;
import java.net.*;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@Component(value = "autoDiscovery", isDefault = true)
@Slf4j
public class AutoDiscoveryConnection implements Connection, ConnectionParent {
private Configuration configuration;
private ConnectionParent parent;
private InetAddress groupName;
private int multicastPort;
private Connection socketsServer;
private MulticastSocket multicastSocket;
private boolean shutdown = false;
private MulticastServerThead multicastServerThead;
private MulticastClientThead multicastClientThead;
private int listenPort;
private final Map<String, Connection> connectionsByNodeUuid = new ConcurrentHashMap<>();
private final Set<Connection> clients = new HashSet<>();
public AutoDiscoveryConnection(Configuration configuration, ConnectionParent parent) {
this.configuration = configuration;
this.parent = parent;
try {
groupName = InetAddress.getByName(configuration.getString("groupName", "225.7.193.61"));
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
multicastPort = configuration.getInt("multicastPort", 34001);
listenPort = configuration.getInt("listenPort", 35000);
while (listenPort < 65535) {
try {
ServerSocket ss = new ServerSocket(listenPort);
ss.close();
break;
} catch (Exception e) {
listenPort++;
}
}
Configuration serverConfig = configuration.getChild("server");
serverConfig.getObject().addProperty("port", listenPort);
if (serverConfig.getString("type", null) == null) {
serverConfig.getObject().addProperty("type", "defaultSocketsServer");
}
socketsServer = Factory.instantiate(Connection.class, serverConfig, this);
try {
boolean complete = false;
for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); niEnum.hasMoreElements() && !complete; ) {
NetworkInterface ni = niEnum.nextElement();
if (!ni.isLoopback()) {
for (Enumeration<InetAddress> ia = ni.getInetAddresses(); ia.hasMoreElements() && !complete; ) {
try {
multicastSocket = new MulticastSocket(multicastPort);
multicastSocket.setInterface(ia.nextElement());
multicastSocket.joinGroup(groupName);
complete = true;
} catch (Exception e) {
//Do nothing
}
}
}
}
if (!complete) {
throw new RuntimeException("Unable to bind to multicast socket on any network interface");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
multicastServerThead = new MulticastServerThead();
multicastServerThead.start();
multicastClientThead = new MulticastClientThead();
multicastClientThead.start();
}
@Override
public void shutdown() {
shutdown = true;
multicastClientThead.interrupt();
try {
multicastClientThead.join(5000);
} catch (Exception e) {
//do nothing
}
try {
multicastSocket.leaveGroup(groupName);
} catch (IOException e) {
//do nothing
}
multicastSocket.close();
try {
multicastServerThead.join(5000);
} catch (Exception e) {
//do nothing
}
socketsServer.shutdown();
for (Connection conn : new HashSet<>(this.clients)) {
conn.shutdown();
}
}
@Override
public boolean forwardMessage(Envelope envelope, String targetNodeUuid) {
Connection connection = connectionsByNodeUuid.get(targetNodeUuid);
if (connection == null) {
log.debug("Unable to forward message - connection missing");
return false;
}
return connection.forwardMessage(envelope, targetNodeUuid);
}
private class MulticastServerThead extends Thread {
public MulticastServerThead() {
super(parent.getNode().getThreadGroup(), parent.getDisplayName() + " - Multicast Server Thread");
}
@Override
public void run() {
while (!shutdown) {
try {
byte buf[] = new byte[1024];
DatagramPacket pack = new DatagramPacket(buf, buf.length);
multicastSocket.receive(pack);
String raw = new String(pack.getData(), 0, pack.getLength());
MulticastData data = (MulticastData) parent.getNode().getSerializer().deserialize(raw, MulticastData.class.getName());
if (!connectionsByNodeUuid.containsKey(data.getUuid()) && !parent.getUuid().equals(data.getUuid())) {
Configuration clientConfig = configuration.getChild("client");
clientConfig.getObject().addProperty("port", data.getPort());
clientConfig.getObject().addProperty("host", pack.getAddress().getHostAddress());
clientConfig.getObject().addProperty("exitOnFail", true);
if (clientConfig.getString("type", null) == null) {
clientConfig.getObject().addProperty("type", "defaultSocketsClient");
}
clients.add(Factory.instantiate(Connection.class, clientConfig, AutoDiscoveryConnection.this));
}
} catch (Exception e) {
if (!shutdown) {
log.error("Error", e);
}
}
}
}
}
private class MulticastClientThead extends Thread {
public MulticastClientThead() {
super(parent.getNode().getThreadGroup(), parent.getDisplayName() + " - Multicast Client Thread");
}
@Override
public void run() {
while (!shutdown) {
try {
MulticastSocket socket = new MulticastSocket();
byte []buffer = parent.getNode().getSerializer().serialize(new MulticastData(parent.getUuid(), listenPort)).getBytes();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, groupName, multicastPort);
socket.send(packet);
socket.close();
Thread.sleep(30 * 1000);
} catch (Exception e) {
if (!shutdown) {
log.error("Error", e);
}
}
}
}
}
@Override
public String getUuid() {
return parent.getUuid();
}
@Override
public String getDisplayName() {
return parent.getDisplayName();
}
@Override
public void enableConnection(Connection connection, String uuid, String displayName) {
connectionsByNodeUuid.put(uuid, connection);
parent.enableConnection(this, uuid, displayName);
}
@Override
public void disableConnection(Connection connection, String uuid, String displayName) {
parent.disableConnection(this, uuid, displayName);
connectionsByNodeUuid.remove(uuid);
if (connection != socketsServer) {
clients.remove(connection);
}
}
@Override
public void handleIncomingEnvelope(Envelope e) {
parent.handleIncomingEnvelope(e);
}
@Override
public Node getNode() {
return parent.getNode();
}
public static class MulticastData {
private String uuid;
private int port;
public MulticastData() {
}
public MulticastData(String uuid, int port) {
this.uuid = uuid;
this.port = port;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}
}
| UTF-8 | Java | 10,456 | java | AutoDiscoveryConnection.java | Java | [
{
"context": "/*\n * Copyright (c) 2015, Eric A Maginniss\n * All rights reserved.\n *\n * Redistribution and ",
"end": 42,
"score": 0.9998451471328735,
"start": 26,
"tag": "NAME",
"value": "Eric A Maginniss"
},
{
"context": "CULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL ERIC A... | null | [] | /*
* Copyright (c) 2015, <NAME>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <NAME> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.emaginniss.agni.connections;
import lombok.extern.slf4j.Slf4j;
import org.emaginniss.agni.Configuration;
import org.emaginniss.agni.Envelope;
import org.emaginniss.agni.Factory;
import org.emaginniss.agni.Node;
import org.emaginniss.agni.annotations.Component;
import java.io.IOException;
import java.net.*;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@Component(value = "autoDiscovery", isDefault = true)
@Slf4j
public class AutoDiscoveryConnection implements Connection, ConnectionParent {
private Configuration configuration;
private ConnectionParent parent;
private InetAddress groupName;
private int multicastPort;
private Connection socketsServer;
private MulticastSocket multicastSocket;
private boolean shutdown = false;
private MulticastServerThead multicastServerThead;
private MulticastClientThead multicastClientThead;
private int listenPort;
private final Map<String, Connection> connectionsByNodeUuid = new ConcurrentHashMap<>();
private final Set<Connection> clients = new HashSet<>();
public AutoDiscoveryConnection(Configuration configuration, ConnectionParent parent) {
this.configuration = configuration;
this.parent = parent;
try {
groupName = InetAddress.getByName(configuration.getString("groupName", "192.168.127.12"));
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
multicastPort = configuration.getInt("multicastPort", 34001);
listenPort = configuration.getInt("listenPort", 35000);
while (listenPort < 65535) {
try {
ServerSocket ss = new ServerSocket(listenPort);
ss.close();
break;
} catch (Exception e) {
listenPort++;
}
}
Configuration serverConfig = configuration.getChild("server");
serverConfig.getObject().addProperty("port", listenPort);
if (serverConfig.getString("type", null) == null) {
serverConfig.getObject().addProperty("type", "defaultSocketsServer");
}
socketsServer = Factory.instantiate(Connection.class, serverConfig, this);
try {
boolean complete = false;
for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); niEnum.hasMoreElements() && !complete; ) {
NetworkInterface ni = niEnum.nextElement();
if (!ni.isLoopback()) {
for (Enumeration<InetAddress> ia = ni.getInetAddresses(); ia.hasMoreElements() && !complete; ) {
try {
multicastSocket = new MulticastSocket(multicastPort);
multicastSocket.setInterface(ia.nextElement());
multicastSocket.joinGroup(groupName);
complete = true;
} catch (Exception e) {
//Do nothing
}
}
}
}
if (!complete) {
throw new RuntimeException("Unable to bind to multicast socket on any network interface");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
multicastServerThead = new MulticastServerThead();
multicastServerThead.start();
multicastClientThead = new MulticastClientThead();
multicastClientThead.start();
}
@Override
public void shutdown() {
shutdown = true;
multicastClientThead.interrupt();
try {
multicastClientThead.join(5000);
} catch (Exception e) {
//do nothing
}
try {
multicastSocket.leaveGroup(groupName);
} catch (IOException e) {
//do nothing
}
multicastSocket.close();
try {
multicastServerThead.join(5000);
} catch (Exception e) {
//do nothing
}
socketsServer.shutdown();
for (Connection conn : new HashSet<>(this.clients)) {
conn.shutdown();
}
}
@Override
public boolean forwardMessage(Envelope envelope, String targetNodeUuid) {
Connection connection = connectionsByNodeUuid.get(targetNodeUuid);
if (connection == null) {
log.debug("Unable to forward message - connection missing");
return false;
}
return connection.forwardMessage(envelope, targetNodeUuid);
}
private class MulticastServerThead extends Thread {
public MulticastServerThead() {
super(parent.getNode().getThreadGroup(), parent.getDisplayName() + " - Multicast Server Thread");
}
@Override
public void run() {
while (!shutdown) {
try {
byte buf[] = new byte[1024];
DatagramPacket pack = new DatagramPacket(buf, buf.length);
multicastSocket.receive(pack);
String raw = new String(pack.getData(), 0, pack.getLength());
MulticastData data = (MulticastData) parent.getNode().getSerializer().deserialize(raw, MulticastData.class.getName());
if (!connectionsByNodeUuid.containsKey(data.getUuid()) && !parent.getUuid().equals(data.getUuid())) {
Configuration clientConfig = configuration.getChild("client");
clientConfig.getObject().addProperty("port", data.getPort());
clientConfig.getObject().addProperty("host", pack.getAddress().getHostAddress());
clientConfig.getObject().addProperty("exitOnFail", true);
if (clientConfig.getString("type", null) == null) {
clientConfig.getObject().addProperty("type", "defaultSocketsClient");
}
clients.add(Factory.instantiate(Connection.class, clientConfig, AutoDiscoveryConnection.this));
}
} catch (Exception e) {
if (!shutdown) {
log.error("Error", e);
}
}
}
}
}
private class MulticastClientThead extends Thread {
public MulticastClientThead() {
super(parent.getNode().getThreadGroup(), parent.getDisplayName() + " - Multicast Client Thread");
}
@Override
public void run() {
while (!shutdown) {
try {
MulticastSocket socket = new MulticastSocket();
byte []buffer = parent.getNode().getSerializer().serialize(new MulticastData(parent.getUuid(), listenPort)).getBytes();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, groupName, multicastPort);
socket.send(packet);
socket.close();
Thread.sleep(30 * 1000);
} catch (Exception e) {
if (!shutdown) {
log.error("Error", e);
}
}
}
}
}
@Override
public String getUuid() {
return parent.getUuid();
}
@Override
public String getDisplayName() {
return parent.getDisplayName();
}
@Override
public void enableConnection(Connection connection, String uuid, String displayName) {
connectionsByNodeUuid.put(uuid, connection);
parent.enableConnection(this, uuid, displayName);
}
@Override
public void disableConnection(Connection connection, String uuid, String displayName) {
parent.disableConnection(this, uuid, displayName);
connectionsByNodeUuid.remove(uuid);
if (connection != socketsServer) {
clients.remove(connection);
}
}
@Override
public void handleIncomingEnvelope(Envelope e) {
parent.handleIncomingEnvelope(e);
}
@Override
public Node getNode() {
return parent.getNode();
}
public static class MulticastData {
private String uuid;
private int port;
public MulticastData() {
}
public MulticastData(String uuid, int port) {
this.uuid = uuid;
this.port = port;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
}
}
| 10,438 | 0.603003 | 0.598221 | 289 | 35.179932 | 30.790432 | 139 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.595156 | false | false | 9 |
4cc71f202c86ba4b25df904500a05812b0dbc179 | 20,401,094,714,416 | 7d927e981213c137e8dec45859c7605da508d47b | /core/src/main/java/com/hand/spc/repository/service/ISampleDataRService.java | bdb4cb4bf46bad93c09155a02e3647f309f59dc9 | [] | no_license | bellmit/HQmsParent | https://github.com/bellmit/HQmsParent | e140069f2800ed80346e0637624ad9d3a93036a1 | 26d5eb9fd4d32b7f9cbcf1e82f50fb61973b7c17 | refs/heads/master | 2022-04-20T06:17:05.916000 | 2020-04-17T04:18:59 | 2020-04-17T04:18:59 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hand.spc.repository.service;
import java.util.List;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import com.hand.spc.repository.dto.SampleDataR;
import com.hand.spc.repository.dto.SampleDataWaitR;
public interface ISampleDataRService extends IBaseService<SampleDataR>, ProxySelf<ISampleDataRService> {
/**
* 根据预处理样本数据ID集合新增样本数据
*
* @param sampleDataWait
* @return
*/
public int insertSampleData(SampleDataWaitR sampleDataWait);
List<SampleDataWaitR> selectIds(List<Long> ids);
int batchInsertSampleData(List<SampleDataR> sampleDataWaitList);
}
| UTF-8 | Java | 682 | java | ISampleDataRService.java | Java | [] | null | [] | package com.hand.spc.repository.service;
import java.util.List;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.service.IBaseService;
import com.hand.spc.repository.dto.SampleDataR;
import com.hand.spc.repository.dto.SampleDataWaitR;
public interface ISampleDataRService extends IBaseService<SampleDataR>, ProxySelf<ISampleDataRService> {
/**
* 根据预处理样本数据ID集合新增样本数据
*
* @param sampleDataWait
* @return
*/
public int insertSampleData(SampleDataWaitR sampleDataWait);
List<SampleDataWaitR> selectIds(List<Long> ids);
int batchInsertSampleData(List<SampleDataR> sampleDataWaitList);
}
| 682 | 0.759259 | 0.759259 | 24 | 26 | 27.572632 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.416667 | false | false | 9 |
32e86e9d7e836a5e3e9b8e0a058f0fb33c9a0613 | 13,365,938,238,815 | b95dd48f08117bd951db91b7025fbcf9987b6ce9 | /src/main/java/com/example/confeo/controller/EventController.java | bf42cd65c072b40fae41124e975d1b6bc57dc5f4 | [] | no_license | moniaS/confeo | https://github.com/moniaS/confeo | 0b3f66616c09dfc80cf35ee44bce8b682e9b229d | 9d1805b07251c84509422249e43c481783935061 | refs/heads/master | 2020-03-07T21:25:34.190000 | 2019-01-07T19:41:28 | 2019-01-07T19:41:28 | 127,726,061 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.confeo.controller;
import com.example.confeo.exception.CannotSignUpOnCanceledEvent;
import com.example.confeo.exception.ParticipantsLimitReached;
import com.example.confeo.exception.XSSConstraintException;
import com.example.confeo.form.EventSearchForm;
import com.example.confeo.model.City;
import com.example.confeo.model.Event;
import com.example.confeo.model.EventType;
import com.example.confeo.model.Role;
import com.example.confeo.model.User;
import com.example.confeo.pdf.PdfGenerator;
import com.example.confeo.service.CategoryService;
import com.example.confeo.service.CityService;
import com.example.confeo.service.EventService;
import com.example.confeo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by mstobieniecka on 2018-05-29.
*/
@Controller
public class EventController extends BasicController {
private EventService eventService;
private final CategoryService categoryService;
private final UserService userService;
private final CityService cityService;
@Autowired
public EventController(EventService eventService, CategoryService categoryService, UserService userService, CityService cityService) {
this.eventService = eventService;
this.categoryService = categoryService;
this.userService = userService;
this.cityService = cityService;
}
@RequestMapping("/events")
private String events(Model model) {
model.addAttribute("eventsByMonth", eventService.findEventsByMonth("%", "%", "%", LocalDate.MIN, LocalDate.MAX));
addSearchValuesToModel(model);
model.addAttribute("eventSearchForm", new EventSearchForm());
return "events";
}
@RequestMapping("/my/events")
private String myEvents(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findByUsername(authentication.getName());
if(user.getRole().equals(Role.ROLE_PARTICIPANT)) {
model.addAttribute("events", user.getAttendingEvents().stream().sorted(Comparator.comparing(Event::getStartDate)).collect(Collectors.toList()));
} else if(user.getRole().equals(Role.ROLE_ORGANIZER)) {
model.addAttribute("events", user.getOrganizedEvents().stream().sorted(Comparator.comparing(Event::getStartDate)).collect(Collectors.toList()));
}
return "my-events";
}
@RequestMapping("/events/add")
public String addEvent(Model model) {
if (!model.containsAttribute("event")){
model.addAttribute("event", new Event());
}
model.addAttribute("eventTypes", EventType.values());
model.addAttribute("categories", categoryService.findAll());
/*for (String city: cityService.findAllCities()){
System.out.println(city);
}*/
model.addAttribute("cities", cityService.findAllCities());
return "add-event";
}
@PostMapping("/events/add/save")
public String saveEvent(@ModelAttribute @Valid Event event, BindingResult bindingResult,
RedirectAttributes redirectAttributes){
if (!isFormValidated(event, redirectAttributes)){
return "redirect:/events/add";
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName();
event.setOrganiser(userService.findByUsername(currentPrincipalName));
try {
eventService.saveEvent(event);
} catch (XSSConstraintException e) {
e.printStackTrace();
redirectAttributes.addFlashAttribute("errorMessage", "Formularz zawiera niedozwolone znaki");
return "redirect:/events/add";
}
return "redirect:/events/" + event.getId();
}
@RequestMapping("/events/{id}/edit")
public String editEvent(Model model, @PathVariable("id") long eventId) {
//jesli nie ma takiego wydarzenia -> przejdz do listy wydarzen
if (eventService.findById(eventId) == null){
return "redirect:/events";
}
if (!model.containsAttribute("event")){
model.addAttribute("event", eventService.findById(eventId));
}
model.addAttribute("eventTypes", EventType.values());
model.addAttribute("categories", categoryService.findAll());
return "edit-event";
}
@PostMapping("/events/edit/{id}/save")
public String saveEventEdit(@ModelAttribute @Valid Event event, @PathVariable("id") long eventId, BindingResult bindingResult,
RedirectAttributes redirectAttributes) {
if (!isFormValidated(event, redirectAttributes)){
return "redirect:/events/" + event.getId() + "/edit";
}
event.setId(eventId);
eventService.updateEvent(event);
return "redirect:/events/" + event.getId();
}
@PostMapping("/events/search")
private String searchEvents(EventSearchForm eventSearchForm, BindingResult bindingResult, Model model) {
model.addAttribute("eventsByMonth", eventService.findEventsByMonth('%' + eventSearchForm.getName() + '%',
'%' + eventSearchForm.getCity() + '%', '%' + eventSearchForm.getCategory() + '%', eventSearchForm.getStartDate(), eventSearchForm.getEndDate()));
addSearchValuesToModel(model);
return "events";
}
@GetMapping("/events/{id}")
private String getEvent(@PathVariable("id") String id, Model model) {
if (eventService.findById(Long.valueOf(id)) == null){
return "redirect:/events";
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentUserName = authentication.getName();
model.addAttribute("isSignedUpForEventAsParticipant", eventService.isUserSignedUpOnEventAsParticipant(currentUserName, Long.valueOf(id)));
model.addAttribute("isSignedUpForEventAsPrelegent", eventService.isUserSignedUpOnEventAsPrelegent(currentUserName, Long.valueOf(id)));
model.addAttribute("event", eventService.findById(Long.valueOf(id)));
return "event";
}
@GetMapping("/events/{id}/cancel")
private String cancelEvent(@PathVariable("id") String id, Model model) {
if (eventService.findById(Long.valueOf(id)) == null){
return "redirect:/events";
}
eventService.cancelEvent(Long.valueOf(id));
model.addAttribute("event", eventService.findById(Long.valueOf(id)));
return "event";
}
@GetMapping("/events/{id}/signUp")
private String signUpOnEvent(@PathVariable("id") String id, Model model, RedirectAttributes redirectAttributes) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
eventService.signUpOnEventAsParticipant(authentication.getName(), Long.valueOf(id));
model.addAttribute("event", eventService.findEvent(Long.valueOf(id)));
redirectAttributes.addFlashAttribute("successMessage", "Zostałeś zapisany na wydarzenie");
} catch (ParticipantsLimitReached participantsLimitReached) {
participantsLimitReached.printStackTrace();
redirectAttributes.addFlashAttribute("failureMessage", "Limit miejsc na wydarzenie został już osiągnięty");
} catch (CannotSignUpOnCanceledEvent cannotSignUpOnCanceledEvent) {
cannotSignUpOnCanceledEvent.printStackTrace();
redirectAttributes.addFlashAttribute("failureMessage", "Nie można zapisać się na anulowaną lub zakończoną konferencję");
}
return "redirect:/events/" + id;
}
@GetMapping("/events/{id}/signOff")
private String signOffFromEvent(@PathVariable("id") String id, Model model, RedirectAttributes redirectAttributes) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
eventService.signOffFromEventAsParticipant(authentication.getName(), Long.valueOf(id));
model.addAttribute("event", eventService.findEvent(Long.valueOf(id)));
redirectAttributes.addFlashAttribute("successMessage", "Zostałeś wypisany z wydarzenia");
return "redirect:/events/" + id;
}
@RequestMapping(value = "/events/{id}/pdf", method = RequestMethod.GET,
produces = MediaType.APPLICATION_PDF_VALUE)
public void generatePdf(@PathVariable("id") long id, HttpServletResponse response) throws IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findByUsername(authentication.getName());
Event event = eventService.findEvent(id);
response.setContentType("application/pdf");
ByteArrayInputStream bis = PdfGenerator.generateInvoice(event, user, "2018/06/" + eventService.getInvoiceNumber().toString());
eventService.setInvoiceNumber(eventService.getInvoiceNumber() + 1);
org.apache.commons.io.IOUtils.copy(bis, response.getOutputStream());
response.flushBuffer();
}
private void addSearchValuesToModel(Model model) {
model.addAttribute("cities", eventService.findCities());
model.addAttribute("categories", eventService.findCategories());
}
private boolean isFormValidated(Event event, RedirectAttributes redirectAttributes){
LocalDate testDate = LocalDate.now();
boolean error = false;
try {
if (event.getStartDate() == null || event.getEndDate() == null){
//redirectAttributes.addFlashAttribute("message", "Proszę podać datę rozpoczęcia i zakończenia");
//redirectAttributes.addFlashAttribute("event", event);
error = true;
} else if (!event.getStartDate().isAfter(testDate)){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać przyszłe daty");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if(event.getEndDate().compareTo(event.getStartDate()) < 0) {
/*redirectAttributes.addFlashAttribute("message", "Proszę podać datę rozpoczęcia starszą niż data zakończenia");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if (event.getName() == null || event.getName() == ""){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać nazwę wydarzenia");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if (event.getDescription().length() > 254){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać opis wydarzenia do 250 znaków");
redirectAttributes.addFlashAttribute("event", event);*/
error = true;
} else if (event.getAddress().getCityName() == null || event.getAddress().getCityName() == ""){
error = true;
} else if (event.getAddress().getStreetName() == null || event.getAddress().getStreetName() == ""){
error = true;
} else if (event.getAddress().getStreetNumber() == null || event.getAddress().getStreetNumber() == ""){
error = true;
} else if (event.getMaxParticipants() < 1){
error = true;
}
Duration duration = Duration.between(testDate.atStartOfDay(), event.getStartDate().atStartOfDay());
long diff = Math.abs(duration.toDays());
if (diff > 180) {
/*redirectAttributes.addFlashAttribute("message", "Proszę podać datę wydarzenia maksymalnie do pół roku wprzód");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
}
} catch (NullPointerException e) {
error = true;
}
if (error) {
redirectAttributes.addFlashAttribute("message", "Formularz zawiera błędy");
redirectAttributes.addFlashAttribute("event", event);
return false;
}
return true;
}
@RequestMapping(value = "/cities/search")
public @ResponseBody List<String> searchCities(@RequestParam("cityName") String cityName) {
List<String> cities = cityService.filterCities(cityName);
return cities;
}
@RequestMapping(value = "/cities/check-if-exists")
public @ResponseBody boolean checkIfCityExists(@RequestParam("cityName") String cityName) {
boolean cityExists = cityService.checkIfCityExists(cityName);
return cityExists;
}
}
| UTF-8 | Java | 13,112 | java | EventController.java | Java | [
{
"context": "t java.util.stream.Collectors;\n\n\n/**\n * Created by mstobieniecka on 2018-05-29.\n */\n@Controller\npublic class Event",
"end": 1524,
"score": 0.9995880722999573,
"start": 1511,
"tag": "USERNAME",
"value": "mstobieniecka"
}
] | null | [] | package com.example.confeo.controller;
import com.example.confeo.exception.CannotSignUpOnCanceledEvent;
import com.example.confeo.exception.ParticipantsLimitReached;
import com.example.confeo.exception.XSSConstraintException;
import com.example.confeo.form.EventSearchForm;
import com.example.confeo.model.City;
import com.example.confeo.model.Event;
import com.example.confeo.model.EventType;
import com.example.confeo.model.Role;
import com.example.confeo.model.User;
import com.example.confeo.pdf.PdfGenerator;
import com.example.confeo.service.CategoryService;
import com.example.confeo.service.CityService;
import com.example.confeo.service.EventService;
import com.example.confeo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by mstobieniecka on 2018-05-29.
*/
@Controller
public class EventController extends BasicController {
private EventService eventService;
private final CategoryService categoryService;
private final UserService userService;
private final CityService cityService;
@Autowired
public EventController(EventService eventService, CategoryService categoryService, UserService userService, CityService cityService) {
this.eventService = eventService;
this.categoryService = categoryService;
this.userService = userService;
this.cityService = cityService;
}
@RequestMapping("/events")
private String events(Model model) {
model.addAttribute("eventsByMonth", eventService.findEventsByMonth("%", "%", "%", LocalDate.MIN, LocalDate.MAX));
addSearchValuesToModel(model);
model.addAttribute("eventSearchForm", new EventSearchForm());
return "events";
}
@RequestMapping("/my/events")
private String myEvents(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findByUsername(authentication.getName());
if(user.getRole().equals(Role.ROLE_PARTICIPANT)) {
model.addAttribute("events", user.getAttendingEvents().stream().sorted(Comparator.comparing(Event::getStartDate)).collect(Collectors.toList()));
} else if(user.getRole().equals(Role.ROLE_ORGANIZER)) {
model.addAttribute("events", user.getOrganizedEvents().stream().sorted(Comparator.comparing(Event::getStartDate)).collect(Collectors.toList()));
}
return "my-events";
}
@RequestMapping("/events/add")
public String addEvent(Model model) {
if (!model.containsAttribute("event")){
model.addAttribute("event", new Event());
}
model.addAttribute("eventTypes", EventType.values());
model.addAttribute("categories", categoryService.findAll());
/*for (String city: cityService.findAllCities()){
System.out.println(city);
}*/
model.addAttribute("cities", cityService.findAllCities());
return "add-event";
}
@PostMapping("/events/add/save")
public String saveEvent(@ModelAttribute @Valid Event event, BindingResult bindingResult,
RedirectAttributes redirectAttributes){
if (!isFormValidated(event, redirectAttributes)){
return "redirect:/events/add";
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentPrincipalName = authentication.getName();
event.setOrganiser(userService.findByUsername(currentPrincipalName));
try {
eventService.saveEvent(event);
} catch (XSSConstraintException e) {
e.printStackTrace();
redirectAttributes.addFlashAttribute("errorMessage", "Formularz zawiera niedozwolone znaki");
return "redirect:/events/add";
}
return "redirect:/events/" + event.getId();
}
@RequestMapping("/events/{id}/edit")
public String editEvent(Model model, @PathVariable("id") long eventId) {
//jesli nie ma takiego wydarzenia -> przejdz do listy wydarzen
if (eventService.findById(eventId) == null){
return "redirect:/events";
}
if (!model.containsAttribute("event")){
model.addAttribute("event", eventService.findById(eventId));
}
model.addAttribute("eventTypes", EventType.values());
model.addAttribute("categories", categoryService.findAll());
return "edit-event";
}
@PostMapping("/events/edit/{id}/save")
public String saveEventEdit(@ModelAttribute @Valid Event event, @PathVariable("id") long eventId, BindingResult bindingResult,
RedirectAttributes redirectAttributes) {
if (!isFormValidated(event, redirectAttributes)){
return "redirect:/events/" + event.getId() + "/edit";
}
event.setId(eventId);
eventService.updateEvent(event);
return "redirect:/events/" + event.getId();
}
@PostMapping("/events/search")
private String searchEvents(EventSearchForm eventSearchForm, BindingResult bindingResult, Model model) {
model.addAttribute("eventsByMonth", eventService.findEventsByMonth('%' + eventSearchForm.getName() + '%',
'%' + eventSearchForm.getCity() + '%', '%' + eventSearchForm.getCategory() + '%', eventSearchForm.getStartDate(), eventSearchForm.getEndDate()));
addSearchValuesToModel(model);
return "events";
}
@GetMapping("/events/{id}")
private String getEvent(@PathVariable("id") String id, Model model) {
if (eventService.findById(Long.valueOf(id)) == null){
return "redirect:/events";
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String currentUserName = authentication.getName();
model.addAttribute("isSignedUpForEventAsParticipant", eventService.isUserSignedUpOnEventAsParticipant(currentUserName, Long.valueOf(id)));
model.addAttribute("isSignedUpForEventAsPrelegent", eventService.isUserSignedUpOnEventAsPrelegent(currentUserName, Long.valueOf(id)));
model.addAttribute("event", eventService.findById(Long.valueOf(id)));
return "event";
}
@GetMapping("/events/{id}/cancel")
private String cancelEvent(@PathVariable("id") String id, Model model) {
if (eventService.findById(Long.valueOf(id)) == null){
return "redirect:/events";
}
eventService.cancelEvent(Long.valueOf(id));
model.addAttribute("event", eventService.findById(Long.valueOf(id)));
return "event";
}
@GetMapping("/events/{id}/signUp")
private String signUpOnEvent(@PathVariable("id") String id, Model model, RedirectAttributes redirectAttributes) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
try {
eventService.signUpOnEventAsParticipant(authentication.getName(), Long.valueOf(id));
model.addAttribute("event", eventService.findEvent(Long.valueOf(id)));
redirectAttributes.addFlashAttribute("successMessage", "Zostałeś zapisany na wydarzenie");
} catch (ParticipantsLimitReached participantsLimitReached) {
participantsLimitReached.printStackTrace();
redirectAttributes.addFlashAttribute("failureMessage", "Limit miejsc na wydarzenie został już osiągnięty");
} catch (CannotSignUpOnCanceledEvent cannotSignUpOnCanceledEvent) {
cannotSignUpOnCanceledEvent.printStackTrace();
redirectAttributes.addFlashAttribute("failureMessage", "Nie można zapisać się na anulowaną lub zakończoną konferencję");
}
return "redirect:/events/" + id;
}
@GetMapping("/events/{id}/signOff")
private String signOffFromEvent(@PathVariable("id") String id, Model model, RedirectAttributes redirectAttributes) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
eventService.signOffFromEventAsParticipant(authentication.getName(), Long.valueOf(id));
model.addAttribute("event", eventService.findEvent(Long.valueOf(id)));
redirectAttributes.addFlashAttribute("successMessage", "Zostałeś wypisany z wydarzenia");
return "redirect:/events/" + id;
}
@RequestMapping(value = "/events/{id}/pdf", method = RequestMethod.GET,
produces = MediaType.APPLICATION_PDF_VALUE)
public void generatePdf(@PathVariable("id") long id, HttpServletResponse response) throws IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
User user = userService.findByUsername(authentication.getName());
Event event = eventService.findEvent(id);
response.setContentType("application/pdf");
ByteArrayInputStream bis = PdfGenerator.generateInvoice(event, user, "2018/06/" + eventService.getInvoiceNumber().toString());
eventService.setInvoiceNumber(eventService.getInvoiceNumber() + 1);
org.apache.commons.io.IOUtils.copy(bis, response.getOutputStream());
response.flushBuffer();
}
private void addSearchValuesToModel(Model model) {
model.addAttribute("cities", eventService.findCities());
model.addAttribute("categories", eventService.findCategories());
}
private boolean isFormValidated(Event event, RedirectAttributes redirectAttributes){
LocalDate testDate = LocalDate.now();
boolean error = false;
try {
if (event.getStartDate() == null || event.getEndDate() == null){
//redirectAttributes.addFlashAttribute("message", "Proszę podać datę rozpoczęcia i zakończenia");
//redirectAttributes.addFlashAttribute("event", event);
error = true;
} else if (!event.getStartDate().isAfter(testDate)){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać przyszłe daty");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if(event.getEndDate().compareTo(event.getStartDate()) < 0) {
/*redirectAttributes.addFlashAttribute("message", "Proszę podać datę rozpoczęcia starszą niż data zakończenia");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if (event.getName() == null || event.getName() == ""){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać nazwę wydarzenia");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
} else if (event.getDescription().length() > 254){
/*redirectAttributes.addFlashAttribute("message", "Proszę podać opis wydarzenia do 250 znaków");
redirectAttributes.addFlashAttribute("event", event);*/
error = true;
} else if (event.getAddress().getCityName() == null || event.getAddress().getCityName() == ""){
error = true;
} else if (event.getAddress().getStreetName() == null || event.getAddress().getStreetName() == ""){
error = true;
} else if (event.getAddress().getStreetNumber() == null || event.getAddress().getStreetNumber() == ""){
error = true;
} else if (event.getMaxParticipants() < 1){
error = true;
}
Duration duration = Duration.between(testDate.atStartOfDay(), event.getStartDate().atStartOfDay());
long diff = Math.abs(duration.toDays());
if (diff > 180) {
/*redirectAttributes.addFlashAttribute("message", "Proszę podać datę wydarzenia maksymalnie do pół roku wprzód");
redirectAttributes.addFlashAttribute("event", event);
return false;*/
error = true;
}
} catch (NullPointerException e) {
error = true;
}
if (error) {
redirectAttributes.addFlashAttribute("message", "Formularz zawiera błędy");
redirectAttributes.addFlashAttribute("event", event);
return false;
}
return true;
}
@RequestMapping(value = "/cities/search")
public @ResponseBody List<String> searchCities(@RequestParam("cityName") String cityName) {
List<String> cities = cityService.filterCities(cityName);
return cities;
}
@RequestMapping(value = "/cities/check-if-exists")
public @ResponseBody boolean checkIfCityExists(@RequestParam("cityName") String cityName) {
boolean cityExists = cityService.checkIfCityExists(cityName);
return cityExists;
}
}
| 13,112 | 0.70753 | 0.70554 | 281 | 45.505337 | 35.799473 | 160 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.508897 | false | false | 9 |
687d988ea365f34dfbcb5514d528fc86e5e1deaf | 27,762,668,659,715 | 279bffecb84102ab7a91726607a5e4c1d18e961f | /orderform/orderform-web/src/main/java/com/qcloud/component/orderform/web/vo/admin/AdminOrderItemVO.java | 346cc302f334e06ef99a5899500429f5d9f0865d | [] | no_license | ChiRains/forest | https://github.com/ChiRains/forest | 8b71de51c477f66a134d9b515b58039a8c94c2ee | cf0b41ff83e4cee281078afe338bba792de05052 | refs/heads/master | 2021-01-19T07:13:19.597000 | 2016-08-18T01:35:54 | 2016-08-18T01:35:54 | 65,869,894 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.qcloud.component.orderform.web.vo.admin;
import com.qcloud.component.goods.model.UnifiedMerchandise;
import com.qcloud.component.sellercenter.QMerchant;
public class AdminOrderItemVO {
// ID
private long id;
// 总单ID
private long orderId;
// 子单ID
private long subOrderId;
// 商家ID
private long merchantId;
// 统一商品ID
private long unifiedMerchandiseId;
// 单价
private double price;
// 数量
private int number;
// 小计金额
private double sum;
// 成交价
private double discount;
// 状态,待付款,已付款,待发货,已发货,已签收
private int state;
private UnifiedMerchandise item;
// 商家
private QMerchant merchant;
public AdminOrderItemVO() {
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setOrderId(long orderId) {
this.orderId = orderId;
}
public long getOrderId() {
return orderId;
}
public void setSubOrderId(long subOrderId) {
this.subOrderId = subOrderId;
}
public long getSubOrderId() {
return subOrderId;
}
public void setMerchantId(long merchantId) {
this.merchantId = merchantId;
}
public long getMerchantId() {
return merchantId;
}
public void setUnifiedMerchandiseId(long unifiedMerchandiseId) {
this.unifiedMerchandiseId = unifiedMerchandiseId;
}
public long getUnifiedMerchandiseId() {
return unifiedMerchandiseId;
}
public void setPrice(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
public void setNumber(int number) {
this.number = number;
}
public int getNumber() {
return number;
}
public void setSum(double sum) {
this.sum = sum;
}
public double getSum() {
return sum;
}
public void setState(int state) {
this.state = state;
}
public int getState() {
return state;
}
public UnifiedMerchandise getItem() {
return item;
}
public void setItem(UnifiedMerchandise item) {
this.item = item;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public QMerchant getMerchant() {
return merchant;
}
public void setMerchant(QMerchant merchant) {
this.merchant = merchant;
}
}
| UTF-8 | Java | 2,949 | java | AdminOrderItemVO.java | Java | [] | null | [] | package com.qcloud.component.orderform.web.vo.admin;
import com.qcloud.component.goods.model.UnifiedMerchandise;
import com.qcloud.component.sellercenter.QMerchant;
public class AdminOrderItemVO {
// ID
private long id;
// 总单ID
private long orderId;
// 子单ID
private long subOrderId;
// 商家ID
private long merchantId;
// 统一商品ID
private long unifiedMerchandiseId;
// 单价
private double price;
// 数量
private int number;
// 小计金额
private double sum;
// 成交价
private double discount;
// 状态,待付款,已付款,待发货,已发货,已签收
private int state;
private UnifiedMerchandise item;
// 商家
private QMerchant merchant;
public AdminOrderItemVO() {
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setOrderId(long orderId) {
this.orderId = orderId;
}
public long getOrderId() {
return orderId;
}
public void setSubOrderId(long subOrderId) {
this.subOrderId = subOrderId;
}
public long getSubOrderId() {
return subOrderId;
}
public void setMerchantId(long merchantId) {
this.merchantId = merchantId;
}
public long getMerchantId() {
return merchantId;
}
public void setUnifiedMerchandiseId(long unifiedMerchandiseId) {
this.unifiedMerchandiseId = unifiedMerchandiseId;
}
public long getUnifiedMerchandiseId() {
return unifiedMerchandiseId;
}
public void setPrice(double price) {
this.price = price;
}
public double getPrice() {
return price;
}
public void setNumber(int number) {
this.number = number;
}
public int getNumber() {
return number;
}
public void setSum(double sum) {
this.sum = sum;
}
public double getSum() {
return sum;
}
public void setState(int state) {
this.state = state;
}
public int getState() {
return state;
}
public UnifiedMerchandise getItem() {
return item;
}
public void setItem(UnifiedMerchandise item) {
this.item = item;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public QMerchant getMerchant() {
return merchant;
}
public void setMerchant(QMerchant merchant) {
this.merchant = merchant;
}
}
| 2,949 | 0.535727 | 0.535727 | 166 | 15.283133 | 17.495213 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.26506 | false | false | 9 |
1f8672bd5c8b6dc63d7a0dedb20e27dc81a2e10e | 11,158,325,050,952 | 232e71e0fbb962edb9c2ed027bb1be9b780ba3ea | /checkbox/src/com/company/Myframe.java | de8336542376f5f6313ae8d1eda9b0fff355153d | [] | no_license | CharanSaminepally/JAVA_FILES | https://github.com/CharanSaminepally/JAVA_FILES | 74fb25aa8a00bc08e7439b2d5cc3f84ca60e3b94 | 865b3b9e658f78b917d9eb1965994b9164539694 | refs/heads/main | 2023-08-14T03:20:03.872000 | 2021-10-10T08:55:57 | 2021-10-10T08:55:57 | 415,533,411 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Myframe extends JFrame implements ActionListener {
JButton button = new JButton();
JCheckBox checkbox = new JCheckBox();
ImageIcon xicon = new ImageIcon("C:\\Users\\DELL\\Desktop\\wrong.PNG");
ImageIcon selectedicon = new ImageIcon("C:\\Users\\DELL\\Desktop\\right.PNG");
Myframe(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button.setText("submit");
button.setSize(10,15);
button.addActionListener(this);
checkbox.setText("I'M NOT A ROBOT");
checkbox.setFocusable(false);
checkbox.setFont(new Font("chiller",Font.BOLD,35));
checkbox.setIcon(xicon);
checkbox.setSelectedIcon(selectedicon);
this.add(checkbox);
this.add(button);
this.pack();
this.setVisible(true);
this.setTitle("checkbox function");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
System.out.println(checkbox.isSelected());
}
}
}
| UTF-8 | Java | 1,206 | java | Myframe.java | Java | [] | null | [] | package com.company;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Myframe extends JFrame implements ActionListener {
JButton button = new JButton();
JCheckBox checkbox = new JCheckBox();
ImageIcon xicon = new ImageIcon("C:\\Users\\DELL\\Desktop\\wrong.PNG");
ImageIcon selectedicon = new ImageIcon("C:\\Users\\DELL\\Desktop\\right.PNG");
Myframe(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
button.setText("submit");
button.setSize(10,15);
button.addActionListener(this);
checkbox.setText("I'M NOT A ROBOT");
checkbox.setFocusable(false);
checkbox.setFont(new Font("chiller",Font.BOLD,35));
checkbox.setIcon(xicon);
checkbox.setSelectedIcon(selectedicon);
this.add(checkbox);
this.add(button);
this.pack();
this.setVisible(true);
this.setTitle("checkbox function");
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==button){
System.out.println(checkbox.isSelected());
}
}
}
| 1,206 | 0.646766 | 0.641791 | 44 | 26.40909 | 22.436089 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 9 |
301405c12bd84d75bd01ae42449d554e3b0fa013 | 20,409,684,644,374 | d65837c6a8ca8968b5eef0078d62eed893357e1c | /app/src/main/java/com/udacity/sandwichclub/utils/JsonUtils.java | 9bce3a0e5deb8d4bd2cd152e3579d23b950e82e6 | [] | no_license | ArisGoico/sandwich-club-submission | https://github.com/ArisGoico/sandwich-club-submission | 08baa29d2ed048992e96cda29f7303cdac630c78 | 6d0f27e164b0281de10a1dfa7f7c1d20463c2537 | refs/heads/master | 2023-01-06T09:56:59.772000 | 2020-10-31T18:56:04 | 2020-10-31T18:56:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.udacity.sandwichclub.utils;
import android.util.Log;
import com.udacity.sandwichclub.model.Sandwich;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class JsonUtils {
private static final String TAG = "JsonUtils";
public static Sandwich parseSandwichJson(String json) {
JSONObject fullJSON = null;
String mainName;
List<String> alsoKnownAs = new ArrayList<String>();
String placeOfOrigin;
String description;
String image;
List<String> ingredients = new ArrayList<String>();
try {
fullJSON = new JSONObject(json);
//Parse JSON
JSONObject name = fullJSON.getJSONObject("name");
mainName = name.getString("mainName");
JSONArray otherNames = name.getJSONArray("alsoKnownAs");
for (int i = 0; i < otherNames.length(); i++) {
alsoKnownAs.add(otherNames.getString(i));
}
placeOfOrigin = fullJSON.getString("placeOfOrigin");
description = fullJSON.getString("description");
image = fullJSON.getString("image");
JSONArray ingredientsArray = fullJSON.getJSONArray("ingredients");
for (int i = 0; i < ingredientsArray.length(); i++) {
ingredients.add(ingredientsArray.getString(i));
}
}
catch (JSONException e) {
Log.w(TAG, "Error while parsing the JSON.");
e.printStackTrace();
return null;
}
catch (Exception e) {
Log.w(TAG, "Unknown error while parsing the JSON.");
e.printStackTrace();
return null;
}
Sandwich result = new Sandwich(mainName, alsoKnownAs, placeOfOrigin, description, image, ingredients);
return result;
}
}
| UTF-8 | Java | 1,928 | java | JsonUtils.java | Java | [] | null | [] | package com.udacity.sandwichclub.utils;
import android.util.Log;
import com.udacity.sandwichclub.model.Sandwich;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class JsonUtils {
private static final String TAG = "JsonUtils";
public static Sandwich parseSandwichJson(String json) {
JSONObject fullJSON = null;
String mainName;
List<String> alsoKnownAs = new ArrayList<String>();
String placeOfOrigin;
String description;
String image;
List<String> ingredients = new ArrayList<String>();
try {
fullJSON = new JSONObject(json);
//Parse JSON
JSONObject name = fullJSON.getJSONObject("name");
mainName = name.getString("mainName");
JSONArray otherNames = name.getJSONArray("alsoKnownAs");
for (int i = 0; i < otherNames.length(); i++) {
alsoKnownAs.add(otherNames.getString(i));
}
placeOfOrigin = fullJSON.getString("placeOfOrigin");
description = fullJSON.getString("description");
image = fullJSON.getString("image");
JSONArray ingredientsArray = fullJSON.getJSONArray("ingredients");
for (int i = 0; i < ingredientsArray.length(); i++) {
ingredients.add(ingredientsArray.getString(i));
}
}
catch (JSONException e) {
Log.w(TAG, "Error while parsing the JSON.");
e.printStackTrace();
return null;
}
catch (Exception e) {
Log.w(TAG, "Unknown error while parsing the JSON.");
e.printStackTrace();
return null;
}
Sandwich result = new Sandwich(mainName, alsoKnownAs, placeOfOrigin, description, image, ingredients);
return result;
}
}
| 1,928 | 0.606846 | 0.605809 | 60 | 31.133333 | 24.861259 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 9 |
54238ef4f6297227a83242b8fcde431f25caa06c | 28,363,964,048,704 | 96b751b71bb7c98eea0535fb31730cfbbd5f374e | /E-KentSayim/src/com/kayiyazilim/ekentsayim/service/KioskService.java | 38a91488af43feb4b52af63ee5f4871d939aa74f | [] | no_license | thens352/AngularDemo2 | https://github.com/thens352/AngularDemo2 | a791d0d0de068d3818008d284c34fc81442d4976 | ef5b1c376e9aaa96ab3fc8f677eea8f28bd1d117 | refs/heads/master | 2021-01-10T02:29:03.382000 | 2015-10-26T11:34:07 | 2015-10-26T11:34:07 | 44,961,587 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kayiyazilim.ekentsayim.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.primefaces.event.RowEditEvent;
import com.kayiyazilim.ekentsayim.dao.BolgeDao;
import com.kayiyazilim.ekentsayim.dao.KioskDao;
import com.kayiyazilim.ekentsayim.dao.KullaniciDao;
import com.kayiyazilim.ekentsayim.dao.ParametreDao;
import com.kayiyazilim.ekentsayim.model.entity.Bolge;
import com.kayiyazilim.ekentsayim.model.entity.Kiosk;
import com.kayiyazilim.ekentsayim.model.entity.Kullanici;
import com.kayiyazilim.ekentsayim.model.entity.Parametre;
import com.kayiyazilim.ekentsayim.model.search.KioskSearch;
import com.kayiyazilim.ekentsayim.model.type.Alan;
import com.kayiyazilim.ekentsayim.model.type.Durum;
import com.kayiyazilim.ekentsayim.model.type.Ekran;
@ManagedBean(name = "kioskService")
@ViewScoped
public class KioskService implements Serializable {
private static final long serialVersionUID = 8057426637668356833L;
@EJB
private KullaniciDao kullaniciDao;
@EJB
private BolgeDao bolgeDao;
@EJB
private KioskDao kioskDao;
private List<Kullanici> kullaniciList;
private List<Bolge> bolgeList;
private List<Kiosk> kioskList;
private Kiosk kiosk = new Kiosk();
public Durum[] getDurumTipleri() {
return Durum.values();
}
public boolean getDurumStatu() {
return kiosk.getDurum() == Durum.SAHADA;
}
@EJB
private ParametreDao parametreDao;
private List<SelectItem> markaList = new ArrayList<SelectItem>();
private List<SelectItem> modelList = new ArrayList<SelectItem>();
private KioskSearch kioskSearch = new KioskSearch();
@PostConstruct
public void init() {
kiosk.setDurum(Durum.SAHADA);
kioskList = kioskDao.findAll();
kullaniciList = kullaniciDao.findAll();
bolgeList = bolgeDao.findAll();
for (Parametre parametre : parametreDao.getParametreListesi(Ekran.e3,
Alan.MARKA)) {
markaList.add(new SelectItem(parametre.getDeger(), parametre
.getDeger()));
}
for (Parametre parametre : parametreDao.getParametreListesi(Ekran.e3,
Alan.MODEL)) {
modelList.add(new SelectItem(parametre.getDeger(), parametre
.getDeger()));
}
}
public void ara() {
kioskList = kioskDao.search(kioskSearch);
}
public void ekle() {
Kiosk aranan = null;
try {
aranan = kioskDao.find(kiosk.getBarkod());
} catch (Exception e) {
e.printStackTrace();
}
if (aranan != null) {
FacesMessage mesaj1 = new FacesMessage(FacesMessage.SEVERITY_WARN,
"Girilen barkoda ait kayıt zaten var.", "");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
} else {
kiosk.setGununTarihi(new Date());
kioskDao.persist(kiosk);
if (kioskList == null)
kioskList = new ArrayList<Kiosk>();
kioskList.add(kiosk);
FacesMessage mesaj1 = new FacesMessage(
"Kaydetme İşlemi Tamamlandı", "");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
}
public void guncelle(RowEditEvent event) {
kiosk = ((Kiosk) event.getObject());
kioskDao.merge(kiosk);
FacesMessage mesaj1 = new FacesMessage("Güncelleme İşlemi Tamamlandı",
"");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
public void sil() {
if (kiosk != null)
kioskDao.remove(kiosk);
kioskList.remove(kiosk);
FacesMessage mesaj1 = new FacesMessage("Silme işlemi Tamamlandı");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
public List<SelectItem> getMarkaList() {
return markaList;
}
public void setMarkaList(List<SelectItem> markaList) {
this.markaList = markaList;
}
public List<SelectItem> getModelList() {
return modelList;
}
public void setModelList(List<SelectItem> modelList) {
this.modelList = modelList;
}
public KioskSearch getKioskSearch() {
return kioskSearch;
}
public void setKioskSearch(KioskSearch kioskSearch) {
this.kioskSearch = kioskSearch;
}
public List<Kullanici> getKullaniciList() {
return kullaniciList;
}
public void setKullaniciList(List<Kullanici> kullaniciList) {
this.kullaniciList = kullaniciList;
}
public List<Bolge> getBolgeList() {
return bolgeList;
}
public void setBolgeList(List<Bolge> bolgeList) {
this.bolgeList = bolgeList;
}
public List<Kiosk> getKioskList() {
return kioskList;
}
public void setKioskList(List<Kiosk> kioskList) {
this.kioskList = kioskList;
}
public Kiosk getKiosk() {
return kiosk;
}
public void setKiosk(Kiosk kiosk) {
this.kiosk = kiosk;
}
}
| UTF-8 | Java | 4,804 | java | KioskService.java | Java | [] | null | [] | package com.kayiyazilim.ekentsayim.service;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.primefaces.event.RowEditEvent;
import com.kayiyazilim.ekentsayim.dao.BolgeDao;
import com.kayiyazilim.ekentsayim.dao.KioskDao;
import com.kayiyazilim.ekentsayim.dao.KullaniciDao;
import com.kayiyazilim.ekentsayim.dao.ParametreDao;
import com.kayiyazilim.ekentsayim.model.entity.Bolge;
import com.kayiyazilim.ekentsayim.model.entity.Kiosk;
import com.kayiyazilim.ekentsayim.model.entity.Kullanici;
import com.kayiyazilim.ekentsayim.model.entity.Parametre;
import com.kayiyazilim.ekentsayim.model.search.KioskSearch;
import com.kayiyazilim.ekentsayim.model.type.Alan;
import com.kayiyazilim.ekentsayim.model.type.Durum;
import com.kayiyazilim.ekentsayim.model.type.Ekran;
@ManagedBean(name = "kioskService")
@ViewScoped
public class KioskService implements Serializable {
private static final long serialVersionUID = 8057426637668356833L;
@EJB
private KullaniciDao kullaniciDao;
@EJB
private BolgeDao bolgeDao;
@EJB
private KioskDao kioskDao;
private List<Kullanici> kullaniciList;
private List<Bolge> bolgeList;
private List<Kiosk> kioskList;
private Kiosk kiosk = new Kiosk();
public Durum[] getDurumTipleri() {
return Durum.values();
}
public boolean getDurumStatu() {
return kiosk.getDurum() == Durum.SAHADA;
}
@EJB
private ParametreDao parametreDao;
private List<SelectItem> markaList = new ArrayList<SelectItem>();
private List<SelectItem> modelList = new ArrayList<SelectItem>();
private KioskSearch kioskSearch = new KioskSearch();
@PostConstruct
public void init() {
kiosk.setDurum(Durum.SAHADA);
kioskList = kioskDao.findAll();
kullaniciList = kullaniciDao.findAll();
bolgeList = bolgeDao.findAll();
for (Parametre parametre : parametreDao.getParametreListesi(Ekran.e3,
Alan.MARKA)) {
markaList.add(new SelectItem(parametre.getDeger(), parametre
.getDeger()));
}
for (Parametre parametre : parametreDao.getParametreListesi(Ekran.e3,
Alan.MODEL)) {
modelList.add(new SelectItem(parametre.getDeger(), parametre
.getDeger()));
}
}
public void ara() {
kioskList = kioskDao.search(kioskSearch);
}
public void ekle() {
Kiosk aranan = null;
try {
aranan = kioskDao.find(kiosk.getBarkod());
} catch (Exception e) {
e.printStackTrace();
}
if (aranan != null) {
FacesMessage mesaj1 = new FacesMessage(FacesMessage.SEVERITY_WARN,
"Girilen barkoda ait kayıt zaten var.", "");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
} else {
kiosk.setGununTarihi(new Date());
kioskDao.persist(kiosk);
if (kioskList == null)
kioskList = new ArrayList<Kiosk>();
kioskList.add(kiosk);
FacesMessage mesaj1 = new FacesMessage(
"Kaydetme İşlemi Tamamlandı", "");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
}
public void guncelle(RowEditEvent event) {
kiosk = ((Kiosk) event.getObject());
kioskDao.merge(kiosk);
FacesMessage mesaj1 = new FacesMessage("Güncelleme İşlemi Tamamlandı",
"");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
public void sil() {
if (kiosk != null)
kioskDao.remove(kiosk);
kioskList.remove(kiosk);
FacesMessage mesaj1 = new FacesMessage("Silme işlemi Tamamlandı");
FacesContext.getCurrentInstance().addMessage("", mesaj1);
kiosk = new Kiosk();
}
public List<SelectItem> getMarkaList() {
return markaList;
}
public void setMarkaList(List<SelectItem> markaList) {
this.markaList = markaList;
}
public List<SelectItem> getModelList() {
return modelList;
}
public void setModelList(List<SelectItem> modelList) {
this.modelList = modelList;
}
public KioskSearch getKioskSearch() {
return kioskSearch;
}
public void setKioskSearch(KioskSearch kioskSearch) {
this.kioskSearch = kioskSearch;
}
public List<Kullanici> getKullaniciList() {
return kullaniciList;
}
public void setKullaniciList(List<Kullanici> kullaniciList) {
this.kullaniciList = kullaniciList;
}
public List<Bolge> getBolgeList() {
return bolgeList;
}
public void setBolgeList(List<Bolge> bolgeList) {
this.bolgeList = bolgeList;
}
public List<Kiosk> getKioskList() {
return kioskList;
}
public void setKioskList(List<Kiosk> kioskList) {
this.kioskList = kioskList;
}
public Kiosk getKiosk() {
return kiosk;
}
public void setKiosk(Kiosk kiosk) {
this.kiosk = kiosk;
}
}
| 4,804 | 0.743846 | 0.737797 | 195 | 23.584616 | 21.457335 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.615385 | false | false | 9 |
f23cc68c4cbb99058c5ddf8cdc899c346c4eebbe | 4,252,017,688,436 | de89430098feb0d7f625075f9baa1a6374079c09 | /src/sk/tuke/oop/game/items/Hammer.java | 2a197529f3a5c11dccdcdca99149e4f89e39d3dc | [] | no_license | peto77/Alien-Breed | https://github.com/peto77/Alien-Breed | 52c9c8e6823b13fb01e85470033b4f18fd7fec5c | b9655d0bf49e3e073c42812a4932a8e8b2bc4706 | refs/heads/master | 2018-10-01T01:38:29.760000 | 2018-06-08T09:10:19 | 2018-06-08T09:10:19 | 136,538,835 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* 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 sk.tuke.oop.game.items;
import sk.tuke.oop.framework.Animation;
import sk.tuke.oop.framework.Item;
import sk.tuke.oop.game.actors.AbstractActor;
/**
*
* @author Peter
*/
public class Hammer extends AbstractActor implements Item {
public Hammer(){
super("hammer");
Animation animation;
int x;
int y;
animation = new Animation("resources/sprites/hammer.png", 16,16,100);
animation.setLooping(true);
animation.setPingPong(true);
setAnimation(animation);
x = 390;
y = 80;
setPosition(x,y);
}
@Override
public void act() {
}
}
| UTF-8 | Java | 876 | java | Hammer.java | Java | [
{
"context": ".oop.game.actors.AbstractActor;\n\n/**\n *\n * @author Peter\n */\npublic class Hammer extends AbstractActor imp",
"end": 364,
"score": 0.9986265897750854,
"start": 359,
"tag": "NAME",
"value": "Peter"
}
] | null | [] | /*
* 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 sk.tuke.oop.game.items;
import sk.tuke.oop.framework.Animation;
import sk.tuke.oop.framework.Item;
import sk.tuke.oop.game.actors.AbstractActor;
/**
*
* @author Peter
*/
public class Hammer extends AbstractActor implements Item {
public Hammer(){
super("hammer");
Animation animation;
int x;
int y;
animation = new Animation("resources/sprites/hammer.png", 16,16,100);
animation.setLooping(true);
animation.setPingPong(true);
setAnimation(animation);
x = 390;
y = 80;
setPosition(x,y);
}
@Override
public void act() {
}
}
| 876 | 0.609589 | 0.59589 | 42 | 19.857143 | 20.460848 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52381 | false | false | 9 |
0e00458df6abefba961f978e1f4add5704be5a0c | 32,134,945,375,070 | 3690f7491946e1e99b3c9e15017a263c2720378e | /app/src/main/java/serviscepde/com/tr/Fragment/AddFragment.java | 7a9b215b8ce15191a7e735a98ab395377863741a | [] | no_license | alimoguz/ServisCepde | https://github.com/alimoguz/ServisCepde | 774a35f84b2bb70337c43c1f6d431d5a5715fc5d | 4000fc11630619fd7148e62e4cd5079b5bcd821e | refs/heads/master | 2021-04-08T11:12:22.538000 | 2020-03-22T20:54:25 | 2020-03-22T20:54:25 | 248,769,962 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package serviscepde.com.tr.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.esafirm.imagepicker.features.ImagePicker;
import com.esafirm.imagepicker.features.ReturnMode;
import com.esafirm.imagepicker.model.Image;
import cn.pedant.SweetAlert.SweetAlertDialog;
import serviscepde.com.tr.AddingActivity;
import serviscepde.com.tr.MainActivity;
import serviscepde.com.tr.R;
import serviscepde.com.tr.SplashActivity;
import java.util.ArrayList;
import java.util.List;
public class AddFragment extends Fragment {
View generalView;
private int selectedCategory = 0;
ArrayList<String> imagesPath = new ArrayList<>();
Context ctx;
Intent addingActivity;
LinearLayout linDialogIsimeArac,linDialogAracimaIs,linDialogAracimaSofor,linDialogSoforeIs,linDialogSatilikArac,linDialogKiralikArac,linDialogYedekParca,linDialogSatilikPlaka;
private Bundle bundle = new Bundle();
private String userToken;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.add_fragment, container, false);
MainActivity.bottomNav.setVisibility(View.VISIBLE);
generalView = rootView;
ctx = generalView.getContext();
linDialogIsimeArac = generalView.findViewById(R.id.linDialogIsimeArac);
linDialogAracimaIs = generalView.findViewById(R.id.linDialogAracimaIs);
linDialogAracimaSofor = generalView.findViewById(R.id.linDialogAracimaSofor);
linDialogSoforeIs = generalView.findViewById(R.id.linDialogSoforeIs);
linDialogSatilikArac = generalView.findViewById(R.id.linDialogSatilikArac);
linDialogKiralikArac = generalView.findViewById(R.id.linDialogKiralikArac);
linDialogYedekParca = generalView.findViewById(R.id.linDialogYedekParca);
linDialogSatilikPlaka = generalView.findViewById(R.id.linDialogSatilikPlaka);
SharedPreferences sharedPref = ctx.getSharedPreferences("prefs" , Context.MODE_PRIVATE);
userToken = sharedPref.getString("userToken" , "0");
Log.i("userToken" ,userToken);
if(userToken.equals("0"))
{
SweetAlertDialog girisAlert = new SweetAlertDialog(ctx , SweetAlertDialog.WARNING_TYPE);
girisAlert.setTitleText("Devam edebilmek için lütfen önce giriş yapın");
girisAlert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Intent intent = new Intent(ctx , SplashActivity.class);
startActivity(intent);
}
});
girisAlert.show();
}
else
{
addingActivity = new Intent(ctx , AddingActivity.class);
linDialogIsimeArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 1;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogAracimaIs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 2;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogAracimaSofor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 3;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSoforeIs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 4;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSatilikArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 5;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogKiralikArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 6;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogYedekParca.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 7;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSatilikPlaka.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 8;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
return rootView;
}
return rootView;
}
private void choosePhoto()
{
bundle.putStringArrayList("imageList" , imagesPath);
addingActivity.putExtras(bundle);
startActivity(addingActivity);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
// Get a list of picked images
List<Image> images = ImagePicker.getImages(data);
for(int i = 0; i < images.size(); i++)
{
String tmp = images.get(i).getPath();
imagesPath.add(tmp);
}
// or get a single image only
Image image = ImagePicker.getFirstImageOrNull(data);
Log.i("Resim/ler" , images.get(0).getPath() );
Log.i("Resim/ler" , image.getPath());
bundle.putStringArrayList("imageList" , imagesPath);
addingActivity.putExtras(bundle);
startActivity(addingActivity);
}
super.onActivityResult(requestCode, resultCode, data);
}
} | UTF-8 | Java | 7,152 | java | AddFragment.java | Java | [] | null | [] | package serviscepde.com.tr.Fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.esafirm.imagepicker.features.ImagePicker;
import com.esafirm.imagepicker.features.ReturnMode;
import com.esafirm.imagepicker.model.Image;
import cn.pedant.SweetAlert.SweetAlertDialog;
import serviscepde.com.tr.AddingActivity;
import serviscepde.com.tr.MainActivity;
import serviscepde.com.tr.R;
import serviscepde.com.tr.SplashActivity;
import java.util.ArrayList;
import java.util.List;
public class AddFragment extends Fragment {
View generalView;
private int selectedCategory = 0;
ArrayList<String> imagesPath = new ArrayList<>();
Context ctx;
Intent addingActivity;
LinearLayout linDialogIsimeArac,linDialogAracimaIs,linDialogAracimaSofor,linDialogSoforeIs,linDialogSatilikArac,linDialogKiralikArac,linDialogYedekParca,linDialogSatilikPlaka;
private Bundle bundle = new Bundle();
private String userToken;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.add_fragment, container, false);
MainActivity.bottomNav.setVisibility(View.VISIBLE);
generalView = rootView;
ctx = generalView.getContext();
linDialogIsimeArac = generalView.findViewById(R.id.linDialogIsimeArac);
linDialogAracimaIs = generalView.findViewById(R.id.linDialogAracimaIs);
linDialogAracimaSofor = generalView.findViewById(R.id.linDialogAracimaSofor);
linDialogSoforeIs = generalView.findViewById(R.id.linDialogSoforeIs);
linDialogSatilikArac = generalView.findViewById(R.id.linDialogSatilikArac);
linDialogKiralikArac = generalView.findViewById(R.id.linDialogKiralikArac);
linDialogYedekParca = generalView.findViewById(R.id.linDialogYedekParca);
linDialogSatilikPlaka = generalView.findViewById(R.id.linDialogSatilikPlaka);
SharedPreferences sharedPref = ctx.getSharedPreferences("prefs" , Context.MODE_PRIVATE);
userToken = sharedPref.getString("userToken" , "0");
Log.i("userToken" ,userToken);
if(userToken.equals("0"))
{
SweetAlertDialog girisAlert = new SweetAlertDialog(ctx , SweetAlertDialog.WARNING_TYPE);
girisAlert.setTitleText("Devam edebilmek için lütfen önce giriş yapın");
girisAlert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Intent intent = new Intent(ctx , SplashActivity.class);
startActivity(intent);
}
});
girisAlert.show();
}
else
{
addingActivity = new Intent(ctx , AddingActivity.class);
linDialogIsimeArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 1;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogAracimaIs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 2;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogAracimaSofor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 3;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSoforeIs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 4;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSatilikArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 5;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogKiralikArac.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 6;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogYedekParca.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 7;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
linDialogSatilikPlaka.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedCategory = 8;
bundle.putInt("selectedCategory" , selectedCategory);
choosePhoto();
}
});
return rootView;
}
return rootView;
}
private void choosePhoto()
{
bundle.putStringArrayList("imageList" , imagesPath);
addingActivity.putExtras(bundle);
startActivity(addingActivity);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (ImagePicker.shouldHandle(requestCode, resultCode, data)) {
// Get a list of picked images
List<Image> images = ImagePicker.getImages(data);
for(int i = 0; i < images.size(); i++)
{
String tmp = images.get(i).getPath();
imagesPath.add(tmp);
}
// or get a single image only
Image image = ImagePicker.getFirstImageOrNull(data);
Log.i("Resim/ler" , images.get(0).getPath() );
Log.i("Resim/ler" , image.getPath());
bundle.putStringArrayList("imageList" , imagesPath);
addingActivity.putExtras(bundle);
startActivity(addingActivity);
}
super.onActivityResult(requestCode, resultCode, data);
}
} | 7,152 | 0.611166 | 0.609347 | 203 | 34.211823 | 29.496922 | 179 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.679803 | false | false | 9 |
d8487a9dc596459db8a1949296d9ae69fe1b29aa | 22,497,038,703,475 | a5eb275d9f7ea089a43db55a211f170318118d5a | /AgregarDoctores.java | 039fe5f0ada4345f15f15465552341a430f7e3dd | [] | no_license | taniac19/-Citas-Medicas | https://github.com/taniac19/-Citas-Medicas | 62f78c9d6e13bc16ebaf0bf9d76472a14b6d95ee | cbcd10409f4aeade7f19eee2f0a1ae3ca9de16c0 | refs/heads/master | 2020-04-01T12:05:00.396000 | 2018-10-15T22:59:32 | 2018-10-15T22:59:32 | 153,190,464 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* 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 javaapplication4;
/**
*
* @author Mirna
*/
public class AgregarDoctores extends javax.swing.JFrame {
/**
* Creates new form AgregarDoctores
*/
public AgregarDoctores() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel8 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jTextField_codigo = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField_nombre = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTextField_especialidad = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel7_anuncios = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jTextField_hora = new javax.swing.JTextField();
jTextField_min = new javax.swing.JTextField();
jTextField_seg = new javax.swing.JTextField();
jTextField_hora2 = new javax.swing.JTextField();
jTextField_min2 = new javax.swing.JTextField();
jTextField_seg2 = new javax.swing.JTextField();
jLabel8.setText("jLabel8");
jTextField3.setText("jTextField3");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Codigo Sequencial:");
jLabel2.setText("Nombre Completo:");
jLabel4.setText(" AGREGAR DOCTORES");
jLabel5.setText("Hora de entrada:");
jLabel6.setText("Especialidad:");
jButton1.setText("Agregar Doctor");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton2.setText("Regresar");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jLabel3.setText("Hora de Salida:");
jLabel7.setText("Hora:");
jLabel9.setText("Min:");
jLabel10.setText("Seg:");
jLabel11.setText("Hora:");
jLabel12.setText("Min:");
jLabel13.setText("Seg:");
jTextField_seg.setText("00");
jTextField_seg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField_segActionPerformed(evt);
}
});
jTextField_seg2.setText("00");
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(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7_anuncios, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
.addComponent(jButton1)))
.addGap(68, 68, 68))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jTextField_hora, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)
.addComponent(jTextField_hora2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(jLabel10))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField_min, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField_seg, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel13))
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(jTextField_min2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField_seg2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(33, 33, 33))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(69, 69, 69))
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(133, 133, 133)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_especialidad, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(jTextField_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField_hora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_min, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_seg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel11)
.addComponent(jLabel13)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField_hora2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_min2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_seg2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)
.addComponent(jTextField_especialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7_anuncios)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(39, 39, 39))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// Agregar
DoctoresDatos doc= new DoctoresDatos();
int cod= Integer.parseInt(jTextField_codigo.getText());
int hora1= Integer.parseInt(jTextField_hora.getText());
int hora2= Integer.parseInt(jTextField_hora2.getText());
int min1= Integer.parseInt(jTextField_min.getText());
int min2= Integer.parseInt(jTextField_min2.getText());
int seg1= Integer.parseInt(jTextField_seg.getText());
int seg2= Integer.parseInt(jTextField_seg2.getText());
doc.doctores.add(new DoctoresDatos(cod, jTextField_nombre.getText(),jTextField_especialidad.getText(),true,hora1,hora2,min1,min2,seg1,seg2));
jLabel7_anuncios.setText("¡Agregado correctamente!");
}//GEN-LAST:event_jButton1MouseClicked
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
// Regresar
Manteniminetos menu= new Manteniminetos();
menu.setVisible(true);
dispose();
}//GEN-LAST:event_jButton2MouseClicked
private void jTextField_segActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_segActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField_segActionPerformed
/**
* @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(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.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 AgregarDoctores().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel7_anuncios;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField_codigo;
private javax.swing.JTextField jTextField_especialidad;
private javax.swing.JTextField jTextField_hora;
private javax.swing.JTextField jTextField_hora2;
private javax.swing.JTextField jTextField_min;
private javax.swing.JTextField jTextField_min2;
private javax.swing.JTextField jTextField_nombre;
private javax.swing.JTextField jTextField_seg;
private javax.swing.JTextField jTextField_seg2;
// End of variables declaration//GEN-END:variables
}
| UTF-8 | Java | 19,096 | java | AgregarDoctores.java | Java | [
{
"context": ".\n */\npackage javaapplication4;\n\n/**\n *\n * @author Mirna\n */\npublic class AgregarDoctores extends javax.sw",
"end": 235,
"score": 0.9992075562477112,
"start": 230,
"tag": "NAME",
"value": "Mirna"
},
{
"context": "ombre Completo:\");\n\n jLabel4.setText(\"... | null | [] | /*
* 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 javaapplication4;
/**
*
* @author Mirna
*/
public class AgregarDoctores extends javax.swing.JFrame {
/**
* Creates new form AgregarDoctores
*/
public AgregarDoctores() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel8 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jTextField_codigo = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField_nombre = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTextField_especialidad = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel7_anuncios = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jTextField_hora = new javax.swing.JTextField();
jTextField_min = new javax.swing.JTextField();
jTextField_seg = new javax.swing.JTextField();
jTextField_hora2 = new javax.swing.JTextField();
jTextField_min2 = new javax.swing.JTextField();
jTextField_seg2 = new javax.swing.JTextField();
jLabel8.setText("jLabel8");
jTextField3.setText("jTextField3");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Codigo Sequencial:");
jLabel2.setText("Nombre Completo:");
jLabel4.setText(" <NAME>");
jLabel5.setText("Hora de entrada:");
jLabel6.setText("Especialidad:");
jButton1.setText("Agregar Doctor");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton2.setText("Regresar");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jLabel3.setText("Hora de Salida:");
jLabel7.setText("Hora:");
jLabel9.setText("Min:");
jLabel10.setText("Seg:");
jLabel11.setText("Hora:");
jLabel12.setText("Min:");
jLabel13.setText("Seg:");
jTextField_seg.setText("00");
jTextField_seg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField_segActionPerformed(evt);
}
});
jTextField_seg2.setText("00");
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(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7_anuncios, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
.addComponent(jButton1)))
.addGap(68, 68, 68))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jTextField_hora, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel11)
.addComponent(jTextField_hora2, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(jLabel10))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField_min, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField_seg, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel13))
.addGroup(layout.createSequentialGroup()
.addGap(5, 5, 5)
.addComponent(jTextField_min2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField_seg2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(33, 33, 33))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(69, 69, 69))
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(133, 133, 133)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_especialidad, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(jTextField_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField_hora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_min, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_seg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel11)
.addComponent(jLabel13)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField_hora2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_min2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField_seg2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)
.addComponent(jTextField_especialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7_anuncios)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addGap(39, 39, 39))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// Agregar
DoctoresDatos doc= new DoctoresDatos();
int cod= Integer.parseInt(jTextField_codigo.getText());
int hora1= Integer.parseInt(jTextField_hora.getText());
int hora2= Integer.parseInt(jTextField_hora2.getText());
int min1= Integer.parseInt(jTextField_min.getText());
int min2= Integer.parseInt(jTextField_min2.getText());
int seg1= Integer.parseInt(jTextField_seg.getText());
int seg2= Integer.parseInt(jTextField_seg2.getText());
doc.doctores.add(new DoctoresDatos(cod, jTextField_nombre.getText(),jTextField_especialidad.getText(),true,hora1,hora2,min1,min2,seg1,seg2));
jLabel7_anuncios.setText("¡Agregado correctamente!");
}//GEN-LAST:event_jButton1MouseClicked
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
// Regresar
Manteniminetos menu= new Manteniminetos();
menu.setVisible(true);
dispose();
}//GEN-LAST:event_jButton2MouseClicked
private void jTextField_segActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_segActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextField_segActionPerformed
/**
* @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(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AgregarDoctores.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 AgregarDoctores().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel7_anuncios;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField_codigo;
private javax.swing.JTextField jTextField_especialidad;
private javax.swing.JTextField jTextField_hora;
private javax.swing.JTextField jTextField_hora2;
private javax.swing.JTextField jTextField_min;
private javax.swing.JTextField jTextField_min2;
private javax.swing.JTextField jTextField_nombre;
private javax.swing.JTextField jTextField_seg;
private javax.swing.JTextField jTextField_seg2;
// End of variables declaration//GEN-END:variables
}
| 19,086 | 0.638596 | 0.623776 | 321 | 58.485981 | 44.290043 | 181 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.82243 | false | false | 9 |
55233e269615f5e3c9c72cb4f2cfe28aa804370d | 30,614,526,891,092 | 7c05b59608c8da39052ef1562080a69c48b0c17e | /src/main/java/org/subhashis/mycroservices/mycurrencyexchangeservice/repository/MyExchangeValueRepository.java | b5a71664bff132606a3279b87b73a08bf631676a | [] | no_license | subha81788/my-currency-exchange-service | https://github.com/subha81788/my-currency-exchange-service | 2400a2835b839db4e66d13643f37600f792766e7 | 246b8ebacd29f258d14fbc339b8a4eaa29cfbfa2 | refs/heads/master | 2021-07-10T14:43:56.520000 | 2020-09-15T10:49:43 | 2020-09-15T10:49:43 | 195,337,060 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.subhashis.mycroservices.mycurrencyexchangeservice.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.subhashis.mycroservices.mycurrencyexchangeservice.model.ExchangeValue;
import java.util.Optional;
@Repository
public interface MyExchangeValueRepository extends JpaRepository<ExchangeValue,Long> {
Optional<ExchangeValue> findByFromAndTo(String from, String to);
}
| UTF-8 | Java | 465 | java | MyExchangeValueRepository.java | Java | [] | null | [] | package org.subhashis.mycroservices.mycurrencyexchangeservice.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.subhashis.mycroservices.mycurrencyexchangeservice.model.ExchangeValue;
import java.util.Optional;
@Repository
public interface MyExchangeValueRepository extends JpaRepository<ExchangeValue,Long> {
Optional<ExchangeValue> findByFromAndTo(String from, String to);
}
| 465 | 0.864516 | 0.864516 | 12 | 37.75 | 33.329479 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 9 |
6de4899ff46387b1e4d279fc0ea865173fa56f9e | 21,526,376,150,495 | dceef8bed33dbd3ad7b6504242de81fc398dc335 | /bdapportal/src/main/java/com/kt/bdapportal/repository/BdapRoleRepository.java | 8b7e5b341e22ec7f24ddd411822da234cc664e69 | [] | no_license | seoyoungrag/bdap | https://github.com/seoyoungrag/bdap | 3377f25864b4db1948fd26c0704e4bcd8df0a16d | d4ed18d3b998cbd1dcb299295fe5dc706645ddbb | refs/heads/master | 2021-01-12T16:14:25.504000 | 2016-11-04T00:37:11 | 2016-11-04T00:37:11 | 71,954,222 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kt.bdapportal.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.kt.bdapportal.domain.BdapRole;
@Repository("bdapRoleRepository")
public interface BdapRoleRepository extends JpaRepository<BdapRole, String>{
public BdapRole findByRoleId(String roleId);
}
| UTF-8 | Java | 370 | java | BdapRoleRepository.java | Java | [] | null | [] | package com.kt.bdapportal.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.kt.bdapportal.domain.BdapRole;
@Repository("bdapRoleRepository")
public interface BdapRoleRepository extends JpaRepository<BdapRole, String>{
public BdapRole findByRoleId(String roleId);
}
| 370 | 0.805405 | 0.805405 | 13 | 26.461538 | 26.255009 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.615385 | false | false | 9 |
ad78de29df719ed4ad9ac136cc77130c48f72b58 | 24,507,083,403,899 | 54a0d58d592745ac48b138d817baab833baae7e3 | /IPTVPersistence/src/pl/edu/agh/iptv/persistence/Entity.java | b9db9734a7c5c5c999aba46f5e49c1f4e818a4e5 | [] | no_license | biddyweb/ims-iptv | https://github.com/biddyweb/ims-iptv | c8cc68700193f558cbad03b3b033575a69417d14 | c41c2962658ea20207954f6543038c32f8b692a8 | refs/heads/master | 2020-04-05T23:39:30.137000 | 2010-03-17T13:00:15 | 2010-03-17T13:00:15 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.edu.agh.iptv.persistence;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
@MappedSuperclass
public class Entity{
Long id;
int version;
public Entity()
{
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
@Version
@Column(name="version")
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public void setId(Long id){
this.id = id;
}
public int hashCode() {
return getId().intValue();
}
public boolean equals(Object obj) {
if (obj instanceof Entity) {
return getId().equals(((Entity)obj).getId());
}
return super.equals(obj);
}
} | UTF-8 | Java | 841 | java | Entity.java | Java | [] | null | [] | package pl.edu.agh.iptv.persistence;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
@MappedSuperclass
public class Entity{
Long id;
int version;
public Entity()
{
}
@Id
@GeneratedValue
public Long getId() {
return id;
}
@Version
@Column(name="version")
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public void setId(Long id){
this.id = id;
}
public int hashCode() {
return getId().intValue();
}
public boolean equals(Object obj) {
if (obj instanceof Entity) {
return getId().equals(((Entity)obj).getId());
}
return super.equals(obj);
}
} | 841 | 0.65874 | 0.65874 | 50 | 14.86 | 14.108168 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.26 | false | false | 9 |
9222bfc39d499d96f661c211c9713b8ed151efbe | 9,964,324,181,525 | 7615301fc89c2632d30d2c80f0620250c4869441 | /src/main/java/com/example/ureportdemo/controller/ReportManagerController.java | 3861b6085417a8b6ff36beb5e71083dde6cf29ae | [] | no_license | lastFeng/ureport-demo | https://github.com/lastFeng/ureport-demo | 1b133eaa5f2ce10dbce085b78a9e3e508556554d | 541ed65fc966fa65c606eed5b58cb882c10c17df | refs/heads/main | 2023-01-07T02:30:24.548000 | 2020-11-02T08:10:36 | 2020-11-02T08:10:36 | 306,554,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2001-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.ureportdemo.controller;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.MiniTableRenderData;
import com.deepoove.poi.data.NumbericRenderData;
import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.data.TextRenderData;
import com.example.ureportdemo.entity.MyDataModel;
import com.example.ureportdemo.service.ReportBuildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p> Title: </p>
*
* <p> Description: </p>
*
* @author: Guo Weifeng
* @version: 1.0
* @create: 2020/10/27 9:45
*/
@RestController
public class ReportManagerController {
@Autowired
private ReportBuildService reportBuildService;
@GetMapping("/getUreport")
public String getReport() {
String docxName = String.valueOf(System.currentTimeMillis());
reportBuildService.buildWordDocx(docxName, null);
return "success!";
}
@GetMapping("/getPoi")
public String getPoi() throws Exception {
RowRenderData header = new RowRenderData(
Arrays.asList(new TextRenderData("FFFFFF", "Word处理解决方案"),
new TextRenderData("FFFFFFF", "是否跨平台"),
new TextRenderData("FFFFFFF", "易用性")),
"ff980");
RowRenderData row0 = RowRenderData.build("Poi-tl", "纯Java组件,跨平台", "简单:模板引擎功能,并对POI进行了一些封装");
RowRenderData row1 = RowRenderData.build("Apache Poi", "纯Java组件,跨平台", "简单,缺少一些功能的封装");
RowRenderData row2 = RowRenderData.build("Freemarker", "XML操作,跨平台", "复杂,需要理解XML结构");
RowRenderData row3 = RowRenderData.build("OpenOffice", "需要安装OpenOffice软件",
"复杂,需要了解OpenOffice的API");
RowRenderData row4 = RowRenderData.build("Jacob、winlib", "Windows平台", "复杂,不推荐使用");
List<RowRenderData> tableDatas = Arrays.asList(row0, row1, row2, row3, row4);
Map<String, Object> datas = new HashMap<String, Object>(){
{
put("header", "Hello");
put("name", "POI-TL");
put("word", "模板引擎");
put("time", new Date());
put("what", "Java Word模板引擎: Minimal Microsoft word(docx) templating with {{template}} in Java. It works by expanding tags in a template using values provided in a JavaMap or JavaObject.");
put("compare", new MiniTableRenderData(header, tableDatas,
MiniTableRenderData.WIDTH_A4_FULL));
put("feature", new NumbericRenderData(new ArrayList<TextRenderData>() {
{
add(new TextRenderData("Plug-in grammar, add new grammar by yourself"));
add(new TextRenderData(
"Supports word text, local pictures, web pictures, table, list, header, footer..."));
add(new TextRenderData(
"Templates, not just templates, but also style templates"));
}
}));
}
};
XWPFTemplate template = XWPFTemplate.compile("src/test/resources/template/template.docx").render(datas);
FileOutputStream out = new FileOutputStream("out_template.docx");
template.write(out);
out.flush();
out.close();
template.close();
return "Success";
}
@GetMapping("/getPoiObj")
public String getPoiObj() throws Exception {
RowRenderData header = new RowRenderData(
Arrays.asList(new TextRenderData("FFFFFF", "Word处理解决方案"),
new TextRenderData("FFFFFFF", "是否跨平台"),
new TextRenderData("FFFFFFF", "易用性")),
"ff980");
RowRenderData row0 = RowRenderData.build("Poi-tl", "纯Java组件,跨平台", "简单:模板引擎功能,并对POI进行了一些封装");
RowRenderData row1 = RowRenderData.build("Apache Poi", "纯Java组件,跨平台", "简单,缺少一些功能的封装");
RowRenderData row2 = RowRenderData.build("Freemarker", "XML操作,跨平台", "复杂,需要理解XML结构");
RowRenderData row3 = RowRenderData.build("OpenOffice", "需要安装OpenOffice软件",
"复杂,需要了解OpenOffice的API");
RowRenderData row4 = RowRenderData.build("Jacob、winlib", "Windows平台", "复杂,不推荐使用");
List<RowRenderData> tableDatas = Arrays.asList(row0, row1, row2, row3, row4);
MyDataModel obj = new MyDataModel();
obj.setHeader("Deeply love what you love.");
obj.setName("Poi-tl");
obj.setWord("模板引擎");
obj.setTime("2019-05-31");
obj.setWhat(
"Java Word模板引擎: Minimal Microsoft word(docx) templating with {{template}} in Java. It works by expanding tags in a template using values provided in a JavaMap or JavaObject.");
obj.setCompare(new MiniTableRenderData(header, tableDatas));
obj.setFeature(new NumbericRenderData(new ArrayList<TextRenderData>() {
{
add(new TextRenderData("Plug-in grammar, add new grammar by yourself"));
add(new TextRenderData(
"Supports word text, local pictures, web pictures, table, list, header, footer..."));
add(new TextRenderData("Templates, not just templates, but also style templates"));
}
}));
XWPFTemplate template = XWPFTemplate.compile("src/test/resources/template/template.docx")
.render(obj);
FileOutputStream out = new FileOutputStream("out_template_obj.docx");
template.write(out);
out.flush();
out.close();
template.close();
return "Success!";
}
} | UTF-8 | Java | 6,842 | java | ReportManagerController.java | Java | [
{
"context": "e: </p>\n *\n * <p> Description: </p>\n *\n * @author: Guo Weifeng\n * @version: 1.0\n * @create: 2020/10/27 9:45\n */\n",
"end": 1446,
"score": 0.9997890591621399,
"start": 1435,
"tag": "NAME",
"value": "Guo Weifeng"
},
{
"context": " RowRenderData row4 = RowRen... | null | [] | /*
* Copyright 2001-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.ureportdemo.controller;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.MiniTableRenderData;
import com.deepoove.poi.data.NumbericRenderData;
import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.data.TextRenderData;
import com.example.ureportdemo.entity.MyDataModel;
import com.example.ureportdemo.service.ReportBuildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p> Title: </p>
*
* <p> Description: </p>
*
* @author: <NAME>
* @version: 1.0
* @create: 2020/10/27 9:45
*/
@RestController
public class ReportManagerController {
@Autowired
private ReportBuildService reportBuildService;
@GetMapping("/getUreport")
public String getReport() {
String docxName = String.valueOf(System.currentTimeMillis());
reportBuildService.buildWordDocx(docxName, null);
return "success!";
}
@GetMapping("/getPoi")
public String getPoi() throws Exception {
RowRenderData header = new RowRenderData(
Arrays.asList(new TextRenderData("FFFFFF", "Word处理解决方案"),
new TextRenderData("FFFFFFF", "是否跨平台"),
new TextRenderData("FFFFFFF", "易用性")),
"ff980");
RowRenderData row0 = RowRenderData.build("Poi-tl", "纯Java组件,跨平台", "简单:模板引擎功能,并对POI进行了一些封装");
RowRenderData row1 = RowRenderData.build("Apache Poi", "纯Java组件,跨平台", "简单,缺少一些功能的封装");
RowRenderData row2 = RowRenderData.build("Freemarker", "XML操作,跨平台", "复杂,需要理解XML结构");
RowRenderData row3 = RowRenderData.build("OpenOffice", "需要安装OpenOffice软件",
"复杂,需要了解OpenOffice的API");
RowRenderData row4 = RowRenderData.build("Jacob、winlib", "Windows平台", "复杂,不推荐使用");
List<RowRenderData> tableDatas = Arrays.asList(row0, row1, row2, row3, row4);
Map<String, Object> datas = new HashMap<String, Object>(){
{
put("header", "Hello");
put("name", "POI-TL");
put("word", "模板引擎");
put("time", new Date());
put("what", "Java Word模板引擎: Minimal Microsoft word(docx) templating with {{template}} in Java. It works by expanding tags in a template using values provided in a JavaMap or JavaObject.");
put("compare", new MiniTableRenderData(header, tableDatas,
MiniTableRenderData.WIDTH_A4_FULL));
put("feature", new NumbericRenderData(new ArrayList<TextRenderData>() {
{
add(new TextRenderData("Plug-in grammar, add new grammar by yourself"));
add(new TextRenderData(
"Supports word text, local pictures, web pictures, table, list, header, footer..."));
add(new TextRenderData(
"Templates, not just templates, but also style templates"));
}
}));
}
};
XWPFTemplate template = XWPFTemplate.compile("src/test/resources/template/template.docx").render(datas);
FileOutputStream out = new FileOutputStream("out_template.docx");
template.write(out);
out.flush();
out.close();
template.close();
return "Success";
}
@GetMapping("/getPoiObj")
public String getPoiObj() throws Exception {
RowRenderData header = new RowRenderData(
Arrays.asList(new TextRenderData("FFFFFF", "Word处理解决方案"),
new TextRenderData("FFFFFFF", "是否跨平台"),
new TextRenderData("FFFFFFF", "易用性")),
"ff980");
RowRenderData row0 = RowRenderData.build("Poi-tl", "纯Java组件,跨平台", "简单:模板引擎功能,并对POI进行了一些封装");
RowRenderData row1 = RowRenderData.build("Apache Poi", "纯Java组件,跨平台", "简单,缺少一些功能的封装");
RowRenderData row2 = RowRenderData.build("Freemarker", "XML操作,跨平台", "复杂,需要理解XML结构");
RowRenderData row3 = RowRenderData.build("OpenOffice", "需要安装OpenOffice软件",
"复杂,需要了解OpenOffice的API");
RowRenderData row4 = RowRenderData.build("Jacob、winlib", "Windows平台", "复杂,不推荐使用");
List<RowRenderData> tableDatas = Arrays.asList(row0, row1, row2, row3, row4);
MyDataModel obj = new MyDataModel();
obj.setHeader("Deeply love what you love.");
obj.setName("Poi-tl");
obj.setWord("模板引擎");
obj.setTime("2019-05-31");
obj.setWhat(
"Java Word模板引擎: Minimal Microsoft word(docx) templating with {{template}} in Java. It works by expanding tags in a template using values provided in a JavaMap or JavaObject.");
obj.setCompare(new MiniTableRenderData(header, tableDatas));
obj.setFeature(new NumbericRenderData(new ArrayList<TextRenderData>() {
{
add(new TextRenderData("Plug-in grammar, add new grammar by yourself"));
add(new TextRenderData(
"Supports word text, local pictures, web pictures, table, list, header, footer..."));
add(new TextRenderData("Templates, not just templates, but also style templates"));
}
}));
XWPFTemplate template = XWPFTemplate.compile("src/test/resources/template/template.docx")
.render(obj);
FileOutputStream out = new FileOutputStream("out_template_obj.docx");
template.write(out);
out.flush();
out.close();
template.close();
return "Success!";
}
} | 6,837 | 0.64415 | 0.634789 | 148 | 42.317566 | 35.358788 | 204 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 9 |
1958ab33cb4f7d06ada0d049d536d44bcdc0b9e3 | 26,147,760,966,284 | c499369b6befb407a2e3d7f13b5b7f30940b9510 | /src/Q5637.java | a4ff1ce4ad19c7e9bb5229f1feec110dcf080f68 | [] | no_license | cbdog94/Leetcode | https://github.com/cbdog94/Leetcode | fb0caf08c1d8561d2035c3d00e7afd9b0ef9ab55 | 2a21a81f29810f9984615e54372a182055fc0970 | refs/heads/master | 2021-09-12T23:45:00.324000 | 2021-09-05T07:37:24 | 2021-09-05T07:37:24 | 127,594,914 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class Q5637 {
public boolean halvesAreAlike(String s) {
s = s.toLowerCase();
int count = 0;
for (int i = 0; i < s.length() / 2; i++) {
switch (s.charAt(i)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
count++;
break;
default:
}
}
for (int i = s.length() / 2; i < s.length(); i++) {
switch (s.charAt(i)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
count--;
break;
default:
}
}
return count == 0;
}
}
| UTF-8 | Java | 805 | java | Q5637.java | Java | [] | null | [] | public class Q5637 {
public boolean halvesAreAlike(String s) {
s = s.toLowerCase();
int count = 0;
for (int i = 0; i < s.length() / 2; i++) {
switch (s.charAt(i)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
count++;
break;
default:
}
}
for (int i = s.length() / 2; i < s.length(); i++) {
switch (s.charAt(i)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
count--;
break;
default:
}
}
return count == 0;
}
}
| 805 | 0.295652 | 0.284472 | 31 | 24.967741 | 11.618905 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.354839 | false | false | 9 |
060d2533909b8d2e67ab102c42ecffe498ea73c3 | 13,743,895,405,376 | 1a348eca8b3bd1436c9774f3675ff8a51cfe660f | /src/main/java/com/esl/sysdog/model/Fornecedor.java | 8e086918c58c49e714a2f2dafd303766e1dd010e | [] | no_license | EliedersonLinhares/SysDog | https://github.com/EliedersonLinhares/SysDog | b711d103d2cb683c35cc24e5dbb8a1cec8c38c63 | 028fe86e4961f2f6bd4e566288f9e6d416a620be | refs/heads/master | 2020-05-02T09:41:14.933000 | 2019-03-26T22:58:26 | 2019-03-26T22:58:26 | 177,878,114 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.esl.sysdog.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name ="fornecedor")
public class Fornecedor{
@Id
@GeneratedValue( strategy= GenerationType.IDENTITY)
private Long codigo;
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
}
@Column(length = 50, nullable=false)
private String nomeF;
@Column(length = 13, nullable=false)
private String telefone;
@Column(length = 50)
private String contato;
@Column(length = 14)
private String celular;
@Column(length = 50)
private String email;
@Column(length = 80)
private String descricaoF;
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getContato() {
return contato;
}
public void setContato(String contato) {
this.contato = contato;
}
public String getCelular() {
return celular;
}
public void setCelular(String celular) {
this.celular = celular;
}
public String getNomeF() {
return nomeF;
}
public void setNomeF(String nomeF) {
this.nomeF = nomeF;
}
public String getDescricaoF() {
return descricaoF;
}
public void setDescricaoF(String descricaoF) {
this.descricaoF = descricaoF;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
//uso do Ominifaces para conversão de dados de caixas de seleção
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Fornecedor other = (Fornecedor) obj;
if (codigo == null) {
if (other.codigo != null)
return false;
} else if (!codigo.equals(other.codigo))
return false;
return true;
}
}
| ISO-8859-1 | Java | 2,305 | java | Fornecedor.java | Java | [] | null | [] | package com.esl.sysdog.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name ="fornecedor")
public class Fornecedor{
@Id
@GeneratedValue( strategy= GenerationType.IDENTITY)
private Long codigo;
public Long getCodigo() {
return codigo;
}
public void setCodigo(Long codigo) {
this.codigo = codigo;
}
@Column(length = 50, nullable=false)
private String nomeF;
@Column(length = 13, nullable=false)
private String telefone;
@Column(length = 50)
private String contato;
@Column(length = 14)
private String celular;
@Column(length = 50)
private String email;
@Column(length = 80)
private String descricaoF;
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getContato() {
return contato;
}
public void setContato(String contato) {
this.contato = contato;
}
public String getCelular() {
return celular;
}
public void setCelular(String celular) {
this.celular = celular;
}
public String getNomeF() {
return nomeF;
}
public void setNomeF(String nomeF) {
this.nomeF = nomeF;
}
public String getDescricaoF() {
return descricaoF;
}
public void setDescricaoF(String descricaoF) {
this.descricaoF = descricaoF;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
//uso do Ominifaces para conversão de dados de caixas de seleção
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Fornecedor other = (Fornecedor) obj;
if (codigo == null) {
if (other.codigo != null)
return false;
} else if (!codigo.equals(other.codigo))
return false;
return true;
}
}
| 2,305 | 0.694613 | 0.687663 | 130 | 16.707693 | 16.522919 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.361538 | false | false | 9 |
484029072c90f7c048cc90cad9c35cf0a6d24cdd | 21,689,584,903,241 | 7499897e1563e522be6904f07b759bb295ef98d3 | /src/PayrollSystemTest.java | bb4c7a01a2e495826d7ec080d4545363cbf6764e | [] | no_license | mdalamin-eu/JavaUniversityAssignment | https://github.com/mdalamin-eu/JavaUniversityAssignment | 8339ba2084c112a6cd8617976d93d83631b126e3 | a46027a88fc31339cdb31710278b9feca0387d4a | refs/heads/master | 2023-04-27T03:05:46.643000 | 2021-05-21T17:59:48 | 2021-05-21T17:59:48 | 369,615,488 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Calendar;
public class PayrollSystemTest{
public static void main(String[] args){
int currentMonth = 1 + Calendar.getInstance().get(Calendar.MONTH);
// Employee array
Employee[] employees = new Employee[5];
//here i used this month for result (salary+bonus)
employees[0] = new SalariedEmployee(
"Masom", "Miah", "masom@centria.fi", "064774773428", 800.0f, 5, 3, 1883);
employees[1] = new HourlyEmployee(
"Karim", "Sujon", "karim@centria.fi", "226756743738", 16.75f, 40.0f, 12, 12, 1975);
employees[2] = new CommissionEmployee(
"Jakko", "Khan", "jakko@centria.fi", "36775737835", 10000.0f, .06f, 12, 13, 1965);
employees[3] = new BasePlusCommissionEmployee(
"Bishal", "Thapa", "bishal@centria.fi", "46743348787", 5000.0f, .04f, 300.0f, 12, 12, 1956);
//here i used this month for result (salary+bonus)
employees[4] = new SalariedEmployee(
"Md", "Alamin", "md.alamin@centria.fi", "064774773428", 800.0f, 5, 3, 1883);
System.out.println("Employees processed polymorphically:\n");
for(Employee currentEmployee : employees){
System.out.println(currentEmployee);
// determine of element BasePlusCommissionEmployee
if(currentEmployee instanceof BasePlusCommissionEmployee){
BasePlusCommissionEmployee employee =
(BasePlusCommissionEmployee) currentEmployee;
employee.setBaseSalary(1.10f * employee.getBaseSalary());
System.out.printf("new base salary with 10%% increase is: $%,.2f\n",
employee.getBaseSalary());
}
System.out.printf("earned $%,.2f\n\n",
(currentEmployee.getBirthday().getMonth() == currentMonth) ?
currentEmployee.earnings() + 100.0f : currentEmployee.earnings());
}
for(int j=0; j<employees.length; j++){
System.out.printf("Employee %d is a %s\n",
j, employees[j].getClass().getName());
}
}
} | UTF-8 | Java | 2,178 | java | PayrollSystemTest.java | Java | [
{
"context": "oyees[0] = new SalariedEmployee(\n \"Masom\", \"Miah\", \"masom@centria.fi\", \"064774773428\", 800",
"end": 380,
"score": 0.9998365640640259,
"start": 375,
"tag": "NAME",
"value": "Masom"
},
{
"context": "= new SalariedEmployee(\n \"Masom\... | null | [] | import java.util.Calendar;
public class PayrollSystemTest{
public static void main(String[] args){
int currentMonth = 1 + Calendar.getInstance().get(Calendar.MONTH);
// Employee array
Employee[] employees = new Employee[5];
//here i used this month for result (salary+bonus)
employees[0] = new SalariedEmployee(
"Masom", "Miah", "<EMAIL>", "064774773428", 800.0f, 5, 3, 1883);
employees[1] = new HourlyEmployee(
"Karim", "Sujon", "<EMAIL>", "226756743738", 16.75f, 40.0f, 12, 12, 1975);
employees[2] = new CommissionEmployee(
"Jakko", "Khan", "<EMAIL>", "36775737835", 10000.0f, .06f, 12, 13, 1965);
employees[3] = new BasePlusCommissionEmployee(
"Bishal", "Thapa", "<EMAIL>", "46743348787", 5000.0f, .04f, 300.0f, 12, 12, 1956);
//here i used this month for result (salary+bonus)
employees[4] = new SalariedEmployee(
"Md", "Alamin", "<EMAIL>", "064774773428", 800.0f, 5, 3, 1883);
System.out.println("Employees processed polymorphically:\n");
for(Employee currentEmployee : employees){
System.out.println(currentEmployee);
// determine of element BasePlusCommissionEmployee
if(currentEmployee instanceof BasePlusCommissionEmployee){
BasePlusCommissionEmployee employee =
(BasePlusCommissionEmployee) currentEmployee;
employee.setBaseSalary(1.10f * employee.getBaseSalary());
System.out.printf("new base salary with 10%% increase is: $%,.2f\n",
employee.getBaseSalary());
}
System.out.printf("earned $%,.2f\n\n",
(currentEmployee.getBirthday().getMonth() == currentMonth) ?
currentEmployee.earnings() + 100.0f : currentEmployee.earnings());
}
for(int j=0; j<employees.length; j++){
System.out.printf("Employee %d is a %s\n",
j, employees[j].getClass().getName());
}
}
} | 2,128 | 0.581267 | 0.513774 | 53 | 40.113209 | 33.313072 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.169811 | false | false | 9 |
903921ace9cfc2bab567ce8b4c36137ba482e456 | 1,365,799,607,507 | a53c454c8bca3cab26c5d571218975e86b5ce1ed | /logistics/src/main/java/com/zhiyong/logistics/controller/BaseDataController.java | 2947a1420f61d75cd0f946e2372a24936c196985 | [] | no_license | Jsteven1106/logistics | https://github.com/Jsteven1106/logistics | 36190f98970a9352d1feeb8aeeb259e20225cc39 | b351073fd471f5150df13ecd90ee9ae6df96c4ff | refs/heads/master | 2020-09-08T01:29:04.386000 | 2019-11-11T12:17:34 | 2019-11-11T12:17:34 | 220,971,449 | 0 | 0 | null | false | 2021-05-08T18:01:10 | 2019-11-11T11:57:47 | 2019-11-11T12:21:54 | 2021-05-08T18:01:10 | 3,376 | 0 | 0 | 6 | JavaScript | false | false | package com.zhiyong.logistics.controller;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyong.logistics.mo.MessageObject;
import com.zhiyong.logistics.pojo.BaseData;
import com.zhiyong.logistics.pojo.BaseDataExample;
import com.zhiyong.logistics.pojo.BaseDataExample.Criteria;
import com.zhiyong.logistics.service.BaseDataService;
@Controller
@RequestMapping("/baseData")
public class BaseDataController {
@Autowired
private BaseDataService baseDataService;
@RequestMapping("/baseDataPage")
public String baseDataPage() {
return "baseDataPage";
}
@RequestMapping("/list")
@ResponseBody
public PageInfo<BaseData> list(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize, String keyword) {
// int pageNum = 1; // 当前页,页码默认为1
// int pageSize = 5; // 每页条数
PageHelper.startPage(pageNum, pageSize);
// 条件查询
BaseDataExample example = new BaseDataExample();
if (StringUtils.isNotBlank(keyword)) {// 不为空
// 创建条件限制对象
Criteria criteria = example.createCriteria();
// 模糊查询
criteria.andBaseNameLike("%" + keyword + "%");
/**
* 在同一个criteria限制对象中,设置多条件是AND关系,
* 需要用OR条件,则创建新的ceiteria对象
*/
Criteria criteria2 = example.createCriteria();
example.or(criteria2);
}
List<BaseData> baseDatas = baseDataService.selectByExample(example);
for (BaseData baseData : baseDatas) {
System.out.println(baseData);
}
// 创建分页对象
PageInfo<BaseData> pageInfo = new PageInfo<BaseData>(baseDatas);
return pageInfo;
}
// 删除
@RequestMapping("/delete")
@ResponseBody
public MessageObject delete(Long baseId) {
MessageObject mo = new MessageObject(0, "删除失败,请联系管理员");
// 删除基础数据之前,要先看其是否有子基础数据
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andParentIdEqualTo(baseId);
List<BaseData> baseDatas = baseDataService.selectByExample(example);
if (baseDatas.size() > 0) {
mo = new MessageObject(0, "此分类数据还有子数据,不能直接删除");
} else {
int row = baseDataService.deleteByPrimaryKey(baseId);
if (row == 1) {
mo = new MessageObject(1, "删除成功");
}
}
return mo;
}
// 编辑
@RequestMapping("/edit")
public String edit(Model m, Long baseId) {
// 编辑回显
if (baseId != null) {
BaseData baseData = baseDataService.selectByPrimaryKey(baseId);
m.addAttribute("baseData", baseData);
}
// 查询所有的分类数据
// 只查询parentId = null的分类数据
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andParentIdIsNull();
List<BaseData> parents = baseDataService.selectByExample(example);
m.addAttribute("parents", parents);
return "baseDataEdit";
}
// 检查基础数据是否存在
@RequestMapping("/checkBaseName")
@ResponseBody
public boolean checkBaseName(String baseName) {
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andBaseNameEqualTo(baseName);
List<BaseData> baseDatas = baseDataService.selectByExample(example);
if (baseDatas.size() > 0) {
return false;
}
return true;
}
// 新增操作
@RequestMapping("/insert")
@ResponseBody
public MessageObject insert(BaseData baseData) {
MessageObject mo = new MessageObject(0, "新增数据失败,请联系管理员");
int row = baseDataService.insert(baseData);
if (row == 1) {
mo = new MessageObject(1, "新增数据成功");
}
return mo;
}
// 修改
@RequestMapping("/update")
@ResponseBody
public MessageObject update(BaseData baseData) {
MessageObject mo = new MessageObject(0, "修改数据失败,请联系管理员");
int row = baseDataService.updateByPrimaryKeySelective(baseData);
if (row == 1) {
mo = new MessageObject(1, "修改数据成功");
}
return mo;
}
}
| UTF-8 | Java | 4,525 | java | BaseDataController.java | Java | [] | null | [] | package com.zhiyong.logistics.controller;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyong.logistics.mo.MessageObject;
import com.zhiyong.logistics.pojo.BaseData;
import com.zhiyong.logistics.pojo.BaseDataExample;
import com.zhiyong.logistics.pojo.BaseDataExample.Criteria;
import com.zhiyong.logistics.service.BaseDataService;
@Controller
@RequestMapping("/baseData")
public class BaseDataController {
@Autowired
private BaseDataService baseDataService;
@RequestMapping("/baseDataPage")
public String baseDataPage() {
return "baseDataPage";
}
@RequestMapping("/list")
@ResponseBody
public PageInfo<BaseData> list(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize, String keyword) {
// int pageNum = 1; // 当前页,页码默认为1
// int pageSize = 5; // 每页条数
PageHelper.startPage(pageNum, pageSize);
// 条件查询
BaseDataExample example = new BaseDataExample();
if (StringUtils.isNotBlank(keyword)) {// 不为空
// 创建条件限制对象
Criteria criteria = example.createCriteria();
// 模糊查询
criteria.andBaseNameLike("%" + keyword + "%");
/**
* 在同一个criteria限制对象中,设置多条件是AND关系,
* 需要用OR条件,则创建新的ceiteria对象
*/
Criteria criteria2 = example.createCriteria();
example.or(criteria2);
}
List<BaseData> baseDatas = baseDataService.selectByExample(example);
for (BaseData baseData : baseDatas) {
System.out.println(baseData);
}
// 创建分页对象
PageInfo<BaseData> pageInfo = new PageInfo<BaseData>(baseDatas);
return pageInfo;
}
// 删除
@RequestMapping("/delete")
@ResponseBody
public MessageObject delete(Long baseId) {
MessageObject mo = new MessageObject(0, "删除失败,请联系管理员");
// 删除基础数据之前,要先看其是否有子基础数据
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andParentIdEqualTo(baseId);
List<BaseData> baseDatas = baseDataService.selectByExample(example);
if (baseDatas.size() > 0) {
mo = new MessageObject(0, "此分类数据还有子数据,不能直接删除");
} else {
int row = baseDataService.deleteByPrimaryKey(baseId);
if (row == 1) {
mo = new MessageObject(1, "删除成功");
}
}
return mo;
}
// 编辑
@RequestMapping("/edit")
public String edit(Model m, Long baseId) {
// 编辑回显
if (baseId != null) {
BaseData baseData = baseDataService.selectByPrimaryKey(baseId);
m.addAttribute("baseData", baseData);
}
// 查询所有的分类数据
// 只查询parentId = null的分类数据
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andParentIdIsNull();
List<BaseData> parents = baseDataService.selectByExample(example);
m.addAttribute("parents", parents);
return "baseDataEdit";
}
// 检查基础数据是否存在
@RequestMapping("/checkBaseName")
@ResponseBody
public boolean checkBaseName(String baseName) {
BaseDataExample example = new BaseDataExample();
Criteria criteria = example.createCriteria();
criteria.andBaseNameEqualTo(baseName);
List<BaseData> baseDatas = baseDataService.selectByExample(example);
if (baseDatas.size() > 0) {
return false;
}
return true;
}
// 新增操作
@RequestMapping("/insert")
@ResponseBody
public MessageObject insert(BaseData baseData) {
MessageObject mo = new MessageObject(0, "新增数据失败,请联系管理员");
int row = baseDataService.insert(baseData);
if (row == 1) {
mo = new MessageObject(1, "新增数据成功");
}
return mo;
}
// 修改
@RequestMapping("/update")
@ResponseBody
public MessageObject update(BaseData baseData) {
MessageObject mo = new MessageObject(0, "修改数据失败,请联系管理员");
int row = baseDataService.updateByPrimaryKeySelective(baseData);
if (row == 1) {
mo = new MessageObject(1, "修改数据成功");
}
return mo;
}
}
| 4,525 | 0.735501 | 0.730648 | 156 | 25.416666 | 22.193195 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.782051 | false | false | 9 |
16bfa30e76c2f1be53a659fe28a2ad9c0bea1784 | 9,002,251,457,514 | dee13699fb392c3f1ad8d7c07682df0b3c71db96 | /src/gui/Beer.java | cd03415ae82b5120b1972b5064f8e267860dce5d | [] | no_license | uday246/Oct18 | https://github.com/uday246/Oct18 | 6e251d2949815b158b22acd2ca16d8501f9fa4d5 | 7c6b6d635d6bd2e6a3c7f3434e9a94d9b89a4b9a | refs/heads/master | 2020-08-15T07:39:34.550000 | 2019-10-15T13:13:10 | 2019-10-15T13:13:10 | 215,302,334 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gui;
public class Beer
{
private String name; // the beer's name
private double alcohol; // the alcohol %, eg, .05 for 5%
public String getName()
{
return name;
}
public void setName(String n)
{
this.name = n;
}
public double getAlcohol()
{
return alcohol;
}
public void setAlcohol(double a)
{
alcohol = a;
}
public double intoxicated(double weight)
{
double numDrinks;
// this is a simplification of the
// Widmark formula
numDrinks = (0.08 + 0.015) * weight /
(12 * 7.5 * alcohol);
return numDrinks;
}
public static void main(String[] args)
{
Beer beer1 = new Beer();
Beer beer2 = new Beer();
beer1.setName("Red label");
beer1.setAlcohol(0.052); // 6.2% alcohol
beer2.setName("Blue label");
beer2.setAlcohol(0.062); // 6.2% alcohol
// use setName and setAlcohol on each of these two beers
/* your code goes here */
double lightWeight = 120; /* set this equal to a light person's weight */
double heavyWeight = 220; /* set this equal to a heavy person's weight */
// set this equal to the number of drinks to get the light person intoxicated
// with the first beer, then print that number along with their weight
/* your code goes here */
double lightDrinks1 = beer1.intoxicated(lightWeight);
System.out.println("The number of " + beer1.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks1);
System.out.println();
double heavyDrinks1 =beer1.intoxicated(heavyWeight);
// set this equal to the number of drinks to get the heavy person intoxicated
// with the first beer, then print that number along with their weight
/* your code goes here */
System.out.println("The number of " + beer1.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks1);
System.out.println();
lightWeight = 150.0; // 100 pounds
heavyWeight = 240.0; // 230 pounds
double lightDrinks2 = beer2.intoxicated(lightWeight);
System.out.println("The number of " + beer2.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks2);
// set this equal to the number of drinks to get the light person intoxicated
// with the second beer, then print that number along with their weight
/* your code goes here */
System.out.println();
double heavyDrinks2 =beer2.intoxicated(heavyWeight);
System.out.println("The number of " + beer2.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks2);
// set this equal to the number of drinks to get the heavy person intoxicated
// with the second beer, then print that number along with their weight
/* your code goes here */
System.out.println();
/* DO NOT MODIFY LINES BELOW THIS COMMENT */
Beer beer3 = new Beer();
beer3.setName("Miller Genuine Draft Light");
beer3.setAlcohol(0.042); // 4.2% alcohol
lightWeight = 100.0; // 100 pounds
heavyWeight = 230.0; // 230 pounds
double lightDrinks3 = beer3.intoxicated(lightWeight);
System.out.println("The number of " + beer3.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks3);
System.out.println();
double heavyDrinks3 = beer3.intoxicated(heavyWeight);
System.out.println("The number of " + beer3.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks3);
System.out.println();
}
} | UTF-8 | Java | 4,366 | java | Beer.java | Java | [
{
"context": " Beer beer3 = new Beer();\r\n beer3.setName(\"Miller Genuine Draft Light\");\r\n beer3.setAlco",
"end": 3586,
"score": 0.6430644989013672,
"start": 3585,
"tag": "NAME",
"value": "M"
}
] | null | [] | package gui;
public class Beer
{
private String name; // the beer's name
private double alcohol; // the alcohol %, eg, .05 for 5%
public String getName()
{
return name;
}
public void setName(String n)
{
this.name = n;
}
public double getAlcohol()
{
return alcohol;
}
public void setAlcohol(double a)
{
alcohol = a;
}
public double intoxicated(double weight)
{
double numDrinks;
// this is a simplification of the
// Widmark formula
numDrinks = (0.08 + 0.015) * weight /
(12 * 7.5 * alcohol);
return numDrinks;
}
public static void main(String[] args)
{
Beer beer1 = new Beer();
Beer beer2 = new Beer();
beer1.setName("Red label");
beer1.setAlcohol(0.052); // 6.2% alcohol
beer2.setName("Blue label");
beer2.setAlcohol(0.062); // 6.2% alcohol
// use setName and setAlcohol on each of these two beers
/* your code goes here */
double lightWeight = 120; /* set this equal to a light person's weight */
double heavyWeight = 220; /* set this equal to a heavy person's weight */
// set this equal to the number of drinks to get the light person intoxicated
// with the first beer, then print that number along with their weight
/* your code goes here */
double lightDrinks1 = beer1.intoxicated(lightWeight);
System.out.println("The number of " + beer1.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks1);
System.out.println();
double heavyDrinks1 =beer1.intoxicated(heavyWeight);
// set this equal to the number of drinks to get the heavy person intoxicated
// with the first beer, then print that number along with their weight
/* your code goes here */
System.out.println("The number of " + beer1.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks1);
System.out.println();
lightWeight = 150.0; // 100 pounds
heavyWeight = 240.0; // 230 pounds
double lightDrinks2 = beer2.intoxicated(lightWeight);
System.out.println("The number of " + beer2.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks2);
// set this equal to the number of drinks to get the light person intoxicated
// with the second beer, then print that number along with their weight
/* your code goes here */
System.out.println();
double heavyDrinks2 =beer2.intoxicated(heavyWeight);
System.out.println("The number of " + beer2.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks2);
// set this equal to the number of drinks to get the heavy person intoxicated
// with the second beer, then print that number along with their weight
/* your code goes here */
System.out.println();
/* DO NOT MODIFY LINES BELOW THIS COMMENT */
Beer beer3 = new Beer();
beer3.setName("Miller Genuine Draft Light");
beer3.setAlcohol(0.042); // 4.2% alcohol
lightWeight = 100.0; // 100 pounds
heavyWeight = 230.0; // 230 pounds
double lightDrinks3 = beer3.intoxicated(lightWeight);
System.out.println("The number of " + beer3.getName() +
" drinks needed to make\na person weighing " +
lightWeight + " pounds intoxicated is " + lightDrinks3);
System.out.println();
double heavyDrinks3 = beer3.intoxicated(heavyWeight);
System.out.println("The number of " + beer3.getName() +
" drinks needed to make\na person weighing " +
heavyWeight + " pounds intoxicated is " + heavyDrinks3);
System.out.println();
}
} | 4,366 | 0.568026 | 0.54535 | 126 | 32.666668 | 26.271173 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 9 |
ebefeef768868f88d306d23b47613ea1a16b10a8 | 18,081,812,325,178 | 3d9dfd87b1f0ee9b1450053165cff0911a11f87c | /vend/agentWeb/src/main/java/com/haiyi/service/UserCashApplyService.java | 67daceb39ca59ecf986131007aac32ae11f7c422 | [] | no_license | stramkismet0221/vend | https://github.com/stramkismet0221/vend | 376fbf50a14bc9bb8b9c723691160ee4ca37899e | 9ed04a2fee764514b23d98d6f913a752ca8d2c6b | refs/heads/master | 2022-07-30T21:36:51.254000 | 2020-05-20T03:09:16 | 2020-05-20T03:09:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.haiyi.service;
import com.haiyi.domain.UserCashApply;
import com.haiyi.query.UserCashApplyQuery;
import com.haiyi.service.base.BaseService;
public interface UserCashApplyService extends BaseService<UserCashApply, UserCashApplyQuery> {
} | UTF-8 | Java | 250 | java | UserCashApplyService.java | Java | [] | null | [] | package com.haiyi.service;
import com.haiyi.domain.UserCashApply;
import com.haiyi.query.UserCashApplyQuery;
import com.haiyi.service.base.BaseService;
public interface UserCashApplyService extends BaseService<UserCashApply, UserCashApplyQuery> {
} | 250 | 0.848 | 0.848 | 8 | 30.375 | 29.799067 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 9 |
a5ee5b298818193eb20eb52a6a31f0f0c4d2626a | 33,595,234,197,020 | 4dd43d0403c159d189d51f1382181224798e3e22 | /src/test/java/com/qa/test/DeleteUserApiTest.java | c7379c5609607b149c725c51f11a273e76ec2c03 | [] | no_license | pkshankar/RestAssured_Framework | https://github.com/pkshankar/RestAssured_Framework | b720d64523c015344040bc81a384c872c71597f7 | 76635e7062aeaa01847675256710a55ec64f6c00 | refs/heads/master | 2022-11-26T15:41:48.855000 | 2020-02-28T01:27:55 | 2020-02-28T01:27:55 | 213,409,936 | 0 | 0 | null | false | 2022-11-15T23:30:40 | 2019-10-07T14:45:55 | 2020-02-28T01:29:20 | 2022-11-15T23:30:39 | 123 | 0 | 0 | 5 | HTML | false | false | package com.qa.test;
import java.util.HashMap;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.qa.base.TestBase;
import com.qa.client.RestClient;
import com.qa.pojo.CreateUser;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class DeleteUserApiTest extends TestBase {
String baseUrl, serviceUrl, authorization;
HashMap<String, String> map;
public DeleteUserApiTest() {
super();
}
@BeforeMethod
public void setUp() {
baseUrl = prop.getProperty("baseUrl");
serviceUrl = prop.getProperty("getUserListServiceUrl");
authorization = prop.getProperty("authorization");
map = new HashMap<>();
map.put("AUTHORIZATION", authorization);
}
@Test
public void updateUserApiTest() {
CreateUser createUser = new CreateUser();
createUser.setFirst_name("Loky");
createUser.setLast_name("Mers");
createUser.setGender("female");
createUser.setEmail("loky@mers.com");
createUser.setStatus("active");
Response postResponse = RestClient.PostCall(baseUrl, "json", true, "POST", serviceUrl, map, createUser);
JsonPath jPath = postResponse.jsonPath();
String createdUserId = jPath.get("result.id");
Response deleteResponse = RestClient.DeleteCall(baseUrl, "json", false, "DELETE", serviceUrl, map);
RestClient.getJsonPath(deleteResponse);
}
}
| UTF-8 | Java | 1,362 | java | DeleteUserApiTest.java | Java | [
{
"context": "r = new CreateUser();\n\t\tcreateUser.setFirst_name(\"Loky\");\n\t\tcreateUser.setLast_name(\"Mers\");\n\t\tcreateUse",
"end": 863,
"score": 0.9997577667236328,
"start": 859,
"tag": "NAME",
"value": "Loky"
},
{
"context": "setFirst_name(\"Loky\");\n\t\tcreateUser.setLas... | null | [] | package com.qa.test;
import java.util.HashMap;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.qa.base.TestBase;
import com.qa.client.RestClient;
import com.qa.pojo.CreateUser;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class DeleteUserApiTest extends TestBase {
String baseUrl, serviceUrl, authorization;
HashMap<String, String> map;
public DeleteUserApiTest() {
super();
}
@BeforeMethod
public void setUp() {
baseUrl = prop.getProperty("baseUrl");
serviceUrl = prop.getProperty("getUserListServiceUrl");
authorization = prop.getProperty("authorization");
map = new HashMap<>();
map.put("AUTHORIZATION", authorization);
}
@Test
public void updateUserApiTest() {
CreateUser createUser = new CreateUser();
createUser.setFirst_name("Loky");
createUser.setLast_name("Mers");
createUser.setGender("female");
createUser.setEmail("<EMAIL>");
createUser.setStatus("active");
Response postResponse = RestClient.PostCall(baseUrl, "json", true, "POST", serviceUrl, map, createUser);
JsonPath jPath = postResponse.jsonPath();
String createdUserId = jPath.get("result.id");
Response deleteResponse = RestClient.DeleteCall(baseUrl, "json", false, "DELETE", serviceUrl, map);
RestClient.getJsonPath(deleteResponse);
}
}
| 1,356 | 0.749633 | 0.749633 | 54 | 24.222221 | 24.119814 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.611111 | false | false | 9 |
e3b10aa525ba561b11e00ff8df1ad546b71611c1 | 31,310,311,596,724 | 901dea8c96b19109927554bf0762de2aeb2ad5e1 | /TestProject/src/main/collections/Sorting.java | c9965f5ce6f6dc8a9dacbc81abbd31faebdf2a85 | [] | no_license | KsiadzCRASH/CrashTest | https://github.com/KsiadzCRASH/CrashTest | ff3fadc8682976e840b162cb235aa28da64b80ba | cb4c0553ec026135e217c179e93c6b21769dd1a1 | refs/heads/master | 2021-01-04T22:32:19.172000 | 2012-12-16T23:57:26 | 2012-12-16T23:57:26 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main.collections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Test;
public class Sorting extends TestCase{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
@SuppressWarnings("unused")
private static class A
{
private Integer primId;
private Integer secondId;
private Integer tertiaryFlag;
public A(Integer pId, Integer sId, Integer tFlag) {
super();
this.primId = pId;
this.secondId = sId;
this.tertiaryFlag = tFlag;
}
public Integer getPrimId() {
return primId;
}
public void setPrimId(Integer pId) {
this.primId = pId;
}
public Integer getSecondId() {
return secondId;
}
public void setSecondId(Integer sId) {
this.secondId = sId;
}
public Integer getTertiaryFlag() {
return tertiaryFlag;
}
public void setTertiaryFlag(Integer tertiaryFlag) {
this.tertiaryFlag = tertiaryFlag;
}
@Override
public String toString()
{
return "Prim : " + primId + " Second : " + secondId + " Tertiary : " + tertiaryFlag;
}
}
private List<A> sortData(List<A> data)
{
Collections.sort(data, new Comparator<A>(){
public int compare(A o1, A o2) {
int priComp = 0,
result = 0;
if (o1.getPrimId() == null && o2.getPrimId() == null)
priComp = 0; // dead code
else if (o1.getPrimId() == null)
priComp = -1; // dead code
else if (o2.getPrimId() == null)
priComp = 1; // dead code
else priComp = o1.getPrimId().compareTo(o2.getPrimId());
result = priComp;
if (o1.getSecondId() != null && o2.getSecondId() != null)
{
if(o1.getSecondId().compareTo(o2.getSecondId()) == 0)
{
if (o1.getTertiaryFlag() != null && o2.getTertiaryFlag() != null)
{
result = -o1.getTertiaryFlag().compareTo(o2.getTertiaryFlag());
}
}
}
return result;
}
});
return data;
}
/**
* Ordered data
* @return data without modification
*/
@Test
public void testSortingOrdered()
{
List<A> data = new ArrayList<A>();
data.add(new A(1,1,1));
data.add(new A(2,1,-1));
data.add(new A(3,2,1));
data.add(new A(4,2,-1));
data.add(new A(5,3,1));
data.add(new A(6,3,-1));
data.add(new A(7,4,1));
data.add(new A(8,4,-1));
data.add(new A(9,5,1));
data.add(new A(10,5,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Reverse ordered data
* @return ordered data
*/
@Test
public void testSortingReverse()
{
List<A> data = new ArrayList<A>();
data.add(new A(10,5,-1));
data.add(new A(9,5,1));
data.add(new A(8,4,-1));
data.add(new A(7,4,1));
data.add(new A(6,3,-1));
data.add(new A(5,3,1));
data.add(new A(4,2,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data.add(new A(1,1,1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Randomly ordered data
* @return ordered data
*/
@Test
public void testSortingRandom()
{
List<A> data = new ArrayList<A>();
data.add(new A(6,3,-1));
data.add(new A(7,4,1));
data.add(new A(1,1,1));
data.add(new A(4,2,-1));
data.add(new A(8,4,-1));
data.add(new A(9,5,1));
data.add(new A(5,3,1));
data.add(new A(10,5,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Randomly ordered with missing data
* @return ordered data
*/
@Test
public void testSortingRandomMissingData()
{
List<A> data = new ArrayList<A>();
data.add(new A(6,3,-1));
data.add(new A(7,null,null));
data.add(new A(1,1,1));
data.add(new A(4,null,-1));
data.add(new A(8,null,null));
data.add(new A(9,5,1));
data.add(new A(5,3,null));
data.add(new A(10,null,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
}
| UTF-8 | Java | 4,485 | java | Sorting.java | Java | [] | null | [] | package main.collections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Test;
public class Sorting extends TestCase{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
@SuppressWarnings("unused")
private static class A
{
private Integer primId;
private Integer secondId;
private Integer tertiaryFlag;
public A(Integer pId, Integer sId, Integer tFlag) {
super();
this.primId = pId;
this.secondId = sId;
this.tertiaryFlag = tFlag;
}
public Integer getPrimId() {
return primId;
}
public void setPrimId(Integer pId) {
this.primId = pId;
}
public Integer getSecondId() {
return secondId;
}
public void setSecondId(Integer sId) {
this.secondId = sId;
}
public Integer getTertiaryFlag() {
return tertiaryFlag;
}
public void setTertiaryFlag(Integer tertiaryFlag) {
this.tertiaryFlag = tertiaryFlag;
}
@Override
public String toString()
{
return "Prim : " + primId + " Second : " + secondId + " Tertiary : " + tertiaryFlag;
}
}
private List<A> sortData(List<A> data)
{
Collections.sort(data, new Comparator<A>(){
public int compare(A o1, A o2) {
int priComp = 0,
result = 0;
if (o1.getPrimId() == null && o2.getPrimId() == null)
priComp = 0; // dead code
else if (o1.getPrimId() == null)
priComp = -1; // dead code
else if (o2.getPrimId() == null)
priComp = 1; // dead code
else priComp = o1.getPrimId().compareTo(o2.getPrimId());
result = priComp;
if (o1.getSecondId() != null && o2.getSecondId() != null)
{
if(o1.getSecondId().compareTo(o2.getSecondId()) == 0)
{
if (o1.getTertiaryFlag() != null && o2.getTertiaryFlag() != null)
{
result = -o1.getTertiaryFlag().compareTo(o2.getTertiaryFlag());
}
}
}
return result;
}
});
return data;
}
/**
* Ordered data
* @return data without modification
*/
@Test
public void testSortingOrdered()
{
List<A> data = new ArrayList<A>();
data.add(new A(1,1,1));
data.add(new A(2,1,-1));
data.add(new A(3,2,1));
data.add(new A(4,2,-1));
data.add(new A(5,3,1));
data.add(new A(6,3,-1));
data.add(new A(7,4,1));
data.add(new A(8,4,-1));
data.add(new A(9,5,1));
data.add(new A(10,5,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Reverse ordered data
* @return ordered data
*/
@Test
public void testSortingReverse()
{
List<A> data = new ArrayList<A>();
data.add(new A(10,5,-1));
data.add(new A(9,5,1));
data.add(new A(8,4,-1));
data.add(new A(7,4,1));
data.add(new A(6,3,-1));
data.add(new A(5,3,1));
data.add(new A(4,2,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data.add(new A(1,1,1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Randomly ordered data
* @return ordered data
*/
@Test
public void testSortingRandom()
{
List<A> data = new ArrayList<A>();
data.add(new A(6,3,-1));
data.add(new A(7,4,1));
data.add(new A(1,1,1));
data.add(new A(4,2,-1));
data.add(new A(8,4,-1));
data.add(new A(9,5,1));
data.add(new A(5,3,1));
data.add(new A(10,5,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
/**
* Randomly ordered with missing data
* @return ordered data
*/
@Test
public void testSortingRandomMissingData()
{
List<A> data = new ArrayList<A>();
data.add(new A(6,3,-1));
data.add(new A(7,null,null));
data.add(new A(1,1,1));
data.add(new A(4,null,-1));
data.add(new A(8,null,null));
data.add(new A(9,5,1));
data.add(new A(5,3,null));
data.add(new A(10,null,-1));
data.add(new A(3,2,1));
data.add(new A(2,1,-1));
data = sortData(data);
for (int i = 0; i < data.size(); i++) {
assertEquals((int)data.get(i).getPrimId(), i+1);
}
}
}
| 4,485 | 0.562542 | 0.529766 | 216 | 18.763889 | 17.04908 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.634259 | false | false | 9 |
232545c20cfb8dac197e917187558e72a5c5cec6 | 14,920,716,396,438 | 24a63d1f03634767bce891f78d928a55992394d6 | /LevelEvaluation/AI/Execution.java | 82eef93fa385c9f376998800d89aed6a74e67442 | [] | no_license | barryhong1995/IMGD-4100---MarioQuilt | https://github.com/barryhong1995/IMGD-4100---MarioQuilt | d97bb2dd807e006ca753bbf402007a0d203656a1 | e97a29719bf854dce20ff05700099f55a3304fbb | refs/heads/master | 2021-08-30T04:46:18.787000 | 2017-12-16T02:47:08 | 2017-12-16T02:47:08 | 113,468,491 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package AI;
import java.io.*;
public class Execution {
public static void main(String args[]) {
char[][] rawLevelScene = new char[1000][1000];
Platform[] platforms = new Platform[1000];
AIData ai = new AIData();
try {
// Read level data from file
BufferedReader fileInput = new BufferedReader(new FileReader("./LevelEvaluation/TestLevel/testLevel.txt"));
// Print out result from console
PrintStream out = new PrintStream(new FileOutputStream("level_evaluation.txt"));
System.setOut(out);
String s;
int maxWidth = 0;
int height = 0;
while ((s = fileInput.readLine()) != null) {
int width = 0;
for (char c : s.toCharArray()) {
if (c != ' ') {
rawLevelScene[width][height] = c;
width++;
}
}
if (width > maxWidth) maxWidth = width;
height++;
}
fileInput.close();
// Report status that file is read
System.out.println("File is imported successfully!");
ai.importScene(rawLevelScene, maxWidth, height);
platforms = ai.getPlatformData();
System.out.println("Number of platforms found: " + ai.getLandCount());
System.out.println("Branch System of Platforms:");
for (int i = 0; i < ai.getLandCount(); i++) {
System.out.print("Platform " + platforms[i].getID() + ": ");
for (int j = 0; j < platforms[i].getAccessCount(); j++) {
System.out.print(platforms[i].getAccessList()[j] + " ");
}
System.out.println();
}
if (ai.testClearLevel()) {
System.out.println("Level can be cleared!");
System.out.println("Number of paths: " + ai.getPathCount());
System.out.println(ai.getPossiblePaths());
} else System.out.println("Level cannot be cleared!");
} catch (FileNotFoundException e) {
// Report status that file is not found
System.out.println("File is missing!");
} catch (IOException e) {
// Report error of file
System.out.println("File cannot be read!");
}
}
}
| UTF-8 | Java | 1,917 | java | Execution.java | Java | [] | null | [] | package AI;
import java.io.*;
public class Execution {
public static void main(String args[]) {
char[][] rawLevelScene = new char[1000][1000];
Platform[] platforms = new Platform[1000];
AIData ai = new AIData();
try {
// Read level data from file
BufferedReader fileInput = new BufferedReader(new FileReader("./LevelEvaluation/TestLevel/testLevel.txt"));
// Print out result from console
PrintStream out = new PrintStream(new FileOutputStream("level_evaluation.txt"));
System.setOut(out);
String s;
int maxWidth = 0;
int height = 0;
while ((s = fileInput.readLine()) != null) {
int width = 0;
for (char c : s.toCharArray()) {
if (c != ' ') {
rawLevelScene[width][height] = c;
width++;
}
}
if (width > maxWidth) maxWidth = width;
height++;
}
fileInput.close();
// Report status that file is read
System.out.println("File is imported successfully!");
ai.importScene(rawLevelScene, maxWidth, height);
platforms = ai.getPlatformData();
System.out.println("Number of platforms found: " + ai.getLandCount());
System.out.println("Branch System of Platforms:");
for (int i = 0; i < ai.getLandCount(); i++) {
System.out.print("Platform " + platforms[i].getID() + ": ");
for (int j = 0; j < platforms[i].getAccessCount(); j++) {
System.out.print(platforms[i].getAccessList()[j] + " ");
}
System.out.println();
}
if (ai.testClearLevel()) {
System.out.println("Level can be cleared!");
System.out.println("Number of paths: " + ai.getPathCount());
System.out.println(ai.getPossiblePaths());
} else System.out.println("Level cannot be cleared!");
} catch (FileNotFoundException e) {
// Report status that file is not found
System.out.println("File is missing!");
} catch (IOException e) {
// Report error of file
System.out.println("File cannot be read!");
}
}
}
| 1,917 | 0.641628 | 0.63276 | 57 | 32.63158 | 22.974152 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.561404 | false | false | 9 |
eacfaa035f91fcdc0d81d094ba1b65085f4569de | 8,924,942,063,707 | b82eb723ca41863b8c7d4740f707c9172ba16606 | /web/src/main/java/com/hlib/controller/front/shop/FrontIndexController.java | b56923fc4a43a5431aedbdf1804a7f13018cab60 | [] | no_license | staryin-code/blog | https://github.com/staryin-code/blog | b3c83535da05e7f95a871ab62696221f1c679692 | 2021000a91197bac58f8debc1bf9514978c0c3f5 | refs/heads/master | 2021-05-31T13:51:15.096000 | 2016-04-05T10:41:43 | 2016-04-05T10:41:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hlib.controller.front.shop;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by hlib on 2016/2/25 0025.
*/
@Controller
@RequestMapping(value = "/front/shop/index/")
public class FrontIndexController extends FrontBaseController{
@RequestMapping(value = "show")
public String index(){
return dir + "index";
}
}
| UTF-8 | Java | 429 | java | FrontIndexController.java | Java | [
{
"context": "bind.annotation.RequestMapping;\n\n/**\n * Created by hlib on 2016/2/25 0025.\n */\n@Controller\n@RequestMappin",
"end": 177,
"score": 0.9996111392974854,
"start": 173,
"tag": "USERNAME",
"value": "hlib"
}
] | null | [] | package com.hlib.controller.front.shop;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by hlib on 2016/2/25 0025.
*/
@Controller
@RequestMapping(value = "/front/shop/index/")
public class FrontIndexController extends FrontBaseController{
@RequestMapping(value = "show")
public String index(){
return dir + "index";
}
}
| 429 | 0.727273 | 0.701632 | 22 | 18.5 | 21.722946 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.181818 | false | false | 2 |
d42c4a26c423d7cb39e35fd138d47a61993ac5ce | 26,293,789,823,421 | c9d0a5ba06620f5a14669e1a8b06bb5a51f543c1 | /GeneTeX/src/util/Utility.java | 1e3fba347a7d10856137950b7b5d01afa6599ca4 | [] | no_license | MehdiBksr/GeneTeX | https://github.com/MehdiBksr/GeneTeX | dc210bd53754b06b251ad0668c1c130dcf860f55 | 12b60358f438ce221cbe0678b271fe046beefd6d | refs/heads/master | 2020-06-01T15:11:59.991000 | 2013-06-19T13:15:13 | 2013-06-19T13:15:13 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package util;
import java.awt.image.BufferedImage;
import data.PreprocessedImage;
import argument.ArgumentHandler;
/** Utility class, regrouping functions which are potentially useful.
* @author Mehdi BOUKSARA, Théo MERLE, Marceau THALGOTT
*
*/
public class Utility {
/** Prints verbose messages when the verbose option is specified in the
* command line
* @param message The verbose message to be printed
* @param over Boolean indicating if the message is to be printed at the
* end of a specific action.
*/
public static void printVerbose(String message, boolean over) {
ArgumentHandler options = ArgumentHandler.getInstance();
if (options.getVerbose() && over) System.out.println(message);
else if (options.getVerbose()) System.out.print("[Verbose] " + message);
}
/** Reverts the binarisation process by creating a BufferedImage in which
* each pixel represents a pixel of the binarised image : if a given pixel
* is coloured (true), the corresponding pixel in the BufferedImage will
* be set to black.
*
* @param preprocessedImage The PreprocessedImage representing a binarised image.
* @return a BufferedImage representing the binarised image.
*/
public static BufferedImage toBI(PreprocessedImage preprocessedImage) {
BufferedImage bi = new BufferedImage(preprocessedImage.getPixels().length, preprocessedImage.getPixels()[0].length,
BufferedImage.TYPE_INT_ARGB);
// looking the value of each pixel in the binarised image
for (int i = 0; i < preprocessedImage.getPixels().length; i++) {
for (int j = 0; j < preprocessedImage.getPixels()[i].length; j++) {
if (preprocessedImage.getPixels()[i][j])
bi.setRGB(i, j, 0xFF000000);
else
bi.setRGB(i, j, 0xFFFFFFFF);
}
}
return bi;
}
}
| ISO-8859-1 | Java | 1,780 | java | Utility.java | Java | [
{
"context": "functions which are potentially useful.\n * @author Mehdi BOUKSARA, Théo MERLE, Marceau THALGOTT\n *\n */\npublic class",
"end": 213,
"score": 0.9998690485954285,
"start": 199,
"tag": "NAME",
"value": "Mehdi BOUKSARA"
},
{
"context": "are potentially useful.\n * @author... | null | [] | package util;
import java.awt.image.BufferedImage;
import data.PreprocessedImage;
import argument.ArgumentHandler;
/** Utility class, regrouping functions which are potentially useful.
* @author <NAME>, <NAME>, <NAME>
*
*/
public class Utility {
/** Prints verbose messages when the verbose option is specified in the
* command line
* @param message The verbose message to be printed
* @param over Boolean indicating if the message is to be printed at the
* end of a specific action.
*/
public static void printVerbose(String message, boolean over) {
ArgumentHandler options = ArgumentHandler.getInstance();
if (options.getVerbose() && over) System.out.println(message);
else if (options.getVerbose()) System.out.print("[Verbose] " + message);
}
/** Reverts the binarisation process by creating a BufferedImage in which
* each pixel represents a pixel of the binarised image : if a given pixel
* is coloured (true), the corresponding pixel in the BufferedImage will
* be set to black.
*
* @param preprocessedImage The PreprocessedImage representing a binarised image.
* @return a BufferedImage representing the binarised image.
*/
public static BufferedImage toBI(PreprocessedImage preprocessedImage) {
BufferedImage bi = new BufferedImage(preprocessedImage.getPixels().length, preprocessedImage.getPixels()[0].length,
BufferedImage.TYPE_INT_ARGB);
// looking the value of each pixel in the binarised image
for (int i = 0; i < preprocessedImage.getPixels().length; i++) {
for (int j = 0; j < preprocessedImage.getPixels()[i].length; j++) {
if (preprocessedImage.getPixels()[i][j])
bi.setRGB(i, j, 0xFF000000);
else
bi.setRGB(i, j, 0xFFFFFFFF);
}
}
return bi;
}
}
| 1,757 | 0.727937 | 0.721754 | 51 | 33.882355 | 31.044336 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.843137 | false | false | 2 |
f6d00708fd6970647a008f53a1ff10f3efde6fe3 | 16,707,422,849,374 | 7cfc3643eb4df093b0292d1f9c2cae98477411b2 | /src/main/java/com/b/b/h/c.java | 743eb4411adb6e07abd14023a8912bb1f3ba8b14 | [] | no_license | correaj418/PebbleAppGradle | https://github.com/correaj418/PebbleAppGradle | 7f934a2deb3f54fcc21b1c41900dfcb8344c337b | 71b3312b59e9cd5fe7d58cf39212375f73cdcefb | refs/heads/master | 2021-07-11T01:46:36.017000 | 2017-10-13T01:07:02 | 2017-10-13T01:07:02 | 106,761,390 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.b.b.h;
import android.content.Context;
import android.net.Uri;
import com.b.a.b.e;
import com.b.a.b.f;
import com.b.a.c.d;
import com.b.a.m;
import com.b.b.a.b;
import com.b.b.j;
import com.b.b.u.a;
import com.b.b.y;
import java.io.InputStream;
public class c extends k {
public e<b> a(Context context, j jVar, String str, String str2, int i, int i2, boolean z) {
if (str2.startsWith("content:/")) {
return super.a(context, jVar, str, str2, i, i2, z);
}
return null;
}
protected InputStream a(Context context, String str) {
return context.getContentResolver().openInputStream(Uri.parse(str));
}
public e<m> a(j jVar, d dVar, f<a> fVar) {
if (!dVar.d().getScheme().startsWith("content")) {
return null;
}
final e<m> fVar2 = new f();
final j jVar2 = jVar;
final d dVar2 = dVar;
final f<a> fVar3 = fVar;
jVar.e().e().a(new Runnable(this) {
final /* synthetic */ c e;
public void run() {
try {
InputStream openInputStream = jVar2.c().getContentResolver().openInputStream(Uri.parse(dVar2.d().toString()));
if (openInputStream == null) {
throw new Exception("Unable to load content stream");
}
int available = openInputStream.available();
m cVar = new com.b.a.e.c(jVar2.e().e(), openInputStream);
fVar2.b((Object) cVar);
fVar3.a(null, new a(cVar, (long) available, y.LOADED_FROM_CACHE, null, null));
} catch (Exception e) {
fVar2.a(e);
fVar3.a(e, null);
}
}
});
return fVar2;
}
}
| UTF-8 | Java | 1,831 | java | c.java | Java | [] | null | [] | package com.b.b.h;
import android.content.Context;
import android.net.Uri;
import com.b.a.b.e;
import com.b.a.b.f;
import com.b.a.c.d;
import com.b.a.m;
import com.b.b.a.b;
import com.b.b.j;
import com.b.b.u.a;
import com.b.b.y;
import java.io.InputStream;
public class c extends k {
public e<b> a(Context context, j jVar, String str, String str2, int i, int i2, boolean z) {
if (str2.startsWith("content:/")) {
return super.a(context, jVar, str, str2, i, i2, z);
}
return null;
}
protected InputStream a(Context context, String str) {
return context.getContentResolver().openInputStream(Uri.parse(str));
}
public e<m> a(j jVar, d dVar, f<a> fVar) {
if (!dVar.d().getScheme().startsWith("content")) {
return null;
}
final e<m> fVar2 = new f();
final j jVar2 = jVar;
final d dVar2 = dVar;
final f<a> fVar3 = fVar;
jVar.e().e().a(new Runnable(this) {
final /* synthetic */ c e;
public void run() {
try {
InputStream openInputStream = jVar2.c().getContentResolver().openInputStream(Uri.parse(dVar2.d().toString()));
if (openInputStream == null) {
throw new Exception("Unable to load content stream");
}
int available = openInputStream.available();
m cVar = new com.b.a.e.c(jVar2.e().e(), openInputStream);
fVar2.b((Object) cVar);
fVar3.a(null, new a(cVar, (long) available, y.LOADED_FROM_CACHE, null, null));
} catch (Exception e) {
fVar2.a(e);
fVar3.a(e, null);
}
}
});
return fVar2;
}
}
| 1,831 | 0.522665 | 0.513381 | 56 | 31.696428 | 27.075239 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.946429 | false | false | 2 |
3e75ac1dd47f8c62c9cce01304f48b2dd1dfc8a2 | 12,704,513,312,158 | 2219bc5d24700a8e6d7e31909172968b8e648530 | /src/com/hh_dots/Main.java | fa2afd68ecbc9b0f3f8adbed2f31444e4d94b87c | [] | no_license | AlexanderAshin/hh_dots | https://github.com/AlexanderAshin/hh_dots | 09fd73ae9aa4becb768031141783c5c15d442edb | 54e923965c1e6fed8d55efb2771b98f078ca644b | refs/heads/master | 2021-01-13T00:49:12.557000 | 2015-10-07T07:24:24 | 2015-10-07T07:24:24 | 43,764,843 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hh_dots;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n = 0,i,j;
double distance;
Scanner in = new Scanner(System.in);
while (n < 1) {// если значение N меньше 1 - вводим ещё раз
System.out.print("Enter N ");
n = in.nextInt();//ввод N
}
double [][] dotsData= new double[n][4]; //инициализация массива
for(i = 0; i < n; i++)
dotsData[i] = new double[4];
for(i = 0; i < n; i++){ //вод XY и форматирование массива
System.out.printf("X(%d)= ", i+1);
dotsData[i][0] = in.nextDouble(); //X
System.out.printf("Y(%d)= ", i+1);
dotsData[i][1] = in.nextDouble(); //Y
dotsData[i][2] = (n == 1) ? 0 : Double.MAX_VALUE; //«радиус»
dotsData[i][3]=0;//счетчик «соседей»
}
for (i = 0; i<n-1; i++) //расчет «радиусов»
for(j = i+1; j<n; j++){
distance = Math.sqrt(Math.pow(dotsData[j][0] - dotsData[i][0], 2) + Math.pow(dotsData[j][1] - dotsData[i][1], 2));
if(dotsData[i][2] > distance)dotsData[i][2] = distance;
if(dotsData[j][2] > distance)dotsData[j][2] = distance;
}
for (i = 0;i < n-1; i++) //расчет количества «соседей»
for(j = i+1; j<n; j++){
distance = Math.sqrt(Math.pow(dotsData[j][0] - dotsData[i][0], 2) + Math.pow(dotsData[j][1] - dotsData[i][1], 2));
if(dotsData[i][2]*2 >= distance)dotsData[i][3]++;
if(dotsData[j][2]*2 >= distance)dotsData[j][3]++;
}
for (i = 0; i<n; i++) //вывод результатов
System.out.printf("X(%.0f,%.0f) Rad: %.5f CON: %.0f\n",dotsData[i][0], dotsData[i][1], dotsData[i][2], dotsData[i][3]);
}
} | WINDOWS-1251 | Java | 2,001 | java | Main.java | Java | [] | null | [] | package com.hh_dots;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n = 0,i,j;
double distance;
Scanner in = new Scanner(System.in);
while (n < 1) {// если значение N меньше 1 - вводим ещё раз
System.out.print("Enter N ");
n = in.nextInt();//ввод N
}
double [][] dotsData= new double[n][4]; //инициализация массива
for(i = 0; i < n; i++)
dotsData[i] = new double[4];
for(i = 0; i < n; i++){ //вод XY и форматирование массива
System.out.printf("X(%d)= ", i+1);
dotsData[i][0] = in.nextDouble(); //X
System.out.printf("Y(%d)= ", i+1);
dotsData[i][1] = in.nextDouble(); //Y
dotsData[i][2] = (n == 1) ? 0 : Double.MAX_VALUE; //«радиус»
dotsData[i][3]=0;//счетчик «соседей»
}
for (i = 0; i<n-1; i++) //расчет «радиусов»
for(j = i+1; j<n; j++){
distance = Math.sqrt(Math.pow(dotsData[j][0] - dotsData[i][0], 2) + Math.pow(dotsData[j][1] - dotsData[i][1], 2));
if(dotsData[i][2] > distance)dotsData[i][2] = distance;
if(dotsData[j][2] > distance)dotsData[j][2] = distance;
}
for (i = 0;i < n-1; i++) //расчет количества «соседей»
for(j = i+1; j<n; j++){
distance = Math.sqrt(Math.pow(dotsData[j][0] - dotsData[i][0], 2) + Math.pow(dotsData[j][1] - dotsData[i][1], 2));
if(dotsData[i][2]*2 >= distance)dotsData[i][3]++;
if(dotsData[j][2]*2 >= distance)dotsData[j][3]++;
}
for (i = 0; i<n; i++) //вывод результатов
System.out.printf("X(%.0f,%.0f) Rad: %.5f CON: %.0f\n",dotsData[i][0], dotsData[i][1], dotsData[i][2], dotsData[i][3]);
}
} | 2,001 | 0.490494 | 0.461706 | 38 | 47.473682 | 31.546738 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.289474 | false | false | 2 |
20d0943b1b47ba56b697b926607083f573acb6c7 | 17,136,919,563,684 | 42ce17f5adff8c9a24276a2e26303ebfeb6f46e4 | /portfolio-plugin-src/com/atlassian/rm/jpo/issueloading/lucene/issue/querying/explanation/QueryResultMatcher.java | 24632803f5b72e58a8204cbf1e5a5b953ef49206 | [
"Apache-2.0"
] | permissive | tied/jira-5 | https://github.com/tied/jira-5 | 1ffea0533cee2cbf351eda5a9f28380e893baa99 | e7369b9092d730ca7c25622da8da6d2a80973316 | refs/heads/master | 2020-03-11T12:50:11.014000 | 2018-04-04T11:19:00 | 2018-04-04T11:19:00 | 130,008,681 | 1 | 0 | null | true | 2018-04-18T05:30:56 | 2018-04-18T05:30:55 | 2018-04-04T11:19:10 | 2018-04-04T11:19:09 | 13,530 | 0 | 0 | 0 | null | false | null | // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) ansi
// Source File Name: QueryResultMatcher.java
package com.atlassian.rm.jpo.issueloading.lucene.issue.querying.explanation;
import java.util.Collections;
import java.util.Set;
// Referenced classes of package com.atlassian.rm.jpo.issueloading.lucene.issue.querying.explanation:
// ExplainerDocumentMatcher
class QueryResultMatcher
implements ExplainerDocumentMatcher
{
QueryResultMatcher(Set matchedDocuments)
{
this.matchedDocuments = matchedDocuments;
}
public boolean matches(int document)
{
return matchedDocuments.contains(Integer.valueOf(document));
}
public boolean matchesAny(Set documents)
{
return !Collections.disjoint(matchedDocuments, documents);
}
private final Set matchedDocuments;
}
| UTF-8 | Java | 942 | java | QueryResultMatcher.java | Java | [
{
"context": "// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.\n// Jad home page: http://www.kpdus.com/jad.html\n",
"end": 61,
"score": 0.9996659159660339,
"start": 45,
"tag": "NAME",
"value": "Pavel Kouznetsov"
}
] | null | [] | // Decompiled by Jad v1.5.8g. Copyright 2001 <NAME>.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) ansi
// Source File Name: QueryResultMatcher.java
package com.atlassian.rm.jpo.issueloading.lucene.issue.querying.explanation;
import java.util.Collections;
import java.util.Set;
// Referenced classes of package com.atlassian.rm.jpo.issueloading.lucene.issue.querying.explanation:
// ExplainerDocumentMatcher
class QueryResultMatcher
implements ExplainerDocumentMatcher
{
QueryResultMatcher(Set matchedDocuments)
{
this.matchedDocuments = matchedDocuments;
}
public boolean matches(int document)
{
return matchedDocuments.contains(Integer.valueOf(document));
}
public boolean matchesAny(Set documents)
{
return !Collections.disjoint(matchedDocuments, documents);
}
private final Set matchedDocuments;
}
| 932 | 0.738854 | 0.730361 | 34 | 26.705883 | 27.16781 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.235294 | false | false | 2 |
914818ad1440c502b1d4c180f84fc0fbef7a5825 | 33,346,126,126,313 | f62d1696929cd3f9bfe4e5aa396fae5646c6c79b | /app/src/main/java/com/dett/mvvmdemo/net/AppRepository.java | 6a84bd3346d507c6705212fa27710b0958c9313b | [] | no_license | wangjiandett/MVVMDemo | https://github.com/wangjiandett/MVVMDemo | a33bc9fa4c2325dfdc875cbc2b700a0958294128 | e0de58ca86e862aa9e58145c21f99562e3fd3269 | refs/heads/main | 2023-02-23T04:15:40.884000 | 2021-01-26T03:31:01 | 2021-01-26T03:31:01 | 306,188,524 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dett.mvvmdemo.net;
import com.dett.dettmvvm.mvvm.BaseModel;
import com.dett.dettmvvm.mvvm.BaseRepository;
/**
* 自定义AppRepository
*
* @author wangjian
* Created on 2020/11/2 15:13
*/
public class AppRepository extends BaseRepository {
@Override
protected <Response, Data> BaseModel<Response, Data> getBaseModel() {
return (BaseModel<Response, Data>) new BaseModel<BaseResponse<Data>, Data>();
}
}
| UTF-8 | Java | 442 | java | AppRepository.java | Java | [
{
"context": "Repository;\n\n/**\n * 自定义AppRepository\n *\n * @author wangjian\n * Created on 2020/11/2 15:13\n */\npublic class Ap",
"end": 166,
"score": 0.9989216923713684,
"start": 158,
"tag": "USERNAME",
"value": "wangjian"
}
] | null | [] | package com.dett.mvvmdemo.net;
import com.dett.dettmvvm.mvvm.BaseModel;
import com.dett.dettmvvm.mvvm.BaseRepository;
/**
* 自定义AppRepository
*
* @author wangjian
* Created on 2020/11/2 15:13
*/
public class AppRepository extends BaseRepository {
@Override
protected <Response, Data> BaseModel<Response, Data> getBaseModel() {
return (BaseModel<Response, Data>) new BaseModel<BaseResponse<Data>, Data>();
}
}
| 442 | 0.720183 | 0.694954 | 18 | 23.222221 | 25.552898 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 2 |
c5fc8eb0912db95e446eef8b10c21f621f750850 | 12,902,081,823,147 | 9ef5d7bc1e9c180dc533a5c251063bde37a18e51 | /src/com/vc/admin/system/action/EditUploadFileAction.java | e3a532a7dbf8dfae347b18d407a00380738c9de1 | [] | no_license | broSmasher/vc_m | https://github.com/broSmasher/vc_m | 57d93eaada431020ee1dba20aeb686cbb0f64007 | a2599059d5ba03ee05335b14f62a30f2e6c80cc4 | refs/heads/master | 2016-09-14T01:10:23.771000 | 2016-09-12T02:28:23 | 2016-09-12T02:28:23 | 60,224,318 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vc.admin.system.action;
import java.io.File;
import org.apache.struts2.ServletActionContext;
import com.inveno.util.PropertyUtils;
import com.inveno.util.UploadFileUtil;
import com.vc.common.baseclass.BaseAction;
/**
* html编辑器上传文件Action
*
* @author yaoyuan
*
*/
@SuppressWarnings( { "static-access", "serial" })
public class EditUploadFileAction extends BaseAction {
private String uploadContentType;
private File upload;
private String uploadFileName;
private String fileurl;
/**
* 编辑器上传图片
*
* @author 黄豆豆
* @Date 2008-7-4
* @return
*/
public String editUploadFile() {
if (upload != null && uploadContentType.startsWith("image")) {
String filePath = PropertyUtils.getProperty("upload");
String fileName = System.currentTimeMillis() + "0" + uploadFileName;
String fileUrl = filePath + "/product/";
//(2012-12-07 将路径中的大小字符转换成大写 liming修改)
fileurl = UploadFileUtil.uploadFile(upload,fileUrl, fileName.toLowerCase());
String path = ServletActionContext.getServletContext()
.getContextPath();
// 应用名
fileurl = path + fileurl;
}
return this.SUCCESS;
}
/**
* @return the uploadContentType
*/
public String getUploadContentType() {
return uploadContentType;
}
/**
* @param uploadContentType
* the uploadContentType to set
*/
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
/**
* @return the upload
*/
public File getUpload() {
return upload;
}
/**
* @param upload
* the upload to set
*/
public void setUpload(File upload) {
this.upload = upload;
}
/**
* @return the uploadFileName
*/
public String getUploadFileName() {
return uploadFileName;
}
/**
* @param uploadFileName
* the uploadFileName to set
*/
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
/**
* @return the fileurl
*/
public String getFileurl() {
return fileurl;
}
/**
* @param fileurl
* the fileurl to set
*/
public void setFileurl(String fileurl) {
this.fileurl = fileurl;
}
}
| UTF-8 | Java | 2,348 | java | EditUploadFileAction.java | Java | [
{
"context": "n;\r\n\r\n\r\n/**\r\n * html编辑器上传文件Action\r\n * \r\n * @author yaoyuan\r\n * \r\n */\r\n@SuppressWarnings( { \"static-access\", ",
"end": 291,
"score": 0.9994591474533081,
"start": 284,
"tag": "USERNAME",
"value": "yaoyuan"
},
{
"context": " fileurl;\r\n\r\n\t/**\r\n\t ... | null | [] | package com.vc.admin.system.action;
import java.io.File;
import org.apache.struts2.ServletActionContext;
import com.inveno.util.PropertyUtils;
import com.inveno.util.UploadFileUtil;
import com.vc.common.baseclass.BaseAction;
/**
* html编辑器上传文件Action
*
* @author yaoyuan
*
*/
@SuppressWarnings( { "static-access", "serial" })
public class EditUploadFileAction extends BaseAction {
private String uploadContentType;
private File upload;
private String uploadFileName;
private String fileurl;
/**
* 编辑器上传图片
*
* @author 黄豆豆
* @Date 2008-7-4
* @return
*/
public String editUploadFile() {
if (upload != null && uploadContentType.startsWith("image")) {
String filePath = PropertyUtils.getProperty("upload");
String fileName = System.currentTimeMillis() + "0" + uploadFileName;
String fileUrl = filePath + "/product/";
//(2012-12-07 将路径中的大小字符转换成大写 liming修改)
fileurl = UploadFileUtil.uploadFile(upload,fileUrl, fileName.toLowerCase());
String path = ServletActionContext.getServletContext()
.getContextPath();
// 应用名
fileurl = path + fileurl;
}
return this.SUCCESS;
}
/**
* @return the uploadContentType
*/
public String getUploadContentType() {
return uploadContentType;
}
/**
* @param uploadContentType
* the uploadContentType to set
*/
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
/**
* @return the upload
*/
public File getUpload() {
return upload;
}
/**
* @param upload
* the upload to set
*/
public void setUpload(File upload) {
this.upload = upload;
}
/**
* @return the uploadFileName
*/
public String getUploadFileName() {
return uploadFileName;
}
/**
* @param uploadFileName
* the uploadFileName to set
*/
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
/**
* @return the fileurl
*/
public String getFileurl() {
return fileurl;
}
/**
* @param fileurl
* the fileurl to set
*/
public void setFileurl(String fileurl) {
this.fileurl = fileurl;
}
}
| 2,348 | 0.646127 | 0.639085 | 109 | 18.844036 | 19.128813 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.302752 | false | false | 2 |
9082c0e23d755fce9cf303cecdcd6d1495ca85ad | 31,396,210,980,888 | f18df45915b3e5c4b256519bb6dfd7d57afe10fc | /src/main/java/collectivesense/cluster/HierarchicalCluster.java | b0be7d570f8a4fd32b559f901e0a5269966fbc38 | [] | no_license | rkhmelyuk/collective-sense | https://github.com/rkhmelyuk/collective-sense | 9f4b98ede246adc1b99b1a31ed6647e58496e39b | b261be8844ccdd7f4961cff09bd59ed949e7fdf6 | refs/heads/master | 2020-05-18T00:39:29.090000 | 2010-12-24T22:11:37 | 2010-12-24T22:11:37 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package collectivesense.cluster;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
/**
* @author Ruslan Khmelyuk
* @created 2010-12-20
*/
public class HierarchicalCluster {
BiCluster cluster(Map<String, List> matrix, RowsDistance distance) {
final MathContext context = new MathContext(10, RoundingMode.HALF_UP);
Map<List, BigDecimal> distances = new LinkedHashMap<List, BigDecimal>();
int currentClusterId = -1;
List<BiCluster> cluster = new ArrayList<BiCluster>();
int index = 0;
for (Map.Entry<String, List> entry : matrix.entrySet()) {
List<BigDecimal> value = new ArrayList<BigDecimal>(entry.getValue().size());
for (Object val : entry.getValue()) {
value.add(toBigDecimal(val, context));
}
cluster.add(new BiCluster(index++, value));
}
while (cluster.size() > 1) {
List<Integer> lowestPair = Arrays.asList(0, 1);
BigDecimal closest = distance.calculate(cluster.get(0).getVec(), cluster.get(1).getVec());
for (int i = 0; i < cluster.size(); i++) {
for (int j = i+1; j < cluster.size(); j++) {
List key = Arrays.asList(cluster.get(i).getVec(), cluster.get(j).getVec());
if (!distances.containsKey(key)) {
distances.put(key, distance.calculate(cluster.get(i).getVec(), cluster.get(j).getVec()));
}
BigDecimal d = distances.get(key);
if (d.compareTo(closest) < 0) {
closest = d;
lowestPair = Arrays.asList(i, j);
}
}
}
List<BigDecimal> mergeVec = new ArrayList<BigDecimal>();
for (int k = 0; k < cluster.get(0).getVec().size(); k++) {
BigDecimal val = cluster.get(lowestPair.get(0)).getVec().get(k)
.add(cluster.get(lowestPair.get(1)).getVec().get(k))
.divide(new BigDecimal(2), context);
mergeVec.add(val);
}
int lowestPair0 = lowestPair.get(0);
int lowestPair1 = lowestPair.get(1);
BiCluster newCluster = new BiCluster(
currentClusterId, mergeVec,
cluster.get(lowestPair0),
cluster.get(lowestPair1),
closest);
currentClusterId--;
cluster.remove(lowestPair1);
cluster.remove(lowestPair0);
cluster.add(newCluster);
}
return cluster.get(0);
}
private BigDecimal toBigDecimal(Object value, MathContext context) {
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
if (value instanceof Double) {
return new BigDecimal((Double) value, context);
}
if (value instanceof Integer) {
return new BigDecimal((Integer) value, context);
}
return new BigDecimal(value.toString(), context);
}
public void print(Map<String, List> matrix, BiCluster cluster) {
if (cluster != null) {
List<String> labels = new ArrayList<String>(matrix.keySet());
printCluster(cluster, labels, 0);
}
}
private void printCluster(BiCluster cluster, List<String> labels, int level) {
for (int i = 0; i < level; i++) System.out.print(" ");
if (cluster.getId() < 0) {
System.out.println("-");
}
else {
System.out.println(labels.get(cluster.getId()));
}
if (cluster.getLeft() != null) {
printCluster(cluster.getLeft(), labels, level + 1);
}
if (cluster.getRight() != null) {
printCluster(cluster.getRight(), labels, level + 1);
}
}
}
| UTF-8 | Java | 3,968 | java | HierarchicalCluster.java | Java | [
{
"context": ".RoundingMode;\nimport java.util.*;\n\n/**\n * @author Ruslan Khmelyuk\n * @created 2010-12-20\n */\npublic class Hierarchi",
"end": 175,
"score": 0.9998316168785095,
"start": 160,
"tag": "NAME",
"value": "Ruslan Khmelyuk"
}
] | null | [] | package collectivesense.cluster;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
/**
* @author <NAME>
* @created 2010-12-20
*/
public class HierarchicalCluster {
BiCluster cluster(Map<String, List> matrix, RowsDistance distance) {
final MathContext context = new MathContext(10, RoundingMode.HALF_UP);
Map<List, BigDecimal> distances = new LinkedHashMap<List, BigDecimal>();
int currentClusterId = -1;
List<BiCluster> cluster = new ArrayList<BiCluster>();
int index = 0;
for (Map.Entry<String, List> entry : matrix.entrySet()) {
List<BigDecimal> value = new ArrayList<BigDecimal>(entry.getValue().size());
for (Object val : entry.getValue()) {
value.add(toBigDecimal(val, context));
}
cluster.add(new BiCluster(index++, value));
}
while (cluster.size() > 1) {
List<Integer> lowestPair = Arrays.asList(0, 1);
BigDecimal closest = distance.calculate(cluster.get(0).getVec(), cluster.get(1).getVec());
for (int i = 0; i < cluster.size(); i++) {
for (int j = i+1; j < cluster.size(); j++) {
List key = Arrays.asList(cluster.get(i).getVec(), cluster.get(j).getVec());
if (!distances.containsKey(key)) {
distances.put(key, distance.calculate(cluster.get(i).getVec(), cluster.get(j).getVec()));
}
BigDecimal d = distances.get(key);
if (d.compareTo(closest) < 0) {
closest = d;
lowestPair = Arrays.asList(i, j);
}
}
}
List<BigDecimal> mergeVec = new ArrayList<BigDecimal>();
for (int k = 0; k < cluster.get(0).getVec().size(); k++) {
BigDecimal val = cluster.get(lowestPair.get(0)).getVec().get(k)
.add(cluster.get(lowestPair.get(1)).getVec().get(k))
.divide(new BigDecimal(2), context);
mergeVec.add(val);
}
int lowestPair0 = lowestPair.get(0);
int lowestPair1 = lowestPair.get(1);
BiCluster newCluster = new BiCluster(
currentClusterId, mergeVec,
cluster.get(lowestPair0),
cluster.get(lowestPair1),
closest);
currentClusterId--;
cluster.remove(lowestPair1);
cluster.remove(lowestPair0);
cluster.add(newCluster);
}
return cluster.get(0);
}
private BigDecimal toBigDecimal(Object value, MathContext context) {
if (value instanceof BigDecimal) {
return (BigDecimal) value;
}
if (value instanceof Double) {
return new BigDecimal((Double) value, context);
}
if (value instanceof Integer) {
return new BigDecimal((Integer) value, context);
}
return new BigDecimal(value.toString(), context);
}
public void print(Map<String, List> matrix, BiCluster cluster) {
if (cluster != null) {
List<String> labels = new ArrayList<String>(matrix.keySet());
printCluster(cluster, labels, 0);
}
}
private void printCluster(BiCluster cluster, List<String> labels, int level) {
for (int i = 0; i < level; i++) System.out.print(" ");
if (cluster.getId() < 0) {
System.out.println("-");
}
else {
System.out.println(labels.get(cluster.getId()));
}
if (cluster.getLeft() != null) {
printCluster(cluster.getLeft(), labels, level + 1);
}
if (cluster.getRight() != null) {
printCluster(cluster.getRight(), labels, level + 1);
}
}
}
| 3,959 | 0.538306 | 0.528478 | 112 | 34.42857 | 27.60943 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.741071 | false | false | 2 |
ad52376a1c4509966009a25f0dd327b84432d583 | 558,345,786,999 | 55678ea3af1926eb8125a208df32df782c0944fa | /code/src/java/edu/byu/isys413/group1a/intex2/Controllers/TxController.java | 724249536badc3bcef4c23c77c2d571e58c4d6e7 | [] | no_license | Aaronius/intex2 | https://github.com/Aaronius/intex2 | 12e75697e4289bdd8b92bfb9de05d25f3aa0659f | f627d3f28179d4adc5575f92d423ff97158ca4b6 | refs/heads/main | 2023-01-15T14:03:24.186000 | 2020-11-26T19:50:23 | 2020-11-26T19:50:23 | 316,323,305 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.byu.isys413.group1a.intex2.Controllers;
import edu.byu.isys413.group1a.intex2.BOs.Account;
import edu.byu.isys413.group1a.intex2.BOs.Customer;
import edu.byu.isys413.group1a.intex2.BOs.Fee;
import edu.byu.isys413.group1a.intex2.BOs.JournalEntry;
import edu.byu.isys413.group1a.intex2.BOs.JournalEntryContainer;
import edu.byu.isys413.group1a.intex2.BOs.Membership;
import edu.byu.isys413.group1a.intex2.BOs.Payment;
import edu.byu.isys413.group1a.intex2.BOs.Rental;
import edu.byu.isys413.group1a.intex2.BOs.RevenueSource;
import edu.byu.isys413.group1a.intex2.BOs.Store;
import edu.byu.isys413.group1a.intex2.BOs.StoreProduct;
import edu.byu.isys413.group1a.intex2.BOs.Tx;
import edu.byu.isys413.group1a.intex2.BOs.TxLine;
import edu.byu.isys413.group1a.intex2.DAOs.AccountDAO;
import edu.byu.isys413.group1a.intex2.DAOs.FeeDAO;
import edu.byu.isys413.group1a.intex2.DAOs.JournalEntryDAO;
import edu.byu.isys413.group1a.intex2.DAOs.MembershipDAO;
import edu.byu.isys413.group1a.intex2.DAOs.PaymentDAO;
import edu.byu.isys413.group1a.intex2.DAOs.RentalDAO;
import edu.byu.isys413.group1a.intex2.DAOs.RentalVideoDAO;
import edu.byu.isys413.group1a.intex2.DAOs.StoreDAO;
import edu.byu.isys413.group1a.intex2.DAOs.StoreProductDAO;
import edu.byu.isys413.group1a.intex2.DAOs.TxDAO;
import edu.byu.isys413.group1a.intex2.DAOs.TxLineDAO;
import edu.byu.isys413.group1a.intex2.BOs.TxDisplay;
import edu.byu.isys413.group1a.intex2.Misc.ConnectionPool;
import edu.byu.isys413.group1a.intex2.Misc.DataException;
import java.sql.*;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Iterator;
import java.util.Vector;
/**
* Controls a transaction (and possible returns) and its related associations.
*
* @author Group 1A, isys@aaronhardy.com
*/
public class TxController {
private final String STOREID = "0000010942ed61aeb33d203e001000ac00e900c6";
private Customer curCust = null;
private Tx curTx = null;
private TxDisplay txd= null;
private final double TAXPERCENT = .0625;
private double minFeeAmt = 0;
private int actual = 0;
private int allowed = 0;
private Vector tableVector = new Vector();
private JournalEntryContainer jeContainer = new JournalEntryContainer();
/**
* Creates instance of class
*/
public TxController() {
}
/**
* This is a temporary method to sustain our sweet legacy software
*/
public void saveTx(Tx tx, float balPayment) throws Exception{
tx.setBalPayment(balPayment);
saveTx(tx);
}
/**
* Save Transaction without connection passed in
*/
public void saveTx(Tx tx) throws Exception{
Connection conn = ConnectionPool.getInstance().get();
saveTx(tx, conn);
ConnectionPool.getInstance().release(conn);
}
/**
* Save Transaction
*/
public void saveTx(Tx tx, Connection conn) throws Exception{
try {
//curTx.setStore(StoreDAO.getInstance().read(STOREID));
savePayment(tx.getPayment(), conn);
adjustAccount(tx.getCustomer().getAccount(),tx.getBalPayment(), conn);
adjustTxLineAssociations(tx, conn);
addTxLevelJEs(tx);
jeContainer.saveJournalEntries(conn);
TxDAO.getInstance().save(tx, conn);
// if tx is from fee, cash was paid and cash JE should be made
conn.commit();
}catch (Exception e) {
try{
conn.rollback();
}catch (SQLException e2) {
e.printStackTrace();
throw new DataException("Could not roll back the database transaction!", e2);
}
e.printStackTrace();
throw new DataException("An error occurred while saving the transaction.", e);
}
}
/**
* Adjust associations of specific txLine type
*/
private void adjustTxLineAssociations(Tx tx, Connection conn) throws Exception{
List<TxLine> txLines = tx.getTxLines();//?
// For each transaction line
for (Iterator<TxLine> iter = txLines.iterator(); iter.hasNext();){
TxLine txLine = iter.next();
TxLineDAO.getInstance().save(txLine,conn);
// Set up JE for txLine
JournalEntry journalEntry = JournalEntryDAO.getInstance().create();
switch (txLine.getSerialNum().length()) {
case 2: // Membership
Membership mem = (Membership)txLine.getRevenueSource();
mem.setAccount(tx.getCustomer().getAccount());
MembershipDAO.getInstance().save(mem, conn);
Account curAcct = tx.getCustomer().getAccount();
curAcct.setMembership(mem);
jeContainer.addMembershipJE(tx, txLine);
break;
case 4: // Fee
FeeDAO.getInstance().save((Fee)txLine.getRevenueSource(),conn);
//This occurs because a fee does not have a payment
Account acct = tx.getCustomer().getAccount();
acct.setBalance(acct.getBalance() + tx.getTotal());
AccountDAO.getInstance().save(acct, conn);
jeContainer.addFeeJE(tx, txLine);
break;
case 8: // Rental
adjustRentalInfo((Rental)txLine.getRevenueSource(), conn);
jeContainer.addRentalJE(tx, txLine);
break;
case 12: // Product
// Note: This subtracts a negative if its a returned product - all good.
adjustQOH(tx.getStore(),txLine.getRevenueSource(), txLine.getQuantity(), conn);
jeContainer.addProductJE(tx, txLine);
break;
}
}
}
/**
* Adjusts the Quantity on Hand when a transaction is saved
*/
private void adjustQOH(Store store, RevenueSource revenueSource, int quantity, Connection conn) throws Exception{
StoreProduct sp = StoreProductDAO.getInstance().readByForeign(store.getId(), revenueSource.getId(), conn);
sp.setQtyOnHand(sp.getQtyOnHand()-quantity);
StoreProductDAO.getInstance().save(sp, conn);
}
/**
* Adjusts the Rental Info when a transaction is saved
*/
private void adjustRentalInfo(Rental rental, Connection conn) throws Exception{
RentalDAO.getInstance().save(rental, conn);
rental.getRentalVideo().setStatus("out");
RentalVideoDAO.getInstance().save(rental.getRentalVideo(), conn);
}
/**
* Adjusts the Account Info when a transaction is saved
*/
private void adjustAccount(Account acct, float balPayment, Connection conn) throws Exception{
acct.setBalance(acct.getBalance()-balPayment);
AccountDAO.getInstance().save(acct, conn);
}
/**
* Saves a Payment record
*/
private void savePayment(Payment payment, Connection conn) throws Exception{
PaymentDAO.getInstance().save(payment, conn);
}
/**
* Saves tx related JEs
*/
private void addTxLevelJEs(Tx tx) throws Exception{
if (tx.getPayment().getAmtTendered() > 0){ // If there's a payment, we're going to debit cash
jeContainer.addCashDebitJE(tx);
// If some previous balance is paid off, we must credit A/R for that amount
if (tx.getBalPayment() > 0){
jeContainer.addBalancePaymentJE(tx);
}
} else { // If there's no payment, it must be fee - add A/R debit JE
jeContainer.addAccountsReceivableDebitJE(tx);
}
jeContainer.addTaxPayableJE(tx);
}
/**
* Initializes a new transaction for a customer
*/
public void newTx(Customer cust) throws Exception{
try{
curTx = TxDAO.getInstance().create();
curTx.setCustomer(cust);
this.curCust = cust;
txd = new TxDisplay();
} catch(Exception e){
throw new DataException("An error occurred while creating a new transaction");
}
try {
minFeeAmt = Double.parseDouble(StoreDAO.getInstance().read(STOREID).getPayMinFeeAmt().toString());
}catch(Exception e){
throw new DataException("The store database could not be accessed");
}
}
/**
* Returns the GUI information for a transaction
*/
public TxDisplay getTxDisplay(){
return txd;
}
/**
* Sets the GUI information for a transaction
*/
public void setTxDisplay(TxDisplay txd){
this.txd = txd;
}
/**
* Returns the Vector representation of the table for a previous
* transaction of a return
*/
public Vector getVector(Tx tx){
List<TxLine> txLines = tx.getTxLines();
Vector txVector = new Vector();
for (int i = 0; i < txLines.size(); i++){
TxLine txLine = txLines.get(i);
String serialNum = txLine.getSerialNum();
Vector blankRow = new Vector();
blankRow.add(0, txLine.getQuantity());
blankRow.add(1, txLine.getRevenueSource().getDescription());
blankRow.add(2, txLine.getSerialNum());
//checks to make sure the sku # is 8 digits, which means the item is a rental not a product or something else
if(serialNum.length() == 8){
blankRow.add(3, txLine.getDueDate());
}else{
blankRow.add(3, "");
}
DecimalFormat fmt = new DecimalFormat("0.00");
blankRow.add(4, fmt.format(txLine.getSubTotal()));
txVector.add(blankRow);//table.insertRow(0, (Vector)blankRow);
}
return txVector;
}
/**
* Generates the Vector representation of a table for a transaction
*/
public void createTableVector(){
tableVector.clear();
List<TxLine> lines = curTx.getTxLines();
for(int i = 0; i < lines.size(); i++){
TxLine txLine = lines.get(i);
Vector blankRow = new Vector();
blankRow.add(0, txLine.getQuantity());
blankRow.add(1, txLine.getRevenueSource().getDescription());
blankRow.add(2, txLine.getSerialNum());
//checks to make sure the sku # is 8 digits, which means the item is a rental not a product or something else
if(txLine.getSerialNum().length() == 8){
blankRow.add(3, txLine.getDueDate());
}else{
blankRow.add(3, "");
}
DecimalFormat fmt = new DecimalFormat("0.00");
blankRow.add(4, fmt.format(txLine.getSubTotal()));
tableVector.add(blankRow);//table.insertRow(0, (Vector)blankRow);
}
}
/**
* Adds a transaction line to the table and returns the Vector
* representation of the table
*/
public Vector addTransactionLine(String serialNum, String quantity) throws Exception{//Vector should be stored
// Make sure serial number was entered
if (serialNum.equals("")){
throw new DataException("You must enter a sku/serial to add the transaction line item.");
}
// If membership, rental, or product, add txline
if (serialNum.length() == 2 || serialNum.length() == 8 || serialNum.length() == 12){
TxLine txLine = curTx.newTxLine(Integer.parseInt(quantity), serialNum, STOREID);
calculateTaxSubTotals();
calculateTotal();
} else{
throw new DataException("You must enter a rental serial of 8 digits\n or a product sku of 12 digits to add the transaction line item");
}
//Create Table Vector
createTableVector();
return tableVector;
}
/**
* Removes a transaction line from the table and returns the Vector
* representation of the table
*/
public Vector removeTransactionLine(int num){
curTx.removeTxLine(num);
createTableVector();
return tableVector;
}
/**
* Formats the variables to have two decimal places
**/
private double formatDisplay(double value){
DecimalFormat fmt = new DecimalFormat("0.00");
return Double.parseDouble(fmt.format(value));
}
/**
* Calculates the final total and sets value in txDisplay
*/
public void calculateTotal(){//Pass table object
double total = 0.00;
//calculates the total and prints it
total = txd.getTax() + txd.getSubTotal() + txd.getBalancePayment();
total = formatDisplay(total);
txd.setTotal(total);
txd.setPayment(total);
txd.setChange(0);
}
/**
* Calculates the total paid and sets value in txDisplay
*/
public void calculateTotalPaid(){//Pass table object
double total = 0.00;
//calculates the total and prints it
total = txd.getTax() + txd.getSubTotal() + txd.getBalancePayment();
txd.setTotal(formatDisplay(total));
txd.setChange(txd.getPayment()-txd.getTotal());
}
/**
* Calculates the subTotal and sets value in txDisplay
*/
public void calculateTaxSubTotals(){
double subTotal = 0, tax = 0, price = 0;
String priceString = " ", taxString;
//checks to make sure there are rows
if (tableVector.size() >= 0){
//loops through the rows and gets the prices to calculate the subtotal
for (int counter = 0; counter < tableVector.size(); counter++){
price = Double.parseDouble(((Vector)tableVector.get(counter)).get(4).toString());
subTotal += price;
}
tax = subTotal * TAXPERCENT;
DecimalFormat fmt = new DecimalFormat("0.00");
taxString = fmt.format(tax);
tax = Double.parseDouble(taxString);
}
txd.setSubTotal(subTotal);
txd.setTax(tax);
}
/**
* Calculates the minimum balance due and sets value in txDisplay
*/
public void calculateMinBalance(){
double accountBalance = 0.00, minBalanceDue = 0.00;
//Calculates a minimum amount due so the outstanding balance is never greater than $5.00
txd.setBalance(curCust.getAccount().getBalance());
if (txd.getBalance() > minFeeAmt){
//make them pay X => accountBalance - X = minFeeAmt usually minFeeAmt = $5.00
//minBalanceDue = accountBalance - minFeeAmt;
txd.setMinAmtDue((txd.getBalance() - minFeeAmt));
} else{
txd.setMinAmtDue(0);
}
txd.setPayment(txd.getBalance());
txd.setBalancePayment(txd.getBalance());
}
/**
* Creates a payment record
*/
public void makePayment() throws Exception{
try{
Payment payment = PaymentDAO.getInstance().create();
payment.setAmount((float)txd.getTotal());
payment.setAmtTendered((float)txd.getPayment());
payment.setChange((float)txd.getChange());
curTx.setPayment(payment);
curTx.setTax((float)txd.getTax());
curTx.setTotal((float)txd.getTotal());
curTx.setStore(StoreDAO.getInstance().read(STOREID));
try {
saveTx(curTx, (float)txd.getBalancePayment());
} catch (Exception e) {
e.printStackTrace();
throw new DataException("There was an error while processing the transaction");
}
} catch (Exception e){
e.printStackTrace();
throw new DataException(e.getMessage());
}
}
/**
* Looks up a transaction from a transaction number
*/
public Tx lookupTx(String txNum) throws Exception{
curTx = TxDAO.getInstance().read(txNum);
return curTx;
}
/**
* Sets current customer
*/
public Customer getCust(){
return curCust;
}
/**
* Sets current customer
*/
public void setCust(Customer cust){
this.curCust = cust;
}
}
| UTF-8 | Java | 14,986 | java | TxController.java | Java | [
{
"context": " its related associations.\n *\n * @author Group 1A, isys@aaronhardy.com\n */\npublic class TxController {\n \n private fina",
"end": 1769,
"score": 0.9999268651008606,
"start": 1750,
"tag": "EMAIL",
"value": "isys@aaronhardy.com"
}
] | null | [] | package edu.byu.isys413.group1a.intex2.Controllers;
import edu.byu.isys413.group1a.intex2.BOs.Account;
import edu.byu.isys413.group1a.intex2.BOs.Customer;
import edu.byu.isys413.group1a.intex2.BOs.Fee;
import edu.byu.isys413.group1a.intex2.BOs.JournalEntry;
import edu.byu.isys413.group1a.intex2.BOs.JournalEntryContainer;
import edu.byu.isys413.group1a.intex2.BOs.Membership;
import edu.byu.isys413.group1a.intex2.BOs.Payment;
import edu.byu.isys413.group1a.intex2.BOs.Rental;
import edu.byu.isys413.group1a.intex2.BOs.RevenueSource;
import edu.byu.isys413.group1a.intex2.BOs.Store;
import edu.byu.isys413.group1a.intex2.BOs.StoreProduct;
import edu.byu.isys413.group1a.intex2.BOs.Tx;
import edu.byu.isys413.group1a.intex2.BOs.TxLine;
import edu.byu.isys413.group1a.intex2.DAOs.AccountDAO;
import edu.byu.isys413.group1a.intex2.DAOs.FeeDAO;
import edu.byu.isys413.group1a.intex2.DAOs.JournalEntryDAO;
import edu.byu.isys413.group1a.intex2.DAOs.MembershipDAO;
import edu.byu.isys413.group1a.intex2.DAOs.PaymentDAO;
import edu.byu.isys413.group1a.intex2.DAOs.RentalDAO;
import edu.byu.isys413.group1a.intex2.DAOs.RentalVideoDAO;
import edu.byu.isys413.group1a.intex2.DAOs.StoreDAO;
import edu.byu.isys413.group1a.intex2.DAOs.StoreProductDAO;
import edu.byu.isys413.group1a.intex2.DAOs.TxDAO;
import edu.byu.isys413.group1a.intex2.DAOs.TxLineDAO;
import edu.byu.isys413.group1a.intex2.BOs.TxDisplay;
import edu.byu.isys413.group1a.intex2.Misc.ConnectionPool;
import edu.byu.isys413.group1a.intex2.Misc.DataException;
import java.sql.*;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Iterator;
import java.util.Vector;
/**
* Controls a transaction (and possible returns) and its related associations.
*
* @author Group 1A, <EMAIL>
*/
public class TxController {
private final String STOREID = "0000010942ed61aeb33d203e001000ac00e900c6";
private Customer curCust = null;
private Tx curTx = null;
private TxDisplay txd= null;
private final double TAXPERCENT = .0625;
private double minFeeAmt = 0;
private int actual = 0;
private int allowed = 0;
private Vector tableVector = new Vector();
private JournalEntryContainer jeContainer = new JournalEntryContainer();
/**
* Creates instance of class
*/
public TxController() {
}
/**
* This is a temporary method to sustain our sweet legacy software
*/
public void saveTx(Tx tx, float balPayment) throws Exception{
tx.setBalPayment(balPayment);
saveTx(tx);
}
/**
* Save Transaction without connection passed in
*/
public void saveTx(Tx tx) throws Exception{
Connection conn = ConnectionPool.getInstance().get();
saveTx(tx, conn);
ConnectionPool.getInstance().release(conn);
}
/**
* Save Transaction
*/
public void saveTx(Tx tx, Connection conn) throws Exception{
try {
//curTx.setStore(StoreDAO.getInstance().read(STOREID));
savePayment(tx.getPayment(), conn);
adjustAccount(tx.getCustomer().getAccount(),tx.getBalPayment(), conn);
adjustTxLineAssociations(tx, conn);
addTxLevelJEs(tx);
jeContainer.saveJournalEntries(conn);
TxDAO.getInstance().save(tx, conn);
// if tx is from fee, cash was paid and cash JE should be made
conn.commit();
}catch (Exception e) {
try{
conn.rollback();
}catch (SQLException e2) {
e.printStackTrace();
throw new DataException("Could not roll back the database transaction!", e2);
}
e.printStackTrace();
throw new DataException("An error occurred while saving the transaction.", e);
}
}
/**
* Adjust associations of specific txLine type
*/
private void adjustTxLineAssociations(Tx tx, Connection conn) throws Exception{
List<TxLine> txLines = tx.getTxLines();//?
// For each transaction line
for (Iterator<TxLine> iter = txLines.iterator(); iter.hasNext();){
TxLine txLine = iter.next();
TxLineDAO.getInstance().save(txLine,conn);
// Set up JE for txLine
JournalEntry journalEntry = JournalEntryDAO.getInstance().create();
switch (txLine.getSerialNum().length()) {
case 2: // Membership
Membership mem = (Membership)txLine.getRevenueSource();
mem.setAccount(tx.getCustomer().getAccount());
MembershipDAO.getInstance().save(mem, conn);
Account curAcct = tx.getCustomer().getAccount();
curAcct.setMembership(mem);
jeContainer.addMembershipJE(tx, txLine);
break;
case 4: // Fee
FeeDAO.getInstance().save((Fee)txLine.getRevenueSource(),conn);
//This occurs because a fee does not have a payment
Account acct = tx.getCustomer().getAccount();
acct.setBalance(acct.getBalance() + tx.getTotal());
AccountDAO.getInstance().save(acct, conn);
jeContainer.addFeeJE(tx, txLine);
break;
case 8: // Rental
adjustRentalInfo((Rental)txLine.getRevenueSource(), conn);
jeContainer.addRentalJE(tx, txLine);
break;
case 12: // Product
// Note: This subtracts a negative if its a returned product - all good.
adjustQOH(tx.getStore(),txLine.getRevenueSource(), txLine.getQuantity(), conn);
jeContainer.addProductJE(tx, txLine);
break;
}
}
}
/**
* Adjusts the Quantity on Hand when a transaction is saved
*/
private void adjustQOH(Store store, RevenueSource revenueSource, int quantity, Connection conn) throws Exception{
StoreProduct sp = StoreProductDAO.getInstance().readByForeign(store.getId(), revenueSource.getId(), conn);
sp.setQtyOnHand(sp.getQtyOnHand()-quantity);
StoreProductDAO.getInstance().save(sp, conn);
}
/**
* Adjusts the Rental Info when a transaction is saved
*/
private void adjustRentalInfo(Rental rental, Connection conn) throws Exception{
RentalDAO.getInstance().save(rental, conn);
rental.getRentalVideo().setStatus("out");
RentalVideoDAO.getInstance().save(rental.getRentalVideo(), conn);
}
/**
* Adjusts the Account Info when a transaction is saved
*/
private void adjustAccount(Account acct, float balPayment, Connection conn) throws Exception{
acct.setBalance(acct.getBalance()-balPayment);
AccountDAO.getInstance().save(acct, conn);
}
/**
* Saves a Payment record
*/
private void savePayment(Payment payment, Connection conn) throws Exception{
PaymentDAO.getInstance().save(payment, conn);
}
/**
* Saves tx related JEs
*/
private void addTxLevelJEs(Tx tx) throws Exception{
if (tx.getPayment().getAmtTendered() > 0){ // If there's a payment, we're going to debit cash
jeContainer.addCashDebitJE(tx);
// If some previous balance is paid off, we must credit A/R for that amount
if (tx.getBalPayment() > 0){
jeContainer.addBalancePaymentJE(tx);
}
} else { // If there's no payment, it must be fee - add A/R debit JE
jeContainer.addAccountsReceivableDebitJE(tx);
}
jeContainer.addTaxPayableJE(tx);
}
/**
* Initializes a new transaction for a customer
*/
public void newTx(Customer cust) throws Exception{
try{
curTx = TxDAO.getInstance().create();
curTx.setCustomer(cust);
this.curCust = cust;
txd = new TxDisplay();
} catch(Exception e){
throw new DataException("An error occurred while creating a new transaction");
}
try {
minFeeAmt = Double.parseDouble(StoreDAO.getInstance().read(STOREID).getPayMinFeeAmt().toString());
}catch(Exception e){
throw new DataException("The store database could not be accessed");
}
}
/**
* Returns the GUI information for a transaction
*/
public TxDisplay getTxDisplay(){
return txd;
}
/**
* Sets the GUI information for a transaction
*/
public void setTxDisplay(TxDisplay txd){
this.txd = txd;
}
/**
* Returns the Vector representation of the table for a previous
* transaction of a return
*/
public Vector getVector(Tx tx){
List<TxLine> txLines = tx.getTxLines();
Vector txVector = new Vector();
for (int i = 0; i < txLines.size(); i++){
TxLine txLine = txLines.get(i);
String serialNum = txLine.getSerialNum();
Vector blankRow = new Vector();
blankRow.add(0, txLine.getQuantity());
blankRow.add(1, txLine.getRevenueSource().getDescription());
blankRow.add(2, txLine.getSerialNum());
//checks to make sure the sku # is 8 digits, which means the item is a rental not a product or something else
if(serialNum.length() == 8){
blankRow.add(3, txLine.getDueDate());
}else{
blankRow.add(3, "");
}
DecimalFormat fmt = new DecimalFormat("0.00");
blankRow.add(4, fmt.format(txLine.getSubTotal()));
txVector.add(blankRow);//table.insertRow(0, (Vector)blankRow);
}
return txVector;
}
/**
* Generates the Vector representation of a table for a transaction
*/
public void createTableVector(){
tableVector.clear();
List<TxLine> lines = curTx.getTxLines();
for(int i = 0; i < lines.size(); i++){
TxLine txLine = lines.get(i);
Vector blankRow = new Vector();
blankRow.add(0, txLine.getQuantity());
blankRow.add(1, txLine.getRevenueSource().getDescription());
blankRow.add(2, txLine.getSerialNum());
//checks to make sure the sku # is 8 digits, which means the item is a rental not a product or something else
if(txLine.getSerialNum().length() == 8){
blankRow.add(3, txLine.getDueDate());
}else{
blankRow.add(3, "");
}
DecimalFormat fmt = new DecimalFormat("0.00");
blankRow.add(4, fmt.format(txLine.getSubTotal()));
tableVector.add(blankRow);//table.insertRow(0, (Vector)blankRow);
}
}
/**
* Adds a transaction line to the table and returns the Vector
* representation of the table
*/
public Vector addTransactionLine(String serialNum, String quantity) throws Exception{//Vector should be stored
// Make sure serial number was entered
if (serialNum.equals("")){
throw new DataException("You must enter a sku/serial to add the transaction line item.");
}
// If membership, rental, or product, add txline
if (serialNum.length() == 2 || serialNum.length() == 8 || serialNum.length() == 12){
TxLine txLine = curTx.newTxLine(Integer.parseInt(quantity), serialNum, STOREID);
calculateTaxSubTotals();
calculateTotal();
} else{
throw new DataException("You must enter a rental serial of 8 digits\n or a product sku of 12 digits to add the transaction line item");
}
//Create Table Vector
createTableVector();
return tableVector;
}
/**
* Removes a transaction line from the table and returns the Vector
* representation of the table
*/
public Vector removeTransactionLine(int num){
curTx.removeTxLine(num);
createTableVector();
return tableVector;
}
/**
* Formats the variables to have two decimal places
**/
private double formatDisplay(double value){
DecimalFormat fmt = new DecimalFormat("0.00");
return Double.parseDouble(fmt.format(value));
}
/**
* Calculates the final total and sets value in txDisplay
*/
public void calculateTotal(){//Pass table object
double total = 0.00;
//calculates the total and prints it
total = txd.getTax() + txd.getSubTotal() + txd.getBalancePayment();
total = formatDisplay(total);
txd.setTotal(total);
txd.setPayment(total);
txd.setChange(0);
}
/**
* Calculates the total paid and sets value in txDisplay
*/
public void calculateTotalPaid(){//Pass table object
double total = 0.00;
//calculates the total and prints it
total = txd.getTax() + txd.getSubTotal() + txd.getBalancePayment();
txd.setTotal(formatDisplay(total));
txd.setChange(txd.getPayment()-txd.getTotal());
}
/**
* Calculates the subTotal and sets value in txDisplay
*/
public void calculateTaxSubTotals(){
double subTotal = 0, tax = 0, price = 0;
String priceString = " ", taxString;
//checks to make sure there are rows
if (tableVector.size() >= 0){
//loops through the rows and gets the prices to calculate the subtotal
for (int counter = 0; counter < tableVector.size(); counter++){
price = Double.parseDouble(((Vector)tableVector.get(counter)).get(4).toString());
subTotal += price;
}
tax = subTotal * TAXPERCENT;
DecimalFormat fmt = new DecimalFormat("0.00");
taxString = fmt.format(tax);
tax = Double.parseDouble(taxString);
}
txd.setSubTotal(subTotal);
txd.setTax(tax);
}
/**
* Calculates the minimum balance due and sets value in txDisplay
*/
public void calculateMinBalance(){
double accountBalance = 0.00, minBalanceDue = 0.00;
//Calculates a minimum amount due so the outstanding balance is never greater than $5.00
txd.setBalance(curCust.getAccount().getBalance());
if (txd.getBalance() > minFeeAmt){
//make them pay X => accountBalance - X = minFeeAmt usually minFeeAmt = $5.00
//minBalanceDue = accountBalance - minFeeAmt;
txd.setMinAmtDue((txd.getBalance() - minFeeAmt));
} else{
txd.setMinAmtDue(0);
}
txd.setPayment(txd.getBalance());
txd.setBalancePayment(txd.getBalance());
}
/**
* Creates a payment record
*/
public void makePayment() throws Exception{
try{
Payment payment = PaymentDAO.getInstance().create();
payment.setAmount((float)txd.getTotal());
payment.setAmtTendered((float)txd.getPayment());
payment.setChange((float)txd.getChange());
curTx.setPayment(payment);
curTx.setTax((float)txd.getTax());
curTx.setTotal((float)txd.getTotal());
curTx.setStore(StoreDAO.getInstance().read(STOREID));
try {
saveTx(curTx, (float)txd.getBalancePayment());
} catch (Exception e) {
e.printStackTrace();
throw new DataException("There was an error while processing the transaction");
}
} catch (Exception e){
e.printStackTrace();
throw new DataException(e.getMessage());
}
}
/**
* Looks up a transaction from a transaction number
*/
public Tx lookupTx(String txNum) throws Exception{
curTx = TxDAO.getInstance().read(txNum);
return curTx;
}
/**
* Sets current customer
*/
public Customer getCust(){
return curCust;
}
/**
* Sets current customer
*/
public void setCust(Customer cust){
this.curCust = cust;
}
}
| 14,974 | 0.661017 | 0.644268 | 465 | 31.227957 | 26.601553 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.582796 | false | false | 2 |
84b2d933b814083587e823f89601f2863e5286d9 | 13,821,204,822,868 | 10bf277e335239334409c63d5d48596e008695e9 | /src/struts/register/RegisterAction.java | a7f4bb5b7709f78f56f3b94de739c051601247ea | [] | no_license | 102400/vcb | https://github.com/102400/vcb | 247ca69274f9ba6c944b0c3aeca3339383c0b9be | f88b93926a4f2c8e9e9b87131b4bb75dbd0b04e5 | refs/heads/master | 2021-01-11T14:13:54.971000 | 2017-10-23T02:12:31 | 2017-10-23T02:12:31 | 81,205,238 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package struts.register;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import entity.Location;
import entity.User;
import rule.Email;
import rule.Nickname;
import rule.Password;
import rule.Username;
import service.RegisterService;
import util.MD5;
public class RegisterAction extends ActionSupport {
private String nickname;
private String username;
private String email;
private String password;
private String locationName;
private double n; //纬度
private double e; //经度
private String captcha;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public double getN() {
return n;
}
public void setN(double n) {
this.n = n;
}
public double getE() {
return e;
}
public void setE(double e) {
this.e = e;
}
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
if(nickname==null) { //什么都没填
return reload();
}
HttpSession session = ServletActionContext.getRequest().getSession();
final String CAPTCHA = (String)session.getAttribute("CAPTCHA");
// System.out.println(CAPTCHA + ":" + captcha);
if(CAPTCHA==null||!CAPTCHA.equals(captcha)) {
return reload();
}
System.out.println("a");
if(n>90||n<-90||e>180||e<-180) { //经纬度合法检测
return reload();
}
System.out.println("b");
if("".equals(locationName)) {
return reload();
}
System.out.println("c");
if(!(new Email(email).isLegal()
&&new Nickname(nickname).isLegal()
&&new Password(password).isLegal()
&&new Username(username).isLegal())) {
return reload();
}
System.out.println("d");
System.out.println(this);
User user = new User();
user.setUserNickname(nickname);
user.setUserName(username);
user.setUserEmail(email);
user.setUserPasswordMd5(MD5.code(password));
Location location = new Location();
location.setName(locationName);
location.setN(n);
location.setE(e);
RegisterService registerService = new RegisterService();
boolean isSuccess = registerService.tryToRegister(user, location);
if(isSuccess) {
ActionContext.getContext().put("message", "注册成功,请登录");
return "registerSuccess";
}
return reload();
}
private String reload() {
return "reload";
}
@Override
public String toString() {
return "RegisterAction [nickname=" + nickname + ", username=" + username + ", email=" + email + ", password="
+ password + ", n=" + n + ", e=" + e + ", captcha=" + captcha + "]";
}
}
| UTF-8 | Java | 3,328 | java | RegisterAction.java | Java | [
{
"context": "ckname;\n\t}\n\tpublic String getUsername() {\n\t\treturn username;\n\t}\n\tpublic void setUsername(String username) {\n\t",
"end": 827,
"score": 0.9347693920135498,
"start": 819,
"tag": "USERNAME",
"value": "username"
},
{
"context": "d setUsername(String username) {\n... | null | [] | package struts.register;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import entity.Location;
import entity.User;
import rule.Email;
import rule.Nickname;
import rule.Password;
import rule.Username;
import service.RegisterService;
import util.MD5;
public class RegisterAction extends ActionSupport {
private String nickname;
private String username;
private String email;
private String password;
private String locationName;
private double n; //纬度
private double e; //经度
private String captcha;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public double getN() {
return n;
}
public void setN(double n) {
this.n = n;
}
public double getE() {
return e;
}
public void setE(double e) {
this.e = e;
}
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
if(nickname==null) { //什么都没填
return reload();
}
HttpSession session = ServletActionContext.getRequest().getSession();
final String CAPTCHA = (String)session.getAttribute("CAPTCHA");
// System.out.println(CAPTCHA + ":" + captcha);
if(CAPTCHA==null||!CAPTCHA.equals(captcha)) {
return reload();
}
System.out.println("a");
if(n>90||n<-90||e>180||e<-180) { //经纬度合法检测
return reload();
}
System.out.println("b");
if("".equals(locationName)) {
return reload();
}
System.out.println("c");
if(!(new Email(email).isLegal()
&&new Nickname(nickname).isLegal()
&&new Password(password).isLegal()
&&new Username(username).isLegal())) {
return reload();
}
System.out.println("d");
System.out.println(this);
User user = new User();
user.setUserNickname(nickname);
user.setUserName(username);
user.setUserEmail(email);
user.setUserPasswordMd5(MD5.code(password));
Location location = new Location();
location.setName(locationName);
location.setN(n);
location.setE(e);
RegisterService registerService = new RegisterService();
boolean isSuccess = registerService.tryToRegister(user, location);
if(isSuccess) {
ActionContext.getContext().put("message", "注册成功,请登录");
return "registerSuccess";
}
return reload();
}
private String reload() {
return "reload";
}
@Override
public String toString() {
return "RegisterAction [nickname=" + nickname + ", username=" + username + ", email=" + email + ", password="
+ <PASSWORD> + ", n=" + n + ", e=" + e + ", captcha=" + captcha + "]";
}
}
| 3,330 | 0.692566 | 0.68769 | 145 | 21.634483 | 18.70785 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 2 |
c77c7cd02e246ea9b2426e90dfc5d42405744760 | 36,481,452,222,256 | 387733ad112887b13a0e104b714e1a02870caa1a | /JavaFiles/InternationalisationI18N/src/kDateFormat.java | 2c4a300b75f1398f76333954f6bd86d84340e8a5 | [] | no_license | vikas19931265/Coding | https://github.com/vikas19931265/Coding | 52d17ebbfc07286ae2d11f23491e5af3ca68a934 | 5391a28d9a1202f05dfe06ad67860d9c3606cb64 | refs/heads/master | 2021-01-06T09:46:17.050000 | 2020-03-02T18:10:33 | 2020-03-02T18:10:33 | 241,179,848 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
DateFormat
======================
Various locations follows various styles to represent the date
Example
IN : DD-MM-YYYY
US : MM-DD-YYYY
you can use DateFormat to format java date according to a particular a locale
DateFormat class is present in java.text package and it is an abstract class.
DateFormat df = new DateFormat(); // invalid as DateFormat is an abstract class
Getting DateFormat object for the default locale
=======================================================
public static DateFormat getInstance()
public static DateFormat getDateInstance()
public static DateFormat getDateInstance(int style)
The allowed styles are 0 to 3
DateFormat.FULL--->0------>wedenesday 10th september 2014
DateFormat.LONG--->1------>10th september 2014
DateFormat.MEDIUM--->2---->10th sep 2014
DateFormat.SHORT--->3------>10|09|14
note: The default style is medium style
*/ | UTF-8 | Java | 899 | java | kDateFormat.java | Java | [] | null | [] | /*
DateFormat
======================
Various locations follows various styles to represent the date
Example
IN : DD-MM-YYYY
US : MM-DD-YYYY
you can use DateFormat to format java date according to a particular a locale
DateFormat class is present in java.text package and it is an abstract class.
DateFormat df = new DateFormat(); // invalid as DateFormat is an abstract class
Getting DateFormat object for the default locale
=======================================================
public static DateFormat getInstance()
public static DateFormat getDateInstance()
public static DateFormat getDateInstance(int style)
The allowed styles are 0 to 3
DateFormat.FULL--->0------>wedenesday 10th september 2014
DateFormat.LONG--->1------>10th september 2014
DateFormat.MEDIUM--->2---->10th sep 2014
DateFormat.SHORT--->3------>10|09|14
note: The default style is medium style
*/ | 899 | 0.684093 | 0.650723 | 39 | 22.076923 | 25.856989 | 79 | false | false | 0 | 0 | 0 | 0 | 70 | 0.077864 | 0.076923 | false | false | 2 |
e5c5250bda9b20111e2459a0dfb9b055323fdb3a | 34,050,500,747,764 | 5f5f886154501c8a1cf72e99097818558666cb8a | /src/main/java/com/epam/servicedesk/service/ListRequestService.java | d69a22c8fbb5a0aaed194c5bfde5fcc60666a656 | [] | no_license | zhdaurenkyzy/Servicedesk | https://github.com/zhdaurenkyzy/Servicedesk | 52ffc0affc33a2cfffe349af2f6136cc2cd0b4a3 | e10d10c007347ef570e74f663c272f0470bd19de | refs/heads/master | 2022-07-12T23:20:54.857000 | 2019-10-31T19:18:13 | 2019-10-31T19:18:13 | 214,470,257 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.epam.servicedesk.service;
import com.epam.servicedesk.database.RequestDAO;
import com.epam.servicedesk.entity.User;
import com.epam.servicedesk.enums.Role;
import com.epam.servicedesk.exception.ConnectionException;
import com.epam.servicedesk.exception.ValidationException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static com.epam.servicedesk.database.RequestDAO.*;
import static com.epam.servicedesk.database.RequestDAO.GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID;
import static com.epam.servicedesk.util.ConstantForApp.*;
import static com.epam.servicedesk.validation.AbstractValidation.isNumeric;
public class ListRequestService implements Service {
@Override
public void execute(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException, ValidationException, ConnectionException {
RequestDAO requestDAO = new RequestDAO();
User user = (User) httpServletRequest.getSession().getAttribute(USER_PARAMETER);
String clientId = httpServletRequest.getParameter(CLIENT_ID_PARAMETER);
String statusId = httpServletRequest.getParameter(STATUS_ID_PARAMETER);
String authorId = httpServletRequest.getParameter(AUTHOR_ID_PARAMETER);
String engineerId = httpServletRequest.getParameter(ENGINEER_ID_PARAMETER);
httpServletRequest.setAttribute(ROLE_PARAMETER, Role.OPERATOR);
if (clientId != null && isNumeric(clientId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_CLIENT_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_CLIENT_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if (statusId != null && isNumeric(statusId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequestByStatus(user.getId(), Long.parseLong(statusId), GET_VIEW_ALL_REQUEST_BY_STATUS_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_STATUS_ID);
httpServletRequest.getSession().setAttribute(STATUS_ID_PARAMETER, statusId);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if (authorId != null && isNumeric(authorId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_BY_AUTHOR_OF_CREATION_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_AUTHOR_OF_CREATION);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if ((engineerId != null && isNumeric(engineerId)) && Long.parseLong(engineerId) == user.getId()) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_ENGINEER_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if ((engineerId != null && isNumeric(engineerId)) && Long.parseLong(engineerId) == NULL_ID) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(NULL_ID, GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_ENGINEER_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, NULL_ID);
} else {
if (user.getUserRole() == Role.OPERATOR) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequestView());
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, EMPTY_STRING);
} else {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequest(user.getId(), GET_VIEW_ALL_REQUEST));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, USER_PARAMETER);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
}
}
httpServletRequest.getServletContext().getRequestDispatcher(LIST_REQUEST_JSP).forward(httpServletRequest, httpServletResponse);
}
}
| UTF-8 | Java | 4,537 | java | ListRequestService.java | Java | [] | null | [] | package com.epam.servicedesk.service;
import com.epam.servicedesk.database.RequestDAO;
import com.epam.servicedesk.entity.User;
import com.epam.servicedesk.enums.Role;
import com.epam.servicedesk.exception.ConnectionException;
import com.epam.servicedesk.exception.ValidationException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import static com.epam.servicedesk.database.RequestDAO.*;
import static com.epam.servicedesk.database.RequestDAO.GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID;
import static com.epam.servicedesk.util.ConstantForApp.*;
import static com.epam.servicedesk.validation.AbstractValidation.isNumeric;
public class ListRequestService implements Service {
@Override
public void execute(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException, ValidationException, ConnectionException {
RequestDAO requestDAO = new RequestDAO();
User user = (User) httpServletRequest.getSession().getAttribute(USER_PARAMETER);
String clientId = httpServletRequest.getParameter(CLIENT_ID_PARAMETER);
String statusId = httpServletRequest.getParameter(STATUS_ID_PARAMETER);
String authorId = httpServletRequest.getParameter(AUTHOR_ID_PARAMETER);
String engineerId = httpServletRequest.getParameter(ENGINEER_ID_PARAMETER);
httpServletRequest.setAttribute(ROLE_PARAMETER, Role.OPERATOR);
if (clientId != null && isNumeric(clientId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_CLIENT_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_CLIENT_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if (statusId != null && isNumeric(statusId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequestByStatus(user.getId(), Long.parseLong(statusId), GET_VIEW_ALL_REQUEST_BY_STATUS_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_STATUS_ID);
httpServletRequest.getSession().setAttribute(STATUS_ID_PARAMETER, statusId);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if (authorId != null && isNumeric(authorId)) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_BY_AUTHOR_OF_CREATION_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_AUTHOR_OF_CREATION);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if ((engineerId != null && isNumeric(engineerId)) && Long.parseLong(engineerId) == user.getId()) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(user.getId(), GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_ENGINEER_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
} else if ((engineerId != null && isNumeric(engineerId)) && Long.parseLong(engineerId) == NULL_ID) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllByUser(NULL_ID, GET_VIEW_ALL_REQUEST_BY_ENGINEER_ID));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, REQUEST_ENGINEER_USER_ID);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, NULL_ID);
} else {
if (user.getUserRole() == Role.OPERATOR) {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequestView());
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, EMPTY_STRING);
} else {
httpServletRequest.setAttribute(REQUEST_STATES_ATTRIBUTE, requestDAO.getAllRequest(user.getId(), GET_VIEW_ALL_REQUEST));
httpServletRequest.getSession().setAttribute(COLUMN_FOR_SEARCH, USER_PARAMETER);
httpServletRequest.getSession().setAttribute(USER_ID_FOR_SEARCH, user.getId());
}
}
httpServletRequest.getServletContext().getRequestDispatcher(LIST_REQUEST_JSP).forward(httpServletRequest, httpServletResponse);
}
}
| 4,537 | 0.739035 | 0.739035 | 63 | 71.015877 | 45.440174 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.222222 | false | false | 2 |
33da33e9fdfdd8568513f33f7d6ae95934988d0f | 34,067,680,602,391 | 1399663fc4d5f75ad0931b6eedda6a964bad5883 | /market_analytics/src/com/ldhenergy/risk/marketanalytics/plvector/PLVectorPoint.java | 3efcbd4f6f653082e6499ee63403de13966107c7 | [] | no_license | simbataisa/cci | https://github.com/simbataisa/cci | 98cc7342b63ed6477dd69a91ea608855e2e59668 | 8143cf2dfed32c51106032eb06ebc497f74fff9e | refs/heads/master | 2018-04-13T06:17:06.519000 | 2017-05-05T06:52:50 | 2017-05-05T06:52:50 | 90,326,713 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ldhenergy.risk.marketanalytics.plvector;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.ldhenergy.risk.curvebuilder.util.StatsUtil;
/**
* The Class PLVectorPoint. Represents a single pl point in the risk window.
*
* @author srebrm
*/
public class PLVectorPoint implements Comparable, Serializable {
private static final long serialVersionUID = 1L;
/** The sdf. */
private static SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
/** The sdf2. */
private static SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy");
/** The historic date. @uml.property name="historicDate" */
private Date historicDate;
/** The pl value. @uml.property name="plValue" */
private double plValue;
/**
* Instantiates a new pL vector point.
*/
public PLVectorPoint(){
}
/**
* Instantiates a new pL vector point.
*
* @param historicDate the historic date
* @param plValue the pl value
*/
public PLVectorPoint(Date historicDate, double plValue) {
super();
this.historicDate = historicDate;
this.plValue = plValue;
}
/**
* Gets the historic date.
*
* @return the historic date
* @uml.property name="historicDate"
*/
public Date getHistoricDate() {
return historicDate;
}
/**
* Sets the historic date.
*
* @param historicDate the new historic date
* @uml.property name="historicDate"
*/
public void setHistoricDate(Date historicDate) {
this.historicDate = historicDate;
}
/**
* Gets the pl value.
*
* @return the pl value
* @uml.property name="plValue"
*/
public double getPlValue() {
return plValue;
}
/**
* Sets the pl value.
*
* @param plValue the new pl value
* @uml.property name="plValue"
*/
public void setPlValue(double plValue) {
this.plValue = plValue;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((historicDate == null) ? 0 : historicDate.hashCode());
long temp;
temp = Double.doubleToLongBits(plValue);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PLVectorPoint other = (PLVectorPoint) obj;
if (historicDate == null) {
if (other.historicDate != null)
return false;
} else if (!historicDate.equals(other.historicDate))
return false;
if (Double.doubleToLongBits(plValue) != Double
.doubleToLongBits(other.plValue))
return false;
return true;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "" + sdf2.format(historicDate) + "," + plValue;
}
/**
* To string2.
*
* @return the string
*/
public String toString2() {
return "PLVectorPoint [ historicDate=" + sdf.format(historicDate) + ", plValue="
+ plValue + "]";
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(Object arg0) {
PLVectorPoint p2 = (PLVectorPoint) arg0;
if(StatsUtil.equalDouble(plValue, p2.plValue)){
return 0;
}else{
//highest to lowest
return (int)(this.plValue - p2.plValue);
}
}
/**
* Copy.
*
* @return the pL vector point
*/
public PLVectorPoint copy(){
PLVectorPoint retVal = new PLVectorPoint();
retVal.historicDate = new Date(this.historicDate.getTime());
retVal.plValue = this.plValue;
return retVal;
}
}
| UTF-8 | Java | 3,865 | java | PLVectorPoint.java | Java | [
{
"context": "ngle pl point in the risk window.\r\n *\r\n * @author srebrm\r\n */\r\npublic class PLVectorPoint implements Compa",
"end": 311,
"score": 0.999691903591156,
"start": 305,
"tag": "USERNAME",
"value": "srebrm"
}
] | null | [] | package com.ldhenergy.risk.marketanalytics.plvector;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.ldhenergy.risk.curvebuilder.util.StatsUtil;
/**
* The Class PLVectorPoint. Represents a single pl point in the risk window.
*
* @author srebrm
*/
public class PLVectorPoint implements Comparable, Serializable {
private static final long serialVersionUID = 1L;
/** The sdf. */
private static SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
/** The sdf2. */
private static SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy");
/** The historic date. @uml.property name="historicDate" */
private Date historicDate;
/** The pl value. @uml.property name="plValue" */
private double plValue;
/**
* Instantiates a new pL vector point.
*/
public PLVectorPoint(){
}
/**
* Instantiates a new pL vector point.
*
* @param historicDate the historic date
* @param plValue the pl value
*/
public PLVectorPoint(Date historicDate, double plValue) {
super();
this.historicDate = historicDate;
this.plValue = plValue;
}
/**
* Gets the historic date.
*
* @return the historic date
* @uml.property name="historicDate"
*/
public Date getHistoricDate() {
return historicDate;
}
/**
* Sets the historic date.
*
* @param historicDate the new historic date
* @uml.property name="historicDate"
*/
public void setHistoricDate(Date historicDate) {
this.historicDate = historicDate;
}
/**
* Gets the pl value.
*
* @return the pl value
* @uml.property name="plValue"
*/
public double getPlValue() {
return plValue;
}
/**
* Sets the pl value.
*
* @param plValue the new pl value
* @uml.property name="plValue"
*/
public void setPlValue(double plValue) {
this.plValue = plValue;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((historicDate == null) ? 0 : historicDate.hashCode());
long temp;
temp = Double.doubleToLongBits(plValue);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PLVectorPoint other = (PLVectorPoint) obj;
if (historicDate == null) {
if (other.historicDate != null)
return false;
} else if (!historicDate.equals(other.historicDate))
return false;
if (Double.doubleToLongBits(plValue) != Double
.doubleToLongBits(other.plValue))
return false;
return true;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "" + sdf2.format(historicDate) + "," + plValue;
}
/**
* To string2.
*
* @return the string
*/
public String toString2() {
return "PLVectorPoint [ historicDate=" + sdf.format(historicDate) + ", plValue="
+ plValue + "]";
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(Object arg0) {
PLVectorPoint p2 = (PLVectorPoint) arg0;
if(StatsUtil.equalDouble(plValue, p2.plValue)){
return 0;
}else{
//highest to lowest
return (int)(this.plValue - p2.plValue);
}
}
/**
* Copy.
*
* @return the pL vector point
*/
public PLVectorPoint copy(){
PLVectorPoint retVal = new PLVectorPoint();
retVal.historicDate = new Date(this.historicDate.getTime());
retVal.plValue = this.plValue;
return retVal;
}
}
| 3,865 | 0.637516 | 0.632859 | 173 | 20.34104 | 19.738884 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.404624 | false | false | 2 |
56e52d52fc7765a2a9b1d40150320b16adf34125 | 2,001,454,816,368 | 0e0b86292fb1c06eec47806718b253b848aaebf2 | /src/main/java/com/jsu/pojo/TbFileExample.java | 6e5dbb17b8fc298686e68dac6ab43527355a63ec | [] | no_license | LiCQing/SSM-Cloudy | https://github.com/LiCQing/SSM-Cloudy | 8d7cffeff23659b72c653468d3155bdf890d450f | 8083f83fa2a955eec0f683f35df53a691fa84f07 | refs/heads/master | 2022-12-24T08:43:52.877000 | 2020-02-04T05:29:21 | 2020-02-04T05:29:21 | 238,125,362 | 1 | 0 | null | false | 2022-12-16T05:01:51 | 2020-02-04T04:47:37 | 2022-04-08T08:22:20 | 2022-12-16T05:01:48 | 57,767 | 0 | 0 | 11 | Java | false | false | package com.jsu.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TbFileExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TbFileExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andFIdIsNull() {
addCriterion("f_id is null");
return (Criteria) this;
}
public Criteria andFIdIsNotNull() {
addCriterion("f_id is not null");
return (Criteria) this;
}
public Criteria andFIdEqualTo(Integer value) {
addCriterion("f_id =", value, "fId");
return (Criteria) this;
}
public Criteria andFIdNotEqualTo(Integer value) {
addCriterion("f_id <>", value, "fId");
return (Criteria) this;
}
public Criteria andFIdGreaterThan(Integer value) {
addCriterion("f_id >", value, "fId");
return (Criteria) this;
}
public Criteria andFIdGreaterThanOrEqualTo(Integer value) {
addCriterion("f_id >=", value, "fId");
return (Criteria) this;
}
public Criteria andFIdLessThan(Integer value) {
addCriterion("f_id <", value, "fId");
return (Criteria) this;
}
public Criteria andFIdLessThanOrEqualTo(Integer value) {
addCriterion("f_id <=", value, "fId");
return (Criteria) this;
}
public Criteria andFIdIn(List<Integer> values) {
addCriterion("f_id in", values, "fId");
return (Criteria) this;
}
public Criteria andFIdNotIn(List<Integer> values) {
addCriterion("f_id not in", values, "fId");
return (Criteria) this;
}
public Criteria andFIdBetween(Integer value1, Integer value2) {
addCriterion("f_id between", value1, value2, "fId");
return (Criteria) this;
}
public Criteria andFIdNotBetween(Integer value1, Integer value2) {
addCriterion("f_id not between", value1, value2, "fId");
return (Criteria) this;
}
public Criteria andFNameIsNull() {
addCriterion("f_name is null");
return (Criteria) this;
}
public Criteria andFNameIsNotNull() {
addCriterion("f_name is not null");
return (Criteria) this;
}
public Criteria andFNameEqualTo(String value) {
addCriterion("f_name =", value, "fName");
return (Criteria) this;
}
public Criteria andFNameNotEqualTo(String value) {
addCriterion("f_name <>", value, "fName");
return (Criteria) this;
}
public Criteria andFNameGreaterThan(String value) {
addCriterion("f_name >", value, "fName");
return (Criteria) this;
}
public Criteria andFNameGreaterThanOrEqualTo(String value) {
addCriterion("f_name >=", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLessThan(String value) {
addCriterion("f_name <", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLessThanOrEqualTo(String value) {
addCriterion("f_name <=", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLike(String value) {
addCriterion("f_name like", value, "fName");
return (Criteria) this;
}
public Criteria andFNameNotLike(String value) {
addCriterion("f_name not like", value, "fName");
return (Criteria) this;
}
public Criteria andFNameIn(List<String> values) {
addCriterion("f_name in", values, "fName");
return (Criteria) this;
}
public Criteria andFNameNotIn(List<String> values) {
addCriterion("f_name not in", values, "fName");
return (Criteria) this;
}
public Criteria andFNameBetween(String value1, String value2) {
addCriterion("f_name between", value1, value2, "fName");
return (Criteria) this;
}
public Criteria andFNameNotBetween(String value1, String value2) {
addCriterion("f_name not between", value1, value2, "fName");
return (Criteria) this;
}
public Criteria andFSizeIsNull() {
addCriterion("f_size is null");
return (Criteria) this;
}
public Criteria andFSizeIsNotNull() {
addCriterion("f_size is not null");
return (Criteria) this;
}
public Criteria andFSizeEqualTo(Long value) {
addCriterion("f_size =", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotEqualTo(Long value) {
addCriterion("f_size <>", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeGreaterThan(Long value) {
addCriterion("f_size >", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeGreaterThanOrEqualTo(Long value) {
addCriterion("f_size >=", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeLessThan(Long value) {
addCriterion("f_size <", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeLessThanOrEqualTo(Long value) {
addCriterion("f_size <=", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeIn(List<Long> values) {
addCriterion("f_size in", values, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotIn(List<Long> values) {
addCriterion("f_size not in", values, "fSize");
return (Criteria) this;
}
public Criteria andFSizeBetween(Long value1, Long value2) {
addCriterion("f_size between", value1, value2, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotBetween(Long value1, Long value2) {
addCriterion("f_size not between", value1, value2, "fSize");
return (Criteria) this;
}
public Criteria andFCreateTimeIsNull() {
addCriterion("f_create_time is null");
return (Criteria) this;
}
public Criteria andFCreateTimeIsNotNull() {
addCriterion("f_create_time is not null");
return (Criteria) this;
}
public Criteria andFCreateTimeEqualTo(Date value) {
addCriterion("f_create_time =", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotEqualTo(Date value) {
addCriterion("f_create_time <>", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeGreaterThan(Date value) {
addCriterion("f_create_time >", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("f_create_time >=", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeLessThan(Date value) {
addCriterion("f_create_time <", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("f_create_time <=", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeIn(List<Date> values) {
addCriterion("f_create_time in", values, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotIn(List<Date> values) {
addCriterion("f_create_time not in", values, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeBetween(Date value1, Date value2) {
addCriterion("f_create_time between", value1, value2, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("f_create_time not between", value1, value2, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCateIsNull() {
addCriterion("f_cate is null");
return (Criteria) this;
}
public Criteria andFCateIsNotNull() {
addCriterion("f_cate is not null");
return (Criteria) this;
}
public Criteria andFCateEqualTo(Integer value) {
addCriterion("f_cate =", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotEqualTo(Integer value) {
addCriterion("f_cate <>", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateGreaterThan(Integer value) {
addCriterion("f_cate >", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateGreaterThanOrEqualTo(Integer value) {
addCriterion("f_cate >=", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateLessThan(Integer value) {
addCriterion("f_cate <", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateLessThanOrEqualTo(Integer value) {
addCriterion("f_cate <=", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateIn(List<Integer> values) {
addCriterion("f_cate in", values, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotIn(List<Integer> values) {
addCriterion("f_cate not in", values, "fCate");
return (Criteria) this;
}
public Criteria andFCateBetween(Integer value1, Integer value2) {
addCriterion("f_cate between", value1, value2, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotBetween(Integer value1, Integer value2) {
addCriterion("f_cate not between", value1, value2, "fCate");
return (Criteria) this;
}
public Criteria andFDeleteTimeIsNull() {
addCriterion("f_delete_time is null");
return (Criteria) this;
}
public Criteria andFDeleteTimeIsNotNull() {
addCriterion("f_delete_time is not null");
return (Criteria) this;
}
public Criteria andFDeleteTimeEqualTo(Date value) {
addCriterion("f_delete_time =", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotEqualTo(Date value) {
addCriterion("f_delete_time <>", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeGreaterThan(Date value) {
addCriterion("f_delete_time >", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeGreaterThanOrEqualTo(Date value) {
addCriterion("f_delete_time >=", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeLessThan(Date value) {
addCriterion("f_delete_time <", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeLessThanOrEqualTo(Date value) {
addCriterion("f_delete_time <=", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeIn(List<Date> values) {
addCriterion("f_delete_time in", values, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotIn(List<Date> values) {
addCriterion("f_delete_time not in", values, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeBetween(Date value1, Date value2) {
addCriterion("f_delete_time between", value1, value2, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotBetween(Date value1, Date value2) {
addCriterion("f_delete_time not between", value1, value2, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFStatusIsNull() {
addCriterion("f_status is null");
return (Criteria) this;
}
public Criteria andFStatusIsNotNull() {
addCriterion("f_status is not null");
return (Criteria) this;
}
public Criteria andFStatusEqualTo(Integer value) {
addCriterion("f_status =", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotEqualTo(Integer value) {
addCriterion("f_status <>", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusGreaterThan(Integer value) {
addCriterion("f_status >", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("f_status >=", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusLessThan(Integer value) {
addCriterion("f_status <", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusLessThanOrEqualTo(Integer value) {
addCriterion("f_status <=", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusIn(List<Integer> values) {
addCriterion("f_status in", values, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotIn(List<Integer> values) {
addCriterion("f_status not in", values, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusBetween(Integer value1, Integer value2) {
addCriterion("f_status between", value1, value2, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotBetween(Integer value1, Integer value2) {
addCriterion("f_status not between", value1, value2, "fStatus");
return (Criteria) this;
}
public Criteria andIsDirIsNull() {
addCriterion("is_dir is null");
return (Criteria) this;
}
public Criteria andIsDirIsNotNull() {
addCriterion("is_dir is not null");
return (Criteria) this;
}
public Criteria andIsDirEqualTo(Integer value) {
addCriterion("is_dir =", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotEqualTo(Integer value) {
addCriterion("is_dir <>", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirGreaterThan(Integer value) {
addCriterion("is_dir >", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirGreaterThanOrEqualTo(Integer value) {
addCriterion("is_dir >=", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirLessThan(Integer value) {
addCriterion("is_dir <", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirLessThanOrEqualTo(Integer value) {
addCriterion("is_dir <=", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirIn(List<Integer> values) {
addCriterion("is_dir in", values, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotIn(List<Integer> values) {
addCriterion("is_dir not in", values, "isDir");
return (Criteria) this;
}
public Criteria andIsDirBetween(Integer value1, Integer value2) {
addCriterion("is_dir between", value1, value2, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotBetween(Integer value1, Integer value2) {
addCriterion("is_dir not between", value1, value2, "isDir");
return (Criteria) this;
}
public Criteria andPIdIsNull() {
addCriterion("p_id is null");
return (Criteria) this;
}
public Criteria andPIdIsNotNull() {
addCriterion("p_id is not null");
return (Criteria) this;
}
public Criteria andPIdEqualTo(Integer value) {
addCriterion("p_id =", value, "pId");
return (Criteria) this;
}
public Criteria andPIdNotEqualTo(Integer value) {
addCriterion("p_id <>", value, "pId");
return (Criteria) this;
}
public Criteria andPIdGreaterThan(Integer value) {
addCriterion("p_id >", value, "pId");
return (Criteria) this;
}
public Criteria andPIdGreaterThanOrEqualTo(Integer value) {
addCriterion("p_id >=", value, "pId");
return (Criteria) this;
}
public Criteria andPIdLessThan(Integer value) {
addCriterion("p_id <", value, "pId");
return (Criteria) this;
}
public Criteria andPIdLessThanOrEqualTo(Integer value) {
addCriterion("p_id <=", value, "pId");
return (Criteria) this;
}
public Criteria andPIdIn(List<Integer> values) {
addCriterion("p_id in", values, "pId");
return (Criteria) this;
}
public Criteria andPIdNotIn(List<Integer> values) {
addCriterion("p_id not in", values, "pId");
return (Criteria) this;
}
public Criteria andPIdBetween(Integer value1, Integer value2) {
addCriterion("p_id between", value1, value2, "pId");
return (Criteria) this;
}
public Criteria andPIdNotBetween(Integer value1, Integer value2) {
addCriterion("p_id not between", value1, value2, "pId");
return (Criteria) this;
}
public Criteria andUIdIsNull() {
addCriterion("u_id is null");
return (Criteria) this;
}
public Criteria andUIdIsNotNull() {
addCriterion("u_id is not null");
return (Criteria) this;
}
public Criteria andUIdEqualTo(Integer value) {
addCriterion("u_id =", value, "uId");
return (Criteria) this;
}
public Criteria andUIdNotEqualTo(Integer value) {
addCriterion("u_id <>", value, "uId");
return (Criteria) this;
}
public Criteria andUIdGreaterThan(Integer value) {
addCriterion("u_id >", value, "uId");
return (Criteria) this;
}
public Criteria andUIdGreaterThanOrEqualTo(Integer value) {
addCriterion("u_id >=", value, "uId");
return (Criteria) this;
}
public Criteria andUIdLessThan(Integer value) {
addCriterion("u_id <", value, "uId");
return (Criteria) this;
}
public Criteria andUIdLessThanOrEqualTo(Integer value) {
addCriterion("u_id <=", value, "uId");
return (Criteria) this;
}
public Criteria andUIdIn(List<Integer> values) {
addCriterion("u_id in", values, "uId");
return (Criteria) this;
}
public Criteria andUIdNotIn(List<Integer> values) {
addCriterion("u_id not in", values, "uId");
return (Criteria) this;
}
public Criteria andUIdBetween(Integer value1, Integer value2) {
addCriterion("u_id between", value1, value2, "uId");
return (Criteria) this;
}
public Criteria andUIdNotBetween(Integer value1, Integer value2) {
addCriterion("u_id not between", value1, value2, "uId");
return (Criteria) this;
}
public Criteria andMIdIsNull() {
addCriterion("m_id is null");
return (Criteria) this;
}
public Criteria andMIdIsNotNull() {
addCriterion("m_id is not null");
return (Criteria) this;
}
public Criteria andMIdEqualTo(Integer value) {
addCriterion("m_id =", value, "mId");
return (Criteria) this;
}
public Criteria andMIdNotEqualTo(Integer value) {
addCriterion("m_id <>", value, "mId");
return (Criteria) this;
}
public Criteria andMIdGreaterThan(Integer value) {
addCriterion("m_id >", value, "mId");
return (Criteria) this;
}
public Criteria andMIdGreaterThanOrEqualTo(Integer value) {
addCriterion("m_id >=", value, "mId");
return (Criteria) this;
}
public Criteria andMIdLessThan(Integer value) {
addCriterion("m_id <", value, "mId");
return (Criteria) this;
}
public Criteria andMIdLessThanOrEqualTo(Integer value) {
addCriterion("m_id <=", value, "mId");
return (Criteria) this;
}
public Criteria andMIdIn(List<Integer> values) {
addCriterion("m_id in", values, "mId");
return (Criteria) this;
}
public Criteria andMIdNotIn(List<Integer> values) {
addCriterion("m_id not in", values, "mId");
return (Criteria) this;
}
public Criteria andMIdBetween(Integer value1, Integer value2) {
addCriterion("m_id between", value1, value2, "mId");
return (Criteria) this;
}
public Criteria andMIdNotBetween(Integer value1, Integer value2) {
addCriterion("m_id not between", value1, value2, "mId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | UTF-8 | Java | 27,258 | java | TbFileExample.java | Java | [] | null | [] | package com.jsu.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TbFileExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TbFileExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andFIdIsNull() {
addCriterion("f_id is null");
return (Criteria) this;
}
public Criteria andFIdIsNotNull() {
addCriterion("f_id is not null");
return (Criteria) this;
}
public Criteria andFIdEqualTo(Integer value) {
addCriterion("f_id =", value, "fId");
return (Criteria) this;
}
public Criteria andFIdNotEqualTo(Integer value) {
addCriterion("f_id <>", value, "fId");
return (Criteria) this;
}
public Criteria andFIdGreaterThan(Integer value) {
addCriterion("f_id >", value, "fId");
return (Criteria) this;
}
public Criteria andFIdGreaterThanOrEqualTo(Integer value) {
addCriterion("f_id >=", value, "fId");
return (Criteria) this;
}
public Criteria andFIdLessThan(Integer value) {
addCriterion("f_id <", value, "fId");
return (Criteria) this;
}
public Criteria andFIdLessThanOrEqualTo(Integer value) {
addCriterion("f_id <=", value, "fId");
return (Criteria) this;
}
public Criteria andFIdIn(List<Integer> values) {
addCriterion("f_id in", values, "fId");
return (Criteria) this;
}
public Criteria andFIdNotIn(List<Integer> values) {
addCriterion("f_id not in", values, "fId");
return (Criteria) this;
}
public Criteria andFIdBetween(Integer value1, Integer value2) {
addCriterion("f_id between", value1, value2, "fId");
return (Criteria) this;
}
public Criteria andFIdNotBetween(Integer value1, Integer value2) {
addCriterion("f_id not between", value1, value2, "fId");
return (Criteria) this;
}
public Criteria andFNameIsNull() {
addCriterion("f_name is null");
return (Criteria) this;
}
public Criteria andFNameIsNotNull() {
addCriterion("f_name is not null");
return (Criteria) this;
}
public Criteria andFNameEqualTo(String value) {
addCriterion("f_name =", value, "fName");
return (Criteria) this;
}
public Criteria andFNameNotEqualTo(String value) {
addCriterion("f_name <>", value, "fName");
return (Criteria) this;
}
public Criteria andFNameGreaterThan(String value) {
addCriterion("f_name >", value, "fName");
return (Criteria) this;
}
public Criteria andFNameGreaterThanOrEqualTo(String value) {
addCriterion("f_name >=", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLessThan(String value) {
addCriterion("f_name <", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLessThanOrEqualTo(String value) {
addCriterion("f_name <=", value, "fName");
return (Criteria) this;
}
public Criteria andFNameLike(String value) {
addCriterion("f_name like", value, "fName");
return (Criteria) this;
}
public Criteria andFNameNotLike(String value) {
addCriterion("f_name not like", value, "fName");
return (Criteria) this;
}
public Criteria andFNameIn(List<String> values) {
addCriterion("f_name in", values, "fName");
return (Criteria) this;
}
public Criteria andFNameNotIn(List<String> values) {
addCriterion("f_name not in", values, "fName");
return (Criteria) this;
}
public Criteria andFNameBetween(String value1, String value2) {
addCriterion("f_name between", value1, value2, "fName");
return (Criteria) this;
}
public Criteria andFNameNotBetween(String value1, String value2) {
addCriterion("f_name not between", value1, value2, "fName");
return (Criteria) this;
}
public Criteria andFSizeIsNull() {
addCriterion("f_size is null");
return (Criteria) this;
}
public Criteria andFSizeIsNotNull() {
addCriterion("f_size is not null");
return (Criteria) this;
}
public Criteria andFSizeEqualTo(Long value) {
addCriterion("f_size =", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotEqualTo(Long value) {
addCriterion("f_size <>", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeGreaterThan(Long value) {
addCriterion("f_size >", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeGreaterThanOrEqualTo(Long value) {
addCriterion("f_size >=", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeLessThan(Long value) {
addCriterion("f_size <", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeLessThanOrEqualTo(Long value) {
addCriterion("f_size <=", value, "fSize");
return (Criteria) this;
}
public Criteria andFSizeIn(List<Long> values) {
addCriterion("f_size in", values, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotIn(List<Long> values) {
addCriterion("f_size not in", values, "fSize");
return (Criteria) this;
}
public Criteria andFSizeBetween(Long value1, Long value2) {
addCriterion("f_size between", value1, value2, "fSize");
return (Criteria) this;
}
public Criteria andFSizeNotBetween(Long value1, Long value2) {
addCriterion("f_size not between", value1, value2, "fSize");
return (Criteria) this;
}
public Criteria andFCreateTimeIsNull() {
addCriterion("f_create_time is null");
return (Criteria) this;
}
public Criteria andFCreateTimeIsNotNull() {
addCriterion("f_create_time is not null");
return (Criteria) this;
}
public Criteria andFCreateTimeEqualTo(Date value) {
addCriterion("f_create_time =", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotEqualTo(Date value) {
addCriterion("f_create_time <>", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeGreaterThan(Date value) {
addCriterion("f_create_time >", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("f_create_time >=", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeLessThan(Date value) {
addCriterion("f_create_time <", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("f_create_time <=", value, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeIn(List<Date> values) {
addCriterion("f_create_time in", values, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotIn(List<Date> values) {
addCriterion("f_create_time not in", values, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeBetween(Date value1, Date value2) {
addCriterion("f_create_time between", value1, value2, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("f_create_time not between", value1, value2, "fCreateTime");
return (Criteria) this;
}
public Criteria andFCateIsNull() {
addCriterion("f_cate is null");
return (Criteria) this;
}
public Criteria andFCateIsNotNull() {
addCriterion("f_cate is not null");
return (Criteria) this;
}
public Criteria andFCateEqualTo(Integer value) {
addCriterion("f_cate =", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotEqualTo(Integer value) {
addCriterion("f_cate <>", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateGreaterThan(Integer value) {
addCriterion("f_cate >", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateGreaterThanOrEqualTo(Integer value) {
addCriterion("f_cate >=", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateLessThan(Integer value) {
addCriterion("f_cate <", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateLessThanOrEqualTo(Integer value) {
addCriterion("f_cate <=", value, "fCate");
return (Criteria) this;
}
public Criteria andFCateIn(List<Integer> values) {
addCriterion("f_cate in", values, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotIn(List<Integer> values) {
addCriterion("f_cate not in", values, "fCate");
return (Criteria) this;
}
public Criteria andFCateBetween(Integer value1, Integer value2) {
addCriterion("f_cate between", value1, value2, "fCate");
return (Criteria) this;
}
public Criteria andFCateNotBetween(Integer value1, Integer value2) {
addCriterion("f_cate not between", value1, value2, "fCate");
return (Criteria) this;
}
public Criteria andFDeleteTimeIsNull() {
addCriterion("f_delete_time is null");
return (Criteria) this;
}
public Criteria andFDeleteTimeIsNotNull() {
addCriterion("f_delete_time is not null");
return (Criteria) this;
}
public Criteria andFDeleteTimeEqualTo(Date value) {
addCriterion("f_delete_time =", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotEqualTo(Date value) {
addCriterion("f_delete_time <>", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeGreaterThan(Date value) {
addCriterion("f_delete_time >", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeGreaterThanOrEqualTo(Date value) {
addCriterion("f_delete_time >=", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeLessThan(Date value) {
addCriterion("f_delete_time <", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeLessThanOrEqualTo(Date value) {
addCriterion("f_delete_time <=", value, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeIn(List<Date> values) {
addCriterion("f_delete_time in", values, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotIn(List<Date> values) {
addCriterion("f_delete_time not in", values, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeBetween(Date value1, Date value2) {
addCriterion("f_delete_time between", value1, value2, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFDeleteTimeNotBetween(Date value1, Date value2) {
addCriterion("f_delete_time not between", value1, value2, "fDeleteTime");
return (Criteria) this;
}
public Criteria andFStatusIsNull() {
addCriterion("f_status is null");
return (Criteria) this;
}
public Criteria andFStatusIsNotNull() {
addCriterion("f_status is not null");
return (Criteria) this;
}
public Criteria andFStatusEqualTo(Integer value) {
addCriterion("f_status =", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotEqualTo(Integer value) {
addCriterion("f_status <>", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusGreaterThan(Integer value) {
addCriterion("f_status >", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("f_status >=", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusLessThan(Integer value) {
addCriterion("f_status <", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusLessThanOrEqualTo(Integer value) {
addCriterion("f_status <=", value, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusIn(List<Integer> values) {
addCriterion("f_status in", values, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotIn(List<Integer> values) {
addCriterion("f_status not in", values, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusBetween(Integer value1, Integer value2) {
addCriterion("f_status between", value1, value2, "fStatus");
return (Criteria) this;
}
public Criteria andFStatusNotBetween(Integer value1, Integer value2) {
addCriterion("f_status not between", value1, value2, "fStatus");
return (Criteria) this;
}
public Criteria andIsDirIsNull() {
addCriterion("is_dir is null");
return (Criteria) this;
}
public Criteria andIsDirIsNotNull() {
addCriterion("is_dir is not null");
return (Criteria) this;
}
public Criteria andIsDirEqualTo(Integer value) {
addCriterion("is_dir =", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotEqualTo(Integer value) {
addCriterion("is_dir <>", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirGreaterThan(Integer value) {
addCriterion("is_dir >", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirGreaterThanOrEqualTo(Integer value) {
addCriterion("is_dir >=", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirLessThan(Integer value) {
addCriterion("is_dir <", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirLessThanOrEqualTo(Integer value) {
addCriterion("is_dir <=", value, "isDir");
return (Criteria) this;
}
public Criteria andIsDirIn(List<Integer> values) {
addCriterion("is_dir in", values, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotIn(List<Integer> values) {
addCriterion("is_dir not in", values, "isDir");
return (Criteria) this;
}
public Criteria andIsDirBetween(Integer value1, Integer value2) {
addCriterion("is_dir between", value1, value2, "isDir");
return (Criteria) this;
}
public Criteria andIsDirNotBetween(Integer value1, Integer value2) {
addCriterion("is_dir not between", value1, value2, "isDir");
return (Criteria) this;
}
public Criteria andPIdIsNull() {
addCriterion("p_id is null");
return (Criteria) this;
}
public Criteria andPIdIsNotNull() {
addCriterion("p_id is not null");
return (Criteria) this;
}
public Criteria andPIdEqualTo(Integer value) {
addCriterion("p_id =", value, "pId");
return (Criteria) this;
}
public Criteria andPIdNotEqualTo(Integer value) {
addCriterion("p_id <>", value, "pId");
return (Criteria) this;
}
public Criteria andPIdGreaterThan(Integer value) {
addCriterion("p_id >", value, "pId");
return (Criteria) this;
}
public Criteria andPIdGreaterThanOrEqualTo(Integer value) {
addCriterion("p_id >=", value, "pId");
return (Criteria) this;
}
public Criteria andPIdLessThan(Integer value) {
addCriterion("p_id <", value, "pId");
return (Criteria) this;
}
public Criteria andPIdLessThanOrEqualTo(Integer value) {
addCriterion("p_id <=", value, "pId");
return (Criteria) this;
}
public Criteria andPIdIn(List<Integer> values) {
addCriterion("p_id in", values, "pId");
return (Criteria) this;
}
public Criteria andPIdNotIn(List<Integer> values) {
addCriterion("p_id not in", values, "pId");
return (Criteria) this;
}
public Criteria andPIdBetween(Integer value1, Integer value2) {
addCriterion("p_id between", value1, value2, "pId");
return (Criteria) this;
}
public Criteria andPIdNotBetween(Integer value1, Integer value2) {
addCriterion("p_id not between", value1, value2, "pId");
return (Criteria) this;
}
public Criteria andUIdIsNull() {
addCriterion("u_id is null");
return (Criteria) this;
}
public Criteria andUIdIsNotNull() {
addCriterion("u_id is not null");
return (Criteria) this;
}
public Criteria andUIdEqualTo(Integer value) {
addCriterion("u_id =", value, "uId");
return (Criteria) this;
}
public Criteria andUIdNotEqualTo(Integer value) {
addCriterion("u_id <>", value, "uId");
return (Criteria) this;
}
public Criteria andUIdGreaterThan(Integer value) {
addCriterion("u_id >", value, "uId");
return (Criteria) this;
}
public Criteria andUIdGreaterThanOrEqualTo(Integer value) {
addCriterion("u_id >=", value, "uId");
return (Criteria) this;
}
public Criteria andUIdLessThan(Integer value) {
addCriterion("u_id <", value, "uId");
return (Criteria) this;
}
public Criteria andUIdLessThanOrEqualTo(Integer value) {
addCriterion("u_id <=", value, "uId");
return (Criteria) this;
}
public Criteria andUIdIn(List<Integer> values) {
addCriterion("u_id in", values, "uId");
return (Criteria) this;
}
public Criteria andUIdNotIn(List<Integer> values) {
addCriterion("u_id not in", values, "uId");
return (Criteria) this;
}
public Criteria andUIdBetween(Integer value1, Integer value2) {
addCriterion("u_id between", value1, value2, "uId");
return (Criteria) this;
}
public Criteria andUIdNotBetween(Integer value1, Integer value2) {
addCriterion("u_id not between", value1, value2, "uId");
return (Criteria) this;
}
public Criteria andMIdIsNull() {
addCriterion("m_id is null");
return (Criteria) this;
}
public Criteria andMIdIsNotNull() {
addCriterion("m_id is not null");
return (Criteria) this;
}
public Criteria andMIdEqualTo(Integer value) {
addCriterion("m_id =", value, "mId");
return (Criteria) this;
}
public Criteria andMIdNotEqualTo(Integer value) {
addCriterion("m_id <>", value, "mId");
return (Criteria) this;
}
public Criteria andMIdGreaterThan(Integer value) {
addCriterion("m_id >", value, "mId");
return (Criteria) this;
}
public Criteria andMIdGreaterThanOrEqualTo(Integer value) {
addCriterion("m_id >=", value, "mId");
return (Criteria) this;
}
public Criteria andMIdLessThan(Integer value) {
addCriterion("m_id <", value, "mId");
return (Criteria) this;
}
public Criteria andMIdLessThanOrEqualTo(Integer value) {
addCriterion("m_id <=", value, "mId");
return (Criteria) this;
}
public Criteria andMIdIn(List<Integer> values) {
addCriterion("m_id in", values, "mId");
return (Criteria) this;
}
public Criteria andMIdNotIn(List<Integer> values) {
addCriterion("m_id not in", values, "mId");
return (Criteria) this;
}
public Criteria andMIdBetween(Integer value1, Integer value2) {
addCriterion("m_id between", value1, value2, "mId");
return (Criteria) this;
}
public Criteria andMIdNotBetween(Integer value1, Integer value2) {
addCriterion("m_id not between", value1, value2, "mId");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | 27,258 | 0.564055 | 0.560533 | 871 | 30.296211 | 24.587471 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.724455 | false | false | 2 |
f8c82d00b55062c90b82320fa386afa96fe3c4e8 | 2,001,454,819,387 | 5c8103248cc20d39800f73fe064a136366e648d5 | /permission/src/main/java/com/junyi/permission/task/InterfaceScanner.java | 62df26e1c6d1d7f46c6ec898b8b2807a9f49c52a | [] | no_license | kangyunhui/caifa-government-bingtuan-api | https://github.com/kangyunhui/caifa-government-bingtuan-api | 555b87fae6ecc6acb621fea8a49a81a471707c4c | 40d10e08beac16ac0fc6b1fed639077c04246f48 | refs/heads/master | 2023-03-25T17:09:55.155000 | 2021-03-23T12:54:11 | 2021-03-23T12:54:11 | 350,711,919 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.junyi.permission.task;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.junyi.permission.annotation.NoAuthorized;
import com.junyi.permission.annotation.Public;
import com.junyi.permission.entity.ButtonInterface;
import com.junyi.permission.entity.Interface;
import com.junyi.permission.mapper.ButtonInterfaceMapper;
import com.junyi.permission.mapper.InterfaceMapper;
import com.junyi.permission.service.ButtonService;
import com.junyi.permission.service.InterfaceService;
import com.junyi.permission.util.CommonUtils;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author erma66.feng
* @email erma66@sina.cn
* @date 2020/3/18 0018
* @description xxxx
*/
@Component
@Order(1)
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class InterfaceScanner implements CommandLineRunner {
private static final String MATCH_URL_PARAM = "(\\w|-)+";
private static final String[] SWAGGER_PATHS = {"/swagger-resources", "/api-docs"};
private final @NonNull RequestMappingHandlerMapping handlerMapping;
private final @NonNull InterfaceService interfaceService;
private final @NonNull ButtonService buttonService;
private final @NonNull InterfaceMapper interfaceMapper;
private final @NonNull ButtonInterfaceMapper buttonInterfaceMapper;
@Override
public void run(String... args) {
Map<String, Interface> mapDb = getIntergfaceFromDb();
Map<String, Interface> mapCode = getInterfaceFromCode();
List<Interface> diffList = diff(mapCode, mapDb);
interfaceService.saveOrUpdateBatch(diffList);
List<String> deletedIds = getDeleted(mapCode, mapDb);
if (deletedIds.size() > 0) {
interfaceMapper.deleteBatchIds(deletedIds);
buttonInterfaceMapper.delete(
Wrappers.<ButtonInterface>lambdaQuery()
.in(ButtonInterface::getInterfaceId, deletedIds));
}
interfaceService.loadUserInterface();
interfaceService.loadPublicInterface();
interfaceService.loadNoAuthorisedInterface();
}
private List<String> getDeleted(Map<String, Interface> mapCode, Map<String, Interface> mapDb) {
List<String> ids = new ArrayList<>();
for (Map.Entry<String, Interface> entry : mapDb.entrySet()) {
if (!mapCode.containsKey(entry.getKey())) {
ids.add(entry.getValue().getGuid());
}
}
return ids;
}
/**
* 如果代码中的接口在数据库中已经存在,并且内容相同,则不处理 如果代码中的接口在数据库中已经存在,但内容不同,则更新数据库中的 如果代码中的接口在数据库中不存在,则插入数据库
*
* @param mapCode 代码中的接口
* @param mapDb 数据库中的接口
* @return
*/
private List<Interface> diff(Map<String, Interface> mapCode, Map<String, Interface> mapDb) {
List<Interface> interfaceList = new ArrayList<>();
for (Map.Entry<String, Interface> entry : mapCode.entrySet()) {
String key = entry.getKey();
Interface interCode = entry.getValue();
if (mapDb.containsKey(key)) {
Interface interDb = mapDb.get(key);
if (!interCode.isSimilar(interDb)) {
interDb.setName(interCode.getName());
interDb.setTag(interCode.getTag());
interDb.setNotes(interCode.getNotes());
interDb.setAuthorized(interCode.isAuthorized());
interDb.setPublicInterface(interCode.isPublicInterface());
interfaceList.add(interDb);
}
} else {
interCode.setGuid(CommonUtils.getUUID());
interfaceList.add(interCode);
}
}
return interfaceList;
}
private Map<String, Interface> getIntergfaceFromDb() {
List<Interface> list = interfaceService.list();
Map<String, Interface> map = new HashMap<>(list.size());
for (Interface inter : list) {
map.put(inter.getUrl() + inter.getMethodType(), inter);
log.debug(
"interface:{},{},{},{}",
inter.getName(),
inter.getTag(),
inter.getUrl(),
inter.getMethodType());
}
return map;
}
private Map<String, Interface> getInterfaceFromCode() {
Map<String, Interface> map = new HashMap<>();
Map<RequestMappingInfo, HandlerMethod> map1 = handlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map1.entrySet()) {
RequestMappingInfo info = entry.getKey();
String url = info.getPatternsCondition().toString();
if (StringUtils.isEmpty(url)) {
continue;
}
if (isSwaggerUrl(url)) {
continue;
}
HandlerMethod method = entry.getValue();
Interface inter = new Interface();
inter.setUrl(processUrl(url));
if (info.getMethodsCondition().isEmpty()) {
continue;
} else {
inter.setMethodType(replaceBrackets(info.getMethodsCondition().toString()));
}
ApiOperation annotation = method.getMethodAnnotation(ApiOperation.class);
if (annotation == null) {
inter.setName(method.getMethod().getName());
inter.setNotes(method.getMethod().getName());
inter.setTag(method.getBeanType().getSimpleName());
} else {
inter.setName(annotation.value());
inter.setTag(annotation.tags()[0]);
inter.setNotes(annotation.notes());
}
inter.setPublicInterface(method.hasMethodAnnotation(Public.class));
inter.setAuthorized(
!inter.isPublicInterface() && !method.hasMethodAnnotation(NoAuthorized.class));
map.put(inter.getUrl() + inter.getMethodType(), inter);
}
return map;
}
private boolean isSwaggerUrl(String url) {
for (String swaggerUrl : SWAGGER_PATHS) {
if (url.contains(swaggerUrl)) {
return true;
}
}
return false;
}
/** 处理url */
public String processUrl(String url) {
url = replaceBrackets(url);
if (isNeedMatch(url)) {
return toRegular(url);
}
return url;
}
/** 去除中括号 */
private String replaceBrackets(String str) {
if (str.startsWith("[") && str.endsWith("]")) {
return str.substring(1, str.length() - 1);
}
return str;
}
/** 转为正则表达式 */
private String toRegular(String url) {
int start = url.indexOf("{");
int end = url.indexOf("}");
url = url.substring(0, start) + MATCH_URL_PARAM + url.substring(end + 1);
if (isNeedMatch(url)) {
return toRegular(url);
} else {
url = "^" + url;
url = url.replace("/", "\\/");
return url;
}
}
private boolean isNeedMatch(String str) {
return str.contains("{") && str.contains("}");
}
}
| UTF-8 | Java | 8,067 | java | InterfaceScanner.java | Java | [
{
"context": "a.util.List;\nimport java.util.Map;\n\n/**\n * @author erma66.feng\n * @email erma66@sina.cn\n * @date 2020/3/18 0018\n",
"end": 1292,
"score": 0.8589317202568054,
"start": 1281,
"tag": "NAME",
"value": "erma66.feng"
},
{
"context": "va.util.Map;\n\n/**\n * @author erma... | null | [] | package com.junyi.permission.task;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.junyi.permission.annotation.NoAuthorized;
import com.junyi.permission.annotation.Public;
import com.junyi.permission.entity.ButtonInterface;
import com.junyi.permission.entity.Interface;
import com.junyi.permission.mapper.ButtonInterfaceMapper;
import com.junyi.permission.mapper.InterfaceMapper;
import com.junyi.permission.service.ButtonService;
import com.junyi.permission.service.InterfaceService;
import com.junyi.permission.util.CommonUtils;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author erma66.feng
* @email <EMAIL>
* @date 2020/3/18 0018
* @description xxxx
*/
@Component
@Order(1)
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class InterfaceScanner implements CommandLineRunner {
private static final String MATCH_URL_PARAM = "(\\w|-)+";
private static final String[] SWAGGER_PATHS = {"/swagger-resources", "/api-docs"};
private final @NonNull RequestMappingHandlerMapping handlerMapping;
private final @NonNull InterfaceService interfaceService;
private final @NonNull ButtonService buttonService;
private final @NonNull InterfaceMapper interfaceMapper;
private final @NonNull ButtonInterfaceMapper buttonInterfaceMapper;
@Override
public void run(String... args) {
Map<String, Interface> mapDb = getIntergfaceFromDb();
Map<String, Interface> mapCode = getInterfaceFromCode();
List<Interface> diffList = diff(mapCode, mapDb);
interfaceService.saveOrUpdateBatch(diffList);
List<String> deletedIds = getDeleted(mapCode, mapDb);
if (deletedIds.size() > 0) {
interfaceMapper.deleteBatchIds(deletedIds);
buttonInterfaceMapper.delete(
Wrappers.<ButtonInterface>lambdaQuery()
.in(ButtonInterface::getInterfaceId, deletedIds));
}
interfaceService.loadUserInterface();
interfaceService.loadPublicInterface();
interfaceService.loadNoAuthorisedInterface();
}
private List<String> getDeleted(Map<String, Interface> mapCode, Map<String, Interface> mapDb) {
List<String> ids = new ArrayList<>();
for (Map.Entry<String, Interface> entry : mapDb.entrySet()) {
if (!mapCode.containsKey(entry.getKey())) {
ids.add(entry.getValue().getGuid());
}
}
return ids;
}
/**
* 如果代码中的接口在数据库中已经存在,并且内容相同,则不处理 如果代码中的接口在数据库中已经存在,但内容不同,则更新数据库中的 如果代码中的接口在数据库中不存在,则插入数据库
*
* @param mapCode 代码中的接口
* @param mapDb 数据库中的接口
* @return
*/
private List<Interface> diff(Map<String, Interface> mapCode, Map<String, Interface> mapDb) {
List<Interface> interfaceList = new ArrayList<>();
for (Map.Entry<String, Interface> entry : mapCode.entrySet()) {
String key = entry.getKey();
Interface interCode = entry.getValue();
if (mapDb.containsKey(key)) {
Interface interDb = mapDb.get(key);
if (!interCode.isSimilar(interDb)) {
interDb.setName(interCode.getName());
interDb.setTag(interCode.getTag());
interDb.setNotes(interCode.getNotes());
interDb.setAuthorized(interCode.isAuthorized());
interDb.setPublicInterface(interCode.isPublicInterface());
interfaceList.add(interDb);
}
} else {
interCode.setGuid(CommonUtils.getUUID());
interfaceList.add(interCode);
}
}
return interfaceList;
}
private Map<String, Interface> getIntergfaceFromDb() {
List<Interface> list = interfaceService.list();
Map<String, Interface> map = new HashMap<>(list.size());
for (Interface inter : list) {
map.put(inter.getUrl() + inter.getMethodType(), inter);
log.debug(
"interface:{},{},{},{}",
inter.getName(),
inter.getTag(),
inter.getUrl(),
inter.getMethodType());
}
return map;
}
private Map<String, Interface> getInterfaceFromCode() {
Map<String, Interface> map = new HashMap<>();
Map<RequestMappingInfo, HandlerMethod> map1 = handlerMapping.getHandlerMethods();
for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : map1.entrySet()) {
RequestMappingInfo info = entry.getKey();
String url = info.getPatternsCondition().toString();
if (StringUtils.isEmpty(url)) {
continue;
}
if (isSwaggerUrl(url)) {
continue;
}
HandlerMethod method = entry.getValue();
Interface inter = new Interface();
inter.setUrl(processUrl(url));
if (info.getMethodsCondition().isEmpty()) {
continue;
} else {
inter.setMethodType(replaceBrackets(info.getMethodsCondition().toString()));
}
ApiOperation annotation = method.getMethodAnnotation(ApiOperation.class);
if (annotation == null) {
inter.setName(method.getMethod().getName());
inter.setNotes(method.getMethod().getName());
inter.setTag(method.getBeanType().getSimpleName());
} else {
inter.setName(annotation.value());
inter.setTag(annotation.tags()[0]);
inter.setNotes(annotation.notes());
}
inter.setPublicInterface(method.hasMethodAnnotation(Public.class));
inter.setAuthorized(
!inter.isPublicInterface() && !method.hasMethodAnnotation(NoAuthorized.class));
map.put(inter.getUrl() + inter.getMethodType(), inter);
}
return map;
}
private boolean isSwaggerUrl(String url) {
for (String swaggerUrl : SWAGGER_PATHS) {
if (url.contains(swaggerUrl)) {
return true;
}
}
return false;
}
/** 处理url */
public String processUrl(String url) {
url = replaceBrackets(url);
if (isNeedMatch(url)) {
return toRegular(url);
}
return url;
}
/** 去除中括号 */
private String replaceBrackets(String str) {
if (str.startsWith("[") && str.endsWith("]")) {
return str.substring(1, str.length() - 1);
}
return str;
}
/** 转为正则表达式 */
private String toRegular(String url) {
int start = url.indexOf("{");
int end = url.indexOf("}");
url = url.substring(0, start) + MATCH_URL_PARAM + url.substring(end + 1);
if (isNeedMatch(url)) {
return toRegular(url);
} else {
url = "^" + url;
url = url.replace("/", "\\/");
return url;
}
}
private boolean isNeedMatch(String str) {
return str.contains("{") && str.contains("}");
}
}
| 8,060 | 0.617973 | 0.614532 | 217 | 35.152073 | 25.462902 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62212 | false | false | 2 |
c0674127f374a8e372641cbef8ad98a88ff5472b | 1,666,447,375,450 | fb213b4d73ff48dd528a9557e77aee8dc303ae6f | /TestCasesforPalindrome.java | 56fda864bea9de2c07f11b435d08902be4843fc7 | [] | no_license | singh-aakash/java-Assignments | https://github.com/singh-aakash/java-Assignments | d845f5fe6399cb4537b9e1d8e8d117f38bf4f188 | f141d9b99cb01c9d3fecfd233dfc3ad382a42180 | refs/heads/master | 2020-04-10T16:04:41.971000 | 2018-12-19T13:22:10 | 2018-12-19T13:22:10 | 161,132,360 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import org.junit.Test;
public class TestCasesforPalindrome {
@Test
public void test() {
MultiplePalindrome multiplePalindrome = new MultiplePalindrome();
String[] inputnames = {"MAM", "NITIN", "INIT", "RAW", "AKASH", "SAS", "FOX", "TET", "MEET","JICKY"};
String[] reSults = {"TET","SAS","NITIN","MAM"};
ArrayList<String> actual_String_Array = multiplePalindrome.palindromefinder(inputnames);
assertEquals(reSults, actual_String_Array);
}
@Test
public void test2() {
MultiplePalindrome multiplePalindrome = new MultiplePalindrome();
String[] inputnames = {"MAM", "NITIN", "INIT", "RAW", "AKASH", "SAS", "FOX", "TET", "MEET","JICKY"};
String[] reSults = {"TET,","SAS,","NITIN"};
ArrayList<String> actual_String_Array = multiplePalindrome.palindromefinder(inputnames);
assertEquals(reSults, actual_String_Array);
}
}
| UTF-8 | Java | 948 | java | TestCasesforPalindrome.java | Java | [
{
"context": " MultiplePalindrome();\r\n\t\tString[] inputnames = {\"MAM\", \"NITIN\", \"INIT\", \"RAW\", \"AKASH\", \"SAS\", \"FOX\", ",
"end": 277,
"score": 0.9984334707260132,
"start": 274,
"tag": "NAME",
"value": "MAM"
},
{
"context": "lePalindrome();\r\n\t\tString[] inputnames =... | null | [] | import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import org.junit.Test;
public class TestCasesforPalindrome {
@Test
public void test() {
MultiplePalindrome multiplePalindrome = new MultiplePalindrome();
String[] inputnames = {"MAM", "NITIN", "INIT", "RAW", "AKASH", "SAS", "FOX", "TET", "MEET","JICKY"};
String[] reSults = {"TET","SAS","NITIN","MAM"};
ArrayList<String> actual_String_Array = multiplePalindrome.palindromefinder(inputnames);
assertEquals(reSults, actual_String_Array);
}
@Test
public void test2() {
MultiplePalindrome multiplePalindrome = new MultiplePalindrome();
String[] inputnames = {"MAM", "NITIN", "INIT", "RAW", "AKASH", "SAS", "FOX", "TET", "MEET","JICKY"};
String[] reSults = {"TET,","SAS,","NITIN"};
ArrayList<String> actual_String_Array = multiplePalindrome.palindromefinder(inputnames);
assertEquals(reSults, actual_String_Array);
}
}
| 948 | 0.681435 | 0.68038 | 28 | 31.857143 | 33.577965 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.357143 | false | false | 2 |
16c1ca9382e8e8bc0a7a3e1d0d2e6ea3b59eda61 | 20,590,073,267,993 | f62a87ef1ace7951f983fe89b2454fb771be2750 | /Health/app/src/main/java/com/application/health/ValueUserFoodMenu.java | f4c70d6b13f1eedc96f196ee9e85e4258697f538 | [] | no_license | Antoshka-Tkachev/Health | https://github.com/Antoshka-Tkachev/Health | e8236a63535994a0bca4c1f925881449318a3b83 | 37fcf015136609c433774d5d6f5bb4e78b47feec | refs/heads/master | 2021-01-14T03:57:48.916000 | 2020-07-29T11:30:33 | 2020-07-29T11:30:33 | 244,627,909 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.application.health;
import java.util.ArrayList;
public class ValueUserFoodMenu {
private ArrayList<String> nameMenus;
private ArrayList<ValueUserFoodMenuHelper> productsInFoodMenu;
private String name;
private int number;
private long userId;
private static ValueUserFoodMenu instance;
private ValueUserFoodMenu(){}
public static ValueUserFoodMenu getInstance(){
if (instance == null){ //если объект еще не создан
instance = new ValueUserFoodMenu(); //создать новый объект
}
return instance; // вернуть ранее созданный объект
}
public ArrayList<String> getNameMenus() {
return nameMenus;
}
public void setNameMenus(ArrayList<String> nameMenus) {
this.nameMenus = nameMenus;
}
public ArrayList<ValueUserFoodMenuHelper> getProductsInFoodMenu() {
return productsInFoodMenu;
}
public void setProductsInFoodMenu(ArrayList<ValueUserFoodMenuHelper> productsInFoodMenu) {
this.productsInFoodMenu = productsInFoodMenu;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public void createNewName() {
String newName = "Новое меню";
boolean nameIsFree = true;
for (int i = 0; i < nameMenus.size(); i++) {
if (nameMenus.get(i).equals(newName)) {
nameIsFree = false;
break;
}
}
if (nameIsFree) {
name = newName;
return;
}
int count = 1;
String bufferNewName = "";
while (!nameIsFree) {
bufferNewName = newName + count;
nameIsFree = true;
for (int i = 0; i < nameMenus.size(); i++) {
if (nameMenus.get(i).equals(bufferNewName)) {
nameIsFree = false;
count++;
break;
}
}
}
name = bufferNewName;
}
}
| UTF-8 | Java | 2,493 | java | ValueUserFoodMenu.java | Java | [] | null | [] | package com.application.health;
import java.util.ArrayList;
public class ValueUserFoodMenu {
private ArrayList<String> nameMenus;
private ArrayList<ValueUserFoodMenuHelper> productsInFoodMenu;
private String name;
private int number;
private long userId;
private static ValueUserFoodMenu instance;
private ValueUserFoodMenu(){}
public static ValueUserFoodMenu getInstance(){
if (instance == null){ //если объект еще не создан
instance = new ValueUserFoodMenu(); //создать новый объект
}
return instance; // вернуть ранее созданный объект
}
public ArrayList<String> getNameMenus() {
return nameMenus;
}
public void setNameMenus(ArrayList<String> nameMenus) {
this.nameMenus = nameMenus;
}
public ArrayList<ValueUserFoodMenuHelper> getProductsInFoodMenu() {
return productsInFoodMenu;
}
public void setProductsInFoodMenu(ArrayList<ValueUserFoodMenuHelper> productsInFoodMenu) {
this.productsInFoodMenu = productsInFoodMenu;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public void createNewName() {
String newName = "Новое меню";
boolean nameIsFree = true;
for (int i = 0; i < nameMenus.size(); i++) {
if (nameMenus.get(i).equals(newName)) {
nameIsFree = false;
break;
}
}
if (nameIsFree) {
name = newName;
return;
}
int count = 1;
String bufferNewName = "";
while (!nameIsFree) {
bufferNewName = newName + count;
nameIsFree = true;
for (int i = 0; i < nameMenus.size(); i++) {
if (nameMenus.get(i).equals(bufferNewName)) {
nameIsFree = false;
count++;
break;
}
}
}
name = bufferNewName;
}
}
| 2,493 | 0.547974 | 0.546733 | 97 | 22.927835 | 20.931034 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.443299 | false | false | 2 |
7ac11df838c6d73761977b6aeb2100de3cee375d | 34,797,825,044,669 | 58299717e0b471abf602afbd3c37adac7bc6c8fc | /src/datastructures/linkedlist/delete/Node.java | f4d2432d49ba82b491c5d78b01db8c4fb13b9698 | [] | no_license | mantonioisc/hacker-rank | https://github.com/mantonioisc/hacker-rank | 25ed2d1f6f58dc046b2e36497a269dfccc017797 | a4879006dc4fb9f7340ff0297c0132b10ee283aa | refs/heads/master | 2021-06-03T04:27:02.789000 | 2020-06-18T21:44:08 | 2020-06-18T21:44:08 | 97,062,256 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package datastructures.linkedlist.delete;
public class Node {
int data;
Node next;
Node Delete(Node head, int position) {
if (head != null) {
if (position == 0) {
Node newHead = head.next;
head.next = null;//make Node instance available for gc
return newHead;
} else if (position == 1) {//Special case for the second on list, this is not needed when inserting!!!
Node removed = head.next;
head.next = removed.next;
removed.next = null;//make Node instance available for gc
} else if (head.next != null) {//For position >= 2. The null check is to protect against a bigger index passed in a list of one element
int i = 1;//1 must be one or it will fail
Node ith = head.next;//Since we have a special case for pos=1, we need to start a node after that compared to insertion algorithm
while (i++ < position - 1 && ith.next != null) {//(pos - 1) since we are stopping 1 node before the one we want to remove
ith = ith.next;
}
if (ith.next != null) {//if position > size nothing will happen, this "if" is to guard against NPE
Node removed = ith.next;
ith.next = removed.next;
removed.next = null;//make Node instance available for gc
}
}
}
return head;
}
public static Node delete(Node head, int position) {
return new Node().Delete(head, position);
}
}
| UTF-8 | Java | 1,629 | java | Node.java | Java | [] | null | [] | package datastructures.linkedlist.delete;
public class Node {
int data;
Node next;
Node Delete(Node head, int position) {
if (head != null) {
if (position == 0) {
Node newHead = head.next;
head.next = null;//make Node instance available for gc
return newHead;
} else if (position == 1) {//Special case for the second on list, this is not needed when inserting!!!
Node removed = head.next;
head.next = removed.next;
removed.next = null;//make Node instance available for gc
} else if (head.next != null) {//For position >= 2. The null check is to protect against a bigger index passed in a list of one element
int i = 1;//1 must be one or it will fail
Node ith = head.next;//Since we have a special case for pos=1, we need to start a node after that compared to insertion algorithm
while (i++ < position - 1 && ith.next != null) {//(pos - 1) since we are stopping 1 node before the one we want to remove
ith = ith.next;
}
if (ith.next != null) {//if position > size nothing will happen, this "if" is to guard against NPE
Node removed = ith.next;
ith.next = removed.next;
removed.next = null;//make Node instance available for gc
}
}
}
return head;
}
public static Node delete(Node head, int position) {
return new Node().Delete(head, position);
}
}
| 1,629 | 0.546961 | 0.541436 | 38 | 41.86842 | 41.048862 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.605263 | false | false | 2 |
84033764c45b95e1023c543950bb53d0b9bbcb45 | 13,769,665,167,357 | f7d089477995461b11d7808096c69dda7995da61 | /E-Adventure/src/main/java/es/eucm/eadventure/engine/core/control/functionaldata/FunctionalBookImage.java | 3f6b04132926b30fc6865f2d0aade789a92b26c9 | [] | no_license | angeldelblanco/eadventure-legacy | https://github.com/angeldelblanco/eadventure-legacy | 3b20616313498aa024847a94dff63eead022f35e | dcc52f41d4bef8be5bcc4360bbed971f79a1a3d7 | refs/heads/master | 2020-12-13T19:56:18.709000 | 2013-10-18T10:50:24 | 2013-10-18T10:50:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*******************************************************************************
* eAdventure (formerly <e-Adventure> and <e-Game>) is a research project of the e-UCM
* research group.
*
* Copyright 2005-2012 e-UCM research group.
*
* e-UCM is a research group of the Department of Software Engineering
* and Artificial Intelligence at the Complutense University of Madrid
* (School of Computer Science).
*
* C Profesor Jose Garcia Santesmases sn,
* 28040 Madrid (Madrid), Spain.
*
* For more info please visit: <http://e-adventure.e-ucm.es> or
* <http://www.e-ucm.es>
*
* ****************************************************************************
* This file is part of eAdventure, version 1.5.
*
* You can access a list of all the contributors to eAdventure at:
* http://e-adventure.e-ucm.es/contributors
*
* ****************************************************************************
* eAdventure is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* eAdventure is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Adventure. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package es.eucm.eadventure.engine.core.control.functionaldata;
import java.awt.Graphics2D;
import java.awt.Image;
import es.eucm.eadventure.common.data.chapter.book.BookParagraph;
import es.eucm.eadventure.engine.multimedia.MultimediaManager;
/**
* This is a image that can be put in a book scene
*/
public class FunctionalBookImage extends FunctionalBookParagraph {
/**
* The image book
*/
private BookParagraph bookImage;
/**
* The image of the image book
*/
private Image image;
/**
* Creates a new FunctionalBookImage
*
* @param image
* the image to be rendered
*/
public FunctionalBookImage( BookParagraph image ) {
//set the book image
this.bookImage = image;
//and loads the image
this.image = MultimediaManager.getInstance( ).loadImageFromZip( bookImage.getContent( ), MultimediaManager.IMAGE_SCENE );
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#canBeSplitted()
*/
@Override
public boolean canBeSplitted( ) {
return false;
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#draw(java.awt.Graphics2D, int, int)
*/
@Override
public void draw( Graphics2D g, int x, int y ) {
//This book only draw a image
g.drawImage( image, x, y + 5, null );
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#getHeight()
*/
@Override
public int getHeight( ) {
//The height of the book is the height of the image
return (int) Math.ceil( ( image.getHeight( null ) + 5 ) / (double) FunctionalTextBook.LINE_HEIGHT ) * FunctionalTextBook.LINE_HEIGHT;
}
}
| UTF-8 | Java | 3,793 | java | FunctionalBookImage.java | Java | [
{
"context": "f Computer Science).\r\n * \r\n * C Profesor Jose Garcia Santesmases sn,\r\n * 28040 Madrid (Madrid), Spain.\r\n * ",
"end": 516,
"score": 0.9992193579673767,
"start": 490,
"tag": "NAME",
"value": "Jose Garcia Santesmases sn"
}
] | null | [] | /*******************************************************************************
* eAdventure (formerly <e-Adventure> and <e-Game>) is a research project of the e-UCM
* research group.
*
* Copyright 2005-2012 e-UCM research group.
*
* e-UCM is a research group of the Department of Software Engineering
* and Artificial Intelligence at the Complutense University of Madrid
* (School of Computer Science).
*
* C Profesor <NAME>,
* 28040 Madrid (Madrid), Spain.
*
* For more info please visit: <http://e-adventure.e-ucm.es> or
* <http://www.e-ucm.es>
*
* ****************************************************************************
* This file is part of eAdventure, version 1.5.
*
* You can access a list of all the contributors to eAdventure at:
* http://e-adventure.e-ucm.es/contributors
*
* ****************************************************************************
* eAdventure is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* eAdventure is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Adventure. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package es.eucm.eadventure.engine.core.control.functionaldata;
import java.awt.Graphics2D;
import java.awt.Image;
import es.eucm.eadventure.common.data.chapter.book.BookParagraph;
import es.eucm.eadventure.engine.multimedia.MultimediaManager;
/**
* This is a image that can be put in a book scene
*/
public class FunctionalBookImage extends FunctionalBookParagraph {
/**
* The image book
*/
private BookParagraph bookImage;
/**
* The image of the image book
*/
private Image image;
/**
* Creates a new FunctionalBookImage
*
* @param image
* the image to be rendered
*/
public FunctionalBookImage( BookParagraph image ) {
//set the book image
this.bookImage = image;
//and loads the image
this.image = MultimediaManager.getInstance( ).loadImageFromZip( bookImage.getContent( ), MultimediaManager.IMAGE_SCENE );
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#canBeSplitted()
*/
@Override
public boolean canBeSplitted( ) {
return false;
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#draw(java.awt.Graphics2D, int, int)
*/
@Override
public void draw( Graphics2D g, int x, int y ) {
//This book only draw a image
g.drawImage( image, x, y + 5, null );
}
/*
* (non-Javadoc)
* @see es.eucm.eadventure.engine.core.control.functionaldata.FunctionalBookParagraph#getHeight()
*/
@Override
public int getHeight( ) {
//The height of the book is the height of the image
return (int) Math.ceil( ( image.getHeight( null ) + 5 ) / (double) FunctionalTextBook.LINE_HEIGHT ) * FunctionalTextBook.LINE_HEIGHT;
}
}
| 3,773 | 0.580279 | 0.574743 | 106 | 33.78302 | 33.525547 | 141 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.264151 | false | false | 2 |
a1d251eaa871ed4d7be1ee6bab6f3e6b16128c88 | 36,137,854,832,879 | bfc3eab6658f7199c232d3d23698d17faebd5842 | /src/ar/sgt/android/smsscheduler/widget/MessageAdapter.java | 8cea08d97fe385126e1c23d16d20fca9412b76c1 | [] | no_license | dahool/SMSScheduller | https://github.com/dahool/SMSScheduller | d15c4079d5883d0ef013a20598185f0180e4113f | b5c0976114d018170be1cb8f73a5c5481ca9c518 | refs/heads/master | 2020-12-02T17:24:46.533000 | 2013-10-03T23:38:11 | 2013-10-03T23:38:11 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ar.sgt.android.smsscheduler.widget;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import ar.sgt.android.smsscheduler.R;
import ar.sgt.android.smsscheduler.db.model.Message;
import ar.sgt.android.smsscheduler.utils.ContactHelper;
public class MessageAdapter extends ArrayAdapter<Message> {
private Context context;
private int layoutResourceId;
private List<Message> objects = null;
public MessageAdapter(Context context, int layoutResourceId,
List<Message> objects) {
super(context, layoutResourceId, objects);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.objects = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
MessageHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new MessageHolder();
holder.title = (TextView) row.findViewById(R.id.txtTitle);
holder.message = (TextView) row.findViewById(R.id.txtMessage);
holder.schDate = (TextView) row.findViewById(R.id.txtDate);
holder.status = (ImageView) row.findViewById(R.id.imgStatus);
row.setTag(holder);
} else {
holder = (MessageHolder) row.getTag();
}
Message message = objects.get(position);
holder.setId(message.getId());
holder.setTitle(formatContact(message.getContactId()));
holder.setMessage(message.getMessage());
holder.setSchDate(formatDate(message.getSendDate()));
holder.setStatus(message.getStatus());
return row;
}
private String formatContact(String value) {
String name = ContactHelper.findContactName(context, value);
return name == null ? value : name;
}
private String formatDate(Date value) {
return DateFormat.getDateTimeInstance().format(value);
}
static class MessageHolder {
private long id;
private TextView title;
private TextView message;
private TextView schDate;
private ImageView status;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public TextView getTitle() {
return title;
}
public void setTitle(TextView title) {
this.title = title;
}
public void setTitle(String title) {
this.title.setText(title);
}
public TextView getMessage() {
return message;
}
public void setMessage(TextView message) {
this.message = message;
}
public void setMessage(String message) {
this.message.setText(message);
}
public TextView getSchDate() {
return schDate;
}
public void setSchDate(TextView schDate) {
this.schDate = schDate;
}
public void setSchDate(String schDate) {
this.schDate.setText(schDate);
}
public ImageView getStatus() {
return status;
}
public void setStatus(int status) {
switch (status) {
case 1:
this.status.setImageResource(R.drawable.ic_status_ok);
break;
case 2:
this.status.setImageResource(R.drawable.ic_status_error);
break;
default:
this.status.setImageResource(R.drawable.ic_status_p);
break;
}
}
}
}
| UTF-8 | Java | 3,396 | java | MessageAdapter.java | Java | [] | null | [] | package ar.sgt.android.smsscheduler.widget;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import ar.sgt.android.smsscheduler.R;
import ar.sgt.android.smsscheduler.db.model.Message;
import ar.sgt.android.smsscheduler.utils.ContactHelper;
public class MessageAdapter extends ArrayAdapter<Message> {
private Context context;
private int layoutResourceId;
private List<Message> objects = null;
public MessageAdapter(Context context, int layoutResourceId,
List<Message> objects) {
super(context, layoutResourceId, objects);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.objects = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
MessageHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new MessageHolder();
holder.title = (TextView) row.findViewById(R.id.txtTitle);
holder.message = (TextView) row.findViewById(R.id.txtMessage);
holder.schDate = (TextView) row.findViewById(R.id.txtDate);
holder.status = (ImageView) row.findViewById(R.id.imgStatus);
row.setTag(holder);
} else {
holder = (MessageHolder) row.getTag();
}
Message message = objects.get(position);
holder.setId(message.getId());
holder.setTitle(formatContact(message.getContactId()));
holder.setMessage(message.getMessage());
holder.setSchDate(formatDate(message.getSendDate()));
holder.setStatus(message.getStatus());
return row;
}
private String formatContact(String value) {
String name = ContactHelper.findContactName(context, value);
return name == null ? value : name;
}
private String formatDate(Date value) {
return DateFormat.getDateTimeInstance().format(value);
}
static class MessageHolder {
private long id;
private TextView title;
private TextView message;
private TextView schDate;
private ImageView status;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public TextView getTitle() {
return title;
}
public void setTitle(TextView title) {
this.title = title;
}
public void setTitle(String title) {
this.title.setText(title);
}
public TextView getMessage() {
return message;
}
public void setMessage(TextView message) {
this.message = message;
}
public void setMessage(String message) {
this.message.setText(message);
}
public TextView getSchDate() {
return schDate;
}
public void setSchDate(TextView schDate) {
this.schDate = schDate;
}
public void setSchDate(String schDate) {
this.schDate.setText(schDate);
}
public ImageView getStatus() {
return status;
}
public void setStatus(int status) {
switch (status) {
case 1:
this.status.setImageResource(R.drawable.ic_status_ok);
break;
case 2:
this.status.setImageResource(R.drawable.ic_status_error);
break;
default:
this.status.setImageResource(R.drawable.ic_status_p);
break;
}
}
}
}
| 3,396 | 0.724971 | 0.724382 | 130 | 25.123077 | 19.792002 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.407692 | false | false | 2 |
11a2e681eb8c6cb67556e54c5e480625ac82bbfd | 36,137,854,830,168 | c836dcd4a96d0be9841bfcf8234565d738518f43 | /shop/src/main/java/com/eleven/shop/dao/NewsDao.java | 52d87d9b412a0b24be7c21d4b42034775e6cb647 | [] | no_license | mrgswen/shop | https://github.com/mrgswen/shop | ace172a724956db9371081894f0d83afe810ae94 | 1b028d7779c678a089d35c38b98e648cb8d6761c | refs/heads/master | 2021-05-07T19:29:33.145000 | 2017-10-31T00:20:40 | 2017-10-31T00:20:40 | 108,923,185 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.eleven.shop.dao;
import com.eleven.shop.bean.News;
public interface NewsDao extends BaseDao<News>{
}
| UTF-8 | Java | 126 | java | NewsDao.java | Java | [] | null | [] | package com.eleven.shop.dao;
import com.eleven.shop.bean.News;
public interface NewsDao extends BaseDao<News>{
}
| 126 | 0.714286 | 0.714286 | 7 | 16 | 18.126539 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 2 |
bea56e784ce6ab7e844b5f385a87db2b6da39305 | 28,930,899,767,983 | 12b78dc1b16a55e53652ef13b6872916d5b5daea | /smsm-dao/src/main/java/com/smsm/mapper/CompanyMapper.java | 0732964975ebb98fe1873e298608201ea81f19a3 | [] | no_license | yangqi0224/spring-boot-web | https://github.com/yangqi0224/spring-boot-web | 62788b6e43ec286369d22ce83514e1178bbd25b3 | 6082a987d061f2c815f98ee304ebe3fa43c627fb | refs/heads/master | 2020-06-15T17:41:56.522000 | 2019-07-05T07:00:00 | 2019-07-05T07:00:00 | 195,355,313 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.smsm.mapper;
import com.smsm.model.*;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface CompanyMapper {
long countByExample(CompanyExample example);
int deleteByExample(CompanyExample example);
int deleteByPrimaryKey(String companyId);
int insert(Company record);
List<Company> selectByExampleWithBLOBs(CompanyExample example);
List<Company> selectByExample(CompanyExample example);
Company selectByPrimaryKey(String companyId);
int updateByExampleSelective(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByExampleWithBLOBs(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByExample(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByPrimaryKeySelective(Company record);
int updateByPrimaryKeyWithBLOBs(Company record);
int updateByPrimaryKey(Company record);
int insertSelective1(User user);
int updateByPrimaryKey1(User user);
Company selectByPrimaryKey1(String companyName);
Company getCompanyBuUserPhone(String userPhone);
//更新一条公司记录
int updateCompanyInfo(Company record);
//插入一条公司信息
int insertCompanyInfo(Company record);
//查找所有公司
List<Company> findAllCompany();
Company selectCompanyById(String companyId);
int uploadImage(@Param("userPhone")String userPhone,@Param("imgName")String imgName);
} | UTF-8 | Java | 1,514 | java | CompanyMapper.java | Java | [] | null | [] | package com.smsm.mapper;
import com.smsm.model.*;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface CompanyMapper {
long countByExample(CompanyExample example);
int deleteByExample(CompanyExample example);
int deleteByPrimaryKey(String companyId);
int insert(Company record);
List<Company> selectByExampleWithBLOBs(CompanyExample example);
List<Company> selectByExample(CompanyExample example);
Company selectByPrimaryKey(String companyId);
int updateByExampleSelective(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByExampleWithBLOBs(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByExample(@Param("record") Company record, @Param("example") CompanyExample example);
int updateByPrimaryKeySelective(Company record);
int updateByPrimaryKeyWithBLOBs(Company record);
int updateByPrimaryKey(Company record);
int insertSelective1(User user);
int updateByPrimaryKey1(User user);
Company selectByPrimaryKey1(String companyName);
Company getCompanyBuUserPhone(String userPhone);
//更新一条公司记录
int updateCompanyInfo(Company record);
//插入一条公司信息
int insertCompanyInfo(Company record);
//查找所有公司
List<Company> findAllCompany();
Company selectCompanyById(String companyId);
int uploadImage(@Param("userPhone")String userPhone,@Param("imgName")String imgName);
} | 1,514 | 0.765986 | 0.763946 | 54 | 26.24074 | 29.828482 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.703704 | false | false | 2 |
bbe8b274facef5378dc3affdd1b605051c2f9998 | 7,799,660,629,613 | 2696b09417f4038e1206334d47821807ba5d76f7 | /Simulator/src/main/java/ui/script/ScriptPopupItemCommandVariable.java | b49d46b7c5402faa5ac3182a2b54ffc97493c77f | [
"Apache-2.0",
"LGPL-3.0-only",
"LicenseRef-scancode-proprietary-license",
"BSD-3-Clause",
"CC-BY-4.0",
"CC0-1.0",
"CC-BY-3.0",
"CDDL-1.1",
"CC-BY-NC-4.0",
"LGPL-2.1-only",
"CC-BY-NC-SA-4.0",
"EPL-2.0",
"JSON",
"CDDL-1.0",
"MIT",
"LGPL-2.0-or-later",
"Zlib",
"MPL-2.0",
"Classpath-... | permissive | A-Herzog/Warteschlangensimulator | https://github.com/A-Herzog/Warteschlangensimulator | d62b39ae58006da5dff497cf993de40f35f0a79b | ea5f804f8d9425c30c0eb666bfee2c96f93e111a | refs/heads/master | 2023-09-01T08:50:54.103000 | 2023-08-31T23:56:23 | 2023-08-31T23:56:23 | 253,913,348 | 31 | 7 | Apache-2.0 | false | 2023-07-07T22:09:19 | 2020-04-07T21:13:47 | 2023-07-02T21:01:35 | 2023-07-07T22:08:56 | 668,283 | 28 | 8 | 0 | Java | false | false | /**
* Copyright 2020 Alexander Herzog
*
* 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 ui.script;
import java.awt.Component;
import javax.swing.Icon;
import simulator.editmodel.EditModel;
import systemtools.BaseDialog;
/**
* Popupmenü-Eintrag zur Ausführung eines Befehls, der einen Variablennamen enthält
* @author Alexander Herzog
* @see ScriptPopupItemCommandModel
*/
public class ScriptPopupItemCommandVariable extends ScriptPopupItemCommandModel {
/**
* Konstruktor der Klasse
* @param name Name des Eintrags (kann <code>null</code> sein)
* @param hint Tooltip des Eintrags (kann <code>null</code> sein)
* @param icon Icon für den Eintrag (kann <code>null</code> sein)
* @param command Befehl, der in das Textfeld eingefügt werden soll (muss ein "%s" enthalten).
* @param owner Übergeordnetes Element (zur Ausrichtung des Dialogs)
* @param model Editor-Modell dem die Daten entnommen werden sollen
* @param help Hilfe-Runnable (für Dialog)
*/
public ScriptPopupItemCommandVariable(final String name, final String hint, final Icon icon, final String command, final Component owner, final EditModel model, final Runnable help) {
super(name,hint,icon,command,owner,model,help);
}
@Override
protected String getParameter(final Component owner, final EditModel model, final Runnable help) {
final SelectVariableDialog dialog=new SelectVariableDialog(owner,model,help);
if (dialog.getClosedBy()!=BaseDialog.CLOSED_BY_OK) return null;
return dialog.getVariableName();
}
}
| WINDOWS-1252 | Java | 2,087 | java | ScriptPopupItemCommandVariable.java | Java | [
{
"context": "/**\r\n * Copyright 2020 Alexander Herzog\r\n *\r\n * Licensed under the Apache License, Versio",
"end": 39,
"score": 0.9998704195022583,
"start": 23,
"tag": "NAME",
"value": "Alexander Herzog"
},
{
"context": "ehls, der einen Variablennamen enthält\r\n * @author Alexan... | null | [] | /**
* Copyright 2020 <NAME>
*
* 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 ui.script;
import java.awt.Component;
import javax.swing.Icon;
import simulator.editmodel.EditModel;
import systemtools.BaseDialog;
/**
* Popupmenü-Eintrag zur Ausführung eines Befehls, der einen Variablennamen enthält
* @author <NAME>
* @see ScriptPopupItemCommandModel
*/
public class ScriptPopupItemCommandVariable extends ScriptPopupItemCommandModel {
/**
* Konstruktor der Klasse
* @param name Name des Eintrags (kann <code>null</code> sein)
* @param hint Tooltip des Eintrags (kann <code>null</code> sein)
* @param icon Icon für den Eintrag (kann <code>null</code> sein)
* @param command Befehl, der in das Textfeld eingefügt werden soll (muss ein "%s" enthalten).
* @param owner Übergeordnetes Element (zur Ausrichtung des Dialogs)
* @param model Editor-Modell dem die Daten entnommen werden sollen
* @param help Hilfe-Runnable (für Dialog)
*/
public ScriptPopupItemCommandVariable(final String name, final String hint, final Icon icon, final String command, final Component owner, final EditModel model, final Runnable help) {
super(name,hint,icon,command,owner,model,help);
}
@Override
protected String getParameter(final Component owner, final EditModel model, final Runnable help) {
final SelectVariableDialog dialog=new SelectVariableDialog(owner,model,help);
if (dialog.getClosedBy()!=BaseDialog.CLOSED_BY_OK) return null;
return dialog.getVariableName();
}
}
| 2,067 | 0.744231 | 0.740385 | 51 | 38.784313 | 36.76812 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.215686 | false | false | 2 |
6da40f87c3b0c9d5c5c05f4e6cdb8a8005020ddc | 12,936,441,504,427 | de07eeb45d5ad7002879daed06f19fb18eb7dd43 | /src/Grafica/Stecca.java | f68ca76beaa42bd620012defd11ba777293a9570 | [] | no_license | jMahJong/jMahJong | https://github.com/jMahJong/jMahJong | 52a33866930b8c151fa261f82e37aa6e18bbb1dc | 735af1c904080c6a5925a3b32830d7f7a7971a55 | refs/heads/master | 2016-08-04T14:34:29.530000 | 2011-03-16T17:45:00 | 2011-03-16T17:45:00 | 1,488,099 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Grafica;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JPanel;
import Gioco.*;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class Stecca extends JPanel {
JLabel immaginePedine[] = new JLabel[14];
Giocatore giocatore;
int posizione;
private Image img;
private static final long serialVersionUID = 1L;
public Stecca(Giocatore giocatore, int posizione)
{
this(posizione);
this.giocatore=giocatore;
}
public Stecca(int posizione) {
try
{
this.img = ImageIO.read(new File("images/stecca.png"));
}
catch (IOException ex)
{
Logger.getLogger(Stecca.class.getName()).log(Level.SEVERE, null, ex);
}
this.posizione=posizione;
svuotaStecca();
}
public void aggiornaStecca()
{
ArrayList<Pedina> pedine = giocatore.getMano();
if (posizione == Costanti.GIU)
{
for (int i=0;i<pedine.size();i++)
{
immaginePedine[i] = new PedinaGUI(pedine.get(i),Costanti.GIU);
}
}
else
{
for (int i=0;i<pedine.size();i++)
{
immaginePedine[i] = new PedinaGUI(posizione);
}
}
}
private void svuotaStecca()
{
// DA COMMENTARE ALLA FINE
if (posizione == Costanti.GIU)
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i] = new PedinaGUI("DRAGHI_2.png",posizione);
this.add(immaginePedine[i]);
}
else
{
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i] = new PedinaGUI(posizione);
this.add(immaginePedine[i]);
}
}
// DA DECOMMENTARE ALLA FINE
// for (int i=0;i<immaginePedine.length;i++)
// {
// immaginePedine[i] = new JLabel("");
// this.add(immaginePedine[i]);
// }
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i].addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent event) {
immaginePremutaMouseMousePressed(event);
}
});
}
}
@Override
public void paintComponent(Graphics g)
{
ImageIcon icon = createRotatedImage(new JPanel(), new ImageIcon(this.img), posizione);
// ImageIcon icon = new ImageIcon(this.img);
int iconWidth = icon.getIconWidth();
int iconHeight = icon.getIconHeight();
double iconAspect = (double) iconHeight / iconWidth;
int w = getWidth();
int h = getHeight();
double canvasAspect = (double) h / w;
int x = 0, y = 0;
if(iconAspect < canvasAspect)
{
y = h;
y = (y - h) / 2; // center it along vertical
}
else
{
x = w;
x = (x - w) / 2; // center it along horizontal
}
Image immagine = icon.getImage();
g.drawImage(immagine, x, y, w + x, h + y, 0, 0, iconWidth, iconHeight, null);
}
public static ImageIcon createRotatedImage(Component c, Icon icon, double rotatedAngle)
{
double DEGREE_90 = 90.0 * Math.PI / 180.0;
// convert rotatedAngle to a value from 0 to 360
double originalAngle = rotatedAngle % 360;
if (rotatedAngle != 0 && originalAngle == 0) {
originalAngle = 360.0;
}
// convert originalAngle to a value from 0 to 90
double angle = originalAngle % 90;
if (originalAngle != 0.0 && angle == 0.0) {
angle = 90.0;
}
double radian = Math.toRadians(angle);
int iw = icon.getIconWidth();
int ih = icon.getIconHeight();
int w;
int h;
if ((originalAngle >= 0 && originalAngle <= 90) || (originalAngle > 180 && originalAngle <= 270)) {
w = (int) (iw * Math.sin(DEGREE_90 - radian) + ih * Math.sin(radian));
h = (int) (iw * Math.sin(radian) + ih * Math.sin(DEGREE_90 - radian));
}
else {
w = (int) (ih * Math.sin(DEGREE_90 - radian) + iw * Math.sin(radian));
h = (int) (ih * Math.sin(radian) + iw * Math.sin(DEGREE_90 - radian));
}
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
Graphics2D g2d = (Graphics2D) g.create();
// calculate the center of the icon.
int cx = iw / 2;
int cy = ih / 2;
// move the graphics center point to the center of the icon.
g2d.translate(w/2, h/2);
// rotate the graphcis about the center point of the icon
g2d.rotate(Math.toRadians(originalAngle));
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
icon.paintIcon(c, g2d, -cx, -cy);
g2d.dispose();
return new ImageIcon(image);
}
private void immaginePremutaMouseMousePressed(MouseEvent event) {
Object immaginePremuta = event.getSource();
for (int i=0;i<immaginePedine.length;i++)
{
if (immaginePremuta == immaginePedine[i])
System.out.println("premuta "+i);
}
}
}
| UTF-8 | Java | 5,959 | java | Stecca.java | Java | [] | null | [] | package Grafica;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JPanel;
import Gioco.*;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
public class Stecca extends JPanel {
JLabel immaginePedine[] = new JLabel[14];
Giocatore giocatore;
int posizione;
private Image img;
private static final long serialVersionUID = 1L;
public Stecca(Giocatore giocatore, int posizione)
{
this(posizione);
this.giocatore=giocatore;
}
public Stecca(int posizione) {
try
{
this.img = ImageIO.read(new File("images/stecca.png"));
}
catch (IOException ex)
{
Logger.getLogger(Stecca.class.getName()).log(Level.SEVERE, null, ex);
}
this.posizione=posizione;
svuotaStecca();
}
public void aggiornaStecca()
{
ArrayList<Pedina> pedine = giocatore.getMano();
if (posizione == Costanti.GIU)
{
for (int i=0;i<pedine.size();i++)
{
immaginePedine[i] = new PedinaGUI(pedine.get(i),Costanti.GIU);
}
}
else
{
for (int i=0;i<pedine.size();i++)
{
immaginePedine[i] = new PedinaGUI(posizione);
}
}
}
private void svuotaStecca()
{
// DA COMMENTARE ALLA FINE
if (posizione == Costanti.GIU)
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i] = new PedinaGUI("DRAGHI_2.png",posizione);
this.add(immaginePedine[i]);
}
else
{
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i] = new PedinaGUI(posizione);
this.add(immaginePedine[i]);
}
}
// DA DECOMMENTARE ALLA FINE
// for (int i=0;i<immaginePedine.length;i++)
// {
// immaginePedine[i] = new JLabel("");
// this.add(immaginePedine[i]);
// }
for (int i=0;i<immaginePedine.length;i++)
{
immaginePedine[i].addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent event) {
immaginePremutaMouseMousePressed(event);
}
});
}
}
@Override
public void paintComponent(Graphics g)
{
ImageIcon icon = createRotatedImage(new JPanel(), new ImageIcon(this.img), posizione);
// ImageIcon icon = new ImageIcon(this.img);
int iconWidth = icon.getIconWidth();
int iconHeight = icon.getIconHeight();
double iconAspect = (double) iconHeight / iconWidth;
int w = getWidth();
int h = getHeight();
double canvasAspect = (double) h / w;
int x = 0, y = 0;
if(iconAspect < canvasAspect)
{
y = h;
y = (y - h) / 2; // center it along vertical
}
else
{
x = w;
x = (x - w) / 2; // center it along horizontal
}
Image immagine = icon.getImage();
g.drawImage(immagine, x, y, w + x, h + y, 0, 0, iconWidth, iconHeight, null);
}
public static ImageIcon createRotatedImage(Component c, Icon icon, double rotatedAngle)
{
double DEGREE_90 = 90.0 * Math.PI / 180.0;
// convert rotatedAngle to a value from 0 to 360
double originalAngle = rotatedAngle % 360;
if (rotatedAngle != 0 && originalAngle == 0) {
originalAngle = 360.0;
}
// convert originalAngle to a value from 0 to 90
double angle = originalAngle % 90;
if (originalAngle != 0.0 && angle == 0.0) {
angle = 90.0;
}
double radian = Math.toRadians(angle);
int iw = icon.getIconWidth();
int ih = icon.getIconHeight();
int w;
int h;
if ((originalAngle >= 0 && originalAngle <= 90) || (originalAngle > 180 && originalAngle <= 270)) {
w = (int) (iw * Math.sin(DEGREE_90 - radian) + ih * Math.sin(radian));
h = (int) (iw * Math.sin(radian) + ih * Math.sin(DEGREE_90 - radian));
}
else {
w = (int) (ih * Math.sin(DEGREE_90 - radian) + iw * Math.sin(radian));
h = (int) (ih * Math.sin(radian) + iw * Math.sin(DEGREE_90 - radian));
}
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
Graphics2D g2d = (Graphics2D) g.create();
// calculate the center of the icon.
int cx = iw / 2;
int cy = ih / 2;
// move the graphics center point to the center of the icon.
g2d.translate(w/2, h/2);
// rotate the graphcis about the center point of the icon
g2d.rotate(Math.toRadians(originalAngle));
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
icon.paintIcon(c, g2d, -cx, -cy);
g2d.dispose();
return new ImageIcon(image);
}
private void immaginePremutaMouseMousePressed(MouseEvent event) {
Object immaginePremuta = event.getSource();
for (int i=0;i<immaginePedine.length;i++)
{
if (immaginePremuta == immaginePedine[i])
System.out.println("premuta "+i);
}
}
}
| 5,959 | 0.550092 | 0.536499 | 196 | 29.403061 | 25.623766 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.566326 | false | false | 2 |
2b65eb50f69d43f4f08b1c3d6da7a9aaf596dba3 | 20,177,756,391,110 | fef5296397f9b950a11455e880a919537390aea0 | /java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsManipulationTest.java | 6f199e0e1e58e2eb97d2c2cb6c0aefaec6c9fbb5 | [
"Apache-2.0"
] | permissive | apache/netbeans | https://github.com/apache/netbeans | 5a4d6fa9e4f230b33e44519a479d66e47a381289 | 28d308b400bbe439ac0ac84b64d823ce0b69272e | refs/heads/master | 2023-08-29T15:32:41.838000 | 2023-08-29T09:48:59 | 2023-08-29T09:48:59 | 102,083,576 | 1,692 | 718 | Apache-2.0 | false | 2023-09-14T19:41:05 | 2017-09-01T07:00:11 | 2023-09-14T09:51:47 | 2023-09-14T19:41:04 | 381,002 | 2,386 | 791 | 718 | Java | false | false | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.api.java.source.gen;
import com.sun.source.tree.*;
import org.junit.Test;
import org.netbeans.api.java.source.*;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.modules.java.source.save.PositionEstimator;
import org.netbeans.modules.java.source.query.CommentHandler;
import org.netbeans.modules.java.source.builder.CommentHandlerService;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.TypeKind;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
/**
* @author Rastislav Komara (<a href="mailto:moonko@netbeans.orgm">RKo</a>)
* @todo documentation
*/
public class CommentsManipulationTest extends GeneratorTestBase {
// private final String TEST_CONTENT
public CommentsManipulationTest(String aName) {
super(aName);
}
public static NbTestSuite suite() {
NbTestSuite suite = new NbTestSuite();
suite.addTestSuite(CommentsManipulationTest.class);
return suite;
}
String getGoldenPckg() {
return "";
}
String getSourcePckg() {
return "";
}
/**
* Simulates encapsulate field refactoring with copy javadoc feature.
*
* @throws Exception if something goes wrong.
*/
/* @Test
public void testEncapsulateField() throws Exception {
File testFile = new File(getWorkDir(), "Test.java");
String origin =
"public class EncapsulateField {\n" +
"\n" +
"*//**
* Level of encapsulation
*//*\n" +
"public int encapsulate = 5;" +
"}\n";
TestUtilities.copyStringToFile(testFile, origin);
String golden = "\n" +
"public class NewArrayTest {\n" +
"\n" +
"int[] test = new int[5];" +
"}\n";
JavaSource src = getJavaSource(testFile);
Task<WorkingCopy> task = new Task<WorkingCopy>() {
public void run(WorkingCopy workingCopy) throws Exception {
workingCopy.toPhase(JavaSource.Phase.RESOLVED);
CompilationUnitTree cut = workingCopy.getCompilationUnit();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
TreeMaker make = workingCopy.getTreeMaker();
Tree setter = createSetter(make, "Encapsulate");
ClassTree toRewrite = make.insertClassMember(clazz, clazz.getMembers().size(), setter);
VariableTree node = (VariableTree) extractOriginalNode(cut);
VariableTree newVar = make.Variable(make.Modifiers(EnumSet.of(Modifier.PRIVATE)), node.getName(), node.getType(), node.getInitializer());
workingCopy.rewrite(clazz, toRewrite);
workingCopy.rewrite(node, newVar);
}
};
src.runModificationTask(task).commit();
String res = TestUtilities.copyFileToString(testFile);
System.out.println(res);
// assertEquals(golden, res);
}*/
private Tree createSetter(TreeMaker make, String name) {
VariableTree parameter = make.Variable(make.Modifiers(EnumSet.of(Modifier.FINAL)), "encapsulate", make.PrimitiveType(TypeKind.INT), null);
return make.Method(make.Modifiers(EnumSet.of(Modifier.PUBLIC)),
"set" + name, make.PrimitiveType(TypeKind.INT),
Collections.<TypeParameterTree>emptyList(),
Collections.<VariableTree>singletonList(parameter),
Collections.<ExpressionTree>emptyList(),
"{;}",
make.Literal(5));
}
private Tree extractOriginalNode(CompilationUnitTree cut) {
List<? extends Tree> classes = cut.getTypeDecls();
if (!classes.isEmpty()) {
ClassTree clazz = (ClassTree) classes.get(0);
List<? extends Tree> trees = clazz.getMembers();
if (trees.size() == 2) {
return trees.get(1);
}
}
throw new IllegalStateException("There is no array declaration in expected place.");
}
public void testAddCommentOnClassTree() throws Exception {
File testFile = new File(getWorkDir(), "Test.java");
String origin =
"public class EncapsulateField {\n" +
"\n" +
"/** Level of encapsulation */\n" +
"public int encapsulate = 5;" +
"}\n";
TestUtilities.copyStringToFile(testFile, origin);
JavaSource src = getJavaSource(testFile);
Task<WorkingCopy> task = new Task<WorkingCopy>() {
public void run(WorkingCopy workingCopy) throws IOException {
workingCopy.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
//
TreeMaker treeMaker = workingCopy.getTreeMaker();
CompilationUnitTree cu = workingCopy.getCompilationUnit();
List<? extends Tree> list = cu.getTypeDecls();
for (int i = 0; i < list.size(); i++) {
Tree tree = list.get(i);
if (tree instanceof ClassTree) {
javax.lang.model.element.Name simpleName = ((ClassTree) tree).getSimpleName();
Tree newClassTree = treeMaker.setLabel(tree, simpleName);
// setup new coment
setComment("What's up?\n", treeMaker, newClassTree, workingCopy.getTreeUtilities());
workingCopy.rewrite(tree, newClassTree);
}
}
}
public void setComment(String commentText, TreeMaker treeMaker, Tree commentTree, TreeUtilities utils) {
int found = -1;
List<Comment> comments = utils.getComments(commentTree, true);
for (int i = 0; i < comments.size() && found == -1; i++) {
Comment comment = comments.get(i);
if (comment.isDocComment()) {
found = i;
}
}
if (found != -1) {
treeMaker.removeComment(commentTree, found, true);
}
if (commentText != null) {
Comment comment = Comment.create(Comment.Style.JAVADOC, PositionEstimator.NOPOS, PositionEstimator.NOPOS, 1,
commentText);
treeMaker.insertComment(commentTree, comment, found, true);
}
}
};
src.runModificationTask(task).commit();
System.out.println(TestUtilities.copyFileToString(testFile));
}
}
| UTF-8 | Java | 7,528 | java | CommentsManipulationTest.java | Java | [
{
"context": "il.EnumSet;\nimport java.util.List;\n\n/**\n * @author Rastislav Komara (<a href=\"mailto:moonko@netbeans.orgm\">RKo</a>)\n ",
"end": 1421,
"score": 0.9998728632926941,
"start": 1405,
"tag": "NAME",
"value": "Rastislav Komara"
},
{
"context": "\n/**\n * @author Rastisla... | null | [] | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.api.java.source.gen;
import com.sun.source.tree.*;
import org.junit.Test;
import org.netbeans.api.java.source.*;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.modules.java.source.save.PositionEstimator;
import org.netbeans.modules.java.source.query.CommentHandler;
import org.netbeans.modules.java.source.builder.CommentHandlerService;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.TypeKind;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
/**
* @author <NAME> (<a href="mailto:<EMAIL>">RKo</a>)
* @todo documentation
*/
public class CommentsManipulationTest extends GeneratorTestBase {
// private final String TEST_CONTENT
public CommentsManipulationTest(String aName) {
super(aName);
}
public static NbTestSuite suite() {
NbTestSuite suite = new NbTestSuite();
suite.addTestSuite(CommentsManipulationTest.class);
return suite;
}
String getGoldenPckg() {
return "";
}
String getSourcePckg() {
return "";
}
/**
* Simulates encapsulate field refactoring with copy javadoc feature.
*
* @throws Exception if something goes wrong.
*/
/* @Test
public void testEncapsulateField() throws Exception {
File testFile = new File(getWorkDir(), "Test.java");
String origin =
"public class EncapsulateField {\n" +
"\n" +
"*//**
* Level of encapsulation
*//*\n" +
"public int encapsulate = 5;" +
"}\n";
TestUtilities.copyStringToFile(testFile, origin);
String golden = "\n" +
"public class NewArrayTest {\n" +
"\n" +
"int[] test = new int[5];" +
"}\n";
JavaSource src = getJavaSource(testFile);
Task<WorkingCopy> task = new Task<WorkingCopy>() {
public void run(WorkingCopy workingCopy) throws Exception {
workingCopy.toPhase(JavaSource.Phase.RESOLVED);
CompilationUnitTree cut = workingCopy.getCompilationUnit();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
TreeMaker make = workingCopy.getTreeMaker();
Tree setter = createSetter(make, "Encapsulate");
ClassTree toRewrite = make.insertClassMember(clazz, clazz.getMembers().size(), setter);
VariableTree node = (VariableTree) extractOriginalNode(cut);
VariableTree newVar = make.Variable(make.Modifiers(EnumSet.of(Modifier.PRIVATE)), node.getName(), node.getType(), node.getInitializer());
workingCopy.rewrite(clazz, toRewrite);
workingCopy.rewrite(node, newVar);
}
};
src.runModificationTask(task).commit();
String res = TestUtilities.copyFileToString(testFile);
System.out.println(res);
// assertEquals(golden, res);
}*/
private Tree createSetter(TreeMaker make, String name) {
VariableTree parameter = make.Variable(make.Modifiers(EnumSet.of(Modifier.FINAL)), "encapsulate", make.PrimitiveType(TypeKind.INT), null);
return make.Method(make.Modifiers(EnumSet.of(Modifier.PUBLIC)),
"set" + name, make.PrimitiveType(TypeKind.INT),
Collections.<TypeParameterTree>emptyList(),
Collections.<VariableTree>singletonList(parameter),
Collections.<ExpressionTree>emptyList(),
"{;}",
make.Literal(5));
}
private Tree extractOriginalNode(CompilationUnitTree cut) {
List<? extends Tree> classes = cut.getTypeDecls();
if (!classes.isEmpty()) {
ClassTree clazz = (ClassTree) classes.get(0);
List<? extends Tree> trees = clazz.getMembers();
if (trees.size() == 2) {
return trees.get(1);
}
}
throw new IllegalStateException("There is no array declaration in expected place.");
}
public void testAddCommentOnClassTree() throws Exception {
File testFile = new File(getWorkDir(), "Test.java");
String origin =
"public class EncapsulateField {\n" +
"\n" +
"/** Level of encapsulation */\n" +
"public int encapsulate = 5;" +
"}\n";
TestUtilities.copyStringToFile(testFile, origin);
JavaSource src = getJavaSource(testFile);
Task<WorkingCopy> task = new Task<WorkingCopy>() {
public void run(WorkingCopy workingCopy) throws IOException {
workingCopy.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
//
TreeMaker treeMaker = workingCopy.getTreeMaker();
CompilationUnitTree cu = workingCopy.getCompilationUnit();
List<? extends Tree> list = cu.getTypeDecls();
for (int i = 0; i < list.size(); i++) {
Tree tree = list.get(i);
if (tree instanceof ClassTree) {
javax.lang.model.element.Name simpleName = ((ClassTree) tree).getSimpleName();
Tree newClassTree = treeMaker.setLabel(tree, simpleName);
// setup new coment
setComment("What's up?\n", treeMaker, newClassTree, workingCopy.getTreeUtilities());
workingCopy.rewrite(tree, newClassTree);
}
}
}
public void setComment(String commentText, TreeMaker treeMaker, Tree commentTree, TreeUtilities utils) {
int found = -1;
List<Comment> comments = utils.getComments(commentTree, true);
for (int i = 0; i < comments.size() && found == -1; i++) {
Comment comment = comments.get(i);
if (comment.isDocComment()) {
found = i;
}
}
if (found != -1) {
treeMaker.removeComment(commentTree, found, true);
}
if (commentText != null) {
Comment comment = Comment.create(Comment.Style.JAVADOC, PositionEstimator.NOPOS, PositionEstimator.NOPOS, 1,
commentText);
treeMaker.insertComment(commentTree, comment, found, true);
}
}
};
src.runModificationTask(task).commit();
System.out.println(TestUtilities.copyFileToString(testFile));
}
}
| 7,505 | 0.599628 | 0.597237 | 198 | 37.020203 | 30.314341 | 153 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.636364 | false | false | 2 |
9bf923bef6978f1496a06bbd907e3407c600111d | 20,177,756,393,143 | 9cbbaab42e48199c4128ff42e31a1ea955a49595 | /src/main/java/com/mwz/demo/sharebooks/service/UserService.java | 49299c7f4dd5b91818293a12a3ee68d8a5c0801e | [] | no_license | MaWeizheng-4396/sharebooks | https://github.com/MaWeizheng-4396/sharebooks | e2f012aeb0cf1f528f61150f73171249b98f746b | ce40c718228bb093997549ed83e4020b8115d31e | refs/heads/master | 2020-04-13T15:13:06.543000 | 2018-12-27T11:10:45 | 2018-12-27T11:10:45 | 163,284,705 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mwz.demo.sharebooks.service;
import com.mwz.demo.sharebooks.entity.Admin;
import com.mwz.demo.sharebooks.entity.Users;
import org.apache.ibatis.annotations.Param;
public interface UserService {
public Users login(String usersname, String userspwd);
public Integer updata(String idusers ,String users_email,String users_tel);
public Admin adminLogin(@Param("name") String name, @Param("pwd") String pwd);
}
| UTF-8 | Java | 438 | java | UserService.java | Java | [] | null | [] | package com.mwz.demo.sharebooks.service;
import com.mwz.demo.sharebooks.entity.Admin;
import com.mwz.demo.sharebooks.entity.Users;
import org.apache.ibatis.annotations.Param;
public interface UserService {
public Users login(String usersname, String userspwd);
public Integer updata(String idusers ,String users_email,String users_tel);
public Admin adminLogin(@Param("name") String name, @Param("pwd") String pwd);
}
| 438 | 0.76484 | 0.76484 | 15 | 28.200001 | 29.373911 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false | 2 |
4fe4c1c8eade4f0c0a525aa42466ac96679992f3 | 4,200,478,029,216 | 293b1640eba7ddc7dd75a14b33b9aaa803caa906 | /src/ec/ssr/functions/X469.java | ff7c745e73eed5b66bfd36b34ee0374708cf75c9 | [] | no_license | luizvbo/ssr | https://github.com/luizvbo/ssr | a5703087456b3037c64082760c41e98cc31d4dcf | 522ae0b7d72eb60f19cba30b876950871c7ae6db | refs/heads/master | 2020-03-29T20:53:24.718000 | 2016-12-02T00:08:25 | 2016-12-02T00:08:25 | 150,337,098 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ec.ssr.functions;
public class X469 extends X{
@Override
public String getVariableName() {
return "x469";
}
@Override
public int getInputIndex() {
return 468;
}
} | UTF-8 | Java | 182 | java | X469.java | Java | [] | null | [] | package ec.ssr.functions;
public class X469 extends X{
@Override
public String getVariableName() {
return "x469";
}
@Override
public int getInputIndex() {
return 468;
}
} | 182 | 0.703297 | 0.653846 | 13 | 13.076923 | 11.822153 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 2 |
048e75b55306c56fe8275987dce7aafca2674112 | 6,528,350,301,332 | 5999f678df2cd154f6727e2df6c57d97d22ccab9 | /src/main/java/com/moviesapplication/moviesApp/service/MovieService.java | a6eea34d61db1ed04f8b3364baad029e50a94d50 | [] | no_license | nilsys/moviesAppBackEnd-SpringBoot-oracle | https://github.com/nilsys/moviesAppBackEnd-SpringBoot-oracle | 428939e78b01ef618f33dc778a43b3d4036a4579 | 70be9464a69c74a074e767aa953a66133cd903a8 | refs/heads/master | 2022-12-20T12:56:00.838000 | 2020-10-03T04:36:14 | 2020-10-03T04:36:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.moviesapplication.moviesApp.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.moviesapplication.moviesApp.model.MovieModel;
import com.moviesapplication.moviesApp.repository.MovieRepository;
@Service
public class MovieService implements ServiceInt {
@Autowired
private MovieRepository movieRepo;
@Transactional
public void addMovie(MovieModel movie) {
movieRepo.saveMovie(movie);
System.out.println("se agrego una nueva pelicula");
}
@Transactional
public void delMovie(MovieModel movie) {
movieRepo.deleteMovie(movie);
System.out.println("se elimino la pelicula");
}
@Transactional
public void edMovie(MovieModel movie) {
movieRepo.editMovie(movie);
System.out.println("se edito la pelicula");
}
@Transactional
public List<MovieModel> listMovies() {
return movieRepo.allMovies();
}
@Transactional
public List<MovieModel> listGenre(String genre) {
return movieRepo.moviesPerGenre(genre);
}
}
| UTF-8 | Java | 1,123 | java | MovieService.java | Java | [] | null | [] | package com.moviesapplication.moviesApp.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.moviesapplication.moviesApp.model.MovieModel;
import com.moviesapplication.moviesApp.repository.MovieRepository;
@Service
public class MovieService implements ServiceInt {
@Autowired
private MovieRepository movieRepo;
@Transactional
public void addMovie(MovieModel movie) {
movieRepo.saveMovie(movie);
System.out.println("se agrego una nueva pelicula");
}
@Transactional
public void delMovie(MovieModel movie) {
movieRepo.deleteMovie(movie);
System.out.println("se elimino la pelicula");
}
@Transactional
public void edMovie(MovieModel movie) {
movieRepo.editMovie(movie);
System.out.println("se edito la pelicula");
}
@Transactional
public List<MovieModel> listMovies() {
return movieRepo.allMovies();
}
@Transactional
public List<MovieModel> listGenre(String genre) {
return movieRepo.moviesPerGenre(genre);
}
}
| 1,123 | 0.788068 | 0.788068 | 48 | 22.395834 | 21.668659 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.125 | false | false | 2 |
56cfc6575ed6f982d74f99dae03744d8f81168cd | 8,108,898,285,878 | adec64a8595e7af4d208fc46242285046ffe31fc | /src/Task2.java | 47b96009d3fc480e5846d8e332b5560d7130363e | [] | no_license | Elh-Ayoub/course-project | https://github.com/Elh-Ayoub/course-project | 3f26307512bb23bd5c222e999218cd52cb23ba7a | d4944ebea4159a888434cd21a811932e97d4107b | refs/heads/master | 2023-02-05T17:03:43.677000 | 2020-12-23T16:50:17 | 2020-12-23T16:50:17 | 323,955,101 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class Task2 {
private static Scanner relation;
public static Boolean isSubstring(String S, String sub) {
if (S.indexOf(sub) >= 0) {
return true;
}
return false;
}
public static void main(String[] args) {
relation = new Scanner(System.in);
System.out.print("Input two relation separated with ';' : \nR = ");
String R = relation.nextLine();
String R1 = "", R2 = "";
String Result = "";
int ind = R.indexOf(";");
for (int i = 0; i < R.length(); i++) {
if (i < ind) {
R1 += R.charAt(i);
}
if (i > ind) {
R2 += R.charAt(i);
}
}
StringBuilder str = new StringBuilder(R);
int start, end;
while (str.indexOf("(") != -1) {
start = str.lastIndexOf("(");
end = str.indexOf(")", start);
if (!(isSubstring(R2, str.substring(start, end)) && isSubstring(R1, str.substring(start, end)))) {
Result += str.substring(start, end + 1) + " ,";
}
str.replace(start, end + 1, new StringBuilder(str.substring(start + 1, end)).toString());
}
StringBuilder res = new StringBuilder(Result); // the following three line just to make it look better.
res.replace(Result.lastIndexOf(" ,"), Result.length(), ""); // replacing the last comma with empty space
Result = res.toString();
System.out.println("{" + Result + "}");
}
}
| UTF-8 | Java | 1,315 | java | Task2.java | Java | [] | null | [] | import java.util.Scanner;
public class Task2 {
private static Scanner relation;
public static Boolean isSubstring(String S, String sub) {
if (S.indexOf(sub) >= 0) {
return true;
}
return false;
}
public static void main(String[] args) {
relation = new Scanner(System.in);
System.out.print("Input two relation separated with ';' : \nR = ");
String R = relation.nextLine();
String R1 = "", R2 = "";
String Result = "";
int ind = R.indexOf(";");
for (int i = 0; i < R.length(); i++) {
if (i < ind) {
R1 += R.charAt(i);
}
if (i > ind) {
R2 += R.charAt(i);
}
}
StringBuilder str = new StringBuilder(R);
int start, end;
while (str.indexOf("(") != -1) {
start = str.lastIndexOf("(");
end = str.indexOf(")", start);
if (!(isSubstring(R2, str.substring(start, end)) && isSubstring(R1, str.substring(start, end)))) {
Result += str.substring(start, end + 1) + " ,";
}
str.replace(start, end + 1, new StringBuilder(str.substring(start + 1, end)).toString());
}
StringBuilder res = new StringBuilder(Result); // the following three line just to make it look better.
res.replace(Result.lastIndexOf(" ,"), Result.length(), ""); // replacing the last comma with empty space
Result = res.toString();
System.out.println("{" + Result + "}");
}
}
| 1,315 | 0.612167 | 0.602281 | 43 | 29.581396 | 28.234262 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.953488 | false | false | 2 |
87314915e676e023e42de18bf85e0bcecf72669a | 25,142,738,562,089 | 261053ece2f16bdd98cfacb9782d50068d289d91 | /default/ovms/ovms-client/ovms-enterprise-client/src/main/java/com/htstar/ovms/enterprise/api/entity/EtpNotice.java | 524b8c04fe3cc67e6fea26174c00d3b57c256a88 | [] | no_license | jiangdm/java | https://github.com/jiangdm/java | 0e271a2f2980b1bb9f7459bb8c2fcb90d61dfaa9 | 4d9428619247ba4fa3f9513505c62e506ecdaf3b | refs/heads/main | 2023-01-12T15:15:18.300000 | 2020-11-19T09:43:24 | 2020-11-19T09:43:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.htstar.ovms.enterprise.api.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 企业公告
*
* @author lw
* @date 2020-08-10 11:38:31
*/
@Data
@TableName("etp_notice")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "企业公告")
public class EtpNotice extends Model<EtpNotice> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId
@ApiModelProperty(value="主键")
private Integer id;
/**
* 企业id
*/
@ApiModelProperty(value="企业id")
private Integer etpId;
/**
* 公告标题
*/
@ApiModelProperty(value="公告标题")
private String noticeTitle;
/**
* 公告内容
*/
@ApiModelProperty(value="公告内容")
private String noticeContent;
/**
* 发布人id
*/
@ApiModelProperty(value="发布人id")
private Integer putUserId;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value="创建时间")
private LocalDateTime createTime;
/**
* 删除标记 0:正常 1:删除
*/
@ApiModelProperty(value="删除标记 0:正常 1:删除")
private Integer delFlag;
@TableField(exist = false)
@ApiModelProperty(value="企业名称")
private String etpName;
@TableField(exist = false)
@ApiModelProperty(value="发布人员")
private String putUserName;
}
| UTF-8 | Java | 1,858 | java | EtpNotice.java | Java | [
{
"context": "ava.time.LocalDateTime;\n\n/**\n * 企业公告\n *\n * @author lw\n * @date 2020-08-10 11:38:31\n */\n@Data\n@TableName",
"end": 556,
"score": 0.9945053458213806,
"start": 554,
"tag": "USERNAME",
"value": "lw"
}
] | null | [] | package com.htstar.ovms.enterprise.api.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 企业公告
*
* @author lw
* @date 2020-08-10 11:38:31
*/
@Data
@TableName("etp_notice")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "企业公告")
public class EtpNotice extends Model<EtpNotice> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId
@ApiModelProperty(value="主键")
private Integer id;
/**
* 企业id
*/
@ApiModelProperty(value="企业id")
private Integer etpId;
/**
* 公告标题
*/
@ApiModelProperty(value="公告标题")
private String noticeTitle;
/**
* 公告内容
*/
@ApiModelProperty(value="公告内容")
private String noticeContent;
/**
* 发布人id
*/
@ApiModelProperty(value="发布人id")
private Integer putUserId;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value="创建时间")
private LocalDateTime createTime;
/**
* 删除标记 0:正常 1:删除
*/
@ApiModelProperty(value="删除标记 0:正常 1:删除")
private Integer delFlag;
@TableField(exist = false)
@ApiModelProperty(value="企业名称")
private String etpName;
@TableField(exist = false)
@ApiModelProperty(value="发布人员")
private String putUserName;
}
| 1,858 | 0.683353 | 0.672293 | 74 | 22.216217 | 16.724533 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.297297 | false | false | 2 |
cdc8d4fb95c634c4b40113672b141d652028c364 | 22,462,678,970,992 | 6a9ab3f41537947643067761b1c2c1f9cc26a8df | /project/src/main/java/com/rest/demo/sum/Login.java | 013e82b7424fcc901c4deb76780cea3cc64edafb | [] | no_license | suchuantao/sct | https://github.com/suchuantao/sct | 8c6c900af154af8374a65b86dd7a62821ff605fc | 064cdd4b35398a9910ef6f83e5721098879758bb | refs/heads/master | 2021-07-07T00:51:16.188000 | 2020-11-10T09:13:33 | 2020-11-10T09:13:33 | 200,036,830 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.rest.demo.sum;
public class Login {
public boolean login(String name, String pwd) {
if (name.equals(name.equals("admin")) && pwd.equals("123456")) {
return true;
}else{
return false;
}
}
public static void main(String[] args) {
Login login =new Login();
}
}
| UTF-8 | Java | 345 | java | Login.java | Java | [
{
"context": "tring pwd) {\n if (name.equals(name.equals(\"admin\")) && pwd.equals(\"123456\")) {\n return ",
"end": 143,
"score": 0.9860249757766724,
"start": 138,
"tag": "USERNAME",
"value": "admin"
},
{
"context": "(name.equals(name.equals(\"admin\")) && pwd.equa... | null | [] | package com.rest.demo.sum;
public class Login {
public boolean login(String name, String pwd) {
if (name.equals(name.equals("admin")) && pwd.equals("<PASSWORD>")) {
return true;
}else{
return false;
}
}
public static void main(String[] args) {
Login login =new Login();
}
}
| 349 | 0.547826 | 0.530435 | 16 | 20.5625 | 20.386787 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 2 |
967324fa0cd54adf6e8a7589960243eac53eb2fe | 27,943,057,285,626 | 60c144f3e9ce737fb8b9fd92e61e6959d949fc77 | /Project/src/TwoDArray.java | d1d8e82dd20384f7f491d2f082452bbcfc669673 | [] | no_license | payal-15/1stRepository | https://github.com/payal-15/1stRepository | 37a727ba5406de14b08f156fb0eac50aaaa5f855 | 2fd21ff3cf2c18b84ff8f2ed0920e0be36dfab70 | refs/heads/master | 2020-03-14T23:02:58.317000 | 2018-07-03T05:19:41 | 2018-07-03T05:19:41 | 131,835,387 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class TwoDArray {
void printTwoD(int ar[][])
{
for(int i=0;i<ar.length;i++)
{
for(int j=0;j<ar[i].length;j++)
{
System.out.print(ar[i][j]+" ");
}
System.out.println();
}
}
//Read element from user
int[][] read2D()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter no of rows you want in 2-d");
int row=sc.nextInt();
System.out.println("Enter no of cols you want in 2-d");
int col=sc.nextInt();
int mat[][]=new int[row][col];
System.out.println("Enter the "+row*col+ " elements");
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
mat[i][j]=sc.nextInt();
}
}
return mat;
}
//addition of matrix
int[][] addMatrix(int mat1[][], int mat2[][])
{
if(mat1.length !=mat2.length || mat1[0].length!=mat2[0].length)
{
return null;
}
int add[][]=new int[mat1.length][mat1[0].length];
for (int i = 0; i < add.length; i++) {
for (int j = 0; j < add[i].length; j++) {
add[i][j]=mat1[i][j]+mat2[i][j];
}
}
return add;
}
//return biggest element from matrix
int getbig(int mat[][])
{
int big=mat[0][0];
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(big<mat[i][j])
{
big=mat[i][j];
}
}
}
return big;
}
//return smallest element from matrix
int getsmall(int mat[][])
{
int small=mat[0][0];
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(small>mat[i][j])
{
small=mat[i][j];
}
}
}
return small;
}
//return no of positive element from matrix
int getnoOfPositive(int mat[][])
{
int p=0;
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(mat[i][j]>0)
{
p++;
}
}
}
return p;
}
//TRANSPOSE
void transpose(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = i+1; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[j][i];
a[j][i]=t;
}
}
}
//transpose the non square matrix
int[][] transposenonsq(int a[][])
{
int na[][]=new int[a[0].length][a.length];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
na[j][i]=a[i][j];
}
}
return na;
}
//reverse the row
void reverseRow(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length/2; j++) {
int t=a[i][j];
a[i][j]=a[i][a[i].length-1-j];
a[i][a[i].length-1-j]=t;
}
}
}
//reverse the column
void reverseCol(int a[][])
{
for (int i = 0; i < a.length/2; i++) {
for (int j = 0; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[a.length-1-i][j];
a[a.length-1-i][j]=t;
}
}
}
//
void goLeft(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[i][a[i].length-1];
a[i][a[i].length-1]=t;
}
}
}
public static void main(String[] args) {
int ar[][]= {{1,2,3},{4,5,6,7,8},{9,10,11,12,13}};
TwoDArray td = new TwoDArray();
td.printTwoD(ar);
//READ THE MATRIX ELEMENTs.
System.out.println("Enter first matrix ements: ");
int mat1[][]=td.read2D();
/* System.out.println("Enter SECOND matrix ements: ");
int mat2[][]=td.read2D();
System.out.println("Enter Third matrix ements: ");
int mat3[][]=td.read2D();
System.out.println("FIrst matrix Element");
td.printTwoD(mat1);
System.out.println("second matrix Element");
td.printTwoD(mat2);
// Addition of 2 matrix
int sum[][]=td.addMatrix(mat1, mat2);
if(sum==null)
{
System.out.println("Addition not possible");
}else
{
System.out.println("Added matrix ");
td.printTwoD(sum);
}
//addition of 3 matrix
int sum1[][]=td.addMatrix(td.addMatrix(mat1, mat2),mat3);
if(sum1==null)
{
System.out.println("Addition not possible");
}else
{
System.out.println("Added matrix: ");
td.printTwoD(sum1);
}
int big=td.getbig(mat1);
int small=td.getsmall(mat1);
int positive=td.getnoOfPositive(mat1);
System.out.println(big+" "+small+" "+ positive);
//transpose
td.transpose(mat1);
td.printTwoD(mat1);
//transpose non square
int resT[][]=td.transposenonsq(mat1);
td.printTwoD(resT);
//reverse row
td.reverseRow(mat1);
td.printTwoD(mat1);
//reverse col
td.reverseCol(mat1);
td.printTwoD(mat1);*/
td.goLeft(mat1);
td.printTwoD(mat1);
}
}
| UTF-8 | Java | 4,678 | java | TwoDArray.java | Java | [] | null | [] | import java.util.Scanner;
public class TwoDArray {
void printTwoD(int ar[][])
{
for(int i=0;i<ar.length;i++)
{
for(int j=0;j<ar[i].length;j++)
{
System.out.print(ar[i][j]+" ");
}
System.out.println();
}
}
//Read element from user
int[][] read2D()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter no of rows you want in 2-d");
int row=sc.nextInt();
System.out.println("Enter no of cols you want in 2-d");
int col=sc.nextInt();
int mat[][]=new int[row][col];
System.out.println("Enter the "+row*col+ " elements");
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
mat[i][j]=sc.nextInt();
}
}
return mat;
}
//addition of matrix
int[][] addMatrix(int mat1[][], int mat2[][])
{
if(mat1.length !=mat2.length || mat1[0].length!=mat2[0].length)
{
return null;
}
int add[][]=new int[mat1.length][mat1[0].length];
for (int i = 0; i < add.length; i++) {
for (int j = 0; j < add[i].length; j++) {
add[i][j]=mat1[i][j]+mat2[i][j];
}
}
return add;
}
//return biggest element from matrix
int getbig(int mat[][])
{
int big=mat[0][0];
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(big<mat[i][j])
{
big=mat[i][j];
}
}
}
return big;
}
//return smallest element from matrix
int getsmall(int mat[][])
{
int small=mat[0][0];
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(small>mat[i][j])
{
small=mat[i][j];
}
}
}
return small;
}
//return no of positive element from matrix
int getnoOfPositive(int mat[][])
{
int p=0;
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
if(mat[i][j]>0)
{
p++;
}
}
}
return p;
}
//TRANSPOSE
void transpose(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = i+1; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[j][i];
a[j][i]=t;
}
}
}
//transpose the non square matrix
int[][] transposenonsq(int a[][])
{
int na[][]=new int[a[0].length][a.length];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
na[j][i]=a[i][j];
}
}
return na;
}
//reverse the row
void reverseRow(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length/2; j++) {
int t=a[i][j];
a[i][j]=a[i][a[i].length-1-j];
a[i][a[i].length-1-j]=t;
}
}
}
//reverse the column
void reverseCol(int a[][])
{
for (int i = 0; i < a.length/2; i++) {
for (int j = 0; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[a.length-1-i][j];
a[a.length-1-i][j]=t;
}
}
}
//
void goLeft(int a[][])
{
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
int t=a[i][j];
a[i][j]=a[i][a[i].length-1];
a[i][a[i].length-1]=t;
}
}
}
public static void main(String[] args) {
int ar[][]= {{1,2,3},{4,5,6,7,8},{9,10,11,12,13}};
TwoDArray td = new TwoDArray();
td.printTwoD(ar);
//READ THE MATRIX ELEMENTs.
System.out.println("Enter first matrix ements: ");
int mat1[][]=td.read2D();
/* System.out.println("Enter SECOND matrix ements: ");
int mat2[][]=td.read2D();
System.out.println("Enter Third matrix ements: ");
int mat3[][]=td.read2D();
System.out.println("FIrst matrix Element");
td.printTwoD(mat1);
System.out.println("second matrix Element");
td.printTwoD(mat2);
// Addition of 2 matrix
int sum[][]=td.addMatrix(mat1, mat2);
if(sum==null)
{
System.out.println("Addition not possible");
}else
{
System.out.println("Added matrix ");
td.printTwoD(sum);
}
//addition of 3 matrix
int sum1[][]=td.addMatrix(td.addMatrix(mat1, mat2),mat3);
if(sum1==null)
{
System.out.println("Addition not possible");
}else
{
System.out.println("Added matrix: ");
td.printTwoD(sum1);
}
int big=td.getbig(mat1);
int small=td.getsmall(mat1);
int positive=td.getnoOfPositive(mat1);
System.out.println(big+" "+small+" "+ positive);
//transpose
td.transpose(mat1);
td.printTwoD(mat1);
//transpose non square
int resT[][]=td.transposenonsq(mat1);
td.printTwoD(resT);
//reverse row
td.reverseRow(mat1);
td.printTwoD(mat1);
//reverse col
td.reverseCol(mat1);
td.printTwoD(mat1);*/
td.goLeft(mat1);
td.printTwoD(mat1);
}
}
| 4,678 | 0.519667 | 0.49829 | 223 | 18.977579 | 16.78977 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.654709 | false | false | 2 |
060a4f4478312366cd800acb4366bfbfe3db6344 | 14,448,269,992,600 | a9e2ce9b664fb0664a62ad00e1aaaf69a3e1bdd4 | /src/main/java/com/RadioPlayer/models/players/DABPlayer.java | 9d763937f6a7cfab8c79f8124606682dbc429baa | [] | no_license | Kamigoro/RadioPlayer | https://github.com/Kamigoro/RadioPlayer | ef45226c86c91a8320b646bdf97357243f03af59 | c9173275923bf0b562f36dc727e7d1b7a5e74fb1 | refs/heads/master | 2021-05-21T21:30:22.760000 | 2020-04-13T10:49:41 | 2020-04-13T10:49:41 | 252,807,953 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.RadioPlayer.models.players;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.ArrayList;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.RadioPlayer.models.Media;
import com.RadioPlayer.models.RadioPlayer;
import com.RadioPlayer.models.constants.Constant;
public class DABPlayer implements IPlayer {
private RadioPlayer radio;
private Media[] listOfDABStations;
private int currentStationIndex;
private boolean isPlaying;
private Clip clip;
private boolean isWorking;
private ArrayList<Media> listOfPresets = new ArrayList<Media>();
public DABPlayer(RadioPlayer radio){
isPlaying = false;
listDABStations();
isWorking = true;
currentStationIndex = 0;
this.radio = radio;
instanciatePreset();
}
private void instanciatePreset() {
for (int i = Constant.indexOfFirstPreset; i < Constant.maxPresetInRadio; i++) {
listOfPresets.add(new Media());
}
}
public Media[] listDABStations() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(this.getClass().getResourceAsStream(("/com/RadioPlayer/media/dabStations.xml")));
NodeList dabStationList = document.getElementsByTagName("dabStation");
listOfDABStations = new Media[dabStationList.getLength()];
for (int i = 0; i<dabStationList.getLength();i++) {
Node song = dabStationList.item(i);
if(song.getNodeType() == Node.ELEMENT_NODE) {
Element songElement = (Element)song;
listOfDABStations[i] = new Media(
i,
songElement.getAttribute("stationName"),
songElement.getAttribute("frequency"),
songElement.getAttribute("stationLogo"),
songElement.getAttribute("stationImage"),
songElement.getAttribute("songPath"));
}
}
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return listOfDABStations;
}
@Override
public void leftClick() {
clip.stop();//Arr�ter la musique actuelle
isPlaying = true;//Quand on change de musique on la joue directement
if(currentStationIndex>0) {//Jouer la chanson pr�c�dente s'il y'en a une
currentStationIndex--;
} else {
currentStationIndex = listOfDABStations.length - 1;
}
playMusic();
}
@Override
public void okClick() {
// Ne fait rien car one ne peut pas mettre en pause une station
}
@Override
public void rightClick() {
clip.stop();//Arr�ter la station actuelle
isPlaying = true;//Quand on change de station on la joue directement
if(currentStationIndex<listOfDABStations.length-1) {//Jouer la station suivante s'il y'en a une
currentStationIndex++;
} else {
currentStationIndex = 0;
}
playMusic();
}
@Override
public void playMusic() {
try {
if(isWorking) {
String songPath = listOfDABStations[currentStationIndex].getSongPath();
InputStream is = this.getClass().getResourceAsStream(songPath);
AudioInputStream audioInput = AudioSystem.getAudioInputStream(new BufferedInputStream(is));
clip = AudioSystem.getClip();
clip.open(audioInput);
clip.loop(Clip.LOOP_CONTINUOUSLY);
clip.start();
}
sendMediaToRadio();
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}
@Override
public void stopPlayer() {
isPlaying = false;
clip.stop();
}
@Override
public void launchPlayer() {
if(isPlaying == false) {
isPlaying = true;
playMusic();
}
}
@Override
public void sendMediaToRadio() {
radio.editPlayerInformations(listOfDABStations[currentStationIndex]);
}
@Override
public void setCurrentMediaIndex(int index) {
clip.stop();
currentStationIndex = index;
playMusic();
}
@Override
public Media getCurrentMedia() {
return listOfDABStations[currentStationIndex];
}
@Override
public void setPresetsWithAutotune() {
for (int i = Constant.indexOfFirstPreset; i < Constant.maxPresetInRadio; i++) {
listOfPresets.set(i, listOfDABStations[i]);
}
}
@Override
public Media getPreset(int index) {
return listOfPresets.get(index);
}
@Override
public void setPreset(int index) {
listOfPresets.set(index, getCurrentMedia());
}
@Override
public void setIsWorking(boolean isWorking) {
this.isWorking = isWorking;
if(!isWorking) {
stopPlayer();
}
}
@Override
public boolean isPlaying() {
return isPlaying;
}
public ArrayList<Media> getListOfPresets() {
return listOfPresets;
}
}
| UTF-8 | Java | 5,319 | java | DABPlayer.java | Java | [] | null | [] | package com.RadioPlayer.models.players;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.ArrayList;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.RadioPlayer.models.Media;
import com.RadioPlayer.models.RadioPlayer;
import com.RadioPlayer.models.constants.Constant;
public class DABPlayer implements IPlayer {
private RadioPlayer radio;
private Media[] listOfDABStations;
private int currentStationIndex;
private boolean isPlaying;
private Clip clip;
private boolean isWorking;
private ArrayList<Media> listOfPresets = new ArrayList<Media>();
public DABPlayer(RadioPlayer radio){
isPlaying = false;
listDABStations();
isWorking = true;
currentStationIndex = 0;
this.radio = radio;
instanciatePreset();
}
private void instanciatePreset() {
for (int i = Constant.indexOfFirstPreset; i < Constant.maxPresetInRadio; i++) {
listOfPresets.add(new Media());
}
}
public Media[] listDABStations() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(this.getClass().getResourceAsStream(("/com/RadioPlayer/media/dabStations.xml")));
NodeList dabStationList = document.getElementsByTagName("dabStation");
listOfDABStations = new Media[dabStationList.getLength()];
for (int i = 0; i<dabStationList.getLength();i++) {
Node song = dabStationList.item(i);
if(song.getNodeType() == Node.ELEMENT_NODE) {
Element songElement = (Element)song;
listOfDABStations[i] = new Media(
i,
songElement.getAttribute("stationName"),
songElement.getAttribute("frequency"),
songElement.getAttribute("stationLogo"),
songElement.getAttribute("stationImage"),
songElement.getAttribute("songPath"));
}
}
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return listOfDABStations;
}
@Override
public void leftClick() {
clip.stop();//Arr�ter la musique actuelle
isPlaying = true;//Quand on change de musique on la joue directement
if(currentStationIndex>0) {//Jouer la chanson pr�c�dente s'il y'en a une
currentStationIndex--;
} else {
currentStationIndex = listOfDABStations.length - 1;
}
playMusic();
}
@Override
public void okClick() {
// Ne fait rien car one ne peut pas mettre en pause une station
}
@Override
public void rightClick() {
clip.stop();//Arr�ter la station actuelle
isPlaying = true;//Quand on change de station on la joue directement
if(currentStationIndex<listOfDABStations.length-1) {//Jouer la station suivante s'il y'en a une
currentStationIndex++;
} else {
currentStationIndex = 0;
}
playMusic();
}
@Override
public void playMusic() {
try {
if(isWorking) {
String songPath = listOfDABStations[currentStationIndex].getSongPath();
InputStream is = this.getClass().getResourceAsStream(songPath);
AudioInputStream audioInput = AudioSystem.getAudioInputStream(new BufferedInputStream(is));
clip = AudioSystem.getClip();
clip.open(audioInput);
clip.loop(Clip.LOOP_CONTINUOUSLY);
clip.start();
}
sendMediaToRadio();
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}
@Override
public void stopPlayer() {
isPlaying = false;
clip.stop();
}
@Override
public void launchPlayer() {
if(isPlaying == false) {
isPlaying = true;
playMusic();
}
}
@Override
public void sendMediaToRadio() {
radio.editPlayerInformations(listOfDABStations[currentStationIndex]);
}
@Override
public void setCurrentMediaIndex(int index) {
clip.stop();
currentStationIndex = index;
playMusic();
}
@Override
public Media getCurrentMedia() {
return listOfDABStations[currentStationIndex];
}
@Override
public void setPresetsWithAutotune() {
for (int i = Constant.indexOfFirstPreset; i < Constant.maxPresetInRadio; i++) {
listOfPresets.set(i, listOfDABStations[i]);
}
}
@Override
public Media getPreset(int index) {
return listOfPresets.get(index);
}
@Override
public void setPreset(int index) {
listOfPresets.set(index, getCurrentMedia());
}
@Override
public void setIsWorking(boolean isWorking) {
this.isWorking = isWorking;
if(!isWorking) {
stopPlayer();
}
}
@Override
public boolean isPlaying() {
return isPlaying;
}
public ArrayList<Media> getListOfPresets() {
return listOfPresets;
}
}
| 5,319 | 0.733384 | 0.731501 | 204 | 25.034313 | 22.553722 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.142157 | false | false | 2 |
5c473338e2a8c97426896328a5b399c6b1793f28 | 3,539,053,067,535 | 94cda92b18b29de050bd3e565b891cfa8bd42ba7 | /mall-service/src/main/java/com/nf/service/port/ReceivingInfService.java | 30aee50676a90c86961bf9f2978511846c706715 | [] | no_license | XiHaLongGe/individual-event-second-mall | https://github.com/XiHaLongGe/individual-event-second-mall | 235df1385c839fc0c46b3f53ebde79e70cc1c409 | 97d0be6e67a7974d5faf97e23835acbe64db9220 | refs/heads/master | 2022-12-28T06:05:35.162000 | 2020-05-19T03:39:40 | 2020-05-19T03:39:40 | 233,203,381 | 0 | 0 | null | false | 2022-12-15T23:25:41 | 2020-01-11T08:56:55 | 2020-05-19T03:39:54 | 2022-12-15T23:25:39 | 9,345 | 0 | 0 | 6 | Java | false | false | package com.nf.service.port;
import com.nf.entity.ReceivingInfEntity;
import java.util.List;
/**
* @Author: LJP
* @Classname ReceivingInfService
* @Date: 2020-02-06 15:49
* @Description: 收货信息表service层接口
*/
public interface ReceivingInfService {
/**
* 根据用户id获取所有收货信息
* @param loginId 用户id
* @return
*/
List<ReceivingInfEntity> getListByLoginId(Integer loginId);
/**
* 根据收货信息id获取所有收货信息
* @param receivingInfId 收货信息id
* @return
*/
ReceivingInfEntity getListByReceivingInfId(Integer receivingInfId);
/**
* 添加收货信息
* @param receivingInfEntity 收货信息实体类
* @return
*/
boolean insertReceivingInf(ReceivingInfEntity receivingInfEntity);
/**
* 修改收货信息
* @param receivingInfEntity 收货信息实体类
* @return
*/
boolean updateReceivingInf(ReceivingInfEntity receivingInfEntity);
/**
* 根据收货信息id设为默认地址
* @return
*/
boolean updateIsDefault(Integer receivingInfId);
/**
* 撤消用户id的默认地址,结合updateIsDefault使用
* @return
*/
boolean updateNotDefault(Integer loginId);
/**
* 结合 撤消/设置默认地址的方法使用
* @param receivingInfId 收货信息id
* @param loginId 登录id
* @return
*/
boolean updateDefault(Integer receivingInfId, Integer loginId);
/**
* 删除收货信息
* @param receivingInfId 收货信息id
* @return
*/
boolean deleteReceivingInf(Integer receivingInfId);
}
| UTF-8 | Java | 1,680 | java | ReceivingInfService.java | Java | [
{
"context": "nfEntity;\n\nimport java.util.List;\n\n/**\n * @Author: LJP\n * @Classname ReceivingInfService\n * @Date: 2020-",
"end": 115,
"score": 0.9996716976165771,
"start": 112,
"tag": "USERNAME",
"value": "LJP"
}
] | null | [] | package com.nf.service.port;
import com.nf.entity.ReceivingInfEntity;
import java.util.List;
/**
* @Author: LJP
* @Classname ReceivingInfService
* @Date: 2020-02-06 15:49
* @Description: 收货信息表service层接口
*/
public interface ReceivingInfService {
/**
* 根据用户id获取所有收货信息
* @param loginId 用户id
* @return
*/
List<ReceivingInfEntity> getListByLoginId(Integer loginId);
/**
* 根据收货信息id获取所有收货信息
* @param receivingInfId 收货信息id
* @return
*/
ReceivingInfEntity getListByReceivingInfId(Integer receivingInfId);
/**
* 添加收货信息
* @param receivingInfEntity 收货信息实体类
* @return
*/
boolean insertReceivingInf(ReceivingInfEntity receivingInfEntity);
/**
* 修改收货信息
* @param receivingInfEntity 收货信息实体类
* @return
*/
boolean updateReceivingInf(ReceivingInfEntity receivingInfEntity);
/**
* 根据收货信息id设为默认地址
* @return
*/
boolean updateIsDefault(Integer receivingInfId);
/**
* 撤消用户id的默认地址,结合updateIsDefault使用
* @return
*/
boolean updateNotDefault(Integer loginId);
/**
* 结合 撤消/设置默认地址的方法使用
* @param receivingInfId 收货信息id
* @param loginId 登录id
* @return
*/
boolean updateDefault(Integer receivingInfId, Integer loginId);
/**
* 删除收货信息
* @param receivingInfId 收货信息id
* @return
*/
boolean deleteReceivingInf(Integer receivingInfId);
}
| 1,680 | 0.647141 | 0.638773 | 72 | 18.916666 | 19.451328 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 2 |
611e1a42a30caac945e0afd71e49617a3f8cad03 | 16,106,127,367,021 | 332110019a8c8227a0389f73c218f1feda6d38e4 | /app/src/main/java/com/example/humberto/raites_uabc/RecyclerViewHelper.java | bbd20847b660523c1fa38f2ee88aba8914918c1f | [] | no_license | bethosthoned/Raites_uabc2 | https://github.com/bethosthoned/Raites_uabc2 | ee93529f75e2d202d6d03fba89abc76dd61f3528 | 70dd58a44bbf6d415b8b58986b612f9353b0067f | refs/heads/master | 2020-04-11T02:04:45.014000 | 2018-12-12T04:55:39 | 2018-12-12T04:55:39 | 161,434,774 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.humberto.raites_uabc;
import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.humberto.raites_uabc.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
public class RecyclerViewHelper {
public interface ItemRenderer {
void render(View root, JSONObject object) throws JSONException;
}
public static void config(Activity activity, RecyclerView recycler, final int layout, final List<JSONObject> items, final ItemRenderer renderer) {
recycler.setLayoutManager(new LinearLayoutManager(activity));
recycler.setAdapter(new RecyclerView.Adapter() {
private View root;
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
root = LayoutInflater.from(viewGroup.getContext()).inflate(layout, viewGroup, false);
return new RecyclerView.ViewHolder(root) {
@Override
public String toString() {
return super.toString();
}
};
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
JSONObject object = items.get(i);
try {
renderer.render(root, object);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public int getItemCount() {
return items.size();
}
});
}
}
| UTF-8 | Java | 1,909 | java | RecyclerViewHelper.java | Java | [] | null | [] | package com.example.humberto.raites_uabc;
import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.humberto.raites_uabc.R;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
public class RecyclerViewHelper {
public interface ItemRenderer {
void render(View root, JSONObject object) throws JSONException;
}
public static void config(Activity activity, RecyclerView recycler, final int layout, final List<JSONObject> items, final ItemRenderer renderer) {
recycler.setLayoutManager(new LinearLayoutManager(activity));
recycler.setAdapter(new RecyclerView.Adapter() {
private View root;
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
root = LayoutInflater.from(viewGroup.getContext()).inflate(layout, viewGroup, false);
return new RecyclerView.ViewHolder(root) {
@Override
public String toString() {
return super.toString();
}
};
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
JSONObject object = items.get(i);
try {
renderer.render(root, object);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public int getItemCount() {
return items.size();
}
});
}
}
| 1,909 | 0.616553 | 0.615506 | 59 | 31.355932 | 29.143574 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.576271 | false | false | 2 |
f5901d7fdd5aafb8e72e64f2daad45a306ce3a78 | 30,090,540,892,453 | c73e7aaebfe4dbbf9fec4ef6c85b890445624a80 | /app/src/main/java/com/smart_f/welcomebroadcast/ISpeechProcessing.java | 26b99d481134d4957dcfa50002cc52af9318c360 | [] | no_license | UIT2015/WelcomeBroadcast | https://github.com/UIT2015/WelcomeBroadcast | 634819c9de59cb7e0f0b0c851cf9b99280a8424e | d9502a8679a4e60b2457ae204dab0a8fa8b7d698 | refs/heads/master | 2021-05-09T06:33:19.609000 | 2018-01-30T06:28:09 | 2018-01-30T06:28:09 | 119,333,116 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.smart_f.welcomebroadcast;
/**
* 语音合成接口
* Created by chenxi on 2018/1/27.
*/
public interface ISpeechProcessing {
void speechSynthesisByString(String sentence);
}
| UTF-8 | Java | 195 | java | ISpeechProcessing.java | Java | [
{
"context": "t_f.welcomebroadcast;\n\n/**\n * 语音合成接口\n * Created by chenxi on 2018/1/27.\n */\n\npublic interface ISpeechProces",
"end": 73,
"score": 0.9996246695518494,
"start": 67,
"tag": "USERNAME",
"value": "chenxi"
}
] | null | [] | package com.smart_f.welcomebroadcast;
/**
* 语音合成接口
* Created by chenxi on 2018/1/27.
*/
public interface ISpeechProcessing {
void speechSynthesisByString(String sentence);
}
| 195 | 0.737705 | 0.699454 | 10 | 17.299999 | 18.515129 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 2 |
030e5ea8250f604b3a8a7c72754317ead4564a16 | 18,657,337,986,460 | dbab17fd58d3f6be7405d97092ceff7bb5bf4b01 | /src/com/kimboo/giffy/SplashActivity.java | 086cb6395e2ff1db17d4a9b38f113e38828af098 | [
"Apache-2.0"
] | permissive | 4gus71n/Giffy | https://github.com/4gus71n/Giffy | 5f895178fa701968c94c38e6211115a15d35fa7b | c9a7829d31a8ee7309ab1d3c4188e7215bb9b675 | refs/heads/master | 2020-04-16T11:35:19.626000 | 2013-08-27T01:36:16 | 2013-08-27T01:36:16 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package com.kimboo.giffy;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.ViewSwitcher;
import com.kimboo.giffy.utils.Constants;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.Animator.AnimatorListener;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
public class SplashActivity extends Activity {
private static final String TAG = SplashActivity.class.getName();
/**
* Animation to display in the tv.
*/
private AnimationDrawable mProgressAnimation;
/**
* Device physic height and width.
*/
private int mDstHeight;
private int mDstWidth;
private WindowManager mWinMgr;
/**
* OnClick triggered when you click in the {@linkplain R.id.splash_init_anonymous_btn} button.
*/
private final OnClickListener mLoginAnonymousClick = new OnClickListener() {
@Override
public void onClick(View v) {
hideFilmStripMenu();
beginAnimationLoading();
//Dont do anything of UI inside this method nor the AsyncTask methods-
launchBackgroundLoading();
}
};
/**
* OnClick triggered when you click in the {@linkplain R.id.splash_init_session_btn} button.
*/
private final OnClickListener mLoginUserClick = new OnClickListener() {
@Override
public void onClick(View v) {
hideFilmStripMenu();
beginAnimationLoading();
//Dont do anything of UI inside this method nor the AsyncTask methods-
launchBackgroundLoading();
}
};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
initWidgets();
}
protected void hideFilmStripMenu() {
final ScrollView filmStripView = (ScrollView) findViewById(R.id.splash_movie_strip);
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(filmStripView, "translationX", 0, filmStripView.getWidth()),
ObjectAnimator.ofFloat(filmStripView, "alpha", 1, 0.25f)
);
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
@Override
public void onAnimationEnd(Animator animation) {
filmStripView.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
filmStripView.setVisibility(View.GONE);
}
});
set.setDuration(3 * 1000).start();
}
@Override
protected void onStart() {
super.onStart();
if (App.getInstance().userLogin()) {
launchBackgroundLoading();
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
beginAnimationStatic();
}
/**
* Initializes the onClick and view events.
*/
private void initWidgets() {
Button loginAnonymous = (Button) findViewById(R.id.splash_init_anonymous_btn);
loginAnonymous.setOnClickListener(mLoginAnonymousClick);
Button loginUser = (Button) findViewById(R.id.splash_init_session_btn);
loginUser.setOnClickListener(mLoginUserClick);
}
private void launchBackgroundLoading() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
startBackgroundLoading();
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
endBackgroundLoading();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
if (App.getInstance().firstInstallation()) {
setupResources();
App.getInstance().firstInstallation(Boolean.FALSE);
}
}
}.execute();
}
private void startBackgroundLoading() {
//TODO: Do background init operations here
}
private void endBackgroundLoading() {
Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
}
private void setupResources() {
setupDeviceWidth();
}
private void setupDeviceWidth() {
mWinMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
mDstWidth = mWinMgr.getDefaultDisplay().getWidth();
mDstHeight = mWinMgr.getDefaultDisplay().getHeight();
App.getInstance().putInt(Constants.System.DEVICE_WIDTH,mDstWidth);
App.getInstance().putInt(Constants.System.DEVICE_HEIGHT,mDstHeight);
}
private void beginAnimationStatic() {
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.splash_switcher);
if (switcher.getDisplayedChild() != 0) {
switcher.showPrevious();
}
ImageView img = (ImageView) findViewById(R.id.splash_animation_static);
if (mProgressAnimation != null)
mProgressAnimation.stop();
mProgressAnimation = (AnimationDrawable) img.getBackground();
mProgressAnimation.start();
}
private void beginAnimationLoading() {
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.splash_switcher);
if (switcher.getDisplayedChild() != 1) {
switcher.showNext();
}
ImageView img = (ImageView) findViewById(R.id.splash_animation);
if (mProgressAnimation != null)
mProgressAnimation.stop();
mProgressAnimation = (AnimationDrawable) img.getBackground();
mProgressAnimation.start();
}
}
| UTF-8 | Java | 6,463 | java | SplashActivity.java | Java | [] | null | [] |
package com.kimboo.giffy;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.ViewSwitcher;
import com.kimboo.giffy.utils.Constants;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.Animator.AnimatorListener;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
public class SplashActivity extends Activity {
private static final String TAG = SplashActivity.class.getName();
/**
* Animation to display in the tv.
*/
private AnimationDrawable mProgressAnimation;
/**
* Device physic height and width.
*/
private int mDstHeight;
private int mDstWidth;
private WindowManager mWinMgr;
/**
* OnClick triggered when you click in the {@linkplain R.id.splash_init_anonymous_btn} button.
*/
private final OnClickListener mLoginAnonymousClick = new OnClickListener() {
@Override
public void onClick(View v) {
hideFilmStripMenu();
beginAnimationLoading();
//Dont do anything of UI inside this method nor the AsyncTask methods-
launchBackgroundLoading();
}
};
/**
* OnClick triggered when you click in the {@linkplain R.id.splash_init_session_btn} button.
*/
private final OnClickListener mLoginUserClick = new OnClickListener() {
@Override
public void onClick(View v) {
hideFilmStripMenu();
beginAnimationLoading();
//Dont do anything of UI inside this method nor the AsyncTask methods-
launchBackgroundLoading();
}
};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
initWidgets();
}
protected void hideFilmStripMenu() {
final ScrollView filmStripView = (ScrollView) findViewById(R.id.splash_movie_strip);
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(filmStripView, "translationX", 0, filmStripView.getWidth()),
ObjectAnimator.ofFloat(filmStripView, "alpha", 1, 0.25f)
);
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
@Override
public void onAnimationEnd(Animator animation) {
filmStripView.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
filmStripView.setVisibility(View.GONE);
}
});
set.setDuration(3 * 1000).start();
}
@Override
protected void onStart() {
super.onStart();
if (App.getInstance().userLogin()) {
launchBackgroundLoading();
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
beginAnimationStatic();
}
/**
* Initializes the onClick and view events.
*/
private void initWidgets() {
Button loginAnonymous = (Button) findViewById(R.id.splash_init_anonymous_btn);
loginAnonymous.setOnClickListener(mLoginAnonymousClick);
Button loginUser = (Button) findViewById(R.id.splash_init_session_btn);
loginUser.setOnClickListener(mLoginUserClick);
}
private void launchBackgroundLoading() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
startBackgroundLoading();
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
endBackgroundLoading();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
if (App.getInstance().firstInstallation()) {
setupResources();
App.getInstance().firstInstallation(Boolean.FALSE);
}
}
}.execute();
}
private void startBackgroundLoading() {
//TODO: Do background init operations here
}
private void endBackgroundLoading() {
Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
}
private void setupResources() {
setupDeviceWidth();
}
private void setupDeviceWidth() {
mWinMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
mDstWidth = mWinMgr.getDefaultDisplay().getWidth();
mDstHeight = mWinMgr.getDefaultDisplay().getHeight();
App.getInstance().putInt(Constants.System.DEVICE_WIDTH,mDstWidth);
App.getInstance().putInt(Constants.System.DEVICE_HEIGHT,mDstHeight);
}
private void beginAnimationStatic() {
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.splash_switcher);
if (switcher.getDisplayedChild() != 0) {
switcher.showPrevious();
}
ImageView img = (ImageView) findViewById(R.id.splash_animation_static);
if (mProgressAnimation != null)
mProgressAnimation.stop();
mProgressAnimation = (AnimationDrawable) img.getBackground();
mProgressAnimation.start();
}
private void beginAnimationLoading() {
ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.splash_switcher);
if (switcher.getDisplayedChild() != 1) {
switcher.showNext();
}
ImageView img = (ImageView) findViewById(R.id.splash_animation);
if (mProgressAnimation != null)
mProgressAnimation.stop();
mProgressAnimation = (AnimationDrawable) img.getBackground();
mProgressAnimation.start();
}
}
| 6,463 | 0.636237 | 0.63438 | 194 | 32.309277 | 25.02282 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.469072 | false | false | 2 |
a6442e905f58d64072430fcfa977e9d25e946543 | 29,317,446,795,840 | d4bbaf6f06d323f6a5682f8a8e050230e3ca8216 | /7º Período/Linguagens de Programação III/eclipse-workspace/ThreadTest/src/RunnableExample.java | 2672fe66d1740b2a70546c6419f17c2e22385825 | [] | no_license | vbob/Engenharia | https://github.com/vbob/Engenharia | 8a468d48dacab03aaa0828ffb28b59c8d15e3fd6 | bad1e0d0ac348e5b5488537e8222b0e3a0b31663 | refs/heads/master | 2021-10-26T22:51:21.211000 | 2019-04-14T14:54:25 | 2019-04-14T14:54:25 | 107,336,914 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public class RunnableExample implements Runnable{
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
System.out.print("***");
}
}
}
| UTF-8 | Java | 165 | java | RunnableExample.java | Java | [] | null | [] |
public class RunnableExample implements Runnable{
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
System.out.print("***");
}
}
}
| 165 | 0.569697 | 0.533333 | 8 | 18.375 | 16.461603 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.625 | false | false | 2 |
f52ff87302191ce5a1b1851e8ba910fa27e0af77 | 15,264,313,773,410 | faea2aa5dba658a343d44d361422a6680fc90781 | /DesignPatterns/src/main/java/learn/tutorials/chainofresposibilitypattern/Client.java | ee7219226d956afd7968ea8481a6032a31b4f7f4 | [] | no_license | kdsalvy/Tutorials | https://github.com/kdsalvy/Tutorials | 9888a55b80d0e3c0c1caace1b878b2f1f5d6aab0 | 4547b43f31a7c547593309aeb57fd867eebfc960 | refs/heads/master | 2022-12-07T16:00:32.354000 | 2020-07-02T06:09:03 | 2020-07-02T06:09:03 | 42,946,320 | 0 | 1 | null | false | 2022-11-24T06:59:54 | 2015-09-22T16:28:54 | 2020-07-02T06:09:07 | 2022-11-24T06:59:51 | 288 | 0 | 1 | 9 | Java | false | false | package learn.tutorials.chainofresposibilitypattern;
import java.lang.annotation.Annotation;
import java.util.Set;
import org.reflections.Reflections;
public class Client {
public static void main(String[] args) throws Exception {
JobHandlerType jobHandlerType = JobHandlerType.TYPE3;
Handler handler = null;
// Get the instance of a class based on its job-type
Reflections reflections = new Reflections(Client.class.getPackage().getName());
Set<Class<?>> classSet = reflections.getTypesAnnotatedWith(JobType.class);
for (Class<?> clazz : classSet) {
Annotation annotation = clazz.getAnnotation(JobType.class);
JobType jobType = (JobType) annotation;
if (jobType.jobHandlerType() == jobHandlerType) {
handler = (Handler) new AnnotationParser().parse(clazz);
}
}
handler.handleRequest();
}
}
| UTF-8 | Java | 858 | java | Client.java | Java | [] | null | [] | package learn.tutorials.chainofresposibilitypattern;
import java.lang.annotation.Annotation;
import java.util.Set;
import org.reflections.Reflections;
public class Client {
public static void main(String[] args) throws Exception {
JobHandlerType jobHandlerType = JobHandlerType.TYPE3;
Handler handler = null;
// Get the instance of a class based on its job-type
Reflections reflections = new Reflections(Client.class.getPackage().getName());
Set<Class<?>> classSet = reflections.getTypesAnnotatedWith(JobType.class);
for (Class<?> clazz : classSet) {
Annotation annotation = clazz.getAnnotation(JobType.class);
JobType jobType = (JobType) annotation;
if (jobType.jobHandlerType() == jobHandlerType) {
handler = (Handler) new AnnotationParser().parse(clazz);
}
}
handler.handleRequest();
}
}
| 858 | 0.724942 | 0.723776 | 27 | 29.777779 | 26.176514 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.703704 | false | false | 2 |
600adb4d74a214f6761d46b79e82169e2d70d924 | 27,865,747,845,794 | ffda655090be111a841fce4a0d8687a92c5e28bc | /main/java/com/pwc/query/controllers/models/elements/ControllerElements.java | a0129022ea311cf769b8b795a87f718cb0ff5bfb | [] | no_license | sonal96-git/ContactTest | https://github.com/sonal96-git/ContactTest | 72d5b9fea6cb7a4466534f4172e4b6656f53aab0 | ce0aab65c747063a450797711c73e9314eda5308 | refs/heads/master | 2022-07-19T09:01:59.006000 | 2020-05-29T14:52:38 | 2020-05-29T14:52:38 | 267,881,791 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pwc.query.controllers.models.elements;
public class ControllerElements {
protected String itemUrl;
protected String itemWidth;
protected String itemHeight;
protected boolean isPage;
protected boolean isVideo;
protected String itemVideoTranscriptLink;
public String getItemUrl() {
return itemUrl;
}
public void setItemUrl(String itemUrl) {
this.itemUrl = itemUrl;
}
public String getItemHeight() {
return itemHeight;
}
public void setItemHeight(String itemHeight) {
this.itemHeight = itemHeight;
}
public String getItemWidth() {
return itemWidth;
}
public void setItemWidth(String itemWidth) {
this.itemWidth = itemWidth;
}
public boolean isPage() {
return isPage;
}
public void setPage(boolean isPage) {
this.isPage = isPage;
}
public boolean isVideo() {
return isVideo;
}
public void setVideo(boolean isVideo) {
this.isVideo = isVideo;
}
public String getItemVideoTranscriptLink() {
return itemVideoTranscriptLink;
}
public void setItemVideoTranscriptLink(String itemVideoTranscriptLink) {
this.itemVideoTranscriptLink = itemVideoTranscriptLink;
}
}
| UTF-8 | Java | 1,297 | java | ControllerElements.java | Java | [] | null | [] | package com.pwc.query.controllers.models.elements;
public class ControllerElements {
protected String itemUrl;
protected String itemWidth;
protected String itemHeight;
protected boolean isPage;
protected boolean isVideo;
protected String itemVideoTranscriptLink;
public String getItemUrl() {
return itemUrl;
}
public void setItemUrl(String itemUrl) {
this.itemUrl = itemUrl;
}
public String getItemHeight() {
return itemHeight;
}
public void setItemHeight(String itemHeight) {
this.itemHeight = itemHeight;
}
public String getItemWidth() {
return itemWidth;
}
public void setItemWidth(String itemWidth) {
this.itemWidth = itemWidth;
}
public boolean isPage() {
return isPage;
}
public void setPage(boolean isPage) {
this.isPage = isPage;
}
public boolean isVideo() {
return isVideo;
}
public void setVideo(boolean isVideo) {
this.isVideo = isVideo;
}
public String getItemVideoTranscriptLink() {
return itemVideoTranscriptLink;
}
public void setItemVideoTranscriptLink(String itemVideoTranscriptLink) {
this.itemVideoTranscriptLink = itemVideoTranscriptLink;
}
}
| 1,297 | 0.659985 | 0.659985 | 63 | 19.587301 | 19.312496 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.301587 | false | false | 2 |
0d69b170975cd39dceda8c005b68b5d05c078f3c | 9,715,216,075,671 | 740147af653347dca2ce58fd5ec08e748cdd151c | /src/main/java/br/com/nova/roma/tap/projeto/controlador/ControladorDaLoterica.java | 034426ce3e69ba37ef182d039b9c4fdd4154e490 | [
"MIT"
] | permissive | ricardofrosty45/TAP-Projeto | https://github.com/ricardofrosty45/TAP-Projeto | d068f8a5ae23e70dd42117ec033c2b41fb2c6daf | 4b5053ce2f2ccf5b7e8eaab9dcd3bf7f6e177fa7 | refs/heads/master | 2021-07-12T09:56:58.501000 | 2020-10-13T21:04:36 | 2020-10-13T21:04:36 | 212,948,655 | 0 | 0 | MIT | false | 2020-10-13T21:05:11 | 2019-10-05T05:25:18 | 2020-10-13T21:04:40 | 2020-10-13T21:05:10 | 3,197 | 0 | 0 | 1 | Java | false | false | package br.com.nova.roma.tap.projeto.controlador;
import java.util.LinkedList;
import java.util.Queue;
import br.com.nova.roma.tap.projeto.interfaces.impl.FuncoesLotericaImpl;
public class ControladorDaLoterica extends FuncoesLotericaImpl {
private final Queue<String> listaNomeCaixa = new LinkedList<String>();
@SuppressWarnings("unused")
private static boolean aberto = true;
public ControladorDaLoterica() {
this.listaNomeCaixa.add("Luan");
}
public void fecharLoterica() {
System.out.println("Fechando Loterica");
System.out.println("Loterica fechada:" + Thread.currentThread().getName());
setAberto(false);
synchronized (this.listaNomeCaixa) {
this.listaNomeCaixa.notifyAll();
}
System.exit(0);
}
}
| UTF-8 | Java | 773 | java | ControladorDaLoterica.java | Java | [
{
"context": "roladorDaLoterica() {\r\n\t\tthis.listaNomeCaixa.add(\"Luan\");\r\n\t}\r\n\t\r\n\tpublic void fecharLoterica() {\r\n\t\tSys",
"end": 466,
"score": 0.8670166730880737,
"start": 462,
"tag": "NAME",
"value": "Luan"
}
] | null | [] | package br.com.nova.roma.tap.projeto.controlador;
import java.util.LinkedList;
import java.util.Queue;
import br.com.nova.roma.tap.projeto.interfaces.impl.FuncoesLotericaImpl;
public class ControladorDaLoterica extends FuncoesLotericaImpl {
private final Queue<String> listaNomeCaixa = new LinkedList<String>();
@SuppressWarnings("unused")
private static boolean aberto = true;
public ControladorDaLoterica() {
this.listaNomeCaixa.add("Luan");
}
public void fecharLoterica() {
System.out.println("Fechando Loterica");
System.out.println("Loterica fechada:" + Thread.currentThread().getName());
setAberto(false);
synchronized (this.listaNomeCaixa) {
this.listaNomeCaixa.notifyAll();
}
System.exit(0);
}
}
| 773 | 0.723157 | 0.721863 | 31 | 22.935484 | 24.228662 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.290323 | false | false | 2 |
0090932b409516d58e8794871094ceca8c9edddf | 9,715,216,075,445 | b286254d4f0c269d6b1bdd5736405abd93df0884 | /1.semester/Mobile/test/Test.java | 414a19679d22a066a17837806919c65751fa4a7e | [] | no_license | joandrsn/workspaces | https://github.com/joandrsn/workspaces | ceb1882a565ccb43467f6bcb2b870fc547a05cae | ffb67ab0ee6799eea8acc844f8a7a1d11ddd7acc | refs/heads/master | 2021-05-27T16:16:20.532000 | 2013-11-22T09:27:56 | 2013-11-22T09:27:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package test;
import service.Service;
public class Test {
public static void main(String[] args){
Service.createContact("Mark", "Medum", "ssdg", "sdhs");
Service.createContact("Maria", "Medum", "", "");
Service.createContact("Sig", "", "", "");
System.out.println(Service.getContacts(""));
}
}
| UTF-8 | Java | 307 | java | Test.java | Java | [
{
"context": "oid main(String[] args){\n\t\tService.createContact(\"Mark\", \"Medum\", \"ssdg\", \"sdhs\");\n\t\tService.createConta",
"end": 131,
"score": 0.9998851418495178,
"start": 127,
"tag": "NAME",
"value": "Mark"
},
{
"context": "(String[] args){\n\t\tService.createContact(\"... | null | [] | package test;
import service.Service;
public class Test {
public static void main(String[] args){
Service.createContact("Mark", "Medum", "ssdg", "sdhs");
Service.createContact("Maria", "Medum", "", "");
Service.createContact("Sig", "", "", "");
System.out.println(Service.getContacts(""));
}
}
| 307 | 0.651466 | 0.651466 | 13 | 22.615385 | 20.992813 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.923077 | false | false | 2 |
832c4fcf9a9ac761141bb78106f4283c7053c55d | 15,333,033,305,702 | 84a2b5b3b636c07564d449c402b458c4e8ec0760 | /kafka-manager-common/src/main/java/com/xiaojukeji/kafka/manager/common/entity/pojo/TopicExpiredDO.java | f90cadd0750e349a5dd9bd095f1d4ac40a179b98 | [
"Apache-2.0"
] | permissive | tcf1207239873/Logi-KafkaManager | https://github.com/tcf1207239873/Logi-KafkaManager | 535b663d24c988425ec564fbe072a7910e6c86af | 73e51a888b0c1fcda186e2a08e224e5c1fb80a08 | refs/heads/master | 2023-05-07T02:19:23.776000 | 2021-05-10T09:30:59 | 2021-05-10T09:30:59 | 360,016,146 | 2 | 0 | Apache-2.0 | true | 2021-06-08T06:55:35 | 2021-04-21T03:03:59 | 2021-05-10T09:31:10 | 2021-06-08T06:55:34 | 20,054 | 0 | 0 | 0 | Java | false | false | package com.xiaojukeji.kafka.manager.common.entity.pojo;
import java.util.Date;
/**
* @author zengqiao
* @date 20/3/30
*/
public class TopicExpiredDO {
private Long id;
private Long clusterId;
private String topicName;
private Integer expiredDay;
private Date gmtRetain;
private Integer status;
private Date gmtCreate;
private Date gmtModify;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getExpiredDay() {
return expiredDay;
}
public void setExpiredDay(Integer expiredDay) {
this.expiredDay = expiredDay;
}
public Date getGmtRetain() {
return gmtRetain;
}
public void setGmtRetain(Date gmtRetain) {
this.gmtRetain = gmtRetain;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Date getGmtModify() {
return gmtModify;
}
public void setGmtModify(Date gmtModify) {
this.gmtModify = gmtModify;
}
@Override
public String toString() {
return "TopicExpiredDO{" +
"id=" + id +
", clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", expiredDay=" + expiredDay +
", gmtRetain=" + gmtRetain +
", status=" + status +
", gmtCreate=" + gmtCreate +
", gmtModify=" + gmtModify +
'}';
}
} | UTF-8 | Java | 2,054 | java | TopicExpiredDO.java | Java | [
{
"context": "tity.pojo;\n\nimport java.util.Date;\n\n/**\n * @author zengqiao\n * @date 20/3/30\n */\npublic class TopicExpiredDO ",
"end": 105,
"score": 0.889610767364502,
"start": 97,
"tag": "USERNAME",
"value": "zengqiao"
}
] | null | [] | package com.xiaojukeji.kafka.manager.common.entity.pojo;
import java.util.Date;
/**
* @author zengqiao
* @date 20/3/30
*/
public class TopicExpiredDO {
private Long id;
private Long clusterId;
private String topicName;
private Integer expiredDay;
private Date gmtRetain;
private Integer status;
private Date gmtCreate;
private Date gmtModify;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getExpiredDay() {
return expiredDay;
}
public void setExpiredDay(Integer expiredDay) {
this.expiredDay = expiredDay;
}
public Date getGmtRetain() {
return gmtRetain;
}
public void setGmtRetain(Date gmtRetain) {
this.gmtRetain = gmtRetain;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Date getGmtModify() {
return gmtModify;
}
public void setGmtModify(Date gmtModify) {
this.gmtModify = gmtModify;
}
@Override
public String toString() {
return "TopicExpiredDO{" +
"id=" + id +
", clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", expiredDay=" + expiredDay +
", gmtRetain=" + gmtRetain +
", status=" + status +
", gmtCreate=" + gmtCreate +
", gmtModify=" + gmtModify +
'}';
}
} | 2,054 | 0.565239 | 0.562804 | 103 | 18.951456 | 16.957045 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.330097 | false | false | 2 |
551196ed5cc1347aed6b1d6de1b723b2a901650d | 25,838,523,306,111 | 9440818d503ce8b648e719e287a9e7a3e1fc03eb | /app/src/androidTest/java/de/marcuskrahl/dailytasks/DailyDueIntervalTest.java | 6fb4209eafed8736de8e67a2499553c9f13a7a33 | [
"MIT"
] | permissive | mk747gx/DailyTasks | https://github.com/mk747gx/DailyTasks | 8274106889f82355651c34956c3231f3dc255209 | c5902dd4605429a60dbfa1c00c7740f309bc1247 | refs/heads/master | 2015-08-18T18:48:38.854000 | 2015-01-03T17:51:56 | 2015-01-03T17:51:56 | 28,693,225 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.marcuskrahl.dailytasks;
import junit.framework.Assert;
public class DailyDueIntervalTest extends DueIntervalTest {
@Override
protected DueInterval createInstance() {
return new DailyDueInterval();
}
public void testIfIntervalIsTrueForAllDates() {
DueInterval dueInterval = new DailyDueInterval();
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(0)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(1)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(5)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(1000)));
}
}
| UTF-8 | Java | 692 | java | DailyDueIntervalTest.java | Java | [] | null | [] | package de.marcuskrahl.dailytasks;
import junit.framework.Assert;
public class DailyDueIntervalTest extends DueIntervalTest {
@Override
protected DueInterval createInstance() {
return new DailyDueInterval();
}
public void testIfIntervalIsTrueForAllDates() {
DueInterval dueInterval = new DailyDueInterval();
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(0)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(1)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(5)));
Assert.assertTrue(dueInterval.isDue(getCalendarForCurrentDatePlusDays(1000)));
}
}
| 692 | 0.758671 | 0.748555 | 20 | 33.599998 | 31.992811 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 2 |
d946dae48c8dd019a1cdab9408dc2694b9873057 | 17,042,430,291,441 | 95f44d1ea888114672c5557fbce2f360c93b94ca | /security/src/main/java/cn/decision/security/controller/ResourceManagerController.java | c53b016b85afbac851e86ccdf496477b2660bdbe | [] | no_license | cookiegkl/ls_red_manager | https://github.com/cookiegkl/ls_red_manager | 0e7b1ea4d17bc59dcf5927b9999d959a8dce75aa | a57de8e5f7071d2750a6c1044d7e4b9a17d65f07 | refs/heads/master | 2019-03-09T23:25:09.923000 | 2017-08-28T09:34:13 | 2017-08-28T09:34:13 | 101,350,338 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.decision.security.controller;
import javax.servlet.http.HttpServletRequest;
import cn.decision.security.util.UrlParameterAuth.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.decision.framework.controller.BasicRedisController;
import cn.decision.security.UserApplicationContext;
import cn.decision.security.controller.vo.SearchResourceVo;
import cn.decision.security.util.UrlParameterAuth;
import org.springframework.web.servlet.ModelAndView;
/**
* @description 菜单管理控制类
*/
@Controller
@RequestMapping(value = "/sys/resources")
public class ResourceManagerController extends BasicRedisController {
private static Logger logger = LoggerFactory.getLogger(ResourceManagerController.class);
/**
* 进入到菜单管理页面
*
* @return
*/
@RequestMapping("toResourcePage")
public ModelAndView toResourcePage() {
return new ModelAndView("security/resource/menuList");
}
/**
* 分页查询菜单
*
* @param model
* @param search
* @return
*/
@RequestMapping("toResourceList")
public ModelAndView toResourceList(Model model, SearchResourceVo search, HttpServletRequest request) {
Result urlAuthResult = UrlParameterAuth.authIllegalities(request);
if (!urlAuthResult.isSuccessed()) {
logger.warn("用户:" + getSessionUser(request).getId() + " 请求:" + request.getRequestURI() + " " + urlAuthResult.getMsg());
return new ModelAndView("illegal");
}
String memberId = UserApplicationContext.getCurrentUserMemberId();
search.setMemberId(memberId);
model.addAttribute("search", search);
return new ModelAndView("security/resource/menuList");
}
}
| UTF-8 | Java | 1,929 | java | ResourceManagerController.java | Java | [] | null | [] | package cn.decision.security.controller;
import javax.servlet.http.HttpServletRequest;
import cn.decision.security.util.UrlParameterAuth.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.decision.framework.controller.BasicRedisController;
import cn.decision.security.UserApplicationContext;
import cn.decision.security.controller.vo.SearchResourceVo;
import cn.decision.security.util.UrlParameterAuth;
import org.springframework.web.servlet.ModelAndView;
/**
* @description 菜单管理控制类
*/
@Controller
@RequestMapping(value = "/sys/resources")
public class ResourceManagerController extends BasicRedisController {
private static Logger logger = LoggerFactory.getLogger(ResourceManagerController.class);
/**
* 进入到菜单管理页面
*
* @return
*/
@RequestMapping("toResourcePage")
public ModelAndView toResourcePage() {
return new ModelAndView("security/resource/menuList");
}
/**
* 分页查询菜单
*
* @param model
* @param search
* @return
*/
@RequestMapping("toResourceList")
public ModelAndView toResourceList(Model model, SearchResourceVo search, HttpServletRequest request) {
Result urlAuthResult = UrlParameterAuth.authIllegalities(request);
if (!urlAuthResult.isSuccessed()) {
logger.warn("用户:" + getSessionUser(request).getId() + " 请求:" + request.getRequestURI() + " " + urlAuthResult.getMsg());
return new ModelAndView("illegal");
}
String memberId = UserApplicationContext.getCurrentUserMemberId();
search.setMemberId(memberId);
model.addAttribute("search", search);
return new ModelAndView("security/resource/menuList");
}
}
| 1,929 | 0.7264 | 0.725333 | 58 | 31.327587 | 29.612083 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.431034 | false | false | 2 |
16237ef48106f75c408a19b7aa529d495728b515 | 29,489,245,501,741 | 5e3fd43fd3b1cd42d07f17c440238534afa10813 | /src/main/java/guru/springframework/controllers/ControllerExceptionHandler.java | 5ccb61e662968b2e23645c166f678895aa5f6a10 | [
"MIT"
] | permissive | nsimao/spring5-recipe-app | https://github.com/nsimao/spring5-recipe-app | e56eb08cbd38a6f19c38fc7744018f570959c5ac | a542e42371da5363892836c39c09e6d572a1fa90 | refs/heads/master | 2020-03-29T00:31:27.346000 | 2018-11-04T18:41:47 | 2018-11-04T18:41:47 | 149,343,575 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package guru.springframework.controllers;
import guru.springframework.exceptions.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
/**
* @author Nelson Simão
* @since 1.0
*/
@ControllerAdvice
public class ControllerExceptionHandler {
// -------------------------- OTHER METHODS --------------------------
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public ModelAndView handleNotFound(Exception exception) {
return getModelAndView(exception, "404error");
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(NumberFormatException.class)
public ModelAndView handleNumberFormat(Exception exception) {
return getModelAndView(exception, "400error");
}
private ModelAndView getModelAndView(Exception exception, String viewName) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(viewName);
modelAndView.addObject("exception", exception);
return modelAndView;
}
}
| UTF-8 | Java | 1,282 | java | ControllerExceptionHandler.java | Java | [
{
"context": "ramework.web.servlet.ModelAndView;\n\n/**\n * @author Nelson Simão\n * @since 1.0\n */\n\n@ControllerAdvice\npublic class",
"end": 419,
"score": 0.9998520612716675,
"start": 407,
"tag": "NAME",
"value": "Nelson Simão"
}
] | null | [] | package guru.springframework.controllers;
import guru.springframework.exceptions.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
/**
* @author <NAME>
* @since 1.0
*/
@ControllerAdvice
public class ControllerExceptionHandler {
// -------------------------- OTHER METHODS --------------------------
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
public ModelAndView handleNotFound(Exception exception) {
return getModelAndView(exception, "404error");
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(NumberFormatException.class)
public ModelAndView handleNumberFormat(Exception exception) {
return getModelAndView(exception, "400error");
}
private ModelAndView getModelAndView(Exception exception, String viewName) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(viewName);
modelAndView.addObject("exception", exception);
return modelAndView;
}
}
| 1,275 | 0.741608 | 0.735363 | 37 | 33.62162 | 25.660309 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.459459 | false | false | 2 |
a67d1026af751cc8a20f4959129539cc41a14a22 | 19,129,784,400,875 | 794f29a0574a2c8f5d64957dfc7fcec4c8ea3f1d | /GCD/src/pl/polsl/java/andrzej/kowol/serverclient/controller/Controller.java | e8037da06aaa5470a44ac27d064e42edd6a45b23 | [] | no_license | andrzej560/Java-Projects | https://github.com/andrzej560/Java-Projects | 015b329ef5d15be901d4bc89edeab2ba8522b04b | 5c7d57b756c849e4670aa46f13af74365f644622 | refs/heads/master | 2021-01-10T13:50:09.706000 | 2015-10-05T08:54:00 | 2015-10-05T08:54:00 | 43,672,277 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.polsl.java.andrzej.kowol.serverclient.controller;
import java.io.IOException;
import pl.polsl.java.andrzej.kowol.serverclient.model.Server;
import pl.polsl.java.andrzej.kowol.serverclient.view.Client;
import pl.polsl.java.andrzej.kowol.serverclient.view.View;
/**
* Main class of application. Create server or client.
*
* @author Andrzej Kowol
* @version 1.0
*/
public class Controller {
/**
* Main method of application. Responsible for create server or client on
* specified port.
*
* @param args First optional parameter is number of port. If the second
* optional parameter equals "client" then the client will be started. In
* other cases server will be started.
*/
public static void main(String[] args) {
View view = new View();
int port;
final int DEFAULT_PORT = 1025;
final String CLIENT_KEYWORD = "client";
if (args.length >= 1) {
try {
port = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
view.printException(1);
port = DEFAULT_PORT;
}
} else {
port = DEFAULT_PORT;
}
if (!(port >= 1025 && port <= 65535)) {
port = DEFAULT_PORT;
}
view.printPortInfo(port); //information about port
if (args.length >= 2 && args[1].equals(CLIENT_KEYWORD)) {
view.printInfo(2); //information about client mode
Client client = new Client(port);
try {
client.clientRun();
} catch (IOException e) {
view.printException(2); //information that is necessary to create server first
}
} else {
view.printInfo(1); //information about server mode
Server server = new Server(port);
try {
server.serverRun();
} catch (IOException | NullPointerException e) {
view.printException(1); //information that server probably exists on this port already
}
}
}
}
| UTF-8 | Java | 2,119 | java | Controller.java | Java | [
{
"context": "pplication. Create server or client.\n *\n * @author Andrzej Kowol\n * @version 1.0\n */\npublic class Controller {\n\n ",
"end": 359,
"score": 0.9998947978019714,
"start": 346,
"tag": "NAME",
"value": "Andrzej Kowol"
}
] | null | [] | package pl.polsl.java.andrzej.kowol.serverclient.controller;
import java.io.IOException;
import pl.polsl.java.andrzej.kowol.serverclient.model.Server;
import pl.polsl.java.andrzej.kowol.serverclient.view.Client;
import pl.polsl.java.andrzej.kowol.serverclient.view.View;
/**
* Main class of application. Create server or client.
*
* @author <NAME>
* @version 1.0
*/
public class Controller {
/**
* Main method of application. Responsible for create server or client on
* specified port.
*
* @param args First optional parameter is number of port. If the second
* optional parameter equals "client" then the client will be started. In
* other cases server will be started.
*/
public static void main(String[] args) {
View view = new View();
int port;
final int DEFAULT_PORT = 1025;
final String CLIENT_KEYWORD = "client";
if (args.length >= 1) {
try {
port = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
view.printException(1);
port = DEFAULT_PORT;
}
} else {
port = DEFAULT_PORT;
}
if (!(port >= 1025 && port <= 65535)) {
port = DEFAULT_PORT;
}
view.printPortInfo(port); //information about port
if (args.length >= 2 && args[1].equals(CLIENT_KEYWORD)) {
view.printInfo(2); //information about client mode
Client client = new Client(port);
try {
client.clientRun();
} catch (IOException e) {
view.printException(2); //information that is necessary to create server first
}
} else {
view.printInfo(1); //information about server mode
Server server = new Server(port);
try {
server.serverRun();
} catch (IOException | NullPointerException e) {
view.printException(1); //information that server probably exists on this port already
}
}
}
}
| 2,112 | 0.579047 | 0.567721 | 68 | 30.161764 | 25.769688 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false | 2 |
bc7e443f15eb0c9e05d866d69936e31e3c17ef69 | 19,645,180,476,171 | 9b5b6a786a30e14c468c15dbd44b89ca6fb808bd | /server/src/test/java/com/devicehive/config/ApplicationContextHolderTest.java | 7d1ad3ac530ae7fe59b38d06ee078558c34a84e2 | [
"MIT"
] | permissive | stanislavsidorenko/devicehive-java | https://github.com/stanislavsidorenko/devicehive-java | 9afa2bd0bc21148e704413582a2a00ebec949076 | 79c97a8955f8fb2fdfac66983312f8bc3d429adb | refs/heads/master | 2016-12-31T13:01:37.494000 | 2016-11-01T20:34:42 | 2016-11-01T20:34:42 | 26,729,176 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.devicehive.config;
import com.devicehive.server.util.context.ApplicationContextHolder;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mock;
import org.springframework.context.ApplicationContext;
public class ApplicationContextHolderTest {
@Mock
private ApplicationContext applicationContext;
@Test
public void test() {
ApplicationContextHolder applicationContextHolder = new ApplicationContextHolder();
applicationContextHolder.setApplicationContext(applicationContext);
Assert.assertEquals(ApplicationContextHolder.getApplicationContext(), applicationContext);
}
}
| UTF-8 | Java | 647 | java | ApplicationContextHolderTest.java | Java | [] | null | [] | package com.devicehive.config;
import com.devicehive.server.util.context.ApplicationContextHolder;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mock;
import org.springframework.context.ApplicationContext;
public class ApplicationContextHolderTest {
@Mock
private ApplicationContext applicationContext;
@Test
public void test() {
ApplicationContextHolder applicationContextHolder = new ApplicationContextHolder();
applicationContextHolder.setApplicationContext(applicationContext);
Assert.assertEquals(ApplicationContextHolder.getApplicationContext(), applicationContext);
}
}
| 647 | 0.797527 | 0.797527 | 21 | 29.809525 | 30.785927 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.52381 | false | false | 2 |
f56887f4ff29baf55f9152aeb9bf6b7c5b408bd8 | 3,822,520,949,901 | 60fd481d47bdcc768ebae0bd265fa9a676183f17 | /store-core/src/main/java/com/graby/store/dao/mybatis/ImportRecordDao.java | 5f77a2f941bc11096971013f4b9e3d7d7a5dc7c6 | [] | no_license | zilonglym/xinyu | https://github.com/zilonglym/xinyu | 3257d2d10187205c4f91efa4fed8e992a9419694 | 8828638b77e3e0f6da099f050476cf634ef84c7b | refs/heads/master | 2020-03-09T16:49:34.758000 | 2018-03-27T06:52:46 | 2018-03-27T06:52:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.graby.store.dao.mybatis;
import java.util.List;
import java.util.Map;
import com.graby.store.base.MyBatisRepository;
import com.graby.store.entity.ImportRecord;
@MyBatisRepository
public interface ImportRecordDao {
/**
* 导入 流水 记录
* @param checkOut
* */
public void save(ImportRecord importRecord);
/**
* 查询最后一个批次导入的信息
* @return
*/
public List<ImportRecord> findLastBatchImportRecord();
/**
* 查询 导入记录
* @param params
* @return
*/
public List<ImportRecord> findImportRecord(Map<String,Object> params);
/**
* 记录数量
* @param params
* @return
*/
public Long findImportRecordCount(Map<String,Object> params);
}
| UTF-8 | Java | 722 | java | ImportRecordDao.java | Java | [] | null | [] | package com.graby.store.dao.mybatis;
import java.util.List;
import java.util.Map;
import com.graby.store.base.MyBatisRepository;
import com.graby.store.entity.ImportRecord;
@MyBatisRepository
public interface ImportRecordDao {
/**
* 导入 流水 记录
* @param checkOut
* */
public void save(ImportRecord importRecord);
/**
* 查询最后一个批次导入的信息
* @return
*/
public List<ImportRecord> findLastBatchImportRecord();
/**
* 查询 导入记录
* @param params
* @return
*/
public List<ImportRecord> findImportRecord(Map<String,Object> params);
/**
* 记录数量
* @param params
* @return
*/
public Long findImportRecordCount(Map<String,Object> params);
}
| 722 | 0.703313 | 0.703313 | 38 | 16.473684 | 18.768307 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.947368 | false | false | 2 |
56c4b7d2519733fdc55e6f4aa3f3c5771d838abf | 4,320,737,107,859 | 713bf5c6ac57f8d43f9152fabbcd4c033662df03 | /javaprog/BitManipulation/AndOrXorProperties.java | 07941e4e9ceacc4f14e444e26e11be6db8cbb8d9 | [] | no_license | sujeet2395/Program | https://github.com/sujeet2395/Program | e8d9672944cddc51d0aaebb4350d8f798ca09eeb | d29d7ac2dad88a182375ef162301a3564853ba3e | refs/heads/master | 2020-03-19T07:35:19.468000 | 2019-05-28T16:06:05 | 2019-05-28T16:06:05 | 136,128,415 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package BitManipulation;
public class AndOrXorProperties {
public static void andProp() {
System.out.println("f & f : "+(false&false));
System.out.println("t & f : "+(true&false));
System.out.println("f & t : "+(false&true));
System.out.println("t & t : "+(true&true));
System.out.println("--------------");
}
public static void orProp() {
System.out.println("f | f : "+(false|false));
System.out.println("t | f : "+(true|false));
System.out.println("f | t : "+(false|true));
System.out.println("t | t : "+(true|true));
System.out.println("--------------");
}
public static void xorProp() {
System.out.println("f ^ f : "+(false^false));
System.out.println("t ^ f : "+(true^false));
System.out.println("f ^ t : "+(false^true));
System.out.println("t ^ t : "+(true^true));
System.out.println("--------------");
}
public static void setKthBit(int n, int k) {
int mask=1<<k;
System.out.println(Integer.toBinaryString(n));
n=n|mask;
System.out.println(Integer.toBinaryString(n));
}
public static void setKthBitOff(int n, int k) {
int mask=1<<k;
int revmask=~mask;
System.out.println(Integer.toBinaryString(n));
n=n&revmask;
System.out.println(Integer.toBinaryString(n));
}
public static void toogleKthBit(int n, int k) {
int mask=1<<k;
System.out.println(Integer.toBinaryString(n));
n=n^mask;
System.out.println(Integer.toBinaryString(n));
}
public static void printAllBits(int n) {
int i, mask;
System.out.println(Integer.toBinaryString(n));
for(i=31; i>=0; i--)
{
mask=1<<i;
if((n&mask)==0)
{
System.out.print(0);
}
else{
System.out.print(1);
}
}
System.out.println();
}
public static void main(String[] args) {
//andProp();
//orProp();
//xorProp();
int n=57;
int k=3;
setKthBit(n, k);
setKthBitOff(n, k);
toogleKthBit(n, k);
printAllBits(n);
}
}
| UTF-8 | Java | 2,265 | java | AndOrXorProperties.java | Java | [] | null | [] | package BitManipulation;
public class AndOrXorProperties {
public static void andProp() {
System.out.println("f & f : "+(false&false));
System.out.println("t & f : "+(true&false));
System.out.println("f & t : "+(false&true));
System.out.println("t & t : "+(true&true));
System.out.println("--------------");
}
public static void orProp() {
System.out.println("f | f : "+(false|false));
System.out.println("t | f : "+(true|false));
System.out.println("f | t : "+(false|true));
System.out.println("t | t : "+(true|true));
System.out.println("--------------");
}
public static void xorProp() {
System.out.println("f ^ f : "+(false^false));
System.out.println("t ^ f : "+(true^false));
System.out.println("f ^ t : "+(false^true));
System.out.println("t ^ t : "+(true^true));
System.out.println("--------------");
}
public static void setKthBit(int n, int k) {
int mask=1<<k;
System.out.println(Integer.toBinaryString(n));
n=n|mask;
System.out.println(Integer.toBinaryString(n));
}
public static void setKthBitOff(int n, int k) {
int mask=1<<k;
int revmask=~mask;
System.out.println(Integer.toBinaryString(n));
n=n&revmask;
System.out.println(Integer.toBinaryString(n));
}
public static void toogleKthBit(int n, int k) {
int mask=1<<k;
System.out.println(Integer.toBinaryString(n));
n=n^mask;
System.out.println(Integer.toBinaryString(n));
}
public static void printAllBits(int n) {
int i, mask;
System.out.println(Integer.toBinaryString(n));
for(i=31; i>=0; i--)
{
mask=1<<i;
if((n&mask)==0)
{
System.out.print(0);
}
else{
System.out.print(1);
}
}
System.out.println();
}
public static void main(String[] args) {
//andProp();
//orProp();
//xorProp();
int n=57;
int k=3;
setKthBit(n, k);
setKthBitOff(n, k);
toogleKthBit(n, k);
printAllBits(n);
}
}
| 2,265 | 0.507726 | 0.501987 | 72 | 30.458334 | 17.913322 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.861111 | false | false | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.