blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4fd1e067871946820a81a443bb516c8d30605384 | 33efe60e38d8fe5ffe54a0877000970f04d8fe7a | /src/main/java/com/bolsadeideas/springboot/app/model/service/IUploadFileService.java | 0086a75ebb12beba161a383be195524d970e86a5 | [] | no_license | llStrevensll/SpringBoot-Mysql | 70e918fd4f771ae22ca94a9afce99ef6913da0a4 | 46b726dd14bace78b6aa1555990ac62879a22b8b | refs/heads/master | 2021-04-22T01:58:27.582149 | 2020-04-17T23:34:24 | 2020-04-17T23:34:24 | 249,841,372 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 532 | java | package com.bolsadeideas.springboot.app.model.service;
import java.io.IOException;
import java.net.MalformedURLException;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
public interface IUploadFileService {
public Resource load(String filename) throws MalformedURLException;
public String copy(MultipartFile file) throws IOException;
public boolean delete(String filename);
public void deleteAll();
public void init() throws IOException;
}
| [
"[email protected]"
] | |
4ac885f6c59391e2969e75008555479acb9e2956 | d2c90bcc07dbb6d4eec5707f721fd135f581da4b | /CommandType.java | 42cab9568507f3e6b3b2af98690d3c76ed46eb7e | [] | no_license | Meagherq/CIS457FinalProject | a9e5afbdac435996b2f42a3ec2b06dbc83334e82 | e146d3a13c42d448d62581649f6e246e9ef56acb | refs/heads/master | 2020-05-15T08:20:52.122932 | 2019-04-19T14:41:06 | 2019-04-19T14:41:06 | 182,158,453 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 47 | java | enum CommandType{
MESSAGE, QUIT, COMMAND
}
| [
"[email protected]"
] | |
764d680bf5705cfc19d1402331ffee2b33a5209a | 638f87b495f948e5023464ea0b361862afd35ea4 | /src/main/java/br/gov/pa/cosanpa/gopera/managedBean/RelatorioHorasBean.java | 88d35098c2f922b8a84c8f3ead6df03761c0cd06 | [] | no_license | prodigasistemas/gsan-operacional | 6971759fa1f18c75f0018fd1b3847ce272fa5543 | fa87bf69eff3412ad5e153351d45d9a6ea0a29ba | refs/heads/master | 2021-01-17T09:08:05.864963 | 2017-07-18T14:40:20 | 2019-04-18T12:58:52 | 15,616,471 | 1 | 3 | null | 2015-04-06T12:19:36 | 2014-01-03T18:31:34 | Java | UTF-8 | Java | false | false | 4,013 | java | package br.gov.pa.cosanpa.gopera.managedBean;
import static br.gov.model.util.Utilitarios.converteAnoMesParaMesAno;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.jboss.logging.Logger;
import br.gov.pa.cosanpa.gopera.util.DadosExcel;
import br.gov.pa.cosanpa.gopera.util.GeradorExcel;
import br.gov.servicos.operacao.RelatorioHorasRepositorio;
import br.gov.servicos.operacao.to.FiltroOperacionalTO;
import br.gov.servicos.operacao.to.HorasRelatorioTO;
@ManagedBean
@ViewScoped
public class RelatorioHorasBean extends BaseMensagemBean{
private Logger logger = Logger.getLogger(RelatorioHorasBean.class);
@EJB
private RelatorioHorasRepositorio relatorioHoras;
private FiltroOperacionalTO to = new FiltroOperacionalTO();
public void exibir() {
try {
if (!to.intervaloValido()) {
mostrarMensagemErro(bundle.getText("erro_intervalo_invalido"));
return;
}
List<HorasRelatorioTO> relatorio = relatorioHoras.consultaHoras(to);
final Integer qtdMaximaCmb = relatorioHoras.quantidadeMaximaCmb(to);
if (relatorio.size() == 0){
mostrarMensagemAviso(bundle.getText("erro_nao_existe_retorno_filtro"));
}else{
DadosExcel excel = new DadosExcel() {
public String periodo() {
return converteAnoMesParaMesAno(to.getReferenciaInicial()) + " a " + converteAnoMesParaMesAno(to.getReferenciaFinal());
}
public String filtro(){
return to.filtroSelecionado();
}
public String tituloRelatorio() {
return bundle.getText("horas_sistema");
}
public String nomeArquivo() {
return "Horas do Sistema";
}
public List<List<String>> dados() {
List<List<String>> linhas = new ArrayList<List<String>>();
for (HorasRelatorioTO item : relatorio) {
linhas.add(item.toArray());
}
return linhas;
}
public String[] cabecalho() {
String[] cabecalho = new String[]{
bundle.getText("gerencia_regional")
, bundle.getText("unidade_negocio")
, bundle.getText("municipio")
, bundle.getText("localidade")
, bundle.getText("tipo_unidade_operacional")
, bundle.getText("codigo_uc")
, bundle.getText("unidade_operacional")
, bundle.getText("referencia")
, bundle.getText("total_horas_mes")
, bundle.getText("conjunto_motor_bomba")
, bundle.getText("horas_paradas_energia")
, bundle.getText("horas_paradas_manutencao")
, bundle.getText("horas_paradas_controle")
, bundle.getText("horas_trabalhadas")
};
String[] comCmbs = Arrays.copyOf(cabecalho, cabecalho.length + qtdMaximaCmb);
for(int i = cabecalho.length; i < cabecalho.length + qtdMaximaCmb; i++){
comCmbs[i] = (i - cabecalho.length + 1) + " CMB";
}
return comCmbs;
}
};
GeradorExcel gerador = new GeradorExcel(excel);
gerador.geraPlanilha();
}
} catch (Exception e) {
logger.error(bundle.getText("erro_gerar_relatorio"), e);
mostrarMensagemErro(bundle.getText("erro_gerar_relatorio"));
}
}
public FiltroOperacionalTO getTo() {
return to;
}
public void setTo(FiltroOperacionalTO to) {
this.to = to;
}
}
| [
"[email protected]"
] | |
63e28d963f2129d957675364053be953c7fd9328 | 3eff2ea119ebaab6b84609a109c2ccc591cc7337 | /gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java | 0870529162bd91758629b01b64b5834ca7befe4c | [] | no_license | xjxlx/player | 4887b2766e60cbde1f28508875e20b7ddfe23487 | a5e4a9d8d52c5637ac2ea3a15e707aa801bce12b | refs/heads/master | 2023-08-04T09:11:07.940900 | 2023-08-01T08:22:51 | 2023-08-01T08:22:51 | 330,207,524 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 33,078 | java | package com.shuyu.gsyvideoplayer.video;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.listener.GSYVideoShotListener;
import com.shuyu.gsyvideoplayer.listener.GSYVideoShotSaveListener;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.utils.NetworkUtils;
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer;
import java.io.File;
import moe.codeest.enviews.ENDownloadView;
import moe.codeest.enviews.ENPlayView;
/**
* 标准播放器,继承之后实现一些ui显示效果,如显示/隐藏ui,播放按键等
* Created by shuyu on 2016/11/11.
*/
public class StandardGSYVideoPlayer extends GSYVideoPlayer {
//亮度dialog
protected Dialog mBrightnessDialog;
//音量dialog
protected Dialog mVolumeDialog;
//触摸进度dialog
protected Dialog mProgressDialog;
//触摸进度条的progress
protected ProgressBar mDialogProgressBar;
//音量进度条的progress
protected ProgressBar mDialogVolumeProgressBar;
//亮度文本
protected TextView mBrightnessDialogTv;
//触摸移动显示文本
protected TextView mDialogSeekTime;
//触摸移动显示全部时间
protected TextView mDialogTotalTime;
//触摸移动方向icon
protected ImageView mDialogIcon;
protected Drawable mBottomProgressDrawable;
protected Drawable mBottomShowProgressDrawable;
protected Drawable mBottomShowProgressThumbDrawable;
protected Drawable mVolumeProgressDrawable;
protected Drawable mDialogProgressBarDrawable;
protected int mDialogProgressHighLightColor = -11;
protected int mDialogProgressNormalColor = -11;
/**
* 1.5.0开始加入,如果需要不同布局区分功能,需要重载
*/
public StandardGSYVideoPlayer(Context context, Boolean fullFlag) {
super(context, fullFlag);
}
public StandardGSYVideoPlayer(Context context) {
super(context);
}
public StandardGSYVideoPlayer(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void init(Context context) {
super.init(context);
//增加自定义ui
if (mBottomProgressDrawable != null) {
mBottomProgressBar.setProgressDrawable(mBottomProgressDrawable);
}
if (mBottomShowProgressDrawable != null) {
mProgressBar.setProgressDrawable(mBottomProgressDrawable);
}
if (mBottomShowProgressThumbDrawable != null) {
mProgressBar.setThumb(mBottomShowProgressThumbDrawable);
}
}
/**
* 继承后重写可替换为你需要的布局
*
* @return
*/
@Override
public int getLayoutId() {
return R.layout.video_layout_standard;
}
/**
* 开始播放
*/
@Override
public void startPlayLogic() {
if (mVideoAllCallBack != null) {
Debuger.printfLog("onClickStartThumb");
mVideoAllCallBack.onClickStartThumb(mOriginUrl, mTitle, StandardGSYVideoPlayer.this);
}
prepareVideo();
startDismissControlViewTimer();
}
/**
* 显示wifi确定框,如需要自定义继承重写即可
*/
@Override
protected void showWifiDialog() {
if (!NetworkUtils.isAvailable(mContext)) {
//Toast.makeText(mContext, getResources().getString(R.string.no_net), Toast.LENGTH_LONG).show();
startPlayLogic();
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivityContext());
builder.setMessage(getResources().getString(R.string.tips_not_wifi));
builder.setPositiveButton(getResources().getString(R.string.tips_not_wifi_confirm), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
startPlayLogic();
}
});
builder.setNegativeButton(getResources().getString(R.string.tips_not_wifi_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
/**
* 触摸显示滑动进度dialog,如需要自定义继承重写即可,记得重写dismissProgressDialog
*/
@Override
@SuppressWarnings("ResourceType")
protected void showProgressDialog(float deltaX, String seekTime, int seekTimePosition, String totalTime, int totalTimeDuration) {
if (mProgressDialog == null) {
View localView = LayoutInflater.from(getActivityContext()).inflate(getProgressDialogLayoutId(), null);
if (localView.findViewById(getProgressDialogProgressId()) instanceof ProgressBar) {
mDialogProgressBar = ((ProgressBar) localView.findViewById(getProgressDialogProgressId()));
if (mDialogProgressBarDrawable != null) {
mDialogProgressBar.setProgressDrawable(mDialogProgressBarDrawable);
}
}
if (localView.findViewById(getProgressDialogCurrentDurationTextId()) instanceof TextView) {
mDialogSeekTime = ((TextView) localView.findViewById(getProgressDialogCurrentDurationTextId()));
}
if (localView.findViewById(getProgressDialogAllDurationTextId()) instanceof TextView) {
mDialogTotalTime = ((TextView) localView.findViewById(getProgressDialogAllDurationTextId()));
}
if (localView.findViewById(getProgressDialogImageId()) instanceof ImageView) {
mDialogIcon = ((ImageView) localView.findViewById(getProgressDialogImageId()));
}
mProgressDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress);
mProgressDialog.setContentView(localView);
mProgressDialog.getWindow().addFlags(Window.FEATURE_ACTION_BAR);
mProgressDialog.getWindow().addFlags(32);
mProgressDialog.getWindow().addFlags(16);
mProgressDialog.getWindow().setLayout(getWidth(), getHeight());
if (mDialogProgressNormalColor != -11 && mDialogTotalTime != null) {
mDialogTotalTime.setTextColor(mDialogProgressNormalColor);
}
if (mDialogProgressHighLightColor != -11 && mDialogSeekTime != null) {
mDialogSeekTime.setTextColor(mDialogProgressHighLightColor);
}
WindowManager.LayoutParams localLayoutParams = mProgressDialog.getWindow().getAttributes();
localLayoutParams.gravity = Gravity.TOP;
localLayoutParams.width = getWidth();
localLayoutParams.height = getHeight();
int location[] = new int[2];
getLocationOnScreen(location);
localLayoutParams.x = location[0];
localLayoutParams.y = location[1];
mProgressDialog.getWindow().setAttributes(localLayoutParams);
}
if (!mProgressDialog.isShowing()) {
mProgressDialog.show();
}
if (mDialogSeekTime != null) {
mDialogSeekTime.setText(seekTime);
}
if (mDialogTotalTime != null) {
mDialogTotalTime.setText(" / " + totalTime);
}
if (totalTimeDuration > 0)
if (mDialogProgressBar != null) {
mDialogProgressBar.setProgress(seekTimePosition * 100 / totalTimeDuration);
}
if (deltaX > 0) {
if (mDialogIcon != null) {
mDialogIcon.setBackgroundResource(R.drawable.video_forward_icon);
}
} else {
if (mDialogIcon != null) {
mDialogIcon.setBackgroundResource(R.drawable.video_backward_icon);
}
}
}
@Override
protected void dismissProgressDialog() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
/**
* 触摸音量dialog,如需要自定义继承重写即可,记得重写dismissVolumeDialog
*/
@Override
protected void showVolumeDialog(float deltaY, int volumePercent) {
if (mVolumeDialog == null) {
View localView = LayoutInflater.from(getActivityContext()).inflate(getVolumeLayoutId(), null);
if (localView.findViewById(getVolumeProgressId()) instanceof ProgressBar) {
mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(getVolumeProgressId()));
if (mVolumeProgressDrawable != null && mDialogVolumeProgressBar != null) {
mDialogVolumeProgressBar.setProgressDrawable(mVolumeProgressDrawable);
}
}
mVolumeDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress);
mVolumeDialog.setContentView(localView);
mVolumeDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
mVolumeDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
mVolumeDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
mVolumeDialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
WindowManager.LayoutParams localLayoutParams = mVolumeDialog.getWindow().getAttributes();
localLayoutParams.gravity = Gravity.TOP | Gravity.START;
localLayoutParams.width = getWidth();
localLayoutParams.height = getHeight();
int location[] = new int[2];
getLocationOnScreen(location);
localLayoutParams.x = location[0];
localLayoutParams.y = location[1];
mVolumeDialog.getWindow().setAttributes(localLayoutParams);
}
if (!mVolumeDialog.isShowing()) {
mVolumeDialog.show();
}
if (mDialogVolumeProgressBar != null) {
mDialogVolumeProgressBar.setProgress(volumePercent);
}
}
@Override
protected void dismissVolumeDialog() {
if (mVolumeDialog != null) {
mVolumeDialog.dismiss();
mVolumeDialog = null;
}
}
/**
* 触摸亮度dialog,如需要自定义继承重写即可,记得重写dismissBrightnessDialog
*/
@Override
protected void showBrightnessDialog(float percent) {
if (mBrightnessDialog == null) {
View localView = LayoutInflater.from(getActivityContext()).inflate(getBrightnessLayoutId(), null);
if (localView.findViewById(getBrightnessTextId()) instanceof TextView) {
mBrightnessDialogTv = (TextView) localView.findViewById(getBrightnessTextId());
}
mBrightnessDialog = new Dialog(getActivityContext(), R.style.video_style_dialog_progress);
mBrightnessDialog.setContentView(localView);
mBrightnessDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
mBrightnessDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
mBrightnessDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
mBrightnessDialog.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mBrightnessDialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
WindowManager.LayoutParams localLayoutParams = mBrightnessDialog.getWindow().getAttributes();
localLayoutParams.gravity = Gravity.TOP | Gravity.END;
localLayoutParams.width = getWidth();
localLayoutParams.height = getHeight();
int location[] = new int[2];
getLocationOnScreen(location);
localLayoutParams.x = location[0];
localLayoutParams.y = location[1];
mBrightnessDialog.getWindow().setAttributes(localLayoutParams);
}
if (!mBrightnessDialog.isShowing()) {
mBrightnessDialog.show();
}
if (mBrightnessDialogTv != null)
mBrightnessDialogTv.setText((int) (percent * 100) + "%");
}
@Override
protected void dismissBrightnessDialog() {
if (mBrightnessDialog != null) {
mBrightnessDialog.dismiss();
mBrightnessDialog = null;
}
}
@Override
protected void cloneParams(GSYBaseVideoPlayer from, GSYBaseVideoPlayer to) {
super.cloneParams(from, to);
StandardGSYVideoPlayer sf = (StandardGSYVideoPlayer) from;
StandardGSYVideoPlayer st = (StandardGSYVideoPlayer) to;
if (st.mProgressBar != null && sf.mProgressBar != null) {
st.mProgressBar.setProgress(sf.mProgressBar.getProgress());
st.mProgressBar.setSecondaryProgress(sf.mProgressBar.getSecondaryProgress());
}
if (st.mTotalTimeTextView != null && sf.mTotalTimeTextView != null) {
st.mTotalTimeTextView.setText(sf.mTotalTimeTextView.getText());
}
if (st.mCurrentTimeTextView != null && sf.mCurrentTimeTextView != null) {
st.mCurrentTimeTextView.setText(sf.mCurrentTimeTextView.getText());
}
}
/**
* 将自定义的效果也设置到全屏
*
* @param context
* @param actionBar 是否有actionBar,有的话需要隐藏
* @param statusBar 是否有状态bar,有的话需要隐藏
* @return
*/
@Override
public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) {
GSYBaseVideoPlayer gsyBaseVideoPlayer = super.startWindowFullscreen(context, actionBar, statusBar);
if (gsyBaseVideoPlayer != null) {
StandardGSYVideoPlayer gsyVideoPlayer = (StandardGSYVideoPlayer) gsyBaseVideoPlayer;
gsyVideoPlayer.setLockClickListener(mLockClickListener);
gsyVideoPlayer.setNeedLockFull(isNeedLockFull());
initFullUI(gsyVideoPlayer);
//比如你自定义了返回案件,但是因为返回按键底层已经设置了返回事件,所以你需要在这里重新增加的逻辑
}
return gsyBaseVideoPlayer;
}
/********************************各类UI的状态显示*********************************************/
/**
* 点击触摸显示和隐藏逻辑
*/
@Override
protected void onClickUiToggle() {
if (mIfCurrentIsFullscreen && mLockCurScreen && mNeedLockFull) {
setViewShowState(mLockScreen, VISIBLE);
return;
}
if (mCurrentState == CURRENT_STATE_PREPAREING) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPrepareingClear();
} else {
changeUiToPreparingShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PLAYING) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPlayingClear();
} else {
changeUiToPlayingShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PAUSE) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPauseClear();
} else {
changeUiToPauseShow();
}
}
} else if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToCompleteClear();
} else {
changeUiToCompleteShow();
}
}
} else if (mCurrentState == CURRENT_STATE_PLAYING_BUFFERING_START) {
if (mBottomContainer != null) {
if (mBottomContainer.getVisibility() == View.VISIBLE) {
changeUiToPlayingBufferingClear();
} else {
changeUiToPlayingBufferingShow();
}
}
}
}
@Override
protected void hideAllWidget() {
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomProgressBar, VISIBLE);
setViewShowState(mStartButton, INVISIBLE);
}
@Override
protected void changeUiToNormal() {
Debuger.printfLog("changeUiToNormal");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, VISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
updateStartImage();
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
}
@Override
protected void changeUiToPreparingShow() {
Debuger.printfLog("changeUiToPreparingShow");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, VISIBLE);
setViewShowState(mStartButton, INVISIBLE);
setViewShowState(mLoadingProgressBar, VISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar;
if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) {
((ENDownloadView) mLoadingProgressBar).start();
}
}
}
@Override
protected void changeUiToPlayingShow() {
Debuger.printfLog("changeUiToPlayingShow");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, VISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
}
@Override
protected void changeUiToPauseShow() {
Debuger.printfLog("changeUiToPauseShow");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, VISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
updatePauseCover();
}
@Override
protected void changeUiToPlayingBufferingShow() {
Debuger.printfLog("changeUiToPlayingBufferingShow");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, VISIBLE);
setViewShowState(mStartButton, INVISIBLE);
setViewShowState(mLoadingProgressBar, VISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar;
if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) {
((ENDownloadView) mLoadingProgressBar).start();
}
}
}
@Override
protected void changeUiToCompleteShow() {
Debuger.printfLog("changeUiToCompleteShow");
setViewShowState(mTopContainer, VISIBLE);
setViewShowState(mBottomContainer, VISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, VISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
}
@Override
protected void changeUiToError() {
Debuger.printfLog("changeUiToError");
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
dismissVolumeDialog();
dismissBrightnessDialog();
}
/**
* 触摸进度dialog的layoutId
* 继承后重写可返回自定义
* 有自定义的实现逻辑可重载showProgressDialog方法
*/
protected int getProgressDialogLayoutId() {
return R.layout.video_progress_dialog;
}
/**
* 触摸进度dialog的进度条id
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showProgressDialog方法
*/
protected int getProgressDialogProgressId() {
return R.id.duration_progressbar;
}
/**
* 触摸进度dialog的当前时间文本
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showProgressDialog方法
*/
protected int getProgressDialogCurrentDurationTextId() {
return R.id.tv_current;
}
/**
* 触摸进度dialog全部时间文本
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showProgressDialog方法
*/
protected int getProgressDialogAllDurationTextId() {
return R.id.tv_duration;
}
/**
* 触摸进度dialog的图片id
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showProgressDialog方法
*/
protected int getProgressDialogImageId() {
return R.id.duration_image_tip;
}
/**
* 音量dialog的layoutId
* 继承后重写可返回自定义
* 有自定义的实现逻辑可重载showVolumeDialog方法
*/
protected int getVolumeLayoutId() {
return R.layout.video_volume_dialog;
}
/**
* 音量dialog的百分比进度条 id
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showVolumeDialog方法
*/
protected int getVolumeProgressId() {
return R.id.volume_progressbar;
}
/**
* 亮度dialog的layoutId
* 继承后重写可返回自定义
* 有自定义的实现逻辑可重载showBrightnessDialog方法
*/
protected int getBrightnessLayoutId() {
return R.layout.video_brightness;
}
/**
* 亮度dialog的百分比text id
* 继承后重写可返回自定义,如果没有可返回空
* 有自定义的实现逻辑可重载showBrightnessDialog方法
*/
protected int getBrightnessTextId() {
return R.id.app_video_brightness;
}
protected void changeUiToPrepareingClear() {
Debuger.printfLog("changeUiToPrepareingClear");
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, INVISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
}
protected void changeUiToPlayingClear() {
Debuger.printfLog("changeUiToPlayingClear");
changeUiToClear();
setViewShowState(mBottomProgressBar, VISIBLE);
}
protected void changeUiToPauseClear() {
Debuger.printfLog("changeUiToPauseClear");
changeUiToClear();
setViewShowState(mBottomProgressBar, VISIBLE);
updatePauseCover();
}
protected void changeUiToPlayingBufferingClear() {
Debuger.printfLog("changeUiToPlayingBufferingClear");
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, INVISIBLE);
setViewShowState(mLoadingProgressBar, VISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, VISIBLE);
setViewShowState(mLockScreen, GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar;
if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) {
((ENDownloadView) mLoadingProgressBar).start();
}
}
updateStartImage();
}
protected void changeUiToClear() {
Debuger.printfLog("changeUiToClear");
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, INVISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, INVISIBLE);
setViewShowState(mBottomProgressBar, INVISIBLE);
setViewShowState(mLockScreen, GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
}
protected void changeUiToCompleteClear() {
Debuger.printfLog("changeUiToCompleteClear");
setViewShowState(mTopContainer, INVISIBLE);
setViewShowState(mBottomContainer, INVISIBLE);
setViewShowState(mStartButton, VISIBLE);
setViewShowState(mLoadingProgressBar, INVISIBLE);
setViewShowState(mThumbImageViewLayout, VISIBLE);
setViewShowState(mBottomProgressBar, VISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? VISIBLE : GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
}
/**
* 定义开始按键显示
*/
protected void updateStartImage() {
if (mStartButton instanceof ENPlayView) {
ENPlayView enPlayView = (ENPlayView) mStartButton;
enPlayView.setDuration(500);
if (mCurrentState == CURRENT_STATE_PLAYING) {
enPlayView.play();
} else if (mCurrentState == CURRENT_STATE_ERROR) {
enPlayView.pause();
} else {
enPlayView.pause();
}
} else if (mStartButton instanceof ImageView) {
ImageView imageView = (ImageView) mStartButton;
if (mCurrentState == CURRENT_STATE_PLAYING) {
imageView.setImageResource(R.drawable.video_click_pause_selector);
} else if (mCurrentState == CURRENT_STATE_ERROR) {
imageView.setImageResource(R.drawable.video_click_error_selector);
} else {
imageView.setImageResource(R.drawable.video_click_play_selector);
}
}
}
/**
* 全屏的UI逻辑
*/
private void initFullUI(StandardGSYVideoPlayer standardGSYVideoPlayer) {
if (mBottomProgressDrawable != null) {
standardGSYVideoPlayer.setBottomProgressBarDrawable(mBottomProgressDrawable);
}
if (mBottomShowProgressDrawable != null && mBottomShowProgressThumbDrawable != null) {
standardGSYVideoPlayer.setBottomShowProgressBarDrawable(mBottomShowProgressDrawable,
mBottomShowProgressThumbDrawable);
}
if (mVolumeProgressDrawable != null) {
standardGSYVideoPlayer.setDialogVolumeProgressBar(mVolumeProgressDrawable);
}
if (mDialogProgressBarDrawable != null) {
standardGSYVideoPlayer.setDialogProgressBar(mDialogProgressBarDrawable);
}
if (mDialogProgressHighLightColor >= 0 && mDialogProgressNormalColor >= 0) {
standardGSYVideoPlayer.setDialogProgressColor(mDialogProgressHighLightColor, mDialogProgressNormalColor);
}
}
/**
* 底部进度条-弹出的
*/
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb) {
mBottomShowProgressDrawable = drawable;
mBottomShowProgressThumbDrawable = thumb;
if (mProgressBar != null) {
mProgressBar.setProgressDrawable(drawable);
mProgressBar.setThumb(thumb);
}
}
/**
* 底部进度条-非弹出
*/
public void setBottomProgressBarDrawable(Drawable drawable) {
mBottomProgressDrawable = drawable;
if (mBottomProgressBar != null) {
mBottomProgressBar.setProgressDrawable(drawable);
}
}
/**
* 声音进度条
*/
public void setDialogVolumeProgressBar(Drawable drawable) {
mVolumeProgressDrawable = drawable;
}
/**
* 中间进度条
*/
public void setDialogProgressBar(Drawable drawable) {
mDialogProgressBarDrawable = drawable;
}
/**
* 中间进度条字体颜色
*/
public void setDialogProgressColor(int highLightColor, int normalColor) {
mDialogProgressHighLightColor = highLightColor;
mDialogProgressNormalColor = normalColor;
}
/************************************* 关于截图的 ****************************************/
/**
* 获取截图
*/
public void taskShotPic(GSYVideoShotListener gsyVideoShotListener) {
this.taskShotPic(gsyVideoShotListener, false);
}
/**
* 获取截图
*
* @param high 是否需要高清的
*/
public void taskShotPic(GSYVideoShotListener gsyVideoShotListener, boolean high) {
if (getCurrentPlayer().getRenderProxy() != null) {
getCurrentPlayer().getRenderProxy().taskShotPic(gsyVideoShotListener, high);
}
}
/**
* 保存截图
*/
public void saveFrame(final File file, GSYVideoShotSaveListener gsyVideoShotSaveListener) {
saveFrame(file, false, gsyVideoShotSaveListener);
}
/**
* 保存截图
*
* @param high 是否需要高清的
*/
public void saveFrame(final File file, final boolean high, final GSYVideoShotSaveListener gsyVideoShotSaveListener) {
if (getCurrentPlayer().getRenderProxy() != null) {
getCurrentPlayer().getRenderProxy().saveFrame(file, high, gsyVideoShotSaveListener);
}
}
/**
* 重新开启进度查询以及控制view消失的定时任务
* 用于解决GSYVideoHelper中通过removeview方式做全屏切换导致的定时任务停止的问题
* GSYVideoControlView onDetachedFromWindow()
*/
public void restartTimerTask() {
startProgressTimer();
startDismissControlViewTimer();
}
}
| [
"[email protected]"
] | |
8bfdea80a41f11856abc7b9bd952e35a9f6b00db | e7b85e42786bdf213d8553be5518538acd44da5a | /src/com/xinyu/test/TestArray44.java | d2925addae3c74d8a16c8cece4086e6857d39087 | [] | no_license | TomasYu/AlgorithmsLearn | 9db3b4a2134e11d9960a0374c6932cfe8b2c1f5d | dbadae27672111e0c7a2b3ad5f506c52de6f2492 | refs/heads/master | 2023-08-08T20:55:25.644881 | 2023-07-29T10:14:09 | 2023-07-29T10:14:09 | 164,102,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,589 | java | package com.xinyu.test;
public class TestArray44 {
public static void main(String[] args) {
superEggDrop(1,2);
}
/**
* 鸡蛋掉落
* 你将获得 K 个鸡蛋,并可以使用一栋从 1 到 N 共有 N 层楼的建筑。
*
* 每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去。
*
* 你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落下的鸡蛋都不会破。
*
* 每次移动,你可以取一个鸡蛋(如果你有完整的鸡蛋)并把它从任一楼层 X 扔下(满足 1 <= X <= N)。
*
* 你的目标是确切地知道 F 的值是多少。
*
* 无论 F 的初始值如何,你确定 F 的值的最小移动次数是多少?
*
*
*
* 示例 1:
*
* 输入:K = 1, N = 2
* 输出:2
* 解释:
* 鸡蛋从 1 楼掉落。如果它碎了,我们肯定知道 F = 0 。
* 否则,鸡蛋从 2 楼掉落。如果它碎了,我们肯定知道 F = 1 。
* 如果它没碎,那么我们肯定知道 F = 2 。
* 因此,在最坏的情况下我们需要移动 2 次以确定 F 是多少。
* 示例 2:
*
* 输入:K = 2, N = 6
* 输出:3
* 示例 3:
*
* 输入:K = 3, N = 14
* 输出:4
*
*
* 提示:
*
* 1 <= K <= 100
* 1 <= N <= 10000
*/
public static int superEggDrop(int K, int N) {
return -1;
}
}
| [
"[email protected]"
] | |
56acefa953c76ed20c45701ee6622e254a2b358d | 39e0376030030a04a619c8b57a2e00e8c3fd35da | /project1026/src/event/MyWindowListener.java | 5e0bdb894cd87e431d1c44a36fabe59ffaff018f | [] | no_license | zzangyoon/java_workspace | daf2d64ed4f90723002ec83315b705733869a926 | 93219bd467b84ee4e02589a60bd8ee9a98af7cb7 | refs/heads/master | 2023-01-23T19:39:11.266701 | 2020-11-20T08:40:10 | 2020-11-20T08:40:10 | 305,320,851 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 1,187 | java | /*10. 윈도우창을 대상으로 발생할 수 있는 이벤트를 감지하는 리스너 구현하기*/
package event;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class MyWindowListener implements WindowListener{
public void windowActivated(WindowEvent e){ //현재 창을 활성화시킬때 (즉, 커서가 현재 창에 올라와 사용중일때)
System.out.println("windowActivated 호출");
}
public void windowClosed(WindowEvent e){ //창이 닫히면
System.out.println("windowClosed 호출");
}
public void windowClosing(WindowEvent e){ //닫기 버튼을 누르때(창이 닫히지는 않음)
System.out.println("windowClosing 호출");
}
public void windowDeactivated(WindowEvent e){
System.out.println("windowDeactivated 호출");
}
public void windowDeiconified(WindowEvent e){ //최소화 버튼을 눌러 아이콘화 시킬때
System.out.println("windowDeiconified 호출");
}
public void windowIconified(WindowEvent e){ //아이콘화의 반대
System.out.println("windowIconified 호출");
}
public void windowOpened(WindowEvent e){ //창이 뜰 때
System.out.println("windowOpened 호출");
}
}
| [
"[email protected]"
] | |
7cfaef17c25066164abbc50429c3a689ab732374 | 20f82399d6285fe04753877b1dc4619b8572a7ce | /OMC/src/main/java/com/a/omc/initializer/OMCInitializer.java | 4e67c0e4ca4347aaee81e10b9d7ee6da42e2953e | [] | no_license | jklopp11/OMC | 9866ca7349702bf2605fe5a25e2cabb41808f683 | 04ba1787eff754d41462a302227d847c3a771bbb | refs/heads/master | 2020-06-23T05:45:13.873775 | 2019-07-24T03:22:30 | 2019-07-24T03:22:30 | 198,529,156 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 869 | java | package com.a.omc.initializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.a.omc.handler.OMCServerHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
@Component
public class OMCInitializer extends ChannelInitializer<Channel> {
@Autowired
private OMCServerHandler omcServerHandler;
@Override
protected void initChannel(Channel sc) throws Exception {
sc.pipeline().addLast(new ObjectEncoder());
sc.pipeline().addLast(new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)));
sc.pipeline().addLast(omcServerHandler);
}
}
| [
"[email protected]"
] | |
fa554a249a05fe9e46e74b1a3ff18af71c294ca5 | 51cb5b254c68472ee67cc4147472506b477fc4b2 | /src/test/java/com/cybertek/pages/zContactInfoPage.java | 4a35712ee199fe9c979c8b924803110e1251a998 | [] | no_license | selmanland/EU5TestNGSelenium | acdab04b0b6fb4ba3711deac70ed9097fbb91a48 | 07a6a322039463b9aa0f54b874d130a9db2e9040 | refs/heads/master | 2023-07-18T04:36:31.150763 | 2021-08-24T22:04:46 | 2021-08-24T22:04:55 | 394,937,417 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 455 | java | package com.cybertek.pages;
import com.cybertek.utilities.Driver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
public class zContactInfoPage extends BasePage{
public zContactInfoPage (){
PageFactory.initElements(Driver.get(),this);
}
public WebElement getName(String name){
return Driver.get().findElement(By.xpath("//h1[text()='"+name+"']"));
}
}
| [
"[email protected]"
] | |
4fd6f517c095dd6c0838ad7c71771e98c5b0a0f0 | fee12418e40ec6590de3a6d6379cc7bafa997d79 | /AdventOfCode/src/aoc20/Day4.java | b32d1dfec7897c9856ea08680fa43b507e6b29c0 | [
"MIT"
] | permissive | melonhead901/programming-competition | 02681d864d3175fc13dbe0ce34fa44265399a9f4 | 42c574f680ccbc0f1247c7eb45c8cbb0dac1248e | refs/heads/master | 2022-12-22T07:05:29.277453 | 2022-12-14T05:42:36 | 2022-12-14T05:42:36 | 25,145,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,990 | java | package aoc20;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Day4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int count = 0;
while (in.hasNextLine()) {
if (processCase(in)) {
count++;
}
System.out.println(count);
}
}
private static boolean processCase(Scanner in) {
List<String> words = new ArrayList<>();
String line = in.nextLine();
while (!line.isEmpty()) {
words.addAll(Arrays.asList(line.split(" ")));
line = in.nextLine();
}
boolean valid = validateWords(words);
return valid;
}
private static boolean part1(List<String> words) {
Set<String> prefixes = new HashSet<>();
for (String word : words) {
prefixes.add(word.split(":")[0]);
}
return isSuccessful(prefixes);
}
private static boolean validateWords(List<String> words) {
/*
byr (Birth Year) - four digits; at least 1920 and at most 2002.
iyr (Issue Year) - four digits; at least 2010 and at most 2020.
eyr (Expiration Year) - four digits; at least 2020 and at most 2030.
hgt (Height) - a number followed by either cm or in:
If cm, the number must be at least 150 and at most 193.
If in, the number must be at least 59 and at most 76.
hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f.
ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth.
pid (Passport ID) - a nine-digit number, including leading zeroes.
cid (Country ID) - ignored, missing or not.
*/
int countValid = 0;
Map<String, String> mapping = new HashMap<>(words.size());
for (String word : words) {
String[] splits = word.split(":");
mapping.put(splits[0], splits[1]);
}
for (Map.Entry<String, String> entry : mapping.entrySet()) {
String value = entry.getValue();
switch (entry.getKey()) {
case "byr":
if (validateInt(value, 1920, 2002)) {
countValid++;
}
break;
case "iyr":
if (validateInt(value, 2010, 2020)) {
countValid++;
}
break;
case "eyr":
if (validateInt(value, 2020, 2030)) {
countValid++;
}
break;
case "hgt":
if (value.endsWith("cm")) {
if (validateInt(value.substring(0, 3), 150, 193)) {
countValid++;
}
} else if (value.endsWith("in")) {
if (validateInt(value.substring(0, 2), 59, 76)) {
countValid++;
}
}
break;
case "hcl":
if (regexMatch(value, "#[0-9a-f]{6}")) {
countValid++;
}
break;
case "ecl":
if (ImmutableList.of("amb", "blu", "brn", "gry", "grn", "hzl", "oth")
.contains(value)) {
countValid++;
}
break;
case "pid":
if (regexMatch(value, "[0-9]{9}")) {
countValid++;
}
break;
}
}
if (!(countValid >= 7)) {
// System.err.println(String.format("%s: %s", countValid, words));
}
return countValid >= 7;
}
private static boolean regexMatch(String value, String regex) {
Pattern pattern = Pattern.compile("^" + regex + "$");
Matcher matcher = pattern.matcher(value);
boolean result = matcher.find();
return result;
}
private static boolean validateInt(String value, int min, int max) {
try {
int val = Integer.parseInt(value);
return (val >= min) && (val <= max);
} catch (NumberFormatException ignored) {
}
return false;
}
private static boolean isSuccessful(Set<String> prefixes) {
Set<String> requiredPrefixes = new HashSet<>(ImmutableSet.of("byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"));
prefixes.retainAll(requiredPrefixes);
return prefixes.size() >= 7;
}
}
| [
"[email protected]"
] | |
1fd0e1af364f1836942d2c99c9ab923f7ff17fb0 | 17e8438486cb3e3073966ca2c14956d3ba9209ea | /dso/branches/sigar-maven/code/base/dso-spring/tests.unit/com/tctest/spring/bean/CounterSaverMixinAdvisor.java | bbdb9035c67bde82cc3d5a6151c30636510aba26 | [] | no_license | sirinath/Terracotta | fedfc2c4f0f06c990f94b8b6c3b9c93293334345 | 00a7662b9cf530dfdb43f2dd821fa559e998c892 | refs/heads/master | 2021-01-23T05:41:52.414211 | 2015-07-02T15:21:54 | 2015-07-02T15:21:54 | 38,613,711 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 438 | java | /*
* All content copyright (c) 2003-2008 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
*/
package com.tctest.spring.bean;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
public class CounterSaverMixinAdvisor extends DefaultIntroductionAdvisor {
public CounterSaverMixinAdvisor() {
super(new CounterSaverMixin(), CounterSaver.class);
}
}
| [
"jvoegele@7fc7bbf3-cf45-46d4-be06-341739edd864"
] | jvoegele@7fc7bbf3-cf45-46d4-be06-341739edd864 |
6be1e7c263a36e9e4d659f8cb4cce7cd86d26b09 | a3edd6d1d63b169222c109d799a34f93c6411f1d | /mybatisplus/src/main/java/com/chr/mybatisplus/netty/HttpServer.java | 9b2cabb1e8e8076ff5c6a2e837b51dc89c933884 | [] | no_license | RAY-chr/oauth2 | f90f1c8f708806f9b53f711fcebe1a8e807126fe | 78d9ab3231a83fabb8762033363fd6663166ca04 | refs/heads/master | 2021-07-09T04:32:20.376445 | 2020-08-14T03:02:40 | 2020-08-14T03:02:40 | 238,162,565 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,714 | java | package com.chr.mybatisplus.netty;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author RAY
* @descriptions Netty的Handler必须是多例的
* @since 2020/3/29
*/
@Component
public class HttpServer {
/*@Autowired
private HttpServerHandler serverHandler;*/
/** Autowired默认单例,多例使用需如下
* 1、在需要多例调用的类上加@Scope("prototype")
2、在进行注入时,不能直接使用@Autowired,否则注入的还是单例,需要使用工厂,最简单的是用
@Autowired
private ObjectFactory<T> objectFactory;
对象进行注入(T为你要注入的类),想要使用该多例对象时,用
T t = objectFactory.getObject();
*/
@Autowired
private ObjectFactory<HttpServerHandler> objectFactory;
private static final Logger logger = LoggerFactory.getLogger(HttpServer.class);
private static class Inner{
private static final HttpServer INSTANCE = new HttpServer();
}
public static HttpServer getInstance(){
return Inner.INSTANCE;
}
public void start()throws Exception{
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
ServerBootstrap bootstrap = new ServerBootstrap();
try {
bootstrap.group(bossGroup,workerGroup) //设置链接和工作线程组
.channel(NioServerSocketChannel.class) //设置服务端
.option(ChannelOption.SO_BACKLOG,128) //设置客户端连接队列的链接个数
.childOption(ChannelOption.SO_KEEPALIVE,true) //设置保持活动链接状态
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel sc) throws Exception {
ChannelPipeline pipeline = sc.pipeline();
// websocket 基于http协议,所以要有http编解码器
pipeline.addLast(new HttpServerCodec());
// 对写大数据流的支持
pipeline.addLast(new ChunkedWriteHandler());
// 对httpMessage进行聚合,聚合成FullHttpRequest或FullHttpResponse
// 几乎在netty中的编程,都会使用到此hanler
pipeline.addLast(new HttpObjectAggregator(1024*64));
/*
* websocket 服务器处理的协议,用于指定给客户端连接访问的路由 : /ws
* 本handler会帮你处理一些繁重的复杂的事
* 会帮你处理握手动作: handshaking(close, ping, pong) ping + pong = 心跳
* 对于websocket来讲,都是以frames进行传输的,不同的数据类型对应的frames也不同
*/
pipeline.addLast(new WebSocketServerProtocolHandler("/ws"));
System.out.println(objectFactory.getObject());
pipeline.addLast(objectFactory.getObject());
}
}); //给workerGroup的 EventLoop对应的管道设置处理器
logger.info("服务器 is ready");
//启动服务器绑定端口 用作http长连接的话,端口最好取80开头的,例如6667就不行
ChannelFuture fu = bootstrap.bind(8088).sync();
fu.addListener(future->{
if (future.isSuccess()){
logger.info("监听端口成功");
}else {
System.out.println("监听失败");
}
});
//监听通道
fu.channel().closeFuture().sync();
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}
}
| [
"[email protected]"
] | |
cb5c04af74e77971e5327be03439eeb9f3902d78 | ca5e1627ef3b81d79d50fbf41e821dbcc0b4e4aa | /src/main/java/com/example/producer/controller/TestController.java | 9fe56fdb84acefbb453777cebf55cc7ef3487588 | [] | no_license | ymgczh/producer | 2ba3ea09d381f0b278d5b8231ca36d4ded14b252 | 523bec3d2d2cd7e976138e51bbb65e2978037a3c | refs/heads/master | 2020-06-18T12:45:17.460626 | 2019-07-11T02:40:52 | 2019-07-11T02:40:52 | 196,307,303 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 643 | java | package com.example.producer.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* simple description
*
* @Description: java class description
* @Author: 张昊
* @CreateDate: 2019/7/11 8:34
* @Version: 1.0
* <p>Copyright: 内蒙古金财信息技术有限公司 (c) 2019</p>
*/
@RestController
public class TestController {
@RequestMapping("/helloPerson")
public String helloPerson(@RequestParam String name){
return "hello " + name + " welcome our home";
}
}
| [
"[email protected]"
] | |
fb9646d44e85adbed31787910b9a711d477c39a4 | 79cfe3a37d3edee488035d61b8f462d1a0b725ff | /Tourism/app/src/main/java/Adapter/hainanAdapter.java | 98adafa075d97eda89412a78d41cc3add9200287 | [] | no_license | Davidlover/mygraduationdesign | 80d2b2cac42b08699a26b92e1d7525e3745e7d32 | b03e972028f53a33d4cdd5d803f32daf64a8821f | refs/heads/master | 2020-06-15T06:47:04.305184 | 2019-07-04T11:52:31 | 2019-07-04T11:52:31 | 195,230,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,280 | java | package Adapter;
import android.support.annotation.NonNull;
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.TextView;
import com.example.lenovo.tourism.R;
import java.util.List;
//import java.util.List;
//
public class hainanAdapter extends RecyclerView.Adapter<hainanAdapter.ViewHolder> {
// private int resourceId;
private List<Hainan> mHainanList;
static class ViewHolder extends RecyclerView.ViewHolder{
ImageView hainanimage;
// TextView beijingname;
public ViewHolder(View view){
super(view);
hainanimage=(ImageView)view.findViewById(R.id.hainan_item_image);
// beijingname=(TextView)view.findViewById(R.id.beijing_item_name);
}
}
public hainanAdapter(List<Hainan>mHainanList1)
{
mHainanList=mHainanList1;
}
@NonNull
@Override
public hainanAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view=LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.hainan_item,viewGroup,false);
ViewHolder holder=new ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull hainanAdapter.ViewHolder viewHolder, int position) {
Hainan hainan=mHainanList.get(position);
viewHolder.hainanimage.setImageResource(hainan.getImageId());
//viewHolder.beijingname.setText(beijing.getName());
}
@Override
public int getItemCount() {
return mHainanList.size();
}
/**
* ListView的代码
*
* */
// @Override
// public View getView(int position, View convertView, ViewGroup parent)
// {
// //获取当前实例
// Beijing beijing=getItem(position);
// View view=LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
// ImageView BeijingImage=(ImageView)view.findViewById(R.id.beijing_item_image);
// TextView BeijingName=(TextView)view.findViewById(R.id.beijing_item_name);
// BeijingImage.setImageResource(beijing.getImageId());
// BeijingName.setText(beijing.getName());
// return view;
// }
}
| [
"[email protected]"
] | |
b6c2b9b3d9aa8605d295b6fedaf83f0f5abfa504 | abc616ce431a07fcd0bae01431793084372c17eb | /app/src/androidTest/java/com/myapplicationdev/android/demoradiobuttons/ExampleInstrumentedTest.java | d409b130c2ddef608bec75287857d1ea834e1e24 | [] | no_license | QaiWalker/DemoRadioButton | 7071fed1d9e9634c5f7feb83d67d62828ce5254e | 2a152d4acb605071d547b84110a46fc025d71836 | refs/heads/master | 2020-03-11T04:18:22.779938 | 2018-07-03T10:18:22 | 2018-07-03T10:18:22 | 129,773,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 774 | java | package com.myapplicationdev.android.demoradiobuttons;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.myapplicationdev.android.demoradiobuttons", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
eb2213f5455e690ca8e335907600d6f31d385ca0 | 407a5a94092e23be91303b15fa8be687bb657cdd | /app/src/main/java/com/example/e_softwarica/testing.java | 5583e75c2cc41a74eca5a8fc9e23845da7a73925 | [] | no_license | Gobinda3134/Test-master-master | 4236e8562b18fd4d606eb7ebebd6015b076f5cd9 | ca89a75213ca9687e1b4ce818b44d59372e35546 | refs/heads/master | 2021-01-04T08:33:38.905225 | 2020-02-24T15:50:44 | 2020-02-24T15:50:44 | 240,467,789 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 166 | java | package com.example.e_softwarica;
public class testing {
public String login(String Username, String Password)
{
return Username+Password;
}
}
| [
"[email protected]"
] | |
d7f4dcafb1353e4754ea9f57eb34ed1d95422b06 | a1826c2ed9c12cfc395fb1a14c1a2e1f097155cb | /eipanycast-20200309/src/main/java/com/aliyun/eipanycast20200309/models/AssociateAnycastEipAddressResponse.java | f252b50334301f5329c6e637012efee97183d19e | [
"Apache-2.0"
] | permissive | aliyun/alibabacloud-java-sdk | 83a6036a33c7278bca6f1bafccb0180940d58b0b | 008923f156adf2e4f4785a0419f60640273854ec | refs/heads/master | 2023-09-01T04:10:33.640756 | 2023-09-01T02:40:45 | 2023-09-01T02:40:45 | 288,968,318 | 40 | 45 | null | 2023-06-13T02:47:13 | 2020-08-20T09:51:08 | Java | UTF-8 | Java | false | false | 1,484 | java | // This file is auto-generated, don't edit it. Thanks.
package com.aliyun.eipanycast20200309.models;
import com.aliyun.tea.*;
public class AssociateAnycastEipAddressResponse extends TeaModel {
@NameInMap("headers")
@Validation(required = true)
public java.util.Map<String, String> headers;
@NameInMap("statusCode")
@Validation(required = true)
public Integer statusCode;
@NameInMap("body")
@Validation(required = true)
public AssociateAnycastEipAddressResponseBody body;
public static AssociateAnycastEipAddressResponse build(java.util.Map<String, ?> map) throws Exception {
AssociateAnycastEipAddressResponse self = new AssociateAnycastEipAddressResponse();
return TeaModel.build(map, self);
}
public AssociateAnycastEipAddressResponse setHeaders(java.util.Map<String, String> headers) {
this.headers = headers;
return this;
}
public java.util.Map<String, String> getHeaders() {
return this.headers;
}
public AssociateAnycastEipAddressResponse setStatusCode(Integer statusCode) {
this.statusCode = statusCode;
return this;
}
public Integer getStatusCode() {
return this.statusCode;
}
public AssociateAnycastEipAddressResponse setBody(AssociateAnycastEipAddressResponseBody body) {
this.body = body;
return this;
}
public AssociateAnycastEipAddressResponseBody getBody() {
return this.body;
}
}
| [
"[email protected]"
] | |
291f1179cfcfa241d36865bea367392b1d5ce963 | 8cef41ae7ed638b9a8fc87bb5080502ce8f48773 | /src/main/Laucher.java | 8d2006f4333f1f3f2c4f3118d2d8fbf6065d0c80 | [] | no_license | trancongman276/BoomBaseOnJava | 6e59d97fa23ab096bcb234ad54c33a4607f4df27 | aa9a584a237f39732cba47572bbfb5f4b3014d54 | refs/heads/master | 2020-11-28T16:06:19.006700 | 2020-01-01T09:05:47 | 2020-01-01T09:05:47 | 229,863,048 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 158 | java | package main;
public class Laucher {
static DrawGame game;
public static void main(String[] args) {
game = new DrawGame("Boom");
game.start();
}
}
| [
"[email protected]"
] | |
dc3540588cdb363f6ec94936a2626db4a5367347 | ff99b4349b799f45ac2bbbd23f4a31188b63b987 | /iMessenger/app/src/main/java/com/instigatemobile/imessenger/models/Conversation.java | 518a62c7f4c5d823b84d221f5e1304145816c0d4 | [] | no_license | AlbertAghajanyan/Projects | 880ad4f335b207e20e1840f98b344ad81da9da57 | 0ca46a92f967769c62469533dfe7d49d4cfb7243 | refs/heads/master | 2021-09-02T01:13:02.002293 | 2017-12-29T15:10:01 | 2017-12-29T15:10:01 | 115,730,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 328 | java | package com.instigatemobile.imessenger.models;
import java.util.ArrayList;
public class Conversation {
private ArrayList<Message> listMessageData;
public Conversation() {
listMessageData = new ArrayList<>();
}
public ArrayList<Message> getListMessageData() {
return listMessageData;
}
}
| [
"[email protected]"
] | |
7ba68a9e86903aa7f24e5d7e30916bafa0ca4519 | 4616356119413429abebbb0f2677370b3c561453 | /j3_extra_GeoRestservice_d/src/com/example/Southwest_.java | 7af7dbb8508b92e8c00c8a49813ff9c35b395d02 | [] | no_license | miquelpl/JAVA-WB | 0dc3965a42a4276d07511da85bc0fb6b8338b3a2 | 7a44484290feceab733c340014bc9f1fd5dcfe4c | refs/heads/master | 2021-04-30T02:09:50.826562 | 2018-04-05T14:24:08 | 2018-04-05T14:24:08 | 121,497,325 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 554 | java |
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Southwest_ {
@SerializedName("lat")
@Expose
private Double lat;
@SerializedName("lng")
@Expose
private Double lng;
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
public Double getLng() {
return lng;
}
public void setLng(Double lng) {
this.lng = lng;
}
}
| [
"[email protected]"
] | |
c2bc9462bd016cc7aabb22e038e36cad51a9fc2e | b6a1452e57b2f43a5a3ccb1a372baff0f13a3788 | /Singleton/Singleton.java | 5ffcbe6562f89140211292e7242acfa8b4bc9398 | [] | no_license | YifuQiu/SoftwreDesignPattern | 326d56392bb10b46f15bdf9c135cf2161e343ed1 | f7acb07cb05fdb9a278f9924f23a0304ea134919 | refs/heads/master | 2020-07-29T14:02:56.729775 | 2019-09-20T16:27:00 | 2019-09-20T16:27:00 | 209,833,676 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 239 | java | package Singleton;
public class Singleton {
private static Singleton instance;
private Singleton() {
}
public static Singleton getInstance() {
if(instance == null) {
instance = new Singleton();
}
return instance;
}
}
| [
"[email protected]"
] | |
e81953fcd7b35b2f17c8659e117e9bf1d832fc5a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_257c87a88ecdfa8def9079133a9ad8e801ddc3be/ObjectMapperTest/2_257c87a88ecdfa8def9079133a9ad8e801ddc3be_ObjectMapperTest_s.java | bcb6589606b9eae8c7bdc7184c1e522ded5dac0f | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 5,583 | java | package de.caluga.test.mongo.suite;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import de.caluga.morphium.Morphium;
import de.caluga.morphium.ObjectMapperImpl;
import org.bson.types.ObjectId;
import org.junit.Test;
import java.util.Date;
/**
* User: Stpehan Bösebeck
* Date: 26.03.12
* Time: 14:04
* <p/>
* TODO: Add documentation here
*/
public class ObjectMapperTest extends MongoTest {
@Test
public void testCreateCamelCase() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
assert (om.createCamelCase("this_is_a_test", false).equals("thisIsATest")) : "Error camil case translation not working";
assert (om.createCamelCase("a_test_this_is", true).equals("ATestThisIs")) : "Error - capitalized String wrong";
}
@Test
public void testConvertCamelCase() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
assert (om.convertCamelCase("thisIsATest").equals("this_is_a_test")) : "Conversion failed!";
}
@Test
public void testGetCollectionName() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
assert (om.getCollectionName(CachedObject.class).equals("cached_object")) : "Cached object test failed";
assert (om.getCollectionName(UncachedObject.class).equals("uncached_object")) : "Uncached object test failed";
}
@Test
public void testMarshall() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
UncachedObject o = new UncachedObject();
o.setCounter(12345);
o.setValue("This \" is $ test");
DBObject dbo = om.marshall(o);
System.out.println("Marshalling was: " + dbo.toString());
assert (dbo.toString().equals("{ \"value\" : \"This \\\" is $ test\" , \"counter\" : 12345 , \"_id\" : null }")) : "String creation failed?" + dbo.toString();
}
@Test
public void testUnmarshall() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
BasicDBObject dbo = new BasicDBObject();
dbo.put("counter", 12345);
dbo.put("value", "A test");
om.unmarshall(UncachedObject.class, dbo);
}
@Test
public void testGetId() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
UncachedObject o = new UncachedObject();
o.setCounter(12345);
o.setValue("This \" is $ test");
o.setMongoId(new ObjectId(new Date()));
ObjectId id = om.getId(o);
assert (id.equals(o.getMongoId())) : "IDs not equal!";
}
@Test
public void testIsEntity() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
assert (om.isEntity(UncachedObject.class)) : "Uncached Object no Entity?=!?=!?";
assert (om.isEntity(new UncachedObject())) : "Uncached Object no Entity?=!?=!?";
assert (!om.isEntity("")) : "String is an Entity?";
}
@Test
public void testGetValue() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
UncachedObject o = new UncachedObject();
o.setCounter(12345);
o.setValue("This \" is $ test");
assert (om.getValue(o, "counter").equals(12345)) : "Value not ok!";
}
@Test
public void testSetValue() throws Exception {
ObjectMapperImpl om = new ObjectMapperImpl();
UncachedObject o = new UncachedObject();
o.setCounter(12345);
om.setValue(o, "A test", "value");
assert ("A test".equals(o.getValue())) : "Value not set";
}
@Test
public void complexObjectTest() {
ObjectMapperImpl om = new ObjectMapperImpl();
UncachedObject o = new UncachedObject();
o.setCounter(12345);
o.setValue("Embedded value");
Morphium.get().store(o);
ComplexObject co = new ComplexObject();
co.setEinText("Ein text");
co.setEmbed(o);
ObjectId embedId = o.getMongoId();
o = new UncachedObject();
o.setCounter(12345);
o.setValue("Referenced value");
// o.setMongoId(new ObjectId(new Date()));
Morphium.get().store(o);
co.setRef(o);
co.setId(new ObjectId(new Date()));
String st = co.toString();
System.out.println("Referenced object: " + om.marshall(o).toString());
DBObject marshall = om.marshall(co);
System.out.println("Complex object: " + marshall.toString());
//Unmarshalling stuff
co = om.unmarshall(ComplexObject.class, marshall);
co.getEmbed().setMongoId(embedId); //need to set ID manually, as it won't be stored!
String st2 = co.toString();
assert (st.equals(st2)) : "Strings not equal?\n" + st + "\n" + st2;
}
@Test
public void nullValueTests() {
ObjectMapperImpl om = new ObjectMapperImpl();
ComplexObject o=new ComplexObject();
o.setTrans("TRANSIENT");
DBObject obj=null;
try {
obj= om.marshall(o);
} catch(IllegalArgumentException e) {
//good, ein_text is null - should trigger this exception!
}
assert(obj==null):"NotNull constraint not enforced! "+obj.toString();
o.setEinText("Ein Text");
obj=om.marshall(o);
assert(!obj.containsField("trans")):"Transient field used?!?!?";
assert(obj.containsField("null_value")):"Null value not set";
}
}
| [
"[email protected]"
] | |
1a6af4607bb9c6b26d7bd9a2c408c65575eab81b | 9324f7177a6c139af8dc691b98f5aced07cdcc29 | /app/src/main/java/com/example/vitalle/Sprite.java | 57b5c9ed0c3315e0f2673bb89ebc2b3adce42d60 | [] | no_license | matthewlsimms94/Vitalle | 1e1bcb44539bc722bbf3a116e362257bd31c4275 | e56fc6a9d07a100a291d758eb7ac66064f3d59d9 | refs/heads/master | 2021-01-18T17:46:44.595498 | 2016-09-25T17:02:19 | 2016-09-25T17:02:19 | 69,120,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,230 | java | package com.example.vitalle;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.widget.ImageView;
import android.graphics.Rect;
/**
* Created by samsung on 9/24/2016.
*/
public class Sprite {
private int iCurrentFrame;
private int iNumberOfFrames;
private int iFrameLength;
private int iFrameCounter;
private int iFrameWidth;
private int iFrameHeight;
private int x, y;
private float scaleX,scaleY;
private Bitmap bSource;
private Bitmap bFrame;
//private Context parentContext;
public Sprite(int resourceId, Context parentContext, int numberOfFrames, int frameLength, float scaleX, float scaleY) {
bSource = BitmapFactory.decodeResource(parentContext.getResources(), resourceId);
iCurrentFrame = 0;
iNumberOfFrames = numberOfFrames;
iFrameLength = frameLength;
iFrameCounter = 0;
x = 50;
y = 50;
this.scaleX = scaleX;
this.scaleY = scaleY;
iFrameWidth = bSource.getWidth()/iNumberOfFrames;
iFrameHeight = bSource.getHeight();
bFrame = Bitmap.createBitmap(iFrameWidth, iFrameHeight, Bitmap.Config.RGB_565);
//cTarget = new Canvas(bSource);
}
void update(int x, int y){
this.x = x;
this.y = y;
iFrameCounter++;
if (iFrameCounter >= iFrameLength)
{
iFrameCounter = 0;
iCurrentFrame++;
if (iCurrentFrame >= iNumberOfFrames)
iCurrentFrame = 0;
bFrame = Bitmap.createBitmap(bSource,iCurrentFrame*iFrameWidth,0,iFrameWidth,iFrameHeight);
}
}
void draw(Canvas canvas){
Rect src = new Rect(0,0,iFrameWidth-1, iFrameHeight-1);
Rect dest = new Rect((int)(x*scaleX),(int)(y*scaleY),(int)((x+iFrameWidth-1)*scaleX), (int)((y+iFrameHeight-1)*scaleY));
canvas.drawBitmap(bFrame, src, dest, null);
//canvas.drawBitmap(bFrame,x,y,null);
//imTarget.setImageDrawable(new BitmapDrawable(parentContext.getResources(), bFrame));
}
}
| [
"[email protected]"
] | |
c14533517af09289b27549ea4c105f756b4c5cb1 | a23b0c79672b59b7fee2f0730269318d8959ee18 | /src/main/java/org/elasticsearch/rest/action/cat/RestFielddataAction.java | b4d5e9833cb69b80127f4bbdadfe6d87e6aaf4e8 | [
"Apache-2.0"
] | permissive | lemonJun/ESHunt | 1d417fc3605be8c5b384c66a5b623dea6ba77a6a | d66ed11d64234e783f67699e643daa77c9d077e3 | refs/heads/master | 2021-01-19T08:30:47.171304 | 2017-04-09T06:08:58 | 2017-04-09T06:08:58 | 87,639,997 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,636 | java | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.elasticsearch.rest.action.cat;
import com.carrotsearch.hppc.ObjectLongMap;
import com.carrotsearch.hppc.ObjectLongOpenHashMap;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.Table;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.action.support.RestResponseListener;
import org.elasticsearch.rest.action.support.RestTable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static org.elasticsearch.rest.RestRequest.Method.GET;
/**
* Cat API class to display information about the size of fielddata fields per node
*/
public class RestFielddataAction extends AbstractCatAction {
@Inject
public RestFielddataAction(Settings settings, RestController controller, Client client) {
super(settings, controller, client);
controller.registerHandler(GET, "/_cat/fielddata", this);
controller.registerHandler(GET, "/_cat/fielddata/{fields}", this);
}
@Override
void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
nodesStatsRequest.clear();
nodesStatsRequest.indices(true);
String[] fields = request.paramAsStringArray("fields", null);
nodesStatsRequest.indices().fieldDataFields(fields == null ? new String[] { "*" } : fields);
client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
@Override
public RestResponse buildResponse(NodesStatsResponse nodeStatses) throws Exception {
return RestTable.buildResponse(buildTable(request, nodeStatses), channel);
}
});
}
@Override
void documentation(StringBuilder sb) {
sb.append("/_cat/fielddata\n");
sb.append("/_cat/fielddata/{fields}\n");
}
@Override
Table getTableWithHeader(RestRequest request) {
Table table = new Table();
table.startHeaders().addCell("id", "desc:node id").addCell("host", "alias:h;desc:host name").addCell("ip", "desc:ip address").addCell("node", "alias:n;desc:node name").addCell("total", "text-align:right;desc:total field data usage").endHeaders();
return table;
}
private Table buildTable(final RestRequest request, final NodesStatsResponse nodeStatses) {
Set<String> fieldNames = new HashSet<>();
Map<NodeStats, ObjectLongMap<String>> nodesFields = new HashMap<>();
// Collect all the field names so a new table can be built
for (NodeStats ns : nodeStatses.getNodes()) {
ObjectLongOpenHashMap<String> fields = ns.getIndices().getFieldData().getFields();
nodesFields.put(ns, fields);
if (fields != null) {
for (String key : fields.keys().toArray(String.class)) {
fieldNames.add(key);
}
}
}
// The table must be rebuilt because it has dynamic headers based on the fields
Table table = new Table();
table.startHeaders().addCell("id", "desc:node id").addCell("host", "alias:h;desc:host name").addCell("ip", "desc:ip address").addCell("node", "alias:n;desc:node name").addCell("total", "text-align:right;desc:total field data usage");
// The table columns must be built dynamically since the number of fields is unknown
for (String fieldName : fieldNames) {
table.addCell(fieldName, "text-align:right;desc:" + fieldName + " field");
}
table.endHeaders();
for (Map.Entry<NodeStats, ObjectLongMap<String>> statsEntry : nodesFields.entrySet()) {
table.startRow();
// add the node info and field data total before each individual field
NodeStats ns = statsEntry.getKey();
table.addCell(ns.getNode().id());
table.addCell(ns.getNode().getHostName());
table.addCell(ns.getNode().getHostAddress());
table.addCell(ns.getNode().getName());
table.addCell(ns.getIndices().getFieldData().getMemorySize());
ObjectLongMap<String> fields = statsEntry.getValue();
for (String fieldName : fieldNames) {
table.addCell(new ByteSizeValue(fields == null ? 0L : fields.getOrDefault(fieldName, 0L)));
}
table.endRow();
}
return table;
}
}
| [
"[email protected]"
] | |
5f4c29a4a04303d5a001e6510787fb078722ff68 | cd0466177f20a893cb2ef00e7e1d6682c2b9091a | /app/src/main/java/com/chen/fy/patshow/util/RUtil.java | 2b01014cf934aed09d61b359a15f45cc4f0b70eb | [] | no_license | StephenChenOk/PatShow | 497583321280a23fcca3e6a1af7623ff2d1f4277 | 77bef76e9c358bb0d1b964e5e8d28d0b0853392e | refs/heads/master | 2023-04-13T22:22:38.545291 | 2021-04-23T05:53:37 | 2021-04-23T05:53:37 | 345,638,581 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 619 | java | package com.chen.fy.patshow.util;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.chen.fy.patshow.MyApplication;
public class RUtil {
public static String toString(int key){
return MyApplication.getContext().getResources().getString(key);
}
public static int toInt(int key){
return MyApplication.getContext().getResources().getInteger(key);
}
/// R -> Bitmap
public static Bitmap RToBitmap(Resources resources, int resource){
return BitmapFactory.decodeResource(resources, resource);
}
}
| [
"[email protected]"
] | |
dab3a06022121ed3248bdbdfbd6d80cc4d022fb5 | 729db4b8070ca7d5d41d20a19a645fe5d2e1db32 | /app/src/test/java/cn/edu/swl/s07150741/mycamera/ExampleUnitTest.java | 907ce91dbb9d3a0e9eebb773859352ea4512cb26 | [] | no_license | gdmec07150741/MyCamera | 2358c8ab5e11bb7ab7cb9c9ea0bea9e88119c61a | 613da2fbcd32b13c66c0b797e28072ccf12d6976 | refs/heads/master | 2020-06-09T12:21:04.053081 | 2016-12-09T13:52:52 | 2016-12-09T13:52:52 | 76,039,502 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package cn.edu.swl.s07150741.mycamera;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
5e384b0cab02d8a394efd9d6bbac22e25f3d83ff | 38335bb81ec864b820f171dff86e48ea7fcf94de | /src/data_structures/grafo/ArcoYaExisteException.java | 97723c620ec349c3611632c061c2df9bf8cd012d | [] | no_license | Juan2707/Proyecto_3_201910_SEC_02_TEAM_3 | 4ef64962ad571c803afb7229864c9e7566826544 | 99168b347ab5fdf8886eff2209bdd1dd5784378d | refs/heads/master | 2020-05-25T10:09:23.224241 | 2019-05-21T03:16:40 | 2019-05-21T03:16:40 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,552 | java | /**
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id: ArcoYaExisteException.java,v 1.3 2008/10/11 22:02:54 alf-mora Exp $
* Universidad de los Andes (Bogotá - Colombia)
* Departamento de Ingeniería de Sistemas y Computación
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2 (http://cupi2.uniandes.edu.co)
* Framework: Cupi2Collections
* Autor: Pablo Barvo - Mar 29, 2006
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package data_structures.grafo;
/**
* Excepción lanzada cuando el arco especificado ya existe
*/
public class ArcoYaExisteException extends Exception
{
// -----------------------------------------------------------------
// Constantes
// -----------------------------------------------------------------
/**
* Constante para la serialización
*/
private static final long serialVersionUID = 1L;
// -----------------------------------------------------------------
// Atributos
// -----------------------------------------------------------------
/**
* Identificador del vértice desde donde debería salir el arco
*/
private Object origen;
/**
* Identificador del vértice hasta donde debería llegar el arco
*/
private Object destino;
// -----------------------------------------------------------------
// Constructores
// -----------------------------------------------------------------
/**
* Constructor de la excepción
* @param mensaje Mensaje de error
* @param idDesde Identificador del vértice desde donde sale el arco
* @param idHasta Identificador del vértice hasta donde llega el arco
*/
public ArcoYaExisteException( String mensaje, Object idDesde, Object idHasta )
{
super( mensaje );
origen = idDesde;
destino = idHasta;
}
// -----------------------------------------------------------------
// Métodos
// -----------------------------------------------------------------
/**
* Devuelve el identificador del vértice desde donde debe salir el arco
* @return identificador del vértice desde donde debe salir el arco
*/
public Object darOrigen( )
{
return origen;
}
/**
* Devuelve el identificador del vértice hasta donde debe llegar el arco
* @return identificador del vértice hasta donde debe llegar el arco
*/
public Object darDestino( )
{
return destino;
}
}
| [
"[email protected]"
] | |
769f76784da0d0ece10255af9d51519c3d86c57e | 96a31b041b617d2fc62fcfc694481401ab1c0bed | /lets-spring-data-jpa-pagination/src/main/java/io/github/wdpm/domain/Person.java | 5b89ec68db7f5aa62b1dc06263ae81eb9be89723 | [
"MIT"
] | permissive | wdpm/lets-spring | 5534911a296df2fb75f2c99da6c42ce66a18b705 | 073f02fbbba745334b445fe256e955c6be4e20d3 | refs/heads/master | 2023-01-23T12:06:42.363835 | 2020-05-25T07:19:05 | 2020-05-25T07:19:05 | 266,372,658 | 0 | 0 | MIT | 2020-12-13T07:25:50 | 2020-05-23T16:11:12 | Java | UTF-8 | Java | false | false | 1,790 | java | package io.github.wdpm.domain;
import javax.persistence.*;
import java.util.Objects;
@Entity
@NamedQuery(name = "Person.findByFirstNameNamed",
query = "SELECT p FROM Person p WHERE p.firstName = ?1")
@NamedNativeQuery(name = "Person.findByLastNameNativeNamed",
query = "SELECT * FROM Person p WHERE p.lastName = :lastName")
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
private int age;
public Person() {
}
public Person(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
return id.equals(person.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Person{" + "id=" + id + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' +
", age=" + age + '}';
}
}
| [
"[email protected]"
] | |
7cc0c7d52289beb15d7b1bdff76b1d159c39e493 | c7571421f7808c1426185578b764860dc93396f0 | /src/main/java/yte/etkinlikyonetim/BasvuruPK.java | 213b9d469676c944c952aae601e1f04c612f2675 | [] | no_license | rabiaonal/YTE-etkinlik-yonetim | 9439f1d9987027d80d5eab076c5bc2916fd18b87 | cc733c2f30fbd539a3317f5a76f92e7a3a36eedf | refs/heads/master | 2022-12-25T06:54:23.133186 | 2020-10-02T14:10:15 | 2020-10-02T14:10:15 | 300,630,364 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 408 | java | package yte.etkinlikyonetim;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
@Embeddable
@AllArgsConstructor
@ToString
@Getter
@Setter
@NoArgsConstructor
public class BasvuruPK implements Serializable {
@Column(name = "ETKINLIK_ID")
private Long etkinlik_id;
@Column(name = "KATILIMCI_ID")
private Long katilimci_id;
}
| [
"[email protected]"
] | |
30bb5f5f466c875e4f6993ae5af479f2cb26ddac | 866cb725f9490fd11cdd44e6ecec1366980b0402 | /src/java/modelo/Comparendo_Curso.java | 35930c6176fa8cfb3335c6784c2c7754758fe847 | [] | no_license | rcamacholci/Transito | 40abe81d107f1596c2748269b1bf9ace7ab51027 | e12813a4072dbdcaa61892e874f442bed291f65d | refs/heads/master | 2020-03-13T14:34:25.747242 | 2018-04-26T18:16:29 | 2018-04-26T18:16:29 | 131,161,178 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,587 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @author Administrador
*/
public class Comparendo_Curso {
private long id_comparendo_curso;
private long fk_persona;
private long fk_comparendo;
private int certificado;
private Date fecha;
private int lugar;
private float valor;
private int estado;
private int descuento;
public int getCertificado() {
return certificado;
}
public void setCertificado(int certificado) {
this.certificado = certificado;
}
public int getEstado() {
return estado;
}
public void setEstado(int estado) {
this.estado = estado;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public long getFk_comparendo() {
return fk_comparendo;
}
public void setFk_comparendo(long fk_comparendo) {
this.fk_comparendo = fk_comparendo;
}
public long getFk_persona() {
return fk_persona;
}
public void setFk_persona(long fk_persona) {
this.fk_persona = fk_persona;
}
public long getId_comparendo_curso() {
return id_comparendo_curso;
}
public void setId_comparendo_curso(long id_comparendo_curso) {
this.id_comparendo_curso = id_comparendo_curso;
}
public int getLugar() {
return lugar;
}
public void setLugar(int lugar) {
this.lugar = lugar;
}
public float getValor() {
return valor;
}
public void setValor(float valor) {
this.valor = valor;
}
public int getDescuento() {
return descuento;
}
public void setDescuento(int descuento) {
this.descuento = descuento;
}
public static Comparendo_Curso load(ResultSet rs) throws SQLException{
Comparendo_Curso comparendoCurso = new Comparendo_Curso();
comparendoCurso.setId_comparendo_curso(rs.getLong(1));
comparendoCurso.setFk_persona(rs.getLong(2));
comparendoCurso.setFk_comparendo(rs.getLong(3));
comparendoCurso.setCertificado(rs.getInt(4));
comparendoCurso.setFecha(rs.getDate(5));
comparendoCurso.setLugar(rs.getInt(6));
comparendoCurso.setValor(rs.getFloat(7));
comparendoCurso.setEstado(rs.getInt(8));
comparendoCurso.setDescuento(rs.getInt(9));
return comparendoCurso;
}
}
| [
"[email protected]"
] | |
160d560fc8bca4a783180e2d57ad11e215de8e3c | 4f752c6fb477e7f90f024b5a0f9d96854a70cd1f | /ms225hk_assign1/Ex08/FunctionPointers.java | dcff765aedda5b858ec0f23d29020f98f4a787b2 | [] | no_license | mohammedsabbagh/1DV507 | d5b129f98289109c52b7a6dc4a999005509976a7 | 2fa58e4c775d58d838782eaa44c15e6c625dd7df | refs/heads/master | 2020-04-25T12:13:04.534620 | 2019-03-03T16:24:23 | 2019-03-03T16:24:23 | 172,770,730 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,155 | java |
package ms225hk_assign1.Ex08;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import java.lang.Math;
public class FunctionPointers {
public static void main(String[] args) {
System.out.println("Part 1: Apply predicates");
List<Integer> list = Arrays.asList(45, 3, 24, 16, 1, 1, 3, 8, 7, 6, 10, 12, 17, 22, 30);
System.out.print("Print all numbers: ");
Predicate<Integer> all = n -> true;
selectAndPrint(list, all);
System.out.print("\nPrint all odd numbers: ");
Predicate<Integer> odd = n -> n % 2 == 1; // Must be updated
selectAndPrint(list, odd);
System.out.print("\nPrint all numbers greater than 10: ");
Predicate<Integer> aboveTen = n -> n > 10; // Must be updated
selectAndPrint(list, aboveTen);
System.out.println("\n\nPart 2: Apply functions");
List<Double> numbers = Arrays.asList(1.0, 16.0, 25.0, 81.0);
System.out.println("Original: " + numbers);
System.out.println("Square root: " + applyFunction(numbers, Math::sqrt));
System.out.println("Power of two: " + applyFunction(numbers, FunctionPointers::powerOfTwo));
}
// Prints all elements in the list where predicate evaluates to true
public static void selectAndPrint(List<Integer> list, Predicate<Integer> predicate) {
int number = 0;
for (int i = 0; i < list.size(); i++) {
number = list.get(i);
if (predicate.test(number))
System.out.print(number + " ");
}
}
// Returns a new list containing the numbers resulting from applying fx
// on the input list numbers
private static List<Double> applyFunction(List<Double> numbers, Function<Double, Double> fx) {
List<Double> newList = new ArrayList<Double>();
for (double d : numbers)
newList.add(fx.apply(d));
return newList;
}
private static Double powerOfTwo(Double d) {
return Math.pow(d, 2); // Must be updated (or in another way d*d)
}
}
| [
"[email protected]"
] | |
446a5e0424d2f356d4bfa7bd7278ab03046f38d7 | a36241da3efd087345ac422f2ab58274952f2b47 | /app/src/main/java/com/example/day10jigunag/BaseApp.java | 531cd420a8ffaa354405ed019f3bca6849c6ca9a | [] | no_license | 546547tete/Day10jigunag | d33ada1d445441b9753efa14a42c63487ee06f23 | 4d0544e3455cf7d6d97f4e2c2172a7efa4b86771 | refs/heads/master | 2022-11-20T02:15:50.309088 | 2020-07-21T08:03:40 | 2020-07-21T08:03:40 | 281,334,902 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 687 | java | package com.example.day10jigunag;
import android.app.Application;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.helper.Logger;
/**
* For developer startup JPush SDK
*
* 一般建议在自定义 Application 类里初始化。也可以在主 Activity 里。
*/
public class BaseApp extends Application {
private static final String TAG = "JIGUANG-Example";
@Override
public void onCreate() {
// Logger.d(TAG, "[ExampleApplication] onCreate");
super.onCreate();
JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
JPushInterface.init(this); // 初始化 JPush
}
}
| [
"[email protected]"
] | |
94a11b006976d38fb882f1d9319a6ff0aed1e26e | 56f6eb70e65281101b864580055c11677d0118c6 | /3D v4/src/Polygon3D.java | 6b9f68ad157255156a538e7cb3f84dfeb3b96d8b | [] | no_license | samcparker/Less-Bad-3D-Project | bf9b1773bf4ce3b9e4dde3697982679bea5247d4 | 5eeb6b0908faddeff06801e9daebc2b1995024f6 | refs/heads/master | 2023-04-12T19:12:58.368994 | 2021-05-02T19:00:36 | 2021-05-02T19:00:36 | 158,752,751 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,109 | java | import java.awt.*;
import java.util.ArrayList;
public class Polygon3D {
Polygon polygon;
double distance;
double depth;
ArrayList<Vertex> vertices;
public Polygon3D() {
polygon = new Polygon();
vertices = new ArrayList<>();
}
public void draw(Graphics2D g2d) {
g2d.fill(polygon);
}
public void update() {
this.polygon = createPolygon2D();
this.depth = getDepth();
this.distance = getDistance();
// TODO : Calculate the distance from Camera to the central point of this polygon using calculateDistance()
// TODO : Calculate the depth of this polygon from Camera using calculateDepth()
// TODO : Calculate screen position of polygon
}
public Polygon createPolygon2D() {
polygon = new Polygon();
for (Vertex vertex : vertices) {
int[] screenLocation = vertex.getScreenLocation(Main.canvas.getCamera());
polygon.addPoint(screenLocation[0], screenLocation[1]);
}
return polygon;
}
public void fillPolygon(Graphics2D g2d) {
if (getDepth() > 0) {
g2d.fill(polygon);
}
}
public void drawPolygon(Graphics2D g2d) {
if (getDepth() >= 0) {
g2d.draw(polygon);
}
}
public void addVertex(Vertex vertex) {
vertices.add(vertex);
}
public double getDepth() {
return getMiddleVertex().calculateDepth(Main.canvas.camera);
}
public double getDistance() {
return getMiddleVertex().calculateDistance(Main.canvas.getCamera().getLocation());
}
private Vertex getMiddleVertex() {
double x = 0;
double y = 0;
double z = 0;
for (Vertex vertex : vertices) {
x += vertex.getX();
y += vertex.getY();
z += vertex.getZ();
}
x /= vertices.size();
y /= vertices.size();
z /= vertices.size();
return new Vertex(x, y, z);
}
}
| [
"[email protected]"
] | |
500788a8cbd0eacf1789f87cbd1ff40c73e13d5f | 1b7598667fe72dc6a4057ca42dbd1ae9f1f4d63c | /src/main/java/com/lanyu/jenkins/hellojenkins/common/vo/RedisInfo.java | c62c3fed6da8a0a4f84bc48a1c82cc286d9db6d0 | [] | no_license | lanyu1/helloJenkins | a9e0aef5c8065c29f5d9818c3e142c7179a9703a | 20f28ea7d2ee736dc6cdabeba5476772e2f33af4 | refs/heads/master | 2023-07-15T15:05:51.782922 | 2021-09-01T01:49:52 | 2021-09-01T01:49:52 | 370,936,255 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,331 | java | package com.lanyu.jenkins.hellojenkins.common.vo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* @author lanyu
* @date 2021年08月11日 10:59
*/
@Data
public class RedisInfo {
private static Map<String, String> map = new HashMap<>();
static {
map.put("redis_version", "Redis 服务器版本");
map.put("os", "Redis 服务器的宿主操作系统");
map.put("arch_bits", " 架构(32 或 64 位)");
map.put("multiplexing_api", "Redis 所使用的事件处理机制");
map.put("gcc_version", "编译 Redis 时所使用的 GCC 版本");
map.put("process_id", "服务器进程的 PID");
map.put("run_id", "Redis 服务器的随机标识符(用于 Sentinel 和集群)");
map.put("tcp_port", "TCP/IP 监听端口");
map.put("uptime_in_seconds", "自 Redis 服务器启动以来,经过的秒数");
map.put("uptime_in_days", "自 Redis 服务器启动以来,经过的天数");
map.put("lru_clock", " 以分钟为单位进行自增的时钟,用于 LRU 管理");
map.put("connected_clients", "已连接客户端的数量(不包括通过从属服务器连接的客户端)");
map.put("client_longest_output_list", "当前连接的客户端当中,最长的输出列表");
map.put("client_longest_input_buf", "当前连接的客户端当中,最大输入缓存");
map.put("blocked_clients", "正在等待阻塞命令(BLPOP、BRPOP、BRPOPLPUSH)的客户端的数量");
map.put("used_memory", "由 Redis 分配器分配的内存总量,以字节(byte)为单位");
map.put("used_memory_human", "以人类可读的格式返回 Redis 分配的内存总量");
map.put("used_memory_rss", "从操作系统的角度,返回 Redis 已分配的内存总量(俗称常驻集大小)。这个值和 top 、 ps 等命令的输出一致");
map.put("used_memory_peak", " Redis 的内存消耗峰值(以字节为单位)");
map.put("used_memory_peak_human", "以人类可读的格式返回 Redis 的内存消耗峰值");
map.put("used_memory_lua", "Lua 引擎所使用的内存大小(以字节为单位)");
map.put("redis_mode", "运行模式,单机(standalone)或者集群(cluster)");
map.put("executable", "server脚本目录");
map.put("config_file", "配置文件目录");
map.put("used_memory_rss_human", "以人类可读的方式返回 Redis 已分配的内存总量");
map.put("used_memory_peak_perc", "内存使用率峰值");
map.put("total_system_memory", "系统总内存");
map.put("total_system_memory_human", "以人类可读的方式返回系统总内存");
map.put("used_memory_lua_human", "以人类可读的方式返回Lua 引擎所使用的内存大小");
map.put("maxmemory", "最大内存限制,0表示无限制");
map.put("maxmemory_human", "以人类可读的方式返回最大限制内存");
map.put("maxmemory_policy", "超过内存限制后的处理策略");
map.put("loading", "服务器是否正在载入持久化文件");
map.put("rdb_changes_since_last_save", "离最近一次成功生成rdb文件,写入命令的个数,即有多少个写入命令没有持久化");
map.put("rdb_bgsave_in_progress", "服务器是否正在创建rdb文件");
map.put("rdb_last_bgsave_status", "最近一次rdb持久化是否成功");
map.put("rdb_last_bgsave_time_sec", "最近一次成功生成rdb文件耗时秒数");
map.put("rdb_current_bgsave_time_sec", "如果服务器正在创建rdb文件,那么这个域记录的就是当前的创建操作已经耗费的秒数");
map.put("aof_enabled", "是否开启了aof");
map.put("aof_rewrite_in_progress", "标识aof的rewrite操作是否在进行中");
map.put("aof_last_rewrite_time_sec", "最近一次aof rewrite耗费的时长");
map.put("aof_current_rewrite_time_sec", "如果rewrite操作正在进行,则记录所使用的时间,单位秒");
map.put("aof_last_bgrewrite_status", "上次bgrewrite aof操作的状态");
map.put("aof_last_write_status", "上次aof写入状态");
map.put("total_commands_processed", "redis处理的命令数");
map.put("instantaneous_ops_per_sec", "redis当前的qps,redis内部较实时的每秒执行的命令数");
map.put("total_net_input_bytes", "redis网络入口流量字节数");
map.put("total_net_output_bytes", "redis网络出口流量字节数");
map.put("instantaneous_input_kbps", "redis网络入口kps");
map.put("instantaneous_output_kbps", "redis网络出口kps");
map.put("rejected_connections", "拒绝的连接个数,redis连接个数达到maxclients限制,拒绝新连接的个数");
map.put("expired_keys", "运行以来过期的key的数量");
map.put("evicted_keys", "运行以来剔除(超过了maxmemory后)的key的数量");
map.put("keyspace_hits", "命中次数");
map.put("keyspace_misses", "没命中次数");
}
private String key;
private String value;
private String description;
public String getDescription() {
return map.get(this.key);
}
}
| [
"[email protected]"
] | |
4e0dd38226bfa0037998aacaec909f1ed4efedba | a2faf74eb89a0cfbd713d4e2f94048967b0ab284 | /src/main/java/com/mitix/yiming/service/impl/DesignsServiceImpl.java | 5ada1507ff6abd019a566220b3ddcce0e1d124ff | [] | no_license | manzusaka/yiming | b9c172fd5289d2fe72e42e738ab90f076e762911 | e8a2d54fb55f2114b2ef05095d2415646b165045 | refs/heads/master | 2021-09-10T13:37:20.160037 | 2018-03-27T03:26:58 | 2018-03-27T03:26:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,369 | java | package com.mitix.yiming.service.impl;
import com.mitix.yiming.FileUtil;
import com.mitix.yiming.SIDUtil;
import com.mitix.yiming.bean.DesFiles;
import com.mitix.yiming.bean.Designs;
import com.mitix.yiming.mapper.YiMingMapper;
import com.mitix.yiming.service.DesignsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by oldflame on 2017/6/16.
*/
@Service
public class DesignsServiceImpl implements DesignsService {
@Autowired
private YiMingMapper yiMingMapper;
@Autowired
private FilePathComponent filePathComponent;
private static Map<String, String> dTypeMap = new HashMap<>();
private static Map<String, String> dlTypeMap = new HashMap<>();
{
dTypeMap.put("设计效果图", "1");
dTypeMap.put("空间效果图", "2");
dTypeMap.put("软装搭配设计", "3");
dTypeMap.put("客户回访照", "4");
dlTypeMap.put("1", "设计效果图");
dlTypeMap.put("2", "空间效果图");
dlTypeMap.put("3", "软装搭配设计");
dlTypeMap.put("4", "客户回访照");
}
@Override
@Transactional
public void saveDesigns(String liningcode, String designname, List<DesFiles> sjlist/*, List<DesFiles> xglist*/) {
String liningcodeTouse = liningcode.trim();
String designnameTouse = designname.trim();
int count = yiMingMapper.selectLiningsExists(liningcodeTouse);
if (count == 0) {
throw new RuntimeException("请正确填写布料信息");
}
Map<String, Object> map = new HashMap<>();
map.put("liningcode", liningcodeTouse);
map.put("designname", designnameTouse);
int count1 = yiMingMapper.selectDisignsExists(map);
if (count1 > 0) {
throw new RuntimeException("同一个面料下存在同款的设计");
}
String designcode = SIDUtil.getUUID16();
Designs designs = new Designs();
designs.setLiningcode(liningcodeTouse);
designs.setDesigncode(designcode);
designs.setDesignname(designnameTouse);
yiMingMapper.insertDesigns(designs);
if (sjlist != null && sjlist.size() > 0) {
for (DesFiles desFiles : sjlist) {
File sourceFile = new File(filePathComponent.getTempFolder(), desFiles.getUrlfix());
File destFile = new File(filePathComponent.getLogosFolder());
try {
FileUtil.move(sourceFile, destFile, true);
} catch (Exception e) {
throw new RuntimeException();
}
desFiles.setDesigncode(designcode);
desFiles.setType(dTypeMap.get(desFiles.getType()));
yiMingMapper.insertFiles(desFiles);
}
}
// if (xglist != null && xglist.size() > 0) {
// for (DesFiles desFiles : xglist) {
// File sourceFile = new File(filePathComponent.getTempFolder(), desFiles.getUrlfix());
// File destFile = new File(filePathComponent.getLogosFolder());
// try {
// FileUtil.move(sourceFile, destFile, true);
// } catch (Exception e) {
// throw new RuntimeException();
// }
// desFiles.setDesigncode(designcode);
// desFiles.setType("2");
// yiMingMapper.insertFiles(desFiles);
// }
// }
}
@Transactional
@Override
public void updateDesigns(Integer id, String liningcode, String designname, List<DesFiles> sjlistList) {
String liningcodeTouse = liningcode.trim();
String designnameTouse = designname.trim();
int count = yiMingMapper.selectLiningsExists(liningcodeTouse);
if (count == 0) {
throw new RuntimeException("请正确填写布料信息");
}
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("designname", designnameTouse);
yiMingMapper.updateDesignsById(map);
Designs designs = yiMingMapper.selectDesignsById(id);
List<DesFiles> inFilesList = yiMingMapper.listDesFilesByDesignCode(designs.getDesigncode());
List<DesFiles> insertDesFiles = new ArrayList<>();
List<DesFiles> updateDesFiles = new ArrayList<>();
List<DesFiles> deleteDesFiles = new ArrayList<>();
List<Integer> updateIdList = new ArrayList<>();
for (DesFiles desFiles : sjlistList) {
if (desFiles.getId() == null) {
insertDesFiles.add(desFiles);
} else {
updateDesFiles.add(desFiles);
updateIdList.add(desFiles.getId());
}
}
for (DesFiles desFiles : inFilesList) {
if (!updateIdList.contains(desFiles.getId())) {
deleteDesFiles.add(desFiles);
}
}
if (insertDesFiles != null && insertDesFiles.size() > 0) {
for (DesFiles insertDesFile : insertDesFiles) {
File sourceFile = new File(filePathComponent.getTempFolder(), insertDesFile.getUrlfix());
File destFile = new File(filePathComponent.getLogosFolder());
try {
FileUtil.move(sourceFile, destFile, true);
} catch (Exception e) {
throw new RuntimeException();
}
insertDesFile.setDesigncode(designs.getDesigncode());
insertDesFile.setType(dTypeMap.get(insertDesFile.getType()));
yiMingMapper.insertFiles(insertDesFile);
}
}
if (updateDesFiles != null && updateDesFiles.size() > 0) {
for (DesFiles updateDesFile : updateDesFiles) {
updateDesFile.setType(dTypeMap.get(updateDesFile.getType()));
yiMingMapper.updateDesFiles(updateDesFile);
}
}
if (deleteDesFiles != null && deleteDesFiles.size() > 0) {
for (DesFiles deleteDesFile : deleteDesFiles) {
yiMingMapper.deleteDesFiles(deleteDesFile);
}
}
}
@Override
public List<Designs> listLiningsDesigns(String lcode) {
String liningcodeToUse = lcode.trim();
Map<String, Object> param = new HashMap<>();
param.put("liningcode", liningcodeToUse);
List<Designs> designsList = yiMingMapper.listLiningsDesigns(param);
return designsList;
}
@Override
@Transactional
public void deleteLiningsDesigns(String designcode, String liningcode) {
String liningcodeTouse = liningcode.trim();
String designcodeTouse = designcode.trim();
List<DesFiles> desFilesList = yiMingMapper.selectFilesByDesigns(designcodeTouse);
//删除图片
if (desFilesList != null && desFilesList.size() > 0) {
for (DesFiles desFiles : desFilesList) {
Integer id = desFiles.getId();
yiMingMapper.deleteFiles(id);
}
}
//删除设计
yiMingMapper.deleteDesignsByDesigns(designcodeTouse);
if (desFilesList != null && desFilesList.size() > 0) {
for (DesFiles desFiles : desFilesList) {
try {
String filenamenew = desFiles.getUrlfix();
File filepath = new File(filePathComponent.getLogosFolder(), filenamenew);
filepath.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@Override
public Designs selectById(Integer desid) {
return yiMingMapper.selectDesignsById(desid);
}
@Override
public List<DesFiles> listDesFilesByDesignCode(String designcode) {
List<DesFiles> desFiles = yiMingMapper.listDesFilesByDesignCode(designcode);
if (desFiles != null && desFiles.size() > 0) {
for (DesFiles desFile : desFiles) {
desFile.setType(dlTypeMap.get(desFile.getType()));
}
}
return desFiles;
}
}
| [
"[email protected]"
] | |
f876b9411546ca4b585ed58b3a1c5b4e572f3826 | 57323bcb93524752dce658e128ba165c95e1a6e4 | /bmrb_plus_pdb_ext/src/EDU/bmrb/starlibj/DataValueNode.java | c61eb798da603910b06d71cc7474e1c285a7fee6 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | yokochi47/BMRBxTool | b1e922940bac6e2d010b3dcbd96661efe1ec563f | 78acbf8fae9a3dd1aae2fdf5ba8b0b469624a761 | refs/heads/master | 2023-08-18T18:31:28.076291 | 2023-08-10T03:50:30 | 2023-08-10T03:50:30 | 120,285,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,500 | java | package EDU.bmrb.starlibj;
/** DataValueNode is the class that stores a single value from the
* STAR tree. It is used for both loop values and the values associated
* with tags outside of loops. Making this a class instead of just a
* string allows for the handling of the delimiter type.
*/
public class DataValueNode extends StarNode implements Cloneable {
protected String myStrVal;
protected short delimType;
/** delimiter type that indicates that you don't care about
* the delimiter type - only used for searches such as
* <TT>searchForType()</TT>
* @see getDelimType
@ @see StarNode.searchForType()
*/
public static short DONT_CARE = -1;
/** delimiter type that indicates that this is a nonquoted value.
* @see getDelimType
*/
public static short NON = 0;
/** delimiter type that indicates that this is a doublequoted value (")
* @see getDelimType
*/
public static short DOUBLE = 1;
/** delimiter type that indicates that this is a singlequoted value (')
* @see getDelimType
*/
public static short SINGLE = 2;
/** delimiter type that indicates that this is semicolon demilited (;)
* @see getDelimType
*/
public static short SEMICOLON = 3;
/** delimiter type that indicates that this is a framecode value
* @see getDelimType
*/
public static short FRAMECODE = 4;
/** Returns the delimiter type of this value.
* Note that the delimiter type of this value determines what kind
* of delimiter is used by this value. The delimiter itself is not
* Included as part of the value string. So a value that appears
* as "sample value" in the STAR file will contain <TT>sample value</TT>
* in the string, and will be of delimiter type <TT>DOUBLE</TT>. This
* is true for all the value types, including framecodes (the dollarsign
* is not part of the string value itself).
* @return NON, DOUBLE, SINGLE, SEMICOLON, or FRAMECODE
*/
public short getDelimType() {
return delimType;
}
/** Sets the delimiter type of this value.
* Lets the programmer choose a delimiter type for this value.
*
* @exception BadValueForDelimiter Throws this exception if
* the delimiter type is incorrect for the given type of string
* (for example, if a string with whitespace is given a delimiter
* type of "NON", that's an error.)
*/
public void setDelimType(short setTo) throws BadValueForDelimiter {
if (StarValidity.isValidForDelim(myStrVal, setTo)) delimType = setTo;
else throw new BadValueForDelimiter(myStrVal, setTo);
}
/** Returns the string containing the value of this node. All values
* are stored as strings, even numbers. If you desire to look at the
* value as a number, there are many Java methods that will let you
* convert strings to numbers on-the-fly.
*/
public String getValue() {
return myStrVal;
}
/** Sets the string value for this node.
* @exception BadValueForDelimiter The string value is not
* acceptable for the delimiter the value has. If you are
* intending to change the delimiter too in the next statement,
* try changing the delimiter *first*, or use the method to
* change both at once <TT>setValAndDelim</TT>
* @see setValAndDelim()
*/
public void setValue(String newVal) throws BadValueForDelimiter {
if (StarValidity.isValidForDelim(newVal, delimType)) myStrVal = newVal;
else throw new BadValueForDelimiter(newVal, delimType);
}
/** Sets the string for this value, and the delimiter.
* @exception BadValueForDelimiter The string value is not
* acceptable for the delimiter given..
*/
public void setValue(String newVal, short newDelim) throws BadValueForDelimiter {
if (StarValidity.isValidForDelim(newVal, newDelim)) {
myStrVal = newVal;
delimType = newDelim;
} else throw new BadValueForDelimiter(newVal, newDelim);
}
/** Constructor - all DataValueNodes must have a string value,
* so no provisions are made for a 'default' no-args constructor.
* The delimiter type will be chosen as the first delimiter type
* that is valid for the string value. It will try all the
* types of delimiter until a valid type is found, using the
* following order to try them in:
* <TT><OL>
* <LI>NON</LI>
* <LI>DOUBLE</LI>
* <LI>SINGLE</LI>
* <LI>SEMICOLON</LI>
* </OL></TT>
* @exception BadValueForDelimiter if the value for the
* node won't be valid syntax given the kind of delimiter
* the node has. In theory this should be very rare
* given that most strings should fit into at least one of
* the delimiter types. The only problem is when a multiline
* string cannot be a semicolon string because it has
* embedded semicolons that appear at the start of a line.
*/
public DataValueNode(String str) throws BadValueForDelimiter {
super();
short i;
myStrVal = str;
// Find the appropriate delimiter type:
// (Never pick FRAMECODE unless explicitly told to do so.)
for (i = NON; i <= SEMICOLON; i++) {
if (StarValidity.isValidForDelim(str, i)) {
delimType = i;
break;
}
}
if (i > SEMICOLON) throw new BadValueForDelimiter(str, i);
}
/** Constructor - all DataValueNodes must have a string value,
* so no provisions are made for a 'default' no-args constructor.
* @param str The string to set the value to.
* @param delim The delimiter type to set the value to.
*/
public DataValueNode(String str, short delim) throws BadValueForDelimiter {
super();
if (StarValidity.isValidForDelim(str, delim)) {
myStrVal = str;
delimType = delim;
} else throw new BadValueForDelimiter(str, delim);
}
/** Constructor - copy another DataValueNode. */
public DataValueNode(DataValueNode copyMe) {
super(copyMe);
myStrVal = (copyMe.getValue() == null) ? null : new String(copyMe.getValue());
delimType = copyMe.getDelimType();
}
/** Allocates a new copy of me and returns a reference to it.
* This is a deep copy, meaning that all children are copied
* instead of linked.
*/
public Object clone() {
return new DataValueNode(this);
}
/** Alias for getValue */
public String getLabel() {
return myStrVal;
}
/** Unparse prints the contents of the StarNode object out to the
* given stream. This is essentially the inverse of the CS term
* to "parse", hence the name "Unparse". The parameter given is
* the indentation level to print things.
*/
public void Unparse(int indent) {
// Fill this messy thing in later.
}
/** Useful for printing.
*/
public int myLongestStr() {
int retVal = myStrVal.length();
if (delimType == NON) retVal += 0; // Leave it as it is.
else if (delimType == SINGLE) retVal += 2;
else if (delimType == DOUBLE) retVal += 2;
else if (delimType == FRAMECODE) retVal += 1;
else if (delimType == SEMICOLON) retVal += 4; // fairly meaningless, really
return retVal;
}
public VectorCheckType searchForType(Class <? > type, short delim) {
// Default behavior if not overridden is to check my
// own type and add myself to the list if I am the
// type being looked for.
VectorCheckType retVal = new VectorCheckType();
try {
retVal.addType(Class.forName(StarValidity.clsNameStarNode));
retVal.freezeTypes();
if (type.isInstance(this) && (delim == getDelimType() || delim == DONT_CARE)) retVal.addElement(this);
} catch (ClassNotFoundException exc) {
System.err.println("Should never happen exception: " + exc.getMessage());
exc.printStackTrace();
}
return retVal; // Intended to be overridden
}
} | [
"[email protected]"
] | |
b5e4e13500bb53c136a7e0cd323fd0a91b342251 | c7419e15724c8f6d147522e252b07c168f853a2c | /src/main/java/net/consensys/eventeum/integration/broadcast/BlockchainEventBroadcaster.java | 9bdc8001f0c9155dcc8cf23b160c4d7000f846c4 | [
"Apache-2.0"
] | permissive | azeem-r00t/eventeum | 3a34b413bf7716e4cea26bc3d2fb929b69e91153 | 7358ea3b2c04ca60743daed5caf74f92e9229416 | refs/heads/master | 2020-03-19T02:35:45.507529 | 2018-06-04T16:05:51 | 2018-06-04T16:05:51 | 135,642,562 | 0 | 0 | Apache-2.0 | 2018-06-04T16:05:52 | 2018-05-31T22:49:34 | Java | UTF-8 | Java | false | false | 747 | java | package net.consensys.eventeum.integration.broadcast;
import net.consensys.eventeum.dto.block.BlockDetails;
import net.consensys.eventeum.dto.event.ContractEventDetails;
/**
* An interface for a class that broadcasts etheruem blockchain details to the wider system.
*
* @author Craig Williams <[email protected]>
*/
public interface BlockchainEventBroadcaster {
/**
* Broadcast details of a new block that has been mined.
* @param block
*/
void broadcastNewBlock(BlockDetails block);
/**
* Broadcasts details of a new smart contract event that has been emitted from the ethereum blockchain.
* @param eventDetails
*/
void broadcastContractEvent(ContractEventDetails eventDetails);
}
| [
"[email protected]"
] | |
cf1ea5f1713d947f1be882a6a795f90140d82a59 | 7572fd4d0c4689b28dc7a4278d3ff1be926f4895 | /src/main/java/api/message/error/APIReplyParseException.java | bcd65295d69dd5c8f1bca09f68b3afd47dab5450 | [] | no_license | anhmanh1011/FxExchange | ec463c52c305ba875e50e11973d109325951e5a8 | d2dc7f63c3c63a1551a2dc40ba88f174947ed9e7 | refs/heads/master | 2023-07-30T15:28:05.834146 | 2021-09-13T06:54:21 | 2021-09-13T06:54:21 | 384,871,263 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 555 | java | package api.message.error;
public class APIReplyParseException extends Exception {
private static final long serialVersionUID = 6518944426920316999L;
/**
* Creates a new instance of
* <code>APIReplyParseException</code> without detail message.
*/
public APIReplyParseException() {}
/**
* Constructs an instance of
* <code>APIReplyParseException</code> with the specified detail message.
*
* @param msg the detail message.
*/
public APIReplyParseException(String msg) {
super(msg);
}
}
| [
"[email protected]"
] | |
9c534682c72f0de3b7ae508737049325c4ccc2b8 | e4423f90ddfce24798620089fdbee09b5718d41e | /Corejavetraining/src/com/corejava/training/Exceptionhandling/MultipleCatchBlockDemo.java | e58802206cc809c989e03192ebad8ce0dc71c8d9 | [] | no_license | MrPathak21/Lab-book | be8679ac9863cd827d8b87e7bac74971b11d756e | 2f40baa9f2995944811290a853ba58a48eaa6fc5 | refs/heads/main | 2023-04-08T05:37:25.016003 | 2021-04-14T20:20:50 | 2021-04-14T20:20:50 | 357,949,063 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,074 | java | package com.corejava.training.Exceptionhandling;
public class MultipleCatchBlockDemo {
public static void main(String[] args) {
System.out.println("Main starts....");
try {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = a/b;
System.out.println("Result: "+c);
}
catch(ArithmeticException e) {
System.out.println("Denominator should not be zero");
//System.out.println(e.getMessage());
e.printStackTrace();
}
catch(NumberFormatException e) {
System.out.println("Pass correct type of args");
//System.out.println(e.getMessage());
e.printStackTrace();
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println("Pass correct no. of args");
//System.out.println(e.getMessage());
e.printStackTrace();
}
System.out.println("Main ends....");
}
}
| [
"[email protected]"
] | |
cb51ae46e9ca9305f7df6181dc6f4681cea0a2a1 | a58f3cfcd76f30336478e16e370a75bcdab014b8 | /web-project/src/main/java/cn/yy/b2c/gciantispider/service/IRealTimeComputDataService.java | f223734bbfda41b3f6879e43c8d5d4098b38325b | [] | no_license | YANGPenny/anti-spider | 9859d0fcc7a6ae34d73b48ccf54cdc0a14640453 | 990772f76554d686b792fedb95c94cb28b7aa6b1 | refs/heads/master | 2022-12-24T10:32:43.376957 | 2019-09-26T09:28:33 | 2019-09-26T09:28:33 | 211,049,432 | 0 | 0 | null | 2022-12-10T00:39:22 | 2019-09-26T09:18:10 | JavaScript | UTF-8 | Java | false | false | 727 | java | /*
* Created on 2017年7月28日
* INhRedisDataService.java V1.0
*
* Copyright Notice =========================================================
* This file contains proprietary information of Kingpintcn Information Technology Co.,Ltd
* Copying or reproduction without prior written approval is prohibited.
* Copyright (c) 2012 =======================================================
*/
package cn.yy.b2c.gciantispider.service;
public interface IRealTimeComputDataService {
/**
* 从redis备份流量数据
*/
void saveRealTimeComputData();
/**
* 统计一天的流量信息
*/
void saveNhCrawlerCurdayInfo();
/**
* 统计链路数据
*/
void saveDataCollectData();
}
| [
"[email protected]"
] | |
08d36e9eea7a9d0d11d448422085061db5498d62 | 3c542e30fa49f2f847d475c62dbcbfdea8f493b6 | /src/main/java/com/ebizcuit/security/ajax/AjaxLoginProcessingFilter.java | 0cf1da0ddc2beac42cdb94fdf9334ae189ae6e47 | [] | no_license | onoph/100-days-of-code | 5c80301eb3599f4e42c82542c975687a4ae2504b | 362463f48750198c0d9e37c86c470c069992f61d | refs/heads/master | 2021-01-12T02:04:14.225106 | 2017-02-13T22:35:41 | 2017-02-13T22:35:41 | 78,465,001 | 0 | 0 | null | 2017-01-09T20:14:52 | 2017-01-09T20:14:51 | null | UTF-8 | Java | false | false | 3,640 | java | package com.ebizcuit.security.ajax;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import com.ebizcuit.security.exception.AuthMethodNotSupportedException;
import com.ebizcuit.security.model.LoginRequest;
import com.ebizcuit.security.util.WebUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
public class AjaxLoginProcessingFilter extends AbstractAuthenticationProcessingFilter {
private static Logger logger = LoggerFactory.getLogger(AjaxLoginProcessingFilter.class);
private final AuthenticationSuccessHandler successHandler;
private final AuthenticationFailureHandler failureHandler;
private final ObjectMapper objectMapper;
public AjaxLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
AuthenticationFailureHandler failureHandler, ObjectMapper mapper)
{
super(defaultProcessUrl);
this.successHandler = successHandler;
this.failureHandler = failureHandler;
this.objectMapper = mapper;
}
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
throws AuthenticationException, IOException, ServletException
{
if (!HttpMethod.POST.name().equals(request.getMethod()) || !WebUtil.isAjax(request)) {
if(logger.isDebugEnabled()) {
logger.debug("Authentication method not supported. Request method: " + request.getMethod());
}
throw new AuthMethodNotSupportedException("Authentication method not supported");
}
LoginRequest loginRequest = objectMapper.readValue(request.getReader(), LoginRequest.class);
if(StringUtils.isBlank(loginRequest.getUsername())
|| StringUtils.isBlank(loginRequest.getPassword()))
{
throw new AuthenticationServiceException("Username or Password not provided");
}
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
loginRequest.getUsername(), loginRequest.getPassword());
return this.getAuthenticationManager().authenticate(token);
}
@Override
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response,
FilterChain chain, Authentication authResult) throws IOException, ServletException
{
successHandler.onAuthenticationSuccess(request, response, authResult);
}
@Override
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
AuthenticationException failed) throws IOException, ServletException
{
SecurityContextHolder.clearContext();
failureHandler.onAuthenticationFailure(request, response, failed);
}
}
| [
"[email protected]"
] | |
4df333d08970a524e4f25d6285c1dc682493459e | 890af51efbc9b8237e0fd09903f78fe2bb9caadd | /general/storage/com/hd/agent/storage/dao/AdjustmentsMapper.java | af5019b574419fa00b4a918ee9a0ac01ebdc0989 | [] | no_license | 1045907427/project | 815fb0c5b4b44bf5d8365acfde61b6f68be6e52a | 6eaecf09cd3414295ccf91454f62cf4d619cdbf2 | refs/heads/master | 2020-04-14T19:17:54.310613 | 2019-01-14T10:49:11 | 2019-01-14T10:49:11 | 164,052,678 | 0 | 5 | null | null | null | null | UTF-8 | Java | false | false | 4,072 | java | package com.hd.agent.storage.dao;
import com.hd.agent.common.util.PageMap;
import com.hd.agent.storage.model.Adjustments;
import com.hd.agent.storage.model.AdjustmentsDetail;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 库存调账单dao
* @author chenwei
*/
public interface AdjustmentsMapper {
/**
* 添加调账单基本信息
* @param adjustments
* @return
* @author chenwei
* @date May 24, 2013
*/
public int addAdjustments(Adjustments adjustments);
/**
* 添加调整单明细信息
* @param adjustmentsDetail
* @return
* @author chenwei
* @date May 24, 2013
*/
public int addAdjustmentsDetail(AdjustmentsDetail adjustmentsDetail);
/**
* 获取调账单列表
* @param pageMap
* @return
* @author chenwei
* @date May 25, 2013
*/
public List showAdjustmentsList(PageMap pageMap);
/**
* 获取调账单数量
* @param pageMap
* @return
* @author chenwei
* @date May 25, 2013
*/
public int showAdjustmentsCount(PageMap pageMap);
/**
* 获取调账单信息
* @param id
* @return
* @author chenwei
* @date May 25, 2013
*/
public Adjustments getAdjustmentsInfo(@Param("id")String id);
/**
* 根据调账单编号获取调账单明细列表
* @param adjustmentsid
* @param storageid
* @return
* @author chenwei
* @date May 25, 2013
*/
public List getAdjustmentsDetailList(@Param("adjustmentsid")String adjustmentsid, @Param("storageid")String storageid);
/**
* 删除调账单
* @param id
* @return
* @author chenwei
* @date May 25, 2013
*/
public int deleteAdjustments(@Param("id")String id);
/**
* 删除调账单明细
* @param adjustmentsid
* @return
* @author chenwei
* @date May 25, 2013
*/
public int deleteAdjustmentsDetail(@Param("adjustmentsid")String adjustmentsid);
/**
* 修改调账单
* @param adjustments
* @return
* @author chenwei
* @date May 27, 2013
*/
public int editAdjustments(Adjustments adjustments);
/**
* 通过盘点单编号,获取调账单信息
* @param checkListid
* @return
* @author chenwei
* @date May 28, 2013
*/
public Adjustments getAdjustmentsByCheckListid(String checkListid);
/**
* 审核调账单
* @param id
* @param userid
* @param username
* @return
* @author chenwei
* @date May 28, 2013
*/
public int auditAdjustments(@Param("id")String id,@Param("userid")String userid,@Param("username")String username,@Param("businessdate")String businessdate);
/**
* 反审调账单
* @param id
* @return
* @author chenwei
* @date May 28, 2013
*/
public int oppauditAdjustments(@Param("id")String id);
/**
* 导出调账单
* @param pageMap
* @return
* @author panxiaoxiao
* @date Apr 29, 2014
*/
public List<Map<String, Object>> getAdjustmentListExport(PageMap pageMap);
/**
* 获取调账单列表<br/>
* map中参数:<br/>
* dataSql:数据权限<br/>
* idarrs: 编号字符串组,类似 1,2,3<br/>
* status: 表示状态3<br/>
* statusarr: 表示状态,类似 1,2,3<br/>
* billtype : 单据类型1报益单2报损单<br/>
* @param map
* @return
* @author zhanghonghui
* @date 2013-10-16
*/
public List showAdjustmentsListBy(Map map);
/**
* 更新打印次数
* @param adjustments
* @return
* @author zhanghonghui
* @date 2015年1月9日
*/
public int updateOrderPrinttimes(Adjustments adjustments);
/**
* 更新调账单明细相关的商品批次编号
* @param id
* @param summarybatchid
* @return
* @author chenwei
* @date 2015年10月28日
*/
public int updateAdjustmentsDetailSummarybatchid(@Param("id")String id,@Param("summarybatchid")String summarybatchid,@Param("price")BigDecimal price);
/**
* 获取报溢调账单生成凭证的数据
* @param list
* @return java.util.List
* @throws
* @author luoqiang
* @date Jan 03, 2018
*/
public List getAdjustmentsSumData(@Param("list")List list,@Param("billtype")String billtype);
} | [
"[email protected]"
] | |
6c79be7b8792f507f492c459f5cd7f6168f2a1b5 | 9075319a8ffaae62e79fd91d85a01831a8ecf629 | /app/src/androidTest/java/com/bufflife/bufflife/mapViewTest.java | 311beb2925121888917f0f008cfbe0e2df9114e7 | [] | no_license | jbirdman48/BuffLifeV3 | 1e55844d2cd905a4501fea750e1c251eadc8a17c | a369288e704f4c8b9b98be3a6bc6711d7c10ddb1 | refs/heads/master | 2021-05-31T11:37:45.070368 | 2015-12-11T21:38:26 | 2015-12-11T21:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,355 | java | package com.bufflife.bufflife;
/**
* @author Jesse Bird on 11/7/15.
*/
import android.content.Intent;
import android.test.ActivityUnitTestCase;
import android.test.suitebuilder.annotation.MediumTest;
import android.webkit.WebView;
import android.widget.Button;
public class mapViewTest extends ActivityUnitTestCase<mapView> {
private Intent mStartIntent;
private WebView mButton;
public mapViewTest() {
super(mapView.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
// In setUp, you can create any shared test data, or set up mock components to inject
// into your Activity. But do not call startActivity() until the actual test methods.
mStartIntent = new Intent(Intent.ACTION_MAIN);
}
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
startActivity(mStartIntent, null, null);
mButton = (WebView) getActivity().findViewById(R.id.bustracker1);
//assertNotNull(getActivity());
//assertNotNull(mButton);
}
/**
* This test demonstrates examining the way that activity calls startActivity() to launch
* other activities.
*/
@MediumTest
public void testSubLaunch() {
mapView activity = startActivity(mStartIntent, null, null);
mButton = (WebView) activity.findViewById(R.id.mapview1);
// This test confirms that when you click the button, the activity attempts to open
// another activity (by calling startActivity) and close itself (by calling finish()).
mButton.performClick();
//assertNotNull(getStartedActivityIntent());
//assertTrue(isFinishCalled());
}
/**
* This test demonstrates ways to exercise the Activity's life cycle.
*/
@MediumTest
public void testLifeCycleCreate() {
mapView activity = startActivity(mStartIntent, null, null);
// At this point, onCreate() has been called, but nothing else
// Complete the startup of the activity
getInstrumentation().callActivityOnStart(activity);
getInstrumentation().callActivityOnResume(activity);
// At this point you could test for various configuration aspects, or you could
// use a Mock Context to confirm that your activity has made certain calls to the system
// and set itself up properly.
getInstrumentation().callActivityOnPause(activity);
// At this point you could confirm that the activity has paused properly, as if it is
// no longer the topmost activity on screen.
getInstrumentation().callActivityOnStop(activity);
// At this point, you could confirm that the activity has shut itself down appropriately,
// or you could use a Mock Context to confirm that your activity has released any system
// resources it should no longer be holding.
// ActivityUnitTestCase.tearDown(), which is always automatically called, will take care
// of calling onDestroy().
}
} | [
"[email protected]"
] | |
752bfaee0829eae54af5448d64af36d35df4396b | e1c6ef7778727932ea9ab7979ca1e0993b655327 | /plugins/caex30/caex.caex30.edit/src-gen/caex/caex30/caex/provider/NominalScaledItemProvider.java | 1884db241df19e1029a15c533b25668427c1d57a | [] | no_license | kit-sdq/AutomationML-CAEX-Metamodel | b8c262b14a39623b2560df99569310de3a9b86f2 | c2a10acb1f0fc594be1de3ad62b7d1569d16c9b6 | refs/heads/master | 2021-04-15T13:31:21.809712 | 2019-11-27T08:40:08 | 2019-11-27T08:40:08 | 126,177,811 | 1 | 1 | null | 2019-02-03T21:08:55 | 2018-03-21T12:49:54 | Java | UTF-8 | Java | false | false | 4,487 | java | /**
*/
package caex.caex30.caex.provider;
import caex.caex30.caex.CAEXPackage;
import caex.caex30.caex.NominalScaled;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
/**
* This is the item provider adapter for a {@link caex.caex30.caex.NominalScaled} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public class NominalScaledItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NominalScaledItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addRequiredValuePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Required Value feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void addRequiredValuePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_NominalScaled_requiredValue_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_NominalScaled_requiredValue_feature", "_UI_NominalScaled_type"),
CAEXPackage.Literals.NOMINAL_SCALED__REQUIRED_VALUE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This returns NominalScaled.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/NominalScaled"));
}
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getText(Object object) {
return getString("_UI_NominalScaled_type");
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(NominalScaled.class)) {
case CAEXPackage.NOMINAL_SCALED__REQUIRED_VALUE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
/**
* This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
* that can be created under this object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ResourceLocator getResourceLocator() {
return CAEX30EditPlugin.INSTANCE;
}
}
| [
"[email protected]"
] | |
dd60d533c7737885d96c58fb8da99858da5f6959 | 355096b78c5c1c670663f372034495e4930ff34b | /src/test/java/DemoTraditionalChinese2SimplifiedChinese.java | 69abbd6f0b73d45fc20fdb1be48ec2f54642d4b4 | [] | no_license | pconcool/nlp | 3ee25511b676f1574364eccbd33776361ff7fb2f | d1ac1e92e1368fe3a8ad5808914483b1d6896ad8 | refs/heads/master | 2020-10-01T13:07:28.501396 | 2017-11-28T10:48:21 | 2017-11-28T10:48:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 409 | java | import com.hankcs.hanlp.HanLP;
/**
* 简繁转换
* @author hankcs
*/
public class DemoTraditionalChinese2SimplifiedChinese
{
public static void main(String[] args)
{
System.out.println(HanLP.convertToTraditionalChinese("用笔记本电脑写程序"));
System.out.println(HanLP.convertToSimplifiedChinese("「以後等妳當上皇后,就能買士多啤梨慶祝了」"));
}
} | [
"[email protected]"
] | |
faaa1b43705296c84709864b5505914a169cfb75 | 2f250fe113b6fe2b1ce896ba9b5586b48c96d10e | /opfpush/src/main/java/org/onepf/opfpush/RetryBroadcastReceiver.java | a632ffa5ae91884470b5d5c0a1d1f495cc55a010 | [
"Apache-2.0"
] | permissive | GrimReio/OPFPush | 31fc256abac0920a56ae28957e05b03cc4394824 | 210a0f39aec24ddfdfe43a1617c69c0afff6e9db | refs/heads/master | 2021-01-17T20:52:06.111945 | 2014-10-24T21:53:15 | 2014-10-24T21:53:15 | 28,494,605 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,382 | java | /*
* Copyright 2012-2014 One Platform Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onepf.opfpush;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* @author Kirill Rozov
* @since 01.10.14.
*/
public final class RetryBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
final OPFPushHelper helper = OPFPushHelper.getInstance(context);
if (helper.isInitDone()) {
final String action = intent.getAction();
if (Constants.ACTION_REGISTER.equals(action)) {
helper.register(intent.getStringExtra(Constants.EXTRA_PROVIDER_NAME));
} else {
throw new OPFPushException("Unknown action '%s'.", action);
}
}
}
}
| [
"[email protected]"
] | |
50d1b50309453cb0699d6e80d60b6f121a4a325f | 3386dd7e7be492cfb06912215e5ef222bbc7ce34 | /autocomment_netbeans/spooned/org/jbpm/query/jpa/data/JaxbQuerySerializationTest.java | c06af43f0f7c49a9b82a6eb9e06885411eba0be5 | [
"Apache-2.0"
] | permissive | nerzid/autocomment | cc1d3af05045bf24d279e2f824199ac8ae51b5fd | 5803cf674f5cadfdc672d4957d46130a3cca6cd9 | refs/heads/master | 2021-03-24T09:17:16.799705 | 2016-09-28T14:32:21 | 2016-09-28T14:32:21 | 69,360,519 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,576 | java | /**
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* 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.jbpm.query.jpa.data;
import java.util.ArrayList;
import java.io.ByteArrayInputStream;
import java.util.HashSet;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.util.List;
import javax.xml.bind.Marshaller;
import java.util.Set;
import java.io.StringWriter;
import javax.xml.bind.Unmarshaller;
public class JaxbQuerySerializationTest extends AbstractQuerySerializationTest {
Set<Class> extraClasses = new HashSet<Class>();
@Override
public <T> T testRoundTrip(T input) throws Exception {
String xmlStr = convertJaxbObjectToString(input);
logger.debug(xmlStr);
return ((T) (convertStringToJaxbObject(xmlStr, input.getClass())));
}
public String convertJaxbObjectToString(Object object) throws JAXBException {
List<Class> classes = new ArrayList<Class>();
classes.add(object.getClass());
classes.addAll(extraClasses);
Marshaller marshaller = JAXBContext.newInstance(classes.toArray(new Class[classes.size()])).createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
StringWriter stringWriter = new StringWriter();
marshaller.marshal(object, stringWriter);
String output = stringWriter.toString();
return output;
}
public Object convertStringToJaxbObject(String xmlStr, Class clazz) throws JAXBException {
List<Class> classes = new ArrayList<Class>();
classes.add(clazz);
classes.addAll(extraClasses);
Unmarshaller unmarshaller = JAXBContext.newInstance(classes.toArray(new Class[classes.size()])).createUnmarshaller();
ByteArrayInputStream xmlStrInputStream = new ByteArrayInputStream(xmlStr.getBytes());
Object jaxbObj = unmarshaller.unmarshal(xmlStrInputStream);
return jaxbObj;
}
@Override
void addSerializableClass(Class objClass) {
JaxbQuerySerializationTest.this.extraClasses.add(objClass);
}
}
| [
"[email protected]"
] | |
0aa237efe323a3e5a60cb14826d67354849c6aa3 | e9affefd4e89b3c7e2064fee8833d7838c0e0abc | /aws-java-sdk-core/src/test/java/com/amazonaws/regions/InstanceMetadataRegionProviderTest.java | faa2eb1490bf129af62b2cc541155f86bc06821c | [
"Apache-2.0"
] | permissive | aws/aws-sdk-java | 2c6199b12b47345b5d3c50e425dabba56e279190 | bab987ab604575f41a76864f755f49386e3264b4 | refs/heads/master | 2023-08-29T10:49:07.379135 | 2023-08-28T21:05:55 | 2023-08-28T21:05:55 | 574,877 | 3,695 | 3,092 | Apache-2.0 | 2023-09-13T23:35:28 | 2010-03-22T23:34:58 | null | UTF-8 | Java | false | false | 3,973 | java | /*
* Copyright 2011-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.regions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import com.amazonaws.AmazonClientException;
import com.amazonaws.SDKGlobalConfiguration;
import com.amazonaws.util.EC2MetadataUtilsServer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/**
* Tests broken up by fixture.
*/
@RunWith(Enclosed.class)
public class InstanceMetadataRegionProviderTest {
/**
* If the EC2 metadata service is running it should return the region the server is mocked
* with.
*/
public static class MetadataServiceRunningTest {
private static EC2MetadataUtilsServer server;
private AwsRegionProvider regionProvider;
@BeforeClass
public static void setupFixture() throws IOException {
server = new EC2MetadataUtilsServer("localhost", 0, true);
server.start();
System.setProperty(SDKGlobalConfiguration.EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY,
"http://localhost:" + server.getLocalPort());
}
@AfterClass
public static void tearDownFixture() throws IOException {
server.stop();
System.clearProperty(
SDKGlobalConfiguration.EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY);
}
@Before
public void setup() {
regionProvider = new InstanceMetadataRegionProvider();
}
@Test
public void metadataServiceRunning_ProvidesCorrectRegion() {
assertEquals("us-east-1", regionProvider.getRegion());
}
@Test
public void ec2MetadataDisabled_shouldReturnRegionAfterEnabled() {
try {
System.setProperty("com.amazonaws.sdk.disableEc2Metadata", "true");
regionProvider.getRegion();
fail("exception not thrown when EC2Metadata disabled");
} catch (AmazonClientException ex) {
//expected
} finally {
System.clearProperty("com.amazonaws.sdk.disableEc2Metadata");
}
assertNotNull("region should not be null", regionProvider.getRegion());
}
}
/**
* If the EC2 metdata service is not present then the provider should just return null instead
* of failing. This is to allow the provider to be used in a chain context where another
* provider further down the chain may be able to provide the region.
*/
public static class MetadataServiceNotRunning {
private AwsRegionProvider regionProvider;
@Before
public void setup() {
System.setProperty(SDKGlobalConfiguration.EC2_METADATA_SERVICE_OVERRIDE_SYSTEM_PROPERTY,
"http://localhost:54123");
regionProvider = new InstanceMetadataRegionProvider();
}
@Test
public void metadataServiceRunning_ProvidesCorrectRegion() {
assertNull(regionProvider.getRegion());
}
}
} | [
""
] | |
5a64955b581154a51083b11154011789d71072ce | 37bd9beca09122463e0d406e572f25720daa2d1c | /Lab 6/src/Main.java | fb5d63c63fc9a0f7a80ae0adc8f69c253857fcd4 | [] | no_license | Vitaljaz/Java-course | 35aac469dcf8155ce93b8cecd202bed77089313e | 045950447e32de38eeb88932cab5012d35643b6e | refs/heads/master | 2021-01-05T19:51:10.306604 | 2020-03-11T18:29:43 | 2020-03-11T18:29:43 | 241,121,543 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,304 | java | import java.io.*;
public class Main {
private static double[] sinArray;
private static double[] newArray;
public static void main(String[] args) {
sinArray = new double[360];
newArray = new double[360];
task1();
task2();
task3();
task4();
}
public static void task1() {
try {
PrintWriter pw = new PrintWriter("sin.txt");
for (int i = 0; i < 360; i++) {
pw.println(Math.sin(i));
}
pw.flush();
pw.close();
} catch (FileNotFoundException e) {
System.out.println("[TASK 1]: Error with file sin.txt");
e.printStackTrace();
}
}
public static void task2() {
try {
BufferedReader sinReader = new BufferedReader(new FileReader("sin.txt"));
String str;
int i = 0;
while ((str = sinReader.readLine()) != null) {
sinArray[i] = Double.parseDouble(str);
i++;
}
sinReader.close();
} catch (Exception e) {
System.out.println("[TASK 2]: Error with file sin.txt.");
e.printStackTrace();
}
try {
BufferedReader iReader = new BufferedReader(new FileReader("input.txt"));
String str = iReader.readLine();
iReader.close();
int k = Integer.parseInt(str);
System.out.println("[TASK 2]: " + sinArray[k]);
} catch (Exception e) {
System.out.println("[TASK 2]: Error with file input.txt");
e.printStackTrace();
}
}
public static void task3() {
try {
FileOutputStream fos = new FileOutputStream("sin2.dat");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(sinArray);
oos.close();
double[] newArray;
FileInputStream fis = new FileInputStream("sin2.dat");
ObjectInputStream iis = new ObjectInputStream(fis);
newArray = (double[]) iis.readObject();
iis.close();
System.out.println("[TASK 3]: oldArray[223] = " + sinArray[223] + " ; newArray[223] = " + newArray[223]);
} catch (Exception e) {
e.printStackTrace();
System.out.println("[TASK 3]: Error with sin2.dat");
}
}
public static void task4() {
try {
FileOutputStream fos = new FileOutputStream("sin3.dat");
ObjectOutputStream oos = new ObjectOutputStream(fos);
for (double i : sinArray) {
oos.writeDouble(i);
}
oos.close();
FileInputStream fis = new FileInputStream("sin3.dat");
ObjectInputStream iis = new ObjectInputStream(fis);
double[] newArray = new double[360];
for (int i = 0; i < sinArray.length; i++) {
newArray[i] = iis.readDouble();
}
iis.close();
System.out.println("[TASK 4]: oldArray[333] = " + sinArray[333] + " ; newArray[333] = " + newArray[33]);
} catch (Exception e) {
e.printStackTrace();
System.out.println("[TASK 4]: Error with sin3.dat");
}
}
}
| [
"[email protected]"
] | |
151b2c6b4fba0e01011f83224680021cc1f523e1 | b6492f34e185dc8e155d4dfb29303c363b1938aa | /yunGuo-service/src/main/java/com/yunguo/config/JacksonConfig.java | dd9b19da07dacdbdaa986511763bbbb9c770ec20 | [] | no_license | TiMiWang/yunguo | 434fae949ac995cee991ae4ae59fc8c90bebf6b8 | cce5810373756a92ae4b11828851b68816fb18be | refs/heads/master | 2020-04-09T09:00:00.688613 | 2018-12-03T16:15:24 | 2018-12-03T16:15:24 | 160,216,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,322 | java | package com.yunguo.config;
import java.io.IOException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
@Configuration
public class JacksonConfig {
@Bean
@Primary
@ConditionalOnMissingBean(ObjectMapper.class)
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
@Override
public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
jsonGenerator.writeString("");
}
});
return objectMapper;
}
}
| [
"[email protected]"
] | |
51d8c58b6013063e04d55e3a32cff4677d356e5b | 733676ce14530e49c12f9bf1bb27060def9ffb72 | /src/main/java/BusinessLayer/BankAccountType.java | 57d71611ebf869a23d3223690805ec902e14eb6a | [] | no_license | dstokes1623/BankAccountManager | a6a9bf38986b69610b75242576d12454a874d781 | e574d32c8e29b8a32e30f9e2f7720f4e7f312370 | refs/heads/master | 2023-01-04T02:46:06.266689 | 2020-10-27T16:50:44 | 2020-10-27T16:50:44 | 307,768,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package BusinessLayer;
/**
*
* @author 0798727
*/
public enum BankAccountType {
Checking,
Saving,
Investment
}
| [
"[email protected]"
] | |
2e4c24a7110aa6b3491d5110d0101c2af85b5899 | 4f8f44009520adb622b5e0cc110ff8aa52e30cf6 | /src/com/tom/dp22Mediator/Test.java | 77cc6539efa185cbf669d039d6fe3b8bbf8512a6 | [] | no_license | ZhuChuanchuan/DesignPattern | f7521db36a63eb8a96b2a45413c4715adf2e801a | 501429b2c92fad69abe8668efd6d04bbb33a892d | refs/heads/master | 2021-01-19T14:15:50.133916 | 2017-04-13T08:56:14 | 2017-04-13T08:56:14 | 88,139,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 227 | java | package com.tom.dp22Mediator;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Mediator mediator=new MyMediator();
mediator.createMediator();
mediator.workAll();
}
}
| [
"[email protected]"
] | |
e05258671a7ef2da56ed8043d4af14739b71bdb5 | 8fa221482da055f4c8105b590617a27595826cc3 | /sources/com/google/android/gms/games/internal/api/zzcg.java | 7257538360fba8f27aae2c75fd6992ff53462184 | [] | no_license | TehVenomm/sauceCodeProject | 4ed2f12393e67508986aded101fa2db772bd5c6b | 0b4e49a98d14b99e7d144a20e4c9ead408694d78 | refs/heads/master | 2023-03-15T16:36:41.544529 | 2018-10-08T03:44:58 | 2018-10-08T03:44:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,194 | java | package com.google.android.gms.games.internal.api;
import android.os.RemoteException;
import com.google.android.gms.common.api.Api.zzb;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.internal.zzn;
import com.google.android.gms.games.internal.GamesClientImpl;
import com.google.android.gms.games.snapshot.SnapshotContents;
import com.google.android.gms.games.snapshot.SnapshotMetadataChange;
final class zzcg extends zzcn {
private /* synthetic */ SnapshotMetadataChange zzhhz;
private /* synthetic */ String zzhib;
private /* synthetic */ String zzhic;
private /* synthetic */ SnapshotContents zzhid;
zzcg(zzcb zzcb, GoogleApiClient googleApiClient, String str, String str2, SnapshotMetadataChange snapshotMetadataChange, SnapshotContents snapshotContents) {
this.zzhib = str;
this.zzhic = str2;
this.zzhhz = snapshotMetadataChange;
this.zzhid = snapshotContents;
super(googleApiClient);
}
protected final /* synthetic */ void zza(zzb zzb) throws RemoteException {
((GamesClientImpl) zzb).zza((zzn) this, this.zzhib, this.zzhic, this.zzhhz, this.zzhid);
}
}
| [
"[email protected]"
] | |
3a7bd73b4d4385498f45edbbd1daab348cd87417 | cef75b4b7de59d4b76a386862fe6172712adc545 | /src/com/ymdq/thy/bean/personcenter/UpdateVersionResponse.java | 6181d310e35013f812fc46c63a328d3387e5bb83 | [] | no_license | tgf229/THYProperty | 9ccde1ad6518a037b3f1ef73de26941763064e29 | f7182d9e376dbe31bfa521b1f110fef2c8c84515 | refs/heads/master | 2021-01-10T21:54:44.561564 | 2015-12-28T12:07:44 | 2015-12-28T12:07:44 | 42,927,268 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,553 | java | /*
* 文 件 名: UpdateVersionResponse.java
* 版 权: Linkage Technology Co., Ltd. Copyright 2010-2011, All rights reserved
* 描 述: <描述>
* 版 本: <版本号>
* 创 建 人: user
* 创建时间: 2014-11-28
*/
package com.ymdq.thy.bean.personcenter;
import com.ymdq.thy.bean.BaseResponse;
/**
* <版本更新检查>
* <功能详细描述>
*
* @author WT
* @version [版本号, 2014-11-28]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class UpdateVersionResponse extends BaseResponse
{
/**
* 最新版本
*/
private String version;
/**
* 更新内容
*/
private String content;
/**
* 是否强制更新 0不强制 1强制
*/
private String isUpdate;
/**
* 下载地址
*/
private String urlAddress;
public String getVersion()
{
return version;
}
public void setVersion(String version)
{
this.version = version;
}
public String getContent()
{
return content;
}
public void setContent(String content)
{
this.content = content;
}
public String getIsUpdate()
{
return isUpdate;
}
public void setIsUpdate(String isUpdate)
{
this.isUpdate = isUpdate;
}
public String getUrlAddress()
{
return urlAddress;
}
public void setUrlAddress(String urlAddress)
{
this.urlAddress = urlAddress;
}
}
| [
"[email protected]"
] | |
5ee0a4ab1c100e468f1f267f372aac6d836bd730 | d9228cdbfd15ae1f82be4222e76ee5097311774f | /src/org/usfirst/frc/team2834/robot/commands/auto/DoLowBar.java | 6b9f3a27f783a6cabc95df0cd95d4534478f6d63 | [] | no_license | adamraine/frc2016 | 1b5b76abee25b0f8771e085f4f9a6348df9f404a | ac63134ea976db8c41868f3cb75b9ece62fd6fbd | refs/heads/master | 2021-06-08T16:42:34.186666 | 2016-08-19T16:04:50 | 2016-08-19T16:04:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 457 | java | package org.usfirst.frc.team2834.robot.commands.auto;
import edu.wpi.first.wpilibj.command.CommandGroup;
/**
*
*/
public class DoLowBar extends CommandGroup {
public DoLowBar() {
super("Do Low Bar");
addSequential(new TimedAngler(-0.5, 0.6));
addSequential(new TimedHaloDrive(0.5, 0.2, false, 1.5));
addSequential(new TimedHaloDrive(-0.1, 0.0, false, 0.1));
addSequential(new TimedAngler(0.5, 1));
}
}
| [
"[email protected]"
] | |
cc8cd94c7c3da652ae9aba60b1a4fe1a1406b17e | ba005c6729aed08554c70f284599360a5b3f1174 | /lib/selenium-server-standalone-3.4.0/org/apache/http/conn/OperatedClientConnection.java | ca717ff1b4d952d4d637216f46d7d56fe364266a | [] | no_license | Viral-patel703/Testyourbond-aut0 | f6727a6da3b1fbf69cc57aeb89e15635f09e249a | 784ab7a3df33d0efbd41f3adadeda22844965a56 | refs/heads/master | 2020-08-09T00:27:26.261661 | 2017-11-07T10:12:05 | 2017-11-07T10:12:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 858 | java | package org.apache.http.conn;
import java.io.IOException;
import java.net.Socket;
import org.apache.http.HttpClientConnection;
import org.apache.http.HttpHost;
import org.apache.http.HttpInetConnection;
import org.apache.http.params.HttpParams;
@Deprecated
public abstract interface OperatedClientConnection
extends HttpClientConnection, HttpInetConnection
{
public abstract HttpHost getTargetHost();
public abstract boolean isSecure();
public abstract Socket getSocket();
public abstract void opening(Socket paramSocket, HttpHost paramHttpHost)
throws IOException;
public abstract void openCompleted(boolean paramBoolean, HttpParams paramHttpParams)
throws IOException;
public abstract void update(Socket paramSocket, HttpHost paramHttpHost, boolean paramBoolean, HttpParams paramHttpParams)
throws IOException;
}
| [
"[email protected]"
] | |
2c10843045fa66a5ca004a0f178da00a9bd0e72b | d4b9484c6f13edc179a1aa6814e061f170b84403 | /boot-web-admin/src/test/java/com/example/admin/AssertionsTest.java | f542724740e80443291fb1ca58c1045a807b42ef | [] | no_license | jiushigao/springboot-learn | 0f354cbf5867d3a37bf421a65861d587a38417ab | 5bb1eea8b27b2a8bb6b64d4376254861fae1a562 | refs/heads/master | 2023-03-24T07:35:20.300468 | 2021-03-22T12:44:30 | 2021-03-22T12:44:30 | 350,338,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,643 | java | package com.example.admin;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
public class AssertionsTest {
@DisplayName("测试简单断言")
@Test
void testSimpleAssertion(){
int cal = cal(2, 3);
//相等
assertEquals(5,cal,"业务逻辑错误");
Object obj1 = new Object();
Object obj2 = new Object();
//判断两个引用是否指向同一对象
assertSame(obj1,obj2,"不是同一对象");
}
int cal(int a,int b){
return a+b;
}
@DisplayName("数组断言")
@Test
void array(){
assertArrayEquals(new int[]{1,2},new int[]{1,2});
}
@DisplayName("组合断言")
@Test
void all(){
/**
* 所有断言都需要成功
*/
assertAll("test",
()->assertTrue(true&&true),
()->assertEquals(1,1));
System.out.println("测试成功");
}
//需要抛出指定异常
@DisplayName("异常断言")
@Test
void testException(){
assertThrows(ArithmeticException.class,()->{int i = 10/1;},"没有发生数学计算异常");
}
@DisplayName("快速失败")
@Test
void testFail(){
if(1==1){
fail("测试失败");
}
}
@DisplayName("测试前置条件")
@Test
void testAssumptions(){
Assumptions.assumeTrue(false,"前置条件失败");
System.out.println("======");
}
}
| [
"[email protected]"
] | |
e3906dea960ae60e2a800b0b5aaa149d370ecd4f | 4f80fd8c1b9c608584f3473690f8fa4c245421e4 | /10Applications/src/pkg10applications/Prime.java | 40db7d55f7c192a4d32777946306595df629045f | [] | no_license | BedirT/JavaStudy | 3989600f47e545529af80b566c66cea30d77e019 | 030409db0525fedf7af8d70c15a229202f5fa393 | refs/heads/master | 2016-09-01T07:26:26.465695 | 2016-05-01T22:47:10 | 2016-05-01T22:47:10 | 50,141,495 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 821 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pkg10applications;
import java.util.Scanner;
/**
*
* @author BedirTapkan
*/
public class Prime {
public static void main(String[] args) {
//Write a program in Java to find out if a number is prime in Java?
//(input 7: output true , input 9 : output false)
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
boolean a = false;
System.out.println(n);
for(int i = 2 ; i < n ; i++){
if(n%i==0){
a = true;
}
}
if(a){System.out.println("True");}
else{System.out.println("False");}
}
}
| [
"[email protected]"
] | |
48fbd14e07d4d89360520f0c4ffd5650cf6d2be4 | 4e65035c3a7c8043ff446177f4874955fbae9565 | /src/com/jpm/supersimplestock/service/ServiceSimpleStockImpl.java | 306c2ab9994f6dbc459c0022d0241fc1a932232a | [] | no_license | adelmogentilini/superSimpleStock | a95f2c0c4b7c489ee36546e8b0ee76ac2d7b180c | 44a413143eae11f07626074851c86c2a0158679c | refs/heads/master | 2020-07-07T06:36:18.177133 | 2016-08-21T10:12:48 | 2016-08-21T10:12:48 | 66,188,333 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,238 | java | package com.jpm.supersimplestock.service;
import com.jpm.supersimplestock.PersistenceMarket;
import com.jpm.supersimplestock.shared.BigFunctions;
import com.jpm.supersimplestock.shared.Constants;
import com.jpm.supersimplestock.stock.SimpleStock;
import com.jpm.supersimplestock.trade.Trade;
import java.math.BigDecimal;
import java.util.Date;
/**
* This class is the 'default implementation for interface' for respond to requirements of
* example project.
* <p>
* Created by adelmo on 20/08/2016.
*/
public class ServiceSimpleStockImpl implements ServiceSimpleStock {
/**
* Calculate dividend yeld for the stock wth symbol at price indicated.
*
* @param symbol
* @param price
*/
@Override
public BigDecimal dividendYeldFor(String symbol, double price) {
return dividendYeldFor(symbol, new BigDecimal(price, Constants.MC));
}
@Override
public BigDecimal dividendYeldFor(String symbol, BigDecimal price) {
SimpleStock stock = PersistenceMarket.getInstance().getStock(symbol);
return stock.dividendYeld(price);
}
/**
* Calculate pe ratio for the stock with symbol at price indicated.
*
* @param symbol
* @param price
*/
@Override
public BigDecimal peRatioFor(String symbol, BigDecimal price) {
SimpleStock stock = PersistenceMarket.getInstance().getStock(symbol);
return stock.peRatio(price);
}
/**
* Record a buy of a quantity of qty for Stock identify by simple at price.
*
* @param symbol
* @param qty
* @param price
*/
@Override
public void tradeBuy(String symbol, BigDecimal qty, BigDecimal price) {
SimpleStock stock = PersistenceMarket.getInstance().getStock(symbol);
Trade td = stock.buy(qty, price);
PersistenceMarket.getInstance().addTrade(td);
}
/**
* Record a sell of a quantity of qty for Stock identify by simple at price.
*
* @param symbol
* @param qty
* @param price
*/
@Override
public void tradeSell(String symbol, BigDecimal qty, BigDecimal price) {
SimpleStock stock = PersistenceMarket.getInstance().getStock(symbol);
Trade td = stock.sell(qty, price);
PersistenceMarket.getInstance().addTrade(td);
}
/**
* For default consider only the trade in the last CONSTANTS.DEF_FOR_STOCK minutes
* (15 is default like requirements).
*
* @param symbol
* @return
*/
@Override
public BigDecimal stockPrice(String symbol) {
return stockPrice(symbol, Constants.DEF_FOR_STOCK);
}
@Override
public BigDecimal stockPrice(String symbol, long minutes) {
Date limit = new Date();
limit.setTime(limit.getTime() - Constants.MILLIS_FOR_MINUTE * minutes); // tot minutes before
BigDecimal sumtq, sumq;
sumtq = new BigDecimal(0, Constants.MC);
sumq = new BigDecimal(0, Constants.MC);
for (Trade trade : PersistenceMarket.getInstance().getTradeFrom(symbol, limit)) {
sumtq = sumtq.add(trade.getPrice().multiply(trade.getQuantity(), Constants.MC), Constants.MC);
sumq = sumq.add(trade.getQuantity(), Constants.MC);
}
if (sumq.compareTo(BigDecimal.ZERO) == 0){
// Not possible divide by zero
return BigDecimal.ZERO;
}else{
return sumtq.divide(sumq, Constants.MC);
}
}
/**
* Use a precision of SCALE decimal for exponential function.
* SCALE is definde in constants.
*
* @return
*/
@Override
public BigDecimal gbce() {
BigDecimal geometric = new BigDecimal(1, Constants.MC), total = new BigDecimal(0);
for(SimpleStock stk: PersistenceMarket.getInstance().getAllStock()){
geometric = geometric.multiply(stockPrice(stk.getSymbol()), Constants.MC);
total = total.add(BigDecimal.ONE);
}
BigDecimal exponent = BigDecimal.ONE.divide(total, Constants.MC);
// z = x^y --> z = exp ( ln(x) * y )
BigDecimal gbce = BigFunctions.exp( BigFunctions.ln(geometric, Constants.SCALE).multiply(exponent), Constants.SCALE );
return gbce;
}
}
| [
"[email protected]"
] | |
09deff5cdcbf5b2edc22237bea398fa212186ae9 | 0bbf9aeadb6fface74435fe1560f3d5811ab4eec | /src/Controller/AddNewStudentController.java | cbffbc4977e5459fc357d89c1ea5cec491162d38 | [] | no_license | Direct-Entry-Program-Dulanga/StudentMS | 7589f65114d68320842bb182425ce92f1262c830 | ca2068a30465ee5c02497a4f06e6b4f363b9b964 | refs/heads/master | 2023-05-10T19:33:18.706626 | 2021-06-01T11:16:33 | 2021-06-01T11:16:33 | 372,736,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 62 | java | package Controller;
public class AddNewStudentController {
}
| [
"[email protected]"
] | |
91f4660f185483aec2aafa2c6c6361021c728bd9 | bc12106d1c0a727cac074bcdfd85f1ed08846519 | /src/main/java/com/example/mbenben/studydemo/anim/swipbackhelper/view/SwipeBackPage.java | ee72e8d6ec2eb563dc0a6b323c2a3c612fa55f3a | [] | no_license | zhiaixinyang/PersonalCollect | 35810b03683725f437006da3613089aa94a436bf | 5f70cfa12275b2c492af66454b6c039a861f3f10 | refs/heads/master | 2021-01-11T20:00:14.080510 | 2018-12-15T09:10:12 | 2018-12-15T09:10:12 | 79,442,513 | 59 | 11 | null | null | null | null | UTF-8 | Java | false | false | 3,605 | java | package com.example.mbenben.studydemo.anim.swipbackhelper.view;
import android.annotation.TargetApi;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.ViewGroup;
/**
* Created by Mr.Jude on 2015/8/3.
* 每个滑动页面的管理
*/
public class SwipeBackPage {
//仅为判断是否需要将mSwipeBackLayout注入进去
private boolean mEnable = true;
private boolean mRelativeEnable = false;
Activity mActivity;
SwipeBackLayout mSwipeBackLayout;
RelateSlider slider;
SwipeBackPage(Activity activity){
this.mActivity = activity;
}
//页面的回调用于配置滑动效果
void onCreate(){
mActivity.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mActivity.getWindow().getDecorView().setBackgroundColor(Color.TRANSPARENT);
mSwipeBackLayout = new SwipeBackLayout(mActivity);
mSwipeBackLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
slider = new RelateSlider(this);
}
void onPostCreate(){
handleLayout();
}
@TargetApi(11)
public SwipeBackPage setSwipeRelateEnable(boolean enable){
mRelativeEnable = enable;
slider.setEnable(enable);
return this;
}
public SwipeBackPage setSwipeRelateOffset(int offset){
slider.setOffset(offset);
return this;
}
//是否可滑动关闭
public SwipeBackPage setSwipeBackEnable(boolean enable) {
mEnable = enable;
mSwipeBackLayout.setEnableGesture(enable);
handleLayout();
return this;
}
private void handleLayout(){
if (mEnable||mRelativeEnable){
mSwipeBackLayout.attachToActivity(mActivity);
}else {
mSwipeBackLayout.removeFromActivity(mActivity);
}
}
//可滑动的范围。百分比。200表示为左边200px的屏幕
public SwipeBackPage setSwipeEdge(int swipeEdge){
mSwipeBackLayout.setEdgeSize(swipeEdge);
return this;
}
//可滑动的范围。百分比。0.2表示为左边20%的屏幕
public SwipeBackPage setSwipeEdgePercent(float swipeEdgePercent){
mSwipeBackLayout.setEdgeSizePercent(swipeEdgePercent);
return this;
}
//对横向滑动手势的敏感程度。0为迟钝 1为敏感
public SwipeBackPage setSwipeSensitivity(float sensitivity){
mSwipeBackLayout.setSensitivity(mActivity, sensitivity);
return this;
}
//底层阴影颜色
public SwipeBackPage setScrimColor(int color){
mSwipeBackLayout.setScrimColor(color);
return this;
}
//触发关闭Activity百分比
public SwipeBackPage setClosePercent(float percent){
mSwipeBackLayout.setScrollThreshold(percent);
return this;
}
public SwipeBackPage setDisallowInterceptTouchEvent(boolean disallowIntercept){
mSwipeBackLayout.setDisallowInterceptTouchEvent(disallowIntercept);
return this;
}
public SwipeBackPage addListener(SwipeListener listener){
mSwipeBackLayout.addSwipeListener(listener);
return this;
}
public SwipeBackPage removeListener(SwipeListener listener){
mSwipeBackLayout.removeSwipeListener(listener);
return this;
}
public SwipeBackLayout getSwipeBackLayout() {
return mSwipeBackLayout;
}
public void scrollToFinishActivity() {
mSwipeBackLayout.scrollToFinishActivity();
}
}
| [
"[email protected]"
] | |
cc9b081b6b7755fcd54c3291b24e32b3eaf0112e | 3e6b8cbac56c43947cce053286bed6be4cd17496 | /data/src/main/java/com/calabashCat/android/sample/data/executor/UIThread.java | fd73d1866eaadae03f13d8c3fc070341e72a4d99 | [
"Apache-2.0"
] | permissive | BitTigerInst/calabashCat | 74652f596be962a64a503e1a2a89fc71f38080a6 | 02bf7f0631e6c07d855468b8eaaa705026cbc9a1 | refs/heads/master | 2021-01-13T00:59:19.839011 | 2016-03-11T09:35:53 | 2016-03-11T09:35:53 | 51,179,144 | 5 | 3 | null | 2016-03-06T10:22:01 | 2016-02-05T22:51:46 | Java | UTF-8 | Java | false | false | 1,069 | java | /**
* Copyright (C) 2015 Fernando Cejas Open Source Project
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.calabashCat.android.sample.data.executor;
import rx.Scheduler;
import rx.android.schedulers.AndroidSchedulers;
/**
* MainThread (UI Thread) implementation based on a {@link rx.Scheduler}
* which will execute actions on the Android UI thread
*/
public class UIThread implements PostExecutionThread {
public UIThread() {
}
@Override
public Scheduler getScheduler() {
return AndroidSchedulers.mainThread();
}
}
| [
"[email protected]"
] | |
db14c7ef6c6209cc10dd00bbb0680ca774960b1b | 84609ef7eeae1ff118260255b3513f93cee530f7 | /app/src/main/java/ucai/cn/fulicter/adapter/CollectsAdapter.java | 947649b2352da1c2f06902450e4f9a8dbffb966a | [] | no_license | huaxiaojii/Fulicenter | 450540838babf90cb55bf7ec202f9d8abc380012 | 0899aaa09399be74089dc342961bcc5d985863ff | refs/heads/master | 2021-01-11T00:00:51.298857 | 2016-10-31T01:13:59 | 2016-10-31T01:13:59 | 70,772,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,426 | java | package ucai.cn.fulicter.adapter;
/**
* Created by User on 2016/10/26.
*/
import android.content.Context;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.ucai.fulicenter.R;
import ucai.cn.fulicter.FuLiCenterApplication;
import ucai.cn.fulicter.I;
import ucai.cn.fulicter.bean.CollectBean;
import ucai.cn.fulicter.bean.MessageBean;
import ucai.cn.fulicter.net.NetDao;
import ucai.cn.fulicter.net.OkHttpUtils;
import ucai.cn.fulicter.utils.CommonUtils;
import ucai.cn.fulicter.utils.ImageLoader;
import ucai.cn.fulicter.utils.L;
import ucai.cn.fulicter.utils.MFGT;
import ucai.cn.fulicter.view.FooterViewHolder;
public class CollectsAdapter extends Adapter {
Context mContext;
List<CollectBean> mList;
boolean isMore;
int soryBy = I.SORT_BY_ADDTIME_DESC;
public CollectsAdapter(Context context, List<CollectBean> list) {
mContext = context;
mList = new ArrayList<>();
mList.addAll(list);
}
public void setSoryBy(int soryBy) {
this.soryBy = soryBy;
notifyDataSetChanged();
}
public boolean isMore() {
return isMore;
}
public void setMore(boolean more) {
isMore = more;
notifyDataSetChanged();
}
public void remove(CollectBean bean) {
mList.remove(bean);
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ViewHolder holder = null;
if (viewType == I.TYPE_FOOTER) {
holder = new FooterViewHolder(View.inflate(mContext, R.layout.item_footer, null));
} else {
holder = new ColelctsViewHolder(View.inflate(mContext, R.layout.item_collects, null));
}
return holder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
if(getItemViewType(position)==I.TYPE_FOOTER){
FooterViewHolder vh = (FooterViewHolder) holder;
vh.mtvFooter.setText(String.valueOf(getFootString()));
}else{
ColelctsViewHolder vh = (ColelctsViewHolder) holder;
CollectBean goods = mList.get(position);
ImageLoader.downloadImg(mContext,vh.mIvGoodsThumb,goods.getGoodsThumb());
vh.mTvGoodsName.setText(goods.getGoodsName());
vh.mLayoutGoods.setTag(goods.getGoodsId());
vh.mLayoutGoods.setTag(goods);
}
}
private int getFootString() {
return isMore?R.string.load_more:R.string.no_more;
}
@Override
public int getItemCount() {
return mList != null ? mList.size() + 1 : 1;
}
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return I.TYPE_FOOTER;
}
return I.TYPE_ITEM;
}
public void initData(ArrayList<CollectBean> list) {
if(mList!=null){
mList.clear();
}
mList.addAll(list);
notifyDataSetChanged();
}
public void addData(ArrayList<CollectBean> list) {
mList.addAll(list);
notifyDataSetChanged();
}
class ColelctsViewHolder extends ViewHolder{
@BindView(R.id.ivGoodsThumb)
ImageView mIvGoodsThumb;
@BindView(R.id.tvGoodsName)
TextView mTvGoodsName;
@BindView(R.id.iv_collect_del)
ImageView mIvCollectDel;
@BindView(R.id.layout_goods)
RelativeLayout mLayoutGoods;
ColelctsViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
@OnClick(R.id.layout_goods)
public void onGoodsItemClick(){
// int goodsId = (int) mLayoutGoods.getTag();
// MFGT.gotoGoodsDetailsActivity(mContext,goodsId);
CollectBean goods = (CollectBean) mLayoutGoods.getTag();
MFGT.gotoGoodsDetailsActivity(mContext,goods.getGoodsId());
}
@OnClick(R.id.iv_collect_del)
public void deleteCollect(){
final CollectBean goods = (CollectBean) mLayoutGoods.getTag();
String username = FuLiCenterApplication.getUser().getMuserName();
NetDao.deleteCollect(mContext, username, goods.getGoodsId(), new OkHttpUtils.OnCompleteListener<MessageBean>() {
@Override
public void onSuccess(MessageBean result) {
if(result!=null && result.isSuccess()){
mList.remove(goods);
notifyDataSetChanged();
}else{
CommonUtils.showLongToast(result!=null?result.getMsg():
mContext.getResources().getString(R.string.delete_collect_fail));
}
}
@Override
public void onError(String error) {
L.e("error="+error);
CommonUtils.showLongToast(mContext.getResources().getString(R.string.delete_collect_fail));
}
});
}
}
} | [
"[email protected]"
] | |
6f2f584f47568e0091ad4762bef5cbf08b36dfe9 | dfa1b897529378f5bfc046a0c6d7eb798aec3149 | /test/ekraft/javabrake/JavaBrakeTest.java | 54df2248c08f6fd2540f8fe6ff59f33ef3359c9a | [
"MIT"
] | permissive | Gigafrosty/JavaBrake | 234948addadacc64f85d20d1bd417eba4a7496ad | 7faabb50a2beee07f000f3c7aed1c78f3d03810e | refs/heads/master | 2020-04-23T12:52:55.655676 | 2015-08-30T08:26:44 | 2015-08-30T08:26:44 | 41,612,382 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,310 | java | package ekraft.javabrake;
import ekraft.javabrake.db.Disc;
import ekraft.javabrake.db.Title;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
/**
* Created by ekraft on 8/30/15
*/
public class JavaBrakeTest {
@Test
public void testSwordArtOnline2Volume1Disc1() {
Disc disc = JavaBrake.convertToDisc("Sword Art Online 2 Volume 1 Disc 1", "+ title 1:\n" +
" + Main Feature\n" +
" + vts 1, ttn 1, cells 0->17 (2014372 blocks)\n" +
" + duration: 01:11:07\n" +
" + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 23.976 fps\n" +
" + autocrop: 0/0/0/0\n" +
" + support opencl: no\n" +
" + support hwd: not built-in\n" +
" + chapters:\n" +
" + 1: cells 0->0, 100610 blocks, duration 00:03:22\n" +
" + 2: cells 1->1, 145020 blocks, duration 00:05:06\n" +
" + 3: cells 2->2, 379884 blocks, duration 00:13:36\n" +
" + 4: cells 3->3, 45528 blocks, duration 00:01:30\n" +
" + 5: cells 4->4, 3152 blocks, duration 00:00:07\n" +
" + 6: cells 5->5, 52560 blocks, duration 00:01:53\n" +
" + 7: cells 6->6, 44297 blocks, duration 00:01:30\n" +
" + 8: cells 7->7, 255265 blocks, duration 00:09:07\n" +
" + 9: cells 8->8, 270449 blocks, duration 00:09:34\n" +
" + 10: cells 9->9, 46850 blocks, duration 00:01:30\n" +
" + 11: cells 10->10, 3122 blocks, duration 00:00:07\n" +
" + 12: cells 11->11, 12291 blocks, duration 00:00:27\n" +
" + 13: cells 12->12, 44428 blocks, duration 00:01:30\n" +
" + 14: cells 13->13, 332539 blocks, duration 00:12:01\n" +
" + 15: cells 14->14, 225660 blocks, duration 00:08:06\n" +
" + 16: cells 15->15, 46858 blocks, duration 00:01:30\n" +
" + 17: cells 16->17, 5859 blocks, duration 00:00:13\n" +
" + audio tracks:\n" +
" + 1, English (AC3) (2.0 ch) (iso639-2: eng), 48000Hz, 384000bps\n" +
" + 2, Japanese (AC3) (2.0 ch) (iso639-2: jpn), 48000Hz, 384000bps\n" +
" + subtitle tracks:\n" +
" + 1, English (iso639-2: eng) (Bitmap)(VOBSUB)\n" +
" + 2, English (iso639-2: eng) (Bitmap)(VOBSUB)\n" +
" + 3, Espanol (iso639-2: spa) (Bitmap)(VOBSUB)\n" +
"+ title 2:\n" +
" + vts 2, ttn 1, cells 0->0 (43585 blocks)\n" +
" + duration: 00:01:32\n" +
" + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 23.976 fps\n" +
" + autocrop: 0/0/0/0\n" +
" + support opencl: no\n" +
" + support hwd: not built-in\n" +
" + chapters:\n" +
" + 1: cells 0->0, 43585 blocks, duration 00:01:32\n" +
" + audio tracks:\n" +
" + 1, Japanese (AC3) (2.0 ch) (iso639-2: jpn), 48000Hz, 384000bps\n" +
" + subtitle tracks:\n" +
"\n");
assertEquals("Sword Art Online 2 Volume 1 Disc 1", disc.getName());
assertTrue(disc.isDvd());
assertEquals(2, disc.getTitles().size());
Title title1 = disc.getTitles().get(0);
assertEquals(1, title1.getIndex());
assertEquals(1, title1.getAngles());
assertTrue(title1.isMainFeature());
assertEquals(4267, title1.getDuration());
assertEquals(Arrays.asList(202, 306, 816, 90, 7, 113, 90, 547, 574, 90, 7, 27, 90, 721, 486, 90, 13),
title1.getChapters());
assertEquals(Arrays.asList("English", "English", "Espanol"), title1.getSubtitleTracks());
assertEquals(2, title1.getAudioTracks().size());
assertEquals(1, title1.getAudioTracks().get(0).getIndex());
assertEquals("English", title1.getAudioTracks().get(0).getLanguage());
assertEquals(2.0, title1.getAudioTracks().get(0).getChannels());
assertEquals(2, title1.getAudioTracks().get(1).getIndex());
assertEquals("Japanese", title1.getAudioTracks().get(1).getLanguage());
assertEquals(2.0, title1.getAudioTracks().get(1).getChannels());
Title title2 = disc.getTitles().get(1);
assertEquals(2, title2.getIndex());
assertEquals(1, title2.getAngles());
assertFalse(title2.isMainFeature());
assertEquals(92, title2.getDuration());
assertEquals(Collections.singletonList(92), title2.getChapters());
assertEquals(new ArrayList<>(), title2.getSubtitleTracks());
assertEquals(1, title2.getAudioTracks().size());
assertEquals(1, title2.getAudioTracks().get(0).getIndex());
assertEquals("Japanese", title2.getAudioTracks().get(0).getLanguage());
assertEquals(2.0, title2.getAudioTracks().get(0).getChannels());
}
@Test
public void test20MillionMilesToEarthDisc1() {
Disc disc = JavaBrake.convertToDisc("20 Million Miles to Earth (Disc 1)", "+ title 2:\n" +
" + vts 2, ttn 1, cells 0->32 (3321668 blocks)\n" +
" + angle(s) 2\n" +
" + duration: 01:22:27\n" +
" + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 29.970 fps\n" +
" + autocrop: 6/10/0/0\n" +
" + support opencl: no\n" +
" + support hwd: not built-in\n" +
" + chapters:\n" +
" + 1: cells 0->1, 171664 blocks, duration 00:03:38\n" +
" + 2: cells 2->3, 271740 blocks, duration 00:05:47\n" +
" + 3: cells 4->5, 327567 blocks, duration 00:08:17\n" +
" + 4: cells 6->7, 163747 blocks, duration 00:04:22\n" +
" + 5: cells 8->9, 186870 blocks, duration 00:04:57\n" +
" + 6: cells 10->11, 178400 blocks, duration 00:04:50\n" +
" + 7: cells 12->13, 204418 blocks, duration 00:05:31\n" +
" + 8: cells 14->15, 297170 blocks, duration 00:07:49\n" +
" + 9: cells 16->17, 171401 blocks, duration 00:04:50\n" +
" + 10: cells 18->19, 317947 blocks, duration 00:06:51\n" +
" + 11: cells 20->21, 244054 blocks, duration 00:06:56\n" +
" + 12: cells 22->23, 169773 blocks, duration 00:04:10\n" +
" + 13: cells 24->25, 152584 blocks, duration 00:03:34\n" +
" + 14: cells 26->27, 117534 blocks, duration 00:02:51\n" +
" + 15: cells 28->29, 176722 blocks, duration 00:04:13\n" +
" + 16: cells 30->31, 169323 blocks, duration 00:03:50\n" +
" + 17: cells 32->32, 754 blocks, duration 00:00:02\n" +
" + audio tracks:\n" +
" + 1, English (AC3) (2.0 ch) (iso639-2: eng), 48000Hz, 192000bps\n" +
" + 2, English (AC3) (Director's Commentary 1) (2.0 ch) (iso639-2: eng), 48000Hz, 192000bps\n" +
" + subtitle tracks:\n" +
" + 1, English (iso639-2: eng) (Bitmap)(VOBSUB)\n" +
" + 2, Francais (iso639-2: fra) (Bitmap)(VOBSUB)\n" +
" + 3, Closed Captions (iso639-2: eng) (Text)(CC)\n" +
"+ title 5:\n" +
" + vts 4, ttn 1, cells 0->0 (4391 blocks)\n" +
" + duration: 00:00:14\n" +
" + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 29.970 fps\n" +
" + autocrop: 0/2/0/10\n" +
" + support opencl: no\n" +
" + support hwd: not built-in\n" +
" + chapters:\n" +
" + 1: cells 0->0, 4204 blocks, duration 00:00:14\n" +
" + 2: cells 0->0, 187 blocks, duration 00:00:01\n" +
" + audio tracks:\n" +
" + 1, Unknown (AC3) (5.1 ch) (iso639-2: und), 48000Hz, 448000bps\n" +
" + subtitle tracks:\n" +
"+ title 10:\n" +
" + vts 8, ttn 1, cells 0->1 (5513 blocks)\n" +
" + duration: 00:00:17\n" +
" + size: 720x480, pixel aspect: 32/27, display aspect: 1.78, 29.970 fps\n" +
" + autocrop: 66/72/0/0\n" +
" + support opencl: no\n" +
" + support hwd: not built-in\n" +
" + chapters:\n" +
" + 1: cells 0->0, 5326 blocks, duration 00:00:17\n" +
" + 2: cells 1->1, 187 blocks, duration 00:00:01\n" +
" + audio tracks:\n" +
" + 1, Unknown (AC3) (2.0 ch) (iso639-2: und), 48000Hz, 192000bps\n" +
" + subtitle tracks:\n");
assertEquals("20 Million Miles to Earth (Disc 1)", disc.getName());
assertTrue(disc.isDvd());
assertEquals(3, disc.getTitles().size());
Title title1 = disc.getTitles().get(0);
assertEquals(2, title1.getIndex());
assertEquals(2, title1.getAngles());
assertFalse(title1.isMainFeature());
assertEquals(4947, title1.getDuration());
assertEquals(Arrays.asList(218, 347, 497, 262, 297, 290, 331, 469, 290, 411, 416, 250, 214, 171, 253, 230, 2),
title1.getChapters());
assertEquals(Arrays.asList("English", "Francais", "Closed Captions"), title1.getSubtitleTracks());
assertEquals(2, title1.getAudioTracks().size());
assertEquals(1, title1.getAudioTracks().get(0).getIndex());
assertEquals("English", title1.getAudioTracks().get(0).getLanguage());
assertEquals(2.0, title1.getAudioTracks().get(0).getChannels());
assertEquals(2, title1.getAudioTracks().get(1).getIndex());
assertEquals("English", title1.getAudioTracks().get(1).getLanguage());
assertEquals(2.0, title1.getAudioTracks().get(1).getChannels());
Title title2 = disc.getTitles().get(1);
assertEquals(5, title2.getIndex());
assertEquals(1, title2.getAngles());
assertFalse(title2.isMainFeature());
assertEquals(14, title2.getDuration());
assertEquals(Arrays.asList(14, 1),
title2.getChapters());
assertEquals(new ArrayList<String>(), title2.getSubtitleTracks());
assertEquals(1, title2.getAudioTracks().size());
assertEquals(1, title2.getAudioTracks().get(0).getIndex());
assertEquals("Unknown", title2.getAudioTracks().get(0).getLanguage());
assertEquals(5.1, title2.getAudioTracks().get(0).getChannels());
Title title3 = disc.getTitles().get(2);
assertEquals(10, title3.getIndex());
assertEquals(1, title3.getAngles());
assertFalse(title3.isMainFeature());
assertEquals(17, title3.getDuration());
assertEquals(Arrays.asList(17, 1), title3.getChapters());
assertEquals(new ArrayList<String>(), title3.getSubtitleTracks());
assertEquals(1, title3.getAudioTracks().size());
assertEquals(1, title3.getAudioTracks().get(0).getIndex());
assertEquals("Unknown", title3.getAudioTracks().get(0).getLanguage());
assertEquals(2.0, title3.getAudioTracks().get(0).getChannels());
}
} | [
"[email protected]"
] | |
5c5e6fbbb53a7fb48bacab1893aa00a45728673c | 72d13850e4ff2fb0b1740153615820018a6676eb | /src/main/java/pl/edu/wat/backend/services/UserDetailsServiceImpl.java | 2d17d03edb4126211e0e8ca321cbd0a8b57dd9a1 | [] | no_license | mateuszjwat/web-backend | c62e4ffb223b90155ec44078c11ddc526d3db66b | 5601c205c1d89b5ca3567bad9976cca083e08207 | refs/heads/master | 2023-06-09T08:12:57.487184 | 2021-06-24T19:02:03 | 2021-06-24T19:02:03 | 372,816,877 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,012 | java | package pl.edu.wat.backend.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pl.edu.wat.backend.entities.UserImpl;
import pl.edu.wat.backend.repositories.UserRepository;
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
UserRepository userRepository;
@Override
@Transactional
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserImpl userImpl = userRepository.findUserByUsername(username)
.orElseThrow(() -> new UsernameNotFoundException("UserImpl Not Found with username: " + username));
return userImpl;
}
}
| [
"[email protected]"
] | |
e3796591f0821c7475b82e1ad21f7df331030ee8 | e09e3c31934628241b73baf7cce31fd06e274907 | /plugin/src/main/java/io/dazraf/vertx/maven/compiler/Compiler.java | d9720de1fc99286f4d74eeeea2e03ef26fc808cb | [
"MIT"
] | permissive | illuminace/vertx-hot | cd298e653b9bd295e05679fb04d569853da78d43 | c62cbaef57fc434ede0ccaea472c45410d69c463 | refs/heads/master | 2021-01-21T04:08:46.171190 | 2015-12-03T18:42:33 | 2015-12-03T18:42:33 | 44,908,596 | 0 | 0 | null | 2015-10-25T12:12:23 | 2015-10-25T12:12:23 | null | UTF-8 | Java | false | false | 3,433 | java | package io.dazraf.vertx.maven.compiler;
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.invoker.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* This class represents the primary interaction with the Maven runtime to build the project
*/
public class Compiler {
private static final Logger logger = LoggerFactory.getLogger(Compiler.class);
private static final Pattern ERROR_PATTERN = Pattern.compile("\\[ERROR\\] [^:]+:\\[\\d+,\\d+\\].*");
private static final Pattern DEPENDENCY_RESOLUTION_PATTERN = Pattern.compile("^\\[INFO\\].*:compile:(.*)$");
private static final List<String> GOALS = Collections.singletonList("dependency:resolve compile");
private final Properties compilerProperties = new Properties();
public Compiler() {
compilerProperties.setProperty("outputAbsoluteArtifactFilename", "true");
}
/**
* Compile the maven project, returning the list of classpath paths as reported by maven
*
* @param project This is the top level maven project that was provided by the maven run time when the plugin was invoked
* @return the result of compilation containing the classpaths etc
* @throws CompilerException for any compiler errors
* @throws MavenInvocationException for any unexpected maven invocation errors
*/
public CompileResult compile(MavenProject project) throws CompilerException, MavenInvocationException {
List<String> classPath = new ArrayList<>();
// precendence to load from the resources folders rather than the build
project.getResources().stream().map(Resource::getDirectory).forEach(classPath::add);
classPath.add(project.getBuild().getOutputDirectory());
Set<String> messages = new HashSet<>();
InvocationRequest request = setupInvocationRequest(project, classPath, messages);
return execute(request, messages, classPath);
}
private CompileResult execute(InvocationRequest request, Set<String> messages, List<String> classPath) throws CompilerException, MavenInvocationException {
try {
InvocationResult result = new DefaultInvoker().execute(request);
if (result.getExitCode() != 0) {
logger.error("Error with exit code {}", result.getExitCode());
throw new CompilerException(result.getExitCode(), messages);
}
return new CompileResult(classPath);
} catch (MavenInvocationException e) {
logger.error("Maven invocation exception:", e);
throw e;
}
}
private InvocationRequest setupInvocationRequest(MavenProject project, List<String> classPath, Set<String> messages) {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(project.getFile());
request.setOutputHandler(msg -> collectResults(msg, messages, classPath));
request.setGoals(GOALS);
request.setProperties(compilerProperties);
return request;
}
private void collectResults(String msg, Set<String> messages, List<String> classPath) {
Matcher matcher = DEPENDENCY_RESOLUTION_PATTERN.matcher(msg);
if (matcher.matches()) {
String dependency = matcher.group(1);
classPath.add(dependency);
}
if (ERROR_PATTERN.matcher(msg).matches()) {
System.out.println(msg);
messages.add(msg);
}
}
}
| [
"[email protected]"
] | |
3410b933bcf350e7747891e1a6f67e00e5eff90a | 1467876aa95046f802cc29a1a523dd8699f91bb0 | /src/main/java/com/wfh/controller/MainController.java | 91e6bca5968f73dcd72530e038dda4f5f0187ba4 | [] | no_license | My-Heaven/Chamilo | b42155b1e103c64269e5300b0c2ed5d1dc418324 | 2509aa8862c0438a3294f2fc8c2d9a7f76200ab0 | refs/heads/master | 2023-06-27T05:30:11.353423 | 2021-07-27T06:42:18 | 2021-07-27T06:42:18 | 388,067,473 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,255 | java | package com.wfh.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.wfh.dao.UserDAO;
import com.wfh.dao.UserInfoDAO;
import com.wfh.model.User;
import com.wfh.model.UserInfo;
@Controller
public class MainController {
@Autowired
private UserDAO UserDAO;
@Autowired
private UserInfoDAO UserInfoDAO;
@RequestMapping("/")
public String loadApp() {
return "index";
}
@RequestMapping("/AdminPage")
public String adminPage() {
return "AdminPage";
}
@RequestMapping("/StudentPage")
public String studentPage() {
return "StudentPage";
}
@RequestMapping("/TeacherPage")
public String teacherPage() {
return "TeacherPage";
}
@RequestMapping("/CreateUserPage")
public String createUserPage() {
return "CreateUserPage";
}
@RequestMapping("/UpdatePage")
public String updateUserPage(HttpServletRequest request) {
int id= Integer.parseInt(request.getParameter("ids"));
UserInfo user = UserInfoDAO.findUserById(id);
request.setAttribute("u", user);
return "UpdatePage";
}
@RequestMapping("/login")
public String login(HttpServletRequest request) {
HttpSession session = request.getSession();
String username = request.getParameter("username");
String password = request.getParameter("password");
if (null!=username & !username.isEmpty() & null!=password & !password.isEmpty()) {
User u = UserDAO.findUser(username, password);
if (u != null) {
if (u.getRole_id() == 1) {
UserInfo user = UserInfoDAO.findUserById(u.getId());
session.setAttribute("user", user);
return "AdminPage";
} else if (u.getRole_id() == 2) {
return "TeacherPage";
} else if (u.getRole_id() == 3) {
return "StudentPage";
}
}
}
return "index";
}
@RequestMapping("/logout")
public String logout(HttpServletRequest request) {
HttpSession session = request.getSession();
session.invalidate();
return "index";
}
@RequestMapping("/list-user")
public String listUser(HttpServletRequest request) {
List<UserInfo> listUser = UserInfoDAO.getListUser();
request.setAttribute("LISTUSER", listUser);
return "FindPage";
}
@RequestMapping("/create-user")
public String createNewUser(HttpServletRequest request) {
String username =request.getParameter("username");
String password =request.getParameter("password");
String lastname =request.getParameter("lastname");
String firstname =request.getParameter("firstname");
String email =request.getParameter("email");
String role_id =request.getParameter("role_id");
String phone = request.getParameter("phone");
String code = request.getParameter("code");
UserInfoDAO.createUser(code, username, password, email, lastname, firstname, phone, role_id);
return "AdminPage";
}
@RequestMapping("/search-by-id")
public String searchById(HttpServletRequest request) {
String searchValue = request.getParameter("searchValue");
List<UserInfo> listUser = UserInfoDAO.searchUserById(searchValue);
request.setAttribute("LISTUSER", listUser);
return "FindPage";
}
@RequestMapping("/update-user")
public String updateUser(HttpServletRequest request) {
String username =request.getParameter("username");
String password =request.getParameter("password");
String lastname =request.getParameter("lastname");
String firstname =request.getParameter("firstname");
String email =request.getParameter("email");
String role_id =request.getParameter("role_id");
String id = request.getParameter("id");
UserInfoDAO.updateUserById(username, password, email, lastname, firstname, role_id, id);
//--------
List<UserInfo> listUser = UserInfoDAO.getListUser();
request.setAttribute("LISTUSER", listUser);
return "FindPage";
}
@RequestMapping("/delete-user")
public String deleteUser(HttpServletRequest request) {
int id = Integer.parseInt(request.getParameter("ids"));
UserInfoDAO.deleteUser(id);
//-------
List<UserInfo> listUser = UserInfoDAO.getListUser();
request.setAttribute("LISTUSER", listUser);
return "FindPage";
}
}
| [
"[email protected]"
] | |
21388132fa394d594ab7e7e7851b4c840d08f733 | 2e51d94f48da1472a7f0cc9dc411c10822c5f856 | /src/test/java/com/mycompany/myapp/selenium/LoginPageObject.java | b9bcc6312c22fa9d30a70b372b98b23c9d2b1d06 | [] | no_license | BulkSecurityGeneratorProject/fauxshop-angular1 | baf2632b6c204e1ce5746fae7219470eaa92cf4f | 14f9b3012374356263f0eb0cda57a876ab22e003 | refs/heads/master | 2022-12-16T17:27:18.292166 | 2018-03-27T03:26:07 | 2018-03-27T03:26:07 | 296,549,286 | 0 | 0 | null | 2020-09-18T07:39:23 | 2020-09-18T07:39:22 | null | UTF-8 | Java | false | false | 717 | java | package com.mycompany.myapp.selenium;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class LoginPageObject {
private WebDriver driver;
private static WebElement element = null;
private static By loginTitle = By.id("loginTitle");
public LoginPageObject(WebDriver driver) {
this.driver = driver;
}
public WebElement loginTitle(WebDriver driver){
element = driver.findElement(loginTitle);
return element;
}
public boolean verifyLoginTitle() {
String loginTitleText = "Sign in";
return loginTitle(driver).getText().contains(loginTitleText);
}
}
| [
"[email protected]"
] | |
cfbfff173e041d6a99ee5ac72fbd7c545f7f469b | cdab7a5f358b8a15439827fb001cb838a6d30f56 | /src/com/sonic/juc/Lock8Demo05.java | 10e101384bc20a22010d2a72a2b60e0b7bf0acb9 | [] | no_license | SonicXia/lianxi | bd82d6b84a191345ea36c58d9e9b7dcaf429f9bd | 35b125f1aebfb95b9dac667dfb2d1753b4d3b1f0 | refs/heads/master | 2020-12-03T21:02:16.949155 | 2020-02-25T01:22:34 | 2020-02-25T01:22:34 | 231,486,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,242 | java | package com.sonic.juc;
import java.util.concurrent.TimeUnit;
class Phone {
public static synchronized void sendEmail() throws InterruptedException {
TimeUnit.SECONDS.sleep(3);
System.out.println("*****sendEmail");
}
public static synchronized void sendSMS() {
System.out.println("*****sendSMS");
}
public void sayHello() {
System.out.println("*****sayHello");
}
}
/**
* 8 lock
*
*1 标准访问,请问先打印邮件还是短信?[对象锁](*****sendEmail*****sendSMS)
*2 暂停4秒在邮件方法中,请问先打印邮件还是短信?[对象锁](抱着资源睡,*****sendEmail*****sendSMS)
*3 新增普通 sayHello方法,请问先打印邮件还是短信?[对象锁](普通方法不加锁,各执行各的,互不影响)
*4 两部手机,请问先打印邮件还是短信?[对象锁](两个不同实例对象,各执行各的,互不影响)
*5 两个静态同步方法,同一部手机,请问先打印邮件还是短信?[类锁](*****sendEmail*****sendSMS)
*6 两个静态同步方法,2部手机请问先打印邮件还是短信?[类锁](*****sendEmail*****sendSMS)
*7 1个静态同步方法,1个普通同步方法,同一部手机请问先打印邮件还是短信?(锁的对象不同[类锁、对象锁]。各执行各的,互不影响)
*8 1个静态同步方法,1个普通同步方法,2部手机请问先打印邮件还是短信?(锁的对象不同[类锁、对象锁]。各执行各的,互不影响)
*
* 笔记:
* (1~2)一个对象里面如果有多个 synchronized方法,某个时刻内,只要一个线程去调用其中的一个 synchronized方法了,
* 其他的线程都只能等待,换句话说,某一时刻内,只能有唯一一个线程去访问这些 synchronized方法。
* 锁的是当前对象 this,被锁定后,其他的线程都不能进入到当前对象的其他的 synchronized方法。
* (synchronized方法只影响所在对象中的其他 synchronized方法)
* (3)加个普通方法后发现和同步锁无关。
* (4)换成两个对象后,不是同一把(对象)锁了,情况立刻变化。
* (1~4)synchronized实现同步的基础:Java中的每一个对象都可以作为锁。
* 具体表现为以下三种形式:
* 1、对于普通同步方法,锁的是当前实例对象(this);
* 2、对于同步方法块,锁的是 Synchronized括号里配置的对象;
* (5~6)3、对于静态同步方法,锁的是当前类的 Class对象。
*
* 当一个线程试图访问同步代码块时,它首先必须得到锁,退出或抛出异常时必须释放锁。
*
* 也就是说,如果一个实例对象的非静态同步方法获取锁后,该实例对象的其他非静态同步方法必须等待获取锁
* 的方法释放锁后才能获取锁,可是别的实例对象的非静态同步方法因为跟该实例对象的非静态同步方法用的是不同的锁,
* 所以无须等待该实例对象释放锁就可以获取它们自己的锁。
*
* 所有的静态同步方法用的也是用一把锁 --> 类对象本身(Class)
* (7~8)这两把锁是两个不同的对象,所以静态同步方法与非静态同步方法之间是不会有竞态条件的。
* 但是一旦一个静态同步方法获取锁后,其他的静态同步方法都必须等待该方法释放锁后才能获取锁(锁的都是Class对象),
* 不论是否是同一个实例对象的静态同步方法之间(phone1),
* 还是不同的实例对象的静态同步方法之间(phone1与phone2),只要它们是同一个类(Class)的实例对象。
*
* this:当前对象锁
* Class:全局锁(类锁)
*
* @author Sonic
*/
public class Lock8Demo05 {
public static void main(String[] args) throws Exception {
Phone phone = new Phone();
Phone phone2 = new Phone();
new Thread(() -> {
try {
phone.sendEmail();
} catch (Exception e) {
e.printStackTrace();
}
}, "A").start();
TimeUnit.MILLISECONDS.sleep(100);
new Thread(() -> {
try {
// phone.sendSMS();
// phone.sayHello();
phone2.sendSMS();
} catch (Exception e) {
e.printStackTrace();
}
}, "B").start();
}
}
| [
"[email protected]"
] | |
2723089b8e3d44e0d3079b847826473f2575c873 | a7a28039a642232a849922882419ed26f161be06 | /app/src/main/java/com/app/thinkfit/ui/auth/sign_up/survey_strengthen/SurveyStrengthenActivity.java | 3e14e9804ef41ae9b9eaf47f1ea117aa7148fe92 | [] | no_license | cmFodWx5YWRhdjEyMTA5/ThinkFit-Android-2018 | 0ce257ee52f026e0cea30a4ec47700dcbf35c5de | cf8fc92915d807d0ea59fccd3073be299367364e | refs/heads/master | 2020-03-30T07:21:47.095137 | 2018-06-12T16:21:17 | 2018-06-12T16:21:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,988 | java | package com.app.thinkfit.ui.auth.sign_up.survey_strengthen;
/*
* Copyright Ⓒ 2018. All rights reserved
* Author DangTin. Create on 2018/05/20
*/
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.app.thinkfit.R;
import com.app.thinkfit.constant.Constant;
import com.app.thinkfit.constant.GlobalFuntion;
import com.app.thinkfit.ui.base.BaseMVPDialogActivity;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class SurveyStrengthenActivity extends BaseMVPDialogActivity implements SurveyStrengthenMVPView {
@Inject
SurveyStrengthenPresenter presenter;
@BindView(R.id.tv_question_survey_strengthen)
TextView tvQuestionSurveyStrengthen;
@BindView(R.id.rdg_strengthen)
RadioGroup rdgStrengthen;
@BindView(R.id.rdb1)
RadioButton rdb1;
@BindView(R.id.rdb2)
RadioButton rdb2;
@BindView(R.id.rdb3)
RadioButton rdb3;
@BindView(R.id.img_back)
ImageView imgBack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
viewUnbind = ButterKnife.bind(this);
presenter.initialView(this);
imgBack.setVisibility(View.VISIBLE);
loadData();
onClickSelectMode();
}
@Override
protected boolean bindView() {
return true;
}
@Override
protected int addContextView() {
return R.layout.activity_survey_strengthen;
}
@Override
protected void onDestroy() {
presenter.destroyView();
super.onDestroy();
}
@Override
public void showNoNetworkAlert() {
showAlert(getString(R.string.error_not_connect_to_internet));
}
@Override
public void onErrorCallApi(int code) {
GlobalFuntion.showMessageError(this, code);
}
private void loadData() {
Spannable question_1 = new SpannableString(getString(R.string.question_survey_strengthen_1));
tvQuestionSurveyStrengthen.setText(question_1);
tvQuestionSurveyStrengthen.append(" ");
Spannable question_2 = new SpannableString(getString(R.string.strengthen_));
ClickableSpan clickStrengthen = new ClickableSpan() {
@Override
public void onClick(View textView) {
GlobalFuntion.showDialogDescription(
SurveyStrengthenActivity.this,
"Hi, thank you. I set its gravity to top, the dialog goes on the");
}
@Override
public void updateDrawState(TextPaint textPaint) {
textPaint.setColor(getResources().getColor(R.color.orange));
}
};
question_2.setSpan(clickStrengthen, 0, question_2.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tvQuestionSurveyStrengthen.append(question_2);
tvQuestionSurveyStrengthen.append(" ");
Spannable question_3 = new SpannableString(getString(R.string.question_survey_strengthen_2));
tvQuestionSurveyStrengthen.append(question_3);
tvQuestionSurveyStrengthen.setMovementMethod(LinkMovementMethod.getInstance());
}
private void onClickSelectMode() {
rdgStrengthen.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rdb1:
rdb1.setTextColor(getResources().getColor(R.color.orange));
rdb2.setTextColor(getResources().getColor(R.color.black));
rdb3.setTextColor(getResources().getColor(R.color.black));
break;
case R.id.rdb2:
rdb2.setTextColor(getResources().getColor(R.color.orange));
rdb1.setTextColor(getResources().getColor(R.color.black));
rdb3.setTextColor(getResources().getColor(R.color.black));
break;
case R.id.rdb3:
rdb3.setTextColor(getResources().getColor(R.color.orange));
rdb1.setTextColor(getResources().getColor(R.color.black));
rdb2.setTextColor(getResources().getColor(R.color.black));
break;
}
}
});
}
@OnClick(R.id.tv_continue)
public void onClickContinue() {
int checkedRadioButtonId = rdgStrengthen.getCheckedRadioButtonId();
switch (checkedRadioButtonId) {
case R.id.rdb1:
GlobalFuntion.goToDetailSelected(SurveyStrengthenActivity.this,
getString(R.string.title_strengthen_1), getString(R.string.message_strengthen_1),
Constant.SURVEY_STRENGTHEN_ACTIVITY);
break;
case R.id.rdb2:
GlobalFuntion.goToDetailSelected(SurveyStrengthenActivity.this,
getString(R.string.title_strengthen_2), getString(R.string.message_strengthen_2),
Constant.SURVEY_STRENGTHEN_ACTIVITY);
break;
case R.id.rdb3:
GlobalFuntion.goToDetailSelected(SurveyStrengthenActivity.this,
getString(R.string.title_strengthen_3), getString(R.string.message_strengthen_3),
Constant.SURVEY_STRENGTHEN_ACTIVITY);
break;
}
}
@OnClick(R.id.img_back)
public void onClickBack() {
onBackPressed();
}
}
| [
"[email protected]"
] | |
06d5853d780b60390688592eea358c10329f8c34 | 9127e73fb9ff6ca5fed8af9317a3a31ee2da3532 | /app/src/main/java/com/zhongyou/meettvapplicaion/utils/SizeUtils.java | 09bf8a14ea565cbf73bb0b4b6cee2167ebe66e82 | [] | no_license | woyl/zy_tv | 3e156ad0dc5982d9d994cbacddb4cc1d11a82003 | ddd1b98695817c18687d0f3e0b18291a09d29f27 | refs/heads/master | 2023-01-19T01:59:33.987412 | 2020-11-26T04:59:18 | 2020-11-26T04:59:18 | 316,114,199 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,723 | java | package com.zhongyou.meettvapplicaion.utils;
import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* @author [email protected]
* @date 2019-11-22 10:24.
*/
public class SizeUtils {
Activity mActivity;
public SizeUtils(Activity mActivity) {
this.mActivity = mActivity;
}
/**
* px转sp
*
* @param px
* @return
*/
public float pxToSp(int px) {
float sp;
DisplayMetrics dm = new DisplayMetrics();
dm = mActivity.getResources().getDisplayMetrics();
int ppi = dm.densityDpi;
sp = (float) (px * 160 / ppi);
return sp;
}
public DisplayMetrics screenSize() {
DisplayMetrics dm = new DisplayMetrics();
mActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm;
}
public void setLayoutSize(View view, int wdith, int height) {
ViewGroup.LayoutParams lt = view.getLayoutParams();
lt.height = height * screenHeight() / 1334;
lt.width = wdith * screenWidth() / 750;
view.setLayoutParams(lt);
}
public void setViewMatchParent(View view){
ViewGroup.LayoutParams lt = view.getLayoutParams();
lt.height = DisplayUtil.getHeight(mActivity);
lt.width = DisplayUtil.getWidth(mActivity);
view.setLayoutParams(lt);
}
public void setLayoutSizeHeight(View view, int height) {
ViewGroup.LayoutParams lt = view.getLayoutParams();
lt.height = height;
view.setLayoutParams(lt);
}
public void setLayoutSizeWidht(View view, int widht) {
ViewGroup.LayoutParams lt = view.getLayoutParams();
lt.width = widht * screenWidth() / 750;
view.setLayoutParams(lt);
}
public void setTextSize(TextView view, int size) {
view.setTextSize(pxToSp(size * screenWidth() / 750) + 3);
}
public void setButtonTextSize(Button view, int size) {
view.setTextSize(pxToSp(size * screenWidth() / 750) + 3);
}
public void setRelativeLayoutMargin(
View view,
int left,
int top,
int right,
int bottom) {
RelativeLayout navigationLl = new RelativeLayout(mActivity);
RelativeLayout.LayoutParams lt = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
navigationLl.setLayoutParams(lt);
lt.setMargins(left * screenWidth() / 750, top * screenHeight() / 1334, right * screenWidth() / 750, bottom * screenHeight() / 1334);
view.setLayoutParams(lt);
}
public void setRelativeLayoutMargin(
View view,
int left,
int top,
int right,
int bottom, int a) {
RelativeLayout navigationLl = new RelativeLayout(mActivity);
RelativeLayout.LayoutParams lt = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
navigationLl.setLayoutParams(lt);
lt.setMargins(left * screenWidth() / 750, top * screenHeight() / 1334, right * screenWidth() / 750, bottom * screenHeight() / 1334);
view.setLayoutParams(lt);
}
public void setLinearLayoutMargin(
LinearLayout viewGroup,
View view,
int left,
int top,
int right,
int bottom) {
LinearLayout.LayoutParams lt = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
viewGroup.setLayoutParams(lt);
lt.setMargins(left * screenWidth() / 750, top * screenHeight() / 1334, right * screenWidth() / 750, bottom * screenHeight() / 1334);
view.setLayoutParams(lt);
}
//得到屏幕宽
public int screenWidth() {
return screenSize().widthPixels;
}
//得到屏幕的高
public int screenHeight() {
return screenSize().heightPixels;
}
}
| [
"[email protected]"
] | |
e7c5ee88d0b6791b10786a8bbfa74f9d10298222 | b2565b85745fdaf0aaafbadf1a6766b1209b508f | /ruoyi-system/src/main/java/com/ruoyi/system/service/ISlGroupsService.java | cd8a91fb2b4e433818e231789f1b22ae98dde9c5 | [
"MIT"
] | permissive | Qihao97/ruoyi | 942ce5f64d5069f06d85858ec14d139944fd42ce | ae8239aa0f45db1cd08857600c16f20dd39c4587 | refs/heads/master | 2022-09-14T12:27:58.475573 | 2019-11-10T01:49:33 | 2019-11-10T01:50:51 | 220,728,065 | 0 | 1 | MIT | 2022-09-01T23:15:42 | 2019-11-10T01:52:33 | CSS | UTF-8 | Java | false | false | 965 | java | package com.ruoyi.system.service;
import com.ruoyi.system.domain.senselink.SlDevice;
import com.ruoyi.system.domain.senselink.SlGroups;
import java.util.List;
/**
* 人员组业务层
*
* @author ruoyi
*/
public interface ISlGroupsService
{
/**
* 通过人员组ID查询人员组
*
* @param id 人员组D
* @return 人员组对象信息
*/
public SlGroups selectGroupsById(Long id);
/**
* 通过人员组ID删除人员组
*
* @param id 角色ID
* @return 结果
*/
public boolean deleteGroupsById(Long id);
/**
* 保存或更新人员组信息
*
* @param slGroups 人员组信息
* @return 结果
*/
public int saveOrUpdateGroups(SlGroups slGroups);
/**
* 批量保存或更新人员组信息
*
* @param groupsList 人员组信息列表
* @return 结果
*/
public int batchSaveOrUpdateGroups(List groupsList);
}
| [
"[email protected]"
] | |
b8215ef85bfd93cd07f2ba01d97c880d15377494 | 7e6d0095a7c2589eb07c887ae8efb454881e782c | /src/main/java/model/Admin.java | 28cfe40d632a93db1739ef3469cbc3afc03a28af | [] | no_license | Whatder/xuexue_web | 82a3f43ae663353edd438d9ebad2d5f3576095c9 | a0de4941846606d879f9ade65fa7708a5d63f9fc | refs/heads/master | 2021-04-15T14:41:32.074690 | 2018-04-08T07:21:34 | 2018-04-08T07:21:34 | 126,697,527 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 506 | java | package model;
public class Admin {
int id;
String account;
String password;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"[email protected]"
] | |
e93570b815cbbcaa737e38f5a98eac06ad7ce0c4 | fbd00cdf4c68ee7f7ccebf71b761de4692a17d89 | /LeetCode/44.wildcard-matching.java | 4ec02514ca234216adf2dac4640d4d3cd0f9f5bd | [] | no_license | Andiedie/Algorithm | 3211f8cf27da91f12a3d282a139a963d3e9be891 | a3742e7782cdbecb52d57d41054355d0c05ff9b9 | refs/heads/master | 2020-04-24T10:20:31.375736 | 2019-03-26T09:06:13 | 2019-03-26T09:06:13 | 171,891,194 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,755 | java | /*
* @lc app=leetcode id=44 lang=java
*
* [44] Wildcard Matching
*
* https://leetcode.com/problems/wildcard-matching/description/
*
* algorithms
* Hard (22.33%)
* Total Accepted: 161.7K
* Total Submissions: 723.8K
* Testcase Example: '"aa"\n"a"'
*
* Given an input string (s) and a pattern (p), implement wildcard pattern
* matching with support for '?' and '*'.
*
*
* '?' Matches any single character.
* '*' Matches any sequence of characters (including the empty sequence).
*
*
* The matching should cover the entire input string (not partial).
*
* Note:
*
*
* s could be empty and contains only lowercase letters a-z.
* p could be empty and contains only lowercase letters a-z, and characters
* like ? or *.
*
*
* Example 1:
*
*
* Input:
* s = "aa"
* p = "a"
* Output: false
* Explanation: "a" does not match the entire string "aa".
*
*
* Example 2:
*
*
* Input:
* s = "aa"
* p = "*"
* Output: true
* Explanation: '*' matches any sequence.
*
*
* Example 3:
*
*
* Input:
* s = "cb"
* p = "?a"
* Output: false
* Explanation: '?' matches 'c', but the second letter is 'a', which does not
* match 'b'.
*
*
* Example 4:
*
*
* Input:
* s = "adceb"
* p = "*a*b"
* Output: true
* Explanation: The first '*' matches the empty sequence, while the second '*'
* matches the substring "dce".
*
*
* Example 5:
*
*
* Input:
* s = "acdcb"
* p = "a*c?b"
* Output: false
*
*
*/
/**
* 给定一个匹配串和一个模式串,模式串可能包含符号 * 和符号 ?
* ? 匹配任何单一字符
* * 匹配任何字符串(包括空字符串)
*
* Reference https://leetcode.com/problems/wildcard-matching/discuss/17810/Linear-runtime-and-constant-space-solution
* 使用迭代的方式处理,详细请看注释
* 另外也可以用类似第十题的 DP,速度比这个稍慢
*/
class Solution {
public boolean isMatch(String s, String p) {
// 指向当前 s 和 p 正在比较的位置
int sIndex = 0, pIndex = 0;
// * 号出现或匹配后,记录 * 号和主字符串匹配当前的位置
int sIndex4LastStar = -1;
// * 号出现后,继续其位置
int lastStar = -1;
while (sIndex < s.length()) {
if (pIndex < p.length() && (p.charAt(pIndex) == s.charAt(sIndex) || p.charAt(pIndex) == '?')) {
// 字符串正常匹配(包括 ? 号匹配)
sIndex++;
pIndex++;
} else if (pIndex < p.length() && p.charAt(pIndex) == '*') {
// 字符串不匹配,遇到 * 号
// 惰性:我们假设这个 * 号什么都不匹配
// 记录下这个星号的位置
lastStar = pIndex;
// 记录下现在 * 号和主字符串匹配的位置,( 0 个匹配也算是匹配的一种)
sIndex4LastStar = sIndex;
// 从下一个符号开始匹配
pIndex++;
} else if (sIndex4LastStar != -1) {
// 字符串不匹配,但是之前有星号可用
// 惰性:使用 * 匹配一位,并将 * 号和主字符串匹配的位置 + 1
sIndex = ++sIndex4LastStar;
// 由于上述惰性,假设 * 号的匹配到此为止了,从 * 号下一位开始匹配
pIndex = lastStar + 1;
} else {
// 没有任何匹配,失败
return false;
}
}
// 如果还有 * 号,那么直接设这些 * 号不匹配任何东西,跳过即可
while (pIndex < p.length() && p.charAt(pIndex) == '*')
pIndex++;
return pIndex == p.length();
}
}
| [
"[email protected]"
] | |
f9639d5ba9aca3fbfa10e7d1962d2e7eeb957fde | 641fc9df7f344bf661f9c931d45761506e57eb37 | /gmall-admin-web/src/main/java/com/itcast/gmall/admin/oms/controller/OrderReturnApplyController.java | b25a8b4ad9b9b224cb241ec235e216fbbc0ed5e3 | [
"MIT"
] | permissive | Pursuexy/gmall-parent01 | 3a10f4a16e260026f0aa4930cb1f3f3e0583d73c | 5e27544620410f0b3880f7d53579a5a20f727c3b | refs/heads/master | 2023-03-31T00:03:06.914941 | 2021-04-04T16:49:15 | 2021-04-04T16:49:15 | 354,592,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package com.itcast.gmall.admin.oms.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 订单退货申请 前端控制器
* </p>
*
* @author Pursuexy
* @since 2021-02-26
*/
@RestController
@RequestMapping("/oms/order-return-apply")
public class OrderReturnApplyController {
}
| [
"[email protected]"
] | |
fe20256aa068ee8bc6686aa44445cc66eee34865 | 238acd37aed3a8575ef08ee5e41dc4cacc406a9e | /src/com/github/koys/adventura/logika/PrikazKufor.java | 96e88c9ba5cb4b4b874f0815c114a7bfaf986b23 | [] | no_license | samkoys/hotovaVerze | d8ce705daff67bf8c4b2eea50fb65b1d9d988668 | 9ce94b724300cfcc42f68b7f52ca037c63e11e89 | refs/heads/master | 2020-03-08T00:36:12.996093 | 2018-04-09T21:14:05 | 2018-04-09T21:14:05 | 127,809,901 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,895 | java | /* Soubor je ulozen v kodovani UTF-8.
* Kontrola kódování: Příliš žluťoučký kůň úpěl ďábelské ódy. */
package com.github.koys.adventura.logika;
/*******************************************************************************
* Pomocí příkazu kufor se nám vypíše seznam věcí uložených v kufru.
*
* @author jméno autora
* @version 0.00.000
*/
public class PrikazKufor implements IPrikaz
{
//== Datové atributy (statické i instancí)======================================
private static final String NAME = "kufor";
private HerniPlan herniPlan;
//== Konstruktory a tovární metody =============================================
/***************************************************************************
* Konstruktor třídy PrikazKufor
*
* @param herniPlan herní plán, ve kterém se bude ve hře "chodit"
*/
public PrikazKufor(HerniPlan herniPlan) {
this.herniPlan = herniPlan;
}
//== Nesoukromé metody (instancí i třídy) ======================================
/**
* Provádí příkaz "inventory". Vypíše všechny věci, které jsou v kufru.
*
* @return zpráva, kterou vypíše hra hráči
*/
@Override
public String proved(String... parametry) {
if (herniPlan.getKufor().getVeci().isEmpty()) {
// pokud je kufor prázdný
return "Kufor je prazdny";
}
else {
// pokud je v kufru jedna a více věcí.
return "Seznam veci v kufru:" + herniPlan.getKufor().getVeci() + ".";
}
}
/**
* Metoda vrací název příkazu
*
* @ return název příkazu
*/
@Override
public String getNazev() {
return NAME;
}
//== Soukromé metody (instancí i třídy) ========================================
} | [
"[email protected]"
] | |
615e3b2ca12e9fce8a91d07f68a8ba7f066aef2e | 553ee734ba4d0959294debb16b02a217bd1e634a | /BaseProcessor/src/main/java/net/sunxu/mybatis/automapper/processor/mapper/mapper/HandlerForDecorator.java | 67332e8aa88215c612ad5ccb3d79210fe3d9179c | [
"MIT"
] | permissive | sunxuia/MyBatisAutoMapper | f235b265729d295fa391dfa95d7c2ae5eef8edd6 | 3e7475ffe57710bcd3532905ade9069c14f2ebb4 | refs/heads/master | 2021-07-01T05:45:12.109248 | 2019-11-02T12:53:57 | 2019-11-02T12:53:57 | 219,153,441 | 0 | 0 | MIT | 2021-04-22T18:43:37 | 2019-11-02T12:52:33 | Java | UTF-8 | Java | false | false | 267 | java | package net.sunxu.mybatis.automapper.processor.mapper.mapper;
import net.sunxu.mybatis.automapper.processor.mapper.MapperElementsCreator;
interface HandlerForDecorator {
MapperElementsCreator decorate(MapperElementsCreator provider, MapperModel mapperModel);
}
| [
"[email protected]"
] | |
b2b38000e65ff103e46806ccf0a33082c0a79385 | acdddd8fd8b8cb78c33bec70b480436a7dbb11d9 | /src/com/itap/jira/agile/Board.java | 406a4f479f39451e549b25db1f7cceaa8b962183 | [] | no_license | ynrani/iTAP | d72f77a2db9f5e96ad015a7095cf1c647282fff7 | c5d4e369de7add21e443950c5b57721128669405 | refs/heads/master | 2021-01-02T14:29:45.970058 | 2020-02-09T03:57:08 | 2020-02-09T03:57:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,748 | java | /**
* jira-client - a simple JIRA REST client
* Copyright (c) 2013 Bob Carroll ([email protected])
* <p>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.itap.jira.agile;
import com.itap.jira.Field;
import com.itap.jira.JiraException;
import com.itap.jira.RestClient;
import net.sf.json.JSONObject;
import java.util.List;
/**
* Represents an Agile Board.
*
* @author pldupont
*/
public class Board extends AgileResource {
private String type;
/**
* Creates a Board from a JSON payload.
*
* @param restclient REST client instance
* @param json JSON payload
*/
protected Board(RestClient restclient, JSONObject json) throws JiraException {
super(restclient, json);
}
/**
* Retrieves the given rapid view.
*
* @param restclient REST client instance
* @param id Internal JIRA ID of the rapid view
* @return a rapid view instance
* @throws JiraException when the retrieval fails
*/
public static Board get(RestClient restclient, long id) throws JiraException {
return AgileResource.get(restclient, Board.class, RESOURCE_URI + "board/" + id);
}
/**
* Retrieves all boards visible to the session user.
*
* @param restclient REST client instance
* @return a list of boards
* @throws JiraException when the retrieval fails
*/
public static List<Board> getAll(RestClient restclient) throws JiraException {
return AgileResource.list(restclient, Board.class, RESOURCE_URI + "board");
}
@Override
protected void deserialize(JSONObject json) throws JiraException {
super.deserialize(json);
type = Field.getString(json.get("type"));
}
/**
* @return The board type.
*/
public String getType() {
return this.type;
}
/**
* @return All sprints related to the current board.
* @throws JiraException when the retrieval fails
*/
public List<Sprint> getSprints() throws JiraException {
return Sprint.getAll(getRestclient(), getId());
}
/**
* @return All issues in the Board backlog.
* @throws JiraException when the retrieval fails
*/
public List<Issue> getBacklog() throws JiraException {
return AgileResource.list(getRestclient(), Issue.class, RESOURCE_URI + "board/" + getId() + "/backlog", "issues");
}
/**
* @return All issues without epic in the Board .
* @throws JiraException when the retrieval fails
*/
public List<Issue> getIssuesWithoutEpic() throws JiraException {
return AgileResource.list(getRestclient(), Issue.class, RESOURCE_URI + "board/" + getId() + "/epic/none/issue", "issues");
}
/**
* @return All epics associated to the Board.
* @throws JiraException when the retrieval fails
*/
public List<Epic> getEpics() throws JiraException {
return AgileResource.list(getRestclient(), Epic.class, RESOURCE_URI + "board/" + getId() + "/epic");
}
}
| [
"[email protected]"
] | |
92d691cc73e0a91dace980ea583e8daa8465a071 | f2eb9e26cc75d9e31ef4212f2d967e816a9371bd | /modules/datamodel/src/main/java/org/shaolin/bmdp/datamodel/page/OpInvokeWorkflowType.java | 062dc91f16673ff49a55b522c320b72e659d3f8a | [
"Apache-2.0"
] | permissive | predans/uimaster | 9b641b031ed5bedbf6c266ea8202cb273fd0835f | 4071cca988394053dfae5c0592c302d22228b53e | refs/heads/master | 2021-01-18T12:38:50.736814 | 2015-12-23T05:55:41 | 2015-12-23T05:55:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,029 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.08.21 at 10:32:01 AM CST
//
package org.shaolin.bmdp.datamodel.page;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import org.shaolin.bmdp.datamodel.common.ExpressionType;
import org.shaolin.javacc.context.ParsingContext;
import org.shaolin.javacc.exception.ParsingException;
/**
* <p>Java class for OpInvokeWorkflowType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="OpInvokeWorkflowType">
* <complexContent>
* <extension base="{http://bmdp.shaolin.org/datamodel/Page}OpType">
* <sequence>
* <element name="expression" type="{http://bmdp.shaolin.org/datamodel/Common}ExpressionType" minOccurs="0"/>
* </sequence>
* <attribute name="eventConsumer" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="partyType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="beforeActionWidget" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="nextActionWidget" type="{http://www.w3.org/2001/XMLSchema}string" />
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OpInvokeWorkflowType", propOrder = {
"expression"
})
public class OpInvokeWorkflowType
extends OpType
implements Serializable
{
private final static long serialVersionUID = 1L;
protected ExpressionType expression;
@XmlAttribute(name = "eventConsumer", required = true)
protected String eventConsumer;
@XmlAttribute(name = "partyType", required = true)
protected String partyType;
@XmlAttribute(name = "beforeActionWidget")
protected String beforeActionWidget;
@XmlAttribute(name = "nextActionWidget")
protected String nextActionWidget;
/**
* Gets the value of the expression property.
*
* @return
* possible object is
* {@link ExpressionType }
*
*/
public ExpressionType getExpression() {
return expression;
}
/**
* Sets the value of the expression property.
*
* @param value
* allowed object is
* {@link ExpressionType }
*
*/
public void setExpression(ExpressionType value) {
this.expression = value;
}
/**
* Gets the value of the eventConsumer property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getEventConsumer() {
return eventConsumer;
}
/**
* Sets the value of the eventConsumer property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setEventConsumer(String value) {
this.eventConsumer = value;
}
/**
* Gets the value of the partyType property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPartyType() {
return partyType;
}
/**
* Sets the value of the partyType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPartyType(String value) {
this.partyType = value;
}
/**
* Gets the value of the beforeActionWidget property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getBeforeActionWidget() {
return beforeActionWidget;
}
/**
* Sets the value of the beforeActionWidget property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setBeforeActionWidget(String value) {
this.beforeActionWidget = value;
}
/**
* Gets the value of the nextActionWidget property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNextActionWidget() {
return nextActionWidget;
}
/**
* Sets the value of the nextActionWidget property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNextActionWidget(String value) {
this.nextActionWidget = value;
}
public void parse(ParsingContext context) throws ParsingException
{
getExpression().parse(context);
}
}
| [
"[email protected]"
] | |
080c18b79a209d8f1eda6efab23b6b1fe5506e79 | af0d940b8a09d02e9aaa25498a3e4227e766cd15 | /src/main/java/com/library/domain/response/LoginResponse.java | 5b08af1ba98437e77211d892cfb03277ccdaad0b | [] | no_license | Franky238/book-app | f4cd62e5a9382a7b67b6513718af0d6432873d69 | b473dfe965504ebb7fdb9ecafdaaf9813b6a7ac0 | refs/heads/master | 2021-01-11T17:12:18.544084 | 2017-01-21T19:47:38 | 2017-01-21T19:47:38 | 79,738,884 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 232 | java | package com.library.domain.response;
public class LoginResponse {
private String token;
public LoginResponse (String token) {
this.token = token;
}
public String getToken() {
return token;
}
}
| [
"[email protected]"
] | |
59ee95d1639c9c75f098aa972417ece982a4d6c6 | c14fb0f9b029829c56beec12c96e579835c6502b | /app/src/main/java/com/example/xiaolitongxue/wieying/view/fragment/MyFragment.java | 41ad1f1f22ac262b483a2a78c2df48dc8c2ff662 | [] | no_license | WeiYingApp/WeiYingApp | 4ce836e0b2c37c5754551cc4a9436b86fd73e781 | 0801a6cf878720cbcec327dbeead49890a8af5cd | refs/heads/master | 2020-03-17T16:54:36.242489 | 2018-05-22T08:20:00 | 2018-05-22T08:20:00 | 133,767,102 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 973 | java | package com.example.xiaolitongxue.wieying.view.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.xiaolitongxue.wieying.R;
import com.example.xiaolitongxue.wieying.presenter.MyPresenter;
/**
* Created by xiaolitongxue on 2018/5/16.
* 我的
*/
public class MyFragment extends BaseFragment<MyPresenter>{
@Override
View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
View view = inflater.inflate(R.layout.fragment_my_layout,container,false);
return view;
}
@Override
void initData(@Nullable Bundle savedInstanceState) {
}
@Override
void findViewByIdView(View view) {
}
@Override
MyPresenter newPresenter() {
return new MyPresenter();
}
}
| [
"https://github.com/liyanan039164/text.git"
] | https://github.com/liyanan039164/text.git |
1505badef218293c25465f0c558b2d72fdb6b2fe | 805b90a6e35e73126d18353b9b7ad7474d4cbd4c | /src/test/java/org/got5/tapestry5/jquery/pages/ShowSource.java | 07602858babd5f7e95277a7de9eb82ad72b14381 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | got5/tapestry5-jquery | 53fba925fe6746645bb64f3cc547a8213ada72e8 | d929e8bfe7e9d6489c36dc23c54cd95b4b3e7c7b | refs/heads/master | 2023-03-07T10:07:57.790884 | 2018-08-23T09:06:30 | 2018-08-23T09:06:30 | 613,533 | 57 | 54 | NOASSERTION | 2022-08-08T20:00:02 | 2010-04-16T12:50:28 | HTML | UTF-8 | Java | false | false | 2,187 | java | package org.got5.tapestry5.jquery.pages;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.BeanModelSource;
import org.apache.tapestry5.services.Request;
import org.got5.tapestry5.jquery.entities.User;
public class ShowSource {
@Property
private User user;
@Property
private User currentUser;
@Property
private int currentIndex;
@Property
@Persist
private List<User> users;
@Component
private Zone detailZone;
@Inject
private BeanModelSource _beanModelSource;
@Inject
private ComponentResources _componentResources;
@Inject
private Request request;
void setupRender() {
users = createUsers(50);
}
public BeanModel getMyModel(){
BeanModel myModel = _beanModelSource.createDisplayModel(User.class,
_componentResources.getMessages());
myModel.add("action", null);
myModel.include("firstName", "lastName", "action");
myModel.get("firstName").sortable(false);
myModel.get("lastName").label("Surname");
return myModel;
}
@OnEvent(value = EventConstants.ACTION)
Object showDetail(String lastName)
{
if (!request.isXHR()) { return this; }
for(User u : users){
if(u.getLastName().equalsIgnoreCase(lastName))
user= u;
}
return detailZone;
}
public JSONObject getDialogParam()
{
JSONObject param = new JSONObject();
param.put("width", 400);
return param;
}
private User createUser(int i)
{
User u = new User();
u.setAge(i);
u.setFirstName("Humpty" + i + 10);
u.setLastName("Dumpty" + i + 200);
return u;
}
private List<User> createUsers(int number)
{
List<User> users = new ArrayList<User>();
for (int i = 0; i < number; i++)
{
users.add(createUser(i));
}
return users;
}
}
| [
"[email protected]"
] | |
950112fb01da82a20ada96e6eda2d620cff0c94f | 05aff24eac0a8545e6489f88a6c671edb2ee5b6d | /CoderByteAlgorithms/CodelandUsernameValidation.java | e812c697db230e7061489d60264bf2a5efb8d9c8 | [] | no_license | SoneSaile/Bootcamp-InterJavaDeveloper | c79df5cbb5835e36bc723a69eb119f28c144abd9 | 5e4ec81e81ac6a94c8b18f269165aba3df227c74 | refs/heads/master | 2023-03-14T14:39:19.739362 | 2021-03-07T18:02:16 | 2021-03-07T18:02:16 | 342,070,528 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,038 | java | package CoderByteAlgorithms;
import java.util.Scanner;
import java.util.*;
import java.io.*;
class CodelandUsernameValidation {
public static String CodeLandUsernameValidation(String str) {
String validation = "false";
if ((str.length() >= 4) && (str.length() <= 25)) {
if (Character.isLetter(str.charAt(0))) {
if (!str.endsWith("_")) {
for (int n = 0; n < str.length(); n++) {
if (Character.isDigit((str.charAt(n))) || Character.isLetter((str.charAt(n))) || str.charAt(n) == '_') {
validation = "true";
} else {
validation = "false";
break;
}
}
}
}
}
return validation;
}
public static void main(String[] args) {
//Scanner s = Scanner(System.in);
System.out.print(CodeLandUsernameValidation("usernamehello123"));
}
}
| [
"[email protected]"
] | |
d8ab1a3ab92749f1854d4c68272bca48c3238512 | 4180e942d47e4ebad1784dcc5b4407aaedf10b26 | /app/src/androidTest/java/com/lambertsoft/app03/ApplicationTest.java | c2a998404e12cc3d245999490922b616fa8d1470 | [] | no_license | PabloLambert/App03 | 61d4a438f3a8138518a9b1f346d25384a334c1be | 49ccfdf2cb922986113f5cb7e5eab8e3b20530df | refs/heads/master | 2020-04-18T21:09:47.964525 | 2014-12-13T16:32:35 | 2014-12-13T16:32:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 352 | java | package com.lambertsoft.app03;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"[email protected]"
] | |
08e1c3d7829afed779c8dcc857f66b2d76f76f34 | 5cb6a5c87d9bd6f6c3006564ce6441cbaf331890 | /src/test/java/org/ayfaar/app/controllers/NewSearchControllerUnitTest.java | cc9c371e76db44e707af147b99dc7e1ddae58ad6 | [] | no_license | maxsemen/ii | 041078b9621ee650f4f483ca4712cbac91c23c57 | 32cbe834c710097c5690e5766090404ca2156c11 | refs/heads/master | 2020-12-25T11:31:46.624057 | 2014-08-11T08:05:49 | 2014-08-11T08:05:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,111 | java | package org.ayfaar.app.controllers;
import org.ayfaar.app.controllers.search.SearchCache;
import org.ayfaar.app.controllers.search.SearchQuotesHelper;
import org.ayfaar.app.controllers.search.SearchResultPage;
import org.ayfaar.app.dao.SearchDao;
import org.ayfaar.app.model.Term;
import org.ayfaar.app.utils.AliasesMap;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.List;
import static java.util.Arrays.asList;
import static org.ayfaar.app.controllers.NewSearchController.PAGE_SIZE;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyList;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class NewSearchControllerUnitTest {
@Mock SearchDao searchDao;
@Mock SearchCache cache;
@Mock SearchQuotesHelper handleItems;
@Mock AliasesMap aliasesMap;
@InjectMocks @Spy
NewSearchController controller;
@Before
public void setUp() {
}
@SuppressWarnings("unchecked")
@Test
public void testHasMore() {
String q = "время";
Term term = new Term(q);
when(aliasesMap.getTerm(q)).thenReturn(term);
List<String> morphs = asList(q);
when(controller.getAllMorphs(anyList())).thenReturn(morphs);
List items = mock(List.class);
when(searchDao.findInItems(morphs, 0, PAGE_SIZE+1, null)).thenReturn(items);
when(items.size()).thenReturn(21);
SearchResultPage page = controller.search(q, 0, null);
assertTrue(page.isHasMore());
verify(searchDao, only()).findInItems(anyList(), anyInt(), anyInt(), anyString());
verify(items).remove(20);
}
// в таком же стиле можно добавить тесты на:
// поиск фразы - не термина
// поиск второй страницы
// поиск со двумя запросами в базу (второй для синонимов)
}
| [
"[email protected]"
] | |
8f4fd3a36a34c33de2bc8243ce35704c6570bedc | bc180e77724b817c9b1aa0c355ad7011695ef828 | /src/roundrobin/Roundrobin_main.java | f3d780de0dba1bd3db5ea07308a50252f3f250cd | [] | no_license | smzn/Roundrobin | a94c9536aa8ef695b8ac1d798ceec149703babde | 6149e46e2c34d420e9b820700778166a9e7343a3 | refs/heads/master | 2021-01-10T03:34:34.596046 | 2015-12-22T04:14:14 | 2015-12-22T04:14:14 | 48,409,829 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 912 | java | package roundrobin;
public class Roundrobin_main {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=10;
int k=5;
Combination c = new Combination(n,k);
System.out.println("C("+c.getN()+","+c.getK()+")="
+c.getSize());
System.out.println("全ての組合せを表示します。");
System.out.println("toString を利用");
for(int i=0; i<c.getSize(); ++i){
System.out.println(i+1+ ":" + c.toString(i));
}
System.out.println("直接値を取得");
int temp[] = new int[k];
for(int i=0; i<c.getSize(); ++i){
String result = "";
c.getElements(i,temp);
result += i+":";
for(int j=0; j<temp.length; ++j){
result += temp[j];
if(j!=temp.length-1){
result += ",";
}
}
System.out.println(result);
}
}
}
| [
"[email protected]"
] | |
cda850b11ec89708c02848c512068471aa660ee1 | 35c40b73478185f6f1e48c1265b01cd9ef551588 | /src/com/enation/javashop/core/model/mapper/GoodsListMapper.java | 2c6b6bb83625f3fec11c54b0c4203cdb4bfb469f | [] | no_license | chaseluo/JavaShop | 2e42a76ebf6893894d13653140c77a311ca0e28c | 604b327d60c88cd2e12487cef5a1d5f8bab18e6d | refs/heads/master | 2021-07-24T23:06:02.031608 | 2017-11-06T08:15:05 | 2017-11-06T08:15:05 | 109,664,093 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,560 | java | package com.enation.javashop.core.model.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.springframework.jdbc.core.RowMapper;
import com.enation.eop.sdk.utils.UploadUtil;
import com.enation.javashop.core.model.support.GoodsView;
/**
* 商品列表mapper
* @author kingapex
* 2010-7-16下午01:48:59
*/
public class GoodsListMapper implements RowMapper {
/**
* 返回{@link GooodsView}
* 在本方法中对属性进行了读取和处理,并放入到了 propMap属性
*/
@Override
public Object mapRow(ResultSet rs, int arg1) throws SQLException {
GoodsView goods = new GoodsView();
goods.setName(rs.getString("name"));
goods.setGoods_id(rs.getInt("goods_id"));
goods.setImage_default(rs.getString("image_default"));
goods.setMktprice(rs.getDouble("mktprice"));
goods.setPrice(rs.getDouble("price"));
goods.setCreate_time(rs.getLong("create_time"));
goods.setLast_modify(rs.getLong("last_modify"));
goods.setType_id(rs.getInt("type_id"));
goods.setPoint(rs.getInt("point"));
goods.setStore(rs.getInt("store"));
goods.setCat_id(rs.getInt("cat_id"));
goods.setSn(rs.getString("sn"));
goods.setIntro(rs.getString("intro"));
goods.setStore(rs.getInt("store"));
goods.setImage_file(UploadUtil.replacePath(rs.getString("image_file")));
Map propMap = new HashMap();
for(int i=0;i<20;i++){
String value = rs.getString("p" + (i+1));
propMap.put("p"+(i+1),value);
}
goods.setPropMap(propMap);
return goods;
}
}
| [
"[email protected]"
] | |
38ed108d9737ba8b53d2a45f8b5387da2fc19e4e | 501a472cefd3ca014a7c1b3587bbb7e863917ea5 | /src/main/java/sorting/Sort.java | 6bd1289a9709825915ecca11151d66e62cf7932c | [] | no_license | cleancoder1/programmerNotes | a855e5126deea12a8b87139c42f1e190a32e9107 | 228ab6c726966600c972c017523b97f375e86c9d | refs/heads/master | 2020-03-22T01:08:12.938938 | 2018-12-26T15:52:47 | 2018-12-26T15:52:47 | 139,285,254 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 809 | java | package sorting;
import edu.princeton.cs.algs4.StdOut;
public abstract class Sort {
// public abstract void sort(Comparable a[]);
protected void exchange(Comparable input[], int a, int b) {
Comparable temp = input[a];
input[a] = input[b];
input[b] = temp;
}
protected boolean less(Comparable a, Comparable b) {
return a.compareTo(b) < 0;
}
public boolean isSorted(Comparable[] a) { // Test whether the array entries are in order.
for (int i = 1; i < a.length; i++)
if (less(a[i], a[i - 1])) return false;
return true;
}
public void show(Comparable[] a) { // Print the array, on a single line.
for (int i = 0; i < a.length; i++)
StdOut.print(a[i] + " ");
StdOut.println();
}
}
| [
"[email protected]"
] | |
068451abeeed50dc049e25e11a505ffa769174f6 | b43c06ea353643da89d8543207dbeefa9fa09117 | /src/leetcode/GuessNumberHigherOrLowerII.java | 53aa8e43f181183186b6b1b9ccf74be88c86075a | [] | no_license | weichenjiegit/algorithm_data_structure | 7d52f5370e52b968c4892951ebf69dd26cb94255 | c4ebbeba30a536315ad0731ef29f7261faa8639e | refs/heads/master | 2021-01-19T01:49:44.538018 | 2016-10-23T19:21:59 | 2016-10-23T19:21:59 | 45,594,283 | 0 | 0 | null | 2015-12-07T07:35:41 | 2015-11-05T07:11:13 | null | UTF-8 | Java | false | false | 2,166 | java | package leetcode;
/**
* We are playing the Guess Game. The game is as follows:
*
* I pick a number from 1 to n. You have to guess which number I picked.
*
* Every time you guess wrong, I'll tell you whether the number I picked is higher or lower.
*
* However, when you guess a particular number x, and you guess wrong, you pay $x. You win the game
* when you guess the number I picked.
*/
public class GuessNumberHigherOrLowerII {
/**
* Given any n, we make a guess k. Then we break the interval [1,n] into [1,k - 1] and [k +
* 1,n]. The min of worst case cost can be calculated recursively as
*
* cost[1,n] = k + max{cost[1,k - 1] + cost[k+1,n]}
*/
public int getMoneyAmount(int n) {
int[][] dp = new int[n + 2][n + 2];
for (int len = 1; len < n; len++) {
for (int from = 1, to = from + len; to <= n; from++, to++) {
dp[from][to] = Integer.MAX_VALUE;
for (int k = from; k <= to; k++)
dp[from][to] = Math.min(dp[from][to], k + Math.max(dp[from][k - 1], dp[k + 1][to]));
}
}
return dp[1][n];
}
public int getMoneyAmount2(int n) {
// all intervals are inclusive
// add 1 to the length just to make the index the same as numbers used
int[][] dp = new int[n + 1][n + 1];
// iterate the lengths of the intervals since the calculations of longer intervals rely on
// shorter ones
for (int l = 2; l <= n; l++) {
// iterate all the intervals with length l, the start of which is i. Hence the interval
// will be [i, i + (l - 1)]
for (int i = 1; i <= n - (l - 1); i++) {
dp[i][i + (l - 1)] = Integer.MAX_VALUE;
// iterate all the first guesses g
for (int g = i; g <= i + (l - 1); g++) {
int costForThisGuess;
// if g is the last integer, g + 1 does not exist.
// else dp[i, i + (l - 1)]: g (first guess) + max{the cost of left part [i, g
// - 1], the cost of right part [g + 1, i + (l - 1)]}
if (g == n) {
costForThisGuess = dp[i][g - 1] + g;
} else {
costForThisGuess = g + Math.max(dp[i][g - 1], dp[g + 1][i + (l - 1)]);
}
dp[i][i + (l - 1)] = Math.min(dp[i][i + (l - 1)], costForThisGuess);
}
}
}
return dp[1][n];
}
}
| [
"[email protected]"
] | |
c23d8072aec8e68388b955ce018aaeb223c15d1d | 95733b93bd698fe47bbf9990f37ffdf06f44ba21 | /givus/src/kr/co/zadusoft/contents/model/MainModel.java | c9c8b77d3b4685ea2ebba3d42fd4d0880bb3039f | [] | no_license | choiseungchul/jsp | b9c4ab4e32c9e9741d2334604f3fec47028c0a9b | c29942ed7b8be8d5a94f6ce5025b54eebd735296 | refs/heads/master | 2021-01-18T19:26:27.332470 | 2015-06-24T16:13:58 | 2015-06-24T16:13:58 | 37,726,710 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | package kr.co.zadusoft.contents.model;
public class MainModel {
public String id;
public String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| [
"[email protected]"
] | |
d80e99fd83f4cf7dfc7ce3ea22f0b408c9390032 | 70b93fc3640b2ddec70eb6f0c035fde79d05b63e | /Recipe_Teller/app/src/main/java/com/example/recipe_teller/modelHTWD/TwdModel.java | 37cfd675bb7607e19876fdc6e385feca7c18111a | [] | no_license | tehloo/RecipeTeller | 53a613d409c2c9fcca7b341eab476d58b96bd079 | abe51964a780a351cf37e9706cffacb98111ad25 | refs/heads/master | 2022-09-26T10:25:51.921743 | 2020-06-04T13:34:19 | 2020-06-04T13:34:19 | 269,369,395 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,055 | java | /*
* Copyright (c) 2018 LG Electronics Inc.
*/
package com.example.recipe_teller.modelHTWD;
/*
* This class makes it easy to load various model files for demonstration of the startup engine.
* It is not required for actual products.
*/
/**
* Model information are de-serialized from json files in asset/keyword_model for TWD config using Gson.
*/
public class TwdModel {
/**
* am file path
*/
String amModelFile;
/**
* net file path
*/
String netModelFile;
/**
* Sensitivity value, decimal number
*/
int sensitivity;
/**
* cm value, floating-point number
*/
float cm;
/**
* Weight value, decimal number
*/
int weight;
@Override
public String toString() {
return "TwdModel{" +
"amModelFile='" + amModelFile + '\'' +
", netModelFile='" + netModelFile + '\'' +
", sensitivity=" + sensitivity +
", cm=" + cm +
", weight=" + weight +
'}';
}
}
| [
"[email protected]"
] | |
cd6b297d93707f0971d5c1bb3535fa2ac31eede8 | 61389bbb3a1c71e5e10101985913be0b52fcae87 | /usage/src/main/java/com/ning/billing/usage/timeline/categories/CategoryAndMetrics.java | c1ba8b5fcd932700a5e135dd4840c3c2963f4204 | [
"Apache-2.0"
] | permissive | pengfanhust/killbill | 513de990b701d4bc98ecaa90eb054fc2b24eb10f | 9acd2ea2745a96b35a9a4bb0648364ac04fa08c9 | refs/heads/master | 2021-01-18T12:07:57.489859 | 2012-10-28T20:19:28 | 2012-10-28T20:19:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,142 | java | /*
* Copyright 2010-2012 Ning, Inc.
*
* Ning 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 com.ning.billing.usage.timeline.categories;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public class CategoryAndMetrics implements Comparable<CategoryAndMetrics> {
@JsonProperty
private final String eventCategory;
@JsonProperty
private final Set<String> metrics = new HashSet<String>();
public CategoryAndMetrics(final String eventCategory) {
this.eventCategory = eventCategory;
}
@JsonCreator
public CategoryAndMetrics(@JsonProperty("eventCategory") final String eventCategory, @JsonProperty("metrics") final List<String> metrics) {
this.eventCategory = eventCategory;
this.metrics.addAll(metrics);
}
public void addMetric(final String metric) {
metrics.add(metric);
}
public String getEventCategory() {
return eventCategory;
}
public Set<String> getMetrics() {
return metrics;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("CategoryAndMetrics");
sb.append("{eventCategory='").append(eventCategory).append('\'');
sb.append(", metrics=").append(metrics);
sb.append('}');
return sb.toString();
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final CategoryAndMetrics that = (CategoryAndMetrics) o;
if (!eventCategory.equals(that.eventCategory)) {
return false;
}
if (!metrics.equals(that.metrics)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = eventCategory.hashCode();
result = 31 * result + metrics.hashCode();
return result;
}
@Override
public int compareTo(final CategoryAndMetrics o) {
final int categoryComparison = eventCategory.compareTo(o.getEventCategory());
if (categoryComparison != 0) {
return categoryComparison;
} else {
if (metrics.size() > o.getMetrics().size()) {
return 1;
} else if (metrics.size() < o.getMetrics().size()) {
return -1;
} else {
return 0;
}
}
}
}
| [
"[email protected]"
] | |
4ab783bac04f13972d8bbcf9363630010ea69abd | 2ea1f9fa18a799eeef9b81fcd3c0f8951b2aacb5 | /src/stochasticSimulation/SpecialZone.java | 2bc727f032527839d22c6f2c720475e40c68bdeb | [] | no_license | m-serra/rEvolutionary | 3ef30564f88c6ec57b389f5a757aaf3f06dc002f | 8c8f29f60d7b6380b9922afcf892713c52119726 | refs/heads/master | 2020-03-17T01:26:21.617984 | 2018-05-12T16:01:06 | 2018-05-12T16:01:06 | 133,152,916 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,262 | java | package stochasticSimulation;
/**
* The class special zone defines special cost zones within a Grid.
* Special cost zones have higher cost of movement than normal zones.
* The zone is defined by the initial and final point of a square.
* @author ManuelSerraNunes
*
*/
class SpecialZone {
/**
* The cost of the special cost zone.
*/
protected int cost;
/**
* The initial point of the square that forms the special cost zone.
*/
protected Point pInitial;
/**
* The final point of the square that forms the special cost zone.
*/
protected Point pFinal;
/**
* Constructor for SpecialCost zones.
* @param cost the cost of the zone
* @param i the initial point of the square that forms the special cost zone.
* @param f the final point of the square that forms the special cost zone.
*/
SpecialZone(int cost, Point i, Point f){
this.cost = cost;
pInitial = i;
pFinal = f;
}
/**
* Setter for the the cost
* @param cost the cost to be set.
*/
protected void setCost(int cost){
this.cost = cost;
}
/**
* Redefinition of the toString method to retrieve all the fields of the zone.
*/
@Override
public String toString() {
return "cost: " + cost + "; Initial: " + pInitial + "; Final: " + pFinal;
}
}
| [
"[email protected]"
] | |
dcfda8aefe6c6e90e827a05f60ff1c8ec308aac5 | 3b95f494fc07ee8cccb5b12b6b4f2c4e101f3f08 | /src/program_tugas/MHS.java | 9f21341b5ded5ab7152756d2c37f536aa6afe305 | [] | no_license | 5170411316/PBO_Aisa_InformatikaE | 9b2bd135c32c92adddd9549a4051455eec9917b7 | 622964dc5d44d1bcf25ea34df2606caa76e74ca1 | refs/heads/master | 2020-04-05T18:11:03.034176 | 2018-11-11T15:42:08 | 2018-11-11T15:42:08 | 157,091,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,751 | java |
package program_tugas;
import java.util.*;
/**
*
* @author Bismillah
*/
public class MHS {
private String nim;
private String nama, ipk;
public static List<MHS> sMhs = new ArrayList<>();
public MHS() {
}
public MHS(String nim, String nama, String ipk) {
this.nim = nim;
this.nama = nama;
this.ipk = ipk;
}
public void sortIpk() {
Collections.sort(sMhs, new Comparator<MHS>(){
@Override
public int compare(MHS t, MHS t1) {
return t.getIpk().compareTo(t1.getIpk());
}
});
for (MHS mahasiswa : sMhs) {
System.out.println(mahasiswa.getIpk() + " => " + mahasiswa.getIpk());
}
}
public void sortNama() {
Collections.sort(sMhs, new Comparator<MHS>(){
@Override
public int compare(MHS t, MHS t1) {
return t1.getNama().compareTo(t.getNama());
}
});
for (MHS mahasiswa : sMhs) {
System.out.println(mahasiswa.getNama() + " => " + mahasiswa.getNama());
}
}
public void sortNim() {
Collections.sort(sMhs, new Comparator<MHS>(){
@Override
public int compare(MHS t, MHS t1) {
return t.getNim().compareTo(t1.getNim());
}
});
for (MHS mahasiswa : sMhs) {
System.out.println(mahasiswa.getNim() + " => " + mahasiswa.getNim());
}
}
public void isiData(String nim, String nama, String ipk) {
sMhs.add(new MHS(nim, nama, ipk));
//System.out.println(nama);
}
public void tampilData() {
int i=1;
for (MHS mahasiswa : sMhs) {
System.out.println("Data ke - " + i++);
System.out.println("Nim : " + mahasiswa.nim);
System.out.println("Nama : " + mahasiswa.nama);
System.out.println("IPK : " + mahasiswa.ipk);
}
}
public String getNim() {
return nim;
}
public String getNama() {
return nama;
}
public String getIpk() {
return ipk;
}
public void setNim(String nim) {
this.nim = nim;
}
public void setNama(String nama) {
this.nama = nama;
}
public void setIpk(String ipk) {
this.ipk = ipk;
}
@Override
public String toString() {
String str = "Nim: " + nim + "\n" +
"Nama: " + nama + "\n" +
"IPK: " + ipk;
return str;
}
}
| [
"Bismillah@LAPTOP-3JQ8KR8I"
] | Bismillah@LAPTOP-3JQ8KR8I |
00426e3d535af119424b8071747ccd66353ef4dd | 3f767d13fc4dd0db69aaa50b0792ccf40292dc09 | /src/leetcode/Leet27.java | 41aaa77d4e58223a1f32b68f5bc288cf7ae7bcbb | [] | no_license | brook-joker/algorithm | b5ed5ae556bdf6cbd7b4f9901989506f41e33405 | 04e187544129ebe9837425cc73aea74189e4dd16 | refs/heads/master | 2020-04-26T18:05:14.833428 | 2020-04-06T04:22:48 | 2020-04-06T04:22:48 | 173,733,682 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 571 | java | package leetcode;
public class Leet27 {
// public int removeElement(int[] nums, int val) {
// int i = 0;
// for (int j = 0; j < nums.length; j++) {
// if (nums[i] != val) {
// nums[i++] = nums[j];
// }
// }
// return i;
// }
public int removeElement(int[] nums, int val) {
int n = nums.length;
for (int j = 0; j < nums.length; j++) {
if (nums[j] == val) {
nums[j] = nums[n-1];
n--;
}
}
return n;
}
}
| [
"[email protected]"
] | |
8e28480cf306c6586e51a8cc7d15c0dcabef1b56 | 3f38d4150c6c0d61b526101761c920a74141d777 | /6P/Number.java | 38f4b4a4ebfe85ddee8e8bdfec037ebd5fafd4a9 | [] | no_license | khite95/Java-Projects | f965b79690900e349f56326860986f6462607389 | 455ffc8d7ff4078beb8cd693cb5876efdbd85971 | refs/heads/master | 2022-04-07T21:30:37.794221 | 2020-03-03T16:48:31 | 2020-03-03T16:48:31 | 244,688,825 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 828 | java | /**
* Number.java.
*
* @author Kenneth Hite
* CS416 7/1/2016
*
*/
public class Number extends Operand
{
private Float token;
/**
* Number.
*
* @param s float.
*/
public Number( float s )
{
token = s;
}
/**
* getToken.
*
* @return token float.
*/
public float getToken()
{
return token;
}
/**
* print.
*
* @return returnstring String.
*/
public String printable( )
{
int tokenint = Math.round( token );
String returnstring = "@" + tokenint;
return returnstring;
}
/**
* getop.
*
* @return s String.
*/
public String getop()
{
String floatString = String.valueOf( token );
return floatString;
}
} | [
"[email protected]"
] | |
6e3e6fcf998fabaab40704ca53f7dc013e0f3af4 | 0b70a9ce5be81ec29e40e99fcb925774eb726e2f | /src/main/java/com/wx/service/combine/HeadLineShopCategoryCombineService.java | 2d794e5a9352adfd3f765b426a5e22f23bc4b9c7 | [] | no_license | lihaowen31/springbasic | 6a595f50f3612895d2a2e835231e7caaf7128609 | 2108db0ef9bf81cd5754ef4c340351eb147f2b61 | refs/heads/master | 2023-02-22T20:02:36.900385 | 2021-01-26T14:43:14 | 2021-01-26T14:43:14 | 330,969,092 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 222 | java | package com.wx.service.combine;
import com.wx.entity.dto.MainPageInfoDTO;
import com.wx.entity.dto.Result;
public interface HeadLineShopCategoryCombineService {
Result<MainPageInfoDTO> getMainPageInfo();
}
| [
"[email protected]"
] | |
e269394989f0a7191ed37c0c72d1c7da50ace38c | 94ebed63ba7cab2f6b3d3bcb007eac26e78a82f1 | /src/test/java/com/central/varth/resp/RespSerializerTest.java | 892fc5dde3284eaad732f62c30443b9da9f705fe | [
"Apache-2.0"
] | permissive | faisaladnan/varth | ccce82df6042dd310f243b530c39da856caa15c2 | 5f0202bb9fa1554ab26746e80d0d5f4ddc0668b5 | refs/heads/master | 2021-01-01T19:42:08.915243 | 2014-06-15T01:45:06 | 2014-06-15T01:45:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,012 | java | /**
*
* Copyright 2014 Central Software
* 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.central.varth.resp;
import org.junit.Assert;
import org.junit.Test;
public class RespSerializerTest {
@Test
public void pingCommand()
{
String command = "PING";
String expCommand = "*1\r\n$4\r\nPING\r\n";
RespSerializer serializer = new RespSerializer();
String cmdz = serializer.serialize(command);
System.err.println(cmdz);
Assert.assertEquals(expCommand, cmdz);
}
}
| [
"[email protected]"
] | |
7409cb41ec3a8923cce79b03cfd89c457b66814e | 7db19d6ea18c566220c797e59afdc65e8cfde114 | /tcc-core/src/main/java/org/bytesoft/openjtcc/remote/Committable.java | 9f6d7e6e840b1b8f5002e1430beea8f3c8645038 | [
"Apache-2.0"
] | permissive | xushaomin/openjtcc | 34e590d60f4e76c26c1c6e2d60ed497945cb4004 | 569f4a0e782f53eeee8a496763eb9e061b0cf902 | refs/heads/master | 2021-01-18T11:12:39.605639 | 2015-03-04T06:00:40 | 2015-03-04T06:00:40 | 31,840,751 | 2 | 4 | null | 2015-03-08T06:29:35 | 2015-03-08T06:29:34 | null | UTF-8 | Java | false | false | 1,108 | java | /**
* Copyright 2014 yangming.liu<[email protected]>.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*/
package org.bytesoft.openjtcc.remote;
import java.rmi.RemoteException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.SystemException;
public interface Committable {
public void commit() throws HeuristicMixedException, HeuristicRollbackException, SystemException, RemoteException;
}
| [
"[email protected]"
] | |
afa139f9de6cd7214a5a74ec302038061cf81e78 | 7fa9c6b0fa1d0726ae1cda0199716c811a1ea01b | /Crawler/data/MyFunctionalInterface.java | 2575330d8bc04a8eaea1170a5dcb7c94bd7c6664 | [] | no_license | NayrozD/DD2476-Project | b0ca75799793d8ced8d4d3ba3c43c79bb84a72c0 | 94dfb3c0a470527b069e2e0fd9ee375787ee5532 | refs/heads/master | 2023-03-18T04:04:59.111664 | 2021-03-10T15:03:07 | 2021-03-10T15:03:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 852 | java | 2
https://raw.githubusercontent.com/liuminchao123/JavaWeb_Learning/master/02.%20java/Java/%E9%BB%91%E9%A9%AC%E6%95%99%E7%A8%8B/23.%E3%80%90%E5%87%BD%E6%95%B0%E5%BC%8F%E6%8E%A5%E5%8F%A3%E3%80%91-%E7%AC%94%E8%AE%B0/code/12_FunctionalInterface/src/com/itheima/demo01/FunctionalInterface/MyFunctionalInterface.java
package com.itheima.demo01.FunctionalInterface;
/*
函数式接口:有且只有一个抽象方法的接口,称之为函数式接口
当然接口中可以包含其他的方法(默认,静态,私有)
@FunctionalInterface注解
作用:可以检测接口是否是一个函数式接口
是:编译成功
否:编译失败(接口中没有抽象方法抽象方法的个数多余1个)
*/
@FunctionalInterface
public interface MyFunctionalInterface {
//定义一个抽象方法
public abstract void method();
}
| [
"[email protected]"
] | |
e96df1d16db5ba83e991e75a4d9764f239d12b11 | c23041e73978456e589da48c6df983cff2cb7b25 | /weather/src/main/java/com/gddst/lhy/weather/fragment/WeatherFragment.java | e824f6e2001d3bd0b351ab96ab28aafc8a45f1b5 | [] | no_license | laihouyou/HFWeather | aacd664d261900706637b0467a1010d51773a5d8 | 201187643ac7acc099cffb9f678db04f73875766 | refs/heads/master | 2021-07-10T14:41:03.876971 | 2020-07-27T10:12:00 | 2020-07-27T10:12:00 | 167,662,084 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,349 | java | package com.gddst.lhy.weather.fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide;
import com.com.sky.downloader.greendao.CityVoDao;
import com.gddst.app.lib_common.MPAndroidChart.LineChartManager;
import com.gddst.app.lib_common.base.BaseApplication;
import com.gddst.app.lib_common.base.fragment.BaseFragment;
import com.gddst.app.lib_common.net.DlObserve;
import com.gddst.app.lib_common.net.NetManager;
import com.gddst.app.lib_common.utils.DateUtil;
import com.gddst.app.lib_common.weather.db.CityVo;
import com.gddst.app.lib_common.weather.util.Keys;
import com.gddst.lhy.weather.R;
import com.gddst.lhy.weather.WeatherActivity;
import com.gddst.lhy.weather.util.WeatherUtil;
import com.gddst.lhy.weather.vo.AirNow;
import com.gddst.lhy.weather.vo.WeatherVo;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.ValueFormatter;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import retrofit2.Response;
public class WeatherFragment extends BaseFragment {
// private SwipeRefreshLayout swipeRefres;
//空气质量aqi
private TextView aqi_text;
private TextView pm25_text;
//当日天气
private TextView tv_Celsius;
private TextView tv_situation;
private NestedScrollView scrollView;
private LinearLayout day_linelayout;
private LinearLayout suggestion_linearlayout;
private LineChart lineChart_host24;
private WeatherActivity context;
private String cityCid;
public static WeatherFragment getFragment(String cityCid){
WeatherFragment weatherFragment=new WeatherFragment();
Bundle bundle=new Bundle();
bundle.putString(WeatherUtil.cid,cityCid);
weatherFragment.setArguments(bundle);
return weatherFragment;
}
@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context= (WeatherActivity) getActivity();
return getLayoutInflater().inflate(R.layout.fragment_weather_layout,container,false);
}
@Override
protected void initView(View view) {
aqi_text = view.findViewById(R.id.aqi_text);
pm25_text = view.findViewById(R.id.pm25_text);
tv_Celsius = view.findViewById(R.id.tv_Celsius);
tv_situation = view.findViewById(R.id.tv_situation);
scrollView = view.findViewById(R.id.scrollView);
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
context.swipeRefres.setEnabled(scrollView.getScrollY() == 0);
}
});
day_linelayout = view.findViewById(R.id.day_linelayout);
suggestion_linearlayout = view.findViewById(R.id.suggestion_linearlayout);
lineChart_host24 = view.findViewById(R.id.host_24);
}
private void intiLineChartView(List<WeatherVo.HourlyBean> hourlyBeanList) {
//设置X轴数据格式
XAxis xAxis=lineChart_host24.getXAxis();
xAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
int i= (int) value;
String time=hourlyBeanList.get(i).getTime();
String timeStr=time.split(" ")[1];
return timeStr;
}
});
YAxis yAxis=lineChart_host24.getAxisLeft();
yAxis.setAxisMinimum(0);
yAxis.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
return value+"°";
}
});
ArrayList<Entry> values = new ArrayList<>();
for (int i = 0; i < hourlyBeanList.size(); i++) {
String tmp=hourlyBeanList.get(i).getTmp();
values.add(new Entry(i,Float.parseFloat(tmp)));
}
LineChartManager.initSingleLineChart(context,lineChart_host24,values);
}
@Override
protected void initListener() {
}
@Override
protected void lazyLoad() {
if (getArguments()!=null){
cityCid=getArguments().getString(WeatherUtil.cid);
}
initWeathert();
}
private void initWeathert() {
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(BaseApplication.getIns());
String cityId=this.cityCid;
String weatherVoString = sharedPreferences.getString(cityId, "");
if (TextUtils.isEmpty(weatherVoString)) {
//刚进来如果没有城市信息则去定位获取当前位置坐标
showLocationBefore();
} else {
WeatherVoToGson(weatherVoString);
}
String picUrl = sharedPreferences.getString(WeatherUtil.picUrl, "");
if (TextUtils.isEmpty(picUrl)) {
getPicImage();
} else {
showPicImage(picUrl);
}
}
private void WeatherVoToGson(String weatherVoString) {
WeatherVo weatherVo = BaseApplication.getGson().fromJson(weatherVoString, WeatherVo.class);
context.isLocationValue=true;
long time= DateUtil.timeSub(weatherVo.getUpdateTime(),DateUtil.getNow());
if (time>= WeatherUtil.weatherUpdateTimeInterval){
showTimeOutBefore();
requestWeather(weatherVo.getBasic().getCid(),weatherVo.getCityType());
}else {
showText(weatherVo);
}
}
private void showLocationBefore() {
// context.isLocationValue=false;
// context.tv_title.setText("正在获取当前所在城市");
// context.swipeRefres.setRefreshing(true);
tv_Celsius.setText("暂无数据");
tv_situation.setText("暂无数据");
}
private void showTimeOutBefore() {
context.swipeRefres.setRefreshing(true);
context.tv_title.setText("数据已过期正在更新");
}
private void showPicImage(String picUrl) {
Glide.with(context).load(picUrl).into(context.im_pic);
}
public Observable getWeatherObservable(String cityCid, final int cityType){
return Observable.just(cityCid)
.subscribeOn(Schedulers.io())
.flatMap(new Function<String, ObservableSource<WeatherVo>>() {
@Override
public ObservableSource<WeatherVo> apply(String weatherCode) throws Exception {
return getZip(
getobservableNow(weatherCode,cityType),
getobservableAirNow(weatherCode),
cityType
);
}
});
}
public void requestWeather(String cityCid, final int cityType) {
getWeatherObservable(cityCid,cityType)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new DlObserve<WeatherVo>() {
@Override
public void onResponse(WeatherVo weatherVo) throws IOException {
showText(weatherVo);
context.swipeRefres.setRefreshing(false);
Toast.makeText(context, weatherVo.getStatus(), Toast.LENGTH_LONG).show();
}
@Override
public void onError(int errorCode, String errorMsg) {
Toast.makeText(context, errorMsg, Toast.LENGTH_LONG).show();
context.swipeRefres.setRefreshing(false);
}
});
}
private Observable getZip(Observable observableNow, Observable observableAirNow, final int cityType){
return Observable.zip(observableNow, observableAirNow, new BiFunction<WeatherVo,AirNow,WeatherVo>() {
@Override
public WeatherVo apply(WeatherVo weatherVo, AirNow airNow) throws Exception {
weatherVo.setAirNow(airNow);
SharedPreferences.Editor editor = PreferenceManager
.getDefaultSharedPreferences(BaseApplication.getIns()).edit();
editor.putString(weatherVo.getBasic().getCid(), BaseApplication.getGson().toJson(weatherVo));
editor.apply();
//保存城市信息
CityVo cityVo = new CityVo();
cityVo.setCid(weatherVo.getBasic().getCid());
cityVo.setLocation(weatherVo.getBasic().getLocation());
cityVo.setAdmin_area(weatherVo.getBasic().getAdmin_area());
cityVo.setCnty(weatherVo.getBasic().getCnty());
cityVo.setLat(weatherVo.getBasic().getLat());
cityVo.setLon(weatherVo.getBasic().getLon());
cityVo.setParent_city(weatherVo.getBasic().getParent_city());
cityVo.setTz(weatherVo.getBasic().getTz());
cityVo.setAddCityTime(DateUtil.getNow());
cityVo.setCityType(cityType);
List<CityVo> cityVoList = BaseApplication.getIns().getDaoSession().getCityVoDao()
.queryBuilder().where(CityVoDao.Properties.Cid.eq(cityVo.getCid())).list();
if (cityVoList.size() == 0) {
BaseApplication.getIns().getDaoSession().getCityVoDao().insertOrReplace(cityVo);
Map<String, Object> parMap = new HashMap<>();
parMap.put(WeatherUtil.add_action, cityVo);
//数据插入成功发送
EventBus.getDefault().post(parMap);
}
return weatherVo;
}
});
}
private Observable getobservableNow(String weatherId, final int cityType){
return NetManager.INSTANCE.getShopClient()
.getWeatherNow(Keys.key, weatherId)
.map(new Function<Response<ResponseBody>, WeatherVo>() {
@Override
public WeatherVo apply(Response<ResponseBody> response) throws Exception {
return ResponseToWeatherVo(response,cityType);
}
});
}
private Observable getobservableAirNow(String weatherId){
return NetManager.INSTANCE.getShopClient()
.getAirNow(Keys.key, weatherId)
.map(new Function<Response<ResponseBody>, AirNow>() {
@Override
public AirNow apply(Response<ResponseBody> response) throws Exception {
AirNow airNow=ResponseToAirNow(response);
return airNow;
}
});
}
public void getPicImage() {
NetManager.INSTANCE.getShopClient()
.getPicUrl()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new DlObserve<Response<ResponseBody>>() {
@Override
public void onResponse(Response<ResponseBody> s) throws IOException {
if (s.code() == 200) {
String picUrl = s.body().string();
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences
(BaseApplication.getIns()).edit();
editor.putString(WeatherUtil.picUrl, picUrl);
editor.apply();
showPicImage(picUrl);
}
}
@Override
public void onError(int errorCode, String errorMsg) {
Toast.makeText(context, errorMsg, Toast.LENGTH_LONG).show();
}
});
}
private void showText(WeatherVo weatherVo) {
if (weatherVo == null)
return;
// context.newWeatherVo=weatherVo;
List<WeatherVo.LifestyleBean> lifestyleVos = weatherVo.getLifestyle();
List<WeatherVo.DailyForecastBean> weatherForecasts = weatherVo.getDaily_forecast();
AirNow airNow = weatherVo.getAirNow();
WeatherVo.NowBean now = weatherVo.getNow();
if (lifestyleVos == null)
return;
suggestion_linearlayout.removeAllViews();
for (WeatherVo.LifestyleBean lifestyleBase : lifestyleVos) {
View view = getLayoutInflater().inflate(R.layout.item_suggestion_text, suggestion_linearlayout, false);
TextView item_suggestion_text_tv = view.findViewById(R.id.item_suggestion_text_tv);
String text = "";
switch (lifestyleBase.getType()){
case WeatherUtil.comf:
text="舒适度指数";
break;
case WeatherUtil.cw:
text="洗车指数";
break;
case WeatherUtil.drsg:
text="穿衣指数";
break;
case WeatherUtil.flu:
text="感冒指数";
break;
case WeatherUtil.sport:
text="运动指数";
break;
case WeatherUtil.trav:
text="旅游指数";
break;
case WeatherUtil.uv:
text="紫外线指数";
break;
case WeatherUtil.air:
text="空气污染扩散条件指数";
break;
default:
break;
}
if (lifestyleVos.indexOf(lifestyleBase)==lifestyleVos.size()){
text+=":"+lifestyleBase.getBrf() + " " + lifestyleBase.getTxt();
}else {
text+=":"+lifestyleBase.getBrf() + " " + lifestyleBase.getTxt()+"\n";
}
item_suggestion_text_tv.setText(text);
suggestion_linearlayout.addView(item_suggestion_text_tv);
}
if (weatherForecasts == null)
return;
day_linelayout.removeAllViews();
for (WeatherVo.DailyForecastBean forecastBase : weatherForecasts) {
View view = getLayoutInflater().inflate(R.layout.item_day_text, day_linelayout, false);
TextView tv_date = view.findViewById(R.id.tv_date);
TextView tv_two = view.findViewById(R.id.tv_two);
TextView tv_max = view.findViewById(R.id.tv_max);
TextView tv_min = view.findViewById(R.id.tv_min);
tv_date.setText(forecastBase.getDate());
tv_two.setText(forecastBase.getCond_txt_d());
tv_max.setText(forecastBase.getTmp_max());
tv_min.setText(forecastBase.getTmp_min());
day_linelayout.addView(view);
}
aqi_text.setText(TextUtils.isEmpty(airNow.getAqi())?"暂无数据":airNow.getAqi());
pm25_text.setText(TextUtils.isEmpty(airNow.getPm25())?"暂无数据":airNow.getPm25());
if (now != null) {
tv_Celsius.setText(now.getFl() + "℃");
tv_situation.setText(now.getCond_txt());
}
context.tv_title.setText(weatherVo.getBasic().getLocation());
String timeStr=weatherVo.getUpdate().getLoc().split(" ")[1];
context.tv_time.setText(timeStr);
//设置24小时天气数据
List<WeatherVo.HourlyBean> hourlyBeanList= weatherVo.getHourly();
intiLineChartView(hourlyBeanList);
}
private WeatherVo ResponseToWeatherVo(Response<ResponseBody> response,int cityType) throws IOException, JSONException {
if (response.code() != 200 ) {
return new WeatherVo();
}
String body = response.body().string();
JSONObject jsonObject = new JSONObject(body);
JSONArray jsonArray = jsonObject.getJSONArray(WeatherUtil.HeWeather6);
JSONObject weatherObject = jsonArray.getJSONObject(0);
String status=weatherObject.getString(WeatherUtil.status);
if (status.equals(WeatherUtil.ok)){
WeatherVo weatherVo = BaseApplication.getGson().fromJson(weatherObject.toString(), WeatherVo.class);
weatherVo.setUpdateTime(DateUtil.getNow());
weatherVo.setCityType(cityType);
return weatherVo;
}
return new WeatherVo();
}
private AirNow ResponseToAirNow(Response<ResponseBody> response) throws IOException, JSONException {
if (response.code() != 200 ) {
return new AirNow();
}
String body = response.body().string();
JSONObject jsonObject = new JSONObject(body);
JSONArray jsonArray = jsonObject.getJSONArray(WeatherUtil.HeWeather6);
JSONObject weatherObject = jsonArray.getJSONObject(0);
String status=weatherObject.getString(WeatherUtil.status);
if (status.equals(WeatherUtil.ok)){
AirNow airNow = BaseApplication.getGson().fromJson(weatherObject.getJSONObject(WeatherUtil.air_now_city).toString(), AirNow.class);
return airNow;
}
return new AirNow();
}
@Override
public boolean excueOnKeyDown(int keyCode, KeyEvent event) {
return false;
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.